UNPKG

eve

Version:

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

1 lines 902 B
import{walkCauseChain}from"#shared/errors.js";import{cancelRun,getWorld}from"#internal/workflow/runtime.js";import{EntityConflictError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{resumeSessionInbox}from"#execution/session-inbox/resume.js";async function settleContinuationConflictStep(e){"use step";try{e.command!==void 0&&await resumeSessionInbox(e.continuationToken,e.command)}finally{e.activityCollectorRunId!==void 0&&await cancelCollector(e.activityCollectorRunId)}}async function cancelCollector(e){try{await cancelRun(await getWorld(),e,{cancelReason:`Session candidate did not acquire continuation ownership`})}catch(e){if(!isInactiveRun(e))throw e}}function isInactiveRun(e){for(let t of walkCauseChain(e))if(WorkflowRunNotFoundError.is(t)||RunExpiredError.is(t)||EntityConflictError.is(t))return!0;return!1}export{settleContinuationConflictStep};