@ai-sdk/anthropic 2.0.0-alpha.13 → 2.0.0-alpha.14

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.
@@ -65,7 +65,7 @@ declare function bashTool_20241022<RESULT>(options?: {
65
65
  }, RESULT>;
66
66
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
67
67
  }): {
68
- type: 'provider-defined';
68
+ type: 'provider-defined-client';
69
69
  id: 'anthropic.bash_20241022';
70
70
  args: {};
71
71
  parameters: typeof Bash20241022Parameters;
@@ -102,7 +102,7 @@ declare function bashTool_20250124<RESULT>(options?: {
102
102
  }, RESULT>;
103
103
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
104
104
  }): {
105
- type: 'provider-defined';
105
+ type: 'provider-defined-client';
106
106
  id: 'anthropic.bash_20250124';
107
107
  args: {};
108
108
  parameters: typeof Bash20250124Parameters;
@@ -174,7 +174,7 @@ declare function textEditorTool_20241022<RESULT>(options?: {
174
174
  }, RESULT>;
175
175
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
176
176
  }): {
177
- type: 'provider-defined';
177
+ type: 'provider-defined-client';
178
178
  id: 'anthropic.text_editor_20241022';
179
179
  args: {};
180
180
  parameters: typeof TextEditor20241022Parameters;
@@ -246,7 +246,7 @@ declare function textEditorTool_20250124<RESULT>(options?: {
246
246
  }, RESULT>;
247
247
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
248
248
  }): {
249
- type: 'provider-defined';
249
+ type: 'provider-defined-client';
250
250
  id: 'anthropic.text_editor_20250124';
251
251
  args: {};
252
252
  parameters: typeof TextEditor20250124Parameters;
@@ -308,7 +308,7 @@ declare function computerTool_20241022<RESULT>(options: {
308
308
  }, RESULT>;
309
309
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
310
310
  }): {
311
- type: 'provider-defined';
311
+ type: 'provider-defined-client';
312
312
  id: 'anthropic.computer_20241022';
313
313
  args: {};
314
314
  parameters: typeof Computer20241022Parameters;
@@ -403,13 +403,50 @@ declare function computerTool_20250124<RESULT>(options: {
403
403
  }, RESULT>;
404
404
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
405
405
  }): {
406
- type: 'provider-defined';
406
+ type: 'provider-defined-client';
407
407
  id: 'anthropic.computer_20250124';
408
408
  args: {};
409
409
  parameters: typeof Computer20250124Parameters;
410
410
  execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;
411
411
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
412
412
  };
413
+ /**
414
+ * Creates a web search tool that gives Claude direct access to real-time web content.
415
+ * Must have name "web_search".
416
+ *
417
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
418
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
419
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
420
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
421
+ */
422
+ declare function webSearchTool_20250305(options?: {
423
+ maxUses?: number;
424
+ allowedDomains?: string[];
425
+ blockedDomains?: string[];
426
+ userLocation?: {
427
+ type: 'approximate';
428
+ city?: string;
429
+ region?: string;
430
+ country?: string;
431
+ timezone?: string;
432
+ };
433
+ }): {
434
+ type: 'provider-defined-server';
435
+ id: 'anthropic.web_search_20250305';
436
+ name: 'web_search';
437
+ args: {
438
+ maxUses?: number;
439
+ allowedDomains?: string[];
440
+ blockedDomains?: string[];
441
+ userLocation?: {
442
+ type: 'approximate';
443
+ city?: string;
444
+ region?: string;
445
+ country?: string;
446
+ timezone?: string;
447
+ };
448
+ };
449
+ };
413
450
  declare const anthropicTools: {
414
451
  bash_20241022: typeof bashTool_20241022;
415
452
  bash_20250124: typeof bashTool_20250124;
@@ -417,6 +454,7 @@ declare const anthropicTools: {
417
454
  textEditor_20250124: typeof textEditorTool_20250124;
418
455
  computer_20241022: typeof computerTool_20241022;
419
456
  computer_20250124: typeof computerTool_20250124;
457
+ webSearch_20250305: typeof webSearchTool_20250305;
420
458
  };
421
459
 
422
460
  export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools };
