import { type CallbackDeliveryOutcome } from "./callback-outbox-policy.js"; import { type CallbackAttemptOutcome, type CallbackEnvelopeV1 } from "./callback-transport.js"; import { type AgentMessage, type Conversation } from "./protocol.js"; export type CallbackOutboxLane = "lifecycle" | "notification"; export type CallbackOutboxField = "callback_delivery" | "callback_notification_delivery"; export declare function callbackOutboxField(lane: CallbackOutboxLane): CallbackOutboxField; export declare function callbackOutboxEvent(lane: CallbackOutboxLane, suffix: string): string; export interface PreparedCallbackDeliveryClaim { options: { retryPending?: boolean; disableCallbackRetry?: boolean; }; statePath: string; logPath: string; message: AgentMessage; deliveryAttempt: number; deliveryAttemptId: string; callbackOutboxLane?: CallbackOutboxLane; callbackEnvelope?: CallbackEnvelopeV1; } export interface CallbackOutboxSettlementStatePort { withWriter(storeDir: string, operation: () => Result): Result; withStateTransaction(statePath: string, operation: () => Result): Result; storeDirForStatePath(statePath: string): string; load(statePath: string): Conversation; save(statePath: string, conversation: Conversation): void; append(logPath: string, event: Record): void; } export interface CallbackRetryMonitorPort { start(input: { statePath: string; callbackOutboxLane: CallbackOutboxLane; }): { pid?: number | null; }; } export interface CallbackOutboxSettlementPorts { state: CallbackOutboxSettlementStatePort; retryMonitor: CallbackRetryMonitorPort; clock: { now(): Date; nowMs(): number; }; attemptLeaseMs: number; retryDelaysMs: readonly number[]; } export interface CallbackDeliverySettlementResult { delivered: boolean; error?: unknown; delivery?: CallbackDeliveryOutcome; /** Authoritative host-neutral result for this single transport attempt. */ outcome?: CallbackAttemptOutcome; } export interface SettleAcceptedCallbackInput { conversation: Conversation; statePath: string; logPath: string; expectedMessageId?: string; reason: string; callbackOutboxLane?: CallbackOutboxLane; } export declare function createCallbackOutboxSettlement({ state, retryMonitor, clock, attemptLeaseMs, retryDelaysMs }: CallbackOutboxSettlementPorts): { persistDeliveryProgress: (prepared: PreparedCallbackDeliveryClaim, progress: Record) => void; settleDelivery: (prepared: PreparedCallbackDeliveryClaim, result: CallbackDeliverySettlementResult) => Conversation; settleAcceptedWhileLocked: ({ conversation, statePath, logPath, expectedMessageId, reason, callbackOutboxLane }: SettleAcceptedCallbackInput) => Conversation | undefined; settleAccepted: (input: Omit) => Conversation | undefined; };