agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
29 lines (28 loc) • 1.35 kB
TypeScript
/**
* classifyError — pure function mapping a thrown error to one of the
* coarse `ReliabilityScope.errorKind` categories used by reliability rules.
*
* Centralized so rules read structured `errorKind` instead of doing
* regex on `error.message` themselves. Add new categories ONLY when a
* new rule needs to discriminate them — keep the taxonomy small.
*
* Categories:
* • 'ok' — no error (caller should pass `undefined` or omit)
* • 'circuit-open' — `CircuitOpenError` from the breaker layer
* • 'rate-limit' — HTTP 429 or vendor rate-limit signal
* • '5xx-transient' — HTTP 5xx, ETIMEDOUT, ECONNRESET, ECONNREFUSED
* • 'schema-fail' — `OutputSchemaError` from the schema validator
* • 'unknown' — anything else (default; still routable but
* consumers usually `'fail-fast'` on this)
*/
import type { ReliabilityScope } from './types.js';
type ErrorKind = ReliabilityScope['errorKind'];
/**
* Classify an error into a `ReliabilityScope['errorKind']` category.
*
* @param err - The thrown value. May be an Error, a vendor SDK error
* shape with `.status`/`.code`, or anything else (`unknown` defaults).
* @returns the matching coarse category string.
*/
export declare function classifyError(err: unknown): ErrorKind;
export {};