/**
 * Chaos Monkey fetch wrapper for testing error handling.
 *
 * Randomly injects errors into requests to test retry logic and error
 * handling paths. This operates at the fetch level, making it realistic
 * for testing real-world failure scenarios.
 *
 * **Error types:**
 * 1. **HTTP errors**: Request fails before streaming starts (429, 500, 503, etc.)
 * 2. **Mid-stream HTTP errors**: Connection drops during streaming (ECONNRESET, timeout)
 * 3. **SSE error events**: Error chunks in the event stream
 *
 * Each fetch request represents one "step" in the AI SDK's multi-step
 * streaming architecture. The error rate controls what percentage of
 * steps will fail.
 */
import type { FetchFunction } from "@ai-sdk/provider-utils";
export interface ChaosOptions {
    /**
     * Probability that a step (HTTP request) returns an error (0.0-1.0).
     * Default: 0 (disabled)
     */
    errorRate: number;
    /**
     * HTTP status codes to randomly select from when injecting HTTP-level errors.
     * Default: [429, 500, 503, 529]
     */
    statusCodes?: number[];
    /**
     * Error codes to randomly select from when injecting errors.
     * These match the codes expected by the clark error handler.
     * Default: ["rate_limit_error", "overloaded_error", "api_error"]
     */
    errorCodes?: string[];
    /**
     * Probability that errors are injected as stream errors vs HTTP errors.
     * 0.5 = 50% HTTP errors, 50% stream errors.
     * Default: 0.5
     */
    streamErrorRate?: number;
    /**
     * Range of chunks to wait before injecting stream error.
     * Default: { min: 1, max: 5 }
     */
    streamErrorDelay?: {
        min: number;
        max: number;
    };
    /**
     * Probability that stream errors are injected as HTTP-level stream errors
     * (connection drop, timeout) vs SSE error event chunks.
     * 0.5 = 50% HTTP stream errors (abort), 50% SSE error events.
     * Default: 0.5
     */
    streamHttpErrorRate?: number;
}
/**
 * Statistics about chaos monkey activity.
 */
export interface ChaosStats {
    requestCount: number;
    errorCount: number;
    httpErrorCount: number;
    streamErrorCount: number;
    streamHttpErrorCount: number;
    streamSseErrorCount: number;
    errorRate: number;
}
/**
 * Creates a fetch function that randomly injects errors for testing.
 *
 * This wraps the base fetch function and intercepts a percentage of requests,
 * injecting realistic errors including HTTP failures, mid-stream connection drops,
 * and SSE error events.
 *
 * @param options - Chaos configuration
 * @param baseFetch - Underlying fetch implementation to wrap (defaults to global fetch)
 * @returns Wrapped fetch function with error injection
 *
 * @example
 * ```typescript
 * // 30% error rate: 15% HTTP errors, 15% stream errors (7.5% abort, 7.5% SSE)
 * const chaosFetch = createChaosFetch(
 *   {
 *     errorRate: 0.3,              // 30% of requests error
 *     streamErrorRate: 0.5,         // 50% of errors are stream errors
 *     streamHttpErrorRate: 0.5,     // 50% of stream errors are HTTP aborts
 *     statusCodes: [429, 500, 503],
 *   },
 *   fetch
 * );
 *
 * // Use in provider settings
 * const settings = {
 *   clark: {
 *     fetch: chaosFetch
 *   }
 * };
 * ```
 */
export declare function createChaosFetch(options: ChaosOptions, baseFetch?: FetchFunction): FetchFunction;
//# sourceMappingURL=chaos-fetch.d.ts.map