import type { ContextReader } from "#context/key.js"; import type { HarnessSessionBase, SessionStateMap } from "#harness/types.js"; import { type SessionProjection } from "#protocol/session-projection.js"; import type { MessageStreamEvent, UnstampedMessageStreamEvent } from "#protocol/message.js"; export declare function enterSessionProjection(ctx: ContextReader, state: SessionStateMap | undefined): void; /** Enters the stored projection unless this step already did. */ export declare function ensureSessionProjection(ctx: ContextReader, state: SessionStateMap | undefined): void; /** The projection as of the last event the current step published. */ export declare function currentProjection(ctx?: ContextReader | undefined): SessionProjection; /** The step's live projection, or the session's stored one when no step entered it. */ export declare function projectionFor(ctx: ContextReader, state: SessionStateMap | undefined): SessionProjection; export declare function recordPublishedEvent(ctx: ContextReader, event: MessageStreamEvent | UnstampedMessageStreamEvent): void; /** Records the session a transition the step published produced. */ export declare function recordAppliedSession(ctx: ContextReader, session: HarnessSessionBase): void; /** The session the step's last applied transition produced, if it applied any. */ export declare function appliedSession(ctx: ContextReader): T | undefined; export declare function saveSessionProjection(session: T, ctx: ContextReader): T; /** * The session saves the lifecycle its steps read. Calls and tasks are for the stream's readers, * which fold them from the events, and their outputs can be large, so the checkpoint omits them. */ export declare function saveProjection(session: T, projection: SessionProjection): T; /** The projection one step reads and folds what it publishes into. */ export interface StepProjection { read(): SessionProjection; /** Folds an event no publish sink folded: the step runs without one. */ record(event: UnstampedMessageStreamEvent): void; } /** * A step's projection: the context's live one, which the publish sink folds, or, for a step * that runs without a context, a detached one the step folds itself. */ export declare function stepProjection(ctx: ContextReader | undefined, state: SessionStateMap | undefined): StepProjection;