UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

39 lines (38 loc) • 2.3 kB
/** * humanizeLLMError — turn a raw provider/SDK error into a plain-language * sentence a NON-developer can act on. * * agentfootprint targets vibe-coding / non-developer builders. A raw * "[browser-anthropic] Failed to fetch" or "401 Unauthorized" means * nothing to them. This maps the common failure shapes to a friendly, * actionable message. The raw error is preserved on `.cause` (and via * `wrapLLMError`) so developers can still dig in. * * Pure + dependency-light: string/shape matching only. Extend the cases * as new provider failure modes surface — keep each message short and * tell the user what to DO. */ /** * The FIXED sentences {@link humanizeLLMError} answers with — every answer * except the fallback, which quotes the raw message. A reader that sends a * failure somewhere a person reads it (an AG-UI `RUN_ERROR`) passes on only * these: the fallback's raw text may hold anything a provider put in it. */ export declare const LLM_ERROR_SENTENCES: Readonly<{ readonly unreachable: "Couldn't reach the AI model. Check your internet connection, and that the provider/API key is set up correctly."; readonly auth: "The AI provider rejected the request — the API key looks missing or invalid. Add or fix it in Settings."; readonly rateLimited: "The AI provider is busy (rate limit / quota). Wait a moment, then try again."; readonly timeout: "The AI model took too long to respond. Try again — if it keeps happening, simplify the request."; readonly providerDown: "The AI provider had a temporary problem on their end. Try again in a moment."; readonly rejected: "The AI request was rejected — the model name or request may be wrong. Check the model in the code."; readonly unknown: "The AI call failed for an unknown reason."; }>; /** Map a thrown provider/SDK error to a friendly, actionable sentence. */ export declare function humanizeLLMError(err: unknown): string; /** * Wrap a raw provider error in a fresh Error whose `.message` is the * humanized sentence, preserving the original on `.cause` for developers * (and "Copy for LLM"). Re-throw this from the LLM call site so the * friendly message flows through onError → onRunFailed → the monitor. */ export declare function wrapLLMError(err: unknown): Error;