/** * ChannelHeartbeatScheduler — runs per-account heartbeat probes for plugins * that expose a `heartbeat.check(...)` hook, records the result in the shared * {@link ChannelHealthMonitor}, and asks the lifecycle supervisor for a soft * restart when a check fails (rate-limited to once per minute per channel). * * Previously this lived as `_scheduleHeartbeat` + `_clearHeartbeatTimers` + * `_softRestartChannel` + two private Maps on `ChannelManager`. Extracting it * makes the heartbeat policy testable in isolation and lets the lifecycle * supervisor focus on plugin start/stop without worrying about timer wiring. */ import type { Config } from '../config/schema.js'; import type { ChannelPlugin } from './plugin-types.js'; import type { ChannelHealthMonitor } from './health-monitor.js'; export interface ChannelHeartbeatSchedulerOptions { /** Effective config snapshot (per-account listing comes from `plugin.config.listAccountIds(cfg)`). */ getConfig: () => Config; /** Shared health monitor that channel APIs surface to the UI. */ healthMonitor: ChannelHealthMonitor; /** * Triggered when a check fails AND we are past the restart-throttle window. * The supervisor performs `stop()` + `startPlugin()`; the scheduler does not * touch plugin lifecycle directly. */ requestSoftRestart: (channelId: string) => void; } export declare class ChannelHeartbeatScheduler { private readonly opts; /** Key shape: `${pluginId}:${accountId}`. */ private readonly timers; private readonly lastRestartAt; constructor(opts: ChannelHeartbeatSchedulerOptions); /** Register heartbeat checks for every account exposed by the plugin. */ schedule(plugin: ChannelPlugin): void; /** Drop every probe scheduled for `pluginId` (called on stop / soft-restart). */ clear(pluginId: string): void; /** Test helper / process shutdown. */ clearAll(): void; private runProbe; }