@ai-sdk/anthropic 3.0.76 → 3.0.78

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.78
4
+
5
+ ### Patch Changes
6
+
7
+ - 6e28d25: fix(anthropic): propagate toModelOutput providerOption to anthropic tool results
8
+
9
+ ## 3.0.77
10
+
11
+ ### Patch Changes
12
+
13
+ - d53314d: feat(anthropic): add the new advisor tool
14
+
3
15
  ## 3.0.76
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -5,10 +5,17 @@ import { FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
6
  /**
7
7
  * Represents a single iteration in the usage breakdown.
8
- * When compaction occurs, the API returns an iterations array showing
9
- * usage for each sampling iteration (compaction + message).
8
+ *
9
+ * The API returns an iterations array showing usage for each sampling
10
+ * iteration. Iterations can be:
11
+ * - `compaction`: a context compaction step (billed at executor rates).
12
+ * - `message`: an executor sampling iteration (billed at executor rates).
13
+ * - `advisor_message`: an advisor sub-inference (billed at the advisor
14
+ * model's rates; `model` carries the advisor model ID). Advisor token
15
+ * usage is NOT rolled into the top-level usage totals because it bills
16
+ * at a different rate; inspect this array directly for advisor billing.
10
17
  */
11
- interface AnthropicUsageIteration {
18
+ type AnthropicUsageIteration = {
12
19
  type: 'compaction' | 'message';
13
20
  /**
14
21
  * Number of input tokens consumed in this iteration.
@@ -18,7 +25,41 @@ interface AnthropicUsageIteration {
18
25
  * Number of output tokens generated in this iteration.
19
26
  */
20
27
  outputTokens: number;
21
- }
28
+ /**
29
+ * Number of cache-creation input tokens consumed in this iteration.
30
+ */
31
+ cacheCreationInputTokens?: number;
32
+ /**
33
+ * Number of cache-read input tokens consumed in this iteration.
34
+ */
35
+ cacheReadInputTokens?: number;
36
+ } | {
37
+ type: 'advisor_message';
38
+ /**
39
+ * The advisor model that produced this iteration.
40
+ */
41
+ model: string;
42
+ /**
43
+ * Number of input tokens consumed in this iteration.
44
+ */
45
+ inputTokens: number;
46
+ /**
47
+ * Number of output tokens generated in this iteration.
48
+ */
49
+ outputTokens: number;
50
+ /**
51
+ * Number of cache-creation input tokens consumed by this advisor
52
+ * sub-inference. Nonzero when advisor-side caching is enabled and
53
+ * the advisor writes a fresh cache entry.
54
+ */
55
+ cacheCreationInputTokens?: number;
56
+ /**
57
+ * Number of cache-read input tokens consumed by this advisor
58
+ * sub-inference. Nonzero on the second and later advisor calls
59
+ * when advisor-side caching is enabled.
60
+ */
61
+ cacheReadInputTokens?: number;
62
+ };
22
63
  interface AnthropicMessageMetadata {
23
64
  usage: JSONObject;
24
65
  cacheCreationInputTokens: number | null;
@@ -242,6 +283,60 @@ interface AnthropicToolOptions {
242
283
  }
243
284
 
244
285
  declare const anthropicTools: {
286
+ /**
287
+ * Pairs a faster executor model with a higher-intelligence advisor model
288
+ * that provides strategic guidance mid-generation.
289
+ *
290
+ * The advisor lets a faster, lower-cost executor model consult a
291
+ * higher-intelligence advisor model server-side. The advisor reads the
292
+ * executor's full transcript and produces a plan or course correction;
293
+ * the executor continues with the task, informed by the advice. All of
294
+ * this happens inside a single `/v1/messages` request.
295
+ *
296
+ * Beta header `advisor-tool-2026-03-01` is added automatically when this
297
+ * tool is included.
298
+ *
299
+ * Multi-turn conversations: pass the full assistant content (including
300
+ * `advisor_tool_result` blocks) back to the API on subsequent turns. If
301
+ * you omit the advisor tool from `tools` on a follow-up turn while the
302
+ * message history still contains `advisor_tool_result` blocks, the API
303
+ * returns a `400 invalid_request_error`.
304
+ *
305
+ * Supported executor models: Claude Haiku 4.5, Sonnet 4.6, Opus 4.6,
306
+ * Opus 4.7. The advisor must be at least as capable as the executor.
307
+ *
308
+ * @param model - The advisor model ID (required), e.g. `"claude-opus-4-7"`.
309
+ * @param maxUses - Maximum advisor calls per request (per-request cap).
310
+ * @param caching - Enables prompt caching for the advisor's transcript
311
+ * across calls within a conversation. Worthwhile from ~3 advisor calls
312
+ * per conversation.
313
+ */
314
+ advisor_20260301: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
315
+ type: "advisor_result";
316
+ text: string;
317
+ } | {
318
+ type: "advisor_redacted_result";
319
+ encryptedContent: string;
320
+ } | {
321
+ type: "advisor_tool_result_error";
322
+ errorCode: string;
323
+ }, {
324
+ model: string;
325
+ maxUses?: number;
326
+ caching?: {
327
+ type: "ephemeral";
328
+ ttl: "5m" | "1h";
329
+ };
330
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
331
+ type: "advisor_result";
332
+ text: string;
333
+ } | {
334
+ type: "advisor_redacted_result";
335
+ encryptedContent: string;
336
+ } | {
337
+ type: "advisor_tool_result_error";
338
+ errorCode: string;
339
+ }>;
245
340
  /**
246
341
  * The bash tool enables Claude to execute shell commands in a persistent bash session,
247
342
  * allowing system operations, script execution, and command-line automation.
package/dist/index.d.ts CHANGED
@@ -5,10 +5,17 @@ import { FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
6
  /**
7
7
  * Represents a single iteration in the usage breakdown.
8
- * When compaction occurs, the API returns an iterations array showing
9
- * usage for each sampling iteration (compaction + message).
8
+ *
9
+ * The API returns an iterations array showing usage for each sampling
10
+ * iteration. Iterations can be:
11
+ * - `compaction`: a context compaction step (billed at executor rates).
12
+ * - `message`: an executor sampling iteration (billed at executor rates).
13
+ * - `advisor_message`: an advisor sub-inference (billed at the advisor
14
+ * model's rates; `model` carries the advisor model ID). Advisor token
15
+ * usage is NOT rolled into the top-level usage totals because it bills
16
+ * at a different rate; inspect this array directly for advisor billing.
10
17
  */
11
- interface AnthropicUsageIteration {
18
+ type AnthropicUsageIteration = {
12
19
  type: 'compaction' | 'message';
13
20
  /**
14
21
  * Number of input tokens consumed in this iteration.
@@ -18,7 +25,41 @@ interface AnthropicUsageIteration {
18
25
  * Number of output tokens generated in this iteration.
19
26
  */
20
27
  outputTokens: number;
21
- }
28
+ /**
29
+ * Number of cache-creation input tokens consumed in this iteration.
30
+ */
31
+ cacheCreationInputTokens?: number;
32
+ /**
33
+ * Number of cache-read input tokens consumed in this iteration.
34
+ */
35
+ cacheReadInputTokens?: number;
36
+ } | {
37
+ type: 'advisor_message';
38
+ /**
39
+ * The advisor model that produced this iteration.
40
+ */
41
+ model: string;
42
+ /**
43
+ * Number of input tokens consumed in this iteration.
44
+ */
45
+ inputTokens: number;
46
+ /**
47
+ * Number of output tokens generated in this iteration.
48
+ */
49
+ outputTokens: number;
50
+ /**
51
+ * Number of cache-creation input tokens consumed by this advisor
52
+ * sub-inference. Nonzero when advisor-side caching is enabled and
53
+ * the advisor writes a fresh cache entry.
54
+ */
55
+ cacheCreationInputTokens?: number;
56
+ /**
57
+ * Number of cache-read input tokens consumed by this advisor
58
+ * sub-inference. Nonzero on the second and later advisor calls
59
+ * when advisor-side caching is enabled.
60
+ */
61
+ cacheReadInputTokens?: number;
62
+ };
22
63
  interface AnthropicMessageMetadata {
23
64
  usage: JSONObject;
24
65
  cacheCreationInputTokens: number | null;
@@ -242,6 +283,60 @@ interface AnthropicToolOptions {
242
283
  }
243
284
 
244
285
  declare const anthropicTools: {
286
+ /**
287
+ * Pairs a faster executor model with a higher-intelligence advisor model
288
+ * that provides strategic guidance mid-generation.
289
+ *
290
+ * The advisor lets a faster, lower-cost executor model consult a
291
+ * higher-intelligence advisor model server-side. The advisor reads the
292
+ * executor's full transcript and produces a plan or course correction;
293
+ * the executor continues with the task, informed by the advice. All of
294
+ * this happens inside a single `/v1/messages` request.
295
+ *
296
+ * Beta header `advisor-tool-2026-03-01` is added automatically when this
297
+ * tool is included.
298
+ *
299
+ * Multi-turn conversations: pass the full assistant content (including
300
+ * `advisor_tool_result` blocks) back to the API on subsequent turns. If
301
+ * you omit the advisor tool from `tools` on a follow-up turn while the
302
+ * message history still contains `advisor_tool_result` blocks, the API
303
+ * returns a `400 invalid_request_error`.
304
+ *
305
+ * Supported executor models: Claude Haiku 4.5, Sonnet 4.6, Opus 4.6,
306
+ * Opus 4.7. The advisor must be at least as capable as the executor.
307
+ *
308
+ * @param model - The advisor model ID (required), e.g. `"claude-opus-4-7"`.
309
+ * @param maxUses - Maximum advisor calls per request (per-request cap).
310
+ * @param caching - Enables prompt caching for the advisor's transcript
311
+ * across calls within a conversation. Worthwhile from ~3 advisor calls
312
+ * per conversation.
313
+ */
314
+ advisor_20260301: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
315
+ type: "advisor_result";
316
+ text: string;
317
+ } | {
318
+ type: "advisor_redacted_result";
319
+ encryptedContent: string;
320
+ } | {
321
+ type: "advisor_tool_result_error";
322
+ errorCode: string;
323
+ }, {
324
+ model: string;
325
+ maxUses?: number;
326
+ caching?: {
327
+ type: "ephemeral";
328
+ ttl: "5m" | "1h";
329
+ };
330
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
331
+ type: "advisor_result";
332
+ text: string;
333
+ } | {
334
+ type: "advisor_redacted_result";
335
+ encryptedContent: string;
336
+ } | {
337
+ type: "advisor_tool_result_error";
338
+ errorCode: string;
339
+ }>;
245
340
  /**
246
341
  * The bash tool enables Claude to execute shell commands in a persistent bash session,
247
342
  * allowing system operations, script execution, and command-line automation.