@ai-sdk/anthropic 4.0.0-beta.4 → 4.0.0-beta.41

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 (53) hide show
  1. package/CHANGELOG.md +305 -4
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +83 -58
  4. package/dist/index.js +2043 -1356
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +85 -58
  7. package/dist/internal/index.js +1804 -1342
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/05-anthropic.mdx +116 -13
  10. package/package.json +14 -15
  11. package/src/{anthropic-messages-api.ts → anthropic-api.ts} +14 -6
  12. package/src/anthropic-error.ts +1 -1
  13. package/src/anthropic-files.ts +95 -0
  14. package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +263 -78
  15. package/src/anthropic-message-metadata.ts +1 -4
  16. package/src/{anthropic-messages-options.ts → anthropic-options.ts} +68 -11
  17. package/src/anthropic-prepare-tools.ts +14 -7
  18. package/src/anthropic-provider.ts +42 -13
  19. package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +4 -4
  20. package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +190 -149
  21. package/src/forward-anthropic-container-id-from-last-step.ts +2 -2
  22. package/src/get-cache-control.ts +5 -2
  23. package/src/index.ts +1 -1
  24. package/src/internal/index.ts +11 -2
  25. package/src/map-anthropic-stop-reason.ts +1 -1
  26. package/src/sanitize-json-schema.ts +203 -0
  27. package/src/skills/anthropic-skills-api.ts +44 -0
  28. package/src/skills/anthropic-skills.ts +132 -0
  29. package/src/tool/bash_20241022.ts +2 -2
  30. package/src/tool/bash_20250124.ts +2 -2
  31. package/src/tool/code-execution_20250522.ts +2 -2
  32. package/src/tool/code-execution_20250825.ts +2 -2
  33. package/src/tool/code-execution_20260120.ts +2 -2
  34. package/src/tool/computer_20241022.ts +2 -2
  35. package/src/tool/computer_20250124.ts +2 -2
  36. package/src/tool/computer_20251124.ts +2 -2
  37. package/src/tool/memory_20250818.ts +2 -2
  38. package/src/tool/text-editor_20241022.ts +2 -2
  39. package/src/tool/text-editor_20250124.ts +2 -2
  40. package/src/tool/text-editor_20250429.ts +2 -2
  41. package/src/tool/text-editor_20250728.ts +6 -3
  42. package/src/tool/tool-search-bm25_20251119.ts +2 -2
  43. package/src/tool/tool-search-regex_20251119.ts +2 -2
  44. package/src/tool/web-fetch-20250910.ts +2 -2
  45. package/src/tool/web-fetch-20260209.ts +2 -2
  46. package/src/tool/web-search_20250305.ts +2 -2
  47. package/src/tool/web-search_20260209.ts +2 -2
  48. package/dist/index.d.mts +0 -1090
  49. package/dist/index.mjs +0 -5244
  50. package/dist/index.mjs.map +0 -1
  51. package/dist/internal/index.d.mts +0 -969
  52. package/dist/internal/index.mjs +0 -5136
  53. package/dist/internal/index.mjs.map +0 -1
@@ -1,367 +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
- prepareTools: () => prepareTools
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
- // src/anthropic-messages-language-model.ts
30
- var import_provider3 = require("@ai-sdk/provider");
31
- 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";
32
22
 
33
23
  // src/anthropic-error.ts
34
- var import_provider_utils = require("@ai-sdk/provider-utils");
35
- var import_v4 = require("zod/v4");
36
- var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
37
- () => (0, import_provider_utils.zodSchema)(
38
- import_v4.z.object({
39
- type: import_v4.z.literal("error"),
40
- error: import_v4.z.object({
41
- type: import_v4.z.string(),
42
- 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()
43
37
  })
44
38
  })
45
39
  )
46
40
  );
47
- var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
41
+ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
48
42
  errorSchema: anthropicErrorDataSchema,
49
43
  errorToMessage: (data) => data.error.message
50
44
  });
51
45
 
