UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.39 kB
import{n as executeExistingOpenClawStateRead}from"./openclaw-state-db-readonly-Cd5_cxBs.mjs";import{i as captureWorktreeRunEndContext}from"./run-end-lifecycle-mk2iX8J8.mjs";import{l as readLiveRegistryWorktreeByPath,t as captureWorktreeRegistryReadGuard}from"./registry-read-mqD__iTh.mjs";import{r as localWorkspaceProjectionPath}from"./local-workspace-checkout-BneJgVKr.mjs"; //!src/gateway/worker-environments/local-workspace-read.ts 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!==await localWorkspaceProjectionPath({worktree:r,env:t.environment})))throw new Error(`Local sandbox workspace owner changed`);assertCurrent();return{root:o?.baseline_ref?o.projection_path:e.cwd,worktreeId:r.id,assertCurrent}}export{readLocalWorkspacePath};