export interface ToolErrorShape { code: string; message: string; retry_after?: number; suggestion?: string; /** For model_rate_limited: the MODEL whose provider throttled (e.g. "Nano Banana"). */ source?: string; } export interface AhErrorInit { code: string; message: string; retryAfter?: number; suggestion?: string; httpStatus?: number; /** For model_rate_limited: the model name whose provider is throttling. */ source?: string; /** * The API's own error code, when the broad `code` above deliberately generalises * it (e.g. every 409 maps to `conflict`). Lets a tool branch on the specific * condition without narrowing the broad code that other callers already match. * INTERNAL: not part of the agent-facing error payload. */ apiCode?: string; } export declare class AhError extends Error { readonly code: string; readonly retryAfter?: number; readonly suggestion?: string; readonly httpStatus?: number; readonly source?: string; /** The API's specific error code when `code` is a deliberate generalisation. */ readonly apiCode?: string; constructor(init: AhErrorInit); toPayload(): { error: ToolErrorShape; }; } export declare function toErrorPayload(err: unknown): { error: ToolErrorShape; }; export declare function parseRetryAfter(header: string | null | undefined): number | undefined; export declare function mapHttpError(status: number, body: unknown, retryAfterHeader?: string | null): AhError;