UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

86 lines (85 loc) • 3.02 kB
import { r as asNullableRecord } from "../../record-coerce-CVPuDqcc.mjs"; import { n as parseModelRef } from "../../model-selection-normalize-DIZCRGVF.mjs"; import "../../runtime-doctor-migrations-YTlcIEpR.mjs"; import "../../model-ref-parse-BpvmDSae.mjs"; //#region extensions/llm-task/doctor-contract-api.ts const ENTRY_PATH = "plugins.entries.llm-task"; function preserveLiteralLegacyModelRefs(e) { return e.filter((e) => { if (e !== e.trim() || e === "*") return false; const t = parseModelRef(e, ""); if (!t) return false; return `${t.provider}/${t.model}` === e; }); } const legacyConfigRules = [{ path: [ "plugins", "entries", "llm-task", "config", "allowedModels" ], message: `${ENTRY_PATH}.config.allowedModels moved to ${ENTRY_PATH}.llm.allowedCompletionModels. Run "openclaw doctor --fix".` }, { path: [ "plugins", "entries", "llm-task" ], message: `${ENTRY_PATH} needs host-owned LLM model/profile permissions to preserve shipped tool parameters. Run "openclaw doctor --fix".`, match: (e) => { const t = asNullableRecord(e); const n = asNullableRecord(t?.llm); return n?.allowModelOverride === void 0 || n.allowAuthProfileOverride === void 0; } }]; function normalizeCompatibilityConfig({ cfg: e }) { const t = asNullableRecord(e.plugins); const n = asNullableRecord(t?.entries); const r = asNullableRecord(n?.["llm-task"]); if (!r) return { config: e, changes: [] }; const i = asNullableRecord(r.config) ?? {}; const a = Object.hasOwn(i, "allowedModels"); const o = i.allowedModels; const s = Array.isArray(o) ? o.filter((e) => typeof e === "string") : void 0; const c = !a ? void 0 : !Array.isArray(o) ? [] : o.length === 0 ? void 0 : preserveLiteralLegacyModelRefs(s ?? []); const l = asNullableRecord(r.llm) ?? {}; const u = { ...l, ...l.allowModelOverride === void 0 ? { allowModelOverride: true } : {}, ...l.allowAuthProfileOverride === void 0 ? { allowAuthProfileOverride: true } : {}, ...l.allowedCompletionModels === void 0 && c !== void 0 ? { allowedCompletionModels: c } : {} }; const d = l.allowModelOverride === void 0 || l.allowAuthProfileOverride === void 0; if (!a && !d) return { config: e, changes: [] }; const { allowedModels: f, ...p } = i; const m = []; if (a) m.push(l.allowedCompletionModels !== void 0 ? `Removed ${ENTRY_PATH}.config.allowedModels; existing ${ENTRY_PATH}.llm.allowedCompletionModels remains authoritative.` : c !== void 0 ? `Moved ${ENTRY_PATH}.config.allowedModels to ${ENTRY_PATH}.llm.allowedCompletionModels.` : `Removed empty ${ENTRY_PATH}.config.allowedModels; unrestricted model selection remains unchanged.`); if (d) m.push(`Enabled ${ENTRY_PATH}.llm model and auth-profile overrides to preserve shipped llm-task behavior.`); return { config: { ...e, plugins: { ...t, entries: { ...n, "llm-task": { ...r, llm: u, config: p } } } }, changes: m }; } //#endregion export { legacyConfigRules, normalizeCompatibilityConfig };