@fairyhunter13/ai-anthropic 3.0.58-fork.8 → 3.0.74-fork

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +277 -0
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +156 -67
  4. package/dist/index.js +2190 -1471
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +167 -58
  7. package/dist/internal/index.js +1950 -1458
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/05-anthropic.mdx +116 -13
  10. package/package.json +15 -12
  11. package/src/{anthropic-messages-api.ts → anthropic-api.ts} +46 -15
  12. package/src/anthropic-error.ts +1 -1
  13. package/src/anthropic-files.ts +95 -0
  14. package/src/{anthropic-messages-options.ts → anthropic-language-model-options.ts} +80 -41
  15. package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +221 -138
  16. package/src/anthropic-message-metadata.ts +2 -1
  17. package/src/anthropic-prepare-tools.ts +68 -26
  18. package/src/anthropic-provider.ts +42 -13
  19. package/src/anthropic-tools.ts +18 -0
  20. package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +4 -4
  21. package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +233 -180
  22. package/src/forward-anthropic-container-id-from-last-step.ts +2 -2
  23. package/src/get-cache-control.ts +5 -2
  24. package/src/index.ts +1 -1
  25. package/src/internal/index.ts +9 -3
  26. package/src/map-anthropic-stop-reason.ts +1 -1
  27. package/src/sanitize-json-schema.ts +203 -0
  28. package/src/skills/anthropic-skills-api.ts +44 -0
  29. package/src/skills/anthropic-skills.ts +132 -0
  30. package/src/tool/bash_20241022.ts +2 -2
  31. package/src/tool/bash_20250124.ts +2 -2
  32. package/src/tool/code-execution_20250522.ts +2 -2
  33. package/src/tool/code-execution_20250825.ts +2 -2
  34. package/src/tool/code-execution_20260120.ts +2 -2
  35. package/src/tool/computer_20241022.ts +2 -2
  36. package/src/tool/computer_20250124.ts +2 -2
  37. package/src/tool/computer_20251124.ts +2 -2
  38. package/src/tool/memory_20250818.ts +2 -2
  39. package/src/tool/text-editor_20241022.ts +2 -2
  40. package/src/tool/text-editor_20250124.ts +2 -2
  41. package/src/tool/text-editor_20250429.ts +2 -2
  42. package/src/tool/text-editor_20250728.ts +6 -3
  43. package/src/tool/tool-search-bm25_20251119.ts +2 -2
  44. package/src/tool/tool-search-regex_20251119.ts +2 -2
  45. package/src/tool/web-fetch-20250910.ts +2 -2
  46. package/src/tool/web-fetch-20260209.ts +2 -2
  47. package/src/tool/web-fetch-20260309.ts +181 -0
  48. package/src/tool/web-search_20250305.ts +2 -2
  49. package/src/tool/web-search_20260209.ts +19 -2
  50. package/dist/index.d.mts +0 -1105
  51. package/dist/index.mjs +0 -5394
  52. package/dist/index.mjs.map +0 -1
  53. package/dist/internal/index.d.mts +0 -981
  54. package/dist/internal/index.mjs +0 -5287
  55. package/dist/internal/index.mjs.map +0 -1
@@ -1,368 +1,364 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/internal/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- AnthropicMessagesLanguageModel: () => AnthropicMessagesLanguageModel,
24
- anthropicTools: () => anthropicTools,
25
- getModelCapabilities: () => getModelCapabilities,
26
- prepareTools: () => prepareTools
27
- });
28
- module.exports = __toCommonJS(index_exports);
29
-
30
- // src/anthropic-messages-language-model.ts
31
- var import_provider3 = require("@ai-sdk/provider");
32
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
1
+ // src/anthropic-language-model.ts
2
+ import {
3
+ APICallError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ combineHeaders,
7
+ createEventSourceResponseHandler,
8
+ createJsonResponseHandler,
9
+ createToolNameMapping,
10
+ generateId,
11
+ isCustomReasoning,
12
+ mapReasoningToProviderBudget,
13
+ mapReasoningToProviderEffort,
14
+ parseProviderOptions as parseProviderOptions2,
15
+ postJsonToApi,
16
+ resolve,
17
+ resolveProviderReference as resolveProviderReference2,
18
+ serializeModelOptions,
19
+ WORKFLOW_SERIALIZE,
20
+ WORKFLOW_DESERIALIZE
21
+ } from "@ai-sdk/provider-utils";
33
22
 
34
23
  // src/anthropic-error.ts
