UNPKG

eve

Version:

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

1 lines 1.22 kB
import{createRuntimeToolCallActionFromToolCall}from"#harness/input-requests.js";import{ASK_QUESTION_TOOL_NAME}from"#runtime/framework-tools/ask-question.js";function extractQuestionInputRequests(n){let r=[];for(let i of n.toolCalls){if(i.toolName!==ASK_QUESTION_TOOL_NAME||n.excludedCallIds.has(i.toolCallId))continue;let a=createRuntimeToolCallActionFromToolCall({toolCall:i}),o=a.input,s={action:a,display:`text`,prompt:String(o.prompt),requestId:a.callId};o.allowFreeform!==void 0&&(s.allowFreeform=o.allowFreeform),o.options!==void 0&&(s.options=o.options,s.display=`select`),r.push(s)}return r}function extractToolApprovalInputRequests(t){let n=[],r=new Map;for(let e of t.content)e.type===`tool-call`&&r.set(e.toolCallId,e);for(let i of t.content){if(i.type!==`tool-approval-request`)continue;let t=i,a=t.toolCall??(t.toolCallId===void 0?void 0:r.get(t.toolCallId));if(a===void 0)continue;let o=createRuntimeToolCallActionFromToolCall({toolCall:a});n.push({action:o,allowFreeform:!1,display:`confirmation`,options:[{id:`approve`,label:`Yes`},{id:`deny`,label:`No`}],prompt:`Approve tool call: ${a.toolName}`,requestId:t.approvalId})}return n}export{extractQuestionInputRequests,extractToolApprovalInputRequests};