UNPKG

eve

Version:

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

1 lines 1.37 kB
import{resolveToolCallInputObject}from"#harness/coordination.js";import{createPresentedRuntimeActionRequestFromToolCall}from"#harness/action-presentation.js";function isInvalidToolCall(e){return e.invalid===!0}function createInvalidToolCallInputError(e){let{toolCall:t}=e,n={type:`tool-error`,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input,error:e.error};return t.dynamic===!0&&(n.dynamic=!0),t.providerExecuted===!0&&(n.providerExecuted=!0),t.providerMetadata!==void 0&&(n.providerMetadata=t.providerMetadata),t.toolMetadata!==void 0&&(n.toolMetadata=t.toolMetadata),n}function resolveProviderToolCallRequest(e,t){try{return{request:createPresentedRuntimeActionRequestFromToolCall({toolCall:{...e,providerExecuted:!0,type:`tool-call`},tools:t})}}catch(t){if(!(t instanceof TypeError))throw t;return{toolError:createInvalidToolCallInputError({error:t,toolCall:{input:e.input,providerExecuted:!0,toolCallId:e.toolCallId,toolName:e.toolName,type:`tool-call`}})}}}function getInvalidToolCallInputError(e){let{toolCall:t}=e;if(!isInvalidToolCall(t))try{resolveToolCallInputObject(t.input,{callId:t.toolCallId,toolName:t.toolName});return}catch(e){if(e instanceof TypeError)return createInvalidToolCallInputError({error:e,toolCall:t});throw e}}export{createInvalidToolCallInputError,getInvalidToolCallInputError,isInvalidToolCall,resolveProviderToolCallRequest};