// Shared state between server.js and api-prompts.js
// Avoids circular requires
const EventEmitter = require('events');

const sessions = new Map(); // id -> { ptyProcess, clients, meta }

// Session event bus — decouples PTY lifecycle from listeners (queue engine,
// auto-approval, idle detection, hooks). Inspired by tmux's hook system.
const sessionEvents = new EventEmitter();
sessionEvents.setMaxListeners(50);

module.exports = { sessions, sessionEvents };
