@ai-sdk/anthropic 4.0.0-beta.3 → 4.0.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,375 +1,451 @@
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/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- VERSION: () => VERSION,
24
- anthropic: () => anthropic,
25
- createAnthropic: () => createAnthropic,
26
- forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep
27
- });
28
- module.exports = __toCommonJS(src_exports);
29
-
30
1
  // src/anthropic-provider.ts
31
- var import_provider4 = require("@ai-sdk/provider");
32
- var import_provider_utils26 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ InvalidArgumentError,
4
+ NoSuchModelError
5
+ } from "@ai-sdk/provider";
6
+ import {
7
+ generateId as generateId2,
8
+ loadApiKey,
9
+ loadOptionalSetting,
10
+ withoutTrailingSlash,
11
+ withUserAgentSuffix
12
+ } from "@ai-sdk/provider-utils";
33
13
 
34
- // src/version.ts
35
- var VERSION = true ? "4.0.0-beta.3" : "0.0.0-test";
36
-
37
- // src/anthropic-messages-language-model.ts
38
- var import_provider3 = require("@ai-sdk/provider");
39
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
14
+ // src/anthropic-files.ts
15
+ import {
16
+ combineHeaders,
17
+ convertBase64ToUint8Array,
18
+ createJsonResponseHandler,
19
+ lazySchema as lazySchema2,
20
+ postFormDataToApi,
21
+ zodSchema as zodSchema2
22
+ } from "@ai-sdk/provider-utils";
23
+ import { z as z2 } from "zod/v4";
40
24
 
41
25
  // src/anthropic-error.ts
