UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 1.45 kB
import{getAuthoredModuleExport,materializeAuthoredModuleExport}from"#internal/authored-module.js";import{toErrorMessage}from"#shared/errors.js";import"#compiler/source-graph.js";const SANDBOX_SELECTOR_MARKER=Symbol.for(`eve.sandbox-selector`);function requireModuleBackedDefinitionLoadOptions(e,t){if(e.binding===void 0||e.loadNamespace===void 0)throw Error(`Module-backed source "${t}" requires a compiled binding.`);return{binding:e.binding,loadNamespace:e.loadNamespace}}async function loadModuleBackedDefinition(e){if(e.binding.logicalPath!==e.source.logicalPath)throw Error(`Compiled binding "${e.source.sourceId}" targets "${e.binding.logicalPath}", not "${e.source.logicalPath}".`);let t=await e.loadNamespace(e.source.sourceId),n=getAuthoredModuleExport(t,e.source);if(e.kind===`sandbox`&&typeof n==`function`&&Reflect.get(n,SANDBOX_SELECTOR_MARKER)===!0)return n;try{return await materializeAuthoredModuleExport(n)}catch(t){throw e.kind===`sandbox`&&typeof n==`function`?Error(`Failed to execute the sandbox export "${e.source.exportName??`default`}" from "${e.displayPath??e.source.logicalPath}" as a zero-argument definition factory. Runtime selectors must be passed to defineSandbox(...): ${toErrorMessage(t)}`):Error(`Failed to execute the ${e.kind} export "${e.source.exportName??`default`}" from "${e.displayPath??e.source.logicalPath}": ${toErrorMessage(t)}`)}}export{loadModuleBackedDefinition,requireModuleBackedDefinitionLoadOptions};