/** A provider exhausted its own retry budget; do not retry another registration * owned by that provider in this dispatch. Other providers remain eligible. */ export declare const MODEL_PROVIDER_RETRY_BUDGET_EXHAUSTED = "MODEL_PROVIDER_RETRY_BUDGET_EXHAUSTED"; /** Recognizes a provider-owned exhausted retry budget through SDK wrappers. */ export declare function isModelProviderRetryBudgetExhaustedError(error: unknown): boolean; /** * Render any thrown model-call failure as one diagnostic line — the HTTP * status (unwrapped from the AI SDK retry envelope) plus the most specific * message found on the error or its structured body. Providers throw a mix of * `Error` instances and bare `{ status, error }` objects; a bare object * stringifies to the useless "[object Object]", so the model-failover rethrow * routes non-trivial values through here to keep logs, trajectories, and any * user-surfaced failure text diagnostic. Never returns "[object Object]": when * no status or message is recoverable it serializes the payload instead. */ export declare function describeModelCallError(error: unknown): string; /** Recognizes rate limits from structured provider status, including retry envelopes. Status-less errors use message matching; status and statusCode are both supported. */ export declare function isRateLimitError(error: unknown): boolean; /** * The user-facing reply for a credit-exhausted provider. One provider-neutral * string serves every delivery path because the failure boundary does not * reliably know whether routing selected Eliza Cloud or a direct provider. * The direct chat API (`packages/agent` re-uses it) and connector failure-reply * path therefore report the same actionable condition without misattributing * billing ownership. Characters override via * `character.templates.insufficientCreditsReply`. */ export declare const INSUFFICIENT_CREDITS_REPLY = "The configured AI provider is out of credits or quota. Add credits or increase its quota, then try again."; export declare function isInsufficientCreditsMessage(message: string): boolean; /** * Detect provider credit/quota exhaustion — HTTP 402, a structured * `insufficient_credits`/`insufficient_quota` error body, or a 429 that * carries billing context — so the user-facing failure reply can say "top up" * instead of suggesting a retry that can never succeed against a drained * balance. Mirrors {@link isRateLimitError}: the structural signal (status * after unwrapping the AI SDK retry envelope, then the provider error body) * runs first; the message-substring scan is only a status-less fallback. * * Callers MUST check this before {@link isRateLimitError}: a 429 *with* * billing context is credit exhaustion ("top up"), whereas a bare 429 is * "try again in a moment". */ export declare function isInsufficientCreditsError(error: unknown): boolean; /** * Detect provider auth failures (401/403 — invalid/expired/unauthorized API key) * so the user-facing failure reply can say "my cloud key isn't authorized — check * your Eliza Cloud key / add credits" instead of the opaque generic * "something went wrong". Mirrors {@link isRateLimitError}: structured HTTP status * first, message-substring fallback second. */ export declare function isAuthError(error: unknown): boolean; /** * Detect failures where another model provider is worth trying before giving up. * This intentionally includes {@link isRateLimitError} so subscription-credit * exhaustion from CLI-SDK providers follows the same structural 429/session-limit * classifier as the graceful reply path. * * `modelType` gates the decision per slot. `TEXT_TO_SPEECH` never fails over: * a voice swap is not a transient-recoverable condition, and a Kokoro * model-download failure surfaces as `fetch failed`, which would otherwise match * the transient heuristics below and silently rotate to a different voice engine *. TTS fails closed — the configured voice errors loudly instead. */ export declare function isModelProviderFallbackError(error: unknown, modelType?: string): boolean; /** * Why the turn ended on the structured-failure path, classified from the * error that killed the runtime. Distinguishable causes get * distinguishable user-facing replies instead of one generic * "something flaked" template: * * - `missing_capability` — the planner requested a tool which was not * registered or otherwise invocable in this runtime. Retrying cannot help; * the honest reply names the gap. * - `planner_exhaustion` — the planner ran out of budget (tool calls, * repeated failures, token budget) before finishing. Retrying may help. * - `context_overflow` — the provider rejected the model call at its * documented context limit and the planner terminated without rewriting * completed results. Retrying the identical request cannot help; the * honest reply asks for a smaller range or narrower request. * - `transient` — a model/provider/infrastructure error; the pre-existing * generic path. */ export type StructuredFailureCause = "missing_capability" | "handler_error" | "persistence_error" | "planner_exhaustion" | "context_overflow" | "transient"; /** * Classify the error that aborted the message runtime into a * `StructuredFailureCause`. Trajectory-limit aborts are the only errors * that structurally identify their cause today. Only * `unavailable_tool_calls` proves a capability is absent. A * `required_tool_misses` limit can occur with a registered tool when the model * repeatedly emits no usable call, so it is planner exhaustion and retryable. * Everything else stays `transient`. */ export declare function classifyStructuredFailureCause(error: unknown): StructuredFailureCause; export declare function buildFailureReplyPrompt(recentMessages: string, cause?: StructuredFailureCause): string; export declare function stripReasoningBlocks(raw: string): string;