import { type PreparedCallback } from "./callback-outbox-service.js"; import { executorForConversation, type Conversation } from "./protocol.js"; import type { TerminalCompletionEvidence, TerminalControlRef } from "./terminal-agent-adapter.js"; import { type TerminalDispatchLedgerDocument } from "./terminal-dispatch-ledger-codec.js"; import type { TerminalDispatchRepositoryCliAdapter } from "./terminal-dispatch-repository-cli-adapter.js"; import { type LocalCompletionRecoveryResult, type TerminalCompletionPreparation, type VerifiedDeadRecoveryResult } from "./terminal-dispatch-recovery-service.js"; import { type VerifiedDeadDispatchRequest } from "./terminal-dispatch-recovery-authority.js"; import { type TranscriptEvent } from "./transcript.js"; import { type BoundTerminalAgentProcessObservation, type VerifiedDeadAgentAuthorityDecision, type VerifiedDeadAgentCompletionObservation, type VerifiedDeadTerminalAgentProcessProof } from "./verified-dead-agent-policy.js"; export interface TerminalDispatchRecoveryCliDependencies { repository: TerminalDispatchRepositoryCliAdapter; authority: { terminalControl(value: unknown): TerminalControlRef | undefined; assertNoDeferredTransfer(input: { storeDir: string; conversation: Conversation; action: "approve" | "cancel"; }): void; assertTurnBindingCurrent(conversation: Conversation, operation: string): void; storeDirForConversation(conversation: Conversation): string | undefined; }; observation: { process(input: { options: Record; conversation: Conversation; terminalControl: TerminalControlRef; }): Promise; completion(input: { options: Record; conversation: Conversation; terminalControl: TerminalControlRef; }): Promise>; }; completion: { prepare(input: { options: Record; statePath: string; logPath: string; conversation: Conversation; executor: ReturnType; terminalControl: TerminalControlRef; terminalMessageId: string; completion: TerminalCompletionEvidence; allowSupersedeRecovery?: boolean; completionFingerprint?: string; }): TerminalCompletionPreparation; }; runtime: { isProcessAlive(pid: number): boolean; }; } export interface TerminalDispatchRecoveryCliFacade { loadOwner(ledger: TerminalDispatchLedgerDocument): Conversation | undefined; assertManagedOwner(input: { storeDir: string; conversation: Conversation; terminalControl: TerminalControlRef; action: "approve" | "cancel"; }): void; assertNativeThreadStoreAuthority(input: { terminalControl: TerminalControlRef; nativeThreadId: string; storeDir: string; }): void; orphanedForRecovery(terminalControl: TerminalControlRef): TerminalDispatchLedgerDocument | undefined; bindingFields(conversation: Conversation): TerminalDispatchLedgerDocument; reconcilePrepared(terminalControl: TerminalControlRef, ledger?: TerminalDispatchLedgerDocument): TerminalDispatchLedgerDocument | undefined; isVerifiedDead(conversation: Conversation | Record): boolean; exactVerifiedDeadAuthority(input: { conversation: Conversation; storeDir: string; terminalControl: TerminalControlRef; logPath: string; }): VerifiedDeadAgentAuthorityDecision; ensureVerifiedDeadEvent(input: { logPath: string; proof: VerifiedDeadTerminalAgentProcessProof; action: "managed_close" | "monitor_reconciliation"; }): { proof: VerifiedDeadTerminalAgentProcessProof; evidenceId: string; recordedAt: string; }; ensureVerifiedDeadClosedEvent(input: { logPath: string; conversation: Conversation; evidenceId: string; }): void; assertVerifiedDeadDispatch(input: VerifiedDeadDispatchRequest): { ledger: TerminalDispatchLedgerDocument; resolved: boolean; }; resolveVerifiedDeadDispatch(input: VerifiedDeadDispatchRequest & { reason: string; }): boolean; stallAccepted(input: { options: Record; storeDir: string; statePath: string; logPath: string; expectedConversationId: string; expectedMessageId?: string; }): Promise>; settleLocalCompletion(input: { storeDir: string; statePath: string; logPath: string; }): LocalCompletionRecoveryResult; prepareCompletion(input: { options: Record; statePath: string; logPath: string; conversation: Conversation; executor: ReturnType; terminalControl: TerminalControlRef; terminalMessageId: string; completion: TerminalCompletionEvidence; allowSupersedeRecovery?: boolean; completionFingerprint?: string; }): TerminalCompletionPreparation; readEvents(logPath: string): TranscriptEvent[]; } /** Bind typed recovery decisions to the existing CLI transaction boundary. */ export declare function createTerminalDispatchRecoveryCliAdapter(dependencies: TerminalDispatchRecoveryCliDependencies): TerminalDispatchRecoveryCliFacade;