import { BaseLlm, type BaseLlmConnection, type LlmRequest, type LlmResponse } from '@google/adk'; export interface ResilientLlmOptions { /** * How long to wait for a call (for each chunk, when streaming). Default 90 s: normal calls take 5–20 s, but a CLI * model answers in one piece and may legitimately take longer (Kitana itself gives its CLI 120 s, and may fall back * from one CLI to another inside a call) — abandoning a healthy call only starts a duplicate next to it. */ callTimeoutMs?: number; /** Calls in total, the first one included. Default 2. */ attempts?: number; /** * Calls in total when the provider answers "too many requests" or "overloaded" (429, 5xx). Default 3: these pass * by themselves, unlike a hang. */ transientAttempts?: number; /** * The longest wait before such a retry. The provider's own "retry in N s" is used when it gives one; a longer one * (a daily quota: hours) means waiting is pointless, so the error is reported at once. Default 60 s — a per-minute * quota (Gemini's free tier: 5 requests a minute, an investigation needs about 10) is back within a minute, and * waiting for it beats failing. */ maxRetryDelayMs?: number; /** Called before a call is started again. */ onRetry?: (info: { attempt: number; attempts: number; reason: string; }) => void; /** * Called with every error that leaves this wrapper. Needed because ADK swallows an error raised inside a specialist * (an agent used as a tool): without this nobody would ever see it. */ onError?: (message: string) => void; /** Replaceable in tests. */ sleep?: (ms: number) => Promise; } export declare const DEFAULT_CALL_TIMEOUT_MS = 90000; /** setTimeout's limit: a longer delay silently becomes 1 ms. */ export declare const MAX_CALL_TIMEOUT_MS = 2147483647; export declare class ResilientLlm extends BaseLlm { private readonly inner; private readonly options; private readonly callTimeoutMs; private readonly attempts; private readonly transientAttempts; private readonly maxRetryDelayMs; private readonly sleep; constructor(inner: BaseLlm, options?: ResilientLlmOptions); generateContentAsync(request: LlmRequest, stream?: boolean, abortSignal?: AbortSignal): AsyncGenerator; connect(request: LlmRequest): Promise; }