@ai-sdk/anthropic 2.0.0-alpha.8 → 2.0.0-alpha.9

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,14 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.0-alpha.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 362b048: add web search tool support
8
+ - Updated dependencies [811dff3]
9
+ - @ai-sdk/provider@2.0.0-alpha.9
10
+ - @ai-sdk/provider-utils@3.0.0-alpha.9
11
+
3
12
  ## 2.0.0-alpha.8
4
13
 
5
14
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -20,18 +20,107 @@ declare const anthropicProviderOptions: z.ZodObject<{
20
20
  type: "enabled" | "disabled";
21
21
  budgetTokens?: number | undefined;
22
22
  }>>;
23
+ /**
24
+ * Web search tool configuration for Claude models that support it.
25
+ * When provided, automatically adds the web search tool to the request.
26
+ */
27
+ webSearch: z.ZodOptional<z.ZodObject<{
28
+ /**
29
+ * Limit the number of searches per request (optional)
30
+ * Defaults to 5 if not specified
31
+ */
32
+ maxUses: z.ZodOptional<z.ZodNumber>;
33
+ /**
34
+ * Only include results from these domains (optional)
35
+ * Cannot be used with blockedDomains
36
+ */
37
+ allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
+ /**
39
+ * Never include results from these domains (optional)
40
+ * Cannot be used with allowedDomains
41
+ */
42
+ blockedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
43
+ /**
44
+ * Localize search results based on user location (optional)
45
+ */
46
+ userLocation: z.ZodOptional<z.ZodObject<{
47
+ type: z.ZodLiteral<"approximate">;
48
+ city: z.ZodOptional<z.ZodString>;
49
+ region: z.ZodOptional<z.ZodString>;
50
+ country: z.ZodString;
51
+ timezone: z.ZodOptional<z.ZodString>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ type: "approximate";
54
+ country: string;
55
+ city?: string | undefined;
56
+ region?: string | undefined;
57
+ timezone?: string | undefined;
58
+ }, {
59
+ type: "approximate";
60
+ country: string;
61
+ city?: string | undefined;
62
+ region?: string | undefined;
63
+ timezone?: string | undefined;
64
+ }>>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ maxUses?: number | undefined;
67
+ allowedDomains?: string[] | undefined;
68
+ blockedDomains?: string[] | undefined;
69
+ userLocation?: {
70
+ type: "approximate";
71
+ country: string;
72
+ city?: string | undefined;
73
+ region?: string | undefined;
74
+ timezone?: string | undefined;
75
+ } | undefined;
76
+ }, {
77
+ maxUses?: number | undefined;
78
+ allowedDomains?: string[] | undefined;
79
+ blockedDomains?: string[] | undefined;
80
+ userLocation?: {
81
+ type: "approximate";
82
+ country: string;
83
+ city?: string | undefined;
84
+ region?: string | undefined;
85
+ timezone?: string | undefined;
86
+ } | undefined;
87
+ }>>;
23
88
  }, "strip", z.ZodTypeAny, {
24
89
  sendReasoning?: boolean | undefined;
25
90
  thinking?: {
26
91
  type: "enabled" | "disabled";
27
92
  budgetTokens?: number | undefined;
28
93
  } | undefined;
94
+ webSearch?: {
95
+ maxUses?: number | undefined;
96
+ allowedDomains?: string[] | undefined;
97
+ blockedDomains?: string[] | undefined;
98
+ userLocation?: {
99
+ type: "approximate";
100
+ country: string;
101
+ city?: string | undefined;
102
+ region?: string | undefined;
103
+ timezone?: string | undefined;
104
+ } | undefined;
105
+ } | undefined;
29
106
  }, {
30
107
  sendReasoning?: boolean | undefined;
31
108
  thinking?: {
32
109
  type: "enabled" | "disabled";
33
110
  budgetTokens?: number | undefined;
34
111
  } | undefined;
112
+ webSearch?: {
113
+ maxUses?: number | undefined;
114
+ allowedDomains?: string[] | undefined;
115
+ blockedDomains?: string[] | undefined;
116
+ userLocation?: {
117
+ type: "approximate";
118
+ country: string;
119
+ city?: string | undefined;
120
+ region?: string | undefined;
121
+ timezone?: string | undefined;
122
+ } | undefined;
123
+ } | undefined;
35
124
  }>;
36
125
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
37
126
 
