eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.46 kB
JavaScript
import{createLogger,logError}from"#internal/logging.js";import{toError}from"#shared/errors.js";import{startWorkflowOnCurrentDeployment,workflowToolRunWorkflowReference}from"#execution/workflow-runtime.js";import{registerWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.workflow-tool-run`);async function startWorkflowToolRun(e){let t=crypto.randomUUID();return{hookToken:t,runId:(await startWorkflowOnCurrentDeployment(workflowToolRunWorkflowReference,[{...e,hookToken:t}])).runId}}async function startWorkflowTask(e){let{task:t,batchEvent:n,session:r}=e;try{let i=await startWorkflowToolRun({agents:e.agents,callId:t.callId,canRequestInput:e.canRequestInput,executeInput:t.executeInput,input:t.input,owner:e.owner,session:{auth:{current:e.auth,initiator:e.initiatorAuth},id:r.sessionId,parent:e.parentSession,turn:{id:n.turnId,sequence:n.sequence}},stepIndex:n.stepIndex,toolName:t.toolName,workflowId:t.workflowId});return{session:registerWorkflowToolRun(r,{callId:t.callId,lifetime:`turn`,origin:{turnId:n.turnId,stepIndex:n.stepIndex},address:i,toolName:t.toolName})}}catch(e){return logError(log,`workflow tool run failed to start`,e,{callId:t.callId,toolName:t.toolName}),{result:createRuntimeToolResultFromValue({callId:t.callId,isError:!0,output:toError(e),toolName:t.toolName}),session:r}}}export{startWorkflowTask,startWorkflowToolRun};