UNPKG

eve

Version:

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

1 lines 823 B
import{createHook}from"#compiled/@workflow/core/index.js";import{isWorkflowToolRunControlMessage}from"#execution/tools/workflow/messages.js";function openWorkflowToolRunControlInbox(e){let t=createHook({token:e})[Symbol.asyncIterator](),n=new AbortController,r,i=consumeCancel(t,e=>{r=e,n.abort(new WorkflowToolRunCancelledError(e))});return i.catch(()=>{}),{cancelled:i,reason:()=>r,signal:n.signal}}async function consumeCancel(e,t){for(;;){let n=await e.next();if(n.done===!0)return await new Promise(()=>{});if(isWorkflowToolRunControlMessage(n.value))throw t(n.value.reason),new WorkflowToolRunCancelledError(n.value.reason)}}var WorkflowToolRunCancelledError=class extends Error{constructor(e){super(e),this.name=`WorkflowToolRunCancelledError`}};export{WorkflowToolRunCancelledError,openWorkflowToolRunControlInbox};