import type { ExecutorKind } from "./executors.js"; import type { TerminalAgentAdapter, TerminalRuntimeIdentity, TerminalScreenInspection } from "./terminal-agent-adapter.js"; import type { TerminalControlRef } from "./terminal-control-ref.js"; import { type ClaudeInjectedPasteCapture } from "./claude-injected-paste-proof.js"; export declare const CODEX_PASTE_ENTER_SETTLE_MS = 121; export declare const CODEX_MULTILINE_SETTLE_POLL_MS = 30; export declare const CODEX_MULTILINE_STABLE_CAPTURES = 2; export declare const CODEX_EXACT_CANDIDATE_GRACE_CAPTURES = 8; export declare const CODEX_MULTILINE_SETTLE_SCROLLBACK_LINES = 240; /** A terminal send failed at a boundary that proves input never started. */ export declare class TerminalInputNotStartedError extends Error { readonly code = "AKK_TERMINAL_INPUT_NOT_STARTED"; constructor(message: string, options?: { cause?: unknown; }); } /** * Text is already in the terminal composer, but this bridge invocation proved * that it never called the Enter transport boundary. * * Callers may persist this as narrow recovery evidence. It says nothing about * whether the draft remains exact or whether a later human action submitted * it; those facts must be re-observed under the terminal lock. */ export declare class TerminalEnterDispatchNotAttemptedError extends Error { readonly code = "AKK_TERMINAL_ENTER_DISPATCH_NOT_ATTEMPTED"; readonly stage = "enter_not_attempted"; constructor(message: string, options?: { cause?: unknown; }); } /** * The caller's one-shot Enter reservation was invoked, so this recovery * attempt is permanently consumed even though C-m was not proven dispatched. */ export declare class TerminalEnterDispatchReservedError extends Error { readonly code = "AKK_TERMINAL_ENTER_DISPATCH_RESERVED"; readonly stage = "enter_reserved"; readonly doNotRetry = true; constructor(message: string, options?: { cause?: unknown; }); } export type TerminalTransportStage = "text_injected" | "enter_dispatched"; export interface TerminalTransportStageEvent { stage: TerminalTransportStage; agent: ExecutorKind; terminalControl: TerminalControlRef; multiline: boolean; } export interface TerminalSendBoundaryContext { agent: ExecutorKind; terminalControl: TerminalControlRef; multiline: boolean; text: string; } export interface TerminalSendOptions { runtime?: TerminalRuntimeIdentity; /** Runs after identity verification and immediately before text injection. */ beforeText?: (context: TerminalSendBoundaryContext) => void | Promise; /** Runs after exact composer/identity proof and immediately before Enter. */ beforeEnter?: (context: TerminalSendBoundaryContext) => void | Promise; /** Require the agent's exact stable composer proof even for a single-line send. */ requireExactComposerBeforeEnter?: boolean; /** * User-explicit managed-path guard. Recapture an exactly empty composer * immediately before the first text-delivery call so a stale list/preflight * observation can fall back without appending to a human draft. */ requireExactEmptyComposerBeforeText?: boolean; /** User-explicit physical Send may steer a mutable working composer. */ allowWorkingComposerForUserExplicit?: boolean; /** * User-explicit managed Send only: after an exactly empty pre-text * boundary has accepted the request, cross Codex's paste-suppression window * and dispatch Enter without using a rendered Composer proof as a veto. */ userExplicitEnterAfterTextWithoutComposerVeto?: boolean; /** * Retry-only authority from a preliminary exact-empty observation. After * `beforeText` reserves the attempt, the bridge independently recaptures the * same empty composer and then immediately makes its sole text-delivery call. */ requireExactEmptyComposerAfterBeforeText?: { preliminaryComposerDigest: string; }; /** * Awaited immediately after each irreversible transport boundary so the * caller can durably persist the exact proof level before continuing. */ onTransportStage?: (event: TerminalTransportStageEvent) => void | Promise; } export interface TerminalSendResult { stage: "enter_dispatched"; agent: ExecutorKind; terminalControl: TerminalControlRef; multiline: boolean; } interface TerminalCodexStableComposerObservationBase { terminalControl: TerminalControlRef; digest: string; stableCaptures: number; } type TerminalCodexObservedComposerState = "exact_draft" | "exact_empty" | "different_draft" | "working" | "approval_or_modal"; /** Closed, content-redacting observation of the current Codex composer. */ export type TerminalCodexComposerObservation = { [State in TerminalCodexObservedComposerState]: TerminalCodexStableComposerObservationBase & { state: State; }; }[TerminalCodexObservedComposerState] | { state: "identity_drift" | "unavailable"; reason: string; }; type TerminalCodexCapturedComposerState = TerminalCodexObservedComposerState; type TerminalCodexComposerSnapshot = { [State in TerminalCodexCapturedComposerState]: { state: State; terminalControl: TerminalControlRef; digest: string; }; }[TerminalCodexCapturedComposerState] | { state: "identity_drift"; reason: string; } | { state: "unavailable"; reason: string; /** A repaint may still materialize a classifiable live composer. */ retryable?: false; } | { state: "unavailable"; reason: string; retryable: true; terminalControl: TerminalControlRef; digest: string; }; type TerminalTextSubmissionPreflight = "send" | "send_with_composer" | "observe_composer"; interface CapturedTerminalInspection { terminalControl: TerminalControlRef; screen: string; inspection: TerminalScreenInspection; } export interface TerminalTextSubmissionRuntimePorts { preflight(terminalControl: TerminalControlRef, operation: TerminalTextSubmissionPreflight): void; verifyIdentity(agent: ExecutorKind, terminalControl: TerminalControlRef, runtime: TerminalRuntimeIdentity | undefined): Promise; captureInspection(adapter: TerminalAgentAdapter, terminalControl: TerminalControlRef, options: { runtime?: TerminalRuntimeIdentity; scrollbackLines?: number; }): Promise; captureStyled(terminalControl: TerminalControlRef): Promise; deliverText(terminalControl: TerminalControlRef, text: string): Promise; dispatchEnter(terminalControl: TerminalControlRef): Promise; nowMs(): number; sleep(milliseconds: number): Promise; } interface CodexComposerCapture { state: "exact_draft" | "exact_empty" | "different_draft"; digest: string; } export interface TerminalTextSubmissionClassifierPorts { sameIdentity(left: TerminalControlRef, right: TerminalControlRef): boolean; stripEscapes(screen: string): string; codexBlockingModalVisible(screen: string): boolean; inspectCodexAsyncQuestionInputMode(screen: string): "absent" | "collapsed" | "expanded" | "ambiguous"; currentCodexComposer(styledScreen: string, expectedText: string, allowOpaqueLargePastePlaceholder?: boolean, classifyOpaqueLargePasteAsDifferent?: boolean, exactSlashPopupRows?: readonly string[], allowStyledSlashPopupWithoutViewportPaint?: boolean, agentVersion?: string): CodexComposerCapture | undefined; exactTerminalComposer(agent: ExecutorKind, screen: string, expectedText: string): { digest: string; } | undefined; exactClaudeComposer(screen: string, expectedText: string): { digest: string; } | undefined; exactClaudeInjectedPastePlaceholder(screen: string, expectedText: string): ClaudeInjectedPasteCapture | undefined; } export interface CreateTerminalTextSubmissionBridgeInput { runtime: TerminalTextSubmissionRuntimePorts; classifiers: TerminalTextSubmissionClassifierPorts; } export declare class TerminalTextSubmissionBridge { private readonly runtime; private readonly classifiers; constructor(input: CreateTerminalTextSubmissionBridgeInput); send(adapter: TerminalAgentAdapter, terminalControl: TerminalControlRef, text: string, options?: TerminalSendOptions): Promise; observeCodexComposer(adapter: TerminalAgentAdapter, terminalControl: TerminalControlRef, expectedText: string, runtime?: TerminalRuntimeIdentity): Promise; settleCodexComposerObservation(adapter: TerminalAgentAdapter, terminalControl: TerminalControlRef, expectedText: string, runtime: TerminalRuntimeIdentity | undefined, options: { minimumStableMs: number; requiredState?: TerminalCodexCapturedComposerState; allowOpaqueLargePastePlaceholder?: boolean; classifyOpaqueLargePasteAsDifferent?: boolean; allowWorkingComposer?: boolean; }): Promise; captureCodexComposerSnapshot(adapter: TerminalAgentAdapter, terminalControl: TerminalControlRef, expectedText: string, runtime?: TerminalRuntimeIdentity, options?: { allowOpaqueLargePastePlaceholder?: boolean; classifyOpaqueLargePasteAsDifferent?: boolean; allowWorkingComposer?: boolean; }): Promise; private settleCodexMultilineComposer; private verifyExactComposerBeforeEnter; private claudeInjectedPasteProofPorts; private verifyExactEmptyComposerBeforeText; } export {};