42
- var import_provider_utils = require("@ai-sdk/provider-utils");
43
- var import_v4 = require("zod/v4");
44
- var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
45
- () => (0, import_provider_utils.zodSchema)(
46
- import_v4.z.object({
47
- type: import_v4.z.literal("error"),
48
- error: import_v4.z.object({
49
- type: import_v4.z.string(),
50
- message: import_v4.z.string()
26
+ import {
27
+ createJsonErrorResponseHandler,
28
+ lazySchema,
29
+ zodSchema
30
+ } from "@ai-sdk/provider-utils";
31
+ import { z } from "zod/v4";
32
+ var anthropicErrorDataSchema = lazySchema(
33
+ () => zodSchema(
34
+ z.object({
35
+ type: z.literal("error"),
36
+ error: z.object({
37
+ type: z.string(),
38
+ message: z.string()
51
39
  })
52
40
  })
53
41
  )
54
42
  );
55
- var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
43
+ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
56
44
  errorSchema: anthropicErrorDataSchema,
57
45
  errorToMessage: (data) => data.error.message
58
46
  });
59
47
 
48
+ // src/anthropic-files.ts
49
+ var anthropicUploadFileResponseSchema = lazySchema2(
50
+ () => zodSchema2(
51
+ z2.object({
52
+ id: z2.string(),
53
+ type: z2.literal("file"),
54
+ filename: z2.string(),
55
+ mime_type: z2.string(),
56
+ size_bytes: z2.number(),
57
+ created_at: z2.string(),
58
+ downloadable: z2.boolean().nullish()
59
+ })
60
+ )
61
+ );
62
+ var AnthropicFiles = class {
63
+ constructor(config) {
64
+ this.config = config;
65
+ this.specificationVersion = "v4";
66
+ }
67
+ get provider() {
68
+ return this.config.provider;
69
+ }
70
+ async uploadFile({
71
+ data,
72
+ mediaType,
73
+ filename
74
+ }) {
75
+ var _a, _b;
76
+ const fileBytes = data instanceof Uint8Array ? data : convertBase64ToUint8Array(data);
77
+ const blob = new Blob([fileBytes], { type: mediaType });
78
+ const formData = new FormData();
79
+ if (filename != null) {
80
+ formData.append("file", blob, filename);
81
+ } else {
82
+ formData.append("file", blob);
83
+ }
84
+ const { value: response } = await postFormDataToApi({
85
+ url: `${this.config.baseURL}/files`,
86
+ headers: combineHeaders(this.config.headers(), {
87
+ "anthropic-beta": "files-api-2025-04-14"
88
+ }),
89
+ formData,
90
+ failedResponseHandler: anthropicFailedResponseHandler,
91
+ successfulResponseHandler: createJsonResponseHandler(
92
+ anthropicUploadFileResponseSchema
93
+ ),
94
+ fetch: this.config.fetch
95
+ });
96
+ return {
97
+ warnings: [],
98
+ providerReference: { anthropic: response.id },
99
+ mediaType: (_a = response.mime_type) != null ? _a : mediaType,
100
+ filename: (_b = response.filename) != null ? _b : filename,
101
+ providerMetadata: {
102
+ anthropic: {
103
+ filename: response.filename,
104
+ mimeType: response.mime_type,
105
+ sizeBytes: response.size_bytes,
106
+ createdAt: response.created_at,
107
+ ...response.downloadable != null ? { downloadable: response.downloadable } : {}
108
+ }
109
+ }
110
+ };
111
+ }
112
+ };
113
+
114
+ // src/anthropic-messages-language-model.ts
115
+ import {
116
+ APICallError
117
+ } from "@ai-sdk/provider";
118
+ import {
119
+ combineHeaders as combineHeaders2,
120
+ createEventSourceResponseHandler,
121
+ createJsonResponseHandler as createJsonResponseHandler2,
122
+ createToolNameMapping,
123
+ generateId,
124
+ isCustomReasoning,
125
+ mapReasoningToProviderBudget,
126
+ mapReasoningToProviderEffort,
127
+ parseProviderOptions as parseProviderOptions2,
128
+ postJsonToApi,
129
+ resolve,
130
+ resolveProviderReference as resolveProviderReference2,
131
+ serializeModelOptions,
132
+ WORKFLOW_SERIALIZE,
133
+ WORKFLOW_DESERIALIZE
134
+ } from "@ai-sdk/provider-utils";
135
+
60
136
  // src/anthropic-messages-api.ts
61
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
62
- var import_v42 = require("zod/v4");
63
- var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
64
- () => (0, import_provider_utils2.zodSchema)(
65
- import_v42.z.object({
66
- type: import_v42.z.literal("message"),
67
- id: import_v42.z.string().nullish(),
68
- model: import_v42.z.string().nullish(),
69
- content: import_v42.z.array(
70
- import_v42.z.discriminatedUnion("type", [
71
- import_v42.z.object({
72
- type: import_v42.z.literal("text"),
73
- text: import_v42.z.string(),
74
- citations: import_v42.z.array(
75
- import_v42.z.discriminatedUnion("type", [
76
- import_v42.z.object({
77
- type: import_v42.z.literal("web_search_result_location"),
78
- cited_text: import_v42.z.string(),
79
- url: import_v42.z.string(),
80
- title: import_v42.z.string(),
81
- encrypted_index: import_v42.z.string()
137
+ import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
138
+ import { z as z3 } from "zod/v4";
139
+ var anthropicMessagesResponseSchema = lazySchema3(
140
+ () => zodSchema3(
141
+ z3.object({
142
+ type: z3.literal("message"),
143
+ id: z3.string().nullish(),
144
+ model: z3.string().nullish(),
145
+ content: z3.array(
146
+ z3.discriminatedUnion("type", [
147
+ z3.object({
148
+ type: z3.literal("text"),
149
+ text: z3.string(),
150
+ citations: z3.array(
151
+ z3.discriminatedUnion("type", [
152
+ z3.object({
153
+ type: z3.literal("web_search_result_location"),
154
+ cited_text: z3.string(),
155
+ url: z3.string(),
156
+ title: z3.string(),
157
+ encrypted_index: z3.string()
82
158
  }),
83
- import_v42.z.object({
84
- type: import_v42.z.literal("page_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_page_number: import_v42.z.number(),
89
- end_page_number: import_v42.z.number()
159
+ z3.object({
160
+ type: z3.literal("page_location"),
161
+ cited_text: z3.string(),
162
+ document_index: z3.number(),
163
+ document_title: z3.string().nullable(),
164
+ start_page_number: z3.number(),
165
+ end_page_number: z3.number()
90
166
  }),
91
- import_v42.z.object({
92
- type: import_v42.z.literal("char_location"),
93
- cited_text: import_v42.z.string(),
94
- document_index: import_v42.z.number(),
95
- document_title: import_v42.z.string().nullable(),
96
- start_char_index: import_v42.z.number(),
97
- end_char_index: import_v42.z.number()
167
+ z3.object({
168
+ type: z3.literal("char_location"),
169
+ cited_text: z3.string(),
170
+ document_index: z3.number(),
171
+ document_title: z3.string().nullable(),
172
+ start_char_index: z3.number(),
173
+ end_char_index: z3.number()
98
174
  })
99
175
  ])
100
176
  ).optional()
101
177
  }),
102
- import_v42.z.object({
103
- type: import_v42.z.literal("thinking"),
104
- thinking: import_v42.z.string(),
105
- signature: import_v42.z.string()
178
+ z3.object({
179
+ type: z3.literal("thinking"),
180
+ thinking: z3.string(),
181
+ signature: z3.string()
106
182
  }),
107
- import_v42.z.object({
108
- type: import_v42.z.literal("redacted_thinking"),
109
- data: import_v42.z.string()
183
+ z3.object({
184
+ type: z3.literal("redacted_thinking"),
185
+ data: z3.string()
110
186
  }),
111
- import_v42.z.object({
112
- type: import_v42.z.literal("compaction"),
113
- content: import_v42.z.string()
187
+ z3.object({
188
+ type: z3.literal("compaction"),
189
+ content: z3.string()
114
190
  }),
115
- import_v42.z.object({
116
- type: import_v42.z.literal("tool_use"),
117
- id: import_v42.z.string(),
118
- name: import_v42.z.string(),
119
- input: import_v42.z.unknown(),
191
+ z3.object({
192
+ type: z3.literal("tool_use"),
193
+ id: z3.string(),
194
+ name: z3.string(),
195
+ input: z3.unknown(),
120
196
  // Programmatic tool calling: caller info when triggered from code execution
121
- caller: import_v42.z.union([
122
- import_v42.z.object({
123
- type: import_v42.z.literal("code_execution_20250825"),
124
- tool_id: import_v42.z.string()
197
+ caller: z3.union([
198
+ z3.object({
199
+ type: z3.literal("code_execution_20250825"),
200
+ tool_id: z3.string()
125
201
  }),
126
- import_v42.z.object({
127
- type: import_v42.z.literal("code_execution_20260120"),
128
- tool_id: import_v42.z.string()
202
+ z3.object({
203
+ type: z3.literal("code_execution_20260120"),
204
+ tool_id: z3.string()
129
205
  }),
130
- import_v42.z.object({
131
- type: import_v42.z.literal("direct")
206
+ z3.object({
207
+ type: z3.literal("direct")
132
208
  })
133
209
  ]).optional()
134
210
  }),
135
- import_v42.z.object({
136
- type: import_v42.z.literal("server_tool_use"),
137
- id: import_v42.z.string(),
138
- name: import_v42.z.string(),
139
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
140
- caller: import_v42.z.union([
141
- import_v42.z.object({
142
- type: import_v42.z.literal("code_execution_20260120"),
143
- tool_id: import_v42.z.string()
211
+ z3.object({
212
+ type: z3.literal("server_tool_use"),
213
+ id: z3.string(),
214
+ name: z3.string(),
215
+ input: z3.record(z3.string(), z3.unknown()).nullish(),
216
+ caller: z3.union([
217
+ z3.object({
218
+ type: z3.literal("code_execution_20260120"),
219
+ tool_id: z3.string()
144
220
  }),
145
- import_v42.z.object({
146
- type: import_v42.z.literal("direct")
221
+ z3.object({
222
+ type: z3.literal("direct")
147
223
  })
148
224
  ]).optional()
149
225
  }),
150
- import_v42.z.object({
151
- type: import_v42.z.literal("mcp_tool_use"),
152
- id: import_v42.z.string(),
153
- name: import_v42.z.string(),
154
- input: import_v42.z.unknown(),
155
- server_name: import_v42.z.string()
226
+ z3.object({
227
+ type: z3.literal("mcp_tool_use"),
228
+ id: z3.string(),
229
+ name: z3.string(),
230
+ input: z3.unknown(),
231
+ server_name: z3.string()
156
232
  }),
157
- import_v42.z.object({
158
- type: import_v42.z.literal("mcp_tool_result"),
159
- tool_use_id: import_v42.z.string(),
160
- is_error: import_v42.z.boolean(),
161
- content: import_v42.z.array(
162
- import_v42.z.union([
163
- import_v42.z.string(),
164
- import_v42.z.object({ type: import_v42.z.literal("text"), text: import_v42.z.string() })
233
+ z3.object({
234
+ type: z3.literal("mcp_tool_result"),
235
+ tool_use_id: z3.string(),
236
+ is_error: z3.boolean(),
237
+ content: z3.array(
238
+ z3.union([
239
+ z3.string(),
240
+ z3.object({ type: z3.literal("text"), text: z3.string() })
165
241
  ])
166
242
  )
167
243
  }),
168
- import_v42.z.object({
169
- type: import_v42.z.literal("web_fetch_tool_result"),
170
- tool_use_id: import_v42.z.string(),
171
- content: import_v42.z.union([
172
- import_v42.z.object({
173
- type: import_v42.z.literal("web_fetch_result"),
174
- url: import_v42.z.string(),
175
- retrieved_at: import_v42.z.string(),
176
- content: import_v42.z.object({
177
- type: import_v42.z.literal("document"),
178
- title: import_v42.z.string().nullable(),
179
- citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
180
- source: import_v42.z.union([
181
- import_v42.z.object({
182
- type: import_v42.z.literal("base64"),
183
- media_type: import_v42.z.literal("application/pdf"),
184
- data: import_v42.z.string()
244
+ z3.object({
245
+ type: z3.literal("web_fetch_tool_result"),
246
+ tool_use_id: z3.string(),
247
+ content: z3.union([
248
+ z3.object({
249
+ type: z3.literal("web_fetch_result"),
250
+ url: z3.string(),
251
+ retrieved_at: z3.string(),
252
+ content: z3.object({
253
+ type: z3.literal("document"),
254
+ title: z3.string().nullable(),
255
+ citations: z3.object({ enabled: z3.boolean() }).optional(),
256
+ source: z3.union([
257
+ z3.object({
258
+ type: z3.literal("base64"),
259
+ media_type: z3.literal("application/pdf"),
260
+ data: z3.string()
185
261
  }),
186
- import_v42.z.object({
187
- type: import_v42.z.literal("text"),
188
- media_type: import_v42.z.literal("text/plain"),
189
- data: import_v42.z.string()
262
+ z3.object({
263
+ type: z3.literal("text"),
264
+ media_type: z3.literal("text/plain"),
265
+ data: z3.string()
190
266
  })
191
267
  ])
192
268
  })
193
269
  }),
194
- import_v42.z.object({
195
- type: import_v42.z.literal("web_fetch_tool_result_error"),
196
- error_code: import_v42.z.string()
270
+ z3.object({
271
+ type: z3.literal("web_fetch_tool_result_error"),
272
+ error_code: z3.string()
197
273
  })
198
274
  ])
199
275
  }),
200
- import_v42.z.object({
201
- type: import_v42.z.literal("web_search_tool_result"),
202
- tool_use_id: import_v42.z.string(),
203
- content: import_v42.z.union([
204
- import_v42.z.array(
205
- import_v42.z.object({
206
- type: import_v42.z.literal("web_search_result"),
207
- url: import_v42.z.string(),
208
- title: import_v42.z.string(),
209
- encrypted_content: import_v42.z.string(),
210
- page_age: import_v42.z.string().nullish()
276
+ z3.object({
277
+ type: z3.literal("web_search_tool_result"),
278
+ tool_use_id: z3.string(),
279
+ content: z3.union([
280
+ z3.array(
281
+ z3.object({
282
+ type: z3.literal("web_search_result"),
283
+ url: z3.string(),
284
+ title: z3.string(),
285
+ encrypted_content: z3.string(),
286
+ page_age: z3.string().nullish()
211
287
  })
212
288
  ),
213
- import_v42.z.object({
214
- type: import_v42.z.literal("web_search_tool_result_error"),
215
- error_code: import_v42.z.string()
289
+ z3.object({
290
+ type: z3.literal("web_search_tool_result_error"),
291
+ error_code: z3.string()
216
292
  })
217
293
  ])
218
294
  }),
219
295
  // code execution results for code_execution_20250522 tool:
220
- import_v42.z.object({
221
- type: import_v42.z.literal("code_execution_tool_result"),
222
- tool_use_id: import_v42.z.string(),
223
- content: import_v42.z.union([
224
- import_v42.z.object({
225
- type: import_v42.z.literal("code_execution_result"),
226
- stdout: import_v42.z.string(),
227
- stderr: import_v42.z.string(),
228
- return_code: import_v42.z.number(),
229
- content: import_v42.z.array(
230
- import_v42.z.object({
231
- type: import_v42.z.literal("code_execution_output"),
232
- file_id: import_v42.z.string()
296
+ z3.object({
297
+ type: z3.literal("code_execution_tool_result"),
298
+ tool_use_id: z3.string(),
299
+ content: z3.union([
300
+ z3.object({
301
+ type: z3.literal("code_execution_result"),
302
+ stdout: z3.string(),
303
+ stderr: z3.string(),
304
+ return_code: z3.number(),
305
+ content: z3.array(
306
+ z3.object({
307
+ type: z3.literal("code_execution_output"),
308
+ file_id: z3.string()
233
309
  })
234
310
  ).optional().default([])
235
311
  }),
236
- import_v42.z.object({
237
- type: import_v42.z.literal("encrypted_code_execution_result"),
238
- encrypted_stdout: import_v42.z.string(),
239
- stderr: import_v42.z.string(),
240
- return_code: import_v42.z.number(),
241
- content: import_v42.z.array(
242
- import_v42.z.object({
243
- type: import_v42.z.literal("code_execution_output"),
244
- file_id: import_v42.z.string()
312
+ z3.object({
313
+ type: z3.literal("encrypted_code_execution_result"),
314
+ encrypted_stdout: z3.string(),
315
+ stderr: z3.string(),
316
+ return_code: z3.number(),
317
+ content: z3.array(
318
+ z3.object({
319
+ type: z3.literal("code_execution_output"),
320
+ file_id: z3.string()
245
321
  })
246
322
  ).optional().default([])
247
323
  }),
248
- import_v42.z.object({
249
- type: import_v42.z.literal("code_execution_tool_result_error"),
250
- error_code: import_v42.z.string()
324
+ z3.object({
325
+ type: z3.literal("code_execution_tool_result_error"),
326
+ error_code: z3.string()
251
327
  })
252
328
  ])
253
329
  }),
254
330
  // bash code execution results for code_execution_20250825 tool:
255
- import_v42.z.object({
256
- type: import_v42.z.literal("bash_code_execution_tool_result"),
257
- tool_use_id: import_v42.z.string(),
258
- content: import_v42.z.discriminatedUnion("type", [
259
- import_v42.z.object({
260
- type: import_v42.z.literal("bash_code_execution_result"),
261
- content: import_v42.z.array(
262
- import_v42.z.object({
263
- type: import_v42.z.literal("bash_code_execution_output"),
264
- file_id: import_v42.z.string()
331
+ z3.object({
332
+ type: z3.literal("bash_code_execution_tool_result"),
333
+ tool_use_id: z3.string(),
334
+ content: z3.discriminatedUnion("type", [
335
+ z3.object({
336
+ type: z3.literal("bash_code_execution_result"),
337
+ content: z3.array(
338
+ z3.object({
339
+ type: z3.literal("bash_code_execution_output"),
340
+ file_id: z3.string()
265
341
  })
266
342
  ),
267
- stdout: import_v42.z.string(),
268
- stderr: import_v42.z.string(),
269
- return_code: import_v42.z.number()
343
+ stdout: z3.string(),
344
+ stderr: z3.string(),
345
+ return_code: z3.number()
270
346
  }),
271
- import_v42.z.object({
272
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
273
- error_code: import_v42.z.string()
347
+ z3.object({
348
+ type: z3.literal("bash_code_execution_tool_result_error"),
349
+ error_code: z3.string()
274
350
  })
275
351
  ])
276
352
  }),
277
353
  // text editor code execution results for code_execution_20250825 tool:
278
- import_v42.z.object({
279
- type: import_v42.z.literal("text_editor_code_execution_tool_result"),
280
- tool_use_id: import_v42.z.string(),
281
- content: import_v42.z.discriminatedUnion("type", [
282
- import_v42.z.object({
283
- type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
284
- error_code: import_v42.z.string()
354
+ z3.object({
355
+ type: z3.literal("text_editor_code_execution_tool_result"),
356
+ tool_use_id: z3.string(),
357
+ content: z3.discriminatedUnion("type", [
358
+ z3.object({
359
+ type: z3.literal("text_editor_code_execution_tool_result_error"),
360
+ error_code: z3.string()
285
361
  }),
286
- import_v42.z.object({
287
- type: import_v42.z.literal("text_editor_code_execution_view_result"),
288
- content: import_v42.z.string(),
289
- file_type: import_v42.z.string(),
290
- num_lines: import_v42.z.number().nullable(),
291
- start_line: import_v42.z.number().nullable(),
292
- total_lines: import_v42.z.number().nullable()
362
+ z3.object({
363
+ type: z3.literal("text_editor_code_execution_view_result"),
364
+ content: z3.string(),
365
+ file_type: z3.string(),
366
+ num_lines: z3.number().nullable(),
367
+ start_line: z3.number().nullable(),
368
+ total_lines: z3.number().nullable()
293
369
  }),
294
- import_v42.z.object({
295
- type: import_v42.z.literal("text_editor_code_execution_create_result"),
296
- is_file_update: import_v42.z.boolean()
370
+ z3.object({
371
+ type: z3.literal("text_editor_code_execution_create_result"),
372
+ is_file_update: z3.boolean()
297
373
  }),
298
- import_v42.z.object({
299
- type: import_v42.z.literal(
374
+ z3.object({
375
+ type: z3.literal(
300
376
  "text_editor_code_execution_str_replace_result"
301
377
  ),
302
- lines: import_v42.z.array(import_v42.z.string()).nullable(),
303
- new_lines: import_v42.z.number().nullable(),
304
- new_start: import_v42.z.number().nullable(),
305
- old_lines: import_v42.z.number().nullable(),
306
- old_start: import_v42.z.number().nullable()
378
+ lines: z3.array(z3.string()).nullable(),
379
+ new_lines: z3.number().nullable(),
380
+ new_start: z3.number().nullable(),
381
+ old_lines: z3.number().nullable(),
382
+ old_start: z3.number().nullable()
307
383
  })
308
384
  ])
309
385
  }),
310
386
  // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
311
- import_v42.z.object({
312
- type: import_v42.z.literal("tool_search_tool_result"),
313
- tool_use_id: import_v42.z.string(),
314
- content: import_v42.z.union([
315
- import_v42.z.object({
316
- type: import_v42.z.literal("tool_search_tool_search_result"),
317
- tool_references: import_v42.z.array(
318
- import_v42.z.object({
319
- type: import_v42.z.literal("tool_reference"),
320
- tool_name: import_v42.z.string()
387
+ z3.object({
388
+ type: z3.literal("tool_search_tool_result"),
389
+ tool_use_id: z3.string(),
390
+ content: z3.union([
391
+ z3.object({
392
+ type: z3.literal("tool_search_tool_search_result"),
393
+ tool_references: z3.array(
394
+ z3.object({
395
+ type: z3.literal("tool_reference"),
396
+ tool_name: z3.string()
321
397
  })
322
398
  )
323
399
  }),
324
- import_v42.z.object({
325
- type: import_v42.z.literal("tool_search_tool_result_error"),
326
- error_code: import_v42.z.string()
400
+ z3.object({
401
+ type: z3.literal("tool_search_tool_result_error"),
402
+ error_code: z3.string()
327
403
  })
328
404
  ])
329
405
  })
330
406
  ])
331
407
  ),
332
- stop_reason: import_v42.z.string().nullish(),
333
- stop_sequence: import_v42.z.string().nullish(),
334
- usage: import_v42.z.looseObject({
335
- input_tokens: import_v42.z.number(),
336
- output_tokens: import_v42.z.number(),
337
- cache_creation_input_tokens: import_v42.z.number().nullish(),
338
- cache_read_input_tokens: import_v42.z.number().nullish(),
339
- iterations: import_v42.z.array(
340
- import_v42.z.object({
341
- type: import_v42.z.union([import_v42.z.literal("compaction"), import_v42.z.literal("message")]),
342
- input_tokens: import_v42.z.number(),
343
- output_tokens: import_v42.z.number()
408
+ stop_reason: z3.string().nullish(),
409
+ stop_sequence: z3.string().nullish(),
410
+ usage: z3.looseObject({
411
+ input_tokens: z3.number(),
412
+ output_tokens: z3.number(),
413
+ cache_creation_input_tokens: z3.number().nullish(),
414
+ cache_read_input_tokens: z3.number().nullish(),
415
+ iterations: z3.array(
416
+ z3.object({
417
+ type: z3.union([z3.literal("compaction"), z3.literal("message")]),
418
+ input_tokens: z3.number(),
419
+ output_tokens: z3.number()
344
420
  })
345
421
  ).nullish()
346
422
  }),
347
- container: import_v42.z.object({
348
- expires_at: import_v42.z.string(),
349
- id: import_v42.z.string(),
350
- skills: import_v42.z.array(
351
- import_v42.z.object({
352
- type: import_v42.z.union([import_v42.z.literal("anthropic"), import_v42.z.literal("custom")]),
353
- skill_id: import_v42.z.string(),
354
- version: import_v42.z.string()
423
+ container: z3.object({
424
+ expires_at: z3.string(),
425
+ id: z3.string(),
426
+ skills: z3.array(
427
+ z3.object({
428
+ type: z3.union([z3.literal("anthropic"), z3.literal("custom")]),
429
+ skill_id: z3.string(),
430
+ version: z3.string()
355
431
  })
356
432
  ).nullish()
357
433
  }).nullish(),
358
- context_management: import_v42.z.object({
359
- applied_edits: import_v42.z.array(
360
- import_v42.z.union([
361
- import_v42.z.object({
362
- type: import_v42.z.literal("clear_tool_uses_20250919"),
363
- cleared_tool_uses: import_v42.z.number(),
364
- cleared_input_tokens: import_v42.z.number()
434
+ context_management: z3.object({
435
+ applied_edits: z3.array(
436
+ z3.union([
437
+ z3.object({
438
+ type: z3.literal("clear_tool_uses_20250919"),
439
+ cleared_tool_uses: z3.number(),
440
+ cleared_input_tokens: z3.number()
365
441
  }),
366
- import_v42.z.object({
367
- type: import_v42.z.literal("clear_thinking_20251015"),
368
- cleared_thinking_turns: import_v42.z.number(),
369
- cleared_input_tokens: import_v42.z.number()
442
+ z3.object({
443
+ type: z3.literal("clear_thinking_20251015"),
444
+ cleared_thinking_turns: z3.number(),
445
+ cleared_input_tokens: z3.number()
370
446
  }),
371
- import_v42.z.object({
372
- type: import_v42.z.literal("compact_20260112")
447
+ z3.object({
448
+ type: z3.literal("compact_20260112")
373
449
  })
374
450
  ])
375
451
  )
@@ -377,457 +453,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
377
453
  })
378
454
  )
379
455
  );
380
- var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
381
- () => (0, import_provider_utils2.zodSchema)(
382
- import_v42.z.discriminatedUnion("type", [
383
- import_v42.z.object({
384
- type: import_v42.z.literal("message_start"),
385
- message: import_v42.z.object({
386
- id: import_v42.z.string().nullish(),
387
- model: import_v42.z.string().nullish(),
388
- role: import_v42.z.string().nullish(),
389
- usage: import_v42.z.looseObject({
390
- input_tokens: import_v42.z.number(),
391
- cache_creation_input_tokens: import_v42.z.number().nullish(),
392
- cache_read_input_tokens: import_v42.z.number().nullish()
456
+ var anthropicMessagesChunkSchema = lazySchema3(
457
+ () => zodSchema3(
458
+ z3.discriminatedUnion("type", [
459
+ z3.object({
460
+ type: z3.literal("message_start"),
461
+ message: z3.object({
462
+ id: z3.string().nullish(),
463
+ model: z3.string().nullish(),
464
+ role: z3.string().nullish(),
465
+ usage: z3.looseObject({
466
+ input_tokens: z3.number(),
467
+ cache_creation_input_tokens: z3.number().nullish(),
468
+ cache_read_input_tokens: z3.number().nullish()
393
469
  }),
394
470
  // Programmatic tool calling: content may be pre-populated for deferred tool calls
395
- content: import_v42.z.array(
396
- import_v42.z.discriminatedUnion("type", [
397
- import_v42.z.object({
398
- type: import_v42.z.literal("tool_use"),
399
- id: import_v42.z.string(),
400
- name: import_v42.z.string(),
401
- input: import_v42.z.unknown(),
402
- caller: import_v42.z.union([
403
- import_v42.z.object({
404
- type: import_v42.z.literal("code_execution_20250825"),
405
- tool_id: import_v42.z.string()
471
+ content: z3.array(
472
+ z3.discriminatedUnion("type", [
473
+ z3.object({
474
+ type: z3.literal("tool_use"),
475
+ id: z3.string(),
476
+ name: z3.string(),
477
+ input: z3.unknown(),
478
+ caller: z3.union([
479
+ z3.object({
480
+ type: z3.literal("code_execution_20250825"),
481
+ tool_id: z3.string()
406
482
  }),
407
- import_v42.z.object({
408
- type: import_v42.z.literal("code_execution_20260120"),
409
- tool_id: import_v42.z.string()
483
+ z3.object({
484
+ type: z3.literal("code_execution_20260120"),
485
+ tool_id: z3.string()
410
486
  }),
411
- import_v42.z.object({
412
- type: import_v42.z.literal("direct")
487
+ z3.object({
488
+ type: z3.literal("direct")
413
489
  })
414
490
  ]).optional()
415
491
  })
416
492
  ])
417
493
  ).nullish(),
418
- stop_reason: import_v42.z.string().nullish(),
419
- container: import_v42.z.object({
420
- expires_at: import_v42.z.string(),
421
- id: import_v42.z.string()
494
+ stop_reason: z3.string().nullish(),
495
+ container: z3.object({
496
+ expires_at: z3.string(),
497
+ id: z3.string()
422
498
  }).nullish()
423
499
  })
424
500
  }),
425
- import_v42.z.object({
426
- type: import_v42.z.literal("content_block_start"),
427
- index: import_v42.z.number(),
428
- content_block: import_v42.z.discriminatedUnion("type", [
429
- import_v42.z.object({
430
- type: import_v42.z.literal("text"),
431
- text: import_v42.z.string()
501
+ z3.object({
502
+ type: z3.literal("content_block_start"),
503
+ index: z3.number(),
504
+ content_block: z3.discriminatedUnion("type", [
505
+ z3.object({
506
+ type: z3.literal("text"),
507
+ text: z3.string()
432
508
  }),
433
- import_v42.z.object({
434
- type: import_v42.z.literal("thinking"),
435
- thinking: import_v42.z.string()
509
+ z3.object({
510
+ type: z3.literal("thinking"),
511
+ thinking: z3.string()
436
512
  }),
437
- import_v42.z.object({
438
- type: import_v42.z.literal("tool_use"),
439
- id: import_v42.z.string(),
440
- name: import_v42.z.string(),
513
+ z3.object({
514
+ type: z3.literal("tool_use"),
515
+ id: z3.string(),
516
+ name: z3.string(),
441
517
  // Programmatic tool calling: input may be present directly for deferred tool calls
442
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional(),
518
+ input: z3.record(z3.string(), z3.unknown()).optional(),
443
519
  // Programmatic tool calling: caller info when triggered from code execution
444
- caller: import_v42.z.union([
445
- import_v42.z.object({
446
- type: import_v42.z.literal("code_execution_20250825"),
447
- tool_id: import_v42.z.string()
520
+ caller: z3.union([
521
+ z3.object({
522
+ type: z3.literal("code_execution_20250825"),
523
+ tool_id: z3.string()
448
524
  }),
449
- import_v42.z.object({
450
- type: import_v42.z.literal("code_execution_20260120"),
451
- tool_id: import_v42.z.string()
525
+ z3.object({
526
+ type: z3.literal("code_execution_20260120"),
527
+ tool_id: z3.string()
452
528
  }),
453
- import_v42.z.object({
454
- type: import_v42.z.literal("direct")
529
+ z3.object({
530
+ type: z3.literal("direct")
455
531
  })
456
532
  ]).optional()
457
533
  }),
458
- import_v42.z.object({
459
- type: import_v42.z.literal("redacted_thinking"),
460
- data: import_v42.z.string()
534
+ z3.object({
535
+ type: z3.literal("redacted_thinking"),
536
+ data: z3.string()
461
537
  }),
462
- import_v42.z.object({
463
- type: import_v42.z.literal("compaction"),
464
- content: import_v42.z.string().nullish()
538
+ z3.object({
539
+ type: z3.literal("compaction"),
540
+ content: z3.string().nullish()
465
541
  }),
466
- import_v42.z.object({
467
- type: import_v42.z.literal("server_tool_use"),
468
- id: import_v42.z.string(),
469
- name: import_v42.z.string(),
470
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
471
- caller: import_v42.z.union([
472
- import_v42.z.object({
473
- type: import_v42.z.literal("code_execution_20260120"),
474
- tool_id: import_v42.z.string()
542
+ z3.object({
543
+ type: z3.literal("server_tool_use"),
544
+ id: z3.string(),
545
+ name: z3.string(),
546
+ input: z3.record(z3.string(), z3.unknown()).nullish(),
547
+ caller: z3.union([
548
+ z3.object({
549
+ type: z3.literal("code_execution_20260120"),
550
+ tool_id: z3.string()
475
551
  }),
476
- import_v42.z.object({
477
- type: import_v42.z.literal("direct")
552
+ z3.object({
553
+ type: z3.literal("direct")
478
554
  })
479
555
  ]).optional()
480
556
  }),
481
- import_v42.z.object({
482
- type: import_v42.z.literal("mcp_tool_use"),
483
- id: import_v42.z.string(),
484
- name: import_v42.z.string(),
485
- input: import_v42.z.unknown(),
486
- server_name: import_v42.z.string()
557
+ z3.object({
558
+ type: z3.literal("mcp_tool_use"),
559
+ id: z3.string(),
560
+ name: z3.string(),
561
+ input: z3.unknown(),
562
+ server_name: z3.string()
487
563
  }),
488
- import_v42.z.object({
489
- type: import_v42.z.literal("mcp_tool_result"),
490
- tool_use_id: import_v42.z.string(),
491
- is_error: import_v42.z.boolean(),
492
- content: import_v42.z.array(
493
- import_v42.z.union([
494
- import_v42.z.string(),
495
- import_v42.z.object({ type: import_v42.z.literal("text"), text: import_v42.z.string() })
564
+ z3.object({
565
+ type: z3.literal("mcp_tool_result"),
566
+ tool_use_id: z3.string(),
567
+ is_error: z3.boolean(),
568
+ content: z3.array(
569
+ z3.union([
570
+ z3.string(),
571
+ z3.object({ type: z3.literal("text"), text: z3.string() })
496
572
  ])
497
573
  )
498
574
  }),
499
- import_v42.z.object({
500
- type: import_v42.z.literal("web_fetch_tool_result"),
501
- tool_use_id: import_v42.z.string(),
502
- content: import_v42.z.union([
503
- import_v42.z.object({
504
- type: import_v42.z.literal("web_fetch_result"),
505
- url: import_v42.z.string(),
506
- retrieved_at: import_v42.z.string(),
507
- content: import_v42.z.object({
508
- type: import_v42.z.literal("document"),
509
- title: import_v42.z.string().nullable(),
510
- citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
511
- source: import_v42.z.union([
512
- import_v42.z.object({
513
- type: import_v42.z.literal("base64"),
514
- media_type: import_v42.z.literal("application/pdf"),
515
- data: import_v42.z.string()
575
+ z3.object({
576
+ type: z3.literal("web_fetch_tool_result"),
577
+ tool_use_id: z3.string(),
578
+ content: z3.union([
579
+ z3.object({
580
+ type: z3.literal("web_fetch_result"),
581
+ url: z3.string(),
582
+ retrieved_at: z3.string(),
583
+ content: z3.object({
584
+ type: z3.literal("document"),
585
+ title: z3.string().nullable(),
586
+ citations: z3.object({ enabled: z3.boolean() }).optional(),
587
+ source: z3.union([
588
+ z3.object({
589
+ type: z3.literal("base64"),
590
+ media_type: z3.literal("application/pdf"),
591
+ data: z3.string()
516
592
  }),
517
- import_v42.z.object({
518
- type: import_v42.z.literal("text"),
519
- media_type: import_v42.z.literal("text/plain"),
520
- data: import_v42.z.string()
593
+ z3.object({
594
+ type: z3.literal("text"),
595
+ media_type: z3.literal("text/plain"),
596
+ data: z3.string()
521
597
  })
522
598
  ])
523
599
  })
524
600
  }),
525
- import_v42.z.object({
526
- type: import_v42.z.literal("web_fetch_tool_result_error"),
527
- error_code: import_v42.z.string()
601
+ z3.object({
602
+ type: z3.literal("web_fetch_tool_result_error"),
603
+ error_code: z3.string()
528
604
  })
529
605
  ])
530
606
  }),
531
- import_v42.z.object({
532
- type: import_v42.z.literal("web_search_tool_result"),
533
- tool_use_id: import_v42.z.string(),
534
- content: import_v42.z.union([
535
- import_v42.z.array(
536
- import_v42.z.object({
537
- type: import_v42.z.literal("web_search_result"),
538
- url: import_v42.z.string(),
539
- title: import_v42.z.string(),
540
- encrypted_content: import_v42.z.string(),
541
- page_age: import_v42.z.string().nullish()
607
+ z3.object({
608
+ type: z3.literal("web_search_tool_result"),
609
+ tool_use_id: z3.string(),
610
+ content: z3.union([
611
+ z3.array(
612
+ z3.object({
613
+ type: z3.literal("web_search_result"),
614
+ url: z3.string(),
615
+ title: z3.string(),
616
+ encrypted_content: z3.string(),
617
+ page_age: z3.string().nullish()
542
618
  })
543
619
  ),
544
- import_v42.z.object({
545
- type: import_v42.z.literal("web_search_tool_result_error"),
546
- error_code: import_v42.z.string()
620
+ z3.object({
621
+ type: z3.literal("web_search_tool_result_error"),
622
+ error_code: z3.string()
547
623
  })
548
624
  ])
549
625
  }),
550
626
  // code execution results for code_execution_20250522 tool:
551
- import_v42.z.object({
552
- type: import_v42.z.literal("code_execution_tool_result"),
553
- tool_use_id: import_v42.z.string(),
554
- content: import_v42.z.union([
555
- import_v42.z.object({
556
- type: import_v42.z.literal("code_execution_result"),
557
- stdout: import_v42.z.string(),
558
- stderr: import_v42.z.string(),
559
- return_code: import_v42.z.number(),
560
- content: import_v42.z.array(
561
- import_v42.z.object({
562
- type: import_v42.z.literal("code_execution_output"),
563
- file_id: import_v42.z.string()
627
+ z3.object({
628
+ type: z3.literal("code_execution_tool_result"),
629
+ tool_use_id: z3.string(),
630
+ content: z3.union([
631
+ z3.object({
632
+ type: z3.literal("code_execution_result"),
633
+ stdout: z3.string(),
634
+ stderr: z3.string(),
635
+ return_code: z3.number(),
636
+ content: z3.array(
637
+ z3.object({
638
+ type: z3.literal("code_execution_output"),
639
+ file_id: z3.string()
564
640
  })
565
641
  ).optional().default([])
566
642
  }),
567
- import_v42.z.object({
568
- type: import_v42.z.literal("encrypted_code_execution_result"),
569
- encrypted_stdout: import_v42.z.string(),
570
- stderr: import_v42.z.string(),
571
- return_code: import_v42.z.number(),
572
- content: import_v42.z.array(
573
- import_v42.z.object({
574
- type: import_v42.z.literal("code_execution_output"),
575
- file_id: import_v42.z.string()
643
+ z3.object({
644
+ type: z3.literal("encrypted_code_execution_result"),
645
+ encrypted_stdout: z3.string(),
646
+ stderr: z3.string(),
647
+ return_code: z3.number(),
648
+ content: z3.array(
649
+ z3.object({
650
+ type: z3.literal("code_execution_output"),
651
+ file_id: z3.string()
576
652
  })
577
653
  ).optional().default([])
578
654
  }),
579
- import_v42.z.object({
580
- type: import_v42.z.literal("code_execution_tool_result_error"),
581
- error_code: import_v42.z.string()
655
+ z3.object({
656
+ type: z3.literal("code_execution_tool_result_error"),
657
+ error_code: z3.string()
582
658
  })
583
659
  ])
584
660
  }),
585
661
  // bash code execution results for code_execution_20250825 tool:
586
- import_v42.z.object({
587
- type: import_v42.z.literal("bash_code_execution_tool_result"),
588
- tool_use_id: import_v42.z.string(),
589
- content: import_v42.z.discriminatedUnion("type", [
590
- import_v42.z.object({
591
- type: import_v42.z.literal("bash_code_execution_result"),
592
- content: import_v42.z.array(
593
- import_v42.z.object({
594
- type: import_v42.z.literal("bash_code_execution_output"),
595
- file_id: import_v42.z.string()
662
+ z3.object({
663
+ type: z3.literal("bash_code_execution_tool_result"),
664
+ tool_use_id: z3.string(),
665
+ content: z3.discriminatedUnion("type", [
666
+ z3.object({
667
+ type: z3.literal("bash_code_execution_result"),
668
+ content: z3.array(
669
+ z3.object({
670
+ type: z3.literal("bash_code_execution_output"),
671
+ file_id: z3.string()
596
672
  })
597
673
  ),
598
- stdout: import_v42.z.string(),
599
- stderr: import_v42.z.string(),
600
- return_code: import_v42.z.number()
674
+ stdout: z3.string(),
675
+ stderr: z3.string(),
676
+ return_code: z3.number()
601
677
  }),
602
- import_v42.z.object({
603
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
604
- error_code: import_v42.z.string()
678
+ z3.object({
679
+ type: z3.literal("bash_code_execution_tool_result_error"),
680
+ error_code: z3.string()
605
681
  })
606
682
  ])
607
683
  }),
608
684
  // text editor code execution results for code_execution_20250825 tool:
609
- import_v42.z.object({
610
- type: import_v42.z.literal("text_editor_code_execution_tool_result"),
611
- tool_use_id: import_v42.z.string(),
612
- content: import_v42.z.discriminatedUnion("type", [
613
- import_v42.z.object({
614
- type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
615
- error_code: import_v42.z.string()
685
+ z3.object({
686
+ type: z3.literal("text_editor_code_execution_tool_result"),
687
+ tool_use_id: z3.string(),
688
+ content: z3.discriminatedUnion("type", [
689
+ z3.object({
690
+ type: z3.literal("text_editor_code_execution_tool_result_error"),
691
+ error_code: z3.string()
616
692
  }),
617
- import_v42.z.object({
618
- type: import_v42.z.literal("text_editor_code_execution_view_result"),
619
- content: import_v42.z.string(),
620
- file_type: import_v42.z.string(),
621
- num_lines: import_v42.z.number().nullable(),
622
- start_line: import_v42.z.number().nullable(),
623
- total_lines: import_v42.z.number().nullable()
693
+ z3.object({
694
+ type: z3.literal("text_editor_code_execution_view_result"),
695
+ content: z3.string(),
696
+ file_type: z3.string(),
697
+ num_lines: z3.number().nullable(),
698
+ start_line: z3.number().nullable(),
699
+ total_lines: z3.number().nullable()
624
700
  }),
625
- import_v42.z.object({
626
- type: import_v42.z.literal("text_editor_code_execution_create_result"),
627
- is_file_update: import_v42.z.boolean()
701
+ z3.object({
702
+ type: z3.literal("text_editor_code_execution_create_result"),
703
+ is_file_update: z3.boolean()
628
704
  }),
629
- import_v42.z.object({
630
- type: import_v42.z.literal(
705
+ z3.object({
706
+ type: z3.literal(
631
707
  "text_editor_code_execution_str_replace_result"
632
708
  ),
633
- lines: import_v42.z.array(import_v42.z.string()).nullable(),
634
- new_lines: import_v42.z.number().nullable(),
635
- new_start: import_v42.z.number().nullable(),
636
- old_lines: import_v42.z.number().nullable(),
637
- old_start: import_v42.z.number().nullable()
709
+ lines: z3.array(z3.string()).nullable(),
710
+ new_lines: z3.number().nullable(),
711
+ new_start: z3.number().nullable(),
712
+ old_lines: z3.number().nullable(),
713
+ old_start: z3.number().nullable()
638
714
  })
639
715
  ])
640
716
  }),
641
717
  // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
642
- import_v42.z.object({
643
- type: import_v42.z.literal("tool_search_tool_result"),
644
- tool_use_id: import_v42.z.string(),
645
- content: import_v42.z.union([
646
- import_v42.z.object({
647
- type: import_v42.z.literal("tool_search_tool_search_result"),
648
- tool_references: import_v42.z.array(
649
- import_v42.z.object({
650
- type: import_v42.z.literal("tool_reference"),
651
- tool_name: import_v42.z.string()
718
+ z3.object({
719
+ type: z3.literal("tool_search_tool_result"),
720
+ tool_use_id: z3.string(),
721
+ content: z3.union([
722
+ z3.object({
723
+ type: z3.literal("tool_search_tool_search_result"),
724
+ tool_references: z3.array(
725
+ z3.object({
726
+ type: z3.literal("tool_reference"),
727
+ tool_name: z3.string()
652
728
  })
653
729
  )
654
730
  }),
655
- import_v42.z.object({
656
- type: import_v42.z.literal("tool_search_tool_result_error"),
657
- error_code: import_v42.z.string()
731
+ z3.object({
732
+ type: z3.literal("tool_search_tool_result_error"),
733
+ error_code: z3.string()
658
734
  })
659
735
  ])
660
736
  })
661
737
  ])
662
738
  }),
663
- import_v42.z.object({
664
- type: import_v42.z.literal("content_block_delta"),
665
- index: import_v42.z.number(),
666
- delta: import_v42.z.discriminatedUnion("type", [
667
- import_v42.z.object({
668
- type: import_v42.z.literal("input_json_delta"),
669
- partial_json: import_v42.z.string()
739
+ z3.object({
740
+ type: z3.literal("content_block_delta"),
741
+ index: z3.number(),
742
+ delta: z3.discriminatedUnion("type", [
743
+ z3.object({
744
+ type: z3.literal("input_json_delta"),
745
+ partial_json: z3.string()
670
746
  }),
671
- import_v42.z.object({
672
- type: import_v42.z.literal("text_delta"),
673
- text: import_v42.z.string()
747
+ z3.object({
748
+ type: z3.literal("text_delta"),
749
+ text: z3.string()
674
750
  }),
675
- import_v42.z.object({
676
- type: import_v42.z.literal("thinking_delta"),
677
- thinking: import_v42.z.string()
751
+ z3.object({
752
+ type: z3.literal("thinking_delta"),
753
+ thinking: z3.string()
678
754
  }),
679
- import_v42.z.object({
680
- type: import_v42.z.literal("signature_delta"),
681
- signature: import_v42.z.string()
755
+ z3.object({
756
+ type: z3.literal("signature_delta"),
757
+ signature: z3.string()
682
758
  }),
683
- import_v42.z.object({
684
- type: import_v42.z.literal("compaction_delta"),
685
- content: import_v42.z.string().nullish()
759
+ z3.object({
760
+ type: z3.literal("compaction_delta"),
761
+ content: z3.string().nullish()
686
762
  }),
687
- import_v42.z.object({
688
- type: import_v42.z.literal("citations_delta"),
689
- citation: import_v42.z.discriminatedUnion("type", [
690
- import_v42.z.object({
691
- type: import_v42.z.literal("web_search_result_location"),
692
- cited_text: import_v42.z.string(),
693
- url: import_v42.z.string(),
694
- title: import_v42.z.string(),
695
- encrypted_index: import_v42.z.string()
763
+ z3.object({
764
+ type: z3.literal("citations_delta"),
765
+ citation: z3.discriminatedUnion("type", [
766
+ z3.object({
767
+ type: z3.literal("web_search_result_location"),
768
+ cited_text: z3.string(),
769
+ url: z3.string(),
770
+ title: z3.string(),
771
+ encrypted_index: z3.string()
696
772
  }),
697
- import_v42.z.object({
698
- type: import_v42.z.literal("page_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_page_number: import_v42.z.number(),
703
- end_page_number: import_v42.z.number()
773
+ z3.object({
774
+ type: z3.literal("page_location"),
775
+ cited_text: z3.string(),
776
+ document_index: z3.number(),
777
+ document_title: z3.string().nullable(),
778
+ start_page_number: z3.number(),
779
+ end_page_number: z3.number()
704
780
  }),
705
- import_v42.z.object({
706
- type: import_v42.z.literal("char_location"),
707
- cited_text: import_v42.z.string(),
708
- document_index: import_v42.z.number(),
709
- document_title: import_v42.z.string().nullable(),
710
- start_char_index: import_v42.z.number(),
711
- end_char_index: import_v42.z.number()
781
+ z3.object({
782
+ type: z3.literal("char_location"),
783
+ cited_text: z3.string(),
784
+ document_index: z3.number(),
785
+ document_title: z3.string().nullable(),
786
+ start_char_index: z3.number(),
787
+ end_char_index: z3.number()
712
788
  })
713
789
  ])
714
790
  })
715
791
  ])
716
792
  }),
717
- import_v42.z.object({
718
- type: import_v42.z.literal("content_block_stop"),
719
- index: import_v42.z.number()
793
+ z3.object({
794
+ type: z3.literal("content_block_stop"),
795
+ index: z3.number()
720
796
  }),
721
- import_v42.z.object({
722
- type: import_v42.z.literal("error"),
723
- error: import_v42.z.object({
724
- type: import_v42.z.string(),
725
- message: import_v42.z.string()
797
+ z3.object({
798
+ type: z3.literal("error"),
799
+ error: z3.object({
800
+ type: z3.string(),
801
+ message: z3.string()
726
802
  })
727
803
  }),
728
- import_v42.z.object({
729
- type: import_v42.z.literal("message_delta"),
730
- delta: import_v42.z.object({
731
- stop_reason: import_v42.z.string().nullish(),
732
- stop_sequence: import_v42.z.string().nullish(),
733
- container: import_v42.z.object({
734
- expires_at: import_v42.z.string(),
735
- id: import_v42.z.string(),
736
- skills: import_v42.z.array(
737
- import_v42.z.object({
738
- type: import_v42.z.union([
739
- import_v42.z.literal("anthropic"),
740
- import_v42.z.literal("custom")
804
+ z3.object({
805
+ type: z3.literal("message_delta"),
806
+ delta: z3.object({
807
+ stop_reason: z3.string().nullish(),
808
+ stop_sequence: z3.string().nullish(),
809
+ container: z3.object({
810
+ expires_at: z3.string(),
811
+ id: z3.string(),
812
+ skills: z3.array(
813
+ z3.object({
814
+ type: z3.union([
815
+ z3.literal("anthropic"),
816
+ z3.literal("custom")
741
817
  ]),
742
- skill_id: import_v42.z.string(),
743
- version: import_v42.z.string()
818
+ skill_id: z3.string(),
819
+ version: z3.string()
744
820
  })
745
821
  ).nullish()
746
822
  }).nullish()
747
823
  }),
748
- usage: import_v42.z.looseObject({
749
- input_tokens: import_v42.z.number().nullish(),
750
- output_tokens: import_v42.z.number(),
751
- cache_creation_input_tokens: import_v42.z.number().nullish(),
752
- cache_read_input_tokens: import_v42.z.number().nullish(),
753
- iterations: import_v42.z.array(
754
- import_v42.z.object({
755
- type: import_v42.z.union([import_v42.z.literal("compaction"), import_v42.z.literal("message")]),
756
- input_tokens: import_v42.z.number(),
757
- output_tokens: import_v42.z.number()
824
+ usage: z3.looseObject({
825
+ input_tokens: z3.number().nullish(),
826
+ output_tokens: z3.number(),
827
+ cache_creation_input_tokens: z3.number().nullish(),
828
+ cache_read_input_tokens: z3.number().nullish(),
829
+ iterations: z3.array(
830
+ z3.object({
831
+ type: z3.union([z3.literal("compaction"), z3.literal("message")]),
832
+ input_tokens: z3.number(),
833
+ output_tokens: z3.number()
758
834
  })
759
835
  ).nullish()
760
836
  }),
761
- context_management: import_v42.z.object({
762
- applied_edits: import_v42.z.array(
763
- import_v42.z.union([
764
- import_v42.z.object({
765
- type: import_v42.z.literal("clear_tool_uses_20250919"),
766
- cleared_tool_uses: import_v42.z.number(),
767
- cleared_input_tokens: import_v42.z.number()
837
+ context_management: z3.object({
838
+ applied_edits: z3.array(
839
+ z3.union([
840
+ z3.object({
841
+ type: z3.literal("clear_tool_uses_20250919"),
842
+ cleared_tool_uses: z3.number(),
843
+ cleared_input_tokens: z3.number()
768
844
  }),
769
- import_v42.z.object({
770
- type: import_v42.z.literal("clear_thinking_20251015"),
771
- cleared_thinking_turns: import_v42.z.number(),
772
- cleared_input_tokens: import_v42.z.number()
845
+ z3.object({
846
+ type: z3.literal("clear_thinking_20251015"),
847
+ cleared_thinking_turns: z3.number(),
848
+ cleared_input_tokens: z3.number()
773
849
  }),
774
- import_v42.z.object({
775
- type: import_v42.z.literal("compact_20260112")
850
+ z3.object({
851
+ type: z3.literal("compact_20260112")
776
852
  })
777
853
  ])
778
854
  )
779
855
  }).nullish()
780
856
  }),
781
- import_v42.z.object({
782
- type: import_v42.z.literal("message_stop")
857
+ z3.object({
858
+ type: z3.literal("message_stop")
783
859
  }),
784
- import_v42.z.object({
785
- type: import_v42.z.literal("ping")
860
+ z3.object({
861
+ type: z3.literal("ping")
786
862
  })
787
863
  ])
788
864
  )
789
865
  );
790
- var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
791
- () => (0, import_provider_utils2.zodSchema)(
792
- import_v42.z.object({
793
- signature: import_v42.z.string().optional(),
794
- redactedData: import_v42.z.string().optional()
866
+ var anthropicReasoningMetadataSchema = lazySchema3(
867
+ () => zodSchema3(
868
+ z3.object({
869
+ signature: z3.string().optional(),
870
+ redactedData: z3.string().optional()
795
871
  })
796
872
  )
797
873
  );
798
874
 
799
875
  // src/anthropic-messages-options.ts
800
- var import_v43 = require("zod/v4");
801
- var anthropicFilePartProviderOptions = import_v43.z.object({
876
+ import { z as z4 } from "zod/v4";
877
+ var anthropicFilePartProviderOptions = z4.object({
802
878
  /**
803
879
  * Citation configuration for this document.
804
880
  * When enabled, this document will generate citations in the response.
805
881
  */
806
- citations: import_v43.z.object({
882
+ citations: z4.object({
807
883
  /**
808
884
  * Enable citations for this document
809
885
  */
810
- enabled: import_v43.z.boolean()
886
+ enabled: z4.boolean()
811
887
  }).optional(),
812
888
  /**
813
889
  * Custom title for the document.
814
890
  * If not provided, the filename will be used.
815
891
  */
816
- title: import_v43.z.string().optional(),
892
+ title: z4.string().optional(),
817
893
  /**
818
894
  * Context about the document that will be passed to the model
819
895
  * but not used towards cited content.
820
896
  * Useful for storing document metadata as text or stringified JSON.
821
897
  */
822
- context: import_v43.z.string().optional()
898
+ context: z4.string().optional()
823
899
  });
824
- var anthropicLanguageModelOptions = import_v43.z.object({
900
+ var anthropicLanguageModelOptions = z4.object({
825
901
  /**
826
902
  * Whether to send reasoning to the model.
827
903
  *
828
904
  * This allows you to deactivate reasoning inputs for models that do not support them.
829
905
  */
830
- sendReasoning: import_v43.z.boolean().optional(),
906
+ sendReasoning: z4.boolean().optional(),
831
907
  /**
832
908
  * Determines how structured outputs are generated.
833
909
  *
@@ -835,52 +911,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
835
911
  * - `jsonTool`: Use a special 'json' tool to specify the structured output format.
836
912
  * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
837
913
  */
838
- structuredOutputMode: import_v43.z.enum(["outputFormat", "jsonTool", "auto"]).optional(),
914
+ structuredOutputMode: z4.enum(["outputFormat", "jsonTool", "auto"]).optional(),
839
915
  /**
840
916
  * Configuration for enabling Claude's extended thinking.
841
917
  *
842
918
  * When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
843
919
  * Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
844
920
  */
845
- thinking: import_v43.z.discriminatedUnion("type", [
846
- import_v43.z.object({
921
+ thinking: z4.discriminatedUnion("type", [
922
+ z4.object({
847
923
  /** for Sonnet 4.6, Opus 4.6, and newer models */
848
- type: import_v43.z.literal("adaptive")
924
+ type: z4.literal("adaptive"),
925
+ /**
926
+ * Controls whether thinking content is included in the response.
927
+ * - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
928
+ * - `"summarized"`: Thinking content is returned. Required to see reasoning output.
929
+ */
930
+ display: z4.enum(["omitted", "summarized"]).optional()
849
931
  }),
850
- import_v43.z.object({
932
+ z4.object({
851
933
  /** for models before Opus 4.6, except Sonnet 4.6 still supports it */
852
- type: import_v43.z.literal("enabled"),
853
- budgetTokens: import_v43.z.number().optional()
934
+ type: z4.literal("enabled"),
935
+ budgetTokens: z4.number().optional()
854
936
  }),
855
- import_v43.z.object({
856
- type: import_v43.z.literal("disabled")
937
+ z4.object({
938
+ type: z4.literal("disabled")
857
939
  })
858
940
  ]).optional(),
859
941
  /**
860
942
  * Whether to disable parallel function calling during tool use. Default is false.
861
943
  * When set to true, Claude will use at most one tool per response.
862
944
  */
863
- disableParallelToolUse: import_v43.z.boolean().optional(),
945
+ disableParallelToolUse: z4.boolean().optional(),
864
946
  /**
865
947
  * Cache control settings for this message.
866
948
  * See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
867
949
  */
868
- cacheControl: import_v43.z.object({
869
- type: import_v43.z.literal("ephemeral"),
870
- ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
950
+ cacheControl: z4.object({
951
+ type: z4.literal("ephemeral"),
952
+ ttl: z4.union([z4.literal("5m"), z4.literal("1h")]).optional()
953
+ }).optional(),
954
+ /**
955
+ * Metadata to include with the request.
956
+ *
957
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
958
+ */
959
+ metadata: z4.object({
960
+ /**
961
+ * An external identifier for the user associated with the request.
962
+ *
963
+ * Should be a UUID, hash value, or other opaque identifier.
964
+ * Must not contain PII (name, email, phone number, etc.).
965
+ */
966
+ userId: z4.string().optional()
871
967
  }).optional(),
872
968
  /**
873
969
  * MCP servers to be utilized in this request.
874
970
  */
875
- mcpServers: import_v43.z.array(
876
- import_v43.z.object({
877
- type: import_v43.z.literal("url"),
878
- name: import_v43.z.string(),
879
- url: import_v43.z.string(),
880
- authorizationToken: import_v43.z.string().nullish(),
881
- toolConfiguration: import_v43.z.object({
882
- enabled: import_v43.z.boolean().nullish(),
883
- allowedTools: import_v43.z.array(import_v43.z.string()).nullish()
971
+ mcpServers: z4.array(
972
+ z4.object({
973
+ type: z4.literal("url"),
974
+ name: z4.string(),
975
+ url: z4.string(),
976
+ authorizationToken: z4.string().nullish(),
977
+ toolConfiguration: z4.object({
978
+ enabled: z4.boolean().nullish(),
979
+ allowedTools: z4.array(z4.string()).nullish()
884
980
  }).nullish()
885
981
  })
886
982
  ).optional(),
@@ -889,14 +985,21 @@ var anthropicLanguageModelOptions = import_v43.z.object({
889
985
  * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
890
986
  * Requires code execution tool to be enabled.
891
987
  */
892
- container: import_v43.z.object({
893
- id: import_v43.z.string().optional(),
894
- skills: import_v43.z.array(
895
- import_v43.z.object({
896
- type: import_v43.z.union([import_v43.z.literal("anthropic"), import_v43.z.literal("custom")]),
897
- skillId: import_v43.z.string(),
898
- version: import_v43.z.string().optional()
899
- })
988
+ container: z4.object({
989
+ id: z4.string().optional(),
990
+ skills: z4.array(
991
+ z4.discriminatedUnion("type", [
992
+ z4.object({
993
+ type: z4.literal("anthropic"),
994
+ skillId: z4.string(),
995
+ version: z4.string().optional()
996
+ }),
997
+ z4.object({
998
+ type: z4.literal("custom"),
999
+ providerReference: z4.record(z4.string(), z4.string()),
1000
+ version: z4.string().optional()
1001
+ })
1002
+ ])
900
1003
  ).optional()
901
1004
  }).optional(),
902
1005
  /**
@@ -907,65 +1010,86 @@ var anthropicLanguageModelOptions = import_v43.z.object({
907
1010
  *
908
1011
  * @default true
909
1012
  */
910
- toolStreaming: import_v43.z.boolean().optional(),
1013
+ toolStreaming: z4.boolean().optional(),
911
1014
  /**
912
1015
  * @default 'high'
913
1016
  */
914
- effort: import_v43.z.enum(["low", "medium", "high", "max"]).optional(),
1017
+ effort: z4.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
1018
+ /**
1019
+ * Task budget for agentic turns. Informs the model of the total token budget
1020
+ * available for the current task, allowing it to prioritize work and wind down
1021
+ * gracefully as the budget is consumed.
1022
+ *
1023
+ * Advisory only — does not enforce a hard token limit.
1024
+ */
1025
+ taskBudget: z4.object({
1026
+ type: z4.literal("tokens"),
1027
+ total: z4.number().int().min(2e4),
1028
+ remaining: z4.number().int().min(0).optional()
1029
+ }).optional(),
915
1030
  /**
916
1031
  * Enable fast mode for faster inference (2.5x faster output token speeds).
917
1032
  * Only supported with claude-opus-4-6.
918
1033
  */
919
- speed: import_v43.z.enum(["fast", "standard"]).optional(),
1034
+ speed: z4.enum(["fast", "standard"]).optional(),
1035
+ /**
1036
+ * Controls where model inference runs for this request.
1037
+ *
1038
+ * - `"global"`: Inference may run in any available geography (default).
1039
+ * - `"us"`: Inference runs only in US-based infrastructure.
1040
+ *
1041
+ * See https://platform.claude.com/docs/en/build-with-claude/data-residency
1042
+ */
1043
+ inferenceGeo: z4.enum(["us", "global"]).optional(),
920
1044
  /**
921
1045
  * A set of beta features to enable.
922
1046
  * Allow a provider to receive the full `betas` set if it needs it.
923
1047
  */
924
- anthropicBeta: import_v43.z.array(import_v43.z.string()).optional(),
925
- contextManagement: import_v43.z.object({
926
- edits: import_v43.z.array(
927
- import_v43.z.discriminatedUnion("type", [
928
- import_v43.z.object({
929
- type: import_v43.z.literal("clear_tool_uses_20250919"),
930
- trigger: import_v43.z.discriminatedUnion("type", [
931
- import_v43.z.object({
932
- type: import_v43.z.literal("input_tokens"),
933
- value: import_v43.z.number()
1048
+ anthropicBeta: z4.array(z4.string()).optional(),
1049
+ contextManagement: z4.object({
1050
+ edits: z4.array(
1051
+ z4.discriminatedUnion("type", [
1052
+ z4.object({
1053
+ type: z4.literal("clear_tool_uses_20250919"),
1054
+ trigger: z4.discriminatedUnion("type", [
1055
+ z4.object({
1056
+ type: z4.literal("input_tokens"),
1057
+ value: z4.number()
934
1058
  }),
935
- import_v43.z.object({
936
- type: import_v43.z.literal("tool_uses"),
937
- value: import_v43.z.number()
1059
+ z4.object({
1060
+ type: z4.literal("tool_uses"),
1061
+ value: z4.number()
938
1062
  })
939
1063
  ]).optional(),
940
- keep: import_v43.z.object({
941
- type: import_v43.z.literal("tool_uses"),
942
- value: import_v43.z.number()
1064
+ keep: z4.object({
1065
+ type: z4.literal("tool_uses"),
1066
+ value: z4.number()
943
1067
  }).optional(),
944
- clearAtLeast: import_v43.z.object({
945
- type: import_v43.z.literal("input_tokens"),
946
- value: import_v43.z.number()
1068
+ clearAtLeast: z4.object({
1069
+ type: z4.literal("input_tokens"),
1070
+ value: z4.number()
947
1071
  }).optional(),
948
- clearToolInputs: import_v43.z.boolean().optional(),
949
- excludeTools: import_v43.z.array(import_v43.z.string()).optional()
1072
+ clearToolInputs: z4.boolean().optional(),
1073
+ excludeTools: z4.array(z4.string()).optional()
950
1074
  }),
951
- import_v43.z.object({
952
- type: import_v43.z.literal("clear_thinking_20251015"),
953
- keep: import_v43.z.union([
954
- import_v43.z.literal("all"),
955
- import_v43.z.object({
956
- type: import_v43.z.literal("thinking_turns"),
957
- value: import_v43.z.number()
1075
+ z4.object({
1076
+ type: z4.literal("clear_thinking_20251015"),
1077
+ keep: z4.union([
1078
+ z4.literal("all"),
1079
+ z4.object({
1080
+ type: z4.literal("thinking_turns"),
1081
+ value: z4.number()
958
1082
  })
959
1083
  ]).optional()
960
1084
  }),
961
- import_v43.z.object({
962
- type: import_v43.z.literal("compact_20260112"),
963
- trigger: import_v43.z.object({
964
- type: import_v43.z.literal("input_tokens"),
965
- value: import_v43.z.number()
1085
+ z4.object({
1086
+ type: z4.literal("compact_20260112"),
1087
+ trigger: z4.object({
1088
+ type: z4.literal("input_tokens"),
1089
+ value: z4.number()
966
1090
  }).optional(),
967
- pauseAfterCompaction: import_v43.z.boolean().optional(),
968
- instructions: import_v43.z.string().optional()
1091
+ pauseAfterCompaction: z4.boolean().optional(),
1092
+ instructions: z4.string().optional()
969
1093
  })
970
1094
  ])
971
1095
  )
@@ -973,7 +1097,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
973
1097
  });
974
1098
 
975
1099
  // src/anthropic-prepare-tools.ts
976
- var import_provider = require("@ai-sdk/provider");
1100
+ import {
1101
+ UnsupportedFunctionalityError
1102
+ } from "@ai-sdk/provider";
977
1103
 
978
1104
  // src/get-cache-control.ts
979
1105
  var MAX_CACHE_BREAKPOINTS = 4;
@@ -1018,31 +1144,31 @@ var CacheControlValidator = class {
1018
1144
  };
1019
1145
 
1020
1146
  // src/tool/text-editor_20250728.ts
1021
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
1022
- var import_v44 = require("zod/v4");
1023
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
1024
- var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
1025
- () => (0, import_provider_utils4.zodSchema)(
1026
- import_v44.z.object({
1027
- maxCharacters: import_v44.z.number().optional()
1147
+ import { createProviderToolFactory } from "@ai-sdk/provider-utils";
1148
+ import { z as z5 } from "zod/v4";
1149
+ import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
1150
+ var textEditor_20250728ArgsSchema = lazySchema4(
1151
+ () => zodSchema4(
1152
+ z5.object({
1153
+ maxCharacters: z5.number().optional()
1028
1154
  })
1029
1155
  )
1030
1156
  );
1031
- var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
1032
- () => (0, import_provider_utils4.zodSchema)(
1033
- import_v44.z.object({
1034
- command: import_v44.z.enum(["view", "create", "str_replace", "insert"]),
1035
- path: import_v44.z.string(),
1036
- file_text: import_v44.z.string().optional(),
1037
- insert_line: import_v44.z.number().int().optional(),
1038
- new_str: import_v44.z.string().optional(),
1039
- insert_text: import_v44.z.string().optional(),
1040
- old_str: import_v44.z.string().optional(),
1041
- view_range: import_v44.z.array(import_v44.z.number().int()).optional()
1157
+ var textEditor_20250728InputSchema = lazySchema4(
1158
+ () => zodSchema4(
1159
+ z5.object({
1160
+ command: z5.enum(["view", "create", "str_replace", "insert"]),
1161
+ path: z5.string(),
1162
+ file_text: z5.string().optional(),
1163
+ insert_line: z5.number().int().optional(),
1164
+ new_str: z5.string().optional(),
1165
+ insert_text: z5.string().optional(),
1166
+ old_str: z5.string().optional(),
1167
+ view_range: z5.array(z5.number().int()).optional()
1042
1168
  })
1043
1169
  )
1044
1170
  );
1045
- var factory = (0, import_provider_utils3.createProviderToolFactory)({
1171
+ var factory = createProviderToolFactory({
1046
1172
  id: "anthropic.text_editor_20250728",
1047
1173
  inputSchema: textEditor_20250728InputSchema
1048
1174
  });
@@ -1051,45 +1177,49 @@ var textEditor_20250728 = (args = {}) => {
1051
1177
  };
1052
1178
 
1053
1179
  // src/tool/web-search_20260209.ts
1054
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1055
- var import_v45 = require("zod/v4");
1056
- var webSearch_20260209ArgsSchema = (0, import_provider_utils5.lazySchema)(
1057
- () => (0, import_provider_utils5.zodSchema)(
1058
- import_v45.z.object({
1059
- maxUses: import_v45.z.number().optional(),
1060
- allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
1061
- blockedDomains: import_v45.z.array(import_v45.z.string()).optional(),
1062
- userLocation: import_v45.z.object({
1063
- type: import_v45.z.literal("approximate"),
1064
- city: import_v45.z.string().optional(),
1065
- region: import_v45.z.string().optional(),
1066
- country: import_v45.z.string().optional(),
1067
- timezone: import_v45.z.string().optional()
1180
+ import {
1181
+ createProviderToolFactoryWithOutputSchema,
1182
+ lazySchema as lazySchema5,
1183
+ zodSchema as zodSchema5
1184
+ } from "@ai-sdk/provider-utils";
1185
+ import { z as z6 } from "zod/v4";
1186
+ var webSearch_20260209ArgsSchema = lazySchema5(
1187
+ () => zodSchema5(
1188
+ z6.object({
1189
+ maxUses: z6.number().optional(),
1190
+ allowedDomains: z6.array(z6.string()).optional(),
1191
+ blockedDomains: z6.array(z6.string()).optional(),
1192
+ userLocation: z6.object({
1193
+ type: z6.literal("approximate"),
1194
+ city: z6.string().optional(),
1195
+ region: z6.string().optional(),
1196
+ country: z6.string().optional(),
1197
+ timezone: z6.string().optional()
1068
1198
  }).optional()
1069
1199
  })
1070
1200
  )
1071
1201
  );
1072
- var webSearch_20260209OutputSchema = (0, import_provider_utils5.lazySchema)(
1073
- () => (0, import_provider_utils5.zodSchema)(
1074
- import_v45.z.array(
1075
- import_v45.z.object({
1076
- url: import_v45.z.string(),
1077
- title: import_v45.z.string().nullable(),
1078
- pageAge: import_v45.z.string().nullable(),
1079
- encryptedContent: import_v45.z.string(),
1080
- type: import_v45.z.literal("web_search_result")
1202
+ var webSearch_20260209OutputSchema = lazySchema5(
1203
+ () => zodSchema5(
1204
+ z6.array(
1205
+ z6.object({
1206
+ url: z6.string(),
1207
+ title: z6.string().nullable(),
1208
+ pageAge: z6.string().nullable(),
1209
+ encryptedContent: z6.string(),
1210
+ type: z6.literal("web_search_result")
1081
1211
  })
1082
1212
  )
1083
1213
  )
1084
1214
  );
1085
- var webSearch_20260209InputSchema = (0, import_provider_utils5.lazySchema)(
1086
- () => (0, import_provider_utils5.zodSchema)(
1087
- import_v45.z.object({
1088
- query: import_v45.z.string()
1215
+ var webSearch_20260209InputSchema = lazySchema5(
1216
+ () => zodSchema5(
1217
+ z6.object({
1218
+ query: z6.string()
1089
1219
  })
1090
1220
  )
1091
1221
  );
1092
- var factory2 = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
1222
+ var factory2 = createProviderToolFactoryWithOutputSchema({
1093
1223
  id: "anthropic.web_search_20260209",
1094
1224
  inputSchema: webSearch_20260209InputSchema,
1095
1225
  outputSchema: webSearch_20260209OutputSchema,
@@ -1100,45 +1230,49 @@ var webSearch_20260209 = (args = {}) => {
1100
1230
  };
1101
1231
 
1102
1232
  // src/tool/web-search_20250305.ts
1103
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1104
- var import_v46 = require("zod/v4");
1105
- var webSearch_20250305ArgsSchema = (0, import_provider_utils6.lazySchema)(
1106
- () => (0, import_provider_utils6.zodSchema)(
1107
- import_v46.z.object({
1108
- maxUses: import_v46.z.number().optional(),
1109
- allowedDomains: import_v46.z.array(import_v46.z.string()).optional(),
1110
- blockedDomains: import_v46.z.array(import_v46.z.string()).optional(),
1111
- userLocation: import_v46.z.object({
1112
- type: import_v46.z.literal("approximate"),
1113
- city: import_v46.z.string().optional(),
1114
- region: import_v46.z.string().optional(),
1115
- country: import_v46.z.string().optional(),
1116
- timezone: import_v46.z.string().optional()
1233
+ import {
1234
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
1235
+ lazySchema as lazySchema6,
1236
+ zodSchema as zodSchema6
1237
+ } from "@ai-sdk/provider-utils";
1238
+ import { z as z7 } from "zod/v4";
1239
+ var webSearch_20250305ArgsSchema = lazySchema6(
1240
+ () => zodSchema6(
1241
+ z7.object({
1242
+ maxUses: z7.number().optional(),
1243
+ allowedDomains: z7.array(z7.string()).optional(),
1244
+ blockedDomains: z7.array(z7.string()).optional(),
1245
+ userLocation: z7.object({
1246
+ type: z7.literal("approximate"),
1247
+ city: z7.string().optional(),
1248
+ region: z7.string().optional(),
1249
+ country: z7.string().optional(),
1250
+ timezone: z7.string().optional()
1117
1251
  }).optional()
1118
1252
  })
1119
1253
  )
1120
1254
  );
1121
- var webSearch_20250305OutputSchema = (0, import_provider_utils6.lazySchema)(
1122
- () => (0, import_provider_utils6.zodSchema)(
1123
- import_v46.z.array(
1124
- import_v46.z.object({
1125
- url: import_v46.z.string(),
1126
- title: import_v46.z.string().nullable(),
1127
- pageAge: import_v46.z.string().nullable(),
1128
- encryptedContent: import_v46.z.string(),
1129
- type: import_v46.z.literal("web_search_result")
1255
+ var webSearch_20250305OutputSchema = lazySchema6(
1256
+ () => zodSchema6(
1257
+ z7.array(
1258
+ z7.object({
1259
+ url: z7.string(),
1260
+ title: z7.string().nullable(),
1261
+ pageAge: z7.string().nullable(),
1262
+ encryptedContent: z7.string(),
1263
+ type: z7.literal("web_search_result")
1130
1264
  })
1131
1265
  )
1132
1266
  )
1133
1267
  );
1134
- var webSearch_20250305InputSchema = (0, import_provider_utils6.lazySchema)(
1135
- () => (0, import_provider_utils6.zodSchema)(
1136
- import_v46.z.object({
1137
- query: import_v46.z.string()
1268
+ var webSearch_20250305InputSchema = lazySchema6(
1269
+ () => zodSchema6(
1270
+ z7.object({
1271
+ query: z7.string()
1138
1272
  })
1139
1273
  )
1140
1274
  );
1141
- var factory3 = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
1275
+ var factory3 = createProviderToolFactoryWithOutputSchema2({
1142
1276
  id: "anthropic.web_search_20250305",
1143
1277
  inputSchema: webSearch_20250305InputSchema,
1144
1278
  outputSchema: webSearch_20250305OutputSchema,
@@ -1149,53 +1283,57 @@ var webSearch_20250305 = (args = {}) => {
1149
1283
  };
1150
1284
 
1151
1285
  // src/tool/web-fetch-20260209.ts
1152
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1153
- var import_v47 = require("zod/v4");
1154
- var webFetch_20260209ArgsSchema = (0, import_provider_utils7.lazySchema)(
1155
- () => (0, import_provider_utils7.zodSchema)(
1156
- import_v47.z.object({
1157
- maxUses: import_v47.z.number().optional(),
1158
- allowedDomains: import_v47.z.array(import_v47.z.string()).optional(),
1159
- blockedDomains: import_v47.z.array(import_v47.z.string()).optional(),
1160
- citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
1161
- maxContentTokens: import_v47.z.number().optional()
1286
+ import {
1287
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
1288
+ lazySchema as lazySchema7,
1289
+ zodSchema as zodSchema7
1290
+ } from "@ai-sdk/provider-utils";
1291
+ import { z as z8 } from "zod/v4";
1292
+ var webFetch_20260209ArgsSchema = lazySchema7(
1293
+ () => zodSchema7(
1294
+ z8.object({
1295
+ maxUses: z8.number().optional(),
1296
+ allowedDomains: z8.array(z8.string()).optional(),
1297
+ blockedDomains: z8.array(z8.string()).optional(),
1298
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1299
+ maxContentTokens: z8.number().optional()
1162
1300
  })
1163
1301
  )
1164
1302
  );
1165
- var webFetch_20260209OutputSchema = (0, import_provider_utils7.lazySchema)(
1166
- () => (0, import_provider_utils7.zodSchema)(
1167
- import_v47.z.object({
1168
- type: import_v47.z.literal("web_fetch_result"),
1169
- url: import_v47.z.string(),
1170
- content: import_v47.z.object({
1171
- type: import_v47.z.literal("document"),
1172
- title: import_v47.z.string().nullable(),
1173
- citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
1174
- source: import_v47.z.union([
1175
- import_v47.z.object({
1176
- type: import_v47.z.literal("base64"),
1177
- mediaType: import_v47.z.literal("application/pdf"),
1178
- data: import_v47.z.string()
1303
+ var webFetch_20260209OutputSchema = lazySchema7(
1304
+ () => zodSchema7(
1305
+ z8.object({
1306
+ type: z8.literal("web_fetch_result"),
1307
+ url: z8.string(),
1308
+ content: z8.object({
1309
+ type: z8.literal("document"),
1310
+ title: z8.string().nullable(),
1311
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1312
+ source: z8.union([
1313
+ z8.object({
1314
+ type: z8.literal("base64"),
1315
+ mediaType: z8.literal("application/pdf"),
1316
+ data: z8.string()
1179
1317
  }),
1180
- import_v47.z.object({
1181
- type: import_v47.z.literal("text"),
1182
- mediaType: import_v47.z.literal("text/plain"),
1183
- data: import_v47.z.string()
1318
+ z8.object({
1319
+ type: z8.literal("text"),
1320
+ mediaType: z8.literal("text/plain"),
1321
+ data: z8.string()
1184
1322
  })
1185
1323
  ])
1186
1324
  }),
1187
- retrievedAt: import_v47.z.string().nullable()
1325
+ retrievedAt: z8.string().nullable()
1188
1326
  })
1189
1327
  )
1190
1328
  );
1191
- var webFetch_20260209InputSchema = (0, import_provider_utils7.lazySchema)(
1192
- () => (0, import_provider_utils7.zodSchema)(
1193
- import_v47.z.object({
1194
- url: import_v47.z.string()
1329
+ var webFetch_20260209InputSchema = lazySchema7(
1330
+ () => zodSchema7(
1331
+ z8.object({
1332
+ url: z8.string()
1195
1333
  })
1196
1334
  )
1197
1335
  );
1198
- var factory4 = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
1336
+ var factory4 = createProviderToolFactoryWithOutputSchema3({
1199
1337
  id: "anthropic.web_fetch_20260209",
1200
1338
  inputSchema: webFetch_20260209InputSchema,
1201
1339
  outputSchema: webFetch_20260209OutputSchema,
@@ -1206,53 +1344,57 @@ var webFetch_20260209 = (args = {}) => {
1206
1344
  };
1207
1345
 
1208
1346
  // src/tool/web-fetch-20250910.ts
1209
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1210
- var import_v48 = require("zod/v4");
1211
- var webFetch_20250910ArgsSchema = (0, import_provider_utils8.lazySchema)(
1212
- () => (0, import_provider_utils8.zodSchema)(
1213
- import_v48.z.object({
1214
- maxUses: import_v48.z.number().optional(),
1215
- allowedDomains: import_v48.z.array(import_v48.z.string()).optional(),
1216
- blockedDomains: import_v48.z.array(import_v48.z.string()).optional(),
1217
- citations: import_v48.z.object({ enabled: import_v48.z.boolean() }).optional(),
1218
- maxContentTokens: import_v48.z.number().optional()
1347
+ import {
1348
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
1349
+ lazySchema as lazySchema8,
1350
+ zodSchema as zodSchema8
1351
+ } from "@ai-sdk/provider-utils";
1352
+ import { z as z9 } from "zod/v4";
1353
+ var webFetch_20250910ArgsSchema = lazySchema8(
1354
+ () => zodSchema8(
1355
+ z9.object({
1356
+ maxUses: z9.number().optional(),
1357
+ allowedDomains: z9.array(z9.string()).optional(),
1358
+ blockedDomains: z9.array(z9.string()).optional(),
1359
+ citations: z9.object({ enabled: z9.boolean() }).optional(),
1360
+ maxContentTokens: z9.number().optional()
1219
1361
  })
1220
1362
  )
1221
1363
  );
1222
- var webFetch_20250910OutputSchema = (0, import_provider_utils8.lazySchema)(
1223
- () => (0, import_provider_utils8.zodSchema)(
1224
- import_v48.z.object({
1225
- type: import_v48.z.literal("web_fetch_result"),
1226
- url: import_v48.z.string(),
1227
- content: import_v48.z.object({
1228
- type: import_v48.z.literal("document"),
1229
- title: import_v48.z.string().nullable(),
1230
- citations: import_v48.z.object({ enabled: import_v48.z.boolean() }).optional(),
1231
- source: import_v48.z.union([
1232
- import_v48.z.object({
1233
- type: import_v48.z.literal("base64"),
1234
- mediaType: import_v48.z.literal("application/pdf"),
1235
- data: import_v48.z.string()
1364
+ var webFetch_20250910OutputSchema = lazySchema8(
1365
+ () => zodSchema8(
1366
+ z9.object({
1367
+ type: z9.literal("web_fetch_result"),
1368
+ url: z9.string(),
1369
+ content: z9.object({
1370
+ type: z9.literal("document"),
1371
+ title: z9.string().nullable(),
1372
+ citations: z9.object({ enabled: z9.boolean() }).optional(),
1373
+ source: z9.union([
1374
+ z9.object({
1375
+ type: z9.literal("base64"),
1376
+ mediaType: z9.literal("application/pdf"),
1377
+ data: z9.string()
1236
1378
  }),
1237
- import_v48.z.object({
1238
- type: import_v48.z.literal("text"),
1239
- mediaType: import_v48.z.literal("text/plain"),
1240
- data: import_v48.z.string()
1379
+ z9.object({
1380
+ type: z9.literal("text"),
1381
+ mediaType: z9.literal("text/plain"),
1382
+ data: z9.string()
1241
1383
  })
1242
1384
  ])
1243
1385
  }),
1244
- retrievedAt: import_v48.z.string().nullable()
1386
+ retrievedAt: z9.string().nullable()
1245
1387
  })
1246
1388
  )
1247
1389
  );
1248
- var webFetch_20250910InputSchema = (0, import_provider_utils8.lazySchema)(
1249
- () => (0, import_provider_utils8.zodSchema)(
1250
- import_v48.z.object({
1251
- url: import_v48.z.string()
1390
+ var webFetch_20250910InputSchema = lazySchema8(
1391
+ () => zodSchema8(
1392
+ z9.object({
1393
+ url: z9.string()
1252
1394
  })
1253
1395
  )
1254
1396
  );
1255
- var factory5 = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
1397
+ var factory5 = createProviderToolFactoryWithOutputSchema4({
1256
1398
  id: "anthropic.web_fetch_20250910",
1257
1399
  inputSchema: webFetch_20250910InputSchema,
1258
1400
  outputSchema: webFetch_20250910OutputSchema,
@@ -1263,13 +1405,14 @@ var webFetch_20250910 = (args = {}) => {
1263
1405
  };
1264
1406
 
1265
1407
  // src/anthropic-prepare-tools.ts
1266
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1408
+ import { validateTypes } from "@ai-sdk/provider-utils";
1267
1409
  async function prepareTools({
1268
1410
  tools,
1269
1411
  toolChoice,
1270
1412
  disableParallelToolUse,
1271
1413
  cacheControlValidator,
1272
- supportsStructuredOutput
1414
+ supportsStructuredOutput,
1415
+ supportsStrictTools
1273
1416
  }) {
1274
1417
  var _a;
1275
1418
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -1291,13 +1434,20 @@ async function prepareTools({
1291
1434
  const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
1292
1435
  const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
1293
1436
  const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
1437
+ if (!supportsStrictTools && tool.strict != null) {
1438
+ toolWarnings.push({
1439
+ type: "unsupported",
1440
+ feature: "strict",
1441
+ details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
1442
+ });
1443
+ }
1294
1444
  anthropicTools2.push({
1295
1445
  name: tool.name,
1296
1446
  description: tool.description,
1297
1447
  input_schema: tool.inputSchema,
1298
1448
  cache_control: cacheControl,
1299
1449
  ...eagerInputStreaming ? { eager_input_streaming: true } : {},
1300
- ...supportsStructuredOutput === true && tool.strict != null ? { strict: tool.strict } : {},
1450
+ ...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
1301
1451
  ...deferLoading != null ? { defer_loading: deferLoading } : {},
1302
1452
  ...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
1303
1453
  ...tool.inputExamples != null ? {
@@ -1405,7 +1555,7 @@ async function prepareTools({
1405
1555
  break;
1406
1556
  }
1407
1557
  case "anthropic.text_editor_20250728": {
1408
- const args = await (0, import_provider_utils9.validateTypes)({
1558
+ const args = await validateTypes({
1409
1559
  value: tool.args,
1410
1560
  schema: textEditor_20250728ArgsSchema
1411
1561
  });
@@ -1445,7 +1595,7 @@ async function prepareTools({
1445
1595
  }
1446
1596
  case "anthropic.web_fetch_20250910": {
1447
1597
  betas.add("web-fetch-2025-09-10");
1448
- const args = await (0, import_provider_utils9.validateTypes)({
1598
+ const args = await validateTypes({
1449
1599
  value: tool.args,
1450
1600
  schema: webFetch_20250910ArgsSchema
1451
1601
  });
@@ -1463,7 +1613,7 @@ async function prepareTools({
1463
1613
  }
1464
1614
  case "anthropic.web_fetch_20260209": {
1465
1615
  betas.add("code-execution-web-tools-2026-02-09");
1466
- const args = await (0, import_provider_utils9.validateTypes)({
1616
+ const args = await validateTypes({
1467
1617
  value: tool.args,
1468
1618
  schema: webFetch_20260209ArgsSchema
1469
1619
  });
@@ -1480,7 +1630,7 @@ async function prepareTools({
1480
1630
  break;
1481
1631
  }
1482
1632
  case "anthropic.web_search_20250305": {
1483
- const args = await (0, import_provider_utils9.validateTypes)({
1633
+ const args = await validateTypes({
1484
1634
  value: tool.args,
1485
1635
  schema: webSearch_20250305ArgsSchema
1486
1636
  });
@@ -1497,7 +1647,7 @@ async function prepareTools({
1497
1647
  }
1498
1648
  case "anthropic.web_search_20260209": {
1499
1649
  betas.add("code-execution-web-tools-2026-02-09");
1500
- const args = await (0, import_provider_utils9.validateTypes)({
1650
+ const args = await validateTypes({
1501
1651
  value: tool.args,
1502
1652
  schema: webSearch_20260209ArgsSchema
1503
1653
  });
@@ -1513,7 +1663,6 @@ async function prepareTools({
1513
1663
  break;
1514
1664
  }
1515
1665
  case "anthropic.tool_search_regex_20251119": {
1516
- betas.add("advanced-tool-use-2025-11-20");
1517
1666
  anthropicTools2.push({
1518
1667
  type: "tool_search_tool_regex_20251119",
1519
1668
  name: "tool_search_tool_regex"
@@ -1521,7 +1670,6 @@ async function prepareTools({
1521
1670
  break;
1522
1671
  }
1523
1672
  case "anthropic.tool_search_bm25_20251119": {
1524
- betas.add("advanced-tool-use-2025-11-20");
1525
1673
  anthropicTools2.push({
1526
1674
  type: "tool_search_tool_bm25_20251119",
1527
1675
  name: "tool_search_tool_bm25"
@@ -1592,7 +1740,7 @@ async function prepareTools({
1592
1740
  };
1593
1741
  default: {
1594
1742
  const _exhaustiveCheck = type;
1595
- throw new import_provider.UnsupportedFunctionalityError({
1743
+ throw new UnsupportedFunctionalityError({
1596
1744
  functionality: `tool choice type: ${_exhaustiveCheck}`
1597
1745
  });
1598
1746
  }
@@ -1640,36 +1788,50 @@ function convertAnthropicMessagesUsage({
1640
1788
  }
1641
1789
 
1642
1790
  // 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");
1791
+ import {
1792
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
1793
+ } from "@ai-sdk/provider";
1794
+ import {
1795
+ convertBase64ToUint8Array as convertBase64ToUint8Array2,
1796
+ convertToBase64,
1797
+ isProviderReference,
1798
+ parseProviderOptions,
1799
+ resolveProviderReference,
1800
+ validateTypes as validateTypes2,
1801
+ isNonNullable
1802
+ } from "@ai-sdk/provider-utils";
1645
1803
 
1646
1804
  // 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()
1805
+ import {
1806
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
1807
+ lazySchema as lazySchema9,
1808
+ zodSchema as zodSchema9
1809
+ } from "@ai-sdk/provider-utils";
1810
+ import { z as z10 } from "zod/v4";
1811
+ var codeExecution_20250522OutputSchema = lazySchema9(
1812
+ () => zodSchema9(
1813
+ z10.object({
1814
+ type: z10.literal("code_execution_result"),
1815
+ stdout: z10.string(),
1816
+ stderr: z10.string(),
1817
+ return_code: z10.number(),
1818
+ content: z10.array(
1819
+ z10.object({
1820
+ type: z10.literal("code_execution_output"),
1821
+ file_id: z10.string()
1660
1822
  })
1661
1823
  ).optional().default([])
1662
1824
  })
1663
1825
  )
1664
1826
  );
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()
1827
+ var codeExecution_20250522InputSchema = lazySchema9(
1828
+ () => zodSchema9(
1829
+ z10.object({
1830
+ code: z10.string()
1669
1831
  })
1670
1832
  )
1671
1833
  );
1672
- var factory6 = (0, import_provider_utils10.createProviderToolFactoryWithOutputSchema)({
1834
+ var factory6 = createProviderToolFactoryWithOutputSchema5({
1673
1835
  id: "anthropic.code_execution_20250522",
1674
1836
  inputSchema: codeExecution_20250522InputSchema,
1675
1837
  outputSchema: codeExecution_20250522OutputSchema
@@ -1679,102 +1841,106 @@ var codeExecution_20250522 = (args = {}) => {
1679
1841
  };
1680
1842
 
1681
1843
  // 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()
1844
+ import {
1845
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
1846
+ lazySchema as lazySchema10,
1847
+ zodSchema as zodSchema10
1848
+ } from "@ai-sdk/provider-utils";
1849
+ import { z as z11 } from "zod/v4";
1850
+ var codeExecution_20250825OutputSchema = lazySchema10(
1851
+ () => zodSchema10(
1852
+ z11.discriminatedUnion("type", [
1853
+ z11.object({
1854
+ type: z11.literal("code_execution_result"),
1855
+ stdout: z11.string(),
1856
+ stderr: z11.string(),
1857
+ return_code: z11.number(),
1858
+ content: z11.array(
1859
+ z11.object({
1860
+ type: z11.literal("code_execution_output"),
1861
+ file_id: z11.string()
1696
1862
  })
1697
1863
  ).optional().default([])
1698
1864
  }),
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()
1865
+ z11.object({
1866
+ type: z11.literal("bash_code_execution_result"),
1867
+ content: z11.array(
1868
+ z11.object({
1869
+ type: z11.literal("bash_code_execution_output"),
1870
+ file_id: z11.string()
1705
1871
  })
1706
1872
  ),
1707
- stdout: import_v410.z.string(),
1708
- stderr: import_v410.z.string(),
1709
- return_code: import_v410.z.number()
1873
+ stdout: z11.string(),
1874
+ stderr: z11.string(),
1875
+ return_code: z11.number()
1710
1876
  }),
1711
- import_v410.z.object({
1712
- type: import_v410.z.literal("bash_code_execution_tool_result_error"),
1713
- error_code: import_v410.z.string()
1877
+ z11.object({
1878
+ type: z11.literal("bash_code_execution_tool_result_error"),
1879
+ error_code: z11.string()
1714
1880
  }),
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()
1881
+ z11.object({
1882
+ type: z11.literal("text_editor_code_execution_tool_result_error"),
1883
+ error_code: z11.string()
1718
1884
  }),
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()
1885
+ z11.object({
1886
+ type: z11.literal("text_editor_code_execution_view_result"),
1887
+ content: z11.string(),
1888
+ file_type: z11.string(),
1889
+ num_lines: z11.number().nullable(),
1890
+ start_line: z11.number().nullable(),
1891
+ total_lines: z11.number().nullable()
1726
1892
  }),
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()
1893
+ z11.object({
1894
+ type: z11.literal("text_editor_code_execution_create_result"),
1895
+ is_file_update: z11.boolean()
1730
1896
  }),
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()
1897
+ z11.object({
1898
+ type: z11.literal("text_editor_code_execution_str_replace_result"),
1899
+ lines: z11.array(z11.string()).nullable(),
1900
+ new_lines: z11.number().nullable(),
1901
+ new_start: z11.number().nullable(),
1902
+ old_lines: z11.number().nullable(),
1903
+ old_start: z11.number().nullable()
1738
1904
  })
1739
1905
  ])
1740
1906
  )
1741
1907
  );
1742
- var codeExecution_20250825InputSchema = (0, import_provider_utils11.lazySchema)(
1743
- () => (0, import_provider_utils11.zodSchema)(
1744
- import_v410.z.discriminatedUnion("type", [
1908
+ var codeExecution_20250825InputSchema = lazySchema10(
1909
+ () => zodSchema10(
1910
+ z11.discriminatedUnion("type", [
1745
1911
  // 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()
1912
+ z11.object({
1913
+ type: z11.literal("programmatic-tool-call"),
1914
+ code: z11.string()
1749
1915
  }),
1750
- import_v410.z.object({
1751
- type: import_v410.z.literal("bash_code_execution"),
1752
- command: import_v410.z.string()
1916
+ z11.object({
1917
+ type: z11.literal("bash_code_execution"),
1918
+ command: z11.string()
1753
1919
  }),
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()
1920
+ z11.discriminatedUnion("command", [
1921
+ z11.object({
1922
+ type: z11.literal("text_editor_code_execution"),
1923
+ command: z11.literal("view"),
1924
+ path: z11.string()
1759
1925
  }),
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()
1926
+ z11.object({
1927
+ type: z11.literal("text_editor_code_execution"),
1928
+ command: z11.literal("create"),
1929
+ path: z11.string(),
1930
+ file_text: z11.string().nullish()
1765
1931
  }),
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()
1932
+ z11.object({
1933
+ type: z11.literal("text_editor_code_execution"),
1934
+ command: z11.literal("str_replace"),
1935
+ path: z11.string(),
1936
+ old_str: z11.string(),
1937
+ new_str: z11.string()
1772
1938
  })
1773
1939
  ])
1774
1940
  ])
1775
1941
  )
1776
1942
  );
1777
- var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
1943
+ var factory7 = createProviderToolFactoryWithOutputSchema6({
1778
1944
  id: "anthropic.code_execution_20250825",
1779
1945
  inputSchema: codeExecution_20250825InputSchema,
1780
1946
  outputSchema: codeExecution_20250825OutputSchema,
@@ -1788,113 +1954,117 @@ var codeExecution_20250825 = (args = {}) => {
1788
1954
  };
1789
1955
 
1790
1956
  // 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()
1957
+ import {
1958
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
1959
+ lazySchema as lazySchema11,
1960
+ zodSchema as zodSchema11
1961
+ } from "@ai-sdk/provider-utils";
1962
+ import { z as z12 } from "zod/v4";
1963
+ var codeExecution_20260120OutputSchema = lazySchema11(
1964
+ () => zodSchema11(
1965
+ z12.discriminatedUnion("type", [
1966
+ z12.object({
1967
+ type: z12.literal("code_execution_result"),
1968
+ stdout: z12.string(),
1969
+ stderr: z12.string(),
1970
+ return_code: z12.number(),
1971
+ content: z12.array(
1972
+ z12.object({
1973
+ type: z12.literal("code_execution_output"),
1974
+ file_id: z12.string()
1805
1975
  })
1806
1976
  ).optional().default([])
1807
1977
  }),
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()
1978
+ z12.object({
1979
+ type: z12.literal("encrypted_code_execution_result"),
1980
+ encrypted_stdout: z12.string(),
1981
+ stderr: z12.string(),
1982
+ return_code: z12.number(),
1983
+ content: z12.array(
1984
+ z12.object({
1985
+ type: z12.literal("code_execution_output"),
1986
+ file_id: z12.string()
1817
1987
  })
1818
1988
  ).optional().default([])
1819
1989
  }),
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()
1990
+ z12.object({
1991
+ type: z12.literal("bash_code_execution_result"),
1992
+ content: z12.array(
1993
+ z12.object({
1994
+ type: z12.literal("bash_code_execution_output"),
1995
+ file_id: z12.string()
1826
1996
  })
1827
1997
  ),
1828
- stdout: import_v411.z.string(),
1829
- stderr: import_v411.z.string(),
1830
- return_code: import_v411.z.number()
1998
+ stdout: z12.string(),
1999
+ stderr: z12.string(),
2000
+ return_code: z12.number()
1831
2001
  }),
1832
- import_v411.z.object({
1833
- type: import_v411.z.literal("bash_code_execution_tool_result_error"),
1834
- error_code: import_v411.z.string()
2002
+ z12.object({
2003
+ type: z12.literal("bash_code_execution_tool_result_error"),
2004
+ error_code: z12.string()
1835
2005
  }),
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()
2006
+ z12.object({
2007
+ type: z12.literal("text_editor_code_execution_tool_result_error"),
2008
+ error_code: z12.string()
1839
2009
  }),
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()
2010
+ z12.object({
2011
+ type: z12.literal("text_editor_code_execution_view_result"),
2012
+ content: z12.string(),
2013
+ file_type: z12.string(),
2014
+ num_lines: z12.number().nullable(),
2015
+ start_line: z12.number().nullable(),
2016
+ total_lines: z12.number().nullable()
1847
2017
  }),
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()
2018
+ z12.object({
2019
+ type: z12.literal("text_editor_code_execution_create_result"),
2020
+ is_file_update: z12.boolean()
1851
2021
  }),
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()
2022
+ z12.object({
2023
+ type: z12.literal("text_editor_code_execution_str_replace_result"),
2024
+ lines: z12.array(z12.string()).nullable(),
2025
+ new_lines: z12.number().nullable(),
2026
+ new_start: z12.number().nullable(),
2027
+ old_lines: z12.number().nullable(),
2028
+ old_start: z12.number().nullable()
1859
2029
  })
1860
2030
  ])
1861
2031
  )
1862
2032
  );
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()
2033
+ var codeExecution_20260120InputSchema = lazySchema11(
2034
+ () => zodSchema11(
2035
+ z12.discriminatedUnion("type", [
2036
+ z12.object({
2037
+ type: z12.literal("programmatic-tool-call"),
2038
+ code: z12.string()
1869
2039
  }),
1870
- import_v411.z.object({
1871
- type: import_v411.z.literal("bash_code_execution"),
1872
- command: import_v411.z.string()
2040
+ z12.object({
2041
+ type: z12.literal("bash_code_execution"),
2042
+ command: z12.string()
1873
2043
  }),
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()
2044
+ z12.discriminatedUnion("command", [
2045
+ z12.object({
2046
+ type: z12.literal("text_editor_code_execution"),
2047
+ command: z12.literal("view"),
2048
+ path: z12.string()
1879
2049
  }),
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()
2050
+ z12.object({
2051
+ type: z12.literal("text_editor_code_execution"),
2052
+ command: z12.literal("create"),
2053
+ path: z12.string(),
2054
+ file_text: z12.string().nullish()
1885
2055
  }),
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()
2056
+ z12.object({
2057
+ type: z12.literal("text_editor_code_execution"),
2058
+ command: z12.literal("str_replace"),
2059
+ path: z12.string(),
2060
+ old_str: z12.string(),
2061
+ new_str: z12.string()
1892
2062
  })
1893
2063
  ])
1894
2064
  ])
1895
2065
  )
1896
2066
  );
1897
- var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
2067
+ var factory8 = createProviderToolFactoryWithOutputSchema7({
1898
2068
  id: "anthropic.code_execution_20260120",
1899
2069
  inputSchema: codeExecution_20260120InputSchema,
1900
2070
  outputSchema: codeExecution_20260120OutputSchema,
@@ -1905,21 +2075,25 @@ var codeExecution_20260120 = (args = {}) => {
1905
2075
  };
1906
2076
 
1907
2077
  // 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()
2078
+ import {
2079
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
2080
+ lazySchema as lazySchema12,
2081
+ zodSchema as zodSchema12
2082
+ } from "@ai-sdk/provider-utils";
2083
+ import { z as z13 } from "zod/v4";
2084
+ var toolSearchRegex_20251119OutputSchema = lazySchema12(
2085
+ () => zodSchema12(
2086
+ z13.array(
2087
+ z13.object({
2088
+ type: z13.literal("tool_reference"),
2089
+ toolName: z13.string()
1916
2090
  })
1917
2091
  )
1918
2092
  )
1919
2093
  );
1920
- var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema)(
1921
- () => (0, import_provider_utils13.zodSchema)(
1922
- import_v412.z.object({
2094
+ var toolSearchRegex_20251119InputSchema = lazySchema12(
2095
+ () => zodSchema12(
2096
+ z13.object({
1923
2097
  /**
1924
2098
  * A regex pattern to search for tools.
1925
2099
  * Uses Python re.search() syntax. Maximum 200 characters.
@@ -1930,15 +2104,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
1930
2104
  * - "database.*query|query.*database" - OR patterns for flexibility
1931
2105
  * - "(?i)slack" - case-insensitive search
1932
2106
  */
1933
- pattern: import_v412.z.string(),
2107
+ pattern: z13.string(),
1934
2108
  /**
1935
2109
  * Maximum number of tools to return. Optional.
1936
2110
  */
1937
- limit: import_v412.z.number().optional()
2111
+ limit: z13.number().optional()
1938
2112
  })
1939
2113
  )
1940
2114
  );
1941
- var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
2115
+ var factory9 = createProviderToolFactoryWithOutputSchema8({
1942
2116
  id: "anthropic.tool_search_regex_20251119",
1943
2117
  inputSchema: toolSearchRegex_20251119InputSchema,
1944
2118
  outputSchema: toolSearchRegex_20251119OutputSchema,
@@ -1951,17 +2125,17 @@ var toolSearchRegex_20251119 = (args = {}) => {
1951
2125
  // src/convert-to-anthropic-messages-prompt.ts
1952
2126
  function convertToString(data) {
1953
2127
  if (typeof data === "string") {
1954
- return new TextDecoder().decode((0, import_provider_utils14.convertBase64ToUint8Array)(data));
2128
+ return new TextDecoder().decode(convertBase64ToUint8Array2(data));
1955
2129
  }
1956
2130
  if (data instanceof Uint8Array) {
1957
2131
  return new TextDecoder().decode(data);
1958
2132
  }
1959
2133
  if (data instanceof URL) {
1960
- throw new import_provider2.UnsupportedFunctionalityError({
2134
+ throw new UnsupportedFunctionalityError2({
1961
2135
  functionality: "URL-based text documents are not supported for citations"
1962
2136
  });
1963
2137
  }
1964
- throw new import_provider2.UnsupportedFunctionalityError({
2138
+ throw new UnsupportedFunctionalityError2({
1965
2139
  functionality: `unsupported data type for text documents: ${typeof data}`
1966
2140
  });
1967
2141
  }
@@ -1989,7 +2163,7 @@ async function convertToAnthropicMessagesPrompt({
1989
2163
  const messages = [];
1990
2164
  async function shouldEnableCitations(providerMetadata) {
1991
2165
  var _a2, _b2;
1992
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2166
+ const anthropicOptions = await parseProviderOptions({
1993
2167
  provider: "anthropic",
1994
2168
  providerOptions: providerMetadata,
1995
2169
  schema: anthropicFilePartProviderOptions
@@ -1997,7 +2171,7 @@ async function convertToAnthropicMessagesPrompt({
1997
2171
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
1998
2172
  }
1999
2173
  async function getDocumentMetadata(providerMetadata) {
2000
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2174
+ const anthropicOptions = await parseProviderOptions({
2001
2175
  provider: "anthropic",
2002
2176
  providerOptions: providerMetadata,
2003
2177
  schema: anthropicFilePartProviderOptions
@@ -2014,7 +2188,7 @@ async function convertToAnthropicMessagesPrompt({
2014
2188
  switch (type) {
2015
2189
  case "system": {
2016
2190
  if (system != null) {
2017
- throw new import_provider2.UnsupportedFunctionalityError({
2191
+ throw new UnsupportedFunctionalityError2({
2018
2192
  functionality: "Multiple system messages that are separated by user/assistant messages"
2019
2193
  });
2020
2194
  }
@@ -2054,7 +2228,26 @@ async function convertToAnthropicMessagesPrompt({
2054
2228
  break;
2055
2229
  }
2056
2230
  case "file": {
2057
- if (part.mediaType.startsWith("image/")) {
2231
+ if (isProviderReference(part.data)) {
2232
+ const fileId = resolveProviderReference({
2233
+ reference: part.data,
2234
+ provider: "anthropic"
2235
+ });
2236
+ betas.add("files-api-2025-04-14");
2237
+ if (part.mediaType.startsWith("image/")) {
2238
+ anthropicContent.push({
2239
+ type: "image",
2240
+ source: { type: "file", file_id: fileId },
2241
+ cache_control: cacheControl
2242
+ });
2243
+ } else {
2244
+ anthropicContent.push({
2245
+ type: "document",
2246
+ source: { type: "file", file_id: fileId },
2247
+ cache_control: cacheControl
2248
+ });
2249
+ }
2250
+ } else if (part.mediaType.startsWith("image/")) {
2058
2251
  anthropicContent.push({
2059
2252
  type: "image",
2060
2253
  source: isUrlData(part.data) ? {
@@ -2063,7 +2256,7 @@ async function convertToAnthropicMessagesPrompt({
2063
2256
  } : {
2064
2257
  type: "base64",
2065
2258
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
2066
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2259
+ data: convertToBase64(part.data)
2067
2260
  },
2068
2261
  cache_control: cacheControl
2069
2262
  });
@@ -2083,7 +2276,7 @@ async function convertToAnthropicMessagesPrompt({
2083
2276
  } : {
2084
2277
  type: "base64",
2085
2278
  media_type: "application/pdf",
2086
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2279
+ data: convertToBase64(part.data)
2087
2280
  },
2088
2281
  title: (_b = metadata.title) != null ? _b : part.filename,
2089
2282
  ...metadata.context && { context: metadata.context },
@@ -2117,7 +2310,7 @@ async function convertToAnthropicMessagesPrompt({
2117
2310
  cache_control: cacheControl
2118
2311
  });
2119
2312
  } else {
2120
- throw new import_provider2.UnsupportedFunctionalityError({
2313
+ throw new UnsupportedFunctionalityError2({
2121
2314
  functionality: `media type: ${part.mediaType}`
2122
2315
  });
2123
2316
  }
@@ -2153,26 +2346,16 @@ async function convertToAnthropicMessagesPrompt({
2153
2346
  type: "text",
2154
2347
  text: contentPart.text
2155
2348
  };
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
2349
  case "file-url": {
2350
+ if (contentPart.mediaType.startsWith("image/")) {
2351
+ return {
2352
+ type: "image",
2353
+ source: {
2354
+ type: "url",
2355
+ url: contentPart.url
2356
+ }
2357
+ };
2358
+ }
2176
2359
  return {
2177
2360
  type: "document",
2178
2361
  source: {
@@ -2182,6 +2365,16 @@ async function convertToAnthropicMessagesPrompt({
2182
2365
  };
2183
2366
  }
2184
2367
  case "file-data": {
2368
+ if (contentPart.mediaType.startsWith("image/")) {
2369
+ return {
2370
+ type: "image",
2371
+ source: {
2372
+ type: "base64",
2373
+ media_type: contentPart.mediaType,
2374
+ data: contentPart.data
2375
+ }
2376
+ };
2377
+ }
2185
2378
  if (contentPart.mediaType === "application/pdf") {
2186
2379
  betas.add("pdfs-2024-09-25");
2187
2380
  return {
@@ -2221,7 +2414,7 @@ async function convertToAnthropicMessagesPrompt({
2221
2414
  return void 0;
2222
2415
  }
2223
2416
  }
2224
- }).filter(import_provider_utils14.isNonNullable);
2417
+ }).filter(isNonNullable);
2225
2418
  break;
2226
2419
  case "text":
2227
2420
  case "error-text":
@@ -2297,7 +2490,7 @@ async function convertToAnthropicMessagesPrompt({
2297
2490
  }
2298
2491
  case "reasoning": {
2299
2492
  if (sendReasoning) {
2300
- const reasoningMetadata = await (0, import_provider_utils14.parseProviderOptions)({
2493
+ const reasoningMetadata = await parseProviderOptions({
2301
2494
  provider: "anthropic",
2302
2495
  providerOptions: part.providerOptions,
2303
2496
  schema: anthropicReasoningMetadataSchema
@@ -2503,7 +2696,7 @@ async function convertToAnthropicMessagesPrompt({
2503
2696
  break;
2504
2697
  }
2505
2698
  if (output.value.type === "code_execution_result") {
2506
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2699
+ const codeExecutionOutput = await validateTypes2({
2507
2700
  value: output.value,
2508
2701
  schema: codeExecution_20250522OutputSchema
2509
2702
  });
@@ -2520,7 +2713,7 @@ async function convertToAnthropicMessagesPrompt({
2520
2713
  cache_control: cacheControl
2521
2714
  });
2522
2715
  } else if (output.value.type === "encrypted_code_execution_result") {
2523
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2716
+ const codeExecutionOutput = await validateTypes2({
2524
2717
  value: output.value,
2525
2718
  schema: codeExecution_20260120OutputSchema
2526
2719
  });
@@ -2539,7 +2732,7 @@ async function convertToAnthropicMessagesPrompt({
2539
2732
  });
2540
2733
  }
2541
2734
  } else {
2542
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2735
+ const codeExecutionOutput = await validateTypes2({
2543
2736
  value: output.value,
2544
2737
  schema: codeExecution_20250825OutputSchema
2545
2738
  });
@@ -2608,7 +2801,7 @@ async function convertToAnthropicMessagesPrompt({
2608
2801
  });
2609
2802
  break;
2610
2803
  }
2611
- const webFetchOutput = await (0, import_provider_utils14.validateTypes)({
2804
+ const webFetchOutput = await validateTypes2({
2612
2805
  value: output.value,
2613
2806
  schema: webFetch_20250910OutputSchema
2614
2807
  });
@@ -2643,7 +2836,7 @@ async function convertToAnthropicMessagesPrompt({
2643
2836
  });
2644
2837
  break;
2645
2838
  }
2646
- const webSearchOutput = await (0, import_provider_utils14.validateTypes)({
2839
+ const webSearchOutput = await validateTypes2({
2647
2840
  value: output.value,
2648
2841
  schema: webSearch_20250305OutputSchema
2649
2842
  });
@@ -2670,7 +2863,7 @@ async function convertToAnthropicMessagesPrompt({
2670
2863
  });
2671
2864
  break;
2672
2865
  }
2673
- const toolSearchOutput = await (0, import_provider_utils14.validateTypes)({
2866
+ const toolSearchOutput = await validateTypes2({
2674
2867
  value: output.value,
2675
2868
  schema: toolSearchRegex_20251119OutputSchema
2676
2869
  });
@@ -2828,13 +3021,22 @@ function createCitationSource(citation, citationDocuments, generateId3) {
2828
3021
  }
2829
3022
  };
2830
3023
  }
2831
- var AnthropicMessagesLanguageModel = class {
3024
+ var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
2832
3025
  constructor(modelId, config) {
2833
3026
  this.specificationVersion = "v4";
2834
3027
  var _a;
2835
3028
  this.modelId = modelId;
2836
3029
  this.config = config;
2837
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils15.generateId;
3030
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
3031
+ }
3032
+ static [WORKFLOW_SERIALIZE](model) {
3033
+ return serializeModelOptions({
3034
+ modelId: model.modelId,
3035
+ config: model.config
3036
+ });
3037
+ }
3038
+ static [WORKFLOW_DESERIALIZE](options) {
3039
+ return new _AnthropicMessagesLanguageModel(options.modelId, options.config);
2838
3040
  }
2839
3041
  supportsUrl(url) {
2840
3042
  return url.protocol === "https:";
@@ -2869,10 +3071,11 @@ var AnthropicMessagesLanguageModel = class {
2869
3071
  seed,
2870
3072
  tools,
2871
3073
  toolChoice,
3074
+ reasoning,
2872
3075
  providerOptions,
2873
3076
  stream
2874
3077
  }) {
2875
- var _a, _b, _c, _d, _e, _f, _g;
3078
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2876
3079
  const warnings = [];
2877
3080
  if (frequencyPenalty != null) {
2878
3081
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2908,12 +3111,12 @@ var AnthropicMessagesLanguageModel = class {
2908
3111
  }
2909
3112
  }
2910
3113
  const providerOptionsName = this.providerOptionsName;
2911
- const canonicalOptions = await (0, import_provider_utils15.parseProviderOptions)({
3114
+ const canonicalOptions = await parseProviderOptions2({
2912
3115
  provider: "anthropic",
2913
3116
  providerOptions,
2914
3117
  schema: anthropicLanguageModelOptions
2915
3118
  });
2916
- const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils15.parseProviderOptions)({
3119
+ const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
2917
3120
  provider: providerOptionsName,
2918
3121
  providerOptions,
2919
3122
  schema: anthropicLanguageModelOptions
@@ -2927,10 +3130,41 @@ var AnthropicMessagesLanguageModel = class {
2927
3130
  const {
2928
3131
  maxOutputTokens: maxOutputTokensForModel,
2929
3132
  supportsStructuredOutput: modelSupportsStructuredOutput,
3133
+ supportsAdaptiveThinking,
3134
+ rejectsSamplingParameters,
3135
+ supportsXhighEffort,
2930
3136
  isKnownModel
2931
3137
  } = getModelCapabilities(this.modelId);
3138
+ if (rejectsSamplingParameters) {
3139
+ if (temperature != null) {
3140
+ warnings.push({
3141
+ type: "unsupported",
3142
+ feature: "temperature",
3143
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
3144
+ });
3145
+ temperature = void 0;
3146
+ }
3147
+ if (topK != null) {
3148
+ warnings.push({
3149
+ type: "unsupported",
3150
+ feature: "topK",
3151
+ details: `topK is not supported by ${this.modelId} and will be ignored`
3152
+ });
3153
+ topK = void 0;
3154
+ }
3155
+ if (topP != null) {
3156
+ warnings.push({
3157
+ type: "unsupported",
3158
+ feature: "topP",
3159
+ details: `topP is not supported by ${this.modelId} and will be ignored`
3160
+ });
3161
+ topP = void 0;
3162
+ }
3163
+ }
3164
+ const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2932
3165
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2933
- const structureOutputMode = (_b = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b : "auto";
3166
+ const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
3167
+ const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
2934
3168
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2935
3169
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
2936
3170
  type: "function",
@@ -2940,7 +3174,7 @@ var AnthropicMessagesLanguageModel = class {
2940
3174
  } : void 0;
2941
3175
  const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
2942
3176
  const cacheControlValidator = new CacheControlValidator();
2943
- const toolNameMapping = (0, import_provider_utils15.createToolNameMapping)({
3177
+ const toolNameMapping = createToolNameMapping({
2944
3178
  tools,
2945
3179
  providerToolNames: {
2946
3180
  "anthropic.code_execution_20250522": "code_execution",
@@ -2965,14 +3199,32 @@ var AnthropicMessagesLanguageModel = class {
2965
3199
  });
2966
3200
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
2967
3201
  prompt,
2968
- sendReasoning: (_c = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _c : true,
3202
+ sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
2969
3203
  warnings,
2970
3204
  cacheControlValidator,
2971
3205
  toolNameMapping
2972
3206
  });
2973
- const thinkingType = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.type;
3207
+ if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
3208
+ const reasoningConfig = resolveAnthropicReasoningConfig({
3209
+ reasoning,
3210
+ supportsAdaptiveThinking,
3211
+ supportsXhighEffort,
3212
+ maxOutputTokensForModel,
3213
+ warnings
3214
+ });
3215
+ if (reasoningConfig != null) {
3216
+ if (anthropicOptions.thinking == null) {
3217
+ anthropicOptions.thinking = reasoningConfig.thinking;
3218
+ }
3219
+ if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
3220
+ anthropicOptions.effort = reasoningConfig.effort;
3221
+ }
3222
+ }
3223
+ }
3224
+ const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
2974
3225
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
2975
- let thinkingBudget = thinkingType === "enabled" ? (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.budgetTokens : void 0;
3226
+ let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
3227
+ const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
2976
3228
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
2977
3229
  const baseArgs = {
2978
3230
  // model id:
@@ -2987,14 +3239,24 @@ var AnthropicMessagesLanguageModel = class {
2987
3239
  ...isThinking && {
2988
3240
  thinking: {
2989
3241
  type: thinkingType,
2990
- ...thinkingBudget != null && { budget_tokens: thinkingBudget }
3242
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget },
3243
+ ...thinkingDisplay != null && { display: thinkingDisplay }
2991
3244
  }
2992
3245
  },
2993
- ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3246
+ ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
2994
3247
  output_config: {
2995
3248
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
2996
3249
  effort: anthropicOptions.effort
2997
3250
  },
3251
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
3252
+ task_budget: {
3253
+ type: anthropicOptions.taskBudget.type,
3254
+ total: anthropicOptions.taskBudget.total,
3255
+ ...anthropicOptions.taskBudget.remaining != null && {
3256
+ remaining: anthropicOptions.taskBudget.remaining
3257
+ }
3258
+ }
3259
+ },
2998
3260
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2999
3261
  format: {
3000
3262
  type: "json_schema",
@@ -3006,9 +3268,15 @@ var AnthropicMessagesLanguageModel = class {
3006
3268
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
3007
3269
  speed: anthropicOptions.speed
3008
3270
  },
3271
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3272
+ inference_geo: anthropicOptions.inferenceGeo
3273
+ },
3009
3274
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3010
3275
  cache_control: anthropicOptions.cacheControl
3011
3276
  },
3277
+ ...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
3278
+ metadata: { user_id: anthropicOptions.metadata.userId }
3279
+ },
3012
3280
  // mcp servers:
3013
3281
  ...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
3014
3282
  mcp_servers: anthropicOptions.mcpServers.map((server) => ({
@@ -3030,7 +3298,10 @@ var AnthropicMessagesLanguageModel = class {
3030
3298
  id: anthropicOptions.container.id,
3031
3299
  skills: anthropicOptions.container.skills.map((skill) => ({
3032
3300
  type: skill.type,
3033
- skill_id: skill.skillId,
3301
+ skill_id: skill.type === "custom" ? resolveProviderReference2({
3302
+ reference: skill.providerReference,
3303
+ provider: "anthropic"
3304
+ }) : skill.skillId,
3034
3305
  version: skill.version
3035
3306
  }))
3036
3307
  }
@@ -3132,7 +3403,7 @@ var AnthropicMessagesLanguageModel = class {
3132
3403
  }
3133
3404
  baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
3134
3405
  } else {
3135
- if (topP != null && temperature != null) {
3406
+ if (isAnthropicModel && topP != null && temperature != null) {
3136
3407
  warnings.push({
3137
3408
  type: "unsupported",
3138
3409
  feature: "topP",
@@ -3176,10 +3447,13 @@ var AnthropicMessagesLanguageModel = class {
3176
3447
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
3177
3448
  betas.add("effort-2025-11-24");
3178
3449
  }
3450
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
3451
+ betas.add("task-budgets-2026-03-13");
3452
+ }
3179
3453
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3180
3454
  betas.add("fast-mode-2026-02-01");
3181
3455
  }
3182
- if (stream && ((_f = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _f : true)) {
3456
+ if (stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true)) {
3183
3457
  betas.add("fine-grained-tool-streaming-2025-05-14");
3184
3458
  }
3185
3459
  const {
@@ -3193,13 +3467,15 @@ var AnthropicMessagesLanguageModel = class {
3193
3467
  toolChoice: { type: "required" },
3194
3468
  disableParallelToolUse: true,
3195
3469
  cacheControlValidator,
3196
- supportsStructuredOutput: false
3470
+ supportsStructuredOutput: false,
3471
+ supportsStrictTools
3197
3472
  } : {
3198
3473
  tools: tools != null ? tools : [],
3199
3474
  toolChoice,
3200
3475
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3201
3476
  cacheControlValidator,
3202
- supportsStructuredOutput
3477
+ supportsStructuredOutput,
3478
+ supportsStrictTools
3203
3479
  }
3204
3480
  );
3205
3481
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3216,7 +3492,7 @@ var AnthropicMessagesLanguageModel = class {
3216
3492
  ...betas,
3217
3493
  ...toolsBetas,
3218
3494
  ...userSuppliedBetas,
3219
- ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
3495
+ ...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
3220
3496
  ]),
3221
3497
  usesJsonResponseTool: jsonResponseTool != null,
3222
3498
  toolNameMapping,
@@ -3228,16 +3504,16 @@ var AnthropicMessagesLanguageModel = class {
3228
3504
  betas,
3229
3505
  headers
3230
3506
  }) {
3231
- return (0, import_provider_utils15.combineHeaders)(
3232
- await (0, import_provider_utils15.resolve)(this.config.headers),
3507
+ return combineHeaders2(
3508
+ this.config.headers ? await resolve(this.config.headers) : void 0,
3233
3509
  headers,
3234
3510
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
3235
3511
  );
3236
3512
  }
3237
3513
  async getBetasFromHeaders(requestHeaders) {
3238
3514
  var _a, _b;
3239
- const configHeaders = await (0, import_provider_utils15.resolve)(this.config.headers);
3240
- const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
3515
+ const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
3516
+ const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
3241
3517
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
3242
3518
  return new Set(
3243
3519
  [
@@ -3302,12 +3578,12 @@ var AnthropicMessagesLanguageModel = class {
3302
3578
  responseHeaders,
3303
3579
  value: response,
3304
3580
  rawValue: rawResponse
3305
- } = await (0, import_provider_utils15.postJsonToApi)({
3581
+ } = await postJsonToApi({
3306
3582
  url: this.buildRequestUrl(false),
3307
3583
  headers: await this.getHeaders({ betas, headers: options.headers }),
3308
3584
  body: this.transformRequestBody(args, betas),
3309
3585
  failedResponseHandler: anthropicFailedResponseHandler,
3310
- successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3586
+ successfulResponseHandler: createJsonResponseHandler2(
3311
3587
  anthropicMessagesResponseSchema
3312
3588
  ),
3313
3589
  abortSignal: options.abortSignal,
@@ -3701,6 +3977,7 @@ var AnthropicMessagesLanguageModel = class {
3701
3977
  };
3702
3978
  }
3703
3979
  async doStream(options) {
3980
+ "use step";
3704
3981
  var _a, _b;
3705
3982
  const {
3706
3983
  args: body,
@@ -3722,12 +3999,12 @@ var AnthropicMessagesLanguageModel = class {
3722
3999
  body.tools
3723
4000
  );
3724
4001
  const url = this.buildRequestUrl(true);
3725
- const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
4002
+ const { responseHeaders, value: response } = await postJsonToApi({
3726
4003
  url,
3727
4004
  headers: await this.getHeaders({ betas, headers: options.headers }),
3728
4005
  body: this.transformRequestBody(body, betas),
3729
4006
  failedResponseHandler: anthropicFailedResponseHandler,
3730
- successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
4007
+ successfulResponseHandler: createEventSourceResponseHandler(
3731
4008
  anthropicMessagesChunkSchema
3732
4009
  ),
3733
4010
  abortSignal: options.abortSignal,
@@ -4452,7 +4729,7 @@ var AnthropicMessagesLanguageModel = class {
4452
4729
  }
4453
4730
  if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
4454
4731
  const error = result.value.error;
4455
- throw new import_provider3.APICallError({
4732
+ throw new APICallError({
4456
4733
  message: error.message,
4457
4734
  url,
4458
4735
  requestBodyValues: body,
@@ -4475,46 +4752,76 @@ var AnthropicMessagesLanguageModel = class {
4475
4752
  }
4476
4753
  };
4477
4754
  function getModelCapabilities(modelId) {
4478
- if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4755
+ if (modelId.includes("claude-opus-4-7")) {
4756
+ return {
4757
+ maxOutputTokens: 128e3,
4758
+ supportsStructuredOutput: true,
4759
+ supportsAdaptiveThinking: true,
4760
+ rejectsSamplingParameters: true,
4761
+ supportsXhighEffort: true,
4762
+ isKnownModel: true
4763
+ };
4764
+ } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4479
4765
  return {
4480
4766
  maxOutputTokens: 128e3,
4481
4767
  supportsStructuredOutput: true,
4768
+ supportsAdaptiveThinking: true,
4769
+ rejectsSamplingParameters: false,
4770
+ supportsXhighEffort: false,
4482
4771
  isKnownModel: true
4483
4772
  };
4484
4773
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
4485
4774
  return {
4486
4775
  maxOutputTokens: 64e3,
4487
4776
  supportsStructuredOutput: true,
4777
+ supportsAdaptiveThinking: false,
4778
+ rejectsSamplingParameters: false,
4779
+ supportsXhighEffort: false,
4488
4780
  isKnownModel: true
4489
4781
  };
4490
4782
  } else if (modelId.includes("claude-opus-4-1")) {
4491
4783
  return {
4492
4784
  maxOutputTokens: 32e3,
4493
4785
  supportsStructuredOutput: true,
4786
+ supportsAdaptiveThinking: false,
4787
+ rejectsSamplingParameters: false,
4788
+ supportsXhighEffort: false,
4494
4789
  isKnownModel: true
4495
4790
  };
4496
4791
  } else if (modelId.includes("claude-sonnet-4-")) {
4497
4792
  return {
4498
4793
  maxOutputTokens: 64e3,
4499
4794
  supportsStructuredOutput: false,
4795
+ supportsAdaptiveThinking: false,
4796
+ rejectsSamplingParameters: false,
4797
+ supportsXhighEffort: false,
4500
4798
  isKnownModel: true
4501
4799
  };
4502
4800
  } else if (modelId.includes("claude-opus-4-")) {
4503
4801
  return {
4504
4802
  maxOutputTokens: 32e3,
4505
4803
  supportsStructuredOutput: false,
4804
+ supportsAdaptiveThinking: false,
4805
+ rejectsSamplingParameters: false,
4806
+ supportsXhighEffort: false,
4506
4807
  isKnownModel: true
4507
4808
  };
4508
4809
  } else if (modelId.includes("claude-3-haiku")) {
4509
4810
  return {
4510
4811
  maxOutputTokens: 4096,
4511
4812
  supportsStructuredOutput: false,
4813
+ supportsAdaptiveThinking: false,
4814
+ rejectsSamplingParameters: false,
4815
+ supportsXhighEffort: false,
4512
4816
  isKnownModel: true
4513
4817
  };
4514
4818
  } else {
4515
4819
  return {
4516
4820
  maxOutputTokens: 4096,
4517
4821
  supportsStructuredOutput: false,
4822
+ supportsAdaptiveThinking: false,
4823
+ rejectsSamplingParameters: false,
4824
+ supportsXhighEffort: false,
4518
4825
  isKnownModel: false
4519
4826
  };
4520
4827
  }
@@ -4537,6 +4844,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
4537
4844
  }
4538
4845
  return hasWebTool20260209 && !hasCodeExecutionTool;
4539
4846
  }
4847
+ function resolveAnthropicReasoningConfig({
4848
+ reasoning,
4849
+ supportsAdaptiveThinking,
4850
+ supportsXhighEffort,
4851
+ maxOutputTokensForModel,
4852
+ warnings
4853
+ }) {
4854
+ if (!isCustomReasoning(reasoning)) {
4855
+ return void 0;
4856
+ }
4857
+ if (reasoning === "none") {
4858
+ return { thinking: { type: "disabled" } };
4859
+ }
4860
+ if (supportsAdaptiveThinking) {
4861
+ const effort = mapReasoningToProviderEffort({
4862
+ reasoning,
4863
+ effortMap: {
4864
+ minimal: "low",
4865
+ low: "low",
4866
+ medium: "medium",
4867
+ high: "high",
4868
+ xhigh: supportsXhighEffort ? "xhigh" : "max"
4869
+ },
4870
+ warnings
4871
+ });
4872
+ return { thinking: { type: "adaptive" }, effort };
4873
+ }
4874
+ const budgetTokens = mapReasoningToProviderBudget({
4875
+ reasoning,
4876
+ maxOutputTokens: maxOutputTokensForModel,
4877
+ maxReasoningBudget: maxOutputTokensForModel,
4878
+ warnings
4879
+ });
4880
+ if (budgetTokens == null) {
4881
+ return void 0;
4882
+ }
4883
+ return { thinking: { type: "enabled", budgetTokens } };
4884
+ }
4540
4885
  function mapAnthropicResponseContextManagement(contextManagement) {
4541
4886
  return contextManagement ? {
4542
4887
  appliedEdits: contextManagement.applied_edits.map((edit) => {
@@ -4564,44 +4909,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
4564
4909
  }
4565
4910
 
4566
4911
  // src/tool/bash_20241022.ts
4567
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
4568
- var import_v413 = require("zod/v4");
4569
- var bash_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
4570
- () => (0, import_provider_utils16.zodSchema)(
4571
- import_v413.z.object({
4572
- command: import_v413.z.string(),
4573
- restart: import_v413.z.boolean().optional()
4912
+ import {
4913
+ createProviderToolFactory as createProviderToolFactory2,
4914
+ lazySchema as lazySchema13,
4915
+ zodSchema as zodSchema13
4916
+ } from "@ai-sdk/provider-utils";
4917
+ import { z as z14 } from "zod/v4";
4918
+ var bash_20241022InputSchema = lazySchema13(
4919
+ () => zodSchema13(
4920
+ z14.object({
4921
+ command: z14.string(),
4922
+ restart: z14.boolean().optional()
4574
4923
  })
4575
4924
  )
4576
4925
  );
4577
- var bash_20241022 = (0, import_provider_utils16.createProviderToolFactory)({
4926
+ var bash_20241022 = createProviderToolFactory2({
4578
4927
  id: "anthropic.bash_20241022",
4579
4928
  inputSchema: bash_20241022InputSchema
4580
4929
  });
4581
4930
 
4582
4931
  // src/tool/bash_20250124.ts
4583
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
4584
- var import_v414 = require("zod/v4");
4585
- var bash_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
4586
- () => (0, import_provider_utils17.zodSchema)(
4587
- import_v414.z.object({
4588
- command: import_v414.z.string(),
4589
- restart: import_v414.z.boolean().optional()
4932
+ import {
4933
+ createProviderToolFactory as createProviderToolFactory3,
4934
+ lazySchema as lazySchema14,
4935
+ zodSchema as zodSchema14
4936
+ } from "@ai-sdk/provider-utils";
4937
+ import { z as z15 } from "zod/v4";
4938
+ var bash_20250124InputSchema = lazySchema14(
4939
+ () => zodSchema14(
4940
+ z15.object({
4941
+ command: z15.string(),
4942
+ restart: z15.boolean().optional()
4590
4943
  })
4591
4944
  )
4592
4945
  );
4593
- var bash_20250124 = (0, import_provider_utils17.createProviderToolFactory)({
4946
+ var bash_20250124 = createProviderToolFactory3({
4594
4947
  id: "anthropic.bash_20250124",
4595
4948
  inputSchema: bash_20250124InputSchema
4596
4949
  });
4597
4950
 
4598
4951
  // src/tool/computer_20241022.ts
4599
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
4600
- var import_v415 = require("zod/v4");
4601
- var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4602
- () => (0, import_provider_utils18.zodSchema)(
4603
- import_v415.z.object({
4604
- action: import_v415.z.enum([
4952
+ import {
4953
+ createProviderToolFactory as createProviderToolFactory4,
4954
+ lazySchema as lazySchema15,
4955
+ zodSchema as zodSchema15
4956
+ } from "@ai-sdk/provider-utils";
4957
+ import { z as z16 } from "zod/v4";
4958
+ var computer_20241022InputSchema = lazySchema15(
4959
+ () => zodSchema15(
4960
+ z16.object({
4961
+ action: z16.enum([
4605
4962
  "key",
4606
4963
  "type",
4607
4964
  "mouse_move",
@@ -4613,23 +4970,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4613
4970
  "screenshot",
4614
4971
  "cursor_position"
4615
4972
  ]),
4616
- coordinate: import_v415.z.array(import_v415.z.number().int()).optional(),
4617
- text: import_v415.z.string().optional()
4973
+ coordinate: z16.array(z16.number().int()).optional(),
4974
+ text: z16.string().optional()
4618
4975
  })
4619
4976
  )
4620
4977
  );
4621
- var computer_20241022 = (0, import_provider_utils18.createProviderToolFactory)({
4978
+ var computer_20241022 = createProviderToolFactory4({
4622
4979
  id: "anthropic.computer_20241022",
4623
4980
  inputSchema: computer_20241022InputSchema
4624
4981
  });
4625
4982
 
4626
4983
  // src/tool/computer_20250124.ts
4627
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
4628
- var import_v416 = require("zod/v4");
4629
- var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4630
- () => (0, import_provider_utils19.zodSchema)(
4631
- import_v416.z.object({
4632
- action: import_v416.z.enum([
4984
+ import {
4985
+ createProviderToolFactory as createProviderToolFactory5,
4986
+ lazySchema as lazySchema16,
4987
+ zodSchema as zodSchema16
4988
+ } from "@ai-sdk/provider-utils";
4989
+ import { z as z17 } from "zod/v4";
4990
+ var computer_20250124InputSchema = lazySchema16(
4991
+ () => zodSchema16(
4992
+ z17.object({
4993
+ action: z17.enum([
4633
4994
  "key",
4634
4995
  "hold_key",
4635
4996
  "type",
@@ -4647,27 +5008,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4647
5008
  "wait",
4648
5009
  "screenshot"
4649
5010
  ]),
4650
- coordinate: import_v416.z.tuple([import_v416.z.number().int(), import_v416.z.number().int()]).optional(),
4651
- duration: import_v416.z.number().optional(),
4652
- scroll_amount: import_v416.z.number().optional(),
4653
- scroll_direction: import_v416.z.enum(["up", "down", "left", "right"]).optional(),
4654
- start_coordinate: import_v416.z.tuple([import_v416.z.number().int(), import_v416.z.number().int()]).optional(),
4655
- text: import_v416.z.string().optional()
5011
+ coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5012
+ duration: z17.number().optional(),
5013
+ scroll_amount: z17.number().optional(),
5014
+ scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
5015
+ start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5016
+ text: z17.string().optional()
4656
5017
  })
4657
5018
  )
4658
5019
  );
4659
- var computer_20250124 = (0, import_provider_utils19.createProviderToolFactory)({
5020
+ var computer_20250124 = createProviderToolFactory5({
4660
5021
  id: "anthropic.computer_20250124",
4661
5022
  inputSchema: computer_20250124InputSchema
4662
5023
  });
4663
5024
 
4664
5025
  // src/tool/computer_20251124.ts
4665
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
4666
- var import_v417 = require("zod/v4");
4667
- var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4668
- () => (0, import_provider_utils20.zodSchema)(
4669
- import_v417.z.object({
4670
- action: import_v417.z.enum([
5026
+ import {
5027
+ createProviderToolFactory as createProviderToolFactory6,
5028
+ lazySchema as lazySchema17,
5029
+ zodSchema as zodSchema17
5030
+ } from "@ai-sdk/provider-utils";
5031
+ import { z as z18 } from "zod/v4";
5032
+ var computer_20251124InputSchema = lazySchema17(
5033
+ () => zodSchema17(
5034
+ z18.object({
5035
+ action: z18.enum([
4671
5036
  "key",
4672
5037
  "hold_key",
4673
5038
  "type",
@@ -4686,166 +5051,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4686
5051
  "screenshot",
4687
5052
  "zoom"
4688
5053
  ]),
4689
- coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
4690
- duration: import_v417.z.number().optional(),
4691
- region: import_v417.z.tuple([
4692
- import_v417.z.number().int(),
4693
- import_v417.z.number().int(),
4694
- import_v417.z.number().int(),
4695
- import_v417.z.number().int()
5054
+ coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
5055
+ duration: z18.number().optional(),
5056
+ region: z18.tuple([
5057
+ z18.number().int(),
5058
+ z18.number().int(),
5059
+ z18.number().int(),
5060
+ z18.number().int()
4696
5061
  ]).optional(),
4697
- scroll_amount: import_v417.z.number().optional(),
4698
- scroll_direction: import_v417.z.enum(["up", "down", "left", "right"]).optional(),
4699
- start_coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
4700
- text: import_v417.z.string().optional()
5062
+ scroll_amount: z18.number().optional(),
5063
+ scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
5064
+ start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
5065
+ text: z18.string().optional()
4701
5066
  })
4702
5067
  )
4703
5068
  );
4704
- var computer_20251124 = (0, import_provider_utils20.createProviderToolFactory)({
5069
+ var computer_20251124 = createProviderToolFactory6({
4705
5070
  id: "anthropic.computer_20251124",
4706
5071
  inputSchema: computer_20251124InputSchema
4707
5072
  });
4708
5073
 
4709
5074
  // src/tool/memory_20250818.ts
4710
- var import_provider_utils21 = require("@ai-sdk/provider-utils");
4711
- var import_v418 = require("zod/v4");
4712
- var memory_20250818InputSchema = (0, import_provider_utils21.lazySchema)(
4713
- () => (0, import_provider_utils21.zodSchema)(
4714
- import_v418.z.discriminatedUnion("command", [
4715
- import_v418.z.object({
4716
- command: import_v418.z.literal("view"),
4717
- path: import_v418.z.string(),
4718
- view_range: import_v418.z.tuple([import_v418.z.number(), import_v418.z.number()]).optional()
5075
+ import {
5076
+ createProviderToolFactory as createProviderToolFactory7,
5077
+ lazySchema as lazySchema18,
5078
+ zodSchema as zodSchema18
5079
+ } from "@ai-sdk/provider-utils";
5080
+ import { z as z19 } from "zod/v4";
5081
+ var memory_20250818InputSchema = lazySchema18(
5082
+ () => zodSchema18(
5083
+ z19.discriminatedUnion("command", [
5084
+ z19.object({
5085
+ command: z19.literal("view"),
5086
+ path: z19.string(),
5087
+ view_range: z19.tuple([z19.number(), z19.number()]).optional()
4719
5088
  }),
4720
- import_v418.z.object({
4721
- command: import_v418.z.literal("create"),
4722
- path: import_v418.z.string(),
4723
- file_text: import_v418.z.string()
5089
+ z19.object({
5090
+ command: z19.literal("create"),
5091
+ path: z19.string(),
5092
+ file_text: z19.string()
4724
5093
  }),
4725
- import_v418.z.object({
4726
- command: import_v418.z.literal("str_replace"),
4727
- path: import_v418.z.string(),
4728
- old_str: import_v418.z.string(),
4729
- new_str: import_v418.z.string()
5094
+ z19.object({
5095
+ command: z19.literal("str_replace"),
5096
+ path: z19.string(),
5097
+ old_str: z19.string(),
5098
+ new_str: z19.string()
4730
5099
  }),
4731
- import_v418.z.object({
4732
- command: import_v418.z.literal("insert"),
4733
- path: import_v418.z.string(),
4734
- insert_line: import_v418.z.number(),
4735
- insert_text: import_v418.z.string()
5100
+ z19.object({
5101
+ command: z19.literal("insert"),
5102
+ path: z19.string(),
5103
+ insert_line: z19.number(),
5104
+ insert_text: z19.string()
4736
5105
  }),
4737
- import_v418.z.object({
4738
- command: import_v418.z.literal("delete"),
4739
- path: import_v418.z.string()
5106
+ z19.object({
5107
+ command: z19.literal("delete"),
5108
+ path: z19.string()
4740
5109
  }),
4741
- import_v418.z.object({
4742
- command: import_v418.z.literal("rename"),
4743
- old_path: import_v418.z.string(),
4744
- new_path: import_v418.z.string()
5110
+ z19.object({
5111
+ command: z19.literal("rename"),
5112
+ old_path: z19.string(),
5113
+ new_path: z19.string()
4745
5114
  })
4746
5115
  ])
4747
5116
  )
4748
5117
  );
4749
- var memory_20250818 = (0, import_provider_utils21.createProviderToolFactory)({
5118
+ var memory_20250818 = createProviderToolFactory7({
4750
5119
  id: "anthropic.memory_20250818",
4751
5120
  inputSchema: memory_20250818InputSchema
4752
5121
  });
4753
5122
 
4754
5123
  // src/tool/text-editor_20241022.ts
4755
- var import_provider_utils22 = require("@ai-sdk/provider-utils");
4756
- var import_v419 = require("zod/v4");
4757
- var textEditor_20241022InputSchema = (0, import_provider_utils22.lazySchema)(
4758
- () => (0, import_provider_utils22.zodSchema)(
4759
- import_v419.z.object({
4760
- command: import_v419.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
4761
- path: import_v419.z.string(),
4762
- file_text: import_v419.z.string().optional(),
4763
- insert_line: import_v419.z.number().int().optional(),
4764
- new_str: import_v419.z.string().optional(),
4765
- insert_text: import_v419.z.string().optional(),
4766
- old_str: import_v419.z.string().optional(),
4767
- view_range: import_v419.z.array(import_v419.z.number().int()).optional()
5124
+ import {
5125
+ createProviderToolFactory as createProviderToolFactory8,
5126
+ lazySchema as lazySchema19,
5127
+ zodSchema as zodSchema19
5128
+ } from "@ai-sdk/provider-utils";
5129
+ import { z as z20 } from "zod/v4";
5130
+ var textEditor_20241022InputSchema = lazySchema19(
5131
+ () => zodSchema19(
5132
+ z20.object({
5133
+ command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5134
+ path: z20.string(),
5135
+ file_text: z20.string().optional(),
5136
+ insert_line: z20.number().int().optional(),
5137
+ new_str: z20.string().optional(),
5138
+ insert_text: z20.string().optional(),
5139
+ old_str: z20.string().optional(),
5140
+ view_range: z20.array(z20.number().int()).optional()
4768
5141
  })
4769
5142
  )
4770
5143
  );
4771
- var textEditor_20241022 = (0, import_provider_utils22.createProviderToolFactory)({
5144
+ var textEditor_20241022 = createProviderToolFactory8({
4772
5145
  id: "anthropic.text_editor_20241022",
4773
5146
  inputSchema: textEditor_20241022InputSchema
4774
5147
  });
4775
5148
 
4776
5149
  // src/tool/text-editor_20250124.ts
4777
- var import_provider_utils23 = require("@ai-sdk/provider-utils");
4778
- var import_v420 = require("zod/v4");
4779
- var textEditor_20250124InputSchema = (0, import_provider_utils23.lazySchema)(
4780
- () => (0, import_provider_utils23.zodSchema)(
4781
- import_v420.z.object({
4782
- command: import_v420.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
4783
- path: import_v420.z.string(),
4784
- file_text: import_v420.z.string().optional(),
4785
- insert_line: import_v420.z.number().int().optional(),
4786
- new_str: import_v420.z.string().optional(),
4787
- insert_text: import_v420.z.string().optional(),
4788
- old_str: import_v420.z.string().optional(),
4789
- view_range: import_v420.z.array(import_v420.z.number().int()).optional()
5150
+ import {
5151
+ createProviderToolFactory as createProviderToolFactory9,
5152
+ lazySchema as lazySchema20,
5153
+ zodSchema as zodSchema20
5154
+ } from "@ai-sdk/provider-utils";
5155
+ import { z as z21 } from "zod/v4";
5156
+ var textEditor_20250124InputSchema = lazySchema20(
5157
+ () => zodSchema20(
5158
+ z21.object({
5159
+ command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5160
+ path: z21.string(),
5161
+ file_text: z21.string().optional(),
5162
+ insert_line: z21.number().int().optional(),
5163
+ new_str: z21.string().optional(),
5164
+ insert_text: z21.string().optional(),
5165
+ old_str: z21.string().optional(),
5166
+ view_range: z21.array(z21.number().int()).optional()
4790
5167
  })
4791
5168
  )
4792
5169
  );
4793
- var textEditor_20250124 = (0, import_provider_utils23.createProviderToolFactory)({
5170
+ var textEditor_20250124 = createProviderToolFactory9({
4794
5171
  id: "anthropic.text_editor_20250124",
4795
5172
  inputSchema: textEditor_20250124InputSchema
4796
5173
  });
4797
5174
 
4798
5175
  // src/tool/text-editor_20250429.ts
4799
- var import_provider_utils24 = require("@ai-sdk/provider-utils");
4800
- var import_v421 = require("zod/v4");
4801
- var textEditor_20250429InputSchema = (0, import_provider_utils24.lazySchema)(
4802
- () => (0, import_provider_utils24.zodSchema)(
4803
- import_v421.z.object({
4804
- command: import_v421.z.enum(["view", "create", "str_replace", "insert"]),
4805
- path: import_v421.z.string(),
4806
- file_text: import_v421.z.string().optional(),
4807
- insert_line: import_v421.z.number().int().optional(),
4808
- new_str: import_v421.z.string().optional(),
4809
- insert_text: import_v421.z.string().optional(),
4810
- old_str: import_v421.z.string().optional(),
4811
- view_range: import_v421.z.array(import_v421.z.number().int()).optional()
5176
+ import {
5177
+ createProviderToolFactory as createProviderToolFactory10,
5178
+ lazySchema as lazySchema21,
5179
+ zodSchema as zodSchema21
5180
+ } from "@ai-sdk/provider-utils";
5181
+ import { z as z22 } from "zod/v4";
5182
+ var textEditor_20250429InputSchema = lazySchema21(
5183
+ () => zodSchema21(
5184
+ z22.object({
5185
+ command: z22.enum(["view", "create", "str_replace", "insert"]),
5186
+ path: z22.string(),
5187
+ file_text: z22.string().optional(),
5188
+ insert_line: z22.number().int().optional(),
5189
+ new_str: z22.string().optional(),
5190
+ insert_text: z22.string().optional(),
5191
+ old_str: z22.string().optional(),
5192
+ view_range: z22.array(z22.number().int()).optional()
4812
5193
  })
4813
5194
  )
4814
5195
  );
4815
- var textEditor_20250429 = (0, import_provider_utils24.createProviderToolFactory)({
5196
+ var textEditor_20250429 = createProviderToolFactory10({
4816
5197
  id: "anthropic.text_editor_20250429",
4817
5198
  inputSchema: textEditor_20250429InputSchema
4818
5199
  });
4819
5200
 
4820
5201
  // src/tool/tool-search-bm25_20251119.ts
4821
- var import_provider_utils25 = require("@ai-sdk/provider-utils");
4822
- var import_v422 = require("zod/v4");
4823
- var toolSearchBm25_20251119OutputSchema = (0, import_provider_utils25.lazySchema)(
4824
- () => (0, import_provider_utils25.zodSchema)(
4825
- import_v422.z.array(
4826
- import_v422.z.object({
4827
- type: import_v422.z.literal("tool_reference"),
4828
- toolName: import_v422.z.string()
5202
+ import {
5203
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
5204
+ lazySchema as lazySchema22,
5205
+ zodSchema as zodSchema22
5206
+ } from "@ai-sdk/provider-utils";
5207
+ import { z as z23 } from "zod/v4";
5208
+ var toolSearchBm25_20251119OutputSchema = lazySchema22(
5209
+ () => zodSchema22(
5210
+ z23.array(
5211
+ z23.object({
5212
+ type: z23.literal("tool_reference"),
5213
+ toolName: z23.string()
4829
5214
  })
4830
5215
  )
4831
5216
  )
4832
5217
  );
4833
- var toolSearchBm25_20251119InputSchema = (0, import_provider_utils25.lazySchema)(
4834
- () => (0, import_provider_utils25.zodSchema)(
4835
- import_v422.z.object({
5218
+ var toolSearchBm25_20251119InputSchema = lazySchema22(
5219
+ () => zodSchema22(
5220
+ z23.object({
4836
5221
  /**
4837
5222
  * A natural language query to search for tools.
4838
5223
  * Claude will use BM25 text search to find relevant tools.
4839
5224
  */
4840
- query: import_v422.z.string(),
5225
+ query: z23.string(),
4841
5226
  /**
4842
5227
  * Maximum number of tools to return. Optional.
4843
5228
  */
4844
- limit: import_v422.z.number().optional()
5229
+ limit: z23.number().optional()
4845
5230
  })
4846
5231
  )
4847
5232
  );
4848
- var factory10 = (0, import_provider_utils25.createProviderToolFactoryWithOutputSchema)({
5233
+ var factory10 = createProviderToolFactoryWithOutputSchema9({
4849
5234
  id: "anthropic.tool_search_bm25_20251119",
4850
5235
  inputSchema: toolSearchBm25_20251119InputSchema,
4851
5236
  outputSchema: toolSearchBm25_20251119OutputSchema,
@@ -5057,31 +5442,163 @@ var anthropicTools = {
5057
5442
  toolSearchBm25_20251119
5058
5443
  };
5059
5444
 
5445
+ // src/skills/anthropic-skills.ts
5446
+ import {
5447
+ combineHeaders as combineHeaders3,
5448
+ convertBase64ToUint8Array as convertBase64ToUint8Array3,
5449
+ createJsonResponseHandler as createJsonResponseHandler3,
5450
+ getFromApi,
5451
+ postFormDataToApi as postFormDataToApi2,
5452
+ resolve as resolve2
5453
+ } from "@ai-sdk/provider-utils";
5454
+
5455
+ // src/skills/anthropic-skills-api.ts
5456
+ import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
5457
+ import { z as z24 } from "zod/v4";
5458
+ var anthropicSkillResponseSchema = lazySchema23(
5459
+ () => zodSchema23(
5460
+ z24.object({
5461
+ id: z24.string(),
5462
+ display_title: z24.string().nullish(),
5463
+ name: z24.string().nullish(),
5464
+ description: z24.string().nullish(),
5465
+ latest_version: z24.string().nullish(),
5466
+ source: z24.string(),
5467
+ created_at: z24.string(),
5468
+ updated_at: z24.string()
5469
+ })
5470
+ )
5471
+ );
5472
+ var anthropicSkillVersionListResponseSchema = lazySchema23(
5473
+ () => zodSchema23(
5474
+ z24.object({
5475
+ data: z24.array(
5476
+ z24.object({
5477
+ version: z24.string()
5478
+ })
5479
+ )
5480
+ })
5481
+ )
5482
+ );
5483
+ var anthropicSkillVersionResponseSchema = lazySchema23(
5484
+ () => zodSchema23(
5485
+ z24.object({
5486
+ type: z24.string(),
5487
+ skill_id: z24.string(),
5488
+ name: z24.string().nullish(),
5489
+ description: z24.string().nullish()
5490
+ })
5491
+ )
5492
+ );
5493
+
5494
+ // src/skills/anthropic-skills.ts
5495
+ var AnthropicSkills = class {
5496
+ constructor(config) {
5497
+ this.config = config;
5498
+ this.specificationVersion = "v4";
5499
+ }
5500
+ get provider() {
5501
+ return this.config.provider;
5502
+ }
5503
+ async getHeaders() {
5504
+ return combineHeaders3(await resolve2(this.config.headers), {
5505
+ "anthropic-beta": "skills-2025-10-02"
5506
+ });
5507
+ }
5508
+ async fetchVersionMetadata({
5509
+ skillId,
5510
+ version,
5511
+ headers
5512
+ }) {
5513
+ const { value: versionResponse } = await getFromApi({
5514
+ url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
5515
+ headers,
5516
+ failedResponseHandler: anthropicFailedResponseHandler,
5517
+ successfulResponseHandler: createJsonResponseHandler3(
5518
+ anthropicSkillVersionResponseSchema
5519
+ ),
5520
+ fetch: this.config.fetch
5521
+ });
5522
+ return {
5523
+ ...versionResponse.name != null ? { name: versionResponse.name } : {},
5524
+ ...versionResponse.description != null ? { description: versionResponse.description } : {}
5525
+ };
5526
+ }
5527
+ async uploadSkill(params) {
5528
+ var _a, _b;
5529
+ const warnings = [];
5530
+ const formData = new FormData();
5531
+ if (params.displayTitle != null) {
5532
+ formData.append("display_title", params.displayTitle);
5533
+ }
5534
+ for (const file of params.files) {
5535
+ const content = typeof file.content === "string" ? convertBase64ToUint8Array3(file.content) : file.content;
5536
+ formData.append("files[]", new Blob([content]), file.path);
5537
+ }
5538
+ const headers = await this.getHeaders();
5539
+ const { value: response } = await postFormDataToApi2({
5540
+ url: `${this.config.baseURL}/skills`,
5541
+ headers,
5542
+ formData,
5543
+ failedResponseHandler: anthropicFailedResponseHandler,
5544
+ successfulResponseHandler: createJsonResponseHandler3(
5545
+ anthropicSkillResponseSchema
5546
+ ),
5547
+ fetch: this.config.fetch
5548
+ });
5549
+ const versionMetadata = response.latest_version != null ? await this.fetchVersionMetadata({
5550
+ skillId: response.id,
5551
+ version: response.latest_version,
5552
+ headers
5553
+ }) : {};
5554
+ const name = (_a = versionMetadata.name) != null ? _a : response.name;
5555
+ const description = (_b = versionMetadata.description) != null ? _b : response.description;
5556
+ return {
5557
+ providerReference: { anthropic: response.id },
5558
+ ...response.display_title != null ? { displayTitle: response.display_title } : {},
5559
+ ...name != null ? { name } : {},
5560
+ ...description != null ? { description } : {},
5561
+ ...response.latest_version != null ? { latestVersion: response.latest_version } : {},
5562
+ providerMetadata: {
5563
+ anthropic: {
5564
+ ...response.source != null ? { source: response.source } : {},
5565
+ ...response.created_at != null ? { createdAt: response.created_at } : {},
5566
+ ...response.updated_at != null ? { updatedAt: response.updated_at } : {}
5567
+ }
5568
+ },
5569
+ warnings
5570
+ };
5571
+ }
5572
+ };
5573
+
5574
+ // src/version.ts
5575
+ var VERSION = true ? "4.0.0-beta.31" : "0.0.0-test";
5576
+
5060
5577
  // src/anthropic-provider.ts
5061
5578
  function createAnthropic(options = {}) {
5062
5579
  var _a, _b;
5063
- const baseURL = (_a = (0, import_provider_utils26.withoutTrailingSlash)(
5064
- (0, import_provider_utils26.loadOptionalSetting)({
5580
+ const baseURL = (_a = withoutTrailingSlash(
5581
+ loadOptionalSetting({
5065
5582
  settingValue: options.baseURL,
5066
5583
  environmentVariableName: "ANTHROPIC_BASE_URL"
5067
5584
  })
5068
5585
  )) != null ? _a : "https://api.anthropic.com/v1";
5069
5586
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
5070
5587
  if (options.apiKey && options.authToken) {
5071
- throw new import_provider4.InvalidArgumentError({
5588
+ throw new InvalidArgumentError({
5072
5589
  argument: "apiKey/authToken",
5073
5590
  message: "Both apiKey and authToken were provided. Please use only one authentication method."
5074
5591
  });
5075
5592
  }
5076
5593
  const getHeaders = () => {
5077
5594
  const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
5078
- "x-api-key": (0, import_provider_utils26.loadApiKey)({
5595
+ "x-api-key": loadApiKey({
5079
5596
  apiKey: options.apiKey,
5080
5597
  environmentVariableName: "ANTHROPIC_API_KEY",
5081
5598
  description: "Anthropic"
5082
5599
  })
5083
5600
  };
5084
- return (0, import_provider_utils26.withUserAgentSuffix)(
5601
+ return withUserAgentSuffix(
5085
5602
  {
5086
5603
  "anthropic-version": "2023-06-01",
5087
5604
  ...authHeaders,
@@ -5097,13 +5614,19 @@ function createAnthropic(options = {}) {
5097
5614
  baseURL,
5098
5615
  headers: getHeaders,
5099
5616
  fetch: options.fetch,
5100
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils26.generateId,
5617
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
5101
5618
  supportedUrls: () => ({
5102
5619
  "image/*": [/^https?:\/\/.*$/],
5103
5620
  "application/pdf": [/^https?:\/\/.*$/]
5104
5621
  })
5105
5622
  });
5106
5623
  };
5624
+ const createSkills = () => new AnthropicSkills({
5625
+ provider: `${providerName.replace(".messages", "")}.skills`,
5626
+ baseURL,
5627
+ headers: getHeaders,
5628
+ fetch: options.fetch
5629
+ });
5107
5630
  const provider = function(modelId) {
5108
5631
  if (new.target) {
5109
5632
  throw new Error(
@@ -5117,12 +5640,19 @@ function createAnthropic(options = {}) {
5117
5640
  provider.chat = createChatModel;
5118
5641
  provider.messages = createChatModel;
5119
5642
  provider.embeddingModel = (modelId) => {
5120
- throw new import_provider4.NoSuchModelError({ modelId, modelType: "embeddingModel" });
5643
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
5121
5644
  };
5122
5645
  provider.textEmbeddingModel = provider.embeddingModel;
5123
5646
  provider.imageModel = (modelId) => {
5124
- throw new import_provider4.NoSuchModelError({ modelId, modelType: "imageModel" });
5647
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
5125
5648
  };
5649
+ provider.files = () => new AnthropicFiles({
5650
+ provider: providerName,
5651
+ baseURL,
5652
+ headers: getHeaders,
5653
+ fetch: options.fetch
5654
+ });
5655
+ provider.skills = createSkills;
5126
5656
  provider.tools = anthropicTools;
5127
5657
  return provider;
5128
5658
  }
@@ -5147,11 +5677,10 @@ function forwardAnthropicContainerIdFromLastStep({
5147
5677
  }
5148
5678
  return void 0;
5149
5679
  }
5150
- // Annotate the CommonJS export names for ESM import in node:
5151
- 0 && (module.exports = {
5680
+ export {
5152
5681
  VERSION,
5153
5682
  anthropic,
5154
5683
  createAnthropic,
5155
5684
  forwardAnthropicContainerIdFromLastStep
5156
- });
5685
+ };
5157
5686
  //# sourceMappingURL=index.js.map