import type { PiAcceptance } from './pi-rpc.js'; import type { DaemonLogger } from './logging.js'; export interface PiNotifier { notify(message: string): Promise; } export interface ReceiptReconciler { received(inbox: Record): Promise; } export type SlackEventBody = { event_id?: unknown; event?: Record; }; /** Serializes all admission/post-commit pi notifications in delivery order. */ export type CoordinatorReservation = { value: T; release(): void; }; export declare class GatewayCoordinator { private tail; private accepting; run(operation: () => Promise | T): Promise; /** * Return a value to the caller while retaining the serialization lane. The * caller must release the lease after its external boundary (currently the * control response flush) succeeds or is cancelled. */ reserve(operation: () => Promise | T): Promise>; /** Reject future work, while allowing already accepted work to finish. */ close(): void; drain(): Promise; } /** Replays only durably admitted Slack work that pi has not accepted yet. */ export declare function reconcilePendingSlackEffects(notifier: PiNotifier, receipts?: ReceiptReconciler, logger?: DaemonLogger): Promise; /** * Handles a real top-level Events API body. Ignored events deliberately do not * enter the ledger; relevant events are acknowledged only after SQLite commit. */ export declare function processSlackEvent(body: SlackEventBody, botId: string, notifier: PiNotifier, acknowledge: () => Promise | void, receipts?: ReceiptReconciler, logger?: DaemonLogger): Promise<'ignored' | 'duplicate' | 'accepted'>; export type SocketModeEnvelope = { type?: unknown; body?: unknown; ack: () => Promise | void; }; /** * Owns acknowledgement of one low-level Socket Mode envelope. Keeping this * seam below Bolt's listener middleware prevents its Events API auto-ack. */ export declare function handleSocketModeEnvelope(envelope: SocketModeEnvelope, botId: string, notifier: PiNotifier, coordinator: GatewayCoordinator, receipts?: ReceiptReconciler, logger?: DaemonLogger): Promise<'ignored' | 'duplicate' | 'accepted'>; /** Starts the one low-level Socket Mode connection with gateway-owned acknowledgement. */ export declare function startSlackGateway(options: { botToken: string; appToken: string; botId: string; notifier: PiNotifier; coordinator?: GatewayCoordinator; logger?: DaemonLogger; }): Promise<{ stop(): Promise; }>;