/**
 * Possible delivery statuses for a session delivery record.
 */
export type MeshSessionDeliveryStatus = 'queued' | 'delivering' | 'delivered' | 'acked' | 'completed' | 'failed' | 'expired' | 'cancelled';
/**
 * Kind of delivery — controls priority and policy handling.
 */
export type MeshSessionDeliveryKind = 'task' | 'followup' | 'approval' | 'recovery' | 'system_notice';
/**
 * A session delivery decision — what to do when a task arrives for a session.
 */
export type MeshDeliveryDecision = 'immediate' | 'queued' | 'rejected';
export interface MeshDeliveryPolicyResult {
    decision: MeshDeliveryDecision;
    reason: string;
    /** When decision='queued', estimated deliver-after ISO timestamp if known. */
    deliverAfter?: string;
    /** Human-readable explanation for coordinator/operator. */
    message: string;
}
/**
 * Determine whether to deliver immediately, queue, or reject based on session status.
 *
 * This is a pure function — it does not write to any store.
 */
export declare function resolveDeliveryDecision(sessionStatus: string | undefined, opts?: {
    kind?: MeshSessionDeliveryKind;
    /** When true, busy session immediate injection is allowed (provider-specific capability). */
    allowBusyInjection?: boolean;
}): MeshDeliveryPolicyResult;
export interface SessionDeliveryRecord {
    id: string;
    meshId: string;
    nodeId?: string;
    sessionId?: string;
    providerType?: string;
    taskId?: string;
    kind: MeshSessionDeliveryKind;
    priority: number;
    message: string;
    status: MeshSessionDeliveryStatus;
    deliverAfter?: string;
    expiresAt?: string;
    attemptCount: number;
    sourceCoordinatorSessionId?: string;
    sourceCoordinatorDaemonId?: string;
    lastError?: string;
    createdAt: string;
    updatedAt: string;
}
/**
 * Create a delivery record in the store.
 */
export declare function createSessionDelivery(opts: {
    meshId: string;
    nodeId?: string;
    sessionId?: string;
    providerType?: string;
    taskId?: string;
    kind: MeshSessionDeliveryKind;
    message: string;
    status: MeshSessionDeliveryStatus;
    priority?: number;
    deliverAfter?: string;
    expiresAt?: string;
    sourceCoordinatorSessionId?: string;
    sourceCoordinatorDaemonId?: string;
}): SessionDeliveryRecord;
/**
 * Update the status of a delivery record.
 */
export declare function updateSessionDeliveryStatus(id: string, status: MeshSessionDeliveryStatus, opts?: {
    lastError?: string;
    incrementAttempt?: boolean;
}): void;
/**
 * Get active (non-terminal) deliveries for a mesh, optionally filtered by session.
 */
export declare function getActiveSessionDeliveries(meshId: string, sessionId?: string): {
    id: string;
    meshId: string;
    nodeId: string | null;
    sessionId: string | null;
    providerType: string | null;
    taskId: string | null;
    kind: string;
    priority: number;
    message: string;
    status: string;
    deliverAfter: string | null;
    expiresAt: string | null;
    attemptCount: number;
    sourceCoordinatorSessionId: string | null;
    sourceCoordinatorDaemonId: string | null;
    lastError: string | null;
    createdAt: string;
    updatedAt: string;
}[];
/**
 * DELIVERED-NOT-CONSUMED-REDRIVE consume path. Advance a task's delivery record(s) to a
 * CONSUMED status ('acked'/'completed') by (mesh, session[, task]), INCLUDING rows already in
 * 'delivered' — unlike getActiveSessionDeliveries which excludes 'delivered'. The store's
 * monotonic guard only ever advances the row. Returns the number of rows advanced.
 */
export declare function consumeSessionDelivery(meshId: string, sessionId: string, status: 'acked' | 'completed', taskId?: string): number;
export declare function __clearSessionDeliveriesForTests(meshId: string): void;
/**
 * Mark all active (queued/delivering/delivered/acked) deliveries for a session as completed or failed.
 * Called when a task's terminal status is confirmed so delivery records stay in sync.
 */
export declare function markSessionDeliveriesTerminal(meshId: string, sessionId: string, terminalStatus: 'completed' | 'failed'): void;
