/** * Error types and handling for Scoutline. * * P1-01 introduces the normalised error contract from DESIGN.md §4: * `ScoutlineErrorCode`, `ScoutlineError`, `ValidationError`, * `UnsupportedCapabilityError`, `UnsupportedOptionError`, * `ConfigurationError`, `isRetryableError`, `getErrorExitCode`. * * The legacy `ZaiError` compatibility name is retained with its existing * 4-arg constructor signature so current imports keep working without * modification. Legacy subclasses (`AuthError`, `ApiError`, * `NetworkError`, `TimeoutError`, `FileError`) continue to extend * `ZaiError` for backward compatibility. The invocation-local * `formatErrorOutput` lives in `./output.js` (DESIGN.md §3). * * P4-01 routes the error formatter in `lib/output.js` through * `lib/redact.js` so redaction is a single source of truth. */ export type ScoutlineErrorCode = "AUTH_ERROR" | "TIMEOUT_ERROR" | "NETWORK_ERROR" | "VALIDATION_ERROR" | "QUOTA_ERROR" | "UNSUPPORTED_CAPABILITY" | "UNSUPPORTED_OPTION" | "API_ERROR" | "FILE_ERROR" | "UNKNOWN_ERROR" | "CONFIGURATION_ERROR" | "TEST_ISOLATION_VIOLATION"; export interface ScoutlineErrorOptions { statusCode?: number; help?: string; retryable?: boolean; exitCode?: number; /** * Provider-supplied retry delay hint, in milliseconds (the transport * form of `Retry-After` / `X-RateLimit-Retry-After`). Adaptors parse * the header and set this; the shared executor honours it as a floor * over its own backoff, capped by the policy. Executor-internal * transport — it is never part of the public error envelope. */ retryAfterMs?: number; } export declare class ScoutlineError extends Error { readonly code: ScoutlineErrorCode; readonly statusCode?: number; readonly help?: string; readonly retryable: boolean; readonly exitCode: number; readonly retryAfterMs?: number; constructor(message: string, code: ScoutlineErrorCode, options?: ScoutlineErrorOptions); } /** * Compatibility name for existing imports. The 4-arg constructor * signature matches the legacy `ZaiError` so current call sites keep * working without modification. Status codes passed here become * `statusCode`; `help` becomes `help`; `retryable` and `exitCode` keep * their defaults (`false` / `1`). * * The `code` parameter retains its legacy `string` type so existing * call sites (and tests) that pass non-union string codes keep * compiling. The value is cast through `ScoutlineErrorCode` at the * super call because TypeScript types are erased at runtime — the * parent constructor stores whatever string was passed. * * The trailing `options` parameter is additive and optional; the 4-arg * signature every current caller uses is unchanged. It carries the * normalized error's optional fields — currently the Provider retry hint. */ export declare class ZaiError extends ScoutlineError { constructor(message: string, code: string, statusCode?: number, help?: string, options?: Pick); } export declare class ValidationError extends ScoutlineError { constructor(message: string, help?: string); } export declare class UnsupportedCapabilityError extends ScoutlineError { constructor(provider: string, capability: string); } /** * Provider-specific option unsupported by a Capability. The constructor * signature is unchanged so all current throw sites keep compiling without * modification; the structured fields expose the same information notices * used to extract from the message string. Provider-fallback notices read * these fields directly (the message format MUST stay stable — it is * checked verbatim by existing adapter tests). */ export declare class UnsupportedOptionError extends ScoutlineError { readonly provider: string; readonly capability: string; readonly option: string; constructor(provider: string, capability: string, option: string); } /** * M7 (owner-ruled fix): CLI-parse rejection of a flag a command does not * accept. Previously these sites threw `UnsupportedOptionError`, whose * message — `Provider "X" does not support option …` — is a false * sentence at parse time: no Provider was consulted, none is at fault. * `UnsupportedOptionError` stays untouched for genuine Provider-side * use (adapters pin its wording verbatim). * * Same public code (`UNSUPPORTED_OPTION`) and exit code (1) so error * envelopes stay machine-parseable; only the attribution changes — * the COMMAND is the subject. `help` carries surface-specific guidance * (e.g. `repo tree` points at the budgeted repo subcommands). */ export declare class CommandOptionUnsupportedError extends ScoutlineError { readonly command: string; readonly option: string; constructor(command: string, option: string, options?: { help?: string; }); } export declare class ConfigurationError extends ScoutlineError { constructor(message: string, help?: string); } /** * Normalized concrete quota-exhaustion error (DESIGN.md §18, PRD FR-090). * * P6 introduces this construction path because the public code (`QUOTA_ERROR`, * status 429, terminal retry) has been declared since P1 but no concrete * class existed. The Adapters and shared execution surface this class for * Provider-side exhausted-quota conditions; `formatErrorOutput` and the * invocation adapter apply the standard redaction/envelope so credential * material and Provider bodies never reach the public envelope. * * Retry semantics are intentionally terminal: an exhausted quota cannot be * resolved by another attempt. The shared retry classifier in * `lib/execution.ts` relies on `retryable === false` here. */ export declare class QuotaError extends ScoutlineError { /** * `options` is additive and optional: the 0/1/2-arg forms every * current throw site uses behave exactly as before. A Provider * retry hint may be carried through it, but it stays informational — * `retryable: false` is fixed here, so the hint can never make an * exhausted quota retryable (the #140 ruling). */ constructor(message?: string, help?: string, options?: Pick); } export declare function isRetryableError(error: unknown): boolean; export declare function getErrorExitCode(error: unknown): number; export declare class AuthError extends ZaiError { constructor(message: string, keyName?: string); } export declare class ApiError extends ZaiError { /** * `options` is additive and optional: the 2-arg form every current * throw site uses behaves exactly as before. It exists so an Adapter * that parsed a Provider retry header can surface the delay on the * NORMALIZED error (the seam the shared executor reads). */ constructor(message: string, statusCode: number, options?: Pick); } export declare class NetworkError extends ZaiError { constructor(message: string); } export declare class TimeoutError extends ZaiError { /** * The configured timeout duration that elapsed, in milliseconds. Kept as * a first-class field (Fixup D) so an Adapter rewrapping a typed * `TimeoutError` can preserve the original duration instead of re-reading * an ambient `process.env` value that may differ from the injected env. * * Phase A MiniMax transport (critique G4): the constructor accepts an * optional `help` override so MiniMax callers can surface the * `MINIMAX_TIMEOUT` env var instead of the default `Z_AI_TIMEOUT` * reference. Strict superset — existing 1-arg callers continue to * receive the default help text unchanged. * * #205: an additive options parameter lets the class carry * `retryAfterMs`, so a Provider `Retry-After` parsed on 408/504 * reaches the shared executor (which honours it off any * `ScoutlineError`) instead of being discarded. Strict superset — * 1-arg and 2-arg call sites stay byte-identical. */ readonly durationMs: number; constructor(timeoutMs: number, help?: string, options?: Pick); } export declare class FileError extends ZaiError { constructor(message: string, help?: string); } //# sourceMappingURL=errors.d.ts.map