UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 2.92 kB
import{i as resolveOpenClawPackageRootsSync}from"./openclaw-root-DP80HYD2.mjs";import{r as isPathInside}from"./path-guards-DGttsOJI.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{f as resolveIdentityPathViaExistingAncestorSync}from"./path-existence-BR9MXlgL.mjs";import{a as getOpenClawDatabaseMaintenanceScope}from"./openclaw-state-maintenance-context-D-pYfco8.mjs";import"./openclaw-state-db-async-lifecycle-DlV0ztcV.mjs";import{t as DoctorMaintenanceRefusalError}from"./update-doctor-result-B09W3zwf.mjs";import{t as maintainRetainedUpdateRuntimes}from"./temp-artifact-cleanup-Ib8Ozg92.mjs";import{t as note}from"./note-e4DtVgg2.mjs";import{n as holdDoctorMaintenanceExit}from"./doctor-maintenance-exit-Ci7Ig37v.mjs";import{t as inspectDoctorTemporaryDirectories}from"./temporary-directories-B7kVk3bo.mjs"; //!src/commands/doctor-retained-runtime.ts async function prepareRetainedUpdateRuntimeMaintenance(e,t){const{directories:n,warnings:r}=await inspectDoctorTemporaryDirectories(e,t);const i=[...resolveOpenClawPackageRootsSync({moduleUrl:import.meta.url,argv1:process.argv[1],cwd:process.cwd()}),...t?.packageRoots??[]];return async(e,t)=>[...await maintainRetainedUpdateRuntimes({packageRoots:i,temporaryDirectories:n,repair:e,...t}),...r]}async function cleanupRetainedUpdateRuntimesBeforeMaintenance(e){const t=holdDoctorMaintenanceExit();try{const n=await prepareRetainedUpdateRuntimeMaintenance(e);const[{captureRetainedNativeWorkerSource:r},{retireIdleOpenClawStateReadWorkers:i}]=await Promise.all([import(`./worker-native-lifecycle-f9m3SNRo.mjs`),import(`./openclaw-state-read-worker-CbgS3yrn.mjs`)]);const a=r();let o;try{o=await i(a);await a.retireIdleBroker()}catch(e){throw new DoctorMaintenanceRefusalError(`Doctor inspection resource cleanup failed: ${formatErrorMessage(e)}. Updater runtimes were kept; resolve this cleanup failure, then rerun openclaw doctor --fix.`,{kind:`data-at-risk`,reason:`active-mutation`},{cause:e})}const s=await n(true,{assertCurrent:()=>t.signal.throwIfAborted(),assertResourcesSettled(e){const t=a.activeWorkerPaths().some(t=>t===void 0||isPathInside(e,resolveIdentityPathViaExistingAncestorSync(t)));if(!o||t)throw new Error(`independent native work in this process (PID: ${process.pid}); let these holders finish, then rerun openclaw doctor --fix`)}});if(s.length)note(s.join(` `),`Updater runtimes`)}finally{t.release()}}async function prepareRetainedUpdateRuntimeCleanup(e,t){const n=getOpenClawDatabaseMaintenanceScope();const r=await prepareRetainedUpdateRuntimeMaintenance(e,t);return async(e,t)=>{const i=await r(e,t??{assertCurrent:()=>{if(!n?.ownsSchemaMaintenance)throw new Error(`Doctor does not hold Gateway maintenance`);n.assertAdmission()}});if(i.length)note(i.join(` `),`Updater runtimes`)}}export{cleanupRetainedUpdateRuntimesBeforeMaintenance,prepareRetainedUpdateRuntimeCleanup,prepareRetainedUpdateRuntimeMaintenance};