UNPKG

eve

Version:

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

1 lines 1.07 kB
const PENDING_KEY=`eve.harness.pendingCodeModeInterrupt`;function getPendingCodeModeInterrupt(t){let n=t?.[PENDING_KEY];if(isRecord(n)&&!(!isCodeModeInterruptShape(n.interrupt)||!Array.isArray(n.responseMessages)))return{interrupt:n.interrupt,responseMessages:n.responseMessages}}function setPendingCodeModeInterrupt(t){return{...t.session,state:{...t.session.state,[PENDING_KEY]:{interrupt:t.interrupt,responseMessages:t.responseMessages}}}}function clearPendingCodeModeInterrupt(t){if(t.state?.[PENDING_KEY]===void 0)return t;let n={...t.state};return delete n[PENDING_KEY],{...t,state:Object.keys(n).length>0?n:void 0}}function isCodeModeInterruptShape(e){return isRecord(e)&&e.type===`code-mode-interrupt`&&typeof e.interruptId==`string`&&typeof e.outerToolCallId==`string`&&isRecord(e.payload)&&typeof e.payload.kind==`string`&&isRecord(e.continuation)&&typeof e.continuation.outerToolCallId==`string`}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{clearPendingCodeModeInterrupt,getPendingCodeModeInterrupt,setPendingCodeModeInterrupt};