@rulvar/anthropic 1.123.0 → 1.125.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.
- package/dist/index.d.ts +8 -1
- package/dist/index.js +37 -12
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -149,7 +149,14 @@ declare function mapStopReason(stopReason: string | null | undefined, stopDetail
|
|
|
149
149
|
/**
|
|
150
150
|
* Normalizes Messages API usage under the Usage invariant: Anthropic
|
|
151
151
|
* reports input_tokens EXCLUDING cache reads and writes, so the canonical
|
|
152
|
-
* inputTokens is the sum of all three.
|
|
152
|
+
* inputTokens is the sum of all three. The `cache_creation` breakdown
|
|
153
|
+
* (ephemeral_5m_input_tokens / ephemeral_1h_input_tokens) fills the
|
|
154
|
+
* canonical TTL split (RV810) when it agrees with the flat total, so the
|
|
155
|
+
* 1h premium prices at its own rate downstream; a breakdown that
|
|
156
|
+
* contradicts the flat total is dropped rather than shipped as a broken
|
|
157
|
+
* invariant (the flat total is the billable number, and the
|
|
158
|
+
* undifferentiated 5m-rate fold is the historical conservative default).
|
|
159
|
+
* With no flat field, the breakdown IS the total.
|
|
153
160
|
*/
|
|
154
161
|
declare function normalizeAnthropicUsage(raw: Record<string, unknown> | undefined): Usage;
|
|
155
162
|
interface TurnMapping {
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const ALL_EFFORTS = [
|
|
|
14
14
|
* one page snapshot. A later re-verification bumps it table-wide; a
|
|
15
15
|
* rate CHANGE is a new release with a new pricingVersion.
|
|
16
16
|
*/
|
|
17
|
-
const RATES_VERIFIED_AT = "2026-07-
|
|
17
|
+
const RATES_VERIFIED_AT = "2026-07-31";
|
|
18
18
|
function current(contextWindow, maxOutputTokens, pricing, cacheMinTokens) {
|
|
19
19
|
return {
|
|
20
20
|
caps: {
|
|
@@ -29,6 +29,7 @@ function current(contextWindow, maxOutputTokens, pricing, cacheMinTokens) {
|
|
|
29
29
|
outputUsdPerMTok: pricing.out,
|
|
30
30
|
cacheReadUsdPerMTok: pricing.cacheRead,
|
|
31
31
|
cacheWriteUsdPerMTok: pricing.cacheWrite,
|
|
32
|
+
cacheWrite1hUsdPerMTok: pricing.cacheWrite1h,
|
|
32
33
|
ratesVerifiedAt: RATES_VERIFIED_AT
|
|
33
34
|
} }
|
|
34
35
|
},
|
|
@@ -42,32 +43,37 @@ const ANTHROPIC_MODELS = {
|
|
|
42
43
|
in: 10,
|
|
43
44
|
out: 50,
|
|
44
45
|
cacheRead: 1,
|
|
45
|
-
cacheWrite: 12.5
|
|
46
|
+
cacheWrite: 12.5,
|
|
47
|
+
cacheWrite1h: 20
|
|
46
48
|
}, 2048),
|
|
47
49
|
"claude-opus-4-8": current(1e6, 128e3, {
|
|
48
50
|
in: 5,
|
|
49
51
|
out: 25,
|
|
50
52
|
cacheRead: .5,
|
|
51
|
-
cacheWrite: 6.25
|
|
53
|
+
cacheWrite: 6.25,
|
|
54
|
+
cacheWrite1h: 10
|
|
52
55
|
}, 4096),
|
|
53
56
|
"claude-opus-4-7": current(1e6, 128e3, {
|
|
54
57
|
in: 5,
|
|
55
58
|
out: 25,
|
|
56
59
|
cacheRead: .5,
|
|
57
|
-
cacheWrite: 6.25
|
|
60
|
+
cacheWrite: 6.25,
|
|
61
|
+
cacheWrite1h: 10
|
|
58
62
|
}, 4096),
|
|
59
63
|
"claude-sonnet-5": current(1e6, 128e3, {
|
|
60
64
|
in: 2,
|
|
61
65
|
out: 10,
|
|
62
66
|
cacheRead: .2,
|
|
63
|
-
cacheWrite: 2.5
|
|
67
|
+
cacheWrite: 2.5,
|
|
68
|
+
cacheWrite1h: 4
|
|
64
69
|
}, 2048),
|
|
65
70
|
"claude-haiku-4-5": (() => {
|
|
66
71
|
const base = current(2e5, 64e3, {
|
|
67
72
|
in: 1,
|
|
68
73
|
out: 5,
|
|
69
74
|
cacheRead: .1,
|
|
70
|
-
cacheWrite: 1.25
|
|
75
|
+
cacheWrite: 1.25,
|
|
76
|
+
cacheWrite1h: 2
|
|
71
77
|
}, 2048);
|
|
72
78
|
return {
|
|
73
79
|
...base,
|
|
@@ -83,7 +89,8 @@ const ANTHROPIC_MODELS = {
|
|
|
83
89
|
in: 5,
|
|
84
90
|
out: 25,
|
|
85
91
|
cacheRead: .5,
|
|
86
|
-
cacheWrite: 6.25
|
|
92
|
+
cacheWrite: 6.25,
|
|
93
|
+
cacheWrite1h: 10
|
|
87
94
|
}, 4096),
|
|
88
95
|
thinkingForm: "enabled-budget"
|
|
89
96
|
},
|
|
@@ -92,7 +99,8 @@ const ANTHROPIC_MODELS = {
|
|
|
92
99
|
in: 3,
|
|
93
100
|
out: 15,
|
|
94
101
|
cacheRead: .3,
|
|
95
|
-
cacheWrite: 3.75
|
|
102
|
+
cacheWrite: 3.75,
|
|
103
|
+
cacheWrite1h: 6
|
|
96
104
|
}, 2048),
|
|
97
105
|
thinkingForm: "enabled-budget"
|
|
98
106
|
}
|
|
@@ -119,7 +127,7 @@ const ANTHROPIC_MODELS = {
|
|
|
119
127
|
* Sonnet 5 promotion ending on 2026-08-31).
|
|
120
128
|
*/
|
|
121
129
|
const ANTHROPIC_PRICING = {
|
|
122
|
-
pricingVersion: "anthropic-2026-07-
|
|
130
|
+
pricingVersion: "anthropic-2026-07-31",
|
|
123
131
|
models: (() => {
|
|
124
132
|
const models = {};
|
|
125
133
|
for (const [name, info] of Object.entries(ANTHROPIC_MODELS)) if (info.caps.pricing !== void 0) models[`anthropic:${name}`] = info.caps.pricing;
|
|
@@ -429,18 +437,35 @@ function mapStopReason(stopReason, stopDetails) {
|
|
|
429
437
|
/**
|
|
430
438
|
* Normalizes Messages API usage under the Usage invariant: Anthropic
|
|
431
439
|
* reports input_tokens EXCLUDING cache reads and writes, so the canonical
|
|
432
|
-
* inputTokens is the sum of all three.
|
|
440
|
+
* inputTokens is the sum of all three. The `cache_creation` breakdown
|
|
441
|
+
* (ephemeral_5m_input_tokens / ephemeral_1h_input_tokens) fills the
|
|
442
|
+
* canonical TTL split (RV810) when it agrees with the flat total, so the
|
|
443
|
+
* 1h premium prices at its own rate downstream; a breakdown that
|
|
444
|
+
* contradicts the flat total is dropped rather than shipped as a broken
|
|
445
|
+
* invariant (the flat total is the billable number, and the
|
|
446
|
+
* undifferentiated 5m-rate fold is the historical conservative default).
|
|
447
|
+
* With no flat field, the breakdown IS the total.
|
|
433
448
|
*/
|
|
434
449
|
function normalizeAnthropicUsage(raw) {
|
|
435
450
|
const input = typeof raw?.input_tokens === "number" ? raw.input_tokens : 0;
|
|
436
451
|
const output = typeof raw?.output_tokens === "number" ? raw.output_tokens : 0;
|
|
437
452
|
const cacheRead = typeof raw?.cache_read_input_tokens === "number" ? raw.cache_read_input_tokens : 0;
|
|
438
|
-
const
|
|
453
|
+
const flatWrite = typeof raw?.cache_creation_input_tokens === "number" ? raw.cache_creation_input_tokens : void 0;
|
|
454
|
+
const breakdown = raw?.cache_creation;
|
|
455
|
+
const write5m = typeof breakdown?.ephemeral_5m_input_tokens === "number" ? breakdown.ephemeral_5m_input_tokens : void 0;
|
|
456
|
+
const write1h = typeof breakdown?.ephemeral_1h_input_tokens === "number" ? breakdown.ephemeral_1h_input_tokens : void 0;
|
|
457
|
+
const splitSum = write5m === void 0 && write1h === void 0 ? void 0 : (write5m ?? 0) + (write1h ?? 0);
|
|
458
|
+
const cacheWrite = flatWrite ?? splitSum ?? 0;
|
|
459
|
+
const splitAgrees = splitSum !== void 0 && splitSum === cacheWrite;
|
|
439
460
|
return {
|
|
440
461
|
inputTokens: input + cacheRead + cacheWrite,
|
|
441
462
|
outputTokens: output,
|
|
442
463
|
cacheReadTokens: cacheRead,
|
|
443
|
-
cacheWriteTokens: cacheWrite
|
|
464
|
+
cacheWriteTokens: cacheWrite,
|
|
465
|
+
...splitAgrees ? {
|
|
466
|
+
cacheWrite5mTokens: write5m ?? 0,
|
|
467
|
+
cacheWrite1hTokens: write1h ?? 0
|
|
468
|
+
} : {}
|
|
444
469
|
};
|
|
445
470
|
}
|
|
446
471
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/anthropic",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.125.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.115.0",
|
|
26
|
-
"@rulvar/core": "1.
|
|
26
|
+
"@rulvar/core": "1.125.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.20.1",
|
|
30
30
|
"tsdown": "^0.22.14",
|
|
31
31
|
"typescript": "~6.0.3",
|
|
32
|
-
"@rulvar/testing": "1.
|
|
32
|
+
"@rulvar/testing": "1.125.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|