/** * Retry and backoff utilities for the MCP server manager */ /** * Configuration for exponential backoff */ export interface BackoffConfig { /** Base delay in milliseconds (default: 1000) */ baseMs: number; /** Maximum delay in milliseconds (default: 30000) */ maxMs: number; /** Multiplier for each attempt (default: 2) */ multiplier?: number; /** Random jitter factor 0-1 (default: 0.1) */ jitter?: number; } /** * Default backoff configuration */ export declare const DEFAULT_BACKOFF_CONFIG: Required; /** * Calculates the delay for a given attempt using exponential backoff * * @param attempt - The attempt number (0-based) * @param config - Backoff configuration * @returns Delay in milliseconds */ export declare function calculateBackoff(attempt: number, config?: Partial): number; /** * Creates a promise that resolves after the specified delay */ export declare function delay(ms: number): Promise; /** * Creates a cancellable delay */ export declare function cancellableDelay(ms: number): { promise: Promise; cancel: () => void; }; /** * Configuration for retry operations */ export interface RetryConfig { /** Maximum number of attempts */ maxAttempts: number; /** Backoff configuration */ backoff: BackoffConfig; /** Optional function to determine if an error is retryable */ isRetryable?: (error: unknown) => boolean; /** Optional callback called before each retry */ onRetry?: (attempt: number, error: unknown, delayMs: number) => void; } /** * Result of a retry operation */ export type RetryResult = { success: true; value: T; attempts: number; } | { success: false; error: unknown; attempts: number; }; /** * Executes an operation with retry logic * * @param operation - The async operation to execute * @param config - Retry configuration * @returns Result of the operation */ export declare function retry(operation: () => Promise, config: RetryConfig): Promise>; /** * Creates a timeout wrapper for a promise * * @param promise - The promise to wrap * @param timeoutMs - Timeout in milliseconds * @param timeoutError - Optional error to throw on timeout * @returns Promise that rejects on timeout */ export declare function withTimeout(promise: Promise, timeoutMs: number, timeoutError?: Error): Promise; /** * Creates a deferred promise that can be resolved/rejected externally */ export interface Deferred { promise: Promise; resolve: (value: T) => void; reject: (reason?: unknown) => void; } export declare function createDeferred(): Deferred; //# sourceMappingURL=retry.d.ts.map