UNPKG

eve

Version:

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

1 lines 1.27 kB
import{expectObjectRecord,getAuthoredModuleExport,materializeAuthoredModuleExport}from"#internal/authored-module.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";var ResolveAgentError=class extends Error{logicalPath;sourceId;constructor(e,t={}){super(e),this.name=`ResolveAgentError`,t.logicalPath!==void 0&&(this.logicalPath=t.logicalPath),t.sourceId!==void 0&&(this.sourceId=t.sourceId)}};function createResolvedModuleSourceRef(e){return{exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId,sourceKind:`module`}}async function loadResolvedModuleExport(e){let t=e.nodeId??ROOT_COMPILED_AGENT_NODE_ID,n=e.moduleMap.nodes[t]?.modules[e.definition.sourceId];if(n===void 0)throw new ResolveAgentError(`Missing compiled module namespace for ${e.kindLabel} source "${e.definition.sourceId}" in node "${t}".`,{logicalPath:e.definition.logicalPath,sourceId:e.definition.sourceId});let r=expectObjectRecord(n,`Missing compiled module namespace for ${e.kindLabel} source "${e.definition.sourceId}" in node "${t}".`),i=getAuthoredModuleExport(r,{exportName:e.definition.exportName,logicalPath:e.definition.logicalPath});return await materializeAuthoredModuleExport(i)}export{ResolveAgentError,createResolvedModuleSourceRef,loadResolvedModuleExport};