UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

42 lines (41 loc) • 2.14 kB
import { r as CronStreamPolicyDeniedError } from "./stream-exec-authority-CRx6XpZo.mjs"; import { r as getSandboxPersistentExecCapability } from "./persistent-exec.types-DoJqKDH2.mjs"; import { r as readStreamSandboxContext } from "./stream-context-CUn0Kkey.mjs"; import { r as execContainer } from "./container-engine-CscrTTHa.mjs"; import { o as readDockerPersistentContainer, t as assertDockerPersistentTargetCurrent } from "./docker-persistent-target-CUAQLHHF.mjs"; //#region src/gateway/cron-stream-sandbox-approval.ts /** Recheck the configured image and sandbox generation across the human approval wait. */ async function prepareCronStreamSandboxApproval(e) { const { sandbox: t, target: n } = e; const r = t.backend; const i = r && getSandboxPersistentExecCapability(r); if (!r || !i) throw new CronStreamPolicyDeniedError("Sandbox stream approval is unavailable for this backend."); const assertCurrent = () => { const e = readStreamSandboxContext(t); if (e.configLabel !== n.configLabel || e.scopeKey !== n.scopeKey || t.sessionKey !== n.sessionKey || e.agentId !== n.agentId || getSandboxPersistentExecCapability(r) !== i) throw new CronStreamPolicyDeniedError("The sandbox stream target changed while awaiting approval."); }; const read = async () => { assertCurrent(); const e = await assertDockerPersistentTargetCurrent(i.target, AbortSignal.timeout(3e4)); const t = await readDockerPersistentContainer(e, i.containerId, AbortSignal.timeout(3e4)); assertCurrent(); if (t.kind !== "running" || t.startedAt !== i.containerStartedAt) throw new CronStreamPolicyDeniedError("The sandbox container changed while awaiting approval."); const n = await i.resolveImage(); const r = await execContainer(e, [ "image", "inspect", "--format", "{{.Id}}", i.imageReference ], { signal: AbortSignal.timeout(3e4) }); assertCurrent(); if (r.stdout.trim() !== n) throw new CronStreamPolicyDeniedError("The configured sandbox image changed while awaiting approval."); }; await read(); return { assertCurrent, revalidate: read }; } //#endregion export { prepareCronStreamSandboxApproval };