openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4 lines • 3.02 kB
JavaScript
import{l as listCrabboxLegacyWarmLeases,p as recoverCrabboxWarmImageCapture,s as crabboxCaptureUnsupportedSentence,u as listCrabboxWarmImages}from"./crabbox-worker-warm-image-store-Bkmwt6Qm.mjs";import{a as crabboxWarmImageRecoveryHint,t as CRABBOX_WARM_IMAGE_WAIT_HINT}from"./crabbox-worker-warm-image-records-B8HI4d8j.mjs";
//!extensions/crabbox/src/crabbox-worker-warm-image-cli.ts
function registerCrabboxWarmImageCommands(e,t){e.command(`crabbox`).description(`Manage Crabbox warm images`).command(`warm-images`).description(`Inspect local warm-image ownership or acknowledge manual provider cleanup`).option(`--json`,`Print local warm-image records as JSON`).option(`--recover <selector>`,`Clear the exact capture or legacy allocation shown by inspection after manual cleanup`).option(`--acknowledge-provider-cleanup`,`Confirm owning processes and recovered workers are stopped and provider artifacts are reconciled`).action(async e=>{if(e.acknowledgeProviderCleanup&&!e.recover)throw new Error(`--acknowledge-provider-cleanup requires --recover <selector> from warm-images inspection.`);if(e.recover)await recoverCrabboxWarmImageCapture(t,e.recover,e.acknowledgeProviderCleanup===true);const n=await listCrabboxWarmImages(t);const r=await listCrabboxLegacyWarmLeases(t);const i=`Restart the Gateway after manual reconciliation; the next eligible worker can capture again.`;if(e.json){process.stdout.write(`${JSON.stringify({images:n,legacyLeases:r,...e.recover?{recoveredCapture:e.recover,nextSteps:i}:{}},null,2)}\n`);return}const a=e.recover?[`Selected recovery record and capture-source allocation cleared; retained images and other allocation choices are preserved. No provider commands were run.`,i]:[];if(n.length===0&&r.length===0)a.push(`No Crabbox warm images are recorded locally.`);for(const e of r){a.push(`Legacy worker allocation ${e.leaseId}: original image choice is unknown.`);a.push(` ${crabboxWarmImageRecoveryHint(e.selector)}`)}for(const e of n){a.push(`${e.profileKey}: ${e.checkpointId??`no checkpoint`} (${e.state})`);if(e.captureUnsupported)a.push(` Capture unsupported: ${crabboxCaptureUnsupportedSentence(e.captureUnsupported.message)} Workers use an existing compatible snapshot when one is available and otherwise provision cold; capture attempts are skipped until warmImages.refreshAfter has elapsed since the refusal. Set settings.warmImage: false on the profile to stop capture attempts.`);if(e.capture){const t=e.capture.phase===`uncertain`;const n=t?`paused`:e.capture.stale?`still pending`:`in progress`;a.push(` Capture ${n}: ${e.capture.selector}`);if(t)a.push(` ${crabboxWarmImageRecoveryHint(e.capture.selector,e.capture.checkpointIds)}`);else if(e.capture.stale)a.push(` ${CRABBOX_WARM_IMAGE_WAIT_HINT}`)}if(e.retirement)a.push(` Checkpoint deletion pending: ${e.retirement.checkpointId}; retried during periodic maintenance or the next warm-image capture or worker teardown.`)}process.stdout.write(`${a.join(`
`)}\n`)})}export{registerCrabboxWarmImageCommands};