/** * Restart Health - Wait loop after restart to verify gateway is healthy * * Polls service runtime + port usage + HTTP health probe to confirm: * 1. Service is running with a new PID * 2. Port is being listened on by the new process * 3. HTTP /api/health responds successfully * 4. Version matches expected (optional) */ import type { GatewayServiceRuntime } from '../../../daemon/types.js'; import type { PortUsage } from '../../../infra/ports.js'; export declare const DEFAULT_RESTART_HEALTH_TIMEOUT_MS = 60000; export declare const DEFAULT_RESTART_HEALTH_DELAY_MS = 500; export declare const DEFAULT_RESTART_HEALTH_ATTEMPTS: number; export type GatewayRestartWaitTask = 'healthy' | 'version-mismatch' | 'stale-pids' | 'stopped-free' | 'timeout'; export interface GatewayRestartSnapshot { runtime?: GatewayServiceRuntime; portUsage?: PortUsage; healthy: boolean; staleGatewayPids: number[]; gatewayVersion?: string | null; expectedVersion?: string; versionMismatch?: { expected: string; actual: string | null; }; waitTask?: GatewayRestartWaitTask; elapsedMs?: number; } interface RestartHealthService { readRuntime: (env?: Record) => Promise; } /** * Wait for gateway restart to complete and verify health. * * Loop: * 1. Check service runtime → get PID * 2. inspectPortUsage → confirm port is busy with new process * 3. HTTP probe /api/health → confirm reachable * 4. Version match (if expectedVersion provided) */ export declare function waitForRestartHealth(params: { service: RestartHealthService; port: number; expectedVersion?: string; timeoutMs?: number; delayMs?: number; token?: string; onProgress?: (snapshot: GatewayRestartSnapshot) => void; }): Promise; export type GatewayPortHealthSnapshot = { portUsage?: PortUsage; healthy: boolean; }; export declare function waitForGatewayHealthyListener(params: { port: number; attempts?: number; delayMs?: number; token?: string; }): Promise; export declare function renderGatewayPortHealthDiagnostics(snapshot: GatewayPortHealthSnapshot): string[]; export {};