UNPKG

eve

Version:

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

34 lines (33 loc) • 1.42 kB
import type { TurnCaller } from "#channel/types.js"; import type { DurableSessionState } from "#execution/durable-session-store.js"; import type { TurnOutcome } from "#execution/session/turn-step-types.js"; import type { WorkflowEntryResult } from "#execution/session/entry-input.js"; import type { RunMode } from "#shared/run-mode.js"; /** The three ways a session ends. `done` already emitted its terminal event inside the turn. */ export type SessionTerminalOutcome = { readonly kind: "done"; readonly action: TurnOutcome & { readonly kind: "done"; }; } | { readonly kind: "expired"; } | { readonly kind: "failed"; readonly error: unknown; readonly turnId?: string; }; export interface SessionFinalizationContext { readonly caller: TurnCaller | undefined; readonly cursor: { readonly serializedContext: Record<string, unknown>; readonly sessionState: DurableSessionState | undefined; }; readonly mode: RunMode; readonly sessionWritable: WritableStream<Uint8Array>; } /** * Terminates descendants, emits the terminal protocol event when the turn has * not already done so, then settles whoever is waiting on this session: the * task callback and delegated parent in task mode, or the parked caller. */ export declare function finalizeSession(outcome: SessionTerminalOutcome, context: SessionFinalizationContext): Promise<WorkflowEntryResult>;