/** * Structured brain error so the *kind* of failure is machine-distinguishable end-to-end (the message * is prefixed `[code]`, which the Runner lifts into `TaskResult.errorCode`). This lets an external * caller react correctly without string-matching: `auth` → the API key is wrong, **stop and fix it** * (it's not retried, so the caller gets a fast failure); `rate_limit` → back off; `network`/`server` * → a transient outage worth retrying. Only `network`/`server`/`rate_limit` are retried by the brains. */ import type { Usage } from "../internal/llm.js"; /** A zeroed `Usage` for synthetic error/short-circuit assistant messages (no tokens spent). Shared by * the circuit-breaker, degradation, and routing brains so the empty-usage shape lives in one place. */ export declare const ZERO_USAGE: Usage; /** The single source of truth for brain error codes — the type, the `[code]` parser, and the prefix * stripper all derive from this one list, so adding a code can't silently diverge across call sites. */ declare const BRAIN_ERROR_CODES: readonly ["auth", "rate_limit", "invalid_request", "server", "network", "http"]; export type BrainErrorCode = (typeof BRAIN_ERROR_CODES)[number]; export declare class BrainError extends Error { readonly code: BrainErrorCode; readonly status?: number; constructor(code: BrainErrorCode, detail: string, status?: number); } /** Map an HTTP status to an error class. 401/403 = auth (don't retry); 429 = rate limit; 5xx = server. */ export declare function classifyHttp(status: number): BrainErrorCode; /** Lift the machine-readable code back out of a `[code] …` prefixed `errorMessage` (the single shared * parser — circuit breaker, degradation, and the Runner all read the prefix this way, council #7). */ export declare function extractErrorCode(errorMessage: string | undefined): BrainErrorCode | undefined; /** Strip a leading `[code] ` prefix (including the trailing space) from an `errorMessage`, leaving the * human text. Pairs with {@link extractErrorCode} so a caller can lift the code and clean the message * without re-hardcoding the code list (the Runner does both when assembling `TaskResult`). */ export declare function stripErrorCodePrefix(errorMessage: string): string; export {}; //# sourceMappingURL=errors.d.ts.map