mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-21 02:55:16 +00:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import type { Command } from "commander";
|
|
import { defaultRuntime } from "../runtime.js";
|
|
import { resolveOptionFromCommand, runCommandWithRuntime } from "./cli-utils.js";
|
|
import { formatCliCommand } from "./command-format.js";
|
|
|
|
export { defaultRuntime };
|
|
|
|
export function runModelsCommand(action: () => Promise<void>) {
|
|
return runCommandWithRuntime(defaultRuntime, action);
|
|
}
|
|
|
|
export function resolveModelAgentOption(
|
|
command: Command | undefined,
|
|
opts?: { agent?: unknown },
|
|
): string | undefined {
|
|
return (
|
|
resolveOptionFromCommand<string>(command, "agent") ??
|
|
(typeof opts?.agent === "string" ? opts.agent : undefined)
|
|
);
|
|
}
|
|
|
|
export function rejectAgentScopedModelWrite(
|
|
command: Command,
|
|
commandName: "set" | "set-image",
|
|
): void {
|
|
const agent = resolveOptionFromCommand<string>(command, "agent");
|
|
if (!agent) {
|
|
return;
|
|
}
|
|
throw new Error(
|
|
`openclaw models ${commandName} does not support --agent; it only updates global model defaults. Remove --agent, or run ${formatCliCommand("openclaw agents list")} and set the per-agent model in agent config.`,
|
|
);
|
|
}
|