fix: normalize stale qmd binary paths

This commit is contained in:
Peter Steinberger
2026-04-12 19:08:44 +01:00
parent 19d8069aea
commit 067f27f6a2
2 changed files with 23 additions and 1 deletions

View File

@@ -89,6 +89,20 @@ describe("resolveMemoryBackendConfig", () => {
expect(resolved.qmd?.command).toBe("/Applications/QMD Tools/qmd");
});
it("normalizes stale homebrew qmd paths to the portable command", () => {
const cfg = {
agents: { defaults: { workspace: "/tmp/memory-test" } },
memory: {
backend: "qmd",
qmd: {
command: "/opt/homebrew/bin/qmd",
},
},
} as OpenClawConfig;
const resolved = resolveMemoryBackendConfig({ cfg, agentId: "main" });
expect(resolved.qmd?.command).toBe("qmd");
});
it("resolves custom paths relative to workspace", () => {
const cfg = {
agents: {

View File

@@ -244,6 +244,14 @@ function resolveSearchTool(raw?: MemoryQmdConfig["searchTool"]): string | undefi
return value ? value : undefined;
}
function normalizeQmdCommand(command: string): string {
const normalized = path.normalize(command);
if (normalized === "/opt/homebrew/bin/qmd" || normalized === "/usr/local/bin/qmd") {
return "qmd";
}
return command;
}
function resolveSessionConfig(
cfg: MemoryQmdConfig["sessions"],
workspaceDir: string,
@@ -397,7 +405,7 @@ export function resolveMemoryBackendConfig(params: {
const rawCommand = normalizeOptionalString(qmdCfg?.command) || "qmd";
const parsedCommand = splitShellArgs(rawCommand);
const command = parsedCommand?.[0] || rawCommand.split(/\s+/)[0] || "qmd";
const command = normalizeQmdCommand(parsedCommand?.[0] || rawCommand.split(/\s+/)[0] || "qmd");
const resolved: ResolvedQmdConfig = {
command,
mcporter: resolveMcporterConfig(qmdCfg?.mcporter),