UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.15 kB
import path from"node:path";import{randomUUID}from"node:crypto"; //!src/agents/sandbox/input-staging.ts const INPUT_STAGER=Symbol.for(`openclaw.sandboxInputStager`);function bindSandboxInputStager(e,t){Object.defineProperty(e,INPUT_STAGER,{value:t,configurable:true})}function getSandboxInputStager(e){return e[INPUT_STAGER]}function createSandboxInputStager(e){return async t=>{const assertCurrent=()=>{t.signal?.throwIfAborted();e.assertCurrent();t.assertCurrent()};assertCurrent();const[{root:n},{stagedInputDirectory:r,STAGED_INPUT_GITIGNORE:i}]=await Promise.all([import(`./fs-safe-Do6cgu7u.mjs`),import(`./staged-inputs-BJwqoKb_.mjs`)]);const a=r(randomUUID());const o=`${a}/${t.prefix}.log`;const s=e.bridge.resolvePath({filePath:o,cwd:e.root});if(s.hostPath!==path.join(e.root,o))throw new Error(`Sandbox input staging is shadowed by another mount`);const c=await n(e.root);for(const[e,n]of[[`${a}/.gitignore`,i],[o,t.content]]){assertCurrent();await c.create(e,n,{mode:384,assertBeforeMutation:assertCurrent})}assertCurrent();return s.containerPath}}export{createSandboxInputStager as n,getSandboxInputStager as r,bindSandboxInputStager as t};