openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
47 lines (46 loc) • 1.65 kB
JavaScript
import { n as executeExistingOpenClawStateRead } from "./openclaw-state-db-readonly-B6YHb1oF.mjs";
import { i as captureWorktreeRunEndContext } from "./run-end-lifecycle-CvtGWdnp.mjs";
import { l as readLiveRegistryWorktreeByPath, t as captureWorktreeRegistryReadGuard } from "./registry-read-DAFI5cQY.mjs";
import { r as localWorkspaceProjectionPath } from "./local-workspace-checkout-D7yp8kUm.mjs";
//#region src/gateway/worker-environments/local-workspace-read.ts
/** Read the live backing without capturing, publishing, or stopping guest writers. */
async function readLocalWorkspacePath(e) {
const t = captureWorktreeRunEndContext(process.env);
const n = captureWorktreeRegistryReadGuard(t, "lifecycle");
const r = await readLiveRegistryWorktreeByPath(t, e.cwd);
const i = n(r);
const assertCurrent = () => {
i();
e.assertCurrent?.();
};
assertCurrent();
if (!r) return {
root: e.cwd,
assertCurrent
};
if (r.id !== e.worktreeId) throw new Error("Local sandbox workspace owner changed");
const a = await executeExistingOpenClawStateRead({
path: t.admission.databasePath,
env: t.environment
}, {
type: "localWorkspace.readBacking",
input: { id: r.id }
}, {
context: t,
current: true,
live: true
});
assertCurrent();
const o = a?.row;
if (o && (r.ownerKind !== "session" || o.session_key !== r.ownerId || o.projection_path !== localWorkspaceProjectionPath({
worktree: r,
env: t.environment
}))) throw new Error("Local sandbox workspace owner changed");
return {
root: o?.baseline_ref ? o.projection_path : e.cwd,
worktreeId: r.id,
assertCurrent
};
}
//#endregion
export { readLocalWorkspacePath };