@rulvar/anthropic 1.73.0 → 1.74.0

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -661,6 +661,20 @@ function anthropicErrorToWire(error) {
661
661
  const value = headerGet(name);
662
662
  if (value !== void 0) buckets[name] = value;
663
663
  }
664
+ const limitOf = (name) => {
665
+ const value = headerGet(name);
666
+ if (value === void 0) return;
667
+ const match = /^[\t ]*([0-9]+)[\t ]*$/.exec(value);
668
+ return match === null ? void 0 : Number(match[1]);
669
+ };
670
+ const requestsPerMinute = limitOf("x-ratelimit-limit-requests");
671
+ const inputTokensPerMinute = limitOf("x-ratelimit-limit-input-tokens");
672
+ const outputTokensPerMinute = limitOf("x-ratelimit-limit-output-tokens");
673
+ const reportedLimits = {
674
+ ...requestsPerMinute === void 0 ? {} : { requestsPerMinute },
675
+ ...inputTokensPerMinute === void 0 ? {} : { inputTokensPerMinute },
676
+ ...outputTokensPerMinute === void 0 ? {} : { outputTokensPerMinute }
677
+ };
664
678
  return {
665
679
  code: "agent",
666
680
  message,
@@ -669,6 +683,7 @@ function anthropicErrorToWire(error) {
669
683
  kind: "rate-limit",
670
684
  ...retryAfterMs === void 0 ? {} : { retryAfterMs },
671
685
  ...Object.keys(buckets).length > 0 ? { buckets } : {},
686
+ ...Object.keys(reportedLimits).length > 0 ? { reportedLimits } : {},
672
687
  status: 429
673
688
  }
674
689
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/anthropic",
3
- "version": "1.73.0",
3
+ "version": "1.74.0",
4
4
  "description": "Rulvar first-class provider adapter over @anthropic-ai/sdk.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@anthropic-ai/sdk": "^0.110.0",
26
- "@rulvar/core": "1.73.0"
26
+ "@rulvar/core": "1.74.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^22.20.0",
30
30
  "tsdown": "^0.22.3",
31
31
  "typescript": "~6.0.3",
32
- "@rulvar/testing": "1.73.0"
32
+ "@rulvar/testing": "1.74.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",