eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.29 kB
JavaScript
import{expectObjectRecord,getAuthoredModuleExport}from"#internal/authored-module.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{getBoundSandboxEnvironment,isSandboxEnvironment}from"#shared/sandbox-environment.js";import{defineParentSandbox}from"#public/definitions/sandbox.js";import{ResolveAgentError}from"#runtime/resolve-helpers.js";async function resolveSandboxDefinition(e,t,n){if(e.inheritsParent===!0)return{exportName:e.exportName,kind:`parent`,logicalPath:e.logicalPath,revisionHash:e.revisionHash,selector:defineParentSandbox(),sourceId:e.sourceId,sourceKind:`module`};let r=t.nodes[n??ROOT_COMPILED_AGENT_NODE_ID]?.modules[e.sourceId],i=expectObjectRecord(r,`Missing sandbox module "${e.logicalPath}".`),a=getAuthoredModuleExport(i,e);if(typeof a!=`function`)throw new ResolveAgentError(`Sandbox "${e.logicalPath}" does not export a selector.`);let o=e.environmentExportName?i[e.environmentExportName]:getBoundSandboxEnvironment(a),s={exportName:e.exportName,logicalPath:e.logicalPath,revisionHash:e.revisionHash,selector:a,sourceId:e.sourceId,sourceKind:`module`};if(!isSandboxEnvironment(o))throw new ResolveAgentError(`Sandbox "${e.logicalPath}" has no environment.`);return{...s,environment:o,kind:`independent`}}export{resolveSandboxDefinition};