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

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 (50) hide show
  1. package/CHANGELOG.md +293 -4
  2. package/README.md +2 -0
  3. package/dist/index.d.ts +83 -58
  4. package/dist/index.js +1918 -1259
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +85 -58
  7. package/dist/internal/index.js +1679 -1245
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/05-anthropic.mdx +115 -12
  10. package/package.json +14 -15
  11. package/src/{anthropic-messages-api.ts → anthropic-api.ts} +8 -4
  12. package/src/anthropic-files.ts +96 -0
  13. package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +239 -54
  14. package/src/anthropic-message-metadata.ts +0 -3
  15. package/src/{anthropic-messages-options.ts → anthropic-options.ts} +68 -11
  16. package/src/anthropic-prepare-tools.ts +12 -5
  17. package/src/anthropic-provider.ts +39 -10
  18. package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +3 -3
  19. package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +51 -28
  20. package/src/get-cache-control.ts +1 -1
  21. package/src/index.ts +1 -1
  22. package/src/internal/index.ts +11 -2
  23. package/src/sanitize-json-schema.ts +203 -0
  24. package/src/skills/anthropic-skills-api.ts +44 -0
  25. package/src/skills/anthropic-skills.ts +136 -0
  26. package/src/tool/bash_20241022.ts +2 -2
  27. package/src/tool/bash_20250124.ts +2 -2
  28. package/src/tool/code-execution_20250522.ts +2 -2
  29. package/src/tool/code-execution_20250825.ts +2 -2
  30. package/src/tool/code-execution_20260120.ts +2 -2
  31. package/src/tool/computer_20241022.ts +2 -2
  32. package/src/tool/computer_20250124.ts +2 -2
  33. package/src/tool/computer_20251124.ts +2 -2
  34. package/src/tool/memory_20250818.ts +2 -2
  35. package/src/tool/text-editor_20241022.ts +2 -2
  36. package/src/tool/text-editor_20250124.ts +2 -2
  37. package/src/tool/text-editor_20250429.ts +2 -2
  38. package/src/tool/text-editor_20250728.ts +2 -2
  39. package/src/tool/tool-search-bm25_20251119.ts +2 -2
  40. package/src/tool/tool-search-regex_20251119.ts +2 -2
  41. package/src/tool/web-fetch-20250910.ts +2 -2
  42. package/src/tool/web-fetch-20260209.ts +2 -2
  43. package/src/tool/web-search_20250305.ts +2 -2
  44. package/src/tool/web-search_20260209.ts +2 -2
  45. package/dist/index.d.mts +0 -1090
  46. package/dist/index.mjs +0 -5244
  47. package/dist/index.mjs.map +0 -1
  48. package/dist/internal/index.d.mts +0 -969
  49. package/dist/internal/index.mjs +0 -5136
  50. package/dist/internal/index.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,375 +1,451 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var 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
+ convertBase64ToUint8Array,
18
+ createJsonResponseHandler,
19
+ lazySchema as lazySchema2,
20
+ postFormDataToApi,
21
+ zodSchema as zodSchema2
22
+ } from "@ai-sdk/provider-utils";
23
+ import { z as z2 } from "zod/v4";
40
24
 
41
25
  // src/anthropic-error.ts
