mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 18:24:35 +00:00
fix: local updates for PR #4780
Co-authored-by: jlowin <jlowin@users.noreply.github.com>
This commit is contained in:
committed by
Gustavo Madeira Santana
parent
dd4715a2c4
commit
f24e3cdae5
@@ -5,11 +5,14 @@ import {
|
||||
parseModelRef,
|
||||
resolveModelRefFromString,
|
||||
} from "../../agents/model-selection.js";
|
||||
import { listAgentIds } from "../../agents/agent-scope.js";
|
||||
import { formatCliCommand } from "../../cli/command-format.js";
|
||||
import {
|
||||
type OpenClawConfig,
|
||||
readConfigFileSnapshot,
|
||||
writeConfigFile,
|
||||
} from "../../config/config.js";
|
||||
import { normalizeAgentId } from "../../routing/session-key.js";
|
||||
|
||||
export const ensureFlagCompatibility = (opts: { json?: boolean; plain?: boolean }) => {
|
||||
if (opts.json && opts.plain) {
|
||||
@@ -82,6 +85,22 @@ export function normalizeAlias(alias: string): string {
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function resolveKnownAgentId(params: {
|
||||
cfg: OpenClawConfig;
|
||||
rawAgentId?: string | null;
|
||||
}): string | undefined {
|
||||
const raw = params.rawAgentId?.trim();
|
||||
if (!raw) return undefined;
|
||||
const agentId = normalizeAgentId(raw);
|
||||
const knownAgents = listAgentIds(params.cfg);
|
||||
if (!knownAgents.includes(agentId)) {
|
||||
throw new Error(
|
||||
`Unknown agent id "${raw}". Use "${formatCliCommand("openclaw agents list")}" to see configured agents.`,
|
||||
);
|
||||
}
|
||||
return agentId;
|
||||
}
|
||||
|
||||
export { modelKey };
|
||||
export { DEFAULT_MODEL, DEFAULT_PROVIDER };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user