@@ -65,7 +65,7 @@ declare function bashTool_20241022<RESULT>(options?: {
65
65
  }, RESULT>;
66
66
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
67
67
  }): {
68
- type: 'provider-defined';
68
+ type: 'provider-defined-client';
69
69
  id: 'anthropic.bash_20241022';
70
70
  args: {};
71
71
  parameters: typeof Bash20241022Parameters;
@@ -102,7 +102,7 @@ declare function bashTool_20250124<RESULT>(options?: {
102
102
  }, RESULT>;
103
103
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
104
104
  }): {
105
- type: 'provider-defined';
105
+ type: 'provider-defined-client';
106
106
  id: 'anthropic.bash_20250124';
107
107
  args: {};
108
108
  parameters: typeof Bash20250124Parameters;
@@ -174,7 +174,7 @@ declare function textEditorTool_20241022<RESULT>(options?: {
174
174
  }, RESULT>;
175
175
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
176
176
  }): {
177
- type: 'provider-defined';
177
+ type: 'provider-defined-client';
178
178
  id: 'anthropic.text_editor_20241022';
179
179
  args: {};
180
180
  parameters: typeof TextEditor20241022Parameters;
@@ -246,7 +246,7 @@ declare function textEditorTool_20250124<RESULT>(options?: {
246
246
  }, RESULT>;
247
247
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
248
248
  }): {
249
- type: 'provider-defined';
249
+ type: 'provider-defined-client';
250
250
  id: 'anthropic.text_editor_20250124';
251
251
  args: {};
252
252
  parameters: typeof TextEditor20250124Parameters;
@@ -308,7 +308,7 @@ declare function computerTool_20241022<RESULT>(options: {
308
308
  }, RESULT>;
309
309
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
310
310
  }): {
311
- type: 'provider-defined';
311
+ type: 'provider-defined-client';
312
312
  id: 'anthropic.computer_20241022';
313
313
  args: {};
314
314
  parameters: typeof Computer20241022Parameters;
@@ -403,13 +403,50 @@ declare function computerTool_20250124<RESULT>(options: {
403
403
  }, RESULT>;
404
404
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
405
405
  }): {
406
- type: 'provider-defined';
406
+ type: 'provider-defined-client';
407
407
  id: 'anthropic.computer_20250124';
408
408
  args: {};
409
409
  parameters: typeof Computer20250124Parameters;
410
410
  execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;
411
411
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
412
412
  };
413
+ /**
414
+ * Creates a web search tool that gives Claude direct access to real-time web content.
415
+ * Must have name "web_search".
416
+ *
417
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
418
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
419
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
420
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
421
+ */
422
+ declare function webSearchTool_20250305(options?: {
423
+ maxUses?: number;
424
+ allowedDomains?: string[];
425
+ blockedDomains?: string[];
426
+ userLocation?: {
427
+ type: 'approximate';
428
+ city?: string;
429
+ region?: string;
430
+ country?: string;
431
+ timezone?: string;
432
+ };
433
+ }): {
434
+ type: 'provider-defined-server';
435
+ id: 'anthropic.web_search_20250305';
436
+ name: 'web_search';
437
+ args: {
438
+ maxUses?: number;
439
+ allowedDomains?: string[];
440
+ blockedDomains?: string[];
441
+ userLocation?: {
442
+ type: 'approximate';
443
+ city?: string;
444
+ region?: string;
445
+ country?: string;
446
+ timezone?: string;
447
+ };
448
+ };
449
+ };
413
450
  declare const anthropicTools: {
414
451
  bash_20241022: typeof bashTool_20241022;
415
452
  bash_20250124: typeof bashTool_20250124;
@@ -417,6 +454,7 @@ declare const anthropicTools: {
417
454
  textEditor_20250124: typeof textEditorTool_20250124;
418
455
  computer_20241022: typeof computerTool_20241022;
419
456
  computer_20250124: typeof computerTool_20250124;
457
+ webSearch_20250305: typeof webSearchTool_20250305;
420
458
  };
421
459
 
422
460
  export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools };
@@ -47,13 +47,6 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
47
47
 
48
48
  // src/anthropic-messages-options.ts
