import type { Processor, ProcessAPIErrorArgs, ProcessAPIErrorResult } from './index.js';
export type StreamErrorRetryMatcher = (error: unknown) => boolean;
export type StreamErrorRetryDelayMs = number | ((args: ProcessAPIErrorArgs) => number | Promise<number>);
/**
 * A matcher with its own retry policy. When this matcher is the first to match
 * an error, its `maxRetries` and `delayMs` override the processor-level defaults.
 * Omitted fields fall back to the processor-level values.
 */
export type StreamErrorRetryMatcherConfig = {
    match: StreamErrorRetryMatcher;
    maxRetries?: number;
    delayMs?: StreamErrorRetryDelayMs;
    onRetry?: (args: ProcessAPIErrorArgs & {
        delayMs: number;
    }) => void | Promise<void>;
};
/** A matcher entry: either a plain predicate or a config object with per-matcher policy. */
export type StreamErrorRetryMatcherEntry = StreamErrorRetryMatcher | StreamErrorRetryMatcherConfig;
export type StreamErrorRetryProcessorOptions = {
    maxRetries?: number;
    matchers?: StreamErrorRetryMatcherEntry[];
    /**
     * Retry unknown errors that are not matched by provider metadata, built-in
     * matchers, or custom matchers. Credential and quota refusals are excluded.
     * Uses the processor-level `maxRetries` and `delayMs`. Defaults to false.
     */
    retryUnknownErrors?: boolean;
    /**
     * Optional delay (ms) to wait before signaling a retry. Accepts a number or an
     * async function evaluated with the current error args. Negative/non-finite
     * values are clamped to 0. Defaults to 0 (retry immediately), preserving the
     * existing behavior for consumers that do not configure a delay.
     */
    delayMs?: StreamErrorRetryDelayMs;
    /**
     * Maximum provider-controlled Retry-After delay in milliseconds. Invalid values
     * are clamped to 0. Defaults to 30 seconds. This does not cap an explicitly
     * configured delayMs value.
     */
    maxRetryAfterMs?: number;
};
export declare function isRetryableOpenAIResponsesStreamError(error: unknown): boolean;
/**
 * Matcher for transient HTTP 400 (Bad Request) failures. Providers like OpenAI
 * occasionally return 400 during service degradation that succeeds on retry.
 * Recommended with `maxRetries: 1` since a 400 could also be genuinely invalid.
 * Credential and quota refusals are never matched: OpenAI stream error frames such as
 * `invalid_api_key` can surface with a derived `statusCode: 400`, and Anthropic reports
 * an exhausted credit balance or usage cap as a 400. A rejected model or parameter
 * (`model_not_found`, unsupported model) is never matched either: the identical
 * request fails the same way on retry.
 */
export declare function isBadRequestError(error: unknown): boolean;
export declare class StreamErrorRetryProcessor implements Processor<'stream-error-retry-processor'> {
    #private;
    readonly id: 'stream-error-retry-processor';
    readonly name = "Stream Error Retry Processor";
    constructor(options?: StreamErrorRetryProcessorOptions);
    processAPIError(args: ProcessAPIErrorArgs): Promise<ProcessAPIErrorResult | void>;
}
//# sourceMappingURL=stream-error-retry-processor.d.ts.map