eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
40 lines (39 loc) • 2.07 kB
TypeScript
import type { TurnCaller } from "#channel/types.js";
import type { DurableSessionState } from "#execution/durable-session-store.js";
/**
* Write-through cell owned by `workflowEntry`: written
* unconditionally by the driver loop as turns advance, read only by the
* outer catch. When the loop throws, its locals are unreachable, so this
* cell is the crash path's only view of values that changed after turn 1.
*
* Reach for this cell only when all three hold for a value:
* 1. it is produced or replaced inside the driver loop, so the entry
* function's own locals go stale;
* 2. it travels by value inside Workflow step results — there is no
* store the catch could re-read it from at crash time;
* 3. the crash path needs its latest value to discharge a cleanup
* obligation.
* If any of the three fails, read the value from where it already lives
* instead of mirroring it here.
*/
export interface CrashCleanupState {
caller: TurnCaller | undefined;
callerResolved: boolean;
lastSessionState: DurableSessionState | undefined;
serializedContext: Record<string, unknown>;
terminalEmitted: boolean;
turnId?: string;
}
export declare function hasDelegatedCallerContext(serializedContext: Record<string, unknown>): boolean;
/**
* Caller to reject from the crash path. Normally the resolved cell value —
* including `undefined` after a settled reply cleared it, when there is
* nothing left to notify. When the crash happened before
* `resolveInitialTurnCallerStep` ever ran (e.g. `createSessionStep` threw),
* the cell is empty even though a delegated caller may be parked on this
* session's reply, so the caller is re-resolved from the serialized context
* — which needs nothing from the failed steps. Best-effort: when resolution
* fails again there is no reachable caller to notify.
*/
export declare function resolveCallerForCrash(state: CrashCleanupState, serializedContext: Record<string, unknown>): Promise<TurnCaller | undefined>;
export declare function createSafeOuterWorkflowError(): Error;