openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.61 kB
JavaScript
import{i as prepareModelReplacementConfig}from"./retired-model-ref-repair-DEPRKNGf.mjs";import{t as createModelAliasCanonicalizer}from"./model-alias-canonicalization-B9DfKNbD.mjs";import{n as canonicalizeCronModelReplacementAliases}from"./legacy-repair-Bpgsh7Eq.mjs";import{t as inspectDoctorModelReferences}from"./model-reference-inventory-DpUHPOcR.mjs";import{t as maybeRepairCodexSessionRoutes}from"./codex-route-session-repair-C2qQ1qJs.mjs";
//!src/commands/doctor/shared/model-replacement-preparation.ts
async function prepareExplicitModelReplacement(e){const t=e.env;const n=[];const r=[];const append=e=>{n.push(...e.changes);r.push(...e.warnings)};prepareModelReplacementConfig(e.cfg,e.choices);append(await maybeRepairCodexSessionRoutes({cfg:e.cfg,env:t,shouldRepair:true,modelReplacements:e.choices,canonicalizeModelAliasesOnly:true}));const i=await canonicalizeCronModelReplacementAliases({cfg:e.cfg,env:t,modelReplacements:e.choices});append(i);const a=createModelAliasCanonicalizer(e.cfg,e.choices);const o=new Set(e.choices.map(e=>e.from));const s=await inspectDoctorModelReferences({cfg:e.cfg,env:t,matches:e=>o.has(e)});if(i.warnings.length||s.warnings.length||s.references.some(e=>(e.path.startsWith(`sessions.`)||e.path.startsWith(`cron.`))&&(!e.agentId||a(e.rawModelRef,e.agentId))))throw new Error(`Model replacement deferred: some saved aliases could not be prepared safely. Unlock affected model selections or restore access to the reported stores, then rerun the same Doctor command. Config aliases were not retargeted.`);return{changes:n,warnings:r}}export{prepareExplicitModelReplacement};