import type { CodexOpenRootRolloutInventory } from "./agent-session-provider.js"; import type { DeferredForegroundTransfer, DeferredForegroundTransferSourceKind, DeferredForegroundTransferSourceRolloutAuthority, DeferredForegroundTransferSourceTurnAuthority } from "./deferred-foreground-transfer.js"; import { type ManagedSessionState } from "./managed-session.js"; import { type Conversation } from "./protocol.js"; import { type CodexSendAuthorityContext } from "./terminal-authority-policy.js"; import type { TerminalControlRef } from "./terminal-agent-adapter.js"; import type { DeferredCodexForegroundDispatchSnapshot } from "./terminal-dispatch-composition.js"; export interface DeferredForegroundAuthorityAdapterPorts { turn: { terminalControl(value: unknown): TerminalControlRef | undefined; storeDir(conversation: Conversation): string | undefined; turnsForSession(storeDir: string, sessionId: string): Conversation[]; needsAttention(conversation: Conversation): boolean; readEvents(logPath: string): Record[]; }; ledger: { load(control: TerminalControlRef): Record | undefined; matchesControl(ledger: Record | undefined, control: TerminalControlRef, options?: { requireCurrentRoute?: boolean; requireProcessAnchor?: boolean; }): boolean; processAnchor(ledger: Record): number | undefined; }; transition: { hasUnresolved(storeDir: string, session: ManagedSessionState): boolean; hasAny(storeDir: string, session: ManagedSessionState): boolean; }; } export declare function codexCandidateInventoryHasNoOtherManagedClaim(ports: DeferredForegroundAuthorityAdapterPorts, { storeDir, inventory, sourceSessionId, includeDetached }: { storeDir: string; inventory: CodexOpenRootRolloutInventory; sourceSessionId: string; includeDetached?: boolean; }): boolean; export type HumanExplicitCallbackDebtDisposition = "supersedable" | "settled"; export type HumanExplicitCallbackDebtRetirementDisposition = HumanExplicitCallbackDebtDisposition | "no_callback_debt"; /** * A private managed token is an optional fast-path hint for human Send. It may * be omitted, but a supplied token must still name the exact current binding. */ export declare function humanExplicitCallbackDebtManagedTokenMatches(expectedManagedToken: unknown, session: ManagedSessionState): boolean; /** * Classify callback state only after the Turn has been proven to belong to the * exact current binding generation. Undefined is deliberately fail-closed. */ export declare function humanExplicitCallbackDebtDisposition(turn: Conversation, session: ManagedSessionState): HumanExplicitCallbackDebtDisposition | undefined; /** * Classify only the lifecycle callback record retired by a new human Send. * A Turn without that record is not proof of safe continuation: exact safe * abort and explicit-abandonment evidence remain mandatory in * deferredCandidateSourceTurnHistory. It merely cannot veto retirement of a * different Turn's independently proven callback debt. */ export declare function humanExplicitCallbackDebtRetirementDisposition(turn: Conversation, session: ManagedSessionState): HumanExplicitCallbackDebtRetirementDisposition | undefined; export declare function deferredCandidateSourceTurnHistory(ports: DeferredForegroundAuthorityAdapterPorts, storeDir: string, session: ManagedSessionState): DeferredForegroundTransferSourceTurnAuthority[] | undefined; export declare function explicitlyAbandonedCandidateSourceFingerprint(ports: DeferredForegroundAuthorityAdapterPorts, { storeDir, session, sourceTurnHistory, dispatchSnapshot, sourceRevision, sourceBindingToken, ledgerOverride, requireResolvedTopLevel }: { storeDir: string; session: ManagedSessionState; sourceTurnHistory: DeferredForegroundTransferSourceTurnAuthority[]; dispatchSnapshot: DeferredCodexForegroundDispatchSnapshot; sourceRevision?: number; sourceBindingToken?: string; ledgerOverride?: Record; requireResolvedTopLevel?: boolean; }): string | undefined; export declare function assertFrozenExplicitlyAbandonedPredecessorAuthority(ports: DeferredForegroundAuthorityAdapterPorts, { storeDir, transfer, terminalControl }: { storeDir: string; transfer: DeferredForegroundTransfer; terminalControl: TerminalControlRef; }): void; export declare function deferredCodexForegroundDispatchSnapshot(ports: DeferredForegroundAuthorityAdapterPorts, terminalControl: TerminalControlRef): DeferredCodexForegroundDispatchSnapshot; export declare function deferredCodexPreviousDispatchSnapshotMatches(ports: DeferredForegroundAuthorityAdapterPorts, { transfer, terminalControl, ledger }: { transfer: DeferredForegroundTransfer; terminalControl: TerminalControlRef; ledger: Record | undefined; }): boolean; export type DeferredCodexAuthorityMode = "list" | "prepare" | "boundary_bound" | "boundary_transitioning"; export interface DeferredCodexAuthorityObservation { sourceKind: DeferredForegroundTransferSourceKind; sourceRolloutAuthority: DeferredForegroundTransferSourceRolloutAuthority; sourceTurnHistory?: DeferredForegroundTransferSourceTurnAuthority[]; dispatchSnapshot?: DeferredCodexForegroundDispatchSnapshot; sourceAbandonmentFingerprint?: string; exactSource: boolean; } export declare function observeDeferredCodexAuthority(ports: DeferredForegroundAuthorityAdapterPorts, { mode, storeDir, context, sourceSession, candidateInventory, abandonment, fixedSourceRolloutAuthority, fixedDispatchSnapshot, sourceRevision, sourceBindingToken, requireUnclaimedCandidate }: { mode: DeferredCodexAuthorityMode; storeDir: string; context: CodexSendAuthorityContext; sourceSession?: ManagedSessionState; candidateInventory?: CodexOpenRootRolloutInventory; abandonment: "never" | "missing_rollout" | "missing_inventory_rollout"; fixedSourceRolloutAuthority?: DeferredForegroundTransferSourceRolloutAuthority; fixedDispatchSnapshot?: DeferredCodexForegroundDispatchSnapshot; sourceRevision?: number; sourceBindingToken?: string; requireUnclaimedCandidate?: boolean; }): DeferredCodexAuthorityObservation | undefined;