export declare const TERMINAL_SUBMISSION_RETRY_SCHEMA: "agent-knock-knock/terminal-submission-retry"; export declare const TERMINAL_SUBMISSION_RETRY_VERSION: 1; export declare const TERMINAL_SUBMISSION_RETRY_FILE = "submission-retry.json"; export type TerminalSubmissionRetryMode = "exact_draft_enter" | "replacement_send"; export type TerminalSubmissionRetryState = "replacement_reserved" | "replacement_text_reserved" | "replacement_text_injected" | "enter_reserved" | "enter_dispatched" | "agent_accepted"; export interface TerminalSubmissionRetryRecord { schema: typeof TERMINAL_SUBMISSION_RETRY_SCHEMA; version: typeof TERMINAL_SUBMISSION_RETRY_VERSION; revision: number; attempt_id: string; mode: TerminalSubmissionRetryMode; state: TerminalSubmissionRetryState; store_dir: string; state_path: string; session_id: string; turn_id: string; original_message_id: string; active_message_id: string; request_hash: string; terminal_target: string; callback_route_fingerprint: string | null; deferred_foreground_transfer_id: string | null; reserved_at: string; updated_at: string; replacement_text_reserved_at?: string; replacement_text_injected_at?: string; enter_reserved_at?: string; enter_dispatched_at?: string; agent_accepted_at?: string; } export type TerminalSubmissionComposerState = "exact_draft" | "exact_empty" | "different_draft" | "working" | "approval_or_modal" | "identity_drift" | "unavailable"; export type TerminalSubmissionRetryDecision = { action: "repair_accepted"; } | { action: "submit_exact_draft"; activeMessageId: string; } | { action: "start_replacement"; } | { action: "resume_replacement"; activeMessageId: string; } | { action: "refuse"; reason: string; }; export interface TerminalSubmissionRetryFacts { agent: string; exactTurnTarget: boolean; accepted: boolean; composer: TerminalSubmissionComposerState; submissionStatus?: string; lastProvenStage?: string; submissionTextInjectedAt?: string; enterDispatchedAt?: string; enterNotAttemptedAt?: string; enterNotAttemptedReason?: string; ledgerStatus?: string; ledgerTextInjectedAt?: string; ledgerEnterDispatchedAt?: string; ledgerEnterNotAttemptedAt?: string; ledgerEnterNotAttemptedReason?: string; ledgerAgentAcceptedAt?: string; originalMessageId?: string; currentMessageId?: string; attempt?: TerminalSubmissionRetryRecord; } export interface TerminalSubmissionRetryPendingProjection { messageId: string; preparedAt: string; textInjectedAt: string; enterDispatchedAt: string; } export declare function projectTerminalSubmissionRetryPending(input: { attempt: TerminalSubmissionRetryRecord; submission: Record; ledger: Record; }): TerminalSubmissionRetryPendingProjection; /** * Pure recovery policy. In particular, `exact_empty` is useful only when a * structured pre-key receipt proves the original Enter was never attempted. * A legacy error string or a missing Enter timestamp is not that proof. */ export declare function decideTerminalSubmissionRetry(facts: TerminalSubmissionRetryFacts): TerminalSubmissionRetryDecision; export declare function terminalSubmissionRetryPath(statePath: string): string; export declare function loadTerminalSubmissionRetry(statePath: string): TerminalSubmissionRetryRecord | undefined; export declare function saveTerminalSubmissionRetry(statePath: string, candidate: TerminalSubmissionRetryRecord, expectedRevision: number | null): TerminalSubmissionRetryRecord; export declare function terminalSubmissionRetryLedgerFields(attempt: TerminalSubmissionRetryRecord | undefined): Record; export declare function terminalSubmissionRetryLedgerPrefix(attempt: TerminalSubmissionRetryRecord, ledger: Record): "current" | "previous" | "missing_initial"; export type TerminalSubmissionRetryStartupDecision = { action: "promote_pending"; } | { action: "finalize_accepted"; } | { action: "repair_terminal_ledger"; outcome: "not_accepted" | "uncertain"; at: string; reason?: string; } | { action: "repair_terminal_state"; outcome: "uncertain"; at: string; reason?: string; } | { action: "no_change"; reason: string; } | { action: "refuse"; reason: string; }; export declare function decideTerminalSubmissionRetryStartup(input: { attempt: TerminalSubmissionRetryRecord; submission: Record; ledger: Record; }): TerminalSubmissionRetryStartupDecision;