Classifies LLM server probe failures into actionable error messages.
// Source: https://github.com/mnfst/llm-gateway | License: MIT | Copyright 2026 MNFST, Inc
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Classify a probe failure into an actionable error message.
*
* `probeModels` hits `{baseUrl}/models` on an operator-provided URL to
* discover what models a local LLM server exposes. When that fails we
* want to tell the user WHY in a way they can act on — a bare
* "fetch failed" or "ECONNREFUSED" is useless without context.
*/
export type ProbeFailureKind =
| 'connection_refused'
| 'timeout'
| 'dns_failure'
| 'tls_mismatch'
| 'not_found'
| 'non_json'
| 'unauthorized'
| 'empty_models'
| 'bad_status'
| 'unknown';
export interface ProbeError {
kind: ProbeFailureKind;
/** Short, user-facing explanation
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key