35
- var import_provider_utils = require("@ai-sdk/provider-utils");
36
- var import_v4 = require("zod/v4");
37
- var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
38
- () => (0, import_provider_utils.zodSchema)(
39
- import_v4.z.object({
40
- type: import_v4.z.literal("error"),
41
- error: import_v4.z.object({
42
- type: import_v4.z.string(),
43
- message: import_v4.z.string()
24
+ import {
25
+ createJsonErrorResponseHandler,
26
+ lazySchema,
27
+ zodSchema
28
+ } from "@ai-sdk/provider-utils";
29
+ import { z } from "zod/v4";
30
+ var anthropicErrorDataSchema = lazySchema(
31
+ () => zodSchema(
32
+ z.object({
33
+ type: z.literal("error"),
34
+ error: z.object({
35
+ type: z.string(),
36
+ message: z.string()
44
37
  })
45
38
  })
46
39
  )
47
40
  );
48
- var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
41
+ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
49
42
  errorSchema: anthropicErrorDataSchema,
50
43
  errorToMessage: (data) => data.error.message
51
44
  });
52
45
 
53
- // src/anthropic-messages-api.ts
54
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
55
- var import_v42 = require("zod/v4");
56
- var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
57
- () => (0, import_provider_utils2.zodSchema)(
58
- import_v42.z.object({
59
- type: import_v42.z.literal("message"),
60
- id: import_v42.z.string().nullish(),
61
- model: import_v42.z.string().nullish(),
62
- content: import_v42.z.array(
63
- import_v42.z.discriminatedUnion("type", [
64
- import_v42.z.object({
65
- type: import_v42.z.literal("text"),
66
- text: import_v42.z.string(),
67
- citations: import_v42.z.array(
68
- import_v42.z.discriminatedUnion("type", [
69
- import_v42.z.object({
70
- type: import_v42.z.literal("web_search_result_location"),
71
- cited_text: import_v42.z.string(),
72
- url: import_v42.z.string(),
73
- title: import_v42.z.string(),
74
- encrypted_index: import_v42.z.string()
46
+ // src/anthropic-api.ts
47
+ import {
48
+ lazySchema as lazySchema2,
49
+ zodSchema as zodSchema2
50
+ } from "@ai-sdk/provider-utils";
51
+ import { z as z2 } from "zod/v4";
52
+ var anthropicResponseSchema = lazySchema2(
53
+ () => zodSchema2(
54
+ z2.object({
55
+ type: z2.literal("message"),
56
+ id: z2.string().nullish(),
57
+ model: z2.string().nullish(),
58
+ content: z2.array(
59
+ z2.discriminatedUnion("type", [
60
+ z2.object({
61
+ type: z2.literal("text"),
62
+ text: z2.string(),
63
+ citations: z2.array(
64
+ z2.discriminatedUnion("type", [
65
+ z2.object({
66
+ type: z2.literal("web_search_result_location"),
67
+ cited_text: z2.string(),
68
+ url: z2.string(),
69
+ title: z2.string(),
70
+ encrypted_index: z2.string()
75
71
  }),
76
- import_v42.z.object({
77
- type: import_v42.z.literal("page_location"),
78
- cited_text: import_v42.z.string(),
79
- document_index: import_v42.z.number(),
80
- document_title: import_v42.z.string().nullable(),
81
- start_page_number: import_v42.z.number(),
82
- end_page_number: import_v42.z.number()
72
+ z2.object({
73
+ type: z2.literal("page_location"),
74
+ cited_text: z2.string(),
75
+ document_index: z2.number(),
76
+ document_title: z2.string().nullable(),
77
+ start_page_number: z2.number(),
78
+ end_page_number: z2.number()
83
79
  }),
84
- import_v42.z.object({
85
- type: import_v42.z.literal("char_location"),
86
- cited_text: import_v42.z.string(),
87
- document_index: import_v42.z.number(),
88
- document_title: import_v42.z.string().nullable(),
89
- start_char_index: import_v42.z.number(),
90
- end_char_index: import_v42.z.number()
80
+ z2.object({
81
+ type: z2.literal("char_location"),
82
+ cited_text: z2.string(),
83
+ document_index: z2.number(),
84
+ document_title: z2.string().nullable(),
85
+ start_char_index: z2.number(),
86
+ end_char_index: z2.number()
91
87
  })
92
88
  ])
93
89
  ).optional()
94
90
  }),
95
- import_v42.z.object({
96
- type: import_v42.z.literal("thinking"),
97
- thinking: import_v42.z.string(),
98
- signature: import_v42.z.string()
91
+ z2.object({
92
+ type: z2.literal("thinking"),
93
+ thinking: z2.string(),
94
+ signature: z2.string()
99
95
  }),
100
- import_v42.z.object({
101
- type: import_v42.z.literal("redacted_thinking"),
102
- data: import_v42.z.string()
96
+ z2.object({
97
+ type: z2.literal("redacted_thinking"),
98
+ data: z2.string()
103
99
  }),
104
- import_v42.z.object({
105
- type: import_v42.z.literal("compaction"),
106
- content: import_v42.z.string()
100
+ z2.object({
101
+ type: z2.literal("compaction"),
102
+ content: z2.string()
107
103
  }),
108
- import_v42.z.object({
109
- type: import_v42.z.literal("tool_use"),
110
- id: import_v42.z.string(),
111
- name: import_v42.z.string(),
112
- input: import_v42.z.unknown(),
104
+ z2.object({
105
+ type: z2.literal("tool_use"),
106
+ id: z2.string(),
107
+ name: z2.string(),
108
+ input: z2.unknown(),
113
109
  // Programmatic tool calling: caller info when triggered from code execution
114
- caller: import_v42.z.union([
115
- import_v42.z.object({
116
- type: import_v42.z.literal("code_execution_20250825"),
117
- tool_id: import_v42.z.string()
110
+ caller: z2.union([
111
+ z2.object({
112
+ type: z2.literal("code_execution_20250825"),
113
+ tool_id: z2.string()
118
114
  }),
119
- import_v42.z.object({
120
- type: import_v42.z.literal("code_execution_20260120"),
121
- tool_id: import_v42.z.string()
115
+ z2.object({
116
+ type: z2.literal("code_execution_20260120"),
117
+ tool_id: z2.string()
122
118
  }),
123
- import_v42.z.object({
124
- type: import_v42.z.literal("direct")
119
+ z2.object({
120
+ type: z2.literal("direct")
125
121
  })
126
122
  ]).optional()
127
123
  }),
128
- import_v42.z.object({
129
- type: import_v42.z.literal("server_tool_use"),
130
- id: import_v42.z.string(),
131
- name: import_v42.z.string(),
132
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
133
- caller: import_v42.z.union([
134
- import_v42.z.object({
135
- type: import_v42.z.literal("code_execution_20260120"),
136
- tool_id: import_v42.z.string()
124
+ z2.object({
125
+ type: z2.literal("server_tool_use"),
126
+ id: z2.string(),
127
+ name: z2.string(),
128
+ input: z2.record(z2.string(), z2.unknown()).nullish(),
129
+ caller: z2.union([
130
+ z2.object({
131
+ type: z2.literal("code_execution_20260120"),
132
+ tool_id: z2.string()
137
133
  }),
138
- import_v42.z.object({
139
- type: import_v42.z.literal("direct")
134
+ z2.object({
135
+ type: z2.literal("direct")
140
136
  })
141
137
  ]).optional()
142
138
  }),
143
- import_v42.z.object({
144
- type: import_v42.z.literal("mcp_tool_use"),
145
- id: import_v42.z.string(),
146
- name: import_v42.z.string(),
147
- input: import_v42.z.unknown(),
148
- server_name: import_v42.z.string()
139
+ z2.object({
140
+ type: z2.literal("mcp_tool_use"),
141
+ id: z2.string(),
142
+ name: z2.string(),
143
+ input: z2.unknown(),
144
+ server_name: z2.string()
149
145
  }),
150
- import_v42.z.object({
151
- type: import_v42.z.literal("mcp_tool_result"),
152
- tool_use_id: import_v42.z.string(),
153
- is_error: import_v42.z.boolean(),
154
- content: import_v42.z.array(
155
- import_v42.z.union([
156
- import_v42.z.string(),
157
- import_v42.z.object({ type: import_v42.z.literal("text"), text: import_v42.z.string() })
146
+ z2.object({
147
+ type: z2.literal("mcp_tool_result"),
148
+ tool_use_id: z2.string(),
149
+ is_error: z2.boolean(),
150
+ content: z2.array(
151
+ z2.union([
152
+ z2.string(),
153
+ z2.object({ type: z2.literal("text"), text: z2.string() })
158
154
  ])
159
155
  )
160
156
  }),
161
- import_v42.z.object({
162
- type: import_v42.z.literal("web_fetch_tool_result"),
163
- tool_use_id: import_v42.z.string(),
164
- content: import_v42.z.union([
165
- import_v42.z.object({
166
- type: import_v42.z.literal("web_fetch_result"),
167
- url: import_v42.z.string(),
168
- retrieved_at: import_v42.z.string(),
169
- content: import_v42.z.object({
170
- type: import_v42.z.literal("document"),
171
- title: import_v42.z.string().nullable(),
172
- citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
173
- source: import_v42.z.union([
174
- import_v42.z.object({
175
- type: import_v42.z.literal("base64"),
176
- media_type: import_v42.z.literal("application/pdf"),
177
- data: import_v42.z.string()
157
+ z2.object({
158
+ type: z2.literal("web_fetch_tool_result"),
159
+ tool_use_id: z2.string(),
160
+ content: z2.union([
161
+ z2.object({
162
+ type: z2.literal("web_fetch_result"),
163
+ url: z2.string(),
164
+ retrieved_at: z2.string(),
165
+ content: z2.object({
166
+ type: z2.literal("document"),
167
+ title: z2.string().nullable(),
168
+ citations: z2.object({ enabled: z2.boolean() }).optional(),
169
+ source: z2.union([
170
+ z2.object({
171
+ type: z2.literal("base64"),
172
+ media_type: z2.literal("application/pdf"),
173
+ data: z2.string()
178
174
  }),
179
- import_v42.z.object({
180
- type: import_v42.z.literal("text"),
181
- media_type: import_v42.z.literal("text/plain"),
182
- data: import_v42.z.string()
175
+ z2.object({
176
+ type: z2.literal("text"),
177
+ media_type: z2.literal("text/plain"),
178
+ data: z2.string()
183
179
  })
184
180
  ])
185
181
  })
186
182
  }),
187
- import_v42.z.object({
188
- type: import_v42.z.literal("web_fetch_tool_result_error"),
189
- error_code: import_v42.z.string()
183
+ z2.object({
184
+ type: z2.literal("web_fetch_tool_result_error"),
185
+ error_code: z2.string()
190
186
  })
191
187
  ])
192
188
  }),
193
- import_v42.z.object({
194
- type: import_v42.z.literal("web_search_tool_result"),
195
- tool_use_id: import_v42.z.string(),
196
- content: import_v42.z.union([
197
- import_v42.z.array(
198
- import_v42.z.object({
199
- type: import_v42.z.literal("web_search_result"),
200
- url: import_v42.z.string(),
201
- title: import_v42.z.string(),
202
- encrypted_content: import_v42.z.string(),
203
- page_age: import_v42.z.string().nullish()
189
+ z2.object({
190
+ type: z2.literal("web_search_tool_result"),
191
+ tool_use_id: z2.string(),
192
+ content: z2.union([
193
+ z2.array(
194
+ z2.object({
195
+ type: z2.literal("web_search_result"),
196
+ url: z2.string(),
197
+ title: z2.string(),
198
+ encrypted_content: z2.string(),
199
+ page_age: z2.string().nullish()
204
200
  })
205
201
  ),
206
- import_v42.z.object({
207
- type: import_v42.z.literal("web_search_tool_result_error"),
208
- error_code: import_v42.z.string()
202
+ z2.object({
203
+ type: z2.literal("web_search_tool_result_error"),
204
+ error_code: z2.string()
209
205
  })
210
206
  ])
211
207
  }),
212
208
  // code execution results for code_execution_20250522 tool:
213
- import_v42.z.object({
214
- type: import_v42.z.literal("code_execution_tool_result"),
215
- tool_use_id: import_v42.z.string(),
216
- content: import_v42.z.union([
217
- import_v42.z.object({
218
- type: import_v42.z.literal("code_execution_result"),
219
- stdout: import_v42.z.string(),
220
- stderr: import_v42.z.string(),
221
- return_code: import_v42.z.number(),
222
- content: import_v42.z.array(
223
- import_v42.z.object({
224
- type: import_v42.z.literal("code_execution_output"),
225
- file_id: import_v42.z.string()
209
+ z2.object({
210
+ type: z2.literal("code_execution_tool_result"),
211
+ tool_use_id: z2.string(),
212
+ content: z2.union([
213
+ z2.object({
214
+ type: z2.literal("code_execution_result"),
215
+ stdout: z2.string(),
216
+ stderr: z2.string(),
217
+ return_code: z2.number(),
218
+ content: z2.array(
219
+ z2.object({
220
+ type: z2.literal("code_execution_output"),
221
+ file_id: z2.string()
226
222
  })
227
223
  ).optional().default([])
228
224
  }),
229
- import_v42.z.object({
230
- type: import_v42.z.literal("encrypted_code_execution_result"),
231
- encrypted_stdout: import_v42.z.string(),
232
- stderr: import_v42.z.string(),
233
- return_code: import_v42.z.number(),
234
- content: import_v42.z.array(
235
- import_v42.z.object({
236
- type: import_v42.z.literal("code_execution_output"),
237
- file_id: import_v42.z.string()
225
+ z2.object({
226
+ type: z2.literal("encrypted_code_execution_result"),
227
+ encrypted_stdout: z2.string(),
228
+ stderr: z2.string(),
229
+ return_code: z2.number(),
230
+ content: z2.array(
231
+ z2.object({
232
+ type: z2.literal("code_execution_output"),
233
+ file_id: z2.string()
238
234
  })
239
235
  ).optional().default([])
240
236
  }),
241
- import_v42.z.object({
242
- type: import_v42.z.literal("code_execution_tool_result_error"),
243
- error_code: import_v42.z.string()
237
+ z2.object({
238
+ type: z2.literal("code_execution_tool_result_error"),
239
+ error_code: z2.string()
244
240
  })
245
241
  ])
246
242
  }),
247
243
  // bash code execution results for code_execution_20250825 tool:
248
- import_v42.z.object({
249
- type: import_v42.z.literal("bash_code_execution_tool_result"),
250
- tool_use_id: import_v42.z.string(),
251
- content: import_v42.z.discriminatedUnion("type", [
252
- import_v42.z.object({
253
- type: import_v42.z.literal("bash_code_execution_result"),
254
- content: import_v42.z.array(
255
- import_v42.z.object({
256
- type: import_v42.z.literal("bash_code_execution_output"),
257
- file_id: import_v42.z.string()
244
+ z2.object({
245
+ type: z2.literal("bash_code_execution_tool_result"),
246
+ tool_use_id: z2.string(),
247
+ content: z2.discriminatedUnion("type", [
248
+ z2.object({
249
+ type: z2.literal("bash_code_execution_result"),
250
+ content: z2.array(
251
+ z2.object({
252
+ type: z2.literal("bash_code_execution_output"),
253
+ file_id: z2.string()
258
254
  })
259
255
  ),
260
- stdout: import_v42.z.string(),
261
- stderr: import_v42.z.string(),
262
- return_code: import_v42.z.number()
256
+ stdout: z2.string(),
257
+ stderr: z2.string(),
258
+ return_code: z2.number()
263
259
  }),
264
- import_v42.z.object({
265
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
266
- error_code: import_v42.z.string()
260
+ z2.object({
261
+ type: z2.literal("bash_code_execution_tool_result_error"),
262
+ error_code: z2.string()
267
263
  })
268
264
  ])
269
265
  }),
270
266
  // text editor code execution results for code_execution_20250825 tool:
271
- import_v42.z.object({
272
- type: import_v42.z.literal("text_editor_code_execution_tool_result"),
273
- tool_use_id: import_v42.z.string(),
274
- content: import_v42.z.discriminatedUnion("type", [
275
- import_v42.z.object({
276
- type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
277
- error_code: import_v42.z.string()
267
+ z2.object({
268
+ type: z2.literal("text_editor_code_execution_tool_result"),
269
+ tool_use_id: z2.string(),
270
+ content: z2.discriminatedUnion("type", [
271
+ z2.object({
272
+ type: z2.literal("text_editor_code_execution_tool_result_error"),
273
+ error_code: z2.string()
278
274
  }),
279
- import_v42.z.object({
280
- type: import_v42.z.literal("text_editor_code_execution_view_result"),
281
- content: import_v42.z.string(),
282
- file_type: import_v42.z.string(),
283
- num_lines: import_v42.z.number().nullable(),
284
- start_line: import_v42.z.number().nullable(),
285
- total_lines: import_v42.z.number().nullable()
275
+ z2.object({
276
+ type: z2.literal("text_editor_code_execution_view_result"),
277
+ content: z2.string(),
278
+ file_type: z2.string(),
279
+ num_lines: z2.number().nullable(),
280
+ start_line: z2.number().nullable(),
281
+ total_lines: z2.number().nullable()
286
282
  }),
287
- import_v42.z.object({
288
- type: import_v42.z.literal("text_editor_code_execution_create_result"),
289
- is_file_update: import_v42.z.boolean()
283
+ z2.object({
284
+ type: z2.literal("text_editor_code_execution_create_result"),
285
+ is_file_update: z2.boolean()
290
286
  }),
291
- import_v42.z.object({
292
- type: import_v42.z.literal(
287
+ z2.object({
288
+ type: z2.literal(
293
289
  "text_editor_code_execution_str_replace_result"
294
290
  ),
295
- lines: import_v42.z.array(import_v42.z.string()).nullable(),
296
- new_lines: import_v42.z.number().nullable(),
297
- new_start: import_v42.z.number().nullable(),
298
- old_lines: import_v42.z.number().nullable(),
299
- old_start: import_v42.z.number().nullable()
291
+ lines: z2.array(z2.string()).nullable(),
292
+ new_lines: z2.number().nullable(),
293
+ new_start: z2.number().nullable(),
294
+ old_lines: z2.number().nullable(),
295
+ old_start: z2.number().nullable()
300
296
  })
301
297
  ])
302
298
  }),
303
299
  // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
304
- import_v42.z.object({
305
- type: import_v42.z.literal("tool_search_tool_result"),
306
- tool_use_id: import_v42.z.string(),
307
- content: import_v42.z.union([
308
- import_v42.z.object({
309
- type: import_v42.z.literal("tool_search_tool_search_result"),
310
- tool_references: import_v42.z.array(
311
- import_v42.z.object({
312
- type: import_v42.z.literal("tool_reference"),
313
- tool_name: import_v42.z.string()
300
+ z2.object({
301
+ type: z2.literal("tool_search_tool_result"),
302
+ tool_use_id: z2.string(),
303
+ content: z2.union([
304
+ z2.object({
305
+ type: z2.literal("tool_search_tool_search_result"),
306
+ tool_references: z2.array(
307
+ z2.object({
308
+ type: z2.literal("tool_reference"),
309
+ tool_name: z2.string()
314
310
  })
315
311
  )
316
312
  }),
317
- import_v42.z.object({
318
- type: import_v42.z.literal("tool_search_tool_result_error"),
319
- error_code: import_v42.z.string()
313
+ z2.object({
314
+ type: z2.literal("tool_search_tool_result_error"),
315
+ error_code: z2.string()
320
316
  })
321
317
  ])
322
318
  })
323
319
  ])
324
320
  ),
325
- stop_reason: import_v42.z.string().nullish(),
326
- stop_sequence: import_v42.z.string().nullish(),
327
- usage: import_v42.z.looseObject({
328
- input_tokens: import_v42.z.number(),
329
- output_tokens: import_v42.z.number(),
330
- cache_creation_input_tokens: import_v42.z.number().nullish(),
331
- cache_read_input_tokens: import_v42.z.number().nullish(),
332
- iterations: import_v42.z.array(
333
- import_v42.z.object({
334
- type: import_v42.z.union([import_v42.z.literal("compaction"), import_v42.z.literal("message")]),
335
- input_tokens: import_v42.z.number(),
336
- output_tokens: import_v42.z.number()
321
+ stop_reason: z2.string().nullish(),
322
+ stop_sequence: z2.string().nullish(),
323
+ usage: z2.looseObject({
324
+ input_tokens: z2.number(),
325
+ output_tokens: z2.number(),
326
+ cache_creation_input_tokens: z2.number().nullish(),
327
+ cache_read_input_tokens: z2.number().nullish(),
328
+ iterations: z2.array(
329
+ z2.object({
330
+ type: z2.union([z2.literal("compaction"), z2.literal("message")]),
331
+ input_tokens: z2.number(),
332
+ output_tokens: z2.number()
337
333
  })
338
334
  ).nullish()
339
335
  }),
340
- container: import_v42.z.object({
341
- expires_at: import_v42.z.string(),
342
- id: import_v42.z.string(),
343
- skills: import_v42.z.array(
344
- import_v42.z.object({
345
- type: import_v42.z.union([import_v42.z.literal("anthropic"), import_v42.z.literal("custom")]),
346
- skill_id: import_v42.z.string(),
347
- version: import_v42.z.string()
336
+ container: z2.object({
337
+ expires_at: z2.string(),
338
+ id: z2.string(),
339
+ skills: z2.array(
340
+ z2.object({
341
+ type: z2.union([z2.literal("anthropic"), z2.literal("custom")]),
342
+ skill_id: z2.string(),
343
+ version: z2.string()
348
344
  })
349
345
  ).nullish()
350
346
  }).nullish(),
351
- context_management: import_v42.z.object({
352
- applied_edits: import_v42.z.array(
353
- import_v42.z.union([
354
- import_v42.z.object({
355
- type: import_v42.z.literal("clear_tool_uses_20250919"),
356
- cleared_tool_uses: import_v42.z.number(),
357
- cleared_input_tokens: import_v42.z.number()
347
+ context_management: z2.object({
348
+ applied_edits: z2.array(
349
+ z2.union([
350
+ z2.object({
351
+ type: z2.literal("clear_tool_uses_20250919"),
352
+ cleared_tool_uses: z2.number(),
353
+ cleared_input_tokens: z2.number()
358
354
  }),
359
- import_v42.z.object({
360
- type: import_v42.z.literal("clear_thinking_20251015"),
361
- cleared_thinking_turns: import_v42.z.number(),
362
- cleared_input_tokens: import_v42.z.number()
355
+ z2.object({
356
+ type: z2.literal("clear_thinking_20251015"),
357
+ cleared_thinking_turns: z2.number(),
358
+ cleared_input_tokens: z2.number()
363
359
  }),
364
- import_v42.z.object({
365
- type: import_v42.z.literal("compact_20260112")
360
+ z2.object({
361
+ type: z2.literal("compact_20260112")
366
362
  })
367
363
  ])
368
364
  )
@@ -370,457 +366,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
370
366
  })
371
367
  )
372
368
  );
373
- var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
374
- () => (0, import_provider_utils2.zodSchema)(
375
- import_v42.z.discriminatedUnion("type", [
376
- import_v42.z.object({
377
- type: import_v42.z.literal("message_start"),
378
- message: import_v42.z.object({
379
- id: import_v42.z.string().nullish(),
380
- model: import_v42.z.string().nullish(),
381
- role: import_v42.z.string().nullish(),
382
- usage: import_v42.z.looseObject({
383
- input_tokens: import_v42.z.number(),
384
- cache_creation_input_tokens: import_v42.z.number().nullish(),
385
- cache_read_input_tokens: import_v42.z.number().nullish()
369
+ var anthropicChunkSchema = lazySchema2(
370
+ () => zodSchema2(
371
+ z2.discriminatedUnion("type", [
372
+ z2.object({
373
+ type: z2.literal("message_start"),
374
+ message: z2.object({
375
+ id: z2.string().nullish(),
376
+ model: z2.string().nullish(),
377
+ role: z2.string().nullish(),
378
+ usage: z2.looseObject({
379
+ input_tokens: z2.number(),
380
+ cache_creation_input_tokens: z2.number().nullish(),
381
+ cache_read_input_tokens: z2.number().nullish()
386
382
  }),
387
383
  // Programmatic tool calling: content may be pre-populated for deferred tool calls
388
- content: import_v42.z.array(
389
- import_v42.z.discriminatedUnion("type", [
390
- import_v42.z.object({
391
- type: import_v42.z.literal("tool_use"),
392
- id: import_v42.z.string(),
393
- name: import_v42.z.string(),
394
- input: import_v42.z.unknown(),
395
- caller: import_v42.z.union([
396
- import_v42.z.object({
397
- type: import_v42.z.literal("code_execution_20250825"),
398
- tool_id: import_v42.z.string()
384
+ content: z2.array(
385
+ z2.discriminatedUnion("type", [
386
+ z2.object({
387
+ type: z2.literal("tool_use"),
388
+ id: z2.string(),
389
+ name: z2.string(),
390
+ input: z2.unknown(),
391
+ caller: z2.union([
392
+ z2.object({
393
+ type: z2.literal("code_execution_20250825"),
394
+ tool_id: z2.string()
399
395
  }),
400
- import_v42.z.object({
401
- type: import_v42.z.literal("code_execution_20260120"),
402
- tool_id: import_v42.z.string()
396
+ z2.object({
397
+ type: z2.literal("code_execution_20260120"),
398
+ tool_id: z2.string()
403
399
  }),
404
- import_v42.z.object({
405
- type: import_v42.z.literal("direct")
400
+ z2.object({
401
+ type: z2.literal("direct")
406
402
  })
407
403
  ]).optional()
408
404
  })
409
405
  ])
410
406
  ).nullish(),
411
- stop_reason: import_v42.z.string().nullish(),
412
- container: import_v42.z.object({
413
- expires_at: import_v42.z.string(),
414
- id: import_v42.z.string()
407
+ stop_reason: z2.string().nullish(),
408
+ container: z2.object({
409
+ expires_at: z2.string(),
410
+ id: z2.string()
415
411
  }).nullish()
416
412
  })
417
413
  }),
418
- import_v42.z.object({
419
- type: import_v42.z.literal("content_block_start"),
420
- index: import_v42.z.number(),
421
- content_block: import_v42.z.discriminatedUnion("type", [
422
- import_v42.z.object({
423
- type: import_v42.z.literal("text"),
424
- text: import_v42.z.string()
414
+ z2.object({
415
+ type: z2.literal("content_block_start"),
416
+ index: z2.number(),
417
+ content_block: z2.discriminatedUnion("type", [
418
+ z2.object({
419
+ type: z2.literal("text"),
420
+ text: z2.string()
425
421
  }),
426
- import_v42.z.object({
427
- type: import_v42.z.literal("thinking"),
428
- thinking: import_v42.z.string()
422
+ z2.object({
423
+ type: z2.literal("thinking"),
424
+ thinking: z2.string()
429
425
  }),
430
- import_v42.z.object({
431
- type: import_v42.z.literal("tool_use"),
432
- id: import_v42.z.string(),
433
- name: import_v42.z.string(),
426
+ z2.object({
427
+ type: z2.literal("tool_use"),
428
+ id: z2.string(),
429
+ name: z2.string(),
434
430
  // Programmatic tool calling: input may be present directly for deferred tool calls
435
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional(),
431
+ input: z2.record(z2.string(), z2.unknown()).optional(),
436
432
  // Programmatic tool calling: caller info when triggered from code execution
437
- caller: import_v42.z.union([
438
- import_v42.z.object({
439
- type: import_v42.z.literal("code_execution_20250825"),
440
- tool_id: import_v42.z.string()
433
+ caller: z2.union([
434
+ z2.object({
435
+ type: z2.literal("code_execution_20250825"),
436
+ tool_id: z2.string()
441
437
  }),
442
- import_v42.z.object({
443
- type: import_v42.z.literal("code_execution_20260120"),
444
- tool_id: import_v42.z.string()
438
+ z2.object({
439
+ type: z2.literal("code_execution_20260120"),
440
+ tool_id: z2.string()
445
441
  }),
446
- import_v42.z.object({
447
- type: import_v42.z.literal("direct")
442
+ z2.object({
443
+ type: z2.literal("direct")
448
444
  })
449
445
  ]).optional()
450
446
  }),
451
- import_v42.z.object({
452
- type: import_v42.z.literal("redacted_thinking"),
453
- data: import_v42.z.string()
447
+ z2.object({
448
+ type: z2.literal("redacted_thinking"),
449
+ data: z2.string()
454
450
  }),
455
- import_v42.z.object({
456
- type: import_v42.z.literal("compaction"),
457
- content: import_v42.z.string().nullish()
451
+ z2.object({
452
+ type: z2.literal("compaction"),
453
+ content: z2.string().nullish()
458
454
  }),
459
- import_v42.z.object({
460
- type: import_v42.z.literal("server_tool_use"),
461
- id: import_v42.z.string(),
462
- name: import_v42.z.string(),
463
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
464
- caller: import_v42.z.union([
465
- import_v42.z.object({
466
- type: import_v42.z.literal("code_execution_20260120"),
467
- tool_id: import_v42.z.string()
455
+ z2.object({
456
+ type: z2.literal("server_tool_use"),
457
+ id: z2.string(),
458
+ name: z2.string(),
459
+ input: z2.record(z2.string(), z2.unknown()).nullish(),
460
+ caller: z2.union([
461
+ z2.object({
462
+ type: z2.literal("code_execution_20260120"),
463
+ tool_id: z2.string()
468
464
  }),
469
- import_v42.z.object({
470
- type: import_v42.z.literal("direct")
465
+ z2.object({
466
+ type: z2.literal("direct")
471
467
  })
472
468
  ]).optional()
473
469
  }),
474
- import_v42.z.object({
475
- type: import_v42.z.literal("mcp_tool_use"),
476
- id: import_v42.z.string(),
477
- name: import_v42.z.string(),
478
- input: import_v42.z.unknown(),
479
- server_name: import_v42.z.string()
470
+ z2.object({
471
+ type: z2.literal("mcp_tool_use"),
472
+ id: z2.string(),
473
+ name: z2.string(),
474
+ input: z2.unknown(),
475
+ server_name: z2.string()
480
476
  }),
481
- import_v42.z.object({
482
- type: import_v42.z.literal("mcp_tool_result"),
483
- tool_use_id: import_v42.z.string(),
484
- is_error: import_v42.z.boolean(),
485
- content: import_v42.z.array(
486
- import_v42.z.union([
487
- import_v42.z.string(),
488
- import_v42.z.object({ type: import_v42.z.literal("text"), text: import_v42.z.string() })
477
+ z2.object({
478
+ type: z2.literal("mcp_tool_result"),
479
+ tool_use_id: z2.string(),
480
+ is_error: z2.boolean(),
481
+ content: z2.array(
482
+ z2.union([
483
+ z2.string(),
484
+ z2.object({ type: z2.literal("text"), text: z2.string() })
489
485
  ])
490
486
  )
491
487
  }),
492
- import_v42.z.object({
493
- type: import_v42.z.literal("web_fetch_tool_result"),
494
- tool_use_id: import_v42.z.string(),
495
- content: import_v42.z.union([
496
- import_v42.z.object({
497
- type: import_v42.z.literal("web_fetch_result"),
498
- url: import_v42.z.string(),
499
- retrieved_at: import_v42.z.string(),
500
- content: import_v42.z.object({
501
- type: import_v42.z.literal("document"),
502
- title: import_v42.z.string().nullable(),
503
- citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
504
- source: import_v42.z.union([
505
- import_v42.z.object({
506
- type: import_v42.z.literal("base64"),
507
- media_type: import_v42.z.literal("application/pdf"),
508
- data: import_v42.z.string()
488
+ z2.object({
489
+ type: z2.literal("web_fetch_tool_result"),
490
+ tool_use_id: z2.string(),
491
+ content: z2.union([
492
+ z2.object({
493
+ type: z2.literal("web_fetch_result"),
494
+ url: z2.string(),
495
+ retrieved_at: z2.string(),
496
+ content: z2.object({
497
+ type: z2.literal("document"),
498
+ title: z2.string().nullable(),
499
+ citations: z2.object({ enabled: z2.boolean() }).optional(),
500
+ source: z2.union([
501
+ z2.object({
502
+ type: z2.literal("base64"),
503
+ media_type: z2.literal("application/pdf"),
504
+ data: z2.string()
509
505
  }),
510
- import_v42.z.object({
511
- type: import_v42.z.literal("text"),
512
- media_type: import_v42.z.literal("text/plain"),
513
- data: import_v42.z.string()
506
+ z2.object({
507
+ type: z2.literal("text"),
508
+ media_type: z2.literal("text/plain"),
509
+ data: z2.string()
514
510
  })
515
511
  ])
516
512
  })
517
513
  }),
518
- import_v42.z.object({
519
- type: import_v42.z.literal("web_fetch_tool_result_error"),
520
- error_code: import_v42.z.string()
514
+ z2.object({
515
+ type: z2.literal("web_fetch_tool_result_error"),
516
+ error_code: z2.string()
521
517
  })
522
518
  ])
523
519
  }),
524
- import_v42.z.object({
525
- type: import_v42.z.literal("web_search_tool_result"),
526
- tool_use_id: import_v42.z.string(),
527
- content: import_v42.z.union([
528
- import_v42.z.array(
529
- import_v42.z.object({
530
- type: import_v42.z.literal("web_search_result"),
531
- url: import_v42.z.string(),
532
- title: import_v42.z.string(),
533
- encrypted_content: import_v42.z.string(),
534
- page_age: import_v42.z.string().nullish()
520
+ z2.object({
521
+ type: z2.literal("web_search_tool_result"),
522
+ tool_use_id: z2.string(),
523
+ content: z2.union([
524
+ z2.array(
525
+ z2.object({
526
+ type: z2.literal("web_search_result"),
527
+ url: z2.string(),
528
+ title: z2.string(),
529
+ encrypted_content: z2.string(),
530
+ page_age: z2.string().nullish()
535
531
  })
536
532
  ),
537
- import_v42.z.object({
538
- type: import_v42.z.literal("web_search_tool_result_error"),
539
- error_code: import_v42.z.string()
533
+ z2.object({
534
+ type: z2.literal("web_search_tool_result_error"),
535
+ error_code: z2.string()
540
536
  })
541
537
  ])
542
538
  }),
543
539
  // code execution results for code_execution_20250522 tool:
544
- import_v42.z.object({
545
- type: import_v42.z.literal("code_execution_tool_result"),
546
- tool_use_id: import_v42.z.string(),
547
- content: import_v42.z.union([
548
- import_v42.z.object({
549
- type: import_v42.z.literal("code_execution_result"),
550
- stdout: import_v42.z.string(),
551
- stderr: import_v42.z.string(),
552
- return_code: import_v42.z.number(),
553
- content: import_v42.z.array(
554
- import_v42.z.object({
555
- type: import_v42.z.literal("code_execution_output"),
556
- file_id: import_v42.z.string()
540
+ z2.object({
541
+ type: z2.literal("code_execution_tool_result"),
542
+ tool_use_id: z2.string(),
543
+ content: z2.union([
544
+ z2.object({
545
+ type: z2.literal("code_execution_result"),
546
+ stdout: z2.string(),
547
+ stderr: z2.string(),
548
+ return_code: z2.number(),
549
+ content: z2.array(
550
+ z2.object({
551
+ type: z2.literal("code_execution_output"),
552
+ file_id: z2.string()
557
553
  })
558
554
  ).optional().default([])
559
555
  }),
560
- import_v42.z.object({
561
- type: import_v42.z.literal("encrypted_code_execution_result"),
562
- encrypted_stdout: import_v42.z.string(),
563
- stderr: import_v42.z.string(),
564
- return_code: import_v42.z.number(),
565
- content: import_v42.z.array(
566
- import_v42.z.object({
567
- type: import_v42.z.literal("code_execution_output"),
568
- file_id: import_v42.z.string()
556
+ z2.object({
557
+ type: z2.literal("encrypted_code_execution_result"),
558
+ encrypted_stdout: z2.string(),
559
+ stderr: z2.string(),
560
+ return_code: z2.number(),
561
+ content: z2.array(
562
+ z2.object({
563
+ type: z2.literal("code_execution_output"),
564
+ file_id: z2.string()
569
565
  })
570
566
  ).optional().default([])
571
567
  }),
572
- import_v42.z.object({
573
- type: import_v42.z.literal("code_execution_tool_result_error"),
574
- error_code: import_v42.z.string()
568
+ z2.object({
569
+ type: z2.literal("code_execution_tool_result_error"),
570
+ error_code: z2.string()
575
571
  })
576
572
  ])
577
573
  }),
578
574
  // bash code execution results for code_execution_20250825 tool:
579
- import_v42.z.object({
580
- type: import_v42.z.literal("bash_code_execution_tool_result"),
581
- tool_use_id: import_v42.z.string(),
582
- content: import_v42.z.discriminatedUnion("type", [
583
- import_v42.z.object({
584
- type: import_v42.z.literal("bash_code_execution_result"),
585
- content: import_v42.z.array(
586
- import_v42.z.object({
587
- type: import_v42.z.literal("bash_code_execution_output"),
588
- file_id: import_v42.z.string()
575
+ z2.object({
576
+ type: z2.literal("bash_code_execution_tool_result"),
577
+ tool_use_id: z2.string(),
578
+ content: z2.discriminatedUnion("type", [
579
+ z2.object({
580
+ type: z2.literal("bash_code_execution_result"),
581
+ content: z2.array(
582
+ z2.object({
583
+ type: z2.literal("bash_code_execution_output"),
584
+ file_id: z2.string()
589
585
  })
590
586
  ),
591
- stdout: import_v42.z.string(),
592
- stderr: import_v42.z.string(),
593
- return_code: import_v42.z.number()
587
+ stdout: z2.string(),
588
+ stderr: z2.string(),
589
+ return_code: z2.number()
594
590
  }),
595
- import_v42.z.object({
596
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
597
- error_code: import_v42.z.string()
591
+ z2.object({
592
+ type: z2.literal("bash_code_execution_tool_result_error"),
593
+ error_code: z2.string()
598
594
  })
599
595
  ])
600
596
  }),
601
597
  // text editor code execution results for code_execution_20250825 tool:
602
- import_v42.z.object({
603
- type: import_v42.z.literal("text_editor_code_execution_tool_result"),
604
- tool_use_id: import_v42.z.string(),
605
- content: import_v42.z.discriminatedUnion("type", [
606
- import_v42.z.object({
607
- type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
608
- error_code: import_v42.z.string()
598
+ z2.object({
599
+ type: z2.literal("text_editor_code_execution_tool_result"),
600
+ tool_use_id: z2.string(),
601
+ content: z2.discriminatedUnion("type", [
602
+ z2.object({
603
+ type: z2.literal("text_editor_code_execution_tool_result_error"),
604
+ error_code: z2.string()
609
605
  }),
610
- import_v42.z.object({
611
- type: import_v42.z.literal("text_editor_code_execution_view_result"),
612
- content: import_v42.z.string(),
613
- file_type: import_v42.z.string(),
614
- num_lines: import_v42.z.number().nullable(),
615
- start_line: import_v42.z.number().nullable(),
616
- total_lines: import_v42.z.number().nullable()
606
+ z2.object({
607
+ type: z2.literal("text_editor_code_execution_view_result"),
608
+ content: z2.string(),
609
+ file_type: z2.string(),
610
+ num_lines: z2.number().nullable(),
611
+ start_line: z2.number().nullable(),
612
+ total_lines: z2.number().nullable()
617
613
  }),
618
- import_v42.z.object({
619
- type: import_v42.z.literal("text_editor_code_execution_create_result"),
620
- is_file_update: import_v42.z.boolean()
614
+ z2.object({
615
+ type: z2.literal("text_editor_code_execution_create_result"),
616
+ is_file_update: z2.boolean()
621
617
  }),
622
- import_v42.z.object({
623
- type: import_v42.z.literal(
618
+ z2.object({
619
+ type: z2.literal(
624
620
  "text_editor_code_execution_str_replace_result"
625
621
  ),
626
- lines: import_v42.z.array(import_v42.z.string()).nullable(),
627
- new_lines: import_v42.z.number().nullable(),
628
- new_start: import_v42.z.number().nullable(),
629
- old_lines: import_v42.z.number().nullable(),
630
- old_start: import_v42.z.number().nullable()
622
+ lines: z2.array(z2.string()).nullable(),
623
+ new_lines: z2.number().nullable(),
624
+ new_start: z2.number().nullable(),
625
+ old_lines: z2.number().nullable(),
626
+ old_start: z2.number().nullable()
631
627
  })
632
628
  ])
633
629
  }),
634
630
  // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
635
- import_v42.z.object({
636
- type: import_v42.z.literal("tool_search_tool_result"),
637
- tool_use_id: import_v42.z.string(),
638
- content: import_v42.z.union([
639
- import_v42.z.object({
640
- type: import_v42.z.literal("tool_search_tool_search_result"),
641
- tool_references: import_v42.z.array(
642
- import_v42.z.object({
643
- type: import_v42.z.literal("tool_reference"),
644
- tool_name: import_v42.z.string()
631
+ z2.object({
632
+ type: z2.literal("tool_search_tool_result"),
633
+ tool_use_id: z2.string(),
634
+ content: z2.union([
635
+ z2.object({
636
+ type: z2.literal("tool_search_tool_search_result"),
637
+ tool_references: z2.array(
638
+ z2.object({
639
+ type: z2.literal("tool_reference"),
640
+ tool_name: z2.string()
645
641
  })
646
642
  )
647
643
  }),
648
- import_v42.z.object({
649
- type: import_v42.z.literal("tool_search_tool_result_error"),
650
- error_code: import_v42.z.string()
644
+ z2.object({
645
+ type: z2.literal("tool_search_tool_result_error"),
646
+ error_code: z2.string()
651
647
  })
652
648
  ])
653
649
  })
654
650
  ])
655
651
  }),
656
- import_v42.z.object({
657
- type: import_v42.z.literal("content_block_delta"),
658
- index: import_v42.z.number(),
659
- delta: import_v42.z.discriminatedUnion("type", [
660
- import_v42.z.object({
661
- type: import_v42.z.literal("input_json_delta"),
662
- partial_json: import_v42.z.string()
652
+ z2.object({
653
+ type: z2.literal("content_block_delta"),
654
+ index: z2.number(),
655
+ delta: z2.discriminatedUnion("type", [
656
+ z2.object({
657
+ type: z2.literal("input_json_delta"),
658
+ partial_json: z2.string()
663
659
  }),
664
- import_v42.z.object({
665
- type: import_v42.z.literal("text_delta"),
666
- text: import_v42.z.string()
660
+ z2.object({
661
+ type: z2.literal("text_delta"),
662
+ text: z2.string()
667
663
  }),
668
- import_v42.z.object({
669
- type: import_v42.z.literal("thinking_delta"),
670
- thinking: import_v42.z.string()
664
+ z2.object({
665
+ type: z2.literal("thinking_delta"),
666
+ thinking: z2.string()
671
667
  }),
672
- import_v42.z.object({
673
- type: import_v42.z.literal("signature_delta"),
674
- signature: import_v42.z.string()
668
+ z2.object({
669
+ type: z2.literal("signature_delta"),
670
+ signature: z2.string()
675
671
  }),
676
- import_v42.z.object({
677
- type: import_v42.z.literal("compaction_delta"),
678
- content: import_v42.z.string().nullish()
672
+ z2.object({
673
+ type: z2.literal("compaction_delta"),
674
+ content: z2.string().nullish()
679
675
  }),
680
- import_v42.z.object({
681
- type: import_v42.z.literal("citations_delta"),
682
- citation: import_v42.z.discriminatedUnion("type", [
683
- import_v42.z.object({
684
- type: import_v42.z.literal("web_search_result_location"),
685
- cited_text: import_v42.z.string(),
686
- url: import_v42.z.string(),
687
- title: import_v42.z.string(),
688
- encrypted_index: import_v42.z.string()
676
+ z2.object({
677
+ type: z2.literal("citations_delta"),
678
+ citation: z2.discriminatedUnion("type", [
679
+ z2.object({
680
+ type: z2.literal("web_search_result_location"),
681
+ cited_text: z2.string(),
682
+ url: z2.string(),
683
+ title: z2.string(),
684
+ encrypted_index: z2.string()
689
685
  }),
690
- import_v42.z.object({
691
- type: import_v42.z.literal("page_location"),
692
- cited_text: import_v42.z.string(),
693
- document_index: import_v42.z.number(),
694
- document_title: import_v42.z.string().nullable(),
695
- start_page_number: import_v42.z.number(),
696
- end_page_number: import_v42.z.number()
686
+ z2.object({
687
+ type: z2.literal("page_location"),
688
+ cited_text: z2.string(),
689
+ document_index: z2.number(),
690
+ document_title: z2.string().nullable(),
691
+ start_page_number: z2.number(),
692
+ end_page_number: z2.number()
697
693
  }),
698
- import_v42.z.object({
699
- type: import_v42.z.literal("char_location"),
700
- cited_text: import_v42.z.string(),
701
- document_index: import_v42.z.number(),
702
- document_title: import_v42.z.string().nullable(),
703
- start_char_index: import_v42.z.number(),
704
- end_char_index: import_v42.z.number()
694
+ z2.object({
695
+ type: z2.literal("char_location"),
696
+ cited_text: z2.string(),
697
+ document_index: z2.number(),
698
+ document_title: z2.string().nullable(),
699
+ start_char_index: z2.number(),
700
+ end_char_index: z2.number()
705
701
  })
706
702
  ])
707
703
  })
708
704
  ])
709
705
  }),
710
- import_v42.z.object({
711
- type: import_v42.z.literal("content_block_stop"),
712
- index: import_v42.z.number()
706
+ z2.object({
707
+ type: z2.literal("content_block_stop"),
708
+ index: z2.number()
713
709
  }),
714
- import_v42.z.object({
715
- type: import_v42.z.literal("error"),
716
- error: import_v42.z.object({
717
- type: import_v42.z.string(),
718
- message: import_v42.z.string()
710
+ z2.object({
711
+ type: z2.literal("error"),
712
+ error: z2.object({
713
+ type: z2.string(),
714
+ message: z2.string()
719
715
  })
720
716
  }),
721
- import_v42.z.object({
722
- type: import_v42.z.literal("message_delta"),
723
- delta: import_v42.z.object({
724
- stop_reason: import_v42.z.string().nullish(),
725
- stop_sequence: import_v42.z.string().nullish(),
726
- container: import_v42.z.object({
727
- expires_at: import_v42.z.string(),
728
- id: import_v42.z.string(),
729
- skills: import_v42.z.array(
730
- import_v42.z.object({
731
- type: import_v42.z.union([
732
- import_v42.z.literal("anthropic"),
733
- import_v42.z.literal("custom")
717
+ z2.object({
718
+ type: z2.literal("message_delta"),
719
+ delta: z2.object({
720
+ stop_reason: z2.string().nullish(),
721
+ stop_sequence: z2.string().nullish(),
722
+ container: z2.object({
723
+ expires_at: z2.string(),
724
+ id: z2.string(),
725
+ skills: z2.array(
726
+ z2.object({
727
+ type: z2.union([
728
+ z2.literal("anthropic"),
729
+ z2.literal("custom")
734
730
  ]),
735
- skill_id: import_v42.z.string(),
736
- version: import_v42.z.string()
731
+ skill_id: z2.string(),
732
+ version: z2.string()
737
733
  })
738
734
  ).nullish()
739
735
  }).nullish()
740
736
  }),
741
- usage: import_v42.z.looseObject({
742
- input_tokens: import_v42.z.number().nullish(),
743
- output_tokens: import_v42.z.number(),
744
- cache_creation_input_tokens: import_v42.z.number().nullish(),
745
- cache_read_input_tokens: import_v42.z.number().nullish(),
746
- iterations: import_v42.z.array(
747
- import_v42.z.object({
748
- type: import_v42.z.union([import_v42.z.literal("compaction"), import_v42.z.literal("message")]),
749
- input_tokens: import_v42.z.number(),
750
- output_tokens: import_v42.z.number()
737
+ usage: z2.looseObject({
738
+ input_tokens: z2.number().nullish(),
739
+ output_tokens: z2.number(),
740
+ cache_creation_input_tokens: z2.number().nullish(),
741
+ cache_read_input_tokens: z2.number().nullish(),
742
+ iterations: z2.array(
743
+ z2.object({
744
+ type: z2.union([z2.literal("compaction"), z2.literal("message")]),
745
+ input_tokens: z2.number(),
746
+ output_tokens: z2.number()
751
747
  })
752
748
  ).nullish()
753
749
  }),
754
- context_management: import_v42.z.object({
755
- applied_edits: import_v42.z.array(
756
- import_v42.z.union([
757
- import_v42.z.object({
758
- type: import_v42.z.literal("clear_tool_uses_20250919"),
759
- cleared_tool_uses: import_v42.z.number(),
760
- cleared_input_tokens: import_v42.z.number()
750
+ context_management: z2.object({
751
+ applied_edits: z2.array(
752
+ z2.union([
753
+ z2.object({
754
+ type: z2.literal("clear_tool_uses_20250919"),
755
+ cleared_tool_uses: z2.number(),
756
+ cleared_input_tokens: z2.number()
761
757
  }),
762
- import_v42.z.object({
763
- type: import_v42.z.literal("clear_thinking_20251015"),
764
- cleared_thinking_turns: import_v42.z.number(),
765
- cleared_input_tokens: import_v42.z.number()
758
+ z2.object({
759
+ type: z2.literal("clear_thinking_20251015"),
760
+ cleared_thinking_turns: z2.number(),
761
+ cleared_input_tokens: z2.number()
766
762
  }),
767
- import_v42.z.object({
768
- type: import_v42.z.literal("compact_20260112")
763
+ z2.object({
764
+ type: z2.literal("compact_20260112")
769
765
  })
770
766
  ])
771
767
  )
772
768
  }).nullish()
773
769
  }),
774
- import_v42.z.object({
775
- type: import_v42.z.literal("message_stop")
770
+ z2.object({
771
+ type: z2.literal("message_stop")
776
772
  }),
777
- import_v42.z.object({
778
- type: import_v42.z.literal("ping")
773
+ z2.object({
774
+ type: z2.literal("ping")
779
775
  })
780
776
  ])
781
777
  )
782
778
  );
783
- var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
784
- () => (0, import_provider_utils2.zodSchema)(
785
- import_v42.z.object({
786
- signature: import_v42.z.string().optional(),
787
- redactedData: import_v42.z.string().optional()
779
+ var anthropicReasoningMetadataSchema = lazySchema2(
780
+ () => zodSchema2(
781
+ z2.object({
782
+ signature: z2.string().optional(),
783
+ redactedData: z2.string().optional()
788
784
  })
789
785
  )
790
786
  );
791
787
 
792
- // src/anthropic-messages-options.ts
793
- var import_v43 = require("zod/v4");
794
- var anthropicFilePartProviderOptions = import_v43.z.object({
788
+ // src/anthropic-language-model-options.ts
789
+ import { z as z3 } from "zod/v4";
790
+ var anthropicFilePartProviderOptions = z3.object({
795
791
  /**
796
792
  * Citation configuration for this document.
797
793
  * When enabled, this document will generate citations in the response.
798
794
  */
799
- citations: import_v43.z.object({
795
+ citations: z3.object({
800
796
  /**
801
797
  * Enable citations for this document
802
798
  */
803
- enabled: import_v43.z.boolean()
799
+ enabled: z3.boolean()
804
800
  }).optional(),
805
801
  /**
806
802
  * Custom title for the document.
807
803
  * If not provided, the filename will be used.
808
804
  */
809
- title: import_v43.z.string().optional(),
805
+ title: z3.string().optional(),
810
806
  /**
811
807
  * Context about the document that will be passed to the model
812
808
  * but not used towards cited content.
813
809
  * Useful for storing document metadata as text or stringified JSON.
814
810
  */
815
- context: import_v43.z.string().optional()
811
+ context: z3.string().optional()
816
812
  });
817
- var anthropicLanguageModelOptions = import_v43.z.object({
813
+ var anthropicLanguageModelOptions = z3.object({
818
814
  /**
819
815
  * Whether to send reasoning to the model.
820
816
  *
821
817
  * This allows you to deactivate reasoning inputs for models that do not support them.
822
818
  */
823
- sendReasoning: import_v43.z.boolean().optional(),
819
+ sendReasoning: z3.boolean().optional(),
824
820
  /**
825
821
  * Determines how structured outputs are generated.
826
822
  *
@@ -828,64 +824,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
828
824
  * - `jsonTool`: Use a special 'json' tool to specify the structured output format.
829
825
  * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
830
826
  */
831
- structuredOutputMode: import_v43.z.enum(["outputFormat", "jsonTool", "auto"]).optional(),
827
+ structuredOutputMode: z3.enum(["outputFormat", "jsonTool", "auto"]).optional(),
832
828
  /**
833
829
  * Configuration for enabling Claude's extended thinking.
834
830
  *
835
831
  * When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
836
832
  * Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
837
833
  */
838
- thinking: import_v43.z.discriminatedUnion("type", [
839
- import_v43.z.object({
834
+ thinking: z3.discriminatedUnion("type", [
835
+ z3.object({
840
836
  /** for Sonnet 4.6, Opus 4.6, and newer models */
841
- type: import_v43.z.literal("adaptive"),
837
+ type: z3.literal("adaptive"),
842
838
  /**
843
- * Controls thinking output visibility.
844
- * - 'omitted': thinking happens but output is not returned (faster TTFT)
845
- * - 'summarized': a summary of the thinking is returned
839
+ * Controls whether thinking content is included in the response.
840
+ * - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
841
+ * - `"summarized"`: Thinking content is returned. Required to see reasoning output.
846
842
  */
847
- display: import_v43.z.enum(["omitted", "summarized"]).optional()
843
+ display: z3.enum(["omitted", "summarized"]).optional()
848
844
  }),
849
- import_v43.z.object({
845
+ z3.object({
850
846
  /** for models before Opus 4.6, except Sonnet 4.6 still supports it */
851
- type: import_v43.z.literal("enabled"),
852
- budgetTokens: import_v43.z.number().optional(),
853
- /**
854
- * Controls thinking output visibility.
855
- * - 'omitted': thinking happens but output is not returned (faster TTFT)
856
- * - 'summarized': a summary of the thinking is returned
857
- */
858
- display: import_v43.z.enum(["omitted", "summarized"]).optional()
847
+ type: z3.literal("enabled"),
848
+ budgetTokens: z3.number().optional()
859
849
  }),
860
- import_v43.z.object({
861
- type: import_v43.z.literal("disabled")
850
+ z3.object({
851
+ type: z3.literal("disabled")
862
852
  })
863
853
  ]).optional(),
864
854
  /**
865
855
  * Whether to disable parallel function calling during tool use. Default is false.
866
856
  * When set to true, Claude will use at most one tool per response.
867
857
  */
868
- disableParallelToolUse: import_v43.z.boolean().optional(),
858
+ disableParallelToolUse: z3.boolean().optional(),
869
859
  /**
870
860
  * Cache control settings for this message.
871
861
  * See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
872
862
  */
873
- cacheControl: import_v43.z.object({
874
- type: import_v43.z.literal("ephemeral"),
875
- ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
863
+ cacheControl: z3.object({
864
+ type: z3.literal("ephemeral"),
865
+ ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
866
+ }).optional(),
867
+ /**
868
+ * Metadata to include with the request.
869
+ *
870
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
871
+ */
872
+ metadata: z3.object({
873
+ /**
874
+ * An external identifier for the user associated with the request.
875
+ *
876
+ * Should be a UUID, hash value, or other opaque identifier.
877
+ * Must not contain PII (name, email, phone number, etc.).
878
+ */
879
+ userId: z3.string().optional()
876
880
  }).optional(),
877
881
  /**
878
882
  * MCP servers to be utilized in this request.
879
883
  */
880
- mcpServers: import_v43.z.array(
881
- import_v43.z.object({
882
- type: import_v43.z.literal("url"),
883
- name: import_v43.z.string(),
884
- url: import_v43.z.string(),
885
- authorizationToken: import_v43.z.string().nullish(),
886
- toolConfiguration: import_v43.z.object({
887
- enabled: import_v43.z.boolean().nullish(),
888
- allowedTools: import_v43.z.array(import_v43.z.string()).nullish()
884
+ mcpServers: z3.array(
885
+ z3.object({
886
+ type: z3.literal("url"),
887
+ name: z3.string(),
888
+ url: z3.string(),
889
+ authorizationToken: z3.string().nullish(),
890
+ toolConfiguration: z3.object({
891
+ enabled: z3.boolean().nullish(),
892
+ allowedTools: z3.array(z3.string()).nullish()
889
893
  }).nullish()
890
894
  })
891
895
  ).optional(),
@@ -894,105 +898,129 @@ var anthropicLanguageModelOptions = import_v43.z.object({
894
898
  * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
895
899
  * Requires code execution tool to be enabled.
896
900
  */
897
- container: import_v43.z.object({
898
- id: import_v43.z.string().optional(),
899
- skills: import_v43.z.array(
900
- import_v43.z.object({
901
- type: import_v43.z.union([import_v43.z.literal("anthropic"), import_v43.z.literal("custom")]),
902
- skillId: import_v43.z.string(),
903
- version: import_v43.z.string().optional()
904
- })
901
+ container: z3.object({
902
+ id: z3.string().optional(),
903
+ skills: z3.array(
904
+ z3.discriminatedUnion("type", [
905
+ z3.object({
906
+ type: z3.literal("anthropic"),
907
+ skillId: z3.string(),
908
+ version: z3.string().optional()
909
+ }),
910
+ z3.object({
911
+ type: z3.literal("custom"),
912
+ providerReference: z3.record(z3.string(), z3.string()),
913
+ version: z3.string().optional()
914
+ })
915
+ ])
905
916
  ).optional()
906
917
  }).optional(),
907
918
  /**
908
- * Whether to enable tool streaming (and structured output streaming).
909
- *
910
- * When set to false, the model will return all tool calls and results
911
- * at once after a delay.
919
+ * Whether to enable fine-grained (eager) streaming of tool call inputs
920
+ * and structured outputs for every function tool in the request. When
921
+ * true (the default), each function tool receives a default of
922
+ * `eager_input_streaming: true` unless it explicitly sets
923
+ * `providerOptions.anthropic.eagerInputStreaming`.
912
924
  *
913
925
  * @default true
914
926
  */
915
- toolStreaming: import_v43.z.boolean().optional(),
927
+ toolStreaming: z3.boolean().optional(),
916
928
  /**
917
929
  * @default 'high'
918
930
  */
919
- effort: import_v43.z.enum(["low", "medium", "high", "max"]).optional(),
931
+ effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
932
+ /**
933
+ * Task budget for agentic turns. Informs the model of the total token budget
934
+ * available for the current task, allowing it to prioritize work and wind down
935
+ * gracefully as the budget is consumed.
936
+ *
937
+ * Advisory only — does not enforce a hard token limit.
938
+ */
939
+ taskBudget: z3.object({
940
+ type: z3.literal("tokens"),
941
+ total: z3.number().int().min(2e4),
942
+ remaining: z3.number().int().min(0).optional()
943
+ }).optional(),
920
944
  /**
921
945
  * Enable fast mode for faster inference (2.5x faster output token speeds).
922
946
  * Only supported with claude-opus-4-6.
923
947
  */
924
- speed: import_v43.z.enum(["fast", "standard"]).optional(),
948
+ speed: z3.enum(["fast", "standard"]).optional(),
925
949
  /**
926
- * A set of beta features to enable.
927
- * Allow a provider to receive the full `betas` set if it needs it.
950
+ * Advisor tool configuration. When enabled, Claude consults a cheaper
951
+ * advisor model before generating its response, improving tool-use
952
+ * accuracy and reducing cost on complex agentic tasks.
953
+ *
954
+ * Requires the `advisor-tool-2026-03-01` beta header (added automatically).
928
955
  */
929
- anthropicBeta: import_v43.z.array(import_v43.z.string()).optional(),
956
+ advisor: z3.object({
957
+ /** The model ID for the advisor (e.g. "claude-haiku-4-5"). */
958
+ model: z3.string()
959
+ }).optional(),
930
960
  /**
931
- * Assistant prefill text. When set, this text is appended as a partial
932
- * assistant message at the end of the prompt, guiding the model's output.
933
- * The model will continue generating from where the prefill ends.
934
- *
935
- * Example: Setting prefill to '{"' will make the model start its response with '{"'
961
+ * Enable 300K output tokens per response (vs default ~8K/32K caps).
962
+ * When true, the `output-300k-2026-03-24` beta header is sent automatically
963
+ * and max_tokens capping is raised to 300,000.
936
964
  */
937
- prefill: import_v43.z.string().optional(),
965
+ output300k: z3.boolean().optional(),
938
966
  /**
939
- * Request metadata. Use `user_id` to track per-user usage for abuse detection
940
- * and rate limit apportioning. Should be a UUID or similar opaque identifier.
941
- * See https://docs.anthropic.com/en/api/messages
967
+ * Controls where model inference runs for this request.
968
+ *
969
+ * - `"global"`: Inference may run in any available geography (default).
970
+ * - `"us"`: Inference runs only in US-based infrastructure.
971
+ *
972
+ * See https://platform.claude.com/docs/en/build-with-claude/data-residency
942
973
  */
943
- metadata: import_v43.z.object({
944
- userId: import_v43.z.string().optional()
945
- }).optional(),
974
+ inferenceGeo: z3.enum(["us", "global"]).optional(),
946
975
  /**
947
- * Service tier selection.
948
- * - 'auto': Allow Anthropic to pick standard or priority based on availability.
949
- * See https://docs.anthropic.com/en/api/messages
976
+ * A set of beta features to enable.
977
+ * Allow a provider to receive the full `betas` set if it needs it.
950
978
  */
951
- serviceTier: import_v43.z.enum(["auto"]).optional(),
952
- contextManagement: import_v43.z.object({
953
- edits: import_v43.z.array(
954
- import_v43.z.discriminatedUnion("type", [
955
- import_v43.z.object({
956
- type: import_v43.z.literal("clear_tool_uses_20250919"),
957
- trigger: import_v43.z.discriminatedUnion("type", [
958
- import_v43.z.object({
959
- type: import_v43.z.literal("input_tokens"),
960
- value: import_v43.z.number()
979
+ anthropicBeta: z3.array(z3.string()).optional(),
980
+ contextManagement: z3.object({
981
+ edits: z3.array(
982
+ z3.discriminatedUnion("type", [
983
+ z3.object({
984
+ type: z3.literal("clear_tool_uses_20250919"),
985
+ trigger: z3.discriminatedUnion("type", [
986
+ z3.object({
987
+ type: z3.literal("input_tokens"),
988
+ value: z3.number()
961
989
  }),
962
- import_v43.z.object({
963
- type: import_v43.z.literal("tool_uses"),
964
- value: import_v43.z.number()
990
+ z3.object({
991
+ type: z3.literal("tool_uses"),
992
+ value: z3.number()
965
993
  })
966
994
  ]).optional(),
967
- keep: import_v43.z.object({
968
- type: import_v43.z.literal("tool_uses"),
969
- value: import_v43.z.number()
995
+ keep: z3.object({
996
+ type: z3.literal("tool_uses"),
997
+ value: z3.number()
970
998
  }).optional(),
971
- clearAtLeast: import_v43.z.object({
972
- type: import_v43.z.literal("input_tokens"),
973
- value: import_v43.z.number()
999
+ clearAtLeast: z3.object({
1000
+ type: z3.literal("input_tokens"),
1001
+ value: z3.number()
974
1002
  }).optional(),
975
- clearToolInputs: import_v43.z.boolean().optional(),
976
- excludeTools: import_v43.z.array(import_v43.z.string()).optional()
1003
+ clearToolInputs: z3.boolean().optional(),
1004
+ excludeTools: z3.array(z3.string()).optional()
977
1005
  }),
978
- import_v43.z.object({
979
- type: import_v43.z.literal("clear_thinking_20251015"),
980
- keep: import_v43.z.union([
981
- import_v43.z.literal("all"),
982
- import_v43.z.object({
983
- type: import_v43.z.literal("thinking_turns"),
984
- value: import_v43.z.number()
1006
+ z3.object({
1007
+ type: z3.literal("clear_thinking_20251015"),
1008
+ keep: z3.union([
1009
+ z3.literal("all"),
1010
+ z3.object({
1011
+ type: z3.literal("thinking_turns"),
1012
+ value: z3.number()
985
1013
  })
986
1014
  ]).optional()
987
1015
  }),
988
- import_v43.z.object({
989
- type: import_v43.z.literal("compact_20260112"),
990
- trigger: import_v43.z.object({
991
- type: import_v43.z.literal("input_tokens"),
992
- value: import_v43.z.number()
1016
+ z3.object({
1017
+ type: z3.literal("compact_20260112"),
1018
+ trigger: z3.object({
1019
+ type: z3.literal("input_tokens"),
1020
+ value: z3.number()
993
1021
  }).optional(),
994
- pauseAfterCompaction: import_v43.z.boolean().optional(),
995
- instructions: import_v43.z.string().optional()
1022
+ pauseAfterCompaction: z3.boolean().optional(),
1023
+ instructions: z3.string().optional()
996
1024
  })
997
1025
  ])
998
1026
  )
@@ -1000,7 +1028,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
1000
1028
  });
1001
1029
 
1002
1030
  // src/anthropic-prepare-tools.ts
1003
- var import_provider = require("@ai-sdk/provider");
1031
+ import {
1032
+ UnsupportedFunctionalityError
1033
+ } from "@ai-sdk/provider";
1004
1034
 
1005
1035
  // src/get-cache-control.ts
1006
1036
  var MAX_CACHE_BREAKPOINTS = 4;
@@ -1045,31 +1075,34 @@ var CacheControlValidator = class {
1045
1075
  };
1046
1076
 
1047
1077
  // src/tool/text-editor_20250728.ts
1048
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
1049
- var import_v44 = require("zod/v4");
1050
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
1051
- var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
1052
- () => (0, import_provider_utils4.zodSchema)(
1053
- import_v44.z.object({
1054
- maxCharacters: import_v44.z.number().optional()
1078
+ import {
1079
+ createProviderDefinedToolFactory,
1080
+ lazySchema as lazySchema3,
1081
+ zodSchema as zodSchema3
1082
+ } from "@ai-sdk/provider-utils";
1083
+ import { z as z4 } from "zod/v4";
1084
+ var textEditor_20250728ArgsSchema = lazySchema3(
1085
+ () => zodSchema3(
1086
+ z4.object({
1087
+ maxCharacters: z4.number().optional()
1055
1088
  })
1056
1089
  )
1057
1090
  );
1058
- var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
1059
- () => (0, import_provider_utils4.zodSchema)(
1060
- import_v44.z.object({
1061
- command: import_v44.z.enum(["view", "create", "str_replace", "insert"]),
1062
- path: import_v44.z.string(),
1063
- file_text: import_v44.z.string().optional(),
1064
- insert_line: import_v44.z.number().int().optional(),
1065
- new_str: import_v44.z.string().optional(),
1066
- insert_text: import_v44.z.string().optional(),
1067
- old_str: import_v44.z.string().optional(),
1068
- view_range: import_v44.z.array(import_v44.z.number().int()).optional()
1091
+ var textEditor_20250728InputSchema = lazySchema3(
1092
+ () => zodSchema3(
1093
+ z4.object({
1094
+ command: z4.enum(["view", "create", "str_replace", "insert"]),
1095
+ path: z4.string(),
1096
+ file_text: z4.string().optional(),
1097
+ insert_line: z4.number().int().optional(),
1098
+ new_str: z4.string().optional(),
1099
+ insert_text: z4.string().optional(),
1100
+ old_str: z4.string().optional(),
1101
+ view_range: z4.array(z4.number().int()).optional()
1069
1102
  })
1070
1103
  )
1071
1104
  );
1072
- var factory = (0, import_provider_utils3.createProviderToolFactory)({
1105
+ var factory = createProviderDefinedToolFactory({
1073
1106
  id: "anthropic.text_editor_20250728",
1074
1107
  inputSchema: textEditor_20250728InputSchema
1075
1108
  });
@@ -1078,45 +1111,56 @@ var textEditor_20250728 = (args = {}) => {
1078
1111
  };
1079
1112
 
1080
1113
  // src/tool/web-search_20260209.ts
1081
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1082
- var import_v45 = require("zod/v4");
1083
- var webSearch_20260209ArgsSchema = (0, import_provider_utils5.lazySchema)(
1084
- () => (0, import_provider_utils5.zodSchema)(
1085
- import_v45.z.object({
1086
- maxUses: import_v45.z.number().optional(),
1087
- allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
1088
- blockedDomains: import_v45.z.array(import_v45.z.string()).optional(),
1089
- userLocation: import_v45.z.object({
1090
- type: import_v45.z.literal("approximate"),
1091
- city: import_v45.z.string().optional(),
1092
- region: import_v45.z.string().optional(),
1093
- country: import_v45.z.string().optional(),
1094
- timezone: import_v45.z.string().optional()
1095
- }).optional()
1114
+ import {
1115
+ createProviderExecutedToolFactory,
1116
+ lazySchema as lazySchema4,
1117
+ zodSchema as zodSchema4
1118
+ } from "@ai-sdk/provider-utils";
1119
+ import { z as z5 } from "zod/v4";
1120
+ var webSearch_20260209ArgsSchema = lazySchema4(
1121
+ () => zodSchema4(
1122
+ z5.object({
1123
+ maxUses: z5.number().optional(),
1124
+ allowedDomains: z5.array(z5.string()).optional(),
1125
+ blockedDomains: z5.array(z5.string()).optional(),
1126
+ userLocation: z5.object({
1127
+ type: z5.literal("approximate"),
1128
+ city: z5.string().optional(),
1129
+ region: z5.string().optional(),
1130
+ country: z5.string().optional(),
1131
+ timezone: z5.string().optional()
1132
+ }).optional(),
1133
+ allowedCallers: z5.array(
1134
+ z5.enum([
1135
+ "direct",
1136
+ "code_execution_20250825",
1137
+ "code_execution_20260120"
1138
+ ])
1139
+ ).optional()
1096
1140
  })
1097
1141
  )
1098
1142
  );
1099
- var webSearch_20260209OutputSchema = (0, import_provider_utils5.lazySchema)(
1100
- () => (0, import_provider_utils5.zodSchema)(
1101
- import_v45.z.array(
1102
- import_v45.z.object({
1103
- url: import_v45.z.string(),
1104
- title: import_v45.z.string().nullable(),
1105
- pageAge: import_v45.z.string().nullable(),
1106
- encryptedContent: import_v45.z.string(),
1107
- type: import_v45.z.literal("web_search_result")
1143
+ var webSearch_20260209OutputSchema = lazySchema4(
1144
+ () => zodSchema4(
1145
+ z5.array(
1146
+ z5.object({
1147
+ url: z5.string(),
1148
+ title: z5.string().nullable(),
1149
+ pageAge: z5.string().nullable(),
1150
+ encryptedContent: z5.string(),
1151
+ type: z5.literal("web_search_result")
1108
1152
  })
1109
1153
  )
1110
1154
  )
1111
1155
  );
1112
- var webSearch_20260209InputSchema = (0, import_provider_utils5.lazySchema)(
1113
- () => (0, import_provider_utils5.zodSchema)(
1114
- import_v45.z.object({
1115
- query: import_v45.z.string()
1156
+ var webSearch_20260209InputSchema = lazySchema4(
1157
+ () => zodSchema4(
1158
+ z5.object({
1159
+ query: z5.string()
1116
1160
  })
1117
1161
  )
1118
1162
  );
1119
- var factory2 = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
1163
+ var factory2 = createProviderExecutedToolFactory({
1120
1164
  id: "anthropic.web_search_20260209",
1121
1165
  inputSchema: webSearch_20260209InputSchema,
1122
1166
  outputSchema: webSearch_20260209OutputSchema,
@@ -1127,45 +1171,49 @@ var webSearch_20260209 = (args = {}) => {
1127
1171
  };
1128
1172
 
1129
1173
  // src/tool/web-search_20250305.ts
1130
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1131
- var import_v46 = require("zod/v4");
1132
- var webSearch_20250305ArgsSchema = (0, import_provider_utils6.lazySchema)(
1133
- () => (0, import_provider_utils6.zodSchema)(
1134
- import_v46.z.object({
1135
- maxUses: import_v46.z.number().optional(),
1136
- allowedDomains: import_v46.z.array(import_v46.z.string()).optional(),
1137
- blockedDomains: import_v46.z.array(import_v46.z.string()).optional(),
1138
- userLocation: import_v46.z.object({
1139
- type: import_v46.z.literal("approximate"),
1140
- city: import_v46.z.string().optional(),
1141
- region: import_v46.z.string().optional(),
1142
- country: import_v46.z.string().optional(),
1143
- timezone: import_v46.z.string().optional()
1174
+ import {
1175
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
1176
+ lazySchema as lazySchema5,
1177
+ zodSchema as zodSchema5
1178
+ } from "@ai-sdk/provider-utils";
1179
+ import { z as z6 } from "zod/v4";
1180
+ var webSearch_20250305ArgsSchema = lazySchema5(
1181
+ () => zodSchema5(
1182
+ z6.object({
1183
+ maxUses: z6.number().optional(),
1184
+ allowedDomains: z6.array(z6.string()).optional(),
1185
+ blockedDomains: z6.array(z6.string()).optional(),
1186
+ userLocation: z6.object({
1187
+ type: z6.literal("approximate"),
1188
+ city: z6.string().optional(),
1189
+ region: z6.string().optional(),
1190
+ country: z6.string().optional(),
1191
+ timezone: z6.string().optional()
1144
1192
  }).optional()
1145
1193
  })
1146
1194
  )
1147
1195
  );
1148
- var webSearch_20250305OutputSchema = (0, import_provider_utils6.lazySchema)(
1149
- () => (0, import_provider_utils6.zodSchema)(
1150
- import_v46.z.array(
1151
- import_v46.z.object({
1152
- url: import_v46.z.string(),
1153
- title: import_v46.z.string().nullable(),
1154
- pageAge: import_v46.z.string().nullable(),
1155
- encryptedContent: import_v46.z.string(),
1156
- type: import_v46.z.literal("web_search_result")
1196
+ var webSearch_20250305OutputSchema = lazySchema5(
1197
+ () => zodSchema5(
1198
+ z6.array(
1199
+ z6.object({
1200
+ url: z6.string(),
1201
+ title: z6.string().nullable(),
1202
+ pageAge: z6.string().nullable(),
1203
+ encryptedContent: z6.string(),
1204
+ type: z6.literal("web_search_result")
1157
1205
  })
1158
1206
  )
1159
1207
  )
1160
1208
  );
1161
- var webSearch_20250305InputSchema = (0, import_provider_utils6.lazySchema)(
1162
- () => (0, import_provider_utils6.zodSchema)(
1163
- import_v46.z.object({
1164
- query: import_v46.z.string()
1209
+ var webSearch_20250305InputSchema = lazySchema5(
1210
+ () => zodSchema5(
1211
+ z6.object({
1212
+ query: z6.string()
1165
1213
  })
1166
1214
  )
1167
1215
  );
1168
- var factory3 = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
1216
+ var factory3 = createProviderExecutedToolFactory2({
1169
1217
  id: "anthropic.web_search_20250305",
1170
1218
  inputSchema: webSearch_20250305InputSchema,
1171
1219
  outputSchema: webSearch_20250305OutputSchema,
@@ -1175,131 +1223,210 @@ var webSearch_20250305 = (args = {}) => {
1175
1223
  return factory3(args);
1176
1224
  };
1177
1225
 
1226
+ // src/tool/web-fetch-20260309.ts
1227
+ import {
1228
+ createProviderDefinedToolFactoryWithOutputSchema,
1229
+ lazySchema as lazySchema6,
1230
+ zodSchema as zodSchema6
1231
+ } from "@ai-sdk/provider-utils";
1232
+ import { z as z7 } from "zod/v4";
1233
+ var webFetch_20260309ArgsSchema = lazySchema6(
1234
+ () => zodSchema6(
1235
+ z7.object({
1236
+ maxUses: z7.number().optional(),
1237
+ allowedDomains: z7.array(z7.string()).optional(),
1238
+ blockedDomains: z7.array(z7.string()).optional(),
1239
+ citations: z7.object({ enabled: z7.boolean() }).optional(),
1240
+ maxContentTokens: z7.number().optional(),
1241
+ allowedCallers: z7.array(
1242
+ z7.enum([
1243
+ "direct",
1244
+ "code_execution_20250825",
1245
+ "code_execution_20260120"
1246
+ ])
1247
+ ).optional(),
1248
+ useCache: z7.boolean().optional(),
1249
+ deferLoading: z7.boolean().optional(),
1250
+ strict: z7.boolean().optional()
1251
+ })
1252
+ )
1253
+ );
1254
+ var webFetch_20260309OutputSchema = lazySchema6(
1255
+ () => zodSchema6(
1256
+ z7.object({
1257
+ type: z7.literal("web_fetch_result"),
1258
+ url: z7.string(),
1259
+ content: z7.object({
1260
+ type: z7.literal("document"),
1261
+ title: z7.string().nullable(),
1262
+ citations: z7.object({ enabled: z7.boolean() }).optional(),
1263
+ source: z7.union([
1264
+ z7.object({
1265
+ type: z7.literal("base64"),
1266
+ mediaType: z7.literal("application/pdf"),
1267
+ data: z7.string()
1268
+ }),
1269
+ z7.object({
1270
+ type: z7.literal("text"),
1271
+ mediaType: z7.literal("text/plain"),
1272
+ data: z7.string()
1273
+ })
1274
+ ])
1275
+ }),
1276
+ retrievedAt: z7.string().nullable()
1277
+ })
1278
+ )
1279
+ );
1280
+ var webFetch_20260309InputSchema = lazySchema6(
1281
+ () => zodSchema6(
1282
+ z7.object({
1283
+ url: z7.string()
1284
+ })
1285
+ )
1286
+ );
1287
+ var factory4 = createProviderDefinedToolFactoryWithOutputSchema({
1288
+ id: "anthropic.web_fetch_20260309",
1289
+ inputSchema: webFetch_20260309InputSchema,
1290
+ outputSchema: webFetch_20260309OutputSchema
1291
+ });
1292
+ var webFetch_20260309 = (args = {}) => {
1293
+ return factory4(args);
1294
+ };
1295
+
1178
1296
  // src/tool/web-fetch-20260209.ts
1179
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1180
- var import_v47 = require("zod/v4");
1181
- var webFetch_20260209ArgsSchema = (0, import_provider_utils7.lazySchema)(
1182
- () => (0, import_provider_utils7.zodSchema)(
1183
- import_v47.z.object({
1184
- maxUses: import_v47.z.number().optional(),
1185
- allowedDomains: import_v47.z.array(import_v47.z.string()).optional(),
1186
- blockedDomains: import_v47.z.array(import_v47.z.string()).optional(),
1187
- citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
1188
- maxContentTokens: import_v47.z.number().optional()
1297
+ import {
1298
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
1299
+ lazySchema as lazySchema7,
1300
+ zodSchema as zodSchema7
1301
+ } from "@ai-sdk/provider-utils";
1302
+ import { z as z8 } from "zod/v4";
1303
+ var webFetch_20260209ArgsSchema = lazySchema7(
1304
+ () => zodSchema7(
1305
+ z8.object({
1306
+ maxUses: z8.number().optional(),
1307
+ allowedDomains: z8.array(z8.string()).optional(),
1308
+ blockedDomains: z8.array(z8.string()).optional(),
1309
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1310
+ maxContentTokens: z8.number().optional()
1189
1311
  })
1190
1312
  )
1191
1313
  );
1192
- var webFetch_20260209OutputSchema = (0, import_provider_utils7.lazySchema)(
1193
- () => (0, import_provider_utils7.zodSchema)(
1194
- import_v47.z.object({
1195
- type: import_v47.z.literal("web_fetch_result"),
1196
- url: import_v47.z.string(),
1197
- content: import_v47.z.object({
1198
- type: import_v47.z.literal("document"),
1199
- title: import_v47.z.string().nullable(),
1200
- citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
1201
- source: import_v47.z.union([
1202
- import_v47.z.object({
1203
- type: import_v47.z.literal("base64"),
1204
- mediaType: import_v47.z.literal("application/pdf"),
1205
- data: import_v47.z.string()
1314
+ var webFetch_20260209OutputSchema = lazySchema7(
1315
+ () => zodSchema7(
1316
+ z8.object({
1317
+ type: z8.literal("web_fetch_result"),
1318
+ url: z8.string(),
1319
+ content: z8.object({
1320
+ type: z8.literal("document"),
1321
+ title: z8.string().nullable(),
1322
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1323
+ source: z8.union([
1324
+ z8.object({
1325
+ type: z8.literal("base64"),
1326
+ mediaType: z8.literal("application/pdf"),
1327
+ data: z8.string()
1206
1328
  }),
1207
- import_v47.z.object({
1208
- type: import_v47.z.literal("text"),
1209
- mediaType: import_v47.z.literal("text/plain"),
1210
- data: import_v47.z.string()
1329
+ z8.object({
1330
+ type: z8.literal("text"),
1331
+ mediaType: z8.literal("text/plain"),
1332
+ data: z8.string()
1211
1333
  })
1212
1334
  ])
1213
1335
  }),
1214
- retrievedAt: import_v47.z.string().nullable()
1336
+ retrievedAt: z8.string().nullable()
1215
1337
  })
1216
1338
  )
1217
1339
  );
1218
- var webFetch_20260209InputSchema = (0, import_provider_utils7.lazySchema)(
1219
- () => (0, import_provider_utils7.zodSchema)(
1220
- import_v47.z.object({
1221
- url: import_v47.z.string()
1340
+ var webFetch_20260209InputSchema = lazySchema7(
1341
+ () => zodSchema7(
1342
+ z8.object({
1343
+ url: z8.string()
1222
1344
  })
1223
1345
  )
1224
1346
  );
1225
- var factory4 = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
1347
+ var factory5 = createProviderExecutedToolFactory3({
1226
1348
  id: "anthropic.web_fetch_20260209",
1227
1349
  inputSchema: webFetch_20260209InputSchema,
1228
1350
  outputSchema: webFetch_20260209OutputSchema,
1229
1351
  supportsDeferredResults: true
1230
1352
  });
1231
1353
  var webFetch_20260209 = (args = {}) => {
1232
- return factory4(args);
1354
+ return factory5(args);
1233
1355
  };
1234
1356
 
1235
1357
  // src/tool/web-fetch-20250910.ts
1236
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1237
- var import_v48 = require("zod/v4");
1238
- var webFetch_20250910ArgsSchema = (0, import_provider_utils8.lazySchema)(
1239
- () => (0, import_provider_utils8.zodSchema)(
1240
- import_v48.z.object({
1241
- maxUses: import_v48.z.number().optional(),
1242
- allowedDomains: import_v48.z.array(import_v48.z.string()).optional(),
1243
- blockedDomains: import_v48.z.array(import_v48.z.string()).optional(),
1244
- citations: import_v48.z.object({ enabled: import_v48.z.boolean() }).optional(),
1245
- maxContentTokens: import_v48.z.number().optional()
1358
+ import {
1359
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
1360
+ lazySchema as lazySchema8,
1361
+ zodSchema as zodSchema8
1362
+ } from "@ai-sdk/provider-utils";
1363
+ import { z as z9 } from "zod/v4";
1364
+ var webFetch_20250910ArgsSchema = lazySchema8(
1365
+ () => zodSchema8(
1366
+ z9.object({
1367
+ maxUses: z9.number().optional(),
1368
+ allowedDomains: z9.array(z9.string()).optional(),
1369
+ blockedDomains: z9.array(z9.string()).optional(),
1370
+ citations: z9.object({ enabled: z9.boolean() }).optional(),
1371
+ maxContentTokens: z9.number().optional()
1246
1372
  })
1247
1373
  )
1248
1374
  );
1249
- var webFetch_20250910OutputSchema = (0, import_provider_utils8.lazySchema)(
1250
- () => (0, import_provider_utils8.zodSchema)(
1251
- import_v48.z.object({
1252
- type: import_v48.z.literal("web_fetch_result"),
1253
- url: import_v48.z.string(),
1254
- content: import_v48.z.object({
1255
- type: import_v48.z.literal("document"),
1256
- title: import_v48.z.string().nullable(),
1257
- citations: import_v48.z.object({ enabled: import_v48.z.boolean() }).optional(),
1258
- source: import_v48.z.union([
1259
- import_v48.z.object({
1260
- type: import_v48.z.literal("base64"),
1261
- mediaType: import_v48.z.literal("application/pdf"),
1262
- data: import_v48.z.string()
1375
+ var webFetch_20250910OutputSchema = lazySchema8(
1376
+ () => zodSchema8(
1377
+ z9.object({
1378
+ type: z9.literal("web_fetch_result"),
1379
+ url: z9.string(),
1380
+ content: z9.object({
1381
+ type: z9.literal("document"),
1382
+ title: z9.string().nullable(),
1383
+ citations: z9.object({ enabled: z9.boolean() }).optional(),
1384
+ source: z9.union([
1385
+ z9.object({
1386
+ type: z9.literal("base64"),
1387
+ mediaType: z9.literal("application/pdf"),
1388
+ data: z9.string()
1263
1389
  }),
1264
- import_v48.z.object({
1265
- type: import_v48.z.literal("text"),
1266
- mediaType: import_v48.z.literal("text/plain"),
1267
- data: import_v48.z.string()
1390
+ z9.object({
1391
+ type: z9.literal("text"),
1392
+ mediaType: z9.literal("text/plain"),
1393
+ data: z9.string()
1268
1394
  })
1269
1395
  ])
1270
1396
  }),
1271
- retrievedAt: import_v48.z.string().nullable()
1397
+ retrievedAt: z9.string().nullable()
1272
1398
  })
1273
1399
  )
1274
1400
  );
1275
- var webFetch_20250910InputSchema = (0, import_provider_utils8.lazySchema)(
1276
- () => (0, import_provider_utils8.zodSchema)(
1277
- import_v48.z.object({
1278
- url: import_v48.z.string()
1401
+ var webFetch_20250910InputSchema = lazySchema8(
1402
+ () => zodSchema8(
1403
+ z9.object({
1404
+ url: z9.string()
1279
1405
  })
1280
1406
  )
1281
1407
  );
1282
- var factory5 = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
1408
+ var factory6 = createProviderExecutedToolFactory4({
1283
1409
  id: "anthropic.web_fetch_20250910",
1284
1410
  inputSchema: webFetch_20250910InputSchema,
1285
1411
  outputSchema: webFetch_20250910OutputSchema,
1286
1412
  supportsDeferredResults: true
1287
1413
  });
1288
1414
  var webFetch_20250910 = (args = {}) => {
1289
- return factory5(args);
1415
+ return factory6(args);
1290
1416
  };
1291
1417
 
1292
1418
  // src/anthropic-prepare-tools.ts
1293
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1419
+ import { validateTypes } from "@ai-sdk/provider-utils";
1294
1420
  async function prepareTools({
1295
1421
  tools,
1296
1422
  toolChoice,
1297
1423
  disableParallelToolUse,
1298
1424
  cacheControlValidator,
1299
1425
  supportsStructuredOutput,
1300
- supportsStrictTools
1426
+ supportsStrictTools,
1427
+ defaultEagerInputStreaming = false
1301
1428
  }) {
1302
- var _a;
1429
+ var _a, _b, _c;
1303
1430
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
1304
1431
  const toolWarnings = [];
1305
1432
  const betas = /* @__PURE__ */ new Set();
@@ -1316,7 +1443,7 @@ async function prepareTools({
1316
1443
  canCache: true
1317
1444
  });
1318
1445
  const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
1319
- const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
1446
+ const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
1320
1447
  const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
1321
1448
  const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
1322
1449
  if (!supportsStrictTools && tool.strict != null) {
@@ -1350,28 +1477,33 @@ async function prepareTools({
1350
1477
  break;
1351
1478
  }
1352
1479
  case "provider": {
1480
+ const providerCacheControl = (_c = validator.getCacheControl(tool.providerOptions, {
1481
+ type: "tool definition",
1482
+ canCache: true
1483
+ })) != null ? _c : void 0;
1353
1484
  switch (tool.id) {
1354
1485
  case "anthropic.code_execution_20250522": {
1355
1486
  betas.add("code-execution-2025-05-22");
1356
1487
  anthropicTools2.push({
1357
1488
  type: "code_execution_20250522",
1358
1489
  name: "code_execution",
1359
- cache_control: void 0
1490
+ cache_control: providerCacheControl
1360
1491
  });
1361
1492
  break;
1362
1493
  }
1363
1494
  case "anthropic.code_execution_20250825": {
1364
- betas.add("code-execution-2025-08-25");
1365
1495
  anthropicTools2.push({
1366
1496
  type: "code_execution_20250825",
1367
- name: "code_execution"
1497
+ name: "code_execution",
1498
+ cache_control: providerCacheControl
1368
1499
  });
1369
1500
  break;
1370
1501
  }
1371
1502
  case "anthropic.code_execution_20260120": {
1372
1503
  anthropicTools2.push({
1373
1504
  type: "code_execution_20260120",
1374
- name: "code_execution"
1505
+ name: "code_execution",
1506
+ cache_control: providerCacheControl
1375
1507
  });
1376
1508
  break;
1377
1509
  }
@@ -1383,7 +1515,7 @@ async function prepareTools({
1383
1515
  display_width_px: tool.args.displayWidthPx,
1384
1516
  display_height_px: tool.args.displayHeightPx,
1385
1517
  display_number: tool.args.displayNumber,
1386
- cache_control: void 0
1518
+ cache_control: providerCacheControl
1387
1519
  });
1388
1520
  break;
1389
1521
  }
@@ -1396,7 +1528,7 @@ async function prepareTools({
1396
1528
  display_height_px: tool.args.displayHeightPx,
1397
1529
  display_number: tool.args.displayNumber,
1398
1530
  enable_zoom: tool.args.enableZoom,
1399
- cache_control: void 0
1531
+ cache_control: providerCacheControl
1400
1532
  });
1401
1533
  break;
1402
1534
  }
@@ -1408,7 +1540,7 @@ async function prepareTools({
1408
1540
  display_width_px: tool.args.displayWidthPx,
1409
1541
  display_height_px: tool.args.displayHeightPx,
1410
1542
  display_number: tool.args.displayNumber,
1411
- cache_control: void 0
1543
+ cache_control: providerCacheControl
1412
1544
  });
1413
1545
  break;
1414
1546
  }
@@ -1417,7 +1549,7 @@ async function prepareTools({
1417
1549
  anthropicTools2.push({
1418
1550
  name: "str_replace_editor",
1419
1551
  type: "text_editor_20250124",
1420
- cache_control: void 0
1552
+ cache_control: providerCacheControl
1421
1553
  });
1422
1554
  break;
1423
1555
  }
@@ -1426,7 +1558,7 @@ async function prepareTools({
1426
1558
  anthropicTools2.push({
1427
1559
  name: "str_replace_editor",
1428
1560
  type: "text_editor_20241022",
1429
- cache_control: void 0
1561
+ cache_control: providerCacheControl
1430
1562
  });
1431
1563
  break;
1432
1564
  }
@@ -1435,12 +1567,12 @@ async function prepareTools({
1435
1567
  anthropicTools2.push({
1436
1568
  name: "str_replace_based_edit_tool",
1437
1569
  type: "text_editor_20250429",
1438
- cache_control: void 0
1570
+ cache_control: providerCacheControl
1439
1571
  });
1440
1572
  break;
1441
1573
  }
1442
1574
  case "anthropic.text_editor_20250728": {
1443
- const args = await (0, import_provider_utils9.validateTypes)({
1575
+ const args = await validateTypes({
1444
1576
  value: tool.args,
1445
1577
  schema: textEditor_20250728ArgsSchema
1446
1578
  });
@@ -1448,7 +1580,7 @@ async function prepareTools({
1448
1580
  name: "str_replace_based_edit_tool",
1449
1581
  type: "text_editor_20250728",
1450
1582
  max_characters: args.maxCharacters,
1451
- cache_control: void 0
1583
+ cache_control: providerCacheControl
1452
1584
  });
1453
1585
  break;
1454
1586
  }
@@ -1457,7 +1589,7 @@ async function prepareTools({
1457
1589
  anthropicTools2.push({
1458
1590
  name: "bash",
1459
1591
  type: "bash_20250124",
1460
- cache_control: void 0
1592
+ cache_control: providerCacheControl
1461
1593
  });
1462
1594
  break;
1463
1595
  }
@@ -1466,7 +1598,7 @@ async function prepareTools({
1466
1598
  anthropicTools2.push({
1467
1599
  name: "bash",
1468
1600
  type: "bash_20241022",
1469
- cache_control: void 0
1601
+ cache_control: providerCacheControl
1470
1602
  });
1471
1603
  break;
1472
1604
  }
@@ -1474,13 +1606,13 @@ async function prepareTools({
1474
1606
  betas.add("context-management-2025-06-27");
1475
1607
  anthropicTools2.push({
1476
1608
  name: "memory",
1477
- type: "memory_20250818"
1609
+ type: "memory_20250818",
1610
+ cache_control: providerCacheControl
1478
1611
  });
1479
1612
  break;
1480
1613
  }
1481
1614
  case "anthropic.web_fetch_20250910": {
1482
- betas.add("web-fetch-2025-09-10");
1483
- const args = await (0, import_provider_utils9.validateTypes)({
1615
+ const args = await validateTypes({
1484
1616
  value: tool.args,
1485
1617
  schema: webFetch_20250910ArgsSchema
1486
1618
  });
@@ -1492,13 +1624,12 @@ async function prepareTools({
1492
1624
  blocked_domains: args.blockedDomains,
1493
1625
  citations: args.citations,
1494
1626
  max_content_tokens: args.maxContentTokens,
1495
- cache_control: void 0
1627
+ cache_control: providerCacheControl
1496
1628
  });
1497
1629
  break;
1498
1630
  }
1499
1631
  case "anthropic.web_fetch_20260209": {
1500
- betas.add("code-execution-web-tools-2026-02-09");
1501
- const args = await (0, import_provider_utils9.validateTypes)({
1632
+ const args = await validateTypes({
1502
1633
  value: tool.args,
1503
1634
  schema: webFetch_20260209ArgsSchema
1504
1635
  });
@@ -1510,12 +1641,33 @@ async function prepareTools({
1510
1641
  blocked_domains: args.blockedDomains,
1511
1642
  citations: args.citations,
1512
1643
  max_content_tokens: args.maxContentTokens,
1513
- cache_control: void 0
1644
+ cache_control: providerCacheControl
1645
+ });
1646
+ break;
1647
+ }
1648
+ case "anthropic.web_fetch_20260309": {
1649
+ const args = await validateTypes({
1650
+ value: tool.args,
1651
+ schema: webFetch_20260309ArgsSchema
1652
+ });
1653
+ anthropicTools2.push({
1654
+ type: "web_fetch_20260309",
1655
+ name: "web_fetch",
1656
+ max_uses: args.maxUses,
1657
+ allowed_domains: args.allowedDomains,
1658
+ blocked_domains: args.blockedDomains,
1659
+ citations: args.citations,
1660
+ max_content_tokens: args.maxContentTokens,
1661
+ allowed_callers: args.allowedCallers,
1662
+ use_cache: args.useCache,
1663
+ defer_loading: args.deferLoading,
1664
+ strict: args.strict,
1665
+ cache_control: providerCacheControl
1514
1666
  });
1515
1667
  break;
1516
1668
  }
1517
1669
  case "anthropic.web_search_20250305": {
1518
- const args = await (0, import_provider_utils9.validateTypes)({
1670
+ const args = await validateTypes({
1519
1671
  value: tool.args,
1520
1672
  schema: webSearch_20250305ArgsSchema
1521
1673
  });
@@ -1526,13 +1678,12 @@ async function prepareTools({
1526
1678
  allowed_domains: args.allowedDomains,
1527
1679
  blocked_domains: args.blockedDomains,
1528
1680
  user_location: args.userLocation,
1529
- cache_control: void 0
1681
+ cache_control: providerCacheControl
1530
1682
  });
1531
1683
  break;
1532
1684
  }
1533
1685
  case "anthropic.web_search_20260209": {
1534
- betas.add("code-execution-web-tools-2026-02-09");
1535
- const args = await (0, import_provider_utils9.validateTypes)({
1686
+ const args = await validateTypes({
1536
1687
  value: tool.args,
1537
1688
  schema: webSearch_20260209ArgsSchema
1538
1689
  });
@@ -1543,21 +1694,24 @@ async function prepareTools({
1543
1694
  allowed_domains: args.allowedDomains,
1544
1695
  blocked_domains: args.blockedDomains,
1545
1696
  user_location: args.userLocation,
1546
- cache_control: void 0
1697
+ allowed_callers: args.allowedCallers,
1698
+ cache_control: providerCacheControl
1547
1699
  });
1548
1700
  break;
1549
1701
  }
1550
1702
  case "anthropic.tool_search_regex_20251119": {
1551
1703
  anthropicTools2.push({
1552
1704
  type: "tool_search_tool_regex_20251119",
1553
- name: "tool_search_tool_regex"
1705
+ name: "tool_search_tool_regex",
1706
+ cache_control: providerCacheControl
1554
1707
  });
1555
1708
  break;
1556
1709
  }
1557
1710
  case "anthropic.tool_search_bm25_20251119": {
1558
1711
  anthropicTools2.push({
1559
1712
  type: "tool_search_tool_bm25_20251119",
1560
- name: "tool_search_tool_bm25"
1713
+ name: "tool_search_tool_bm25",
1714
+ cache_control: providerCacheControl
1561
1715
  });
1562
1716
  break;
1563
1717
  }
@@ -1625,15 +1779,15 @@ async function prepareTools({
1625
1779
  };
1626
1780
  default: {
1627
1781
  const _exhaustiveCheck = type;
1628
- throw new import_provider.UnsupportedFunctionalityError({
1782
+ throw new UnsupportedFunctionalityError({
1629
1783
  functionality: `tool choice type: ${_exhaustiveCheck}`
1630
1784
  });
1631
1785
  }
1632
1786
  }
1633
1787
  }
1634
1788
 
1635
- // src/convert-anthropic-messages-usage.ts
1636
- function convertAnthropicMessagesUsage({
1789
+ // src/convert-anthropic-usage.ts
1790
+ function convertAnthropicUsage({
1637
1791
  usage,
1638
1792
  rawUsage
1639
1793
  }) {
@@ -1672,142 +1826,161 @@ function convertAnthropicMessagesUsage({
1672
1826
  };
1673
1827
  }
1674
1828
 
1675
- // src/convert-to-anthropic-messages-prompt.ts
1676
- var import_provider2 = require("@ai-sdk/provider");
1677
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
1829
+ // src/convert-to-anthropic-prompt.ts
1830
+ import {
1831
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
1832
+ } from "@ai-sdk/provider";
1833
+ import {
1834
+ convertBase64ToUint8Array,
1835
+ convertToBase64,
1836
+ getTopLevelMediaType,
1837
+ parseProviderOptions,
1838
+ resolveFullMediaType,
1839
+ resolveProviderReference,
1840
+ validateTypes as validateTypes2,
1841
+ isNonNullable
1842
+ } from "@ai-sdk/provider-utils";
1678
1843
 
1679
1844
  // src/tool/code-execution_20250522.ts
1680
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1681
- var import_v49 = require("zod/v4");
1682
- var codeExecution_20250522OutputSchema = (0, import_provider_utils10.lazySchema)(
1683
- () => (0, import_provider_utils10.zodSchema)(
1684
- import_v49.z.object({
1685
- type: import_v49.z.literal("code_execution_result"),
1686
- stdout: import_v49.z.string(),
1687
- stderr: import_v49.z.string(),
1688
- return_code: import_v49.z.number(),
1689
- content: import_v49.z.array(
1690
- import_v49.z.object({
1691
- type: import_v49.z.literal("code_execution_output"),
1692
- file_id: import_v49.z.string()
1845
+ import {
1846
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
1847
+ lazySchema as lazySchema9,
1848
+ zodSchema as zodSchema9
1849
+ } from "@ai-sdk/provider-utils";
1850
+ import { z as z10 } from "zod/v4";
1851
+ var codeExecution_20250522OutputSchema = lazySchema9(
1852
+ () => zodSchema9(
1853
+ z10.object({
1854
+ type: z10.literal("code_execution_result"),
1855
+ stdout: z10.string(),
1856
+ stderr: z10.string(),
1857
+ return_code: z10.number(),
1858
+ content: z10.array(
1859
+ z10.object({
1860
+ type: z10.literal("code_execution_output"),
1861
+ file_id: z10.string()
1693
1862
  })
1694
1863
  ).optional().default([])
1695
1864
  })
1696
1865
  )
1697
1866
  );
1698
- var codeExecution_20250522InputSchema = (0, import_provider_utils10.lazySchema)(
1699
- () => (0, import_provider_utils10.zodSchema)(
1700
- import_v49.z.object({
1701
- code: import_v49.z.string()
1867
+ var codeExecution_20250522InputSchema = lazySchema9(
1868
+ () => zodSchema9(
1869
+ z10.object({
1870
+ code: z10.string()
1702
1871
  })
1703
1872
  )
1704
1873
  );
1705
- var factory6 = (0, import_provider_utils10.createProviderToolFactoryWithOutputSchema)({
1874
+ var factory7 = createProviderExecutedToolFactory5({
1706
1875
  id: "anthropic.code_execution_20250522",
1707
1876
  inputSchema: codeExecution_20250522InputSchema,
1708
1877
  outputSchema: codeExecution_20250522OutputSchema
1709
1878
  });
1710
1879
  var codeExecution_20250522 = (args = {}) => {
1711
- return factory6(args);
1880
+ return factory7(args);
1712
1881
  };
1713
1882
 
1714
1883
  // src/tool/code-execution_20250825.ts
1715
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1716
- var import_v410 = require("zod/v4");
1717
- var codeExecution_20250825OutputSchema = (0, import_provider_utils11.lazySchema)(
1718
- () => (0, import_provider_utils11.zodSchema)(
1719
- import_v410.z.discriminatedUnion("type", [
1720
- import_v410.z.object({
1721
- type: import_v410.z.literal("code_execution_result"),
1722
- stdout: import_v410.z.string(),
1723
- stderr: import_v410.z.string(),
1724
- return_code: import_v410.z.number(),
1725
- content: import_v410.z.array(
1726
- import_v410.z.object({
1727
- type: import_v410.z.literal("code_execution_output"),
1728
- file_id: import_v410.z.string()
1884
+ import {
1885
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
1886
+ lazySchema as lazySchema10,
1887
+ zodSchema as zodSchema10
1888
+ } from "@ai-sdk/provider-utils";
1889
+ import { z as z11 } from "zod/v4";
1890
+ var codeExecution_20250825OutputSchema = lazySchema10(
1891
+ () => zodSchema10(
1892
+ z11.discriminatedUnion("type", [
1893
+ z11.object({
1894
+ type: z11.literal("code_execution_result"),
1895
+ stdout: z11.string(),
1896
+ stderr: z11.string(),
1897
+ return_code: z11.number(),
1898
+ content: z11.array(
1899
+ z11.object({
1900
+ type: z11.literal("code_execution_output"),
1901
+ file_id: z11.string()
1729
1902
  })
1730
1903
  ).optional().default([])
1731
1904
  }),
1732
- import_v410.z.object({
1733
- type: import_v410.z.literal("bash_code_execution_result"),
1734
- content: import_v410.z.array(
1735
- import_v410.z.object({
1736
- type: import_v410.z.literal("bash_code_execution_output"),
1737
- file_id: import_v410.z.string()
1905
+ z11.object({
1906
+ type: z11.literal("bash_code_execution_result"),
1907
+ content: z11.array(
1908
+ z11.object({
1909
+ type: z11.literal("bash_code_execution_output"),
1910
+ file_id: z11.string()
1738
1911
  })
1739
1912
  ),
1740
- stdout: import_v410.z.string(),
1741
- stderr: import_v410.z.string(),
1742
- return_code: import_v410.z.number()
1913
+ stdout: z11.string(),
1914
+ stderr: z11.string(),
1915
+ return_code: z11.number()
1743
1916
  }),
1744
- import_v410.z.object({
1745
- type: import_v410.z.literal("bash_code_execution_tool_result_error"),
1746
- error_code: import_v410.z.string()
1917
+ z11.object({
1918
+ type: z11.literal("bash_code_execution_tool_result_error"),
1919
+ error_code: z11.string()
1747
1920
  }),
1748
- import_v410.z.object({
1749
- type: import_v410.z.literal("text_editor_code_execution_tool_result_error"),
1750
- error_code: import_v410.z.string()
1921
+ z11.object({
1922
+ type: z11.literal("text_editor_code_execution_tool_result_error"),
1923
+ error_code: z11.string()
1751
1924
  }),
1752
- import_v410.z.object({
1753
- type: import_v410.z.literal("text_editor_code_execution_view_result"),
1754
- content: import_v410.z.string(),
1755
- file_type: import_v410.z.string(),
1756
- num_lines: import_v410.z.number().nullable(),
1757
- start_line: import_v410.z.number().nullable(),
1758
- total_lines: import_v410.z.number().nullable()
1925
+ z11.object({
1926
+ type: z11.literal("text_editor_code_execution_view_result"),
1927
+ content: z11.string(),
1928
+ file_type: z11.string(),
1929
+ num_lines: z11.number().nullable(),
1930
+ start_line: z11.number().nullable(),
1931
+ total_lines: z11.number().nullable()
1759
1932
  }),
1760
- import_v410.z.object({
1761
- type: import_v410.z.literal("text_editor_code_execution_create_result"),
1762
- is_file_update: import_v410.z.boolean()
1933
+ z11.object({
1934
+ type: z11.literal("text_editor_code_execution_create_result"),
1935
+ is_file_update: z11.boolean()
1763
1936
  }),
1764
- import_v410.z.object({
1765
- type: import_v410.z.literal("text_editor_code_execution_str_replace_result"),
1766
- lines: import_v410.z.array(import_v410.z.string()).nullable(),
1767
- new_lines: import_v410.z.number().nullable(),
1768
- new_start: import_v410.z.number().nullable(),
1769
- old_lines: import_v410.z.number().nullable(),
1770
- old_start: import_v410.z.number().nullable()
1937
+ z11.object({
1938
+ type: z11.literal("text_editor_code_execution_str_replace_result"),
1939
+ lines: z11.array(z11.string()).nullable(),
1940
+ new_lines: z11.number().nullable(),
1941
+ new_start: z11.number().nullable(),
1942
+ old_lines: z11.number().nullable(),
1943
+ old_start: z11.number().nullable()
1771
1944
  })
1772
1945
  ])
1773
1946
  )
1774
1947
  );
1775
- var codeExecution_20250825InputSchema = (0, import_provider_utils11.lazySchema)(
1776
- () => (0, import_provider_utils11.zodSchema)(
1777
- import_v410.z.discriminatedUnion("type", [
1948
+ var codeExecution_20250825InputSchema = lazySchema10(
1949
+ () => zodSchema10(
1950
+ z11.discriminatedUnion("type", [
1778
1951
  // Programmatic tool calling format (mapped from { code } by AI SDK)
1779
- import_v410.z.object({
1780
- type: import_v410.z.literal("programmatic-tool-call"),
1781
- code: import_v410.z.string()
1952
+ z11.object({
1953
+ type: z11.literal("programmatic-tool-call"),
1954
+ code: z11.string()
1782
1955
  }),
1783
- import_v410.z.object({
1784
- type: import_v410.z.literal("bash_code_execution"),
1785
- command: import_v410.z.string()
1956
+ z11.object({
1957
+ type: z11.literal("bash_code_execution"),
1958
+ command: z11.string()
1786
1959
  }),
1787
- import_v410.z.discriminatedUnion("command", [
1788
- import_v410.z.object({
1789
- type: import_v410.z.literal("text_editor_code_execution"),
1790
- command: import_v410.z.literal("view"),
1791
- path: import_v410.z.string()
1960
+ z11.discriminatedUnion("command", [
1961
+ z11.object({
1962
+ type: z11.literal("text_editor_code_execution"),
1963
+ command: z11.literal("view"),
1964
+ path: z11.string()
1792
1965
  }),
1793
- import_v410.z.object({
1794
- type: import_v410.z.literal("text_editor_code_execution"),
1795
- command: import_v410.z.literal("create"),
1796
- path: import_v410.z.string(),
1797
- file_text: import_v410.z.string().nullish()
1966
+ z11.object({
1967
+ type: z11.literal("text_editor_code_execution"),
1968
+ command: z11.literal("create"),
1969
+ path: z11.string(),
1970
+ file_text: z11.string().nullish()
1798
1971
  }),
1799
- import_v410.z.object({
1800
- type: import_v410.z.literal("text_editor_code_execution"),
1801
- command: import_v410.z.literal("str_replace"),
1802
- path: import_v410.z.string(),
1803
- old_str: import_v410.z.string(),
1804
- new_str: import_v410.z.string()
1972
+ z11.object({
1973
+ type: z11.literal("text_editor_code_execution"),
1974
+ command: z11.literal("str_replace"),
1975
+ path: z11.string(),
1976
+ old_str: z11.string(),
1977
+ new_str: z11.string()
1805
1978
  })
1806
1979
  ])
1807
1980
  ])
1808
1981
  )
1809
1982
  );
1810
- var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
1983
+ var factory8 = createProviderExecutedToolFactory6({
1811
1984
  id: "anthropic.code_execution_20250825",
1812
1985
  inputSchema: codeExecution_20250825InputSchema,
1813
1986
  outputSchema: codeExecution_20250825OutputSchema,
@@ -1817,142 +1990,150 @@ var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSc
1817
1990
  supportsDeferredResults: true
1818
1991
  });
1819
1992
  var codeExecution_20250825 = (args = {}) => {
1820
- return factory7(args);
1993
+ return factory8(args);
1821
1994
  };
1822
1995
 
1823
1996
  // src/tool/code-execution_20260120.ts
1824
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
1825
- var import_v411 = require("zod/v4");
1826
- var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)(
1827
- () => (0, import_provider_utils12.zodSchema)(
1828
- import_v411.z.discriminatedUnion("type", [
1829
- import_v411.z.object({
1830
- type: import_v411.z.literal("code_execution_result"),
1831
- stdout: import_v411.z.string(),
1832
- stderr: import_v411.z.string(),
1833
- return_code: import_v411.z.number(),
1834
- content: import_v411.z.array(
1835
- import_v411.z.object({
1836
- type: import_v411.z.literal("code_execution_output"),
1837
- file_id: import_v411.z.string()
1997
+ import {
1998
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
1999
+ lazySchema as lazySchema11,
2000
+ zodSchema as zodSchema11
2001
+ } from "@ai-sdk/provider-utils";
2002
+ import { z as z12 } from "zod/v4";
2003
+ var codeExecution_20260120OutputSchema = lazySchema11(
2004
+ () => zodSchema11(
2005
+ z12.discriminatedUnion("type", [
2006
+ z12.object({
2007
+ type: z12.literal("code_execution_result"),
2008
+ stdout: z12.string(),
2009
+ stderr: z12.string(),
2010
+ return_code: z12.number(),
2011
+ content: z12.array(
2012
+ z12.object({
2013
+ type: z12.literal("code_execution_output"),
2014
+ file_id: z12.string()
1838
2015
  })
1839
2016
  ).optional().default([])
1840
2017
  }),
1841
- import_v411.z.object({
1842
- type: import_v411.z.literal("encrypted_code_execution_result"),
1843
- encrypted_stdout: import_v411.z.string(),
1844
- stderr: import_v411.z.string(),
1845
- return_code: import_v411.z.number(),
1846
- content: import_v411.z.array(
1847
- import_v411.z.object({
1848
- type: import_v411.z.literal("code_execution_output"),
1849
- file_id: import_v411.z.string()
2018
+ z12.object({
2019
+ type: z12.literal("encrypted_code_execution_result"),
2020
+ encrypted_stdout: z12.string(),
2021
+ stderr: z12.string(),
2022
+ return_code: z12.number(),
2023
+ content: z12.array(
2024
+ z12.object({
2025
+ type: z12.literal("code_execution_output"),
2026
+ file_id: z12.string()
1850
2027
  })
1851
2028
  ).optional().default([])
1852
2029
  }),
1853
- import_v411.z.object({
1854
- type: import_v411.z.literal("bash_code_execution_result"),
1855
- content: import_v411.z.array(
1856
- import_v411.z.object({
1857
- type: import_v411.z.literal("bash_code_execution_output"),
1858
- file_id: import_v411.z.string()
2030
+ z12.object({
2031
+ type: z12.literal("bash_code_execution_result"),
2032
+ content: z12.array(
2033
+ z12.object({
2034
+ type: z12.literal("bash_code_execution_output"),
2035
+ file_id: z12.string()
1859
2036
  })
1860
2037
  ),
1861
- stdout: import_v411.z.string(),
1862
- stderr: import_v411.z.string(),
1863
- return_code: import_v411.z.number()
2038
+ stdout: z12.string(),
2039
+ stderr: z12.string(),
2040
+ return_code: z12.number()
1864
2041
  }),
1865
- import_v411.z.object({
1866
- type: import_v411.z.literal("bash_code_execution_tool_result_error"),
1867
- error_code: import_v411.z.string()
2042
+ z12.object({
2043
+ type: z12.literal("bash_code_execution_tool_result_error"),
2044
+ error_code: z12.string()
1868
2045
  }),
1869
- import_v411.z.object({
1870
- type: import_v411.z.literal("text_editor_code_execution_tool_result_error"),
1871
- error_code: import_v411.z.string()
2046
+ z12.object({
2047
+ type: z12.literal("text_editor_code_execution_tool_result_error"),
2048
+ error_code: z12.string()
1872
2049
  }),
1873
- import_v411.z.object({
1874
- type: import_v411.z.literal("text_editor_code_execution_view_result"),
1875
- content: import_v411.z.string(),
1876
- file_type: import_v411.z.string(),
1877
- num_lines: import_v411.z.number().nullable(),
1878
- start_line: import_v411.z.number().nullable(),
1879
- total_lines: import_v411.z.number().nullable()
2050
+ z12.object({
2051
+ type: z12.literal("text_editor_code_execution_view_result"),
2052
+ content: z12.string(),
2053
+ file_type: z12.string(),
2054
+ num_lines: z12.number().nullable(),
2055
+ start_line: z12.number().nullable(),
2056
+ total_lines: z12.number().nullable()
1880
2057
  }),
1881
- import_v411.z.object({
1882
- type: import_v411.z.literal("text_editor_code_execution_create_result"),
1883
- is_file_update: import_v411.z.boolean()
2058
+ z12.object({
2059
+ type: z12.literal("text_editor_code_execution_create_result"),
2060
+ is_file_update: z12.boolean()
1884
2061
  }),
1885
- import_v411.z.object({
1886
- type: import_v411.z.literal("text_editor_code_execution_str_replace_result"),
1887
- lines: import_v411.z.array(import_v411.z.string()).nullable(),
1888
- new_lines: import_v411.z.number().nullable(),
1889
- new_start: import_v411.z.number().nullable(),
1890
- old_lines: import_v411.z.number().nullable(),
1891
- old_start: import_v411.z.number().nullable()
2062
+ z12.object({
2063
+ type: z12.literal("text_editor_code_execution_str_replace_result"),
2064
+ lines: z12.array(z12.string()).nullable(),
2065
+ new_lines: z12.number().nullable(),
2066
+ new_start: z12.number().nullable(),
2067
+ old_lines: z12.number().nullable(),
2068
+ old_start: z12.number().nullable()
1892
2069
  })
1893
2070
  ])
1894
2071
  )
1895
2072
  );
1896
- var codeExecution_20260120InputSchema = (0, import_provider_utils12.lazySchema)(
1897
- () => (0, import_provider_utils12.zodSchema)(
1898
- import_v411.z.discriminatedUnion("type", [
1899
- import_v411.z.object({
1900
- type: import_v411.z.literal("programmatic-tool-call"),
1901
- code: import_v411.z.string()
2073
+ var codeExecution_20260120InputSchema = lazySchema11(
2074
+ () => zodSchema11(
2075
+ z12.discriminatedUnion("type", [
2076
+ z12.object({
2077
+ type: z12.literal("programmatic-tool-call"),
2078
+ code: z12.string()
1902
2079
  }),
1903
- import_v411.z.object({
1904
- type: import_v411.z.literal("bash_code_execution"),
1905
- command: import_v411.z.string()
2080
+ z12.object({
2081
+ type: z12.literal("bash_code_execution"),
2082
+ command: z12.string()
1906
2083
  }),
1907
- import_v411.z.discriminatedUnion("command", [
1908
- import_v411.z.object({
1909
- type: import_v411.z.literal("text_editor_code_execution"),
1910
- command: import_v411.z.literal("view"),
1911
- path: import_v411.z.string()
2084
+ z12.discriminatedUnion("command", [
2085
+ z12.object({
2086
+ type: z12.literal("text_editor_code_execution"),
2087
+ command: z12.literal("view"),
2088
+ path: z12.string()
1912
2089
  }),
1913
- import_v411.z.object({
1914
- type: import_v411.z.literal("text_editor_code_execution"),
1915
- command: import_v411.z.literal("create"),
1916
- path: import_v411.z.string(),
1917
- file_text: import_v411.z.string().nullish()
2090
+ z12.object({
2091
+ type: z12.literal("text_editor_code_execution"),
2092
+ command: z12.literal("create"),
2093
+ path: z12.string(),
2094
+ file_text: z12.string().nullish()
1918
2095
  }),
1919
- import_v411.z.object({
1920
- type: import_v411.z.literal("text_editor_code_execution"),
1921
- command: import_v411.z.literal("str_replace"),
1922
- path: import_v411.z.string(),
1923
- old_str: import_v411.z.string(),
1924
- new_str: import_v411.z.string()
2096
+ z12.object({
2097
+ type: z12.literal("text_editor_code_execution"),
2098
+ command: z12.literal("str_replace"),
2099
+ path: z12.string(),
2100
+ old_str: z12.string(),
2101
+ new_str: z12.string()
1925
2102
  })
1926
2103
  ])
1927
2104
  ])
1928
2105
  )
1929
2106
  );
1930
- var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
2107
+ var factory9 = createProviderExecutedToolFactory7({
1931
2108
  id: "anthropic.code_execution_20260120",
1932
2109
  inputSchema: codeExecution_20260120InputSchema,
1933
2110
  outputSchema: codeExecution_20260120OutputSchema,
1934
2111
  supportsDeferredResults: true
1935
2112
  });
1936
2113
  var codeExecution_20260120 = (args = {}) => {
1937
- return factory8(args);
2114
+ return factory9(args);
1938
2115
  };
1939
2116
 
1940
2117
  // src/tool/tool-search-regex_20251119.ts
1941
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
1942
- var import_v412 = require("zod/v4");
1943
- var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils13.lazySchema)(
1944
- () => (0, import_provider_utils13.zodSchema)(
1945
- import_v412.z.array(
1946
- import_v412.z.object({
1947
- type: import_v412.z.literal("tool_reference"),
1948
- toolName: import_v412.z.string()
2118
+ import {
2119
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory8,
2120
+ lazySchema as lazySchema12,
2121
+ zodSchema as zodSchema12
2122
+ } from "@ai-sdk/provider-utils";
2123
+ import { z as z13 } from "zod/v4";
2124
+ var toolSearchRegex_20251119OutputSchema = lazySchema12(
2125
+ () => zodSchema12(
2126
+ z13.array(
2127
+ z13.object({
2128
+ type: z13.literal("tool_reference"),
2129
+ toolName: z13.string()
1949
2130
  })
1950
2131
  )
1951
2132
  )
1952
2133
  );
1953
- var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema)(
1954
- () => (0, import_provider_utils13.zodSchema)(
1955
- import_v412.z.object({
2134
+ var toolSearchRegex_20251119InputSchema = lazySchema12(
2135
+ () => zodSchema12(
2136
+ z13.object({
1956
2137
  /**
1957
2138
  * A regex pattern to search for tools.
1958
2139
  * Uses Python re.search() syntax. Maximum 200 characters.
@@ -1963,57 +2144,32 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
1963
2144
  * - "database.*query|query.*database" - OR patterns for flexibility
1964
2145
  * - "(?i)slack" - case-insensitive search
1965
2146
  */
1966
- pattern: import_v412.z.string(),
2147
+ pattern: z13.string(),
1967
2148
  /**
1968
2149
  * Maximum number of tools to return. Optional.
1969
2150
  */
1970
- limit: import_v412.z.number().optional()
2151
+ limit: z13.number().optional()
1971
2152
  })
1972
2153
  )
1973
2154
  );
1974
- var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
2155
+ var factory10 = createProviderExecutedToolFactory8({
1975
2156
  id: "anthropic.tool_search_regex_20251119",
1976
2157
  inputSchema: toolSearchRegex_20251119InputSchema,
1977
2158
  outputSchema: toolSearchRegex_20251119OutputSchema,
1978
2159
  supportsDeferredResults: true
1979
2160
  });
1980
2161
  var toolSearchRegex_20251119 = (args = {}) => {
1981
- return factory9(args);
2162
+ return factory10(args);
1982
2163
  };
1983
2164
 
1984
- // src/convert-to-anthropic-messages-prompt.ts
1985
- function convertToString(data) {
2165
+ // src/convert-to-anthropic-prompt.ts
2166
+ function convertBytesDataToString(data) {
1986
2167
  if (typeof data === "string") {
1987
- return new TextDecoder().decode((0, import_provider_utils14.convertBase64ToUint8Array)(data));
1988
- }
1989
- if (data instanceof Uint8Array) {
1990
- return new TextDecoder().decode(data);
2168
+ return new TextDecoder().decode(convertBase64ToUint8Array(data));
1991
2169
  }
1992
- if (data instanceof URL) {
1993
- throw new import_provider2.UnsupportedFunctionalityError({
1994
- functionality: "URL-based text documents are not supported for citations"
1995
- });
1996
- }
1997
- throw new import_provider2.UnsupportedFunctionalityError({
1998
- functionality: `unsupported data type for text documents: ${typeof data}`
1999
- });
2000
- }
2001
- function isUrlData(data) {
2002
- return data instanceof URL || isUrlString(data);
2003
- }
2004
- function isUrlString(data) {
2005
- return typeof data === "string" && /^https?:\/\//i.test(data);
2170
+ return new TextDecoder().decode(data);
2006
2171
  }
2007
- function isFileIdData(data) {
2008
- return typeof data === "string" && data.startsWith("anthropic-file://");
2009
- }
2010
- function getFileId(data) {
2011
- return data.replace("anthropic-file://", "");
2012
- }
2013
- function getUrlString(data) {
2014
- return data instanceof URL ? data.toString() : data;
2015
- }
2016
- async function convertToAnthropicMessagesPrompt({
2172
+ async function convertToAnthropicPrompt({
2017
2173
  prompt,
2018
2174
  sendReasoning,
2019
2175
  warnings,
@@ -2028,7 +2184,7 @@ async function convertToAnthropicMessagesPrompt({
2028
2184
  const messages = [];
2029
2185
  async function shouldEnableCitations(providerMetadata) {
2030
2186
  var _a2, _b2;
2031
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2187
+ const anthropicOptions = await parseProviderOptions({
2032
2188
  provider: "anthropic",
2033
2189
  providerOptions: providerMetadata,
2034
2190
  schema: anthropicFilePartProviderOptions
@@ -2036,7 +2192,7 @@ async function convertToAnthropicMessagesPrompt({
2036
2192
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
2037
2193
  }
2038
2194
  async function getDocumentMetadata(providerMetadata) {
2039
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2195
+ const anthropicOptions = await parseProviderOptions({
2040
2196
  provider: "anthropic",
2041
2197
  providerOptions: providerMetadata,
2042
2198
  schema: anthropicFilePartProviderOptions
@@ -2053,18 +2209,21 @@ async function convertToAnthropicMessagesPrompt({
2053
2209
  switch (type) {
2054
2210
  case "system": {
2055
2211
  if (system != null) {
2056
- throw new import_provider2.UnsupportedFunctionalityError({
2212
+ throw new UnsupportedFunctionalityError2({
2057
2213
  functionality: "Multiple system messages that are separated by user/assistant messages"
2058
2214
  });
2059
2215
  }
2060
- system = block.messages.map(({ content, providerOptions }) => ({
2061
- type: "text",
2062
- text: content,
2063
- cache_control: validator.getCacheControl(providerOptions, {
2216
+ system = block.messages.map(({ content, providerOptions }) => {
2217
+ const cc = validator.getCacheControl(providerOptions, {
2064
2218
  type: "system message",
2065
2219
  canCache: true
2066
- })
2067
- }));
2220
+ });
2221
+ return {
2222
+ type: "text",
2223
+ text: content,
2224
+ cache_control: cc
2225
+ };
2226
+ });
2068
2227
  break;
2069
2228
  }
2070
2229
  case "user": {
@@ -2093,87 +2252,131 @@ async function convertToAnthropicMessagesPrompt({
2093
2252
  break;
2094
2253
  }
2095
2254
  case "file": {
2096
- if (isFileIdData(part.data)) {
2097
- const fileId = getFileId(part.data);
2098
- const metadata = await getDocumentMetadata(
2099
- part.providerOptions
2100
- );
2101
- anthropicContent.push({
2102
- type: "document",
2103
- source: {
2104
- type: "file",
2105
- file_id: fileId
2106
- },
2107
- title: (_b = metadata.title) != null ? _b : part.filename,
2108
- ...metadata.context && { context: metadata.context },
2109
- cache_control: cacheControl
2110
- });
2111
- } else if (part.mediaType.startsWith("image/")) {
2112
- anthropicContent.push({
2113
- type: "image",
2114
- source: isUrlData(part.data) ? {
2115
- type: "url",
2116
- url: getUrlString(part.data)
2117
- } : {
2118
- type: "base64",
2119
- media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
2120
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2121
- },
2122
- cache_control: cacheControl
2123
- });
2124
- } else if (part.mediaType === "application/pdf") {
2125
- betas.add("pdfs-2024-09-25");
2126
- const enableCitations = await shouldEnableCitations(
2127
- part.providerOptions
2128
- );
2129
- const metadata = await getDocumentMetadata(
2130
- part.providerOptions
2131
- );
2132
- anthropicContent.push({
2133
- type: "document",
2134
- source: isUrlData(part.data) ? {
2135
- type: "url",
2136
- url: getUrlString(part.data)
2137
- } : {
2138
- type: "base64",
2139
- media_type: "application/pdf",
2140
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2141
- },
2142
- title: (_c = metadata.title) != null ? _c : part.filename,
2143
- ...metadata.context && { context: metadata.context },
2144
- ...enableCitations && {
2145
- citations: { enabled: true }
2146
- },
2147
- cache_control: cacheControl
2148
- });
2149
- } else if (part.mediaType === "text/plain") {
2150
- const enableCitations = await shouldEnableCitations(
2151
- part.providerOptions
2152
- );
2153
- const metadata = await getDocumentMetadata(
2154
- part.providerOptions
2155
- );
2156
- anthropicContent.push({
2157
- type: "document",
2158
- source: isUrlData(part.data) ? {
2159
- type: "url",
2160
- url: getUrlString(part.data)
2161
- } : {
2162
- type: "text",
2163
- media_type: "text/plain",
2164
- data: convertToString(part.data)
2165
- },
2166
- title: (_d = metadata.title) != null ? _d : part.filename,
2167
- ...metadata.context && { context: metadata.context },
2168
- ...enableCitations && {
2169
- citations: { enabled: true }
2170
- },
2171
- cache_control: cacheControl
2172
- });
2173
- } else {
2174
- throw new import_provider2.UnsupportedFunctionalityError({
2175
- functionality: `media type: ${part.mediaType}`
2176
- });
2255
+ switch (part.data.type) {
2256
+ case "reference": {
2257
+ const fileId = resolveProviderReference({
2258
+ reference: part.data.reference,
2259
+ provider: "anthropic"
2260
+ });
2261
+ betas.add("files-api-2025-04-14");
2262
+ if (getTopLevelMediaType(part.mediaType) === "image") {
2263
+ anthropicContent.push({
2264
+ type: "image",
2265
+ source: { type: "file", file_id: fileId },
2266
+ cache_control: cacheControl
2267
+ });
2268
+ } else {
2269
+ anthropicContent.push({
2270
+ type: "document",
2271
+ source: { type: "file", file_id: fileId },
2272
+ cache_control: cacheControl
2273
+ });
2274
+ }
2275
+ break;
2276
+ }
2277
+ case "text": {
2278
+ const enableCitations = await shouldEnableCitations(
2279
+ part.providerOptions
2280
+ );
2281
+ const metadata = await getDocumentMetadata(
2282
+ part.providerOptions
2283
+ );
2284
+ anthropicContent.push({
2285
+ type: "document",
2286
+ source: {
2287
+ type: "text",
2288
+ media_type: "text/plain",
2289
+ data: part.data.text
2290
+ },
2291
+ title: (_b = metadata.title) != null ? _b : part.filename,
2292
+ ...metadata.context && {
2293
+ context: metadata.context
2294
+ },
2295
+ ...enableCitations && {
2296
+ citations: { enabled: true }
2297
+ },
2298
+ cache_control: cacheControl
2299
+ });
2300
+ break;
2301
+ }
2302
+ case "url":
2303
+ case "data": {
2304
+ const topLevel = getTopLevelMediaType(part.mediaType);
2305
+ if (topLevel === "image") {
2306
+ anthropicContent.push({
2307
+ type: "image",
2308
+ source: part.data.type === "url" ? {
2309
+ type: "url",
2310
+ url: part.data.url.toString()
2311
+ } : {
2312
+ type: "base64",
2313
+ media_type: resolveFullMediaType({ part }),
2314
+ data: convertToBase64(part.data.data)
2315
+ },
2316
+ cache_control: cacheControl
2317
+ });
2318
+ } else if (topLevel === "application" && (part.data.type === "url" ? part.mediaType === "application/pdf" : resolveFullMediaType({ part }) === "application/pdf")) {
2319
+ betas.add("pdfs-2024-09-25");
2320
+ const enableCitations = await shouldEnableCitations(
2321
+ part.providerOptions
2322
+ );
2323
+ const metadata = await getDocumentMetadata(
2324
+ part.providerOptions
2325
+ );
2326
+ anthropicContent.push({
2327
+ type: "document",
2328
+ source: part.data.type === "url" ? {
2329
+ type: "url",
2330
+ url: part.data.url.toString()
2331
+ } : {
2332
+ type: "base64",
2333
+ media_type: "application/pdf",
2334
+ data: convertToBase64(part.data.data)
2335
+ },
2336
+ title: (_c = metadata.title) != null ? _c : part.filename,
2337
+ ...metadata.context && {
2338
+ context: metadata.context
2339
+ },
2340
+ ...enableCitations && {
2341
+ citations: { enabled: true }
2342
+ },
2343
+ cache_control: cacheControl
2344
+ });
2345
+ } else if (part.mediaType === "text/plain") {
2346
+ const enableCitations = await shouldEnableCitations(
2347
+ part.providerOptions
2348
+ );
2349
+ const metadata = await getDocumentMetadata(
2350
+ part.providerOptions
2351
+ );
2352
+ anthropicContent.push({
2353
+ type: "document",
2354
+ source: part.data.type === "url" ? {
2355
+ type: "url",
2356
+ url: part.data.url.toString()
2357
+ } : {
2358
+ type: "text",
2359
+ media_type: "text/plain",
2360
+ data: convertBytesDataToString(
2361
+ part.data.data
2362
+ )
2363
+ },
2364
+ title: (_d = metadata.title) != null ? _d : part.filename,
2365
+ ...metadata.context && {
2366
+ context: metadata.context
2367
+ },
2368
+ ...enableCitations && {
2369
+ citations: { enabled: true }
2370
+ },
2371
+ cache_control: cacheControl
2372
+ });
2373
+ } else {
2374
+ throw new UnsupportedFunctionalityError2({
2375
+ functionality: `media type: ${part.mediaType}`
2376
+ });
2377
+ }
2378
+ break;
2379
+ }
2177
2380
  }
2178
2381
  break;
2179
2382
  }
@@ -2207,26 +2410,16 @@ async function convertToAnthropicMessagesPrompt({
2207
2410
  type: "text",
2208
2411
  text: contentPart.text
2209
2412
  };
2210
- case "image-data": {
2211
- return {
2212
- type: "image",
2213
- source: {
2214
- type: "base64",
2215
- media_type: contentPart.mediaType,
2216
- data: contentPart.data
2217
- }
2218
- };
2219
- }
2220
- case "image-url": {
2221
- return {
2222
- type: "image",
2223
- source: {
2224
- type: "url",
2225
- url: contentPart.url
2226
- }
2227
- };
2228
- }
2229
2413
  case "file-url": {
2414
+ if (contentPart.mediaType.startsWith("image/")) {
2415
+ return {
2416
+ type: "image",
2417
+ source: {
2418
+ type: "url",
2419
+ url: contentPart.url
2420
+ }
2421
+ };
2422
+ }
2230
2423
  return {
2231
2424
  type: "document",
2232
2425
  source: {
@@ -2236,6 +2429,16 @@ async function convertToAnthropicMessagesPrompt({
2236
2429
  };
2237
2430
  }
2238
2431
  case "file-data": {
2432
+ if (contentPart.mediaType.startsWith("image/")) {
2433
+ return {
2434
+ type: "image",
2435
+ source: {
2436
+ type: "base64",
2437
+ media_type: contentPart.mediaType,
2438
+ data: contentPart.data
2439
+ }
2440
+ };
2441
+ }
2239
2442
  if (contentPart.mediaType === "application/pdf") {
2240
2443
  betas.add("pdfs-2024-09-25");
2241
2444
  return {
@@ -2275,14 +2478,14 @@ async function convertToAnthropicMessagesPrompt({
2275
2478
  return void 0;
2276
2479
  }
2277
2480
  }
2278
- }).filter(import_provider_utils14.isNonNullable);
2481
+ }).filter(isNonNullable);
2279
2482
  break;
2280
2483
  case "text":
2281
2484
  case "error-text":
2282
2485
  contentValue = output.value;
2283
2486
  break;
2284
2487
  case "execution-denied":
2285
- contentValue = (_f = output.reason) != null ? _f : "Tool execution denied.";
2488
+ contentValue = (_f = output.reason) != null ? _f : "Tool call execution denied.";
2286
2489
  break;
2287
2490
  case "json":
2288
2491
  case "error-json":
@@ -2351,7 +2554,7 @@ async function convertToAnthropicMessagesPrompt({
2351
2554
  }
2352
2555
  case "reasoning": {
2353
2556
  if (sendReasoning) {
2354
- const reasoningMetadata = await (0, import_provider_utils14.parseProviderOptions)({
2557
+ const reasoningMetadata = await parseProviderOptions({
2355
2558
  provider: "anthropic",
2356
2559
  providerOptions: part.providerOptions,
2357
2560
  schema: anthropicReasoningMetadataSchema
@@ -2557,7 +2760,7 @@ async function convertToAnthropicMessagesPrompt({
2557
2760
  break;
2558
2761
  }
2559
2762
  if (output.value.type === "code_execution_result") {
2560
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2763
+ const codeExecutionOutput = await validateTypes2({
2561
2764
  value: output.value,
2562
2765
  schema: codeExecution_20250522OutputSchema
2563
2766
  });
@@ -2574,7 +2777,7 @@ async function convertToAnthropicMessagesPrompt({
2574
2777
  cache_control: cacheControl
2575
2778
  });
2576
2779
  } else if (output.value.type === "encrypted_code_execution_result") {
2577
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2780
+ const codeExecutionOutput = await validateTypes2({
2578
2781
  value: output.value,
2579
2782
  schema: codeExecution_20260120OutputSchema
2580
2783
  });
@@ -2593,7 +2796,7 @@ async function convertToAnthropicMessagesPrompt({
2593
2796
  });
2594
2797
  }
2595
2798
  } else {
2596
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2799
+ const codeExecutionOutput = await validateTypes2({
2597
2800
  value: output.value,
2598
2801
  schema: codeExecution_20250825OutputSchema
2599
2802
  });
@@ -2662,7 +2865,7 @@ async function convertToAnthropicMessagesPrompt({
2662
2865
  });
2663
2866
  break;
2664
2867
  }
2665
- const webFetchOutput = await (0, import_provider_utils14.validateTypes)({
2868
+ const webFetchOutput = await validateTypes2({
2666
2869
  value: output.value,
2667
2870
  schema: webFetch_20250910OutputSchema
2668
2871
  });
@@ -2690,6 +2893,18 @@ async function convertToAnthropicMessagesPrompt({
2690
2893
  }
2691
2894
  if (providerToolName === "web_search") {
2692
2895
  const output = part.output;
2896
+ if (output.type === "error-text" || output.type === "error-json") {
2897
+ anthropicContent.push({
2898
+ type: "web_search_tool_result",
2899
+ tool_use_id: part.toolCallId,
2900
+ content: {
2901
+ type: "web_search_tool_result_error",
2902
+ error_code: "unavailable"
2903
+ },
2904
+ cache_control: cacheControl
2905
+ });
2906
+ break;
2907
+ }
2693
2908
  if (output.type !== "json") {
2694
2909
  warnings.push({
2695
2910
  type: "other",
@@ -2697,7 +2912,7 @@ async function convertToAnthropicMessagesPrompt({
2697
2912
  });
2698
2913
  break;
2699
2914
  }
2700
- const webSearchOutput = await (0, import_provider_utils14.validateTypes)({
2915
+ const webSearchOutput = await validateTypes2({
2701
2916
  value: output.value,
2702
2917
  schema: webSearch_20250305OutputSchema
2703
2918
  });
@@ -2717,6 +2932,18 @@ async function convertToAnthropicMessagesPrompt({
2717
2932
  }
2718
2933
  if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
2719
2934
  const output = part.output;
2935
+ if (output.type === "error-text" || output.type === "error-json") {
2936
+ anthropicContent.push({
2937
+ type: "tool_search_tool_result",
2938
+ tool_use_id: part.toolCallId,
2939
+ content: {
2940
+ type: "tool_search_tool_result_error",
2941
+ error_code: "unavailable"
2942
+ },
2943
+ cache_control: cacheControl
2944
+ });
2945
+ break;
2946
+ }
2720
2947
  if (output.type !== "json") {
2721
2948
  warnings.push({
2722
2949
  type: "other",
@@ -2724,7 +2951,7 @@ async function convertToAnthropicMessagesPrompt({
2724
2951
  });
2725
2952
  break;
2726
2953
  }
2727
- const toolSearchOutput = await (0, import_provider_utils14.validateTypes)({
2954
+ const toolSearchOutput = await validateTypes2({
2728
2955
  value: output.value,
2729
2956
  schema: toolSearchRegex_20251119OutputSchema
2730
2957
  });
@@ -2837,7 +3064,153 @@ function mapAnthropicStopReason({
2837
3064
  }
2838
3065
  }
2839
3066
 
2840
- // src/anthropic-messages-language-model.ts
3067
+ // src/sanitize-json-schema.ts
3068
+ var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
3069
+ "date-time",
3070
+ "time",
3071
+ "date",
3072
+ "duration",
3073
+ "email",
3074
+ "hostname",
3075
+ "uri",
3076
+ "ipv4",
3077
+ "ipv6",
3078
+ "uuid"
3079
+ ]);
3080
+ var DESCRIPTION_CONSTRAINT_KEYS = [
3081
+ "minimum",
3082
+ "maximum",
3083
+ "exclusiveMinimum",
3084
+ "exclusiveMaximum",
3085
+ "multipleOf",
3086
+ "minLength",
3087
+ "maxLength",
3088
+ "pattern",
3089
+ "minItems",
3090
+ "maxItems",
3091
+ "uniqueItems",
3092
+ "minProperties",
3093
+ "maxProperties",
3094
+ "not"
3095
+ ];
3096
+ function sanitizeJsonSchema(schema) {
3097
+ return sanitizeSchema(schema);
3098
+ }
3099
+ function sanitizeDefinition(definition) {
3100
+ if (typeof definition === "boolean" || !isPlainObject(definition)) {
3101
+ return definition;
3102
+ }
3103
+ return sanitizeSchema(definition);
3104
+ }
3105
+ function sanitizeSchema(schema) {
3106
+ const result = {};
3107
+ const schemaWithDefs = schema;
3108
+ if (schema.$ref != null) {
3109
+ return { $ref: schema.$ref };
3110
+ }
3111
+ if (schema.$schema != null) {
3112
+ result.$schema = schema.$schema;
3113
+ }
3114
+ if (schema.$id != null) {
3115
+ result.$id = schema.$id;
3116
+ }
3117
+ if (schema.title != null) {
3118
+ result.title = schema.title;
3119
+ }
3120
+ if (schema.description != null) {
3121
+ result.description = schema.description;
3122
+ }
3123
+ if (schema.default !== void 0) {
3124
+ result.default = schema.default;
3125
+ }
3126
+ if (schema.const !== void 0) {
3127
+ result.const = schema.const;
3128
+ }
3129
+ if (schema.enum != null) {
3130
+ result.enum = schema.enum;
3131
+ }
3132
+ if (schema.type != null) {
3133
+ result.type = schema.type;
3134
+ }
3135
+ if (schema.anyOf != null) {
3136
+ result.anyOf = schema.anyOf.map(sanitizeDefinition);
3137
+ } else if (schema.oneOf != null) {
3138
+ result.anyOf = schema.oneOf.map(sanitizeDefinition);
3139
+ }
3140
+ if (schema.allOf != null) {
3141
+ result.allOf = schema.allOf.map(sanitizeDefinition);
3142
+ }
3143
+ if (schema.definitions != null) {
3144
+ result.definitions = Object.fromEntries(
3145
+ Object.entries(schema.definitions).map(([name, definition]) => [
3146
+ name,
3147
+ sanitizeDefinition(definition)
3148
+ ])
3149
+ );
3150
+ }
3151
+ if (schemaWithDefs.$defs != null) {
3152
+ const resultWithDefs = result;
3153
+ resultWithDefs.$defs = Object.fromEntries(
3154
+ Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
3155
+ name,
3156
+ sanitizeDefinition(definition)
3157
+ ])
3158
+ );
3159
+ }
3160
+ if (schema.type === "object" || schema.properties != null) {
3161
+ if (schema.properties != null) {
3162
+ result.properties = Object.fromEntries(
3163
+ Object.entries(schema.properties).map(([name, definition]) => [
3164
+ name,
3165
+ sanitizeDefinition(definition)
3166
+ ])
3167
+ );
3168
+ }
3169
+ result.additionalProperties = false;
3170
+ if (schema.required != null) {
3171
+ result.required = schema.required;
3172
+ }
3173
+ }
3174
+ if (schema.items != null) {
3175
+ result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
3176
+ }
3177
+ if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
3178
+ result.format = schema.format;
3179
+ }
3180
+ const constraintDescription = getConstraintDescription(schema);
3181
+ if (constraintDescription != null) {
3182
+ result.description = result.description == null ? constraintDescription : `${result.description}
3183
+ ${constraintDescription}`;
3184
+ }
3185
+ return result;
3186
+ }
3187
+ function getConstraintDescription(schema) {
3188
+ const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
3189
+ const value = schema[key];
3190
+ if (value == null || value === false) {
3191
+ return [];
3192
+ }
3193
+ return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
3194
+ });
3195
+ if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
3196
+ descriptions.push(`format: ${schema.format}`);
3197
+ }
3198
+ return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
3199
+ }
3200
+ function formatConstraintName(key) {
3201
+ return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
3202
+ }
3203
+ function formatConstraintValue(value) {
3204
+ if (typeof value === "string") {
3205
+ return value;
3206
+ }
3207
+ return JSON.stringify(value);
3208
+ }
3209
+ function isPlainObject(value) {
3210
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3211
+ }
3212
+
3213
+ // src/anthropic-language-model.ts
2841
3214
  function createCitationSource(citation, citationDocuments, generateId2) {
2842
3215
  var _a;
2843
3216
  if (citation.type === "web_search_result_location") {
@@ -2882,13 +3255,22 @@ function createCitationSource(citation, citationDocuments, generateId2) {
2882
3255
  }
2883
3256
  };
2884
3257
  }
2885
- var AnthropicMessagesLanguageModel = class {
3258
+ var AnthropicLanguageModel = class _AnthropicLanguageModel {
2886
3259
  constructor(modelId, config) {
2887
3260
  this.specificationVersion = "v4";
2888
3261
  var _a;
2889
3262
  this.modelId = modelId;
2890
3263
  this.config = config;
2891
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils15.generateId;
3264
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
3265
+ }
3266
+ static [WORKFLOW_SERIALIZE](model) {
3267
+ return serializeModelOptions({
3268
+ modelId: model.modelId,
3269
+ config: model.config
3270
+ });
3271
+ }
3272
+ static [WORKFLOW_DESERIALIZE](options) {
3273
+ return new _AnthropicLanguageModel(options.modelId, options.config);
2892
3274
  }
2893
3275
  supportsUrl(url) {
2894
3276
  return url.protocol === "https:";
@@ -2927,7 +3309,7 @@ var AnthropicMessagesLanguageModel = class {
2927
3309
  providerOptions,
2928
3310
  stream
2929
3311
  }) {
2930
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3312
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2931
3313
  const warnings = [];
2932
3314
  if (frequencyPenalty != null) {
2933
3315
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2963,12 +3345,12 @@ var AnthropicMessagesLanguageModel = class {
2963
3345
  }
2964
3346
  }
2965
3347
  const providerOptionsName = this.providerOptionsName;
2966
- const canonicalOptions = await (0, import_provider_utils15.parseProviderOptions)({
3348
+ const canonicalOptions = await parseProviderOptions2({
2967
3349
  provider: "anthropic",
2968
3350
  providerOptions,
2969
3351
  schema: anthropicLanguageModelOptions
2970
3352
  });
2971
- const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils15.parseProviderOptions)({
3353
+ const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
2972
3354
  provider: providerOptionsName,
2973
3355
  providerOptions,
2974
3356
  schema: anthropicLanguageModelOptions
@@ -2983,8 +3365,37 @@ var AnthropicMessagesLanguageModel = class {
2983
3365
  maxOutputTokens: maxOutputTokensForModel,
2984
3366
  supportsStructuredOutput: modelSupportsStructuredOutput,
2985
3367
  supportsAdaptiveThinking,
3368
+ rejectsSamplingParameters,
3369
+ supportsXhighEffort,
2986
3370
  isKnownModel
2987
3371
  } = getModelCapabilities(this.modelId);
3372
+ if (rejectsSamplingParameters) {
3373
+ if (temperature != null) {
3374
+ warnings.push({
3375
+ type: "unsupported",
3376
+ feature: "temperature",
3377
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
3378
+ });
3379
+ temperature = void 0;
3380
+ }
3381
+ if (topK != null) {
3382
+ warnings.push({
3383
+ type: "unsupported",
3384
+ feature: "topK",
3385
+ details: `topK is not supported by ${this.modelId} and will be ignored`
3386
+ });
3387
+ topK = void 0;
3388
+ }
3389
+ if (topP != null) {
3390
+ warnings.push({
3391
+ type: "unsupported",
3392
+ feature: "topP",
3393
+ details: `topP is not supported by ${this.modelId} and will be ignored`
3394
+ });
3395
+ topP = void 0;
3396
+ }
3397
+ }
3398
+ const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2988
3399
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2989
3400
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
2990
3401
  const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
@@ -2997,7 +3408,7 @@ var AnthropicMessagesLanguageModel = class {
2997
3408
  } : void 0;
2998
3409
  const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
2999
3410
  const cacheControlValidator = new CacheControlValidator();
3000
- const toolNameMapping = (0, import_provider_utils15.createToolNameMapping)({
3411
+ const toolNameMapping = createToolNameMapping({
3001
3412
  tools,
3002
3413
  providerToolNames: {
3003
3414
  "anthropic.code_execution_20250522": "code_execution",
@@ -3020,51 +3431,42 @@ var AnthropicMessagesLanguageModel = class {
3020
3431
  "anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
3021
3432
  }
3022
3433
  });
3023
- const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
3434
+ const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
3024
3435
  prompt,
3025
3436
  sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
3026
3437
  warnings,
3027
3438
  cacheControlValidator,
3028
3439
  toolNameMapping
3029
3440
  });
3030
- if ((0, import_provider_utils15.isCustomReasoning)(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
3441
+ if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
3031
3442
  const reasoningConfig = resolveAnthropicReasoningConfig({
3032
3443
  reasoning,
3033
3444
  supportsAdaptiveThinking,
3445
+ supportsXhighEffort,
3034
3446
  maxOutputTokensForModel,
3035
3447
  warnings
3036
3448
  });
3037
3449
  if (reasoningConfig != null) {
3038
- anthropicOptions.thinking = reasoningConfig.thinking;
3039
- if (reasoningConfig.effort != null) {
3450
+ if (anthropicOptions.thinking == null) {
3451
+ anthropicOptions.thinking = reasoningConfig.thinking;
3452
+ }
3453
+ if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
3040
3454
  anthropicOptions.effort = reasoningConfig.effort;
3041
3455
  }
3042
3456
  }
3043
3457
  }
3044
- if (anthropicOptions == null ? void 0 : anthropicOptions.prefill) {
3045
- const lastMessage = messagesPrompt.messages[messagesPrompt.messages.length - 1];
3046
- if ((lastMessage == null ? void 0 : lastMessage.role) === "assistant") {
3047
- lastMessage.content.push({
3048
- type: "text",
3049
- text: anthropicOptions.prefill.trim(),
3050
- cache_control: void 0
3051
- });
3052
- } else {
3053
- messagesPrompt.messages.push({
3054
- role: "assistant",
3055
- content: [
3056
- {
3057
- type: "text",
3058
- text: anthropicOptions.prefill.trim(),
3059
- cache_control: void 0
3060
- }
3061
- ]
3062
- });
3063
- }
3458
+ let thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
3459
+ if (thinkingType === "adaptive" && !supportsAdaptiveThinking) {
3460
+ warnings.push({
3461
+ type: "unsupported",
3462
+ feature: "adaptive-thinking",
3463
+ details: `adaptive thinking is not supported by ${this.modelId} and will be ignored`
3464
+ });
3465
+ thinkingType = void 0;
3064
3466
  }
3065
- const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3066
3467
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3067
- let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3468
+ let thinkingBudget = ((_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.type) === "enabled" ? anthropicOptions.thinking.budgetTokens : void 0;
3469
+ const thinkingDisplay = ((_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.type) === "adaptive" ? anthropicOptions.thinking.display : void 0;
3068
3470
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3069
3471
  const baseArgs = {
3070
3472
  // model id:
@@ -3080,20 +3482,27 @@ var AnthropicMessagesLanguageModel = class {
3080
3482
  thinking: {
3081
3483
  type: thinkingType,
3082
3484
  ...thinkingBudget != null && { budget_tokens: thinkingBudget },
3083
- ...((_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.type) !== "disabled" && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display) && {
3084
- display: anthropicOptions.thinking.display
3085
- }
3485
+ ...thinkingDisplay != null && { display: thinkingDisplay }
3086
3486
  }
3087
3487
  },
3088
- ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3488
+ ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3089
3489
  output_config: {
3090
3490
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
3091
3491
  effort: anthropicOptions.effort
3092
3492
  },
3493
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
3494
+ task_budget: {
3495
+ type: anthropicOptions.taskBudget.type,
3496
+ total: anthropicOptions.taskBudget.total,
3497
+ ...anthropicOptions.taskBudget.remaining != null && {
3498
+ remaining: anthropicOptions.taskBudget.remaining
3499
+ }
3500
+ }
3501
+ },
3093
3502
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
3094
3503
  format: {
3095
3504
  type: "json_schema",
3096
- schema: responseFormat.schema
3505
+ schema: sanitizeJsonSchema(responseFormat.schema)
3097
3506
  }
3098
3507
  }
3099
3508
  }
@@ -3101,19 +3510,20 @@ var AnthropicMessagesLanguageModel = class {
3101
3510
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
3102
3511
  speed: anthropicOptions.speed
3103
3512
  },
3104
- ...(anthropicOptions == null ? void 0 : anthropicOptions.metadata) && {
3105
- metadata: {
3106
- ...anthropicOptions.metadata.userId && {
3107
- user_id: anthropicOptions.metadata.userId
3108
- }
3109
- }
3513
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3514
+ inference_geo: anthropicOptions.inferenceGeo
3110
3515
  },
3111
- ...(anthropicOptions == null ? void 0 : anthropicOptions.serviceTier) && {
3112
- service_tier: anthropicOptions.serviceTier
3516
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.advisor) && {
3517
+ advisor: {
3518
+ model: anthropicOptions.advisor.model
3519
+ }
3113
3520
  },
3114
3521
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3115
3522
  cache_control: anthropicOptions.cacheControl
3116
3523
  },
3524
+ ...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
3525
+ metadata: { user_id: anthropicOptions.metadata.userId }
3526
+ },
3117
3527
  // mcp servers:
3118
3528
  ...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
3119
3529
  mcp_servers: anthropicOptions.mcpServers.map((server) => ({
@@ -3135,7 +3545,10 @@ var AnthropicMessagesLanguageModel = class {
3135
3545
  id: anthropicOptions.container.id,
3136
3546
  skills: anthropicOptions.container.skills.map((skill) => ({
3137
3547
  type: skill.type,
3138
- skill_id: skill.skillId,
3548
+ skill_id: skill.type === "custom" ? resolveProviderReference2({
3549
+ reference: skill.providerReference,
3550
+ provider: "anthropic"
3551
+ }) : skill.skillId,
3139
3552
  version: skill.version
3140
3553
  }))
3141
3554
  }
@@ -3236,28 +3649,20 @@ var AnthropicMessagesLanguageModel = class {
3236
3649
  });
3237
3650
  }
3238
3651
  baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
3239
- } else {
3240
- if (topP != null && temperature != null) {
3241
- warnings.push({
3242
- type: "unsupported",
3243
- feature: "topP",
3244
- details: `topP is not supported when temperature is set. topP is ignored.`
3245
- });
3246
- baseArgs.top_p = void 0;
3247
- }
3248
3652
  }
3249
- if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
3653
+ const effectiveMaxTokens = (anthropicOptions == null ? void 0 : anthropicOptions.output300k) ? Math.max(maxOutputTokensForModel, 3e5) : maxOutputTokensForModel;
3654
+ if (isKnownModel && baseArgs.max_tokens > effectiveMaxTokens) {
3250
3655
  if (maxOutputTokens != null) {
3251
3656
  warnings.push({
3252
3657
  type: "unsupported",
3253
3658
  feature: "maxOutputTokens",
3254
- details: `${baseArgs.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${maxOutputTokensForModel} max output tokens. The max output tokens have been limited to ${maxOutputTokensForModel}.`
3659
+ details: `${baseArgs.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${effectiveMaxTokens} max output tokens. The max output tokens have been limited to ${effectiveMaxTokens}.`
3255
3660
  });
3256
3661
  }
3257
- baseArgs.max_tokens = maxOutputTokensForModel;
3662
+ baseArgs.max_tokens = effectiveMaxTokens;
3258
3663
  }
3259
3664
  if ((anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0) {
3260
- betas.add("mcp-client-2025-04-04");
3665
+ betas.add("mcp-client-2025-11-20");
3261
3666
  }
3262
3667
  if (contextManagement) {
3263
3668
  betas.add("context-management-2025-06-27");
@@ -3281,12 +3686,19 @@ var AnthropicMessagesLanguageModel = class {
3281
3686
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
3282
3687
  betas.add("effort-2025-11-24");
3283
3688
  }
3689
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
3690
+ betas.add("task-budgets-2026-03-13");
3691
+ }
3284
3692
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3285
3693
  betas.add("fast-mode-2026-02-01");
3286
3694
  }
3287
- if (stream && ((_i = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _i : true)) {
3288
- betas.add("fine-grained-tool-streaming-2025-05-14");
3695
+ if (anthropicOptions == null ? void 0 : anthropicOptions.advisor) {
3696
+ betas.add("advisor-tool-2026-03-01");
3289
3697
  }
3698
+ if (anthropicOptions == null ? void 0 : anthropicOptions.output300k) {
3699
+ betas.add("output-300k-2026-03-24");
3700
+ }
3701
+ const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
3290
3702
  const {
3291
3703
  tools: anthropicTools2,
3292
3704
  toolChoice: anthropicToolChoice,
@@ -3299,14 +3711,16 @@ var AnthropicMessagesLanguageModel = class {
3299
3711
  disableParallelToolUse: true,
3300
3712
  cacheControlValidator,
3301
3713
  supportsStructuredOutput: false,
3302
- supportsStrictTools
3714
+ supportsStrictTools,
3715
+ defaultEagerInputStreaming
3303
3716
  } : {
3304
3717
  tools: tools != null ? tools : [],
3305
3718
  toolChoice,
3306
3719
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3307
3720
  cacheControlValidator,
3308
3721
  supportsStructuredOutput,
3309
- supportsStrictTools
3722
+ supportsStrictTools,
3723
+ defaultEagerInputStreaming
3310
3724
  }
3311
3725
  );
3312
3726
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3323,7 +3737,7 @@ var AnthropicMessagesLanguageModel = class {
3323
3737
  ...betas,
3324
3738
  ...toolsBetas,
3325
3739
  ...userSuppliedBetas,
3326
- ...(_j = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _j : []
3740
+ ...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
3327
3741
  ]),
3328
3742
  usesJsonResponseTool: jsonResponseTool != null,
3329
3743
  toolNameMapping,
@@ -3335,16 +3749,16 @@ var AnthropicMessagesLanguageModel = class {
3335
3749
  betas,
3336
3750
  headers
3337
3751
  }) {
3338
- return (0, import_provider_utils15.combineHeaders)(
3339
- await (0, import_provider_utils15.resolve)(this.config.headers),
3752
+ return combineHeaders(
3753
+ this.config.headers ? await resolve(this.config.headers) : void 0,
3340
3754
  headers,
3341
3755
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
3342
3756
  );
3343
3757
  }
3344
3758
  async getBetasFromHeaders(requestHeaders) {
3345
3759
  var _a, _b;
3346
- const configHeaders = await (0, import_provider_utils15.resolve)(this.config.headers);
3347
- const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
3760
+ const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
3761
+ const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
3348
3762
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
3349
3763
  return new Set(
3350
3764
  [
@@ -3409,13 +3823,13 @@ var AnthropicMessagesLanguageModel = class {
3409
3823
  responseHeaders,
3410
3824
  value: response,
3411
3825
  rawValue: rawResponse
3412
- } = await (0, import_provider_utils15.postJsonToApi)({
3826
+ } = await postJsonToApi({
3413
3827
  url: this.buildRequestUrl(false),
3414
3828
  headers: await this.getHeaders({ betas, headers: options.headers }),
3415
3829
  body: this.transformRequestBody(args, betas),
3416
3830
  failedResponseHandler: anthropicFailedResponseHandler,
3417
- successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3418
- anthropicMessagesResponseSchema
3831
+ successfulResponseHandler: createJsonResponseHandler(
3832
+ anthropicResponseSchema
3419
3833
  ),
3420
3834
  abortSignal: options.abortSignal,
3421
3835
  fetch: this.config.fetch
@@ -3764,7 +4178,7 @@ var AnthropicMessagesLanguageModel = class {
3764
4178
  }),
3765
4179
  raw: (_e = response.stop_reason) != null ? _e : void 0
3766
4180
  },
3767
- usage: convertAnthropicMessagesUsage({ usage: response.usage }),
4181
+ usage: convertAnthropicUsage({ usage: response.usage }),
3768
4182
  request: { body: args },
3769
4183
  response: {
3770
4184
  id: (_f = response.id) != null ? _f : void 0,
@@ -3774,11 +4188,12 @@ var AnthropicMessagesLanguageModel = class {
3774
4188
  },
3775
4189
  warnings,
3776
4190
  providerMetadata: (() => {
3777
- var _a2, _b2, _c2, _d2, _e2;
4191
+ var _a2, _b2, _c2, _d2, _e2, _f2;
3778
4192
  const anthropicMetadata = {
3779
4193
  usage: response.usage,
3780
4194
  cacheCreationInputTokens: (_a2 = response.usage.cache_creation_input_tokens) != null ? _a2 : null,
3781
- stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
4195
+ cacheReadInputTokens: (_b2 = response.usage.cache_read_input_tokens) != null ? _b2 : null,
4196
+ stopSequence: (_c2 = response.stop_sequence) != null ? _c2 : null,
3782
4197
  iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
3783
4198
  type: iter.type,
3784
4199
  inputTokens: iter.input_tokens,
@@ -3787,15 +4202,15 @@ var AnthropicMessagesLanguageModel = class {
3787
4202
  container: response.container ? {
3788
4203
  expiresAt: response.container.expires_at,
3789
4204
  id: response.container.id,
3790
- skills: (_d2 = (_c2 = response.container.skills) == null ? void 0 : _c2.map((skill) => ({
4205
+ skills: (_e2 = (_d2 = response.container.skills) == null ? void 0 : _d2.map((skill) => ({
3791
4206
  type: skill.type,
3792
4207
  skillId: skill.skill_id,
3793
4208
  version: skill.version
3794
- }))) != null ? _d2 : null
4209
+ }))) != null ? _e2 : null
3795
4210
  } : null,
3796
- contextManagement: (_e2 = mapAnthropicResponseContextManagement(
4211
+ contextManagement: (_f2 = mapAnthropicResponseContextManagement(
3797
4212
  response.context_management
3798
- )) != null ? _e2 : null
4213
+ )) != null ? _f2 : null
3799
4214
  };
3800
4215
  const providerMetadata = {
3801
4216
  anthropic: anthropicMetadata
@@ -3808,6 +4223,7 @@ var AnthropicMessagesLanguageModel = class {
3808
4223
  };
3809
4224
  }
3810
4225
  async doStream(options) {
4226
+ "use step";
3811
4227
  var _a, _b;
3812
4228
  const {
3813
4229
  args: body,
@@ -3829,14 +4245,12 @@ var AnthropicMessagesLanguageModel = class {
3829
4245
  body.tools
3830
4246
  );
3831
4247
  const url = this.buildRequestUrl(true);
3832
- const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
4248
+ const { responseHeaders, value: response } = await postJsonToApi({
3833
4249
  url,
3834
4250
  headers: await this.getHeaders({ betas, headers: options.headers }),
3835
4251
  body: this.transformRequestBody(body, betas),
3836
4252
  failedResponseHandler: anthropicFailedResponseHandler,
3837
- successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
3838
- anthropicMessagesChunkSchema
3839
- ),
4253
+ successfulResponseHandler: createEventSourceResponseHandler(anthropicChunkSchema),
3840
4254
  abortSignal: options.abortSignal,
3841
4255
  fetch: this.config.fetch
3842
4256
  });
@@ -3856,7 +4270,6 @@ var AnthropicMessagesLanguageModel = class {
3856
4270
  const serverToolCalls = {};
3857
4271
  let contextManagement = null;
3858
4272
  let rawUsage = void 0;
3859
- let cacheCreationInputTokens = null;
3860
4273
  let stopSequence = null;
3861
4274
  let container = null;
3862
4275
  let isJsonResponseFromTool = false;
@@ -3868,7 +4281,7 @@ var AnthropicMessagesLanguageModel = class {
3868
4281
  controller.enqueue({ type: "stream-start", warnings });
3869
4282
  },
3870
4283
  transform(chunk, controller) {
3871
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4284
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
3872
4285
  if (options.includeRawChunks) {
3873
4286
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3874
4287
  }
@@ -4403,7 +4816,6 @@ var AnthropicMessagesLanguageModel = class {
4403
4816
  rawUsage = {
4404
4817
  ...value.message.usage
4405
4818
  };
4406
- cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
4407
4819
  if (value.message.container != null) {
4408
4820
  container = {
4409
4821
  expiresAt: value.message.container.expires_at,
@@ -4422,8 +4834,8 @@ var AnthropicMessagesLanguageModel = class {
4422
4834
  }
4423
4835
  controller.enqueue({
4424
4836
  type: "response-metadata",
4425
- id: (_h = value.message.id) != null ? _h : void 0,
4426
- modelId: (_i = value.message.model) != null ? _i : void 0
4837
+ id: (_g = value.message.id) != null ? _g : void 0,
4838
+ modelId: (_h = value.message.model) != null ? _h : void 0
4427
4839
  });
4428
4840
  if (value.message.content != null) {
4429
4841
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
@@ -4439,7 +4851,7 @@ var AnthropicMessagesLanguageModel = class {
4439
4851
  id: part.id,
4440
4852
  toolName: part.name
4441
4853
  });
4442
- const inputStr = JSON.stringify((_j = part.input) != null ? _j : {});
4854
+ const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
4443
4855
  controller.enqueue({
4444
4856
  type: "tool-input-delta",
4445
4857
  id: part.id,
@@ -4477,7 +4889,6 @@ var AnthropicMessagesLanguageModel = class {
4477
4889
  }
4478
4890
  if (value.usage.cache_creation_input_tokens != null) {
4479
4891
  usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
4480
- cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
4481
4892
  }
4482
4893
  if (value.usage.iterations != null) {
4483
4894
  usage.iterations = value.usage.iterations;
@@ -4487,17 +4898,17 @@ var AnthropicMessagesLanguageModel = class {
4487
4898
  finishReason: value.delta.stop_reason,
4488
4899
  isJsonResponseFromTool
4489
4900
  }),
4490
- raw: (_k = value.delta.stop_reason) != null ? _k : void 0
4901
+ raw: (_j = value.delta.stop_reason) != null ? _j : void 0
4491
4902
  };
4492
- stopSequence = (_l = value.delta.stop_sequence) != null ? _l : null;
4903
+ stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
4493
4904
  container = value.delta.container != null ? {
4494
4905
  expiresAt: value.delta.container.expires_at,
4495
4906
  id: value.delta.container.id,
4496
- skills: (_n = (_m = value.delta.container.skills) == null ? void 0 : _m.map((skill) => ({
4907
+ skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
4497
4908
  type: skill.type,
4498
4909
  skillId: skill.skill_id,
4499
4910
  version: skill.version
4500
- }))) != null ? _n : null
4911
+ }))) != null ? _m : null
4501
4912
  } : null;
4502
4913
  if (value.context_management) {
4503
4914
  contextManagement = mapAnthropicResponseContextManagement(
@@ -4513,7 +4924,8 @@ var AnthropicMessagesLanguageModel = class {
4513
4924
  case "message_stop": {
4514
4925
  const anthropicMetadata = {
4515
4926
  usage: rawUsage != null ? rawUsage : null,
4516
- cacheCreationInputTokens,
4927
+ cacheCreationInputTokens: (_n = usage.cache_creation_input_tokens) != null ? _n : null,
4928
+ cacheReadInputTokens: (_o = usage.cache_read_input_tokens) != null ? _o : null,
4517
4929
  stopSequence,
4518
4930
  iterations: usage.iterations ? usage.iterations.map((iter) => ({
4519
4931
  type: iter.type,
@@ -4532,7 +4944,7 @@ var AnthropicMessagesLanguageModel = class {
4532
4944
  controller.enqueue({
4533
4945
  type: "finish",
4534
4946
  finishReason,
4535
- usage: convertAnthropicMessagesUsage({ usage, rawUsage }),
4947
+ usage: convertAnthropicUsage({ usage, rawUsage }),
4536
4948
  providerMetadata
4537
4949
  });
4538
4950
  return;
@@ -4559,7 +4971,7 @@ var AnthropicMessagesLanguageModel = class {
4559
4971
  }
4560
4972
  if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
4561
4973
  const error = result.value.error;
4562
- throw new import_provider3.APICallError({
4974
+ throw new APICallError({
4563
4975
  message: error.message,
4564
4976
  url,
4565
4977
  requestBodyValues: body,
@@ -4582,11 +4994,22 @@ var AnthropicMessagesLanguageModel = class {
4582
4994
  }
4583
4995
  };
4584
4996
  function getModelCapabilities(modelId) {
4585
- if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4997
+ if (modelId.includes("claude-opus-4-7")) {
4586
4998
  return {
4587
4999
  maxOutputTokens: 128e3,
4588
5000
  supportsStructuredOutput: true,
4589
5001
  supportsAdaptiveThinking: true,
5002
+ rejectsSamplingParameters: true,
5003
+ supportsXhighEffort: true,
5004
+ isKnownModel: true
5005
+ };
5006
+ } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
5007
+ return {
5008
+ maxOutputTokens: 128e3,
5009
+ supportsStructuredOutput: true,
5010
+ supportsAdaptiveThinking: true,
5011
+ rejectsSamplingParameters: false,
5012
+ supportsXhighEffort: false,
4590
5013
  isKnownModel: true
4591
5014
  };
4592
5015
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
@@ -4594,6 +5017,8 @@ function getModelCapabilities(modelId) {
4594
5017
  maxOutputTokens: 64e3,
4595
5018
  supportsStructuredOutput: true,
4596
5019
  supportsAdaptiveThinking: false,
5020
+ rejectsSamplingParameters: false,
5021
+ supportsXhighEffort: false,
4597
5022
  isKnownModel: true
4598
5023
  };
4599
5024
  } else if (modelId.includes("claude-opus-4-1")) {
@@ -4601,6 +5026,8 @@ function getModelCapabilities(modelId) {
4601
5026
  maxOutputTokens: 32e3,
4602
5027
  supportsStructuredOutput: true,
4603
5028
  supportsAdaptiveThinking: false,
5029
+ rejectsSamplingParameters: false,
5030
+ supportsXhighEffort: false,
4604
5031
  isKnownModel: true
4605
5032
  };
4606
5033
  } else if (modelId.includes("claude-sonnet-4-")) {
@@ -4608,6 +5035,8 @@ function getModelCapabilities(modelId) {
4608
5035
  maxOutputTokens: 64e3,
4609
5036
  supportsStructuredOutput: false,
4610
5037
  supportsAdaptiveThinking: false,
5038
+ rejectsSamplingParameters: false,
5039
+ supportsXhighEffort: false,
4611
5040
  isKnownModel: true
4612
5041
  };
4613
5042
  } else if (modelId.includes("claude-opus-4-")) {
@@ -4615,6 +5044,8 @@ function getModelCapabilities(modelId) {
4615
5044
  maxOutputTokens: 32e3,
4616
5045
  supportsStructuredOutput: false,
4617
5046
  supportsAdaptiveThinking: false,
5047
+ rejectsSamplingParameters: false,
5048
+ supportsXhighEffort: false,
4618
5049
  isKnownModel: true
4619
5050
  };
4620
5051
  } else if (modelId.includes("claude-3-haiku")) {
@@ -4622,6 +5053,8 @@ function getModelCapabilities(modelId) {
4622
5053
  maxOutputTokens: 4096,
4623
5054
  supportsStructuredOutput: false,
4624
5055
  supportsAdaptiveThinking: false,
5056
+ rejectsSamplingParameters: false,
5057
+ supportsXhighEffort: false,
4625
5058
  isKnownModel: true
4626
5059
  };
4627
5060
  } else {
@@ -4629,6 +5062,8 @@ function getModelCapabilities(modelId) {
4629
5062
  maxOutputTokens: 4096,
4630
5063
  supportsStructuredOutput: false,
4631
5064
  supportsAdaptiveThinking: false,
5065
+ rejectsSamplingParameters: false,
5066
+ supportsXhighEffort: false,
4632
5067
  isKnownModel: false
4633
5068
  };
4634
5069
  }
@@ -4654,30 +5089,31 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
4654
5089
  function resolveAnthropicReasoningConfig({
4655
5090
  reasoning,
4656
5091
  supportsAdaptiveThinking,
5092
+ supportsXhighEffort,
4657
5093
  maxOutputTokensForModel,
4658
5094
  warnings
4659
5095
  }) {
4660
- if (!(0, import_provider_utils15.isCustomReasoning)(reasoning)) {
5096
+ if (!isCustomReasoning(reasoning)) {
4661
5097
  return void 0;
4662
5098
  }
4663
5099
  if (reasoning === "none") {
4664
5100
  return { thinking: { type: "disabled" } };
4665
5101
  }
4666
5102
  if (supportsAdaptiveThinking) {
4667
- const effort = (0, import_provider_utils15.mapReasoningToProviderEffort)({
5103
+ const effort = mapReasoningToProviderEffort({
4668
5104
  reasoning,
4669
5105
  effortMap: {
4670
5106
  minimal: "low",
4671
5107
  low: "low",
4672
5108
  medium: "medium",
4673
5109
  high: "high",
4674
- xhigh: "max"
5110
+ xhigh: supportsXhighEffort ? "xhigh" : "max"
4675
5111
  },
4676
5112
  warnings
4677
5113
  });
4678
5114
  return { thinking: { type: "adaptive" }, effort };
4679
5115
  }
4680
- const budgetTokens = (0, import_provider_utils15.mapReasoningToProviderBudget)({
5116
+ const budgetTokens = mapReasoningToProviderBudget({
4681
5117
  reasoning,
4682
5118
  maxOutputTokens: maxOutputTokensForModel,
4683
5119
  maxReasoningBudget: maxOutputTokensForModel,
@@ -4715,44 +5151,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
4715
5151
  }
4716
5152
 
4717
5153
  // src/tool/bash_20241022.ts
4718
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
4719
- var import_v413 = require("zod/v4");
4720
- var bash_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
4721
- () => (0, import_provider_utils16.zodSchema)(
4722
- import_v413.z.object({
4723
- command: import_v413.z.string(),
4724
- restart: import_v413.z.boolean().optional()
5154
+ import {
5155
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
5156
+ lazySchema as lazySchema13,
5157
+ zodSchema as zodSchema13
5158
+ } from "@ai-sdk/provider-utils";
5159
+ import { z as z14 } from "zod/v4";
5160
+ var bash_20241022InputSchema = lazySchema13(
5161
+ () => zodSchema13(
5162
+ z14.object({
5163
+ command: z14.string(),
5164
+ restart: z14.boolean().optional()
4725
5165
  })
4726
5166
  )
4727
5167
  );
4728
- var bash_20241022 = (0, import_provider_utils16.createProviderToolFactory)({
5168
+ var bash_20241022 = createProviderDefinedToolFactory2({
4729
5169
  id: "anthropic.bash_20241022",
4730
5170
  inputSchema: bash_20241022InputSchema
4731
5171
  });
4732
5172
 
4733
5173
  // src/tool/bash_20250124.ts
4734
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
4735
- var import_v414 = require("zod/v4");
4736
- var bash_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
4737
- () => (0, import_provider_utils17.zodSchema)(
4738
- import_v414.z.object({
4739
- command: import_v414.z.string(),
4740
- restart: import_v414.z.boolean().optional()
5174
+ import {
5175
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
5176
+ lazySchema as lazySchema14,
5177
+ zodSchema as zodSchema14
5178
+ } from "@ai-sdk/provider-utils";
5179
+ import { z as z15 } from "zod/v4";
5180
+ var bash_20250124InputSchema = lazySchema14(
5181
+ () => zodSchema14(
5182
+ z15.object({
5183
+ command: z15.string(),
5184
+ restart: z15.boolean().optional()
4741
5185
  })
4742
5186
  )
4743
5187
  );
4744
- var bash_20250124 = (0, import_provider_utils17.createProviderToolFactory)({
5188
+ var bash_20250124 = createProviderDefinedToolFactory3({
4745
5189
  id: "anthropic.bash_20250124",
4746
5190
  inputSchema: bash_20250124InputSchema
4747
5191
  });
4748
5192
 
4749
5193
  // src/tool/computer_20241022.ts
4750
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
4751
- var import_v415 = require("zod/v4");
4752
- var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4753
- () => (0, import_provider_utils18.zodSchema)(
4754
- import_v415.z.object({
4755
- action: import_v415.z.enum([
5194
+ import {
5195
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
5196
+ lazySchema as lazySchema15,
5197
+ zodSchema as zodSchema15
5198
+ } from "@ai-sdk/provider-utils";
5199
+ import { z as z16 } from "zod/v4";
5200
+ var computer_20241022InputSchema = lazySchema15(
5201
+ () => zodSchema15(
5202
+ z16.object({
5203
+ action: z16.enum([
4756
5204
  "key",
4757
5205
  "type",
4758
5206
  "mouse_move",
@@ -4764,23 +5212,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4764
5212
  "screenshot",
4765
5213
  "cursor_position"
4766
5214
  ]),
4767
- coordinate: import_v415.z.array(import_v415.z.number().int()).optional(),
4768
- text: import_v415.z.string().optional()
5215
+ coordinate: z16.array(z16.number().int()).optional(),
5216
+ text: z16.string().optional()
4769
5217
  })
4770
5218
  )
4771
5219
  );
4772
- var computer_20241022 = (0, import_provider_utils18.createProviderToolFactory)({
5220
+ var computer_20241022 = createProviderDefinedToolFactory4({
4773
5221
  id: "anthropic.computer_20241022",
4774
5222
  inputSchema: computer_20241022InputSchema
4775
5223
  });
4776
5224
 
4777
5225
  // src/tool/computer_20250124.ts
4778
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
4779
- var import_v416 = require("zod/v4");
4780
- var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4781
- () => (0, import_provider_utils19.zodSchema)(
4782
- import_v416.z.object({
4783
- action: import_v416.z.enum([
5226
+ import {
5227
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
5228
+ lazySchema as lazySchema16,
5229
+ zodSchema as zodSchema16
5230
+ } from "@ai-sdk/provider-utils";
5231
+ import { z as z17 } from "zod/v4";
5232
+ var computer_20250124InputSchema = lazySchema16(
5233
+ () => zodSchema16(
5234
+ z17.object({
5235
+ action: z17.enum([
4784
5236
  "key",
4785
5237
  "hold_key",
4786
5238
  "type",
@@ -4798,27 +5250,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4798
5250
  "wait",
4799
5251
  "screenshot"
4800
5252
  ]),
4801
- coordinate: import_v416.z.tuple([import_v416.z.number().int(), import_v416.z.number().int()]).optional(),
4802
- duration: import_v416.z.number().optional(),
4803
- scroll_amount: import_v416.z.number().optional(),
4804
- scroll_direction: import_v416.z.enum(["up", "down", "left", "right"]).optional(),
4805
- start_coordinate: import_v416.z.tuple([import_v416.z.number().int(), import_v416.z.number().int()]).optional(),
4806
- text: import_v416.z.string().optional()
5253
+ coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5254
+ duration: z17.number().optional(),
5255
+ scroll_amount: z17.number().optional(),
5256
+ scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
5257
+ start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5258
+ text: z17.string().optional()
4807
5259
  })
4808
5260
  )
4809
5261
  );
4810
- var computer_20250124 = (0, import_provider_utils19.createProviderToolFactory)({
5262
+ var computer_20250124 = createProviderDefinedToolFactory5({
4811
5263
  id: "anthropic.computer_20250124",
4812
5264
  inputSchema: computer_20250124InputSchema
4813
5265
  });
4814
5266
 
4815
5267
  // src/tool/computer_20251124.ts
4816
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
4817
- var import_v417 = require("zod/v4");
4818
- var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4819
- () => (0, import_provider_utils20.zodSchema)(
4820
- import_v417.z.object({
4821
- action: import_v417.z.enum([
5268
+ import {
5269
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
5270
+ lazySchema as lazySchema17,
5271
+ zodSchema as zodSchema17
5272
+ } from "@ai-sdk/provider-utils";
5273
+ import { z as z18 } from "zod/v4";
5274
+ var computer_20251124InputSchema = lazySchema17(
5275
+ () => zodSchema17(
5276
+ z18.object({
5277
+ action: z18.enum([
4822
5278
  "key",
4823
5279
  "hold_key",
4824
5280
  "type",
@@ -4837,173 +5293,193 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4837
5293
  "screenshot",
4838
5294
  "zoom"
4839
5295
  ]),
4840
- coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
4841
- duration: import_v417.z.number().optional(),
4842
- region: import_v417.z.tuple([
4843
- import_v417.z.number().int(),
4844
- import_v417.z.number().int(),
4845
- import_v417.z.number().int(),
4846
- import_v417.z.number().int()
5296
+ coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
5297
+ duration: z18.number().optional(),
5298
+ region: z18.tuple([
5299
+ z18.number().int(),
5300
+ z18.number().int(),
5301
+ z18.number().int(),
5302
+ z18.number().int()
4847
5303
  ]).optional(),
4848
- scroll_amount: import_v417.z.number().optional(),
4849
- scroll_direction: import_v417.z.enum(["up", "down", "left", "right"]).optional(),
4850
- start_coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
4851
- text: import_v417.z.string().optional()
5304
+ scroll_amount: z18.number().optional(),
5305
+ scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
5306
+ start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
5307
+ text: z18.string().optional()
4852
5308
  })
4853
5309
  )
4854
5310
  );
4855
- var computer_20251124 = (0, import_provider_utils20.createProviderToolFactory)({
5311
+ var computer_20251124 = createProviderDefinedToolFactory6({
4856
5312
  id: "anthropic.computer_20251124",
4857
5313
  inputSchema: computer_20251124InputSchema
4858
5314
  });
4859
5315
 
4860
5316
  // src/tool/memory_20250818.ts
4861
- var import_provider_utils21 = require("@ai-sdk/provider-utils");
4862
- var import_v418 = require("zod/v4");
4863
- var memory_20250818InputSchema = (0, import_provider_utils21.lazySchema)(
4864
- () => (0, import_provider_utils21.zodSchema)(
4865
- import_v418.z.discriminatedUnion("command", [
4866
- import_v418.z.object({
4867
- command: import_v418.z.literal("view"),
4868
- path: import_v418.z.string(),
4869
- view_range: import_v418.z.tuple([import_v418.z.number(), import_v418.z.number()]).optional()
5317
+ import {
5318
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
5319
+ lazySchema as lazySchema18,
5320
+ zodSchema as zodSchema18
5321
+ } from "@ai-sdk/provider-utils";
5322
+ import { z as z19 } from "zod/v4";
5323
+ var memory_20250818InputSchema = lazySchema18(
5324
+ () => zodSchema18(
5325
+ z19.discriminatedUnion("command", [
5326
+ z19.object({
5327
+ command: z19.literal("view"),
5328
+ path: z19.string(),
5329
+ view_range: z19.tuple([z19.number(), z19.number()]).optional()
4870
5330
  }),
4871
- import_v418.z.object({
4872
- command: import_v418.z.literal("create"),
4873
- path: import_v418.z.string(),
4874
- file_text: import_v418.z.string()
5331
+ z19.object({
5332
+ command: z19.literal("create"),
5333
+ path: z19.string(),
5334
+ file_text: z19.string()
4875
5335
  }),
4876
- import_v418.z.object({
4877
- command: import_v418.z.literal("str_replace"),
4878
- path: import_v418.z.string(),
4879
- old_str: import_v418.z.string(),
4880
- new_str: import_v418.z.string()
5336
+ z19.object({
5337
+ command: z19.literal("str_replace"),
5338
+ path: z19.string(),
5339
+ old_str: z19.string(),
5340
+ new_str: z19.string()
4881
5341
  }),
4882
- import_v418.z.object({
4883
- command: import_v418.z.literal("insert"),
4884
- path: import_v418.z.string(),
4885
- insert_line: import_v418.z.number(),
4886
- insert_text: import_v418.z.string()
5342
+ z19.object({
5343
+ command: z19.literal("insert"),
5344
+ path: z19.string(),
5345
+ insert_line: z19.number(),
5346
+ insert_text: z19.string()
4887
5347
  }),
4888
- import_v418.z.object({
4889
- command: import_v418.z.literal("delete"),
4890
- path: import_v418.z.string()
5348
+ z19.object({
5349
+ command: z19.literal("delete"),
5350
+ path: z19.string()
4891
5351
  }),
4892
- import_v418.z.object({
4893
- command: import_v418.z.literal("rename"),
4894
- old_path: import_v418.z.string(),
4895
- new_path: import_v418.z.string()
5352
+ z19.object({
5353
+ command: z19.literal("rename"),
5354
+ old_path: z19.string(),
5355
+ new_path: z19.string()
4896
5356
  })
4897
5357
  ])
4898
5358
  )
4899
5359
  );
4900
- var memory_20250818 = (0, import_provider_utils21.createProviderToolFactory)({
5360
+ var memory_20250818 = createProviderDefinedToolFactory7({
4901
5361
  id: "anthropic.memory_20250818",
4902
5362
  inputSchema: memory_20250818InputSchema
4903
5363
  });
4904
5364
 
4905
5365
  // src/tool/text-editor_20241022.ts
4906
- var import_provider_utils22 = require("@ai-sdk/provider-utils");
4907
- var import_v419 = require("zod/v4");
4908
- var textEditor_20241022InputSchema = (0, import_provider_utils22.lazySchema)(
4909
- () => (0, import_provider_utils22.zodSchema)(
4910
- import_v419.z.object({
4911
- command: import_v419.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
4912
- path: import_v419.z.string(),
4913
- file_text: import_v419.z.string().optional(),
4914
- insert_line: import_v419.z.number().int().optional(),
4915
- new_str: import_v419.z.string().optional(),
4916
- insert_text: import_v419.z.string().optional(),
4917
- old_str: import_v419.z.string().optional(),
4918
- view_range: import_v419.z.array(import_v419.z.number().int()).optional()
5366
+ import {
5367
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
5368
+ lazySchema as lazySchema19,
5369
+ zodSchema as zodSchema19
5370
+ } from "@ai-sdk/provider-utils";
5371
+ import { z as z20 } from "zod/v4";
5372
+ var textEditor_20241022InputSchema = lazySchema19(
5373
+ () => zodSchema19(
5374
+ z20.object({
5375
+ command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5376
+ path: z20.string(),
5377
+ file_text: z20.string().optional(),
5378
+ insert_line: z20.number().int().optional(),
5379
+ new_str: z20.string().optional(),
5380
+ insert_text: z20.string().optional(),
5381
+ old_str: z20.string().optional(),
5382
+ view_range: z20.array(z20.number().int()).optional()
4919
5383
  })
4920
5384
  )
4921
5385
  );
4922
- var textEditor_20241022 = (0, import_provider_utils22.createProviderToolFactory)({
5386
+ var textEditor_20241022 = createProviderDefinedToolFactory8({
4923
5387
  id: "anthropic.text_editor_20241022",
4924
5388
  inputSchema: textEditor_20241022InputSchema
4925
5389
  });
4926
5390
 
4927
5391
  // src/tool/text-editor_20250124.ts
4928
- var import_provider_utils23 = require("@ai-sdk/provider-utils");
4929
- var import_v420 = require("zod/v4");
4930
- var textEditor_20250124InputSchema = (0, import_provider_utils23.lazySchema)(
4931
- () => (0, import_provider_utils23.zodSchema)(
4932
- import_v420.z.object({
4933
- command: import_v420.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
4934
- path: import_v420.z.string(),
4935
- file_text: import_v420.z.string().optional(),
4936
- insert_line: import_v420.z.number().int().optional(),
4937
- new_str: import_v420.z.string().optional(),
4938
- insert_text: import_v420.z.string().optional(),
4939
- old_str: import_v420.z.string().optional(),
4940
- view_range: import_v420.z.array(import_v420.z.number().int()).optional()
5392
+ import {
5393
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
5394
+ lazySchema as lazySchema20,
5395
+ zodSchema as zodSchema20
5396
+ } from "@ai-sdk/provider-utils";
5397
+ import { z as z21 } from "zod/v4";
5398
+ var textEditor_20250124InputSchema = lazySchema20(
5399
+ () => zodSchema20(
5400
+ z21.object({
5401
+ command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5402
+ path: z21.string(),
5403
+ file_text: z21.string().optional(),
5404
+ insert_line: z21.number().int().optional(),
5405
+ new_str: z21.string().optional(),
5406
+ insert_text: z21.string().optional(),
5407
+ old_str: z21.string().optional(),
5408
+ view_range: z21.array(z21.number().int()).optional()
4941
5409
  })
4942
5410
  )
4943
5411
  );
4944
- var textEditor_20250124 = (0, import_provider_utils23.createProviderToolFactory)({
5412
+ var textEditor_20250124 = createProviderDefinedToolFactory9({
4945
5413
  id: "anthropic.text_editor_20250124",
4946
5414
  inputSchema: textEditor_20250124InputSchema
4947
5415
  });
4948
5416
 
4949
5417
  // src/tool/text-editor_20250429.ts
4950
- var import_provider_utils24 = require("@ai-sdk/provider-utils");
4951
- var import_v421 = require("zod/v4");
4952
- var textEditor_20250429InputSchema = (0, import_provider_utils24.lazySchema)(
4953
- () => (0, import_provider_utils24.zodSchema)(
4954
- import_v421.z.object({
4955
- command: import_v421.z.enum(["view", "create", "str_replace", "insert"]),
4956
- path: import_v421.z.string(),
4957
- file_text: import_v421.z.string().optional(),
4958
- insert_line: import_v421.z.number().int().optional(),
4959
- new_str: import_v421.z.string().optional(),
4960
- insert_text: import_v421.z.string().optional(),
4961
- old_str: import_v421.z.string().optional(),
4962
- view_range: import_v421.z.array(import_v421.z.number().int()).optional()
5418
+ import {
5419
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory10,
5420
+ lazySchema as lazySchema21,
5421
+ zodSchema as zodSchema21
5422
+ } from "@ai-sdk/provider-utils";
5423
+ import { z as z22 } from "zod/v4";
5424
+ var textEditor_20250429InputSchema = lazySchema21(
5425
+ () => zodSchema21(
5426
+ z22.object({
5427
+ command: z22.enum(["view", "create", "str_replace", "insert"]),
5428
+ path: z22.string(),
5429
+ file_text: z22.string().optional(),
5430
+ insert_line: z22.number().int().optional(),
5431
+ new_str: z22.string().optional(),
5432
+ insert_text: z22.string().optional(),
5433
+ old_str: z22.string().optional(),
5434
+ view_range: z22.array(z22.number().int()).optional()
4963
5435
  })
4964
5436
  )
4965
5437
  );
4966
- var textEditor_20250429 = (0, import_provider_utils24.createProviderToolFactory)({
5438
+ var textEditor_20250429 = createProviderDefinedToolFactory10({
4967
5439
  id: "anthropic.text_editor_20250429",
4968
5440
  inputSchema: textEditor_20250429InputSchema
4969
5441
  });
4970
5442
 
4971
5443
  // src/tool/tool-search-bm25_20251119.ts
4972
- var import_provider_utils25 = require("@ai-sdk/provider-utils");
4973
- var import_v422 = require("zod/v4");
4974
- var toolSearchBm25_20251119OutputSchema = (0, import_provider_utils25.lazySchema)(
4975
- () => (0, import_provider_utils25.zodSchema)(
4976
- import_v422.z.array(
4977
- import_v422.z.object({
4978
- type: import_v422.z.literal("tool_reference"),
4979
- toolName: import_v422.z.string()
5444
+ import {
5445
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory9,
5446
+ lazySchema as lazySchema22,
5447
+ zodSchema as zodSchema22
5448
+ } from "@ai-sdk/provider-utils";
5449
+ import { z as z23 } from "zod/v4";
5450
+ var toolSearchBm25_20251119OutputSchema = lazySchema22(
5451
+ () => zodSchema22(
5452
+ z23.array(
5453
+ z23.object({
5454
+ type: z23.literal("tool_reference"),
5455
+ toolName: z23.string()
4980
5456
  })
4981
5457
  )
4982
5458
  )
4983
5459
  );
4984
- var toolSearchBm25_20251119InputSchema = (0, import_provider_utils25.lazySchema)(
4985
- () => (0, import_provider_utils25.zodSchema)(
4986
- import_v422.z.object({
5460
+ var toolSearchBm25_20251119InputSchema = lazySchema22(
5461
+ () => zodSchema22(
5462
+ z23.object({
4987
5463
  /**
4988
5464
  * A natural language query to search for tools.
4989
5465
  * Claude will use BM25 text search to find relevant tools.
4990
5466
  */
4991
- query: import_v422.z.string(),
5467
+ query: z23.string(),
4992
5468
  /**
4993
5469
  * Maximum number of tools to return. Optional.
4994
5470
  */
4995
- limit: import_v422.z.number().optional()
5471
+ limit: z23.number().optional()
4996
5472
  })
4997
5473
  )
4998
5474
  );
4999
- var factory10 = (0, import_provider_utils25.createProviderToolFactoryWithOutputSchema)({
5475
+ var factory11 = createProviderExecutedToolFactory9({
5000
5476
  id: "anthropic.tool_search_bm25_20251119",
5001
5477
  inputSchema: toolSearchBm25_20251119InputSchema,
5002
5478
  outputSchema: toolSearchBm25_20251119OutputSchema,
5003
5479
  supportsDeferredResults: true
5004
5480
  });
5005
5481
  var toolSearchBm25_20251119 = (args = {}) => {
5006
- return factory10(args);
5482
+ return factory11(args);
5007
5483
  };
5008
5484
 
5009
5485
  // src/anthropic-tools.ts
@@ -5160,6 +5636,22 @@ var anthropicTools = {
5160
5636
  * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
5161
5637
  */
5162
5638
  webFetch_20260209,
5639
+ /**
5640
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
5641
+ * GA version (no beta header required). Includes caller restrictions, cache control,
5642
+ * deferred loading, and strict mode.
5643
+ *
5644
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
5645
+ * @param allowedDomains - Only fetch from these domains
5646
+ * @param blockedDomains - Never fetch from these domains
5647
+ * @param citations - Citations configuration for fetched documents
5648
+ * @param maxContentTokens - Max content tokens included in context
5649
+ * @param allowedCallers - Restrict callers (e.g. ["direct"] to prevent code_execution usage)
5650
+ * @param useCache - Whether to use cached content (set false for fresh content)
5651
+ * @param deferLoading - Defer loading until tool_search discovers it
5652
+ * @param strict - Enable strict schema validation
5653
+ */
5654
+ webFetch_20260309,
5163
5655
  /**
5164
5656
  * Creates a web search tool that gives Claude direct access to real-time web content.
5165
5657
  *
@@ -5207,11 +5699,11 @@ var anthropicTools = {
5207
5699
  */
5208
5700
  toolSearchBm25_20251119
5209
5701
  };
5210
- // Annotate the CommonJS export names for ESM import in node:
5211
- 0 && (module.exports = {
5212
- AnthropicMessagesLanguageModel,
5702
+ export {
5703
+ AnthropicLanguageModel,
5704
+ AnthropicLanguageModel as AnthropicMessagesLanguageModel,
5213
5705
  anthropicTools,
5214
5706
  getModelCapabilities,
5215
5707
  prepareTools
5216
- });
5708
+ };
5217
5709
  //# sourceMappingURL=index.js.map