/**
 * Unified Proxy Detector
 *
 * Single source of truth for CLIProxy detection.
 * Uses multiple detection methods with fallbacks:
 * 1. HTTP health check (most reliable, ~1s timeout)
 * 2. Session lock file (sessions.json)
 * 3. Port process detection (fallback for orphaned proxies)
 *
 * Detection Order Rationale:
 * - HTTP first: Fastest verification that proxy is responsive
 * - Session lock second: Catches proxies that are starting up
 * - Port process third: Handles orphaned proxies and Windows PID-XXXXX case
 *
 * Solves race conditions between cliproxy-executor.ts and service-manager.ts
 */
import { PortProcess } from '../../utils/port-utils';
/** Detection method used to find the proxy */
export type DetectionMethod = 'http' | 'session-lock' | 'port-process' | 'http-retry';
/** Proxy detection status */
export interface ProxyStatus {
    /** Whether a proxy is running on the port */
    running: boolean;
    /** Whether the proxy was verified healthy via HTTP */
    verified: boolean;
    /** How the proxy was detected */
    method?: DetectionMethod;
    /** PID of the running proxy (if known) */
    pid?: number;
    /** Whether port is blocked by non-CLIProxy process */
    blocked?: boolean;
    /** Process blocking the port (if blocked) */
    blocker?: PortProcess;
    /** Number of active sessions (if session-lock found) */
    sessionCount?: number;
    /** Version of the running proxy (from session lock) */
    version?: string;
}
/**
 * Detect running CLIProxy using multiple methods with fallbacks.
 *
 * Detection order (most reliable first):
 * 1. HTTP health check - fastest, verifies proxy is responsive
 * 2. Session lock - checks sessions.json for tracked proxy
 * 3. Port process - checks OS-level port ownership
 *
 * @param port Port to check (default: 8317)
 * @param verbose Enable verbose logging (default: false)
 * @returns ProxyStatus with detection details
 */
export declare function detectRunningProxy(port?: number, verbose?: boolean): Promise<ProxyStatus>;
/**
 * Wait for proxy to become ready (healthy via HTTP).
 * Useful after detecting proxy via session-lock or port-process.
 *
 * @param port Port to check
 * @param timeout Max wait time in ms (default: 5000)
 * @param pollInterval Time between checks in ms (default: 100)
 * @returns true if proxy became ready, false if timeout
 */
export declare function waitForProxyHealthy(port: number, timeout?: number, pollInterval?: number): Promise<boolean>;
/**
 * Attempt to reclaim an orphaned CLIProxy (running but not in session tracker).
 * Registers a new session with the detected proxy.
 *
 * @param port Port where proxy is running
 * @param pid PID of the proxy process
 * @param verbose Enable verbose logging (default: false)
 * @returns Session ID if reclaimed, null if failed
 */
export declare function reclaimOrphanedProxy(port: number, pid: number, verbose?: boolean): string | null;
//# sourceMappingURL=proxy-detector.d.ts.map