/** Tracks agent runs that have emitted lifecycle `phase: start` without matching `end`/`error`. */
const active = new Set();
export function observeAgentEventForActiveRuns(evt) {
    if (evt.stream !== "lifecycle")
        return;
    const phase = evt.data.phase;
    if (phase === "start")
        active.add(evt.runId);
    if (phase === "end" || phase === "error")
        active.delete(evt.runId);
}
export function getActiveRunIds() {
    return [...active];
}
export function getActiveRunCount() {
    return active.size;
}
export function resetActiveRunsForTest() {
    active.clear();
}
