/** * Engine event-driven alert manager. Evaluates metric-based rules against * sliding time windows and dispatches alert:fired/alert:resolved events * with optional webhook notifications. * * @module alerting/alert-manager */ import type { AlertStateSnapshot, AlertingOptions } from './types'; /** * Event-driven alert manager that evaluates metric-based rules against sliding * time windows and fires `alert:fired` / `alert:resolved` lifecycle events. * * Construct with an `EventTarget` (typically the {@link Engine} instance) and an * {@link AlertingOptions} configuration. The manager subscribes to engine events * on construction and re-evaluates rules every 10 seconds. Dispose it to stop * background evaluation and cancel pending webhooks. * * @example * ```ts * import { Engine, MemoryStorage, AlertManager } from '@lostgradient/weft'; * * await using storage = new MemoryStorage(); * await using engine = new Engine({ storage }); * * using manager = new AlertManager(engine, { * rules: [ * { metric: 'workflow.failure_rate', threshold: 0.1, window: '5m', action: 'log' }, * ], * }); * * engine.addEventListener('alert:fired', (e) => { * console.log('Alert fired!', e); * }); * ``` */ export declare class AlertManager implements Disposable { #private; constructor(target: EventTarget, options: AlertingOptions, getNow?: () => number, startBackgroundTick?: boolean); /** Re-evaluate every rule once, for hosts that drive maintenance explicitly. */ tick(): void; /** Get a detached snapshot of all alert rules (for debugging/testing). */ get states(): readonly AlertStateSnapshot[]; /** Get detached snapshots of the alert rules that are currently firing. */ get activeStates(): readonly AlertStateSnapshot[]; [Symbol.dispose](): void; }