UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

226 lines (225 loc) 8.46 kB
/** * Timeout Constants for NeuroLink * * Centralized timeout configuration to replace magic numbers throughout the codebase. * Each timeout value includes business justification and use case documentation. * * @fileoverview Timeout constants organized by functional area * @author NeuroLink Team * @version 1.0.0 */ /** * Tool execution timeout constants * These values balance reliability vs performance for AI tool operations */ export declare const TOOL_TIMEOUTS: { /** Default timeout for AI tool execution - handles most complex operations */ readonly EXECUTION_DEFAULT_MS: 30000; /** Fast timeout for simple tools that should complete quickly */ readonly EXECUTION_FAST_MS: 5000; /** Extended timeout for complex analysis operations */ readonly EXECUTION_COMPLEX_MS: 60000; /** Ultra-long timeout for batch operations */ readonly EXECUTION_BATCH_MS: 120000; }; /** * Provider connectivity and health check timeouts * Tuned for quick health checks while allowing for network latency */ export declare const PROVIDER_TIMEOUTS: { /** Quick provider health check - should fail fast */ readonly TEST_MS: 5000; /** Provider connection establishment timeout */ readonly CONNECTION_MS: 10000; /** Authentication validation timeout */ readonly AUTH_MS: 3000; /** Model availability check timeout */ readonly MODEL_CHECK_MS: 8000; /** Provider capability discovery timeout */ readonly CAPABILITY_DISCOVERY_MS: 15000; }; /** * MCP (Model Context Protocol) system timeouts * Balanced for reliable MCP server communication */ export declare const MCP_TIMEOUTS: { /** MCP server initialization timeout */ readonly INITIALIZATION_MS: 3000; /** Tool discovery timeout per server */ readonly TOOL_DISCOVERY_MS: 10000; /** MCP client connection timeout */ readonly CLIENT_CONNECTION_MS: 5000; /** External MCP server startup timeout */ readonly EXTERNAL_SERVER_STARTUP_MS: 15000; /** MCP server shutdown timeout */ readonly SHUTDOWN_MS: 5000; }; /** * Circuit breaker timeout configuration * Prevents cascading failures while allowing recovery */ export declare const CIRCUIT_BREAKER_TIMEOUTS: { /** Circuit breaker reset timeout - how long to wait before retry */ readonly RESET_MS: 60000; /** Half-open state timeout - trial period for recovery */ readonly HALF_OPEN_MS: 30000; /** Monitoring window for failure rate calculation */ readonly MONITORING_WINDOW_MS: 300000; }; /** * Network operation timeouts * Configured for various network conditions and use cases */ export declare const NETWORK_TIMEOUTS: { /** Standard network request timeout */ readonly REQUEST_MS: 15000; /** Quick connectivity check timeout */ readonly QUICK_CHECK_MS: 2000; /** File download/upload timeout per MB */ readonly TRANSFER_PER_MB_MS: 1000; /** DNS resolution timeout */ readonly DNS_RESOLUTION_MS: 3000; /** WebSocket connection timeout */ readonly WEBSOCKET_CONNECTION_MS: 10000; }; /** * System operation timeouts * For application lifecycle and resource management */ export declare const SYSTEM_TIMEOUTS: { /** Application graceful shutdown timeout */ readonly GRACEFUL_SHUTDOWN_MS: 30000; /** Resource cleanup timeout */ readonly CLEANUP_OPERATION_MS: 5000; /** Cache flush timeout */ readonly CACHE_FLUSH_MS: 3000; /** Health check interval */ readonly HEALTH_CHECK_INTERVAL_MS: 30000; /** Metrics collection timeout */ readonly METRICS_COLLECTION_MS: 1000; }; /** * Development and testing timeouts * Separate timeouts for development vs production environments */ export declare const DEV_TIMEOUTS: { /** Extended timeout for debugging */ readonly DEBUG_EXTENDED_MS: 300000; /** Unit test timeout */ readonly UNIT_TEST_MS: 10000; /** Integration test timeout */ readonly INTEGRATION_TEST_MS: 60000; /** Mock service response delay */ readonly MOCK_DELAY_MS: 100; }; /** * Combined timeout constants for easy access * Exports all timeout categories in a single object */ export declare const TIMEOUTS: { readonly TOOL: { /** Default timeout for AI tool execution - handles most complex operations */ readonly EXECUTION_DEFAULT_MS: 30000; /** Fast timeout for simple tools that should complete quickly */ readonly EXECUTION_FAST_MS: 5000; /** Extended timeout for complex analysis operations */ readonly EXECUTION_COMPLEX_MS: 60000; /** Ultra-long timeout for batch operations */ readonly EXECUTION_BATCH_MS: 120000; }; readonly PROVIDER: { /** Quick provider health check - should fail fast */ readonly TEST_MS: 5000; /** Provider connection establishment timeout */ readonly CONNECTION_MS: 10000; /** Authentication validation timeout */ readonly AUTH_MS: 3000; /** Model availability check timeout */ readonly MODEL_CHECK_MS: 8000; /** Provider capability discovery timeout */ readonly CAPABILITY_DISCOVERY_MS: 15000; }; readonly MCP: { /** MCP server initialization timeout */ readonly INITIALIZATION_MS: 3000; /** Tool discovery timeout per server */ readonly TOOL_DISCOVERY_MS: 10000; /** MCP client connection timeout */ readonly CLIENT_CONNECTION_MS: 5000; /** External MCP server startup timeout */ readonly EXTERNAL_SERVER_STARTUP_MS: 15000; /** MCP server shutdown timeout */ readonly SHUTDOWN_MS: 5000; }; readonly CIRCUIT_BREAKER: { /** Circuit breaker reset timeout - how long to wait before retry */ readonly RESET_MS: 60000; /** Half-open state timeout - trial period for recovery */ readonly HALF_OPEN_MS: 30000; /** Monitoring window for failure rate calculation */ readonly MONITORING_WINDOW_MS: 300000; }; readonly NETWORK: { /** Standard network request timeout */ readonly REQUEST_MS: 15000; /** Quick connectivity check timeout */ readonly QUICK_CHECK_MS: 2000; /** File download/upload timeout per MB */ readonly TRANSFER_PER_MB_MS: 1000; /** DNS resolution timeout */ readonly DNS_RESOLUTION_MS: 3000; /** WebSocket connection timeout */ readonly WEBSOCKET_CONNECTION_MS: 10000; }; readonly SYSTEM: { /** Application graceful shutdown timeout */ readonly GRACEFUL_SHUTDOWN_MS: 30000; /** Resource cleanup timeout */ readonly CLEANUP_OPERATION_MS: 5000; /** Cache flush timeout */ readonly CACHE_FLUSH_MS: 3000; /** Health check interval */ readonly HEALTH_CHECK_INTERVAL_MS: 30000; /** Metrics collection timeout */ readonly METRICS_COLLECTION_MS: 1000; }; readonly DEV: { /** Extended timeout for debugging */ readonly DEBUG_EXTENDED_MS: 300000; /** Unit test timeout */ readonly UNIT_TEST_MS: 10000; /** Integration test timeout */ readonly INTEGRATION_TEST_MS: 60000; /** Mock service response delay */ readonly MOCK_DELAY_MS: 100; }; }; /** * Timeout utility functions */ export declare const TimeoutUtils: { /** * Get environment-adjusted timeout * @param baseTimeout - Base timeout value in milliseconds * @param environment - Target environment (development gets 2x timeout) * @returns Adjusted timeout value */ readonly getEnvironmentTimeout: (baseTimeout: number, environment?: string | undefined) => number; /** * Get timeout with jitter to prevent thundering herd * @param baseTimeout - Base timeout value * @param jitterFactor - Jitter factor (0.1 = 10% random variation) * @returns Timeout with random jitter applied */ readonly getTimeoutWithJitter: (baseTimeout: number, jitterFactor?: number) => number; /** * Parse timeout string to milliseconds * @param timeout - Timeout string like "30s", "2m", "1h" or number * @returns Timeout in milliseconds */ readonly parseTimeout: (timeout: string | number) => number; }; export declare const DEFAULT_TIMEOUT: 30000; export declare const PROVIDER_TEST_TIMEOUT: 5000; export declare const MCP_INIT_TIMEOUT: 3000; export declare const CIRCUIT_BREAKER_RESET_MS: 60000;