UNPKG

eve

Version:

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

1 lines 1.6 kB
import{WORKFLOW_TASK_INTERRUPT_KIND}from"#harness/workflow-task-state.js";const PENDING_KEY=`eve.harness.pendingWorkflowInterrupt`;function getPendingWorkflowInterrupt(e){let t=e?.[PENDING_KEY];if(isRecord(t)&&isWorkflowInterruptShape(t.interrupt)&&Array.isArray(t.responseMessages)&&!(!Number.isSafeInteger(t.usedCalls)||t.usedCalls<0))return{interrupt:t.interrupt,responseMessages:t.responseMessages,usedCalls:t.usedCalls}}function setPendingWorkflowInterrupt(e){return{...e.session,state:{...e.session.state,[PENDING_KEY]:{interrupt:e.interrupt,responseMessages:e.responseMessages,usedCalls:e.usedCalls}}}}function setPendingWorkflowUsedCalls(e){let t=getPendingWorkflowInterrupt(e.session.state);return t===void 0?e.session:setPendingWorkflowInterrupt({...t,session:e.session,usedCalls:e.usedCalls})}function clearPendingWorkflowInterrupt(e){if(e.state?.[PENDING_KEY]===void 0)return e;let t={...e.state};return delete t[PENDING_KEY],{...e,state:Object.keys(t).length>0?t:void 0}}function isWorkflowInterruptShape(e){return isRecord(e)&&e.type===`code-mode-interrupt`&&typeof e.interruptId==`string`&&typeof e.outerToolCallId==`string`&&isRecord(e.payload)&&e.payload.kind===WORKFLOW_TASK_INTERRUPT_KIND&&isRecord(e.continuation)&&e.continuation.version===2&&typeof e.continuation.outerToolCallId==`string`&&Array.isArray(e.continuation.pendingInterruptions)&&Array.isArray(e.continuation.resolutions)}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{clearPendingWorkflowInterrupt,getPendingWorkflowInterrupt,setPendingWorkflowInterrupt,setPendingWorkflowUsedCalls};