UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

53 lines (52 loc) • 2.5 kB
import { n as hasCompletedUpdateModelRetirement, t as DEFERRED_UPDATE_MODEL_RETIREMENT_WARNING } from "./update-deferred-model-retirement-Czgbuzcr.mjs"; //#region src/infra/deferred-update-warnings.ts /** * Retire model warnings only after the selected run records completion. Plugin * warnings retire when their obligation leaves the pending ledger, a later warning * supersedes them, or the caller reports that plugin's final state itself. * Matches both shipped warning forms without reading retired migration reports. * Messages are ordered oldest first. */ async function readRetiredDeferredUpdateWarnings(e, t = {}) { const n = /* @__PURE__ */ new Set(); if (e.includes("Model retirement deferred until configured plugin installation converges.") && hasCompletedUpdateModelRetirement(t.readUpdateRun?.())) n.add(DEFERRED_UPDATE_MODEL_RETIREMENT_WARNING); const r = /* @__PURE__ */ new Map(); const i = /* @__PURE__ */ new Map(); for (const t of e) { const e = t && /^Plugin "([^"]+)" (?:state migration is pending|data\/settings upgrade is unfinished):/u.exec(t)?.[1]; if (t && e) { r.set(t, e); i.set(e, t); } } if (!r.size) return n; const { readDeferredPluginMigrationsAsync: a } = await import("./deferred-plugin-migrations-D0dr-2ek.mjs"); const o = new Set((await a()).map(({ pluginId: e }) => e)); for (const [e, a] of r) if (!o.has(a) || i.get(a) !== e || t.finallyReportedPluginIds?.has(a)) n.add(e); return n; } /** * Drops warnings a later repair in the same pass settled or superseded, such as * post-session plugin migrations finishing after config preflight reported them * pending. The ledger is authoritative; an unreadable ledger keeps every warning. */ async function retainCurrentDeferredUpdateWarnings(e, t = {}) { const n = await readRetiredDeferredUpdateWarnings(e, t).catch(() => /* @__PURE__ */ new Set()); return e.filter((e) => !n.has(e)); } /** Keep the original process outcome while replacing its settled warning projection. */ function retireDeferredUpdateStepWarnings(e, t) { const n = e.warnings ?? (e.advisory ? [e.advisory.message] : []); const r = n.filter((e) => !t.has(e)); if (r.length === n.length) return e; return { ...e, warnings: r, ...e.advisory ? { advisory: { ...e.advisory, message: r.join("\n") || "Warnings settled during post-core convergence." } } : {} }; } //#endregion export { retainCurrentDeferredUpdateWarnings as n, retireDeferredUpdateStepWarnings as r, readRetiredDeferredUpdateWarnings as t };