/** * Auth key retry — rotates to the next auth profile on rate-limit / auth errors. * * When an agent has multiple auth profiles configured (`auth: ["k1", "k2"]`), * a rate-limit or auth failure triggers a retry with the next key in the * rotation. Each key is tried at most once per invocation. */ import type { AuthProfileStore } from "../auth/types.js"; import type { RemoteClawConfig } from "../config/config.js"; export type AuthKeyRetryOptions = { cfg: RemoteClawConfig; agentId: string; baseEnv?: Record; store?: AuthProfileStore; }; /** * Execute a callback with automatic auth key retry on rate-limit / auth errors. * * - `auth: false` / `undefined` / single key → one attempt, no retry. * - `auth: ["k1", "k2", ...]` → up to `N` attempts (one per key). * * The `execute` callback receives a merged env (base + auth). On a rate-limit * or auth error (thrown or returned in the result), the next profile is * selected via round-robin and the callback is retried. * * @param options Auth config and base env. * @param execute Callback that runs the agent with the given env. * @param getErrorMessage Extracts an error string from a non-thrown result * (e.g. `result.error`). Return `undefined` if no error. */ export declare function withAuthKeyRetry(options: AuthKeyRetryOptions, execute: (env: Record) => Promise, getErrorMessage: (result: T) => string | undefined): Promise;