49
49
  var import_zod2 = require("zod");
50
- var webSearchLocationSchema = import_zod2.z.object({
51
- type: import_zod2.z.literal("approximate"),
52
- city: import_zod2.z.string().optional(),
53
- region: import_zod2.z.string().optional(),
54
- country: import_zod2.z.string(),
55
- timezone: import_zod2.z.string().optional()
56
- });
57
50
  var anthropicFilePartProviderOptions = import_zod2.z.object({
58
51
  /**
59
52
  * Citation configuration for this document.
@@ -78,40 +71,10 @@ var anthropicFilePartProviderOptions = import_zod2.z.object({
78
71
  context: import_zod2.z.string().optional()
79
72
  });
80
73
  var anthropicProviderOptions = import_zod2.z.object({
81
- /**
82
- Include reasoning content in requests sent to the model. Defaults to `true`.
83
-
84
- If you are experiencing issues with the model handling requests involving
85
- */
86
74
  sendReasoning: import_zod2.z.boolean().optional(),
87
75
  thinking: import_zod2.z.object({
88
76
  type: import_zod2.z.union([import_zod2.z.literal("enabled"), import_zod2.z.literal("disabled")]),
89
77
  budgetTokens: import_zod2.z.number().optional()
90
- }).optional(),
91
- /**
92
- * Web search tool configuration for Claude models that support it.
93
- * When provided, automatically adds the web search tool to the request.
94
- */
95
- webSearch: import_zod2.z.object({
96
- /**
97
- * Limit the number of searches per request (optional)
98
- * Defaults to 5 if not specified
99
- */
100
- maxUses: import_zod2.z.number().min(1).max(20).optional(),
101
- /**
102
- * Only include results from these domains (optional)
103
- * Cannot be used with blockedDomains
104
- */
105
- allowedDomains: import_zod2.z.array(import_zod2.z.string()).optional(),
106
- /**
107
- * Never include results from these domains (optional)
108
- * Cannot be used with allowedDomains
109
- */
110
- blockedDomains: import_zod2.z.array(import_zod2.z.string()).optional(),
111
- /**
112
- * Localize search results based on user location (optional)
113
- */
114
- userLocation: webSearchLocationSchema.optional()
115
78
  }).optional()
116
79
  });
117
80
 
