"use strict";
/**
 * Process-local event bus for chat list mutations.
 *
 * The cockpit sidebar (and any other surface that renders a list of
 * chats) needs to react when a chat is created/updated/deleted from
 * ANY source — REST POST, MCP tool call, runner status change. The
 * daemon polled every 12s before, which is fine for status drift but
 * looks broken when a freshly-fired MCP chat takes 12s to appear.
 *
 * We chose a process-local EventEmitter over a DB-NOTIFY broadcast
 * because chorus is single-daemon today; if we ever shard the daemon,
 * this becomes a libsql LISTEN. Subscribers are SSE handlers in
 * `routes/chats-events.ts`.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.chatEventsBus = void 0;
const node_events_1 = require("node:events");
class ChatEventsBus extends node_events_1.EventEmitter {
    emitChange(chatId, kind) {
        const ev = { chatId, kind, ts: Date.now() };
        this.emit('change', ev);
    }
}
exports.chatEventsBus = new ChatEventsBus();
exports.chatEventsBus.setMaxListeners(50);
//# sourceMappingURL=chat-events-bus.js.map