package/dist/index.d.ts CHANGED
@@ -20,18 +20,107 @@ declare const anthropicProviderOptions: z.ZodObject<{
20
20
  type: "enabled" | "disabled";
21
21
  budgetTokens?: number | undefined;
22
22
  }>>;
23
+ /**
24
+ * Web search tool configuration for Claude models that support it.
25
+ * When provided, automatically adds the web search tool to the request.
26
+ */
27
+ webSearch: z.ZodOptional<z.ZodObject<{
28
+ /**
29
+ * Limit the number of searches per request (optional)
30
+ * Defaults to 5 if not specified
31
+ */
32
+ maxUses: z.ZodOptional<z.ZodNumber>;
33
+ /**
34
+ * Only include results from these domains (optional)
35
+ * Cannot be used with blockedDomains
36
+ */
37
+ allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
+ /**
39
+ * Never include results from these domains (optional)
40
+ * Cannot be used with allowedDomains
41
+ */
42
+ blockedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
43
+ /**
44
+ * Localize search results based on user location (optional)
45
+ */
46
+ userLocation: z.ZodOptional<z.ZodObject<{
47
+ type: z.ZodLiteral<"approximate">;
48
+ city: z.ZodOptional<z.ZodString>;
49
+ region: z.ZodOptional<z.ZodString>;
50
+ country: z.ZodString;
51
+ timezone: z.ZodOptional<z.ZodString>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ type: "approximate";
54
+ country: string;
55
+ city?: string | undefined;
56
+ region?: string | undefined;
57
+ timezone?: string | undefined;
58
+ }, {
59
+ type: "approximate";
60
+ country: string;
61
+ city?: string | undefined;
62
+ region?: string | undefined;
63
+ timezone?: string | undefined;
64
+ }>>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ maxUses?: number | undefined;
67
+ allowedDomains?: string[] | undefined;
68
+ blockedDomains?: string[] | undefined;
69
+ userLocation?: {
70
+ type: "approximate";
71
+ country: string;
72
+ city?: string | undefined;
73
+ region?: string | undefined;
74
+ timezone?: string | undefined;
75
+ } | undefined;
76
+ }, {
77
+ maxUses?: number | undefined;
78
+ allowedDomains?: string[] | undefined;
79
+ blockedDomains?: string[] | undefined;
80
+ userLocation?: {
81
+ type: "approximate";
82
+ country: string;
83
+ city?: string | undefined;
84
+ region?: string | undefined;
85
+ timezone?: string | undefined;
86
+ } | undefined;
87
+ }>>;
23
88
  }, "strip", z.ZodTypeAny, {
24
89
  sendReasoning?: boolean | undefined;
25
90
  thinking?: {
26
91
  type: "enabled" | "disabled";
27
92
  budgetTokens?: number | undefined;
28
93
  } | undefined;
94
+ webSearch?: {
95
+ maxUses?: number | undefined;
96
+ allowedDomains?: string[] | undefined;
97
+ blockedDomains?: string[] | undefined;
98
+ userLocation?: {
99
+ type: "approximate";
100
+ country: string;
101
+ city?: string | undefined;
102
+ region?: string | undefined;
103
+ timezone?: string | undefined;
104
+ } | undefined;
105
+ } | undefined;
29
106
  }, {
30
107
  sendReasoning?: boolean | undefined;
31
108
  thinking?: {
32
109
  type: "enabled" | "disabled";
33
110
  budgetTokens?: number | undefined;
34
111
  } | undefined;
112
+ webSearch?: {
113
+ maxUses?: number | undefined;
114
+ allowedDomains?: string[] | undefined;
115
+ blockedDomains?: string[] | undefined;
116
+ userLocation?: {
117
+ type: "approximate";
118
+ country: string;
119
+ city?: string | undefined;
120
+ region?: string | undefined;
121
+ timezone?: string | undefined;
122
+ } | undefined;
123
+ } | undefined;
35
124
  }>;
36
125
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
37
126
 
package/dist/index.js CHANGED
@@ -51,6 +51,13 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
51
51
 
52
52
  // src/anthropic-messages-options.ts
53
53
  var import_zod2 = require("zod");
