/** * Retrying JSON POST shared by the annotator clients. * * Both providers need the same thing: one authenticated POST, exponential backoff on rate limits * and overload, and no retry once the provider has said the request itself is wrong. Keeping that * loop in one place means a fix to it cannot land in one client and not the other. */ export interface RetryPolicy { /** Per request timeout in milliseconds. */ timeoutMs: number; maxRetries: number; } /** What every provider client needs: where, who, which model, and how hard to retry. */ export interface ApiConfig extends RetryPolicy { apiKey: string; baseUrl: string; model: string; } /** * Load a provider's configuration from the environment, after process.loadEnvFile(). * * Throws when the key is missing. That is the fail closed guarantee in docs/threat-model.md: a * provider without a configured key never gets as far as reading a message. */ export declare function apiConfigFromEnv(env: { keyVar: string; urlVar: string; defaultUrl: string; }, model: string, overrides?: Partial): ApiConfig; /** Token accounting, in one shape for every provider. */ export interface Usage { promptTokens: number; completionTokens: number; totalTokens: number; requests: number; } /** An HTTP or protocol failure from an annotation provider. */ export declare class ApiError extends Error { readonly status: number; readonly retryable: boolean; constructor(message: string, status: number, retryable: boolean); } export interface PostJsonOptions { url: string; apiKey: string; payload: unknown; policy: RetryPolicy; /** Build the error for a non 2xx response. Decides what, if anything, of the body is surfaced. */ httpError(status: number, body: unknown): ApiError; /** * Turn a 2xx body into the result. Runs inside the retry loop: throwing an ApiError with * `retryable: false` stops immediately, any other error is retried like a network failure. */ parse(body: unknown): T; } export declare function postJson(options: PostJsonOptions): Promise; //# sourceMappingURL=http.d.ts.map