import type { Api, AssistantMessage } from "../types.js"; export declare const Flag: { readonly Class: 4096; readonly ThinkingLoop: 65536; readonly Transient: 131072; readonly Timeout: 262144; readonly UsageLimit: 524288; readonly StaleResponsesItem: 1048576; readonly MalformedFunctionCall: 2097152; readonly ProviderFinishError: 4194304; readonly EmptyResponse: 8192; readonly ContentBlocked: 32768; /** Account-scoped provider policy denial that may succeed with another credential. */ readonly AccountPolicy: 16384; readonly ContextOverflow: 8388608; readonly AuthFailed: 16777216; readonly SilentAbort: 33554432; readonly UserInterrupt: 67108864; readonly Abort: 134217728; /** Strict-tool rejection (400): grammar too large, schema too complex, or structured outputs unsupported by the model/endpoint. */ readonly Grammar: 268435456; /** Anthropic model/account does not support fast mode / the `speed` parameter. */ readonly FastModeUnsupported: 536870912; /** OAuth refresh failed definitively — the stored grant is dead, re-login required. */ readonly OAuthExpiry: 1073741824; }; export type Flag = (typeof Flag)[keyof typeof Flag]; export declare const STREAM_READ_ERROR_PATTERN: RegExp; export declare const TRANSIENT_TRANSPORT_PATTERN: RegExp; /** * Local llama.cpp / Ollama deterministic tool-call argument JSON parse failure. * The model emitted invalid JSON in a tool call and the server returned HTTP 500 * with this exact text — replaying the same prompt yields the same malformed * output, so callers strip {@link Flag.Transient} when this matches. */ export declare const LLAMA_CPP_TOOL_CALL_PARSE_PATTERN: RegExp; /** Whether an OAuth refresh error message means the grant is definitively dead. */ export declare function isOAuthExpiry(errorMessage: string): boolean; export declare function create(...flags: number[]): number; export declare function is(id: number | undefined, flag: Flag): boolean; export declare function retriable(id: number | undefined, opts?: { replayUnsafe?: boolean; }): boolean; export declare function status(error: unknown): number | undefined; export declare function isStreamReadErrorText(text: string): boolean; /** Persisted-text form of {@link isStreamEnvelopeError}: recognizes the * prefix-tagged envelope diagnostic on an aborted turn's `errorMessage` / * `stopDetails.explanation` so loop-level salvage can classify it after the * original `Error` instance is gone. */ export declare function isStreamEnvelopeErrorText(text: string): boolean; export declare function classify(error: unknown, api?: Api): number; /** * Whether an error (or message string) classifies as an account usage/quota * limit — the persistent, credential-rotation-worthy kind. This is the public * accessor for {@link Flag.UsageLimit}; prefer it over re-running message * regexes at call sites. */ export declare function isUsageLimit(error: unknown, api?: Api): boolean; /** Whether an upstream rejection is an account-scoped policy denial worth retrying with a sibling credential. */ export declare function isAccountPolicyError(error: unknown, api?: Api): boolean; /** * Strict-tool rejection: grammar too large, schema too complex, or structured * outputs unsupported by the model/endpoint. * Accessor for {@link Flag.Grammar}. */ export declare function isGrammarError(error: unknown): boolean; /** * Anthropic model/account does not support fast mode / the `speed` parameter. * Accessor for {@link Flag.FastModeUnsupported}. */ export declare function isFastModeUnsupported(error: unknown): boolean; /** * GitHub Copilot 400 `model_not_supported` response for a model advertised by * `/models` — transient fleet skew, not a malformed request. Reads the * structural `code` through the SDK/body envelopes, then falls back to the * stringified body both SDK families put in `message`. */ export declare function isCopilotTransientModelError(error: unknown): boolean; export declare function classifyMessage(message: { api?: Api; errorId?: number; errorMessage?: string; errorStatus?: number; }): number; export declare function attach(error: E, id: number): E; export declare function isContextOverflow(message: AssistantMessage, contextWindow?: number): boolean; export declare function stringify(id: number | undefined): string; /** * Transient stream corruption where the response was truncated mid-JSON. * * Strings (persisted `stopDetails.explanation`/`errorMessage` diagnostics) are matched with the * stricter {@link STREAM_PARSE_DIAGNOSTIC_PATTERN} — bare "truncated"/"end of file" text is too * low-signal to trust once detached from a live transport `Error`, which keeps the broad pattern. */ export declare function isTransientStreamParseError(error: unknown): boolean; /** Any malformed stream-envelope error (prefix-tagged or out-of-order events). */ export declare function isStreamEnvelopeError(error: unknown): boolean; /** Stream-envelope errors safe to retry against the provider (event ordering only). */ export declare function isRetryableStreamEnvelopeError(error: unknown): boolean;