UNPKG

eve

Version:

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

1 lines 1.82 kB
import{getRuntimeActionRequestKey}from"#runtime/actions/keys.js";const WORKFLOW_RUNTIME_ACTION_INTERRUPT_KIND=`eve.workflow-runtime-action`;function isWorkflowRuntimeActionInterrupt(e){return isRecord(e)&&isRecord(e.payload)&&e.payload.kind===`eve.workflow-runtime-action`}function buildRuntimeActionFromWorkflowInterrupt(e){let t=e.payload,n=t.runtimeAction,r=t.toolInput,i=t.toolName,a=sanitizeCallId(`${i}_${`interruptId`in e?String(e.interruptId):``}`);return n.kind===`remote-agent-call`?{callId:a,description:``,input:r,kind:`remote-agent-call`,name:i,nodeId:n.nodeId,remoteAgentName:n.remoteAgentName??i}:{callId:a,description:``,input:r,kind:`subagent-call`,name:i,nodeId:n.nodeId,subagentName:n.subagentName}}function getWorkflowRuntimeActionInterrupts(e){return e.continuation.ledger.flatMap(t=>t.kind!==`tool`||t.status!==`interrupted`||t.interruptPayload.kind!==`eve.workflow-runtime-action`?[]:[{continuation:e.continuation,input:t.inputJson===``?void 0:JSON.parse(t.inputJson),interruptId:t.interruptId,outerToolCallId:e.continuation.outerToolCallId,payload:t.interruptPayload,toolCallId:t.toolCallId,toolName:t.name,type:`code-mode-interrupt`}])}function buildRuntimeActionsFromWorkflowInterrupt(e){return getWorkflowRuntimeActionInterrupts(e).map(e=>buildRuntimeActionFromWorkflowInterrupt(e))}function getRuntimeActionKeysFromWorkflowInterrupt(t){return buildRuntimeActionsFromWorkflowInterrupt(t).map(getRuntimeActionRequestKey)}function sanitizeCallId(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{WORKFLOW_RUNTIME_ACTION_INTERRUPT_KIND,buildRuntimeActionFromWorkflowInterrupt,buildRuntimeActionsFromWorkflowInterrupt,getRuntimeActionKeysFromWorkflowInterrupt,getWorkflowRuntimeActionInterrupts,isWorkflowRuntimeActionInterrupt};