UNPKG

eve

Version:

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

50 lines (49 loc) • 2.36 kB
import type { DeliverHookPayload, SessionCapabilities, TurnCaller } from "#channel/types.js"; import type { AgentWorkflowRetentionDefinition } from "#shared/agent-definition.js"; import type { RunMode } from "#shared/run-mode.js"; import type { DurableSessionState } from "#execution/durable-session-store.js"; import { type SessionInboxHandle } from "#execution/session-inbox/inbox.js"; import type { WorkflowEntryResult } from "#execution/session/entry-input.js"; /** * Who to tell when this owner exits. The original run anchors the public * stream itself; a successor signals the original run. A `self` anchor may * also name a `notify` step that runs with the final result, which lets an * importer settle whatever predecessor still holds the stream open. */ export type SessionAnchor = { readonly kind: "self"; readonly notify?: (result: WorkflowEntryResult) => Promise<void>; } | { readonly kind: "successor"; }; export interface SessionBoot { readonly anchor: SessionAnchor; readonly caller: TurnCaller | undefined; readonly capabilities?: SessionCapabilities; readonly deploymentId: string; readonly initialInput: DeliverHookPayload | undefined; /** Parks on the inbox before any session-scoped lifecycle work. */ readonly awaitFirstMessage: boolean; readonly mode: RunMode; readonly retention?: AgentWorkflowRetentionDefinition; readonly serializedContext: Record<string, unknown>; readonly sessionId: string; readonly sessionState: DurableSessionState; readonly sessionTimeoutDeadline?: Date; readonly sessionTimeoutMs: number | false; readonly sessionWritable: WritableStream<Uint8Array>; } /** Runs an already prepared owner against its session's existing stream. */ export declare function runPreparedSession(boot: SessionBoot, inbox: SessionInboxHandle): Promise<WorkflowEntryResult>; /** * Terminal path for a boot that failed before the session loop could run. * The caller is re-resolved from context because no turn ever bound it. */ export declare function failSession(input: { readonly error: unknown; readonly mode: RunMode; readonly serializedContext: Record<string, unknown>; readonly sessionId: string; readonly sessionState: DurableSessionState | undefined; readonly sessionWritable: WritableStream<Uint8Array>; }): Promise<never>;