@wrongstack/core 0.292.0 → 0.292.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -441,7 +441,8 @@ function effectiveInputTokens(usage) {
441
441
  }
442
442
  var CONTEXT_OVERFLOW_RE = /context.length|context.window|maximum context|max.*tokens?.*exceeded|prompt is too long|too long|exceeds the context|\btokens\b.*exceed|too many tokens|reduce the length|resulted in \d+ tokens|input.{0,12}too (?:large|long)|context_length_exceeded/i;
443
443
  var CONTENT_FILTER_RE = /content.(filter|policy|moderation)|safety (system|filter)/i;
444
- var QUOTA_EXHAUSTED_RE = /(?:insufficient|exhausted|depleted|exceeded|no|not enough)[-_\s]*(?:quota|credit|balance)|(?:quota|credit|balance)[-_\s]*(?:exhausted|depleted|exceeded|insufficient)|billing[_\s-]*(?:hard[_\s-]*)?limit|payment required|spending limit|plan limit/i;
444
+ var QUOTA_EXHAUSTED_RE = /(?:insufficient|exhausted|depleted|exceeded|no|not enough)[-_\s]*(?:quota|credit|balance)|(?:quota|credit|balance)[-_\s]*(?:exhausted|depleted|exceeded|insufficient)|billing[_\s-]*(?:hard[_\s-]*)?limit|payment required|spending limit|plan limit|usage[-_\s]*limit[-_\s]*(?:reached|exceeded)/i;
445
+ var RATE_LIMIT_EXCEEDED_RE = /rate[-_\s]*limit[-_\s]*exceeded/i;
445
446
  function classifyProviderError(status, body, message) {
446
447
  const type = body?.type;
447
448
  const text = [message, body?.message, type, body?.raw].filter(Boolean).join("\n");
@@ -449,6 +450,9 @@ function classifyProviderError(status, body, message) {
449
450
  if (status === 408) return "timeout";
450
451
  if (status === 599) return "stream_hang";
451
452
  if (status === 402 || QUOTA_EXHAUSTED_RE.test(text)) return "quota_exhausted";
453
+ if (status === 429 && body?.message && RATE_LIMIT_EXCEEDED_RE.test(body.message)) {
454
+ return "quota_exhausted";
455
+ }
452
456
  if (type === "rate_limit_error" || status === 429) return "rate_limit";
453
457
  if (type === "overloaded_error" || status === 529) return "overloaded";
454
458
  if (status >= 500) return "server";