import type { LLMProviderConfig } from "@superblocksteam/library-shared/types";
/**
 * Canonical error category for LLM provider errors.
 * Used consistently across error handling and observability.
 */
export type ErrorCategory = "rate_limit" | "timeout" | "stall" | "api_error" | "auth_error" | "validation_error" | "network" | "aborted" | "overloaded" | "no_output" | "not_found" | "retries_exhausted" | "unknown";
export type AnthropicErrorType = "overloaded_error" | "invalid_request_error" | "authentication_error" | "permission_error" | "not_found_error" | "request_too_large" | "rate_limit_error" | "api_error";
export type AnthropicErrorData = {
    error: {
        type: AnthropicErrorType;
        message: string;
    };
};
export type BedrockErrorType = "AccessDeniedException" | "IncompleteSignature" | "InternalFailure" | "InvalidAction" | "InvalidClientTokenId" | "NotAuthorized" | "RequestExpired" | "ServiceUnavailable" | "ThrottlingException" | "UnrecognizedClientException" | "ValidationError" | "ResourceNotFound";
export type BedrockErrorData = {
    message: string;
    type?: BedrockErrorType;
};
export type RawProviderErrorType = AnthropicErrorType | BedrockErrorType | string;
declare const symbol: unique symbol;
export declare class LLMProviderError extends Error {
    private readonly [symbol];
    private messages;
    name: string;
    provider: LLMProviderConfig["provider"];
    type: ErrorCategory;
    url?: string;
    statusCode?: number;
    isRetryable: boolean;
    data?: ProviderErrorData;
    cause?: unknown;
    constructor({ provider, message, type, isRetryable, aborted, cause, }: {
        provider: LLMProviderConfig["provider"];
        message?: string;
        type?: LLMProviderError["type"];
        isRetryable?: boolean;
        aborted?: boolean;
        cause?: unknown;
    });
    /**
     * Recursively extracts messages from nested error causes.
     *
     * This method walks the entire cause chain and extracts messages
     * from each level, ensuring that no error information is lost.
     *
     * @param cause - The cause to extract messages from
     */
    private extractNestedCauseMessages;
    set message(message: string);
    get message(): string;
    toJSON(): {
        name: string;
        type: ErrorCategory;
        message: string;
        url: string | undefined;
        statusCode: number | undefined;
        isRetryable: boolean;
        data: ProviderErrorData | undefined;
        cause: unknown;
    };
    protected static hasMarker(error: unknown, marker: string): boolean;
    static isInstance(error: unknown): error is LLMProviderError;
}
type ProviderErrorData = {
    type?: string;
    message: string;
    isClark?: boolean;
};
/**
 * Type representing the shape of an APICallError.
 *
 * This is used for duck-typing when the Symbol-based isInstance check fails,
 * which can happen when:
 * - Errors are serialized/deserialized (Symbol markers are lost)
 * - Errors come from different module instances
 * - The SDK sends a plain object in error chunks
 */
type APICallErrorLike = {
    name: string;
    message: string;
    url: string;
    statusCode?: number;
    isRetryable: boolean;
    data?: unknown;
    cause?: unknown;
};
/**
 * Type guard for objects that have the shape of an APICallError.
 *
 * This is a fallback for when APICallError.isInstance() returns false
 * but the object still has the expected APICallError structure.
 */
export declare function isAPICallErrorLike(cause: unknown): cause is APICallErrorLike;
export declare function isProviderErrorRetryable(error: unknown): boolean;
/**
 * Checks if an error is the Vercel AI SDK's AI_NoOutputGeneratedError.
 *
 * This error occurs when a stream completes without generating any output,
 * which can happen due to provider issues or model behavior. This is
 * considered retryable and should trigger provider fallback.
 */
export declare function isNoOutputError(error: unknown): boolean;
/**
 * Checks if an error indicates the prompt exceeded the model's token limit.
 */
export declare function isTokenLimitError(error: unknown): boolean;
export {};
//# sourceMappingURL=error.d.ts.map