UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.33 kB
import{o as measureGatewayBootstrapStep}from"./startup-trace-CnJbL2Y9.mjs";import{a as resolveUpdateRehearsalRoot}from"./update-rehearsal-paths-C4qLj9oD.mjs";import{t as DoctorMaintenanceRefusalError}from"./update-doctor-result-B09W3zwf.mjs";import{t as formatDoctorProgressPhase}from"./doctor-progress-DGmacsiq.mjs";import{p as withDoctorProgress}from"./doctor-health-startup-WrxcBhpP.mjs"; //!src/commands/doctor-original-capture-admission.ts function createDoctorOriginalCaptureHook(e){return async({env:t,signal:n})=>{const[{preserveDoctorOriginalState:r},{getOpenClawDatabaseMaintenanceScope:i}]=await Promise.all([import(`./doctor-original-capture-Cj1HL8gn.mjs`),import(`./openclaw-state-db-async-lifecycle-D8_rltWE.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-CHoSf4vz.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)}}export{createDoctorOriginalCaptureHook};