{"version":3,"file":"provider-rate-limit-error.mjs","names":[],"sources":["../../../../../../../ai/src/errors/provider-rate-limit-error.ts"],"sourcesContent":["import type { AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\nimport { ProviderError } from \"./provider-error\";\n\n/**\n * Payload for `ProviderRateLimitError`. `retryAfter` is the server's\n * hint (typically parsed from the `Retry-After` header) in milliseconds.\n */\nexport type ProviderRateLimitErrorOptions = AIErrorOptions & {\n  retryAfter?: number;\n};\n\n/**\n * Provider refused the call because the account (or key, or window)\n * is over its rate-limit or quota. Retryable after `retryAfter`\n * milliseconds — consumers are expected to back off before retrying.\n *\n * Covers both transient `429 Too Many Requests` and the billing-level\n * `insufficient_quota` case; the adapter decides which provider\n * signals map here.\n *\n * @example\n * if (result.error instanceof ProviderRateLimitError) {\n *   await sleep(result.error.retryAfter ?? 1000);\n * }\n */\nexport class ProviderRateLimitError extends ProviderError {\n  public static readonly defaultCategory: ErrorCategory = \"rate-limit\";\n\n  public readonly retryAfter?: number;\n\n  public constructor(message: string, options?: ProviderRateLimitErrorOptions) {\n    super(message, options, \"PROVIDER_RATE_LIMIT\");\n    this.name = \"ProviderRateLimitError\";\n    this.retryAfter = options?.retryAfter;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,IAAa,yBAAb,cAA4C,cAAc;;yBACA;;CAIxD,AAAO,YAAY,SAAiB,SAAyC;EAC3E,MAAM,SAAS,SAAS,qBAAqB;EAC7C,KAAK,OAAO;EACZ,KAAK,aAAa,SAAS;CAC7B;AACF"}