UNPKG

eve

Version:

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

1 lines 1.75 kB
import{createLogger,logError}from"#internal/logging.js";import{ContextContainer,contextStorage}from"#context/container.js";import{toErrorMessage}from"#shared/errors.js";import{createWorkflowRuntime,waitForCommandHookOwner}from"#execution/workflow-runtime.js";import{buildSubagentRunInput}from"#subagents/tool.js";import{SUBAGENT_START_FAILED}from"#subagents/agent-handle-errors.js";const log=createLogger(`execution.subagent-start-local`);async function startLocalSubagent(e){let{action:t,source:n}=e,r=createWorkflowRuntime({compiledArtifactsSource:e.bundle.compiledArtifactsSource,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,nodeId:t.nodeId}),{childContinuationToken:i,runInput:a}=buildSubagentRunInput({action:t,auth:e.auth,capabilities:e.capabilities,channelMetadata:e.channelMetadata,fanoutSize:e.fanoutSize,initiatorAuth:e.initiatorAuth,graph:e.bundle.graph,parent:e.parent,activityObserver:e.activityObserver,sandboxSessionId:e.sandboxSessionId,session:e.session,selfAgent:n.type===`runtime`,source:n,taskId:e.taskId}),o=n.type===`runtime`?`agent/self`:`agent/local`,s;try{await contextStorage.run(new ContextContainer({localDevRequest:e.localDevRequest}),()=>r.createSession(a)),s=(await waitForCommandHookOwner(i)).runId}catch(n){return logError(log,`local subagent start failed`,n,{callId:t.callId,nodeId:t.nodeId,subagentName:t.subagentName}),{kind:`error`,result:{callId:t.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:SUBAGENT_START_FAILED,message:toErrorMessage(n)},subagentName:t.subagentName},session:e.currentSession}}return{address:{continuationToken:i,kind:o,sessionId:s},callId:t.callId,kind:`called`,name:t.name,session:e.currentSession,toolName:t.subagentName}}export{startLocalSubagent};