@@ -141,10 +104,10 @@ function prepareTools({
141
104
  anthropicTools2.push({
142
105
  name: tool.name,
143
106
  description: tool.description,
144
- input_schema: tool.parameters
107
+ input_schema: tool.inputSchema
145
108
  });
146
109
  break;
147
- case "provider-defined":
110
+ case "provider-defined-client":
148
111
  switch (tool.id) {
149
112
  case "anthropic.computer_20250124":
150
113
  betas.add("computer-use-2025-01-24");
@@ -199,6 +162,32 @@ function prepareTools({
199
162
  break;
200
163
  }
201
164
  break;
165
+ case "provider-defined-server":
166
+ switch (tool.id) {
167
+ case "anthropic.web_search_20250305":
168
+ const webSearchTool = {
169
+ type: "web_search_20250305",
170
+ name: tool.name
171
+ };
172
+ if (tool.args.maxUses) {
173
+ webSearchTool.max_uses = tool.args.maxUses;
174
+ }
175
+ if (tool.args.allowedDomains) {
176
+ webSearchTool.allowed_domains = tool.args.allowedDomains;
177
+ }
178
+ if (tool.args.blockedDomains) {
179
+ webSearchTool.blocked_domains = tool.args.blockedDomains;
180
+ }
181
+ if (tool.args.userLocation) {
182
+ webSearchTool.user_location = tool.args.userLocation;
183
+ }
184
+ anthropicTools2.push(webSearchTool);
185
+ break;
186
+ default:
187
+ toolWarnings.push({ type: "unsupported-tool", tool });
188
+ break;
189
+ }
190
+ break;
202
191
  default:
203
192
  toolWarnings.push({ type: "unsupported-tool", tool });
204
193
  break;
@@ -437,7 +426,7 @@ async function convertToAnthropicMessagesPrompt({
437
426
  cache_control: void 0
438
427
  };
439
428
  }
440
- }) : JSON.stringify(part.result);
429
+ }) : JSON.stringify(part.output);
441
430
  anthropicContent.push({
442
431
  type: "tool_result",
443
432
  tool_use_id: part.toolCallId,
@@ -527,7 +516,7 @@ async function convertToAnthropicMessagesPrompt({
527
516
  type: "tool_use",
528
517
  id: part.toolCallId,
529
518
  name: part.toolName,
530
- input: part.args,
519
+ input: part.input,
531
520
  cache_control: cacheControl
532
521
  });
533
522
  break;
@@ -761,7 +750,7 @@ var AnthropicMessagesLanguageModel = class {
761
750
  type: "function",
762
751
  name: "json",
763
752
  description: "Respond with a JSON object.",
764
- parameters: responseFormat.schema
753
+ inputSchema: responseFormat.schema
765
754
  } : void 0;
766
755
  const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
767
756
  provider: "anthropic",
@@ -824,27 +813,6 @@ var AnthropicMessagesLanguageModel = class {
824
813
  }
825
814
  baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
826
815
  }
827
- let modifiedTools = tools;
828
- let modifiedToolChoice = toolChoice;
829
- if (anthropicOptions == null ? void 0 : anthropicOptions.webSearch) {
830
- const webSearchTool = {
831
- type: "web_search_20250305",
832
- name: "web_search",
833
- max_uses: anthropicOptions.webSearch.maxUses,
834
- allowed_domains: anthropicOptions.webSearch.allowedDomains,
835
- blocked_domains: anthropicOptions.webSearch.blockedDomains,
836
- ...anthropicOptions.webSearch.userLocation && {
837
- user_location: {
838
- type: anthropicOptions.webSearch.userLocation.type,
839
- country: anthropicOptions.webSearch.userLocation.country,
840
- city: anthropicOptions.webSearch.userLocation.city,
841
- region: anthropicOptions.webSearch.userLocation.region,
842
- timezone: anthropicOptions.webSearch.userLocation.timezone
843
- }
844
- }
845
- };
846
- modifiedTools = tools ? [...tools, webSearchTool] : [webSearchTool];
847
- }
848
816
  const {
849
817
  tools: anthropicTools2,
850
818
  toolChoice: anthropicToolChoice,
@@ -854,7 +822,7 @@ var AnthropicMessagesLanguageModel = class {
854
822
  jsonResponseTool != null ? {
855
823
  tools: [jsonResponseTool],
856
824
  toolChoice: { type: "tool", toolName: jsonResponseTool.name }
857
- } : { tools: modifiedTools, toolChoice: modifiedToolChoice }
825
+ } : { tools: tools != null ? tools : [], toolChoice }
858
826
  );
859
827
  return {
860
828
  args: {
@@ -981,7 +949,7 @@ var AnthropicMessagesLanguageModel = class {
981
949
  toolCallType: "function",
982
950
  toolCallId: part.id,
983
951
  toolName: part.name,
984
- args: JSON.stringify(part.input)
952
+ input: JSON.stringify(part.input)
985
953
  }
986
954
  );
987
955
  break;
@@ -1173,7 +1141,7 @@ var AnthropicMessagesLanguageModel = class {
1173
1141
  toolCallType: "function",
1174
1142
  toolCallId: contentBlock.toolCallId,
1175
1143
  toolName: contentBlock.toolName,
1176
- args: contentBlock.jsonText
1144
+ input: contentBlock.jsonText
1177
1145
  });
1178
1146
  }
1179
1147
  delete toolCallContentBlocks[value.index];
@@ -1230,7 +1198,7 @@ var AnthropicMessagesLanguageModel = class {
1230
1198
  toolCallType: "function",
1231
1199
  toolCallId: contentBlock.toolCallId,
1232
1200
  toolName: contentBlock.toolName,
1233
- argsTextDelta: value.delta.partial_json
1201
+ inputTextDelta: value.delta.partial_json
1234
1202
  }
1235
1203
  );
1236
1204
  contentBlock.jsonText += value.delta.partial_json;
@@ -1492,7 +1460,7 @@ var Bash20241022Parameters = import_zod4.z.object({
1492
1460
  });
