UNPKG

eve

Version:

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

1 lines • 1.06 kB
import{readDurableSession}from"#execution/durable-session-store.js";import{findBackgroundWorkflowToolRun,readWorkflowTaskView}from"#harness/workflow-tool-runs.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import"#tasks/types.js";async function acceptTaskAuthorizationEventStep(e){"use step";let{hookPayload:t,taskId:n}=e.delivery,r=readDurableSession(e.sessionState),i=findBackgroundWorkflowToolRun(r.state,n);if(i===void 0)return!1;if(i.task.metadata.kind===`tool`&&i.address.runId===t.childSessionId&&i.task.metadata.name===t.subagentName&&i.origin.turnId===t.event.data.turnId){let e=readWorkflowTaskView(i.task);return t.event.type===`authorization.completed`||e===void 0}let a=getAgentHandleStore(r.state)?.handles??[],o=a.find(e=>e.phase===`claimed`&&e.ownerId===n&&e.identity.name===t.subagentName&&e.address.sessionId===t.childSessionId),s=a.filter(e=>e.phase===`reserved`&&e.ownerId===n&&e.identity.name===t.subagentName);return o===void 0&&s.length!==1?!1:readWorkflowTaskView(i.task)===void 0}export{acceptTaskAuthorizationEventStep};