import type { ExecutorKind } from "./executors.js"; import { type ActiveTerminalProcess, type TerminalAgentAdapter, type TerminalAgentAdapterCapabilities, type TerminalAgentAdapterRegistry, type TerminalApprovalDecision, type TerminalCompletionEvidence, type TerminalControlRef, type TerminalDurableCompletionRequest, type TerminalNativeInspectionObservation, type TerminalNativeInspectionObservationRequest, type TerminalNativeInspectionPlan, type TerminalProcessSnapshot, type TerminalRuntimeIdentity, type TerminalScreenInspection } from "./terminal-agent-adapter.js"; import { type TerminalDiscoveryDiagnosticLog, type TerminalControlProvider } from "./terminal-control-provider.js"; import { type TerminalInteractionAnyProjection } from "./terminal-interaction-protocol.js"; import { type TerminalInteractionResponseExecution, type TerminalInteractionResponseInput, type TerminalInteractionResponseOptions } from "./terminal-interaction-response-bridge.js"; import { type TerminalModelCatalog, type TerminalModelControlPlan, type TerminalModelControlPorts, type TerminalModelControlRepairResult, type TerminalModelControlResidualObservation, type TerminalModelSwitchRequest, type TerminalModelSwitchResult } from "./terminal-model-control.js"; import { type TerminalCodexStatusProbeResult, type TerminalNativeInspectionDismissalOptions, type TerminalNativeInspectionDismissalResult, type TerminalNativeInspectionOptions, type TerminalNativeInspectionResult } from "./terminal-native-inspection-bridge.js"; import { type TerminalCodexComposerObservation, type TerminalSendOptions, type TerminalSendResult } from "./terminal-text-submission-bridge.js"; import type * as UserExplicitSendContract from "./terminal-user-explicit-send-contract.js"; export { TerminalEnterDispatchNotAttemptedError, TerminalEnterDispatchReservedError, TerminalInputNotStartedError, type TerminalCodexComposerObservation, type TerminalSendBoundaryContext, type TerminalSendOptions, type TerminalSendResult, type TerminalTransportStage, type TerminalTransportStageEvent } from "./terminal-text-submission-bridge.js"; export type * from "./terminal-user-explicit-send-contract.js"; export { captureTerminalInteractionRuntimeOffer, TerminalInteractionDispatchReservedError, TerminalInteractionInputNotStartedError, type TerminalInteractionAuthorizationContext, type TerminalInteractionAuthorizationDecision, type TerminalInteractionBeforeDispatchContext, type TerminalInteractionReservedStage, type TerminalInteractionResponseExecution, type TerminalInteractionRuntimeOffer } from "./terminal-interaction-response-bridge.js"; export { inspectCodexAsyncQuestionInputMode, type CodexAsyncQuestionInputMode } from "./terminal-composer-classifier.js"; export { exactCodexReadyStyledComposerCapture, isExactClaudeIdleComposer, isExactClaudeNativeInspectionIdleComposer, NativeInspectionDismissalError, NativeInspectionSubmissionError, type NativeInspectionSubmissionDiagnostic, type NativeInspectionSubmissionStage, type TerminalCodexStatusProbeResult, type TerminalNativeInspectionBeforeDismissContext, type TerminalNativeInspectionBeforeEnterContext, type TerminalNativeInspectionDismissalOptions, type TerminalNativeInspectionDismissalResult, type TerminalNativeInspectionMaterializationEvidence, type TerminalNativeInspectionMaterializationKind, type TerminalNativeInspectionOptions, type TerminalNativeInspectionResult } from "./terminal-native-inspection-bridge.js"; export type TerminalActivityState = "awaiting_approval" | "working" | "idle" | "unknown"; export type TerminalNativeIdentityState = "resolved" | "ambiguous" | "verified_absent" | "unavailable"; export type TerminalDurableActivityState = "working" | "idle" | "unknown"; export interface TerminalBridgeStatus { provider: string; target: string; agent: ExecutorKind; reachable: boolean; capabilities: Readonly; activity_state: TerminalActivityState; activity_reason: string; /** Raw live-screen classification before durable identity reconciliation. */ screen_state?: TerminalActivityState; /** Adapter evidence for screen_state. */ screen_reason?: string; /** Safe foreground-native-identity summary projected by list/status. */ native_identity_state?: TerminalNativeIdentityState; /** Durable task activity projected from exact native artifacts. */ durable_activity_state?: TerminalDurableActivityState; /** Evidence or limitation for durable_activity_state. */ durable_activity_reason?: string; approval_state: { scanned: boolean; blocked: boolean; approvable: boolean; key?: string; keys?: readonly string[]; label?: string; prompt_kind?: string; command?: string; cwd?: string; tool_name?: string; request_detail?: string; reason?: string; fingerprint?: string; choices?: readonly { decision: TerminalApprovalDecision; label: string; fingerprint: string; }[]; decision_mode?: "keys"; request_id?: string; policy_evidence?: { source: "claude_transcript"; kind: "run_command"; command_sha256: string; evidence_fingerprint: string; request_id: string; }; }; screen: { /** Positive complete-frame absence proof; withdrawal only, never input authority. */ async_question_absent?: true; excerpt?: string; /** SHA-256 of the raw capture. The raw terminal contents are never exposed here. */ digest?: string; approval?: Record; error?: string; }; /** Safe, semantic current-question projection; never terminal keys. */ interaction_state?: TerminalInteractionAnyProjection; /** * Owner-private response fence. Public status renderers must remove this * sibling field before returning terminal_status to a model or browser. */ interaction_prompt_fingerprint?: string; /** Owner-private cross-observer identity used for Monitor/Watch arbitration. */ interaction_surface_id?: string; capability_limitation?: string; } export interface ResolvedTerminalConversation { conversationId: string; agent: ExecutorKind; pid: number; legacy: boolean; adapter: TerminalAgentAdapter; terminalControl: TerminalControlRef; } export interface TerminalApprovalExecution { approved: boolean; /** True after either approve_once or reject was dispatched exactly once. */ decisionDispatched?: boolean; decision?: TerminalApprovalDecision; blocked: boolean; reason?: string; key?: string; keys?: readonly string[]; label?: string; promptKind?: string; command?: string; cwd?: string; toolName?: string; requestDetail?: string; fingerprint?: string; screenExcerpt?: string; decisionMode?: "keys"; requestId?: string; } export interface TerminalIdentityVerificationRequest { agent: ExecutorKind; pid: number; terminalControl: TerminalControlRef; runtime?: TerminalRuntimeIdentity; } export interface TerminalIdentityVerificationResult { terminalControl?: TerminalControlRef; } export type TerminalIdentityVerifier = (request: TerminalIdentityVerificationRequest) => Promise; export interface TerminalModelControlBridgeOptions { runtime?: TerminalRuntimeIdentity; /** Revalidate Store/Turn/current-snapshot authority before every UI step. */ beforeInput?: () => void | Promise; /** Read-only catalog from the exact executable bound to this Codex pane. */ loadCodexCatalog?: TerminalModelControlPorts["loadCodexCatalog"]; /** Private, current-snapshot authority to continue one exact `/model`. */ initialResidual?: Extract; } export interface TerminalModelOptionsBridgeResult { terminalControl: TerminalControlRef; catalog: TerminalModelCatalog; } export interface TerminalModelSwitchBridgeResult extends TerminalModelSwitchResult { terminalControl: TerminalControlRef; } export type TerminalModelControlResidualBridgeResult = TerminalModelControlResidualObservation; export interface TerminalModelControlRepairBridgeResult extends Omit { terminalControl: TerminalControlRef; } export interface TerminalCodexDraftSubmissionContext { terminalControl: TerminalControlRef; text: string; composerDigest: string; } export interface TerminalCodexDraftSubmissionOptions { runtime?: TerminalRuntimeIdentity; /** * Persist the caller's one-shot Enter reservation after the preliminary * stable proof. The bridge then independently recaptures the exact draft * before its sole C-m transport call. Invoking this hook consumes the attempt * even when the hook or any later step fails. */ beforeEnterReservation: (context: TerminalCodexDraftSubmissionContext) => void | Promise; } export interface TerminalCodexDraftSubmissionResult { stage: "enter_dispatched"; terminalControl: TerminalControlRef; enterCount: 1; } export interface TerminalNativeInspectionObservationResult { terminalControl: TerminalControlRef; status: TerminalBridgeStatus; /** Same raw-screen fingerprint format used by adapter stale checks. */ screenDigest: string; observation: TerminalNativeInspectionObservation; } export interface TerminalApprovalAuthorizationContext { agent: ExecutorKind; terminalControl: TerminalControlRef; inspection: TerminalScreenInspection; fingerprint?: string; decision: TerminalApprovalDecision; runtime?: TerminalRuntimeIdentity; } export interface TerminalApprovalAuthorizationDecision { approved: boolean; reason?: string; } export interface TerminalApprovalKeyDispatchContext { agent: ExecutorKind; terminalControl: TerminalControlRef; inspection: TerminalScreenInspection; fingerprint: string; decision: TerminalApprovalDecision; keys: readonly string[]; runtime?: TerminalRuntimeIdentity; } export interface TerminalMonitorPoll { status: TerminalBridgeStatus; inspection?: TerminalScreenInspection; completion?: TerminalCompletionEvidence; durableCompletion?: TerminalCompletionEvidence; } export declare class TerminalAgentBridge { readonly registry: TerminalAgentAdapterRegistry; readonly terminalProvider: TerminalControlProvider; private readonly verifyIdentity?; private readonly nowMs; private readonly now; private readonly sleep; private readonly diagnosticLog?; constructor(options: { registry: TerminalAgentAdapterRegistry; terminalProvider: TerminalControlProvider; verifyIdentity?: TerminalIdentityVerifier; nowMs?: () => number; now?: () => Date; sleep?: (milliseconds: number) => Promise; diagnosticLog?: TerminalDiscoveryDiagnosticLog; }); adapterFor(agent: ExecutorKind | string): TerminalAgentAdapter; listProcesses(snapshots: readonly TerminalProcessSnapshot[], agents?: readonly ExecutorKind[]): Promise; discoverProcesses(snapshots: readonly TerminalProcessSnapshot[], agents?: readonly ExecutorKind[]): Promise; attachProcesses(agent: ExecutorKind, processes: T[], options?: { processTree?: readonly TerminalProcessSnapshot[]; }): Promise; terminalConversationId(process: Pick): string; /** * Resolve a persisted control reference by stable endpoint identity. This is * the managed-Session path: its route-shaped v2 terminal id is only a * compatibility alias and may be stale after an explicit provider refresh. */ resolveStoredTerminal(agent: ExecutorKind, pid: number, terminalControl: TerminalControlRef, runtime?: TerminalRuntimeIdentity): Promise; resolveConversationId(conversationId: string | undefined): Promise; status(agent: ExecutorKind, terminalControl: TerminalControlRef, options?: { scrollbackLines?: number; runtime?: TerminalRuntimeIdentity; }): Promise; modelOptions(agent: ExecutorKind, terminalControl: TerminalControlRef, agentVersion: string, plan: TerminalModelControlPlan, options?: TerminalModelControlBridgeOptions): Promise; setModel(agent: ExecutorKind, terminalControl: TerminalControlRef, agentVersion: string, plan: TerminalModelControlPlan, expectedCatalogFingerprint: string, request: TerminalModelSwitchRequest, options?: TerminalModelControlBridgeOptions): Promise; inspectModelControlResidual(agent: ExecutorKind, terminalControl: TerminalControlRef, agentVersion: string, plan: TerminalModelControlPlan, options?: TerminalModelControlBridgeOptions): Promise; repairModelControlResidual(agent: ExecutorKind, terminalControl: TerminalControlRef, agentVersion: string, plan: TerminalModelControlPlan, expectedResidualFingerprint: string, options?: TerminalModelControlBridgeOptions): Promise; private modelControlPorts; private textSubmissionBridge; private interactionResponseBridge; private nativeInspectionBridge; send(agent: ExecutorKind, terminalControl: TerminalControlRef, text: string, options?: TerminalSendOptions): Promise; /** Observe only the current, live Codex composer without exposing its text. */ observeCodexComposer(terminalControl: TerminalControlRef, expectedText: string, options?: { runtime?: TerminalRuntimeIdentity; }): Promise; /** * Replace one selected agent's Composer for an explicit user Send. Approval, * interaction, modal, and identity gates remain; autonomous sends never use it. */ sendUserExplicit(agent: ExecutorKind, terminalControl: TerminalControlRef, text: string, options: UserExplicitSendContract.TerminalUserExplicitSendOptions): Promise; /** Compatibility wrapper for callers that still name the Codex primitive. */ sendUserExplicitCodex(terminalControl: TerminalControlRef, text: string, options: UserExplicitSendContract.TerminalCodexUserExplicitSendOptions): Promise; /** * Submit one already-present exact Codex draft. This primitive never writes * text, clears the composer, or emits C-c, and contains exactly one C-m call. */ submitExactCodexDraft(terminalControl: TerminalControlRef, expectedText: string, options: TerminalCodexDraftSubmissionOptions): Promise; /** * Submit one closed, adapter-owned native inspection command. * * This intentionally does not use `send()`: native slash commands need a * stricter composer proof, and failures after text injection must leave the * draft untouched instead of issuing the legacy best-effort C-u cleanup. */ submitNativeInspection(agent: ExecutorKind, terminalControl: TerminalControlRef, plan: TerminalNativeInspectionPlan, options?: TerminalNativeInspectionOptions): Promise; /** * Submit Codex's closed, version-profiled `/status` probe. * * Unlike the generic native-inspection entry point, callers provide only * the detected Codex version, never a command or plan. */ submitCodexStatusProbe(terminalControl: TerminalControlRef, agentVersion: string, options?: TerminalNativeInspectionOptions): Promise; observeNativeInspection(agent: ExecutorKind, terminalControl: TerminalControlRef, request: TerminalNativeInspectionObservationRequest, options?: { runtime?: TerminalRuntimeIdentity; scrollbackLines?: number; }): Promise; /** * Dismiss one exact adapter-owned modal result after re-observing the same * evidence under the terminal identity fence. There is exactly one key * attempt and no automated retry across an uncertain dismissal boundary. */ dismissNativeInspection(agent: ExecutorKind, terminalControl: TerminalControlRef, plan: TerminalNativeInspectionPlan, request: TerminalNativeInspectionObservationRequest, expectedEvidenceFingerprint: string, options?: TerminalNativeInspectionDismissalOptions): Promise; /** * Prove that the exact managed draft is still present after Enter dispatch. * Two identity-fenced captures are required so transient repaint state never * becomes a hard `not_accepted` conclusion. */ proveExactDraftStillPresent(agent: ExecutorKind, terminalControl: TerminalControlRef, expectedText: string, options?: { runtime?: TerminalRuntimeIdentity; scrollbackLines?: number; }): Promise; /** * Clear a terminal composer's current input without submitting it. This is * intentionally narrower than arbitrary key dispatch and always revalidates * the exact terminal/process identity first. */ clearInputLine(agent: ExecutorKind, terminalControl: TerminalControlRef, options?: { runtime?: TerminalRuntimeIdentity; }): Promise; cancel(agent: ExecutorKind, terminalControl: TerminalControlRef, options?: { runtime?: TerminalRuntimeIdentity; scrollbackLines?: number; }): Promise<{ cancelRequested: boolean; key?: string; keys?: readonly string[]; reason?: string; deniedApproval?: boolean; requestId?: string; }>; approve(agent: ExecutorKind, terminalControl: TerminalControlRef, options?: { decision?: TerminalApprovalDecision; expectedFingerprint?: string; scrollbackLines?: number; runtime?: TerminalRuntimeIdentity; managedRequest?: TerminalDurableCompletionRequest; requiredDecisionMode?: "keys"; authorize?: (context: TerminalApprovalAuthorizationContext) => TerminalApprovalAuthorizationDecision | Promise; /** * Persist an at-most-once dispatch reservation after authorization. The * bridge then recaptures the prompt and revalidates terminal identity * before tmux receives the approval keys. */ beforeKeyDispatch?: (context: TerminalApprovalKeyDispatchContext) => void | Promise; }): Promise; respondInteraction(agent: ExecutorKind, terminalControl: TerminalControlRef, response: TerminalInteractionResponseInput, options: TerminalInteractionResponseOptions): Promise; monitorPoll(options: { agent: ExecutorKind; terminalControl: TerminalControlRef; screenOptions?: { scrollbackLines?: number; requestText?: string; screenChangedSinceSend?: boolean; maxExcerptLength?: number; runtime?: TerminalRuntimeIdentity; }; durableRequest?: TerminalDurableCompletionRequest; }): Promise; private captureInspection; private verifyTerminalIdentity; } export declare function terminalApprovalFingerprint(agent: ExecutorKind, terminalControl: TerminalControlRef, inspection: TerminalScreenInspection, options?: { screen?: string; runtime?: TerminalRuntimeIdentity; decision?: TerminalApprovalDecision; }): string | undefined;