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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +305 -4
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +83 -58
  4. package/dist/index.js +2043 -1356
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +85 -58
  7. package/dist/internal/index.js +1804 -1342
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/05-anthropic.mdx +116 -13
  10. package/package.json +14 -15
  11. package/src/{anthropic-messages-api.ts → anthropic-api.ts} +14 -6
  12. package/src/anthropic-error.ts +1 -1
  13. package/src/anthropic-files.ts +95 -0
  14. package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +263 -78
  15. package/src/anthropic-message-metadata.ts +1 -4
  16. package/src/{anthropic-messages-options.ts → anthropic-options.ts} +68 -11
  17. package/src/anthropic-prepare-tools.ts +14 -7
  18. package/src/anthropic-provider.ts +42 -13
  19. package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +4 -4
  20. package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +190 -149
  21. package/src/forward-anthropic-container-id-from-last-step.ts +2 -2
  22. package/src/get-cache-control.ts +5 -2
  23. package/src/index.ts +1 -1
  24. package/src/internal/index.ts +11 -2
  25. package/src/map-anthropic-stop-reason.ts +1 -1
  26. package/src/sanitize-json-schema.ts +203 -0
  27. package/src/skills/anthropic-skills-api.ts +44 -0
  28. package/src/skills/anthropic-skills.ts +132 -0
  29. package/src/tool/bash_20241022.ts +2 -2
  30. package/src/tool/bash_20250124.ts +2 -2
  31. package/src/tool/code-execution_20250522.ts +2 -2
  32. package/src/tool/code-execution_20250825.ts +2 -2
  33. package/src/tool/code-execution_20260120.ts +2 -2
  34. package/src/tool/computer_20241022.ts +2 -2
  35. package/src/tool/computer_20250124.ts +2 -2
  36. package/src/tool/computer_20251124.ts +2 -2
  37. package/src/tool/memory_20250818.ts +2 -2
  38. package/src/tool/text-editor_20241022.ts +2 -2
  39. package/src/tool/text-editor_20250124.ts +2 -2
  40. package/src/tool/text-editor_20250429.ts +2 -2
  41. package/src/tool/text-editor_20250728.ts +6 -3
  42. package/src/tool/tool-search-bm25_20251119.ts +2 -2
  43. package/src/tool/tool-search-regex_20251119.ts +2 -2
  44. package/src/tool/web-fetch-20250910.ts +2 -2
  45. package/src/tool/web-fetch-20260209.ts +2 -2
  46. package/src/tool/web-search_20250305.ts +2 -2
  47. package/src/tool/web-search_20260209.ts +2 -2
  48. package/dist/index.d.mts +0 -1090
  49. package/dist/index.mjs +0 -5244
  50. package/dist/index.mjs.map +0 -1
  51. package/dist/internal/index.d.mts +0 -969
  52. package/dist/internal/index.mjs +0 -5136
  53. package/dist/internal/index.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,375 +1,454 @@
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 index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- anthropic: () => anthropic,
25
- createAnthropic: () => createAnthropic,
26
- forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep
27
- });
28
- module.exports = __toCommonJS(index_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");
33
-
34
- // src/version.ts
35
- var VERSION = true ? "4.0.0-beta.4" : "0.0.0-test";
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";
36
13
 
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
+ convertInlineFileDataToUint8Array,
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
 
60
- // 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()
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 = convertInlineFileDataToUint8Array(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-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
+
136
+ // src/anthropic-api.ts
137
+ import {
138
+ lazySchema as lazySchema3,
139
+ zodSchema as zodSchema3
140
+ } from "@ai-sdk/provider-utils";
141
+ import { z as z3 } from "zod/v4";
142
+ var anthropicResponseSchema = lazySchema3(
143
+ () => zodSchema3(
144
+ z3.object({
145
+ type: z3.literal("message"),
146
+ id: z3.string().nullish(),
147
+ model: z3.string().nullish(),
148
+ content: z3.array(
149
+ z3.discriminatedUnion("type", [
150
+ z3.object({
151
+ type: z3.literal("text"),
152
+ text: z3.string(),
153
+ citations: z3.array(
154
+ z3.discriminatedUnion("type", [
155
+ z3.object({
156
+ type: z3.literal("web_search_result_location"),
157
+ cited_text: z3.string(),
158
+ url: z3.string(),
159
+ title: z3.string(),
160
+ encrypted_index: z3.string()
82
161
  }),
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()
162
+ z3.object({
163
+ type: z3.literal("page_location"),
164
+ cited_text: z3.string(),
165
+ document_index: z3.number(),
166
+ document_title: z3.string().nullable(),
167
+ start_page_number: z3.number(),
168
+ end_page_number: z3.number()
90
169
  }),
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()
170
+ z3.object({
171
+ type: z3.literal("char_location"),
172
+ cited_text: z3.string(),
173
+ document_index: z3.number(),
174
+ document_title: z3.string().nullable(),
175
+ start_char_index: z3.number(),
176
+ end_char_index: z3.number()
98
177
  })
99
178
  ])
100
179
  ).optional()
101
180
  }),
102
- import_v42.z.object({
103
- type: import_v42.z.literal("thinking"),
104
- thinking: import_v42.z.string(),
105
- signature: import_v42.z.string()
181
+ z3.object({
182
+ type: z3.literal("thinking"),
183
+ thinking: z3.string(),
184
+ signature: z3.string()
106
185
  }),
107
- import_v42.z.object({
108
- type: import_v42.z.literal("redacted_thinking"),
109
- data: import_v42.z.string()
186
+ z3.object({
187
+ type: z3.literal("redacted_thinking"),
188
+ data: z3.string()
110
189
  }),
111
- import_v42.z.object({
112
- type: import_v42.z.literal("compaction"),
113
- content: import_v42.z.string()
190
+ z3.object({
191
+ type: z3.literal("compaction"),
192
+ content: z3.string()
114
193
  }),
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(),
194
+ z3.object({
195
+ type: z3.literal("tool_use"),
196
+ id: z3.string(),
197
+ name: z3.string(),
198
+ input: z3.unknown(),
120
199
  // 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()
200
+ caller: z3.union([
201
+ z3.object({
202
+ type: z3.literal("code_execution_20250825"),
203
+ tool_id: z3.string()
125
204
  }),
126
- import_v42.z.object({
127
- type: import_v42.z.literal("code_execution_20260120"),
128
- tool_id: import_v42.z.string()
205
+ z3.object({
206
+ type: z3.literal("code_execution_20260120"),
207
+ tool_id: z3.string()
129
208
  }),
130
- import_v42.z.object({
131
- type: import_v42.z.literal("direct")
209
+ z3.object({
210
+ type: z3.literal("direct")
132
211
  })
133
212
  ]).optional()
134
213
  }),
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()
214
+ z3.object({
215
+ type: z3.literal("server_tool_use"),
216
+ id: z3.string(),
217
+ name: z3.string(),
218
+ input: z3.record(z3.string(), z3.unknown()).nullish(),
219
+ caller: z3.union([
220
+ z3.object({
221
+ type: z3.literal("code_execution_20260120"),
222
+ tool_id: z3.string()
144
223
  }),
145
- import_v42.z.object({
146
- type: import_v42.z.literal("direct")
224
+ z3.object({
225
+ type: z3.literal("direct")
147
226
  })
148
227
  ]).optional()
149
228
  }),
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()
229
+ z3.object({
230
+ type: z3.literal("mcp_tool_use"),
231
+ id: z3.string(),
232
+ name: z3.string(),
233
+ input: z3.unknown(),
234
+ server_name: z3.string()
156
235
  }),
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() })
236
+ z3.object({
237
+ type: z3.literal("mcp_tool_result"),
238
+ tool_use_id: z3.string(),
239
+ is_error: z3.boolean(),
240
+ content: z3.array(
241
+ z3.union([
242
+ z3.string(),
243
+ z3.object({ type: z3.literal("text"), text: z3.string() })
165
244
  ])
166
245
  )
167
246
  }),
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()
247
+ z3.object({
248
+ type: z3.literal("web_fetch_tool_result"),
249
+ tool_use_id: z3.string(),
250
+ content: z3.union([
251
+ z3.object({
252
+ type: z3.literal("web_fetch_result"),
253
+ url: z3.string(),
254
+ retrieved_at: z3.string(),
255
+ content: z3.object({
256
+ type: z3.literal("document"),
257
+ title: z3.string().nullable(),
258
+ citations: z3.object({ enabled: z3.boolean() }).optional(),
259
+ source: z3.union([
260
+ z3.object({
261
+ type: z3.literal("base64"),
262
+ media_type: z3.literal("application/pdf"),
263
+ data: z3.string()
185
264
  }),
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()
265
+ z3.object({
266
+ type: z3.literal("text"),
267
+ media_type: z3.literal("text/plain"),
268
+ data: z3.string()
190
269
  })
191
270
  ])
192
271
  })
193
272
  }),
194
- import_v42.z.object({
195
- type: import_v42.z.literal("web_fetch_tool_result_error"),
196
- error_code: import_v42.z.string()
273
+ z3.object({
274
+ type: z3.literal("web_fetch_tool_result_error"),
275
+ error_code: z3.string()
197
276
  })
198
277
  ])
199
278
  }),
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()
279
+ z3.object({
280
+ type: z3.literal("web_search_tool_result"),
281
+ tool_use_id: z3.string(),
282
+ content: z3.union([
283
+ z3.array(
284
+ z3.object({
285
+ type: z3.literal("web_search_result"),
286
+ url: z3.string(),
287
+ title: z3.string(),
288
+ encrypted_content: z3.string(),
289
+ page_age: z3.string().nullish()
211
290
  })
212
291
  ),
213
- import_v42.z.object({
214
- type: import_v42.z.literal("web_search_tool_result_error"),
215
- error_code: import_v42.z.string()
292
+ z3.object({
293
+ type: z3.literal("web_search_tool_result_error"),
294
+ error_code: z3.string()
216
295
  })
217
296
  ])
218
297
  }),
219
298
  // 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()
299
+ z3.object({
300
+ type: z3.literal("code_execution_tool_result"),
301
+ tool_use_id: z3.string(),
302
+ content: z3.union([
303
+ z3.object({
304
+ type: z3.literal("code_execution_result"),
305
+ stdout: z3.string(),
306
+ stderr: z3.string(),
307
+ return_code: z3.number(),
308
+ content: z3.array(
309
+ z3.object({
310
+ type: z3.literal("code_execution_output"),
311
+ file_id: z3.string()
233
312
  })
234
313
  ).optional().default([])
235
314
  }),
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()
315
+ z3.object({
316
+ type: z3.literal("encrypted_code_execution_result"),
317
+ encrypted_stdout: z3.string(),
318
+ stderr: z3.string(),
319
+ return_code: z3.number(),
320
+ content: z3.array(
321
+ z3.object({
322
+ type: z3.literal("code_execution_output"),
323
+ file_id: z3.string()
245
324
  })
246
325
  ).optional().default([])
247
326
  }),
248
- import_v42.z.object({
249
- type: import_v42.z.literal("code_execution_tool_result_error"),
250
- error_code: import_v42.z.string()
327
+ z3.object({
328
+ type: z3.literal("code_execution_tool_result_error"),
329
+ error_code: z3.string()
251
330
  })
252
331
  ])
253
332
  }),
254
333
  // 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()
334
+ z3.object({
335
+ type: z3.literal("bash_code_execution_tool_result"),
336
+ tool_use_id: z3.string(),
337
+ content: z3.discriminatedUnion("type", [
338
+ z3.object({
339
+ type: z3.literal("bash_code_execution_result"),
340
+ content: z3.array(
341
+ z3.object({
342
+ type: z3.literal("bash_code_execution_output"),
343
+ file_id: z3.string()
265
344
  })
266
345
  ),
267
- stdout: import_v42.z.string(),
268
- stderr: import_v42.z.string(),
269
- return_code: import_v42.z.number()
346
+ stdout: z3.string(),
347
+ stderr: z3.string(),
348
+ return_code: z3.number()
270
349
  }),
271
- import_v42.z.object({
272
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
273
- error_code: import_v42.z.string()
350
+ z3.object({
351
+ type: z3.literal("bash_code_execution_tool_result_error"),
352
+ error_code: z3.string()
274
353
  })
275
354
  ])
276
355
  }),
277
356
  // 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()
357
+ z3.object({
358
+ type: z3.literal("text_editor_code_execution_tool_result"),
359
+ tool_use_id: z3.string(),
360
+ content: z3.discriminatedUnion("type", [
361
+ z3.object({
362
+ type: z3.literal("text_editor_code_execution_tool_result_error"),
363
+ error_code: z3.string()
285
364
  }),
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()
365
+ z3.object({
366
+ type: z3.literal("text_editor_code_execution_view_result"),
367
+ content: z3.string(),
368
+ file_type: z3.string(),
369
+ num_lines: z3.number().nullable(),
370
+ start_line: z3.number().nullable(),
371
+ total_lines: z3.number().nullable()
293
372
  }),
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()
373
+ z3.object({
374
+ type: z3.literal("text_editor_code_execution_create_result"),
375
+ is_file_update: z3.boolean()
297
376
  }),
298
- import_v42.z.object({
299
- type: import_v42.z.literal(
377
+ z3.object({
378
+ type: z3.literal(
300
379
  "text_editor_code_execution_str_replace_result"
301
380
  ),
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()
381
+ lines: z3.array(z3.string()).nullable(),
382
+ new_lines: z3.number().nullable(),
383
+ new_start: z3.number().nullable(),
384
+ old_lines: z3.number().nullable(),
385
+ old_start: z3.number().nullable()
307
386
  })
308
387
  ])
309
388
  }),
310
389
  // 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()
390
+ z3.object({
391
+ type: z3.literal("tool_search_tool_result"),
392
+ tool_use_id: z3.string(),
393
+ content: z3.union([
394
+ z3.object({
395
+ type: z3.literal("tool_search_tool_search_result"),
396
+ tool_references: z3.array(
397
+ z3.object({
398
+ type: z3.literal("tool_reference"),
399
+ tool_name: z3.string()
321
400
  })
322
401
  )
323
402
  }),
324
- import_v42.z.object({
325
- type: import_v42.z.literal("tool_search_tool_result_error"),
326
- error_code: import_v42.z.string()
403
+ z3.object({
404
+ type: z3.literal("tool_search_tool_result_error"),
405
+ error_code: z3.string()
327
406
  })
328
407
  ])
329
408
  })
330
409
  ])
331
410
  ),
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()
411
+ stop_reason: z3.string().nullish(),
412
+ stop_sequence: z3.string().nullish(),
413
+ usage: z3.looseObject({
414
+ input_tokens: z3.number(),
415
+ output_tokens: z3.number(),
416
+ cache_creation_input_tokens: z3.number().nullish(),
417
+ cache_read_input_tokens: z3.number().nullish(),
418
+ iterations: z3.array(
419
+ z3.object({
420
+ type: z3.union([z3.literal("compaction"), z3.literal("message")]),
421
+ input_tokens: z3.number(),
422
+ output_tokens: z3.number()
344
423
  })
345
424
  ).nullish()
346
425
  }),
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()
426
+ container: z3.object({
427
+ expires_at: z3.string(),
428
+ id: z3.string(),
429
+ skills: z3.array(
430
+ z3.object({
431
+ type: z3.union([z3.literal("anthropic"), z3.literal("custom")]),
432
+ skill_id: z3.string(),
433
+ version: z3.string()
355
434
  })
356
435
  ).nullish()
357
436
  }).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()
437
+ context_management: z3.object({
438
+ applied_edits: z3.array(
439
+ z3.union([
440
+ z3.object({
441
+ type: z3.literal("clear_tool_uses_20250919"),
442
+ cleared_tool_uses: z3.number(),
443
+ cleared_input_tokens: z3.number()
365
444
  }),
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()
445
+ z3.object({
446
+ type: z3.literal("clear_thinking_20251015"),
447
+ cleared_thinking_turns: z3.number(),
448
+ cleared_input_tokens: z3.number()
370
449
  }),
371
- import_v42.z.object({
372
- type: import_v42.z.literal("compact_20260112")
450
+ z3.object({
451
+ type: z3.literal("compact_20260112")
373
452
  })
374
453
  ])
375
454
  )
@@ -377,457 +456,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
377
456
  })
378
457
  )
379
458
  );
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()
459
+ var anthropicChunkSchema = lazySchema3(
460
+ () => zodSchema3(
461
+ z3.discriminatedUnion("type", [
462
+ z3.object({
463
+ type: z3.literal("message_start"),
464
+ message: z3.object({
465
+ id: z3.string().nullish(),
466
+ model: z3.string().nullish(),
467
+ role: z3.string().nullish(),
468
+ usage: z3.looseObject({
469
+ input_tokens: z3.number(),
470
+ cache_creation_input_tokens: z3.number().nullish(),
471
+ cache_read_input_tokens: z3.number().nullish()
393
472
  }),
394
473
  // 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()
474
+ content: z3.array(
475
+ z3.discriminatedUnion("type", [
476
+ z3.object({
477
+ type: z3.literal("tool_use"),
478
+ id: z3.string(),
479
+ name: z3.string(),
480
+ input: z3.unknown(),
481
+ caller: z3.union([
482
+ z3.object({
483
+ type: z3.literal("code_execution_20250825"),
484
+ tool_id: z3.string()
406
485
  }),
407
- import_v42.z.object({
408
- type: import_v42.z.literal("code_execution_20260120"),
409
- tool_id: import_v42.z.string()
486
+ z3.object({
487
+ type: z3.literal("code_execution_20260120"),
488
+ tool_id: z3.string()
410
489
  }),
411
- import_v42.z.object({
412
- type: import_v42.z.literal("direct")
490
+ z3.object({
491
+ type: z3.literal("direct")
413
492
  })
414
493
  ]).optional()
415
494
  })
416
495
  ])
417
496
  ).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()
497
+ stop_reason: z3.string().nullish(),
498
+ container: z3.object({
499
+ expires_at: z3.string(),
500
+ id: z3.string()
422
501
  }).nullish()
423
502
  })
424
503
  }),
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()
504
+ z3.object({
505
+ type: z3.literal("content_block_start"),
506
+ index: z3.number(),
507
+ content_block: z3.discriminatedUnion("type", [
508
+ z3.object({
509
+ type: z3.literal("text"),
510
+ text: z3.string()
432
511
  }),
433
- import_v42.z.object({
434
- type: import_v42.z.literal("thinking"),
435
- thinking: import_v42.z.string()
512
+ z3.object({
513
+ type: z3.literal("thinking"),
514
+ thinking: z3.string()
436
515
  }),
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(),
516
+ z3.object({
517
+ type: z3.literal("tool_use"),
518
+ id: z3.string(),
519
+ name: z3.string(),
441
520
  // 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(),
521
+ input: z3.record(z3.string(), z3.unknown()).optional(),
443
522
  // 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()
523
+ caller: z3.union([
524
+ z3.object({
525
+ type: z3.literal("code_execution_20250825"),
526
+ tool_id: z3.string()
448
527
  }),
449
- import_v42.z.object({
450
- type: import_v42.z.literal("code_execution_20260120"),
451
- tool_id: import_v42.z.string()
528
+ z3.object({
529
+ type: z3.literal("code_execution_20260120"),
530
+ tool_id: z3.string()
452
531
  }),
453
- import_v42.z.object({
454
- type: import_v42.z.literal("direct")
532
+ z3.object({
533
+ type: z3.literal("direct")
455
534
  })
456
535
  ]).optional()
457
536
  }),
458
- import_v42.z.object({
459
- type: import_v42.z.literal("redacted_thinking"),
460
- data: import_v42.z.string()
537
+ z3.object({
538
+ type: z3.literal("redacted_thinking"),
539
+ data: z3.string()
461
540
  }),
462
- import_v42.z.object({
463
- type: import_v42.z.literal("compaction"),
464
- content: import_v42.z.string().nullish()
541
+ z3.object({
542
+ type: z3.literal("compaction"),
543
+ content: z3.string().nullish()
465
544
  }),
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()
545
+ z3.object({
546
+ type: z3.literal("server_tool_use"),
547
+ id: z3.string(),
548
+ name: z3.string(),
549
+ input: z3.record(z3.string(), z3.unknown()).nullish(),
550
+ caller: z3.union([
551
+ z3.object({
552
+ type: z3.literal("code_execution_20260120"),
553
+ tool_id: z3.string()
475
554
  }),
476
- import_v42.z.object({
477
- type: import_v42.z.literal("direct")
555
+ z3.object({
556
+ type: z3.literal("direct")
478
557
  })
479
558
  ]).optional()
480
559
  }),
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()
560
+ z3.object({
561
+ type: z3.literal("mcp_tool_use"),
562
+ id: z3.string(),
563
+ name: z3.string(),
564
+ input: z3.unknown(),
565
+ server_name: z3.string()
487
566
  }),
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() })
567
+ z3.object({
568
+ type: z3.literal("mcp_tool_result"),
569
+ tool_use_id: z3.string(),
570
+ is_error: z3.boolean(),
571
+ content: z3.array(
572
+ z3.union([
573
+ z3.string(),
574
+ z3.object({ type: z3.literal("text"), text: z3.string() })
496
575
  ])
497
576
  )
498
577
  }),
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()
578
+ z3.object({
579
+ type: z3.literal("web_fetch_tool_result"),
580
+ tool_use_id: z3.string(),
581
+ content: z3.union([
582
+ z3.object({
583
+ type: z3.literal("web_fetch_result"),
584
+ url: z3.string(),
585
+ retrieved_at: z3.string(),
586
+ content: z3.object({
587
+ type: z3.literal("document"),
588
+ title: z3.string().nullable(),
589
+ citations: z3.object({ enabled: z3.boolean() }).optional(),
590
+ source: z3.union([
591
+ z3.object({
592
+ type: z3.literal("base64"),
593
+ media_type: z3.literal("application/pdf"),
594
+ data: z3.string()
516
595
  }),
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()
596
+ z3.object({
597
+ type: z3.literal("text"),
598
+ media_type: z3.literal("text/plain"),
599
+ data: z3.string()
521
600
  })
522
601
  ])
523
602
  })
524
603
  }),
525
- import_v42.z.object({
526
- type: import_v42.z.literal("web_fetch_tool_result_error"),
527
- error_code: import_v42.z.string()
604
+ z3.object({
605
+ type: z3.literal("web_fetch_tool_result_error"),
606
+ error_code: z3.string()
528
607
  })
529
608
  ])
530
609
  }),
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()
610
+ z3.object({
611
+ type: z3.literal("web_search_tool_result"),
612
+ tool_use_id: z3.string(),
613
+ content: z3.union([
614
+ z3.array(
615
+ z3.object({
616
+ type: z3.literal("web_search_result"),
617
+ url: z3.string(),
618
+ title: z3.string(),
619
+ encrypted_content: z3.string(),
620
+ page_age: z3.string().nullish()
542
621
  })
543
622
  ),
544
- import_v42.z.object({
545
- type: import_v42.z.literal("web_search_tool_result_error"),
546
- error_code: import_v42.z.string()
623
+ z3.object({
624
+ type: z3.literal("web_search_tool_result_error"),
625
+ error_code: z3.string()
547
626
  })
548
627
  ])
549
628
  }),
550
629
  // 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()
630
+ z3.object({
631
+ type: z3.literal("code_execution_tool_result"),
632
+ tool_use_id: z3.string(),
633
+ content: z3.union([
634
+ z3.object({
635
+ type: z3.literal("code_execution_result"),
636
+ stdout: z3.string(),
637
+ stderr: z3.string(),
638
+ return_code: z3.number(),
639
+ content: z3.array(
640
+ z3.object({
641
+ type: z3.literal("code_execution_output"),
642
+ file_id: z3.string()
564
643
  })
565
644
  ).optional().default([])
566
645
  }),
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()
646
+ z3.object({
647
+ type: z3.literal("encrypted_code_execution_result"),
648
+ encrypted_stdout: z3.string(),
649
+ stderr: z3.string(),
650
+ return_code: z3.number(),
651
+ content: z3.array(
652
+ z3.object({
653
+ type: z3.literal("code_execution_output"),
654
+ file_id: z3.string()
576
655
  })
577
656
  ).optional().default([])
578
657
  }),
579
- import_v42.z.object({
580
- type: import_v42.z.literal("code_execution_tool_result_error"),
581
- error_code: import_v42.z.string()
658
+ z3.object({
659
+ type: z3.literal("code_execution_tool_result_error"),
660
+ error_code: z3.string()
582
661
  })
583
662
  ])
584
663
  }),
585
664
  // 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()
665
+ z3.object({
666
+ type: z3.literal("bash_code_execution_tool_result"),
667
+ tool_use_id: z3.string(),
668
+ content: z3.discriminatedUnion("type", [
669
+ z3.object({
670
+ type: z3.literal("bash_code_execution_result"),
671
+ content: z3.array(
672
+ z3.object({
673
+ type: z3.literal("bash_code_execution_output"),
674
+ file_id: z3.string()
596
675
  })
597
676
  ),
598
- stdout: import_v42.z.string(),
599
- stderr: import_v42.z.string(),
600
- return_code: import_v42.z.number()
677
+ stdout: z3.string(),
678
+ stderr: z3.string(),
679
+ return_code: z3.number()
601
680
  }),
602
- import_v42.z.object({
603
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
604
- error_code: import_v42.z.string()
681
+ z3.object({
682
+ type: z3.literal("bash_code_execution_tool_result_error"),
683
+ error_code: z3.string()
605
684
  })
606
685
  ])
607
686
  }),
608
687
  // 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()
688
+ z3.object({
689
+ type: z3.literal("text_editor_code_execution_tool_result"),
690
+ tool_use_id: z3.string(),
691
+ content: z3.discriminatedUnion("type", [
692
+ z3.object({
693
+ type: z3.literal("text_editor_code_execution_tool_result_error"),
694
+ error_code: z3.string()
616
695
  }),
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()
696
+ z3.object({
697
+ type: z3.literal("text_editor_code_execution_view_result"),
698
+ content: z3.string(),
699
+ file_type: z3.string(),
700
+ num_lines: z3.number().nullable(),
701
+ start_line: z3.number().nullable(),
702
+ total_lines: z3.number().nullable()
624
703
  }),
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()
704
+ z3.object({
705
+ type: z3.literal("text_editor_code_execution_create_result"),
706
+ is_file_update: z3.boolean()
628
707
  }),
629
- import_v42.z.object({
630
- type: import_v42.z.literal(
708
+ z3.object({
709
+ type: z3.literal(
631
710
  "text_editor_code_execution_str_replace_result"
632
711
  ),
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()
712
+ lines: z3.array(z3.string()).nullable(),
713
+ new_lines: z3.number().nullable(),
714
+ new_start: z3.number().nullable(),
715
+ old_lines: z3.number().nullable(),
716
+ old_start: z3.number().nullable()
638
717
  })
639
718
  ])
640
719
  }),
641
720
  // 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()
721
+ z3.object({
722
+ type: z3.literal("tool_search_tool_result"),
723
+ tool_use_id: z3.string(),
724
+ content: z3.union([
725
+ z3.object({
726
+ type: z3.literal("tool_search_tool_search_result"),
727
+ tool_references: z3.array(
728
+ z3.object({
729
+ type: z3.literal("tool_reference"),
730
+ tool_name: z3.string()
652
731
  })
653
732
  )
654
733
  }),
655
- import_v42.z.object({
656
- type: import_v42.z.literal("tool_search_tool_result_error"),
657
- error_code: import_v42.z.string()
734
+ z3.object({
735
+ type: z3.literal("tool_search_tool_result_error"),
736
+ error_code: z3.string()
658
737
  })
659
738
  ])
660
739
  })
661
740
  ])
662
741
  }),
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()
742
+ z3.object({
743
+ type: z3.literal("content_block_delta"),
744
+ index: z3.number(),
745
+ delta: z3.discriminatedUnion("type", [
746
+ z3.object({
747
+ type: z3.literal("input_json_delta"),
748
+ partial_json: z3.string()
670
749
  }),
671
- import_v42.z.object({
672
- type: import_v42.z.literal("text_delta"),
673
- text: import_v42.z.string()
750
+ z3.object({
751
+ type: z3.literal("text_delta"),
752
+ text: z3.string()
674
753
  }),
675
- import_v42.z.object({
676
- type: import_v42.z.literal("thinking_delta"),
677
- thinking: import_v42.z.string()
754
+ z3.object({
755
+ type: z3.literal("thinking_delta"),
756
+ thinking: z3.string()
678
757
  }),
679
- import_v42.z.object({
680
- type: import_v42.z.literal("signature_delta"),
681
- signature: import_v42.z.string()
758
+ z3.object({
759
+ type: z3.literal("signature_delta"),
760
+ signature: z3.string()
682
761
  }),
683
- import_v42.z.object({
684
- type: import_v42.z.literal("compaction_delta"),
685
- content: import_v42.z.string().nullish()
762
+ z3.object({
763
+ type: z3.literal("compaction_delta"),
764
+ content: z3.string().nullish()
686
765
  }),
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()
766
+ z3.object({
767
+ type: z3.literal("citations_delta"),
768
+ citation: z3.discriminatedUnion("type", [
769
+ z3.object({
770
+ type: z3.literal("web_search_result_location"),
771
+ cited_text: z3.string(),
772
+ url: z3.string(),
773
+ title: z3.string(),
774
+ encrypted_index: z3.string()
696
775
  }),
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()
776
+ z3.object({
777
+ type: z3.literal("page_location"),
778
+ cited_text: z3.string(),
779
+ document_index: z3.number(),
780
+ document_title: z3.string().nullable(),
781
+ start_page_number: z3.number(),
782
+ end_page_number: z3.number()
704
783
  }),
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()
784
+ z3.object({
785
+ type: z3.literal("char_location"),
786
+ cited_text: z3.string(),
787
+ document_index: z3.number(),
788
+ document_title: z3.string().nullable(),
789
+ start_char_index: z3.number(),
790
+ end_char_index: z3.number()
712
791
  })
713
792
  ])
714
793
  })
715
794
  ])
716
795
  }),
717
- import_v42.z.object({
718
- type: import_v42.z.literal("content_block_stop"),
719
- index: import_v42.z.number()
796
+ z3.object({
797
+ type: z3.literal("content_block_stop"),
798
+ index: z3.number()
720
799
  }),
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()
800
+ z3.object({
801
+ type: z3.literal("error"),
802
+ error: z3.object({
803
+ type: z3.string(),
804
+ message: z3.string()
726
805
  })
727
806
  }),
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")
807
+ z3.object({
808
+ type: z3.literal("message_delta"),
809
+ delta: z3.object({
810
+ stop_reason: z3.string().nullish(),
811
+ stop_sequence: z3.string().nullish(),
812
+ container: z3.object({
813
+ expires_at: z3.string(),
814
+ id: z3.string(),
815
+ skills: z3.array(
816
+ z3.object({
817
+ type: z3.union([
818
+ z3.literal("anthropic"),
819
+ z3.literal("custom")
741
820
  ]),
742
- skill_id: import_v42.z.string(),
743
- version: import_v42.z.string()
821
+ skill_id: z3.string(),
822
+ version: z3.string()
744
823
  })
745
824
  ).nullish()
746
825
  }).nullish()
747
826
  }),
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()
827
+ usage: z3.looseObject({
828
+ input_tokens: z3.number().nullish(),
829
+ output_tokens: z3.number(),
830
+ cache_creation_input_tokens: z3.number().nullish(),
831
+ cache_read_input_tokens: z3.number().nullish(),
832
+ iterations: z3.array(
833
+ z3.object({
834
+ type: z3.union([z3.literal("compaction"), z3.literal("message")]),
835
+ input_tokens: z3.number(),
836
+ output_tokens: z3.number()
758
837
  })
759
838
  ).nullish()
760
839
  }),
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()
840
+ context_management: z3.object({
841
+ applied_edits: z3.array(
842
+ z3.union([
843
+ z3.object({
844
+ type: z3.literal("clear_tool_uses_20250919"),
845
+ cleared_tool_uses: z3.number(),
846
+ cleared_input_tokens: z3.number()
768
847
  }),
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()
848
+ z3.object({
849
+ type: z3.literal("clear_thinking_20251015"),
850
+ cleared_thinking_turns: z3.number(),
851
+ cleared_input_tokens: z3.number()
773
852
  }),
774
- import_v42.z.object({
775
- type: import_v42.z.literal("compact_20260112")
853
+ z3.object({
854
+ type: z3.literal("compact_20260112")
776
855
  })
777
856
  ])
778
857
  )
779
858
  }).nullish()
780
859
  }),
781
- import_v42.z.object({
782
- type: import_v42.z.literal("message_stop")
860
+ z3.object({
861
+ type: z3.literal("message_stop")
783
862
  }),
784
- import_v42.z.object({
785
- type: import_v42.z.literal("ping")
863
+ z3.object({
864
+ type: z3.literal("ping")
786
865
  })
787
866
  ])
788
867
  )
789
868
  );
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()
869
+ var anthropicReasoningMetadataSchema = lazySchema3(
870
+ () => zodSchema3(
871
+ z3.object({
872
+ signature: z3.string().optional(),
873
+ redactedData: z3.string().optional()
795
874
  })
796
875
  )
797
876
  );
798
877
 
799
- // src/anthropic-messages-options.ts
800
- var import_v43 = require("zod/v4");
801
- var anthropicFilePartProviderOptions = import_v43.z.object({
878
+ // src/anthropic-options.ts
879
+ import { z as z4 } from "zod/v4";
880
+ var anthropicFilePartProviderOptions = z4.object({
802
881
  /**
803
882
  * Citation configuration for this document.
804
883
  * When enabled, this document will generate citations in the response.
805
884
  */
806
- citations: import_v43.z.object({
885
+ citations: z4.object({
807
886
  /**
808
887
  * Enable citations for this document
809
888
  */
810
- enabled: import_v43.z.boolean()
889
+ enabled: z4.boolean()
811
890
  }).optional(),
812
891
  /**
813
892
  * Custom title for the document.
814
893
  * If not provided, the filename will be used.
815
894
  */
816
- title: import_v43.z.string().optional(),
895
+ title: z4.string().optional(),
817
896
  /**
818
897
  * Context about the document that will be passed to the model
819
898
  * but not used towards cited content.
820
899
  * Useful for storing document metadata as text or stringified JSON.
821
900
  */
822
- context: import_v43.z.string().optional()
901
+ context: z4.string().optional()
823
902
  });
824
- var anthropicLanguageModelOptions = import_v43.z.object({
903
+ var anthropicLanguageModelOptions = z4.object({
825
904
  /**
826
905
  * Whether to send reasoning to the model.
827
906
  *
828
907
  * This allows you to deactivate reasoning inputs for models that do not support them.
829
908
  */
830
- sendReasoning: import_v43.z.boolean().optional(),
909
+ sendReasoning: z4.boolean().optional(),
831
910
  /**
832
911
  * Determines how structured outputs are generated.
833
912
  *
@@ -835,52 +914,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
835
914
  * - `jsonTool`: Use a special 'json' tool to specify the structured output format.
836
915
  * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
837
916
  */
838
- structuredOutputMode: import_v43.z.enum(["outputFormat", "jsonTool", "auto"]).optional(),
917
+ structuredOutputMode: z4.enum(["outputFormat", "jsonTool", "auto"]).optional(),
839
918
  /**
840
919
  * Configuration for enabling Claude's extended thinking.
841
920
  *
842
921
  * When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
843
922
  * Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
844
923
  */
845
- thinking: import_v43.z.discriminatedUnion("type", [
846
- import_v43.z.object({
924
+ thinking: z4.discriminatedUnion("type", [
925
+ z4.object({
847
926
  /** for Sonnet 4.6, Opus 4.6, and newer models */
848
- type: import_v43.z.literal("adaptive")
927
+ type: z4.literal("adaptive"),
928
+ /**
929
+ * Controls whether thinking content is included in the response.
930
+ * - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
931
+ * - `"summarized"`: Thinking content is returned. Required to see reasoning output.
932
+ */
933
+ display: z4.enum(["omitted", "summarized"]).optional()
849
934
  }),
850
- import_v43.z.object({
935
+ z4.object({
851
936
  /** 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()
937
+ type: z4.literal("enabled"),
938
+ budgetTokens: z4.number().optional()
854
939
  }),
855
- import_v43.z.object({
856
- type: import_v43.z.literal("disabled")
940
+ z4.object({
941
+ type: z4.literal("disabled")
857
942
  })
858
943
  ]).optional(),
859
944
  /**
860
945
  * Whether to disable parallel function calling during tool use. Default is false.
861
946
  * When set to true, Claude will use at most one tool per response.
862
947
  */
863
- disableParallelToolUse: import_v43.z.boolean().optional(),
948
+ disableParallelToolUse: z4.boolean().optional(),
864
949
  /**
865
950
  * Cache control settings for this message.
866
951
  * See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
867
952
  */
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()
953
+ cacheControl: z4.object({
954
+ type: z4.literal("ephemeral"),
955
+ ttl: z4.union([z4.literal("5m"), z4.literal("1h")]).optional()
956
+ }).optional(),
957
+ /**
958
+ * Metadata to include with the request.
959
+ *
960
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
961
+ */
962
+ metadata: z4.object({
963
+ /**
964
+ * An external identifier for the user associated with the request.
965
+ *
966
+ * Should be a UUID, hash value, or other opaque identifier.
967
+ * Must not contain PII (name, email, phone number, etc.).
968
+ */
969
+ userId: z4.string().optional()
871
970
  }).optional(),
872
971
  /**
873
972
  * MCP servers to be utilized in this request.
874
973
  */
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()
974
+ mcpServers: z4.array(
975
+ z4.object({
976
+ type: z4.literal("url"),
977
+ name: z4.string(),
978
+ url: z4.string(),
979
+ authorizationToken: z4.string().nullish(),
980
+ toolConfiguration: z4.object({
981
+ enabled: z4.boolean().nullish(),
982
+ allowedTools: z4.array(z4.string()).nullish()
884
983
  }).nullish()
885
984
  })
886
985
  ).optional(),
@@ -889,83 +988,112 @@ var anthropicLanguageModelOptions = import_v43.z.object({
889
988
  * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
890
989
  * Requires code execution tool to be enabled.
891
990
  */
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
- })
991
+ container: z4.object({
992
+ id: z4.string().optional(),
993
+ skills: z4.array(
994
+ z4.discriminatedUnion("type", [
995
+ z4.object({
996
+ type: z4.literal("anthropic"),
997
+ skillId: z4.string(),
998
+ version: z4.string().optional()
999
+ }),
1000
+ z4.object({
1001
+ type: z4.literal("custom"),
1002
+ providerReference: z4.record(z4.string(), z4.string()),
1003
+ version: z4.string().optional()
1004
+ })
1005
+ ])
900
1006
  ).optional()
901
1007
  }).optional(),
902
1008
  /**
903
- * Whether to enable tool streaming (and structured output streaming).
904
- *
905
- * When set to false, the model will return all tool calls and results
906
- * at once after a delay.
1009
+ * Whether to enable fine-grained (eager) streaming of tool call inputs
1010
+ * and structured outputs for every function tool in the request. When
1011
+ * true (the default), each function tool receives a default of
1012
+ * `eager_input_streaming: true` unless it explicitly sets
1013
+ * `providerOptions.anthropic.eagerInputStreaming`.
907
1014
  *
908
1015
  * @default true
909
1016
  */
910
- toolStreaming: import_v43.z.boolean().optional(),
1017
+ toolStreaming: z4.boolean().optional(),
911
1018
  /**
912
1019
  * @default 'high'
913
1020
  */
914
- effort: import_v43.z.enum(["low", "medium", "high", "max"]).optional(),
1021
+ effort: z4.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
1022
+ /**
1023
+ * Task budget for agentic turns. Informs the model of the total token budget
1024
+ * available for the current task, allowing it to prioritize work and wind down
1025
+ * gracefully as the budget is consumed.
1026
+ *
1027
+ * Advisory only — does not enforce a hard token limit.
1028
+ */
1029
+ taskBudget: z4.object({
1030
+ type: z4.literal("tokens"),
1031
+ total: z4.number().int().min(2e4),
1032
+ remaining: z4.number().int().min(0).optional()
1033
+ }).optional(),
915
1034
  /**
916
1035
  * Enable fast mode for faster inference (2.5x faster output token speeds).
917
1036
  * Only supported with claude-opus-4-6.
918
1037
  */
919
- speed: import_v43.z.enum(["fast", "standard"]).optional(),
1038
+ speed: z4.enum(["fast", "standard"]).optional(),
1039
+ /**
1040
+ * Controls where model inference runs for this request.
1041
+ *
1042
+ * - `"global"`: Inference may run in any available geography (default).
1043
+ * - `"us"`: Inference runs only in US-based infrastructure.
1044
+ *
1045
+ * See https://platform.claude.com/docs/en/build-with-claude/data-residency
1046
+ */
1047
+ inferenceGeo: z4.enum(["us", "global"]).optional(),
920
1048
  /**
921
1049
  * A set of beta features to enable.
922
1050
  * Allow a provider to receive the full `betas` set if it needs it.
923
1051
  */
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()
1052
+ anthropicBeta: z4.array(z4.string()).optional(),
1053
+ contextManagement: z4.object({
1054
+ edits: z4.array(
1055
+ z4.discriminatedUnion("type", [
1056
+ z4.object({
1057
+ type: z4.literal("clear_tool_uses_20250919"),
1058
+ trigger: z4.discriminatedUnion("type", [
1059
+ z4.object({
1060
+ type: z4.literal("input_tokens"),
1061
+ value: z4.number()
934
1062
  }),
935
- import_v43.z.object({
936
- type: import_v43.z.literal("tool_uses"),
937
- value: import_v43.z.number()
1063
+ z4.object({
1064
+ type: z4.literal("tool_uses"),
1065
+ value: z4.number()
938
1066
  })
939
1067
  ]).optional(),
940
- keep: import_v43.z.object({
941
- type: import_v43.z.literal("tool_uses"),
942
- value: import_v43.z.number()
1068
+ keep: z4.object({
1069
+ type: z4.literal("tool_uses"),
1070
+ value: z4.number()
943
1071
  }).optional(),
944
- clearAtLeast: import_v43.z.object({
945
- type: import_v43.z.literal("input_tokens"),
946
- value: import_v43.z.number()
1072
+ clearAtLeast: z4.object({
1073
+ type: z4.literal("input_tokens"),
1074
+ value: z4.number()
947
1075
  }).optional(),
948
- clearToolInputs: import_v43.z.boolean().optional(),
949
- excludeTools: import_v43.z.array(import_v43.z.string()).optional()
1076
+ clearToolInputs: z4.boolean().optional(),
1077
+ excludeTools: z4.array(z4.string()).optional()
950
1078
  }),
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()
1079
+ z4.object({
1080
+ type: z4.literal("clear_thinking_20251015"),
1081
+ keep: z4.union([
1082
+ z4.literal("all"),
1083
+ z4.object({
1084
+ type: z4.literal("thinking_turns"),
1085
+ value: z4.number()
958
1086
  })
959
1087
  ]).optional()
960
1088
  }),
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()
1089
+ z4.object({
1090
+ type: z4.literal("compact_20260112"),
1091
+ trigger: z4.object({
1092
+ type: z4.literal("input_tokens"),
1093
+ value: z4.number()
966
1094
  }).optional(),
967
- pauseAfterCompaction: import_v43.z.boolean().optional(),
968
- instructions: import_v43.z.string().optional()
1095
+ pauseAfterCompaction: z4.boolean().optional(),
1096
+ instructions: z4.string().optional()
969
1097
  })
970
1098
  ])
971
1099
  )
@@ -973,7 +1101,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
973
1101
  });
974
1102
 
975
1103
  // src/anthropic-prepare-tools.ts
976
- var import_provider = require("@ai-sdk/provider");
1104
+ import {
1105
+ UnsupportedFunctionalityError
1106
+ } from "@ai-sdk/provider";
977
1107
 
978
1108
  // src/get-cache-control.ts
979
1109
  var MAX_CACHE_BREAKPOINTS = 4;
@@ -1018,31 +1148,34 @@ var CacheControlValidator = class {
1018
1148
  };
1019
1149
 
1020
1150
  // 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()
1151
+ import {
1152
+ createProviderDefinedToolFactory,
1153
+ lazySchema as lazySchema4,
1154
+ zodSchema as zodSchema4
1155
+ } from "@ai-sdk/provider-utils";
1156
+ import { z as z5 } from "zod/v4";
1157
+ var textEditor_20250728ArgsSchema = lazySchema4(
1158
+ () => zodSchema4(
1159
+ z5.object({
1160
+ maxCharacters: z5.number().optional()
1028
1161
  })
1029
1162
  )
1030
1163
  );
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()
1164
+ var textEditor_20250728InputSchema = lazySchema4(
1165
+ () => zodSchema4(
1166
+ z5.object({
1167
+ command: z5.enum(["view", "create", "str_replace", "insert"]),
1168
+ path: z5.string(),
1169
+ file_text: z5.string().optional(),
1170
+ insert_line: z5.number().int().optional(),
1171
+ new_str: z5.string().optional(),
1172
+ insert_text: z5.string().optional(),
1173
+ old_str: z5.string().optional(),
1174
+ view_range: z5.array(z5.number().int()).optional()
1042
1175
  })
1043
1176
  )
1044
1177
  );
1045
- var factory = (0, import_provider_utils3.createProviderToolFactory)({
1178
+ var factory = createProviderDefinedToolFactory({
1046
1179
  id: "anthropic.text_editor_20250728",
1047
1180
  inputSchema: textEditor_20250728InputSchema
1048
1181
  });
@@ -1051,45 +1184,49 @@ var textEditor_20250728 = (args = {}) => {
1051
1184
  };
1052
1185
 
1053
1186
  // 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()
1187
+ import {
1188
+ createProviderExecutedToolFactory,
1189
+ lazySchema as lazySchema5,
1190
+ zodSchema as zodSchema5
1191
+ } from "@ai-sdk/provider-utils";
1192
+ import { z as z6 } from "zod/v4";
1193
+ var webSearch_20260209ArgsSchema = lazySchema5(
1194
+ () => zodSchema5(
1195
+ z6.object({
1196
+ maxUses: z6.number().optional(),
1197
+ allowedDomains: z6.array(z6.string()).optional(),
1198
+ blockedDomains: z6.array(z6.string()).optional(),
1199
+ userLocation: z6.object({
1200
+ type: z6.literal("approximate"),
1201
+ city: z6.string().optional(),
1202
+ region: z6.string().optional(),
1203
+ country: z6.string().optional(),
1204
+ timezone: z6.string().optional()
1068
1205
  }).optional()
1069
1206
  })
1070
1207
  )
1071
1208
  );
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")
1209
+ var webSearch_20260209OutputSchema = lazySchema5(
1210
+ () => zodSchema5(
1211
+ z6.array(
1212
+ z6.object({
1213
+ url: z6.string(),
1214
+ title: z6.string().nullable(),
1215
+ pageAge: z6.string().nullable(),
1216
+ encryptedContent: z6.string(),
1217
+ type: z6.literal("web_search_result")
1081
1218
  })
1082
1219
  )
1083
1220
  )
1084
1221
  );
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()
1222
+ var webSearch_20260209InputSchema = lazySchema5(
1223
+ () => zodSchema5(
1224
+ z6.object({
1225
+ query: z6.string()
1089
1226
  })
1090
1227
  )
1091
1228
  );
1092
- var factory2 = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
1229
+ var factory2 = createProviderExecutedToolFactory({
1093
1230
  id: "anthropic.web_search_20260209",
1094
1231
  inputSchema: webSearch_20260209InputSchema,
1095
1232
  outputSchema: webSearch_20260209OutputSchema,
@@ -1100,45 +1237,49 @@ var webSearch_20260209 = (args = {}) => {
1100
1237
  };
1101
1238
 
1102
1239
  // 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()
1240
+ import {
1241
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
1242
+ lazySchema as lazySchema6,
1243
+ zodSchema as zodSchema6
1244
+ } from "@ai-sdk/provider-utils";
1245
+ import { z as z7 } from "zod/v4";
1246
+ var webSearch_20250305ArgsSchema = lazySchema6(
1247
+ () => zodSchema6(
1248
+ z7.object({
1249
+ maxUses: z7.number().optional(),
1250
+ allowedDomains: z7.array(z7.string()).optional(),
1251
+ blockedDomains: z7.array(z7.string()).optional(),
1252
+ userLocation: z7.object({
1253
+ type: z7.literal("approximate"),
1254
+ city: z7.string().optional(),
1255
+ region: z7.string().optional(),
1256
+ country: z7.string().optional(),
1257
+ timezone: z7.string().optional()
1117
1258
  }).optional()
1118
1259
  })
1119
1260
  )
1120
1261
  );
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")
1262
+ var webSearch_20250305OutputSchema = lazySchema6(
1263
+ () => zodSchema6(
1264
+ z7.array(
1265
+ z7.object({
1266
+ url: z7.string(),
1267
+ title: z7.string().nullable(),
1268
+ pageAge: z7.string().nullable(),
1269
+ encryptedContent: z7.string(),
1270
+ type: z7.literal("web_search_result")
1130
1271
  })
1131
1272
  )
1132
1273
  )
1133
1274
  );
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()
1275
+ var webSearch_20250305InputSchema = lazySchema6(
1276
+ () => zodSchema6(
1277
+ z7.object({
1278
+ query: z7.string()
1138
1279
  })
1139
1280
  )
1140
1281
  );
1141
- var factory3 = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
1282
+ var factory3 = createProviderExecutedToolFactory2({
1142
1283
  id: "anthropic.web_search_20250305",
1143
1284
  inputSchema: webSearch_20250305InputSchema,
1144
1285
  outputSchema: webSearch_20250305OutputSchema,
@@ -1149,53 +1290,57 @@ var webSearch_20250305 = (args = {}) => {
1149
1290
  };
1150
1291
 
1151
1292
  // 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()
1293
+ import {
1294
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
1295
+ lazySchema as lazySchema7,
1296
+ zodSchema as zodSchema7
1297
+ } from "@ai-sdk/provider-utils";
1298
+ import { z as z8 } from "zod/v4";
1299
+ var webFetch_20260209ArgsSchema = lazySchema7(
1300
+ () => zodSchema7(
1301
+ z8.object({
1302
+ maxUses: z8.number().optional(),
1303
+ allowedDomains: z8.array(z8.string()).optional(),
1304
+ blockedDomains: z8.array(z8.string()).optional(),
1305
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1306
+ maxContentTokens: z8.number().optional()
1162
1307
  })
1163
1308
  )
1164
1309
  );
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()
1310
+ var webFetch_20260209OutputSchema = lazySchema7(
1311
+ () => zodSchema7(
1312
+ z8.object({
1313
+ type: z8.literal("web_fetch_result"),
1314
+ url: z8.string(),
1315
+ content: z8.object({
1316
+ type: z8.literal("document"),
1317
+ title: z8.string().nullable(),
1318
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1319
+ source: z8.union([
1320
+ z8.object({
1321
+ type: z8.literal("base64"),
1322
+ mediaType: z8.literal("application/pdf"),
1323
+ data: z8.string()
1179
1324
  }),
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()
1325
+ z8.object({
1326
+ type: z8.literal("text"),
1327
+ mediaType: z8.literal("text/plain"),
1328
+ data: z8.string()
1184
1329
  })
1185
1330
  ])
1186
1331
  }),
1187
- retrievedAt: import_v47.z.string().nullable()
1332
+ retrievedAt: z8.string().nullable()
1188
1333
  })
1189
1334
  )
1190
1335
  );
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()
1336
+ var webFetch_20260209InputSchema = lazySchema7(
1337
+ () => zodSchema7(
1338
+ z8.object({
1339
+ url: z8.string()
1195
1340
  })
1196
1341
  )
1197
1342
  );
1198
- var factory4 = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
1343
+ var factory4 = createProviderExecutedToolFactory3({
1199
1344
  id: "anthropic.web_fetch_20260209",
1200
1345
  inputSchema: webFetch_20260209InputSchema,
1201
1346
  outputSchema: webFetch_20260209OutputSchema,
@@ -1206,53 +1351,57 @@ var webFetch_20260209 = (args = {}) => {
1206
1351
  };
1207
1352
 
1208
1353
  // 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()
1354
+ import {
1355
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
1356
+ lazySchema as lazySchema8,
1357
+ zodSchema as zodSchema8
1358
+ } from "@ai-sdk/provider-utils";
1359
+ import { z as z9 } from "zod/v4";
1360
+ var webFetch_20250910ArgsSchema = lazySchema8(
1361
+ () => zodSchema8(
1362
+ z9.object({
1363
+ maxUses: z9.number().optional(),
1364
+ allowedDomains: z9.array(z9.string()).optional(),
1365
+ blockedDomains: z9.array(z9.string()).optional(),
1366
+ citations: z9.object({ enabled: z9.boolean() }).optional(),
1367
+ maxContentTokens: z9.number().optional()
1219
1368
  })
1220
1369
  )
1221
1370
  );
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()
1371
+ var webFetch_20250910OutputSchema = lazySchema8(
1372
+ () => zodSchema8(
1373
+ z9.object({
1374
+ type: z9.literal("web_fetch_result"),
1375
+ url: z9.string(),
1376
+ content: z9.object({
1377
+ type: z9.literal("document"),
1378
+ title: z9.string().nullable(),
1379
+ citations: z9.object({ enabled: z9.boolean() }).optional(),
1380
+ source: z9.union([
1381
+ z9.object({
1382
+ type: z9.literal("base64"),
1383
+ mediaType: z9.literal("application/pdf"),
1384
+ data: z9.string()
1236
1385
  }),
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()
1386
+ z9.object({
1387
+ type: z9.literal("text"),
1388
+ mediaType: z9.literal("text/plain"),
1389
+ data: z9.string()
1241
1390
  })
1242
1391
  ])
1243
1392
  }),
1244
- retrievedAt: import_v48.z.string().nullable()
1393
+ retrievedAt: z9.string().nullable()
1245
1394
  })
1246
1395
  )
1247
1396
  );
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()
1397
+ var webFetch_20250910InputSchema = lazySchema8(
1398
+ () => zodSchema8(
1399
+ z9.object({
1400
+ url: z9.string()
1252
1401
  })
1253
1402
  )
1254
1403
  );
1255
- var factory5 = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
1404
+ var factory5 = createProviderExecutedToolFactory4({
1256
1405
  id: "anthropic.web_fetch_20250910",
1257
1406
  inputSchema: webFetch_20250910InputSchema,
1258
1407
  outputSchema: webFetch_20250910OutputSchema,
@@ -1263,16 +1412,17 @@ var webFetch_20250910 = (args = {}) => {
1263
1412
  };
1264
1413
 
1265
1414
  // src/anthropic-prepare-tools.ts
1266
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1415
+ import { validateTypes } from "@ai-sdk/provider-utils";
1267
1416
  async function prepareTools({
1268
1417
  tools,
1269
1418
  toolChoice,
1270
1419
  disableParallelToolUse,
1271
1420
  cacheControlValidator,
1272
1421
  supportsStructuredOutput,
1273
- supportsStrictTools
1422
+ supportsStrictTools,
1423
+ defaultEagerInputStreaming = false
1274
1424
  }) {
1275
- var _a;
1425
+ var _a, _b;
1276
1426
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
1277
1427
  const toolWarnings = [];
1278
1428
  const betas = /* @__PURE__ */ new Set();
@@ -1289,7 +1439,7 @@ async function prepareTools({
1289
1439
  canCache: true
1290
1440
  });
1291
1441
  const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
1292
- const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
1442
+ const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
1293
1443
  const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
1294
1444
  const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
1295
1445
  if (!supportsStrictTools && tool.strict != null) {
@@ -1413,7 +1563,7 @@ async function prepareTools({
1413
1563
  break;
1414
1564
  }
1415
1565
  case "anthropic.text_editor_20250728": {
1416
- const args = await (0, import_provider_utils9.validateTypes)({
1566
+ const args = await validateTypes({
1417
1567
  value: tool.args,
1418
1568
  schema: textEditor_20250728ArgsSchema
1419
1569
  });
@@ -1453,7 +1603,7 @@ async function prepareTools({
1453
1603
  }
1454
1604
  case "anthropic.web_fetch_20250910": {
1455
1605
  betas.add("web-fetch-2025-09-10");
1456
- const args = await (0, import_provider_utils9.validateTypes)({
1606
+ const args = await validateTypes({
1457
1607
  value: tool.args,
1458
1608
  schema: webFetch_20250910ArgsSchema
1459
1609
  });
@@ -1471,7 +1621,7 @@ async function prepareTools({
1471
1621
  }
1472
1622
  case "anthropic.web_fetch_20260209": {
1473
1623
  betas.add("code-execution-web-tools-2026-02-09");
1474
- const args = await (0, import_provider_utils9.validateTypes)({
1624
+ const args = await validateTypes({
1475
1625
  value: tool.args,
1476
1626
  schema: webFetch_20260209ArgsSchema
1477
1627
  });
@@ -1488,7 +1638,7 @@ async function prepareTools({
1488
1638
  break;
1489
1639
  }
1490
1640
  case "anthropic.web_search_20250305": {
1491
- const args = await (0, import_provider_utils9.validateTypes)({
1641
+ const args = await validateTypes({
1492
1642
  value: tool.args,
1493
1643
  schema: webSearch_20250305ArgsSchema
1494
1644
  });
@@ -1505,7 +1655,7 @@ async function prepareTools({
1505
1655
  }
1506
1656
  case "anthropic.web_search_20260209": {
1507
1657
  betas.add("code-execution-web-tools-2026-02-09");
1508
- const args = await (0, import_provider_utils9.validateTypes)({
1658
+ const args = await validateTypes({
1509
1659
  value: tool.args,
1510
1660
  schema: webSearch_20260209ArgsSchema
1511
1661
  });
@@ -1521,7 +1671,6 @@ async function prepareTools({
1521
1671
  break;
1522
1672
  }
1523
1673
  case "anthropic.tool_search_regex_20251119": {
1524
- betas.add("advanced-tool-use-2025-11-20");
1525
1674
  anthropicTools2.push({
1526
1675
  type: "tool_search_tool_regex_20251119",
1527
1676
  name: "tool_search_tool_regex"
@@ -1529,7 +1678,6 @@ async function prepareTools({
1529
1678
  break;
1530
1679
  }
1531
1680
  case "anthropic.tool_search_bm25_20251119": {
1532
- betas.add("advanced-tool-use-2025-11-20");
1533
1681
  anthropicTools2.push({
1534
1682
  type: "tool_search_tool_bm25_20251119",
1535
1683
  name: "tool_search_tool_bm25"
@@ -1600,15 +1748,15 @@ async function prepareTools({
1600
1748
  };
1601
1749
  default: {
1602
1750
  const _exhaustiveCheck = type;
1603
- throw new import_provider.UnsupportedFunctionalityError({
1751
+ throw new UnsupportedFunctionalityError({
1604
1752
  functionality: `tool choice type: ${_exhaustiveCheck}`
1605
1753
  });
1606
1754
  }
1607
1755
  }
1608
1756
  }
1609
1757
 
1610
- // src/convert-anthropic-messages-usage.ts
1611
- function convertAnthropicMessagesUsage({
1758
+ // src/convert-anthropic-usage.ts
1759
+ function convertAnthropicUsage({
1612
1760
  usage,
1613
1761
  rawUsage
1614
1762
  }) {
@@ -1647,37 +1795,52 @@ function convertAnthropicMessagesUsage({
1647
1795
  };
1648
1796
  }
1649
1797
 
1650
- // src/convert-to-anthropic-messages-prompt.ts
1651
- var import_provider2 = require("@ai-sdk/provider");
1652
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
1798
+ // src/convert-to-anthropic-prompt.ts
1799
+ import {
1800
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
1801
+ } from "@ai-sdk/provider";
1802
+ import {
1803
+ convertBase64ToUint8Array,
1804
+ convertToBase64,
1805
+ getTopLevelMediaType,
1806
+ parseProviderOptions,
1807
+ resolveFullMediaType,
1808
+ resolveProviderReference,
1809
+ validateTypes as validateTypes2,
1810
+ isNonNullable
1811
+ } from "@ai-sdk/provider-utils";
1653
1812
 
1654
1813
  // src/tool/code-execution_20250522.ts
1655
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1656
- var import_v49 = require("zod/v4");
1657
- var codeExecution_20250522OutputSchema = (0, import_provider_utils10.lazySchema)(
1658
- () => (0, import_provider_utils10.zodSchema)(
1659
- import_v49.z.object({
1660
- type: import_v49.z.literal("code_execution_result"),
1661
- stdout: import_v49.z.string(),
1662
- stderr: import_v49.z.string(),
1663
- return_code: import_v49.z.number(),
1664
- content: import_v49.z.array(
1665
- import_v49.z.object({
1666
- type: import_v49.z.literal("code_execution_output"),
1667
- file_id: import_v49.z.string()
1814
+ import {
1815
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
1816
+ lazySchema as lazySchema9,
1817
+ zodSchema as zodSchema9
1818
+ } from "@ai-sdk/provider-utils";
1819
+ import { z as z10 } from "zod/v4";
1820
+ var codeExecution_20250522OutputSchema = lazySchema9(
1821
+ () => zodSchema9(
1822
+ z10.object({
1823
+ type: z10.literal("code_execution_result"),
1824
+ stdout: z10.string(),
1825
+ stderr: z10.string(),
1826
+ return_code: z10.number(),
1827
+ content: z10.array(
1828
+ z10.object({
1829
+ type: z10.literal("code_execution_output"),
1830
+ file_id: z10.string()
1668
1831
  })
1669
1832
  ).optional().default([])
1670
1833
  })
1671
1834
  )
1672
1835
  );
1673
- var codeExecution_20250522InputSchema = (0, import_provider_utils10.lazySchema)(
1674
- () => (0, import_provider_utils10.zodSchema)(
1675
- import_v49.z.object({
1676
- code: import_v49.z.string()
1836
+ var codeExecution_20250522InputSchema = lazySchema9(
1837
+ () => zodSchema9(
1838
+ z10.object({
1839
+ code: z10.string()
1677
1840
  })
1678
1841
  )
1679
1842
  );
1680
- var factory6 = (0, import_provider_utils10.createProviderToolFactoryWithOutputSchema)({
1843
+ var factory6 = createProviderExecutedToolFactory5({
1681
1844
  id: "anthropic.code_execution_20250522",
1682
1845
  inputSchema: codeExecution_20250522InputSchema,
1683
1846
  outputSchema: codeExecution_20250522OutputSchema
@@ -1687,102 +1850,106 @@ var codeExecution_20250522 = (args = {}) => {
1687
1850
  };
1688
1851
 
1689
1852
  // src/tool/code-execution_20250825.ts
1690
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1691
- var import_v410 = require("zod/v4");
1692
- var codeExecution_20250825OutputSchema = (0, import_provider_utils11.lazySchema)(
1693
- () => (0, import_provider_utils11.zodSchema)(
1694
- import_v410.z.discriminatedUnion("type", [
1695
- import_v410.z.object({
1696
- type: import_v410.z.literal("code_execution_result"),
1697
- stdout: import_v410.z.string(),
1698
- stderr: import_v410.z.string(),
1699
- return_code: import_v410.z.number(),
1700
- content: import_v410.z.array(
1701
- import_v410.z.object({
1702
- type: import_v410.z.literal("code_execution_output"),
1703
- file_id: import_v410.z.string()
1853
+ import {
1854
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
1855
+ lazySchema as lazySchema10,
1856
+ zodSchema as zodSchema10
1857
+ } from "@ai-sdk/provider-utils";
1858
+ import { z as z11 } from "zod/v4";
1859
+ var codeExecution_20250825OutputSchema = lazySchema10(
1860
+ () => zodSchema10(
1861
+ z11.discriminatedUnion("type", [
1862
+ z11.object({
1863
+ type: z11.literal("code_execution_result"),
1864
+ stdout: z11.string(),
1865
+ stderr: z11.string(),
1866
+ return_code: z11.number(),
1867
+ content: z11.array(
1868
+ z11.object({
1869
+ type: z11.literal("code_execution_output"),
1870
+ file_id: z11.string()
1704
1871
  })
1705
1872
  ).optional().default([])
1706
1873
  }),
1707
- import_v410.z.object({
1708
- type: import_v410.z.literal("bash_code_execution_result"),
1709
- content: import_v410.z.array(
1710
- import_v410.z.object({
1711
- type: import_v410.z.literal("bash_code_execution_output"),
1712
- file_id: import_v410.z.string()
1874
+ z11.object({
1875
+ type: z11.literal("bash_code_execution_result"),
1876
+ content: z11.array(
1877
+ z11.object({
1878
+ type: z11.literal("bash_code_execution_output"),
1879
+ file_id: z11.string()
1713
1880
  })
1714
1881
  ),
1715
- stdout: import_v410.z.string(),
1716
- stderr: import_v410.z.string(),
1717
- return_code: import_v410.z.number()
1882
+ stdout: z11.string(),
1883
+ stderr: z11.string(),
1884
+ return_code: z11.number()
1718
1885
  }),
1719
- import_v410.z.object({
1720
- type: import_v410.z.literal("bash_code_execution_tool_result_error"),
1721
- error_code: import_v410.z.string()
1886
+ z11.object({
1887
+ type: z11.literal("bash_code_execution_tool_result_error"),
1888
+ error_code: z11.string()
1722
1889
  }),
1723
- import_v410.z.object({
1724
- type: import_v410.z.literal("text_editor_code_execution_tool_result_error"),
1725
- error_code: import_v410.z.string()
1890
+ z11.object({
1891
+ type: z11.literal("text_editor_code_execution_tool_result_error"),
1892
+ error_code: z11.string()
1726
1893
  }),
1727
- import_v410.z.object({
1728
- type: import_v410.z.literal("text_editor_code_execution_view_result"),
1729
- content: import_v410.z.string(),
1730
- file_type: import_v410.z.string(),
1731
- num_lines: import_v410.z.number().nullable(),
1732
- start_line: import_v410.z.number().nullable(),
1733
- total_lines: import_v410.z.number().nullable()
1894
+ z11.object({
1895
+ type: z11.literal("text_editor_code_execution_view_result"),
1896
+ content: z11.string(),
1897
+ file_type: z11.string(),
1898
+ num_lines: z11.number().nullable(),
1899
+ start_line: z11.number().nullable(),
1900
+ total_lines: z11.number().nullable()
1734
1901
  }),
1735
- import_v410.z.object({
1736
- type: import_v410.z.literal("text_editor_code_execution_create_result"),
1737
- is_file_update: import_v410.z.boolean()
1902
+ z11.object({
1903
+ type: z11.literal("text_editor_code_execution_create_result"),
1904
+ is_file_update: z11.boolean()
1738
1905
  }),
1739
- import_v410.z.object({
1740
- type: import_v410.z.literal("text_editor_code_execution_str_replace_result"),
1741
- lines: import_v410.z.array(import_v410.z.string()).nullable(),
1742
- new_lines: import_v410.z.number().nullable(),
1743
- new_start: import_v410.z.number().nullable(),
1744
- old_lines: import_v410.z.number().nullable(),
1745
- old_start: import_v410.z.number().nullable()
1906
+ z11.object({
1907
+ type: z11.literal("text_editor_code_execution_str_replace_result"),
1908
+ lines: z11.array(z11.string()).nullable(),
1909
+ new_lines: z11.number().nullable(),
1910
+ new_start: z11.number().nullable(),
1911
+ old_lines: z11.number().nullable(),
1912
+ old_start: z11.number().nullable()
1746
1913
  })
1747
1914
  ])
1748
1915
  )
1749
1916
  );
1750
- var codeExecution_20250825InputSchema = (0, import_provider_utils11.lazySchema)(
1751
- () => (0, import_provider_utils11.zodSchema)(
1752
- import_v410.z.discriminatedUnion("type", [
1917
+ var codeExecution_20250825InputSchema = lazySchema10(
1918
+ () => zodSchema10(
1919
+ z11.discriminatedUnion("type", [
1753
1920
  // Programmatic tool calling format (mapped from { code } by AI SDK)
1754
- import_v410.z.object({
1755
- type: import_v410.z.literal("programmatic-tool-call"),
1756
- code: import_v410.z.string()
1921
+ z11.object({
1922
+ type: z11.literal("programmatic-tool-call"),
1923
+ code: z11.string()
1757
1924
  }),
1758
- import_v410.z.object({
1759
- type: import_v410.z.literal("bash_code_execution"),
1760
- command: import_v410.z.string()
1925
+ z11.object({
1926
+ type: z11.literal("bash_code_execution"),
1927
+ command: z11.string()
1761
1928
  }),
1762
- import_v410.z.discriminatedUnion("command", [
1763
- import_v410.z.object({
1764
- type: import_v410.z.literal("text_editor_code_execution"),
1765
- command: import_v410.z.literal("view"),
1766
- path: import_v410.z.string()
1929
+ z11.discriminatedUnion("command", [
1930
+ z11.object({
1931
+ type: z11.literal("text_editor_code_execution"),
1932
+ command: z11.literal("view"),
1933
+ path: z11.string()
1767
1934
  }),
1768
- import_v410.z.object({
1769
- type: import_v410.z.literal("text_editor_code_execution"),
1770
- command: import_v410.z.literal("create"),
1771
- path: import_v410.z.string(),
1772
- file_text: import_v410.z.string().nullish()
1935
+ z11.object({
1936
+ type: z11.literal("text_editor_code_execution"),
1937
+ command: z11.literal("create"),
1938
+ path: z11.string(),
1939
+ file_text: z11.string().nullish()
1773
1940
  }),
1774
- import_v410.z.object({
1775
- type: import_v410.z.literal("text_editor_code_execution"),
1776
- command: import_v410.z.literal("str_replace"),
1777
- path: import_v410.z.string(),
1778
- old_str: import_v410.z.string(),
1779
- new_str: import_v410.z.string()
1941
+ z11.object({
1942
+ type: z11.literal("text_editor_code_execution"),
1943
+ command: z11.literal("str_replace"),
1944
+ path: z11.string(),
1945
+ old_str: z11.string(),
1946
+ new_str: z11.string()
1780
1947
  })
1781
1948
  ])
1782
1949
  ])
1783
1950
  )
1784
1951
  );
1785
- var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
1952
+ var factory7 = createProviderExecutedToolFactory6({
1786
1953
  id: "anthropic.code_execution_20250825",
1787
1954
  inputSchema: codeExecution_20250825InputSchema,
1788
1955
  outputSchema: codeExecution_20250825OutputSchema,
@@ -1796,113 +1963,117 @@ var codeExecution_20250825 = (args = {}) => {
1796
1963
  };
1797
1964
 
1798
1965
  // src/tool/code-execution_20260120.ts
1799
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
1800
- var import_v411 = require("zod/v4");
1801
- var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)(
1802
- () => (0, import_provider_utils12.zodSchema)(
1803
- import_v411.z.discriminatedUnion("type", [
1804
- import_v411.z.object({
1805
- type: import_v411.z.literal("code_execution_result"),
1806
- stdout: import_v411.z.string(),
1807
- stderr: import_v411.z.string(),
1808
- return_code: import_v411.z.number(),
1809
- content: import_v411.z.array(
1810
- import_v411.z.object({
1811
- type: import_v411.z.literal("code_execution_output"),
1812
- file_id: import_v411.z.string()
1966
+ import {
1967
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
1968
+ lazySchema as lazySchema11,
1969
+ zodSchema as zodSchema11
1970
+ } from "@ai-sdk/provider-utils";
1971
+ import { z as z12 } from "zod/v4";
1972
+ var codeExecution_20260120OutputSchema = lazySchema11(
1973
+ () => zodSchema11(
1974
+ z12.discriminatedUnion("type", [
1975
+ z12.object({
1976
+ type: z12.literal("code_execution_result"),
1977
+ stdout: z12.string(),
1978
+ stderr: z12.string(),
1979
+ return_code: z12.number(),
1980
+ content: z12.array(
1981
+ z12.object({
1982
+ type: z12.literal("code_execution_output"),
1983
+ file_id: z12.string()
1813
1984
  })
1814
1985
  ).optional().default([])
1815
1986
  }),
1816
- import_v411.z.object({
1817
- type: import_v411.z.literal("encrypted_code_execution_result"),
1818
- encrypted_stdout: import_v411.z.string(),
1819
- stderr: import_v411.z.string(),
1820
- return_code: import_v411.z.number(),
1821
- content: import_v411.z.array(
1822
- import_v411.z.object({
1823
- type: import_v411.z.literal("code_execution_output"),
1824
- file_id: import_v411.z.string()
1987
+ z12.object({
1988
+ type: z12.literal("encrypted_code_execution_result"),
1989
+ encrypted_stdout: z12.string(),
1990
+ stderr: z12.string(),
1991
+ return_code: z12.number(),
1992
+ content: z12.array(
1993
+ z12.object({
1994
+ type: z12.literal("code_execution_output"),
1995
+ file_id: z12.string()
1825
1996
  })
1826
1997
  ).optional().default([])
1827
1998
  }),
1828
- import_v411.z.object({
1829
- type: import_v411.z.literal("bash_code_execution_result"),
1830
- content: import_v411.z.array(
1831
- import_v411.z.object({
1832
- type: import_v411.z.literal("bash_code_execution_output"),
1833
- file_id: import_v411.z.string()
1999
+ z12.object({
2000
+ type: z12.literal("bash_code_execution_result"),
2001
+ content: z12.array(
2002
+ z12.object({
2003
+ type: z12.literal("bash_code_execution_output"),
2004
+ file_id: z12.string()
1834
2005
  })
1835
2006
  ),
1836
- stdout: import_v411.z.string(),
1837
- stderr: import_v411.z.string(),
1838
- return_code: import_v411.z.number()
2007
+ stdout: z12.string(),
2008
+ stderr: z12.string(),
2009
+ return_code: z12.number()
1839
2010
  }),
1840
- import_v411.z.object({
1841
- type: import_v411.z.literal("bash_code_execution_tool_result_error"),
1842
- error_code: import_v411.z.string()
2011
+ z12.object({
2012
+ type: z12.literal("bash_code_execution_tool_result_error"),
2013
+ error_code: z12.string()
1843
2014
  }),
1844
- import_v411.z.object({
1845
- type: import_v411.z.literal("text_editor_code_execution_tool_result_error"),
1846
- error_code: import_v411.z.string()
2015
+ z12.object({
2016
+ type: z12.literal("text_editor_code_execution_tool_result_error"),
2017
+ error_code: z12.string()
1847
2018
  }),
1848
- import_v411.z.object({
1849
- type: import_v411.z.literal("text_editor_code_execution_view_result"),
1850
- content: import_v411.z.string(),
1851
- file_type: import_v411.z.string(),
1852
- num_lines: import_v411.z.number().nullable(),
1853
- start_line: import_v411.z.number().nullable(),
1854
- total_lines: import_v411.z.number().nullable()
2019
+ z12.object({
2020
+ type: z12.literal("text_editor_code_execution_view_result"),
2021
+ content: z12.string(),
2022
+ file_type: z12.string(),
2023
+ num_lines: z12.number().nullable(),
2024
+ start_line: z12.number().nullable(),
2025
+ total_lines: z12.number().nullable()
1855
2026
  }),
1856
- import_v411.z.object({
1857
- type: import_v411.z.literal("text_editor_code_execution_create_result"),
1858
- is_file_update: import_v411.z.boolean()
2027
+ z12.object({
2028
+ type: z12.literal("text_editor_code_execution_create_result"),
2029
+ is_file_update: z12.boolean()
1859
2030
  }),
1860
- import_v411.z.object({
1861
- type: import_v411.z.literal("text_editor_code_execution_str_replace_result"),
1862
- lines: import_v411.z.array(import_v411.z.string()).nullable(),
1863
- new_lines: import_v411.z.number().nullable(),
1864
- new_start: import_v411.z.number().nullable(),
1865
- old_lines: import_v411.z.number().nullable(),
1866
- old_start: import_v411.z.number().nullable()
2031
+ z12.object({
2032
+ type: z12.literal("text_editor_code_execution_str_replace_result"),
2033
+ lines: z12.array(z12.string()).nullable(),
2034
+ new_lines: z12.number().nullable(),
2035
+ new_start: z12.number().nullable(),
2036
+ old_lines: z12.number().nullable(),
2037
+ old_start: z12.number().nullable()
1867
2038
  })
1868
2039
  ])
1869
2040
  )
1870
2041
  );
1871
- var codeExecution_20260120InputSchema = (0, import_provider_utils12.lazySchema)(
1872
- () => (0, import_provider_utils12.zodSchema)(
1873
- import_v411.z.discriminatedUnion("type", [
1874
- import_v411.z.object({
1875
- type: import_v411.z.literal("programmatic-tool-call"),
1876
- code: import_v411.z.string()
2042
+ var codeExecution_20260120InputSchema = lazySchema11(
2043
+ () => zodSchema11(
2044
+ z12.discriminatedUnion("type", [
2045
+ z12.object({
2046
+ type: z12.literal("programmatic-tool-call"),
2047
+ code: z12.string()
1877
2048
  }),
1878
- import_v411.z.object({
1879
- type: import_v411.z.literal("bash_code_execution"),
1880
- command: import_v411.z.string()
2049
+ z12.object({
2050
+ type: z12.literal("bash_code_execution"),
2051
+ command: z12.string()
1881
2052
  }),
1882
- import_v411.z.discriminatedUnion("command", [
1883
- import_v411.z.object({
1884
- type: import_v411.z.literal("text_editor_code_execution"),
1885
- command: import_v411.z.literal("view"),
1886
- path: import_v411.z.string()
2053
+ z12.discriminatedUnion("command", [
2054
+ z12.object({
2055
+ type: z12.literal("text_editor_code_execution"),
2056
+ command: z12.literal("view"),
2057
+ path: z12.string()
1887
2058
  }),
1888
- import_v411.z.object({
1889
- type: import_v411.z.literal("text_editor_code_execution"),
1890
- command: import_v411.z.literal("create"),
1891
- path: import_v411.z.string(),
1892
- file_text: import_v411.z.string().nullish()
2059
+ z12.object({
2060
+ type: z12.literal("text_editor_code_execution"),
2061
+ command: z12.literal("create"),
2062
+ path: z12.string(),
2063
+ file_text: z12.string().nullish()
1893
2064
  }),
1894
- import_v411.z.object({
1895
- type: import_v411.z.literal("text_editor_code_execution"),
1896
- command: import_v411.z.literal("str_replace"),
1897
- path: import_v411.z.string(),
1898
- old_str: import_v411.z.string(),
1899
- new_str: import_v411.z.string()
2065
+ z12.object({
2066
+ type: z12.literal("text_editor_code_execution"),
2067
+ command: z12.literal("str_replace"),
2068
+ path: z12.string(),
2069
+ old_str: z12.string(),
2070
+ new_str: z12.string()
1900
2071
  })
1901
2072
  ])
1902
2073
  ])
1903
2074
  )
1904
2075
  );
1905
- var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
2076
+ var factory8 = createProviderExecutedToolFactory7({
1906
2077
  id: "anthropic.code_execution_20260120",
1907
2078
  inputSchema: codeExecution_20260120InputSchema,
1908
2079
  outputSchema: codeExecution_20260120OutputSchema,
@@ -1913,21 +2084,25 @@ var codeExecution_20260120 = (args = {}) => {
1913
2084
  };
1914
2085
 
1915
2086
  // src/tool/tool-search-regex_20251119.ts
1916
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
1917
- var import_v412 = require("zod/v4");
1918
- var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils13.lazySchema)(
1919
- () => (0, import_provider_utils13.zodSchema)(
1920
- import_v412.z.array(
1921
- import_v412.z.object({
1922
- type: import_v412.z.literal("tool_reference"),
1923
- toolName: import_v412.z.string()
2087
+ import {
2088
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory8,
2089
+ lazySchema as lazySchema12,
2090
+ zodSchema as zodSchema12
2091
+ } from "@ai-sdk/provider-utils";
2092
+ import { z as z13 } from "zod/v4";
2093
+ var toolSearchRegex_20251119OutputSchema = lazySchema12(
2094
+ () => zodSchema12(
2095
+ z13.array(
2096
+ z13.object({
2097
+ type: z13.literal("tool_reference"),
2098
+ toolName: z13.string()
1924
2099
  })
1925
2100
  )
1926
2101
  )
1927
2102
  );
1928
- var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema)(
1929
- () => (0, import_provider_utils13.zodSchema)(
1930
- import_v412.z.object({
2103
+ var toolSearchRegex_20251119InputSchema = lazySchema12(
2104
+ () => zodSchema12(
2105
+ z13.object({
1931
2106
  /**
1932
2107
  * A regex pattern to search for tools.
1933
2108
  * Uses Python re.search() syntax. Maximum 200 characters.
@@ -1938,15 +2113,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
1938
2113
  * - "database.*query|query.*database" - OR patterns for flexibility
1939
2114
  * - "(?i)slack" - case-insensitive search
1940
2115
  */
1941
- pattern: import_v412.z.string(),
2116
+ pattern: z13.string(),
1942
2117
  /**
1943
2118
  * Maximum number of tools to return. Optional.
1944
2119
  */
1945
- limit: import_v412.z.number().optional()
2120
+ limit: z13.number().optional()
1946
2121
  })
1947
2122
  )
1948
2123
  );
1949
- var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
2124
+ var factory9 = createProviderExecutedToolFactory8({
1950
2125
  id: "anthropic.tool_search_regex_20251119",
1951
2126
  inputSchema: toolSearchRegex_20251119InputSchema,
1952
2127
  outputSchema: toolSearchRegex_20251119OutputSchema,
@@ -1956,40 +2131,21 @@ var toolSearchRegex_20251119 = (args = {}) => {
1956
2131
  return factory9(args);
1957
2132
  };
1958
2133
 
1959
- // src/convert-to-anthropic-messages-prompt.ts
1960
- function convertToString(data) {
2134
+ // src/convert-to-anthropic-prompt.ts
2135
+ function convertBytesDataToString(data) {
1961
2136
  if (typeof data === "string") {
1962
- return new TextDecoder().decode((0, import_provider_utils14.convertBase64ToUint8Array)(data));
1963
- }
1964
- if (data instanceof Uint8Array) {
1965
- return new TextDecoder().decode(data);
1966
- }
1967
- if (data instanceof URL) {
1968
- throw new import_provider2.UnsupportedFunctionalityError({
1969
- functionality: "URL-based text documents are not supported for citations"
1970
- });
2137
+ return new TextDecoder().decode(convertBase64ToUint8Array(data));
1971
2138
  }
1972
- throw new import_provider2.UnsupportedFunctionalityError({
1973
- functionality: `unsupported data type for text documents: ${typeof data}`
1974
- });
1975
- }
1976
- function isUrlData(data) {
1977
- return data instanceof URL || isUrlString(data);
1978
- }
1979
- function isUrlString(data) {
1980
- return typeof data === "string" && /^https?:\/\//i.test(data);
1981
- }
1982
- function getUrlString(data) {
1983
- return data instanceof URL ? data.toString() : data;
2139
+ return new TextDecoder().decode(data);
1984
2140
  }
1985
- async function convertToAnthropicMessagesPrompt({
2141
+ async function convertToAnthropicPrompt({
1986
2142
  prompt,
1987
2143
  sendReasoning,
1988
2144
  warnings,
1989
2145
  cacheControlValidator,
1990
2146
  toolNameMapping
1991
2147
  }) {
1992
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
2148
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
1993
2149
  const betas = /* @__PURE__ */ new Set();
1994
2150
  const blocks = groupIntoBlocks(prompt);
1995
2151
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -1997,7 +2153,7 @@ async function convertToAnthropicMessagesPrompt({
1997
2153
  const messages = [];
1998
2154
  async function shouldEnableCitations(providerMetadata) {
1999
2155
  var _a2, _b2;
2000
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2156
+ const anthropicOptions = await parseProviderOptions({
2001
2157
  provider: "anthropic",
2002
2158
  providerOptions: providerMetadata,
2003
2159
  schema: anthropicFilePartProviderOptions
@@ -2005,7 +2161,7 @@ async function convertToAnthropicMessagesPrompt({
2005
2161
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
2006
2162
  }
2007
2163
  async function getDocumentMetadata(providerMetadata) {
2008
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2164
+ const anthropicOptions = await parseProviderOptions({
2009
2165
  provider: "anthropic",
2010
2166
  providerOptions: providerMetadata,
2011
2167
  schema: anthropicFilePartProviderOptions
@@ -2022,7 +2178,7 @@ async function convertToAnthropicMessagesPrompt({
2022
2178
  switch (type) {
2023
2179
  case "system": {
2024
2180
  if (system != null) {
2025
- throw new import_provider2.UnsupportedFunctionalityError({
2181
+ throw new UnsupportedFunctionalityError2({
2026
2182
  functionality: "Multiple system messages that are separated by user/assistant messages"
2027
2183
  });
2028
2184
  }
@@ -2062,72 +2218,131 @@ async function convertToAnthropicMessagesPrompt({
2062
2218
  break;
2063
2219
  }
2064
2220
  case "file": {
2065
- if (part.mediaType.startsWith("image/")) {
2066
- anthropicContent.push({
2067
- type: "image",
2068
- source: isUrlData(part.data) ? {
2069
- type: "url",
2070
- url: getUrlString(part.data)
2071
- } : {
2072
- type: "base64",
2073
- media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
2074
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2075
- },
2076
- cache_control: cacheControl
2077
- });
2078
- } else if (part.mediaType === "application/pdf") {
2079
- betas.add("pdfs-2024-09-25");
2080
- const enableCitations = await shouldEnableCitations(
2081
- part.providerOptions
2082
- );
2083
- const metadata = await getDocumentMetadata(
2084
- part.providerOptions
2085
- );
2086
- anthropicContent.push({
2087
- type: "document",
2088
- source: isUrlData(part.data) ? {
2089
- type: "url",
2090
- url: getUrlString(part.data)
2091
- } : {
2092
- type: "base64",
2093
- media_type: "application/pdf",
2094
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2095
- },
2096
- title: (_b = metadata.title) != null ? _b : part.filename,
2097
- ...metadata.context && { context: metadata.context },
2098
- ...enableCitations && {
2099
- citations: { enabled: true }
2100
- },
2101
- cache_control: cacheControl
2102
- });
2103
- } else if (part.mediaType === "text/plain") {
2104
- const enableCitations = await shouldEnableCitations(
2105
- part.providerOptions
2106
- );
2107
- const metadata = await getDocumentMetadata(
2108
- part.providerOptions
2109
- );
2110
- anthropicContent.push({
2111
- type: "document",
2112
- source: isUrlData(part.data) ? {
2113
- type: "url",
2114
- url: getUrlString(part.data)
2115
- } : {
2116
- type: "text",
2117
- media_type: "text/plain",
2118
- data: convertToString(part.data)
2119
- },
2120
- title: (_c = metadata.title) != null ? _c : part.filename,
2121
- ...metadata.context && { context: metadata.context },
2122
- ...enableCitations && {
2123
- citations: { enabled: true }
2124
- },
2125
- cache_control: cacheControl
2126
- });
2127
- } else {
2128
- throw new import_provider2.UnsupportedFunctionalityError({
2129
- functionality: `media type: ${part.mediaType}`
2130
- });
2221
+ switch (part.data.type) {
2222
+ case "reference": {
2223
+ const fileId = resolveProviderReference({
2224
+ reference: part.data.reference,
2225
+ provider: "anthropic"
2226
+ });
2227
+ betas.add("files-api-2025-04-14");
2228
+ if (getTopLevelMediaType(part.mediaType) === "image") {
2229
+ anthropicContent.push({
2230
+ type: "image",
2231
+ source: { type: "file", file_id: fileId },
2232
+ cache_control: cacheControl
2233
+ });
2234
+ } else {
2235
+ anthropicContent.push({
2236
+ type: "document",
2237
+ source: { type: "file", file_id: fileId },
2238
+ cache_control: cacheControl
2239
+ });
2240
+ }
2241
+ break;
2242
+ }
2243
+ case "text": {
2244
+ const enableCitations = await shouldEnableCitations(
2245
+ part.providerOptions
2246
+ );
2247
+ const metadata = await getDocumentMetadata(
2248
+ part.providerOptions
2249
+ );
2250
+ anthropicContent.push({
2251
+ type: "document",
2252
+ source: {
2253
+ type: "text",
2254
+ media_type: "text/plain",
2255
+ data: part.data.text
2256
+ },
2257
+ title: (_b = metadata.title) != null ? _b : part.filename,
2258
+ ...metadata.context && {
2259
+ context: metadata.context
2260
+ },
2261
+ ...enableCitations && {
2262
+ citations: { enabled: true }
2263
+ },
2264
+ cache_control: cacheControl
2265
+ });
2266
+ break;
2267
+ }
2268
+ case "url":
2269
+ case "data": {
2270
+ const topLevel = getTopLevelMediaType(part.mediaType);
2271
+ if (topLevel === "image") {
2272
+ anthropicContent.push({
2273
+ type: "image",
2274
+ source: part.data.type === "url" ? {
2275
+ type: "url",
2276
+ url: part.data.url.toString()
2277
+ } : {
2278
+ type: "base64",
2279
+ media_type: resolveFullMediaType({ part }),
2280
+ data: convertToBase64(part.data.data)
2281
+ },
2282
+ cache_control: cacheControl
2283
+ });
2284
+ } else if (topLevel === "application" && (part.data.type === "url" ? part.mediaType === "application/pdf" : resolveFullMediaType({ part }) === "application/pdf")) {
2285
+ betas.add("pdfs-2024-09-25");
2286
+ const enableCitations = await shouldEnableCitations(
2287
+ part.providerOptions
2288
+ );
2289
+ const metadata = await getDocumentMetadata(
2290
+ part.providerOptions
2291
+ );
2292
+ anthropicContent.push({
2293
+ type: "document",
2294
+ source: part.data.type === "url" ? {
2295
+ type: "url",
2296
+ url: part.data.url.toString()
2297
+ } : {
2298
+ type: "base64",
2299
+ media_type: "application/pdf",
2300
+ data: convertToBase64(part.data.data)
2301
+ },
2302
+ title: (_c = metadata.title) != null ? _c : part.filename,
2303
+ ...metadata.context && {
2304
+ context: metadata.context
2305
+ },
2306
+ ...enableCitations && {
2307
+ citations: { enabled: true }
2308
+ },
2309
+ cache_control: cacheControl
2310
+ });
2311
+ } else if (part.mediaType === "text/plain") {
2312
+ const enableCitations = await shouldEnableCitations(
2313
+ part.providerOptions
2314
+ );
2315
+ const metadata = await getDocumentMetadata(
2316
+ part.providerOptions
2317
+ );
2318
+ anthropicContent.push({
2319
+ type: "document",
2320
+ source: part.data.type === "url" ? {
2321
+ type: "url",
2322
+ url: part.data.url.toString()
2323
+ } : {
2324
+ type: "text",
2325
+ media_type: "text/plain",
2326
+ data: convertBytesDataToString(
2327
+ part.data.data
2328
+ )
2329
+ },
2330
+ title: (_d = metadata.title) != null ? _d : part.filename,
2331
+ ...metadata.context && {
2332
+ context: metadata.context
2333
+ },
2334
+ ...enableCitations && {
2335
+ citations: { enabled: true }
2336
+ },
2337
+ cache_control: cacheControl
2338
+ });
2339
+ } else {
2340
+ throw new UnsupportedFunctionalityError2({
2341
+ functionality: `media type: ${part.mediaType}`
2342
+ });
2343
+ }
2344
+ break;
2345
+ }
2131
2346
  }
2132
2347
  break;
2133
2348
  }
@@ -2142,10 +2357,10 @@ async function convertToAnthropicMessagesPrompt({
2142
2357
  continue;
2143
2358
  }
2144
2359
  const isLastPart = i2 === content.length - 1;
2145
- const cacheControl = (_d = validator.getCacheControl(part.providerOptions, {
2360
+ const cacheControl = (_e = validator.getCacheControl(part.providerOptions, {
2146
2361
  type: "tool result part",
2147
2362
  canCache: true
2148
- })) != null ? _d : isLastPart ? validator.getCacheControl(message.providerOptions, {
2363
+ })) != null ? _e : isLastPart ? validator.getCacheControl(message.providerOptions, {
2149
2364
  type: "tool result message",
2150
2365
  canCache: true
2151
2366
  }) : void 0;
@@ -2161,26 +2376,16 @@ async function convertToAnthropicMessagesPrompt({
2161
2376
  type: "text",
2162
2377
  text: contentPart.text
2163
2378
  };
2164
- case "image-data": {
2165
- return {
2166
- type: "image",
2167
- source: {
2168
- type: "base64",
2169
- media_type: contentPart.mediaType,
2170
- data: contentPart.data
2171
- }
2172
- };
2173
- }
2174
- case "image-url": {
2175
- return {
2176
- type: "image",
2177
- source: {
2178
- type: "url",
2179
- url: contentPart.url
2180
- }
2181
- };
2182
- }
2183
2379
  case "file-url": {
2380
+ if (contentPart.mediaType.startsWith("image/")) {
2381
+ return {
2382
+ type: "image",
2383
+ source: {
2384
+ type: "url",
2385
+ url: contentPart.url
2386
+ }
2387
+ };
2388
+ }
2184
2389
  return {
2185
2390
  type: "document",
2186
2391
  source: {
@@ -2190,6 +2395,16 @@ async function convertToAnthropicMessagesPrompt({
2190
2395
  };
2191
2396
  }
2192
2397
  case "file-data": {
2398
+ if (contentPart.mediaType.startsWith("image/")) {
2399
+ return {
2400
+ type: "image",
2401
+ source: {
2402
+ type: "base64",
2403
+ media_type: contentPart.mediaType,
2404
+ data: contentPart.data
2405
+ }
2406
+ };
2407
+ }
2193
2408
  if (contentPart.mediaType === "application/pdf") {
2194
2409
  betas.add("pdfs-2024-09-25");
2195
2410
  return {
@@ -2229,14 +2444,14 @@ async function convertToAnthropicMessagesPrompt({
2229
2444
  return void 0;
2230
2445
  }
2231
2446
  }
2232
- }).filter(import_provider_utils14.isNonNullable);
2447
+ }).filter(isNonNullable);
2233
2448
  break;
2234
2449
  case "text":
2235
2450
  case "error-text":
2236
2451
  contentValue = output.value;
2237
2452
  break;
2238
2453
  case "execution-denied":
2239
- contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
2454
+ contentValue = (_f = output.reason) != null ? _f : "Tool call execution denied.";
2240
2455
  break;
2241
2456
  case "json":
2242
2457
  case "error-json":
@@ -2273,16 +2488,16 @@ async function convertToAnthropicMessagesPrompt({
2273
2488
  for (let k = 0; k < content.length; k++) {
2274
2489
  const part = content[k];
2275
2490
  const isLastContentPart = k === content.length - 1;
2276
- const cacheControl = (_f = validator.getCacheControl(part.providerOptions, {
2491
+ const cacheControl = (_g = validator.getCacheControl(part.providerOptions, {
2277
2492
  type: "assistant message part",
2278
2493
  canCache: true
2279
- })) != null ? _f : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2494
+ })) != null ? _g : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2280
2495
  type: "assistant message",
2281
2496
  canCache: true
2282
2497
  }) : void 0;
2283
2498
  switch (part.type) {
2284
2499
  case "text": {
2285
- const textMetadata = (_g = part.providerOptions) == null ? void 0 : _g.anthropic;
2500
+ const textMetadata = (_h = part.providerOptions) == null ? void 0 : _h.anthropic;
2286
2501
  if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
2287
2502
  anthropicContent.push({
2288
2503
  type: "compaction",
@@ -2305,7 +2520,7 @@ async function convertToAnthropicMessagesPrompt({
2305
2520
  }
2306
2521
  case "reasoning": {
2307
2522
  if (sendReasoning) {
2308
- const reasoningMetadata = await (0, import_provider_utils14.parseProviderOptions)({
2523
+ const reasoningMetadata = await parseProviderOptions({
2309
2524
  provider: "anthropic",
2310
2525
  providerOptions: part.providerOptions,
2311
2526
  schema: anthropicReasoningMetadataSchema
@@ -2355,10 +2570,10 @@ async function convertToAnthropicMessagesPrompt({
2355
2570
  const providerToolName = toolNameMapping.toProviderToolName(
2356
2571
  part.toolName
2357
2572
  );
2358
- const isMcpToolUse = ((_i = (_h = part.providerOptions) == null ? void 0 : _h.anthropic) == null ? void 0 : _i.type) === "mcp-tool-use";
2573
+ const isMcpToolUse = ((_j = (_i = part.providerOptions) == null ? void 0 : _i.anthropic) == null ? void 0 : _j.type) === "mcp-tool-use";
2359
2574
  if (isMcpToolUse) {
2360
2575
  mcpToolUseIds.add(part.toolCallId);
2361
- const serverName = (_k = (_j = part.providerOptions) == null ? void 0 : _j.anthropic) == null ? void 0 : _k.serverName;
2576
+ const serverName = (_l = (_k = part.providerOptions) == null ? void 0 : _k.anthropic) == null ? void 0 : _l.serverName;
2362
2577
  if (serverName == null || typeof serverName !== "string") {
2363
2578
  warnings.push({
2364
2579
  type: "other",
@@ -2426,7 +2641,7 @@ async function convertToAnthropicMessagesPrompt({
2426
2641
  }
2427
2642
  break;
2428
2643
  }
2429
- const callerOptions = (_l = part.providerOptions) == null ? void 0 : _l.anthropic;
2644
+ const callerOptions = (_m = part.providerOptions) == null ? void 0 : _m.anthropic;
2430
2645
  const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
2431
2646
  type: callerOptions.caller.type,
2432
2647
  tool_id: callerOptions.caller.toolId
@@ -2479,7 +2694,7 @@ async function convertToAnthropicMessagesPrompt({
2479
2694
  tool_use_id: part.toolCallId,
2480
2695
  content: {
2481
2696
  type: "code_execution_tool_result_error",
2482
- error_code: (_m = errorInfo.errorCode) != null ? _m : "unknown"
2697
+ error_code: (_n = errorInfo.errorCode) != null ? _n : "unknown"
2483
2698
  },
2484
2699
  cache_control: cacheControl
2485
2700
  });
@@ -2490,7 +2705,7 @@ async function convertToAnthropicMessagesPrompt({
2490
2705
  cache_control: cacheControl,
2491
2706
  content: {
2492
2707
  type: "bash_code_execution_tool_result_error",
2493
- error_code: (_n = errorInfo.errorCode) != null ? _n : "unknown"
2708
+ error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
2494
2709
  }
2495
2710
  });
2496
2711
  }
@@ -2511,7 +2726,7 @@ async function convertToAnthropicMessagesPrompt({
2511
2726
  break;
2512
2727
  }
2513
2728
  if (output.value.type === "code_execution_result") {
2514
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2729
+ const codeExecutionOutput = await validateTypes2({
2515
2730
  value: output.value,
2516
2731
  schema: codeExecution_20250522OutputSchema
2517
2732
  });
@@ -2523,12 +2738,12 @@ async function convertToAnthropicMessagesPrompt({
2523
2738
  stdout: codeExecutionOutput.stdout,
2524
2739
  stderr: codeExecutionOutput.stderr,
2525
2740
  return_code: codeExecutionOutput.return_code,
2526
- content: (_o = codeExecutionOutput.content) != null ? _o : []
2741
+ content: (_p = codeExecutionOutput.content) != null ? _p : []
2527
2742
  },
2528
2743
  cache_control: cacheControl
2529
2744
  });
2530
2745
  } else if (output.value.type === "encrypted_code_execution_result") {
2531
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2746
+ const codeExecutionOutput = await validateTypes2({
2532
2747
  value: output.value,
2533
2748
  schema: codeExecution_20260120OutputSchema
2534
2749
  });
@@ -2541,13 +2756,13 @@ async function convertToAnthropicMessagesPrompt({
2541
2756
  encrypted_stdout: codeExecutionOutput.encrypted_stdout,
2542
2757
  stderr: codeExecutionOutput.stderr,
2543
2758
  return_code: codeExecutionOutput.return_code,
2544
- content: (_p = codeExecutionOutput.content) != null ? _p : []
2759
+ content: (_q = codeExecutionOutput.content) != null ? _q : []
2545
2760
  },
2546
2761
  cache_control: cacheControl
2547
2762
  });
2548
2763
  }
2549
2764
  } else {
2550
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2765
+ const codeExecutionOutput = await validateTypes2({
2551
2766
  value: output.value,
2552
2767
  schema: codeExecution_20250825OutputSchema
2553
2768
  });
@@ -2560,7 +2775,7 @@ async function convertToAnthropicMessagesPrompt({
2560
2775
  stdout: codeExecutionOutput.stdout,
2561
2776
  stderr: codeExecutionOutput.stderr,
2562
2777
  return_code: codeExecutionOutput.return_code,
2563
- content: (_q = codeExecutionOutput.content) != null ? _q : []
2778
+ content: (_r = codeExecutionOutput.content) != null ? _r : []
2564
2779
  },
2565
2780
  cache_control: cacheControl
2566
2781
  });
@@ -2593,7 +2808,7 @@ async function convertToAnthropicMessagesPrompt({
2593
2808
  errorValue = output.value;
2594
2809
  }
2595
2810
  } catch (e) {
2596
- const extractedErrorCode = (_r = output.value) == null ? void 0 : _r.errorCode;
2811
+ const extractedErrorCode = (_s = output.value) == null ? void 0 : _s.errorCode;
2597
2812
  errorValue = {
2598
2813
  errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
2599
2814
  };
@@ -2603,7 +2818,7 @@ async function convertToAnthropicMessagesPrompt({
2603
2818
  tool_use_id: part.toolCallId,
2604
2819
  content: {
2605
2820
  type: "web_fetch_tool_result_error",
2606
- error_code: (_s = errorValue.errorCode) != null ? _s : "unavailable"
2821
+ error_code: (_t = errorValue.errorCode) != null ? _t : "unavailable"
2607
2822
  },
2608
2823
  cache_control: cacheControl
2609
2824
  });
@@ -2616,7 +2831,7 @@ async function convertToAnthropicMessagesPrompt({
2616
2831
  });
2617
2832
  break;
2618
2833
  }
2619
- const webFetchOutput = await (0, import_provider_utils14.validateTypes)({
2834
+ const webFetchOutput = await validateTypes2({
2620
2835
  value: output.value,
2621
2836
  schema: webFetch_20250910OutputSchema
2622
2837
  });
@@ -2651,7 +2866,7 @@ async function convertToAnthropicMessagesPrompt({
2651
2866
  });
2652
2867
  break;
2653
2868
  }
2654
- const webSearchOutput = await (0, import_provider_utils14.validateTypes)({
2869
+ const webSearchOutput = await validateTypes2({
2655
2870
  value: output.value,
2656
2871
  schema: webSearch_20250305OutputSchema
2657
2872
  });
@@ -2678,7 +2893,7 @@ async function convertToAnthropicMessagesPrompt({
2678
2893
  });
2679
2894
  break;
2680
2895
  }
2681
- const toolSearchOutput = await (0, import_provider_utils14.validateTypes)({
2896
+ const toolSearchOutput = await validateTypes2({
2682
2897
  value: output.value,
2683
2898
  schema: toolSearchRegex_20251119OutputSchema
2684
2899
  });
@@ -2791,7 +3006,153 @@ function mapAnthropicStopReason({
2791
3006
  }
2792
3007
  }
2793
3008
 
2794
- // src/anthropic-messages-language-model.ts
3009
+ // src/sanitize-json-schema.ts
3010
+ var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
3011
+ "date-time",
3012
+ "time",
3013
+ "date",
3014
+ "duration",
3015
+ "email",
3016
+ "hostname",
3017
+ "uri",
3018
+ "ipv4",
3019
+ "ipv6",
3020
+ "uuid"
3021
+ ]);
3022
+ var DESCRIPTION_CONSTRAINT_KEYS = [
3023
+ "minimum",
3024
+ "maximum",
3025
+ "exclusiveMinimum",
3026
+ "exclusiveMaximum",
3027
+ "multipleOf",
3028
+ "minLength",
3029
+ "maxLength",
3030
+ "pattern",
3031
+ "minItems",
3032
+ "maxItems",
3033
+ "uniqueItems",
3034
+ "minProperties",
3035
+ "maxProperties",
3036
+ "not"
3037
+ ];
3038
+ function sanitizeJsonSchema(schema) {
3039
+ return sanitizeSchema(schema);
3040
+ }
3041
+ function sanitizeDefinition(definition) {
3042
+ if (typeof definition === "boolean" || !isPlainObject(definition)) {
3043
+ return definition;
3044
+ }
3045
+ return sanitizeSchema(definition);
3046
+ }
3047
+ function sanitizeSchema(schema) {
3048
+ const result = {};
3049
+ const schemaWithDefs = schema;
3050
+ if (schema.$ref != null) {
3051
+ return { $ref: schema.$ref };
3052
+ }
3053
+ if (schema.$schema != null) {
3054
+ result.$schema = schema.$schema;
3055
+ }
3056
+ if (schema.$id != null) {
3057
+ result.$id = schema.$id;
3058
+ }
3059
+ if (schema.title != null) {
3060
+ result.title = schema.title;
3061
+ }
3062
+ if (schema.description != null) {
3063
+ result.description = schema.description;
3064
+ }
3065
+ if (schema.default !== void 0) {
3066
+ result.default = schema.default;
3067
+ }
3068
+ if (schema.const !== void 0) {
3069
+ result.const = schema.const;
3070
+ }
3071
+ if (schema.enum != null) {
3072
+ result.enum = schema.enum;
3073
+ }
3074
+ if (schema.type != null) {
3075
+ result.type = schema.type;
3076
+ }
3077
+ if (schema.anyOf != null) {
3078
+ result.anyOf = schema.anyOf.map(sanitizeDefinition);
3079
+ } else if (schema.oneOf != null) {
3080
+ result.anyOf = schema.oneOf.map(sanitizeDefinition);
3081
+ }
3082
+ if (schema.allOf != null) {
3083
+ result.allOf = schema.allOf.map(sanitizeDefinition);
3084
+ }
3085
+ if (schema.definitions != null) {
3086
+ result.definitions = Object.fromEntries(
3087
+ Object.entries(schema.definitions).map(([name, definition]) => [
3088
+ name,
3089
+ sanitizeDefinition(definition)
3090
+ ])
3091
+ );
3092
+ }
3093
+ if (schemaWithDefs.$defs != null) {
3094
+ const resultWithDefs = result;
3095
+ resultWithDefs.$defs = Object.fromEntries(
3096
+ Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
3097
+ name,
3098
+ sanitizeDefinition(definition)
3099
+ ])
3100
+ );
3101
+ }
3102
+ if (schema.type === "object" || schema.properties != null) {
3103
+ if (schema.properties != null) {
3104
+ result.properties = Object.fromEntries(
3105
+ Object.entries(schema.properties).map(([name, definition]) => [
3106
+ name,
3107
+ sanitizeDefinition(definition)
3108
+ ])
3109
+ );
3110
+ }
3111
+ result.additionalProperties = false;
3112
+ if (schema.required != null) {
3113
+ result.required = schema.required;
3114
+ }
3115
+ }
3116
+ if (schema.items != null) {
3117
+ result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
3118
+ }
3119
+ if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
3120
+ result.format = schema.format;
3121
+ }
3122
+ const constraintDescription = getConstraintDescription(schema);
3123
+ if (constraintDescription != null) {
3124
+ result.description = result.description == null ? constraintDescription : `${result.description}
3125
+ ${constraintDescription}`;
3126
+ }
3127
+ return result;
3128
+ }
3129
+ function getConstraintDescription(schema) {
3130
+ const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
3131
+ const value = schema[key];
3132
+ if (value == null || value === false) {
3133
+ return [];
3134
+ }
3135
+ return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
3136
+ });
3137
+ if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
3138
+ descriptions.push(`format: ${schema.format}`);
3139
+ }
3140
+ return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
3141
+ }
3142
+ function formatConstraintName(key) {
3143
+ return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
3144
+ }
3145
+ function formatConstraintValue(value) {
3146
+ if (typeof value === "string") {
3147
+ return value;
3148
+ }
3149
+ return JSON.stringify(value);
3150
+ }
3151
+ function isPlainObject(value) {
3152
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3153
+ }
3154
+
3155
+ // src/anthropic-language-model.ts
2795
3156
  function createCitationSource(citation, citationDocuments, generateId3) {
2796
3157
  var _a;
2797
3158
  if (citation.type === "web_search_result_location") {
@@ -2836,13 +3197,22 @@ function createCitationSource(citation, citationDocuments, generateId3) {
2836
3197
  }
2837
3198
  };
2838
3199
  }
2839
- var AnthropicMessagesLanguageModel = class {
3200
+ var AnthropicLanguageModel = class _AnthropicLanguageModel {
2840
3201
  constructor(modelId, config) {
2841
3202
  this.specificationVersion = "v4";
2842
3203
  var _a;
2843
3204
  this.modelId = modelId;
2844
3205
  this.config = config;
2845
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils15.generateId;
3206
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
3207
+ }
3208
+ static [WORKFLOW_SERIALIZE](model) {
3209
+ return serializeModelOptions({
3210
+ modelId: model.modelId,
3211
+ config: model.config
3212
+ });
3213
+ }
3214
+ static [WORKFLOW_DESERIALIZE](options) {
3215
+ return new _AnthropicLanguageModel(options.modelId, options.config);
2846
3216
  }
2847
3217
  supportsUrl(url) {
2848
3218
  return url.protocol === "https:";
@@ -2877,10 +3247,11 @@ var AnthropicMessagesLanguageModel = class {
2877
3247
  seed,
2878
3248
  tools,
2879
3249
  toolChoice,
3250
+ reasoning,
2880
3251
  providerOptions,
2881
3252
  stream
2882
3253
  }) {
2883
- var _a, _b, _c, _d, _e, _f, _g, _h;
3254
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2884
3255
  const warnings = [];
2885
3256
  if (frequencyPenalty != null) {
2886
3257
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2916,12 +3287,12 @@ var AnthropicMessagesLanguageModel = class {
2916
3287
  }
2917
3288
  }
2918
3289
  const providerOptionsName = this.providerOptionsName;
2919
- const canonicalOptions = await (0, import_provider_utils15.parseProviderOptions)({
3290
+ const canonicalOptions = await parseProviderOptions2({
2920
3291
  provider: "anthropic",
2921
3292
  providerOptions,
2922
3293
  schema: anthropicLanguageModelOptions
2923
3294
  });
2924
- const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils15.parseProviderOptions)({
3295
+ const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
2925
3296
  provider: providerOptionsName,
2926
3297
  providerOptions,
2927
3298
  schema: anthropicLanguageModelOptions
@@ -2935,8 +3306,38 @@ var AnthropicMessagesLanguageModel = class {
2935
3306
  const {
2936
3307
  maxOutputTokens: maxOutputTokensForModel,
2937
3308
  supportsStructuredOutput: modelSupportsStructuredOutput,
3309
+ supportsAdaptiveThinking,
3310
+ rejectsSamplingParameters,
3311
+ supportsXhighEffort,
2938
3312
  isKnownModel
2939
3313
  } = getModelCapabilities(this.modelId);
3314
+ if (rejectsSamplingParameters) {
3315
+ if (temperature != null) {
3316
+ warnings.push({
3317
+ type: "unsupported",
3318
+ feature: "temperature",
3319
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
3320
+ });
3321
+ temperature = void 0;
3322
+ }
3323
+ if (topK != null) {
3324
+ warnings.push({
3325
+ type: "unsupported",
3326
+ feature: "topK",
3327
+ details: `topK is not supported by ${this.modelId} and will be ignored`
3328
+ });
3329
+ topK = void 0;
3330
+ }
3331
+ if (topP != null) {
3332
+ warnings.push({
3333
+ type: "unsupported",
3334
+ feature: "topP",
3335
+ details: `topP is not supported by ${this.modelId} and will be ignored`
3336
+ });
3337
+ topP = void 0;
3338
+ }
3339
+ }
3340
+ const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2940
3341
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2941
3342
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
2942
3343
  const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
@@ -2949,7 +3350,7 @@ var AnthropicMessagesLanguageModel = class {
2949
3350
  } : void 0;
2950
3351
  const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
2951
3352
  const cacheControlValidator = new CacheControlValidator();
2952
- const toolNameMapping = (0, import_provider_utils15.createToolNameMapping)({
3353
+ const toolNameMapping = createToolNameMapping({
2953
3354
  tools,
2954
3355
  providerToolNames: {
2955
3356
  "anthropic.code_execution_20250522": "code_execution",
@@ -2972,16 +3373,34 @@ var AnthropicMessagesLanguageModel = class {
2972
3373
  "anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
2973
3374
  }
2974
3375
  });
2975
- const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
3376
+ const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
2976
3377
  prompt,
2977
3378
  sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
2978
3379
  warnings,
2979
3380
  cacheControlValidator,
2980
3381
  toolNameMapping
2981
3382
  });
2982
- const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3383
+ if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
3384
+ const reasoningConfig = resolveAnthropicReasoningConfig({
3385
+ reasoning,
3386
+ supportsAdaptiveThinking,
3387
+ supportsXhighEffort,
3388
+ maxOutputTokensForModel,
3389
+ warnings
3390
+ });
3391
+ if (reasoningConfig != null) {
3392
+ if (anthropicOptions.thinking == null) {
3393
+ anthropicOptions.thinking = reasoningConfig.thinking;
3394
+ }
3395
+ if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
3396
+ anthropicOptions.effort = reasoningConfig.effort;
3397
+ }
3398
+ }
3399
+ }
3400
+ const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
2983
3401
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
2984
- let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3402
+ let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
3403
+ const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
2985
3404
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
2986
3405
  const baseArgs = {
2987
3406
  // model id:
@@ -2996,18 +3415,28 @@ var AnthropicMessagesLanguageModel = class {
2996
3415
  ...isThinking && {
2997
3416
  thinking: {
2998
3417
  type: thinkingType,
2999
- ...thinkingBudget != null && { budget_tokens: thinkingBudget }
3418
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget },
3419
+ ...thinkingDisplay != null && { display: thinkingDisplay }
3000
3420
  }
3001
3421
  },
3002
- ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3422
+ ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3003
3423
  output_config: {
3004
3424
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
3005
3425
  effort: anthropicOptions.effort
3006
3426
  },
3427
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
3428
+ task_budget: {
3429
+ type: anthropicOptions.taskBudget.type,
3430
+ total: anthropicOptions.taskBudget.total,
3431
+ ...anthropicOptions.taskBudget.remaining != null && {
3432
+ remaining: anthropicOptions.taskBudget.remaining
3433
+ }
3434
+ }
3435
+ },
3007
3436
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
3008
3437
  format: {
3009
3438
  type: "json_schema",
3010
- schema: responseFormat.schema
3439
+ schema: sanitizeJsonSchema(responseFormat.schema)
3011
3440
  }
3012
3441
  }
3013
3442
  }
@@ -3015,9 +3444,15 @@ var AnthropicMessagesLanguageModel = class {
3015
3444
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
3016
3445
  speed: anthropicOptions.speed
3017
3446
  },
3447
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3448
+ inference_geo: anthropicOptions.inferenceGeo
3449
+ },
3018
3450
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3019
3451
  cache_control: anthropicOptions.cacheControl
3020
3452
  },
3453
+ ...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
3454
+ metadata: { user_id: anthropicOptions.metadata.userId }
3455
+ },
3021
3456
  // mcp servers:
3022
3457
  ...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
3023
3458
  mcp_servers: anthropicOptions.mcpServers.map((server) => ({
@@ -3039,7 +3474,10 @@ var AnthropicMessagesLanguageModel = class {
3039
3474
  id: anthropicOptions.container.id,
3040
3475
  skills: anthropicOptions.container.skills.map((skill) => ({
3041
3476
  type: skill.type,
3042
- skill_id: skill.skillId,
3477
+ skill_id: skill.type === "custom" ? resolveProviderReference2({
3478
+ reference: skill.providerReference,
3479
+ provider: "anthropic"
3480
+ }) : skill.skillId,
3043
3481
  version: skill.version
3044
3482
  }))
3045
3483
  }
@@ -3141,7 +3579,7 @@ var AnthropicMessagesLanguageModel = class {
3141
3579
  }
3142
3580
  baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
3143
3581
  } else {
3144
- if (topP != null && temperature != null) {
3582
+ if (isAnthropicModel && topP != null && temperature != null) {
3145
3583
  warnings.push({
3146
3584
  type: "unsupported",
3147
3585
  feature: "topP",
@@ -3185,12 +3623,13 @@ var AnthropicMessagesLanguageModel = class {
3185
3623
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
3186
3624
  betas.add("effort-2025-11-24");
3187
3625
  }
3626
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
3627
+ betas.add("task-budgets-2026-03-13");
3628
+ }
3188
3629
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3189
3630
  betas.add("fast-mode-2026-02-01");
3190
3631
  }
3191
- if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
3192
- betas.add("fine-grained-tool-streaming-2025-05-14");
3193
- }
3632
+ const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
3194
3633
  const {
3195
3634
  tools: anthropicTools2,
3196
3635
  toolChoice: anthropicToolChoice,
@@ -3203,14 +3642,16 @@ var AnthropicMessagesLanguageModel = class {
3203
3642
  disableParallelToolUse: true,
3204
3643
  cacheControlValidator,
3205
3644
  supportsStructuredOutput: false,
3206
- supportsStrictTools
3645
+ supportsStrictTools,
3646
+ defaultEagerInputStreaming
3207
3647
  } : {
3208
3648
  tools: tools != null ? tools : [],
3209
3649
  toolChoice,
3210
3650
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3211
3651
  cacheControlValidator,
3212
3652
  supportsStructuredOutput,
3213
- supportsStrictTools
3653
+ supportsStrictTools,
3654
+ defaultEagerInputStreaming
3214
3655
  }
3215
3656
  );
3216
3657
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3227,7 +3668,7 @@ var AnthropicMessagesLanguageModel = class {
3227
3668
  ...betas,
3228
3669
  ...toolsBetas,
3229
3670
  ...userSuppliedBetas,
3230
- ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
3671
+ ...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
3231
3672
  ]),
3232
3673
  usesJsonResponseTool: jsonResponseTool != null,
3233
3674
  toolNameMapping,
@@ -3239,16 +3680,16 @@ var AnthropicMessagesLanguageModel = class {
3239
3680
  betas,
3240
3681
  headers
3241
3682
  }) {
3242
- return (0, import_provider_utils15.combineHeaders)(
3243
- await (0, import_provider_utils15.resolve)(this.config.headers),
3683
+ return combineHeaders2(
3684
+ this.config.headers ? await resolve(this.config.headers) : void 0,
3244
3685
  headers,
3245
3686
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
3246
3687
  );
3247
3688
  }
3248
3689
  async getBetasFromHeaders(requestHeaders) {
3249
3690
  var _a, _b;
3250
- const configHeaders = await (0, import_provider_utils15.resolve)(this.config.headers);
3251
- const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
3691
+ const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
3692
+ const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
3252
3693
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
3253
3694
  return new Set(
3254
3695
  [
@@ -3313,13 +3754,13 @@ var AnthropicMessagesLanguageModel = class {
3313
3754
  responseHeaders,
3314
3755
  value: response,
3315
3756
  rawValue: rawResponse
3316
- } = await (0, import_provider_utils15.postJsonToApi)({
3757
+ } = await postJsonToApi({
3317
3758
  url: this.buildRequestUrl(false),
3318
3759
  headers: await this.getHeaders({ betas, headers: options.headers }),
3319
3760
  body: this.transformRequestBody(args, betas),
3320
3761
  failedResponseHandler: anthropicFailedResponseHandler,
3321
- successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3322
- anthropicMessagesResponseSchema
3762
+ successfulResponseHandler: createJsonResponseHandler2(
3763
+ anthropicResponseSchema
3323
3764
  ),
3324
3765
  abortSignal: options.abortSignal,
3325
3766
  fetch: this.config.fetch
@@ -3668,7 +4109,7 @@ var AnthropicMessagesLanguageModel = class {
3668
4109
  }),
3669
4110
  raw: (_e = response.stop_reason) != null ? _e : void 0
3670
4111
  },
3671
- usage: convertAnthropicMessagesUsage({ usage: response.usage }),
4112
+ usage: convertAnthropicUsage({ usage: response.usage }),
3672
4113
  request: { body: args },
3673
4114
  response: {
3674
4115
  id: (_f = response.id) != null ? _f : void 0,
@@ -3678,11 +4119,10 @@ var AnthropicMessagesLanguageModel = class {
3678
4119
  },
3679
4120
  warnings,
3680
4121
  providerMetadata: (() => {
3681
- var _a2, _b2, _c2, _d2, _e2;
4122
+ var _a2, _b2, _c2, _d2;
3682
4123
  const anthropicMetadata = {
3683
4124
  usage: response.usage,
3684
- cacheCreationInputTokens: (_a2 = response.usage.cache_creation_input_tokens) != null ? _a2 : null,
3685
- stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
4125
+ stopSequence: (_a2 = response.stop_sequence) != null ? _a2 : null,
3686
4126
  iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
3687
4127
  type: iter.type,
3688
4128
  inputTokens: iter.input_tokens,
@@ -3691,15 +4131,15 @@ var AnthropicMessagesLanguageModel = class {
3691
4131
  container: response.container ? {
3692
4132
  expiresAt: response.container.expires_at,
3693
4133
  id: response.container.id,
3694
- skills: (_d2 = (_c2 = response.container.skills) == null ? void 0 : _c2.map((skill) => ({
4134
+ skills: (_c2 = (_b2 = response.container.skills) == null ? void 0 : _b2.map((skill) => ({
3695
4135
  type: skill.type,
3696
4136
  skillId: skill.skill_id,
3697
4137
  version: skill.version
3698
- }))) != null ? _d2 : null
4138
+ }))) != null ? _c2 : null
3699
4139
  } : null,
3700
- contextManagement: (_e2 = mapAnthropicResponseContextManagement(
4140
+ contextManagement: (_d2 = mapAnthropicResponseContextManagement(
3701
4141
  response.context_management
3702
- )) != null ? _e2 : null
4142
+ )) != null ? _d2 : null
3703
4143
  };
3704
4144
  const providerMetadata = {
3705
4145
  anthropic: anthropicMetadata
@@ -3712,6 +4152,7 @@ var AnthropicMessagesLanguageModel = class {
3712
4152
  };
3713
4153
  }
3714
4154
  async doStream(options) {
4155
+ "use step";
3715
4156
  var _a, _b;
3716
4157
  const {
3717
4158
  args: body,
@@ -3733,14 +4174,12 @@ var AnthropicMessagesLanguageModel = class {
3733
4174
  body.tools
3734
4175
  );
3735
4176
  const url = this.buildRequestUrl(true);
3736
- const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
4177
+ const { responseHeaders, value: response } = await postJsonToApi({
3737
4178
  url,
3738
4179
  headers: await this.getHeaders({ betas, headers: options.headers }),
3739
4180
  body: this.transformRequestBody(body, betas),
3740
4181
  failedResponseHandler: anthropicFailedResponseHandler,
3741
- successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
3742
- anthropicMessagesChunkSchema
3743
- ),
4182
+ successfulResponseHandler: createEventSourceResponseHandler(anthropicChunkSchema),
3744
4183
  abortSignal: options.abortSignal,
3745
4184
  fetch: this.config.fetch
3746
4185
  });
@@ -3760,7 +4199,6 @@ var AnthropicMessagesLanguageModel = class {
3760
4199
  const serverToolCalls = {};
3761
4200
  let contextManagement = null;
3762
4201
  let rawUsage = void 0;
3763
- let cacheCreationInputTokens = null;
3764
4202
  let stopSequence = null;
3765
4203
  let container = null;
3766
4204
  let isJsonResponseFromTool = false;
@@ -3772,7 +4210,7 @@ var AnthropicMessagesLanguageModel = class {
3772
4210
  controller.enqueue({ type: "stream-start", warnings });
3773
4211
  },
3774
4212
  transform(chunk, controller) {
3775
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4213
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
3776
4214
  if (options.includeRawChunks) {
3777
4215
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3778
4216
  }
@@ -4307,7 +4745,6 @@ var AnthropicMessagesLanguageModel = class {
4307
4745
  rawUsage = {
4308
4746
  ...value.message.usage
4309
4747
  };
4310
- cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
4311
4748
  if (value.message.container != null) {
4312
4749
  container = {
4313
4750
  expiresAt: value.message.container.expires_at,
@@ -4326,8 +4763,8 @@ var AnthropicMessagesLanguageModel = class {
4326
4763
  }
4327
4764
  controller.enqueue({
4328
4765
  type: "response-metadata",
4329
- id: (_h = value.message.id) != null ? _h : void 0,
4330
- modelId: (_i = value.message.model) != null ? _i : void 0
4766
+ id: (_g = value.message.id) != null ? _g : void 0,
4767
+ modelId: (_h = value.message.model) != null ? _h : void 0
4331
4768
  });
4332
4769
  if (value.message.content != null) {
4333
4770
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
@@ -4343,7 +4780,7 @@ var AnthropicMessagesLanguageModel = class {
4343
4780
  id: part.id,
4344
4781
  toolName: part.name
4345
4782
  });
4346
- const inputStr = JSON.stringify((_j = part.input) != null ? _j : {});
4783
+ const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
4347
4784
  controller.enqueue({
4348
4785
  type: "tool-input-delta",
4349
4786
  id: part.id,
@@ -4381,7 +4818,6 @@ var AnthropicMessagesLanguageModel = class {
4381
4818
  }
4382
4819
  if (value.usage.cache_creation_input_tokens != null) {
4383
4820
  usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
4384
- cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
4385
4821
  }
4386
4822
  if (value.usage.iterations != null) {
4387
4823
  usage.iterations = value.usage.iterations;
@@ -4391,17 +4827,17 @@ var AnthropicMessagesLanguageModel = class {
4391
4827
  finishReason: value.delta.stop_reason,
4392
4828
  isJsonResponseFromTool
4393
4829
  }),
4394
- raw: (_k = value.delta.stop_reason) != null ? _k : void 0
4830
+ raw: (_j = value.delta.stop_reason) != null ? _j : void 0
4395
4831
  };
4396
- stopSequence = (_l = value.delta.stop_sequence) != null ? _l : null;
4832
+ stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
4397
4833
  container = value.delta.container != null ? {
4398
4834
  expiresAt: value.delta.container.expires_at,
4399
4835
  id: value.delta.container.id,
4400
- skills: (_n = (_m = value.delta.container.skills) == null ? void 0 : _m.map((skill) => ({
4836
+ skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
4401
4837
  type: skill.type,
4402
4838
  skillId: skill.skill_id,
4403
4839
  version: skill.version
4404
- }))) != null ? _n : null
4840
+ }))) != null ? _m : null
4405
4841
  } : null;
4406
4842
  if (value.context_management) {
4407
4843
  contextManagement = mapAnthropicResponseContextManagement(
@@ -4417,7 +4853,6 @@ var AnthropicMessagesLanguageModel = class {
4417
4853
  case "message_stop": {
4418
4854
  const anthropicMetadata = {
4419
4855
  usage: rawUsage != null ? rawUsage : null,
4420
- cacheCreationInputTokens,
4421
4856
  stopSequence,
4422
4857
  iterations: usage.iterations ? usage.iterations.map((iter) => ({
4423
4858
  type: iter.type,
@@ -4436,7 +4871,7 @@ var AnthropicMessagesLanguageModel = class {
4436
4871
  controller.enqueue({
4437
4872
  type: "finish",
4438
4873
  finishReason,
4439
- usage: convertAnthropicMessagesUsage({ usage, rawUsage }),
4874
+ usage: convertAnthropicUsage({ usage, rawUsage }),
4440
4875
  providerMetadata
4441
4876
  });
4442
4877
  return;
@@ -4463,7 +4898,7 @@ var AnthropicMessagesLanguageModel = class {
4463
4898
  }
4464
4899
  if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
4465
4900
  const error = result.value.error;
4466
- throw new import_provider3.APICallError({
4901
+ throw new APICallError({
4467
4902
  message: error.message,
4468
4903
  url,
4469
4904
  requestBodyValues: body,
@@ -4486,46 +4921,76 @@ var AnthropicMessagesLanguageModel = class {
4486
4921
  }
4487
4922
  };
4488
4923
  function getModelCapabilities(modelId) {
4489
- if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4924
+ if (modelId.includes("claude-opus-4-7")) {
4490
4925
  return {
4491
4926
  maxOutputTokens: 128e3,
4492
4927
  supportsStructuredOutput: true,
4928
+ supportsAdaptiveThinking: true,
4929
+ rejectsSamplingParameters: true,
4930
+ supportsXhighEffort: true,
4931
+ isKnownModel: true
4932
+ };
4933
+ } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4934
+ return {
4935
+ maxOutputTokens: 128e3,
4936
+ supportsStructuredOutput: true,
4937
+ supportsAdaptiveThinking: true,
4938
+ rejectsSamplingParameters: false,
4939
+ supportsXhighEffort: false,
4493
4940
  isKnownModel: true
4494
4941
  };
4495
4942
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
4496
4943
  return {
4497
4944
  maxOutputTokens: 64e3,
4498
4945
  supportsStructuredOutput: true,
4946
+ supportsAdaptiveThinking: false,
4947
+ rejectsSamplingParameters: false,
4948
+ supportsXhighEffort: false,
4499
4949
  isKnownModel: true
4500
4950
  };
4501
4951
  } else if (modelId.includes("claude-opus-4-1")) {
4502
4952
  return {
4503
4953
  maxOutputTokens: 32e3,
4504
4954
  supportsStructuredOutput: true,
4955
+ supportsAdaptiveThinking: false,
4956
+ rejectsSamplingParameters: false,
4957
+ supportsXhighEffort: false,
4505
4958
  isKnownModel: true
4506
4959
  };
4507
4960
  } else if (modelId.includes("claude-sonnet-4-")) {
4508
4961
  return {
4509
4962
  maxOutputTokens: 64e3,
4510
4963
  supportsStructuredOutput: false,
4964
+ supportsAdaptiveThinking: false,
4965
+ rejectsSamplingParameters: false,
4966
+ supportsXhighEffort: false,
4511
4967
  isKnownModel: true
4512
4968
  };
4513
4969
  } else if (modelId.includes("claude-opus-4-")) {
4514
4970
  return {
4515
4971
  maxOutputTokens: 32e3,
4516
4972
  supportsStructuredOutput: false,
4973
+ supportsAdaptiveThinking: false,
4974
+ rejectsSamplingParameters: false,
4975
+ supportsXhighEffort: false,
4517
4976
  isKnownModel: true
4518
4977
  };
4519
4978
  } else if (modelId.includes("claude-3-haiku")) {
4520
4979
  return {
4521
4980
  maxOutputTokens: 4096,
4522
4981
  supportsStructuredOutput: false,
4982
+ supportsAdaptiveThinking: false,
4983
+ rejectsSamplingParameters: false,
4984
+ supportsXhighEffort: false,
4523
4985
  isKnownModel: true
4524
4986
  };
4525
4987
  } else {
4526
4988
  return {
4527
4989
  maxOutputTokens: 4096,
4528
4990
  supportsStructuredOutput: false,
4991
+ supportsAdaptiveThinking: false,
4992
+ rejectsSamplingParameters: false,
4993
+ supportsXhighEffort: false,
4529
4994
  isKnownModel: false
4530
4995
  };
4531
4996
  }
@@ -4548,6 +5013,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
4548
5013
  }
4549
5014
  return hasWebTool20260209 && !hasCodeExecutionTool;
4550
5015
  }
5016
+ function resolveAnthropicReasoningConfig({
5017
+ reasoning,
5018
+ supportsAdaptiveThinking,
5019
+ supportsXhighEffort,
5020
+ maxOutputTokensForModel,
5021
+ warnings
5022
+ }) {
5023
+ if (!isCustomReasoning(reasoning)) {
5024
+ return void 0;
5025
+ }
5026
+ if (reasoning === "none") {
5027
+ return { thinking: { type: "disabled" } };
5028
+ }
5029
+ if (supportsAdaptiveThinking) {
5030
+ const effort = mapReasoningToProviderEffort({
5031
+ reasoning,
5032
+ effortMap: {
5033
+ minimal: "low",
5034
+ low: "low",
5035
+ medium: "medium",
5036
+ high: "high",
5037
+ xhigh: supportsXhighEffort ? "xhigh" : "max"
5038
+ },
5039
+ warnings
5040
+ });
5041
+ return { thinking: { type: "adaptive" }, effort };
5042
+ }
5043
+ const budgetTokens = mapReasoningToProviderBudget({
5044
+ reasoning,
5045
+ maxOutputTokens: maxOutputTokensForModel,
5046
+ maxReasoningBudget: maxOutputTokensForModel,
5047
+ warnings
5048
+ });
5049
+ if (budgetTokens == null) {
5050
+ return void 0;
5051
+ }
5052
+ return { thinking: { type: "enabled", budgetTokens } };
5053
+ }
4551
5054
  function mapAnthropicResponseContextManagement(contextManagement) {
4552
5055
  return contextManagement ? {
4553
5056
  appliedEdits: contextManagement.applied_edits.map((edit) => {
@@ -4575,44 +5078,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
4575
5078
  }
4576
5079
 
4577
5080
  // src/tool/bash_20241022.ts
4578
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
4579
- var import_v413 = require("zod/v4");
4580
- var bash_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
4581
- () => (0, import_provider_utils16.zodSchema)(
4582
- import_v413.z.object({
4583
- command: import_v413.z.string(),
4584
- restart: import_v413.z.boolean().optional()
5081
+ import {
5082
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
5083
+ lazySchema as lazySchema13,
5084
+ zodSchema as zodSchema13
5085
+ } from "@ai-sdk/provider-utils";
5086
+ import { z as z14 } from "zod/v4";
5087
+ var bash_20241022InputSchema = lazySchema13(
5088
+ () => zodSchema13(
5089
+ z14.object({
5090
+ command: z14.string(),
5091
+ restart: z14.boolean().optional()
4585
5092
  })
4586
5093
  )
4587
5094
  );
4588
- var bash_20241022 = (0, import_provider_utils16.createProviderToolFactory)({
5095
+ var bash_20241022 = createProviderDefinedToolFactory2({
4589
5096
  id: "anthropic.bash_20241022",
4590
5097
  inputSchema: bash_20241022InputSchema
4591
5098
  });
4592
5099
 
4593
5100
  // src/tool/bash_20250124.ts
4594
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
4595
- var import_v414 = require("zod/v4");
4596
- var bash_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
4597
- () => (0, import_provider_utils17.zodSchema)(
4598
- import_v414.z.object({
4599
- command: import_v414.z.string(),
4600
- restart: import_v414.z.boolean().optional()
5101
+ import {
5102
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
5103
+ lazySchema as lazySchema14,
5104
+ zodSchema as zodSchema14
5105
+ } from "@ai-sdk/provider-utils";
5106
+ import { z as z15 } from "zod/v4";
5107
+ var bash_20250124InputSchema = lazySchema14(
5108
+ () => zodSchema14(
5109
+ z15.object({
5110
+ command: z15.string(),
5111
+ restart: z15.boolean().optional()
4601
5112
  })
4602
5113
  )
4603
5114
  );
4604
- var bash_20250124 = (0, import_provider_utils17.createProviderToolFactory)({
5115
+ var bash_20250124 = createProviderDefinedToolFactory3({
4605
5116
  id: "anthropic.bash_20250124",
4606
5117
  inputSchema: bash_20250124InputSchema
4607
5118
  });
4608
5119
 
4609
5120
  // src/tool/computer_20241022.ts
4610
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
4611
- var import_v415 = require("zod/v4");
4612
- var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4613
- () => (0, import_provider_utils18.zodSchema)(
4614
- import_v415.z.object({
4615
- action: import_v415.z.enum([
5121
+ import {
5122
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
5123
+ lazySchema as lazySchema15,
5124
+ zodSchema as zodSchema15
5125
+ } from "@ai-sdk/provider-utils";
5126
+ import { z as z16 } from "zod/v4";
5127
+ var computer_20241022InputSchema = lazySchema15(
5128
+ () => zodSchema15(
5129
+ z16.object({
5130
+ action: z16.enum([
4616
5131
  "key",
4617
5132
  "type",
4618
5133
  "mouse_move",
@@ -4624,23 +5139,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4624
5139
  "screenshot",
4625
5140
  "cursor_position"
4626
5141
  ]),
4627
- coordinate: import_v415.z.array(import_v415.z.number().int()).optional(),
4628
- text: import_v415.z.string().optional()
5142
+ coordinate: z16.array(z16.number().int()).optional(),
5143
+ text: z16.string().optional()
4629
5144
  })
4630
5145
  )
4631
5146
  );
4632
- var computer_20241022 = (0, import_provider_utils18.createProviderToolFactory)({
5147
+ var computer_20241022 = createProviderDefinedToolFactory4({
4633
5148
  id: "anthropic.computer_20241022",
4634
5149
  inputSchema: computer_20241022InputSchema
4635
5150
  });
4636
5151
 
4637
5152
  // src/tool/computer_20250124.ts
4638
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
4639
- var import_v416 = require("zod/v4");
4640
- var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4641
- () => (0, import_provider_utils19.zodSchema)(
4642
- import_v416.z.object({
4643
- action: import_v416.z.enum([
5153
+ import {
5154
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
5155
+ lazySchema as lazySchema16,
5156
+ zodSchema as zodSchema16
5157
+ } from "@ai-sdk/provider-utils";
5158
+ import { z as z17 } from "zod/v4";
5159
+ var computer_20250124InputSchema = lazySchema16(
5160
+ () => zodSchema16(
5161
+ z17.object({
5162
+ action: z17.enum([
4644
5163
  "key",
4645
5164
  "hold_key",
4646
5165
  "type",
@@ -4658,27 +5177,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4658
5177
  "wait",
4659
5178
  "screenshot"
4660
5179
  ]),
4661
- coordinate: import_v416.z.tuple([import_v416.z.number().int(), import_v416.z.number().int()]).optional(),
4662
- duration: import_v416.z.number().optional(),
4663
- scroll_amount: import_v416.z.number().optional(),
4664
- scroll_direction: import_v416.z.enum(["up", "down", "left", "right"]).optional(),
4665
- start_coordinate: import_v416.z.tuple([import_v416.z.number().int(), import_v416.z.number().int()]).optional(),
4666
- text: import_v416.z.string().optional()
5180
+ coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5181
+ duration: z17.number().optional(),
5182
+ scroll_amount: z17.number().optional(),
5183
+ scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
5184
+ start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5185
+ text: z17.string().optional()
4667
5186
  })
4668
5187
  )
4669
5188
  );
4670
- var computer_20250124 = (0, import_provider_utils19.createProviderToolFactory)({
5189
+ var computer_20250124 = createProviderDefinedToolFactory5({
4671
5190
  id: "anthropic.computer_20250124",
4672
5191
  inputSchema: computer_20250124InputSchema
4673
5192
  });
4674
5193
 
4675
5194
  // src/tool/computer_20251124.ts
4676
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
4677
- var import_v417 = require("zod/v4");
4678
- var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4679
- () => (0, import_provider_utils20.zodSchema)(
4680
- import_v417.z.object({
4681
- action: import_v417.z.enum([
5195
+ import {
5196
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
5197
+ lazySchema as lazySchema17,
5198
+ zodSchema as zodSchema17
5199
+ } from "@ai-sdk/provider-utils";
5200
+ import { z as z18 } from "zod/v4";
5201
+ var computer_20251124InputSchema = lazySchema17(
5202
+ () => zodSchema17(
5203
+ z18.object({
5204
+ action: z18.enum([
4682
5205
  "key",
4683
5206
  "hold_key",
4684
5207
  "type",
@@ -4697,166 +5220,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4697
5220
  "screenshot",
4698
5221
  "zoom"
4699
5222
  ]),
4700
- coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
4701
- duration: import_v417.z.number().optional(),
4702
- region: import_v417.z.tuple([
4703
- import_v417.z.number().int(),
4704
- import_v417.z.number().int(),
4705
- import_v417.z.number().int(),
4706
- import_v417.z.number().int()
5223
+ coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
5224
+ duration: z18.number().optional(),
5225
+ region: z18.tuple([
5226
+ z18.number().int(),
5227
+ z18.number().int(),
5228
+ z18.number().int(),
5229
+ z18.number().int()
4707
5230
  ]).optional(),
4708
- scroll_amount: import_v417.z.number().optional(),
4709
- scroll_direction: import_v417.z.enum(["up", "down", "left", "right"]).optional(),
4710
- start_coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
4711
- text: import_v417.z.string().optional()
5231
+ scroll_amount: z18.number().optional(),
5232
+ scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
5233
+ start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
5234
+ text: z18.string().optional()
4712
5235
  })
4713
5236
  )
4714
5237
  );
4715
- var computer_20251124 = (0, import_provider_utils20.createProviderToolFactory)({
5238
+ var computer_20251124 = createProviderDefinedToolFactory6({
4716
5239
  id: "anthropic.computer_20251124",
4717
5240
  inputSchema: computer_20251124InputSchema
4718
5241
  });
4719
5242
 
4720
5243
  // src/tool/memory_20250818.ts
4721
- var import_provider_utils21 = require("@ai-sdk/provider-utils");
4722
- var import_v418 = require("zod/v4");
4723
- var memory_20250818InputSchema = (0, import_provider_utils21.lazySchema)(
4724
- () => (0, import_provider_utils21.zodSchema)(
4725
- import_v418.z.discriminatedUnion("command", [
4726
- import_v418.z.object({
4727
- command: import_v418.z.literal("view"),
4728
- path: import_v418.z.string(),
4729
- view_range: import_v418.z.tuple([import_v418.z.number(), import_v418.z.number()]).optional()
5244
+ import {
5245
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
5246
+ lazySchema as lazySchema18,
5247
+ zodSchema as zodSchema18
5248
+ } from "@ai-sdk/provider-utils";
5249
+ import { z as z19 } from "zod/v4";
5250
+ var memory_20250818InputSchema = lazySchema18(
5251
+ () => zodSchema18(
5252
+ z19.discriminatedUnion("command", [
5253
+ z19.object({
5254
+ command: z19.literal("view"),
5255
+ path: z19.string(),
5256
+ view_range: z19.tuple([z19.number(), z19.number()]).optional()
4730
5257
  }),
4731
- import_v418.z.object({
4732
- command: import_v418.z.literal("create"),
4733
- path: import_v418.z.string(),
4734
- file_text: import_v418.z.string()
5258
+ z19.object({
5259
+ command: z19.literal("create"),
5260
+ path: z19.string(),
5261
+ file_text: z19.string()
4735
5262
  }),
4736
- import_v418.z.object({
4737
- command: import_v418.z.literal("str_replace"),
4738
- path: import_v418.z.string(),
4739
- old_str: import_v418.z.string(),
4740
- new_str: import_v418.z.string()
5263
+ z19.object({
5264
+ command: z19.literal("str_replace"),
5265
+ path: z19.string(),
5266
+ old_str: z19.string(),
5267
+ new_str: z19.string()
4741
5268
  }),
4742
- import_v418.z.object({
4743
- command: import_v418.z.literal("insert"),
4744
- path: import_v418.z.string(),
4745
- insert_line: import_v418.z.number(),
4746
- insert_text: import_v418.z.string()
5269
+ z19.object({
5270
+ command: z19.literal("insert"),
5271
+ path: z19.string(),
5272
+ insert_line: z19.number(),
5273
+ insert_text: z19.string()
4747
5274
  }),
4748
- import_v418.z.object({
4749
- command: import_v418.z.literal("delete"),
4750
- path: import_v418.z.string()
5275
+ z19.object({
5276
+ command: z19.literal("delete"),
5277
+ path: z19.string()
4751
5278
  }),
4752
- import_v418.z.object({
4753
- command: import_v418.z.literal("rename"),
4754
- old_path: import_v418.z.string(),
4755
- new_path: import_v418.z.string()
5279
+ z19.object({
5280
+ command: z19.literal("rename"),
5281
+ old_path: z19.string(),
5282
+ new_path: z19.string()
4756
5283
  })
4757
5284
  ])
4758
5285
  )
4759
5286
  );
4760
- var memory_20250818 = (0, import_provider_utils21.createProviderToolFactory)({
5287
+ var memory_20250818 = createProviderDefinedToolFactory7({
4761
5288
  id: "anthropic.memory_20250818",
4762
5289
  inputSchema: memory_20250818InputSchema
4763
5290
  });
4764
5291
 
4765
5292
  // src/tool/text-editor_20241022.ts
4766
- var import_provider_utils22 = require("@ai-sdk/provider-utils");
4767
- var import_v419 = require("zod/v4");
4768
- var textEditor_20241022InputSchema = (0, import_provider_utils22.lazySchema)(
4769
- () => (0, import_provider_utils22.zodSchema)(
4770
- import_v419.z.object({
4771
- command: import_v419.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
4772
- path: import_v419.z.string(),
4773
- file_text: import_v419.z.string().optional(),
4774
- insert_line: import_v419.z.number().int().optional(),
4775
- new_str: import_v419.z.string().optional(),
4776
- insert_text: import_v419.z.string().optional(),
4777
- old_str: import_v419.z.string().optional(),
4778
- view_range: import_v419.z.array(import_v419.z.number().int()).optional()
5293
+ import {
5294
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
5295
+ lazySchema as lazySchema19,
5296
+ zodSchema as zodSchema19
5297
+ } from "@ai-sdk/provider-utils";
5298
+ import { z as z20 } from "zod/v4";
5299
+ var textEditor_20241022InputSchema = lazySchema19(
5300
+ () => zodSchema19(
5301
+ z20.object({
5302
+ command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5303
+ path: z20.string(),
5304
+ file_text: z20.string().optional(),
5305
+ insert_line: z20.number().int().optional(),
5306
+ new_str: z20.string().optional(),
5307
+ insert_text: z20.string().optional(),
5308
+ old_str: z20.string().optional(),
5309
+ view_range: z20.array(z20.number().int()).optional()
4779
5310
  })
4780
5311
  )
4781
5312
  );
4782
- var textEditor_20241022 = (0, import_provider_utils22.createProviderToolFactory)({
5313
+ var textEditor_20241022 = createProviderDefinedToolFactory8({
4783
5314
  id: "anthropic.text_editor_20241022",
4784
5315
  inputSchema: textEditor_20241022InputSchema
4785
5316
  });
4786
5317
 
4787
5318
  // src/tool/text-editor_20250124.ts
4788
- var import_provider_utils23 = require("@ai-sdk/provider-utils");
4789
- var import_v420 = require("zod/v4");
4790
- var textEditor_20250124InputSchema = (0, import_provider_utils23.lazySchema)(
4791
- () => (0, import_provider_utils23.zodSchema)(
4792
- import_v420.z.object({
4793
- command: import_v420.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
4794
- path: import_v420.z.string(),
4795
- file_text: import_v420.z.string().optional(),
4796
- insert_line: import_v420.z.number().int().optional(),
4797
- new_str: import_v420.z.string().optional(),
4798
- insert_text: import_v420.z.string().optional(),
4799
- old_str: import_v420.z.string().optional(),
4800
- view_range: import_v420.z.array(import_v420.z.number().int()).optional()
5319
+ import {
5320
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
5321
+ lazySchema as lazySchema20,
5322
+ zodSchema as zodSchema20
5323
+ } from "@ai-sdk/provider-utils";
5324
+ import { z as z21 } from "zod/v4";
5325
+ var textEditor_20250124InputSchema = lazySchema20(
5326
+ () => zodSchema20(
5327
+ z21.object({
5328
+ command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5329
+ path: z21.string(),
5330
+ file_text: z21.string().optional(),
5331
+ insert_line: z21.number().int().optional(),
5332
+ new_str: z21.string().optional(),
5333
+ insert_text: z21.string().optional(),
5334
+ old_str: z21.string().optional(),
5335
+ view_range: z21.array(z21.number().int()).optional()
4801
5336
  })
4802
5337
  )
4803
5338
  );
4804
- var textEditor_20250124 = (0, import_provider_utils23.createProviderToolFactory)({
5339
+ var textEditor_20250124 = createProviderDefinedToolFactory9({
4805
5340
  id: "anthropic.text_editor_20250124",
4806
5341
  inputSchema: textEditor_20250124InputSchema
4807
5342
  });
4808
5343
 
4809
5344
  // src/tool/text-editor_20250429.ts
4810
- var import_provider_utils24 = require("@ai-sdk/provider-utils");
4811
- var import_v421 = require("zod/v4");
4812
- var textEditor_20250429InputSchema = (0, import_provider_utils24.lazySchema)(
4813
- () => (0, import_provider_utils24.zodSchema)(
4814
- import_v421.z.object({
4815
- command: import_v421.z.enum(["view", "create", "str_replace", "insert"]),
4816
- path: import_v421.z.string(),
4817
- file_text: import_v421.z.string().optional(),
4818
- insert_line: import_v421.z.number().int().optional(),
4819
- new_str: import_v421.z.string().optional(),
4820
- insert_text: import_v421.z.string().optional(),
4821
- old_str: import_v421.z.string().optional(),
4822
- view_range: import_v421.z.array(import_v421.z.number().int()).optional()
5345
+ import {
5346
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory10,
5347
+ lazySchema as lazySchema21,
5348
+ zodSchema as zodSchema21
5349
+ } from "@ai-sdk/provider-utils";
5350
+ import { z as z22 } from "zod/v4";
5351
+ var textEditor_20250429InputSchema = lazySchema21(
5352
+ () => zodSchema21(
5353
+ z22.object({
5354
+ command: z22.enum(["view", "create", "str_replace", "insert"]),
5355
+ path: z22.string(),
5356
+ file_text: z22.string().optional(),
5357
+ insert_line: z22.number().int().optional(),
5358
+ new_str: z22.string().optional(),
5359
+ insert_text: z22.string().optional(),
5360
+ old_str: z22.string().optional(),
5361
+ view_range: z22.array(z22.number().int()).optional()
4823
5362
  })
4824
5363
  )
4825
5364
  );
4826
- var textEditor_20250429 = (0, import_provider_utils24.createProviderToolFactory)({
5365
+ var textEditor_20250429 = createProviderDefinedToolFactory10({
4827
5366
  id: "anthropic.text_editor_20250429",
4828
5367
  inputSchema: textEditor_20250429InputSchema
4829
5368
  });
4830
5369
 
4831
5370
  // src/tool/tool-search-bm25_20251119.ts
4832
- var import_provider_utils25 = require("@ai-sdk/provider-utils");
4833
- var import_v422 = require("zod/v4");
4834
- var toolSearchBm25_20251119OutputSchema = (0, import_provider_utils25.lazySchema)(
4835
- () => (0, import_provider_utils25.zodSchema)(
4836
- import_v422.z.array(
4837
- import_v422.z.object({
4838
- type: import_v422.z.literal("tool_reference"),
4839
- toolName: import_v422.z.string()
5371
+ import {
5372
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory9,
5373
+ lazySchema as lazySchema22,
5374
+ zodSchema as zodSchema22
5375
+ } from "@ai-sdk/provider-utils";
5376
+ import { z as z23 } from "zod/v4";
5377
+ var toolSearchBm25_20251119OutputSchema = lazySchema22(
5378
+ () => zodSchema22(
5379
+ z23.array(
5380
+ z23.object({
5381
+ type: z23.literal("tool_reference"),
5382
+ toolName: z23.string()
4840
5383
  })
4841
5384
  )
4842
5385
  )
4843
5386
  );
4844
- var toolSearchBm25_20251119InputSchema = (0, import_provider_utils25.lazySchema)(
4845
- () => (0, import_provider_utils25.zodSchema)(
4846
- import_v422.z.object({
5387
+ var toolSearchBm25_20251119InputSchema = lazySchema22(
5388
+ () => zodSchema22(
5389
+ z23.object({
4847
5390
  /**
4848
5391
  * A natural language query to search for tools.
4849
5392
  * Claude will use BM25 text search to find relevant tools.
4850
5393
  */
4851
- query: import_v422.z.string(),
5394
+ query: z23.string(),
4852
5395
  /**
4853
5396
  * Maximum number of tools to return. Optional.
4854
5397
  */
4855
- limit: import_v422.z.number().optional()
5398
+ limit: z23.number().optional()
4856
5399
  })
4857
5400
  )
4858
5401
  );
4859
- var factory10 = (0, import_provider_utils25.createProviderToolFactoryWithOutputSchema)({
5402
+ var factory10 = createProviderExecutedToolFactory9({
4860
5403
  id: "anthropic.tool_search_bm25_20251119",
4861
5404
  inputSchema: toolSearchBm25_20251119InputSchema,
4862
5405
  outputSchema: toolSearchBm25_20251119OutputSchema,
@@ -5068,31 +5611,163 @@ var anthropicTools = {
5068
5611
  toolSearchBm25_20251119
5069
5612
  };
5070
5613
 
5614
+ // src/skills/anthropic-skills.ts
5615
+ import {
5616
+ combineHeaders as combineHeaders3,
5617
+ convertInlineFileDataToUint8Array as convertInlineFileDataToUint8Array2,
5618
+ createJsonResponseHandler as createJsonResponseHandler3,
5619
+ getFromApi,
5620
+ postFormDataToApi as postFormDataToApi2,
5621
+ resolve as resolve2
5622
+ } from "@ai-sdk/provider-utils";
5623
+
5624
+ // src/skills/anthropic-skills-api.ts
5625
+ import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
5626
+ import { z as z24 } from "zod/v4";
5627
+ var anthropicSkillResponseSchema = lazySchema23(
5628
+ () => zodSchema23(
5629
+ z24.object({
5630
+ id: z24.string(),
5631
+ display_title: z24.string().nullish(),
5632
+ name: z24.string().nullish(),
5633
+ description: z24.string().nullish(),
5634
+ latest_version: z24.string().nullish(),
5635
+ source: z24.string(),
5636
+ created_at: z24.string(),
5637
+ updated_at: z24.string()
5638
+ })
5639
+ )
5640
+ );
5641
+ var anthropicSkillVersionListResponseSchema = lazySchema23(
5642
+ () => zodSchema23(
5643
+ z24.object({
5644
+ data: z24.array(
5645
+ z24.object({
5646
+ version: z24.string()
5647
+ })
5648
+ )
5649
+ })
5650
+ )
5651
+ );
5652
+ var anthropicSkillVersionResponseSchema = lazySchema23(
5653
+ () => zodSchema23(
5654
+ z24.object({
5655
+ type: z24.string(),
5656
+ skill_id: z24.string(),
5657
+ name: z24.string().nullish(),
5658
+ description: z24.string().nullish()
5659
+ })
5660
+ )
5661
+ );
5662
+
5663
+ // src/skills/anthropic-skills.ts
5664
+ var AnthropicSkills = class {
5665
+ constructor(config) {
5666
+ this.config = config;
5667
+ this.specificationVersion = "v4";
5668
+ }
5669
+ get provider() {
5670
+ return this.config.provider;
5671
+ }
5672
+ async getHeaders() {
5673
+ return combineHeaders3(await resolve2(this.config.headers), {
5674
+ "anthropic-beta": "skills-2025-10-02"
5675
+ });
5676
+ }
5677
+ async fetchVersionMetadata({
5678
+ skillId,
5679
+ version,
5680
+ headers
5681
+ }) {
5682
+ const { value: versionResponse } = await getFromApi({
5683
+ url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
5684
+ headers,
5685
+ failedResponseHandler: anthropicFailedResponseHandler,
5686
+ successfulResponseHandler: createJsonResponseHandler3(
5687
+ anthropicSkillVersionResponseSchema
5688
+ ),
5689
+ fetch: this.config.fetch
5690
+ });
5691
+ return {
5692
+ ...versionResponse.name != null ? { name: versionResponse.name } : {},
5693
+ ...versionResponse.description != null ? { description: versionResponse.description } : {}
5694
+ };
5695
+ }
5696
+ async uploadSkill(params) {
5697
+ var _a, _b;
5698
+ const warnings = [];
5699
+ const formData = new FormData();
5700
+ if (params.displayTitle != null) {
5701
+ formData.append("display_title", params.displayTitle);
5702
+ }
5703
+ for (const file of params.files) {
5704
+ const content = convertInlineFileDataToUint8Array2(file.data);
5705
+ formData.append("files[]", new Blob([content]), file.path);
5706
+ }
5707
+ const headers = await this.getHeaders();
5708
+ const { value: response } = await postFormDataToApi2({
5709
+ url: `${this.config.baseURL}/skills`,
5710
+ headers,
5711
+ formData,
5712
+ failedResponseHandler: anthropicFailedResponseHandler,
5713
+ successfulResponseHandler: createJsonResponseHandler3(
5714
+ anthropicSkillResponseSchema
5715
+ ),
5716
+ fetch: this.config.fetch
5717
+ });
5718
+ const versionMetadata = response.latest_version != null ? await this.fetchVersionMetadata({
5719
+ skillId: response.id,
5720
+ version: response.latest_version,
5721
+ headers
5722
+ }) : {};
5723
+ const name = (_a = versionMetadata.name) != null ? _a : response.name;
5724
+ const description = (_b = versionMetadata.description) != null ? _b : response.description;
5725
+ return {
5726
+ providerReference: { anthropic: response.id },
5727
+ ...response.display_title != null ? { displayTitle: response.display_title } : {},
5728
+ ...name != null ? { name } : {},
5729
+ ...description != null ? { description } : {},
5730
+ ...response.latest_version != null ? { latestVersion: response.latest_version } : {},
5731
+ providerMetadata: {
5732
+ anthropic: {
5733
+ ...response.source != null ? { source: response.source } : {},
5734
+ ...response.created_at != null ? { createdAt: response.created_at } : {},
5735
+ ...response.updated_at != null ? { updatedAt: response.updated_at } : {}
5736
+ }
5737
+ },
5738
+ warnings
5739
+ };
5740
+ }
5741
+ };
5742
+
5743
+ // src/version.ts
5744
+ var VERSION = true ? "4.0.0-beta.41" : "0.0.0-test";
5745
+
5071
5746
  // src/anthropic-provider.ts
5072
5747
  function createAnthropic(options = {}) {
5073
5748
  var _a, _b;
5074
- const baseURL = (_a = (0, import_provider_utils26.withoutTrailingSlash)(
5075
- (0, import_provider_utils26.loadOptionalSetting)({
5749
+ const baseURL = (_a = withoutTrailingSlash(
5750
+ loadOptionalSetting({
5076
5751
  settingValue: options.baseURL,
5077
5752
  environmentVariableName: "ANTHROPIC_BASE_URL"
5078
5753
  })
5079
5754
  )) != null ? _a : "https://api.anthropic.com/v1";
5080
5755
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
5081
5756
  if (options.apiKey && options.authToken) {
5082
- throw new import_provider4.InvalidArgumentError({
5757
+ throw new InvalidArgumentError({
5083
5758
  argument: "apiKey/authToken",
5084
5759
  message: "Both apiKey and authToken were provided. Please use only one authentication method."
5085
5760
  });
5086
5761
  }
5087
5762
  const getHeaders = () => {
5088
5763
  const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
5089
- "x-api-key": (0, import_provider_utils26.loadApiKey)({
5764
+ "x-api-key": loadApiKey({
5090
5765
  apiKey: options.apiKey,
5091
5766
  environmentVariableName: "ANTHROPIC_API_KEY",
5092
5767
  description: "Anthropic"
5093
5768
  })
5094
5769
  };
5095
- return (0, import_provider_utils26.withUserAgentSuffix)(
5770
+ return withUserAgentSuffix(
5096
5771
  {
5097
5772
  "anthropic-version": "2023-06-01",
5098
5773
  ...authHeaders,
@@ -5103,18 +5778,24 @@ function createAnthropic(options = {}) {
5103
5778
  };
5104
5779
  const createChatModel = (modelId) => {
5105
5780
  var _a2;
5106
- return new AnthropicMessagesLanguageModel(modelId, {
5781
+ return new AnthropicLanguageModel(modelId, {
5107
5782
  provider: providerName,
5108
5783
  baseURL,
5109
5784
  headers: getHeaders,
5110
5785
  fetch: options.fetch,
5111
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils26.generateId,
5786
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
5112
5787
  supportedUrls: () => ({
5113
5788
  "image/*": [/^https?:\/\/.*$/],
5114
5789
  "application/pdf": [/^https?:\/\/.*$/]
5115
5790
  })
5116
5791
  });
5117
5792
  };
5793
+ const createSkills = () => new AnthropicSkills({
5794
+ provider: `${providerName.replace(".messages", "")}.skills`,
5795
+ baseURL,
5796
+ headers: getHeaders,
5797
+ fetch: options.fetch
5798
+ });
5118
5799
  const provider = function(modelId) {
5119
5800
  if (new.target) {
5120
5801
  throw new Error(
@@ -5128,12 +5809,19 @@ function createAnthropic(options = {}) {
5128
5809
  provider.chat = createChatModel;
5129
5810
  provider.messages = createChatModel;
5130
5811
  provider.embeddingModel = (modelId) => {
5131
- throw new import_provider4.NoSuchModelError({ modelId, modelType: "embeddingModel" });
5812
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
5132
5813
  };
5133
5814
  provider.textEmbeddingModel = provider.embeddingModel;
5134
5815
  provider.imageModel = (modelId) => {
5135
- throw new import_provider4.NoSuchModelError({ modelId, modelType: "imageModel" });
5816
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
5136
5817
  };
5818
+ provider.files = () => new AnthropicFiles({
5819
+ provider: providerName,
5820
+ baseURL,
5821
+ headers: getHeaders,
5822
+ fetch: options.fetch
5823
+ });
5824
+ provider.skills = createSkills;
5137
5825
  provider.tools = anthropicTools;
5138
5826
  return provider;
5139
5827
  }
@@ -5158,11 +5846,10 @@ function forwardAnthropicContainerIdFromLastStep({
5158
5846
  }
5159
5847
  return void 0;
5160
5848
  }
5161
- // Annotate the CommonJS export names for ESM import in node:
5162
- 0 && (module.exports = {
5849
+ export {
5163
5850
  VERSION,
5164
5851
  anthropic,
5165
5852
  createAnthropic,
5166
5853
  forwardAnthropicContainerIdFromLastStep
5167
- });
5854
+ };
5168
5855
  //# sourceMappingURL=index.js.map