/**
 * Python Worker Process Pool
 *
 * Maintains warm Python processes to amortize import costs (torch, transformers).
 * Workers accept JSON commands on stdin, return JSON on stdout.
 * Auto-restart on crash, health checks via heartbeat.
 *
 * CRITICAL: NEVER use console.log() - stdout is JSON-RPC protocol.
 *
 * @module services/python-pool
 */
import { EventEmitter } from 'events';
export interface PoolConfig {
    /** Number of worker processes to maintain (default: 3) */
    poolSize: number;
    /** Restart worker after this many tasks (default: 100) */
    maxTasksPerWorker: number;
    /** Health check interval in ms (default: 30000) */
    healthCheckIntervalMs: number;
    /** Task timeout in ms (default: 120000) */
    taskTimeoutMs: number;
}
export interface PoolStatus {
    total: number;
    busy: number;
    idle: number;
    queued: number;
}
export declare class PythonPool extends EventEmitter {
    private workers;
    private taskQueue;
    private readonly config;
    private healthCheckTimer;
    private nextWorkerId;
    private shuttingDown;
    private readonly pythonCommand;
    constructor(config?: Partial<PoolConfig>);
    /**
     * Start the pool with the given Python script.
     *
     * @param scriptPath - Path to the Python worker script
     * @throws Error if pool is shutting down
     */
    start(scriptPath: string): void;
    /**
     * Execute a command on the next available worker.
     *
     * If all workers are busy, the task is queued and dispatched when
     * a worker becomes available.
     *
     * @param command - JSON-serializable command object
     * @returns Promise resolving with the worker's JSON response
     * @throws Error if pool is shutting down or task times out
     */
    execute(command: Record<string, unknown>): Promise<unknown>;
    /**
     * Shut down all workers and reject queued tasks.
     */
    shutdown(): Promise<void>;
    /**
     * Get pool status for diagnostics.
     */
    getStatus(): PoolStatus;
    private spawnWorker;
    private getAvailableWorker;
    private dispatchTask;
    private processQueue;
    private healthCheck;
}
//# sourceMappingURL=python-pool.d.ts.map