import type { ModelMessage } from "ai"; import { type AuthorizationChallenge } from "#harness/authorization.js"; import type { HarnessSessionBase, SessionStateMap } from "#harness/types.js"; import type { UnstampedMessageStreamEvent } from "#protocol/message.js"; import type { SessionProjection } from "#protocol/session-projection.js"; import { type TurnState } from "./state.js"; import type { SessionView } from "./view.js"; /** What a transition returns. Nothing else changes session state. */ export interface Transition { readonly turn: TurnState; readonly events: readonly UnstampedMessageStreamEvent[]; /** Messages the transition commits to the end of history. */ readonly commit?: readonly ModelMessage[]; /** The transition empties history, as `clear` does. */ readonly clearsHistory?: true; /** Every sign-in the session waits on once the transition applies; `[]` withdraws them all. */ readonly signIns?: readonly AuthorizationChallenge[]; } /** Publishes one event; `messages` is the conversation hooks see with it. */ export type Publish = (event: UnstampedMessageStreamEvent, messages?: readonly ModelMessage[]) => Promise; export declare function sessionView(projection: SessionProjection, state: SessionStateMap | undefined): SessionView; /** * Publishes a transition's events, then saves what it changed. A transition that changes history * needs a session restored with it. */ export declare function applyTransition(session: T, transition: Transition, publish: Publish, messages?: readonly ModelMessage[]): Promise; /** Drops the private records whose owner the projection shows closed. */ export declare function dropClosedRecords(session: T, projection: SessionProjection): T;