54
+ var webSearchLocationSchema = import_zod2.z.object({
55
+ type: import_zod2.z.literal("approximate"),
56
+ city: import_zod2.z.string().optional(),
57
+ region: import_zod2.z.string().optional(),
58
+ country: import_zod2.z.string(),
59
+ timezone: import_zod2.z.string().optional()
60
+ });
54
61
  var anthropicProviderOptions = import_zod2.z.object({
55
62
  /**
56
63
  Include reasoning content in requests sent to the model. Defaults to `true`.
@@ -61,11 +68,39 @@ var anthropicProviderOptions = import_zod2.z.object({
61
68
  thinking: import_zod2.z.object({
62
69
  type: import_zod2.z.union([import_zod2.z.literal("enabled"), import_zod2.z.literal("disabled")]),
63
70
  budgetTokens: import_zod2.z.number().optional()
71
+ }).optional(),
72
+ /**
73
+ * Web search tool configuration for Claude models that support it.
74
+ * When provided, automatically adds the web search tool to the request.
75
+ */
76
+ webSearch: import_zod2.z.object({
77
+ /**
78
+ * Limit the number of searches per request (optional)
79
+ * Defaults to 5 if not specified
80
+ */
81
+ maxUses: import_zod2.z.number().min(1).max(20).optional(),
82
+ /**
83
+ * Only include results from these domains (optional)
84
+ * Cannot be used with blockedDomains
85
+ */
86
+ allowedDomains: import_zod2.z.array(import_zod2.z.string()).optional(),
87
+ /**
88
+ * Never include results from these domains (optional)
89
+ * Cannot be used with allowedDomains
90
+ */
91
+ blockedDomains: import_zod2.z.array(import_zod2.z.string()).optional(),
92
+ /**
93
+ * Localize search results based on user location (optional)
94
+ */
95
+ userLocation: webSearchLocationSchema.optional()
64
96
  }).optional()
65
97
  });
66
98
 
67
99
  // src/anthropic-prepare-tools.ts
68
100
  var import_provider = require("@ai-sdk/provider");
