UNPKG

eve

Version:

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

1 lines 1.83 kB
import{z}from"#compiled/zod/index.js";import{serializeInputSchema}from"#shared/tool-schema.js";import{RuntimeRegistry,RuntimeRegistryError}from"#internal/runtime-registry.js";const SUBAGENT_TOOL_INPUT_SCHEMA=z.strictObject({message:z.string().describe(`The message to send to the subagent. Provide all context the subagent needs to complete the task; the subagent does not see the parent's history.`),outputSchema:z.looseObject({}).describe(`Only provide a non-empty JSON Schema when the caller explicitly requests structured output; otherwise omit this field. The subagent must match a provided schema, and that structured output becomes the tool result.`).optional()}),SUBAGENT_TOOL_INPUT_JSON_SCHEMA=serializeInputSchema(SUBAGENT_TOOL_INPUT_SCHEMA);function createRuntimeSubagentRegistry(e){let t=[],r=new RuntimeRegistry(`subagent`,e.reservedToolNames??[]),i=new Map;for(let n of e.subagents){let e={logicalPath:n.logicalPath,sourceId:n.sourceId};if(i.has(n.nodeId))throw new RuntimeRegistryError(`subagent`,`Found multiple runtime subagents mapped to node id "${n.nodeId}".`,{...e,entryName:n.name});let a=createPreparedRuntimeSubagentTool(n),o={definition:n,prepared:a};r.register(n.name,o,{location:e,duplicateMessage:`Found multiple subagents named "${n.name}". Subagent names must be unique at runtime.`,reservedMessage:`Subagent "${n.name}" collides with another runtime-visible tool name.`}),t.push(a),i.set(n.nodeId,o)}return{preparedTools:t,subagentsByName:r.asMap(),subagentsByNodeId:i}}function createPreparedRuntimeSubagentTool(e){return{description:e.description,inputSchema:SUBAGENT_TOOL_INPUT_JSON_SCHEMA,kind:e.kind,logicalPath:e.logicalPath,name:e.name,nodeId:e.nodeId,outputSchema:e.kind===`remote`?e.outputSchema:void 0,sourceId:e.sourceId}}export{SUBAGENT_TOOL_INPUT_SCHEMA,createRuntimeSubagentRegistry};