UNPKG

eve

Version:

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

1 lines 1.17 kB
import{isObject}from"#shared/guards.js";import{parseJsonValue}from"#shared/json.js";import{buildCallbackContext}from"#context/build-callback-context.js";async function resolveProvidedArguments(e){if(!isObject(e.args))throw Error(`Tool "${e.toolName}" in connection "${e.connection.connectionName}" expected object arguments.`);let t=e.connection.toolCall?.providedArguments;if(t===void 0||Object.keys(t).length===0)return e.args;let n,getContext=()=>n??={...buildCallbackContext(),callId:e.callId,toolName:e.toolName},r={};for(let[n,i]of Object.entries(t)){let t=typeof i==`function`?await i(getContext()):await i;try{r[n]=parseJsonValue(t)}catch{throw Error(`Connection "${e.connection.connectionName}" provided argument "${n}" must resolve to a JSON-serializable value.`)}}return{...e.args,...r}}function omitProvidedArgumentsFromSchema(e,t){if(t.length===0)return e;let n=new Set(t),r={...e};return isObject(e.properties)&&(r.properties=Object.fromEntries(Object.entries(e.properties).filter(([e])=>!n.has(e)))),Array.isArray(e.required)&&(r.required=e.required.filter(e=>typeof e!=`string`||!n.has(e))),r}export{omitProvidedArgumentsFromSchema,resolveProvidedArguments};