/** * Centralized timeout management utilities. * * Provides consistent timeout handling across all async operations * to prevent indefinite hangs and improve reliability. */ /** * Default timeout values in milliseconds. * * These reference the centralized constants where applicable, * ensuring consistency across the codebase. */ export declare const DEFAULT_TIMEOUTS: { /** Timeout for individual tool calls - uses INTERVIEW.TOOL_TIMEOUT */ readonly toolCall: 30000; /** Timeout for LLM API calls - uses TIMEOUTS.INTERVIEW */ readonly llmCall: 60000; /** Timeout for state snapshots - uses WORKFLOW.STATE_SNAPSHOT_TIMEOUT */ readonly stateSnapshot: 10000; /** Timeout for individual probe tool calls - uses WORKFLOW.PROBE_TOOL_TIMEOUT */ readonly probeTool: 5000; /** Timeout for resource reads - uses INTERVIEW.RESOURCE_TIMEOUT */ readonly resourceRead: 15000; /** Timeout for HTTP requests - uses TIMEOUTS.HTTP_REQUEST */ readonly httpRequest: 30000; /** Timeout for SSE connection establishment */ readonly sseConnect: 10000; /** Timeout for interview question generation (longer for local models) */ readonly questionGeneration: 120000; /** Timeout for response analysis */ readonly responseAnalysis: 60000; /** Timeout for profile synthesis */ readonly profileSynthesis: 120000; }; /** * Timeout configuration that can be passed to operations. */ export interface TimeoutConfig { /** Timeout in milliseconds */ timeoutMs: number; /** Name of the operation (for error messages) */ operationName: string; /** Whether to log timeout warnings */ logWarning?: boolean; /** Custom error message */ errorMessage?: string; } /** * Optional timeout behavior overrides. */ export interface TimeoutOptions { /** Abort controller to signal when timeout occurs */ abortController?: AbortController; } /** * Error class for timeout errors. */ export declare class TimeoutError extends Error { readonly operationName: string; readonly timeoutMs: number; constructor(operationName: string, timeoutMs: number, message?: string); } /** * Error class for aborted operations. */ export declare class AbortError extends Error { readonly operationName: string; constructor(operationName: string, message?: string); } /** * Check if an AbortSignal is aborted and throw AbortError if so. * * @param signal - The AbortSignal to check * @param operationName - Name of the operation for error messages * @throws AbortError if the signal is aborted */ export declare function checkAborted(signal: AbortSignal | undefined, operationName: string): void; /** * Wrap a promise with a timeout. * * @param promise - The promise to wrap * @param timeoutMs - Timeout in milliseconds * @param operationName - Name of the operation for error messages * @returns The promise result or throws TimeoutError */ export declare function withTimeout(promise: Promise, timeoutMs: number, operationName: string, options?: TimeoutOptions): Promise; /** * Wrap a promise with a timeout and return a result object instead of throwing. * * @param promise - The promise to wrap * @param timeoutMs - Timeout in milliseconds * @param operationName - Name of the operation * @returns Object with either result or error */ export declare function withTimeoutResult(promise: Promise, timeoutMs: number, operationName: string, options?: TimeoutOptions): Promise<{ success: true; result: T; } | { success: false; error: TimeoutError | Error; }>; /** * Create an abort controller that automatically aborts after a timeout. * * @param timeoutMs - Timeout in milliseconds * @param operationName - Name of the operation * @returns AbortController and cleanup function */ export declare function createTimeoutAbortController(timeoutMs: number, operationName: string): { controller: AbortController; cleanup: () => void; }; /** * Execute multiple promises with individual timeouts. * Returns results for all, including those that timed out. * * @param operations - Array of operations with their timeouts * @returns Array of results (either success with value or failure with error) */ export declare function withTimeoutAll(operations: Array<{ promise: Promise; timeoutMs: number; operationName: string; options?: TimeoutOptions; }>): Promise>; /** * Execute a function with a timeout, retrying on timeout up to maxRetries. * * @param fn - Function to execute * @param timeoutMs - Timeout per attempt * @param operationName - Name of the operation * @param maxRetries - Maximum number of retries (default: 1) * @returns The function result */ export declare function withTimeoutRetry(fn: () => Promise, timeoutMs: number, operationName: string, maxRetries?: number): Promise; /** * Create a deadline-based timeout manager. * Useful for operations with multiple steps that should complete within a total time. * * @param totalTimeoutMs - Total time allowed for all operations * @param operationName - Name of the overall operation * @returns Deadline manager */ export declare function createDeadline(totalTimeoutMs: number, operationName: string): { /** Get remaining time in milliseconds */ getRemainingMs: () => number; /** Check if deadline has passed */ isExpired: () => boolean; /** Get timeout for a sub-operation (remaining time or max, whichever is smaller) */ getTimeoutFor: (maxMs: number) => number; /** Throw if deadline has passed */ checkDeadline: () => void; }; //# sourceMappingURL=timeout.d.ts.map