UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and

108 lines (107 loc) 3.37 kB
/** * Provider Health Checking System * Prevents 500 errors by validating provider availability and configuration */ import { AIProviderName } from "../core/types.js"; export interface ProviderHealthStatus { provider: AIProviderName; isHealthy: boolean; isConfigured: boolean; hasApiKey: boolean; lastChecked: Date; error?: string; warning?: string; responseTime?: number; configurationIssues: string[]; recommendations: string[]; } export interface ProviderHealthCheckOptions { timeout?: number; includeConnectivityTest?: boolean; includeModelValidation?: boolean; cacheResults?: boolean; maxCacheAge?: number; } export declare class ProviderHealthChecker { private static healthCache; private static readonly DEFAULT_TIMEOUT; private static readonly DEFAULT_CACHE_AGE; private static readonly CONSECUTIVE_FAILURE_THRESHOLD; private static consecutiveFailures; /** * Validate and return a safe failure threshold value */ private static getValidatedFailureThreshold; /** * Comprehensive health check for a provider */ static checkProviderHealth(providerName: AIProviderName, options?: ProviderHealthCheckOptions): Promise<ProviderHealthStatus>; /** * Check environment configuration for a provider */ private static checkEnvironmentConfiguration; /** * Check API key validity (format validation) */ private static checkApiKeyValidity; /** * Check connectivity to provider endpoints */ private static checkConnectivity; /** * Check model availability (if possible without making API calls) */ private static checkModelAvailability; /** * Get required environment variables for a provider */ private static getRequiredEnvironmentVariables; /** * Get API key environment variable for a provider */ private static getApiKeyEnvironmentVariable; /** * Validate API key format for a provider */ private static validateApiKeyFormat; /** * Get health check endpoint for connectivity testing */ private static getProviderHealthEndpoint; /** * Provider-specific configuration checks */ private static checkProviderSpecificConfig; /** * Get common models for a provider */ private static getCommonModelsForProvider; /** * Get cached health status if still valid */ private static getCachedHealth; /** * Clear health cache for a provider or all providers */ static clearHealthCache(providerName?: AIProviderName): void; /** * Get the best healthy provider from a list of options * Prioritizes healthy providers over configured but unhealthy ones */ static getBestHealthyProvider(preferredProviders?: string[]): Promise<string | null>; /** * Get health status for all registered providers */ static checkAllProvidersHealth(options?: ProviderHealthCheckOptions): Promise<ProviderHealthStatus[]>; /** * Get a summary of provider health */ static getHealthSummary(healthStatuses: ProviderHealthStatus[]): { total: number; healthy: number; configured: number; hasIssues: number; healthyProviders: string[]; unhealthyProviders: string[]; }; }