@warlock.js/ai-anthropic 5.31.0 → 5.33.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/CHANGELOG.md +20 -0
- package/cjs/index.cjs +33 -7
- package/cjs/index.cjs.map +1 -1
- package/esm/config.type.d.mts +22 -16
- package/esm/config.type.d.mts.map +1 -1
- package/esm/index.d.mts +3 -2
- package/esm/index.mjs +2 -2
- package/esm/known-pricing.d.mts +12 -7
- package/esm/known-pricing.d.mts.map +1 -1
- package/esm/known-pricing.mjs +8 -1
- package/esm/known-pricing.mjs.map +1 -1
- package/esm/model.d.mts +1 -3
- package/esm/model.d.mts.map +1 -1
- package/esm/model.mjs +7 -3
- package/esm/model.mjs.map +1 -1
- package/esm/request.type.d.mts +4 -6
- package/esm/request.type.d.mts.map +1 -1
- package/esm/sdk.d.mts +1 -3
- package/esm/sdk.d.mts.map +1 -1
- package/esm/thinking-mode.d.mts +2 -3
- package/esm/thinking-mode.d.mts.map +1 -1
- package/esm/thinking-mode.mjs +1 -1
- package/esm/utils/index.d.mts +4 -1
- package/esm/utils/index.mjs +1 -1
- package/esm/utils/map-stop-reason.d.mts +1 -1
- package/esm/utils/provider-blocks.d.mts +3 -5
- package/esm/utils/provider-blocks.d.mts.map +1 -1
- package/esm/utils/provider-blocks.mjs +3 -3
- package/esm/utils/provider-blocks.mjs.map +1 -1
- package/esm/utils/server-tool-usage.mjs +17 -0
- package/esm/utils/server-tool-usage.mjs.map +1 -0
- package/esm/utils/to-anthropic-messages.d.mts +3 -5
- package/esm/utils/to-anthropic-messages.d.mts.map +1 -1
- package/esm/utils/to-anthropic-tools.d.mts +1 -3
- package/esm/utils/to-anthropic-tools.d.mts.map +1 -1
- package/llms-full.txt +34 -0
- package/package.json +3 -3
- package/skills/setup-anthropic/SKILL.md +34 -0
package/esm/config.type.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AnthropicThinkingMode } from "./thinking-mode.mjs";
|
|
2
2
|
import { ClientOptions } from "@anthropic-ai/sdk";
|
|
3
3
|
import { ModelConfig, ModelPricing } from "@warlock.js/ai";
|
|
4
|
-
|
|
5
4
|
//#region ../../packages/ai-anthropic/src/config.type.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Configuration for the Anthropic SDK adapter.
|
|
@@ -32,7 +31,7 @@ import { ModelConfig, ModelPricing } from "@warlock.js/ai";
|
|
|
32
31
|
* },
|
|
33
32
|
* });
|
|
34
33
|
*/
|
|
35
|
-
type AnthropicSDKConfig = ClientOptions & {
|
|
34
|
+
export type AnthropicSDKConfig = ClientOptions & {
|
|
36
35
|
provider?: string;
|
|
37
36
|
/**
|
|
38
37
|
* Per-model USD pricing registry, keyed by model name. Surfaced onto
|
|
@@ -49,7 +48,7 @@ type AnthropicSDKConfig = ClientOptions & {
|
|
|
49
48
|
* anthropic.model({ name: "claude-sonnet-4-6" }); // vision auto-true
|
|
50
49
|
* anthropic.model({ name: "custom-proxy-model", vision: false }); // dev override
|
|
51
50
|
*/
|
|
52
|
-
type AnthropicModelConfig = ModelConfig & {
|
|
51
|
+
export type AnthropicModelConfig = ModelConfig & {
|
|
53
52
|
/**
|
|
54
53
|
* Override the auto-inferred vision capability. When omitted, the
|
|
55
54
|
* adapter checks the model name against the known Claude vision
|
|
@@ -156,15 +155,20 @@ type AnthropicModelConfig = ModelConfig & {
|
|
|
156
155
|
* fields use the API defaults (trigger 100,000 input tokens, keep 3 tool
|
|
157
156
|
* uses; Anthropic docs, "Context editing", read 2026-10-17).
|
|
158
157
|
*/
|
|
159
|
-
type AnthropicClearToolUses = {
|
|
160
|
-
/** When clearing starts: an input-token count or a tool-use count. */
|
|
158
|
+
export type AnthropicClearToolUses = {
|
|
159
|
+
/** When clearing starts: an input-token count or a tool-use count. */
|
|
160
|
+
trigger?: {
|
|
161
161
|
inputTokens: number;
|
|
162
162
|
} | {
|
|
163
163
|
toolUses: number;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
};
|
|
165
|
+
/** How many of the most recent tool uses keep their results. */
|
|
166
|
+
keep?: number;
|
|
167
|
+
/** Apply only when at least this many input tokens can be cleared. */
|
|
168
|
+
clearAtLeast?: number;
|
|
169
|
+
/** Tool names whose uses and results are never cleared. */
|
|
170
|
+
excludeTools?: string[];
|
|
171
|
+
/** Also clear the tool-use inputs: `true` for every tool, or a list of tool names. */
|
|
168
172
|
clearToolInputs?: boolean | string[];
|
|
169
173
|
};
|
|
170
174
|
/**
|
|
@@ -173,7 +177,7 @@ type AnthropicClearToolUses = {
|
|
|
173
177
|
* model's default applies (keep all on Opus 4.5+, Sonnet 4.6+, Haiku 5.5 and
|
|
174
178
|
* the Fable / Mythos models; last turn only on older ones).
|
|
175
179
|
*/
|
|
176
|
-
type AnthropicClearThinking = {
|
|
180
|
+
export type AnthropicClearThinking = {
|
|
177
181
|
keep?: number | "all";
|
|
178
182
|
};
|
|
179
183
|
/**
|
|
@@ -181,8 +185,10 @@ type AnthropicClearThinking = {
|
|
|
181
185
|
* added automatically). Server-side edits don't count as history edits for
|
|
182
186
|
* preserved thinking: the API checks the conversation as you sent it.
|
|
183
187
|
*/
|
|
184
|
-
type AnthropicContextManagement = {
|
|
185
|
-
/** Clear old tool results. `true` uses the API defaults. */
|
|
188
|
+
export type AnthropicContextManagement = {
|
|
189
|
+
/** Clear old tool results. `true` uses the API defaults. */
|
|
190
|
+
clearToolUses?: true | AnthropicClearToolUses;
|
|
191
|
+
/** Clear thinking blocks from older turns. `true` uses the model default. */
|
|
186
192
|
clearThinking?: true | AnthropicClearThinking;
|
|
187
193
|
};
|
|
188
194
|
/**
|
|
@@ -194,8 +200,9 @@ type AnthropicContextManagement = {
|
|
|
194
200
|
* before it. Source: Anthropic docs, "Compaction at a token threshold",
|
|
195
201
|
* read 2026-10-17.
|
|
196
202
|
*/
|
|
197
|
-
type AnthropicServerCompaction = {
|
|
198
|
-
/** Input tokens that trigger compaction. At least 50,000; API default 150,000. */
|
|
203
|
+
export type AnthropicServerCompaction = {
|
|
204
|
+
/** Input tokens that trigger compaction. At least 50,000; API default 150,000. */
|
|
205
|
+
triggerTokens?: number;
|
|
199
206
|
/**
|
|
200
207
|
* Replaces the default summarization prompt entirely. When the request has
|
|
201
208
|
* tools, say "do not call any tools", or the summary step may call one.
|
|
@@ -235,7 +242,7 @@ type AnthropicServerCompaction = {
|
|
|
235
242
|
* },
|
|
236
243
|
* });
|
|
237
244
|
*/
|
|
238
|
-
type AnthropicCallOptions = {
|
|
245
|
+
export type AnthropicCallOptions = {
|
|
239
246
|
/**
|
|
240
247
|
* Beta flags (`anthropic-beta` header values). When non-empty the
|
|
241
248
|
* request goes through the SDK's `client.beta.messages` endpoint, which
|
|
@@ -292,5 +299,4 @@ type AnthropicCallOptions = {
|
|
|
292
299
|
thinkingBlockBinding?: "error" | "drop_block";
|
|
293
300
|
};
|
|
294
301
|
//#endregion
|
|
295
|
-
export { AnthropicCallOptions, AnthropicClearThinking, AnthropicClearToolUses, AnthropicContextManagement, AnthropicModelConfig, AnthropicSDKConfig, AnthropicServerCompaction };
|
|
296
302
|
//# sourceMappingURL=config.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.type.d.mts","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/config.type.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.type.d.mts","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCY,qBAAqB;EAC/B;;;;;;EAMA,UAAU,eAAe;;;;;;;;;;YAWf,uBAAuB;;;;;;;;EAQjC;;;;;;;;;;;;EAYA;;;;;;;;;EASA;;;;;;;;;;;;;;;;;;;;;EAqBA;;;;;;;;EAQA;;;;;;;;;;EAUA;;;;;;;;;;;;;;;;;;EAkBA,eAAe;;;;;;;;;;;;;EAaf;;;;;;;;YASU;;EAEV;IAAY;;IAA0B;;;EAEtC;;EAEA;;EAEA;;EAEA;;;;;;;;YASU;EAA2B;;;;;;;YAO3B;;EAEV,uBAAuB;;EAEvB,uBAAuB;;;;;;;;;;;YAYb;;EAEV;;;;;EAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoCU;;;;;;;EAOV;;;;;;;;;;EAUA,OAAO;;;;;;;;;;;EAWP;;;;;;;EAOA,oBAAoB;;;;;;;EAOpB,6BAA6B;;;;;;;;;;;;EAY7B"}
|
package/esm/index.d.mts
CHANGED
|
@@ -3,8 +3,9 @@ import { AnthropicCallOptions, AnthropicClearThinking, AnthropicClearToolUses, A
|
|
|
3
3
|
import { AnthropicNonStreamingRequest, AnthropicRequest, AnthropicRequestOptions, AnthropicStreamingRequest } from "./request.type.mjs";
|
|
4
4
|
import { AnthropicModel } from "./model.mjs";
|
|
5
5
|
import { AnthropicSDK } from "./sdk.mjs";
|
|
6
|
-
import { ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, anthropicPricingFor, withAnthropicCacheWriteRates } from "./known-pricing.mjs";
|
|
6
|
+
import { ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, ANTHROPIC_SERVER_TOOL_PRICING, anthropicPricingFor, withAnthropicCacheWriteRates } from "./known-pricing.mjs";
|
|
7
7
|
import { ANTHROPIC_BLOCK_FORMAT, fromProviderBlocks, toProviderBlocks } from "./utils/provider-blocks.mjs";
|
|
8
8
|
import { AnthropicMessages, ToAnthropicMessagesOptions, toAnthropicMessages } from "./utils/to-anthropic-messages.mjs";
|
|
9
9
|
import { toAnthropicTools } from "./utils/to-anthropic-tools.mjs";
|
|
10
|
-
|
|
10
|
+
import "./utils/index.mjs";
|
|
11
|
+
export { ANTHROPIC_BLOCK_FORMAT, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, ANTHROPIC_SERVER_TOOL_PRICING, type AnthropicCallOptions, type AnthropicClearThinking, type AnthropicClearToolUses, type AnthropicContextManagement, type AnthropicMessages, AnthropicModel, type AnthropicModelConfig, type AnthropicNonStreamingRequest, type AnthropicRequest, type AnthropicRequestOptions, AnthropicSDK, type AnthropicSDKConfig, type AnthropicServerCompaction, type AnthropicStreamingRequest, type AnthropicThinkingMode, type ToAnthropicMessagesOptions, anthropicPricingFor, fromProviderBlocks, inferPreservedThinking, toAnthropicMessages, toAnthropicTools, toProviderBlocks, withAnthropicCacheWriteRates };
|
package/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, anthropicPricingFor, withAnthropicCacheWriteRates } from "./known-pricing.mjs";
|
|
1
|
+
import { ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, ANTHROPIC_SERVER_TOOL_PRICING, anthropicPricingFor, withAnthropicCacheWriteRates } from "./known-pricing.mjs";
|
|
2
2
|
import { inferPreservedThinking } from "./thinking-mode.mjs";
|
|
3
3
|
import { ANTHROPIC_BLOCK_FORMAT, fromProviderBlocks, toProviderBlocks } from "./utils/provider-blocks.mjs";
|
|
4
4
|
import { toAnthropicMessages } from "./utils/to-anthropic-messages.mjs";
|
|
@@ -7,4 +7,4 @@ import "./utils/index.mjs";
|
|
|
7
7
|
import { AnthropicModel } from "./model.mjs";
|
|
8
8
|
import { AnthropicSDK } from "./sdk.mjs";
|
|
9
9
|
|
|
10
|
-
export { ANTHROPIC_BLOCK_FORMAT, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, AnthropicModel, AnthropicSDK, anthropicPricingFor, fromProviderBlocks, inferPreservedThinking, toAnthropicMessages, toAnthropicTools, toProviderBlocks, withAnthropicCacheWriteRates };
|
|
10
|
+
export { ANTHROPIC_BLOCK_FORMAT, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, ANTHROPIC_SERVER_TOOL_PRICING, AnthropicModel, AnthropicSDK, anthropicPricingFor, fromProviderBlocks, inferPreservedThinking, toAnthropicMessages, toAnthropicTools, toProviderBlocks, withAnthropicCacheWriteRates };
|
package/esm/known-pricing.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ModelPricing } from "@warlock.js/ai";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/ai-anthropic/src/known-pricing.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Anthropic's prompt-cache write multipliers, relative to the base input
|
|
@@ -9,8 +8,8 @@ import { ModelPricing } from "@warlock.js/ai";
|
|
|
9
8
|
* Source: https://platform.claude.com/docs/en/about-claude/pricing
|
|
10
9
|
* (fetched 2026-10-17).
|
|
11
10
|
*/
|
|
12
|
-
declare const ANTHROPIC_CACHE_WRITE_MULTIPLIER = 1.25;
|
|
13
|
-
declare const ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = 2;
|
|
11
|
+
export declare const ANTHROPIC_CACHE_WRITE_MULTIPLIER = 1.25;
|
|
12
|
+
export declare const ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = 2;
|
|
14
13
|
/**
|
|
15
14
|
* Built-in Claude API list prices, USD per 1,000,000 tokens, keyed by
|
|
16
15
|
* model id. `cachedInput` is the cache-hit rate, `cacheWrite` the
|
|
@@ -29,7 +28,7 @@ declare const ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = 2;
|
|
|
29
28
|
* Dated snapshot ids (`claude-haiku-4-5-20251001`) resolve to their alias
|
|
30
29
|
* entry through {@link anthropicPricingFor}.
|
|
31
30
|
*/
|
|
32
|
-
declare const ANTHROPIC_MODEL_PRICING: Readonly<Record<string, ModelPricing>>;
|
|
31
|
+
export declare const ANTHROPIC_MODEL_PRICING: Readonly<Record<string, ModelPricing>>;
|
|
33
32
|
/**
|
|
34
33
|
* Look up the built-in list price for a Claude model id. Accepts the
|
|
35
34
|
* alias (`claude-sonnet-4-5`) or a dated snapshot
|
|
@@ -40,7 +39,7 @@ declare const ANTHROPIC_MODEL_PRICING: Readonly<Record<string, ModelPricing>>;
|
|
|
40
39
|
* anthropicPricingFor("claude-haiku-4-5-20251001"); // { input: 1, output: 5, … }
|
|
41
40
|
* anthropicPricingFor("claude-haiku-5-5"); // undefined (prompt-length tiers)
|
|
42
41
|
*/
|
|
43
|
-
declare function anthropicPricingFor(modelName: string): ModelPricing | undefined;
|
|
42
|
+
export declare function anthropicPricingFor(modelName: string): ModelPricing | undefined;
|
|
44
43
|
/**
|
|
45
44
|
* Fill the cache-write rates Anthropic derives from the input rate
|
|
46
45
|
* (5-minute writes 1.25x, 1-hour writes 2x) into a pricing entry that
|
|
@@ -52,7 +51,13 @@ declare function anthropicPricingFor(modelName: string): ModelPricing | undefine
|
|
|
52
51
|
* withAnthropicCacheWriteRates({ input: 3, output: 15 });
|
|
53
52
|
* // { input: 3, output: 15, cacheWrite: 3.75, cacheWrite1h: 6 }
|
|
54
53
|
*/
|
|
55
|
-
declare function withAnthropicCacheWriteRates(pricing: ModelPricing | undefined): ModelPricing | undefined;
|
|
54
|
+
export declare function withAnthropicCacheWriteRates(pricing: ModelPricing | undefined): ModelPricing | undefined;
|
|
55
|
+
/** USD per request, verified 2026-10-18. Tokens are additional.
|
|
56
|
+
* https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool#usage-and-pricing
|
|
57
|
+
* https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool#usage-and-pricing */
|
|
58
|
+
export declare const ANTHROPIC_SERVER_TOOL_PRICING: {
|
|
59
|
+
webSearch: number;
|
|
60
|
+
webFetch: number;
|
|
61
|
+
};
|
|
56
62
|
//#endregion
|
|
57
|
-
export { ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, anthropicPricingFor, withAnthropicCacheWriteRates };
|
|
58
63
|
//# sourceMappingURL=known-pricing.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"known-pricing.d.mts","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/known-pricing.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"known-pricing.d.mts","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/known-pricing.ts"],"mappings":";;;;;;;;;;qBAUa;qBACA;;;;;;;;;;;;;;;;;;;qBAoBA,yBAAyB,SAAS,eAAe;;;;;;;;;;;wBA+C9C,oBAAoB,oBAAoB;;;;;;;;;;;;wBAqBxC,6BACd,SAAS,2BACR;;;;qBAmBU;EAAkC;EAAiB"}
|
package/esm/known-pricing.mjs
CHANGED
|
@@ -159,7 +159,14 @@ function withAnthropicCacheWriteRates(pricing) {
|
|
|
159
159
|
cacheWrite1h
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
+
/** USD per request, verified 2026-10-18. Tokens are additional.
|
|
163
|
+
* https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool#usage-and-pricing
|
|
164
|
+
* https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool#usage-and-pricing */
|
|
165
|
+
const ANTHROPIC_SERVER_TOOL_PRICING = {
|
|
166
|
+
webSearch: .01,
|
|
167
|
+
webFetch: 0
|
|
168
|
+
};
|
|
162
169
|
|
|
163
170
|
//#endregion
|
|
164
|
-
export { ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, anthropicPricingFor, withAnthropicCacheWriteRates };
|
|
171
|
+
export { ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_MULTIPLIER, ANTHROPIC_MODEL_PRICING, ANTHROPIC_SERVER_TOOL_PRICING, anthropicPricingFor, withAnthropicCacheWriteRates };
|
|
165
172
|
//# sourceMappingURL=known-pricing.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"known-pricing.mjs","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/known-pricing.ts"],"sourcesContent":["import type { ModelPricing } from \"@warlock.js/ai\";\n\n/**\n * Anthropic's prompt-cache write multipliers, relative to the base input\n * rate: a 5-minute write costs 1.25x, a 1-hour write 2x. They hold for\n * every Claude model on Anthropic's price list.\n *\n * Source: https://platform.claude.com/docs/en/about-claude/pricing\n * (fetched 2026-10-17).\n */\nexport const ANTHROPIC_CACHE_WRITE_MULTIPLIER = 1.25;\nexport const ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = 2;\n\n/**\n * Built-in Claude API list prices, USD per 1,000,000 tokens, keyed by\n * model id. `cachedInput` is the cache-hit rate, `cacheWrite` the\n * 5-minute write rate and `cacheWrite1h` the 1-hour write rate.\n *\n * Source: https://platform.claude.com/docs/en/about-claude/pricing,\n * \"Model pricing\" table, fetched 2026-10-17. Standard (global) routing,\n * non-batch. Not covered, so pass `pricing` yourself when you need them:\n *\n * - Claude Haiku 5.5 — priced by prompt length (higher rates above\n * 100,000 prompt tokens), which a flat `ModelPricing` cannot express.\n * - US-only inference (`inference_geo: \"us\"`, 1.1x), fast mode, the Batch\n * API, and Claude on Bedrock / Vertex AI (partner-priced).\n * - Limited-availability models (Mythos) and retired models.\n *\n * Dated snapshot ids (`claude-haiku-4-5-20251001`) resolve to their alias\n * entry through {@link anthropicPricingFor}.\n */\nexport const ANTHROPIC_MODEL_PRICING: Readonly<Record<string, ModelPricing>> = {\n \"claude-fable-5-1\": {\n input: 10,\n output: 50,\n cachedInput: 0.25,\n cacheWrite: 12.5,\n cacheWrite1h: 20,\n },\n \"claude-fable-5\": { input: 10, output: 50, cachedInput: 1, cacheWrite: 12.5, cacheWrite1h: 20 },\n \"claude-opus-5-5\": { input: 4, output: 20, cachedInput: 0.2, cacheWrite: 5, cacheWrite1h: 8 },\n \"claude-opus-5\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-opus-4-8\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-opus-4-7\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-opus-4-6\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-opus-4-5\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-sonnet-5-5\": { input: 2, output: 10, cachedInput: 0.1, cacheWrite: 2.5, cacheWrite1h: 4 },\n \"claude-sonnet-5\": { input: 2, output: 10, cachedInput: 0.2, cacheWrite: 2.5, cacheWrite1h: 4 },\n \"claude-sonnet-4-6\": {\n input: 3,\n output: 15,\n cachedInput: 0.3,\n cacheWrite: 3.75,\n cacheWrite1h: 6,\n },\n \"claude-sonnet-4-5\": {\n input: 3,\n output: 15,\n cachedInput: 0.3,\n cacheWrite: 3.75,\n cacheWrite1h: 6,\n },\n \"claude-haiku-4-5\": { input: 1, output: 5, cachedInput: 0.1, cacheWrite: 1.25, cacheWrite1h: 2 },\n};\n\n/** A trailing `-YYYYMMDD` snapshot date on a Claude model id. */\nconst SNAPSHOT_SUFFIX = /-\\d{8}$/;\n\n/**\n * Look up the built-in list price for a Claude model id. Accepts the\n * alias (`claude-sonnet-4-5`) or a dated snapshot\n * (`claude-sonnet-4-5-20250929`). Returns `undefined` for any id not in\n * {@link ANTHROPIC_MODEL_PRICING}, so cost stays unknown rather than wrong.\n *\n * @example\n * anthropicPricingFor(\"claude-haiku-4-5-20251001\"); // { input: 1, output: 5, … }\n * anthropicPricingFor(\"claude-haiku-5-5\"); // undefined (prompt-length tiers)\n */\nexport function anthropicPricingFor(modelName: string): ModelPricing | undefined {\n const exact = ANTHROPIC_MODEL_PRICING[modelName];\n\n if (exact) {\n return exact;\n }\n\n return ANTHROPIC_MODEL_PRICING[modelName.replace(SNAPSHOT_SUFFIX, \"\")];\n}\n\n/**\n * Fill the cache-write rates Anthropic derives from the input rate\n * (5-minute writes 1.25x, 1-hour writes 2x) into a pricing entry that\n * omits them, so a caller who supplies only `{ input, output }` is no\n * longer billed nothing for cache writes. Explicit rates always win; the\n * cache-read rate is left alone because it differs per model.\n *\n * @example\n * withAnthropicCacheWriteRates({ input: 3, output: 15 });\n * // { input: 3, output: 15, cacheWrite: 3.75, cacheWrite1h: 6 }\n */\nexport function withAnthropicCacheWriteRates(\n pricing: ModelPricing | undefined,\n): ModelPricing | undefined {\n if (!pricing) {\n return undefined;\n }\n\n const cacheWrite =\n pricing.cacheWrite ?? pricing.cachedOutput ?? pricing.input * ANTHROPIC_CACHE_WRITE_MULTIPLIER;\n const cacheWrite1h = pricing.cacheWrite1h ?? pricing.input * ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER;\n\n if (pricing.cacheWrite === cacheWrite && pricing.cacheWrite1h === cacheWrite1h) {\n return pricing;\n }\n\n return { ...pricing, cacheWrite, cacheWrite1h };\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,mCAAmC;AAChD,MAAa,sCAAsC;;;;;;;;;;;;;;;;;;;AAoBnD,MAAa,0BAAkE;CAC7E,oBAAoB;EAClB,OAAO;EACP,QAAQ;EACR,aAAa;EACb,YAAY;EACZ,cAAc;CAChB;CACA,kBAAkB;EAAE,OAAO;EAAI,QAAQ;EAAI,aAAa;EAAG,YAAY;EAAM,cAAc;CAAG;CAC9F,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAG,cAAc;CAAE;CAC5F,iBAAiB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAC9F,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAChG,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAChG,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAChG,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAChG,qBAAqB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAK,cAAc;CAAE;CAChG,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAK,cAAc;CAAE;CAC9F,qBAAqB;EACnB,OAAO;EACP,QAAQ;EACR,aAAa;EACb,YAAY;EACZ,cAAc;CAChB;CACA,qBAAqB;EACnB,OAAO;EACP,QAAQ;EACR,aAAa;EACb,YAAY;EACZ,cAAc;CAChB;CACA,oBAAoB;EAAE,OAAO;EAAG,QAAQ;EAAG,aAAa;EAAK,YAAY;EAAM,cAAc;CAAE;AACjG;;AAGA,MAAM,kBAAkB;;;;;;;;;;;AAYxB,SAAgB,oBAAoB,WAA6C;CAC/E,MAAM,QAAQ,wBAAwB;CAEtC,IAAI,OACF,OAAO;CAGT,OAAO,wBAAwB,UAAU,QAAQ,iBAAiB,EAAE;AACtE;;;;;;;;;;;;AAaA,SAAgB,6BACd,SAC0B;CAC1B,IAAI,CAAC,SACH;CAGF,MAAM,aACJ,QAAQ,cAAc,QAAQ,gBAAgB,QAAQ;CACxD,MAAM,eAAe,QAAQ,gBAAgB,QAAQ;CAErD,IAAI,QAAQ,eAAe,cAAc,QAAQ,iBAAiB,cAChE,OAAO;CAGT,OAAO;EAAE,GAAG;EAAS;EAAY;CAAa;AAChD"}
|
|
1
|
+
{"version":3,"file":"known-pricing.mjs","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/known-pricing.ts"],"sourcesContent":["import type { ModelPricing } from \"@warlock.js/ai\";\n\n/**\n * Anthropic's prompt-cache write multipliers, relative to the base input\n * rate: a 5-minute write costs 1.25x, a 1-hour write 2x. They hold for\n * every Claude model on Anthropic's price list.\n *\n * Source: https://platform.claude.com/docs/en/about-claude/pricing\n * (fetched 2026-10-17).\n */\nexport const ANTHROPIC_CACHE_WRITE_MULTIPLIER = 1.25;\nexport const ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = 2;\n\n/**\n * Built-in Claude API list prices, USD per 1,000,000 tokens, keyed by\n * model id. `cachedInput` is the cache-hit rate, `cacheWrite` the\n * 5-minute write rate and `cacheWrite1h` the 1-hour write rate.\n *\n * Source: https://platform.claude.com/docs/en/about-claude/pricing,\n * \"Model pricing\" table, fetched 2026-10-17. Standard (global) routing,\n * non-batch. Not covered, so pass `pricing` yourself when you need them:\n *\n * - Claude Haiku 5.5 — priced by prompt length (higher rates above\n * 100,000 prompt tokens), which a flat `ModelPricing` cannot express.\n * - US-only inference (`inference_geo: \"us\"`, 1.1x), fast mode, the Batch\n * API, and Claude on Bedrock / Vertex AI (partner-priced).\n * - Limited-availability models (Mythos) and retired models.\n *\n * Dated snapshot ids (`claude-haiku-4-5-20251001`) resolve to their alias\n * entry through {@link anthropicPricingFor}.\n */\nexport const ANTHROPIC_MODEL_PRICING: Readonly<Record<string, ModelPricing>> = {\n \"claude-fable-5-1\": {\n input: 10,\n output: 50,\n cachedInput: 0.25,\n cacheWrite: 12.5,\n cacheWrite1h: 20,\n },\n \"claude-fable-5\": { input: 10, output: 50, cachedInput: 1, cacheWrite: 12.5, cacheWrite1h: 20 },\n \"claude-opus-5-5\": { input: 4, output: 20, cachedInput: 0.2, cacheWrite: 5, cacheWrite1h: 8 },\n \"claude-opus-5\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-opus-4-8\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-opus-4-7\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-opus-4-6\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-opus-4-5\": { input: 5, output: 25, cachedInput: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 },\n \"claude-sonnet-5-5\": { input: 2, output: 10, cachedInput: 0.1, cacheWrite: 2.5, cacheWrite1h: 4 },\n \"claude-sonnet-5\": { input: 2, output: 10, cachedInput: 0.2, cacheWrite: 2.5, cacheWrite1h: 4 },\n \"claude-sonnet-4-6\": {\n input: 3,\n output: 15,\n cachedInput: 0.3,\n cacheWrite: 3.75,\n cacheWrite1h: 6,\n },\n \"claude-sonnet-4-5\": {\n input: 3,\n output: 15,\n cachedInput: 0.3,\n cacheWrite: 3.75,\n cacheWrite1h: 6,\n },\n \"claude-haiku-4-5\": { input: 1, output: 5, cachedInput: 0.1, cacheWrite: 1.25, cacheWrite1h: 2 },\n};\n\n/** A trailing `-YYYYMMDD` snapshot date on a Claude model id. */\nconst SNAPSHOT_SUFFIX = /-\\d{8}$/;\n\n/**\n * Look up the built-in list price for a Claude model id. Accepts the\n * alias (`claude-sonnet-4-5`) or a dated snapshot\n * (`claude-sonnet-4-5-20250929`). Returns `undefined` for any id not in\n * {@link ANTHROPIC_MODEL_PRICING}, so cost stays unknown rather than wrong.\n *\n * @example\n * anthropicPricingFor(\"claude-haiku-4-5-20251001\"); // { input: 1, output: 5, … }\n * anthropicPricingFor(\"claude-haiku-5-5\"); // undefined (prompt-length tiers)\n */\nexport function anthropicPricingFor(modelName: string): ModelPricing | undefined {\n const exact = ANTHROPIC_MODEL_PRICING[modelName];\n\n if (exact) {\n return exact;\n }\n\n return ANTHROPIC_MODEL_PRICING[modelName.replace(SNAPSHOT_SUFFIX, \"\")];\n}\n\n/**\n * Fill the cache-write rates Anthropic derives from the input rate\n * (5-minute writes 1.25x, 1-hour writes 2x) into a pricing entry that\n * omits them, so a caller who supplies only `{ input, output }` is no\n * longer billed nothing for cache writes. Explicit rates always win; the\n * cache-read rate is left alone because it differs per model.\n *\n * @example\n * withAnthropicCacheWriteRates({ input: 3, output: 15 });\n * // { input: 3, output: 15, cacheWrite: 3.75, cacheWrite1h: 6 }\n */\nexport function withAnthropicCacheWriteRates(\n pricing: ModelPricing | undefined,\n): ModelPricing | undefined {\n if (!pricing) {\n return undefined;\n }\n\n const cacheWrite =\n pricing.cacheWrite ?? pricing.cachedOutput ?? pricing.input * ANTHROPIC_CACHE_WRITE_MULTIPLIER;\n const cacheWrite1h = pricing.cacheWrite1h ?? pricing.input * ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER;\n\n if (pricing.cacheWrite === cacheWrite && pricing.cacheWrite1h === cacheWrite1h) {\n return pricing;\n }\n\n return { ...pricing, cacheWrite, cacheWrite1h };\n}\n\n/** USD per request, verified 2026-10-18. Tokens are additional.\n * https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool#usage-and-pricing\n * https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool#usage-and-pricing */\nexport const ANTHROPIC_SERVER_TOOL_PRICING = { webSearch: 0.01, webFetch: 0 };\n"],"mappings":";;;;;;;;;AAUA,MAAa,mCAAmC;AAChD,MAAa,sCAAsC;;;;;;;;;;;;;;;;;;;AAoBnD,MAAa,0BAAkE;CAC7E,oBAAoB;EAClB,OAAO;EACP,QAAQ;EACR,aAAa;EACb,YAAY;EACZ,cAAc;CAChB;CACA,kBAAkB;EAAE,OAAO;EAAI,QAAQ;EAAI,aAAa;EAAG,YAAY;EAAM,cAAc;CAAG;CAC9F,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAG,cAAc;CAAE;CAC5F,iBAAiB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAC9F,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAChG,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAChG,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAChG,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAM,cAAc;CAAG;CAChG,qBAAqB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAK,cAAc;CAAE;CAChG,mBAAmB;EAAE,OAAO;EAAG,QAAQ;EAAI,aAAa;EAAK,YAAY;EAAK,cAAc;CAAE;CAC9F,qBAAqB;EACnB,OAAO;EACP,QAAQ;EACR,aAAa;EACb,YAAY;EACZ,cAAc;CAChB;CACA,qBAAqB;EACnB,OAAO;EACP,QAAQ;EACR,aAAa;EACb,YAAY;EACZ,cAAc;CAChB;CACA,oBAAoB;EAAE,OAAO;EAAG,QAAQ;EAAG,aAAa;EAAK,YAAY;EAAM,cAAc;CAAE;AACjG;;AAGA,MAAM,kBAAkB;;;;;;;;;;;AAYxB,SAAgB,oBAAoB,WAA6C;CAC/E,MAAM,QAAQ,wBAAwB;CAEtC,IAAI,OACF,OAAO;CAGT,OAAO,wBAAwB,UAAU,QAAQ,iBAAiB,EAAE;AACtE;;;;;;;;;;;;AAaA,SAAgB,6BACd,SAC0B;CAC1B,IAAI,CAAC,SACH;CAGF,MAAM,aACJ,QAAQ,cAAc,QAAQ,gBAAgB,QAAQ;CACxD,MAAM,eAAe,QAAQ,gBAAgB,QAAQ;CAErD,IAAI,QAAQ,eAAe,cAAc,QAAQ,iBAAiB,cAChE,OAAO;CAGT,OAAO;EAAE,GAAG;EAAS;EAAY;CAAa;AAChD;;;;AAKA,MAAa,gCAAgC;CAAE,WAAW;CAAM,UAAU;AAAE"}
|
package/esm/model.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { AnthropicModelConfig } from "./config.type.mjs";
|
|
|
2
2
|
import { AnthropicNonStreamingRequest, AnthropicRequest, AnthropicRequestOptions, AnthropicStreamingRequest } from "./request.type.mjs";
|
|
3
3
|
import Anthropic from "@anthropic-ai/sdk";
|
|
4
4
|
import { Message, ModelCallOptions, ModelCapabilities, ModelContract, ModelPricing, ModelResponse, ModelStreamChunk } from "@warlock.js/ai";
|
|
5
|
-
|
|
6
5
|
//#region ../../packages/ai-anthropic/src/model.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Anthropic-backed implementation of `ModelContract`.
|
|
@@ -42,7 +41,7 @@ import { Message, ModelCallOptions, ModelCapabilities, ModelContract, ModelPrici
|
|
|
42
41
|
*
|
|
43
42
|
* const result = await myAgent.execute("Summarize today's news.");
|
|
44
43
|
*/
|
|
45
|
-
declare class AnthropicModel implements ModelContract {
|
|
44
|
+
export declare class AnthropicModel implements ModelContract {
|
|
46
45
|
readonly name: string;
|
|
47
46
|
readonly provider: string;
|
|
48
47
|
readonly capabilities: ModelCapabilities;
|
|
@@ -318,5 +317,4 @@ declare class AnthropicModel implements ModelContract {
|
|
|
318
317
|
private logAndWrap;
|
|
319
318
|
}
|
|
320
319
|
//#endregion
|
|
321
|
-
export { AnthropicModel };
|
|
322
320
|
//# sourceMappingURL=model.d.mts.map
|
package/esm/model.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.mts","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.d.mts","names":[],"sources":["../../../../../../../packages/ai-anthropic/src/model.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoNa,0BAA0B;WACrB;WACA;WACA,cAAc;WACd,UAAU;mBAET;mBACA;mBACA;;mBAEA;mBACA;mBACA;EAEjB,YACE,QAAQ,WACR,QAAQ,sBACR;;;;;;;EAgDW,SAAS,UAAU,WAAW,UAAU,mBAAmB,QAAQ;;EAOzE,aACL,UAAU,WACV,SAAS;IAAqB;MAC7B;EACI,aACL,UAAU,WACV,UAAU;IAAqB;MAC9B;EACI,aACL,UAAU,WACV,UAAU;IAAqB;MAC9B;;;;;;;;UAmBK;;EA+BD,KACL,SAAS,8BACT,UAAU,0BACT,QAAQ;EACJ,KACL,SAAS,2BACT,UAAU,0BACT,cAAc;EACV,KACL,SAAS,kBACT,UAAU,0BACT,QAAQ,iBAAiB,cAAc;UAqB5B;;;;;;;;;;;;EA0CD,YAAY,UAAU,WAAW,UAAU,mBAAmB;;;;;;;;;;;;;EAyC7D,OACZ,UAAU,WACV,UAAU,mBACT,cAAc;UAOF;;;;;;;UAwMP;;UAoDA;;;;;;;UAkBA;;;;;;;;;;UAgCA;;;;;;;;;UA+EA;;;;;;;;;;;;;UAsCA;;;;;;;;;;;;;;UA2DA;;;;;;;;;;;;;UAsBA;;;;;;UA0BA;;;;;;UAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+CA;;;;;UAwCA;;;;;;;;;;;;;;UA8BA;;;;;;;;;UAyCA;;;;;;;;;;;;;UA8BA;;;;;;UAmBA;;;;;;UAYA;;;;;UAuBA;;;;;;;;;;;;;;;UA6BA;;;;;;UAiCA"}
|
package/esm/model.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { anthropicPricingFor, withAnthropicCacheWriteRates } from "./known-prici
|
|
|
2
2
|
import { acceptsTemperature, inferPreservedThinking, inferThinkingMode, noReasoningForm } from "./thinking-mode.mjs";
|
|
3
3
|
import { inferMaxOutputTokens } from "./known-output-limits.mjs";
|
|
4
4
|
import { inferVisionCapability } from "./known-vision-models.mjs";
|
|
5
|
+
import { applyServerToolUsage } from "./utils/server-tool-usage.mjs";
|
|
5
6
|
import { applyAnthropicCacheUsage, requestCacheTtl } from "./utils/cache-usage.mjs";
|
|
6
7
|
import { mapStopReason } from "./utils/map-stop-reason.mjs";
|
|
7
8
|
import { toProviderBlocks } from "./utils/provider-blocks.mjs";
|
|
@@ -85,7 +86,7 @@ const EFFORT_TO_OUTPUT_EFFORT = {
|
|
|
85
86
|
max: "max"
|
|
86
87
|
};
|
|
87
88
|
/** Content-block types whose input arrives as `input_json_delta` while streaming. */
|
|
88
|
-
const STREAMED_INPUT_BLOCK_TYPES = new Set([
|
|
89
|
+
const STREAMED_INPUT_BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
89
90
|
"tool_use",
|
|
90
91
|
"server_tool_use",
|
|
91
92
|
"mcp_tool_use"
|
|
@@ -161,7 +162,7 @@ var AnthropicModel = class {
|
|
|
161
162
|
}
|
|
162
163
|
buildRequest(messages, options) {
|
|
163
164
|
const built = this.buildBody(messages, options);
|
|
164
|
-
const betas = [
|
|
165
|
+
const betas = [.../* @__PURE__ */ new Set([...resolveAnthropicOptions(options).betas ?? [], ...built.betas])];
|
|
165
166
|
const body = structuredClone({
|
|
166
167
|
...built.body,
|
|
167
168
|
stream: options?.stream ?? false
|
|
@@ -288,6 +289,7 @@ var AnthropicModel = class {
|
|
|
288
289
|
usage.input = event.message.usage.input_tokens ?? 0;
|
|
289
290
|
const thinkingTokens = event.message.usage.output_tokens_details?.thinking_tokens;
|
|
290
291
|
if (thinkingTokens !== null && thinkingTokens !== void 0) usage.reasoningTokens = thinkingTokens;
|
|
292
|
+
applyServerToolUsage(usage, event.message.usage.server_tool_use);
|
|
291
293
|
applyAnthropicCacheUsage(usage, event.message.usage, cacheTtl);
|
|
292
294
|
if (want.usage) yield {
|
|
293
295
|
type: "usage",
|
|
@@ -355,6 +357,7 @@ var AnthropicModel = class {
|
|
|
355
357
|
if (event.type === "message_delta") {
|
|
356
358
|
rawStopReason = event.delta.stop_reason ?? rawStopReason;
|
|
357
359
|
if (Array.isArray(event.usage.iterations)) compaction = compactionIterationUsage(event.usage);
|
|
360
|
+
applyServerToolUsage(usage, event.usage.server_tool_use);
|
|
358
361
|
usage.output = event.usage.output_tokens ?? usage.output;
|
|
359
362
|
const thinkingTokens = event.usage.output_tokens_details?.thinking_tokens;
|
|
360
363
|
if (thinkingTokens !== null && thinkingTokens !== void 0) usage.reasoningTokens = thinkingTokens;
|
|
@@ -797,6 +800,7 @@ var AnthropicModel = class {
|
|
|
797
800
|
inputIncludesCache: false,
|
|
798
801
|
...thinkingTokens !== null && thinkingTokens !== void 0 ? { reasoningTokens: thinkingTokens } : {}
|
|
799
802
|
};
|
|
803
|
+
applyServerToolUsage(usage, raw.server_tool_use);
|
|
800
804
|
applyAnthropicCacheUsage(usage, raw, cacheTtl);
|
|
801
805
|
addCacheCounts(usage, compaction);
|
|
802
806
|
const cost = computeCost(usage, this.pricing);
|
|
@@ -824,7 +828,7 @@ var AnthropicModel = class {
|
|
|
824
828
|
* model call tools the agent never registered). `stream` is chosen per
|
|
825
829
|
* call by `complete()` / `stream()`.
|
|
826
830
|
*/
|
|
827
|
-
const RESERVED_BODY_FIELDS = new Set([
|
|
831
|
+
const RESERVED_BODY_FIELDS = /* @__PURE__ */ new Set([
|
|
828
832
|
"model",
|
|
829
833
|
"messages",
|
|
830
834
|
"system",
|