openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
43 lines (42 loc) • 1.8 kB
JavaScript
import { n as executeExistingOpenClawStateRead } from "./openclaw-state-db-readonly-B6YHb1oF.mjs";
import { r as captureOpenClawStateWorkerContext } from "./openclaw-state-worker-context-DAKL_dnZ.mjs";
import { d as readRegistryWorktree } from "./registry-read-DAFI5cQY.mjs";
import { a as withSettledLocalWorkspace } from "./local-workspace-projection-d69eRBoO.mjs";
//#region src/gateway/worker-environments/local-workspace-settlement.ts
/** Sandbox recreate recovers through the existing canonical projection owner, including after a controller crash. */
async function withSettledLocalWorkspaceProjectionPath(e, t) {
const n = captureOpenClawStateWorkerContext({
path: e.databasePath,
env: e.env
});
const r = await executeExistingOpenClawStateRead({
path: n.admission.databasePath,
env: n.environment
}, {
type: "localWorkspace.byProjectionPath",
input: { projectionPath: e.projectionPath }
}, {
context: n,
current: true
});
e.assertCurrent?.();
if (!r) {
if (e.requireProjection) throw new Error("Managed sandbox projection is missing; preserve its stopped custody.");
return await t();
}
if (!r.ok || r.type !== "localWorkspace.byProjectionPath") throw new Error("Unexpected local workspace projection lookup.");
if (!r.projection) {
if (e.requireProjection) throw new Error("Managed sandbox projection is missing; preserve its stopped custody.");
return await t();
}
const i = await readRegistryWorktree(n, r.projection.worktree_id);
e.assertCurrent?.();
if (!i) throw new Error("Managed sandbox workspace lost its canonical owner; preserve its stopped custody.");
return await withSettledLocalWorkspace({
worktree: i,
env: n.environment,
assertCurrent: e.assertCurrent
}, t);
}
//#endregion
export { withSettledLocalWorkspaceProjectionPath };