@warlock.js/ai-anthropic 5.31.0 → 5.32.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 +14 -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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Anthropic from "@anthropic-ai/sdk";
|
|
2
2
|
import { Message } from "@warlock.js/ai";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/ai-anthropic/src/utils/to-anthropic-messages.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Result of splitting a vendor-neutral `Message[]` for the Anthropic
|
|
@@ -8,12 +7,12 @@ import { Message } from "@warlock.js/ai";
|
|
|
8
7
|
* string (Anthropic has no `"system"` role inside `messages`), and the
|
|
9
8
|
* remaining turns are mapped to `MessageParam[]`.
|
|
10
9
|
*/
|
|
11
|
-
type AnthropicMessages = {
|
|
10
|
+
export type AnthropicMessages = {
|
|
12
11
|
system: string | undefined;
|
|
13
12
|
messages: Anthropic.MessageParam[];
|
|
14
13
|
};
|
|
15
14
|
/** Options for {@link toAnthropicMessages}. */
|
|
16
|
-
type ToAnthropicMessagesOptions = {
|
|
15
|
+
export type ToAnthropicMessagesOptions = {
|
|
17
16
|
/**
|
|
18
17
|
* Leave out the `thinking` / `redacted_thinking` blocks of assistant turns
|
|
19
18
|
* marked `compaction: "retained"` — turns kept verbatim after a
|
|
@@ -65,7 +64,6 @@ type ToAnthropicMessagesOptions = {
|
|
|
65
64
|
* // system === "Be concise."
|
|
66
65
|
* // messages === [{ role: "user", content: "Hi" }]
|
|
67
66
|
*/
|
|
68
|
-
declare function toAnthropicMessages(messages: Message[], options?: ToAnthropicMessagesOptions): AnthropicMessages;
|
|
67
|
+
export declare function toAnthropicMessages(messages: Message[], options?: ToAnthropicMessagesOptions): AnthropicMessages;
|
|
69
68
|
//#endregion
|
|
70
|
-
export { AnthropicMessages, ToAnthropicMessagesOptions, toAnthropicMessages };
|
|
71
69
|
//# sourceMappingURL=to-anthropic-messages.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-anthropic-messages.d.mts","names":[],"sources":["../../../../../../../../packages/ai-anthropic/src/utils/to-anthropic-messages.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"to-anthropic-messages.d.mts","names":[],"sources":["../../../../../../../../packages/ai-anthropic/src/utils/to-anthropic-messages.ts"],"mappings":";;;;;;;;;YAUY;EACV;EACA,UAAU,UAAU;;;YAIV;;;;;;;;;;EAUV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+Cc,oBACd,UAAU,WACV,UAAS,6BACR"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Anthropic from "@anthropic-ai/sdk";
|
|
2
2
|
import { ToolConfig } from "@warlock.js/ai";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/ai-anthropic/src/utils/to-anthropic-tools.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Convert vendor-neutral `ToolConfig[]` into Anthropic's `tools` array.
|
|
@@ -13,7 +12,6 @@ import { ToolConfig } from "@warlock.js/ai";
|
|
|
13
12
|
* const tools = toAnthropicTools([weatherTool, calculatorTool]);
|
|
14
13
|
* await client.messages.create({ model, max_tokens, messages, tools });
|
|
15
14
|
*/
|
|
16
|
-
declare function toAnthropicTools(tools: ToolConfig<unknown, unknown>[] | undefined): Anthropic.Tool[] | undefined;
|
|
15
|
+
export declare function toAnthropicTools(tools: ToolConfig<unknown, unknown>[] | undefined): Anthropic.Tool[] | undefined;
|
|
17
16
|
//#endregion
|
|
18
|
-
export { toAnthropicTools };
|
|
19
17
|
//# sourceMappingURL=to-anthropic-tools.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-anthropic-tools.d.mts","names":[],"sources":["../../../../../../../../packages/ai-anthropic/src/utils/to-anthropic-tools.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"to-anthropic-tools.d.mts","names":[],"sources":["../../../../../../../../packages/ai-anthropic/src/utils/to-anthropic-tools.ts"],"mappings":";;;;;;;;;;;;;;wBAcgB,iBACd,OAAO,6CACN,UAAU"}
|
package/llms-full.txt
CHANGED
|
@@ -457,6 +457,13 @@ const model = anthropic.model({ name: "claude-opus-5-5" }); // an AnthropicModel
|
|
|
457
457
|
await model.countTokens(messages, { tools }); // exact, via messages.countTokens (network)
|
|
458
458
|
```
|
|
459
459
|
|
|
460
|
+
For budget preflight, `countInputTokens(model, messages, { tools })` from
|
|
461
|
+
`@warlock.js/ai` returns `{ tokens, source }`. It estimates only when native
|
|
462
|
+
counting is absent or explicitly throws `InvalidRequestError` with
|
|
463
|
+
`reason: "count-unsupported"`; this adapter preserves that signal. System and
|
|
464
|
+
tools are supported natively. Ordinary validation, auth, network and rate-limit
|
|
465
|
+
errors propagate. See the cost/budget guide for reserve mode.
|
|
466
|
+
|
|
460
467
|
`countTokens` sends the same system prompt, tools, thinking and `providerOptions.anthropic.betas` a real call would, keeping only the fields the endpoint accepts.
|
|
461
468
|
|
|
462
469
|
## No embeddings
|
|
@@ -474,4 +481,31 @@ Anthropic ships no first-party embeddings API, so `AnthropicSDK` intentionally d
|
|
|
474
481
|
- The `pick-ai-provider` topic of the `warlock-js-ai` skill
|
|
475
482
|
- The `handle-ai-errors` topic of the `warlock-js-ai` skill
|
|
476
483
|
|
|
484
|
+
## Hosted-search usage and fees
|
|
485
|
+
|
|
486
|
+
`complete()` and streaming `done` map the provider's
|
|
487
|
+
`usage.server_tool_use.web_search_requests` / `web_fetch_requests` to
|
|
488
|
+
`usage.serverToolUse.webSearchRequests` / `webFetchRequests`. Streaming
|
|
489
|
+
`message_delta` counts are cumulative snapshots, never added twice. Raw
|
|
490
|
+
`server_tool_use` and search-result blocks remain in `response.blocks` and are
|
|
491
|
+
replayed in history; they never invoke local function handlers.
|
|
492
|
+
|
|
493
|
+
To add request fees to token costs, explicitly compose the verified
|
|
494
|
+
`ANTHROPIC_SERVER_TOOL_PRICING` export into model `pricing.serverTools`:
|
|
495
|
+
|
|
496
|
+
```ts
|
|
497
|
+
import { ANTHROPIC_SERVER_TOOL_PRICING } from "@warlock.js/ai-anthropic";
|
|
498
|
+
const model = anthropic.model({
|
|
499
|
+
name: "claude-sonnet-4-6",
|
|
500
|
+
pricing: { input: 3, output: 15, serverTools: ANTHROPIC_SERVER_TOOL_PRICING },
|
|
501
|
+
});
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
The [search fee](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool#usage-and-pricing)
|
|
505
|
+
is $0.01 per search; [fetch](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool#usage-and-pricing)
|
|
506
|
+
has no additional request fee (verified 2026-10-18). Tokens remain additional.
|
|
507
|
+
No code-execution request count is inferred from blocks. See
|
|
508
|
+
[hosted-tool costs](https://warlock.js.org/v/latest/ai/recipes/cost-tracking/#hosted-tool-request-fees)
|
|
509
|
+
and [fee reservations](https://warlock.js.org/v/latest/ai/recipes/cost-budgets-and-slo/#reserve-hosted-search-fees).
|
|
510
|
+
|
|
477
511
|
|
package/package.json
CHANGED
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"directory": "packages/ai-anthropic"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@warlock.js/ai": "5.
|
|
18
|
+
"@warlock.js/ai": "5.32.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@anthropic-ai/sdk": "^0.129.0",
|
|
22
|
-
"@warlock.js/logger": "5.
|
|
22
|
+
"@warlock.js/logger": "5.32.0"
|
|
23
23
|
},
|
|
24
|
-
"version": "5.
|
|
24
|
+
"version": "5.32.0",
|
|
25
25
|
"main": "./cjs/index.cjs",
|
|
26
26
|
"module": "./esm/index.mjs",
|
|
27
27
|
"types": "./esm/index.d.mts",
|
|
@@ -449,6 +449,13 @@ const model = anthropic.model({ name: "claude-opus-5-5" }); // an AnthropicModel
|
|
|
449
449
|
await model.countTokens(messages, { tools }); // exact, via messages.countTokens (network)
|
|
450
450
|
```
|
|
451
451
|
|
|
452
|
+
For budget preflight, `countInputTokens(model, messages, { tools })` from
|
|
453
|
+
`@warlock.js/ai` returns `{ tokens, source }`. It estimates only when native
|
|
454
|
+
counting is absent or explicitly throws `InvalidRequestError` with
|
|
455
|
+
`reason: "count-unsupported"`; this adapter preserves that signal. System and
|
|
456
|
+
tools are supported natively. Ordinary validation, auth, network and rate-limit
|
|
457
|
+
errors propagate. See the cost/budget guide for reserve mode.
|
|
458
|
+
|
|
452
459
|
`countTokens` sends the same system prompt, tools, thinking and `providerOptions.anthropic.betas` a real call would, keeping only the fields the endpoint accepts.
|
|
453
460
|
|
|
454
461
|
## No embeddings
|
|
@@ -465,3 +472,30 @@ Anthropic ships no first-party embeddings API, so `AnthropicSDK` intentionally d
|
|
|
465
472
|
- The `run-ai-agent` topic of the `warlock-js-ai` skill
|
|
466
473
|
- The `pick-ai-provider` topic of the `warlock-js-ai` skill
|
|
467
474
|
- The `handle-ai-errors` topic of the `warlock-js-ai` skill
|
|
475
|
+
|
|
476
|
+
## Hosted-search usage and fees
|
|
477
|
+
|
|
478
|
+
`complete()` and streaming `done` map the provider's
|
|
479
|
+
`usage.server_tool_use.web_search_requests` / `web_fetch_requests` to
|
|
480
|
+
`usage.serverToolUse.webSearchRequests` / `webFetchRequests`. Streaming
|
|
481
|
+
`message_delta` counts are cumulative snapshots, never added twice. Raw
|
|
482
|
+
`server_tool_use` and search-result blocks remain in `response.blocks` and are
|
|
483
|
+
replayed in history; they never invoke local function handlers.
|
|
484
|
+
|
|
485
|
+
To add request fees to token costs, explicitly compose the verified
|
|
486
|
+
`ANTHROPIC_SERVER_TOOL_PRICING` export into model `pricing.serverTools`:
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
import { ANTHROPIC_SERVER_TOOL_PRICING } from "@warlock.js/ai-anthropic";
|
|
490
|
+
const model = anthropic.model({
|
|
491
|
+
name: "claude-sonnet-4-6",
|
|
492
|
+
pricing: { input: 3, output: 15, serverTools: ANTHROPIC_SERVER_TOOL_PRICING },
|
|
493
|
+
});
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
The [search fee](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool#usage-and-pricing)
|
|
497
|
+
is $0.01 per search; [fetch](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool#usage-and-pricing)
|
|
498
|
+
has no additional request fee (verified 2026-10-18). Tokens remain additional.
|
|
499
|
+
No code-execution request count is inferred from blocks. See
|
|
500
|
+
[hosted-tool costs](https://warlock.js.org/v/latest/ai/recipes/cost-tracking/#hosted-tool-request-fees)
|
|
501
|
+
and [fee reservations](https://warlock.js.org/v/latest/ai/recipes/cost-budgets-and-slo/#reserve-hosted-search-fees).
|