eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.45 kB
JavaScript
import{UNSPECIFIED_INPUT_SCHEMA,toInputSchema,toOutputSchema}from"#tools/schema.js";import{parseJsonObject}from"#shared/json.js";function createWorkflowToolHarnessDefinition(e){let t=e.definition,n={executeInput:e.executeInput,nodeId:e.nodeId,resultKind:e.resultKind,workflowId:e.workflowId};return t.execution===`background`?{...t,...n,execute:createWorkflowToolBackgroundExecute({toolName:t.name,workflowId:e.workflowId})}:{...t,...n,execute:void 0}}function createPreparedWorkflowToolHarnessDefinition(e){if(e.task===void 0)throw Error(`Prepared tool "${e.name}" is not backed by a workflow task.`);return createWorkflowToolHarnessDefinition({definition:{behavior:e.behavior,description:e.description,execution:e.execution,inputSchema:toInputSchema(e.inputSchema)??UNSPECIFIED_INPUT_SCHEMA,name:e.name,outputSchema:toOutputSchema(e.outputSchema),rootOnly:e.rootOnly},nodeId:e.task.nodeId,resultKind:e.task.resultKind,workflowId:e.task.workflowId})}function createWorkflowToolBackgroundExecute(e){return(t,n,r)=>{throw Error(`Background workflow tool "${e.toolName}" must be started by the task runtime (${e.workflowId}).`)}}function parseWorkflowToolInput(e,t){try{return parseJsonObject(e)}catch(e){throw TypeError(`Tool "${t}" is a workflow, so its parsed input must be a JSON object.`,{cause:e})}}export{createPreparedWorkflowToolHarnessDefinition,createWorkflowToolBackgroundExecute,createWorkflowToolHarnessDefinition,parseWorkflowToolInput};