UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

50 lines (49 loc) • 2.73 kB
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; import "./string-coerce-runtime-BwAZZDf5.mjs"; import { createHash } from "node:crypto"; //#region extensions/crabbox/src/crabbox-worker-warm-image-records.ts const allocationHoldsCheckpoint = (e, t) => e.choice.kind === "checkpoint" && e.choice.checkpointId === t || e.imageGeneration?.checkpointId === t; const isCrabboxWarmImageHeld = (e, t) => Object.values(e.allocations).some((e) => allocationHoldsCheckpoint(e, t)); const crabboxWarmImageHoldingLeaseIds = (e, t) => Object.entries(e.allocations).filter(([, e]) => allocationHoldsCheckpoint(e, t)).map(([e]) => e); const CAPTURE_WARNING_AGE_MS = 12e5; function withoutCrabboxWarmImageOperation(e) { const t = { ...e }; delete t.operation; return t; } function crabboxWarmImageCaptureStatus(e) { const t = e.operation?.type === "capture" ? e.operation : void 0; if (!t) return; return { selector: t.id, startedAtMs: t.startedAtMs, ...t.leaseId ? { leaseId: t.leaseId } : {}, ...t.provider ? { provider: t.provider } : {}, phase: t.phase, ...t.checkpointIds ? { checkpointIds: t.checkpointIds } : {}, stale: Date.now() - t.startedAtMs >= CAPTURE_WARNING_AGE_MS }; } const CRABBOX_WARM_IMAGE_WAIT_HINT = "The capture may still be preparing its source or waiting for provider readiness. Inspect openclaw crabbox warm-images --json and allow the owning capture to settle."; function crabboxWarmImageRecoveryHint(e, t) { return `${t?.length ? `Candidate checkpoints: ${t.join(", ")}. ` : ""}Stop the owning Gateway and capture processes, confirm any worker being recovered is stopped, and resolve any untracked checkpoint in the Crabbox catalog before running: openclaw crabbox warm-images --recover ${e} --acknowledge-provider-cleanup. Then restart the Gateway; the next eligible worker can capture again.`; } function crabboxLegacyWarmImageCaptureSelector(e, t) { return `legacy-${createHash("sha256").update(JSON.stringify({ key: e, record: t })).digest("hex")}`; } const legacyLeaseSelector = (e, t) => `legacy-lease-${createHash("sha256").update(JSON.stringify({ key: e, value: t })).digest("hex")}`; function projectCrabboxLegacyWarmLeases(e) { return e.map(({ key: e, value: t }) => ({ leaseId: e, machineClass: isRecord(t) && typeof t.machineClass === "string" ? t.machineClass : void 0, selector: legacyLeaseSelector(e, t) })); } //#endregion export { crabboxWarmImageRecoveryHint as a, projectCrabboxLegacyWarmLeases as c, crabboxWarmImageHoldingLeaseIds as i, withoutCrabboxWarmImageOperation as l, crabboxLegacyWarmImageCaptureSelector as n, isCrabboxWarmImageHeld as o, crabboxWarmImageCaptureStatus as r, legacyLeaseSelector as s, CRABBOX_WARM_IMAGE_WAIT_HINT as t };