UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

10 lines • 22.7 kB
import{r as asNullableRecord,s as ensureRecord}from"./record-coerce-BTbqdJ3-.mjs";import{r as normalizeProviderId}from"./provider-id-A-8WTtLA.mjs";import{c as parseModelPolicyWildcardRef,i as materializeModelPolicyAllowlist}from"./model-policy-allowlist-migration-BI8Uf3RI.mjs";import{i as listModelRefsFromConfigValue}from"./configured-model-refs-BvslYBsZ.mjs";import{n as materializeUtilityModelSeparation}from"./utility-model-separation-migration-D-DCWfMi.mjs";import{t as splitTrailingAuthProfile}from"./model-ref-profile-DFGpvDZX.mjs";import{a as visitAgentEntries,i as visitAgentConfigScopes,r as someAgentEntry,t as deleteRetiredPath}from"./legacy-config-record-shared-B0hPoAz4.mjs";import{r as isModelThinkingFormat}from"./model-config-vocabulary-CXg1OXeo.mjs";import{a as normalizeOptionalAgentRuntimeId}from"./agent-runtime-id-dWmvEQWJ.mjs";import"./types.models-FxDu6Zf8.mjs";import{n as containsAuthoredInclude}from"./include-migration-ownership-KASn2yVx.mjs";import{a as migrateModelCompatCatalogOwnership,c as staleModelContextWindows,i as invalidModelThinkingFormats,n as hasInvalidThinkingFormat,r as hasStaleContextWindowValue,t as MODEL_COMPAT_CATALOG_RULES}from"./legacy-config-migrations.runtime.models.catalog-gvwJ8aO8.mjs";import{t as isLegacyCodexProviderId}from"./legacy-codex-provider-Bh8WIf2G.mjs";import{c as legacyCodexProviderIdentityKey}from"./codex-route-model-ref-DySsVPNo.mjs";import{i as rewriteKnownModelRefs,n as hasOwnDefinedProperty,o as scanKnownModelRefs,s as setRecordEntry,t as MODEL_REF_CANONICALIZATION_MESSAGE}from"./legacy-config-migrations.runtime.models.refs-BcGOdqm2.mjs";import{r as migrateExplicitDefaultModelAllowPolicy,t as collectLegacyDefaultModelAllowRefs}from"./legacy-runtime-model-policy-IOynjY9Z.mjs";import{isDeepStrictEqual}from"node:util"; //!src/commands/doctor/shared/legacy-models-add-metadata.ts const LEGACY_MODELS_ADD_CODEX_MODEL_IDS=/* @__PURE__ */ new Set([`gpt-5.5`,`gpt-5.5-pro`]);function isLegacyModelsAddCodexMetadataModel(e){const t=e.model;const n=normalizeProviderId(e.provider);if(n!==`codex`&&n!==`openai-codex`||!t)return false;const r=t.id?.trim().toLowerCase();if(!r||!LEGACY_MODELS_ADD_CODEX_MODEL_IDS.has(r))return false;return t.api===`openai-chatgpt-responses`&&t.reasoning===true&&Array.isArray(t.input)&&t.input.length===2&&t.input[0]===`text`&&t.input[1]===`image`&&t.cost?.input===5&&t.cost.output===30&&t.cost.cacheRead===.5&&t.cost.cacheWrite===0&&t.contextWindow===4e5&&t.contextTokens===272e3&&t.maxTokens===128e3} //!src/commands/doctor/shared/legacy-config-migrations.runtime.models.codex.ts const OPENAI_PROVIDER_ID=`openai`;const MODEL_UNSCOPED_PROVIDER_DEFAULT_KEYS=[`apiKey`,`auth`,`request`,`timeoutSeconds`,`region`,`injectNumCtxForOpenAICompat`,`localService`,`headers`,`authHeader`];const CANONICAL_PROVIDER_MODEL_LEAK_KEYS=[`apiKey`,`auth`,`contextWindow`,`contextTokens`,`maxTokens`,`timeoutSeconds`,`region`,`injectNumCtxForOpenAICompat`,`params`,`agentRuntime`,`localService`,`headers`,`authHeader`,`request`];function hasCanonicalOpenAIProvider(e){return Object.keys(e).some(e=>normalizeProviderId(e)===OPENAI_PROVIDER_ID)}function collectModelMergeBlockers(e){const t=[];for(const n of MODEL_UNSCOPED_PROVIDER_DEFAULT_KEYS)if(hasOwnDefinedProperty(e.legacy,n))t.push(`models.providers.${e.legacyProviderId}.${n}`);for(const n of CANONICAL_PROVIDER_MODEL_LEAK_KEYS)if(hasOwnDefinedProperty(e.canonical,n))t.push(`models.providers.${OPENAI_PROVIDER_ID}.${n}`);return t}function getCanonicalOpenAIProviderEntry(e){const t=Object.keys(e).find(e=>normalizeProviderId(e)===OPENAI_PROVIDER_ID);const n=t?asNullableRecord(e[t]):void 0;return t&&n?{key:t,value:n}:void 0}function getMergeableLegacyOpenAIModels(e){const t=Array.isArray(e.legacy.models)?e.legacy.models:[];const n=Array.isArray(e.canonical.models)?e.canonical.models:[];const r=/* @__PURE__ */ new Set;const i=/* @__PURE__ */ new Set;for(const e of n){const t=asNullableRecord(e);if(typeof t?.id===`string`&&t.id)r.add(t.id);if(typeof t?.name===`string`&&t.name)i.add(t.name)}return t.filter(e=>{const t=asNullableRecord(e);if(!t)return false;const n=typeof t.id===`string`?t.id:void 0;const a=typeof t.name===`string`?t.name:void 0;if(!n&&!a)return false;return n?!r.has(n):a?!i.has(a):false})}function collectLegacyModelPolicyWildcardPaths(e){const t=/* @__PURE__ */ new Map;visitAgentConfigScopes(asNullableRecord(e)??{},(e,n)=>{const r=asNullableRecord(e.modelPolicy)?.allow;if(!Array.isArray(r))return;for(const[e,i]of r.entries()){const r=typeof i===`string`?parseModelPolicyWildcardRef(i):null;if(!r||r.key!==`${r.provider}/*`)continue;const a=r.provider;if(!isLegacyCodexProviderId(a))continue;const o=t.get(a)??[];o.push(`${n}.modelPolicy.allow.${e}`);t.set(a,o)}});return t}function hasAutoFixableLegacyOpenAICodexProvider(e,t){const n=asNullableRecord(e);if(!n)return false;const r=collectLegacyModelPolicyWildcardPaths(t);const i=getCanonicalOpenAIProviderEntry(n);for(const[e,t]of Object.entries(n)){const n=asNullableRecord(t);if(!n||!isLegacyCodexProviderId(e))continue;if(r.has(normalizeProviderId(e)))continue;if(!i)return true;const{modelCollisions:a,mergeBlockers:o}=inspectLegacyOpenAIProviderMerge(i.value,n,e);if(a.length===0&&o.length===0)return true}return false}function collectBlockedLegacyOpenAICodexProviderPlan(e){const t=asNullableRecord(asNullableRecord(e)?.models);const n=asNullableRecord(t?.providers);const r=n?getCanonicalOpenAIProviderEntry(n):void 0;const i=/* @__PURE__ */ new Set;const a=[];for(const[t,n]of collectLegacyModelPolicyWildcardPaths(e)){const e=legacyCodexProviderIdentityKey(t);if(e)i.add(e);a.push(`- ${n.join(`, `)} cannot migrate automatically because ${t}/* would become openai/* and authorize unrelated OpenAI models.`)}if(!n||!r)return buildBlockedLegacyOpenAICodexProviderPlan(i,a);for(const[e,t]of Object.entries(n)){const n=asNullableRecord(t);if(!n||!isLegacyCodexProviderId(e))continue;const{modelCollisions:o,mergeBlockers:s}=inspectLegacyOpenAIProviderMerge(r.value,n,e);if(o.length===0&&s.length===0)continue;const c=legacyCodexProviderIdentityKey(e);if(c)i.add(c);a.push(o.length>0?`- models.providers.${e} cannot be merged automatically into models.providers.${r.key} because colliding model definitions differ for: ${o.join(`, `)}.`:`- models.providers.${e} cannot be merged automatically into models.providers.${r.key} because provider-level defaults cannot be represented safely on merged models: ${s.join(`, `)}.`)}return buildBlockedLegacyOpenAICodexProviderPlan(i,a)}function buildBlockedLegacyOpenAICodexProviderPlan(e,t){return{blockedModelIdentities:[...e],...t.length>0?{warning:[`Legacy Codex provider routes require manual reconciliation before matching refs can migrate.`,...t,"- Doctor retained matching legacy refs in config, sessions, and cron. These refs will not execute until reconciled: fix the model route/auth metadata, remove the legacy provider entry, then rerun `openclaw doctor --fix`."].join(` `)}:{}}}function resolveMovedCodexModelRuntime(e){if(normalizeProviderId(e.legacyProviderId)!==`codex`)return;const t=asNullableRecord(e.model.agentRuntime);const n=normalizeOptionalAgentRuntimeId(t?.id);if(n&&n!==`auto`)return;if(n===`auto`)return{...t,id:`codex`};const r=asNullableRecord(e.legacyProvider.agentRuntime);const i=normalizeOptionalAgentRuntimeId(r?.id);return i&&i!==`auto`?r??void 0:{...r,id:`codex`}}function buildMergedLegacyOpenAIModel(e,t,n){const r=asNullableRecord(e);if(!r)return e;const i={};const a=typeof t.baseUrl===`string`?t.baseUrl:void 0;const o=typeof t.api===`string`?t.api:void 0;const s=asNullableRecord(t.params);const c=asNullableRecord(t.agentRuntime);const l=resolveMovedCodexModelRuntime({legacyProviderId:n,legacyProvider:t,model:r});if(a&&!r.baseUrl)i.baseUrl=a;if(o&&!r.api)i.api=o;for(const e of[`contextWindow`,`contextTokens`,`maxTokens`])if(typeof t[e]===`number`&&r[e]===void 0)i[e]=t[e];if(s){const e=asNullableRecord(r.params);if(e)i.params={...s,...e};else if(r.params===void 0)i.params=s}if(l)i.agentRuntime=l;else if(c&&r.agentRuntime===void 0)i.agentRuntime=c;if(r.metadataSource===void 0&&isLegacyModelsAddCodexMetadataModel({provider:n,model:r}))i.metadataSource=`models-add`;return Object.keys(i).length>0?Object.assign({},r,i):e}function collectNonEquivalentLegacyOpenAIModelCollisions(e){const t=Array.isArray(e.canonical.models)?e.canonical.models:[];const n=Array.isArray(e.legacy.models)?e.legacy.models:[];const r=/* @__PURE__ */ new Set;for(const i of n){const n=asNullableRecord(i);const a=typeof n?.id===`string`?n.id:void 0;const o=typeof n?.name===`string`?n.name:void 0;if(!n||!a&&!o)continue;const s=t.filter(e=>{const t=asNullableRecord(e);return a?t?.id===a:t?.name===o});if(s.length===0)continue;const c=buildMergedLegacyOpenAIModel(i,e.legacy,e.legacyProviderId);if(!s.every(t=>{const n=buildMergedLegacyOpenAIModel(t,e.canonical,OPENAI_PROVIDER_ID);if(!isDeepStrictEqual(n,c))return false;return MODEL_UNSCOPED_PROVIDER_DEFAULT_KEYS.every(t=>isDeepStrictEqual(e.canonical[t],e.legacy[t]))}))r.add(a??o??`unknown`)}return[...r]}function inspectLegacyOpenAIProviderMerge(e,t,n){const r={canonical:e,legacy:t,legacyProviderId:n};const i=collectNonEquivalentLegacyOpenAIModelCollisions(r);const a=getMergeableLegacyOpenAIModels(r);return{modelCollisions:i,modelsToMerge:a,mergeBlockers:i.length===0&&a.length>0?collectModelMergeBlockers(r):[]}}function prepareLegacyCodexProviderForCanonicalMove(e,t){if(normalizeProviderId(e)!==`codex`||!Array.isArray(t.models))return t;return{...t,models:t.models.map(n=>{const r=asNullableRecord(n);if(!r)return n;const i=resolveMovedCodexModelRuntime({legacyProviderId:e,legacyProvider:t,model:r});return i?{...r,agentRuntime:i}:n})}}function migrateLegacyOpenAICodexProvider(e,t){const n=asNullableRecord(e.models);const r=asNullableRecord(n?.providers);if(!n||!r)return;const i=collectLegacyModelPolicyWildcardPaths(e);for(const[e,n]of Object.entries({...r})){const a=asNullableRecord(r[e])??asNullableRecord(n);if(!a||!isLegacyCodexProviderId(e))continue;if(i.has(normalizeProviderId(e)))continue;if(!hasCanonicalOpenAIProvider(r)){r[OPENAI_PROVIDER_ID]=prepareLegacyCodexProviderForCanonicalMove(e,a);t.push(`Moved models.providers.${e} → models.providers.${OPENAI_PROVIDER_ID}.`)}else{const n=getCanonicalOpenAIProviderEntry(r);const i=n?.key??OPENAI_PROVIDER_ID;const o=n?.value??{};const s=Array.isArray(o.models)?o.models:[];const{modelCollisions:c,modelsToMerge:l,mergeBlockers:u}=inspectLegacyOpenAIProviderMerge(o,a,e);if(c.length>0||u.length>0)continue;const d=l.map(t=>buildMergedLegacyOpenAIModel(t,a,e));if(d.length>0){r[i]={...o,models:[...s,...d]};const n=d.map(e=>{const t=asNullableRecord(e);return typeof t?.id===`string`&&t.id?t.id:typeof t?.name===`string`&&t.name?t.name:`unknown`}).join(`, `);t.push(`Merged ${d.length} model(s) from models.providers.${e} into models.providers.${OPENAI_PROVIDER_ID}: ${n}.`)}else t.push(`Removed models.providers.${e} because models.providers.${OPENAI_PROVIDER_ID} already exists.`)}delete r[e]}}const MODEL_REF_CANONICALIZATION_RULES=[`agents`,`plugins`,`messages`,`tools`,`hooks`,`channels`,`models`].map(e=>({path:[e],message:MODEL_REF_CANONICALIZATION_MESSAGE,match:e=>scanKnownModelRefs(e)})); //!src/commands/doctor/shared/legacy-config-migrations.runtime.models.vllm.ts const QWEN_THINKING_FORMAT_KEYS=[`qwenThinkingFormat`,`qwen_thinking_format`];function normalizeLegacyVllmQwenThinkingFormat(e){if(typeof e!==`string`)return;switch(e.trim().toLowerCase().replace(/[_\s]+/g,`-`)){case`chat-template`:case`chat-template-argument`:case`chat-template-arguments`:case`chat-template-kwarg`:case`chat-template-kwargs`:case`qwen-chat-template`:return`qwen-chat-template`;case`enable-thinking`:case`qwen`:case`request-body`:case`top-level`:return`qwen`;default:return}}function getLegacyVllmQwenThinkingFormat(e){for(const t of QWEN_THINKING_FORMAT_KEYS)if(Object.hasOwn(e,t))return{key:t,value:e[t],compat:normalizeLegacyVllmQwenThinkingFormat(e[t])}}function parseVllmAgentModelKey(e){const t=splitTrailingAuthProfile(e).model.trim();const n=t.indexOf(`/`);if(n<=0)return;const r=t.slice(0,n);if(normalizeProviderId(r)!==`vllm`)return;const i=t.slice(n+1).trim();return i&&i!==`*`?i:void 0}function hasLegacyVllmQwenThinkingFormat(e){return Object.entries(asNullableRecord(e)??{}).some(([e,t])=>parseVllmAgentModelKey(e)&&hasLegacyVllmQwenThinkingParams(asNullableRecord(t)?.params))}function hasLegacyVllmQwenThinkingModelParams(e){if(!Array.isArray(e))return false;return e.some(e=>hasLegacyVllmQwenThinkingParams(asNullableRecord(e)?.params))}function hasLegacyVllmQwenThinkingParams(e){const t=asNullableRecord(e);return Boolean(t&&getLegacyVllmQwenThinkingFormat(t))}function resolveVllmModelTargets(e,t,n=false){let r=findVllmProvider(asNullableRecord(asNullableRecord(e.models)?.providers));if(t?.length){const t=getOrCreateRecord(e,`models`);const n=t?getOrCreateRecord(t,`providers`):void 0;const i=Object.keys(n??{}).find(e=>normalizeProviderId(e)===`vllm`);if(n&&!i)r=getOrCreateRecord(n,`vllm`);if(r&&r.models===void 0)r.models=[]}const i=r?.models;if(!Array.isArray(i))return[];const a=i.flatMap((e,t)=>{const n=asNullableRecord(e);return n?[{model:n,index:t}]:[]});if(!t)return a;const o=n?[...a]:[];for(const e of t){let t=a.find(({model:t})=>t.id===e||t.id===`vllm/${e}`);if(!t){t={model:{id:e,name:e},index:i.length};i.push(t.model);a.push(t)}o.push(t)}const s=/* @__PURE__ */ new Set;return o.filter(({model:e})=>{if(s.has(e))return false;s.add(e);return true})}function collectVllmAgentModelIds(e){return[...listModelRefsFromConfigValue(e?.model),...Object.keys(asNullableRecord(e?.models)??{})].flatMap(e=>{const t=parseVllmAgentModelKey(e);return t?[t]:[]})}function getOrCreateRecord(e,t){if(e[t]===void 0){const n={};e[t]=n;return n}return asNullableRecord(e[t])??void 0}function findVllmProvider(e){if(!e)return;const t=Object.keys(e).find(e=>normalizeProviderId(e)===`vllm`);return t?asNullableRecord(e[t])??void 0:void 0}function hasLegacyVllmQwenThinkingNormalizedProvider(e){const t=asNullableRecord(e);if(!t||asNullableRecord(t.vllm))return false;const n=findVllmProvider(t);return hasLegacyVllmQwenThinkingParams(n?.params)||hasLegacyVllmQwenThinkingModelParams(n?.models)}function migrateVllmQwenThinkingParams(e,t){const migrate=(e,n,r)=>{const i=asNullableRecord(e?.params);const a=i?getLegacyVllmQwenThinkingFormat(i):void 0;if(!e||!i||!a)return;const o=r(a);if(!o)return;for(const e of QWEN_THINKING_FORMAT_KEYS)delete i[e];if(o.length===0)t.push(`Removed ${n}.${a.key}; no concrete vLLM model row or agent model ref exists, so configure models.providers.vllm.models[].compat.thinkingFormat on each Qwen model that needs it.`);for(const{model:e,index:r}of o){if(!a.compat){t.push(`Removed ${n}.${a.key} (unrecognized value ${JSON.stringify(a.value)}; configure models.providers.vllm.models[].compat.thinkingFormat if needed).`);continue}if(e.reasoning===void 0)e.reasoning=true;const i=ensureRecord(e,`compat`);const o=i.thinkingFormat;if(typeof o===`string`&&isModelThinkingFormat(o))t.push(`Removed ${n}.${a.key}; models.providers.vllm.models[${r}].compat.thinkingFormat is already ${JSON.stringify(o)}.`);else{i.thinkingFormat=a.compat;t.push(`Moved ${n}.${a.key} to models.providers.vllm.models[${r}].compat.thinkingFormat (${JSON.stringify(a.compat)}).`)}}if(Object.keys(i).length===0)delete e.params};const n=asNullableRecord(asNullableRecord(e.agents)?.defaults);for(const[t,r]of Object.entries(asNullableRecord(n?.models)??{})){const n=parseVllmAgentModelKey(t);if(n)migrate(asNullableRecord(r),`agents.defaults.models.${JSON.stringify(t)}.params`,t=>{const r=t.compat?resolveVllmModelTargets(e,[n]):[{model:{},index:-1}];return r.length>0?r:void 0})}for(const t of resolveVllmModelTargets(e))migrate(t.model,`models.providers.vllm.models[${t.index}].params`,()=>[t]);const r=collectVllmAgentModelIds(n);const i=[];visitAgentEntries(e,(e,t)=>i.push({agent:e,path:t}));migrate(findVllmProvider(asNullableRecord(asNullableRecord(e.models)?.providers)),`models.providers.vllm.params`,()=>resolveVllmModelTargets(e,[...r,...i.flatMap(({agent:e})=>collectVllmAgentModelIds(e))],true));const selectedTargets=t=>resolveVllmModelTargets(e,t.length?t:void 0);migrate(n,`agents.defaults.params`,()=>selectedTargets(r));for(const{agent:e,path:t}of i)migrate(e,`${t}.params`,()=>{const t=collectVllmAgentModelIds(e);return selectedTargets(t.length?t:r)})}const LEGACY_VLLM_QWEN_THINKING_FORMAT_RULES=[{path:[`agents`,`defaults`,`models`],message:`agents.defaults.models.<vllm-model>.params.qwenThinkingFormat is legacy; run "openclaw doctor --fix" to move it to models.providers.vllm.models[].compat.thinkingFormat.`,match:hasLegacyVllmQwenThinkingFormat},{path:[`models`,`providers`,`vllm`,`params`],message:`models.providers.vllm.params.qwenThinkingFormat is legacy; run "openclaw doctor --fix" to move it to models.providers.vllm.models[].compat.thinkingFormat.`,match:hasLegacyVllmQwenThinkingParams},{path:[`models`,`providers`,`vllm`,`models`],message:`models.providers.vllm.models[*].params.qwenThinkingFormat is legacy; run "openclaw doctor --fix" to move it to models.providers.vllm.models[].compat.thinkingFormat.`,match:hasLegacyVllmQwenThinkingModelParams},{path:[`models`,`providers`],message:`models.providers.<vllm>.params.qwenThinkingFormat is legacy; run "openclaw doctor --fix" to move it to models.providers.<vllm>.models[].compat.thinkingFormat.`,match:hasLegacyVllmQwenThinkingNormalizedProvider},{path:[`agents`,`defaults`,`params`],message:`agents.defaults.params.qwenThinkingFormat is legacy; run "openclaw doctor --fix" to move it to models.providers.vllm.models[].compat.thinkingFormat.`,match:hasLegacyVllmQwenThinkingParams},{path:[`agents`],message:`agents.entries.*.params.qwenThinkingFormat is legacy; run "openclaw doctor --fix" to move it to models.providers.vllm.models[].compat.thinkingFormat.`,match:e=>someAgentEntry(e,e=>hasLegacyVllmQwenThinkingParams(e.params))}];const INVALID_THINKING_FORMAT_RULE={path:[`models`,`providers`],message:`models.providers.<id>.models[*].compat.thinkingFormat has an unrecognized value; run "openclaw doctor --fix" to remove it and restore the runtime default.`,match:hasInvalidThinkingFormat};const STALE_CONTEXT_WINDOW_RULE={path:[`models`,`providers`],message:`models.providers.<id>.models[*].contextWindow has a stale catalog value; run "openclaw doctor --fix" to repair it.`,match:hasStaleContextWindowValue}; //!src/commands/doctor/shared/legacy-config-migrations.runtime.models.ts const LEGACY_CONFIG_MIGRATIONS_RUNTIME_MODELS=[{id:`defaultModel->agents.defaults.model`,legacyRules:[{path:[`defaultModel`],message:`defaultModel moved to agents.defaults.model. Run "openclaw doctor --fix".`}],apply:(e,t)=>{if(!Object.hasOwn(e,`defaultModel`))return;const n=e.defaultModel;if(asNullableRecord(asNullableRecord(e.agents)?.defaults)?.model===void 0&&typeof n===`string`){const r=ensureRecord(ensureRecord(e,`agents`),`defaults`);r.model=n;t.push(`Moved defaultModel → agents.defaults.model.`)}else t.push(`Removed defaultModel (agents.defaults.model already set or value invalid).`);delete e.defaultModel}},{id:`runtime.utility-model-separation`,legacyRules:[{path:[`agents`],message:`Legacy implicit primary model selection needs preservation before separating utility models. Run "openclaw doctor --fix"; dynamic catalog IDs need an explicit primary model.`,match:(e,t)=>materializeUtilityModelSeparation(structuredClone(t)).changes.length>0}],apply:(e,t,n)=>{if(n&&containsAuthoredInclude(n.authoredRaw))return;const r=materializeUtilityModelSeparation(e,n?.authoredRaw??e);if(r.changes.length===0)return;Object.assign(e,r.config);t.push(...r.changes)}},{id:`models.pricing-retired`,legacyRules:[{path:[`models`,`pricing`],message:`models.pricing is retired because pricing ships with the hosted catalog; run "openclaw doctor --fix" to remove it.`}],apply:(e,t)=>{if(deleteRetiredPath(e.models,[`pricing`]))t.push(`Removed models.pricing (pricing now ships with the hosted model catalog).`)}},{id:`models.providers.*.models.*.compat->provider-catalog`,legacyRules:MODEL_COMPAT_CATALOG_RULES,apply:migrateModelCompatCatalogOwnership},{id:`models.providers.codex-routes->models.providers.openai`,legacyRules:[{path:[`models`,`providers`],message:`models.providers.codex and models.providers.openai-codex are legacy; run "openclaw doctor --fix" to move them to models.providers.openai.`,match:(e,t)=>hasAutoFixableLegacyOpenAICodexProvider(e,t)}],apply:migrateLegacyOpenAICodexProvider},{id:`models.canonical-model-refs`,legacyRules:MODEL_REF_CANONICALIZATION_RULES,apply:(e,t)=>{const n=rewriteKnownModelRefs(e,`config`,t);const r=asNullableRecord(n.value);if(!n.changed||!r)return;for(const t of Object.keys(e))delete e[t];for(const[t,n]of Object.entries(r))setRecordEntry(e,t,n)}},{id:`agents.defaults.models->agents.defaults.modelPolicy.allow`,legacyRules:[{path:[`agents`,`defaults`,`models`],message:`Legacy agents.defaults.models restricts model overrides; run "openclaw doctor --fix" to migrate valid refs to agents.defaults.modelPolicy.allow.`,match:(e,t)=>collectLegacyDefaultModelAllowRefs(t)!==null},{path:[`agents`,`defaults`,`models`],message:`Legacy model restriction retained: some keys need explicit provider/model refs. Set agents.defaults.modelPolicy.allow to the intended restriction; until then, editing agents.defaults.models still changes the restriction.`,match:(e,t)=>materializeModelPolicyAllowlist(t).kind===`deferred`}],apply:migrateExplicitDefaultModelAllowPolicy},{id:`agents.defaults.models.vllm.params.qwenThinkingFormat->models.providers.vllm.models.compat.thinkingFormat`,legacyRules:LEGACY_VLLM_QWEN_THINKING_FORMAT_RULES,apply:migrateVllmQwenThinkingParams},{id:`models.providers.*.models.*.compat.thinkingFormat-invalid`,legacyRules:[INVALID_THINKING_FORMAT_RULE],apply:(e,t)=>{for(const{providerId:n,modelIndex:r,compat:i,thinkingFormat:a}of invalidModelThinkingFormats(asNullableRecord(e.models)?.providers)){delete i.thinkingFormat;t.push(`Removed models.providers.${n}.models.${r}.compat.thinkingFormat (unrecognized value ${JSON.stringify(a)}; runtime default applies).`)}}},{id:`models.providers.*.models.*.contextWindow-stale`,legacyRules:[STALE_CONTEXT_WINDOW_RULE],apply:(e,t)=>{for(const{providerId:n,modelIndex:r,model:i,modelId:a,contextWindow:o,fix:s}of staleModelContextWindows(asNullableRecord(e.models)?.providers)){i.contextWindow=s.correct;t.push(`Repaired models.providers.${n}.models[${r}].${a}.contextWindow (${o} → ${s.correct} to match catalog default).`)}}}];export{collectBlockedLegacyOpenAICodexProviderPlan as n,isLegacyModelsAddCodexMetadataModel as r,LEGACY_CONFIG_MIGRATIONS_RUNTIME_MODELS as t};