UNPKG

eve

Version:

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

1 lines 797 B
import{loadContext}from"#context/container.js";import{ContextKey}from"#context/key.js";const BackgroundToolExecutorKey=new ContextKey(`eve.internal.backgroundToolExecution`);function createBackgroundToolCallBatch(){let e=[],t=new Map,n=new Map;return{calls:e,register(r){let i=n.get(r.toolName);if(i===void 0)return;let a=t.get(r.callId);if(a?.definition===i)return;if(a!==void 0)throw Error(`Background tool call "${r.callId}" was registered more than once.`);let o={callId:r.callId,definition:i,input:r.input};t.set(r.callId,o),e.push(o)},setTool(e,t){t===void 0?n.delete(e):n.set(e,t)}}}async function executeBackgroundToolCall(e){return await loadContext().require(BackgroundToolExecutorKey).execute(e)}export{BackgroundToolExecutorKey,createBackgroundToolCallBatch,executeBackgroundToolCall};