101
+ function isWebSearchTool(tool) {
102
+ return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
103
+ }
69
104
  function prepareTools({
70
105
  tools,
71
106
  toolChoice
@@ -78,6 +113,10 @@ function prepareTools({
78
113
  }
79
114
  const anthropicTools2 = [];
80
115
  for (const tool of tools) {
116
+ if (isWebSearchTool(tool)) {
117
+ anthropicTools2.push(tool);
118
+ continue;
119
+ }
81
120
  switch (tool.type) {
82
121
  case "function":
83
122
  anthropicTools2.push({
@@ -489,8 +528,10 @@ function mapAnthropicStopReason({
489
528
  var AnthropicMessagesLanguageModel = class {
490
529
  constructor(modelId, config) {
491
530
  this.specificationVersion = "v2";
531
+ var _a;
492
532
  this.modelId = modelId;
493
533
  this.config = config;
534
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils3.generateId;
494
535
  }
495
536
  supportsUrl(url) {
496
537
  return url.protocol === "https:";
@@ -620,6 +661,27 @@ var AnthropicMessagesLanguageModel = class {
620
661
  }
621
662
  baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
622
663
  }
664
+ let modifiedTools = tools;
665
+ let modifiedToolChoice = toolChoice;
666
+ if (anthropicOptions == null ? void 0 : anthropicOptions.webSearch) {
667
+ const webSearchTool = {
668
+ type: "web_search_20250305",
669
+ name: "web_search",
670
+ max_uses: anthropicOptions.webSearch.maxUses,
671
+ allowed_domains: anthropicOptions.webSearch.allowedDomains,
672
+ blocked_domains: anthropicOptions.webSearch.blockedDomains,
673
+ ...anthropicOptions.webSearch.userLocation && {
674
+ user_location: {
675
+ type: anthropicOptions.webSearch.userLocation.type,
676
+ country: anthropicOptions.webSearch.userLocation.country,
677
+ city: anthropicOptions.webSearch.userLocation.city,
678
+ region: anthropicOptions.webSearch.userLocation.region,
679
+ timezone: anthropicOptions.webSearch.userLocation.timezone
680
+ }
681
+ }
682
+ };
683
+ modifiedTools = tools ? [...tools, webSearchTool] : [webSearchTool];
684
+ }
623
685
  const {
624
686
  tools: anthropicTools2,
625
687
  toolChoice: anthropicToolChoice,
@@ -629,7 +691,7 @@ var AnthropicMessagesLanguageModel = class {
629
691
  jsonResponseTool != null ? {
630
692
  tools: [jsonResponseTool],
631
693
  toolChoice: { type: "tool", toolName: jsonResponseTool.name }
632
- } : { tools, toolChoice }
694
+ } : { tools: modifiedTools, toolChoice: modifiedToolChoice }
633
695
  );
634
696
  return {
635
697
  args: {
@@ -661,7 +723,7 @@ var AnthropicMessagesLanguageModel = class {
661
723
  return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
662
724
  }
663
725
  async doGenerate(options) {
664
- var _a, _b, _c, _d;
726
+ var _a, _b, _c, _d, _e;
665
727
  const { args, warnings, betas, jsonResponseTool } = await this.getArgs(options);
666
728
  const {
667
729
  responseHeaders,
@@ -727,6 +789,38 @@ var AnthropicMessagesLanguageModel = class {
727
789
  );
728
790
  break;
729
791
  }
792
+ case "server_tool_use": {
793
+ continue;
794
+ }
795
+ case "web_search_tool_result": {
796
+ if (Array.isArray(part.content)) {
797
+ for (const result of part.content) {
798
+ if (result.type === "web_search_result") {
799
+ content.push({
800
+ type: "source",
801
+ sourceType: "url",
802
+ id: this.generateId(),
803
+ url: result.url,
804
+ title: result.title,
805
+ providerMetadata: {
806
+ anthropic: {
807
+ encryptedContent: result.encrypted_content,
808
+ pageAge: (_a = result.page_age) != null ? _a : null
809
+ }
810
+ }
811
+ });
812
+ }
813
+ }
814
+ } else if (part.content.type === "web_search_tool_result_error") {
815
+ throw new import_provider3.APICallError({
816
+ message: `Web search failed: ${part.content.error_code}`,
817
+ url: "web_search_api",
818
+ requestBodyValues: { tool_use_id: part.tool_use_id },
819
+ data: { error_code: part.content.error_code }
820
+ });
821
+ }
822
+ break;
823
+ }
730
824
  }
731
825
  }
732
826
  return {
@@ -739,19 +833,19 @@ var AnthropicMessagesLanguageModel = class {
739
833
  inputTokens: response.usage.input_tokens,
740
834
  outputTokens: response.usage.output_tokens,
741
835
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
742
- cachedInputTokens: (_a = response.usage.cache_read_input_tokens) != null ? _a : void 0
836
+ cachedInputTokens: (_b = response.usage.cache_read_input_tokens) != null ? _b : void 0
743
837
  },
744
838
  request: { body: args },
745
839
  response: {
746
- id: (_b = response.id) != null ? _b : void 0,
747
- modelId: (_c = response.model) != null ? _c : void 0,
840
+ id: (_c = response.id) != null ? _c : void 0,
841
+ modelId: (_d = response.model) != null ? _d : void 0,
748
842
  headers: responseHeaders,
749
843
  body: rawResponse
750
844
  },
751
845
  warnings,
752
846
  providerMetadata: {
753
847
  anthropic: {
754
- cacheCreationInputTokens: (_d = response.usage.cache_creation_input_tokens) != null ? _d : null
848
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
755
849
  }
756
850
  }
757
851
  };
@@ -779,6 +873,8 @@ var AnthropicMessagesLanguageModel = class {
779
873
  const toolCallContentBlocks = {};
780
874
  let providerMetadata = void 0;
781
875
  let blockType = void 0;
876
+ const config = this.config;
877
+ const generateId3 = this.generateId;
782
878
  return {
783
879
  stream: response.pipeThrough(
784
880
  new TransformStream({
@@ -786,7 +882,7 @@ var AnthropicMessagesLanguageModel = class {
786
882
  controller.enqueue({ type: "stream-start", warnings });
787
883
  },
788
884
  transform(chunk, controller) {
789
- var _a, _b, _c, _d, _e, _f;
885
+ var _a, _b, _c, _d, _e, _f, _g;
790
886
  if (!chunk.success) {
791
887
  controller.enqueue({ type: "error", error: chunk.error });
792
888
  return;
@@ -825,6 +921,40 @@ var AnthropicMessagesLanguageModel = class {
825
921
  };
826
922
  return;
827
923
  }
924
+ case "server_tool_use": {
925
+ return;
926
+ }
927
+ case "web_search_tool_result": {
928
+ if (Array.isArray(value.content_block.content)) {
929
+ for (const result of value.content_block.content) {
930
+ if (result.type === "web_search_result") {
931
+ controller.enqueue({
932
+ type: "source",
933
+ sourceType: "url",
934
+ id: generateId3(),
935
+ url: result.url,
936
+ title: result.title,
937
+ providerMetadata: {
938
+ anthropic: {
939
+ encryptedContent: result.encrypted_content,
940
+ pageAge: (_a = result.page_age) != null ? _a : null
941
+ }
942
+ }
943
+ });
944
+ }
945
+ }
946
+ } else if (value.content_block.content.type === "web_search_tool_result_error") {
947
+ controller.enqueue({
948
+ type: "error",
949
+ error: {
950
+ type: "web-search-error",
951
+ message: `Web search failed: ${value.content_block.content.error_code}`,
952
+ code: value.content_block.content.error_code
953
+ }
954
+ });
955
+ }
956
+ return;
957
+ }
828
958
  default: {
829
959
  const _exhaustiveCheck = contentBlockType;
830
960
  throw new Error(
@@ -887,6 +1017,9 @@ var AnthropicMessagesLanguageModel = class {
887
1017
  }
888
1018
  case "input_json_delta": {
889
1019
  const contentBlock = toolCallContentBlocks[value.index];
1020
+ if (!contentBlock) {
1021
+ return;
1022
+ }
890
1023
  controller.enqueue(
891
1024
  jsonResponseTool != null ? {
892
1025
  type: "text",
@@ -902,6 +1035,9 @@ var AnthropicMessagesLanguageModel = class {
902
1035
  contentBlock.jsonText += value.delta.partial_json;
903
1036
  return;
904
1037
  }
1038
+ case "citations_delta": {
1039
+ return;
1040
+ }
905
1041
  default: {
906
1042
  const _exhaustiveCheck = deltaType;
907
1043
  throw new Error(
@@ -912,22 +1048,22 @@ var AnthropicMessagesLanguageModel = class {
912
1048
  }
913
1049
  case "message_start": {
914
1050
  usage.inputTokens = value.message.usage.input_tokens;
915
- usage.cachedInputTokens = (_a = value.message.usage.cache_read_input_tokens) != null ? _a : void 0;
1051
+ usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
916
1052
  providerMetadata = {
917
1053
  anthropic: {
918
- cacheCreationInputTokens: (_b = value.message.usage.cache_creation_input_tokens) != null ? _b : null
1054
+ cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
919
1055
  }
920
1056
  };
921
1057
  controller.enqueue({
922
1058
  type: "response-metadata",
923
- id: (_c = value.message.id) != null ? _c : void 0,
924
- modelId: (_d = value.message.model) != null ? _d : void 0
1059
+ id: (_d = value.message.id) != null ? _d : void 0,
1060
+ modelId: (_e = value.message.model) != null ? _e : void 0
925
1061
  });
926
1062
  return;
927
1063
  }
928
1064
  case "message_delta": {
929
1065
  usage.outputTokens = value.usage.output_tokens;
930
- usage.totalTokens = ((_e = usage.inputTokens) != null ? _e : 0) + ((_f = value.usage.output_tokens) != null ? _f : 0);
1066
+ usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
931
1067
  finishReason = mapAnthropicStopReason({
932
1068
  finishReason: value.delta.stop_reason,
933
1069
  isJsonResponseFromTool: jsonResponseTool != null
@@ -984,6 +1120,31 @@ var anthropicMessagesResponseSchema = import_zod3.z.object({
984
1120
  id: import_zod3.z.string(),
985
1121
  name: import_zod3.z.string(),
986
1122
  input: import_zod3.z.unknown()
1123
+ }),
1124
+ import_zod3.z.object({
1125
+ type: import_zod3.z.literal("server_tool_use"),
1126
+ id: import_zod3.z.string(),
1127
+ name: import_zod3.z.string(),
1128
+ input: import_zod3.z.record(import_zod3.z.unknown()).nullish()
1129
+ }),
1130
+ import_zod3.z.object({
1131
+ type: import_zod3.z.literal("web_search_tool_result"),
1132
+ tool_use_id: import_zod3.z.string(),
1133
+ content: import_zod3.z.union([
1134
+ import_zod3.z.array(
1135
+ import_zod3.z.object({
1136
+ type: import_zod3.z.literal("web_search_result"),
1137
+ url: import_zod3.z.string(),
1138
+ title: import_zod3.z.string(),
1139
+ encrypted_content: import_zod3.z.string(),
1140
+ page_age: import_zod3.z.string().nullish()
1141
+ })
1142
+ ),
1143
+ import_zod3.z.object({
1144
+ type: import_zod3.z.literal("web_search_tool_result_error"),
1145
+ error_code: import_zod3.z.string()
1146
+ })
1147
+ ])
987
1148
  })
988
1149
  ])
989
1150
  ),
@@ -992,7 +1153,10 @@ var anthropicMessagesResponseSchema = import_zod3.z.object({
992
1153
  input_tokens: import_zod3.z.number(),
993
1154
  output_tokens: import_zod3.z.number(),
994
1155
  cache_creation_input_tokens: import_zod3.z.number().nullish(),
995
- cache_read_input_tokens: import_zod3.z.number().nullish()
1156
+ cache_read_input_tokens: import_zod3.z.number().nullish(),
1157
+ server_tool_use: import_zod3.z.object({
1158
+ web_search_requests: import_zod3.z.number()
1159
+ }).nullish()
996
1160
  })
997
1161
  });
998
1162
  var anthropicMessagesChunkSchema = import_zod3.z.discriminatedUnion("type", [
@@ -1029,6 +1193,31 @@ var anthropicMessagesChunkSchema = import_zod3.z.discriminatedUnion("type", [
1029
1193
  import_zod3.z.object({
1030
1194
  type: import_zod3.z.literal("redacted_thinking"),
1031
1195
  data: import_zod3.z.string()
1196
+ }),
1197
+ import_zod3.z.object({
1198
+ type: import_zod3.z.literal("server_tool_use"),
1199
+ id: import_zod3.z.string(),
1200
+ name: import_zod3.z.string(),
1201
+ input: import_zod3.z.record(import_zod3.z.unknown()).nullish()
1202
+ }),
1203
+ import_zod3.z.object({
1204
+ type: import_zod3.z.literal("web_search_tool_result"),
1205
+ tool_use_id: import_zod3.z.string(),
1206
+ content: import_zod3.z.union([
1207
+ import_zod3.z.array(
1208
+ import_zod3.z.object({
1209
+ type: import_zod3.z.literal("web_search_result"),
1210
+ url: import_zod3.z.string(),
1211
+ title: import_zod3.z.string(),
1212
+ encrypted_content: import_zod3.z.string(),
1213
+ page_age: import_zod3.z.string().nullish()
1214
+ })
1215
+ ),
1216
+ import_zod3.z.object({
1217
+ type: import_zod3.z.literal("web_search_tool_result_error"),
1218
+ error_code: import_zod3.z.string()
1219
+ })
1220
+ ])
1032
1221
  })
1033
1222
  ])
1034
1223
  }),
@@ -1051,6 +1240,16 @@ var anthropicMessagesChunkSchema = import_zod3.z.discriminatedUnion("type", [
1051
1240
  import_zod3.z.object({
1052
1241
  type: import_zod3.z.literal("signature_delta"),
1053
1242
  signature: import_zod3.z.string()
1243
+ }),
1244
+ import_zod3.z.object({
1245
+ type: import_zod3.z.literal("citations_delta"),
1246
+ citation: import_zod3.z.object({
1247
+ type: import_zod3.z.literal("web_search_result_location"),
1248
+ cited_text: import_zod3.z.string(),
1249
+ url: import_zod3.z.string(),
1250
+ title: import_zod3.z.string(),
1251
+ encrypted_index: import_zod3.z.string()
1252
+ })
1054
1253
  })
1055
1254
  ])
1056
1255
  }),
@@ -1242,15 +1441,19 @@ function createAnthropic(options = {}) {
1242
1441
  }),
1243
1442
  ...options.headers
1244
1443
  });
1245
- const createChatModel = (modelId) => new AnthropicMessagesLanguageModel(modelId, {
1246
- provider: "anthropic.messages",
1247
- baseURL,
1248
- headers: getHeaders,
1249
- fetch: options.fetch,
1250
- supportedUrls: () => ({
1251
- "image/*": [/^https?:\/\/.*$/]
1252
- })
1253
- });
1444
+ const createChatModel = (modelId) => {
1445
+ var _a2;
1446
+ return new AnthropicMessagesLanguageModel(modelId, {
1447
+ provider: "anthropic.messages",
1448
+ baseURL,
1449
+ headers: getHeaders,
1450
+ fetch: options.fetch,
1451
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils4.generateId,
1452
+ supportedUrls: () => ({
1453
+ "image/*": [/^https?:\/\/.*$/]
1454
+ })
1455
+ });
1456
+ };
1254
1457
  const provider = function(modelId) {
1255
1458
  if (new.target) {
1256
1459
  throw new Error(