import { type AgentMessage, type Conversation } from "./protocol.js"; import { type CallbackAttemptOutcome, type CallbackEnvelopeV1, type CallbackRouteV1, type CallbackTransportAttemptV1 } from "./callback-transport.js"; export type { CallbackAttemptOutcome, CallbackEnvelopeV1, CallbackRouteV1 } from "./callback-transport.js"; export interface CallbackDeliveryOutcome { kind: string; injection: Record; wake: Record; run_observation?: Record; /** Generic evidence written alongside the legacy OpenClaw shape. */ attempt_outcome?: CallbackAttemptOutcome; } export interface CallbackProcessFailureObservation { status?: number | null; stdout?: string; stderr?: string; error?: { message?: string; }; } /** * Fence an advisory outbox when its underlying Turn moves on. Accepted * transport evidence is retained for settlement; only unaccepted work is * superseded so a late retry cannot notify the previous lifecycle phase. */ export declare function supersedeCallbackNotificationDelivery(conversation: Conversation, input: { at: string; reason: string; }): Conversation; /** * Explicit Close releases AKK's management of the Turn. Fence both durable * callback lanes unless the host has already accepted the transport. A * transport-start marker is retained as audit evidence, but never authorizes a * retry after Close. */ export declare function supersedeUnacceptedCallbackDeliveries(conversation: Conversation, input: { at: string; reason: string; }): Conversation; /** * Fence only the matching callback lane for the exact native interaction step * that has just been answered. An accepted host transport is immutable * evidence and must be allowed to settle; an unaccepted wake-up must never be * retried after the terminal has already moved on. */ export declare function supersedeMatchingInteractionCallbackDelivery(conversation: Conversation, input: { at: string; interactionId: string; fingerprint: string; }): Conversation; export declare function classifyCallbackProcessFailure(result: CallbackProcessFailureObservation): string | undefined; export interface CallbackDeliveryOptions { callbackRoute?: CallbackRouteV1; gatewayMethod?: string; openclawBin?: string; gatewayUrl?: string; token?: string; gatewaySession?: string; openclawSession?: string; } export interface DeliverCallbackInput { options: CallbackDeliveryOptions; statePath: string; logPath: string; conversation: Conversation; message: AgentMessage; /** Immutable prepared outbox claim crossing the transport boundary. */ attempt: CallbackTransportAttemptV1; route?: CallbackRouteV1; envelope?: CallbackEnvelopeV1; onProgress?: (progress: Record) => void; onAccepted?: (outcome: CallbackDeliveryOutcome) => void; } export type CallbackRetryDisposition = { state: "retryable"; attempt: number; } | { state: "in_flight"; attempt: number; attempt_pid?: number; lease_expires_at?: string; next_attempt_at?: string; } | { state: "accepted"; attempt: number; } | { state: "permanent_failure"; attempt: number; reason: string; } | { state: "uncertain"; attempt: number; reason: string; } | { state: "exhausted"; attempt: number; } | { state: "unavailable"; attempt: number; reason: string; }; export type CallbackRetryPolicyState = { phase: "decided"; disposition: CallbackRetryDisposition; } | { phase: "observe_process"; attempt: number; attempt_pid: number; effective_lease_expires_at_ms?: number; persisted_lease_expires_at?: string; next_attempt_at?: string; transport_started_without_outcome?: true; } | { phase: "observe_clock"; attempt: number; attempt_pid: number; effective_lease_expires_at_ms: number; persisted_lease_expires_at?: string; next_attempt_at?: string; transport_started_without_outcome?: true; }; export type CallbackRetryObservation = { kind: "process_alive"; alive: boolean; } | { kind: "clock"; now_ms: number; }; export interface CallbackRetryPolicyLimits { attemptLeaseMs: number; retryDelayCount: number; } /** * Classify durable callback-outbox evidence before observing live process or * clock state. The returned phase names the first ephemeral observation the * caller may need; already-decided states never authorize either observation. */ export declare function beginCallbackRetryPolicy(callbackDelivery: unknown, limits: CallbackRetryPolicyLimits): CallbackRetryPolicyState; /** * Advance one callback retry observation without performing I/O. A live * process advances to a clock observation only when usable lease evidence is * present, preserving the legacy short-circuit order. */ export declare function reduceCallbackRetryPolicy(state: CallbackRetryPolicyState, observation: CallbackRetryObservation): CallbackRetryPolicyState; export declare function callbackDeliveryHasAcceptedTransport(callbackDelivery: unknown): boolean; export declare function callbackDeliveryAttemptOutcome(callbackDelivery: unknown): CallbackAttemptOutcome | undefined;