52
- // src/anthropic-messages-api.ts
53
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
54
- var import_v42 = require("zod/v4");
55
- var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
56
- () => (0, import_provider_utils2.zodSchema)(
57
- import_v42.z.object({
58
- type: import_v42.z.literal("message"),
59
- id: import_v42.z.string().nullish(),
60
- model: import_v42.z.string().nullish(),
61
- content: import_v42.z.array(
62
- import_v42.z.discriminatedUnion("type", [
63
- import_v42.z.object({
64
- type: import_v42.z.literal("text"),
65
- text: import_v42.z.string(),
66
- citations: import_v42.z.array(
67
- import_v42.z.discriminatedUnion("type", [
68
- import_v42.z.object({
69
- type: import_v42.z.literal("web_search_result_location"),
70
- cited_text: import_v42.z.string(),
71
- url: import_v42.z.string(),
72
- title: import_v42.z.string(),
73
- 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()
74
71
  }),
75
- import_v42.z.object({
76
- type: import_v42.z.literal("page_location"),
77
- cited_text: import_v42.z.string(),
78
- document_index: import_v42.z.number(),
79
- document_title: import_v42.z.string().nullable(),
80
- start_page_number: import_v42.z.number(),
81
- 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()
82
79
  }),
83
- import_v42.z.object({
84
- type: import_v42.z.literal("char_location"),
85
- cited_text: import_v42.z.string(),
86
- document_index: import_v42.z.number(),
87
- document_title: import_v42.z.string().nullable(),
88
- start_char_index: import_v42.z.number(),
89
- 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()
90
87
  })
91
88
  ])
92
89
  ).optional()
93
90
  }),
94
- import_v42.z.object({
95
- type: import_v42.z.literal("thinking"),
96
- thinking: import_v42.z.string(),
97
- signature: import_v42.z.string()
91
+ z2.object({
92
+ type: z2.literal("thinking"),
93
+ thinking: z2.string(),
94
+ signature: z2.string()
98
95
  }),
99
- import_v42.z.object({
100
- type: import_v42.z.literal("redacted_thinking"),
101
- data: import_v42.z.string()
96
+ z2.object({
97
+ type: z2.literal("redacted_thinking"),
98
+ data: z2.string()
102
99
  }),
103
- import_v42.z.object({
104
- type: import_v42.z.literal("compaction"),
105
- content: import_v42.z.string()
100
+ z2.object({
101
+ type: z2.literal("compaction"),
102
+ content: z2.string()
106
103
  }),
107
- import_v42.z.object({
108
- type: import_v42.z.literal("tool_use"),
109
- id: import_v42.z.string(),
110
- name: import_v42.z.string(),
111
- 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(),
112
109
  // Programmatic tool calling: caller info when triggered from code execution
113
- caller: import_v42.z.union([
114
- import_v42.z.object({
115
- type: import_v42.z.literal("code_execution_20250825"),
116
- 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()
117
114
  }),
118
- import_v42.z.object({
119
- type: import_v42.z.literal("code_execution_20260120"),
120
- tool_id: import_v42.z.string()
115
+ z2.object({
116
+ type: z2.literal("code_execution_20260120"),
117
+ tool_id: z2.string()
121
118
  }),
122
- import_v42.z.object({
123
- type: import_v42.z.literal("direct")
119
+ z2.object({
120
+ type: z2.literal("direct")
124
121
  })
125
122
  ]).optional()
126
123
  }),
127
- import_v42.z.object({
128
- type: import_v42.z.literal("server_tool_use"),
129
- id: import_v42.z.string(),
130
- name: import_v42.z.string(),
131
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
132
- caller: import_v42.z.union([
133
- import_v42.z.object({
134
- type: import_v42.z.literal("code_execution_20260120"),
135
- 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()
136
133
  }),
137
- import_v42.z.object({
138
- type: import_v42.z.literal("direct")
134
+ z2.object({
135
+ type: z2.literal("direct")
139
136
  })
140
137
  ]).optional()
141
138
  }),
142
- import_v42.z.object({
143
- type: import_v42.z.literal("mcp_tool_use"),
144
- id: import_v42.z.string(),
145
- name: import_v42.z.string(),
146
- input: import_v42.z.unknown(),
147
- 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()
148
145
  }),
149
- import_v42.z.object({
150
- type: import_v42.z.literal("mcp_tool_result"),
151
- tool_use_id: import_v42.z.string(),
152
- is_error: import_v42.z.boolean(),
153
- content: import_v42.z.array(
154
- import_v42.z.union([
155
- import_v42.z.string(),
156
- 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() })
157
154
  ])
158
155
  )
159
156
  }),
160
- import_v42.z.object({
161
- type: import_v42.z.literal("web_fetch_tool_result"),
162
- tool_use_id: import_v42.z.string(),
163
- content: import_v42.z.union([
164
- import_v42.z.object({
165
- type: import_v42.z.literal("web_fetch_result"),
166
- url: import_v42.z.string(),
167
- retrieved_at: import_v42.z.string(),
168
- content: import_v42.z.object({
169
- type: import_v42.z.literal("document"),
170
- title: import_v42.z.string().nullable(),
171
- citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
172
- source: import_v42.z.union([
173
- import_v42.z.object({
174
- type: import_v42.z.literal("base64"),
175
- media_type: import_v42.z.literal("application/pdf"),
176
- 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()
177
174
  }),
178
- import_v42.z.object({
179
- type: import_v42.z.literal("text"),
180
- media_type: import_v42.z.literal("text/plain"),
181
- data: import_v42.z.string()
175
+ z2.object({
176
+ type: z2.literal("text"),
177
+ media_type: z2.literal("text/plain"),
178
+ data: z2.string()
182
179
  })
183
180
  ])
184
181
  })
185
182
  }),
186
- import_v42.z.object({
187
- type: import_v42.z.literal("web_fetch_tool_result_error"),
188
- error_code: import_v42.z.string()
183
+ z2.object({
184
+ type: z2.literal("web_fetch_tool_result_error"),
185
+ error_code: z2.string()
189
186
  })
190
187
  ])
191
188
  }),
192
- import_v42.z.object({
193
- type: import_v42.z.literal("web_search_tool_result"),
194
- tool_use_id: import_v42.z.string(),
195
- content: import_v42.z.union([
196
- import_v42.z.array(
197
- import_v42.z.object({
198
- type: import_v42.z.literal("web_search_result"),
199
- url: import_v42.z.string(),
200
- title: import_v42.z.string(),
201
- encrypted_content: import_v42.z.string(),
202
- 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()
203
200
  })
204
201
  ),
205
- import_v42.z.object({
206
- type: import_v42.z.literal("web_search_tool_result_error"),
207
- error_code: import_v42.z.string()
202
+ z2.object({
203
+ type: z2.literal("web_search_tool_result_error"),
204
+ error_code: z2.string()
208
205
  })
209
206
  ])
210
207
  }),
211
208
  // code execution results for code_execution_20250522 tool:
212
- import_v42.z.object({
213
- type: import_v42.z.literal("code_execution_tool_result"),
214
- tool_use_id: import_v42.z.string(),
215
- content: import_v42.z.union([
216
- import_v42.z.object({
217
- type: import_v42.z.literal("code_execution_result"),
218
- stdout: import_v42.z.string(),
219
- stderr: import_v42.z.string(),
220
- return_code: import_v42.z.number(),
221
- content: import_v42.z.array(
222
- import_v42.z.object({
223
- type: import_v42.z.literal("code_execution_output"),
224
- 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()
225
222
  })
226
223
  ).optional().default([])
227
224
  }),
228
- import_v42.z.object({
229
- type: import_v42.z.literal("encrypted_code_execution_result"),
230
- encrypted_stdout: import_v42.z.string(),
231
- stderr: import_v42.z.string(),
232
- return_code: import_v42.z.number(),
233
- content: import_v42.z.array(
234
- import_v42.z.object({
235
- type: import_v42.z.literal("code_execution_output"),
236
- 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()
237
234
  })
238
235
  ).optional().default([])
239
236
  }),
240
- import_v42.z.object({
241
- type: import_v42.z.literal("code_execution_tool_result_error"),
242
- error_code: import_v42.z.string()
237
+ z2.object({
238
+ type: z2.literal("code_execution_tool_result_error"),
239
+ error_code: z2.string()
243
240
  })
244
241
  ])
245
242
  }),
246
243
  // bash code execution results for code_execution_20250825 tool:
247
- import_v42.z.object({
248
- type: import_v42.z.literal("bash_code_execution_tool_result"),
249
- tool_use_id: import_v42.z.string(),
250
- content: import_v42.z.discriminatedUnion("type", [
251
- import_v42.z.object({
252
- type: import_v42.z.literal("bash_code_execution_result"),
253
- content: import_v42.z.array(
254
- import_v42.z.object({
255
- type: import_v42.z.literal("bash_code_execution_output"),
256
- 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()
257
254
  })
258
255
  ),
259
- stdout: import_v42.z.string(),
260
- stderr: import_v42.z.string(),
261
- return_code: import_v42.z.number()
256
+ stdout: z2.string(),
257
+ stderr: z2.string(),
258
+ return_code: z2.number()
262
259
  }),
263
- import_v42.z.object({
264
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
265
- error_code: import_v42.z.string()
260
+ z2.object({
261
+ type: z2.literal("bash_code_execution_tool_result_error"),
262
+ error_code: z2.string()
266
263
  })
267
264
  ])
268
265
  }),
269
266
  // text editor code execution results for code_execution_20250825 tool:
270
- import_v42.z.object({
271
- type: import_v42.z.literal("text_editor_code_execution_tool_result"),
272
- tool_use_id: import_v42.z.string(),
273
- content: import_v42.z.discriminatedUnion("type", [
274
- import_v42.z.object({
275
- type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
276
- 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()
277
274
  }),
278
- import_v42.z.object({
279
- type: import_v42.z.literal("text_editor_code_execution_view_result"),
280
- content: import_v42.z.string(),
281
- file_type: import_v42.z.string(),
282
- num_lines: import_v42.z.number().nullable(),
283
- start_line: import_v42.z.number().nullable(),
284
- 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()
285
282
  }),
286
- import_v42.z.object({
287
- type: import_v42.z.literal("text_editor_code_execution_create_result"),
288
- 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()
289
286
  }),
290
- import_v42.z.object({
291
- type: import_v42.z.literal(
287
+ z2.object({
288
+ type: z2.literal(
292
289
  "text_editor_code_execution_str_replace_result"
293
290
  ),
294
- lines: import_v42.z.array(import_v42.z.string()).nullable(),
295
- new_lines: import_v42.z.number().nullable(),
296
- new_start: import_v42.z.number().nullable(),
297
- old_lines: import_v42.z.number().nullable(),
298
- 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()
299
296
  })
300
297
  ])
301
298
  }),
302
299
  // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
303
- import_v42.z.object({
304
- type: import_v42.z.literal("tool_search_tool_result"),
305
- tool_use_id: import_v42.z.string(),
306
- content: import_v42.z.union([
307
- import_v42.z.object({
308
- type: import_v42.z.literal("tool_search_tool_search_result"),
309
- tool_references: import_v42.z.array(
310
- import_v42.z.object({
311
- type: import_v42.z.literal("tool_reference"),
312
- 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()
313
310
  })
314
311
  )
315
312
  }),
316
- import_v42.z.object({
317
- type: import_v42.z.literal("tool_search_tool_result_error"),
318
- error_code: import_v42.z.string()
313
+ z2.object({
314
+ type: z2.literal("tool_search_tool_result_error"),
315
+ error_code: z2.string()
319
316
  })
320
317
  ])
321
318
  })
322
319
  ])
323
320
  ),
324
- stop_reason: import_v42.z.string().nullish(),
325
- stop_sequence: import_v42.z.string().nullish(),
326
- usage: import_v42.z.looseObject({
327
- input_tokens: import_v42.z.number(),
328
- output_tokens: import_v42.z.number(),
329
- cache_creation_input_tokens: import_v42.z.number().nullish(),
330
- cache_read_input_tokens: import_v42.z.number().nullish(),
331
- iterations: import_v42.z.array(
332
- import_v42.z.object({
333
- type: import_v42.z.union([import_v42.z.literal("compaction"), import_v42.z.literal("message")]),
334
- input_tokens: import_v42.z.number(),
335
- 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()
336
333
  })
337
334
  ).nullish()
338
335
  }),
339
- container: import_v42.z.object({
340
- expires_at: import_v42.z.string(),
341
- id: import_v42.z.string(),
342
- skills: import_v42.z.array(
343
- import_v42.z.object({
344
- type: import_v42.z.union([import_v42.z.literal("anthropic"), import_v42.z.literal("custom")]),
345
- skill_id: import_v42.z.string(),
346
- 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()
347
344
  })
348
345
  ).nullish()
349
346
  }).nullish(),
350
- context_management: import_v42.z.object({
351
- applied_edits: import_v42.z.array(
352
- import_v42.z.union([
353
- import_v42.z.object({
354
- type: import_v42.z.literal("clear_tool_uses_20250919"),
355
- cleared_tool_uses: import_v42.z.number(),
356
- 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()
357
354
  }),
358
- import_v42.z.object({
359
- type: import_v42.z.literal("clear_thinking_20251015"),
360
- cleared_thinking_turns: import_v42.z.number(),
361
- 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()
362
359
  }),
363
- import_v42.z.object({
364
- type: import_v42.z.literal("compact_20260112")
360
+ z2.object({
361
+ type: z2.literal("compact_20260112")
365
362
  })
366
363
  ])
367
364
  )
@@ -369,457 +366,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
369
366
  })
370
367
  )
371
368
  );
372
- var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
373
- () => (0, import_provider_utils2.zodSchema)(
374
- import_v42.z.discriminatedUnion("type", [
375
- import_v42.z.object({
376
- type: import_v42.z.literal("message_start"),
377
- message: import_v42.z.object({
378
- id: import_v42.z.string().nullish(),
379
- model: import_v42.z.string().nullish(),
380
- role: import_v42.z.string().nullish(),
381
- usage: import_v42.z.looseObject({
382
- input_tokens: import_v42.z.number(),
383
- cache_creation_input_tokens: import_v42.z.number().nullish(),
384
- 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()
385
382
  }),
386
383
  // Programmatic tool calling: content may be pre-populated for deferred tool calls
387
- content: import_v42.z.array(
388
- import_v42.z.discriminatedUnion("type", [
389
- import_v42.z.object({
390
- type: import_v42.z.literal("tool_use"),
391
- id: import_v42.z.string(),
392
- name: import_v42.z.string(),
393
- input: import_v42.z.unknown(),
394
- caller: import_v42.z.union([
395
- import_v42.z.object({
396
- type: import_v42.z.literal("code_execution_20250825"),
397
- 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()
398
395
  }),
399
- import_v42.z.object({
400
- type: import_v42.z.literal("code_execution_20260120"),
401
- tool_id: import_v42.z.string()
396
+ z2.object({
397
+ type: z2.literal("code_execution_20260120"),
398
+ tool_id: z2.string()
402
399
  }),
403
- import_v42.z.object({
404
- type: import_v42.z.literal("direct")
400
+ z2.object({
401
+ type: z2.literal("direct")
405
402
  })
406
403
  ]).optional()
407
404
  })
408
405
  ])
409
406
  ).nullish(),
410
- stop_reason: import_v42.z.string().nullish(),
411
- container: import_v42.z.object({
412
- expires_at: import_v42.z.string(),
413
- id: import_v42.z.string()
407
+ stop_reason: z2.string().nullish(),
408
+ container: z2.object({
409
+ expires_at: z2.string(),
410
+ id: z2.string()
414
411
  }).nullish()
415
412
  })
416
413
  }),
417
- import_v42.z.object({
418
- type: import_v42.z.literal("content_block_start"),
419
- index: import_v42.z.number(),
420
- content_block: import_v42.z.discriminatedUnion("type", [
421
- import_v42.z.object({
422
- type: import_v42.z.literal("text"),
423
- 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()
424
421
  }),
425
- import_v42.z.object({
426
- type: import_v42.z.literal("thinking"),
427
- thinking: import_v42.z.string()
422
+ z2.object({
423
+ type: z2.literal("thinking"),
424
+ thinking: z2.string()
428
425
  }),
429
- import_v42.z.object({
430
- type: import_v42.z.literal("tool_use"),
431
- id: import_v42.z.string(),
432
- name: import_v42.z.string(),
426
+ z2.object({
427
+ type: z2.literal("tool_use"),
428
+ id: z2.string(),
429
+ name: z2.string(),
433
430
  // Programmatic tool calling: input may be present directly for deferred tool calls
434
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional(),
431
+ input: z2.record(z2.string(), z2.unknown()).optional(),
435
432
  // Programmatic tool calling: caller info when triggered from code execution
436
- caller: import_v42.z.union([
437
- import_v42.z.object({
438
- type: import_v42.z.literal("code_execution_20250825"),
439
- 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()
440
437
  }),
441
- import_v42.z.object({
442
- type: import_v42.z.literal("code_execution_20260120"),
443
- tool_id: import_v42.z.string()
438
+ z2.object({
439
+ type: z2.literal("code_execution_20260120"),
440
+ tool_id: z2.string()
444
441
  }),
445
- import_v42.z.object({
446
- type: import_v42.z.literal("direct")
442
+ z2.object({
443
+ type: z2.literal("direct")
447
444
  })
448
445
  ]).optional()
449
446
  }),
450
- import_v42.z.object({
451
- type: import_v42.z.literal("redacted_thinking"),
452
- data: import_v42.z.string()
447
+ z2.object({
448
+ type: z2.literal("redacted_thinking"),
449
+ data: z2.string()
453
450
  }),
454
- import_v42.z.object({
455
- type: import_v42.z.literal("compaction"),
456
- content: import_v42.z.string().nullish()
451
+ z2.object({
452
+ type: z2.literal("compaction"),
453
+ content: z2.string().nullish()
457
454
  }),
458
- import_v42.z.object({
459
- type: import_v42.z.literal("server_tool_use"),
460
- id: import_v42.z.string(),
461
- name: import_v42.z.string(),
462
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
463
- caller: import_v42.z.union([
464
- import_v42.z.object({
465
- type: import_v42.z.literal("code_execution_20260120"),
466
- 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()
467
464
  }),
468
- import_v42.z.object({
469
- type: import_v42.z.literal("direct")
465
+ z2.object({
466
+ type: z2.literal("direct")
470
467
  })
471
468
  ]).optional()
472
469
  }),
473
- import_v42.z.object({
474
- type: import_v42.z.literal("mcp_tool_use"),
475
- id: import_v42.z.string(),
476
- name: import_v42.z.string(),
477
- input: import_v42.z.unknown(),
478
- 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()
479
476
  }),
480
- import_v42.z.object({
481
- type: import_v42.z.literal("mcp_tool_result"),
482
- tool_use_id: import_v42.z.string(),
483
- is_error: import_v42.z.boolean(),
484
- content: import_v42.z.array(
485
- import_v42.z.union([
486
- import_v42.z.string(),
487
- 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() })
488
485
  ])
489
486
  )
490
487
  }),
491
- import_v42.z.object({
492
- type: import_v42.z.literal("web_fetch_tool_result"),
493
- tool_use_id: import_v42.z.string(),
494
- content: import_v42.z.union([
495
- import_v42.z.object({
496
- type: import_v42.z.literal("web_fetch_result"),
497
- url: import_v42.z.string(),
498
- retrieved_at: import_v42.z.string(),
499
- content: import_v42.z.object({
500
- type: import_v42.z.literal("document"),
501
- title: import_v42.z.string().nullable(),
502
- citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
503
- source: import_v42.z.union([
504
- import_v42.z.object({
505
- type: import_v42.z.literal("base64"),
506
- media_type: import_v42.z.literal("application/pdf"),
507
- 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()
508
505
  }),
509
- import_v42.z.object({
510
- type: import_v42.z.literal("text"),
511
- media_type: import_v42.z.literal("text/plain"),
512
- data: import_v42.z.string()
506
+ z2.object({
507
+ type: z2.literal("text"),
508
+ media_type: z2.literal("text/plain"),
509
+ data: z2.string()
513
510
  })
514
511
  ])
515
512
  })
516
513
  }),
517
- import_v42.z.object({
518
- type: import_v42.z.literal("web_fetch_tool_result_error"),
519
- error_code: import_v42.z.string()
514
+ z2.object({
515
+ type: z2.literal("web_fetch_tool_result_error"),
516
+ error_code: z2.string()
520
517
  })
521
518
  ])
522
519
  }),
523
- import_v42.z.object({
524
- type: import_v42.z.literal("web_search_tool_result"),
525
- tool_use_id: import_v42.z.string(),
526
- content: import_v42.z.union([
527
- import_v42.z.array(
528
- import_v42.z.object({
529
- type: import_v42.z.literal("web_search_result"),
530
- url: import_v42.z.string(),
531
- title: import_v42.z.string(),
532
- encrypted_content: import_v42.z.string(),
533
- 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()
534
531
  })
535
532
  ),
536
- import_v42.z.object({
537
- type: import_v42.z.literal("web_search_tool_result_error"),
538
- error_code: import_v42.z.string()
533
+ z2.object({
534
+ type: z2.literal("web_search_tool_result_error"),
535
+ error_code: z2.string()
539
536
  })
540
537
  ])
541
538
  }),
542
539
  // code execution results for code_execution_20250522 tool:
543
- import_v42.z.object({
544
- type: import_v42.z.literal("code_execution_tool_result"),
545
- tool_use_id: import_v42.z.string(),
546
- content: import_v42.z.union([
547
- import_v42.z.object({
548
- type: import_v42.z.literal("code_execution_result"),
549
- stdout: import_v42.z.string(),
550
- stderr: import_v42.z.string(),
551
- return_code: import_v42.z.number(),
552
- content: import_v42.z.array(
553
- import_v42.z.object({
554
- type: import_v42.z.literal("code_execution_output"),
555
- 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()
556
553
  })
557
554
  ).optional().default([])
558
555
  }),
559
- import_v42.z.object({
560
- type: import_v42.z.literal("encrypted_code_execution_result"),
561
- encrypted_stdout: import_v42.z.string(),
562
- stderr: import_v42.z.string(),
563
- return_code: import_v42.z.number(),
564
- content: import_v42.z.array(
565
- import_v42.z.object({
566
- type: import_v42.z.literal("code_execution_output"),
567
- 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()
568
565
  })
569
566
  ).optional().default([])
570
567
  }),
571
- import_v42.z.object({
572
- type: import_v42.z.literal("code_execution_tool_result_error"),
573
- error_code: import_v42.z.string()
568
+ z2.object({
569
+ type: z2.literal("code_execution_tool_result_error"),
570
+ error_code: z2.string()
574
571
  })
575
572
  ])
576
573
  }),
577
574
  // bash code execution results for code_execution_20250825 tool:
578
- import_v42.z.object({
579
- type: import_v42.z.literal("bash_code_execution_tool_result"),
580
- tool_use_id: import_v42.z.string(),
581
- content: import_v42.z.discriminatedUnion("type", [
582
- import_v42.z.object({
583
- type: import_v42.z.literal("bash_code_execution_result"),
584
- content: import_v42.z.array(
585
- import_v42.z.object({
586
- type: import_v42.z.literal("bash_code_execution_output"),
587
- 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()
588
585
  })
589
586
  ),
590
- stdout: import_v42.z.string(),
591
- stderr: import_v42.z.string(),
592
- return_code: import_v42.z.number()
587
+ stdout: z2.string(),
588
+ stderr: z2.string(),
589
+ return_code: z2.number()
593
590
  }),
594
- import_v42.z.object({
595
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
596
- error_code: import_v42.z.string()
591
+ z2.object({
592
+ type: z2.literal("bash_code_execution_tool_result_error"),
593
+ error_code: z2.string()
597
594
  })
598
595
  ])
599
596
  }),
600
597
  // text editor code execution results for code_execution_20250825 tool:
601
- import_v42.z.object({
602
- type: import_v42.z.literal("text_editor_code_execution_tool_result"),
603
- tool_use_id: import_v42.z.string(),
604
- content: import_v42.z.discriminatedUnion("type", [
605
- import_v42.z.object({
606
- type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
607
- 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()
608
605
  }),
609
- import_v42.z.object({
610
- type: import_v42.z.literal("text_editor_code_execution_view_result"),
611
- content: import_v42.z.string(),
612
- file_type: import_v42.z.string(),
613
- num_lines: import_v42.z.number().nullable(),
614
- start_line: import_v42.z.number().nullable(),
615
- 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()
616
613
  }),
617
- import_v42.z.object({
618
- type: import_v42.z.literal("text_editor_code_execution_create_result"),
619
- 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()
620
617
  }),
621
- import_v42.z.object({
622
- type: import_v42.z.literal(
618
+ z2.object({
619
+ type: z2.literal(
623
620
  "text_editor_code_execution_str_replace_result"
624
621
  ),
625
- lines: import_v42.z.array(import_v42.z.string()).nullable(),
626
- new_lines: import_v42.z.number().nullable(),
627
- new_start: import_v42.z.number().nullable(),
628
- old_lines: import_v42.z.number().nullable(),
629
- 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()
630
627
  })
631
628
  ])
632
629
  }),
633
630
  // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
634
- import_v42.z.object({
635
- type: import_v42.z.literal("tool_search_tool_result"),
636
- tool_use_id: import_v42.z.string(),
637
- content: import_v42.z.union([
638
- import_v42.z.object({
639
- type: import_v42.z.literal("tool_search_tool_search_result"),
640
- tool_references: import_v42.z.array(
641
- import_v42.z.object({
642
- type: import_v42.z.literal("tool_reference"),
643
- 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()
644
641
  })
645
642
  )
646
643
  }),
647
- import_v42.z.object({
648
- type: import_v42.z.literal("tool_search_tool_result_error"),
649
- error_code: import_v42.z.string()
644
+ z2.object({
645
+ type: z2.literal("tool_search_tool_result_error"),
646
+ error_code: z2.string()
650
647
  })
651
648
  ])
652
649
  })
653
650
  ])
654
651
  }),
655
- import_v42.z.object({
656
- type: import_v42.z.literal("content_block_delta"),
657
- index: import_v42.z.number(),
658
- delta: import_v42.z.discriminatedUnion("type", [
659
- import_v42.z.object({
660
- type: import_v42.z.literal("input_json_delta"),
661
- 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()
662
659
  }),
663
- import_v42.z.object({
664
- type: import_v42.z.literal("text_delta"),
665
- text: import_v42.z.string()
660
+ z2.object({
661
+ type: z2.literal("text_delta"),
662
+ text: z2.string()
666
663
  }),
667
- import_v42.z.object({
668
- type: import_v42.z.literal("thinking_delta"),
669
- thinking: import_v42.z.string()
664
+ z2.object({
665
+ type: z2.literal("thinking_delta"),
666
+ thinking: z2.string()
670
667
  }),
671
- import_v42.z.object({
672
- type: import_v42.z.literal("signature_delta"),
673
- signature: import_v42.z.string()
668
+ z2.object({
669
+ type: z2.literal("signature_delta"),
670
+ signature: z2.string()
674
671
  }),
675
- import_v42.z.object({
676
- type: import_v42.z.literal("compaction_delta"),
677
- content: import_v42.z.string().nullish()
672
+ z2.object({
673
+ type: z2.literal("compaction_delta"),
674
+ content: z2.string().nullish()
678
675
  }),
679
- import_v42.z.object({
680
- type: import_v42.z.literal("citations_delta"),
681
- citation: import_v42.z.discriminatedUnion("type", [
682
- import_v42.z.object({
683
- type: import_v42.z.literal("web_search_result_location"),
684
- cited_text: import_v42.z.string(),
685
- url: import_v42.z.string(),
686
- title: import_v42.z.string(),
687
- 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()
688
685
  }),
689
- import_v42.z.object({
690
- type: import_v42.z.literal("page_location"),
691
- cited_text: import_v42.z.string(),
692
- document_index: import_v42.z.number(),
693
- document_title: import_v42.z.string().nullable(),
694
- start_page_number: import_v42.z.number(),
695
- 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()
696
693
  }),
697
- import_v42.z.object({
698
- type: import_v42.z.literal("char_location"),
699
- cited_text: import_v42.z.string(),
700
- document_index: import_v42.z.number(),
701
- document_title: import_v42.z.string().nullable(),
702
- start_char_index: import_v42.z.number(),
703
- 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()
704
701
  })
705
702
  ])
706
703
  })
707
704
  ])
708
705
  }),
709
- import_v42.z.object({
710
- type: import_v42.z.literal("content_block_stop"),
711
- index: import_v42.z.number()
706
+ z2.object({
707
+ type: z2.literal("content_block_stop"),
708
+ index: z2.number()
712
709
  }),
713
- import_v42.z.object({
714
- type: import_v42.z.literal("error"),
715
- error: import_v42.z.object({
716
- type: import_v42.z.string(),
717
- 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()
718
715
  })
719
716
  }),
720
- import_v42.z.object({
721
- type: import_v42.z.literal("message_delta"),
722
- delta: import_v42.z.object({
723
- stop_reason: import_v42.z.string().nullish(),
724
- stop_sequence: import_v42.z.string().nullish(),
725
- container: import_v42.z.object({
726
- expires_at: import_v42.z.string(),
727
- id: import_v42.z.string(),
728
- skills: import_v42.z.array(
729
- import_v42.z.object({
730
- type: import_v42.z.union([
731
- import_v42.z.literal("anthropic"),
732
- 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")
733
730
  ]),
734
- skill_id: import_v42.z.string(),
735
- version: import_v42.z.string()
731
+ skill_id: z2.string(),
732
+ version: z2.string()
736
733
  })
737
734
  ).nullish()
738
735
  }).nullish()
739
736
  }),
740
- usage: import_v42.z.looseObject({
741
- input_tokens: import_v42.z.number().nullish(),
742
- output_tokens: import_v42.z.number(),
743
- cache_creation_input_tokens: import_v42.z.number().nullish(),
744
- cache_read_input_tokens: import_v42.z.number().nullish(),
745
- iterations: import_v42.z.array(
746
- import_v42.z.object({
747
- type: import_v42.z.union([import_v42.z.literal("compaction"), import_v42.z.literal("message")]),
748
- input_tokens: import_v42.z.number(),
749
- 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()
750
747
  })
751
748
  ).nullish()
752
749
  }),
753
- context_management: import_v42.z.object({
754
- applied_edits: import_v42.z.array(
755
- import_v42.z.union([
756
- import_v42.z.object({
757
- type: import_v42.z.literal("clear_tool_uses_20250919"),
758
- cleared_tool_uses: import_v42.z.number(),
759
- 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()
760
757
  }),
761
- import_v42.z.object({
762
- type: import_v42.z.literal("clear_thinking_20251015"),
763
- cleared_thinking_turns: import_v42.z.number(),
764
- 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()
765
762
  }),
766
- import_v42.z.object({
767
- type: import_v42.z.literal("compact_20260112")
763
+ z2.object({
764
+ type: z2.literal("compact_20260112")
768
765
  })
769
766
  ])
770
767
  )
771
768
  }).nullish()
772
769
  }),
773
- import_v42.z.object({
774
- type: import_v42.z.literal("message_stop")
770
+ z2.object({
771
+ type: z2.literal("message_stop")
775
772
  }),
776
- import_v42.z.object({
777
- type: import_v42.z.literal("ping")
773
+ z2.object({
774
+ type: z2.literal("ping")
778
775
  })
779
776
  ])
780
777
  )
781
778
  );
782
- var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
783
- () => (0, import_provider_utils2.zodSchema)(
784
- import_v42.z.object({
785
- signature: import_v42.z.string().optional(),
786
- 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()
787
784
  })
788
785
  )
789
786
  );
790
787
 
791
- // src/anthropic-messages-options.ts
792
- var import_v43 = require("zod/v4");
793
- var anthropicFilePartProviderOptions = import_v43.z.object({
788
+ // src/anthropic-options.ts
789
+ import { z as z3 } from "zod/v4";
790
+ var anthropicFilePartProviderOptions = z3.object({
794
791
  /**
795
792
  * Citation configuration for this document.
796
793
  * When enabled, this document will generate citations in the response.
797
794
  */
798
- citations: import_v43.z.object({
795
+ citations: z3.object({
799
796
  /**
800
797
  * Enable citations for this document
801
798
  */
802
- enabled: import_v43.z.boolean()
799
+ enabled: z3.boolean()
803
800
  }).optional(),
804
801
  /**
805
802
  * Custom title for the document.
806
803
  * If not provided, the filename will be used.
807
804
  */
808
- title: import_v43.z.string().optional(),
805
+ title: z3.string().optional(),
809
806
  /**
810
807
  * Context about the document that will be passed to the model
811
808
  * but not used towards cited content.
812
809
  * Useful for storing document metadata as text or stringified JSON.
813
810
  */
814
- context: import_v43.z.string().optional()
811
+ context: z3.string().optional()
815
812
  });
816
- var anthropicLanguageModelOptions = import_v43.z.object({
813
+ var anthropicLanguageModelOptions = z3.object({
817
814
  /**
818
815
  * Whether to send reasoning to the model.
819
816
  *
820
817
  * This allows you to deactivate reasoning inputs for models that do not support them.
821
818
  */
822
- sendReasoning: import_v43.z.boolean().optional(),
819
+ sendReasoning: z3.boolean().optional(),
823
820
  /**
824
821
  * Determines how structured outputs are generated.
825
822
  *
@@ -827,52 +824,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
827
824
  * - `jsonTool`: Use a special 'json' tool to specify the structured output format.
828
825
  * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
829
826
  */
830
- structuredOutputMode: import_v43.z.enum(["outputFormat", "jsonTool", "auto"]).optional(),
827
+ structuredOutputMode: z3.enum(["outputFormat", "jsonTool", "auto"]).optional(),
831
828
  /**
832
829
  * Configuration for enabling Claude's extended thinking.
833
830
  *
834
831
  * When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
835
832
  * Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
836
833
  */
837
- thinking: import_v43.z.discriminatedUnion("type", [
838
- import_v43.z.object({
834
+ thinking: z3.discriminatedUnion("type", [
835
+ z3.object({
839
836
  /** for Sonnet 4.6, Opus 4.6, and newer models */
840
- type: import_v43.z.literal("adaptive")
837
+ type: z3.literal("adaptive"),
838
+ /**
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.
842
+ */
843
+ display: z3.enum(["omitted", "summarized"]).optional()
841
844
  }),
842
- import_v43.z.object({
845
+ z3.object({
843
846
  /** for models before Opus 4.6, except Sonnet 4.6 still supports it */
844
- type: import_v43.z.literal("enabled"),
845
- budgetTokens: import_v43.z.number().optional()
847
+ type: z3.literal("enabled"),
848
+ budgetTokens: z3.number().optional()
846
849
  }),
847
- import_v43.z.object({
848
- type: import_v43.z.literal("disabled")
850
+ z3.object({
851
+ type: z3.literal("disabled")
849
852
  })
850
853
  ]).optional(),
851
854
  /**
852
855
  * Whether to disable parallel function calling during tool use. Default is false.
853
856
  * When set to true, Claude will use at most one tool per response.
854
857
  */
855
- disableParallelToolUse: import_v43.z.boolean().optional(),
858
+ disableParallelToolUse: z3.boolean().optional(),
856
859
  /**
857
860
  * Cache control settings for this message.
858
861
  * See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
859
862
  */
860
- cacheControl: import_v43.z.object({
861
- type: import_v43.z.literal("ephemeral"),
862
- 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()
863
880
  }).optional(),
864
881
  /**
865
882
  * MCP servers to be utilized in this request.
866
883
  */
867
- mcpServers: import_v43.z.array(
868
- import_v43.z.object({
869
- type: import_v43.z.literal("url"),
870
- name: import_v43.z.string(),
871
- url: import_v43.z.string(),
872
- authorizationToken: import_v43.z.string().nullish(),
873
- toolConfiguration: import_v43.z.object({
874
- enabled: import_v43.z.boolean().nullish(),
875
- 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()
876
893
  }).nullish()
877
894
  })
878
895
  ).optional(),
@@ -881,83 +898,112 @@ var anthropicLanguageModelOptions = import_v43.z.object({
881
898
  * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
882
899
  * Requires code execution tool to be enabled.
883
900
  */
884
- container: import_v43.z.object({
885
- id: import_v43.z.string().optional(),
886
- skills: import_v43.z.array(
887
- import_v43.z.object({
888
- type: import_v43.z.union([import_v43.z.literal("anthropic"), import_v43.z.literal("custom")]),
889
- skillId: import_v43.z.string(),
890
- version: import_v43.z.string().optional()
891
- })
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
+ ])
892
916
  ).optional()
893
917
  }).optional(),
894
918
  /**
895
- * Whether to enable tool streaming (and structured output streaming).
896
- *
897
- * When set to false, the model will return all tool calls and results
898
- * 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`.
899
924
  *
900
925
  * @default true
901
926
  */
902
- toolStreaming: import_v43.z.boolean().optional(),
927
+ toolStreaming: z3.boolean().optional(),
903
928
  /**
904
929
  * @default 'high'
905
930
  */
906
- 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(),
907
944
  /**
908
945
  * Enable fast mode for faster inference (2.5x faster output token speeds).
909
946
  * Only supported with claude-opus-4-6.
910
947
  */
911
- speed: import_v43.z.enum(["fast", "standard"]).optional(),
948
+ speed: z3.enum(["fast", "standard"]).optional(),
949
+ /**
950
+ * Controls where model inference runs for this request.
951
+ *
952
+ * - `"global"`: Inference may run in any available geography (default).
953
+ * - `"us"`: Inference runs only in US-based infrastructure.
954
+ *
955
+ * See https://platform.claude.com/docs/en/build-with-claude/data-residency
956
+ */
957
+ inferenceGeo: z3.enum(["us", "global"]).optional(),
912
958
  /**
913
959
  * A set of beta features to enable.
914
960
  * Allow a provider to receive the full `betas` set if it needs it.
915
961
  */
916
- anthropicBeta: import_v43.z.array(import_v43.z.string()).optional(),
917
- contextManagement: import_v43.z.object({
918
- edits: import_v43.z.array(
919
- import_v43.z.discriminatedUnion("type", [
920
- import_v43.z.object({
921
- type: import_v43.z.literal("clear_tool_uses_20250919"),
922
- trigger: import_v43.z.discriminatedUnion("type", [
923
- import_v43.z.object({
924
- type: import_v43.z.literal("input_tokens"),
925
- value: import_v43.z.number()
962
+ anthropicBeta: z3.array(z3.string()).optional(),
963
+ contextManagement: z3.object({
964
+ edits: z3.array(
965
+ z3.discriminatedUnion("type", [
966
+ z3.object({
967
+ type: z3.literal("clear_tool_uses_20250919"),
968
+ trigger: z3.discriminatedUnion("type", [
969
+ z3.object({
970
+ type: z3.literal("input_tokens"),
971
+ value: z3.number()
926
972
  }),
927
- import_v43.z.object({
928
- type: import_v43.z.literal("tool_uses"),
929
- value: import_v43.z.number()
973
+ z3.object({
974
+ type: z3.literal("tool_uses"),
975
+ value: z3.number()
930
976
  })
931
977
  ]).optional(),
932
- keep: import_v43.z.object({
933
- type: import_v43.z.literal("tool_uses"),
934
- value: import_v43.z.number()
978
+ keep: z3.object({
979
+ type: z3.literal("tool_uses"),
980
+ value: z3.number()
935
981
  }).optional(),
936
- clearAtLeast: import_v43.z.object({
937
- type: import_v43.z.literal("input_tokens"),
938
- value: import_v43.z.number()
982
+ clearAtLeast: z3.object({
983
+ type: z3.literal("input_tokens"),
984
+ value: z3.number()
939
985
  }).optional(),
940
- clearToolInputs: import_v43.z.boolean().optional(),
941
- excludeTools: import_v43.z.array(import_v43.z.string()).optional()
986
+ clearToolInputs: z3.boolean().optional(),
987
+ excludeTools: z3.array(z3.string()).optional()
942
988
  }),
943
- import_v43.z.object({
944
- type: import_v43.z.literal("clear_thinking_20251015"),
945
- keep: import_v43.z.union([
946
- import_v43.z.literal("all"),
947
- import_v43.z.object({
948
- type: import_v43.z.literal("thinking_turns"),
949
- value: import_v43.z.number()
989
+ z3.object({
990
+ type: z3.literal("clear_thinking_20251015"),
991
+ keep: z3.union([
992
+ z3.literal("all"),
993
+ z3.object({
994
+ type: z3.literal("thinking_turns"),
995
+ value: z3.number()
950
996
  })
951
997
  ]).optional()
952
998
  }),
953
- import_v43.z.object({
954
- type: import_v43.z.literal("compact_20260112"),
955
- trigger: import_v43.z.object({
956
- type: import_v43.z.literal("input_tokens"),
957
- value: import_v43.z.number()
999
+ z3.object({
1000
+ type: z3.literal("compact_20260112"),
1001
+ trigger: z3.object({
1002
+ type: z3.literal("input_tokens"),
1003
+ value: z3.number()
958
1004
  }).optional(),
959
- pauseAfterCompaction: import_v43.z.boolean().optional(),
960
- instructions: import_v43.z.string().optional()
1005
+ pauseAfterCompaction: z3.boolean().optional(),
1006
+ instructions: z3.string().optional()
961
1007
  })
962
1008
  ])
963
1009
  )
@@ -965,7 +1011,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
965
1011
  });
966
1012
 
967
1013
  // src/anthropic-prepare-tools.ts
968
- var import_provider = require("@ai-sdk/provider");
1014
+ import {
1015
+ UnsupportedFunctionalityError
1016
+ } from "@ai-sdk/provider";
969
1017
 
970
1018
  // src/get-cache-control.ts
971
1019
  var MAX_CACHE_BREAKPOINTS = 4;
@@ -1010,31 +1058,34 @@ var CacheControlValidator = class {
1010
1058
  };
1011
1059
 
1012
1060
  // src/tool/text-editor_20250728.ts
1013
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
1014
- var import_v44 = require("zod/v4");
1015
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
1016
- var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
1017
- () => (0, import_provider_utils4.zodSchema)(
1018
- import_v44.z.object({
1019
- maxCharacters: import_v44.z.number().optional()
1061
+ import {
1062
+ createProviderDefinedToolFactory,
1063
+ lazySchema as lazySchema3,
1064
+ zodSchema as zodSchema3
1065
+ } from "@ai-sdk/provider-utils";
1066
+ import { z as z4 } from "zod/v4";
1067
+ var textEditor_20250728ArgsSchema = lazySchema3(
1068
+ () => zodSchema3(
1069
+ z4.object({
1070
+ maxCharacters: z4.number().optional()
1020
1071
  })
1021
1072
  )
1022
1073
  );
1023
- var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
1024
- () => (0, import_provider_utils4.zodSchema)(
1025
- import_v44.z.object({
1026
- command: import_v44.z.enum(["view", "create", "str_replace", "insert"]),
1027
- path: import_v44.z.string(),
1028
- file_text: import_v44.z.string().optional(),
1029
- insert_line: import_v44.z.number().int().optional(),
1030
- new_str: import_v44.z.string().optional(),
1031
- insert_text: import_v44.z.string().optional(),
1032
- old_str: import_v44.z.string().optional(),
1033
- view_range: import_v44.z.array(import_v44.z.number().int()).optional()
1074
+ var textEditor_20250728InputSchema = lazySchema3(
1075
+ () => zodSchema3(
1076
+ z4.object({
1077
+ command: z4.enum(["view", "create", "str_replace", "insert"]),
1078
+ path: z4.string(),
1079
+ file_text: z4.string().optional(),
1080
+ insert_line: z4.number().int().optional(),
1081
+ new_str: z4.string().optional(),
1082
+ insert_text: z4.string().optional(),
1083
+ old_str: z4.string().optional(),
1084
+ view_range: z4.array(z4.number().int()).optional()
1034
1085
  })
1035
1086
  )
1036
1087
  );
1037
- var factory = (0, import_provider_utils3.createProviderToolFactory)({
1088
+ var factory = createProviderDefinedToolFactory({
1038
1089
  id: "anthropic.text_editor_20250728",
1039
1090
  inputSchema: textEditor_20250728InputSchema
1040
1091
  });
@@ -1043,45 +1094,49 @@ var textEditor_20250728 = (args = {}) => {
1043
1094
  };
1044
1095
 
1045
1096
  // src/tool/web-search_20260209.ts
1046
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1047
- var import_v45 = require("zod/v4");
1048
- var webSearch_20260209ArgsSchema = (0, import_provider_utils5.lazySchema)(
1049
- () => (0, import_provider_utils5.zodSchema)(
1050
- import_v45.z.object({
1051
- maxUses: import_v45.z.number().optional(),
1052
- allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
1053
- blockedDomains: import_v45.z.array(import_v45.z.string()).optional(),
1054
- userLocation: import_v45.z.object({
1055
- type: import_v45.z.literal("approximate"),
1056
- city: import_v45.z.string().optional(),
1057
- region: import_v45.z.string().optional(),
1058
- country: import_v45.z.string().optional(),
1059
- timezone: import_v45.z.string().optional()
1097
+ import {
1098
+ createProviderExecutedToolFactory,
1099
+ lazySchema as lazySchema4,
1100
+ zodSchema as zodSchema4
1101
+ } from "@ai-sdk/provider-utils";
1102
+ import { z as z5 } from "zod/v4";
1103
+ var webSearch_20260209ArgsSchema = lazySchema4(
1104
+ () => zodSchema4(
1105
+ z5.object({
1106
+ maxUses: z5.number().optional(),
1107
+ allowedDomains: z5.array(z5.string()).optional(),
1108
+ blockedDomains: z5.array(z5.string()).optional(),
1109
+ userLocation: z5.object({
1110
+ type: z5.literal("approximate"),
1111
+ city: z5.string().optional(),
1112
+ region: z5.string().optional(),
1113
+ country: z5.string().optional(),
1114
+ timezone: z5.string().optional()
1060
1115
  }).optional()
1061
1116
  })
1062
1117
  )
1063
1118
  );
1064
- var webSearch_20260209OutputSchema = (0, import_provider_utils5.lazySchema)(
1065
- () => (0, import_provider_utils5.zodSchema)(
1066
- import_v45.z.array(
1067
- import_v45.z.object({
1068
- url: import_v45.z.string(),
1069
- title: import_v45.z.string().nullable(),
1070
- pageAge: import_v45.z.string().nullable(),
1071
- encryptedContent: import_v45.z.string(),
1072
- type: import_v45.z.literal("web_search_result")
1119
+ var webSearch_20260209OutputSchema = lazySchema4(
1120
+ () => zodSchema4(
1121
+ z5.array(
1122
+ z5.object({
1123
+ url: z5.string(),
1124
+ title: z5.string().nullable(),
1125
+ pageAge: z5.string().nullable(),
1126
+ encryptedContent: z5.string(),
1127
+ type: z5.literal("web_search_result")
1073
1128
  })
1074
1129
  )
1075
1130
  )
1076
1131
  );
1077
- var webSearch_20260209InputSchema = (0, import_provider_utils5.lazySchema)(
1078
- () => (0, import_provider_utils5.zodSchema)(
1079
- import_v45.z.object({
1080
- query: import_v45.z.string()
1132
+ var webSearch_20260209InputSchema = lazySchema4(
1133
+ () => zodSchema4(
1134
+ z5.object({
1135
+ query: z5.string()
1081
1136
  })
1082
1137
  )
1083
1138
  );
1084
- var factory2 = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
1139
+ var factory2 = createProviderExecutedToolFactory({
1085
1140
  id: "anthropic.web_search_20260209",
1086
1141
  inputSchema: webSearch_20260209InputSchema,
1087
1142
  outputSchema: webSearch_20260209OutputSchema,
@@ -1092,45 +1147,49 @@ var webSearch_20260209 = (args = {}) => {
1092
1147
  };
1093
1148
 
1094
1149
  // src/tool/web-search_20250305.ts
1095
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1096
- var import_v46 = require("zod/v4");
1097
- var webSearch_20250305ArgsSchema = (0, import_provider_utils6.lazySchema)(
1098
- () => (0, import_provider_utils6.zodSchema)(
1099
- import_v46.z.object({
1100
- maxUses: import_v46.z.number().optional(),
1101
- allowedDomains: import_v46.z.array(import_v46.z.string()).optional(),
1102
- blockedDomains: import_v46.z.array(import_v46.z.string()).optional(),
1103
- userLocation: import_v46.z.object({
1104
- type: import_v46.z.literal("approximate"),
1105
- city: import_v46.z.string().optional(),
1106
- region: import_v46.z.string().optional(),
1107
- country: import_v46.z.string().optional(),
1108
- timezone: import_v46.z.string().optional()
1150
+ import {
1151
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
1152
+ lazySchema as lazySchema5,
1153
+ zodSchema as zodSchema5
1154
+ } from "@ai-sdk/provider-utils";
1155
+ import { z as z6 } from "zod/v4";
1156
+ var webSearch_20250305ArgsSchema = lazySchema5(
1157
+ () => zodSchema5(
1158
+ z6.object({
1159
+ maxUses: z6.number().optional(),
1160
+ allowedDomains: z6.array(z6.string()).optional(),
1161
+ blockedDomains: z6.array(z6.string()).optional(),
1162
+ userLocation: z6.object({
1163
+ type: z6.literal("approximate"),
1164
+ city: z6.string().optional(),
1165
+ region: z6.string().optional(),
1166
+ country: z6.string().optional(),
1167
+ timezone: z6.string().optional()
1109
1168
  }).optional()
1110
1169
  })
1111
1170
  )
1112
1171
  );
1113
- var webSearch_20250305OutputSchema = (0, import_provider_utils6.lazySchema)(
1114
- () => (0, import_provider_utils6.zodSchema)(
1115
- import_v46.z.array(
1116
- import_v46.z.object({
1117
- url: import_v46.z.string(),
1118
- title: import_v46.z.string().nullable(),
1119
- pageAge: import_v46.z.string().nullable(),
1120
- encryptedContent: import_v46.z.string(),
1121
- type: import_v46.z.literal("web_search_result")
1172
+ var webSearch_20250305OutputSchema = lazySchema5(
1173
+ () => zodSchema5(
1174
+ z6.array(
1175
+ z6.object({
1176
+ url: z6.string(),
1177
+ title: z6.string().nullable(),
1178
+ pageAge: z6.string().nullable(),
1179
+ encryptedContent: z6.string(),
1180
+ type: z6.literal("web_search_result")
1122
1181
  })
1123
1182
  )
1124
1183
  )
1125
1184
  );
1126
- var webSearch_20250305InputSchema = (0, import_provider_utils6.lazySchema)(
1127
- () => (0, import_provider_utils6.zodSchema)(
1128
- import_v46.z.object({
1129
- query: import_v46.z.string()
1185
+ var webSearch_20250305InputSchema = lazySchema5(
1186
+ () => zodSchema5(
1187
+ z6.object({
1188
+ query: z6.string()
1130
1189
  })
1131
1190
  )
1132
1191
  );
1133
- var factory3 = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
1192
+ var factory3 = createProviderExecutedToolFactory2({
1134
1193
  id: "anthropic.web_search_20250305",
1135
1194
  inputSchema: webSearch_20250305InputSchema,
1136
1195
  outputSchema: webSearch_20250305OutputSchema,
@@ -1141,53 +1200,57 @@ var webSearch_20250305 = (args = {}) => {
1141
1200
  };
1142
1201
 
1143
1202
  // src/tool/web-fetch-20260209.ts
1144
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1145
- var import_v47 = require("zod/v4");
1146
- var webFetch_20260209ArgsSchema = (0, import_provider_utils7.lazySchema)(
1147
- () => (0, import_provider_utils7.zodSchema)(
1148
- import_v47.z.object({
1149
- maxUses: import_v47.z.number().optional(),
1150
- allowedDomains: import_v47.z.array(import_v47.z.string()).optional(),
1151
- blockedDomains: import_v47.z.array(import_v47.z.string()).optional(),
1152
- citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
1153
- maxContentTokens: import_v47.z.number().optional()
1203
+ import {
1204
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
1205
+ lazySchema as lazySchema6,
1206
+ zodSchema as zodSchema6
1207
+ } from "@ai-sdk/provider-utils";
1208
+ import { z as z7 } from "zod/v4";
1209
+ var webFetch_20260209ArgsSchema = lazySchema6(
1210
+ () => zodSchema6(
1211
+ z7.object({
1212
+ maxUses: z7.number().optional(),
1213
+ allowedDomains: z7.array(z7.string()).optional(),
1214
+ blockedDomains: z7.array(z7.string()).optional(),
1215
+ citations: z7.object({ enabled: z7.boolean() }).optional(),
1216
+ maxContentTokens: z7.number().optional()
1154
1217
  })
1155
1218
  )
1156
1219
  );
1157
- var webFetch_20260209OutputSchema = (0, import_provider_utils7.lazySchema)(
1158
- () => (0, import_provider_utils7.zodSchema)(
1159
- import_v47.z.object({
1160
- type: import_v47.z.literal("web_fetch_result"),
1161
- url: import_v47.z.string(),
1162
- content: import_v47.z.object({
1163
- type: import_v47.z.literal("document"),
1164
- title: import_v47.z.string().nullable(),
1165
- citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
1166
- source: import_v47.z.union([
1167
- import_v47.z.object({
1168
- type: import_v47.z.literal("base64"),
1169
- mediaType: import_v47.z.literal("application/pdf"),
1170
- data: import_v47.z.string()
1220
+ var webFetch_20260209OutputSchema = lazySchema6(
1221
+ () => zodSchema6(
1222
+ z7.object({
1223
+ type: z7.literal("web_fetch_result"),
1224
+ url: z7.string(),
1225
+ content: z7.object({
1226
+ type: z7.literal("document"),
1227
+ title: z7.string().nullable(),
1228
+ citations: z7.object({ enabled: z7.boolean() }).optional(),
1229
+ source: z7.union([
1230
+ z7.object({
1231
+ type: z7.literal("base64"),
1232
+ mediaType: z7.literal("application/pdf"),
1233
+ data: z7.string()
1171
1234
  }),
1172
- import_v47.z.object({
1173
- type: import_v47.z.literal("text"),
1174
- mediaType: import_v47.z.literal("text/plain"),
1175
- data: import_v47.z.string()
1235
+ z7.object({
1236
+ type: z7.literal("text"),
1237
+ mediaType: z7.literal("text/plain"),
1238
+ data: z7.string()
1176
1239
  })
1177
1240
  ])
1178
1241
  }),
1179
- retrievedAt: import_v47.z.string().nullable()
1242
+ retrievedAt: z7.string().nullable()
1180
1243
  })
1181
1244
  )
1182
1245
  );
1183
- var webFetch_20260209InputSchema = (0, import_provider_utils7.lazySchema)(
1184
- () => (0, import_provider_utils7.zodSchema)(
1185
- import_v47.z.object({
1186
- url: import_v47.z.string()
1246
+ var webFetch_20260209InputSchema = lazySchema6(
1247
+ () => zodSchema6(
1248
+ z7.object({
1249
+ url: z7.string()
1187
1250
  })
1188
1251
  )
1189
1252
  );
1190
- var factory4 = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
1253
+ var factory4 = createProviderExecutedToolFactory3({
1191
1254
  id: "anthropic.web_fetch_20260209",
1192
1255
  inputSchema: webFetch_20260209InputSchema,
1193
1256
  outputSchema: webFetch_20260209OutputSchema,
@@ -1198,53 +1261,57 @@ var webFetch_20260209 = (args = {}) => {
1198
1261
  };
1199
1262
 
1200
1263
  // src/tool/web-fetch-20250910.ts
1201
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1202
- var import_v48 = require("zod/v4");
1203
- var webFetch_20250910ArgsSchema = (0, import_provider_utils8.lazySchema)(
1204
- () => (0, import_provider_utils8.zodSchema)(
1205
- import_v48.z.object({
1206
- maxUses: import_v48.z.number().optional(),
1207
- allowedDomains: import_v48.z.array(import_v48.z.string()).optional(),
1208
- blockedDomains: import_v48.z.array(import_v48.z.string()).optional(),
1209
- citations: import_v48.z.object({ enabled: import_v48.z.boolean() }).optional(),
1210
- maxContentTokens: import_v48.z.number().optional()
1264
+ import {
1265
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
1266
+ lazySchema as lazySchema7,
1267
+ zodSchema as zodSchema7
1268
+ } from "@ai-sdk/provider-utils";
1269
+ import { z as z8 } from "zod/v4";
1270
+ var webFetch_20250910ArgsSchema = lazySchema7(
1271
+ () => zodSchema7(
1272
+ z8.object({
1273
+ maxUses: z8.number().optional(),
1274
+ allowedDomains: z8.array(z8.string()).optional(),
1275
+ blockedDomains: z8.array(z8.string()).optional(),
1276
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1277
+ maxContentTokens: z8.number().optional()
1211
1278
  })
1212
1279
  )
1213
1280
  );
1214
- var webFetch_20250910OutputSchema = (0, import_provider_utils8.lazySchema)(
1215
- () => (0, import_provider_utils8.zodSchema)(
1216
- import_v48.z.object({
1217
- type: import_v48.z.literal("web_fetch_result"),
1218
- url: import_v48.z.string(),
1219
- content: import_v48.z.object({
1220
- type: import_v48.z.literal("document"),
1221
- title: import_v48.z.string().nullable(),
1222
- citations: import_v48.z.object({ enabled: import_v48.z.boolean() }).optional(),
1223
- source: import_v48.z.union([
1224
- import_v48.z.object({
1225
- type: import_v48.z.literal("base64"),
1226
- mediaType: import_v48.z.literal("application/pdf"),
1227
- data: import_v48.z.string()
1281
+ var webFetch_20250910OutputSchema = lazySchema7(
1282
+ () => zodSchema7(
1283
+ z8.object({
1284
+ type: z8.literal("web_fetch_result"),
1285
+ url: z8.string(),
1286
+ content: z8.object({
1287
+ type: z8.literal("document"),
1288
+ title: z8.string().nullable(),
1289
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1290
+ source: z8.union([
1291
+ z8.object({
1292
+ type: z8.literal("base64"),
1293
+ mediaType: z8.literal("application/pdf"),
1294
+ data: z8.string()
1228
1295
  }),
1229
- import_v48.z.object({
1230
- type: import_v48.z.literal("text"),
1231
- mediaType: import_v48.z.literal("text/plain"),
1232
- data: import_v48.z.string()
1296
+ z8.object({
1297
+ type: z8.literal("text"),
1298
+ mediaType: z8.literal("text/plain"),
1299
+ data: z8.string()
1233
1300
  })
1234
1301
  ])
1235
1302
  }),
1236
- retrievedAt: import_v48.z.string().nullable()
1303
+ retrievedAt: z8.string().nullable()
1237
1304
  })
1238
1305
  )
1239
1306
  );
1240
- var webFetch_20250910InputSchema = (0, import_provider_utils8.lazySchema)(
1241
- () => (0, import_provider_utils8.zodSchema)(
1242
- import_v48.z.object({
1243
- url: import_v48.z.string()
1307
+ var webFetch_20250910InputSchema = lazySchema7(
1308
+ () => zodSchema7(
1309
+ z8.object({
1310
+ url: z8.string()
1244
1311
  })
1245
1312
  )
1246
1313
  );
1247
- var factory5 = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
1314
+ var factory5 = createProviderExecutedToolFactory4({
1248
1315
  id: "anthropic.web_fetch_20250910",
1249
1316
  inputSchema: webFetch_20250910InputSchema,
1250
1317
  outputSchema: webFetch_20250910OutputSchema,
@@ -1255,16 +1322,17 @@ var webFetch_20250910 = (args = {}) => {
1255
1322
  };
1256
1323
 
1257
1324
  // src/anthropic-prepare-tools.ts
1258
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1325
+ import { validateTypes } from "@ai-sdk/provider-utils";
1259
1326
  async function prepareTools({
1260
1327
  tools,
1261
1328
  toolChoice,
1262
1329
  disableParallelToolUse,
1263
1330
  cacheControlValidator,
1264
1331
  supportsStructuredOutput,
1265
- supportsStrictTools
1332
+ supportsStrictTools,
1333
+ defaultEagerInputStreaming = false
1266
1334
  }) {
1267
- var _a;
1335
+ var _a, _b;
1268
1336
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
1269
1337
  const toolWarnings = [];
1270
1338
  const betas = /* @__PURE__ */ new Set();
@@ -1281,7 +1349,7 @@ async function prepareTools({
1281
1349
  canCache: true
1282
1350
  });
1283
1351
  const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
1284
- const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
1352
+ const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
1285
1353
  const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
1286
1354
  const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
1287
1355
  if (!supportsStrictTools && tool.strict != null) {
@@ -1405,7 +1473,7 @@ async function prepareTools({
1405
1473
  break;
1406
1474
  }
1407
1475
  case "anthropic.text_editor_20250728": {
1408
- const args = await (0, import_provider_utils9.validateTypes)({
1476
+ const args = await validateTypes({
1409
1477
  value: tool.args,
1410
1478
  schema: textEditor_20250728ArgsSchema
1411
1479
  });
@@ -1445,7 +1513,7 @@ async function prepareTools({
1445
1513
  }
1446
1514
  case "anthropic.web_fetch_20250910": {
1447
1515
  betas.add("web-fetch-2025-09-10");
1448
- const args = await (0, import_provider_utils9.validateTypes)({
1516
+ const args = await validateTypes({
1449
1517
  value: tool.args,
1450
1518
  schema: webFetch_20250910ArgsSchema
1451
1519
  });
@@ -1463,7 +1531,7 @@ async function prepareTools({
1463
1531
  }
1464
1532
  case "anthropic.web_fetch_20260209": {
1465
1533
  betas.add("code-execution-web-tools-2026-02-09");
1466
- const args = await (0, import_provider_utils9.validateTypes)({
1534
+ const args = await validateTypes({
1467
1535
  value: tool.args,
1468
1536
  schema: webFetch_20260209ArgsSchema
1469
1537
  });
@@ -1480,7 +1548,7 @@ async function prepareTools({
1480
1548
  break;
1481
1549
  }
1482
1550
  case "anthropic.web_search_20250305": {
1483
- const args = await (0, import_provider_utils9.validateTypes)({
1551
+ const args = await validateTypes({
1484
1552
  value: tool.args,
1485
1553
  schema: webSearch_20250305ArgsSchema
1486
1554
  });
@@ -1497,7 +1565,7 @@ async function prepareTools({
1497
1565
  }
1498
1566
  case "anthropic.web_search_20260209": {
1499
1567
  betas.add("code-execution-web-tools-2026-02-09");
1500
- const args = await (0, import_provider_utils9.validateTypes)({
1568
+ const args = await validateTypes({
1501
1569
  value: tool.args,
1502
1570
  schema: webSearch_20260209ArgsSchema
1503
1571
  });
@@ -1513,7 +1581,6 @@ async function prepareTools({
1513
1581
  break;
1514
1582
  }
1515
1583
  case "anthropic.tool_search_regex_20251119": {
1516
- betas.add("advanced-tool-use-2025-11-20");
1517
1584
  anthropicTools2.push({
1518
1585
  type: "tool_search_tool_regex_20251119",
1519
1586
  name: "tool_search_tool_regex"
@@ -1521,7 +1588,6 @@ async function prepareTools({
1521
1588
  break;
1522
1589
  }
1523
1590
  case "anthropic.tool_search_bm25_20251119": {
1524
- betas.add("advanced-tool-use-2025-11-20");
1525
1591
  anthropicTools2.push({
1526
1592
  type: "tool_search_tool_bm25_20251119",
1527
1593
  name: "tool_search_tool_bm25"
@@ -1592,15 +1658,15 @@ async function prepareTools({
1592
1658
  };
1593
1659
  default: {
1594
1660
  const _exhaustiveCheck = type;
1595
- throw new import_provider.UnsupportedFunctionalityError({
1661
+ throw new UnsupportedFunctionalityError({
1596
1662
  functionality: `tool choice type: ${_exhaustiveCheck}`
1597
1663
  });
1598
1664
  }
1599
1665
  }
1600
1666
  }
1601
1667
 
1602
- // src/convert-anthropic-messages-usage.ts
1603
- function convertAnthropicMessagesUsage({
1668
+ // src/convert-anthropic-usage.ts
1669
+ function convertAnthropicUsage({
1604
1670
  usage,
1605
1671
  rawUsage
1606
1672
  }) {
@@ -1639,37 +1705,52 @@ function convertAnthropicMessagesUsage({
1639
1705
  };
1640
1706
  }
1641
1707
 
1642
- // src/convert-to-anthropic-messages-prompt.ts
1643
- var import_provider2 = require("@ai-sdk/provider");
1644
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
1708
+ // src/convert-to-anthropic-prompt.ts
1709
+ import {
1710
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
1711
+ } from "@ai-sdk/provider";
1712
+ import {
1713
+ convertBase64ToUint8Array,
1714
+ convertToBase64,
1715
+ getTopLevelMediaType,
1716
+ parseProviderOptions,
1717
+ resolveFullMediaType,
1718
+ resolveProviderReference,
1719
+ validateTypes as validateTypes2,
1720
+ isNonNullable
1721
+ } from "@ai-sdk/provider-utils";
1645
1722
 
1646
1723
  // src/tool/code-execution_20250522.ts
1647
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1648
- var import_v49 = require("zod/v4");
1649
- var codeExecution_20250522OutputSchema = (0, import_provider_utils10.lazySchema)(
1650
- () => (0, import_provider_utils10.zodSchema)(
1651
- import_v49.z.object({
1652
- type: import_v49.z.literal("code_execution_result"),
1653
- stdout: import_v49.z.string(),
1654
- stderr: import_v49.z.string(),
1655
- return_code: import_v49.z.number(),
1656
- content: import_v49.z.array(
1657
- import_v49.z.object({
1658
- type: import_v49.z.literal("code_execution_output"),
1659
- file_id: import_v49.z.string()
1724
+ import {
1725
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
1726
+ lazySchema as lazySchema8,
1727
+ zodSchema as zodSchema8
1728
+ } from "@ai-sdk/provider-utils";
1729
+ import { z as z9 } from "zod/v4";
1730
+ var codeExecution_20250522OutputSchema = lazySchema8(
1731
+ () => zodSchema8(
1732
+ z9.object({
1733
+ type: z9.literal("code_execution_result"),
1734
+ stdout: z9.string(),
1735
+ stderr: z9.string(),
1736
+ return_code: z9.number(),
1737
+ content: z9.array(
1738
+ z9.object({
1739
+ type: z9.literal("code_execution_output"),
1740
+ file_id: z9.string()
1660
1741
  })
1661
1742
  ).optional().default([])
1662
1743
  })
1663
1744
  )
1664
1745
  );
1665
- var codeExecution_20250522InputSchema = (0, import_provider_utils10.lazySchema)(
1666
- () => (0, import_provider_utils10.zodSchema)(
1667
- import_v49.z.object({
1668
- code: import_v49.z.string()
1746
+ var codeExecution_20250522InputSchema = lazySchema8(
1747
+ () => zodSchema8(
1748
+ z9.object({
1749
+ code: z9.string()
1669
1750
  })
1670
1751
  )
1671
1752
  );
1672
- var factory6 = (0, import_provider_utils10.createProviderToolFactoryWithOutputSchema)({
1753
+ var factory6 = createProviderExecutedToolFactory5({
1673
1754
  id: "anthropic.code_execution_20250522",
1674
1755
  inputSchema: codeExecution_20250522InputSchema,
1675
1756
  outputSchema: codeExecution_20250522OutputSchema
@@ -1679,102 +1760,106 @@ var codeExecution_20250522 = (args = {}) => {
1679
1760
  };
1680
1761
 
1681
1762
  // src/tool/code-execution_20250825.ts
1682
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1683
- var import_v410 = require("zod/v4");
1684
- var codeExecution_20250825OutputSchema = (0, import_provider_utils11.lazySchema)(
1685
- () => (0, import_provider_utils11.zodSchema)(
1686
- import_v410.z.discriminatedUnion("type", [
1687
- import_v410.z.object({
1688
- type: import_v410.z.literal("code_execution_result"),
1689
- stdout: import_v410.z.string(),
1690
- stderr: import_v410.z.string(),
1691
- return_code: import_v410.z.number(),
1692
- content: import_v410.z.array(
1693
- import_v410.z.object({
1694
- type: import_v410.z.literal("code_execution_output"),
1695
- file_id: import_v410.z.string()
1763
+ import {
1764
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
1765
+ lazySchema as lazySchema9,
1766
+ zodSchema as zodSchema9
1767
+ } from "@ai-sdk/provider-utils";
1768
+ import { z as z10 } from "zod/v4";
1769
+ var codeExecution_20250825OutputSchema = lazySchema9(
1770
+ () => zodSchema9(
1771
+ z10.discriminatedUnion("type", [
1772
+ z10.object({
1773
+ type: z10.literal("code_execution_result"),
1774
+ stdout: z10.string(),
1775
+ stderr: z10.string(),
1776
+ return_code: z10.number(),
1777
+ content: z10.array(
1778
+ z10.object({
1779
+ type: z10.literal("code_execution_output"),
1780
+ file_id: z10.string()
1696
1781
  })
1697
1782
  ).optional().default([])
1698
1783
  }),
1699
- import_v410.z.object({
1700
- type: import_v410.z.literal("bash_code_execution_result"),
1701
- content: import_v410.z.array(
1702
- import_v410.z.object({
1703
- type: import_v410.z.literal("bash_code_execution_output"),
1704
- file_id: import_v410.z.string()
1784
+ z10.object({
1785
+ type: z10.literal("bash_code_execution_result"),
1786
+ content: z10.array(
1787
+ z10.object({
1788
+ type: z10.literal("bash_code_execution_output"),
1789
+ file_id: z10.string()
1705
1790
  })
1706
1791
  ),
1707
- stdout: import_v410.z.string(),
1708
- stderr: import_v410.z.string(),
1709
- return_code: import_v410.z.number()
1792
+ stdout: z10.string(),
1793
+ stderr: z10.string(),
1794
+ return_code: z10.number()
1710
1795
  }),
1711
- import_v410.z.object({
1712
- type: import_v410.z.literal("bash_code_execution_tool_result_error"),
1713
- error_code: import_v410.z.string()
1796
+ z10.object({
1797
+ type: z10.literal("bash_code_execution_tool_result_error"),
1798
+ error_code: z10.string()
1714
1799
  }),
1715
- import_v410.z.object({
1716
- type: import_v410.z.literal("text_editor_code_execution_tool_result_error"),
1717
- error_code: import_v410.z.string()
1800
+ z10.object({
1801
+ type: z10.literal("text_editor_code_execution_tool_result_error"),
1802
+ error_code: z10.string()
1718
1803
  }),
1719
- import_v410.z.object({
1720
- type: import_v410.z.literal("text_editor_code_execution_view_result"),
1721
- content: import_v410.z.string(),
1722
- file_type: import_v410.z.string(),
1723
- num_lines: import_v410.z.number().nullable(),
1724
- start_line: import_v410.z.number().nullable(),
1725
- total_lines: import_v410.z.number().nullable()
1804
+ z10.object({
1805
+ type: z10.literal("text_editor_code_execution_view_result"),
1806
+ content: z10.string(),
1807
+ file_type: z10.string(),
1808
+ num_lines: z10.number().nullable(),
1809
+ start_line: z10.number().nullable(),
1810
+ total_lines: z10.number().nullable()
1726
1811
  }),
1727
- import_v410.z.object({
1728
- type: import_v410.z.literal("text_editor_code_execution_create_result"),
1729
- is_file_update: import_v410.z.boolean()
1812
+ z10.object({
1813
+ type: z10.literal("text_editor_code_execution_create_result"),
1814
+ is_file_update: z10.boolean()
1730
1815
  }),
1731
- import_v410.z.object({
1732
- type: import_v410.z.literal("text_editor_code_execution_str_replace_result"),
1733
- lines: import_v410.z.array(import_v410.z.string()).nullable(),
1734
- new_lines: import_v410.z.number().nullable(),
1735
- new_start: import_v410.z.number().nullable(),
1736
- old_lines: import_v410.z.number().nullable(),
1737
- old_start: import_v410.z.number().nullable()
1816
+ z10.object({
1817
+ type: z10.literal("text_editor_code_execution_str_replace_result"),
1818
+ lines: z10.array(z10.string()).nullable(),
1819
+ new_lines: z10.number().nullable(),
1820
+ new_start: z10.number().nullable(),
1821
+ old_lines: z10.number().nullable(),
1822
+ old_start: z10.number().nullable()
1738
1823
  })
1739
1824
  ])
1740
1825
  )
1741
1826
  );
1742
- var codeExecution_20250825InputSchema = (0, import_provider_utils11.lazySchema)(
1743
- () => (0, import_provider_utils11.zodSchema)(
1744
- import_v410.z.discriminatedUnion("type", [
1827
+ var codeExecution_20250825InputSchema = lazySchema9(
1828
+ () => zodSchema9(
1829
+ z10.discriminatedUnion("type", [
1745
1830
  // Programmatic tool calling format (mapped from { code } by AI SDK)
1746
- import_v410.z.object({
1747
- type: import_v410.z.literal("programmatic-tool-call"),
1748
- code: import_v410.z.string()
1831
+ z10.object({
1832
+ type: z10.literal("programmatic-tool-call"),
1833
+ code: z10.string()
1749
1834
  }),
1750
- import_v410.z.object({
1751
- type: import_v410.z.literal("bash_code_execution"),
1752
- command: import_v410.z.string()
1835
+ z10.object({
1836
+ type: z10.literal("bash_code_execution"),
1837
+ command: z10.string()
1753
1838
  }),
1754
- import_v410.z.discriminatedUnion("command", [
1755
- import_v410.z.object({
1756
- type: import_v410.z.literal("text_editor_code_execution"),
1757
- command: import_v410.z.literal("view"),
1758
- path: import_v410.z.string()
1839
+ z10.discriminatedUnion("command", [
1840
+ z10.object({
1841
+ type: z10.literal("text_editor_code_execution"),
1842
+ command: z10.literal("view"),
1843
+ path: z10.string()
1759
1844
  }),
1760
- import_v410.z.object({
1761
- type: import_v410.z.literal("text_editor_code_execution"),
1762
- command: import_v410.z.literal("create"),
1763
- path: import_v410.z.string(),
1764
- file_text: import_v410.z.string().nullish()
1845
+ z10.object({
1846
+ type: z10.literal("text_editor_code_execution"),
1847
+ command: z10.literal("create"),
1848
+ path: z10.string(),
1849
+ file_text: z10.string().nullish()
1765
1850
  }),
1766
- import_v410.z.object({
1767
- type: import_v410.z.literal("text_editor_code_execution"),
1768
- command: import_v410.z.literal("str_replace"),
1769
- path: import_v410.z.string(),
1770
- old_str: import_v410.z.string(),
1771
- new_str: import_v410.z.string()
1851
+ z10.object({
1852
+ type: z10.literal("text_editor_code_execution"),
1853
+ command: z10.literal("str_replace"),
1854
+ path: z10.string(),
1855
+ old_str: z10.string(),
1856
+ new_str: z10.string()
1772
1857
  })
1773
1858
  ])
1774
1859
  ])
1775
1860
  )
1776
1861
  );
1777
- var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
1862
+ var factory7 = createProviderExecutedToolFactory6({
1778
1863
  id: "anthropic.code_execution_20250825",
1779
1864
  inputSchema: codeExecution_20250825InputSchema,
1780
1865
  outputSchema: codeExecution_20250825OutputSchema,
@@ -1788,113 +1873,117 @@ var codeExecution_20250825 = (args = {}) => {
1788
1873
  };
1789
1874
 
1790
1875
  // src/tool/code-execution_20260120.ts
1791
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
1792
- var import_v411 = require("zod/v4");
1793
- var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)(
1794
- () => (0, import_provider_utils12.zodSchema)(
1795
- import_v411.z.discriminatedUnion("type", [
1796
- import_v411.z.object({
1797
- type: import_v411.z.literal("code_execution_result"),
1798
- stdout: import_v411.z.string(),
1799
- stderr: import_v411.z.string(),
1800
- return_code: import_v411.z.number(),
1801
- content: import_v411.z.array(
1802
- import_v411.z.object({
1803
- type: import_v411.z.literal("code_execution_output"),
1804
- file_id: import_v411.z.string()
1876
+ import {
1877
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
1878
+ lazySchema as lazySchema10,
1879
+ zodSchema as zodSchema10
1880
+ } from "@ai-sdk/provider-utils";
1881
+ import { z as z11 } from "zod/v4";
1882
+ var codeExecution_20260120OutputSchema = lazySchema10(
1883
+ () => zodSchema10(
1884
+ z11.discriminatedUnion("type", [
1885
+ z11.object({
1886
+ type: z11.literal("code_execution_result"),
1887
+ stdout: z11.string(),
1888
+ stderr: z11.string(),
1889
+ return_code: z11.number(),
1890
+ content: z11.array(
1891
+ z11.object({
1892
+ type: z11.literal("code_execution_output"),
1893
+ file_id: z11.string()
1805
1894
  })
1806
1895
  ).optional().default([])
1807
1896
  }),
1808
- import_v411.z.object({
1809
- type: import_v411.z.literal("encrypted_code_execution_result"),
1810
- encrypted_stdout: import_v411.z.string(),
1811
- stderr: import_v411.z.string(),
1812
- return_code: import_v411.z.number(),
1813
- content: import_v411.z.array(
1814
- import_v411.z.object({
1815
- type: import_v411.z.literal("code_execution_output"),
1816
- file_id: import_v411.z.string()
1897
+ z11.object({
1898
+ type: z11.literal("encrypted_code_execution_result"),
1899
+ encrypted_stdout: z11.string(),
1900
+ stderr: z11.string(),
1901
+ return_code: z11.number(),
1902
+ content: z11.array(
1903
+ z11.object({
1904
+ type: z11.literal("code_execution_output"),
1905
+ file_id: z11.string()
1817
1906
  })
1818
1907
  ).optional().default([])
1819
1908
  }),
1820
- import_v411.z.object({
1821
- type: import_v411.z.literal("bash_code_execution_result"),
1822
- content: import_v411.z.array(
1823
- import_v411.z.object({
1824
- type: import_v411.z.literal("bash_code_execution_output"),
1825
- file_id: import_v411.z.string()
1909
+ z11.object({
1910
+ type: z11.literal("bash_code_execution_result"),
1911
+ content: z11.array(
1912
+ z11.object({
1913
+ type: z11.literal("bash_code_execution_output"),
1914
+ file_id: z11.string()
1826
1915
  })
1827
1916
  ),
1828
- stdout: import_v411.z.string(),
1829
- stderr: import_v411.z.string(),
1830
- return_code: import_v411.z.number()
1917
+ stdout: z11.string(),
1918
+ stderr: z11.string(),
1919
+ return_code: z11.number()
1831
1920
  }),
1832
- import_v411.z.object({
1833
- type: import_v411.z.literal("bash_code_execution_tool_result_error"),
1834
- error_code: import_v411.z.string()
1921
+ z11.object({
1922
+ type: z11.literal("bash_code_execution_tool_result_error"),
1923
+ error_code: z11.string()
1835
1924
  }),
1836
- import_v411.z.object({
1837
- type: import_v411.z.literal("text_editor_code_execution_tool_result_error"),
1838
- error_code: import_v411.z.string()
1925
+ z11.object({
1926
+ type: z11.literal("text_editor_code_execution_tool_result_error"),
1927
+ error_code: z11.string()
1839
1928
  }),
1840
- import_v411.z.object({
1841
- type: import_v411.z.literal("text_editor_code_execution_view_result"),
1842
- content: import_v411.z.string(),
1843
- file_type: import_v411.z.string(),
1844
- num_lines: import_v411.z.number().nullable(),
1845
- start_line: import_v411.z.number().nullable(),
1846
- total_lines: import_v411.z.number().nullable()
1929
+ z11.object({
1930
+ type: z11.literal("text_editor_code_execution_view_result"),
1931
+ content: z11.string(),
1932
+ file_type: z11.string(),
1933
+ num_lines: z11.number().nullable(),
1934
+ start_line: z11.number().nullable(),
1935
+ total_lines: z11.number().nullable()
1847
1936
  }),
1848
- import_v411.z.object({
1849
- type: import_v411.z.literal("text_editor_code_execution_create_result"),
1850
- is_file_update: import_v411.z.boolean()
1937
+ z11.object({
1938
+ type: z11.literal("text_editor_code_execution_create_result"),
1939
+ is_file_update: z11.boolean()
1851
1940
  }),
1852
- import_v411.z.object({
1853
- type: import_v411.z.literal("text_editor_code_execution_str_replace_result"),
1854
- lines: import_v411.z.array(import_v411.z.string()).nullable(),
1855
- new_lines: import_v411.z.number().nullable(),
1856
- new_start: import_v411.z.number().nullable(),
1857
- old_lines: import_v411.z.number().nullable(),
1858
- old_start: import_v411.z.number().nullable()
1941
+ z11.object({
1942
+ type: z11.literal("text_editor_code_execution_str_replace_result"),
1943
+ lines: z11.array(z11.string()).nullable(),
1944
+ new_lines: z11.number().nullable(),
1945
+ new_start: z11.number().nullable(),
1946
+ old_lines: z11.number().nullable(),
1947
+ old_start: z11.number().nullable()
1859
1948
  })
1860
1949
  ])
1861
1950
  )
1862
1951
  );
1863
- var codeExecution_20260120InputSchema = (0, import_provider_utils12.lazySchema)(
1864
- () => (0, import_provider_utils12.zodSchema)(
1865
- import_v411.z.discriminatedUnion("type", [
1866
- import_v411.z.object({
1867
- type: import_v411.z.literal("programmatic-tool-call"),
1868
- code: import_v411.z.string()
1952
+ var codeExecution_20260120InputSchema = lazySchema10(
1953
+ () => zodSchema10(
1954
+ z11.discriminatedUnion("type", [
1955
+ z11.object({
1956
+ type: z11.literal("programmatic-tool-call"),
1957
+ code: z11.string()
1869
1958
  }),
1870
- import_v411.z.object({
1871
- type: import_v411.z.literal("bash_code_execution"),
1872
- command: import_v411.z.string()
1959
+ z11.object({
1960
+ type: z11.literal("bash_code_execution"),
1961
+ command: z11.string()
1873
1962
  }),
1874
- import_v411.z.discriminatedUnion("command", [
1875
- import_v411.z.object({
1876
- type: import_v411.z.literal("text_editor_code_execution"),
1877
- command: import_v411.z.literal("view"),
1878
- path: import_v411.z.string()
1963
+ z11.discriminatedUnion("command", [
1964
+ z11.object({
1965
+ type: z11.literal("text_editor_code_execution"),
1966
+ command: z11.literal("view"),
1967
+ path: z11.string()
1879
1968
  }),
1880
- import_v411.z.object({
1881
- type: import_v411.z.literal("text_editor_code_execution"),
1882
- command: import_v411.z.literal("create"),
1883
- path: import_v411.z.string(),
1884
- file_text: import_v411.z.string().nullish()
1969
+ z11.object({
1970
+ type: z11.literal("text_editor_code_execution"),
1971
+ command: z11.literal("create"),
1972
+ path: z11.string(),
1973
+ file_text: z11.string().nullish()
1885
1974
  }),
1886
- import_v411.z.object({
1887
- type: import_v411.z.literal("text_editor_code_execution"),
1888
- command: import_v411.z.literal("str_replace"),
1889
- path: import_v411.z.string(),
1890
- old_str: import_v411.z.string(),
1891
- new_str: import_v411.z.string()
1975
+ z11.object({
1976
+ type: z11.literal("text_editor_code_execution"),
1977
+ command: z11.literal("str_replace"),
1978
+ path: z11.string(),
1979
+ old_str: z11.string(),
1980
+ new_str: z11.string()
1892
1981
  })
1893
1982
  ])
1894
1983
  ])
1895
1984
  )
1896
1985
  );
1897
- var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
1986
+ var factory8 = createProviderExecutedToolFactory7({
1898
1987
  id: "anthropic.code_execution_20260120",
1899
1988
  inputSchema: codeExecution_20260120InputSchema,
1900
1989
  outputSchema: codeExecution_20260120OutputSchema,
@@ -1905,21 +1994,25 @@ var codeExecution_20260120 = (args = {}) => {
1905
1994
  };
1906
1995
 
1907
1996
  // src/tool/tool-search-regex_20251119.ts
1908
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
1909
- var import_v412 = require("zod/v4");
1910
- var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils13.lazySchema)(
1911
- () => (0, import_provider_utils13.zodSchema)(
1912
- import_v412.z.array(
1913
- import_v412.z.object({
1914
- type: import_v412.z.literal("tool_reference"),
1915
- toolName: import_v412.z.string()
1997
+ import {
1998
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory8,
1999
+ lazySchema as lazySchema11,
2000
+ zodSchema as zodSchema11
2001
+ } from "@ai-sdk/provider-utils";
2002
+ import { z as z12 } from "zod/v4";
2003
+ var toolSearchRegex_20251119OutputSchema = lazySchema11(
2004
+ () => zodSchema11(
2005
+ z12.array(
2006
+ z12.object({
2007
+ type: z12.literal("tool_reference"),
2008
+ toolName: z12.string()
1916
2009
  })
1917
2010
  )
1918
2011
  )
1919
2012
  );
1920
- var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema)(
1921
- () => (0, import_provider_utils13.zodSchema)(
1922
- import_v412.z.object({
2013
+ var toolSearchRegex_20251119InputSchema = lazySchema11(
2014
+ () => zodSchema11(
2015
+ z12.object({
1923
2016
  /**
1924
2017
  * A regex pattern to search for tools.
1925
2018
  * Uses Python re.search() syntax. Maximum 200 characters.
@@ -1930,15 +2023,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
1930
2023
  * - "database.*query|query.*database" - OR patterns for flexibility
1931
2024
  * - "(?i)slack" - case-insensitive search
1932
2025
  */
1933
- pattern: import_v412.z.string(),
2026
+ pattern: z12.string(),
1934
2027
  /**
1935
2028
  * Maximum number of tools to return. Optional.
1936
2029
  */
1937
- limit: import_v412.z.number().optional()
2030
+ limit: z12.number().optional()
1938
2031
  })
1939
2032
  )
1940
2033
  );
1941
- var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
2034
+ var factory9 = createProviderExecutedToolFactory8({
1942
2035
  id: "anthropic.tool_search_regex_20251119",
1943
2036
  inputSchema: toolSearchRegex_20251119InputSchema,
1944
2037
  outputSchema: toolSearchRegex_20251119OutputSchema,
@@ -1948,40 +2041,21 @@ var toolSearchRegex_20251119 = (args = {}) => {
1948
2041
  return factory9(args);
1949
2042
  };
1950
2043
 
1951
- // src/convert-to-anthropic-messages-prompt.ts
1952
- function convertToString(data) {
2044
+ // src/convert-to-anthropic-prompt.ts
2045
+ function convertBytesDataToString(data) {
1953
2046
  if (typeof data === "string") {
1954
- return new TextDecoder().decode((0, import_provider_utils14.convertBase64ToUint8Array)(data));
1955
- }
1956
- if (data instanceof Uint8Array) {
1957
- return new TextDecoder().decode(data);
1958
- }
1959
- if (data instanceof URL) {
1960
- throw new import_provider2.UnsupportedFunctionalityError({
1961
- functionality: "URL-based text documents are not supported for citations"
1962
- });
2047
+ return new TextDecoder().decode(convertBase64ToUint8Array(data));
1963
2048
  }
1964
- throw new import_provider2.UnsupportedFunctionalityError({
1965
- functionality: `unsupported data type for text documents: ${typeof data}`
1966
- });
1967
- }
1968
- function isUrlData(data) {
1969
- return data instanceof URL || isUrlString(data);
2049
+ return new TextDecoder().decode(data);
1970
2050
  }
1971
- function isUrlString(data) {
1972
- return typeof data === "string" && /^https?:\/\//i.test(data);
1973
- }
1974
- function getUrlString(data) {
1975
- return data instanceof URL ? data.toString() : data;
1976
- }
1977
- async function convertToAnthropicMessagesPrompt({
2051
+ async function convertToAnthropicPrompt({
1978
2052
  prompt,
1979
2053
  sendReasoning,
1980
2054
  warnings,
1981
2055
  cacheControlValidator,
1982
2056
  toolNameMapping
1983
2057
  }) {
1984
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
2058
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
1985
2059
  const betas = /* @__PURE__ */ new Set();
1986
2060
  const blocks = groupIntoBlocks(prompt);
1987
2061
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -1989,7 +2063,7 @@ async function convertToAnthropicMessagesPrompt({
1989
2063
  const messages = [];
1990
2064
  async function shouldEnableCitations(providerMetadata) {
1991
2065
  var _a2, _b2;
1992
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2066
+ const anthropicOptions = await parseProviderOptions({
1993
2067
  provider: "anthropic",
1994
2068
  providerOptions: providerMetadata,
1995
2069
  schema: anthropicFilePartProviderOptions
@@ -1997,7 +2071,7 @@ async function convertToAnthropicMessagesPrompt({
1997
2071
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
1998
2072
  }
1999
2073
  async function getDocumentMetadata(providerMetadata) {
2000
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2074
+ const anthropicOptions = await parseProviderOptions({
2001
2075
  provider: "anthropic",
2002
2076
  providerOptions: providerMetadata,
2003
2077
  schema: anthropicFilePartProviderOptions
@@ -2014,7 +2088,7 @@ async function convertToAnthropicMessagesPrompt({
2014
2088
  switch (type) {
2015
2089
  case "system": {
2016
2090
  if (system != null) {
2017
- throw new import_provider2.UnsupportedFunctionalityError({
2091
+ throw new UnsupportedFunctionalityError2({
2018
2092
  functionality: "Multiple system messages that are separated by user/assistant messages"
2019
2093
  });
2020
2094
  }
@@ -2054,72 +2128,131 @@ async function convertToAnthropicMessagesPrompt({
2054
2128
  break;
2055
2129
  }
2056
2130
  case "file": {
2057
- if (part.mediaType.startsWith("image/")) {
2058
- anthropicContent.push({
2059
- type: "image",
2060
- source: isUrlData(part.data) ? {
2061
- type: "url",
2062
- url: getUrlString(part.data)
2063
- } : {
2064
- type: "base64",
2065
- media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
2066
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2067
- },
2068
- cache_control: cacheControl
2069
- });
2070
- } else if (part.mediaType === "application/pdf") {
2071
- betas.add("pdfs-2024-09-25");
2072
- const enableCitations = await shouldEnableCitations(
2073
- part.providerOptions
2074
- );
2075
- const metadata = await getDocumentMetadata(
2076
- part.providerOptions
2077
- );
2078
- anthropicContent.push({
2079
- type: "document",
2080
- source: isUrlData(part.data) ? {
2081
- type: "url",
2082
- url: getUrlString(part.data)
2083
- } : {
2084
- type: "base64",
2085
- media_type: "application/pdf",
2086
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2087
- },
2088
- title: (_b = metadata.title) != null ? _b : part.filename,
2089
- ...metadata.context && { context: metadata.context },
2090
- ...enableCitations && {
2091
- citations: { enabled: true }
2092
- },
2093
- cache_control: cacheControl
2094
- });
2095
- } else if (part.mediaType === "text/plain") {
2096
- const enableCitations = await shouldEnableCitations(
2097
- part.providerOptions
2098
- );
2099
- const metadata = await getDocumentMetadata(
2100
- part.providerOptions
2101
- );
2102
- anthropicContent.push({
2103
- type: "document",
2104
- source: isUrlData(part.data) ? {
2105
- type: "url",
2106
- url: getUrlString(part.data)
2107
- } : {
2108
- type: "text",
2109
- media_type: "text/plain",
2110
- data: convertToString(part.data)
2111
- },
2112
- title: (_c = metadata.title) != null ? _c : part.filename,
2113
- ...metadata.context && { context: metadata.context },
2114
- ...enableCitations && {
2115
- citations: { enabled: true }
2116
- },
2117
- cache_control: cacheControl
2118
- });
2119
- } else {
2120
- throw new import_provider2.UnsupportedFunctionalityError({
2121
- functionality: `media type: ${part.mediaType}`
2122
- });
2131
+ switch (part.data.type) {
2132
+ case "reference": {
2133
+ const fileId = resolveProviderReference({
2134
+ reference: part.data.reference,
2135
+ provider: "anthropic"
2136
+ });
2137
+ betas.add("files-api-2025-04-14");
2138
+ if (getTopLevelMediaType(part.mediaType) === "image") {
2139
+ anthropicContent.push({
2140
+ type: "image",
2141
+ source: { type: "file", file_id: fileId },
2142
+ cache_control: cacheControl
2143
+ });
2144
+ } else {
2145
+ anthropicContent.push({
2146
+ type: "document",
2147
+ source: { type: "file", file_id: fileId },
2148
+ cache_control: cacheControl
2149
+ });
2150
+ }
2151
+ break;
2152
+ }
2153
+ case "text": {
2154
+ const enableCitations = await shouldEnableCitations(
2155
+ part.providerOptions
2156
+ );
2157
+ const metadata = await getDocumentMetadata(
2158
+ part.providerOptions
2159
+ );
2160
+ anthropicContent.push({
2161
+ type: "document",
2162
+ source: {
2163
+ type: "text",
2164
+ media_type: "text/plain",
2165
+ data: part.data.text
2166
+ },
2167
+ title: (_b = metadata.title) != null ? _b : part.filename,
2168
+ ...metadata.context && {
2169
+ context: metadata.context
2170
+ },
2171
+ ...enableCitations && {
2172
+ citations: { enabled: true }
2173
+ },
2174
+ cache_control: cacheControl
2175
+ });
2176
+ break;
2177
+ }
2178
+ case "url":
2179
+ case "data": {
2180
+ const topLevel = getTopLevelMediaType(part.mediaType);
2181
+ if (topLevel === "image") {
2182
+ anthropicContent.push({
2183
+ type: "image",
2184
+ source: part.data.type === "url" ? {
2185
+ type: "url",
2186
+ url: part.data.url.toString()
2187
+ } : {
2188
+ type: "base64",
2189
+ media_type: resolveFullMediaType({ part }),
2190
+ data: convertToBase64(part.data.data)
2191
+ },
2192
+ cache_control: cacheControl
2193
+ });
2194
+ } else if (topLevel === "application" && (part.data.type === "url" ? part.mediaType === "application/pdf" : resolveFullMediaType({ part }) === "application/pdf")) {
2195
+ betas.add("pdfs-2024-09-25");
2196
+ const enableCitations = await shouldEnableCitations(
2197
+ part.providerOptions
2198
+ );
2199
+ const metadata = await getDocumentMetadata(
2200
+ part.providerOptions
2201
+ );
2202
+ anthropicContent.push({
2203
+ type: "document",
2204
+ source: part.data.type === "url" ? {
2205
+ type: "url",
2206
+ url: part.data.url.toString()
2207
+ } : {
2208
+ type: "base64",
2209
+ media_type: "application/pdf",
2210
+ data: convertToBase64(part.data.data)
2211
+ },
2212
+ title: (_c = metadata.title) != null ? _c : part.filename,
2213
+ ...metadata.context && {
2214
+ context: metadata.context
2215
+ },
2216
+ ...enableCitations && {
2217
+ citations: { enabled: true }
2218
+ },
2219
+ cache_control: cacheControl
2220
+ });
2221
+ } else if (part.mediaType === "text/plain") {
2222
+ const enableCitations = await shouldEnableCitations(
2223
+ part.providerOptions
2224
+ );
2225
+ const metadata = await getDocumentMetadata(
2226
+ part.providerOptions
2227
+ );
2228
+ anthropicContent.push({
2229
+ type: "document",
2230
+ source: part.data.type === "url" ? {
2231
+ type: "url",
2232
+ url: part.data.url.toString()
2233
+ } : {
2234
+ type: "text",
2235
+ media_type: "text/plain",
2236
+ data: convertBytesDataToString(
2237
+ part.data.data
2238
+ )
2239
+ },
2240
+ title: (_d = metadata.title) != null ? _d : part.filename,
2241
+ ...metadata.context && {
2242
+ context: metadata.context
2243
+ },
2244
+ ...enableCitations && {
2245
+ citations: { enabled: true }
2246
+ },
2247
+ cache_control: cacheControl
2248
+ });
2249
+ } else {
2250
+ throw new UnsupportedFunctionalityError2({
2251
+ functionality: `media type: ${part.mediaType}`
2252
+ });
2253
+ }
2254
+ break;
2255
+ }
2123
2256
  }
2124
2257
  break;
2125
2258
  }
@@ -2134,10 +2267,10 @@ async function convertToAnthropicMessagesPrompt({
2134
2267
  continue;
2135
2268
  }
2136
2269
  const isLastPart = i2 === content.length - 1;
2137
- const cacheControl = (_d = validator.getCacheControl(part.providerOptions, {
2270
+ const cacheControl = (_e = validator.getCacheControl(part.providerOptions, {
2138
2271
  type: "tool result part",
2139
2272
  canCache: true
2140
- })) != null ? _d : isLastPart ? validator.getCacheControl(message.providerOptions, {
2273
+ })) != null ? _e : isLastPart ? validator.getCacheControl(message.providerOptions, {
2141
2274
  type: "tool result message",
2142
2275
  canCache: true
2143
2276
  }) : void 0;
@@ -2153,26 +2286,16 @@ async function convertToAnthropicMessagesPrompt({
2153
2286
  type: "text",
2154
2287
  text: contentPart.text
2155
2288
  };
2156
- case "image-data": {
2157
- return {
2158
- type: "image",
2159
- source: {
2160
- type: "base64",
2161
- media_type: contentPart.mediaType,
2162
- data: contentPart.data
2163
- }
2164
- };
2165
- }
2166
- case "image-url": {
2167
- return {
2168
- type: "image",
2169
- source: {
2170
- type: "url",
2171
- url: contentPart.url
2172
- }
2173
- };
2174
- }
2175
2289
  case "file-url": {
2290
+ if (contentPart.mediaType.startsWith("image/")) {
2291
+ return {
2292
+ type: "image",
2293
+ source: {
2294
+ type: "url",
2295
+ url: contentPart.url
2296
+ }
2297
+ };
2298
+ }
2176
2299
  return {
2177
2300
  type: "document",
2178
2301
  source: {
@@ -2182,6 +2305,16 @@ async function convertToAnthropicMessagesPrompt({
2182
2305
  };
2183
2306
  }
2184
2307
  case "file-data": {
2308
+ if (contentPart.mediaType.startsWith("image/")) {
2309
+ return {
2310
+ type: "image",
2311
+ source: {
2312
+ type: "base64",
2313
+ media_type: contentPart.mediaType,
2314
+ data: contentPart.data
2315
+ }
2316
+ };
2317
+ }
2185
2318
  if (contentPart.mediaType === "application/pdf") {
2186
2319
  betas.add("pdfs-2024-09-25");
2187
2320
  return {
@@ -2221,14 +2354,14 @@ async function convertToAnthropicMessagesPrompt({
2221
2354
  return void 0;
2222
2355
  }
2223
2356
  }
2224
- }).filter(import_provider_utils14.isNonNullable);
2357
+ }).filter(isNonNullable);
2225
2358
  break;
2226
2359
  case "text":
2227
2360
  case "error-text":
2228
2361
  contentValue = output.value;
2229
2362
  break;
2230
2363
  case "execution-denied":
2231
- contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
2364
+ contentValue = (_f = output.reason) != null ? _f : "Tool call execution denied.";
2232
2365
  break;
2233
2366
  case "json":
2234
2367
  case "error-json":
@@ -2265,16 +2398,16 @@ async function convertToAnthropicMessagesPrompt({
2265
2398
  for (let k = 0; k < content.length; k++) {
2266
2399
  const part = content[k];
2267
2400
  const isLastContentPart = k === content.length - 1;
2268
- const cacheControl = (_f = validator.getCacheControl(part.providerOptions, {
2401
+ const cacheControl = (_g = validator.getCacheControl(part.providerOptions, {
2269
2402
  type: "assistant message part",
2270
2403
  canCache: true
2271
- })) != null ? _f : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2404
+ })) != null ? _g : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2272
2405
  type: "assistant message",
2273
2406
  canCache: true
2274
2407
  }) : void 0;
2275
2408
  switch (part.type) {
2276
2409
  case "text": {
2277
- const textMetadata = (_g = part.providerOptions) == null ? void 0 : _g.anthropic;
2410
+ const textMetadata = (_h = part.providerOptions) == null ? void 0 : _h.anthropic;
2278
2411
  if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
2279
2412
  anthropicContent.push({
2280
2413
  type: "compaction",
@@ -2297,7 +2430,7 @@ async function convertToAnthropicMessagesPrompt({
2297
2430
  }
2298
2431
  case "reasoning": {
2299
2432
  if (sendReasoning) {
2300
- const reasoningMetadata = await (0, import_provider_utils14.parseProviderOptions)({
2433
+ const reasoningMetadata = await parseProviderOptions({
2301
2434
  provider: "anthropic",
2302
2435
  providerOptions: part.providerOptions,
2303
2436
  schema: anthropicReasoningMetadataSchema
@@ -2347,10 +2480,10 @@ async function convertToAnthropicMessagesPrompt({
2347
2480
  const providerToolName = toolNameMapping.toProviderToolName(
2348
2481
  part.toolName
2349
2482
  );
2350
- const isMcpToolUse = ((_i = (_h = part.providerOptions) == null ? void 0 : _h.anthropic) == null ? void 0 : _i.type) === "mcp-tool-use";
2483
+ const isMcpToolUse = ((_j = (_i = part.providerOptions) == null ? void 0 : _i.anthropic) == null ? void 0 : _j.type) === "mcp-tool-use";
2351
2484
  if (isMcpToolUse) {
2352
2485
  mcpToolUseIds.add(part.toolCallId);
2353
- const serverName = (_k = (_j = part.providerOptions) == null ? void 0 : _j.anthropic) == null ? void 0 : _k.serverName;
2486
+ const serverName = (_l = (_k = part.providerOptions) == null ? void 0 : _k.anthropic) == null ? void 0 : _l.serverName;
2354
2487
  if (serverName == null || typeof serverName !== "string") {
2355
2488
  warnings.push({
2356
2489
  type: "other",
@@ -2418,7 +2551,7 @@ async function convertToAnthropicMessagesPrompt({
2418
2551
  }
2419
2552
  break;
2420
2553
  }
2421
- const callerOptions = (_l = part.providerOptions) == null ? void 0 : _l.anthropic;
2554
+ const callerOptions = (_m = part.providerOptions) == null ? void 0 : _m.anthropic;
2422
2555
  const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
2423
2556
  type: callerOptions.caller.type,
2424
2557
  tool_id: callerOptions.caller.toolId
@@ -2471,7 +2604,7 @@ async function convertToAnthropicMessagesPrompt({
2471
2604
  tool_use_id: part.toolCallId,
2472
2605
  content: {
2473
2606
  type: "code_execution_tool_result_error",
2474
- error_code: (_m = errorInfo.errorCode) != null ? _m : "unknown"
2607
+ error_code: (_n = errorInfo.errorCode) != null ? _n : "unknown"
2475
2608
  },
2476
2609
  cache_control: cacheControl
2477
2610
  });
@@ -2482,7 +2615,7 @@ async function convertToAnthropicMessagesPrompt({
2482
2615
  cache_control: cacheControl,
2483
2616
  content: {
2484
2617
  type: "bash_code_execution_tool_result_error",
2485
- error_code: (_n = errorInfo.errorCode) != null ? _n : "unknown"
2618
+ error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
2486
2619
  }
2487
2620
  });
2488
2621
  }
@@ -2503,7 +2636,7 @@ async function convertToAnthropicMessagesPrompt({
2503
2636
  break;
2504
2637
  }
2505
2638
  if (output.value.type === "code_execution_result") {
2506
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2639
+ const codeExecutionOutput = await validateTypes2({
2507
2640
  value: output.value,
2508
2641
  schema: codeExecution_20250522OutputSchema
2509
2642
  });
@@ -2515,12 +2648,12 @@ async function convertToAnthropicMessagesPrompt({
2515
2648
  stdout: codeExecutionOutput.stdout,
2516
2649
  stderr: codeExecutionOutput.stderr,
2517
2650
  return_code: codeExecutionOutput.return_code,
2518
- content: (_o = codeExecutionOutput.content) != null ? _o : []
2651
+ content: (_p = codeExecutionOutput.content) != null ? _p : []
2519
2652
  },
2520
2653
  cache_control: cacheControl
2521
2654
  });
2522
2655
  } else if (output.value.type === "encrypted_code_execution_result") {
2523
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2656
+ const codeExecutionOutput = await validateTypes2({
2524
2657
  value: output.value,
2525
2658
  schema: codeExecution_20260120OutputSchema
2526
2659
  });
@@ -2533,13 +2666,13 @@ async function convertToAnthropicMessagesPrompt({
2533
2666
  encrypted_stdout: codeExecutionOutput.encrypted_stdout,
2534
2667
  stderr: codeExecutionOutput.stderr,
2535
2668
  return_code: codeExecutionOutput.return_code,
2536
- content: (_p = codeExecutionOutput.content) != null ? _p : []
2669
+ content: (_q = codeExecutionOutput.content) != null ? _q : []
2537
2670
  },
2538
2671
  cache_control: cacheControl
2539
2672
  });
2540
2673
  }
2541
2674
  } else {
2542
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2675
+ const codeExecutionOutput = await validateTypes2({
2543
2676
  value: output.value,
2544
2677
  schema: codeExecution_20250825OutputSchema
2545
2678
  });
@@ -2552,7 +2685,7 @@ async function convertToAnthropicMessagesPrompt({
2552
2685
  stdout: codeExecutionOutput.stdout,
2553
2686
  stderr: codeExecutionOutput.stderr,
2554
2687
  return_code: codeExecutionOutput.return_code,
2555
- content: (_q = codeExecutionOutput.content) != null ? _q : []
2688
+ content: (_r = codeExecutionOutput.content) != null ? _r : []
2556
2689
  },
2557
2690
  cache_control: cacheControl
2558
2691
  });
@@ -2585,7 +2718,7 @@ async function convertToAnthropicMessagesPrompt({
2585
2718
  errorValue = output.value;
2586
2719
  }
2587
2720
  } catch (e) {
2588
- const extractedErrorCode = (_r = output.value) == null ? void 0 : _r.errorCode;
2721
+ const extractedErrorCode = (_s = output.value) == null ? void 0 : _s.errorCode;
2589
2722
  errorValue = {
2590
2723
  errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
2591
2724
  };
@@ -2595,7 +2728,7 @@ async function convertToAnthropicMessagesPrompt({
2595
2728
  tool_use_id: part.toolCallId,
2596
2729
  content: {
2597
2730
  type: "web_fetch_tool_result_error",
2598
- error_code: (_s = errorValue.errorCode) != null ? _s : "unavailable"
2731
+ error_code: (_t = errorValue.errorCode) != null ? _t : "unavailable"
2599
2732
  },
2600
2733
  cache_control: cacheControl
2601
2734
  });
@@ -2608,7 +2741,7 @@ async function convertToAnthropicMessagesPrompt({
2608
2741
  });
2609
2742
  break;
2610
2743
  }
2611
- const webFetchOutput = await (0, import_provider_utils14.validateTypes)({
2744
+ const webFetchOutput = await validateTypes2({
2612
2745
  value: output.value,
2613
2746
  schema: webFetch_20250910OutputSchema
2614
2747
  });
@@ -2643,7 +2776,7 @@ async function convertToAnthropicMessagesPrompt({
2643
2776
  });
2644
2777
  break;
2645
2778
  }
2646
- const webSearchOutput = await (0, import_provider_utils14.validateTypes)({
2779
+ const webSearchOutput = await validateTypes2({
2647
2780
  value: output.value,
2648
2781
  schema: webSearch_20250305OutputSchema
2649
2782
  });
@@ -2670,7 +2803,7 @@ async function convertToAnthropicMessagesPrompt({
2670
2803
  });
2671
2804
  break;
2672
2805
  }
2673
- const toolSearchOutput = await (0, import_provider_utils14.validateTypes)({
2806
+ const toolSearchOutput = await validateTypes2({
2674
2807
  value: output.value,
2675
2808
  schema: toolSearchRegex_20251119OutputSchema
2676
2809
  });
@@ -2783,7 +2916,153 @@ function mapAnthropicStopReason({
2783
2916
  }
2784
2917
  }
2785
2918
 
2786
- // src/anthropic-messages-language-model.ts
2919
+ // src/sanitize-json-schema.ts
2920
+ var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
2921
+ "date-time",
2922
+ "time",
2923
+ "date",
2924
+ "duration",
2925
+ "email",
2926
+ "hostname",
2927
+ "uri",
2928
+ "ipv4",
2929
+ "ipv6",
2930
+ "uuid"
2931
+ ]);
2932
+ var DESCRIPTION_CONSTRAINT_KEYS = [
2933
+ "minimum",
2934
+ "maximum",
2935
+ "exclusiveMinimum",
2936
+ "exclusiveMaximum",
2937
+ "multipleOf",
2938
+ "minLength",
2939
+ "maxLength",
2940
+ "pattern",
2941
+ "minItems",
2942
+ "maxItems",
2943
+ "uniqueItems",
2944
+ "minProperties",
2945
+ "maxProperties",
2946
+ "not"
2947
+ ];
2948
+ function sanitizeJsonSchema(schema) {
2949
+ return sanitizeSchema(schema);
2950
+ }
2951
+ function sanitizeDefinition(definition) {
2952
+ if (typeof definition === "boolean" || !isPlainObject(definition)) {
2953
+ return definition;
2954
+ }
2955
+ return sanitizeSchema(definition);
2956
+ }
2957
+ function sanitizeSchema(schema) {
2958
+ const result = {};
2959
+ const schemaWithDefs = schema;
2960
+ if (schema.$ref != null) {
2961
+ return { $ref: schema.$ref };
2962
+ }
2963
+ if (schema.$schema != null) {
2964
+ result.$schema = schema.$schema;
2965
+ }
2966
+ if (schema.$id != null) {
2967
+ result.$id = schema.$id;
2968
+ }
2969
+ if (schema.title != null) {
2970
+ result.title = schema.title;
2971
+ }
2972
+ if (schema.description != null) {
2973
+ result.description = schema.description;
2974
+ }
2975
+ if (schema.default !== void 0) {
2976
+ result.default = schema.default;
2977
+ }
2978
+ if (schema.const !== void 0) {
2979
+ result.const = schema.const;
2980
+ }
2981
+ if (schema.enum != null) {
2982
+ result.enum = schema.enum;
2983
+ }
2984
+ if (schema.type != null) {
2985
+ result.type = schema.type;
2986
+ }
2987
+ if (schema.anyOf != null) {
2988
+ result.anyOf = schema.anyOf.map(sanitizeDefinition);
2989
+ } else if (schema.oneOf != null) {
2990
+ result.anyOf = schema.oneOf.map(sanitizeDefinition);
2991
+ }
2992
+ if (schema.allOf != null) {
2993
+ result.allOf = schema.allOf.map(sanitizeDefinition);
2994
+ }
2995
+ if (schema.definitions != null) {
2996
+ result.definitions = Object.fromEntries(
2997
+ Object.entries(schema.definitions).map(([name, definition]) => [
2998
+ name,
2999
+ sanitizeDefinition(definition)
3000
+ ])
3001
+ );
3002
+ }
3003
+ if (schemaWithDefs.$defs != null) {
3004
+ const resultWithDefs = result;
3005
+ resultWithDefs.$defs = Object.fromEntries(
3006
+ Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
3007
+ name,
3008
+ sanitizeDefinition(definition)
3009
+ ])
3010
+ );
3011
+ }
3012
+ if (schema.type === "object" || schema.properties != null) {
3013
+ if (schema.properties != null) {
3014
+ result.properties = Object.fromEntries(
3015
+ Object.entries(schema.properties).map(([name, definition]) => [
3016
+ name,
3017
+ sanitizeDefinition(definition)
3018
+ ])
3019
+ );
3020
+ }
3021
+ result.additionalProperties = false;
3022
+ if (schema.required != null) {
3023
+ result.required = schema.required;
3024
+ }
3025
+ }
3026
+ if (schema.items != null) {
3027
+ result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
3028
+ }
3029
+ if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
3030
+ result.format = schema.format;
3031
+ }
3032
+ const constraintDescription = getConstraintDescription(schema);
3033
+ if (constraintDescription != null) {
3034
+ result.description = result.description == null ? constraintDescription : `${result.description}
3035
+ ${constraintDescription}`;
3036
+ }
3037
+ return result;
3038
+ }
3039
+ function getConstraintDescription(schema) {
3040
+ const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
3041
+ const value = schema[key];
3042
+ if (value == null || value === false) {
3043
+ return [];
3044
+ }
3045
+ return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
3046
+ });
3047
+ if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
3048
+ descriptions.push(`format: ${schema.format}`);
3049
+ }
3050
+ return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
3051
+ }
3052
+ function formatConstraintName(key) {
3053
+ return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
3054
+ }
3055
+ function formatConstraintValue(value) {
3056
+ if (typeof value === "string") {
3057
+ return value;
3058
+ }
3059
+ return JSON.stringify(value);
3060
+ }
3061
+ function isPlainObject(value) {
3062
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3063
+ }
3064
+
3065
+ // src/anthropic-language-model.ts
2787
3066
  function createCitationSource(citation, citationDocuments, generateId2) {
2788
3067
  var _a;
2789
3068
  if (citation.type === "web_search_result_location") {
@@ -2828,13 +3107,22 @@ function createCitationSource(citation, citationDocuments, generateId2) {
2828
3107
  }
2829
3108
  };
2830
3109
  }
2831
- var AnthropicMessagesLanguageModel = class {
3110
+ var AnthropicLanguageModel = class _AnthropicLanguageModel {
2832
3111
  constructor(modelId, config) {
2833
3112
  this.specificationVersion = "v4";
2834
3113
  var _a;
2835
3114
  this.modelId = modelId;
2836
3115
  this.config = config;
2837
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils15.generateId;
3116
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
3117
+ }
3118
+ static [WORKFLOW_SERIALIZE](model) {
3119
+ return serializeModelOptions({
3120
+ modelId: model.modelId,
3121
+ config: model.config
3122
+ });
3123
+ }
3124
+ static [WORKFLOW_DESERIALIZE](options) {
3125
+ return new _AnthropicLanguageModel(options.modelId, options.config);
2838
3126
  }
2839
3127
  supportsUrl(url) {
2840
3128
  return url.protocol === "https:";
@@ -2869,10 +3157,11 @@ var AnthropicMessagesLanguageModel = class {
2869
3157
  seed,
2870
3158
  tools,
2871
3159
  toolChoice,
3160
+ reasoning,
2872
3161
  providerOptions,
2873
3162
  stream
2874
3163
  }) {
2875
- var _a, _b, _c, _d, _e, _f, _g, _h;
3164
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2876
3165
  const warnings = [];
2877
3166
  if (frequencyPenalty != null) {
2878
3167
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2908,12 +3197,12 @@ var AnthropicMessagesLanguageModel = class {
2908
3197
  }
2909
3198
  }
2910
3199
  const providerOptionsName = this.providerOptionsName;
2911
- const canonicalOptions = await (0, import_provider_utils15.parseProviderOptions)({
3200
+ const canonicalOptions = await parseProviderOptions2({
2912
3201
  provider: "anthropic",
2913
3202
  providerOptions,
2914
3203
  schema: anthropicLanguageModelOptions
2915
3204
  });
2916
- const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils15.parseProviderOptions)({
3205
+ const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
2917
3206
  provider: providerOptionsName,
2918
3207
  providerOptions,
2919
3208
  schema: anthropicLanguageModelOptions
@@ -2927,8 +3216,38 @@ var AnthropicMessagesLanguageModel = class {
2927
3216
  const {
2928
3217
  maxOutputTokens: maxOutputTokensForModel,
2929
3218
  supportsStructuredOutput: modelSupportsStructuredOutput,
3219
+ supportsAdaptiveThinking,
3220
+ rejectsSamplingParameters,
3221
+ supportsXhighEffort,
2930
3222
  isKnownModel
2931
3223
  } = getModelCapabilities(this.modelId);
3224
+ if (rejectsSamplingParameters) {
3225
+ if (temperature != null) {
3226
+ warnings.push({
3227
+ type: "unsupported",
3228
+ feature: "temperature",
3229
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
3230
+ });
3231
+ temperature = void 0;
3232
+ }
3233
+ if (topK != null) {
3234
+ warnings.push({
3235
+ type: "unsupported",
3236
+ feature: "topK",
3237
+ details: `topK is not supported by ${this.modelId} and will be ignored`
3238
+ });
3239
+ topK = void 0;
3240
+ }
3241
+ if (topP != null) {
3242
+ warnings.push({
3243
+ type: "unsupported",
3244
+ feature: "topP",
3245
+ details: `topP is not supported by ${this.modelId} and will be ignored`
3246
+ });
3247
+ topP = void 0;
3248
+ }
3249
+ }
3250
+ const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2932
3251
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2933
3252
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
2934
3253
  const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
@@ -2941,7 +3260,7 @@ var AnthropicMessagesLanguageModel = class {
2941
3260
  } : void 0;
2942
3261
  const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
2943
3262
  const cacheControlValidator = new CacheControlValidator();
2944
- const toolNameMapping = (0, import_provider_utils15.createToolNameMapping)({
3263
+ const toolNameMapping = createToolNameMapping({
2945
3264
  tools,
2946
3265
  providerToolNames: {
2947
3266
  "anthropic.code_execution_20250522": "code_execution",
@@ -2964,16 +3283,34 @@ var AnthropicMessagesLanguageModel = class {
2964
3283
  "anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
2965
3284
  }
2966
3285
  });
2967
- const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
3286
+ const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
2968
3287
  prompt,
2969
3288
  sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
2970
3289
  warnings,
2971
3290
  cacheControlValidator,
2972
3291
  toolNameMapping
2973
3292
  });
2974
- const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3293
+ if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
3294
+ const reasoningConfig = resolveAnthropicReasoningConfig({
3295
+ reasoning,
3296
+ supportsAdaptiveThinking,
3297
+ supportsXhighEffort,
3298
+ maxOutputTokensForModel,
3299
+ warnings
3300
+ });
3301
+ if (reasoningConfig != null) {
3302
+ if (anthropicOptions.thinking == null) {
3303
+ anthropicOptions.thinking = reasoningConfig.thinking;
3304
+ }
3305
+ if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
3306
+ anthropicOptions.effort = reasoningConfig.effort;
3307
+ }
3308
+ }
3309
+ }
3310
+ const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
2975
3311
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
2976
- let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3312
+ let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
3313
+ const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
2977
3314
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
2978
3315
  const baseArgs = {
2979
3316
  // model id:
@@ -2988,18 +3325,28 @@ var AnthropicMessagesLanguageModel = class {
2988
3325
  ...isThinking && {
2989
3326
  thinking: {
2990
3327
  type: thinkingType,
2991
- ...thinkingBudget != null && { budget_tokens: thinkingBudget }
3328
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget },
3329
+ ...thinkingDisplay != null && { display: thinkingDisplay }
2992
3330
  }
2993
3331
  },
2994
- ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3332
+ ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
2995
3333
  output_config: {
2996
3334
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
2997
3335
  effort: anthropicOptions.effort
2998
3336
  },
3337
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
3338
+ task_budget: {
3339
+ type: anthropicOptions.taskBudget.type,
3340
+ total: anthropicOptions.taskBudget.total,
3341
+ ...anthropicOptions.taskBudget.remaining != null && {
3342
+ remaining: anthropicOptions.taskBudget.remaining
3343
+ }
3344
+ }
3345
+ },
2999
3346
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
3000
3347
  format: {
3001
3348
  type: "json_schema",
3002
- schema: responseFormat.schema
3349
+ schema: sanitizeJsonSchema(responseFormat.schema)
3003
3350
  }
3004
3351
  }
3005
3352
  }
@@ -3007,9 +3354,15 @@ var AnthropicMessagesLanguageModel = class {
3007
3354
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
3008
3355
  speed: anthropicOptions.speed
3009
3356
  },
3357
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3358
+ inference_geo: anthropicOptions.inferenceGeo
3359
+ },
3010
3360
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3011
3361
  cache_control: anthropicOptions.cacheControl
3012
3362
  },
3363
+ ...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
3364
+ metadata: { user_id: anthropicOptions.metadata.userId }
3365
+ },
3013
3366
  // mcp servers:
3014
3367
  ...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
3015
3368
  mcp_servers: anthropicOptions.mcpServers.map((server) => ({
@@ -3031,7 +3384,10 @@ var AnthropicMessagesLanguageModel = class {
3031
3384
  id: anthropicOptions.container.id,
3032
3385
  skills: anthropicOptions.container.skills.map((skill) => ({
3033
3386
  type: skill.type,
3034
- skill_id: skill.skillId,
3387
+ skill_id: skill.type === "custom" ? resolveProviderReference2({
3388
+ reference: skill.providerReference,
3389
+ provider: "anthropic"
3390
+ }) : skill.skillId,
3035
3391
  version: skill.version
3036
3392
  }))
3037
3393
  }
@@ -3133,7 +3489,7 @@ var AnthropicMessagesLanguageModel = class {
3133
3489
  }
3134
3490
  baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
3135
3491
  } else {
3136
- if (topP != null && temperature != null) {
3492
+ if (isAnthropicModel && topP != null && temperature != null) {
3137
3493
  warnings.push({
3138
3494
  type: "unsupported",
3139
3495
  feature: "topP",
@@ -3177,12 +3533,13 @@ var AnthropicMessagesLanguageModel = class {
3177
3533
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
3178
3534
  betas.add("effort-2025-11-24");
3179
3535
  }
3536
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
3537
+ betas.add("task-budgets-2026-03-13");
3538
+ }
3180
3539
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3181
3540
  betas.add("fast-mode-2026-02-01");
3182
3541
  }
3183
- if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
3184
- betas.add("fine-grained-tool-streaming-2025-05-14");
3185
- }
3542
+ const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
3186
3543
  const {
3187
3544
  tools: anthropicTools2,
3188
3545
  toolChoice: anthropicToolChoice,
@@ -3195,14 +3552,16 @@ var AnthropicMessagesLanguageModel = class {
3195
3552
  disableParallelToolUse: true,
3196
3553
  cacheControlValidator,
3197
3554
  supportsStructuredOutput: false,
3198
- supportsStrictTools
3555
+ supportsStrictTools,
3556
+ defaultEagerInputStreaming
3199
3557
  } : {
3200
3558
  tools: tools != null ? tools : [],
3201
3559
  toolChoice,
3202
3560
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3203
3561
  cacheControlValidator,
3204
3562
  supportsStructuredOutput,
3205
- supportsStrictTools
3563
+ supportsStrictTools,
3564
+ defaultEagerInputStreaming
3206
3565
  }
3207
3566
  );
3208
3567
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3219,7 +3578,7 @@ var AnthropicMessagesLanguageModel = class {
3219
3578
  ...betas,
3220
3579
  ...toolsBetas,
3221
3580
  ...userSuppliedBetas,
3222
- ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
3581
+ ...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
3223
3582
  ]),
3224
3583
  usesJsonResponseTool: jsonResponseTool != null,
3225
3584
  toolNameMapping,
@@ -3231,16 +3590,16 @@ var AnthropicMessagesLanguageModel = class {
3231
3590
  betas,
3232
3591
  headers
3233
3592
  }) {
3234
- return (0, import_provider_utils15.combineHeaders)(
3235
- await (0, import_provider_utils15.resolve)(this.config.headers),
3593
+ return combineHeaders(
3594
+ this.config.headers ? await resolve(this.config.headers) : void 0,
3236
3595
  headers,
3237
3596
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
3238
3597
  );
3239
3598
  }
3240
3599
  async getBetasFromHeaders(requestHeaders) {
3241
3600
  var _a, _b;
3242
- const configHeaders = await (0, import_provider_utils15.resolve)(this.config.headers);
3243
- const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
3601
+ const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
3602
+ const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
3244
3603
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
3245
3604
  return new Set(
3246
3605
  [
@@ -3305,13 +3664,13 @@ var AnthropicMessagesLanguageModel = class {
3305
3664
  responseHeaders,
3306
3665
  value: response,
3307
3666
  rawValue: rawResponse
3308
- } = await (0, import_provider_utils15.postJsonToApi)({
3667
+ } = await postJsonToApi({
3309
3668
  url: this.buildRequestUrl(false),
3310
3669
  headers: await this.getHeaders({ betas, headers: options.headers }),
3311
3670
  body: this.transformRequestBody(args, betas),
3312
3671
  failedResponseHandler: anthropicFailedResponseHandler,
3313
- successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3314
- anthropicMessagesResponseSchema
3672
+ successfulResponseHandler: createJsonResponseHandler(
3673
+ anthropicResponseSchema
3315
3674
  ),
3316
3675
  abortSignal: options.abortSignal,
3317
3676
  fetch: this.config.fetch
@@ -3660,7 +4019,7 @@ var AnthropicMessagesLanguageModel = class {
3660
4019
  }),
3661
4020
  raw: (_e = response.stop_reason) != null ? _e : void 0
3662
4021
  },
3663
- usage: convertAnthropicMessagesUsage({ usage: response.usage }),
4022
+ usage: convertAnthropicUsage({ usage: response.usage }),
3664
4023
  request: { body: args },
3665
4024
  response: {
3666
4025
  id: (_f = response.id) != null ? _f : void 0,
@@ -3670,11 +4029,10 @@ var AnthropicMessagesLanguageModel = class {
3670
4029
  },
3671
4030
  warnings,
3672
4031
  providerMetadata: (() => {
3673
- var _a2, _b2, _c2, _d2, _e2;
4032
+ var _a2, _b2, _c2, _d2;
3674
4033
  const anthropicMetadata = {
3675
4034
  usage: response.usage,
3676
- cacheCreationInputTokens: (_a2 = response.usage.cache_creation_input_tokens) != null ? _a2 : null,
3677
- stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
4035
+ stopSequence: (_a2 = response.stop_sequence) != null ? _a2 : null,
3678
4036
  iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
3679
4037
  type: iter.type,
3680
4038
  inputTokens: iter.input_tokens,
@@ -3683,15 +4041,15 @@ var AnthropicMessagesLanguageModel = class {
3683
4041
  container: response.container ? {
3684
4042
  expiresAt: response.container.expires_at,
3685
4043
  id: response.container.id,
3686
- skills: (_d2 = (_c2 = response.container.skills) == null ? void 0 : _c2.map((skill) => ({
4044
+ skills: (_c2 = (_b2 = response.container.skills) == null ? void 0 : _b2.map((skill) => ({
3687
4045
  type: skill.type,
3688
4046
  skillId: skill.skill_id,
3689
4047
  version: skill.version
3690
- }))) != null ? _d2 : null
4048
+ }))) != null ? _c2 : null
3691
4049
  } : null,
3692
- contextManagement: (_e2 = mapAnthropicResponseContextManagement(
4050
+ contextManagement: (_d2 = mapAnthropicResponseContextManagement(
3693
4051
  response.context_management
3694
- )) != null ? _e2 : null
4052
+ )) != null ? _d2 : null
3695
4053
  };
3696
4054
  const providerMetadata = {
3697
4055
  anthropic: anthropicMetadata
@@ -3704,6 +4062,7 @@ var AnthropicMessagesLanguageModel = class {
3704
4062
  };
3705
4063
  }
3706
4064
  async doStream(options) {
4065
+ "use step";
3707
4066
  var _a, _b;
3708
4067
  const {
3709
4068
  args: body,
@@ -3725,14 +4084,12 @@ var AnthropicMessagesLanguageModel = class {
3725
4084
  body.tools
3726
4085
  );
3727
4086
  const url = this.buildRequestUrl(true);
3728
- const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
4087
+ const { responseHeaders, value: response } = await postJsonToApi({
3729
4088
  url,
3730
4089
  headers: await this.getHeaders({ betas, headers: options.headers }),
3731
4090
  body: this.transformRequestBody(body, betas),
3732
4091
  failedResponseHandler: anthropicFailedResponseHandler,
3733
- successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
3734
- anthropicMessagesChunkSchema
3735
- ),
4092
+ successfulResponseHandler: createEventSourceResponseHandler(anthropicChunkSchema),
3736
4093
  abortSignal: options.abortSignal,
3737
4094
  fetch: this.config.fetch
3738
4095
  });
@@ -3752,7 +4109,6 @@ var AnthropicMessagesLanguageModel = class {
3752
4109
  const serverToolCalls = {};
3753
4110
  let contextManagement = null;
3754
4111
  let rawUsage = void 0;
3755
- let cacheCreationInputTokens = null;
3756
4112
  let stopSequence = null;
3757
4113
  let container = null;
3758
4114
  let isJsonResponseFromTool = false;
@@ -3764,7 +4120,7 @@ var AnthropicMessagesLanguageModel = class {
3764
4120
  controller.enqueue({ type: "stream-start", warnings });
3765
4121
  },
3766
4122
  transform(chunk, controller) {
3767
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4123
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
3768
4124
  if (options.includeRawChunks) {
3769
4125
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3770
4126
  }
@@ -4299,7 +4655,6 @@ var AnthropicMessagesLanguageModel = class {
4299
4655
  rawUsage = {
4300
4656
  ...value.message.usage
4301
4657
  };
4302
- cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
4303
4658
  if (value.message.container != null) {
4304
4659
  container = {
4305
4660
  expiresAt: value.message.container.expires_at,
@@ -4318,8 +4673,8 @@ var AnthropicMessagesLanguageModel = class {
4318
4673
  }
4319
4674
  controller.enqueue({
4320
4675
  type: "response-metadata",
4321
- id: (_h = value.message.id) != null ? _h : void 0,
4322
- modelId: (_i = value.message.model) != null ? _i : void 0
4676
+ id: (_g = value.message.id) != null ? _g : void 0,
4677
+ modelId: (_h = value.message.model) != null ? _h : void 0
4323
4678
  });
4324
4679
  if (value.message.content != null) {
4325
4680
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
@@ -4335,7 +4690,7 @@ var AnthropicMessagesLanguageModel = class {
4335
4690
  id: part.id,
4336
4691
  toolName: part.name
4337
4692
  });
4338
- const inputStr = JSON.stringify((_j = part.input) != null ? _j : {});
4693
+ const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
4339
4694
  controller.enqueue({
4340
4695
  type: "tool-input-delta",
4341
4696
  id: part.id,
@@ -4373,7 +4728,6 @@ var AnthropicMessagesLanguageModel = class {
4373
4728
  }
4374
4729
  if (value.usage.cache_creation_input_tokens != null) {
4375
4730
  usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
4376
- cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
4377
4731
  }
4378
4732
  if (value.usage.iterations != null) {
4379
4733
  usage.iterations = value.usage.iterations;
@@ -4383,17 +4737,17 @@ var AnthropicMessagesLanguageModel = class {
4383
4737
  finishReason: value.delta.stop_reason,
4384
4738
  isJsonResponseFromTool
4385
4739
  }),
4386
- raw: (_k = value.delta.stop_reason) != null ? _k : void 0
4740
+ raw: (_j = value.delta.stop_reason) != null ? _j : void 0
4387
4741
  };
4388
- stopSequence = (_l = value.delta.stop_sequence) != null ? _l : null;
4742
+ stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
4389
4743
  container = value.delta.container != null ? {
4390
4744
  expiresAt: value.delta.container.expires_at,
4391
4745
  id: value.delta.container.id,
4392
- skills: (_n = (_m = value.delta.container.skills) == null ? void 0 : _m.map((skill) => ({
4746
+ skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
4393
4747
  type: skill.type,
4394
4748
  skillId: skill.skill_id,
4395
4749
  version: skill.version
4396
- }))) != null ? _n : null
4750
+ }))) != null ? _m : null
4397
4751
  } : null;
4398
4752
  if (value.context_management) {
4399
4753
  contextManagement = mapAnthropicResponseContextManagement(
@@ -4409,7 +4763,6 @@ var AnthropicMessagesLanguageModel = class {
4409
4763
  case "message_stop": {
4410
4764
  const anthropicMetadata = {
4411
4765
  usage: rawUsage != null ? rawUsage : null,
4412
- cacheCreationInputTokens,
4413
4766
  stopSequence,
4414
4767
  iterations: usage.iterations ? usage.iterations.map((iter) => ({
4415
4768
  type: iter.type,
@@ -4428,7 +4781,7 @@ var AnthropicMessagesLanguageModel = class {
4428
4781
  controller.enqueue({
4429
4782
  type: "finish",
4430
4783
  finishReason,
4431
- usage: convertAnthropicMessagesUsage({ usage, rawUsage }),
4784
+ usage: convertAnthropicUsage({ usage, rawUsage }),
4432
4785
  providerMetadata
4433
4786
  });
4434
4787
  return;
@@ -4455,7 +4808,7 @@ var AnthropicMessagesLanguageModel = class {
4455
4808
  }
4456
4809
  if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
4457
4810
  const error = result.value.error;
4458
- throw new import_provider3.APICallError({
4811
+ throw new APICallError({
4459
4812
  message: error.message,
4460
4813
  url,
4461
4814
  requestBodyValues: body,
@@ -4478,46 +4831,76 @@ var AnthropicMessagesLanguageModel = class {
4478
4831
  }
4479
4832
  };
4480
4833
  function getModelCapabilities(modelId) {
4481
- if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4834
+ if (modelId.includes("claude-opus-4-7")) {
4835
+ return {
4836
+ maxOutputTokens: 128e3,
4837
+ supportsStructuredOutput: true,
4838
+ supportsAdaptiveThinking: true,
4839
+ rejectsSamplingParameters: true,
4840
+ supportsXhighEffort: true,
4841
+ isKnownModel: true
4842
+ };
4843
+ } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4482
4844
  return {
4483
4845
  maxOutputTokens: 128e3,
4484
4846
  supportsStructuredOutput: true,
4847
+ supportsAdaptiveThinking: true,
4848
+ rejectsSamplingParameters: false,
4849
+ supportsXhighEffort: false,
4485
4850
  isKnownModel: true
4486
4851
  };
4487
4852
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
4488
4853
  return {
4489
4854
  maxOutputTokens: 64e3,
4490
4855
  supportsStructuredOutput: true,
4856
+ supportsAdaptiveThinking: false,
4857
+ rejectsSamplingParameters: false,
4858
+ supportsXhighEffort: false,
4491
4859
  isKnownModel: true
4492
4860
  };
4493
4861
  } else if (modelId.includes("claude-opus-4-1")) {
4494
4862
  return {
4495
4863
  maxOutputTokens: 32e3,
4496
4864
  supportsStructuredOutput: true,
4865
+ supportsAdaptiveThinking: false,
4866
+ rejectsSamplingParameters: false,
4867
+ supportsXhighEffort: false,
4497
4868
  isKnownModel: true
4498
4869
  };
4499
4870
  } else if (modelId.includes("claude-sonnet-4-")) {
4500
4871
  return {
4501
4872
  maxOutputTokens: 64e3,
4502
4873
  supportsStructuredOutput: false,
4874
+ supportsAdaptiveThinking: false,
4875
+ rejectsSamplingParameters: false,
4876
+ supportsXhighEffort: false,
4503
4877
  isKnownModel: true
4504
4878
  };
4505
4879
  } else if (modelId.includes("claude-opus-4-")) {
4506
4880
  return {
4507
4881
  maxOutputTokens: 32e3,
4508
4882
  supportsStructuredOutput: false,
4883
+ supportsAdaptiveThinking: false,
4884
+ rejectsSamplingParameters: false,
4885
+ supportsXhighEffort: false,
4509
4886
  isKnownModel: true
4510
4887
  };
4511
4888
  } else if (modelId.includes("claude-3-haiku")) {
4512
4889
  return {
4513
4890
  maxOutputTokens: 4096,
4514
4891
  supportsStructuredOutput: false,
4892
+ supportsAdaptiveThinking: false,
4893
+ rejectsSamplingParameters: false,
4894
+ supportsXhighEffort: false,
4515
4895
  isKnownModel: true
4516
4896
  };
4517
4897
  } else {
4518
4898
  return {
4519
4899
  maxOutputTokens: 4096,
4520
4900
  supportsStructuredOutput: false,
4901
+ supportsAdaptiveThinking: false,
4902
+ rejectsSamplingParameters: false,
4903
+ supportsXhighEffort: false,
4521
4904
  isKnownModel: false
4522
4905
  };
4523
4906
  }
@@ -4540,6 +4923,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
4540
4923
  }
4541
4924
  return hasWebTool20260209 && !hasCodeExecutionTool;
4542
4925
  }
4926
+ function resolveAnthropicReasoningConfig({
4927
+ reasoning,
4928
+ supportsAdaptiveThinking,
4929
+ supportsXhighEffort,
4930
+ maxOutputTokensForModel,
4931
+ warnings
4932
+ }) {
4933
+ if (!isCustomReasoning(reasoning)) {
4934
+ return void 0;
4935
+ }
4936
+ if (reasoning === "none") {
4937
+ return { thinking: { type: "disabled" } };
4938
+ }
4939
+ if (supportsAdaptiveThinking) {
4940
+ const effort = mapReasoningToProviderEffort({
4941
+ reasoning,
4942
+ effortMap: {
4943
+ minimal: "low",
4944
+ low: "low",
4945
+ medium: "medium",
4946
+ high: "high",
4947
+ xhigh: supportsXhighEffort ? "xhigh" : "max"
4948
+ },
4949
+ warnings
4950
+ });
4951
+ return { thinking: { type: "adaptive" }, effort };
4952
+ }
4953
+ const budgetTokens = mapReasoningToProviderBudget({
4954
+ reasoning,
4955
+ maxOutputTokens: maxOutputTokensForModel,
4956
+ maxReasoningBudget: maxOutputTokensForModel,
4957
+ warnings
4958
+ });
4959
+ if (budgetTokens == null) {
4960
+ return void 0;
4961
+ }
4962
+ return { thinking: { type: "enabled", budgetTokens } };
4963
+ }
4543
4964
  function mapAnthropicResponseContextManagement(contextManagement) {
4544
4965
  return contextManagement ? {
4545
4966
  appliedEdits: contextManagement.applied_edits.map((edit) => {
@@ -4567,44 +4988,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
4567
4988
  }
4568
4989
 
4569
4990
  // src/tool/bash_20241022.ts
4570
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
4571
- var import_v413 = require("zod/v4");
4572
- var bash_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
4573
- () => (0, import_provider_utils16.zodSchema)(
4574
- import_v413.z.object({
4575
- command: import_v413.z.string(),
4576
- restart: import_v413.z.boolean().optional()
4991
+ import {
4992
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
4993
+ lazySchema as lazySchema12,
4994
+ zodSchema as zodSchema12
4995
+ } from "@ai-sdk/provider-utils";
4996
+ import { z as z13 } from "zod/v4";
4997
+ var bash_20241022InputSchema = lazySchema12(
4998
+ () => zodSchema12(
4999
+ z13.object({
5000
+ command: z13.string(),
5001
+ restart: z13.boolean().optional()
4577
5002
  })
4578
5003
  )
4579
5004
  );
4580
- var bash_20241022 = (0, import_provider_utils16.createProviderToolFactory)({
5005
+ var bash_20241022 = createProviderDefinedToolFactory2({
4581
5006
  id: "anthropic.bash_20241022",
4582
5007
  inputSchema: bash_20241022InputSchema
4583
5008
  });
4584
5009
 
4585
5010
  // src/tool/bash_20250124.ts
4586
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
4587
- var import_v414 = require("zod/v4");
4588
- var bash_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
4589
- () => (0, import_provider_utils17.zodSchema)(
4590
- import_v414.z.object({
4591
- command: import_v414.z.string(),
4592
- restart: import_v414.z.boolean().optional()
5011
+ import {
5012
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
5013
+ lazySchema as lazySchema13,
5014
+ zodSchema as zodSchema13
5015
+ } from "@ai-sdk/provider-utils";
5016
+ import { z as z14 } from "zod/v4";
5017
+ var bash_20250124InputSchema = lazySchema13(
5018
+ () => zodSchema13(
5019
+ z14.object({
5020
+ command: z14.string(),
5021
+ restart: z14.boolean().optional()
4593
5022
  })
4594
5023
  )
4595
5024
  );
4596
- var bash_20250124 = (0, import_provider_utils17.createProviderToolFactory)({
5025
+ var bash_20250124 = createProviderDefinedToolFactory3({
4597
5026
  id: "anthropic.bash_20250124",
4598
5027
  inputSchema: bash_20250124InputSchema
4599
5028
  });
4600
5029
 
4601
5030
  // src/tool/computer_20241022.ts
4602
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
4603
- var import_v415 = require("zod/v4");
4604
- var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4605
- () => (0, import_provider_utils18.zodSchema)(
4606
- import_v415.z.object({
4607
- action: import_v415.z.enum([
5031
+ import {
5032
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
5033
+ lazySchema as lazySchema14,
5034
+ zodSchema as zodSchema14
5035
+ } from "@ai-sdk/provider-utils";
5036
+ import { z as z15 } from "zod/v4";
5037
+ var computer_20241022InputSchema = lazySchema14(
5038
+ () => zodSchema14(
5039
+ z15.object({
5040
+ action: z15.enum([
4608
5041
  "key",
4609
5042
  "type",
4610
5043
  "mouse_move",
@@ -4616,23 +5049,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4616
5049
  "screenshot",
4617
5050
  "cursor_position"
4618
5051
  ]),
4619
- coordinate: import_v415.z.array(import_v415.z.number().int()).optional(),
4620
- text: import_v415.z.string().optional()
5052
+ coordinate: z15.array(z15.number().int()).optional(),
5053
+ text: z15.string().optional()
4621
5054
  })
4622
5055
  )
4623
5056
  );
4624
- var computer_20241022 = (0, import_provider_utils18.createProviderToolFactory)({
5057
+ var computer_20241022 = createProviderDefinedToolFactory4({
4625
5058
  id: "anthropic.computer_20241022",
4626
5059
  inputSchema: computer_20241022InputSchema
4627
5060
  });
4628
5061
 
4629
5062
  // src/tool/computer_20250124.ts
4630
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
4631
- var import_v416 = require("zod/v4");
4632
- var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4633
- () => (0, import_provider_utils19.zodSchema)(
4634
- import_v416.z.object({
4635
- action: import_v416.z.enum([
5063
+ import {
5064
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
5065
+ lazySchema as lazySchema15,
5066
+ zodSchema as zodSchema15
5067
+ } from "@ai-sdk/provider-utils";
5068
+ import { z as z16 } from "zod/v4";
5069
+ var computer_20250124InputSchema = lazySchema15(
5070
+ () => zodSchema15(
5071
+ z16.object({
5072
+ action: z16.enum([
4636
5073
  "key",
4637
5074
  "hold_key",
4638
5075
  "type",
@@ -4650,27 +5087,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4650
5087
  "wait",
4651
5088
  "screenshot"
4652
5089
  ]),
4653
- coordinate: import_v416.z.tuple([import_v416.z.number().int(), import_v416.z.number().int()]).optional(),
4654
- duration: import_v416.z.number().optional(),
4655
- scroll_amount: import_v416.z.number().optional(),
4656
- scroll_direction: import_v416.z.enum(["up", "down", "left", "right"]).optional(),
4657
- start_coordinate: import_v416.z.tuple([import_v416.z.number().int(), import_v416.z.number().int()]).optional(),
4658
- text: import_v416.z.string().optional()
5090
+ coordinate: z16.tuple([z16.number().int(), z16.number().int()]).optional(),
5091
+ duration: z16.number().optional(),
5092
+ scroll_amount: z16.number().optional(),
5093
+ scroll_direction: z16.enum(["up", "down", "left", "right"]).optional(),
5094
+ start_coordinate: z16.tuple([z16.number().int(), z16.number().int()]).optional(),
5095
+ text: z16.string().optional()
4659
5096
  })
4660
5097
  )
4661
5098
  );
4662
- var computer_20250124 = (0, import_provider_utils19.createProviderToolFactory)({
5099
+ var computer_20250124 = createProviderDefinedToolFactory5({
4663
5100
  id: "anthropic.computer_20250124",
4664
5101
  inputSchema: computer_20250124InputSchema
4665
5102
  });
4666
5103
 
4667
5104
  // src/tool/computer_20251124.ts
4668
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
4669
- var import_v417 = require("zod/v4");
4670
- var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4671
- () => (0, import_provider_utils20.zodSchema)(
4672
- import_v417.z.object({
4673
- action: import_v417.z.enum([
5105
+ import {
5106
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
5107
+ lazySchema as lazySchema16,
5108
+ zodSchema as zodSchema16
5109
+ } from "@ai-sdk/provider-utils";
5110
+ import { z as z17 } from "zod/v4";
5111
+ var computer_20251124InputSchema = lazySchema16(
5112
+ () => zodSchema16(
5113
+ z17.object({
5114
+ action: z17.enum([
4674
5115
  "key",
4675
5116
  "hold_key",
4676
5117
  "type",
@@ -4689,166 +5130,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4689
5130
  "screenshot",
4690
5131
  "zoom"
4691
5132
  ]),
4692
- coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
4693
- duration: import_v417.z.number().optional(),
4694
- region: import_v417.z.tuple([
4695
- import_v417.z.number().int(),
4696
- import_v417.z.number().int(),
4697
- import_v417.z.number().int(),
4698
- import_v417.z.number().int()
5133
+ coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5134
+ duration: z17.number().optional(),
5135
+ region: z17.tuple([
5136
+ z17.number().int(),
5137
+ z17.number().int(),
5138
+ z17.number().int(),
5139
+ z17.number().int()
4699
5140
  ]).optional(),
4700
- scroll_amount: import_v417.z.number().optional(),
4701
- scroll_direction: import_v417.z.enum(["up", "down", "left", "right"]).optional(),
4702
- start_coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
4703
- text: import_v417.z.string().optional()
5141
+ scroll_amount: z17.number().optional(),
5142
+ scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
5143
+ start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5144
+ text: z17.string().optional()
4704
5145
  })
4705
5146
  )
4706
5147
  );
4707
- var computer_20251124 = (0, import_provider_utils20.createProviderToolFactory)({
5148
+ var computer_20251124 = createProviderDefinedToolFactory6({
4708
5149
  id: "anthropic.computer_20251124",
4709
5150
  inputSchema: computer_20251124InputSchema
4710
5151
  });
4711
5152
 
4712
5153
  // src/tool/memory_20250818.ts
4713
- var import_provider_utils21 = require("@ai-sdk/provider-utils");
4714
- var import_v418 = require("zod/v4");
4715
- var memory_20250818InputSchema = (0, import_provider_utils21.lazySchema)(
4716
- () => (0, import_provider_utils21.zodSchema)(
4717
- import_v418.z.discriminatedUnion("command", [
4718
- import_v418.z.object({
4719
- command: import_v418.z.literal("view"),
4720
- path: import_v418.z.string(),
4721
- view_range: import_v418.z.tuple([import_v418.z.number(), import_v418.z.number()]).optional()
5154
+ import {
5155
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
5156
+ lazySchema as lazySchema17,
5157
+ zodSchema as zodSchema17
5158
+ } from "@ai-sdk/provider-utils";
5159
+ import { z as z18 } from "zod/v4";
5160
+ var memory_20250818InputSchema = lazySchema17(
5161
+ () => zodSchema17(
5162
+ z18.discriminatedUnion("command", [
5163
+ z18.object({
5164
+ command: z18.literal("view"),
5165
+ path: z18.string(),
5166
+ view_range: z18.tuple([z18.number(), z18.number()]).optional()
4722
5167
  }),
4723
- import_v418.z.object({
4724
- command: import_v418.z.literal("create"),
4725
- path: import_v418.z.string(),
4726
- file_text: import_v418.z.string()
5168
+ z18.object({
5169
+ command: z18.literal("create"),
5170
+ path: z18.string(),
5171
+ file_text: z18.string()
4727
5172
  }),
4728
- import_v418.z.object({
4729
- command: import_v418.z.literal("str_replace"),
4730
- path: import_v418.z.string(),
4731
- old_str: import_v418.z.string(),
4732
- new_str: import_v418.z.string()
5173
+ z18.object({
5174
+ command: z18.literal("str_replace"),
5175
+ path: z18.string(),
5176
+ old_str: z18.string(),
5177
+ new_str: z18.string()
4733
5178
  }),
4734
- import_v418.z.object({
4735
- command: import_v418.z.literal("insert"),
4736
- path: import_v418.z.string(),
4737
- insert_line: import_v418.z.number(),
4738
- insert_text: import_v418.z.string()
5179
+ z18.object({
5180
+ command: z18.literal("insert"),
5181
+ path: z18.string(),
5182
+ insert_line: z18.number(),
5183
+ insert_text: z18.string()
4739
5184
  }),
4740
- import_v418.z.object({
4741
- command: import_v418.z.literal("delete"),
4742
- path: import_v418.z.string()
5185
+ z18.object({
5186
+ command: z18.literal("delete"),
5187
+ path: z18.string()
4743
5188
  }),
4744
- import_v418.z.object({
4745
- command: import_v418.z.literal("rename"),
4746
- old_path: import_v418.z.string(),
4747
- new_path: import_v418.z.string()
5189
+ z18.object({
5190
+ command: z18.literal("rename"),
5191
+ old_path: z18.string(),
5192
+ new_path: z18.string()
4748
5193
  })
4749
5194
  ])
4750
5195
  )
4751
5196
  );
4752
- var memory_20250818 = (0, import_provider_utils21.createProviderToolFactory)({
5197
+ var memory_20250818 = createProviderDefinedToolFactory7({
4753
5198
  id: "anthropic.memory_20250818",
4754
5199
  inputSchema: memory_20250818InputSchema
4755
5200
  });
4756
5201
 
4757
5202
  // src/tool/text-editor_20241022.ts
4758
- var import_provider_utils22 = require("@ai-sdk/provider-utils");
4759
- var import_v419 = require("zod/v4");
4760
- var textEditor_20241022InputSchema = (0, import_provider_utils22.lazySchema)(
4761
- () => (0, import_provider_utils22.zodSchema)(
4762
- import_v419.z.object({
4763
- command: import_v419.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
4764
- path: import_v419.z.string(),
4765
- file_text: import_v419.z.string().optional(),
4766
- insert_line: import_v419.z.number().int().optional(),
4767
- new_str: import_v419.z.string().optional(),
4768
- insert_text: import_v419.z.string().optional(),
4769
- old_str: import_v419.z.string().optional(),
4770
- view_range: import_v419.z.array(import_v419.z.number().int()).optional()
5203
+ import {
5204
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
5205
+ lazySchema as lazySchema18,
5206
+ zodSchema as zodSchema18
5207
+ } from "@ai-sdk/provider-utils";
5208
+ import { z as z19 } from "zod/v4";
5209
+ var textEditor_20241022InputSchema = lazySchema18(
5210
+ () => zodSchema18(
5211
+ z19.object({
5212
+ command: z19.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5213
+ path: z19.string(),
5214
+ file_text: z19.string().optional(),
5215
+ insert_line: z19.number().int().optional(),
5216
+ new_str: z19.string().optional(),
5217
+ insert_text: z19.string().optional(),
5218
+ old_str: z19.string().optional(),
5219
+ view_range: z19.array(z19.number().int()).optional()
4771
5220
  })
4772
5221
  )
4773
5222
  );
4774
- var textEditor_20241022 = (0, import_provider_utils22.createProviderToolFactory)({
5223
+ var textEditor_20241022 = createProviderDefinedToolFactory8({
4775
5224
  id: "anthropic.text_editor_20241022",
4776
5225
  inputSchema: textEditor_20241022InputSchema
4777
5226
  });
4778
5227
 
4779
5228
  // src/tool/text-editor_20250124.ts
4780
- var import_provider_utils23 = require("@ai-sdk/provider-utils");
4781
- var import_v420 = require("zod/v4");
4782
- var textEditor_20250124InputSchema = (0, import_provider_utils23.lazySchema)(
4783
- () => (0, import_provider_utils23.zodSchema)(
4784
- import_v420.z.object({
4785
- command: import_v420.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
4786
- path: import_v420.z.string(),
4787
- file_text: import_v420.z.string().optional(),
4788
- insert_line: import_v420.z.number().int().optional(),
4789
- new_str: import_v420.z.string().optional(),
4790
- insert_text: import_v420.z.string().optional(),
4791
- old_str: import_v420.z.string().optional(),
4792
- view_range: import_v420.z.array(import_v420.z.number().int()).optional()
5229
+ import {
5230
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
5231
+ lazySchema as lazySchema19,
5232
+ zodSchema as zodSchema19
5233
+ } from "@ai-sdk/provider-utils";
5234
+ import { z as z20 } from "zod/v4";
5235
+ var textEditor_20250124InputSchema = lazySchema19(
5236
+ () => zodSchema19(
5237
+ z20.object({
5238
+ command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5239
+ path: z20.string(),
5240
+ file_text: z20.string().optional(),
5241
+ insert_line: z20.number().int().optional(),
5242
+ new_str: z20.string().optional(),
5243
+ insert_text: z20.string().optional(),
5244
+ old_str: z20.string().optional(),
5245
+ view_range: z20.array(z20.number().int()).optional()
4793
5246
  })
4794
5247
  )
4795
5248
  );
4796
- var textEditor_20250124 = (0, import_provider_utils23.createProviderToolFactory)({
5249
+ var textEditor_20250124 = createProviderDefinedToolFactory9({
4797
5250
  id: "anthropic.text_editor_20250124",
4798
5251
  inputSchema: textEditor_20250124InputSchema
4799
5252
  });
4800
5253
 
4801
5254
  // src/tool/text-editor_20250429.ts
4802
- var import_provider_utils24 = require("@ai-sdk/provider-utils");
4803
- var import_v421 = require("zod/v4");
4804
- var textEditor_20250429InputSchema = (0, import_provider_utils24.lazySchema)(
4805
- () => (0, import_provider_utils24.zodSchema)(
4806
- import_v421.z.object({
4807
- command: import_v421.z.enum(["view", "create", "str_replace", "insert"]),
4808
- path: import_v421.z.string(),
4809
- file_text: import_v421.z.string().optional(),
4810
- insert_line: import_v421.z.number().int().optional(),
4811
- new_str: import_v421.z.string().optional(),
4812
- insert_text: import_v421.z.string().optional(),
4813
- old_str: import_v421.z.string().optional(),
4814
- view_range: import_v421.z.array(import_v421.z.number().int()).optional()
5255
+ import {
5256
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory10,
5257
+ lazySchema as lazySchema20,
5258
+ zodSchema as zodSchema20
5259
+ } from "@ai-sdk/provider-utils";
5260
+ import { z as z21 } from "zod/v4";
5261
+ var textEditor_20250429InputSchema = lazySchema20(
5262
+ () => zodSchema20(
5263
+ z21.object({
5264
+ command: z21.enum(["view", "create", "str_replace", "insert"]),
5265
+ path: z21.string(),
5266
+ file_text: z21.string().optional(),
5267
+ insert_line: z21.number().int().optional(),
5268
+ new_str: z21.string().optional(),
5269
+ insert_text: z21.string().optional(),
5270
+ old_str: z21.string().optional(),
5271
+ view_range: z21.array(z21.number().int()).optional()
4815
5272
  })
4816
5273
  )
4817
5274
  );
4818
- var textEditor_20250429 = (0, import_provider_utils24.createProviderToolFactory)({
5275
+ var textEditor_20250429 = createProviderDefinedToolFactory10({
4819
5276
  id: "anthropic.text_editor_20250429",
4820
5277
  inputSchema: textEditor_20250429InputSchema
4821
5278
  });
4822
5279
 
4823
5280
  // src/tool/tool-search-bm25_20251119.ts
4824
- var import_provider_utils25 = require("@ai-sdk/provider-utils");
4825
- var import_v422 = require("zod/v4");
4826
- var toolSearchBm25_20251119OutputSchema = (0, import_provider_utils25.lazySchema)(
4827
- () => (0, import_provider_utils25.zodSchema)(
4828
- import_v422.z.array(
4829
- import_v422.z.object({
4830
- type: import_v422.z.literal("tool_reference"),
4831
- toolName: import_v422.z.string()
5281
+ import {
5282
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory9,
5283
+ lazySchema as lazySchema21,
5284
+ zodSchema as zodSchema21
5285
+ } from "@ai-sdk/provider-utils";
5286
+ import { z as z22 } from "zod/v4";
5287
+ var toolSearchBm25_20251119OutputSchema = lazySchema21(
5288
+ () => zodSchema21(
5289
+ z22.array(
5290
+ z22.object({
5291
+ type: z22.literal("tool_reference"),
5292
+ toolName: z22.string()
4832
5293
  })
4833
5294
  )
4834
5295
  )
4835
5296
  );
4836
- var toolSearchBm25_20251119InputSchema = (0, import_provider_utils25.lazySchema)(
4837
- () => (0, import_provider_utils25.zodSchema)(
4838
- import_v422.z.object({
5297
+ var toolSearchBm25_20251119InputSchema = lazySchema21(
5298
+ () => zodSchema21(
5299
+ z22.object({
4839
5300
  /**
4840
5301
  * A natural language query to search for tools.
4841
5302
  * Claude will use BM25 text search to find relevant tools.
4842
5303
  */
4843
- query: import_v422.z.string(),
5304
+ query: z22.string(),
4844
5305
  /**
4845
5306
  * Maximum number of tools to return. Optional.
4846
5307
  */
4847
- limit: import_v422.z.number().optional()
5308
+ limit: z22.number().optional()
4848
5309
  })
4849
5310
  )
4850
5311
  );
4851
- var factory10 = (0, import_provider_utils25.createProviderToolFactoryWithOutputSchema)({
5312
+ var factory10 = createProviderExecutedToolFactory9({
4852
5313
  id: "anthropic.tool_search_bm25_20251119",
4853
5314
  inputSchema: toolSearchBm25_20251119InputSchema,
4854
5315
  outputSchema: toolSearchBm25_20251119OutputSchema,
@@ -5059,10 +5520,11 @@ var anthropicTools = {
5059
5520
  */
5060
5521
  toolSearchBm25_20251119
5061
5522
  };
5062
- // Annotate the CommonJS export names for ESM import in node:
5063
- 0 && (module.exports = {
5064
- AnthropicMessagesLanguageModel,
5523
+ export {
5524
+ AnthropicLanguageModel,
5525
+ AnthropicLanguageModel as AnthropicMessagesLanguageModel,
5065
5526
  anthropicTools,
5527
+ getModelCapabilities,
5066
5528
  prepareTools
5067
- });
5529
+ };
5068
5530
  //# sourceMappingURL=index.js.map