refactor(commands): dedupe session target resolution and fs tool test setup

This commit is contained in:
Peter Steinberger
2026-03-02 14:35:26 +00:00
parent b85facfb5d
commit 3efd224ec6
5 changed files with 137 additions and 169 deletions

View File

@@ -2,6 +2,7 @@ import { listAgentIds, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { resolveStorePath } from "../config/sessions.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { normalizeAgentId } from "../routing/session-key.js";
import type { RuntimeEnv } from "../runtime.js";
export type SessionStoreSelectionOptions = {
store?: string;
@@ -78,3 +79,17 @@ export function resolveSessionStoreTargets(
},
];
}
export function resolveSessionStoreTargetsOrExit(params: {
cfg: OpenClawConfig;
opts: SessionStoreSelectionOptions;
runtime: RuntimeEnv;
}): SessionStoreTarget[] | null {
try {
return resolveSessionStoreTargets(params.cfg, params.opts);
} catch (error) {
params.runtime.error(error instanceof Error ? error.message : String(error));
params.runtime.exit(1);
return null;
}
}