/** * Harness error base with a stable machine-routable code and chained cause. * Package errors extend it so tool results and replay can retain failure class. * @module @deepseek-ai/dsh-llm/error */ /** * Base class for all harness errors. Carries a `code` (stable, programmatic — * e.g. `NO_ADAPTER`, `INVALID_ARGS`, `INVARIANT`) distinct from the * human-readable `message`, and supports `cause` chaining via the standard * `ErrorOptions`. `name` defaults to the subclass constructor name. */ export declare class HarnessError extends Error { /** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never by parsing `message`. */ readonly code: string; constructor(message: string, code: string, options?: ErrorOptions); } /** Canonical provider-neutral code for a model request rejected because its context window was exceeded. */ export declare const CONTEXT_WINDOW_EXCEEDED_CODE = "CONTEXT_WINDOW_EXCEEDED"; /** Canonical provider-neutral code for an exhausted account quota or balance. */ export declare const QUOTA_EXCEEDED_CODE = "QUOTA"; /** * Canonical provider-neutral code for a response that completed normally but * carried no content blocks at all. Providers occasionally emit a degenerate * completion (a terminal stop with zero output); adapters classify it as this * failure instead of yielding an empty assistant message, because an empty * message silently ends the turn with nothing for the user or the loop to act * on. The attempt produced nothing durable, so retry policy treats it as safe * to repeat. */ export declare const EMPTY_RESPONSE_CODE = "EMPTY_RESPONSE"; /** * Canonical provider-neutral code for a credential that was supplied but * cannot be used — malformed rather than absent. Distinct from * `MISSING_CREDENTIAL` because the fix differs: correct the stored value * rather than supply one. Deliberately outside the default retryable set — * a malformed credential fails identically on every attempt. */ export declare const INVALID_CREDENTIAL_CODE = "INVALID_CREDENTIAL"; /** * Recognize the context-overflow wording used by OpenAI-compatible providers * and library adapters. Adapters pass all available provider code, type, and * message text so both thrown and in-band delivery styles share one classifier. * @param detail - provider error code/type/message text joined into one string. * @returns true when the detail identifies a request exceeding the model context window. */ export declare function isContextWindowExceededError(detail: string): boolean; /** * Recognize provider wording that identifies an exhausted account quota rather * than a transient request-rate limit. * @param detail - provider error code/type/message text joined into one string. * @returns true only for terminal quota, balance, credit, budget, or usage-limit wording. */ export declare function isQuotaExceededError(detail: string): boolean; /** * Render a thrown value with its full `cause` chain and AggregateError * members, so transport wrappers like undici's `TypeError: fetch failed` * surface the underlying failure instead of masking it. Plain structured * failures render their own data-backed `message`. Diagnostic-surface * rendering only (messages, notices, logs) — never parse the result; route on * {@link HarnessError.code}. * @param value - the caught value (`unknown` in catch clauses). * @returns the outermost message first, each cause appended with `: ` (skipped * when it repeats the wrapper message verbatim), and AggregateError members * bracketed and `; `-joined. */ export declare function errorChain(value: unknown): string; /** * Narrow an arbitrary thrown value to a HarnessError (for `instanceof` at runtime boundaries). * @param value - the caught value (`unknown` in catch clauses). * @returns true only for real instances; duck-typed or cross-realm errors do not narrow. */ export declare function isHarnessError(value: unknown): value is HarnessError; //# sourceMappingURL=error.d.ts.map