/**
 * ChatKit Browser Pool
 *
 * Manages a pool of browser contexts for concurrent ChatKit evaluations.
 * This significantly reduces resource usage compared to spawning separate
 * browsers for each test.
 *
 * Architecture:
 *   - Single browser process (shared across all tests)
 *   - Multiple browser contexts (isolated like incognito windows)
 *   - Shared HTTP server with per-workflow template routing
 *   - Pages are workflow-specific (different workflows get different pages)
 */
import { type BrowserContext, type Page } from 'playwright';
interface PooledPage {
    context: BrowserContext;
    page: Page;
    ready: boolean;
    inUse: boolean;
    templateKey: string;
}
interface ChatKitPoolConfig {
    maxConcurrency: number;
    headless: boolean;
    serverPort?: number;
}
/**
 * Singleton browser pool for ChatKit evaluations.
 * Supports high concurrency by reusing browser contexts.
 * Each workflow gets its own isolated pages via template routing.
 */
export declare class ChatKitBrowserPool {
    private static instance;
    private static cleanupRegistered;
    private browser;
    private server;
    private serverPort;
    private pages;
    private waitQueue;
    private config;
    private templates;
    private initialized;
    private initPromise;
    private idleTimer;
    private constructor();
    /**
     * Register process exit handlers to clean up browser resources
     */
    private static registerCleanupHandlers;
    /**
     * Get the singleton pool instance
     */
    static getInstance(config?: Partial<ChatKitPoolConfig>): ChatKitBrowserPool;
    /**
     * Reset the singleton (for testing)
     */
    static resetInstance(): void;
    /**
     * Generate a template key from workflow configuration.
     * This ensures different workflows get isolated pages.
     */
    static generateTemplateKey(workflowId: string, version?: string, userId?: string): string;
    /**
     * Register a template for a workflow configuration
     */
    setTemplate(templateKey: string, html: string): void;
    /**
     * Initialize the pool - launches browser and creates server
     */
    initialize(): Promise<void>;
    private doInitialize;
    /**
     * Acquire a page from the pool for a specific template.
     * Only returns pages configured for the requested template.
     * Blocks if all pages are in use.
     */
    acquirePage(templateKey: string): Promise<PooledPage>;
    /**
     * Release a page back to the pool
     */
    releasePage(pooledPage: PooledPage): Promise<void>;
    /**
     * Try to serve waiting requests by creating new pages if we have capacity
     */
    private tryServeWaiters;
    /**
     * Schedule automatic shutdown if pool remains idle
     */
    private scheduleIdleShutdown;
    /**
     * Cancel scheduled idle shutdown
     */
    private cancelIdleTimer;
    /**
     * Create a new pooled page with ChatKit initialized for a specific template
     */
    private createPooledPage;
    private refreshPooledPage;
    /**
     * Get pool statistics
     */
    getStats(): {
        total: number;
        inUse: number;
        waiting: number;
        templates: number;
    };
    /**
     * Shutdown the pool and release all resources
     */
    shutdown(): Promise<void>;
}
export {};
//# sourceMappingURL=chatkit-pool.d.ts.map