import type { ExecutorKind } from "./executors.js"; import type { TerminalRuntimeIdentity, TerminalScreenInspection } from "./terminal-agent-adapter.js"; import { type TerminalControlProvider } from "./terminal-control-provider.js"; import { type TerminalControlEvidence, type TerminalControlRef } from "./terminal-control-ref.js"; import { type TerminalInteractionAnswer, type TerminalInteractionDeliveryMode, type TerminalInteractionSubject, type TerminalInteractionSubjectProjection, type TerminalInteractionSubjectResponse } from "./terminal-interaction-protocol.js"; import { type NativeTerminalInteractionActionPlan, type NativeTerminalInteractionInspection } from "./terminal-interaction-core.js"; import { type CodexAsyncQuestionDurableEvidence } from "./codex-async-question-adapter.js"; export type TerminalInteractionReservedStage = "reservation_uncertain" | "text_uncertain" | "key_uncertain"; /** * A response reservation or terminal input may already have happened. The * same interaction must never be dispatched automatically after this error. */ export declare class TerminalInteractionDispatchReservedError extends Error { readonly stage: TerminalInteractionReservedStage; readonly code = "AKK_TERMINAL_INTERACTION_DISPATCH_RESERVED"; readonly doNotRetry = true; constructor(stage: TerminalInteractionReservedStage, message: string, options?: { cause?: unknown; }); } /** * A durable response reservation exists, but the bridge proved that no * terminal text or key delivery was attempted. The caller must discard the * one-shot offer and obtain a fresh status projection before trying again. */ export declare class TerminalInteractionInputNotStartedError extends Error { readonly code = "AKK_TERMINAL_INTERACTION_INPUT_NOT_STARTED"; readonly stage = "input_not_started"; readonly doNotRetry = true; readonly requiresFreshOffer = true; constructor(message: string, options?: { cause?: unknown; }); } export interface TerminalInteractionAuthorizationContext { agent: ExecutorKind; terminalControl: TerminalControlRef; fingerprint: string; projection: TerminalInteractionSubjectProjection; response: TerminalInteractionSubjectResponse; runtime?: TerminalRuntimeIdentity; } export interface TerminalInteractionAuthorizationDecision { approved: boolean; reason?: string; } export interface TerminalInteractionBeforeDispatchContext { agent: ExecutorKind; terminalControl: TerminalControlRef; fingerprint: string; projection: TerminalInteractionSubjectProjection; response: TerminalInteractionSubjectResponse; runtime?: TerminalRuntimeIdentity; } export interface TerminalInteractionResponseExecution { responded: boolean; blocked: boolean; reason?: string; interactionId: string; questionId?: string; responseKind?: TerminalInteractionAnswer["response_kind"]; outcome?: "submitted_or_advanced" | "custom_text_opened" | "confirmed" | "cancelled"; } /** Input is validated against the freshly recaptured v1/v2 projection. */ export type TerminalInteractionResponseInput = { readonly interaction_id: string; readonly turn_id?: string; readonly subject?: TerminalInteractionSubject; readonly answers: readonly TerminalInteractionAnswer[]; readonly delivery_mode?: TerminalInteractionDeliveryMode; }; export interface TerminalInteractionResponseOptions { agentVersion: string; expectedFingerprint: string; expectedExpiresAt: string; scrollbackLines?: number; runtime?: TerminalRuntimeIdentity; authorize?: (context: TerminalInteractionAuthorizationContext) => TerminalInteractionAuthorizationDecision | Promise; /** * Resolve only after the caller has durably persisted its one-shot * dispatch receipt. A successful return is the offer lease acceptance * boundary for the final read-only recapture. */ beforeDispatch?: (context: TerminalInteractionBeforeDispatchContext) => void | Promise; } export interface TerminalInteractionRuntimeOffer { readonly projection: TerminalInteractionSubjectProjection; readonly promptFingerprint: string; readonly surfaceId: string; readonly actionPlan: NativeTerminalInteractionActionPlan; readonly nativeInspection: Exclude; } interface TerminalInteractionCapture { readonly terminalControl: TerminalControlRef; readonly screen: string; readonly inspection: TerminalScreenInspection; } interface TerminalInteractionResponseRuntime { captureInspection: (agent: ExecutorKind, terminalControl: TerminalControlRef, runtime: TerminalRuntimeIdentity, scrollbackLines?: number) => Promise; verifyIdentity: (agent: ExecutorKind, terminalControl: TerminalControlRef, runtime: TerminalRuntimeIdentity) => Promise; now: () => Date; sleep: (milliseconds: number) => Promise; /** Testable exact-rollout evidence seam; production uses the safe reader. */ captureCodexAsyncQuestionEvidence?: (runtime: TerminalRuntimeIdentity) => readonly CodexAsyncQuestionDurableEvidence[] | undefined; } /** * Executes only a closed questionnaire action plan. Store mutation, terminal * locking, and the caller's at-most-once ledger remain outside this service. */ export declare class TerminalInteractionResponseBridge { private readonly terminalProvider; private readonly runtime; constructor(terminalProvider: TerminalControlProvider, runtime: TerminalInteractionResponseRuntime); respond(agent: ExecutorKind, terminalControl: TerminalControlRef, response: TerminalInteractionResponseInput, options: TerminalInteractionResponseOptions): Promise; private captureOffer; private dispatchAsyncQuestionAnswer; private captureAfterAsyncQuestionInput; private openAsyncQuestionEditor; private verifyAsyncQuestionFreeTextEditor; private verifyAsyncQuestionInjectedText; private verifyAsyncQuestionAnswerPostcondition; } interface TerminalInteractionRuntimeCaptureInput { agent: ExecutorKind; terminalControl: TerminalControlRef; screen: string; runtime?: TerminalRuntimeIdentity; now: Date; approvalBlocked?: boolean; /** Exact durable Watch endpoint evidence for legacy provider refs. */ trustedTerminalEvidence?: TerminalControlEvidence; /** Internal exact-rollout evidence seam; never part of a public tool. */ codexAsyncQuestionEvidence?: readonly CodexAsyncQuestionDurableEvidence[]; } export declare function captureTerminalInteractionRuntimeOffer(input: TerminalInteractionRuntimeCaptureInput): TerminalInteractionRuntimeOffer | undefined; export declare function exactCurrentModelControlSurface(agent: ExecutorKind, agentVersion: string | undefined, screen: string): boolean; export {};