// In-memory PTY-handle store. The canonical row index lives in the
// fs-watcher; row state is derived from disk on demand (Task 258). This
// store only tracks the live PTY handles the manager itself spawned —
// they aren't on disk. Lookups by alternative identifiers (bridgeSuffix,
// pid, bridgeSessionId) go through the watcher first to resolve to the
// canonical sessionId; the store is then keyed solely on sessionId.
//
// Lifecycle:
//   - pty-spawner awaits the PID-file CREATE event from the watcher
//     before returning a /spawn response. The store row is registered at
//     that point with sessionId known and bridgeSessionId carried from
//     the PID file. By the time /spawn returns, sessionId is final.
//   - URL capture continues in parallel; the row's `url` field is
//     mutated in place when the URL banner fires (may arrive before or
//     after the PID-file event; both orderings are safe).
//   - The jsonl path is derived from sessionId + spawnCwd at every read
//     site — never stored. Task 258 deleted the stored field.
export class SessionStore {
    bySessionId = new Map();
    add(s) {
        this.bySessionId.set(s.sessionId, s);
    }
    get(sessionId) {
        return this.bySessionId.get(sessionId);
    }
    remove(sessionId) {
        const s = this.bySessionId.get(sessionId);
        if (!s)
            return undefined;
        this.bySessionId.delete(sessionId);
        return s;
    }
    listBySender(senderId, opts = {}) {
        const includeHidden = opts.includeHidden === true;
        const out = [];
        for (const s of this.bySessionId.values()) {
            if (s.senderId !== senderId)
                continue;
            if (!includeHidden && s.hidden)
                continue;
            out.push(s);
        }
        return out;
    }
    all() {
        return [...this.bySessionId.values()];
    }
    size() {
        return this.bySessionId.size;
    }
}
//# sourceMappingURL=session-store.js.map