eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 3.77 kB
JavaScript
import{posix}from"node:path";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{canonicalSourceSlot}from"#compiler/source-graph.js";import{mountRefNamespace,packageStateNamespace}from"#discover/extensions.js";import"#compiler/normalize-subagent.js";function collectSelectedSourceIds(e){return new Set([...e.selected.values()].map(e=>e.sourceId))}function assertRootOnlyConfig(e,t,n){if(!t&&e.experimental?.workflow?.world!==void 0)throw Error(`Workflow world configuration is only supported on the root agent config. Remove "experimental.workflow.world" from "${n}".`)}function assertApplicationOverlayCanApplyToAllNodes(e){let t=e.find(e=>{let t=canonicalSourceSlot(e);return t===`agent`||t.startsWith(`channels/`)||t.startsWith(`schedules/`)||t.startsWith(`subagents/`)||t.startsWith(`extensions/`)});if(t!==void 0)throw Error(`Application programmatic source registered for all local nodes cannot declare "${t}".`)}function assertUniqueRegistryIds(e){let t=new Set;for(let n of e)for(let e of n.sources.keys()){if(t.has(e))throw Error(`Programmatic agent source id "${e}" is registered more than once.`);t.add(e)}}function assertRootOwnedSpecialTool(e,t){if(e.nodeId!==ROOT_COMPILED_AGENT_NODE_ID)throw Error(`${t} can only be enabled on the root agent.`);assertNonExtensionSpecialTool(e,t)}function assertNonExtensionSpecialTool(e,t){if(e.owner.kind===`extension`)throw Error(`${t} cannot be configured by an extension source.`)}function withExtensionNamespace(e,t){return t.kind===`extension`?{...e,extensionNamespace:t.namespace}:e}function assertUniqueBy(e,t,n){let r=new Set;for(let i of e){let e=t(i);if(r.has(e))throw Error(`Compiled ${n} "${e}" is declared more than once.`);r.add(e)}}function withDiagnosticsSummary(e,t){return e.map(e=>(e.configResolver,{...e,agent:{...e.agent,diagnosticsSummary:t}}))}function expectSubagentDescription(e,t){if(e.description===void 0||e.description.trim().length===0)throw Error(`Subagent "${t.logicalPath}" must define a non-empty description.`);return e.description}function createCompiledRemoteAgent(e){let t=e.source.logicalPath.endsWith(`.ts`)||e.source.logicalPath.endsWith(`.js`)?e.source.logicalPath:posix.join(e.source.logicalPath,`agent.ts`),n=e.source.sourceId,r={backing:e.binding.backing,logicalPath:t,owner:e.owner,usage:e.binding.usage},i={backing:{kind:`resource`,sourcePath:e.source.entryPath},binding:r,description:e.definition.description,entryPath:e.source.entryPath,logicalPath:t,name:e.source.subagentId,nodeId:e.nodeId,owner:e.owner,parentNodeId:e.parentNodeId,path:e.definition.path,rootPath:e.source.rootPath,sourceId:n,sourceKind:`module`};return e.sourceRef.exportName!==void 0&&Object.assign(i,{exportName:e.sourceRef.exportName}),e.definition.outputSchema!==void 0&&Object.assign(i,{outputSchema:e.definition.outputSchema}),e.definition.url!==void 0&&Object.assign(i,{url:e.definition.url}),i}function compileExtensionMounts(e,t){let n=collectSelectedSourceIds(t);return e.resolvedExtensions.flatMap(t=>{let r=e.extensions.find(e=>mountRefNamespace(e.logicalPath)===t.namespace);return r===void 0||!n.has(r.sourceId)?[]:[{externalDependencies:[...t.externalDependencies],mountLogicalPath:r.logicalPath,mountSourceId:r.sourceId,namespace:t.namespace,packageName:t.packageName,packageNamespace:packageStateNamespace(t.packageName),sourceRoot:t.sourceRoot}]})}function mergeExternalDependencies(...e){return[...new Set(e.flatMap(e=>e??[]))]}export{assertApplicationOverlayCanApplyToAllNodes,assertNonExtensionSpecialTool,assertRootOnlyConfig,assertRootOwnedSpecialTool,assertUniqueBy,assertUniqueRegistryIds,collectSelectedSourceIds,compileExtensionMounts,createCompiledRemoteAgent,expectSubagentDescription,mergeExternalDependencies,withDiagnosticsSummary,withExtensionNamespace};