/** * Turn state machine. Models the lifecycle of a single agent turn within a session. * * Sibling of `session-machine.ts`. Keeping them separate (rather than nesting * turn state inside session state) matches t3code's split. */ import type { TurnState } from "../contracts/provider-runtime.js"; export type TurnEvent = { type: "begin"; } | { type: "complete"; } | { type: "fail"; reason: string; } | { type: "cancel"; }; export interface TurnTransition { readonly from: TurnState; readonly to: TurnState; readonly event: TurnEvent; readonly at: string; } export declare function nextTurnState(current: TurnState, event: TurnEvent): TurnState; export declare function canTransition(current: TurnState, event: TurnEvent): boolean; export declare function isTerminal(state: TurnState): boolean; export declare class TurnMachine { private state; private readonly history; constructor(initial?: TurnState); current(): TurnState; send(event: TurnEvent): TurnTransition; log(): readonly TurnTransition[]; }