import type { JsonObject } from "#shared/json.js"; /** * The upstream error name the AI Gateway uses for authentication failures. * Exported so consumers of `step.failed` details (the dev TUI's `/model` * hint) match the same identifier this module classifies on. */ export declare const GATEWAY_AUTHENTICATION_ERROR_NAME = "GatewayAuthenticationError"; /** * The summary `name` this module assigns to recognized gateway-auth * failures, carried into failure-event details. Exported for the same * consumers as {@link GATEWAY_AUTHENTICATION_ERROR_NAME}. */ export declare const GATEWAY_AUTH_FAILURE_SUMMARY_NAME = "AI Gateway authentication failed"; /** * One human-readable summary of a known model-call configuration failure. * * Returned by {@link summarizeKnownModelCallConfigError} for terminal * failures that point at a fixable setup mistake (missing API key, * gateway auth failure). Surfaces actionable text in REPL output and in * structured `step.failed` events without dumping the full SDK error * inspection into user-facing logs. */ export interface ModelCallConfigErrorSummary { readonly name: string; readonly message: string; } /** * Returns a concise actionable summary for known terminal configuration * errors raised during a model call. Returns `null` for everything else * so the caller falls back to the raw SDK message. */ export declare function summarizeKnownModelCallConfigError(error: unknown): ModelCallConfigErrorSummary | null; /** * Returns a concise summary for known model-call request failures that are not * configuration errors. These failures happen before the agent can produce a * response, so the user-facing message should avoid implying a bad tool call. */ export declare function summarizeKnownModelCallRequestError(error: unknown): ModelCallConfigErrorSummary | null; /** * Returns the distinct upstream tool types referenced by any * "tool type 'X' is not supported" rejection in an AI Gateway error's * provider attempt list. * * Walks the cause chain to find the gateway error and inspects both the * structured `data` field and the raw `responseBody` JSON. Returns an * empty array for errors that are not of this shape. * * Used by the harness recovery path to identify which framework tools * to drop before retrying the failing step. Detection is by string * match on the upstream tool type — see * {@link resolveFrameworkToolFromUpstreamType} for the mapping back to * framework tool names. */ export declare function extractUnsupportedProviderToolTypes(error: unknown): readonly string[]; /** * Extracts compact, structured diagnostics from AI SDK / AI Gateway model-call * errors. The full SDK error can include very large request bodies (especially * tool schemas), so this shape lifts the important upstream response fields into * `step.failed.details` before any inspector output gets truncated. */ export declare function extractModelCallErrorDetails(error: unknown): JsonObject; /** * A model call that produced no content. Raised by tool-loop.ts from * either of its two triggers: `isEmptyModelResponse` (a completed step * with finishReason 'other' and no output — AI Gateway HTTP 200 whose * stream carries no content, no usage, and no error) or * {@link isNoOutputGeneratedError} (the AI SDK rejecting a stream that * closed after metadata without output, normalized via the model call's * rethrow so both shapes funnel into one recovery). * * The message is channel-visible when recovery is exhausted, so it is * written for end users. The SDK rejection is preserved as `cause` to * keep the two triggers distinguishable in logs. */ export declare class EmptyModelResponseError extends Error { constructor(options?: { cause?: unknown; }); } /** * True when the error (or any error in its cause chain) is the AI SDK's * `NoOutputGeneratedError`. Since `ai@7.0.0-canary.169` (vercel/ai#15938) * a model stream that ends after metadata without any output or finish * chunk rejects with this error instead of completing an empty step — * the same upstream failure `isEmptyModelResponse` detects, surfaced as * a throw. Matched by `name` rather than `instanceof` so the check * survives a duplicated `ai` package and `toError`'s plain-object * coercion, which preserves `name` but not class identity. */ export declare function isNoOutputGeneratedError(error: unknown): boolean; /** * Classifies a model-call failure into the runtime's recovery policy. */ export declare function classifyModelCallError(error: unknown): "retry" | "recoverable" | "terminal";