export type CodexFailureStage = "backend_precheck" | "fallback_scan" | "rpc_dispatch"; export type CodexFallbackHealth = "unique_verified" | "no_match" | "multiple_matches" | "not_checked"; export interface CodexDeliveryDiagnostics { stage: CodexFailureStage; target_thread_id: string | null; dispatch_state: "not_sent" | "unknown" | "accepted"; fallback: CodexFallbackHealth; reason: string; rpc_method?: string; rpc_code?: number; recent_list_match?: "matched" | "no_match" | "not_checked"; recent_list_observed_at?: string; } export declare function codexDiagnosticReason(value: unknown): string; export declare function codexDiagnosticThread(value: unknown): string | null; /** Only these fields may cross the RPC/error/diagnostic-cache boundary. Never copy message, data or params. */ export declare function codexDeliveryDiagnostics(error: unknown, threadId: unknown, stage: CodexFailureStage, fallback?: CodexFallbackHealth): CodexDeliveryDiagnostics; /** Re-project persisted diagnostics too: disk records are not permission to expose arbitrary fields. */ export declare function parseCodexDeliveryDiagnostics(value: unknown): CodexDeliveryDiagnostics | undefined; export declare function codexRecoveryActions(diagnostics?: CodexDeliveryDiagnostics): string[]; export declare function codexDeliveryFailureMessage(message: string, diagnostics: CodexDeliveryDiagnostics): string; export declare class CodexDeliveryError extends Error { readonly diagnostics: CodexDeliveryDiagnostics; readonly code: string; readonly dispatchState: CodexDeliveryDiagnostics["dispatch_state"]; constructor(message: string, diagnostics: CodexDeliveryDiagnostics); } export interface CodexRoutingHealth { backend: "loaded" | "unavailable" | "check_failed"; fallback: CodexFallbackHealth; check_depth: "discovery" | "snapshot"; observed_at: string; last_failure: ({ observed_at: string; } & CodexDeliveryDiagnostics) | null; recovery_actions: string[]; } /** A missing terminal alias does not downgrade a working native route. Health never authorizes input. */ export declare function codexRoutingHealth(backend: CodexRoutingHealth["backend"], checkDepth: CodexRoutingHealth["check_depth"], observedAt: string, lastFailure?: CodexRoutingHealth["last_failure"]): CodexRoutingHealth; export declare function compactCodexRoutingHealth(value: unknown): CodexRoutingHealth | undefined;