/** * Server Readiness Health Check * Issue #1194: update-specific readiness probe (D-5 / D-12 / D-13 / S3-001) * * The CLI has no reusable readiness primitive: `start.ts` prints the URL as soon * as `daemon.start()` returns a PID, and `DaemonManager.waitForExit()` waits for * process *exit* (S1-001). This module implements the readiness contract that * `commandmate update` needs. * * Why not `ApiClient.get()`: it does not set `redirect`, so fetch defaults to * `follow`. With auth enabled, `middleware.ts:142` redirects (307) to `/login`, * which is an AUTH_EXCLUDED_PATH returning 200 HTML *without touching the DB* — * i.e. following the redirect yields a "200 that proves nothing" before * migrations complete (S3-001). Adding `redirect: 'manual'` to ApiClient would * ripple into send/wait/respond/capture/instances, so this probe is standalone. * * @module health-check */ /** Poll interval while waiting for readiness */ export declare const HEALTH_CHECK_INTERVAL_MS = 500; /** Maximum time to wait for readiness */ export declare const HEALTH_CHECK_TIMEOUT_MS = 30000; /** * Outcome of a readiness wait. * * - `ready`: migrations are proven complete (200 + JSON + `success === true`) * - `degraded`: the server answers but readiness cannot be proven (auth / IP / TLS) * - `timeout`: no conclusive answer within the timeout */ export type ReadinessResult = 'ready' | 'degraded' | 'timeout'; /** * Options for {@link waitForReady} */ export interface WaitForReadyOptions { /** Bearer token to send (from CM_AUTH_TOKEN) */ token?: string; /** Poll interval in ms (default: {@link HEALTH_CHECK_INTERVAL_MS}) */ intervalMs?: number; /** Overall timeout in ms (default: {@link HEALTH_CHECK_TIMEOUT_MS}) */ timeoutMs?: number; } /** * Poll the server until it proves readiness. * * Probes `/api/repositories`, which goes through `getDbInstance()` and * therefore runs `runMigrations()` idempotently — a successful JSON response * implies migrations completed. Note that migrations finish *after* the port is * bound (`server.ts:271-275`), so a naive TCP/HTML check is not sufficient. * * @param baseUrl - Server base URL, taken from `IDaemonManager.getStatus().url` (D-13) * @param options - Token and polling overrides * @returns The readiness outcome */ export declare function waitForReady(baseUrl: string, options?: WaitForReadyOptions): Promise; //# sourceMappingURL=health-check.d.ts.map