/**
 * Minimal in-process event bus for agent-related notifications.
 *
 * Subscribers include:
 *   - the settings UI's SSE endpoint (live updates in the browser tab)
 *   - the tray icon updater (dynamic "Pending: N" item)
 *
 * The bus is deliberately simple: one event type ("grant-changed") carrying
 * a snapshot of the grant record. Consumers decide what to do with it.
 * Decoupling via events means the store doesn't need to know about either
 * the UI or the tray — they subscribe independently.
 */
import { EventEmitter } from "events";
class NotificationBroker extends EventEmitter {
    sequence = 0;
    /** Emit a grant-changed event. All subscribers observe synchronously. */
    emitGrantChanged(kind, grant) {
        this.sequence += 1;
        this.emit("grant-changed", { kind, grant, seq: this.sequence });
    }
    subscribe(listener) {
        this.on("grant-changed", listener);
        return () => { this.off("grant-changed", listener); };
    }
    /** Current sequence, for health checks and gap detection. */
    get seq() { return this.sequence; }
}
// Module-scope singleton so both the settings server and the tray updater
// can subscribe without threading the broker through every call site.
export const notifications = new NotificationBroker();
//# sourceMappingURL=notifications.js.map