@rulvar/anthropic 1.73.0 → 1.75.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 +17 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -661,6 +661,22 @@ 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
+ if (match === null) return;
669
+ const parsed = Number(match[1]);
670
+ return Number.isSafeInteger(parsed) ? parsed : void 0;
671
+ };
672
+ const requestsPerMinute = limitOf("x-ratelimit-limit-requests");
673
+ const inputTokensPerMinute = limitOf("x-ratelimit-limit-input-tokens");
674
+ const outputTokensPerMinute = limitOf("x-ratelimit-limit-output-tokens");
675
+ const reportedLimits = {
676
+ ...requestsPerMinute === void 0 ? {} : { requestsPerMinute },
677
+ ...inputTokensPerMinute === void 0 ? {} : { inputTokensPerMinute },
678
+ ...outputTokensPerMinute === void 0 ? {} : { outputTokensPerMinute }
679
+ };
664
680
  return {
665
681
  code: "agent",
666
682
  message,
@@ -669,6 +685,7 @@ function anthropicErrorToWire(error) {
669
685
  kind: "rate-limit",
670
686
  ...retryAfterMs === void 0 ? {} : { retryAfterMs },
671
687
  ...Object.keys(buckets).length > 0 ? { buckets } : {},
688
+ ...Object.keys(reportedLimits).length > 0 ? { reportedLimits } : {},
672
689
  status: 429
673
690
  }
674
691
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/anthropic",
3
- "version": "1.73.0",
3
+ "version": "1.75.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.75.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.75.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",