openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
45 lines (44 loc) • 1.92 kB
JavaScript
import { i as prepareModelReplacementConfig } from "./retired-model-ref-repair-B9RO1-mz.mjs";
import { t as createModelAliasCanonicalizer } from "./model-alias-canonicalization-C1VcgP2i.mjs";
import { n as canonicalizeCronModelReplacementAliases } from "./legacy-repair-D9TVWPHm.mjs";
import { t as inspectDoctorModelReferences } from "./model-reference-inventory-Wy_hgz6X.mjs";
import { t as maybeRepairCodexSessionRoutes } from "./codex-route-session-repair-W0qtGs4p.mjs";
//#region src/commands/doctor/shared/model-replacement-preparation.ts
/** Preserve source identities durably before moving aliases, so interrupted runs remain repairable. */
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
};
}
//#endregion
export { prepareExplicitModelReplacement };