42
- var import_provider_utils = require("@ai-sdk/provider-utils");
43
- var import_v4 = require("zod/v4");
44
- var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
45
- () => (0, import_provider_utils.zodSchema)(
46
- import_v4.z.object({
47
- type: import_v4.z.literal("error"),
48
- error: import_v4.z.object({
49
- type: import_v4.z.string(),
50
- message: import_v4.z.string()
26
+ import {
27
+ createJsonErrorResponseHandler,
28
+ lazySchema,
29
+ zodSchema
30
+ } from "@ai-sdk/provider-utils";
31
+ import { z } from "zod/v4";
32
+ var anthropicErrorDataSchema = lazySchema(
33
+ () => zodSchema(
34
+ z.object({
35
+ type: z.literal("error"),
36
+ error: z.object({
37
+ type: z.string(),
38
+ message: z.string()
51
39
  })
52
40
  })
53
41
  )
54
42
  );
55
- var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
43
+ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
56
44
  errorSchema: anthropicErrorDataSchema,
57
45
  errorToMessage: (data) => data.error.message
58
46
  });
59
47
 
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 = data instanceof Uint8Array ? data : convertBase64ToUint8Array(data);
77
+ const blob = new Blob([fileBytes], { type: mediaType });
78
+ const formData = new FormData();
79
+ if (filename != null) {
80
+ formData.append("file", blob, filename);
81
+ } else {
82
+ formData.append("file", blob);
83
+ }
84
+ const { value: response } = await postFormDataToApi({
85
+ url: `${this.config.baseURL}/files`,
86
+ headers: combineHeaders(this.config.headers(), {
87
+ "anthropic-beta": "files-api-2025-04-14"
88
+ }),
89
+ formData,
90
+ failedResponseHandler: anthropicFailedResponseHandler,
91
+ successfulResponseHandler: createJsonResponseHandler(
92
+ anthropicUploadFileResponseSchema
93
+ ),
94
+ fetch: this.config.fetch
95
+ });
96
+ return {
97
+ warnings: [],
98
+ providerReference: { anthropic: response.id },
99
+ mediaType: (_a = response.mime_type) != null ? _a : mediaType,
100
+ filename: (_b = response.filename) != null ? _b : filename,
101
+ providerMetadata: {
102
+ anthropic: {
103
+ filename: response.filename,
104
+ mimeType: response.mime_type,
105
+ sizeBytes: response.size_bytes,
106
+ createdAt: response.created_at,
107
+ ...response.downloadable != null ? { downloadable: response.downloadable } : {}
108
+ }
109
+ }
110
+ };
111
+ }
112
+ };
113
+
114
+ // src/anthropic-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 { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
138
+ import { z as z3 } from "zod/v4";
139
+ var anthropicResponseSchema = lazySchema3(
140
+ () => zodSchema3(
141
+ z3.object({
142
+ type: z3.literal("message"),
143
+ id: z3.string().nullish(),
144
+ model: z3.string().nullish(),
145
+ content: z3.array(
146
+ z3.discriminatedUnion("type", [
147
+ z3.object({
148
+ type: z3.literal("text"),
149
+ text: z3.string(),
150
+ citations: z3.array(
151
+ z3.discriminatedUnion("type", [
152
+ z3.object({
153
+ type: z3.literal("web_search_result_location"),
154
+ cited_text: z3.string(),
155
+ url: z3.string(),
156
+ title: z3.string(),
157
+ encrypted_index: z3.string()
82
158
  }),
83
- import_v42.z.object({
84
- type: import_v42.z.literal("page_location"),
85
- cited_text: import_v42.z.string(),
86
- document_index: import_v42.z.number(),
87
- document_title: import_v42.z.string().nullable(),
88
- start_page_number: import_v42.z.number(),
89
- end_page_number: import_v42.z.number()
159
+ z3.object({
160
+ type: z3.literal("page_location"),
161
+ cited_text: z3.string(),
162
+ document_index: z3.number(),
163
+ document_title: z3.string().nullable(),
164
+ start_page_number: z3.number(),
165
+ end_page_number: z3.number()
90
166
  }),
91
- import_v42.z.object({
92
- type: import_v42.z.literal("char_location"),
93
- cited_text: import_v42.z.string(),
94
- document_index: import_v42.z.number(),
95
- document_title: import_v42.z.string().nullable(),
96
- start_char_index: import_v42.z.number(),
97
- end_char_index: import_v42.z.number()
167
+ z3.object({
168
+ type: z3.literal("char_location"),
169
+ cited_text: z3.string(),
170
+ document_index: z3.number(),
171
+ document_title: z3.string().nullable(),
172
+ start_char_index: z3.number(),
173
+ end_char_index: z3.number()
98
174
  })
99
175
  ])
100
176
  ).optional()
101
177
  }),
102
- import_v42.z.object({
103
- type: import_v42.z.literal("thinking"),
104
- thinking: import_v42.z.string(),
105
- signature: import_v42.z.string()
178
+ z3.object({
179
+ type: z3.literal("thinking"),
180
+ thinking: z3.string(),
181
+ signature: z3.string()
106
182
  }),
107
- import_v42.z.object({
108
- type: import_v42.z.literal("redacted_thinking"),
109
- data: import_v42.z.string()
183
+ z3.object({
184
+ type: z3.literal("redacted_thinking"),
185
+ data: z3.string()
110
186
  }),
111
- import_v42.z.object({
112
- type: import_v42.z.literal("compaction"),
113
- content: import_v42.z.string()
187
+ z3.object({
188
+ type: z3.literal("compaction"),
189
+ content: z3.string()
114
190
  }),
115
- import_v42.z.object({
116
- type: import_v42.z.literal("tool_use"),
117
- id: import_v42.z.string(),
118
- name: import_v42.z.string(),
119
- input: import_v42.z.unknown(),
191
+ z3.object({
192
+ type: z3.literal("tool_use"),
193
+ id: z3.string(),
194
+ name: z3.string(),
195
+ input: z3.unknown(),
120
196
  // Programmatic tool calling: caller info when triggered from code execution
121
- caller: import_v42.z.union([
122
- import_v42.z.object({
123
- type: import_v42.z.literal("code_execution_20250825"),
124
- tool_id: import_v42.z.string()
197
+ caller: z3.union([
198
+ z3.object({
199
+ type: z3.literal("code_execution_20250825"),
200
+ tool_id: z3.string()
125
201
  }),
126
- import_v42.z.object({
127
- type: import_v42.z.literal("code_execution_20260120"),
128
- tool_id: import_v42.z.string()
202
+ z3.object({
203
+ type: z3.literal("code_execution_20260120"),
204
+ tool_id: z3.string()
129
205
  }),
130
- import_v42.z.object({
131
- type: import_v42.z.literal("direct")
206
+ z3.object({
207
+ type: z3.literal("direct")
132
208
  })
133
209
  ]).optional()
134
210
  }),
135
- import_v42.z.object({
136
- type: import_v42.z.literal("server_tool_use"),
137
- id: import_v42.z.string(),
138
- name: import_v42.z.string(),
139
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
140
- caller: import_v42.z.union([
141
- import_v42.z.object({
142
- type: import_v42.z.literal("code_execution_20260120"),
143
- tool_id: import_v42.z.string()
211
+ z3.object({
212
+ type: z3.literal("server_tool_use"),
213
+ id: z3.string(),
214
+ name: z3.string(),
215
+ input: z3.record(z3.string(), z3.unknown()).nullish(),
216
+ caller: z3.union([
217
+ z3.object({
218
+ type: z3.literal("code_execution_20260120"),
219
+ tool_id: z3.string()
144
220
  }),
145
- import_v42.z.object({
146
- type: import_v42.z.literal("direct")
221
+ z3.object({
222
+ type: z3.literal("direct")
147
223
  })
148
224
  ]).optional()
149
225
  }),
150
- import_v42.z.object({
151
- type: import_v42.z.literal("mcp_tool_use"),
152
- id: import_v42.z.string(),
153
- name: import_v42.z.string(),
154
- input: import_v42.z.unknown(),
155
- server_name: import_v42.z.string()
226
+ z3.object({
227
+ type: z3.literal("mcp_tool_use"),
228
+ id: z3.string(),
229
+ name: z3.string(),
230
+ input: z3.unknown(),
231
+ server_name: z3.string()
156
232
  }),
157
- import_v42.z.object({
158
- type: import_v42.z.literal("mcp_tool_result"),
159
- tool_use_id: import_v42.z.string(),
160
- is_error: import_v42.z.boolean(),
161
- content: import_v42.z.array(
162
- import_v42.z.union([
163
- import_v42.z.string(),
164
- import_v42.z.object({ type: import_v42.z.literal("text"), text: import_v42.z.string() })
233
+ z3.object({
234
+ type: z3.literal("mcp_tool_result"),
235
+ tool_use_id: z3.string(),
236
+ is_error: z3.boolean(),
237
+ content: z3.array(
238
+ z3.union([
239
+ z3.string(),
240
+ z3.object({ type: z3.literal("text"), text: z3.string() })
165
241
  ])
166
242
  )
167
243
  }),
168
- import_v42.z.object({
169
- type: import_v42.z.literal("web_fetch_tool_result"),
170
- tool_use_id: import_v42.z.string(),
171
- content: import_v42.z.union([
172
- import_v42.z.object({
173
- type: import_v42.z.literal("web_fetch_result"),
174
- url: import_v42.z.string(),
175
- retrieved_at: import_v42.z.string(),
176
- content: import_v42.z.object({
177
- type: import_v42.z.literal("document"),
178
- title: import_v42.z.string().nullable(),
179
- citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
180
- source: import_v42.z.union([
181
- import_v42.z.object({
182
- type: import_v42.z.literal("base64"),
183
- media_type: import_v42.z.literal("application/pdf"),
184
- data: import_v42.z.string()
244
+ z3.object({
245
+ type: z3.literal("web_fetch_tool_result"),
246
+ tool_use_id: z3.string(),
247
+ content: z3.union([
248
+ z3.object({
249
+ type: z3.literal("web_fetch_result"),
250
+ url: z3.string(),
251
+ retrieved_at: z3.string(),
252
+ content: z3.object({
253
+ type: z3.literal("document"),
254
+ title: z3.string().nullable(),
255
+ citations: z3.object({ enabled: z3.boolean() }).optional(),
256
+ source: z3.union([
257
+ z3.object({
258
+ type: z3.literal("base64"),
259
+ media_type: z3.literal("application/pdf"),
260
+ data: z3.string()
185
261
  }),
186
- import_v42.z.object({
187
- type: import_v42.z.literal("text"),
188
- media_type: import_v42.z.literal("text/plain"),
189
- data: import_v42.z.string()
262
+ z3.object({
263
+ type: z3.literal("text"),
264
+ media_type: z3.literal("text/plain"),
265
+ data: z3.string()
190
266
  })
191
267
  ])
192
268
  })
193
269
  }),
194
- import_v42.z.object({
195
- type: import_v42.z.literal("web_fetch_tool_result_error"),
196
- error_code: import_v42.z.string()
270
+ z3.object({
271
+ type: z3.literal("web_fetch_tool_result_error"),
272
+ error_code: z3.string()
197
273
  })
198
274
  ])
199
275
  }),
200
- import_v42.z.object({
201
- type: import_v42.z.literal("web_search_tool_result"),
202
- tool_use_id: import_v42.z.string(),
203
- content: import_v42.z.union([
204
- import_v42.z.array(
205
- import_v42.z.object({
206
- type: import_v42.z.literal("web_search_result"),
207
- url: import_v42.z.string(),
208
- title: import_v42.z.string(),
209
- encrypted_content: import_v42.z.string(),
210
- page_age: import_v42.z.string().nullish()
276
+ z3.object({
277
+ type: z3.literal("web_search_tool_result"),
278
+ tool_use_id: z3.string(),
279
+ content: z3.union([
280
+ z3.array(
281
+ z3.object({
282
+ type: z3.literal("web_search_result"),
283
+ url: z3.string(),
284
+ title: z3.string(),
285
+ encrypted_content: z3.string(),
286
+ page_age: z3.string().nullish()
211
287
  })
212
288
  ),
213
- import_v42.z.object({
214
- type: import_v42.z.literal("web_search_tool_result_error"),
215
- error_code: import_v42.z.string()
289
+ z3.object({
290
+ type: z3.literal("web_search_tool_result_error"),
291
+ error_code: z3.string()
216
292
  })
217
293
  ])
218
294
  }),
219
295
  // code execution results for code_execution_20250522 tool:
220
- import_v42.z.object({
221
- type: import_v42.z.literal("code_execution_tool_result"),
222
- tool_use_id: import_v42.z.string(),
223
- content: import_v42.z.union([
224
- import_v42.z.object({
225
- type: import_v42.z.literal("code_execution_result"),
226
- stdout: import_v42.z.string(),
227
- stderr: import_v42.z.string(),
228
- return_code: import_v42.z.number(),
229
- content: import_v42.z.array(
230
- import_v42.z.object({
231
- type: import_v42.z.literal("code_execution_output"),
232
- file_id: import_v42.z.string()
296
+ z3.object({
297
+ type: z3.literal("code_execution_tool_result"),
298
+ tool_use_id: z3.string(),
299
+ content: z3.union([
300
+ z3.object({
301
+ type: z3.literal("code_execution_result"),
302
+ stdout: z3.string(),
303
+ stderr: z3.string(),
304
+ return_code: z3.number(),
305
+ content: z3.array(
306
+ z3.object({
307
+ type: z3.literal("code_execution_output"),
308
+ file_id: z3.string()
233
309
  })
234
310
  ).optional().default([])
235
311
  }),
236
- import_v42.z.object({
237
- type: import_v42.z.literal("encrypted_code_execution_result"),
238
- encrypted_stdout: import_v42.z.string(),
239
- stderr: import_v42.z.string(),
240
- return_code: import_v42.z.number(),
241
- content: import_v42.z.array(
242
- import_v42.z.object({
243
- type: import_v42.z.literal("code_execution_output"),
244
- file_id: import_v42.z.string()
312
+ z3.object({
313
+ type: z3.literal("encrypted_code_execution_result"),
314
+ encrypted_stdout: z3.string(),
315
+ stderr: z3.string(),
316
+ return_code: z3.number(),
317
+ content: z3.array(
318
+ z3.object({
319
+ type: z3.literal("code_execution_output"),
320
+ file_id: z3.string()
245
321
  })
246
322
  ).optional().default([])
247
323
  }),
248
- import_v42.z.object({
249
- type: import_v42.z.literal("code_execution_tool_result_error"),
250
- error_code: import_v42.z.string()
324
+ z3.object({
325
+ type: z3.literal("code_execution_tool_result_error"),
326
+ error_code: z3.string()
251
327
  })
252
328
  ])
253
329
  }),
254
330
  // bash code execution results for code_execution_20250825 tool:
255
- import_v42.z.object({
256
- type: import_v42.z.literal("bash_code_execution_tool_result"),
257
- tool_use_id: import_v42.z.string(),
258
- content: import_v42.z.discriminatedUnion("type", [
259
- import_v42.z.object({
260
- type: import_v42.z.literal("bash_code_execution_result"),
261
- content: import_v42.z.array(
262
- import_v42.z.object({
263
- type: import_v42.z.literal("bash_code_execution_output"),
264
- file_id: import_v42.z.string()
331
+ z3.object({
332
+ type: z3.literal("bash_code_execution_tool_result"),
333
+ tool_use_id: z3.string(),
334
+ content: z3.discriminatedUnion("type", [
335
+ z3.object({
336
+ type: z3.literal("bash_code_execution_result"),
337
+ content: z3.array(
338
+ z3.object({
339
+ type: z3.literal("bash_code_execution_output"),
340
+ file_id: z3.string()
265
341
  })
266
342
  ),
267
- stdout: import_v42.z.string(),
268
- stderr: import_v42.z.string(),
269
- return_code: import_v42.z.number()
343
+ stdout: z3.string(),
344
+ stderr: z3.string(),
345
+ return_code: z3.number()
270
346
  }),
271
- import_v42.z.object({
272
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
273
- error_code: import_v42.z.string()
347
+ z3.object({
348
+ type: z3.literal("bash_code_execution_tool_result_error"),
349
+ error_code: z3.string()
274
350
  })
275
351
  ])
276
352
  }),
277
353
  // text editor code execution results for code_execution_20250825 tool:
278
- import_v42.z.object({
279
- type: import_v42.z.literal("text_editor_code_execution_tool_result"),
280
- tool_use_id: import_v42.z.string(),
281
- content: import_v42.z.discriminatedUnion("type", [
282
- import_v42.z.object({
283
- type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
284
- error_code: import_v42.z.string()
354
+ z3.object({
355
+ type: z3.literal("text_editor_code_execution_tool_result"),
356
+ tool_use_id: z3.string(),
357
+ content: z3.discriminatedUnion("type", [
358
+ z3.object({
359
+ type: z3.literal("text_editor_code_execution_tool_result_error"),
360
+ error_code: z3.string()
285
361
  }),
286
- import_v42.z.object({
287
- type: import_v42.z.literal("text_editor_code_execution_view_result"),
288
- content: import_v42.z.string(),
289
- file_type: import_v42.z.string(),
290
- num_lines: import_v42.z.number().nullable(),
291
- start_line: import_v42.z.number().nullable(),
292
- total_lines: import_v42.z.number().nullable()
362
+ z3.object({
363
+ type: z3.literal("text_editor_code_execution_view_result"),
364
+ content: z3.string(),
365
+ file_type: z3.string(),
366
+ num_lines: z3.number().nullable(),
367
+ start_line: z3.number().nullable(),
368
+ total_lines: z3.number().nullable()
293
369
  }),
294
- import_v42.z.object({
295
- type: import_v42.z.literal("text_editor_code_execution_create_result"),
296
- is_file_update: import_v42.z.boolean()
370
+ z3.object({
371
+ type: z3.literal("text_editor_code_execution_create_result"),
372
+ is_file_update: z3.boolean()
297
373
  }),
298
- import_v42.z.object({
299
- type: import_v42.z.literal(
374
+ z3.object({
375
+ type: z3.literal(
300
376
  "text_editor_code_execution_str_replace_result"
301
377
  ),
302
- lines: import_v42.z.array(import_v42.z.string()).nullable(),
303
- new_lines: import_v42.z.number().nullable(),
304
- new_start: import_v42.z.number().nullable(),
305
- old_lines: import_v42.z.number().nullable(),
306
- old_start: import_v42.z.number().nullable()
378
+ lines: z3.array(z3.string()).nullable(),
379
+ new_lines: z3.number().nullable(),
380
+ new_start: z3.number().nullable(),
381
+ old_lines: z3.number().nullable(),
382
+ old_start: z3.number().nullable()
307
383
  })
308
384
  ])
309
385
  }),
310
386
  // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
311
- import_v42.z.object({
312
- type: import_v42.z.literal("tool_search_tool_result"),
313
- tool_use_id: import_v42.z.string(),
314
- content: import_v42.z.union([
315
- import_v42.z.object({
316
- type: import_v42.z.literal("tool_search_tool_search_result"),
317
- tool_references: import_v42.z.array(
318
- import_v42.z.object({
319
- type: import_v42.z.literal("tool_reference"),
320
- tool_name: import_v42.z.string()
387
+ z3.object({
388
+ type: z3.literal("tool_search_tool_result"),
389
+ tool_use_id: z3.string(),
390
+ content: z3.union([
391
+ z3.object({
392
+ type: z3.literal("tool_search_tool_search_result"),
393
+ tool_references: z3.array(
394
+ z3.object({
395
+ type: z3.literal("tool_reference"),
396
+ tool_name: z3.string()
321
397
  })
322
398
  )
323
399
  }),
324
- import_v42.z.object({
325
- type: import_v42.z.literal("tool_search_tool_result_error"),
326
- error_code: import_v42.z.string()
400
+ z3.object({
401
+ type: z3.literal("tool_search_tool_result_error"),
402
+ error_code: z3.string()
327
403
  })
328
404
  ])
329
405
  })
330
406
  ])
331
407
  ),
332
- stop_reason: import_v42.z.string().nullish(),
333
- stop_sequence: import_v42.z.string().nullish(),
334
- usage: import_v42.z.looseObject({
335
- input_tokens: import_v42.z.number(),
336
- output_tokens: import_v42.z.number(),
337
- cache_creation_input_tokens: import_v42.z.number().nullish(),
338
- cache_read_input_tokens: import_v42.z.number().nullish(),
339
- iterations: import_v42.z.array(
340
- import_v42.z.object({
341
- type: import_v42.z.union([import_v42.z.literal("compaction"), import_v42.z.literal("message")]),
342
- input_tokens: import_v42.z.number(),
343
- output_tokens: import_v42.z.number()
408
+ stop_reason: z3.string().nullish(),
409
+ stop_sequence: z3.string().nullish(),
410
+ usage: z3.looseObject({
411
+ input_tokens: z3.number(),
412
+ output_tokens: z3.number(),
413
+ cache_creation_input_tokens: z3.number().nullish(),
414
+ cache_read_input_tokens: z3.number().nullish(),
415
+ iterations: z3.array(
416
+ z3.object({
417
+ type: z3.union([z3.literal("compaction"), z3.literal("message")]),
418
+ input_tokens: z3.number(),
419
+ output_tokens: z3.number()
344
420
  })
345
421
  ).nullish()
346
422
  }),
347
- container: import_v42.z.object({
348
- expires_at: import_v42.z.string(),
349
- id: import_v42.z.string(),
350
- skills: import_v42.z.array(
351
- import_v42.z.object({
352
- type: import_v42.z.union([import_v42.z.literal("anthropic"), import_v42.z.literal("custom")]),
353
- skill_id: import_v42.z.string(),
354
- version: import_v42.z.string()
423
+ container: z3.object({
424
+ expires_at: z3.string(),
425
+ id: z3.string(),
426
+ skills: z3.array(
427
+ z3.object({
428
+ type: z3.union([z3.literal("anthropic"), z3.literal("custom")]),
429
+ skill_id: z3.string(),
430
+ version: z3.string()
355
431
  })
356
432
  ).nullish()
357
433
  }).nullish(),
358
- context_management: import_v42.z.object({
359
- applied_edits: import_v42.z.array(
360
- import_v42.z.union([
361
- import_v42.z.object({
362
- type: import_v42.z.literal("clear_tool_uses_20250919"),
363
- cleared_tool_uses: import_v42.z.number(),
364
- cleared_input_tokens: import_v42.z.number()
434
+ context_management: z3.object({
435
+ applied_edits: z3.array(
436
+ z3.union([
437
+ z3.object({
438
+ type: z3.literal("clear_tool_uses_20250919"),
439
+ cleared_tool_uses: z3.number(),
440
+ cleared_input_tokens: z3.number()
365
441
  }),
366
- import_v42.z.object({
367
- type: import_v42.z.literal("clear_thinking_20251015"),
368
- cleared_thinking_turns: import_v42.z.number(),
369
- cleared_input_tokens: import_v42.z.number()
442
+ z3.object({
443
+ type: z3.literal("clear_thinking_20251015"),
444
+ cleared_thinking_turns: z3.number(),
445
+ cleared_input_tokens: z3.number()
370
446
  }),
371
- import_v42.z.object({
372
- type: import_v42.z.literal("compact_20260112")
447
+ z3.object({
448
+ type: z3.literal("compact_20260112")
373
449
  })
374
450
  ])
375
451
  )
@@ -377,457 +453,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
377
453
  })
378
454
  )
379
455
  );
380
- var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
381
- () => (0, import_provider_utils2.zodSchema)(
382
- import_v42.z.discriminatedUnion("type", [
383
- import_v42.z.object({
384
- type: import_v42.z.literal("message_start"),
385
- message: import_v42.z.object({
386
- id: import_v42.z.string().nullish(),
387
- model: import_v42.z.string().nullish(),
388
- role: import_v42.z.string().nullish(),
389
- usage: import_v42.z.looseObject({
390
- input_tokens: import_v42.z.number(),
391
- cache_creation_input_tokens: import_v42.z.number().nullish(),
392
- cache_read_input_tokens: import_v42.z.number().nullish()
456
+ var anthropicChunkSchema = lazySchema3(
457
+ () => zodSchema3(
458
+ z3.discriminatedUnion("type", [
459
+ z3.object({
460
+ type: z3.literal("message_start"),
461
+ message: z3.object({
462
+ id: z3.string().nullish(),
463
+ model: z3.string().nullish(),
464
+ role: z3.string().nullish(),
465
+ usage: z3.looseObject({
466
+ input_tokens: z3.number(),
467
+ cache_creation_input_tokens: z3.number().nullish(),
468
+ cache_read_input_tokens: z3.number().nullish()
393
469
  }),
394
470
  // Programmatic tool calling: content may be pre-populated for deferred tool calls
395
- content: import_v42.z.array(
396
- import_v42.z.discriminatedUnion("type", [
397
- import_v42.z.object({
398
- type: import_v42.z.literal("tool_use"),
399
- id: import_v42.z.string(),
400
- name: import_v42.z.string(),
401
- input: import_v42.z.unknown(),
402
- caller: import_v42.z.union([
403
- import_v42.z.object({
404
- type: import_v42.z.literal("code_execution_20250825"),
405
- tool_id: import_v42.z.string()
471
+ content: z3.array(
472
+ z3.discriminatedUnion("type", [
473
+ z3.object({
474
+ type: z3.literal("tool_use"),
475
+ id: z3.string(),
476
+ name: z3.string(),
477
+ input: z3.unknown(),
478
+ caller: z3.union([
479
+ z3.object({
480
+ type: z3.literal("code_execution_20250825"),
481
+ tool_id: z3.string()
406
482
  }),
407
- import_v42.z.object({
408
- type: import_v42.z.literal("code_execution_20260120"),
409
- tool_id: import_v42.z.string()
483
+ z3.object({
484
+ type: z3.literal("code_execution_20260120"),
485
+ tool_id: z3.string()
410
486
  }),
411
- import_v42.z.object({
412
- type: import_v42.z.literal("direct")
487
+ z3.object({
488
+ type: z3.literal("direct")
413
489
  })
414
490
  ]).optional()
415
491
  })
416
492
  ])
417
493
  ).nullish(),
418
- stop_reason: import_v42.z.string().nullish(),
419
- container: import_v42.z.object({
420
- expires_at: import_v42.z.string(),
421
- id: import_v42.z.string()
494
+ stop_reason: z3.string().nullish(),
495
+ container: z3.object({
496
+ expires_at: z3.string(),
497
+ id: z3.string()
422
498
  }).nullish()
423
499
  })
424
500
  }),
425
- import_v42.z.object({
426
- type: import_v42.z.literal("content_block_start"),
427
- index: import_v42.z.number(),
428
- content_block: import_v42.z.discriminatedUnion("type", [
429
- import_v42.z.object({
430
- type: import_v42.z.literal("text"),
431
- text: import_v42.z.string()
501
+ z3.object({
502
+ type: z3.literal("content_block_start"),
503
+ index: z3.number(),
504
+ content_block: z3.discriminatedUnion("type", [
505
+ z3.object({
506
+ type: z3.literal("text"),
507
+ text: z3.string()
432
508
  }),
433
- import_v42.z.object({
434
- type: import_v42.z.literal("thinking"),
435
- thinking: import_v42.z.string()
509
+ z3.object({
510
+ type: z3.literal("thinking"),
511
+ thinking: z3.string()
436
512
  }),
437
- import_v42.z.object({
438
- type: import_v42.z.literal("tool_use"),
439
- id: import_v42.z.string(),
440
- name: import_v42.z.string(),
513
+ z3.object({
514
+ type: z3.literal("tool_use"),
515
+ id: z3.string(),
516
+ name: z3.string(),
441
517
  // Programmatic tool calling: input may be present directly for deferred tool calls
442
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional(),
518
+ input: z3.record(z3.string(), z3.unknown()).optional(),
443
519
  // Programmatic tool calling: caller info when triggered from code execution
444
- caller: import_v42.z.union([
445
- import_v42.z.object({
446
- type: import_v42.z.literal("code_execution_20250825"),
447
- tool_id: import_v42.z.string()
520
+ caller: z3.union([
521
+ z3.object({
522
+ type: z3.literal("code_execution_20250825"),
523
+ tool_id: z3.string()
448
524
  }),
449
- import_v42.z.object({
450
- type: import_v42.z.literal("code_execution_20260120"),
451
- tool_id: import_v42.z.string()
525
+ z3.object({
526
+ type: z3.literal("code_execution_20260120"),
527
+ tool_id: z3.string()
452
528
  }),
453
- import_v42.z.object({
454
- type: import_v42.z.literal("direct")
529
+ z3.object({
530
+ type: z3.literal("direct")
455
531
  })
456
532
  ]).optional()
457
533
  }),
458
- import_v42.z.object({
459
- type: import_v42.z.literal("redacted_thinking"),
460
- data: import_v42.z.string()
534
+ z3.object({
535
+ type: z3.literal("redacted_thinking"),
536
+ data: z3.string()
461
537
  }),
462
- import_v42.z.object({
463
- type: import_v42.z.literal("compaction"),
464
- content: import_v42.z.string().nullish()
538
+ z3.object({
539
+ type: z3.literal("compaction"),
540
+ content: z3.string().nullish()
465
541
  }),
466
- import_v42.z.object({
467
- type: import_v42.z.literal("server_tool_use"),
468
- id: import_v42.z.string(),
469
- name: import_v42.z.string(),
470
- input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish(),
471
- caller: import_v42.z.union([
472
- import_v42.z.object({
473
- type: import_v42.z.literal("code_execution_20260120"),
474
- tool_id: import_v42.z.string()
542
+ z3.object({
543
+ type: z3.literal("server_tool_use"),
544
+ id: z3.string(),
545
+ name: z3.string(),
546
+ input: z3.record(z3.string(), z3.unknown()).nullish(),
547
+ caller: z3.union([
548
+ z3.object({
549
+ type: z3.literal("code_execution_20260120"),
550
+ tool_id: z3.string()
475
551
  }),
476
- import_v42.z.object({
477
- type: import_v42.z.literal("direct")
552
+ z3.object({
553
+ type: z3.literal("direct")
478
554
  })
479
555
  ]).optional()
480
556
  }),
481
- import_v42.z.object({
482
- type: import_v42.z.literal("mcp_tool_use"),
483
- id: import_v42.z.string(),
484
- name: import_v42.z.string(),
485
- input: import_v42.z.unknown(),
486
- server_name: import_v42.z.string()
557
+ z3.object({
558
+ type: z3.literal("mcp_tool_use"),
559
+ id: z3.string(),
560
+ name: z3.string(),
561
+ input: z3.unknown(),
562
+ server_name: z3.string()
487
563
  }),
488
- import_v42.z.object({
489
- type: import_v42.z.literal("mcp_tool_result"),
490
- tool_use_id: import_v42.z.string(),
491
- is_error: import_v42.z.boolean(),
492
- content: import_v42.z.array(
493
- import_v42.z.union([
494
- import_v42.z.string(),
495
- import_v42.z.object({ type: import_v42.z.literal("text"), text: import_v42.z.string() })
564
+ z3.object({
565
+ type: z3.literal("mcp_tool_result"),
566
+ tool_use_id: z3.string(),
567
+ is_error: z3.boolean(),
568
+ content: z3.array(
569
+ z3.union([
570
+ z3.string(),
571
+ z3.object({ type: z3.literal("text"), text: z3.string() })
496
572
  ])
497
573
  )
498
574
  }),
499
- import_v42.z.object({
500
- type: import_v42.z.literal("web_fetch_tool_result"),
501
- tool_use_id: import_v42.z.string(),
502
- content: import_v42.z.union([
503
- import_v42.z.object({
504
- type: import_v42.z.literal("web_fetch_result"),
505
- url: import_v42.z.string(),
506
- retrieved_at: import_v42.z.string(),
507
- content: import_v42.z.object({
508
- type: import_v42.z.literal("document"),
509
- title: import_v42.z.string().nullable(),
510
- citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
511
- source: import_v42.z.union([
512
- import_v42.z.object({
513
- type: import_v42.z.literal("base64"),
514
- media_type: import_v42.z.literal("application/pdf"),
515
- data: import_v42.z.string()
575
+ z3.object({
576
+ type: z3.literal("web_fetch_tool_result"),
577
+ tool_use_id: z3.string(),
578
+ content: z3.union([
579
+ z3.object({
580
+ type: z3.literal("web_fetch_result"),
581
+ url: z3.string(),
582
+ retrieved_at: z3.string(),
583
+ content: z3.object({
584
+ type: z3.literal("document"),
585
+ title: z3.string().nullable(),
586
+ citations: z3.object({ enabled: z3.boolean() }).optional(),
587
+ source: z3.union([
588
+ z3.object({
589
+ type: z3.literal("base64"),
590
+ media_type: z3.literal("application/pdf"),
591
+ data: z3.string()
516
592
  }),
517
- import_v42.z.object({
518
- type: import_v42.z.literal("text"),
519
- media_type: import_v42.z.literal("text/plain"),
520
- data: import_v42.z.string()
593
+ z3.object({
594
+ type: z3.literal("text"),
595
+ media_type: z3.literal("text/plain"),
596
+ data: z3.string()
521
597
  })
522
598
  ])
523
599
  })
524
600
  }),
525
- import_v42.z.object({
526
- type: import_v42.z.literal("web_fetch_tool_result_error"),
527
- error_code: import_v42.z.string()
601
+ z3.object({
602
+ type: z3.literal("web_fetch_tool_result_error"),
603
+ error_code: z3.string()
528
604
  })
529
605
  ])
530
606
  }),
531
- import_v42.z.object({
532
- type: import_v42.z.literal("web_search_tool_result"),
533
- tool_use_id: import_v42.z.string(),
534
- content: import_v42.z.union([
535
- import_v42.z.array(
536
- import_v42.z.object({
537
- type: import_v42.z.literal("web_search_result"),
538
- url: import_v42.z.string(),
539
- title: import_v42.z.string(),
540
- encrypted_content: import_v42.z.string(),
541
- page_age: import_v42.z.string().nullish()
607
+ z3.object({
608
+ type: z3.literal("web_search_tool_result"),
609
+ tool_use_id: z3.string(),
610
+ content: z3.union([
611
+ z3.array(
612
+ z3.object({
613
+ type: z3.literal("web_search_result"),
614
+ url: z3.string(),
615
+ title: z3.string(),
616
+ encrypted_content: z3.string(),
617
+ page_age: z3.string().nullish()
542
618
  })
543
619
  ),
544
- import_v42.z.object({
545
- type: import_v42.z.literal("web_search_tool_result_error"),
546
- error_code: import_v42.z.string()
620
+ z3.object({
621
+ type: z3.literal("web_search_tool_result_error"),
622
+ error_code: z3.string()
547
623
  })
548
624
  ])
549
625
  }),
550
626
  // code execution results for code_execution_20250522 tool:
551
- import_v42.z.object({
552
- type: import_v42.z.literal("code_execution_tool_result"),
553
- tool_use_id: import_v42.z.string(),
554
- content: import_v42.z.union([
555
- import_v42.z.object({
556
- type: import_v42.z.literal("code_execution_result"),
557
- stdout: import_v42.z.string(),
558
- stderr: import_v42.z.string(),
559
- return_code: import_v42.z.number(),
560
- content: import_v42.z.array(
561
- import_v42.z.object({
562
- type: import_v42.z.literal("code_execution_output"),
563
- file_id: import_v42.z.string()
627
+ z3.object({
628
+ type: z3.literal("code_execution_tool_result"),
629
+ tool_use_id: z3.string(),
630
+ content: z3.union([
631
+ z3.object({
632
+ type: z3.literal("code_execution_result"),
633
+ stdout: z3.string(),
634
+ stderr: z3.string(),
635
+ return_code: z3.number(),
636
+ content: z3.array(
637
+ z3.object({
638
+ type: z3.literal("code_execution_output"),
639
+ file_id: z3.string()
564
640
  })
565
641
  ).optional().default([])
566
642
  }),
567
- import_v42.z.object({
568
- type: import_v42.z.literal("encrypted_code_execution_result"),
569
- encrypted_stdout: import_v42.z.string(),
570
- stderr: import_v42.z.string(),
571
- return_code: import_v42.z.number(),
572
- content: import_v42.z.array(
573
- import_v42.z.object({
574
- type: import_v42.z.literal("code_execution_output"),
575
- file_id: import_v42.z.string()
643
+ z3.object({
644
+ type: z3.literal("encrypted_code_execution_result"),
645
+ encrypted_stdout: z3.string(),
646
+ stderr: z3.string(),
647
+ return_code: z3.number(),
648
+ content: z3.array(
649
+ z3.object({
650
+ type: z3.literal("code_execution_output"),
651
+ file_id: z3.string()
576
652
  })
577
653
  ).optional().default([])
578
654
  }),
579
- import_v42.z.object({
580
- type: import_v42.z.literal("code_execution_tool_result_error"),
581
- error_code: import_v42.z.string()
655
+ z3.object({
656
+ type: z3.literal("code_execution_tool_result_error"),
657
+ error_code: z3.string()
582
658
  })
583
659
  ])
584
660
  }),
585
661
  // bash code execution results for code_execution_20250825 tool:
586
- import_v42.z.object({
587
- type: import_v42.z.literal("bash_code_execution_tool_result"),
588
- tool_use_id: import_v42.z.string(),
589
- content: import_v42.z.discriminatedUnion("type", [
590
- import_v42.z.object({
591
- type: import_v42.z.literal("bash_code_execution_result"),
592
- content: import_v42.z.array(
593
- import_v42.z.object({
594
- type: import_v42.z.literal("bash_code_execution_output"),
595
- file_id: import_v42.z.string()
662
+ z3.object({
663
+ type: z3.literal("bash_code_execution_tool_result"),
664
+ tool_use_id: z3.string(),
665
+ content: z3.discriminatedUnion("type", [
666
+ z3.object({
667
+ type: z3.literal("bash_code_execution_result"),
668
+ content: z3.array(
669
+ z3.object({
670
+ type: z3.literal("bash_code_execution_output"),
671
+ file_id: z3.string()
596
672
  })
597
673
  ),
598
- stdout: import_v42.z.string(),
599
- stderr: import_v42.z.string(),
600
- return_code: import_v42.z.number()
674
+ stdout: z3.string(),
675
+ stderr: z3.string(),
676
+ return_code: z3.number()
601
677
  }),
602
- import_v42.z.object({
603
- type: import_v42.z.literal("bash_code_execution_tool_result_error"),
604
- error_code: import_v42.z.string()
678
+ z3.object({
679
+ type: z3.literal("bash_code_execution_tool_result_error"),
680
+ error_code: z3.string()
605
681
  })
606
682
  ])
607
683
  }),
608
684
  // text editor code execution results for code_execution_20250825 tool:
609
- import_v42.z.object({
610
- type: import_v42.z.literal("text_editor_code_execution_tool_result"),
611
- tool_use_id: import_v42.z.string(),
612
- content: import_v42.z.discriminatedUnion("type", [
613
- import_v42.z.object({
614
- type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
615
- error_code: import_v42.z.string()
685
+ z3.object({
686
+ type: z3.literal("text_editor_code_execution_tool_result"),
687
+ tool_use_id: z3.string(),
688
+ content: z3.discriminatedUnion("type", [
689
+ z3.object({
690
+ type: z3.literal("text_editor_code_execution_tool_result_error"),
691
+ error_code: z3.string()
616
692
  }),
617
- import_v42.z.object({
618
- type: import_v42.z.literal("text_editor_code_execution_view_result"),
619
- content: import_v42.z.string(),
620
- file_type: import_v42.z.string(),
621
- num_lines: import_v42.z.number().nullable(),
622
- start_line: import_v42.z.number().nullable(),
623
- total_lines: import_v42.z.number().nullable()
693
+ z3.object({
694
+ type: z3.literal("text_editor_code_execution_view_result"),
695
+ content: z3.string(),
696
+ file_type: z3.string(),
697
+ num_lines: z3.number().nullable(),
698
+ start_line: z3.number().nullable(),
699
+ total_lines: z3.number().nullable()
624
700
  }),
625
- import_v42.z.object({
626
- type: import_v42.z.literal("text_editor_code_execution_create_result"),
627
- is_file_update: import_v42.z.boolean()
701
+ z3.object({
702
+ type: z3.literal("text_editor_code_execution_create_result"),
703
+ is_file_update: z3.boolean()
628
704
  }),
629
- import_v42.z.object({
630
- type: import_v42.z.literal(
705
+ z3.object({
706
+ type: z3.literal(
631
707
  "text_editor_code_execution_str_replace_result"
632
708
  ),
633
- lines: import_v42.z.array(import_v42.z.string()).nullable(),
634
- new_lines: import_v42.z.number().nullable(),
635
- new_start: import_v42.z.number().nullable(),
636
- old_lines: import_v42.z.number().nullable(),
637
- old_start: import_v42.z.number().nullable()
709
+ lines: z3.array(z3.string()).nullable(),
710
+ new_lines: z3.number().nullable(),
711
+ new_start: z3.number().nullable(),
712
+ old_lines: z3.number().nullable(),
713
+ old_start: z3.number().nullable()
638
714
  })
639
715
  ])
640
716
  }),
641
717
  // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
642
- import_v42.z.object({
643
- type: import_v42.z.literal("tool_search_tool_result"),
644
- tool_use_id: import_v42.z.string(),
645
- content: import_v42.z.union([
646
- import_v42.z.object({
647
- type: import_v42.z.literal("tool_search_tool_search_result"),
648
- tool_references: import_v42.z.array(
649
- import_v42.z.object({
650
- type: import_v42.z.literal("tool_reference"),
651
- tool_name: import_v42.z.string()
718
+ z3.object({
719
+ type: z3.literal("tool_search_tool_result"),
720
+ tool_use_id: z3.string(),
721
+ content: z3.union([
722
+ z3.object({
723
+ type: z3.literal("tool_search_tool_search_result"),
724
+ tool_references: z3.array(
725
+ z3.object({
726
+ type: z3.literal("tool_reference"),
727
+ tool_name: z3.string()
652
728
  })
653
729
  )
654
730
  }),
655
- import_v42.z.object({
656
- type: import_v42.z.literal("tool_search_tool_result_error"),
657
- error_code: import_v42.z.string()
731
+ z3.object({
732
+ type: z3.literal("tool_search_tool_result_error"),
733
+ error_code: z3.string()
658
734
  })
659
735
  ])
660
736
  })
661
737
  ])
662
738
  }),
663
- import_v42.z.object({
664
- type: import_v42.z.literal("content_block_delta"),
665
- index: import_v42.z.number(),
666
- delta: import_v42.z.discriminatedUnion("type", [
667
- import_v42.z.object({
668
- type: import_v42.z.literal("input_json_delta"),
669
- partial_json: import_v42.z.string()
739
+ z3.object({
740
+ type: z3.literal("content_block_delta"),
741
+ index: z3.number(),
742
+ delta: z3.discriminatedUnion("type", [
743
+ z3.object({
744
+ type: z3.literal("input_json_delta"),
745
+ partial_json: z3.string()
670
746
  }),
671
- import_v42.z.object({
672
- type: import_v42.z.literal("text_delta"),
673
- text: import_v42.z.string()
747
+ z3.object({
748
+ type: z3.literal("text_delta"),
749
+ text: z3.string()
674
750
  }),
675
- import_v42.z.object({
676
- type: import_v42.z.literal("thinking_delta"),
677
- thinking: import_v42.z.string()
751
+ z3.object({
752
+ type: z3.literal("thinking_delta"),
753
+ thinking: z3.string()
678
754
  }),
679
- import_v42.z.object({
680
- type: import_v42.z.literal("signature_delta"),
681
- signature: import_v42.z.string()
755
+ z3.object({
756
+ type: z3.literal("signature_delta"),
757
+ signature: z3.string()
682
758
  }),
683
- import_v42.z.object({
684
- type: import_v42.z.literal("compaction_delta"),
685
- content: import_v42.z.string().nullish()
759
+ z3.object({
760
+ type: z3.literal("compaction_delta"),
761
+ content: z3.string().nullish()
686
762
  }),
687
- import_v42.z.object({
688
- type: import_v42.z.literal("citations_delta"),
689
- citation: import_v42.z.discriminatedUnion("type", [
690
- import_v42.z.object({
691
- type: import_v42.z.literal("web_search_result_location"),
692
- cited_text: import_v42.z.string(),
693
- url: import_v42.z.string(),
694
- title: import_v42.z.string(),
695
- encrypted_index: import_v42.z.string()
763
+ z3.object({
764
+ type: z3.literal("citations_delta"),
765
+ citation: z3.discriminatedUnion("type", [
766
+ z3.object({
767
+ type: z3.literal("web_search_result_location"),
768
+ cited_text: z3.string(),
769
+ url: z3.string(),
770
+ title: z3.string(),
771
+ encrypted_index: z3.string()
696
772
  }),
697
- import_v42.z.object({
698
- type: import_v42.z.literal("page_location"),
699
- cited_text: import_v42.z.string(),
700
- document_index: import_v42.z.number(),
701
- document_title: import_v42.z.string().nullable(),
702
- start_page_number: import_v42.z.number(),
703
- end_page_number: import_v42.z.number()
773
+ z3.object({
774
+ type: z3.literal("page_location"),
775
+ cited_text: z3.string(),
776
+ document_index: z3.number(),
777
+ document_title: z3.string().nullable(),
778
+ start_page_number: z3.number(),
779
+ end_page_number: z3.number()
704
780
  }),
705
- import_v42.z.object({
706
- type: import_v42.z.literal("char_location"),
707
- cited_text: import_v42.z.string(),
708
- document_index: import_v42.z.number(),
709
- document_title: import_v42.z.string().nullable(),
710
- start_char_index: import_v42.z.number(),
711
- end_char_index: import_v42.z.number()
781
+ z3.object({
782
+ type: z3.literal("char_location"),
783
+ cited_text: z3.string(),
784
+ document_index: z3.number(),
785
+ document_title: z3.string().nullable(),
786
+ start_char_index: z3.number(),
787
+ end_char_index: z3.number()
712
788
  })
713
789
  ])
714
790
  })
715
791
  ])
716
792
  }),
717
- import_v42.z.object({
718
- type: import_v42.z.literal("content_block_stop"),
719
- index: import_v42.z.number()
793
+ z3.object({
794
+ type: z3.literal("content_block_stop"),
795
+ index: z3.number()
720
796
  }),
721
- import_v42.z.object({
722
- type: import_v42.z.literal("error"),
723
- error: import_v42.z.object({
724
- type: import_v42.z.string(),
725
- message: import_v42.z.string()
797
+ z3.object({
798
+ type: z3.literal("error"),
799
+ error: z3.object({
800
+ type: z3.string(),
801
+ message: z3.string()
726
802
  })
727
803
  }),
728
- import_v42.z.object({
729
- type: import_v42.z.literal("message_delta"),
730
- delta: import_v42.z.object({
731
- stop_reason: import_v42.z.string().nullish(),
732
- stop_sequence: import_v42.z.string().nullish(),
733
- container: import_v42.z.object({
734
- expires_at: import_v42.z.string(),
735
- id: import_v42.z.string(),
736
- skills: import_v42.z.array(
737
- import_v42.z.object({
738
- type: import_v42.z.union([
739
- import_v42.z.literal("anthropic"),
740
- import_v42.z.literal("custom")
804
+ z3.object({
805
+ type: z3.literal("message_delta"),
806
+ delta: z3.object({
807
+ stop_reason: z3.string().nullish(),
808
+ stop_sequence: z3.string().nullish(),
809
+ container: z3.object({
810
+ expires_at: z3.string(),
811
+ id: z3.string(),
812
+ skills: z3.array(
813
+ z3.object({
814
+ type: z3.union([
815
+ z3.literal("anthropic"),
816
+ z3.literal("custom")
741
817
  ]),
742
- skill_id: import_v42.z.string(),
743
- version: import_v42.z.string()
818
+ skill_id: z3.string(),
819
+ version: z3.string()
744
820
  })
745
821
  ).nullish()
746
822
  }).nullish()
747
823
  }),
748
- usage: import_v42.z.looseObject({
749
- input_tokens: import_v42.z.number().nullish(),
750
- output_tokens: import_v42.z.number(),
751
- cache_creation_input_tokens: import_v42.z.number().nullish(),
752
- cache_read_input_tokens: import_v42.z.number().nullish(),
753
- iterations: import_v42.z.array(
754
- import_v42.z.object({
755
- type: import_v42.z.union([import_v42.z.literal("compaction"), import_v42.z.literal("message")]),
756
- input_tokens: import_v42.z.number(),
757
- output_tokens: import_v42.z.number()
824
+ usage: z3.looseObject({
825
+ input_tokens: z3.number().nullish(),
826
+ output_tokens: z3.number(),
827
+ cache_creation_input_tokens: z3.number().nullish(),
828
+ cache_read_input_tokens: z3.number().nullish(),
829
+ iterations: z3.array(
830
+ z3.object({
831
+ type: z3.union([z3.literal("compaction"), z3.literal("message")]),
832
+ input_tokens: z3.number(),
833
+ output_tokens: z3.number()
758
834
  })
759
835
  ).nullish()
760
836
  }),
761
- context_management: import_v42.z.object({
762
- applied_edits: import_v42.z.array(
763
- import_v42.z.union([
764
- import_v42.z.object({
765
- type: import_v42.z.literal("clear_tool_uses_20250919"),
766
- cleared_tool_uses: import_v42.z.number(),
767
- cleared_input_tokens: import_v42.z.number()
837
+ context_management: z3.object({
838
+ applied_edits: z3.array(
839
+ z3.union([
840
+ z3.object({
841
+ type: z3.literal("clear_tool_uses_20250919"),
842
+ cleared_tool_uses: z3.number(),
843
+ cleared_input_tokens: z3.number()
768
844
  }),
769
- import_v42.z.object({
770
- type: import_v42.z.literal("clear_thinking_20251015"),
771
- cleared_thinking_turns: import_v42.z.number(),
772
- cleared_input_tokens: import_v42.z.number()
845
+ z3.object({
846
+ type: z3.literal("clear_thinking_20251015"),
847
+ cleared_thinking_turns: z3.number(),
848
+ cleared_input_tokens: z3.number()
773
849
  }),
774
- import_v42.z.object({
775
- type: import_v42.z.literal("compact_20260112")
850
+ z3.object({
851
+ type: z3.literal("compact_20260112")
776
852
  })
777
853
  ])
778
854
  )
779
855
  }).nullish()
780
856
  }),
781
- import_v42.z.object({
782
- type: import_v42.z.literal("message_stop")
857
+ z3.object({
858
+ type: z3.literal("message_stop")
783
859
  }),
784
- import_v42.z.object({
785
- type: import_v42.z.literal("ping")
860
+ z3.object({
861
+ type: z3.literal("ping")
786
862
  })
787
863
  ])
788
864
  )
789
865
  );
790
- var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
791
- () => (0, import_provider_utils2.zodSchema)(
792
- import_v42.z.object({
793
- signature: import_v42.z.string().optional(),
794
- redactedData: import_v42.z.string().optional()
866
+ var anthropicReasoningMetadataSchema = lazySchema3(
867
+ () => zodSchema3(
868
+ z3.object({
869
+ signature: z3.string().optional(),
870
+ redactedData: z3.string().optional()
795
871
  })
796
872
  )
797
873
  );
798
874
 
799
- // src/anthropic-messages-options.ts
800
- var import_v43 = require("zod/v4");
801
- var anthropicFilePartProviderOptions = import_v43.z.object({
875
+ // src/anthropic-options.ts
876
+ import { z as z4 } from "zod/v4";
877
+ var anthropicFilePartProviderOptions = z4.object({
802
878
  /**
803
879
  * Citation configuration for this document.
804
880
  * When enabled, this document will generate citations in the response.
805
881
  */
806
- citations: import_v43.z.object({
882
+ citations: z4.object({
807
883
  /**
808
884
  * Enable citations for this document
809
885
  */
810
- enabled: import_v43.z.boolean()
886
+ enabled: z4.boolean()
811
887
  }).optional(),
812
888
  /**
813
889
  * Custom title for the document.
814
890
  * If not provided, the filename will be used.
815
891
  */
816
- title: import_v43.z.string().optional(),
892
+ title: z4.string().optional(),
817
893
  /**
818
894
  * Context about the document that will be passed to the model
819
895
  * but not used towards cited content.
820
896
  * Useful for storing document metadata as text or stringified JSON.
821
897
  */
822
- context: import_v43.z.string().optional()
898
+ context: z4.string().optional()
823
899
  });
824
- var anthropicLanguageModelOptions = import_v43.z.object({
900
+ var anthropicLanguageModelOptions = z4.object({
825
901
  /**
826
902
  * Whether to send reasoning to the model.
827
903
  *
828
904
  * This allows you to deactivate reasoning inputs for models that do not support them.
829
905
  */
830
- sendReasoning: import_v43.z.boolean().optional(),
906
+ sendReasoning: z4.boolean().optional(),
831
907
  /**
832
908
  * Determines how structured outputs are generated.
833
909
  *
@@ -835,52 +911,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
835
911
  * - `jsonTool`: Use a special 'json' tool to specify the structured output format.
836
912
  * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
837
913
  */
838
- structuredOutputMode: import_v43.z.enum(["outputFormat", "jsonTool", "auto"]).optional(),
914
+ structuredOutputMode: z4.enum(["outputFormat", "jsonTool", "auto"]).optional(),
839
915
  /**
840
916
  * Configuration for enabling Claude's extended thinking.
841
917
  *
842
918
  * When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
843
919
  * Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
844
920
  */
845
- thinking: import_v43.z.discriminatedUnion("type", [
846
- import_v43.z.object({
921
+ thinking: z4.discriminatedUnion("type", [
922
+ z4.object({
847
923
  /** for Sonnet 4.6, Opus 4.6, and newer models */
848
- type: import_v43.z.literal("adaptive")
924
+ type: z4.literal("adaptive"),
925
+ /**
926
+ * Controls whether thinking content is included in the response.
927
+ * - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
928
+ * - `"summarized"`: Thinking content is returned. Required to see reasoning output.
929
+ */
930
+ display: z4.enum(["omitted", "summarized"]).optional()
849
931
  }),
850
- import_v43.z.object({
932
+ z4.object({
851
933
  /** for models before Opus 4.6, except Sonnet 4.6 still supports it */
852
- type: import_v43.z.literal("enabled"),
853
- budgetTokens: import_v43.z.number().optional()
934
+ type: z4.literal("enabled"),
935
+ budgetTokens: z4.number().optional()
854
936
  }),
855
- import_v43.z.object({
856
- type: import_v43.z.literal("disabled")
937
+ z4.object({
938
+ type: z4.literal("disabled")
857
939
  })
858
940
  ]).optional(),
859
941
  /**
860
942
  * Whether to disable parallel function calling during tool use. Default is false.
861
943
  * When set to true, Claude will use at most one tool per response.
862
944
  */
863
- disableParallelToolUse: import_v43.z.boolean().optional(),
945
+ disableParallelToolUse: z4.boolean().optional(),
864
946
  /**
865
947
  * Cache control settings for this message.
866
948
  * See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
867
949
  */
868
- cacheControl: import_v43.z.object({
869
- type: import_v43.z.literal("ephemeral"),
870
- ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
950
+ cacheControl: z4.object({
951
+ type: z4.literal("ephemeral"),
952
+ ttl: z4.union([z4.literal("5m"), z4.literal("1h")]).optional()
953
+ }).optional(),
954
+ /**
955
+ * Metadata to include with the request.
956
+ *
957
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
958
+ */
959
+ metadata: z4.object({
960
+ /**
961
+ * An external identifier for the user associated with the request.
962
+ *
963
+ * Should be a UUID, hash value, or other opaque identifier.
964
+ * Must not contain PII (name, email, phone number, etc.).
965
+ */
966
+ userId: z4.string().optional()
871
967
  }).optional(),
872
968
  /**
873
969
  * MCP servers to be utilized in this request.
874
970
  */
875
- mcpServers: import_v43.z.array(
876
- import_v43.z.object({
877
- type: import_v43.z.literal("url"),
878
- name: import_v43.z.string(),
879
- url: import_v43.z.string(),
880
- authorizationToken: import_v43.z.string().nullish(),
881
- toolConfiguration: import_v43.z.object({
882
- enabled: import_v43.z.boolean().nullish(),
883
- allowedTools: import_v43.z.array(import_v43.z.string()).nullish()
971
+ mcpServers: z4.array(
972
+ z4.object({
973
+ type: z4.literal("url"),
974
+ name: z4.string(),
975
+ url: z4.string(),
976
+ authorizationToken: z4.string().nullish(),
977
+ toolConfiguration: z4.object({
978
+ enabled: z4.boolean().nullish(),
979
+ allowedTools: z4.array(z4.string()).nullish()
884
980
  }).nullish()
885
981
  })
886
982
  ).optional(),
@@ -889,83 +985,112 @@ var anthropicLanguageModelOptions = import_v43.z.object({
889
985
  * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
890
986
  * Requires code execution tool to be enabled.
891
987
  */
892
- container: import_v43.z.object({
893
- id: import_v43.z.string().optional(),
894
- skills: import_v43.z.array(
895
- import_v43.z.object({
896
- type: import_v43.z.union([import_v43.z.literal("anthropic"), import_v43.z.literal("custom")]),
897
- skillId: import_v43.z.string(),
898
- version: import_v43.z.string().optional()
899
- })
988
+ container: z4.object({
989
+ id: z4.string().optional(),
990
+ skills: z4.array(
991
+ z4.discriminatedUnion("type", [
992
+ z4.object({
993
+ type: z4.literal("anthropic"),
994
+ skillId: z4.string(),
995
+ version: z4.string().optional()
996
+ }),
997
+ z4.object({
998
+ type: z4.literal("custom"),
999
+ providerReference: z4.record(z4.string(), z4.string()),
1000
+ version: z4.string().optional()
1001
+ })
1002
+ ])
900
1003
  ).optional()
901
1004
  }).optional(),
902
1005
  /**
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.
1006
+ * Whether to enable fine-grained (eager) streaming of tool call inputs
1007
+ * and structured outputs for every function tool in the request. When
1008
+ * true (the default), each function tool receives a default of
1009
+ * `eager_input_streaming: true` unless it explicitly sets
1010
+ * `providerOptions.anthropic.eagerInputStreaming`.
907
1011
  *
908
1012
  * @default true
909
1013
  */
910
- toolStreaming: import_v43.z.boolean().optional(),
1014
+ toolStreaming: z4.boolean().optional(),
911
1015
  /**
912
1016
  * @default 'high'
913
1017
  */
914
- effort: import_v43.z.enum(["low", "medium", "high", "max"]).optional(),
1018
+ effort: z4.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
1019
+ /**
1020
+ * Task budget for agentic turns. Informs the model of the total token budget
1021
+ * available for the current task, allowing it to prioritize work and wind down
1022
+ * gracefully as the budget is consumed.
1023
+ *
1024
+ * Advisory only — does not enforce a hard token limit.
1025
+ */
1026
+ taskBudget: z4.object({
1027
+ type: z4.literal("tokens"),
1028
+ total: z4.number().int().min(2e4),
1029
+ remaining: z4.number().int().min(0).optional()
1030
+ }).optional(),
915
1031
  /**
916
1032
  * Enable fast mode for faster inference (2.5x faster output token speeds).
917
1033
  * Only supported with claude-opus-4-6.
918
1034
  */
919
- speed: import_v43.z.enum(["fast", "standard"]).optional(),
1035
+ speed: z4.enum(["fast", "standard"]).optional(),
1036
+ /**
1037
+ * Controls where model inference runs for this request.
1038
+ *
1039
+ * - `"global"`: Inference may run in any available geography (default).
1040
+ * - `"us"`: Inference runs only in US-based infrastructure.
1041
+ *
1042
+ * See https://platform.claude.com/docs/en/build-with-claude/data-residency
1043
+ */
1044
+ inferenceGeo: z4.enum(["us", "global"]).optional(),
920
1045
  /**
921
1046
  * A set of beta features to enable.
922
1047
  * Allow a provider to receive the full `betas` set if it needs it.
923
1048
  */
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()
1049
+ anthropicBeta: z4.array(z4.string()).optional(),
1050
+ contextManagement: z4.object({
1051
+ edits: z4.array(
1052
+ z4.discriminatedUnion("type", [
1053
+ z4.object({
1054
+ type: z4.literal("clear_tool_uses_20250919"),
1055
+ trigger: z4.discriminatedUnion("type", [
1056
+ z4.object({
1057
+ type: z4.literal("input_tokens"),
1058
+ value: z4.number()
934
1059
  }),
935
- import_v43.z.object({
936
- type: import_v43.z.literal("tool_uses"),
937
- value: import_v43.z.number()
1060
+ z4.object({
1061
+ type: z4.literal("tool_uses"),
1062
+ value: z4.number()
938
1063
  })
939
1064
  ]).optional(),
940
- keep: import_v43.z.object({
941
- type: import_v43.z.literal("tool_uses"),
942
- value: import_v43.z.number()
1065
+ keep: z4.object({
1066
+ type: z4.literal("tool_uses"),
1067
+ value: z4.number()
943
1068
  }).optional(),
944
- clearAtLeast: import_v43.z.object({
945
- type: import_v43.z.literal("input_tokens"),
946
- value: import_v43.z.number()
1069
+ clearAtLeast: z4.object({
1070
+ type: z4.literal("input_tokens"),
1071
+ value: z4.number()
947
1072
  }).optional(),
948
- clearToolInputs: import_v43.z.boolean().optional(),
949
- excludeTools: import_v43.z.array(import_v43.z.string()).optional()
1073
+ clearToolInputs: z4.boolean().optional(),
1074
+ excludeTools: z4.array(z4.string()).optional()
950
1075
  }),
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()
1076
+ z4.object({
1077
+ type: z4.literal("clear_thinking_20251015"),
1078
+ keep: z4.union([
1079
+ z4.literal("all"),
1080
+ z4.object({
1081
+ type: z4.literal("thinking_turns"),
1082
+ value: z4.number()
958
1083
  })
959
1084
  ]).optional()
960
1085
  }),
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()
1086
+ z4.object({
1087
+ type: z4.literal("compact_20260112"),
1088
+ trigger: z4.object({
1089
+ type: z4.literal("input_tokens"),
1090
+ value: z4.number()
966
1091
  }).optional(),
967
- pauseAfterCompaction: import_v43.z.boolean().optional(),
968
- instructions: import_v43.z.string().optional()
1092
+ pauseAfterCompaction: z4.boolean().optional(),
1093
+ instructions: z4.string().optional()
969
1094
  })
970
1095
  ])
971
1096
  )
@@ -973,7 +1098,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
973
1098
  });
974
1099
 
975
1100
  // src/anthropic-prepare-tools.ts
976
- var import_provider = require("@ai-sdk/provider");
1101
+ import {
1102
+ UnsupportedFunctionalityError
1103
+ } from "@ai-sdk/provider";
977
1104
 
978
1105
  // src/get-cache-control.ts
979
1106
  var MAX_CACHE_BREAKPOINTS = 4;
@@ -1018,31 +1145,31 @@ var CacheControlValidator = class {
1018
1145
  };
1019
1146
 
1020
1147
  // 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()
1148
+ import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
1149
+ import { z as z5 } from "zod/v4";
1150
+ import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
1151
+ var textEditor_20250728ArgsSchema = lazySchema4(
1152
+ () => zodSchema4(
1153
+ z5.object({
1154
+ maxCharacters: z5.number().optional()
1028
1155
  })
1029
1156
  )
1030
1157
  );
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()
1158
+ var textEditor_20250728InputSchema = lazySchema4(
1159
+ () => zodSchema4(
1160
+ z5.object({
1161
+ command: z5.enum(["view", "create", "str_replace", "insert"]),
1162
+ path: z5.string(),
1163
+ file_text: z5.string().optional(),
1164
+ insert_line: z5.number().int().optional(),
1165
+ new_str: z5.string().optional(),
1166
+ insert_text: z5.string().optional(),
1167
+ old_str: z5.string().optional(),
1168
+ view_range: z5.array(z5.number().int()).optional()
1042
1169
  })
1043
1170
  )
1044
1171
  );
1045
- var factory = (0, import_provider_utils3.createProviderToolFactory)({
1172
+ var factory = createProviderDefinedToolFactory({
1046
1173
  id: "anthropic.text_editor_20250728",
1047
1174
  inputSchema: textEditor_20250728InputSchema
1048
1175
  });
@@ -1051,45 +1178,49 @@ var textEditor_20250728 = (args = {}) => {
1051
1178
  };
1052
1179
 
1053
1180
  // 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()
1181
+ import {
1182
+ createProviderExecutedToolFactory,
1183
+ lazySchema as lazySchema5,
1184
+ zodSchema as zodSchema5
1185
+ } from "@ai-sdk/provider-utils";
1186
+ import { z as z6 } from "zod/v4";
1187
+ var webSearch_20260209ArgsSchema = lazySchema5(
1188
+ () => zodSchema5(
1189
+ z6.object({
1190
+ maxUses: z6.number().optional(),
1191
+ allowedDomains: z6.array(z6.string()).optional(),
1192
+ blockedDomains: z6.array(z6.string()).optional(),
1193
+ userLocation: z6.object({
1194
+ type: z6.literal("approximate"),
1195
+ city: z6.string().optional(),
1196
+ region: z6.string().optional(),
1197
+ country: z6.string().optional(),
1198
+ timezone: z6.string().optional()
1068
1199
  }).optional()
1069
1200
  })
1070
1201
  )
1071
1202
  );
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")
1203
+ var webSearch_20260209OutputSchema = lazySchema5(
1204
+ () => zodSchema5(
1205
+ z6.array(
1206
+ z6.object({
1207
+ url: z6.string(),
1208
+ title: z6.string().nullable(),
1209
+ pageAge: z6.string().nullable(),
1210
+ encryptedContent: z6.string(),
1211
+ type: z6.literal("web_search_result")
1081
1212
  })
1082
1213
  )
1083
1214
  )
1084
1215
  );
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()
1216
+ var webSearch_20260209InputSchema = lazySchema5(
1217
+ () => zodSchema5(
1218
+ z6.object({
1219
+ query: z6.string()
1089
1220
  })
1090
1221
  )
1091
1222
  );
1092
- var factory2 = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
1223
+ var factory2 = createProviderExecutedToolFactory({
1093
1224
  id: "anthropic.web_search_20260209",
1094
1225
  inputSchema: webSearch_20260209InputSchema,
1095
1226
  outputSchema: webSearch_20260209OutputSchema,
@@ -1100,45 +1231,49 @@ var webSearch_20260209 = (args = {}) => {
1100
1231
  };
1101
1232
 
1102
1233
  // 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()
1234
+ import {
1235
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
1236
+ lazySchema as lazySchema6,
1237
+ zodSchema as zodSchema6
1238
+ } from "@ai-sdk/provider-utils";
1239
+ import { z as z7 } from "zod/v4";
1240
+ var webSearch_20250305ArgsSchema = lazySchema6(
1241
+ () => zodSchema6(
1242
+ z7.object({
1243
+ maxUses: z7.number().optional(),
1244
+ allowedDomains: z7.array(z7.string()).optional(),
1245
+ blockedDomains: z7.array(z7.string()).optional(),
1246
+ userLocation: z7.object({
1247
+ type: z7.literal("approximate"),
1248
+ city: z7.string().optional(),
1249
+ region: z7.string().optional(),
1250
+ country: z7.string().optional(),
1251
+ timezone: z7.string().optional()
1117
1252
  }).optional()
1118
1253
  })
1119
1254
  )
1120
1255
  );
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")
1256
+ var webSearch_20250305OutputSchema = lazySchema6(
1257
+ () => zodSchema6(
1258
+ z7.array(
1259
+ z7.object({
1260
+ url: z7.string(),
1261
+ title: z7.string().nullable(),
1262
+ pageAge: z7.string().nullable(),
1263
+ encryptedContent: z7.string(),
1264
+ type: z7.literal("web_search_result")
1130
1265
  })
1131
1266
  )
1132
1267
  )
1133
1268
  );
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()
1269
+ var webSearch_20250305InputSchema = lazySchema6(
1270
+ () => zodSchema6(
1271
+ z7.object({
1272
+ query: z7.string()
1138
1273
  })
1139
1274
  )
1140
1275
  );
1141
- var factory3 = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
1276
+ var factory3 = createProviderExecutedToolFactory2({
1142
1277
  id: "anthropic.web_search_20250305",
1143
1278
  inputSchema: webSearch_20250305InputSchema,
1144
1279
  outputSchema: webSearch_20250305OutputSchema,
@@ -1149,53 +1284,57 @@ var webSearch_20250305 = (args = {}) => {
1149
1284
  };
1150
1285
 
1151
1286
  // 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()
1287
+ import {
1288
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
1289
+ lazySchema as lazySchema7,
1290
+ zodSchema as zodSchema7
1291
+ } from "@ai-sdk/provider-utils";
1292
+ import { z as z8 } from "zod/v4";
1293
+ var webFetch_20260209ArgsSchema = lazySchema7(
1294
+ () => zodSchema7(
1295
+ z8.object({
1296
+ maxUses: z8.number().optional(),
1297
+ allowedDomains: z8.array(z8.string()).optional(),
1298
+ blockedDomains: z8.array(z8.string()).optional(),
1299
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1300
+ maxContentTokens: z8.number().optional()
1162
1301
  })
1163
1302
  )
1164
1303
  );
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()
1304
+ var webFetch_20260209OutputSchema = lazySchema7(
1305
+ () => zodSchema7(
1306
+ z8.object({
1307
+ type: z8.literal("web_fetch_result"),
1308
+ url: z8.string(),
1309
+ content: z8.object({
1310
+ type: z8.literal("document"),
1311
+ title: z8.string().nullable(),
1312
+ citations: z8.object({ enabled: z8.boolean() }).optional(),
1313
+ source: z8.union([
1314
+ z8.object({
1315
+ type: z8.literal("base64"),
1316
+ mediaType: z8.literal("application/pdf"),
1317
+ data: z8.string()
1179
1318
  }),
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()
1319
+ z8.object({
1320
+ type: z8.literal("text"),
1321
+ mediaType: z8.literal("text/plain"),
1322
+ data: z8.string()
1184
1323
  })
1185
1324
  ])
1186
1325
  }),
1187
- retrievedAt: import_v47.z.string().nullable()
1326
+ retrievedAt: z8.string().nullable()
1188
1327
  })
1189
1328
  )
1190
1329
  );
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()
1330
+ var webFetch_20260209InputSchema = lazySchema7(
1331
+ () => zodSchema7(
1332
+ z8.object({
1333
+ url: z8.string()
1195
1334
  })
1196
1335
  )
1197
1336
  );
1198
- var factory4 = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
1337
+ var factory4 = createProviderExecutedToolFactory3({
1199
1338
  id: "anthropic.web_fetch_20260209",
1200
1339
  inputSchema: webFetch_20260209InputSchema,
1201
1340
  outputSchema: webFetch_20260209OutputSchema,
@@ -1206,53 +1345,57 @@ var webFetch_20260209 = (args = {}) => {
1206
1345
  };
1207
1346
 
1208
1347
  // 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()
1348
+ import {
1349
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
1350
+ lazySchema as lazySchema8,
1351
+ zodSchema as zodSchema8
1352
+ } from "@ai-sdk/provider-utils";
1353
+ import { z as z9 } from "zod/v4";
1354
+ var webFetch_20250910ArgsSchema = lazySchema8(
1355
+ () => zodSchema8(
1356
+ z9.object({
1357
+ maxUses: z9.number().optional(),
1358
+ allowedDomains: z9.array(z9.string()).optional(),
1359
+ blockedDomains: z9.array(z9.string()).optional(),
1360
+ citations: z9.object({ enabled: z9.boolean() }).optional(),
1361
+ maxContentTokens: z9.number().optional()
1219
1362
  })
1220
1363
  )
1221
1364
  );
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()
1365
+ var webFetch_20250910OutputSchema = lazySchema8(
1366
+ () => zodSchema8(
1367
+ z9.object({
1368
+ type: z9.literal("web_fetch_result"),
1369
+ url: z9.string(),
1370
+ content: z9.object({
1371
+ type: z9.literal("document"),
1372
+ title: z9.string().nullable(),
1373
+ citations: z9.object({ enabled: z9.boolean() }).optional(),
1374
+ source: z9.union([
1375
+ z9.object({
1376
+ type: z9.literal("base64"),
1377
+ mediaType: z9.literal("application/pdf"),
1378
+ data: z9.string()
1236
1379
  }),
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()
1380
+ z9.object({
1381
+ type: z9.literal("text"),
1382
+ mediaType: z9.literal("text/plain"),
1383
+ data: z9.string()
1241
1384
  })
1242
1385
  ])
1243
1386
  }),
1244
- retrievedAt: import_v48.z.string().nullable()
1387
+ retrievedAt: z9.string().nullable()
1245
1388
  })
1246
1389
  )
1247
1390
  );
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()
1391
+ var webFetch_20250910InputSchema = lazySchema8(
1392
+ () => zodSchema8(
1393
+ z9.object({
1394
+ url: z9.string()
1252
1395
  })
1253
1396
  )
1254
1397
  );
1255
- var factory5 = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
1398
+ var factory5 = createProviderExecutedToolFactory4({
1256
1399
  id: "anthropic.web_fetch_20250910",
1257
1400
  inputSchema: webFetch_20250910InputSchema,
1258
1401
  outputSchema: webFetch_20250910OutputSchema,
@@ -1263,16 +1406,17 @@ var webFetch_20250910 = (args = {}) => {
1263
1406
  };
1264
1407
 
1265
1408
  // src/anthropic-prepare-tools.ts
1266
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1409
+ import { validateTypes } from "@ai-sdk/provider-utils";
1267
1410
  async function prepareTools({
1268
1411
  tools,
1269
1412
  toolChoice,
1270
1413
  disableParallelToolUse,
1271
1414
  cacheControlValidator,
1272
1415
  supportsStructuredOutput,
1273
- supportsStrictTools
1416
+ supportsStrictTools,
1417
+ defaultEagerInputStreaming = false
1274
1418
  }) {
1275
- var _a;
1419
+ var _a, _b;
1276
1420
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
1277
1421
  const toolWarnings = [];
1278
1422
  const betas = /* @__PURE__ */ new Set();
@@ -1289,7 +1433,7 @@ async function prepareTools({
1289
1433
  canCache: true
1290
1434
  });
1291
1435
  const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
1292
- const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
1436
+ const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
1293
1437
  const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
1294
1438
  const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
1295
1439
  if (!supportsStrictTools && tool.strict != null) {
@@ -1413,7 +1557,7 @@ async function prepareTools({
1413
1557
  break;
1414
1558
  }
1415
1559
  case "anthropic.text_editor_20250728": {
1416
- const args = await (0, import_provider_utils9.validateTypes)({
1560
+ const args = await validateTypes({
1417
1561
  value: tool.args,
1418
1562
  schema: textEditor_20250728ArgsSchema
1419
1563
  });
@@ -1453,7 +1597,7 @@ async function prepareTools({
1453
1597
  }
1454
1598
  case "anthropic.web_fetch_20250910": {
1455
1599
  betas.add("web-fetch-2025-09-10");
1456
- const args = await (0, import_provider_utils9.validateTypes)({
1600
+ const args = await validateTypes({
1457
1601
  value: tool.args,
1458
1602
  schema: webFetch_20250910ArgsSchema
1459
1603
  });
@@ -1471,7 +1615,7 @@ async function prepareTools({
1471
1615
  }
1472
1616
  case "anthropic.web_fetch_20260209": {
1473
1617
  betas.add("code-execution-web-tools-2026-02-09");
1474
- const args = await (0, import_provider_utils9.validateTypes)({
1618
+ const args = await validateTypes({
1475
1619
  value: tool.args,
1476
1620
  schema: webFetch_20260209ArgsSchema
1477
1621
  });
@@ -1488,7 +1632,7 @@ async function prepareTools({
1488
1632
  break;
1489
1633
  }
1490
1634
  case "anthropic.web_search_20250305": {
1491
- const args = await (0, import_provider_utils9.validateTypes)({
1635
+ const args = await validateTypes({
1492
1636
  value: tool.args,
1493
1637
  schema: webSearch_20250305ArgsSchema
1494
1638
  });
@@ -1505,7 +1649,7 @@ async function prepareTools({
1505
1649
  }
1506
1650
  case "anthropic.web_search_20260209": {
1507
1651
  betas.add("code-execution-web-tools-2026-02-09");
1508
- const args = await (0, import_provider_utils9.validateTypes)({
1652
+ const args = await validateTypes({
1509
1653
  value: tool.args,
1510
1654
  schema: webSearch_20260209ArgsSchema
1511
1655
  });
@@ -1521,7 +1665,6 @@ async function prepareTools({
1521
1665
  break;
1522
1666
  }
1523
1667
  case "anthropic.tool_search_regex_20251119": {
1524
- betas.add("advanced-tool-use-2025-11-20");
1525
1668
  anthropicTools2.push({
1526
1669
  type: "tool_search_tool_regex_20251119",
1527
1670
  name: "tool_search_tool_regex"
@@ -1529,7 +1672,6 @@ async function prepareTools({
1529
1672
  break;
1530
1673
  }
1531
1674
  case "anthropic.tool_search_bm25_20251119": {
1532
- betas.add("advanced-tool-use-2025-11-20");
1533
1675
  anthropicTools2.push({
1534
1676
  type: "tool_search_tool_bm25_20251119",
1535
1677
  name: "tool_search_tool_bm25"
@@ -1600,15 +1742,15 @@ async function prepareTools({
1600
1742
  };
1601
1743
  default: {
1602
1744
  const _exhaustiveCheck = type;
1603
- throw new import_provider.UnsupportedFunctionalityError({
1745
+ throw new UnsupportedFunctionalityError({
1604
1746
  functionality: `tool choice type: ${_exhaustiveCheck}`
1605
1747
  });
1606
1748
  }
1607
1749
  }
1608
1750
  }
1609
1751
 
1610
- // src/convert-anthropic-messages-usage.ts
1611
- function convertAnthropicMessagesUsage({
1752
+ // src/convert-anthropic-usage.ts
1753
+ function convertAnthropicUsage({
1612
1754
  usage,
1613
1755
  rawUsage
1614
1756
  }) {
@@ -1647,37 +1789,51 @@ function convertAnthropicMessagesUsage({
1647
1789
  };
1648
1790
  }
1649
1791
 
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");
1792
+ // src/convert-to-anthropic-prompt.ts
1793
+ import {
1794
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
1795
+ } from "@ai-sdk/provider";
1796
+ import {
1797
+ convertBase64ToUint8Array as convertBase64ToUint8Array2,
1798
+ convertToBase64,
1799
+ isProviderReference,
1800
+ parseProviderOptions,
1801
+ resolveProviderReference,
1802
+ validateTypes as validateTypes2,
1803
+ isNonNullable
1804
+ } from "@ai-sdk/provider-utils";
1653
1805
 
1654
1806
  // 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()
1807
+ import {
1808
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
1809
+ lazySchema as lazySchema9,
1810
+ zodSchema as zodSchema9
1811
+ } from "@ai-sdk/provider-utils";
1812
+ import { z as z10 } from "zod/v4";
1813
+ var codeExecution_20250522OutputSchema = lazySchema9(
1814
+ () => zodSchema9(
1815
+ z10.object({
1816
+ type: z10.literal("code_execution_result"),
1817
+ stdout: z10.string(),
1818
+ stderr: z10.string(),
1819
+ return_code: z10.number(),
1820
+ content: z10.array(
1821
+ z10.object({
1822
+ type: z10.literal("code_execution_output"),
1823
+ file_id: z10.string()
1668
1824
  })
1669
1825
  ).optional().default([])
1670
1826
  })
1671
1827
  )
1672
1828
  );
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()
1829
+ var codeExecution_20250522InputSchema = lazySchema9(
1830
+ () => zodSchema9(
1831
+ z10.object({
1832
+ code: z10.string()
1677
1833
  })
1678
1834
  )
1679
1835
  );
1680
- var factory6 = (0, import_provider_utils10.createProviderToolFactoryWithOutputSchema)({
1836
+ var factory6 = createProviderExecutedToolFactory5({
1681
1837
  id: "anthropic.code_execution_20250522",
1682
1838
  inputSchema: codeExecution_20250522InputSchema,
1683
1839
  outputSchema: codeExecution_20250522OutputSchema
@@ -1687,102 +1843,106 @@ var codeExecution_20250522 = (args = {}) => {
1687
1843
  };
1688
1844
 
1689
1845
  // 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()
1846
+ import {
1847
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
1848
+ lazySchema as lazySchema10,
1849
+ zodSchema as zodSchema10
1850
+ } from "@ai-sdk/provider-utils";
1851
+ import { z as z11 } from "zod/v4";
1852
+ var codeExecution_20250825OutputSchema = lazySchema10(
1853
+ () => zodSchema10(
1854
+ z11.discriminatedUnion("type", [
1855
+ z11.object({
1856
+ type: z11.literal("code_execution_result"),
1857
+ stdout: z11.string(),
1858
+ stderr: z11.string(),
1859
+ return_code: z11.number(),
1860
+ content: z11.array(
1861
+ z11.object({
1862
+ type: z11.literal("code_execution_output"),
1863
+ file_id: z11.string()
1704
1864
  })
1705
1865
  ).optional().default([])
1706
1866
  }),
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()
1867
+ z11.object({
1868
+ type: z11.literal("bash_code_execution_result"),
1869
+ content: z11.array(
1870
+ z11.object({
1871
+ type: z11.literal("bash_code_execution_output"),
1872
+ file_id: z11.string()
1713
1873
  })
1714
1874
  ),
1715
- stdout: import_v410.z.string(),
1716
- stderr: import_v410.z.string(),
1717
- return_code: import_v410.z.number()
1875
+ stdout: z11.string(),
1876
+ stderr: z11.string(),
1877
+ return_code: z11.number()
1718
1878
  }),
1719
- import_v410.z.object({
1720
- type: import_v410.z.literal("bash_code_execution_tool_result_error"),
1721
- error_code: import_v410.z.string()
1879
+ z11.object({
1880
+ type: z11.literal("bash_code_execution_tool_result_error"),
1881
+ error_code: z11.string()
1722
1882
  }),
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()
1883
+ z11.object({
1884
+ type: z11.literal("text_editor_code_execution_tool_result_error"),
1885
+ error_code: z11.string()
1726
1886
  }),
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()
1887
+ z11.object({
1888
+ type: z11.literal("text_editor_code_execution_view_result"),
1889
+ content: z11.string(),
1890
+ file_type: z11.string(),
1891
+ num_lines: z11.number().nullable(),
1892
+ start_line: z11.number().nullable(),
1893
+ total_lines: z11.number().nullable()
1734
1894
  }),
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()
1895
+ z11.object({
1896
+ type: z11.literal("text_editor_code_execution_create_result"),
1897
+ is_file_update: z11.boolean()
1738
1898
  }),
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()
1899
+ z11.object({
1900
+ type: z11.literal("text_editor_code_execution_str_replace_result"),
1901
+ lines: z11.array(z11.string()).nullable(),
1902
+ new_lines: z11.number().nullable(),
1903
+ new_start: z11.number().nullable(),
1904
+ old_lines: z11.number().nullable(),
1905
+ old_start: z11.number().nullable()
1746
1906
  })
1747
1907
  ])
1748
1908
  )
1749
1909
  );
1750
- var codeExecution_20250825InputSchema = (0, import_provider_utils11.lazySchema)(
1751
- () => (0, import_provider_utils11.zodSchema)(
1752
- import_v410.z.discriminatedUnion("type", [
1910
+ var codeExecution_20250825InputSchema = lazySchema10(
1911
+ () => zodSchema10(
1912
+ z11.discriminatedUnion("type", [
1753
1913
  // 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()
1914
+ z11.object({
1915
+ type: z11.literal("programmatic-tool-call"),
1916
+ code: z11.string()
1757
1917
  }),
1758
- import_v410.z.object({
1759
- type: import_v410.z.literal("bash_code_execution"),
1760
- command: import_v410.z.string()
1918
+ z11.object({
1919
+ type: z11.literal("bash_code_execution"),
1920
+ command: z11.string()
1761
1921
  }),
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()
1922
+ z11.discriminatedUnion("command", [
1923
+ z11.object({
1924
+ type: z11.literal("text_editor_code_execution"),
1925
+ command: z11.literal("view"),
1926
+ path: z11.string()
1767
1927
  }),
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()
1928
+ z11.object({
1929
+ type: z11.literal("text_editor_code_execution"),
1930
+ command: z11.literal("create"),
1931
+ path: z11.string(),
1932
+ file_text: z11.string().nullish()
1773
1933
  }),
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()
1934
+ z11.object({
1935
+ type: z11.literal("text_editor_code_execution"),
1936
+ command: z11.literal("str_replace"),
1937
+ path: z11.string(),
1938
+ old_str: z11.string(),
1939
+ new_str: z11.string()
1780
1940
  })
1781
1941
  ])
1782
1942
  ])
1783
1943
  )
1784
1944
  );
1785
- var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
1945
+ var factory7 = createProviderExecutedToolFactory6({
1786
1946
  id: "anthropic.code_execution_20250825",
1787
1947
  inputSchema: codeExecution_20250825InputSchema,
1788
1948
  outputSchema: codeExecution_20250825OutputSchema,
@@ -1796,113 +1956,117 @@ var codeExecution_20250825 = (args = {}) => {
1796
1956
  };
1797
1957
 
1798
1958
  // 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()
1959
+ import {
1960
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
1961
+ lazySchema as lazySchema11,
1962
+ zodSchema as zodSchema11
1963
+ } from "@ai-sdk/provider-utils";
1964
+ import { z as z12 } from "zod/v4";
1965
+ var codeExecution_20260120OutputSchema = lazySchema11(
1966
+ () => zodSchema11(
1967
+ z12.discriminatedUnion("type", [
1968
+ z12.object({
1969
+ type: z12.literal("code_execution_result"),
1970
+ stdout: z12.string(),
1971
+ stderr: z12.string(),
1972
+ return_code: z12.number(),
1973
+ content: z12.array(
1974
+ z12.object({
1975
+ type: z12.literal("code_execution_output"),
1976
+ file_id: z12.string()
1813
1977
  })
1814
1978
  ).optional().default([])
1815
1979
  }),
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()
1980
+ z12.object({
1981
+ type: z12.literal("encrypted_code_execution_result"),
1982
+ encrypted_stdout: z12.string(),
1983
+ stderr: z12.string(),
1984
+ return_code: z12.number(),
1985
+ content: z12.array(
1986
+ z12.object({
1987
+ type: z12.literal("code_execution_output"),
1988
+ file_id: z12.string()
1825
1989
  })
1826
1990
  ).optional().default([])
1827
1991
  }),
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()
1992
+ z12.object({
1993
+ type: z12.literal("bash_code_execution_result"),
1994
+ content: z12.array(
1995
+ z12.object({
1996
+ type: z12.literal("bash_code_execution_output"),
1997
+ file_id: z12.string()
1834
1998
  })
1835
1999
  ),
1836
- stdout: import_v411.z.string(),
1837
- stderr: import_v411.z.string(),
1838
- return_code: import_v411.z.number()
2000
+ stdout: z12.string(),
2001
+ stderr: z12.string(),
2002
+ return_code: z12.number()
1839
2003
  }),
1840
- import_v411.z.object({
1841
- type: import_v411.z.literal("bash_code_execution_tool_result_error"),
1842
- error_code: import_v411.z.string()
2004
+ z12.object({
2005
+ type: z12.literal("bash_code_execution_tool_result_error"),
2006
+ error_code: z12.string()
1843
2007
  }),
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()
2008
+ z12.object({
2009
+ type: z12.literal("text_editor_code_execution_tool_result_error"),
2010
+ error_code: z12.string()
1847
2011
  }),
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()
2012
+ z12.object({
2013
+ type: z12.literal("text_editor_code_execution_view_result"),
2014
+ content: z12.string(),
2015
+ file_type: z12.string(),
2016
+ num_lines: z12.number().nullable(),
2017
+ start_line: z12.number().nullable(),
2018
+ total_lines: z12.number().nullable()
1855
2019
  }),
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()
2020
+ z12.object({
2021
+ type: z12.literal("text_editor_code_execution_create_result"),
2022
+ is_file_update: z12.boolean()
1859
2023
  }),
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()
2024
+ z12.object({
2025
+ type: z12.literal("text_editor_code_execution_str_replace_result"),
2026
+ lines: z12.array(z12.string()).nullable(),
2027
+ new_lines: z12.number().nullable(),
2028
+ new_start: z12.number().nullable(),
2029
+ old_lines: z12.number().nullable(),
2030
+ old_start: z12.number().nullable()
1867
2031
  })
1868
2032
  ])
1869
2033
  )
1870
2034
  );
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()
2035
+ var codeExecution_20260120InputSchema = lazySchema11(
2036
+ () => zodSchema11(
2037
+ z12.discriminatedUnion("type", [
2038
+ z12.object({
2039
+ type: z12.literal("programmatic-tool-call"),
2040
+ code: z12.string()
1877
2041
  }),
1878
- import_v411.z.object({
1879
- type: import_v411.z.literal("bash_code_execution"),
1880
- command: import_v411.z.string()
2042
+ z12.object({
2043
+ type: z12.literal("bash_code_execution"),
2044
+ command: z12.string()
1881
2045
  }),
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()
2046
+ z12.discriminatedUnion("command", [
2047
+ z12.object({
2048
+ type: z12.literal("text_editor_code_execution"),
2049
+ command: z12.literal("view"),
2050
+ path: z12.string()
1887
2051
  }),
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()
2052
+ z12.object({
2053
+ type: z12.literal("text_editor_code_execution"),
2054
+ command: z12.literal("create"),
2055
+ path: z12.string(),
2056
+ file_text: z12.string().nullish()
1893
2057
  }),
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()
2058
+ z12.object({
2059
+ type: z12.literal("text_editor_code_execution"),
2060
+ command: z12.literal("str_replace"),
2061
+ path: z12.string(),
2062
+ old_str: z12.string(),
2063
+ new_str: z12.string()
1900
2064
  })
1901
2065
  ])
1902
2066
  ])
1903
2067
  )
1904
2068
  );
1905
- var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
2069
+ var factory8 = createProviderExecutedToolFactory7({
1906
2070
  id: "anthropic.code_execution_20260120",
1907
2071
  inputSchema: codeExecution_20260120InputSchema,
1908
2072
  outputSchema: codeExecution_20260120OutputSchema,
@@ -1913,21 +2077,25 @@ var codeExecution_20260120 = (args = {}) => {
1913
2077
  };
1914
2078
 
1915
2079
  // 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()
2080
+ import {
2081
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory8,
2082
+ lazySchema as lazySchema12,
2083
+ zodSchema as zodSchema12
2084
+ } from "@ai-sdk/provider-utils";
2085
+ import { z as z13 } from "zod/v4";
2086
+ var toolSearchRegex_20251119OutputSchema = lazySchema12(
2087
+ () => zodSchema12(
2088
+ z13.array(
2089
+ z13.object({
2090
+ type: z13.literal("tool_reference"),
2091
+ toolName: z13.string()
1924
2092
  })
1925
2093
  )
1926
2094
  )
1927
2095
  );
1928
- var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema)(
1929
- () => (0, import_provider_utils13.zodSchema)(
1930
- import_v412.z.object({
2096
+ var toolSearchRegex_20251119InputSchema = lazySchema12(
2097
+ () => zodSchema12(
2098
+ z13.object({
1931
2099
  /**
1932
2100
  * A regex pattern to search for tools.
1933
2101
  * Uses Python re.search() syntax. Maximum 200 characters.
@@ -1938,15 +2106,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
1938
2106
  * - "database.*query|query.*database" - OR patterns for flexibility
1939
2107
  * - "(?i)slack" - case-insensitive search
1940
2108
  */
1941
- pattern: import_v412.z.string(),
2109
+ pattern: z13.string(),
1942
2110
  /**
1943
2111
  * Maximum number of tools to return. Optional.
1944
2112
  */
1945
- limit: import_v412.z.number().optional()
2113
+ limit: z13.number().optional()
1946
2114
  })
1947
2115
  )
1948
2116
  );
1949
- var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
2117
+ var factory9 = createProviderExecutedToolFactory8({
1950
2118
  id: "anthropic.tool_search_regex_20251119",
1951
2119
  inputSchema: toolSearchRegex_20251119InputSchema,
1952
2120
  outputSchema: toolSearchRegex_20251119OutputSchema,
@@ -1956,20 +2124,20 @@ var toolSearchRegex_20251119 = (args = {}) => {
1956
2124
  return factory9(args);
1957
2125
  };
1958
2126
 
1959
- // src/convert-to-anthropic-messages-prompt.ts
2127
+ // src/convert-to-anthropic-prompt.ts
1960
2128
  function convertToString(data) {
1961
2129
  if (typeof data === "string") {
1962
- return new TextDecoder().decode((0, import_provider_utils14.convertBase64ToUint8Array)(data));
2130
+ return new TextDecoder().decode(convertBase64ToUint8Array2(data));
1963
2131
  }
1964
2132
  if (data instanceof Uint8Array) {
1965
2133
  return new TextDecoder().decode(data);
1966
2134
  }
1967
2135
  if (data instanceof URL) {
1968
- throw new import_provider2.UnsupportedFunctionalityError({
2136
+ throw new UnsupportedFunctionalityError2({
1969
2137
  functionality: "URL-based text documents are not supported for citations"
1970
2138
  });
1971
2139
  }
1972
- throw new import_provider2.UnsupportedFunctionalityError({
2140
+ throw new UnsupportedFunctionalityError2({
1973
2141
  functionality: `unsupported data type for text documents: ${typeof data}`
1974
2142
  });
1975
2143
  }
@@ -1982,7 +2150,7 @@ function isUrlString(data) {
1982
2150
  function getUrlString(data) {
1983
2151
  return data instanceof URL ? data.toString() : data;
1984
2152
  }
1985
- async function convertToAnthropicMessagesPrompt({
2153
+ async function convertToAnthropicPrompt({
1986
2154
  prompt,
1987
2155
  sendReasoning,
1988
2156
  warnings,
@@ -1997,7 +2165,7 @@ async function convertToAnthropicMessagesPrompt({
1997
2165
  const messages = [];
1998
2166
  async function shouldEnableCitations(providerMetadata) {
1999
2167
  var _a2, _b2;
2000
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2168
+ const anthropicOptions = await parseProviderOptions({
2001
2169
  provider: "anthropic",
2002
2170
  providerOptions: providerMetadata,
2003
2171
  schema: anthropicFilePartProviderOptions
@@ -2005,7 +2173,7 @@ async function convertToAnthropicMessagesPrompt({
2005
2173
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
2006
2174
  }
2007
2175
  async function getDocumentMetadata(providerMetadata) {
2008
- const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
2176
+ const anthropicOptions = await parseProviderOptions({
2009
2177
  provider: "anthropic",
2010
2178
  providerOptions: providerMetadata,
2011
2179
  schema: anthropicFilePartProviderOptions
@@ -2022,7 +2190,7 @@ async function convertToAnthropicMessagesPrompt({
2022
2190
  switch (type) {
2023
2191
  case "system": {
2024
2192
  if (system != null) {
2025
- throw new import_provider2.UnsupportedFunctionalityError({
2193
+ throw new UnsupportedFunctionalityError2({
2026
2194
  functionality: "Multiple system messages that are separated by user/assistant messages"
2027
2195
  });
2028
2196
  }
@@ -2062,7 +2230,26 @@ async function convertToAnthropicMessagesPrompt({
2062
2230
  break;
2063
2231
  }
2064
2232
  case "file": {
2065
- if (part.mediaType.startsWith("image/")) {
2233
+ if (isProviderReference(part.data)) {
2234
+ const fileId = resolveProviderReference({
2235
+ reference: part.data,
2236
+ provider: "anthropic"
2237
+ });
2238
+ betas.add("files-api-2025-04-14");
2239
+ if (part.mediaType.startsWith("image/")) {
2240
+ anthropicContent.push({
2241
+ type: "image",
2242
+ source: { type: "file", file_id: fileId },
2243
+ cache_control: cacheControl
2244
+ });
2245
+ } else {
2246
+ anthropicContent.push({
2247
+ type: "document",
2248
+ source: { type: "file", file_id: fileId },
2249
+ cache_control: cacheControl
2250
+ });
2251
+ }
2252
+ } else if (part.mediaType.startsWith("image/")) {
2066
2253
  anthropicContent.push({
2067
2254
  type: "image",
2068
2255
  source: isUrlData(part.data) ? {
@@ -2071,7 +2258,7 @@ async function convertToAnthropicMessagesPrompt({
2071
2258
  } : {
2072
2259
  type: "base64",
2073
2260
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
2074
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2261
+ data: convertToBase64(part.data)
2075
2262
  },
2076
2263
  cache_control: cacheControl
2077
2264
  });
@@ -2091,7 +2278,7 @@ async function convertToAnthropicMessagesPrompt({
2091
2278
  } : {
2092
2279
  type: "base64",
2093
2280
  media_type: "application/pdf",
2094
- data: (0, import_provider_utils14.convertToBase64)(part.data)
2281
+ data: convertToBase64(part.data)
2095
2282
  },
2096
2283
  title: (_b = metadata.title) != null ? _b : part.filename,
2097
2284
  ...metadata.context && { context: metadata.context },
@@ -2125,7 +2312,7 @@ async function convertToAnthropicMessagesPrompt({
2125
2312
  cache_control: cacheControl
2126
2313
  });
2127
2314
  } else {
2128
- throw new import_provider2.UnsupportedFunctionalityError({
2315
+ throw new UnsupportedFunctionalityError2({
2129
2316
  functionality: `media type: ${part.mediaType}`
2130
2317
  });
2131
2318
  }
@@ -2161,26 +2348,16 @@ async function convertToAnthropicMessagesPrompt({
2161
2348
  type: "text",
2162
2349
  text: contentPart.text
2163
2350
  };
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
2351
  case "file-url": {
2352
+ if (contentPart.mediaType.startsWith("image/")) {
2353
+ return {
2354
+ type: "image",
2355
+ source: {
2356
+ type: "url",
2357
+ url: contentPart.url
2358
+ }
2359
+ };
2360
+ }
2184
2361
  return {
2185
2362
  type: "document",
2186
2363
  source: {
@@ -2190,6 +2367,16 @@ async function convertToAnthropicMessagesPrompt({
2190
2367
  };
2191
2368
  }
2192
2369
  case "file-data": {
2370
+ if (contentPart.mediaType.startsWith("image/")) {
2371
+ return {
2372
+ type: "image",
2373
+ source: {
2374
+ type: "base64",
2375
+ media_type: contentPart.mediaType,
2376
+ data: contentPart.data
2377
+ }
2378
+ };
2379
+ }
2193
2380
  if (contentPart.mediaType === "application/pdf") {
2194
2381
  betas.add("pdfs-2024-09-25");
2195
2382
  return {
@@ -2229,14 +2416,14 @@ async function convertToAnthropicMessagesPrompt({
2229
2416
  return void 0;
2230
2417
  }
2231
2418
  }
2232
- }).filter(import_provider_utils14.isNonNullable);
2419
+ }).filter(isNonNullable);
2233
2420
  break;
2234
2421
  case "text":
2235
2422
  case "error-text":
2236
2423
  contentValue = output.value;
2237
2424
  break;
2238
2425
  case "execution-denied":
2239
- contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
2426
+ contentValue = (_e = output.reason) != null ? _e : "Tool call execution denied.";
2240
2427
  break;
2241
2428
  case "json":
2242
2429
  case "error-json":
@@ -2305,7 +2492,7 @@ async function convertToAnthropicMessagesPrompt({
2305
2492
  }
2306
2493
  case "reasoning": {
2307
2494
  if (sendReasoning) {
2308
- const reasoningMetadata = await (0, import_provider_utils14.parseProviderOptions)({
2495
+ const reasoningMetadata = await parseProviderOptions({
2309
2496
  provider: "anthropic",
2310
2497
  providerOptions: part.providerOptions,
2311
2498
  schema: anthropicReasoningMetadataSchema
@@ -2511,7 +2698,7 @@ async function convertToAnthropicMessagesPrompt({
2511
2698
  break;
2512
2699
  }
2513
2700
  if (output.value.type === "code_execution_result") {
2514
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2701
+ const codeExecutionOutput = await validateTypes2({
2515
2702
  value: output.value,
2516
2703
  schema: codeExecution_20250522OutputSchema
2517
2704
  });
@@ -2528,7 +2715,7 @@ async function convertToAnthropicMessagesPrompt({
2528
2715
  cache_control: cacheControl
2529
2716
  });
2530
2717
  } else if (output.value.type === "encrypted_code_execution_result") {
2531
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2718
+ const codeExecutionOutput = await validateTypes2({
2532
2719
  value: output.value,
2533
2720
  schema: codeExecution_20260120OutputSchema
2534
2721
  });
@@ -2547,7 +2734,7 @@ async function convertToAnthropicMessagesPrompt({
2547
2734
  });
2548
2735
  }
2549
2736
  } else {
2550
- const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2737
+ const codeExecutionOutput = await validateTypes2({
2551
2738
  value: output.value,
2552
2739
  schema: codeExecution_20250825OutputSchema
2553
2740
  });
@@ -2616,7 +2803,7 @@ async function convertToAnthropicMessagesPrompt({
2616
2803
  });
2617
2804
  break;
2618
2805
  }
2619
- const webFetchOutput = await (0, import_provider_utils14.validateTypes)({
2806
+ const webFetchOutput = await validateTypes2({
2620
2807
  value: output.value,
2621
2808
  schema: webFetch_20250910OutputSchema
2622
2809
  });
@@ -2651,7 +2838,7 @@ async function convertToAnthropicMessagesPrompt({
2651
2838
  });
2652
2839
  break;
2653
2840
  }
2654
- const webSearchOutput = await (0, import_provider_utils14.validateTypes)({
2841
+ const webSearchOutput = await validateTypes2({
2655
2842
  value: output.value,
2656
2843
  schema: webSearch_20250305OutputSchema
2657
2844
  });
@@ -2678,7 +2865,7 @@ async function convertToAnthropicMessagesPrompt({
2678
2865
  });
2679
2866
  break;
2680
2867
  }
2681
- const toolSearchOutput = await (0, import_provider_utils14.validateTypes)({
2868
+ const toolSearchOutput = await validateTypes2({
2682
2869
  value: output.value,
2683
2870
  schema: toolSearchRegex_20251119OutputSchema
2684
2871
  });
@@ -2791,7 +2978,153 @@ function mapAnthropicStopReason({
2791
2978
  }
2792
2979
  }
2793
2980
 
2794
- // src/anthropic-messages-language-model.ts
2981
+ // src/sanitize-json-schema.ts
2982
+ var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
2983
+ "date-time",
2984
+ "time",
2985
+ "date",
2986
+ "duration",
2987
+ "email",
2988
+ "hostname",
2989
+ "uri",
2990
+ "ipv4",
2991
+ "ipv6",
2992
+ "uuid"
2993
+ ]);
2994
+ var DESCRIPTION_CONSTRAINT_KEYS = [
2995
+ "minimum",
2996
+ "maximum",
2997
+ "exclusiveMinimum",
2998
+ "exclusiveMaximum",
2999
+ "multipleOf",
3000
+ "minLength",
3001
+ "maxLength",
3002
+ "pattern",
3003
+ "minItems",
3004
+ "maxItems",
3005
+ "uniqueItems",
3006
+ "minProperties",
3007
+ "maxProperties",
3008
+ "not"
3009
+ ];
3010
+ function sanitizeJsonSchema(schema) {
3011
+ return sanitizeSchema(schema);
3012
+ }
3013
+ function sanitizeDefinition(definition) {
3014
+ if (typeof definition === "boolean" || !isPlainObject(definition)) {
3015
+ return definition;
3016
+ }
3017
+ return sanitizeSchema(definition);
3018
+ }
3019
+ function sanitizeSchema(schema) {
3020
+ const result = {};
3021
+ const schemaWithDefs = schema;
3022
+ if (schema.$ref != null) {
3023
+ return { $ref: schema.$ref };
3024
+ }
3025
+ if (schema.$schema != null) {
3026
+ result.$schema = schema.$schema;
3027
+ }
3028
+ if (schema.$id != null) {
3029
+ result.$id = schema.$id;
3030
+ }
3031
+ if (schema.title != null) {
3032
+ result.title = schema.title;
3033
+ }
3034
+ if (schema.description != null) {
3035
+ result.description = schema.description;
3036
+ }
3037
+ if (schema.default !== void 0) {
3038
+ result.default = schema.default;
3039
+ }
3040
+ if (schema.const !== void 0) {
3041
+ result.const = schema.const;
3042
+ }
3043
+ if (schema.enum != null) {
3044
+ result.enum = schema.enum;
3045
+ }
3046
+ if (schema.type != null) {
3047
+ result.type = schema.type;
3048
+ }
3049
+ if (schema.anyOf != null) {
3050
+ result.anyOf = schema.anyOf.map(sanitizeDefinition);
3051
+ } else if (schema.oneOf != null) {
3052
+ result.anyOf = schema.oneOf.map(sanitizeDefinition);
3053
+ }
3054
+ if (schema.allOf != null) {
3055
+ result.allOf = schema.allOf.map(sanitizeDefinition);
3056
+ }
3057
+ if (schema.definitions != null) {
3058
+ result.definitions = Object.fromEntries(
3059
+ Object.entries(schema.definitions).map(([name, definition]) => [
3060
+ name,
3061
+ sanitizeDefinition(definition)
3062
+ ])
3063
+ );
3064
+ }
3065
+ if (schemaWithDefs.$defs != null) {
3066
+ const resultWithDefs = result;
3067
+ resultWithDefs.$defs = Object.fromEntries(
3068
+ Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
3069
+ name,
3070
+ sanitizeDefinition(definition)
3071
+ ])
3072
+ );
3073
+ }
3074
+ if (schema.type === "object" || schema.properties != null) {
3075
+ if (schema.properties != null) {
3076
+ result.properties = Object.fromEntries(
3077
+ Object.entries(schema.properties).map(([name, definition]) => [
3078
+ name,
3079
+ sanitizeDefinition(definition)
3080
+ ])
3081
+ );
3082
+ }
3083
+ result.additionalProperties = false;
3084
+ if (schema.required != null) {
3085
+ result.required = schema.required;
3086
+ }
3087
+ }
3088
+ if (schema.items != null) {
3089
+ result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
3090
+ }
3091
+ if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
3092
+ result.format = schema.format;
3093
+ }
3094
+ const constraintDescription = getConstraintDescription(schema);
3095
+ if (constraintDescription != null) {
3096
+ result.description = result.description == null ? constraintDescription : `${result.description}
3097
+ ${constraintDescription}`;
3098
+ }
3099
+ return result;
3100
+ }
3101
+ function getConstraintDescription(schema) {
3102
+ const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
3103
+ const value = schema[key];
3104
+ if (value == null || value === false) {
3105
+ return [];
3106
+ }
3107
+ return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
3108
+ });
3109
+ if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
3110
+ descriptions.push(`format: ${schema.format}`);
3111
+ }
3112
+ return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
3113
+ }
3114
+ function formatConstraintName(key) {
3115
+ return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
3116
+ }
3117
+ function formatConstraintValue(value) {
3118
+ if (typeof value === "string") {
3119
+ return value;
3120
+ }
3121
+ return JSON.stringify(value);
3122
+ }
3123
+ function isPlainObject(value) {
3124
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3125
+ }
3126
+
3127
+ // src/anthropic-language-model.ts
2795
3128
  function createCitationSource(citation, citationDocuments, generateId3) {
2796
3129
  var _a;
2797
3130
  if (citation.type === "web_search_result_location") {
@@ -2836,13 +3169,22 @@ function createCitationSource(citation, citationDocuments, generateId3) {
2836
3169
  }
2837
3170
  };
2838
3171
  }
2839
- var AnthropicMessagesLanguageModel = class {
3172
+ var AnthropicLanguageModel = class _AnthropicLanguageModel {
2840
3173
  constructor(modelId, config) {
2841
3174
  this.specificationVersion = "v4";
2842
3175
  var _a;
2843
3176
  this.modelId = modelId;
2844
3177
  this.config = config;
2845
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils15.generateId;
3178
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
3179
+ }
3180
+ static [WORKFLOW_SERIALIZE](model) {
3181
+ return serializeModelOptions({
3182
+ modelId: model.modelId,
3183
+ config: model.config
3184
+ });
3185
+ }
3186
+ static [WORKFLOW_DESERIALIZE](options) {
3187
+ return new _AnthropicLanguageModel(options.modelId, options.config);
2846
3188
  }
2847
3189
  supportsUrl(url) {
2848
3190
  return url.protocol === "https:";
@@ -2877,10 +3219,11 @@ var AnthropicMessagesLanguageModel = class {
2877
3219
  seed,
2878
3220
  tools,
2879
3221
  toolChoice,
3222
+ reasoning,
2880
3223
  providerOptions,
2881
3224
  stream
2882
3225
  }) {
2883
- var _a, _b, _c, _d, _e, _f, _g, _h;
3226
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2884
3227
  const warnings = [];
2885
3228
  if (frequencyPenalty != null) {
2886
3229
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2916,12 +3259,12 @@ var AnthropicMessagesLanguageModel = class {
2916
3259
  }
2917
3260
  }
2918
3261
  const providerOptionsName = this.providerOptionsName;
2919
- const canonicalOptions = await (0, import_provider_utils15.parseProviderOptions)({
3262
+ const canonicalOptions = await parseProviderOptions2({
2920
3263
  provider: "anthropic",
2921
3264
  providerOptions,
2922
3265
  schema: anthropicLanguageModelOptions
2923
3266
  });
2924
- const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils15.parseProviderOptions)({
3267
+ const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
2925
3268
  provider: providerOptionsName,
2926
3269
  providerOptions,
2927
3270
  schema: anthropicLanguageModelOptions
@@ -2935,8 +3278,38 @@ var AnthropicMessagesLanguageModel = class {
2935
3278
  const {
2936
3279
  maxOutputTokens: maxOutputTokensForModel,
2937
3280
  supportsStructuredOutput: modelSupportsStructuredOutput,
3281
+ supportsAdaptiveThinking,
3282
+ rejectsSamplingParameters,
3283
+ supportsXhighEffort,
2938
3284
  isKnownModel
2939
3285
  } = getModelCapabilities(this.modelId);
3286
+ if (rejectsSamplingParameters) {
3287
+ if (temperature != null) {
3288
+ warnings.push({
3289
+ type: "unsupported",
3290
+ feature: "temperature",
3291
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
3292
+ });
3293
+ temperature = void 0;
3294
+ }
3295
+ if (topK != null) {
3296
+ warnings.push({
3297
+ type: "unsupported",
3298
+ feature: "topK",
3299
+ details: `topK is not supported by ${this.modelId} and will be ignored`
3300
+ });
3301
+ topK = void 0;
3302
+ }
3303
+ if (topP != null) {
3304
+ warnings.push({
3305
+ type: "unsupported",
3306
+ feature: "topP",
3307
+ details: `topP is not supported by ${this.modelId} and will be ignored`
3308
+ });
3309
+ topP = void 0;
3310
+ }
3311
+ }
3312
+ const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2940
3313
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2941
3314
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
2942
3315
  const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
@@ -2949,7 +3322,7 @@ var AnthropicMessagesLanguageModel = class {
2949
3322
  } : void 0;
2950
3323
  const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
2951
3324
  const cacheControlValidator = new CacheControlValidator();
2952
- const toolNameMapping = (0, import_provider_utils15.createToolNameMapping)({
3325
+ const toolNameMapping = createToolNameMapping({
2953
3326
  tools,
2954
3327
  providerToolNames: {
2955
3328
  "anthropic.code_execution_20250522": "code_execution",
@@ -2972,16 +3345,34 @@ var AnthropicMessagesLanguageModel = class {
2972
3345
  "anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
2973
3346
  }
2974
3347
  });
2975
- const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
3348
+ const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
2976
3349
  prompt,
2977
3350
  sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
2978
3351
  warnings,
2979
3352
  cacheControlValidator,
2980
3353
  toolNameMapping
2981
3354
  });
2982
- const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3355
+ if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
3356
+ const reasoningConfig = resolveAnthropicReasoningConfig({
3357
+ reasoning,
3358
+ supportsAdaptiveThinking,
3359
+ supportsXhighEffort,
3360
+ maxOutputTokensForModel,
3361
+ warnings
3362
+ });
3363
+ if (reasoningConfig != null) {
3364
+ if (anthropicOptions.thinking == null) {
3365
+ anthropicOptions.thinking = reasoningConfig.thinking;
3366
+ }
3367
+ if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
3368
+ anthropicOptions.effort = reasoningConfig.effort;
3369
+ }
3370
+ }
3371
+ }
3372
+ const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
2983
3373
  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;
3374
+ let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
3375
+ const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
2985
3376
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
2986
3377
  const baseArgs = {
2987
3378
  // model id:
@@ -2996,18 +3387,28 @@ var AnthropicMessagesLanguageModel = class {
2996
3387
  ...isThinking && {
2997
3388
  thinking: {
2998
3389
  type: thinkingType,
2999
- ...thinkingBudget != null && { budget_tokens: thinkingBudget }
3390
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget },
3391
+ ...thinkingDisplay != null && { display: thinkingDisplay }
3000
3392
  }
3001
3393
  },
3002
- ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3394
+ ...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
3003
3395
  output_config: {
3004
3396
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
3005
3397
  effort: anthropicOptions.effort
3006
3398
  },
3399
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
3400
+ task_budget: {
3401
+ type: anthropicOptions.taskBudget.type,
3402
+ total: anthropicOptions.taskBudget.total,
3403
+ ...anthropicOptions.taskBudget.remaining != null && {
3404
+ remaining: anthropicOptions.taskBudget.remaining
3405
+ }
3406
+ }
3407
+ },
3007
3408
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
3008
3409
  format: {
3009
3410
  type: "json_schema",
3010
- schema: responseFormat.schema
3411
+ schema: sanitizeJsonSchema(responseFormat.schema)
3011
3412
  }
3012
3413
  }
3013
3414
  }
@@ -3015,9 +3416,15 @@ var AnthropicMessagesLanguageModel = class {
3015
3416
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
3016
3417
  speed: anthropicOptions.speed
3017
3418
  },
3419
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3420
+ inference_geo: anthropicOptions.inferenceGeo
3421
+ },
3018
3422
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3019
3423
  cache_control: anthropicOptions.cacheControl
3020
3424
  },
3425
+ ...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
3426
+ metadata: { user_id: anthropicOptions.metadata.userId }
3427
+ },
3021
3428
  // mcp servers:
3022
3429
  ...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
3023
3430
  mcp_servers: anthropicOptions.mcpServers.map((server) => ({
@@ -3039,7 +3446,10 @@ var AnthropicMessagesLanguageModel = class {
3039
3446
  id: anthropicOptions.container.id,
3040
3447
  skills: anthropicOptions.container.skills.map((skill) => ({
3041
3448
  type: skill.type,
3042
- skill_id: skill.skillId,
3449
+ skill_id: skill.type === "custom" ? resolveProviderReference2({
3450
+ reference: skill.providerReference,
3451
+ provider: "anthropic"
3452
+ }) : skill.skillId,
3043
3453
  version: skill.version
3044
3454
  }))
3045
3455
  }
@@ -3141,7 +3551,7 @@ var AnthropicMessagesLanguageModel = class {
3141
3551
  }
3142
3552
  baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
3143
3553
  } else {
3144
- if (topP != null && temperature != null) {
3554
+ if (isAnthropicModel && topP != null && temperature != null) {
3145
3555
  warnings.push({
3146
3556
  type: "unsupported",
3147
3557
  feature: "topP",
@@ -3185,12 +3595,13 @@ var AnthropicMessagesLanguageModel = class {
3185
3595
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
3186
3596
  betas.add("effort-2025-11-24");
3187
3597
  }
3598
+ if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
3599
+ betas.add("task-budgets-2026-03-13");
3600
+ }
3188
3601
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3189
3602
  betas.add("fast-mode-2026-02-01");
3190
3603
  }
3191
- if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
3192
- betas.add("fine-grained-tool-streaming-2025-05-14");
3193
- }
3604
+ const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
3194
3605
  const {
3195
3606
  tools: anthropicTools2,
3196
3607
  toolChoice: anthropicToolChoice,
@@ -3203,14 +3614,16 @@ var AnthropicMessagesLanguageModel = class {
3203
3614
  disableParallelToolUse: true,
3204
3615
  cacheControlValidator,
3205
3616
  supportsStructuredOutput: false,
3206
- supportsStrictTools
3617
+ supportsStrictTools,
3618
+ defaultEagerInputStreaming
3207
3619
  } : {
3208
3620
  tools: tools != null ? tools : [],
3209
3621
  toolChoice,
3210
3622
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3211
3623
  cacheControlValidator,
3212
3624
  supportsStructuredOutput,
3213
- supportsStrictTools
3625
+ supportsStrictTools,
3626
+ defaultEagerInputStreaming
3214
3627
  }
3215
3628
  );
3216
3629
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3227,7 +3640,7 @@ var AnthropicMessagesLanguageModel = class {
3227
3640
  ...betas,
3228
3641
  ...toolsBetas,
3229
3642
  ...userSuppliedBetas,
3230
- ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
3643
+ ...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
3231
3644
  ]),
3232
3645
  usesJsonResponseTool: jsonResponseTool != null,
3233
3646
  toolNameMapping,
@@ -3239,16 +3652,16 @@ var AnthropicMessagesLanguageModel = class {
3239
3652
  betas,
3240
3653
  headers
3241
3654
  }) {
3242
- return (0, import_provider_utils15.combineHeaders)(
3243
- await (0, import_provider_utils15.resolve)(this.config.headers),
3655
+ return combineHeaders2(
3656
+ this.config.headers ? await resolve(this.config.headers) : void 0,
3244
3657
  headers,
3245
3658
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
3246
3659
  );
3247
3660
  }
3248
3661
  async getBetasFromHeaders(requestHeaders) {
3249
3662
  var _a, _b;
3250
- const configHeaders = await (0, import_provider_utils15.resolve)(this.config.headers);
3251
- const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
3663
+ const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
3664
+ const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
3252
3665
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
3253
3666
  return new Set(
3254
3667
  [
@@ -3313,13 +3726,13 @@ var AnthropicMessagesLanguageModel = class {
3313
3726
  responseHeaders,
3314
3727
  value: response,
3315
3728
  rawValue: rawResponse
3316
- } = await (0, import_provider_utils15.postJsonToApi)({
3729
+ } = await postJsonToApi({
3317
3730
  url: this.buildRequestUrl(false),
3318
3731
  headers: await this.getHeaders({ betas, headers: options.headers }),
3319
3732
  body: this.transformRequestBody(args, betas),
3320
3733
  failedResponseHandler: anthropicFailedResponseHandler,
3321
- successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3322
- anthropicMessagesResponseSchema
3734
+ successfulResponseHandler: createJsonResponseHandler2(
3735
+ anthropicResponseSchema
3323
3736
  ),
3324
3737
  abortSignal: options.abortSignal,
3325
3738
  fetch: this.config.fetch
@@ -3668,7 +4081,7 @@ var AnthropicMessagesLanguageModel = class {
3668
4081
  }),
3669
4082
  raw: (_e = response.stop_reason) != null ? _e : void 0
3670
4083
  },
3671
- usage: convertAnthropicMessagesUsage({ usage: response.usage }),
4084
+ usage: convertAnthropicUsage({ usage: response.usage }),
3672
4085
  request: { body: args },
3673
4086
  response: {
3674
4087
  id: (_f = response.id) != null ? _f : void 0,
@@ -3678,11 +4091,10 @@ var AnthropicMessagesLanguageModel = class {
3678
4091
  },
3679
4092
  warnings,
3680
4093
  providerMetadata: (() => {
3681
- var _a2, _b2, _c2, _d2, _e2;
4094
+ var _a2, _b2, _c2, _d2;
3682
4095
  const anthropicMetadata = {
3683
4096
  usage: response.usage,
3684
- cacheCreationInputTokens: (_a2 = response.usage.cache_creation_input_tokens) != null ? _a2 : null,
3685
- stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
4097
+ stopSequence: (_a2 = response.stop_sequence) != null ? _a2 : null,
3686
4098
  iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
3687
4099
  type: iter.type,
3688
4100
  inputTokens: iter.input_tokens,
@@ -3691,15 +4103,15 @@ var AnthropicMessagesLanguageModel = class {
3691
4103
  container: response.container ? {
3692
4104
  expiresAt: response.container.expires_at,
3693
4105
  id: response.container.id,
3694
- skills: (_d2 = (_c2 = response.container.skills) == null ? void 0 : _c2.map((skill) => ({
4106
+ skills: (_c2 = (_b2 = response.container.skills) == null ? void 0 : _b2.map((skill) => ({
3695
4107
  type: skill.type,
3696
4108
  skillId: skill.skill_id,
3697
4109
  version: skill.version
3698
- }))) != null ? _d2 : null
4110
+ }))) != null ? _c2 : null
3699
4111
  } : null,
3700
- contextManagement: (_e2 = mapAnthropicResponseContextManagement(
4112
+ contextManagement: (_d2 = mapAnthropicResponseContextManagement(
3701
4113
  response.context_management
3702
- )) != null ? _e2 : null
4114
+ )) != null ? _d2 : null
3703
4115
  };
3704
4116
  const providerMetadata = {
3705
4117
  anthropic: anthropicMetadata
@@ -3712,6 +4124,7 @@ var AnthropicMessagesLanguageModel = class {
3712
4124
  };
3713
4125
  }
3714
4126
  async doStream(options) {
4127
+ "use step";
3715
4128
  var _a, _b;
3716
4129
  const {
3717
4130
  args: body,
@@ -3733,14 +4146,12 @@ var AnthropicMessagesLanguageModel = class {
3733
4146
  body.tools
3734
4147
  );
3735
4148
  const url = this.buildRequestUrl(true);
3736
- const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
4149
+ const { responseHeaders, value: response } = await postJsonToApi({
3737
4150
  url,
3738
4151
  headers: await this.getHeaders({ betas, headers: options.headers }),
3739
4152
  body: this.transformRequestBody(body, betas),
3740
4153
  failedResponseHandler: anthropicFailedResponseHandler,
3741
- successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
3742
- anthropicMessagesChunkSchema
3743
- ),
4154
+ successfulResponseHandler: createEventSourceResponseHandler(anthropicChunkSchema),
3744
4155
  abortSignal: options.abortSignal,
3745
4156
  fetch: this.config.fetch
3746
4157
  });
@@ -3760,7 +4171,6 @@ var AnthropicMessagesLanguageModel = class {
3760
4171
  const serverToolCalls = {};
3761
4172
  let contextManagement = null;
3762
4173
  let rawUsage = void 0;
3763
- let cacheCreationInputTokens = null;
3764
4174
  let stopSequence = null;
3765
4175
  let container = null;
3766
4176
  let isJsonResponseFromTool = false;
@@ -3772,7 +4182,7 @@ var AnthropicMessagesLanguageModel = class {
3772
4182
  controller.enqueue({ type: "stream-start", warnings });
3773
4183
  },
3774
4184
  transform(chunk, controller) {
3775
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4185
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
3776
4186
  if (options.includeRawChunks) {
3777
4187
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3778
4188
  }
@@ -4307,7 +4717,6 @@ var AnthropicMessagesLanguageModel = class {
4307
4717
  rawUsage = {
4308
4718
  ...value.message.usage
4309
4719
  };
4310
- cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
4311
4720
  if (value.message.container != null) {
4312
4721
  container = {
4313
4722
  expiresAt: value.message.container.expires_at,
@@ -4326,8 +4735,8 @@ var AnthropicMessagesLanguageModel = class {
4326
4735
  }
4327
4736
  controller.enqueue({
4328
4737
  type: "response-metadata",
4329
- id: (_h = value.message.id) != null ? _h : void 0,
4330
- modelId: (_i = value.message.model) != null ? _i : void 0
4738
+ id: (_g = value.message.id) != null ? _g : void 0,
4739
+ modelId: (_h = value.message.model) != null ? _h : void 0
4331
4740
  });
4332
4741
  if (value.message.content != null) {
4333
4742
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
@@ -4343,7 +4752,7 @@ var AnthropicMessagesLanguageModel = class {
4343
4752
  id: part.id,
4344
4753
  toolName: part.name
4345
4754
  });
4346
- const inputStr = JSON.stringify((_j = part.input) != null ? _j : {});
4755
+ const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
4347
4756
  controller.enqueue({
4348
4757
  type: "tool-input-delta",
4349
4758
  id: part.id,
@@ -4381,7 +4790,6 @@ var AnthropicMessagesLanguageModel = class {
4381
4790
  }
4382
4791
  if (value.usage.cache_creation_input_tokens != null) {
4383
4792
  usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
4384
- cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
4385
4793
  }
4386
4794
  if (value.usage.iterations != null) {
4387
4795
  usage.iterations = value.usage.iterations;
@@ -4391,17 +4799,17 @@ var AnthropicMessagesLanguageModel = class {
4391
4799
  finishReason: value.delta.stop_reason,
4392
4800
  isJsonResponseFromTool
4393
4801
  }),
4394
- raw: (_k = value.delta.stop_reason) != null ? _k : void 0
4802
+ raw: (_j = value.delta.stop_reason) != null ? _j : void 0
4395
4803
  };
4396
- stopSequence = (_l = value.delta.stop_sequence) != null ? _l : null;
4804
+ stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
4397
4805
  container = value.delta.container != null ? {
4398
4806
  expiresAt: value.delta.container.expires_at,
4399
4807
  id: value.delta.container.id,
4400
- skills: (_n = (_m = value.delta.container.skills) == null ? void 0 : _m.map((skill) => ({
4808
+ skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
4401
4809
  type: skill.type,
4402
4810
  skillId: skill.skill_id,
4403
4811
  version: skill.version
4404
- }))) != null ? _n : null
4812
+ }))) != null ? _m : null
4405
4813
  } : null;
4406
4814
  if (value.context_management) {
4407
4815
  contextManagement = mapAnthropicResponseContextManagement(
@@ -4417,7 +4825,6 @@ var AnthropicMessagesLanguageModel = class {
4417
4825
  case "message_stop": {
4418
4826
  const anthropicMetadata = {
4419
4827
  usage: rawUsage != null ? rawUsage : null,
4420
- cacheCreationInputTokens,
4421
4828
  stopSequence,
4422
4829
  iterations: usage.iterations ? usage.iterations.map((iter) => ({
4423
4830
  type: iter.type,
@@ -4436,7 +4843,7 @@ var AnthropicMessagesLanguageModel = class {
4436
4843
  controller.enqueue({
4437
4844
  type: "finish",
4438
4845
  finishReason,
4439
- usage: convertAnthropicMessagesUsage({ usage, rawUsage }),
4846
+ usage: convertAnthropicUsage({ usage, rawUsage }),
4440
4847
  providerMetadata
4441
4848
  });
4442
4849
  return;
@@ -4463,7 +4870,7 @@ var AnthropicMessagesLanguageModel = class {
4463
4870
  }
4464
4871
  if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
4465
4872
  const error = result.value.error;
4466
- throw new import_provider3.APICallError({
4873
+ throw new APICallError({
4467
4874
  message: error.message,
4468
4875
  url,
4469
4876
  requestBodyValues: body,
@@ -4486,46 +4893,76 @@ var AnthropicMessagesLanguageModel = class {
4486
4893
  }
4487
4894
  };
4488
4895
  function getModelCapabilities(modelId) {
4489
- if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4896
+ if (modelId.includes("claude-opus-4-7")) {
4897
+ return {
4898
+ maxOutputTokens: 128e3,
4899
+ supportsStructuredOutput: true,
4900
+ supportsAdaptiveThinking: true,
4901
+ rejectsSamplingParameters: true,
4902
+ supportsXhighEffort: true,
4903
+ isKnownModel: true
4904
+ };
4905
+ } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
4490
4906
  return {
4491
4907
  maxOutputTokens: 128e3,
4492
4908
  supportsStructuredOutput: true,
4909
+ supportsAdaptiveThinking: true,
4910
+ rejectsSamplingParameters: false,
4911
+ supportsXhighEffort: false,
4493
4912
  isKnownModel: true
4494
4913
  };
4495
4914
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
4496
4915
  return {
4497
4916
  maxOutputTokens: 64e3,
4498
4917
  supportsStructuredOutput: true,
4918
+ supportsAdaptiveThinking: false,
4919
+ rejectsSamplingParameters: false,
4920
+ supportsXhighEffort: false,
4499
4921
  isKnownModel: true
4500
4922
  };
4501
4923
  } else if (modelId.includes("claude-opus-4-1")) {
4502
4924
  return {
4503
4925
  maxOutputTokens: 32e3,
4504
4926
  supportsStructuredOutput: true,
4927
+ supportsAdaptiveThinking: false,
4928
+ rejectsSamplingParameters: false,
4929
+ supportsXhighEffort: false,
4505
4930
  isKnownModel: true
4506
4931
  };
4507
4932
  } else if (modelId.includes("claude-sonnet-4-")) {
4508
4933
  return {
4509
4934
  maxOutputTokens: 64e3,
4510
4935
  supportsStructuredOutput: false,
4936
+ supportsAdaptiveThinking: false,
4937
+ rejectsSamplingParameters: false,
4938
+ supportsXhighEffort: false,
4511
4939
  isKnownModel: true
4512
4940
  };
4513
4941
  } else if (modelId.includes("claude-opus-4-")) {
4514
4942
  return {
4515
4943
  maxOutputTokens: 32e3,
4516
4944
  supportsStructuredOutput: false,
4945
+ supportsAdaptiveThinking: false,
4946
+ rejectsSamplingParameters: false,
4947
+ supportsXhighEffort: false,
4517
4948
  isKnownModel: true
4518
4949
  };
4519
4950
  } else if (modelId.includes("claude-3-haiku")) {
4520
4951
  return {
4521
4952
  maxOutputTokens: 4096,
4522
4953
  supportsStructuredOutput: false,
4954
+ supportsAdaptiveThinking: false,
4955
+ rejectsSamplingParameters: false,
4956
+ supportsXhighEffort: false,
4523
4957
  isKnownModel: true
4524
4958
  };
4525
4959
  } else {
4526
4960
  return {
4527
4961
  maxOutputTokens: 4096,
4528
4962
  supportsStructuredOutput: false,
4963
+ supportsAdaptiveThinking: false,
4964
+ rejectsSamplingParameters: false,
4965
+ supportsXhighEffort: false,
4529
4966
  isKnownModel: false
4530
4967
  };
4531
4968
  }
@@ -4548,6 +4985,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
4548
4985
  }
4549
4986
  return hasWebTool20260209 && !hasCodeExecutionTool;
4550
4987
  }
4988
+ function resolveAnthropicReasoningConfig({
4989
+ reasoning,
4990
+ supportsAdaptiveThinking,
4991
+ supportsXhighEffort,
4992
+ maxOutputTokensForModel,
4993
+ warnings
4994
+ }) {
4995
+ if (!isCustomReasoning(reasoning)) {
4996
+ return void 0;
4997
+ }
4998
+ if (reasoning === "none") {
4999
+ return { thinking: { type: "disabled" } };
5000
+ }
5001
+ if (supportsAdaptiveThinking) {
5002
+ const effort = mapReasoningToProviderEffort({
5003
+ reasoning,
5004
+ effortMap: {
5005
+ minimal: "low",
5006
+ low: "low",
5007
+ medium: "medium",
5008
+ high: "high",
5009
+ xhigh: supportsXhighEffort ? "xhigh" : "max"
5010
+ },
5011
+ warnings
5012
+ });
5013
+ return { thinking: { type: "adaptive" }, effort };
5014
+ }
5015
+ const budgetTokens = mapReasoningToProviderBudget({
5016
+ reasoning,
5017
+ maxOutputTokens: maxOutputTokensForModel,
5018
+ maxReasoningBudget: maxOutputTokensForModel,
5019
+ warnings
5020
+ });
5021
+ if (budgetTokens == null) {
5022
+ return void 0;
5023
+ }
5024
+ return { thinking: { type: "enabled", budgetTokens } };
5025
+ }
4551
5026
  function mapAnthropicResponseContextManagement(contextManagement) {
4552
5027
  return contextManagement ? {
4553
5028
  appliedEdits: contextManagement.applied_edits.map((edit) => {
@@ -4575,44 +5050,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
4575
5050
  }
4576
5051
 
4577
5052
  // 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()
5053
+ import {
5054
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
5055
+ lazySchema as lazySchema13,
5056
+ zodSchema as zodSchema13
5057
+ } from "@ai-sdk/provider-utils";
5058
+ import { z as z14 } from "zod/v4";
5059
+ var bash_20241022InputSchema = lazySchema13(
5060
+ () => zodSchema13(
5061
+ z14.object({
5062
+ command: z14.string(),
5063
+ restart: z14.boolean().optional()
4585
5064
  })
4586
5065
  )
4587
5066
  );
4588
- var bash_20241022 = (0, import_provider_utils16.createProviderToolFactory)({
5067
+ var bash_20241022 = createProviderDefinedToolFactory2({
4589
5068
  id: "anthropic.bash_20241022",
4590
5069
  inputSchema: bash_20241022InputSchema
4591
5070
  });
4592
5071
 
4593
5072
  // 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()
5073
+ import {
5074
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
5075
+ lazySchema as lazySchema14,
5076
+ zodSchema as zodSchema14
5077
+ } from "@ai-sdk/provider-utils";
5078
+ import { z as z15 } from "zod/v4";
5079
+ var bash_20250124InputSchema = lazySchema14(
5080
+ () => zodSchema14(
5081
+ z15.object({
5082
+ command: z15.string(),
5083
+ restart: z15.boolean().optional()
4601
5084
  })
4602
5085
  )
4603
5086
  );
4604
- var bash_20250124 = (0, import_provider_utils17.createProviderToolFactory)({
5087
+ var bash_20250124 = createProviderDefinedToolFactory3({
4605
5088
  id: "anthropic.bash_20250124",
4606
5089
  inputSchema: bash_20250124InputSchema
4607
5090
  });
4608
5091
 
4609
5092
  // 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([
5093
+ import {
5094
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
5095
+ lazySchema as lazySchema15,
5096
+ zodSchema as zodSchema15
5097
+ } from "@ai-sdk/provider-utils";
5098
+ import { z as z16 } from "zod/v4";
5099
+ var computer_20241022InputSchema = lazySchema15(
5100
+ () => zodSchema15(
5101
+ z16.object({
5102
+ action: z16.enum([
4616
5103
  "key",
4617
5104
  "type",
4618
5105
  "mouse_move",
@@ -4624,23 +5111,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
4624
5111
  "screenshot",
4625
5112
  "cursor_position"
4626
5113
  ]),
4627
- coordinate: import_v415.z.array(import_v415.z.number().int()).optional(),
4628
- text: import_v415.z.string().optional()
5114
+ coordinate: z16.array(z16.number().int()).optional(),
5115
+ text: z16.string().optional()
4629
5116
  })
4630
5117
  )
4631
5118
  );
4632
- var computer_20241022 = (0, import_provider_utils18.createProviderToolFactory)({
5119
+ var computer_20241022 = createProviderDefinedToolFactory4({
4633
5120
  id: "anthropic.computer_20241022",
4634
5121
  inputSchema: computer_20241022InputSchema
4635
5122
  });
4636
5123
 
4637
5124
  // 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([
5125
+ import {
5126
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
5127
+ lazySchema as lazySchema16,
5128
+ zodSchema as zodSchema16
5129
+ } from "@ai-sdk/provider-utils";
5130
+ import { z as z17 } from "zod/v4";
5131
+ var computer_20250124InputSchema = lazySchema16(
5132
+ () => zodSchema16(
5133
+ z17.object({
5134
+ action: z17.enum([
4644
5135
  "key",
4645
5136
  "hold_key",
4646
5137
  "type",
@@ -4658,27 +5149,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
4658
5149
  "wait",
4659
5150
  "screenshot"
4660
5151
  ]),
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()
5152
+ coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5153
+ duration: z17.number().optional(),
5154
+ scroll_amount: z17.number().optional(),
5155
+ scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
5156
+ start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
5157
+ text: z17.string().optional()
4667
5158
  })
4668
5159
  )
4669
5160
  );
4670
- var computer_20250124 = (0, import_provider_utils19.createProviderToolFactory)({
5161
+ var computer_20250124 = createProviderDefinedToolFactory5({
4671
5162
  id: "anthropic.computer_20250124",
4672
5163
  inputSchema: computer_20250124InputSchema
4673
5164
  });
4674
5165
 
4675
5166
  // 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([
5167
+ import {
5168
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
5169
+ lazySchema as lazySchema17,
5170
+ zodSchema as zodSchema17
5171
+ } from "@ai-sdk/provider-utils";
5172
+ import { z as z18 } from "zod/v4";
5173
+ var computer_20251124InputSchema = lazySchema17(
5174
+ () => zodSchema17(
5175
+ z18.object({
5176
+ action: z18.enum([
4682
5177
  "key",
4683
5178
  "hold_key",
4684
5179
  "type",
@@ -4697,166 +5192,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
4697
5192
  "screenshot",
4698
5193
  "zoom"
4699
5194
  ]),
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()
5195
+ coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
5196
+ duration: z18.number().optional(),
5197
+ region: z18.tuple([
5198
+ z18.number().int(),
5199
+ z18.number().int(),
5200
+ z18.number().int(),
5201
+ z18.number().int()
4707
5202
  ]).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()
5203
+ scroll_amount: z18.number().optional(),
5204
+ scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
5205
+ start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
5206
+ text: z18.string().optional()
4712
5207
  })
4713
5208
  )
4714
5209
  );
4715
- var computer_20251124 = (0, import_provider_utils20.createProviderToolFactory)({
5210
+ var computer_20251124 = createProviderDefinedToolFactory6({
4716
5211
  id: "anthropic.computer_20251124",
4717
5212
  inputSchema: computer_20251124InputSchema
4718
5213
  });
4719
5214
 
4720
5215
  // 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()
5216
+ import {
5217
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
5218
+ lazySchema as lazySchema18,
5219
+ zodSchema as zodSchema18
5220
+ } from "@ai-sdk/provider-utils";
5221
+ import { z as z19 } from "zod/v4";
5222
+ var memory_20250818InputSchema = lazySchema18(
5223
+ () => zodSchema18(
5224
+ z19.discriminatedUnion("command", [
5225
+ z19.object({
5226
+ command: z19.literal("view"),
5227
+ path: z19.string(),
5228
+ view_range: z19.tuple([z19.number(), z19.number()]).optional()
4730
5229
  }),
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()
5230
+ z19.object({
5231
+ command: z19.literal("create"),
5232
+ path: z19.string(),
5233
+ file_text: z19.string()
4735
5234
  }),
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()
5235
+ z19.object({
5236
+ command: z19.literal("str_replace"),
5237
+ path: z19.string(),
5238
+ old_str: z19.string(),
5239
+ new_str: z19.string()
4741
5240
  }),
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()
5241
+ z19.object({
5242
+ command: z19.literal("insert"),
5243
+ path: z19.string(),
5244
+ insert_line: z19.number(),
5245
+ insert_text: z19.string()
4747
5246
  }),
4748
- import_v418.z.object({
4749
- command: import_v418.z.literal("delete"),
4750
- path: import_v418.z.string()
5247
+ z19.object({
5248
+ command: z19.literal("delete"),
5249
+ path: z19.string()
4751
5250
  }),
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()
5251
+ z19.object({
5252
+ command: z19.literal("rename"),
5253
+ old_path: z19.string(),
5254
+ new_path: z19.string()
4756
5255
  })
4757
5256
  ])
4758
5257
  )
4759
5258
  );
4760
- var memory_20250818 = (0, import_provider_utils21.createProviderToolFactory)({
5259
+ var memory_20250818 = createProviderDefinedToolFactory7({
4761
5260
  id: "anthropic.memory_20250818",
4762
5261
  inputSchema: memory_20250818InputSchema
4763
5262
  });
4764
5263
 
4765
5264
  // 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()
5265
+ import {
5266
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
5267
+ lazySchema as lazySchema19,
5268
+ zodSchema as zodSchema19
5269
+ } from "@ai-sdk/provider-utils";
5270
+ import { z as z20 } from "zod/v4";
5271
+ var textEditor_20241022InputSchema = lazySchema19(
5272
+ () => zodSchema19(
5273
+ z20.object({
5274
+ command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5275
+ path: z20.string(),
5276
+ file_text: z20.string().optional(),
5277
+ insert_line: z20.number().int().optional(),
5278
+ new_str: z20.string().optional(),
5279
+ insert_text: z20.string().optional(),
5280
+ old_str: z20.string().optional(),
5281
+ view_range: z20.array(z20.number().int()).optional()
4779
5282
  })
4780
5283
  )
4781
5284
  );
4782
- var textEditor_20241022 = (0, import_provider_utils22.createProviderToolFactory)({
5285
+ var textEditor_20241022 = createProviderDefinedToolFactory8({
4783
5286
  id: "anthropic.text_editor_20241022",
4784
5287
  inputSchema: textEditor_20241022InputSchema
4785
5288
  });
4786
5289
 
4787
5290
  // 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()
5291
+ import {
5292
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
5293
+ lazySchema as lazySchema20,
5294
+ zodSchema as zodSchema20
5295
+ } from "@ai-sdk/provider-utils";
5296
+ import { z as z21 } from "zod/v4";
5297
+ var textEditor_20250124InputSchema = lazySchema20(
5298
+ () => zodSchema20(
5299
+ z21.object({
5300
+ command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
5301
+ path: z21.string(),
5302
+ file_text: z21.string().optional(),
5303
+ insert_line: z21.number().int().optional(),
5304
+ new_str: z21.string().optional(),
5305
+ insert_text: z21.string().optional(),
5306
+ old_str: z21.string().optional(),
5307
+ view_range: z21.array(z21.number().int()).optional()
4801
5308
  })
4802
5309
  )
4803
5310
  );
4804
- var textEditor_20250124 = (0, import_provider_utils23.createProviderToolFactory)({
5311
+ var textEditor_20250124 = createProviderDefinedToolFactory9({
4805
5312
  id: "anthropic.text_editor_20250124",
4806
5313
  inputSchema: textEditor_20250124InputSchema
4807
5314
  });
4808
5315
 
4809
5316
  // 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()
5317
+ import {
5318
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory10,
5319
+ lazySchema as lazySchema21,
5320
+ zodSchema as zodSchema21
5321
+ } from "@ai-sdk/provider-utils";
5322
+ import { z as z22 } from "zod/v4";
5323
+ var textEditor_20250429InputSchema = lazySchema21(
5324
+ () => zodSchema21(
5325
+ z22.object({
5326
+ command: z22.enum(["view", "create", "str_replace", "insert"]),
5327
+ path: z22.string(),
5328
+ file_text: z22.string().optional(),
5329
+ insert_line: z22.number().int().optional(),
5330
+ new_str: z22.string().optional(),
5331
+ insert_text: z22.string().optional(),
5332
+ old_str: z22.string().optional(),
5333
+ view_range: z22.array(z22.number().int()).optional()
4823
5334
  })
4824
5335
  )
4825
5336
  );
4826
- var textEditor_20250429 = (0, import_provider_utils24.createProviderToolFactory)({
5337
+ var textEditor_20250429 = createProviderDefinedToolFactory10({
4827
5338
  id: "anthropic.text_editor_20250429",
4828
5339
  inputSchema: textEditor_20250429InputSchema
4829
5340
  });
4830
5341
 
4831
5342
  // 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()
5343
+ import {
5344
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory9,
5345
+ lazySchema as lazySchema22,
5346
+ zodSchema as zodSchema22
5347
+ } from "@ai-sdk/provider-utils";
5348
+ import { z as z23 } from "zod/v4";
5349
+ var toolSearchBm25_20251119OutputSchema = lazySchema22(
5350
+ () => zodSchema22(
5351
+ z23.array(
5352
+ z23.object({
5353
+ type: z23.literal("tool_reference"),
5354
+ toolName: z23.string()
4840
5355
  })
4841
5356
  )
4842
5357
  )
4843
5358
  );
4844
- var toolSearchBm25_20251119InputSchema = (0, import_provider_utils25.lazySchema)(
4845
- () => (0, import_provider_utils25.zodSchema)(
4846
- import_v422.z.object({
5359
+ var toolSearchBm25_20251119InputSchema = lazySchema22(
5360
+ () => zodSchema22(
5361
+ z23.object({
4847
5362
  /**
4848
5363
  * A natural language query to search for tools.
4849
5364
  * Claude will use BM25 text search to find relevant tools.
4850
5365
  */
4851
- query: import_v422.z.string(),
5366
+ query: z23.string(),
4852
5367
  /**
4853
5368
  * Maximum number of tools to return. Optional.
4854
5369
  */
4855
- limit: import_v422.z.number().optional()
5370
+ limit: z23.number().optional()
4856
5371
  })
4857
5372
  )
4858
5373
  );
4859
- var factory10 = (0, import_provider_utils25.createProviderToolFactoryWithOutputSchema)({
5374
+ var factory10 = createProviderExecutedToolFactory9({
4860
5375
  id: "anthropic.tool_search_bm25_20251119",
4861
5376
  inputSchema: toolSearchBm25_20251119InputSchema,
4862
5377
  outputSchema: toolSearchBm25_20251119OutputSchema,
@@ -5068,31 +5583,163 @@ var anthropicTools = {
5068
5583
  toolSearchBm25_20251119
5069
5584
  };
5070
5585
 
5586
+ // src/skills/anthropic-skills.ts
5587
+ import {
5588
+ combineHeaders as combineHeaders3,
5589
+ convertBase64ToUint8Array as convertBase64ToUint8Array3,
5590
+ createJsonResponseHandler as createJsonResponseHandler3,
5591
+ getFromApi,
5592
+ postFormDataToApi as postFormDataToApi2,
5593
+ resolve as resolve2
5594
+ } from "@ai-sdk/provider-utils";
5595
+
5596
+ // src/skills/anthropic-skills-api.ts
5597
+ import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
5598
+ import { z as z24 } from "zod/v4";
5599
+ var anthropicSkillResponseSchema = lazySchema23(
5600
+ () => zodSchema23(
5601
+ z24.object({
5602
+ id: z24.string(),
5603
+ display_title: z24.string().nullish(),
5604
+ name: z24.string().nullish(),
5605
+ description: z24.string().nullish(),
5606
+ latest_version: z24.string().nullish(),
5607
+ source: z24.string(),
5608
+ created_at: z24.string(),
5609
+ updated_at: z24.string()
5610
+ })
5611
+ )
5612
+ );
5613
+ var anthropicSkillVersionListResponseSchema = lazySchema23(
5614
+ () => zodSchema23(
5615
+ z24.object({
5616
+ data: z24.array(
5617
+ z24.object({
5618
+ version: z24.string()
5619
+ })
5620
+ )
5621
+ })
5622
+ )
5623
+ );
5624
+ var anthropicSkillVersionResponseSchema = lazySchema23(
5625
+ () => zodSchema23(
5626
+ z24.object({
5627
+ type: z24.string(),
5628
+ skill_id: z24.string(),
5629
+ name: z24.string().nullish(),
5630
+ description: z24.string().nullish()
5631
+ })
5632
+ )
5633
+ );
5634
+
5635
+ // src/skills/anthropic-skills.ts
5636
+ var AnthropicSkills = class {
5637
+ constructor(config) {
5638
+ this.config = config;
5639
+ this.specificationVersion = "v4";
5640
+ }
5641
+ get provider() {
5642
+ return this.config.provider;
5643
+ }
5644
+ async getHeaders() {
5645
+ return combineHeaders3(await resolve2(this.config.headers), {
5646
+ "anthropic-beta": "skills-2025-10-02"
5647
+ });
5648
+ }
5649
+ async fetchVersionMetadata({
5650
+ skillId,
5651
+ version,
5652
+ headers
5653
+ }) {
5654
+ const { value: versionResponse } = await getFromApi({
5655
+ url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
5656
+ headers,
5657
+ failedResponseHandler: anthropicFailedResponseHandler,
5658
+ successfulResponseHandler: createJsonResponseHandler3(
5659
+ anthropicSkillVersionResponseSchema
5660
+ ),
5661
+ fetch: this.config.fetch
5662
+ });
5663
+ return {
5664
+ ...versionResponse.name != null ? { name: versionResponse.name } : {},
5665
+ ...versionResponse.description != null ? { description: versionResponse.description } : {}
5666
+ };
5667
+ }
5668
+ async uploadSkill(params) {
5669
+ var _a, _b;
5670
+ const warnings = [];
5671
+ const formData = new FormData();
5672
+ if (params.displayTitle != null) {
5673
+ formData.append("display_title", params.displayTitle);
5674
+ }
5675
+ for (const file of params.files) {
5676
+ const content = typeof file.content === "string" ? convertBase64ToUint8Array3(file.content) : file.content;
5677
+ formData.append("files[]", new Blob([content]), file.path);
5678
+ }
5679
+ const headers = await this.getHeaders();
5680
+ const { value: response } = await postFormDataToApi2({
5681
+ url: `${this.config.baseURL}/skills`,
5682
+ headers,
5683
+ formData,
5684
+ failedResponseHandler: anthropicFailedResponseHandler,
5685
+ successfulResponseHandler: createJsonResponseHandler3(
5686
+ anthropicSkillResponseSchema
5687
+ ),
5688
+ fetch: this.config.fetch
5689
+ });
5690
+ const versionMetadata = response.latest_version != null ? await this.fetchVersionMetadata({
5691
+ skillId: response.id,
5692
+ version: response.latest_version,
5693
+ headers
5694
+ }) : {};
5695
+ const name = (_a = versionMetadata.name) != null ? _a : response.name;
5696
+ const description = (_b = versionMetadata.description) != null ? _b : response.description;
5697
+ return {
5698
+ providerReference: { anthropic: response.id },
5699
+ ...response.display_title != null ? { displayTitle: response.display_title } : {},
5700
+ ...name != null ? { name } : {},
5701
+ ...description != null ? { description } : {},
5702
+ ...response.latest_version != null ? { latestVersion: response.latest_version } : {},
5703
+ providerMetadata: {
5704
+ anthropic: {
5705
+ ...response.source != null ? { source: response.source } : {},
5706
+ ...response.created_at != null ? { createdAt: response.created_at } : {},
5707
+ ...response.updated_at != null ? { updatedAt: response.updated_at } : {}
5708
+ }
5709
+ },
5710
+ warnings
5711
+ };
5712
+ }
5713
+ };
5714
+
5715
+ // src/version.ts
5716
+ var VERSION = true ? "4.0.0-beta.40" : "0.0.0-test";
5717
+
5071
5718
  // src/anthropic-provider.ts
5072
5719
  function createAnthropic(options = {}) {
5073
5720
  var _a, _b;
5074
- const baseURL = (_a = (0, import_provider_utils26.withoutTrailingSlash)(
5075
- (0, import_provider_utils26.loadOptionalSetting)({
5721
+ const baseURL = (_a = withoutTrailingSlash(
5722
+ loadOptionalSetting({
5076
5723
  settingValue: options.baseURL,
5077
5724
  environmentVariableName: "ANTHROPIC_BASE_URL"
5078
5725
  })
5079
5726
  )) != null ? _a : "https://api.anthropic.com/v1";
5080
5727
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
5081
5728
  if (options.apiKey && options.authToken) {
5082
- throw new import_provider4.InvalidArgumentError({
5729
+ throw new InvalidArgumentError({
5083
5730
  argument: "apiKey/authToken",
5084
5731
  message: "Both apiKey and authToken were provided. Please use only one authentication method."
5085
5732
  });
5086
5733
  }
5087
5734
  const getHeaders = () => {
5088
5735
  const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
5089
- "x-api-key": (0, import_provider_utils26.loadApiKey)({
5736
+ "x-api-key": loadApiKey({
5090
5737
  apiKey: options.apiKey,
5091
5738
  environmentVariableName: "ANTHROPIC_API_KEY",
5092
5739
  description: "Anthropic"
5093
5740
  })
5094
5741
  };
5095
- return (0, import_provider_utils26.withUserAgentSuffix)(
5742
+ return withUserAgentSuffix(
5096
5743
  {
5097
5744
  "anthropic-version": "2023-06-01",
5098
5745
  ...authHeaders,
@@ -5103,18 +5750,24 @@ function createAnthropic(options = {}) {
5103
5750
  };
5104
5751
  const createChatModel = (modelId) => {
5105
5752
  var _a2;
5106
- return new AnthropicMessagesLanguageModel(modelId, {
5753
+ return new AnthropicLanguageModel(modelId, {
5107
5754
  provider: providerName,
5108
5755
  baseURL,
5109
5756
  headers: getHeaders,
5110
5757
  fetch: options.fetch,
5111
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils26.generateId,
5758
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
5112
5759
  supportedUrls: () => ({
5113
5760
  "image/*": [/^https?:\/\/.*$/],
5114
5761
  "application/pdf": [/^https?:\/\/.*$/]
5115
5762
  })
5116
5763
  });
5117
5764
  };
5765
+ const createSkills = () => new AnthropicSkills({
5766
+ provider: `${providerName.replace(".messages", "")}.skills`,
5767
+ baseURL,
5768
+ headers: getHeaders,
5769
+ fetch: options.fetch
5770
+ });
5118
5771
  const provider = function(modelId) {
5119
5772
  if (new.target) {
5120
5773
  throw new Error(
@@ -5128,12 +5781,19 @@ function createAnthropic(options = {}) {
5128
5781
  provider.chat = createChatModel;
5129
5782
  provider.messages = createChatModel;
5130
5783
  provider.embeddingModel = (modelId) => {
5131
- throw new import_provider4.NoSuchModelError({ modelId, modelType: "embeddingModel" });
5784
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
5132
5785
  };
5133
5786
  provider.textEmbeddingModel = provider.embeddingModel;
5134
5787
  provider.imageModel = (modelId) => {
5135
- throw new import_provider4.NoSuchModelError({ modelId, modelType: "imageModel" });
5788
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
5136
5789
  };
5790
+ provider.files = () => new AnthropicFiles({
5791
+ provider: providerName,
5792
+ baseURL,
5793
+ headers: getHeaders,
5794
+ fetch: options.fetch
5795
+ });
5796
+ provider.skills = createSkills;
5137
5797
  provider.tools = anthropicTools;
5138
5798
  return provider;
5139
5799
  }
@@ -5158,11 +5818,10 @@ function forwardAnthropicContainerIdFromLastStep({
5158
5818
  }
5159
5819
  return void 0;
5160
5820
  }
5161
- // Annotate the CommonJS export names for ESM import in node:
5162
- 0 && (module.exports = {
5821
+ export {
5163
5822
  VERSION,
5164
5823
  anthropic,
5165
5824
  createAnthropic,
5166
5825
  forwardAnthropicContainerIdFromLastStep
5167
- });
5826
+ };
5168
5827
  //# sourceMappingURL=index.js.map