1493
1461
  function bashTool_20241022(options = {}) {
1494
1462
  return {
1495
- type: "provider-defined",
1463
+ type: "provider-defined-client",
1496
1464
  id: "anthropic.bash_20241022",
1497
1465
  args: {},
1498
1466
  parameters: Bash20241022Parameters,
@@ -1506,7 +1474,7 @@ var Bash20250124Parameters = import_zod4.z.object({
1506
1474
  });
1507
1475
  function bashTool_20250124(options = {}) {
1508
1476
  return {
1509
- type: "provider-defined",
1477
+ type: "provider-defined-client",
1510
1478
  id: "anthropic.bash_20250124",
1511
1479
  args: {},
1512
1480
  parameters: Bash20250124Parameters,
@@ -1525,7 +1493,7 @@ var TextEditor20241022Parameters = import_zod4.z.object({
1525
1493
  });
1526
1494
  function textEditorTool_20241022(options = {}) {
1527
1495
  return {
1528
- type: "provider-defined",
1496
+ type: "provider-defined-client",
1529
1497
  id: "anthropic.text_editor_20241022",
1530
1498
  args: {},
1531
1499
  parameters: TextEditor20241022Parameters,
@@ -1544,7 +1512,7 @@ var TextEditor20250124Parameters = import_zod4.z.object({
1544
1512
  });
1545
1513
  function textEditorTool_20250124(options = {}) {
1546
1514
  return {
1547
- type: "provider-defined",
1515
+ type: "provider-defined-client",
1548
1516
  id: "anthropic.text_editor_20250124",
1549
1517
  args: {},
1550
1518
  parameters: TextEditor20250124Parameters,
@@ -1570,7 +1538,7 @@ var Computer20241022Parameters = import_zod4.z.object({
1570
1538
  });
1571
1539
  function computerTool_20241022(options) {
1572
1540
  return {
1573
- type: "provider-defined",
1541
+ type: "provider-defined-client",
1574
1542
  id: "anthropic.computer_20241022",
1575
1543
  args: {
1576
1544
  displayWidthPx: options.displayWidthPx,
@@ -1610,7 +1578,7 @@ var Computer20250124Parameters = import_zod4.z.object({
1610
1578
  });
1611
1579
  function computerTool_20250124(options) {
1612
1580
  return {
1613
- type: "provider-defined",
1581
+ type: "provider-defined-client",
1614
1582
  id: "anthropic.computer_20250124",
1615
1583
  args: {
1616
1584
  displayWidthPx: options.displayWidthPx,
@@ -1622,13 +1590,30 @@ function computerTool_20250124(options) {
1622
1590
  experimental_toToolResultContent: options.experimental_toToolResultContent
1623
1591
  };
1624
1592
  }
1593
+ var WebSearch20250305Parameters = import_zod4.z.object({
1594
+ query: import_zod4.z.string()
1595
+ });
1596
+ function webSearchTool_20250305(options = {}) {
1597
+ return {
1598
+ type: "provider-defined-server",
1599
+ id: "anthropic.web_search_20250305",
1600
+ name: "web_search",
1601
+ args: {
1602
+ ...options.maxUses && { maxUses: options.maxUses },
1603
+ ...options.allowedDomains && { allowedDomains: options.allowedDomains },
1604
+ ...options.blockedDomains && { blockedDomains: options.blockedDomains },
1605
+ ...options.userLocation && { userLocation: options.userLocation }
1606
+ }
1607
+ };
1608
+ }
1625
1609
  var anthropicTools = {
1626
1610
  bash_20241022: bashTool_20241022,
1627
1611
  bash_20250124: bashTool_20250124,
1628
1612
  textEditor_20241022: textEditorTool_20241022,
1629
1613
  textEditor_20250124: textEditorTool_20250124,
1630
1614
  computer_20241022: computerTool_20241022,
1631
- computer_20250124: computerTool_20250124
1615
+ computer_20250124: computerTool_20250124,
1616
+ webSearch_20250305: webSearchTool_20250305
1632
1617
  };
1633
1618
  // Annotate the CommonJS export names for ESM import in node:
1634
1619
  0 && (module.exports = {