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

63 lines (62 loc) 2.17 kB
/** * HTTP Retry Handler for MCP Transport * * Provides retry logic with exponential backoff and jitter * specifically designed for HTTP-based MCP transport connections. */ import type { HTTPRetryConfig } from "../types/index.js"; /** * Default HTTP retry configuration */ export declare const DEFAULT_HTTP_RETRY_CONFIG: HTTPRetryConfig; /** * Check if an HTTP status code is retryable based on configuration * * @param status - HTTP status code to check * @param config - HTTP retry configuration * @returns True if the status code should trigger a retry */ export declare function isRetryableStatusCode(status: number, config?: HTTPRetryConfig): boolean; /** * Check if an error is retryable for HTTP operations * * Considers: * - Network errors (ECONNRESET, ENOTFOUND, ECONNREFUSED, ETIMEDOUT) * - Timeout errors * - HTTP status codes in the retryable list * - Fetch/network-related errors * * @param error - Error to check * @param config - HTTP retry configuration (optional) * @returns True if the error is retryable */ export declare function isRetryableHTTPError(error: unknown, config?: HTTPRetryConfig): boolean; /** * Execute an HTTP operation with retry logic * * Implements exponential backoff with jitter to avoid thundering herd problems. * Uses the calculateBackoffDelay function from the core retry handler for * consistent delay calculation across the codebase. * * @param operation - Async operation to execute with retries * @param config - Partial HTTP retry configuration (merged with defaults) * @returns Result of the operation * @throws Last error if all retry attempts fail * * @example * ```typescript * const result = await withHTTPRetry( * async () => { * const response = await fetch(url); * if (!response.ok) { * const error = new Error(`HTTP ${response.status}`) as Error & { status: number }; * error.status = response.status; * throw error; * } * return response.json(); * }, * { maxAttempts: 5, initialDelay: 500 } * ); * ``` */ export declare function withHTTPRetry<T>(operation: () => Promise<T>, config?: Partial<HTTPRetryConfig>): Promise<T>;