import { EventEmitter } from "events";
export type SessionType = "web" | "cli";
export interface SessionInfo {
    chatId: string;
    type: SessionType;
    startedAt: number;
    /** Only set for web sessions */
    abortController?: AbortController;
    /** Only set for web sessions */
    emitter?: EventEmitter;
}
export interface SessionEvent {
    event: "session_started" | "session_stopped" | "chat_metadata_updated" | "user_summoned";
    chatId: string;
    type?: SessionType;
    /** Optional payload for metadata/summon events */
    data?: Record<string, unknown>;
}
export interface SummonInfo {
    message: string;
    urgency: "normal" | "urgent";
    createdAt: string;
}
/**
 * Centralized registry of all active chat sessions (both web and CLI).
 *
 * Extends EventEmitter to broadcast "change" events whenever a session
 * starts or stops, enabling real-time status updates across the app.
 */
declare class SessionRegistry extends EventEmitter {
    private sessions;
    private _version;
    private _metadataVersion;
    private _activeSummons;
    constructor();
    /** Session version counter — incremented on register/unregister/migrate */
    get version(): number;
    /** Metadata version counter — incremented on metadata/summon changes */
    get metadataVersion(): number;
    /** Current active summons (chatId → summon data) */
    get activeSummons(): Map<string, SummonInfo>;
    /** Bump metadata version and emit a change event */
    notifyMetadata(chatId: string, data?: Record<string, unknown>): void;
    /** Register an active summon for a chat */
    addSummon(chatId: string, data: SummonInfo): void;
    /** Clear summon for a chat */
    clearSummon(chatId: string): void;
    /**
     * Register a new active session.
     * If a session already exists for this chatId, it is unregistered first
     * (emitting a "session_stopped" event) to avoid leaking resources.
     * Emits a "change" event with { event: "session_started", chatId, type }.
     */
    register(chatId: string, info: Omit<SessionInfo, "chatId" | "startedAt">): void;
    /**
     * Unregister a session (it has completed or been stopped).
     * Emits a "change" event with { event: "session_stopped", chatId, type }.
     * Returns true if a session was actually removed, false if it didn't exist.
     */
    unregister(chatId: string): boolean;
    /**
     * Migrate a session from one tracking ID to another (e.g., temp ID → real session ID).
     * Emits stop for old ID and start for new ID.
     */
    migrate(oldId: string, newId: string): void;
    /**
     * Get session info for a specific chat ID.
     */
    get(chatId: string): SessionInfo | undefined;
    /**
     * Check if a session exists for the given chat ID.
     */
    has(chatId: string): boolean;
    /**
     * Get a snapshot of all active sessions.
     * Returns a plain object map of chatId → { type, startedAt }.
     */
    getAll(): Record<string, {
        type: SessionType;
        startedAt: number;
    }>;
    /**
     * Get the number of active sessions.
     */
    get size(): number;
}
/** Singleton session registry instance */
export declare const sessionRegistry: SessionRegistry;
export {};
//# sourceMappingURL=session-registry.d.ts.map