UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

86 lines (85 loc) • 3.93 kB
import { a as asOptionalRecord } from "./record-coerce-CVPuDqcc.mjs"; import { i as listAgentIds } from "./agent-roster-t1ooUdXp.mjs"; import { a as visitModelSelectorRefs, r as collectConfiguredModelRefs } from "./configured-model-refs-DtaDJ1Vw.mjs"; import "./agent-scope-BwB8YH6y.mjs"; import { a as resolveAllAgentSessionStoreTargetsSync, s as resolveConfiguredAgentDatabaseTargets } from "./targets-BVE0__Jb.mjs"; import { b as scanDoctorSessionEntriesTolerant } from "./session-accessor-CizTbDQj.mjs"; import { n as createRetainedAgentDatabaseMatcher } from "./agent-deletion-discovery-BUESMyCH.mjs"; import { n as readCronStoreSelectionForDoctor } from "./default-store-selection-OlpQeMWT.mjs"; import { n as createDoctorModelRefResolver } from "./model-alias-canonicalization-C1VcgP2i.mjs"; import { i as loadLegacyCronRepairState } from "./legacy-repair-D9TVWPHm.mjs"; //#region src/commands/doctor/shared/model-reference-inventory.ts /** Reads selectors, not transcripts. Incomplete store scans are reported rather than treated as clean. */ async function inspectDoctorModelReferences(e) { const t = e.env ?? process.env; const n = createDoctorModelRefResolver(e.cfg); const r = /* @__PURE__ */ new Map(); const i = []; const inspect = (t, i, a) => { if (typeof t !== "string") return; const o = n(t, a); if (o && e.matches(o)) r.set(i + ":" + o, { path: i, modelRef: o, rawModelRef: t, agentId: a }); }; const a = listAgentIds(e.cfg); for (const t of collectConfiguredModelRefs(e.cfg)) { const e = a.find((e) => t.path.startsWith("agents.entries." + e + ".")); for (const n of e ? [e] : a.length ? a : [void 0]) inspect(t.value, t.path, n); } const o = [{ path: "agents.defaults", policy: e.cfg.agents?.defaults?.modelPolicy, agentId: void 0 }, ...Object.entries(e.cfg.agents?.entries ?? {}).map(([e, t]) => ({ path: "agents.entries." + e, policy: t.modelPolicy, agentId: e }))]; for (const { path: e, policy: t, agentId: n } of o) t?.allow?.forEach((t, r) => inspect(t, e + ".modelPolicy.allow." + r, n)); try { const n = createRetainedAgentDatabaseMatcher(t, () => resolveConfiguredAgentDatabaseTargets(e.cfg, { env: t })); for (const r of resolveAllAgentSessionStoreTargetsSync(e.cfg, { env: t })) { if (n(r.storePath, r.agentId)) continue; scanDoctorSessionEntriesTolerant({ ...r, env: t }, ({ entry: e, sessionKey: t }) => { if (e.modelOverride) inspect(e.providerOverride ? e.providerOverride + "/" + e.modelOverride : e.modelOverride, "sessions." + r.agentId + "." + t + ".modelOverride", r.agentId); }); } } catch { i.push("Session model reference scan was incomplete; restore access to the session stores and rerun Doctor."); } try { const n = await readCronStoreSelectionForDoctor(e.cfg, t); if (n.status !== "ready") i.push("Cron model reference scan was incomplete: select a cron partition with openclaw doctor --fix, then rerun Doctor."); else { const r = await loadLegacyCronRepairState({ cfg: e.cfg, env: t, storePath: n.storePath, readOnly: true }); for (const e of r?.rawJobs ?? []) { const t = r?.projectedOwnersByJobId.get(String(e.id)); const n = typeof e.agentId === "string" ? e.agentId : t && t.kind !== "unresolved" ? t.agentId : void 0; const i = asOptionalRecord(e.payload); const o = "cron." + String(e.id) + ".payload"; visitModelSelectorRefs(i?.model, o + ".model", (e, t) => n ? inspect(t, e, n) : a.forEach((n) => inspect(t, e, n))); if (Array.isArray(i?.fallbacks)) i.fallbacks.forEach((e, t) => n ? inspect(e, o + ".fallbacks." + t, n) : a.forEach((n) => inspect(e, o + ".fallbacks." + t, n))); } } } catch { i.push("Cron model reference scan was incomplete; restore access to the cron store and rerun Doctor."); } return { references: [...r.values()], warnings: i }; } //#endregion export { inspectDoctorModelReferences as t };