/** * Heartbeat wake scheduler — triggers ad-hoc heartbeat runs outside the regular interval. * * When external events (incoming messages, cron fires, system events) need the koi * to wake up and process immediately, they call {@link requestHeartbeatNow}. This module * coalesces rapid-fire requests (250ms window) and retries with exponential backoff * (1s → 30s) if the heartbeat runner is busy or fails. * * Only one heartbeat runs at a time. Requests that arrive while one is in-flight * are queued and coalesced into the next run. * * @module */ /** Result of a single heartbeat execution. */ export type HeartbeatRunResult = { status: "ran"; durationMs: number; } | { status: "skipped"; reason: string; } | { status: "failed"; reason: string; }; export type HeartbeatWakeHandler = (opts: { reason?: string; }) => Promise; export declare function setHeartbeatWakeHandler(next: HeartbeatWakeHandler | null): void; export declare function requestHeartbeatNow(opts?: { reason?: string; coalesceMs?: number; }): void; export declare function hasHeartbeatWakeHandler(): boolean; export declare function hasPendingHeartbeatWake(): boolean;