/**
 * Timeout utilities for NeuroLink
 *
 * Provides flexible timeout parsing and error handling for AI operations.
 * Supports multiple time formats: milliseconds, seconds, minutes, hours.
 */
import type { TimeoutConfig, TimeoutResult } from "../types/index.js";
/**
 * Custom error class for timeout operations
 */
export declare class TimeoutError extends Error {
    readonly timeout: number;
    readonly provider?: string | undefined;
    readonly operation?: "generate" | "stream" | undefined;
    constructor(message: string, timeout: number, provider?: string | undefined, operation?: "generate" | "stream" | undefined);
}
/**
 * Parse timeout value from various formats
 * @param timeout - Can be number (ms), string with unit, or undefined
 * @returns Parsed timeout in milliseconds or undefined
 * @throws Error if format is invalid
 *
 * Examples:
 * - parseTimeout(5000) => 5000
 * - parseTimeout('30s') => 30000
 * - parseTimeout('2m') => 120000
 * - parseTimeout('1.5h') => 5400000
 * - parseTimeout(undefined) => undefined
 */
export declare function parseTimeout(timeout: number | string | undefined): number | undefined;
/**
 * Default timeout configurations for different providers and operations
 */
export declare const DEFAULT_TIMEOUTS: {
    global: string;
    streaming: string;
    providers: {
        openai: string;
        bedrock: string;
        vertex: string;
        anthropic: string;
        azure: string;
        "google-ai": string;
        huggingface: string;
        ollama: string;
        mistral: string;
    };
    tools: {
        default: string;
        filesystem: string;
        network: string;
        computation: string;
    };
};
/**
 * Get default timeout for a specific provider
 * @param provider - Provider name
 * @param operation - Operation type (generate or stream)
 * @returns Default timeout string
 */
export declare function getDefaultTimeout(provider: string, operation?: "generate" | "stream"): string;
/**
 * Create a timeout promise that rejects after specified duration
 * @param timeout - Timeout duration
 * @param provider - Provider name for error message
 * @param operation - Operation type for error message
 * @returns Promise that rejects with TimeoutError
 */
export declare function createTimeoutPromise(timeout: number | string | undefined, provider: string, operation: "generate" | "stream"): Promise<never> | null;
/**
 * Enhanced timeout manager with proper cleanup and abort controller integration
 * Consolidated from timeout-manager.ts
 */
export declare class TimeoutManager {
    private activeTimeouts;
    /**
     * Execute operation with timeout and proper cleanup
     */
    executeWithTimeout<T>(operation: () => Promise<T>, config: TimeoutConfig): Promise<TimeoutResult<T>>;
    private performSingleOperation;
    private getTimeoutMs;
    private generateOperationId;
    private createTimeoutPromise;
    private registerTimeout;
    cleanup(operationId: string): void;
    gracefulShutdown(): void;
}
/**
 * Wrapper functions consolidated from timeout-wrapper.ts
 */
/**
 * Wrap a promise with timeout
 * @param promise - The promise to wrap
 * @param timeout - Timeout duration (number in ms or string with unit)
 * @param provider - Provider name for error messages
 * @param operation - Operation type (generate or stream)
 * @returns The result of the promise or throws TimeoutError
 */
export declare function withTimeout<T>(promise: Promise<T>, timeout: number | string | undefined, provider: string, operation: "generate" | "stream"): Promise<T>;
/**
 * Wrap a streaming async generator with timeout
 * @param generator - The async generator to wrap
 * @param timeout - Timeout duration for the entire stream
 * @param provider - Provider name for error messages
 * @returns Wrapped async generator that respects timeout
 */
export declare function withStreamingTimeout<T>(generator: AsyncGenerator<T>, timeout: number | string | undefined, provider: string): AsyncGenerator<T>;
/**
 * Create an abort controller with timeout
 * @param timeout - Timeout duration
 * @param provider - Provider name for error messages
 * @param operation - Operation type
 * @returns AbortController and cleanup function
 */
export declare function createTimeoutController(timeout: number | string | undefined, provider: string, operation: "generate" | "stream"): {
    controller: AbortController;
    cleanup: () => void;
    timeoutMs: number;
} | null;
/**
 * Compose an external abort signal with a timeout controller's signal.
 * Returns a single AbortSignal that fires when either signal aborts.
 * If only one signal is present, returns it directly without wrapping.
 *
 * @param externalSignal - User-provided AbortSignal (e.g., from options.abortSignal)
 * @param timeoutSignal - Timeout controller's signal
 * @returns Combined AbortSignal, or undefined if neither is present
 */
export declare function composeAbortSignals(externalSignal?: AbortSignal, timeoutSignal?: AbortSignal): AbortSignal | undefined;
/**
 * Merge abort signals (for combining user abort with timeout)
 * @param signals - Array of abort signals to merge
 * @returns Combined abort controller
 */
export declare function mergeAbortSignals(signals: (AbortSignal | undefined)[]): AbortController;
