import { type TurnOutcome } from "../../agent/turn-outcome.js"; import type { ChatMessage, SuccessfulRequestSnapshot } from "../../types.js"; import { type SessionPolicy } from "../../agent/session-policy.js"; import { type AnyAppEvent, type TurnId } from "../events/app-event.js"; import type { EventSequencer } from "../events/sequencer.js"; import type { OutputSpool } from "../events/event-buffer.js"; import type { AgentPort, RunTurnRequest } from "../ports/agent-port.js"; import type { ConfirmationPort } from "../ports/confirm-port.js"; import type { SecretPort } from "../ports/secret-port.js"; import type { Disposable } from "./disposable.js"; export type TurnResult = { readonly status: "completed"; readonly turnId: TurnId; readonly outcome: TurnOutcome; readonly finalAnswer: string; } | { readonly status: "aborted"; readonly turnId: TurnId; } | { readonly status: "error"; readonly turnId: TurnId; readonly error: Error; }; export interface TurnRunOptions { readonly confirm?: ConfirmationPort | undefined; readonly requestSecret?: SecretPort["request"] | undefined; readonly session?: SessionPolicy | undefined; readonly onMessages?: ((messages: ChatMessage[]) => void) | undefined; readonly onSuccessfulRequest?: ((snapshot: SuccessfulRequestSnapshot) => void) | undefined; readonly onStarted?: (() => void) | undefined; readonly signal?: AbortSignal | undefined; } export interface TurnControllerDeps { readonly agent: AgentPort; readonly sequencer: EventSequencer; readonly spool: OutputSpool; readonly emit: (event: AnyAppEvent) => void; readonly mintTurnId?: (() => TurnId) | undefined; } export declare class TurnController implements Disposable { private readonly deps; private ac; private active; private disposed; private abortReason; constructor(deps: TurnControllerDeps); get running(): boolean; abort(reason?: string): void; run(request: RunTurnRequest, options?: TurnRunOptions): Promise; dispose(): void; }