import 'rollup-plugin-inject-process-env'; /** * Rate limiting, as agent-server reports it. * * On 2026-10-07 the XAPP API's WAF rate-limited agent-server and every chat failed. The widget told * visitors the chat was offline and to check their connection, and retried each message twice more — * adding load to the thing that was already over its limit. Rate limiting is the server answering: * it is not offline, an immediate retry will not help, and the visitor should be told what is going on. * * agent-server signals it two ways: * - before the stream: HTTP 429, `Retry-After`, body `{ error, code: "RATE_LIMITED", retryAfter }` * - after the stream starts: SSE `error` event `{ error, code: "RATE_LIMITED", retryAfter }` */ export declare const RATE_LIMITED_CODE = "RATE_LIMITED"; export declare const RATE_LIMITED_STATUS = 429; /** Shown when the server did not send a message of its own (e.g. a bare 429 from a WAF). */ export declare const RATE_LIMITED_FALLBACK_MESSAGE = "We're getting more requests than usual right now. Please try again in a few minutes."; export type RateLimitError = Error & { statusCode: number; code: typeof RATE_LIMITED_CODE; /** Seconds the server asked us to wait, when it said. */ retryAfter?: number; /** The user-facing message the server sent, when it sent one. */ serverMessage?: string; }; export declare function isRateLimitError(error: unknown): error is RateLimitError; export declare function createRateLimitError(serverMessage?: string, retryAfter?: number): RateLimitError; /** Seconds from a `retryAfter` body field or a `Retry-After` header. HTTP-date values are ignored. */ export declare function parseRetryAfter(value: unknown): number | undefined; interface ResponseLike { headers?: { get(name: string): string | null; }; text?: () => Promise; } /** * Builds the error for a 429 response, reading the agent-server JSON body when there is one. The body * is optional: a 429 from a WAF or proxy in front of agent-server will not carry it. */ export declare function rateLimitErrorFromResponse(response: ResponseLike): Promise; export {};