UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

50 lines (49 loc) • 2.73 kB
import { o as measureGatewayBootstrapStep } from "./startup-trace-DWZsuODq.mjs"; import { a as resolveUpdateRehearsalRoot } from "./update-rehearsal-paths-Dr1MbUA_.mjs"; import { t as DoctorMaintenanceRefusalError } from "./update-doctor-result-DwaI51On.mjs"; import { t as formatDoctorProgressPhase } from "./doctor-progress-C3vWlya1.mjs"; import { f as withDoctorProgress } from "./doctor-health-startup-KiSUu3WC.mjs"; //#region src/commands/doctor-original-capture-admission.ts /** The admitted owner checks deferred schemas before original capture or repair effects. */ function createDoctorOriginalCaptureHook(e) { return async ({ env: t, signal: n }) => { const [{ preserveDoctorOriginalState: r }, { getOpenClawDatabaseMaintenanceScope: i }] = await Promise.all([import("./doctor-original-capture-Bsz8gNpe.mjs"), import("./openclaw-state-db-async-lifecycle-svBk4d27.mjs")]); const a = i(); if (!a) throw new Error("Original state capture requires Doctor's admitted maintenance scope."); if (e.rehearsalRoot !== void 0) try { if (resolveUpdateRehearsalRoot(t) !== e.rehearsalRoot) throw new Error("Disposable Doctor namespace changed before maintenance admission."); const { guardUpdateDoctorSchemaUpgrade: n } = await import("./commands/doctor-update-schema-guard.js"); a.assertOwnerCurrent(); if (resolveUpdateRehearsalRoot(process.env) !== e.rehearsalRoot) throw new Error("Disposable Doctor namespace changed before maintenance admission."); const r = await n({ runtime: e.runtime, json: e.json, preserveSourceArtifacts: e.writeAuthority?.databaseGenerations ? true : void 0 }); a.assertOwnerCurrent(); if (r?.updateSchemaRehearsal) throw new Error("Deferred schema rehearsal cannot authorize repair of agents outside this disposable namespace."); return; } catch (e) { throw new DoctorMaintenanceRefusalError(`Doctor rehearsal admission refused: ${e instanceof Error ? e.message : String(e)}`, { kind: "data-at-risk", reason: "incomplete-migration" }, { cause: e }); } const { restorePrivateStateStoreModes: o } = await import("./openclaw-state-db-permissions-Ber_2Pjh.mjs"); n.throwIfAborted(); a.assertOwnerCurrent(); o(t); const { findings: s, warnings: c } = await withDoctorProgress(formatDoctorProgressPhase("Preserve original state"), () => measureGatewayBootstrapStep("doctor.maintenance.preserve-original-state", () => r({ root: e.root, env: t, runtime: e.runtime, signal: n, assertCurrent: () => a.assertOwnerCurrent(), writeAuthority: e.writeAuthority, fullIntegrityCheck: e.fullIntegrityCheck })), e.json !== true); e.reportFindings(s, c); }; } //#endregion export { createDoctorOriginalCaptureHook };