eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.78 kB
JavaScript
import{contextStorage}from"#context/container.js";import{TurnDeliveryIdsKey}from"#context/keys.js";import{serializeContext}from"#context/serialize.js";import{createDurableSessionState}from"#execution/durable-session-store.js";import{preserveSerializedSessionDynamicModelSelection}from"#context/serialized-dynamic-model-selection.js";import{preserveCancelledTurnMessage}from"#execution/cancelled-turn-message.js";import{readRetainedBackgroundToolResult}from"#execution/tasks/parent/tool-execution.js";import{preserveSerializedInstrumentationState}from"#instrumentation/state.js";import{preserveSerializedBackgroundTaskObservabilityState}from"#shared/serialized-observability-state.js";import{preserveSerializedAgentTraceState}from"#tracing/agent-trace-context-store.js";async function createCancelledModelCallBatchResult(e){let t=serializeContext(e.ctx),n=readRetainedBackgroundToolResult(e.ctx),r=n?.backgroundTaskSession??e.checkpoint?.result.backgroundTaskSession,i=n?.backgroundTasks??e.checkpoint?.result.backgroundTasks,a=r??e.checkpoint?.result.session??e.initialSession,o=e.checkpoint===void 0?await contextStorage.run(e.ctx,()=>preserveCancelledTurnMessage(a,e.stepInput)):a,s={...e.checkpoint?.serializedContext??e.beforeBatchContext,[TurnDeliveryIdsKey.name]:t[TurnDeliveryIdsKey.name]};return{action:`cancelled`,...r===void 0||i===void 0?{}:{backgroundTaskContext:preserveSerializedBackgroundTaskObservabilityState(e.beforeBatchContext,t,i),backgroundTaskState:createDurableSessionState({session:o}),backgroundTasks:i},serializedContext:preserveSerializedInstrumentationState(preserveSerializedAgentTraceState(preserveSerializedSessionDynamicModelSelection(s,t),t),t),sessionState:createDurableSessionState({session:o})}}export{createCancelledModelCallBatchResult};