import type { NexusAIConfig } from '../types/config.js'; import type { SchemaMigration } from '../utils/schema-migrations.js'; /** How one check came out: `fail` breaks the deployment, `warn` needs a look, `skip` had nothing to check. */ export type DoctorStatus = 'ok' | 'warn' | 'fail' | 'skip'; /** One check's result. */ export interface DoctorCheck { /** A stable id, such as `node` or `migrations`. */ id: string; /** What was checked, in a few words. */ title: string; /** How it came out. */ status: DoctorStatus; /** What was found. Never a secret's value. */ detail: string; /** What to do about a warning or a failure. */ hint?: string; } /** Every check's result, and whether the deployment can run. */ export interface DoctorReport { /** The checks, in the order they ran. */ checks: DoctorCheck[]; /** True when nothing failed. */ ok: boolean; /** Checks that failed. */ failures: number; /** Checks that warned. */ warnings: number; } /** A database for the doctor to reach, as `nexus db` reaches one. */ export interface DoctorDatabase { /** A Postgres client (`query`) or a SQLite handle or client. */ client: unknown; /** Which kind it is. Detected from the client when omitted. */ dialect?: 'postgres' | 'sqlite'; /** The migrations it should have. Defaults to every bundled adapter's on its default tables. */ migrations?: readonly SchemaMigration[]; /** The table that records applied migrations. */ table?: string; } /** What the doctor knows about how the application is deployed. */ export interface DoctorDeployment { /** How many replicas run it. Settings that keep state in one process are checked only above 1. */ replicas: number; /** * The stores and shared state it uses, by any name: a checkpointer, the operation store, the * server's state, tenant usage, a rate-limit store, a circuit store, a cache, a tracer. Each is * reported when it keeps its state in process memory, where each replica would see only its own, * and when it lacks an opt-in setting a deployment needs: a Redis operation store without its * dispatch index, or a tracer writing to a persistent store without incremental tracing. */ stores?: Record; } /** What `diagnose()` checks. Everything is optional; a check without its input is skipped. */ export interface DoctorOptions { /** The Node.js version to check. Defaults to the running one. */ nodeVersion?: string; /** Where credentials are read from. Defaults to `process.env`. Only names are reported. */ env?: Record; /** Whether a package is installed. Defaults to resolving it from the working directory. */ resolvePackage?: (name: string) => boolean; /** A database: connectivity, and migrations pending or changed. */ database?: DoctorDatabase; /** A Redis client to ping. */ redis?: { ping(): unknown; }; /** An operation store, read for leases that lapsed and a queue nobody drains. */ operations?: { stats?(now: string): unknown; list?(): unknown; }; /** How long the oldest queued operation may wait before the queue counts as stalled. Defaults to 15 minutes. */ maxQueueAgeMs?: number; /** A client, read for provider health. */ ai?: { getProviderHealth(): ReadonlyArray<{ providerName: string; healthy: boolean; stale?: boolean; }>; }; /** How old the model registry may be, in days. Defaults to the registry's own window. */ registryMaxAgeDays?: number; /** * The application's model registry configuration, such as `withRegistryData()` produced, so the * registry's age is measured from the data it supplies rather than the bundled data. */ models?: NexusAIConfig['models']; /** How the application is deployed. */ deployment?: DoctorDeployment; /** * A release to check readiness for: `3.0` lists, for the stores `deployment` describes, what 3.0's * defaults would change and what to do first, or confirms the preview of them is on. Without it, the * check is skipped. */ upgrade?: '3.0'; /** Replaces the clock, for tests. */ now?: () => Date; } /** * Runs every check its options allow and reports each, never throwing: a check that cannot run is a * failure with the reason. */ export declare function diagnose(options?: DoctorOptions): Promise;