import type { ModelMessage } from "ai"; import type { SessionAuthContext } from "#channel/types.js"; import type { SessionStateMap, StepInput } from "#harness/types.js"; import type { RuntimeWorkflowTaskRequest } from "#shared/action-types.js"; import type { InputRequest } from "#shared/input.js"; /** The coordinates of the model step a suspended step parked from. */ export interface StepCoordinates { readonly sequence: number; readonly stepIndex: number; readonly turnId: string; } /** * A model step whose calls can't all settle yet: some await an approval, others the runtime. * Its response stays out of history until every call it made has a result there, so a call * never reaches the model without its result. */ export interface SuspendedStep { readonly event: StepCoordinates; /** The withheld response. Results join it as they arrive. */ readonly messages: readonly ModelMessage[]; /** Approvals the step still waits on. */ readonly requests: readonly InputRequest[]; /** * Calls a person approved that haven't run. They run when the turn next calls the model, after * its step starts and its budget allows it, as calls the model makes do. */ readonly approved?: readonly InputRequest[]; /** Workflow and agent calls the runtime runs for the step. */ readonly tasks: readonly RuntimeWorkflowTaskRequest[]; /** Who approved each task an approval started, by call id: the task runs as them. */ readonly approvers?: Readonly>; readonly responseAuthRequiredRequestIds?: readonly string[]; /** The caller whose turn parked the step; `null` when unauthenticated. */ readonly requester?: SessionAuthContext | null; } export interface TurnState { /** Input that arrived before it could run: a partial answer, or input behind a policy pass. */ readonly queued?: StepInput; readonly suspended: readonly SuspendedStep[]; /** Approval keys a `once()` approval granted for the rest of the session. */ readonly grants: readonly string[]; } export declare const EMPTY_TURN_STATE: TurnState; export declare function readTurnState(state: SessionStateMap | undefined): TurnState; export declare function writeTurnState(session: T, turn: TurnState): T;