@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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,26 @@ All notable changes to `@warlock.js/ai-anthropic` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.33.0 - 2026-10-19
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Lockstep release; package APIs are unchanged.
|
|
12
|
+
|
|
13
|
+
## 5.32.0 - 2026-10-18
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Pin the package development compiler to TypeScript 7.0.2 and use explicit Node types and source roots with supported module resolution.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Verified that native token counting preserves the shared unsupported-count signal for `countInputTokens` estimation while authentication errors propagate.
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Map cumulative hosted web-search/fetch usage in completions and streams while preserving server-tool blocks. Export verified request-fee prices as `ANTHROPIC_SERVER_TOOL_PRICING` for explicit pricing composition.
|
|
26
|
+
|
|
7
27
|
## 5.31.0 - 2026-10-18
|
|
8
28
|
|
|
9
29
|
### Upgrading
|
package/cjs/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
24
24
|
value: mod,
|
|
25
25
|
enumerable: true
|
|
26
26
|
}) : target, mod));
|
|
@@ -192,6 +192,13 @@ function withAnthropicCacheWriteRates(pricing) {
|
|
|
192
192
|
cacheWrite1h
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
+
/** USD per request, verified 2026-10-18. Tokens are additional.
|
|
196
|
+
* https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool#usage-and-pricing
|
|
197
|
+
* https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool#usage-and-pricing */
|
|
198
|
+
const ANTHROPIC_SERVER_TOOL_PRICING = {
|
|
199
|
+
webSearch: .01,
|
|
200
|
+
webFetch: 0
|
|
201
|
+
};
|
|
195
202
|
|
|
196
203
|
//#endregion
|
|
197
204
|
//#region ../../packages/ai-anthropic/src/thinking-mode.ts
|
|
@@ -495,6 +502,21 @@ function inferVisionCapability(modelName) {
|
|
|
495
502
|
return VISION_CAPABLE_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
496
503
|
}
|
|
497
504
|
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region ../../packages/ai-anthropic/src/utils/server-tool-usage.ts
|
|
507
|
+
/** Installed @anthropic-ai/sdk 0.129.0 ServerToolUsage and MessageDeltaUsage use the same cumulative counters.
|
|
508
|
+
* https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool
|
|
509
|
+
* https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool
|
|
510
|
+
* No code-execution request counter is reported: never count content blocks instead. */
|
|
511
|
+
function applyServerToolUsage(usage, raw) {
|
|
512
|
+
if (!raw) return;
|
|
513
|
+
usage.serverToolUse = {
|
|
514
|
+
...usage.serverToolUse,
|
|
515
|
+
...raw.web_search_requests !== void 0 ? { webSearchRequests: raw.web_search_requests } : {},
|
|
516
|
+
...raw.web_fetch_requests !== void 0 ? { webFetchRequests: raw.web_fetch_requests } : {}
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
498
520
|
//#endregion
|
|
499
521
|
//#region ../../packages/ai-anthropic/src/utils/cache-usage.ts
|
|
500
522
|
/**
|
|
@@ -594,9 +616,9 @@ function mapStopReason(raw) {
|
|
|
594
616
|
/** The `ProviderContentBlock.provider` value this adapter writes and replays. */
|
|
595
617
|
const ANTHROPIC_BLOCK_FORMAT = "anthropic";
|
|
596
618
|
/** Block types the neutral `content` + `toolCalls` fields already carry losslessly. */
|
|
597
|
-
const NEUTRAL_BLOCK_TYPES = new Set(["text", "tool_use"]);
|
|
619
|
+
const NEUTRAL_BLOCK_TYPES = /* @__PURE__ */ new Set(["text", "tool_use"]);
|
|
598
620
|
/** Block types that carry a model-requested call whose id must match `toolCalls`. */
|
|
599
|
-
const TOOL_USE_BLOCK_TYPES = new Set(["tool_use"]);
|
|
621
|
+
const TOOL_USE_BLOCK_TYPES = /* @__PURE__ */ new Set(["tool_use"]);
|
|
600
622
|
/**
|
|
601
623
|
* Assistant-turn block types that may be sent back verbatim. Server-tool
|
|
602
624
|
* results all end in `_tool_result` (`web_search_tool_result`,
|
|
@@ -604,7 +626,7 @@ const TOOL_USE_BLOCK_TYPES = new Set(["tool_use"]);
|
|
|
604
626
|
* else (an unknown or user-side type such as `image`, `document` or a
|
|
605
627
|
* client `tool_result`) is not replayed.
|
|
606
628
|
*/
|
|
607
|
-
const REPLAYABLE_BLOCK_TYPES = new Set([
|
|
629
|
+
const REPLAYABLE_BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
608
630
|
"text",
|
|
609
631
|
"thinking",
|
|
610
632
|
"redacted_thinking",
|
|
@@ -1137,7 +1159,7 @@ const EFFORT_TO_OUTPUT_EFFORT = {
|
|
|
1137
1159
|
max: "max"
|
|
1138
1160
|
};
|
|
1139
1161
|
/** Content-block types whose input arrives as `input_json_delta` while streaming. */
|
|
1140
|
-
const STREAMED_INPUT_BLOCK_TYPES = new Set([
|
|
1162
|
+
const STREAMED_INPUT_BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
1141
1163
|
"tool_use",
|
|
1142
1164
|
"server_tool_use",
|
|
1143
1165
|
"mcp_tool_use"
|
|
@@ -1213,7 +1235,7 @@ var AnthropicModel = class {
|
|
|
1213
1235
|
}
|
|
1214
1236
|
buildRequest(messages, options) {
|
|
1215
1237
|
const built = this.buildBody(messages, options);
|
|
1216
|
-
const betas = [
|
|
1238
|
+
const betas = [.../* @__PURE__ */ new Set([...resolveAnthropicOptions(options).betas ?? [], ...built.betas])];
|
|
1217
1239
|
const body = structuredClone({
|
|
1218
1240
|
...built.body,
|
|
1219
1241
|
stream: options?.stream ?? false
|
|
@@ -1340,6 +1362,7 @@ var AnthropicModel = class {
|
|
|
1340
1362
|
usage.input = event.message.usage.input_tokens ?? 0;
|
|
1341
1363
|
const thinkingTokens = event.message.usage.output_tokens_details?.thinking_tokens;
|
|
1342
1364
|
if (thinkingTokens !== null && thinkingTokens !== void 0) usage.reasoningTokens = thinkingTokens;
|
|
1365
|
+
applyServerToolUsage(usage, event.message.usage.server_tool_use);
|
|
1343
1366
|
applyAnthropicCacheUsage(usage, event.message.usage, cacheTtl);
|
|
1344
1367
|
if (want.usage) yield {
|
|
1345
1368
|
type: "usage",
|
|
@@ -1407,6 +1430,7 @@ var AnthropicModel = class {
|
|
|
1407
1430
|
if (event.type === "message_delta") {
|
|
1408
1431
|
rawStopReason = event.delta.stop_reason ?? rawStopReason;
|
|
1409
1432
|
if (Array.isArray(event.usage.iterations)) compaction = compactionIterationUsage(event.usage);
|
|
1433
|
+
applyServerToolUsage(usage, event.usage.server_tool_use);
|
|
1410
1434
|
usage.output = event.usage.output_tokens ?? usage.output;
|
|
1411
1435
|
const thinkingTokens = event.usage.output_tokens_details?.thinking_tokens;
|
|
1412
1436
|
if (thinkingTokens !== null && thinkingTokens !== void 0) usage.reasoningTokens = thinkingTokens;
|
|
@@ -1849,6 +1873,7 @@ var AnthropicModel = class {
|
|
|
1849
1873
|
inputIncludesCache: false,
|
|
1850
1874
|
...thinkingTokens !== null && thinkingTokens !== void 0 ? { reasoningTokens: thinkingTokens } : {}
|
|
1851
1875
|
};
|
|
1876
|
+
applyServerToolUsage(usage, raw.server_tool_use);
|
|
1852
1877
|
applyAnthropicCacheUsage(usage, raw, cacheTtl);
|
|
1853
1878
|
addCacheCounts(usage, compaction);
|
|
1854
1879
|
const cost = (0, _warlock_js_ai.computeCost)(usage, this.pricing);
|
|
@@ -1876,7 +1901,7 @@ var AnthropicModel = class {
|
|
|
1876
1901
|
* model call tools the agent never registered). `stream` is chosen per
|
|
1877
1902
|
* call by `complete()` / `stream()`.
|
|
1878
1903
|
*/
|
|
1879
|
-
const RESERVED_BODY_FIELDS = new Set([
|
|
1904
|
+
const RESERVED_BODY_FIELDS = /* @__PURE__ */ new Set([
|
|
1880
1905
|
"model",
|
|
1881
1906
|
"messages",
|
|
1882
1907
|
"system",
|
|
@@ -2098,6 +2123,7 @@ exports.ANTHROPIC_BLOCK_FORMAT = ANTHROPIC_BLOCK_FORMAT;
|
|
|
2098
2123
|
exports.ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER;
|
|
2099
2124
|
exports.ANTHROPIC_CACHE_WRITE_MULTIPLIER = ANTHROPIC_CACHE_WRITE_MULTIPLIER;
|
|
2100
2125
|
exports.ANTHROPIC_MODEL_PRICING = ANTHROPIC_MODEL_PRICING;
|
|
2126
|
+
exports.ANTHROPIC_SERVER_TOOL_PRICING = ANTHROPIC_SERVER_TOOL_PRICING;
|
|
2101
2127
|
exports.AnthropicModel = AnthropicModel;
|
|
2102
2128
|
exports.AnthropicSDK = AnthropicSDK;
|
|
2103
2129
|
exports.anthropicPricingFor = anthropicPricingFor;
|