@ai-sdk/anthropic 2.1.0-beta.3 → 2.1.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.d.mts +105 -3
- package/dist/index.d.ts +105 -3
- package/dist/index.js +651 -377
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +631 -357
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +122 -6
- package/dist/internal/index.d.ts +122 -6
- package/dist/internal/index.js +645 -371
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +630 -356
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -38,15 +38,15 @@ module.exports = __toCommonJS(src_exports);
|
|
|
38
38
|
|
|
39
39
|
// src/anthropic-provider.ts
|
|
40
40
|
var import_provider4 = require("@ai-sdk/provider");
|
|
41
|
-
var
|
|
41
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
42
42
|
|
|
43
43
|
// src/version.ts
|
|
44
|
-
var VERSION = true ? "2.1.0-beta.
|
|
44
|
+
var VERSION = true ? "2.1.0-beta.5" : "0.0.0-test";
|
|
45
45
|
|
|
46
46
|
// src/anthropic-messages-language-model.ts
|
|
47
47
|
var import_provider3 = require("@ai-sdk/provider");
|
|
48
|
-
var
|
|
49
|
-
var
|
|
48
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
49
|
+
var import_v47 = require("zod/v4");
|
|
50
50
|
|
|
51
51
|
// src/anthropic-error.ts
|
|
52
52
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
@@ -120,58 +120,110 @@ function getCacheControl(providerMetadata) {
|
|
|
120
120
|
return cacheControlValue;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
// src/tool/
|
|
123
|
+
// src/tool/text-editor_20250728.ts
|
|
124
124
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
125
125
|
var import_v43 = require("zod/v4");
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
126
|
+
var textEditor_20250728ArgsSchema = import_v43.z.object({
|
|
127
|
+
maxCharacters: import_v43.z.number().optional()
|
|
128
|
+
});
|
|
129
|
+
var factory = (0, import_provider_utils2.createProviderDefinedToolFactory)({
|
|
130
|
+
id: "anthropic.text_editor_20250728",
|
|
131
|
+
name: "str_replace_based_edit_tool",
|
|
132
|
+
inputSchema: import_v43.z.object({
|
|
133
|
+
command: import_v43.z.enum(["view", "create", "str_replace", "insert"]),
|
|
134
|
+
path: import_v43.z.string(),
|
|
135
|
+
file_text: import_v43.z.string().optional(),
|
|
136
|
+
insert_line: import_v43.z.number().int().optional(),
|
|
137
|
+
new_str: import_v43.z.string().optional(),
|
|
138
|
+
old_str: import_v43.z.string().optional(),
|
|
139
|
+
view_range: import_v43.z.array(import_v43.z.number().int()).optional()
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
var textEditor_20250728 = (args = {}) => {
|
|
143
|
+
return factory(args);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// src/tool/web-search_20250305.ts
|
|
147
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
148
|
+
var import_v44 = require("zod/v4");
|
|
149
|
+
var webSearch_20250305ArgsSchema = import_v44.z.object({
|
|
150
|
+
maxUses: import_v44.z.number().optional(),
|
|
151
|
+
allowedDomains: import_v44.z.array(import_v44.z.string()).optional(),
|
|
152
|
+
blockedDomains: import_v44.z.array(import_v44.z.string()).optional(),
|
|
153
|
+
userLocation: import_v44.z.object({
|
|
154
|
+
type: import_v44.z.literal("approximate"),
|
|
155
|
+
city: import_v44.z.string().optional(),
|
|
156
|
+
region: import_v44.z.string().optional(),
|
|
157
|
+
country: import_v44.z.string().optional(),
|
|
158
|
+
timezone: import_v44.z.string().optional()
|
|
148
159
|
}).optional()
|
|
149
160
|
});
|
|
150
|
-
var webSearch_20250305OutputSchema =
|
|
151
|
-
|
|
152
|
-
url:
|
|
153
|
-
title:
|
|
154
|
-
pageAge:
|
|
155
|
-
encryptedContent:
|
|
156
|
-
type:
|
|
161
|
+
var webSearch_20250305OutputSchema = import_v44.z.array(
|
|
162
|
+
import_v44.z.object({
|
|
163
|
+
url: import_v44.z.string(),
|
|
164
|
+
title: import_v44.z.string(),
|
|
165
|
+
pageAge: import_v44.z.string().nullable(),
|
|
166
|
+
encryptedContent: import_v44.z.string(),
|
|
167
|
+
type: import_v44.z.literal("web_search_result")
|
|
157
168
|
})
|
|
158
169
|
);
|
|
159
|
-
var
|
|
170
|
+
var factory2 = (0, import_provider_utils3.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
160
171
|
id: "anthropic.web_search_20250305",
|
|
161
172
|
name: "web_search",
|
|
162
|
-
inputSchema:
|
|
163
|
-
query:
|
|
173
|
+
inputSchema: import_v44.z.object({
|
|
174
|
+
query: import_v44.z.string()
|
|
164
175
|
}),
|
|
165
176
|
outputSchema: webSearch_20250305OutputSchema
|
|
166
177
|
});
|
|
167
178
|
var webSearch_20250305 = (args = {}) => {
|
|
168
|
-
return
|
|
179
|
+
return factory2(args);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/tool/web-fetch-20250910.ts
|
|
183
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
184
|
+
var import_v45 = require("zod/v4");
|
|
185
|
+
var webFetch_20250910ArgsSchema = import_v45.z.object({
|
|
186
|
+
maxUses: import_v45.z.number().optional(),
|
|
187
|
+
allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
|
|
188
|
+
blockedDomains: import_v45.z.array(import_v45.z.string()).optional(),
|
|
189
|
+
citations: import_v45.z.object({ enabled: import_v45.z.boolean() }).optional(),
|
|
190
|
+
maxContentTokens: import_v45.z.number().optional()
|
|
191
|
+
});
|
|
192
|
+
var webFetch_20250910OutputSchema = import_v45.z.object({
|
|
193
|
+
type: import_v45.z.literal("web_fetch_result"),
|
|
194
|
+
url: import_v45.z.string(),
|
|
195
|
+
content: import_v45.z.object({
|
|
196
|
+
type: import_v45.z.literal("document"),
|
|
197
|
+
title: import_v45.z.string(),
|
|
198
|
+
citations: import_v45.z.object({ enabled: import_v45.z.boolean() }).optional(),
|
|
199
|
+
source: import_v45.z.union([
|
|
200
|
+
import_v45.z.object({
|
|
201
|
+
type: import_v45.z.literal("base64"),
|
|
202
|
+
mediaType: import_v45.z.literal("application/pdf"),
|
|
203
|
+
data: import_v45.z.string()
|
|
204
|
+
}),
|
|
205
|
+
import_v45.z.object({
|
|
206
|
+
type: import_v45.z.literal("text"),
|
|
207
|
+
mediaType: import_v45.z.literal("text/plain"),
|
|
208
|
+
data: import_v45.z.string()
|
|
209
|
+
})
|
|
210
|
+
])
|
|
211
|
+
}),
|
|
212
|
+
retrievedAt: import_v45.z.string().nullable()
|
|
213
|
+
});
|
|
214
|
+
var factory3 = (0, import_provider_utils4.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
215
|
+
id: "anthropic.web_fetch_20250910",
|
|
216
|
+
name: "web_fetch",
|
|
217
|
+
inputSchema: import_v45.z.object({
|
|
218
|
+
url: import_v45.z.string()
|
|
219
|
+
}),
|
|
220
|
+
outputSchema: webFetch_20250910OutputSchema
|
|
221
|
+
});
|
|
222
|
+
var webFetch_20250910 = (args = {}) => {
|
|
223
|
+
return factory3(args);
|
|
169
224
|
};
|
|
170
225
|
|
|
171
226
|
// src/anthropic-prepare-tools.ts
|
|
172
|
-
function isWebSearchTool(tool) {
|
|
173
|
-
return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
|
|
174
|
-
}
|
|
175
227
|
function prepareTools({
|
|
176
228
|
tools,
|
|
177
229
|
toolChoice,
|
|
@@ -185,12 +237,8 @@ function prepareTools({
|
|
|
185
237
|
}
|
|
186
238
|
const anthropicTools2 = [];
|
|
187
239
|
for (const tool of tools) {
|
|
188
|
-
if (isWebSearchTool(tool)) {
|
|
189
|
-
anthropicTools2.push(tool);
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
240
|
switch (tool.type) {
|
|
193
|
-
case "function":
|
|
241
|
+
case "function": {
|
|
194
242
|
const cacheControl = getCacheControl(tool.providerOptions);
|
|
195
243
|
anthropicTools2.push({
|
|
196
244
|
name: tool.name,
|
|
@@ -199,9 +247,18 @@ function prepareTools({
|
|
|
199
247
|
cache_control: cacheControl
|
|
200
248
|
});
|
|
201
249
|
break;
|
|
202
|
-
|
|
250
|
+
}
|
|
251
|
+
case "provider-defined": {
|
|
203
252
|
switch (tool.id) {
|
|
204
|
-
case "anthropic.
|
|
253
|
+
case "anthropic.code_execution_20250522": {
|
|
254
|
+
betas.add("code-execution-2025-05-22");
|
|
255
|
+
anthropicTools2.push({
|
|
256
|
+
type: "code_execution_20250522",
|
|
257
|
+
name: "code_execution"
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case "anthropic.computer_20250124": {
|
|
205
262
|
betas.add("computer-use-2025-01-24");
|
|
206
263
|
anthropicTools2.push({
|
|
207
264
|
name: "computer",
|
|
@@ -211,7 +268,8 @@ function prepareTools({
|
|
|
211
268
|
display_number: tool.args.displayNumber
|
|
212
269
|
});
|
|
213
270
|
break;
|
|
214
|
-
|
|
271
|
+
}
|
|
272
|
+
case "anthropic.computer_20241022": {
|
|
215
273
|
betas.add("computer-use-2024-10-22");
|
|
216
274
|
anthropicTools2.push({
|
|
217
275
|
name: "computer",
|
|
@@ -221,41 +279,70 @@ function prepareTools({
|
|
|
221
279
|
display_number: tool.args.displayNumber
|
|
222
280
|
});
|
|
223
281
|
break;
|
|
224
|
-
|
|
282
|
+
}
|
|
283
|
+
case "anthropic.text_editor_20250124": {
|
|
225
284
|
betas.add("computer-use-2025-01-24");
|
|
226
285
|
anthropicTools2.push({
|
|
227
286
|
name: "str_replace_editor",
|
|
228
287
|
type: "text_editor_20250124"
|
|
229
288
|
});
|
|
230
289
|
break;
|
|
231
|
-
|
|
290
|
+
}
|
|
291
|
+
case "anthropic.text_editor_20241022": {
|
|
232
292
|
betas.add("computer-use-2024-10-22");
|
|
233
293
|
anthropicTools2.push({
|
|
234
294
|
name: "str_replace_editor",
|
|
235
295
|
type: "text_editor_20241022"
|
|
236
296
|
});
|
|
237
297
|
break;
|
|
238
|
-
|
|
298
|
+
}
|
|
299
|
+
case "anthropic.text_editor_20250429": {
|
|
239
300
|
betas.add("computer-use-2025-01-24");
|
|
240
301
|
anthropicTools2.push({
|
|
241
302
|
name: "str_replace_based_edit_tool",
|
|
242
303
|
type: "text_editor_20250429"
|
|
243
304
|
});
|
|
244
305
|
break;
|
|
245
|
-
|
|
306
|
+
}
|
|
307
|
+
case "anthropic.text_editor_20250728": {
|
|
308
|
+
const args = textEditor_20250728ArgsSchema.parse(tool.args);
|
|
309
|
+
anthropicTools2.push({
|
|
310
|
+
name: "str_replace_based_edit_tool",
|
|
311
|
+
type: "text_editor_20250728",
|
|
312
|
+
max_characters: args.maxCharacters
|
|
313
|
+
});
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
case "anthropic.bash_20250124": {
|
|
246
317
|
betas.add("computer-use-2025-01-24");
|
|
247
318
|
anthropicTools2.push({
|
|
248
319
|
name: "bash",
|
|
249
320
|
type: "bash_20250124"
|
|
250
321
|
});
|
|
251
322
|
break;
|
|
252
|
-
|
|
323
|
+
}
|
|
324
|
+
case "anthropic.bash_20241022": {
|
|
253
325
|
betas.add("computer-use-2024-10-22");
|
|
254
326
|
anthropicTools2.push({
|
|
255
327
|
name: "bash",
|
|
256
328
|
type: "bash_20241022"
|
|
257
329
|
});
|
|
258
330
|
break;
|
|
331
|
+
}
|
|
332
|
+
case "anthropic.web_fetch_20250910": {
|
|
333
|
+
betas.add("web-fetch-2025-09-10");
|
|
334
|
+
const args = webFetch_20250910ArgsSchema.parse(tool.args);
|
|
335
|
+
anthropicTools2.push({
|
|
336
|
+
type: "web_fetch_20250910",
|
|
337
|
+
name: "web_fetch",
|
|
338
|
+
max_uses: args.maxUses,
|
|
339
|
+
allowed_domains: args.allowedDomains,
|
|
340
|
+
blocked_domains: args.blockedDomains,
|
|
341
|
+
citations: args.citations,
|
|
342
|
+
max_content_tokens: args.maxContentTokens
|
|
343
|
+
});
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
259
346
|
case "anthropic.web_search_20250305": {
|
|
260
347
|
const args = webSearch_20250305ArgsSchema.parse(tool.args);
|
|
261
348
|
anthropicTools2.push({
|
|
@@ -268,22 +355,17 @@ function prepareTools({
|
|
|
268
355
|
});
|
|
269
356
|
break;
|
|
270
357
|
}
|
|
271
|
-
|
|
272
|
-
betas.add("code-execution-2025-05-22");
|
|
273
|
-
anthropicTools2.push({
|
|
274
|
-
type: "code_execution_20250522",
|
|
275
|
-
name: "code_execution"
|
|
276
|
-
});
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
default:
|
|
358
|
+
default: {
|
|
280
359
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
281
360
|
break;
|
|
361
|
+
}
|
|
282
362
|
}
|
|
283
363
|
break;
|
|
284
|
-
|
|
364
|
+
}
|
|
365
|
+
default: {
|
|
285
366
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
286
367
|
break;
|
|
368
|
+
}
|
|
287
369
|
}
|
|
288
370
|
}
|
|
289
371
|
if (toolChoice == null) {
|
|
@@ -340,27 +422,27 @@ function prepareTools({
|
|
|
340
422
|
|
|
341
423
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
342
424
|
var import_provider2 = require("@ai-sdk/provider");
|
|
343
|
-
var
|
|
425
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
344
426
|
|
|
345
427
|
// src/tool/code-execution_20250522.ts
|
|
346
|
-
var
|
|
347
|
-
var
|
|
348
|
-
var codeExecution_20250522OutputSchema =
|
|
349
|
-
type:
|
|
350
|
-
stdout:
|
|
351
|
-
stderr:
|
|
352
|
-
return_code:
|
|
428
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
429
|
+
var import_v46 = require("zod/v4");
|
|
430
|
+
var codeExecution_20250522OutputSchema = import_v46.z.object({
|
|
431
|
+
type: import_v46.z.literal("code_execution_result"),
|
|
432
|
+
stdout: import_v46.z.string(),
|
|
433
|
+
stderr: import_v46.z.string(),
|
|
434
|
+
return_code: import_v46.z.number()
|
|
353
435
|
});
|
|
354
|
-
var
|
|
436
|
+
var factory4 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
355
437
|
id: "anthropic.code_execution_20250522",
|
|
356
438
|
name: "code_execution",
|
|
357
|
-
inputSchema:
|
|
358
|
-
code:
|
|
439
|
+
inputSchema: import_v46.z.object({
|
|
440
|
+
code: import_v46.z.string()
|
|
359
441
|
}),
|
|
360
442
|
outputSchema: codeExecution_20250522OutputSchema
|
|
361
443
|
});
|
|
362
444
|
var codeExecution_20250522 = (args = {}) => {
|
|
363
|
-
return
|
|
445
|
+
return factory4(args);
|
|
364
446
|
};
|
|
365
447
|
|
|
366
448
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
@@ -392,7 +474,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
392
474
|
const messages = [];
|
|
393
475
|
async function shouldEnableCitations(providerMetadata) {
|
|
394
476
|
var _a2, _b2;
|
|
395
|
-
const anthropicOptions = await (0,
|
|
477
|
+
const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
|
|
396
478
|
provider: "anthropic",
|
|
397
479
|
providerOptions: providerMetadata,
|
|
398
480
|
schema: anthropicFilePartProviderOptions
|
|
@@ -400,7 +482,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
400
482
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
401
483
|
}
|
|
402
484
|
async function getDocumentMetadata(providerMetadata) {
|
|
403
|
-
const anthropicOptions = await (0,
|
|
485
|
+
const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
|
|
404
486
|
provider: "anthropic",
|
|
405
487
|
providerOptions: providerMetadata,
|
|
406
488
|
schema: anthropicFilePartProviderOptions
|
|
@@ -457,7 +539,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
457
539
|
} : {
|
|
458
540
|
type: "base64",
|
|
459
541
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
460
|
-
data: (0,
|
|
542
|
+
data: (0, import_provider_utils6.convertToBase64)(part.data)
|
|
461
543
|
},
|
|
462
544
|
cache_control: cacheControl
|
|
463
545
|
});
|
|
@@ -477,7 +559,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
477
559
|
} : {
|
|
478
560
|
type: "base64",
|
|
479
561
|
media_type: "application/pdf",
|
|
480
|
-
data: (0,
|
|
562
|
+
data: (0, import_provider_utils6.convertToBase64)(part.data)
|
|
481
563
|
},
|
|
482
564
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
483
565
|
...metadata.context && { context: metadata.context },
|
|
@@ -612,7 +694,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
612
694
|
}
|
|
613
695
|
case "reasoning": {
|
|
614
696
|
if (sendReasoning) {
|
|
615
|
-
const reasoningMetadata = await (0,
|
|
697
|
+
const reasoningMetadata = await (0, import_provider_utils6.parseProviderOptions)({
|
|
616
698
|
provider: "anthropic",
|
|
617
699
|
providerOptions: part.providerOptions,
|
|
618
700
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -653,30 +735,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
653
735
|
}
|
|
654
736
|
case "tool-call": {
|
|
655
737
|
if (part.providerExecuted) {
|
|
656
|
-
if (part.toolName === "web_search") {
|
|
738
|
+
if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
657
739
|
anthropicContent.push({
|
|
658
740
|
type: "server_tool_use",
|
|
659
741
|
id: part.toolCallId,
|
|
660
|
-
name:
|
|
742
|
+
name: part.toolName,
|
|
661
743
|
input: part.input,
|
|
662
744
|
cache_control: cacheControl
|
|
663
745
|
});
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
type: "server_tool_use",
|
|
669
|
-
id: part.toolCallId,
|
|
670
|
-
name: "code_execution",
|
|
671
|
-
input: part.input,
|
|
672
|
-
cache_control: cacheControl
|
|
746
|
+
} else {
|
|
747
|
+
warnings.push({
|
|
748
|
+
type: "other",
|
|
749
|
+
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
673
750
|
});
|
|
674
|
-
break;
|
|
675
751
|
}
|
|
676
|
-
warnings.push({
|
|
677
|
-
type: "other",
|
|
678
|
-
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
679
|
-
});
|
|
680
752
|
break;
|
|
681
753
|
}
|
|
682
754
|
anthropicContent.push({
|
|
@@ -689,7 +761,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
689
761
|
break;
|
|
690
762
|
}
|
|
691
763
|
case "tool-result": {
|
|
692
|
-
if (part.toolName === "
|
|
764
|
+
if (part.toolName === "code_execution") {
|
|
693
765
|
const output = part.output;
|
|
694
766
|
if (output.type !== "json") {
|
|
695
767
|
warnings.push({
|
|
@@ -698,24 +770,21 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
698
770
|
});
|
|
699
771
|
break;
|
|
700
772
|
}
|
|
701
|
-
const
|
|
702
|
-
output.value
|
|
703
|
-
);
|
|
773
|
+
const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
|
|
704
774
|
anthropicContent.push({
|
|
705
|
-
type: "
|
|
775
|
+
type: "code_execution_tool_result",
|
|
706
776
|
tool_use_id: part.toolCallId,
|
|
707
|
-
content:
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
})),
|
|
777
|
+
content: {
|
|
778
|
+
type: codeExecutionOutput.type,
|
|
779
|
+
stdout: codeExecutionOutput.stdout,
|
|
780
|
+
stderr: codeExecutionOutput.stderr,
|
|
781
|
+
return_code: codeExecutionOutput.return_code
|
|
782
|
+
},
|
|
714
783
|
cache_control: cacheControl
|
|
715
784
|
});
|
|
716
785
|
break;
|
|
717
786
|
}
|
|
718
|
-
if (part.toolName === "
|
|
787
|
+
if (part.toolName === "web_fetch") {
|
|
719
788
|
const output = part.output;
|
|
720
789
|
if (output.type !== "json") {
|
|
721
790
|
warnings.push({
|
|
@@ -724,20 +793,57 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
724
793
|
});
|
|
725
794
|
break;
|
|
726
795
|
}
|
|
727
|
-
const
|
|
796
|
+
const webFetchOutput = webFetch_20250910OutputSchema.parse(
|
|
797
|
+
output.value
|
|
798
|
+
);
|
|
728
799
|
anthropicContent.push({
|
|
729
|
-
type: "
|
|
800
|
+
type: "web_fetch_tool_result",
|
|
730
801
|
tool_use_id: part.toolCallId,
|
|
731
802
|
content: {
|
|
732
|
-
type:
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
803
|
+
type: "web_fetch_result",
|
|
804
|
+
url: webFetchOutput.url,
|
|
805
|
+
retrieved_at: webFetchOutput.retrievedAt,
|
|
806
|
+
content: {
|
|
807
|
+
type: "document",
|
|
808
|
+
title: webFetchOutput.content.title,
|
|
809
|
+
citations: webFetchOutput.content.citations,
|
|
810
|
+
source: {
|
|
811
|
+
type: webFetchOutput.content.source.type,
|
|
812
|
+
media_type: webFetchOutput.content.source.mediaType,
|
|
813
|
+
data: webFetchOutput.content.source.data
|
|
814
|
+
}
|
|
815
|
+
}
|
|
736
816
|
},
|
|
737
817
|
cache_control: cacheControl
|
|
738
818
|
});
|
|
739
819
|
break;
|
|
740
820
|
}
|
|
821
|
+
if (part.toolName === "web_search") {
|
|
822
|
+
const output = part.output;
|
|
823
|
+
if (output.type !== "json") {
|
|
824
|
+
warnings.push({
|
|
825
|
+
type: "other",
|
|
826
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
827
|
+
});
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
830
|
+
const webSearchOutput = webSearch_20250305OutputSchema.parse(
|
|
831
|
+
output.value
|
|
832
|
+
);
|
|
833
|
+
anthropicContent.push({
|
|
834
|
+
type: "web_search_tool_result",
|
|
835
|
+
tool_use_id: part.toolCallId,
|
|
836
|
+
content: webSearchOutput.map((result) => ({
|
|
837
|
+
url: result.url,
|
|
838
|
+
title: result.title,
|
|
839
|
+
page_age: result.pageAge,
|
|
840
|
+
encrypted_content: result.encryptedContent,
|
|
841
|
+
type: result.type
|
|
842
|
+
})),
|
|
843
|
+
cache_control: cacheControl
|
|
844
|
+
});
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
741
847
|
warnings.push({
|
|
742
848
|
type: "other",
|
|
743
849
|
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
@@ -831,36 +937,36 @@ function mapAnthropicStopReason({
|
|
|
831
937
|
|
|
832
938
|
// src/anthropic-messages-language-model.ts
|
|
833
939
|
var citationSchemas = {
|
|
834
|
-
webSearchResult:
|
|
835
|
-
type:
|
|
836
|
-
cited_text:
|
|
837
|
-
url:
|
|
838
|
-
title:
|
|
839
|
-
encrypted_index:
|
|
940
|
+
webSearchResult: import_v47.z.object({
|
|
941
|
+
type: import_v47.z.literal("web_search_result_location"),
|
|
942
|
+
cited_text: import_v47.z.string(),
|
|
943
|
+
url: import_v47.z.string(),
|
|
944
|
+
title: import_v47.z.string(),
|
|
945
|
+
encrypted_index: import_v47.z.string()
|
|
840
946
|
}),
|
|
841
|
-
pageLocation:
|
|
842
|
-
type:
|
|
843
|
-
cited_text:
|
|
844
|
-
document_index:
|
|
845
|
-
document_title:
|
|
846
|
-
start_page_number:
|
|
847
|
-
end_page_number:
|
|
947
|
+
pageLocation: import_v47.z.object({
|
|
948
|
+
type: import_v47.z.literal("page_location"),
|
|
949
|
+
cited_text: import_v47.z.string(),
|
|
950
|
+
document_index: import_v47.z.number(),
|
|
951
|
+
document_title: import_v47.z.string().nullable(),
|
|
952
|
+
start_page_number: import_v47.z.number(),
|
|
953
|
+
end_page_number: import_v47.z.number()
|
|
848
954
|
}),
|
|
849
|
-
charLocation:
|
|
850
|
-
type:
|
|
851
|
-
cited_text:
|
|
852
|
-
document_index:
|
|
853
|
-
document_title:
|
|
854
|
-
start_char_index:
|
|
855
|
-
end_char_index:
|
|
955
|
+
charLocation: import_v47.z.object({
|
|
956
|
+
type: import_v47.z.literal("char_location"),
|
|
957
|
+
cited_text: import_v47.z.string(),
|
|
958
|
+
document_index: import_v47.z.number(),
|
|
959
|
+
document_title: import_v47.z.string().nullable(),
|
|
960
|
+
start_char_index: import_v47.z.number(),
|
|
961
|
+
end_char_index: import_v47.z.number()
|
|
856
962
|
})
|
|
857
963
|
};
|
|
858
|
-
var citationSchema =
|
|
964
|
+
var citationSchema = import_v47.z.discriminatedUnion("type", [
|
|
859
965
|
citationSchemas.webSearchResult,
|
|
860
966
|
citationSchemas.pageLocation,
|
|
861
967
|
citationSchemas.charLocation
|
|
862
968
|
]);
|
|
863
|
-
var documentCitationSchema =
|
|
969
|
+
var documentCitationSchema = import_v47.z.discriminatedUnion("type", [
|
|
864
970
|
citationSchemas.pageLocation,
|
|
865
971
|
citationSchemas.charLocation
|
|
866
972
|
]);
|
|
@@ -909,7 +1015,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
909
1015
|
var _a;
|
|
910
1016
|
this.modelId = modelId;
|
|
911
1017
|
this.config = config;
|
|
912
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1018
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
|
|
913
1019
|
}
|
|
914
1020
|
supportsUrl(url) {
|
|
915
1021
|
return url.protocol === "https:";
|
|
@@ -978,7 +1084,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
978
1084
|
description: "Respond with a JSON object.",
|
|
979
1085
|
inputSchema: responseFormat.schema
|
|
980
1086
|
} : void 0;
|
|
981
|
-
const anthropicOptions = await (0,
|
|
1087
|
+
const anthropicOptions = await (0, import_provider_utils7.parseProviderOptions)({
|
|
982
1088
|
provider: "anthropic",
|
|
983
1089
|
providerOptions,
|
|
984
1090
|
schema: anthropicProviderOptions
|
|
@@ -1070,8 +1176,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1070
1176
|
betas,
|
|
1071
1177
|
headers
|
|
1072
1178
|
}) {
|
|
1073
|
-
return (0,
|
|
1074
|
-
await (0,
|
|
1179
|
+
return (0, import_provider_utils7.combineHeaders)(
|
|
1180
|
+
await (0, import_provider_utils7.resolve)(this.config.headers),
|
|
1075
1181
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
1076
1182
|
headers
|
|
1077
1183
|
);
|
|
@@ -1115,12 +1221,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1115
1221
|
responseHeaders,
|
|
1116
1222
|
value: response,
|
|
1117
1223
|
rawValue: rawResponse
|
|
1118
|
-
} = await (0,
|
|
1224
|
+
} = await (0, import_provider_utils7.postJsonToApi)({
|
|
1119
1225
|
url: this.buildRequestUrl(false),
|
|
1120
1226
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1121
1227
|
body: this.transformRequestBody(args),
|
|
1122
1228
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1123
|
-
successfulResponseHandler: (0,
|
|
1229
|
+
successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
|
|
1124
1230
|
anthropicMessagesResponseSchema
|
|
1125
1231
|
),
|
|
1126
1232
|
abortSignal: options.abortSignal,
|
|
@@ -1185,7 +1291,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1185
1291
|
break;
|
|
1186
1292
|
}
|
|
1187
1293
|
case "server_tool_use": {
|
|
1188
|
-
if (part.name === "web_search" || part.name === "code_execution") {
|
|
1294
|
+
if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1189
1295
|
content.push({
|
|
1190
1296
|
type: "tool-call",
|
|
1191
1297
|
toolCallId: part.id,
|
|
@@ -1196,6 +1302,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1196
1302
|
}
|
|
1197
1303
|
break;
|
|
1198
1304
|
}
|
|
1305
|
+
case "web_fetch_tool_result": {
|
|
1306
|
+
if (part.content.type === "web_fetch_result") {
|
|
1307
|
+
content.push({
|
|
1308
|
+
type: "tool-result",
|
|
1309
|
+
toolCallId: part.tool_use_id,
|
|
1310
|
+
toolName: "web_fetch",
|
|
1311
|
+
result: {
|
|
1312
|
+
type: "web_fetch_result",
|
|
1313
|
+
url: part.content.url,
|
|
1314
|
+
retrievedAt: part.content.retrieved_at,
|
|
1315
|
+
content: {
|
|
1316
|
+
type: part.content.content.type,
|
|
1317
|
+
title: part.content.content.title,
|
|
1318
|
+
citations: part.content.content.citations,
|
|
1319
|
+
source: {
|
|
1320
|
+
type: part.content.content.source.type,
|
|
1321
|
+
mediaType: part.content.content.source.media_type,
|
|
1322
|
+
data: part.content.content.source.data
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
},
|
|
1326
|
+
providerExecuted: true
|
|
1327
|
+
});
|
|
1328
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1329
|
+
content.push({
|
|
1330
|
+
type: "tool-result",
|
|
1331
|
+
toolCallId: part.tool_use_id,
|
|
1332
|
+
toolName: "web_fetch",
|
|
1333
|
+
isError: true,
|
|
1334
|
+
result: {
|
|
1335
|
+
type: "web_fetch_tool_result_error",
|
|
1336
|
+
errorCode: part.content.error_code
|
|
1337
|
+
},
|
|
1338
|
+
providerExecuted: true
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
break;
|
|
1342
|
+
}
|
|
1199
1343
|
case "web_search_tool_result": {
|
|
1200
1344
|
if (Array.isArray(part.content)) {
|
|
1201
1345
|
content.push({
|
|
@@ -1306,12 +1450,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1306
1450
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1307
1451
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1308
1452
|
const body = { ...args, stream: true };
|
|
1309
|
-
const { responseHeaders, value: response } = await (0,
|
|
1453
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
|
|
1310
1454
|
url: this.buildRequestUrl(true),
|
|
1311
1455
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1312
1456
|
body: this.transformRequestBody(body),
|
|
1313
1457
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1314
|
-
successfulResponseHandler: (0,
|
|
1458
|
+
successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(
|
|
1315
1459
|
anthropicMessagesChunkSchema
|
|
1316
1460
|
),
|
|
1317
1461
|
abortSignal: options.abortSignal,
|
|
@@ -1324,7 +1468,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1324
1468
|
totalTokens: void 0
|
|
1325
1469
|
};
|
|
1326
1470
|
const contentBlocks = {};
|
|
1327
|
-
let
|
|
1471
|
+
let rawUsage = void 0;
|
|
1472
|
+
let cacheCreationInputTokens = null;
|
|
1328
1473
|
let blockType = void 0;
|
|
1329
1474
|
const generateId3 = this.generateId;
|
|
1330
1475
|
return {
|
|
@@ -1397,7 +1542,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1397
1542
|
return;
|
|
1398
1543
|
}
|
|
1399
1544
|
case "server_tool_use": {
|
|
1400
|
-
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1545
|
+
if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1401
1546
|
contentBlocks[value.index] = {
|
|
1402
1547
|
type: "tool-call",
|
|
1403
1548
|
toolCallId: value.content_block.id,
|
|
@@ -1414,6 +1559,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1414
1559
|
}
|
|
1415
1560
|
return;
|
|
1416
1561
|
}
|
|
1562
|
+
case "web_fetch_tool_result": {
|
|
1563
|
+
const part = value.content_block;
|
|
1564
|
+
if (part.content.type === "web_fetch_result") {
|
|
1565
|
+
controller.enqueue({
|
|
1566
|
+
type: "tool-result",
|
|
1567
|
+
toolCallId: part.tool_use_id,
|
|
1568
|
+
toolName: "web_fetch",
|
|
1569
|
+
result: {
|
|
1570
|
+
type: "web_fetch_result",
|
|
1571
|
+
url: part.content.url,
|
|
1572
|
+
retrievedAt: part.content.retrieved_at,
|
|
1573
|
+
content: {
|
|
1574
|
+
type: part.content.content.type,
|
|
1575
|
+
title: part.content.content.title,
|
|
1576
|
+
citations: part.content.content.citations,
|
|
1577
|
+
source: {
|
|
1578
|
+
type: part.content.content.source.type,
|
|
1579
|
+
mediaType: part.content.content.source.media_type,
|
|
1580
|
+
data: part.content.content.source.data
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1585
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1586
|
+
controller.enqueue({
|
|
1587
|
+
type: "tool-result",
|
|
1588
|
+
toolCallId: part.tool_use_id,
|
|
1589
|
+
toolName: "web_fetch",
|
|
1590
|
+
isError: true,
|
|
1591
|
+
result: {
|
|
1592
|
+
type: "web_fetch_tool_result_error",
|
|
1593
|
+
errorCode: part.content.error_code
|
|
1594
|
+
},
|
|
1595
|
+
providerExecuted: true
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1417
1600
|
case "web_search_tool_result": {
|
|
1418
1601
|
const part = value.content_block;
|
|
1419
1602
|
if (Array.isArray(part.content)) {
|
|
@@ -1616,12 +1799,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1616
1799
|
case "message_start": {
|
|
1617
1800
|
usage.inputTokens = value.message.usage.input_tokens;
|
|
1618
1801
|
usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
usage: value.message.usage,
|
|
1622
|
-
cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
|
|
1623
|
-
}
|
|
1802
|
+
rawUsage = {
|
|
1803
|
+
...value.message.usage
|
|
1624
1804
|
};
|
|
1805
|
+
cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
|
|
1625
1806
|
controller.enqueue({
|
|
1626
1807
|
type: "response-metadata",
|
|
1627
1808
|
id: (_d = value.message.id) != null ? _d : void 0,
|
|
@@ -1636,6 +1817,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1636
1817
|
finishReason: value.delta.stop_reason,
|
|
1637
1818
|
isJsonResponseFromTool: usesJsonResponseTool
|
|
1638
1819
|
});
|
|
1820
|
+
rawUsage = {
|
|
1821
|
+
...rawUsage,
|
|
1822
|
+
...value.usage
|
|
1823
|
+
};
|
|
1639
1824
|
return;
|
|
1640
1825
|
}
|
|
1641
1826
|
case "message_stop": {
|
|
@@ -1643,7 +1828,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1643
1828
|
type: "finish",
|
|
1644
1829
|
finishReason,
|
|
1645
1830
|
usage,
|
|
1646
|
-
providerMetadata
|
|
1831
|
+
providerMetadata: {
|
|
1832
|
+
anthropic: {
|
|
1833
|
+
usage: rawUsage != null ? rawUsage : null,
|
|
1834
|
+
cacheCreationInputTokens
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1647
1837
|
});
|
|
1648
1838
|
return;
|
|
1649
1839
|
}
|
|
@@ -1664,247 +1854,299 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1664
1854
|
};
|
|
1665
1855
|
}
|
|
1666
1856
|
};
|
|
1667
|
-
var anthropicMessagesResponseSchema =
|
|
1668
|
-
type:
|
|
1669
|
-
id:
|
|
1670
|
-
model:
|
|
1671
|
-
content:
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
type:
|
|
1675
|
-
text:
|
|
1676
|
-
citations:
|
|
1857
|
+
var anthropicMessagesResponseSchema = import_v47.z.object({
|
|
1858
|
+
type: import_v47.z.literal("message"),
|
|
1859
|
+
id: import_v47.z.string().nullish(),
|
|
1860
|
+
model: import_v47.z.string().nullish(),
|
|
1861
|
+
content: import_v47.z.array(
|
|
1862
|
+
import_v47.z.discriminatedUnion("type", [
|
|
1863
|
+
import_v47.z.object({
|
|
1864
|
+
type: import_v47.z.literal("text"),
|
|
1865
|
+
text: import_v47.z.string(),
|
|
1866
|
+
citations: import_v47.z.array(citationSchema).optional()
|
|
1677
1867
|
}),
|
|
1678
|
-
|
|
1679
|
-
type:
|
|
1680
|
-
thinking:
|
|
1681
|
-
signature:
|
|
1868
|
+
import_v47.z.object({
|
|
1869
|
+
type: import_v47.z.literal("thinking"),
|
|
1870
|
+
thinking: import_v47.z.string(),
|
|
1871
|
+
signature: import_v47.z.string()
|
|
1682
1872
|
}),
|
|
1683
|
-
|
|
1684
|
-
type:
|
|
1685
|
-
data:
|
|
1873
|
+
import_v47.z.object({
|
|
1874
|
+
type: import_v47.z.literal("redacted_thinking"),
|
|
1875
|
+
data: import_v47.z.string()
|
|
1686
1876
|
}),
|
|
1687
|
-
|
|
1688
|
-
type:
|
|
1689
|
-
id:
|
|
1690
|
-
name:
|
|
1691
|
-
input:
|
|
1877
|
+
import_v47.z.object({
|
|
1878
|
+
type: import_v47.z.literal("tool_use"),
|
|
1879
|
+
id: import_v47.z.string(),
|
|
1880
|
+
name: import_v47.z.string(),
|
|
1881
|
+
input: import_v47.z.unknown()
|
|
1692
1882
|
}),
|
|
1693
|
-
|
|
1694
|
-
type:
|
|
1695
|
-
id:
|
|
1696
|
-
name:
|
|
1697
|
-
input:
|
|
1883
|
+
import_v47.z.object({
|
|
1884
|
+
type: import_v47.z.literal("server_tool_use"),
|
|
1885
|
+
id: import_v47.z.string(),
|
|
1886
|
+
name: import_v47.z.string(),
|
|
1887
|
+
input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
|
|
1698
1888
|
}),
|
|
1699
|
-
|
|
1700
|
-
type:
|
|
1701
|
-
tool_use_id:
|
|
1702
|
-
content:
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1889
|
+
import_v47.z.object({
|
|
1890
|
+
type: import_v47.z.literal("web_fetch_tool_result"),
|
|
1891
|
+
tool_use_id: import_v47.z.string(),
|
|
1892
|
+
content: import_v47.z.union([
|
|
1893
|
+
import_v47.z.object({
|
|
1894
|
+
type: import_v47.z.literal("web_fetch_result"),
|
|
1895
|
+
url: import_v47.z.string(),
|
|
1896
|
+
retrieved_at: import_v47.z.string(),
|
|
1897
|
+
content: import_v47.z.object({
|
|
1898
|
+
type: import_v47.z.literal("document"),
|
|
1899
|
+
title: import_v47.z.string(),
|
|
1900
|
+
citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
|
|
1901
|
+
source: import_v47.z.object({
|
|
1902
|
+
type: import_v47.z.literal("text"),
|
|
1903
|
+
media_type: import_v47.z.string(),
|
|
1904
|
+
data: import_v47.z.string()
|
|
1905
|
+
})
|
|
1906
|
+
})
|
|
1907
|
+
}),
|
|
1908
|
+
import_v47.z.object({
|
|
1909
|
+
type: import_v47.z.literal("web_fetch_tool_result_error"),
|
|
1910
|
+
error_code: import_v47.z.string()
|
|
1911
|
+
})
|
|
1912
|
+
])
|
|
1913
|
+
}),
|
|
1914
|
+
import_v47.z.object({
|
|
1915
|
+
type: import_v47.z.literal("web_search_tool_result"),
|
|
1916
|
+
tool_use_id: import_v47.z.string(),
|
|
1917
|
+
content: import_v47.z.union([
|
|
1918
|
+
import_v47.z.array(
|
|
1919
|
+
import_v47.z.object({
|
|
1920
|
+
type: import_v47.z.literal("web_search_result"),
|
|
1921
|
+
url: import_v47.z.string(),
|
|
1922
|
+
title: import_v47.z.string(),
|
|
1923
|
+
encrypted_content: import_v47.z.string(),
|
|
1924
|
+
page_age: import_v47.z.string().nullish()
|
|
1710
1925
|
})
|
|
1711
1926
|
),
|
|
1712
|
-
|
|
1713
|
-
type:
|
|
1714
|
-
error_code:
|
|
1927
|
+
import_v47.z.object({
|
|
1928
|
+
type: import_v47.z.literal("web_search_tool_result_error"),
|
|
1929
|
+
error_code: import_v47.z.string()
|
|
1715
1930
|
})
|
|
1716
1931
|
])
|
|
1717
1932
|
}),
|
|
1718
|
-
|
|
1719
|
-
type:
|
|
1720
|
-
tool_use_id:
|
|
1721
|
-
content:
|
|
1722
|
-
|
|
1723
|
-
type:
|
|
1724
|
-
stdout:
|
|
1725
|
-
stderr:
|
|
1726
|
-
return_code:
|
|
1933
|
+
import_v47.z.object({
|
|
1934
|
+
type: import_v47.z.literal("code_execution_tool_result"),
|
|
1935
|
+
tool_use_id: import_v47.z.string(),
|
|
1936
|
+
content: import_v47.z.union([
|
|
1937
|
+
import_v47.z.object({
|
|
1938
|
+
type: import_v47.z.literal("code_execution_result"),
|
|
1939
|
+
stdout: import_v47.z.string(),
|
|
1940
|
+
stderr: import_v47.z.string(),
|
|
1941
|
+
return_code: import_v47.z.number()
|
|
1727
1942
|
}),
|
|
1728
|
-
|
|
1729
|
-
type:
|
|
1730
|
-
error_code:
|
|
1943
|
+
import_v47.z.object({
|
|
1944
|
+
type: import_v47.z.literal("code_execution_tool_result_error"),
|
|
1945
|
+
error_code: import_v47.z.string()
|
|
1731
1946
|
})
|
|
1732
1947
|
])
|
|
1733
1948
|
})
|
|
1734
1949
|
])
|
|
1735
1950
|
),
|
|
1736
|
-
stop_reason:
|
|
1737
|
-
usage:
|
|
1738
|
-
input_tokens:
|
|
1739
|
-
output_tokens:
|
|
1740
|
-
cache_creation_input_tokens:
|
|
1741
|
-
cache_read_input_tokens:
|
|
1951
|
+
stop_reason: import_v47.z.string().nullish(),
|
|
1952
|
+
usage: import_v47.z.looseObject({
|
|
1953
|
+
input_tokens: import_v47.z.number(),
|
|
1954
|
+
output_tokens: import_v47.z.number(),
|
|
1955
|
+
cache_creation_input_tokens: import_v47.z.number().nullish(),
|
|
1956
|
+
cache_read_input_tokens: import_v47.z.number().nullish()
|
|
1742
1957
|
})
|
|
1743
1958
|
});
|
|
1744
|
-
var anthropicMessagesChunkSchema =
|
|
1745
|
-
|
|
1746
|
-
type:
|
|
1747
|
-
message:
|
|
1748
|
-
id:
|
|
1749
|
-
model:
|
|
1750
|
-
usage:
|
|
1751
|
-
input_tokens:
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
cache_read_input_tokens: import_v45.z.number().nullish()
|
|
1959
|
+
var anthropicMessagesChunkSchema = import_v47.z.discriminatedUnion("type", [
|
|
1960
|
+
import_v47.z.object({
|
|
1961
|
+
type: import_v47.z.literal("message_start"),
|
|
1962
|
+
message: import_v47.z.object({
|
|
1963
|
+
id: import_v47.z.string().nullish(),
|
|
1964
|
+
model: import_v47.z.string().nullish(),
|
|
1965
|
+
usage: import_v47.z.looseObject({
|
|
1966
|
+
input_tokens: import_v47.z.number(),
|
|
1967
|
+
cache_creation_input_tokens: import_v47.z.number().nullish(),
|
|
1968
|
+
cache_read_input_tokens: import_v47.z.number().nullish()
|
|
1755
1969
|
})
|
|
1756
1970
|
})
|
|
1757
1971
|
}),
|
|
1758
|
-
|
|
1759
|
-
type:
|
|
1760
|
-
index:
|
|
1761
|
-
content_block:
|
|
1762
|
-
|
|
1763
|
-
type:
|
|
1764
|
-
text:
|
|
1972
|
+
import_v47.z.object({
|
|
1973
|
+
type: import_v47.z.literal("content_block_start"),
|
|
1974
|
+
index: import_v47.z.number(),
|
|
1975
|
+
content_block: import_v47.z.discriminatedUnion("type", [
|
|
1976
|
+
import_v47.z.object({
|
|
1977
|
+
type: import_v47.z.literal("text"),
|
|
1978
|
+
text: import_v47.z.string()
|
|
1765
1979
|
}),
|
|
1766
|
-
|
|
1767
|
-
type:
|
|
1768
|
-
thinking:
|
|
1980
|
+
import_v47.z.object({
|
|
1981
|
+
type: import_v47.z.literal("thinking"),
|
|
1982
|
+
thinking: import_v47.z.string()
|
|
1769
1983
|
}),
|
|
1770
|
-
|
|
1771
|
-
type:
|
|
1772
|
-
id:
|
|
1773
|
-
name:
|
|
1984
|
+
import_v47.z.object({
|
|
1985
|
+
type: import_v47.z.literal("tool_use"),
|
|
1986
|
+
id: import_v47.z.string(),
|
|
1987
|
+
name: import_v47.z.string()
|
|
1774
1988
|
}),
|
|
1775
|
-
|
|
1776
|
-
type:
|
|
1777
|
-
data:
|
|
1989
|
+
import_v47.z.object({
|
|
1990
|
+
type: import_v47.z.literal("redacted_thinking"),
|
|
1991
|
+
data: import_v47.z.string()
|
|
1778
1992
|
}),
|
|
1779
|
-
|
|
1780
|
-
type:
|
|
1781
|
-
id:
|
|
1782
|
-
name:
|
|
1783
|
-
input:
|
|
1993
|
+
import_v47.z.object({
|
|
1994
|
+
type: import_v47.z.literal("server_tool_use"),
|
|
1995
|
+
id: import_v47.z.string(),
|
|
1996
|
+
name: import_v47.z.string(),
|
|
1997
|
+
input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
|
|
1784
1998
|
}),
|
|
1785
|
-
|
|
1786
|
-
type:
|
|
1787
|
-
tool_use_id:
|
|
1788
|
-
content:
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1999
|
+
import_v47.z.object({
|
|
2000
|
+
type: import_v47.z.literal("web_fetch_tool_result"),
|
|
2001
|
+
tool_use_id: import_v47.z.string(),
|
|
2002
|
+
content: import_v47.z.union([
|
|
2003
|
+
import_v47.z.object({
|
|
2004
|
+
type: import_v47.z.literal("web_fetch_result"),
|
|
2005
|
+
url: import_v47.z.string(),
|
|
2006
|
+
retrieved_at: import_v47.z.string(),
|
|
2007
|
+
content: import_v47.z.object({
|
|
2008
|
+
type: import_v47.z.literal("document"),
|
|
2009
|
+
title: import_v47.z.string(),
|
|
2010
|
+
citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
|
|
2011
|
+
source: import_v47.z.object({
|
|
2012
|
+
type: import_v47.z.literal("text"),
|
|
2013
|
+
media_type: import_v47.z.string(),
|
|
2014
|
+
data: import_v47.z.string()
|
|
2015
|
+
})
|
|
2016
|
+
})
|
|
2017
|
+
}),
|
|
2018
|
+
import_v47.z.object({
|
|
2019
|
+
type: import_v47.z.literal("web_fetch_tool_result_error"),
|
|
2020
|
+
error_code: import_v47.z.string()
|
|
2021
|
+
})
|
|
2022
|
+
])
|
|
2023
|
+
}),
|
|
2024
|
+
import_v47.z.object({
|
|
2025
|
+
type: import_v47.z.literal("web_search_tool_result"),
|
|
2026
|
+
tool_use_id: import_v47.z.string(),
|
|
2027
|
+
content: import_v47.z.union([
|
|
2028
|
+
import_v47.z.array(
|
|
2029
|
+
import_v47.z.object({
|
|
2030
|
+
type: import_v47.z.literal("web_search_result"),
|
|
2031
|
+
url: import_v47.z.string(),
|
|
2032
|
+
title: import_v47.z.string(),
|
|
2033
|
+
encrypted_content: import_v47.z.string(),
|
|
2034
|
+
page_age: import_v47.z.string().nullish()
|
|
1796
2035
|
})
|
|
1797
2036
|
),
|
|
1798
|
-
|
|
1799
|
-
type:
|
|
1800
|
-
error_code:
|
|
2037
|
+
import_v47.z.object({
|
|
2038
|
+
type: import_v47.z.literal("web_search_tool_result_error"),
|
|
2039
|
+
error_code: import_v47.z.string()
|
|
1801
2040
|
})
|
|
1802
2041
|
])
|
|
1803
2042
|
}),
|
|
1804
|
-
|
|
1805
|
-
type:
|
|
1806
|
-
tool_use_id:
|
|
1807
|
-
content:
|
|
1808
|
-
|
|
1809
|
-
type:
|
|
1810
|
-
stdout:
|
|
1811
|
-
stderr:
|
|
1812
|
-
return_code:
|
|
2043
|
+
import_v47.z.object({
|
|
2044
|
+
type: import_v47.z.literal("code_execution_tool_result"),
|
|
2045
|
+
tool_use_id: import_v47.z.string(),
|
|
2046
|
+
content: import_v47.z.union([
|
|
2047
|
+
import_v47.z.object({
|
|
2048
|
+
type: import_v47.z.literal("code_execution_result"),
|
|
2049
|
+
stdout: import_v47.z.string(),
|
|
2050
|
+
stderr: import_v47.z.string(),
|
|
2051
|
+
return_code: import_v47.z.number()
|
|
1813
2052
|
}),
|
|
1814
|
-
|
|
1815
|
-
type:
|
|
1816
|
-
error_code:
|
|
2053
|
+
import_v47.z.object({
|
|
2054
|
+
type: import_v47.z.literal("code_execution_tool_result_error"),
|
|
2055
|
+
error_code: import_v47.z.string()
|
|
1817
2056
|
})
|
|
1818
2057
|
])
|
|
1819
2058
|
})
|
|
1820
2059
|
])
|
|
1821
2060
|
}),
|
|
1822
|
-
|
|
1823
|
-
type:
|
|
1824
|
-
index:
|
|
1825
|
-
delta:
|
|
1826
|
-
|
|
1827
|
-
type:
|
|
1828
|
-
partial_json:
|
|
2061
|
+
import_v47.z.object({
|
|
2062
|
+
type: import_v47.z.literal("content_block_delta"),
|
|
2063
|
+
index: import_v47.z.number(),
|
|
2064
|
+
delta: import_v47.z.discriminatedUnion("type", [
|
|
2065
|
+
import_v47.z.object({
|
|
2066
|
+
type: import_v47.z.literal("input_json_delta"),
|
|
2067
|
+
partial_json: import_v47.z.string()
|
|
1829
2068
|
}),
|
|
1830
|
-
|
|
1831
|
-
type:
|
|
1832
|
-
text:
|
|
2069
|
+
import_v47.z.object({
|
|
2070
|
+
type: import_v47.z.literal("text_delta"),
|
|
2071
|
+
text: import_v47.z.string()
|
|
1833
2072
|
}),
|
|
1834
|
-
|
|
1835
|
-
type:
|
|
1836
|
-
thinking:
|
|
2073
|
+
import_v47.z.object({
|
|
2074
|
+
type: import_v47.z.literal("thinking_delta"),
|
|
2075
|
+
thinking: import_v47.z.string()
|
|
1837
2076
|
}),
|
|
1838
|
-
|
|
1839
|
-
type:
|
|
1840
|
-
signature:
|
|
2077
|
+
import_v47.z.object({
|
|
2078
|
+
type: import_v47.z.literal("signature_delta"),
|
|
2079
|
+
signature: import_v47.z.string()
|
|
1841
2080
|
}),
|
|
1842
|
-
|
|
1843
|
-
type:
|
|
2081
|
+
import_v47.z.object({
|
|
2082
|
+
type: import_v47.z.literal("citations_delta"),
|
|
1844
2083
|
citation: citationSchema
|
|
1845
2084
|
})
|
|
1846
2085
|
])
|
|
1847
2086
|
}),
|
|
1848
|
-
|
|
1849
|
-
type:
|
|
1850
|
-
index:
|
|
2087
|
+
import_v47.z.object({
|
|
2088
|
+
type: import_v47.z.literal("content_block_stop"),
|
|
2089
|
+
index: import_v47.z.number()
|
|
1851
2090
|
}),
|
|
1852
|
-
|
|
1853
|
-
type:
|
|
1854
|
-
error:
|
|
1855
|
-
type:
|
|
1856
|
-
message:
|
|
2091
|
+
import_v47.z.object({
|
|
2092
|
+
type: import_v47.z.literal("error"),
|
|
2093
|
+
error: import_v47.z.object({
|
|
2094
|
+
type: import_v47.z.string(),
|
|
2095
|
+
message: import_v47.z.string()
|
|
1857
2096
|
})
|
|
1858
2097
|
}),
|
|
1859
|
-
|
|
1860
|
-
type:
|
|
1861
|
-
delta:
|
|
1862
|
-
usage:
|
|
2098
|
+
import_v47.z.object({
|
|
2099
|
+
type: import_v47.z.literal("message_delta"),
|
|
2100
|
+
delta: import_v47.z.object({ stop_reason: import_v47.z.string().nullish() }),
|
|
2101
|
+
usage: import_v47.z.looseObject({
|
|
2102
|
+
output_tokens: import_v47.z.number(),
|
|
2103
|
+
cache_creation_input_tokens: import_v47.z.number().nullish()
|
|
2104
|
+
})
|
|
1863
2105
|
}),
|
|
1864
|
-
|
|
1865
|
-
type:
|
|
2106
|
+
import_v47.z.object({
|
|
2107
|
+
type: import_v47.z.literal("message_stop")
|
|
1866
2108
|
}),
|
|
1867
|
-
|
|
1868
|
-
type:
|
|
2109
|
+
import_v47.z.object({
|
|
2110
|
+
type: import_v47.z.literal("ping")
|
|
1869
2111
|
})
|
|
1870
2112
|
]);
|
|
1871
|
-
var anthropicReasoningMetadataSchema =
|
|
1872
|
-
signature:
|
|
1873
|
-
redactedData:
|
|
2113
|
+
var anthropicReasoningMetadataSchema = import_v47.z.object({
|
|
2114
|
+
signature: import_v47.z.string().optional(),
|
|
2115
|
+
redactedData: import_v47.z.string().optional()
|
|
1874
2116
|
});
|
|
1875
2117
|
|
|
1876
2118
|
// src/tool/bash_20241022.ts
|
|
1877
|
-
var
|
|
1878
|
-
var
|
|
1879
|
-
var bash_20241022 = (0,
|
|
2119
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
2120
|
+
var import_v48 = __toESM(require("zod/v4"));
|
|
2121
|
+
var bash_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1880
2122
|
id: "anthropic.bash_20241022",
|
|
1881
2123
|
name: "bash",
|
|
1882
|
-
inputSchema:
|
|
1883
|
-
command:
|
|
1884
|
-
restart:
|
|
2124
|
+
inputSchema: import_v48.default.object({
|
|
2125
|
+
command: import_v48.default.string(),
|
|
2126
|
+
restart: import_v48.default.boolean().optional()
|
|
1885
2127
|
})
|
|
1886
2128
|
});
|
|
1887
2129
|
|
|
1888
2130
|
// src/tool/bash_20250124.ts
|
|
1889
|
-
var
|
|
1890
|
-
var
|
|
1891
|
-
var bash_20250124 = (0,
|
|
2131
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
2132
|
+
var import_v49 = __toESM(require("zod/v4"));
|
|
2133
|
+
var bash_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1892
2134
|
id: "anthropic.bash_20250124",
|
|
1893
2135
|
name: "bash",
|
|
1894
|
-
inputSchema:
|
|
1895
|
-
command:
|
|
1896
|
-
restart:
|
|
2136
|
+
inputSchema: import_v49.default.object({
|
|
2137
|
+
command: import_v49.default.string(),
|
|
2138
|
+
restart: import_v49.default.boolean().optional()
|
|
1897
2139
|
})
|
|
1898
2140
|
});
|
|
1899
2141
|
|
|
1900
2142
|
// src/tool/computer_20241022.ts
|
|
1901
|
-
var
|
|
1902
|
-
var
|
|
1903
|
-
var computer_20241022 = (0,
|
|
2143
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
2144
|
+
var import_v410 = require("zod/v4");
|
|
2145
|
+
var computer_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1904
2146
|
id: "anthropic.computer_20241022",
|
|
1905
2147
|
name: "computer",
|
|
1906
|
-
inputSchema:
|
|
1907
|
-
action:
|
|
2148
|
+
inputSchema: import_v410.z.object({
|
|
2149
|
+
action: import_v410.z.enum([
|
|
1908
2150
|
"key",
|
|
1909
2151
|
"type",
|
|
1910
2152
|
"mouse_move",
|
|
@@ -1916,19 +2158,19 @@ var computer_20241022 = (0, import_provider_utils8.createProviderDefinedToolFact
|
|
|
1916
2158
|
"screenshot",
|
|
1917
2159
|
"cursor_position"
|
|
1918
2160
|
]),
|
|
1919
|
-
coordinate:
|
|
1920
|
-
text:
|
|
2161
|
+
coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
|
|
2162
|
+
text: import_v410.z.string().optional()
|
|
1921
2163
|
})
|
|
1922
2164
|
});
|
|
1923
2165
|
|
|
1924
2166
|
// src/tool/computer_20250124.ts
|
|
1925
|
-
var
|
|
1926
|
-
var
|
|
1927
|
-
var computer_20250124 = (0,
|
|
2167
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
2168
|
+
var import_v411 = require("zod/v4");
|
|
2169
|
+
var computer_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1928
2170
|
id: "anthropic.computer_20250124",
|
|
1929
2171
|
name: "computer",
|
|
1930
|
-
inputSchema:
|
|
1931
|
-
action:
|
|
2172
|
+
inputSchema: import_v411.z.object({
|
|
2173
|
+
action: import_v411.z.enum([
|
|
1932
2174
|
"key",
|
|
1933
2175
|
"hold_key",
|
|
1934
2176
|
"type",
|
|
@@ -1946,63 +2188,63 @@ var computer_20250124 = (0, import_provider_utils9.createProviderDefinedToolFact
|
|
|
1946
2188
|
"wait",
|
|
1947
2189
|
"screenshot"
|
|
1948
2190
|
]),
|
|
1949
|
-
coordinate:
|
|
1950
|
-
duration:
|
|
1951
|
-
scroll_amount:
|
|
1952
|
-
scroll_direction:
|
|
1953
|
-
start_coordinate:
|
|
1954
|
-
text:
|
|
2191
|
+
coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
|
|
2192
|
+
duration: import_v411.z.number().optional(),
|
|
2193
|
+
scroll_amount: import_v411.z.number().optional(),
|
|
2194
|
+
scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
|
|
2195
|
+
start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
|
|
2196
|
+
text: import_v411.z.string().optional()
|
|
1955
2197
|
})
|
|
1956
2198
|
});
|
|
1957
2199
|
|
|
1958
2200
|
// src/tool/text-editor_20241022.ts
|
|
1959
|
-
var
|
|
1960
|
-
var
|
|
1961
|
-
var textEditor_20241022 = (0,
|
|
2201
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2202
|
+
var import_v412 = require("zod/v4");
|
|
2203
|
+
var textEditor_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
1962
2204
|
id: "anthropic.text_editor_20241022",
|
|
1963
2205
|
name: "str_replace_editor",
|
|
1964
|
-
inputSchema:
|
|
1965
|
-
command:
|
|
1966
|
-
path:
|
|
1967
|
-
file_text:
|
|
1968
|
-
insert_line:
|
|
1969
|
-
new_str:
|
|
1970
|
-
old_str:
|
|
1971
|
-
view_range:
|
|
2206
|
+
inputSchema: import_v412.z.object({
|
|
2207
|
+
command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2208
|
+
path: import_v412.z.string(),
|
|
2209
|
+
file_text: import_v412.z.string().optional(),
|
|
2210
|
+
insert_line: import_v412.z.number().int().optional(),
|
|
2211
|
+
new_str: import_v412.z.string().optional(),
|
|
2212
|
+
old_str: import_v412.z.string().optional(),
|
|
2213
|
+
view_range: import_v412.z.array(import_v412.z.number().int()).optional()
|
|
1972
2214
|
})
|
|
1973
2215
|
});
|
|
1974
2216
|
|
|
1975
2217
|
// src/tool/text-editor_20250124.ts
|
|
1976
|
-
var
|
|
1977
|
-
var
|
|
1978
|
-
var textEditor_20250124 = (0,
|
|
2218
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2219
|
+
var import_v413 = require("zod/v4");
|
|
2220
|
+
var textEditor_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
1979
2221
|
id: "anthropic.text_editor_20250124",
|
|
1980
2222
|
name: "str_replace_editor",
|
|
1981
|
-
inputSchema:
|
|
1982
|
-
command:
|
|
1983
|
-
path:
|
|
1984
|
-
file_text:
|
|
1985
|
-
insert_line:
|
|
1986
|
-
new_str:
|
|
1987
|
-
old_str:
|
|
1988
|
-
view_range:
|
|
2223
|
+
inputSchema: import_v413.z.object({
|
|
2224
|
+
command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2225
|
+
path: import_v413.z.string(),
|
|
2226
|
+
file_text: import_v413.z.string().optional(),
|
|
2227
|
+
insert_line: import_v413.z.number().int().optional(),
|
|
2228
|
+
new_str: import_v413.z.string().optional(),
|
|
2229
|
+
old_str: import_v413.z.string().optional(),
|
|
2230
|
+
view_range: import_v413.z.array(import_v413.z.number().int()).optional()
|
|
1989
2231
|
})
|
|
1990
2232
|
});
|
|
1991
2233
|
|
|
1992
2234
|
// src/tool/text-editor_20250429.ts
|
|
1993
|
-
var
|
|
1994
|
-
var
|
|
1995
|
-
var textEditor_20250429 = (0,
|
|
2235
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2236
|
+
var import_v414 = require("zod/v4");
|
|
2237
|
+
var textEditor_20250429 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
1996
2238
|
id: "anthropic.text_editor_20250429",
|
|
1997
2239
|
name: "str_replace_based_edit_tool",
|
|
1998
|
-
inputSchema:
|
|
1999
|
-
command:
|
|
2000
|
-
path:
|
|
2001
|
-
file_text:
|
|
2002
|
-
insert_line:
|
|
2003
|
-
new_str:
|
|
2004
|
-
old_str:
|
|
2005
|
-
view_range:
|
|
2240
|
+
inputSchema: import_v414.z.object({
|
|
2241
|
+
command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
|
|
2242
|
+
path: import_v414.z.string(),
|
|
2243
|
+
file_text: import_v414.z.string().optional(),
|
|
2244
|
+
insert_line: import_v414.z.number().int().optional(),
|
|
2245
|
+
new_str: import_v414.z.string().optional(),
|
|
2246
|
+
old_str: import_v414.z.string().optional(),
|
|
2247
|
+
view_range: import_v414.z.array(import_v414.z.number().int()).optional()
|
|
2006
2248
|
})
|
|
2007
2249
|
});
|
|
2008
2250
|
|
|
@@ -2068,6 +2310,8 @@ var anthropicTools = {
|
|
|
2068
2310
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2069
2311
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2070
2312
|
*
|
|
2313
|
+
* Supported models: Claude Sonnet 3.5
|
|
2314
|
+
*
|
|
2071
2315
|
* Tool name must be `str_replace_editor`.
|
|
2072
2316
|
*/
|
|
2073
2317
|
textEditor_20241022,
|
|
@@ -2076,6 +2320,8 @@ var anthropicTools = {
|
|
|
2076
2320
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2077
2321
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2078
2322
|
*
|
|
2323
|
+
* Supported models: Claude Sonnet 3.7
|
|
2324
|
+
*
|
|
2079
2325
|
* Tool name must be `str_replace_editor`.
|
|
2080
2326
|
*/
|
|
2081
2327
|
textEditor_20250124,
|
|
@@ -2087,8 +2333,36 @@ var anthropicTools = {
|
|
|
2087
2333
|
* Note: This version does not support the "undo_edit" command.
|
|
2088
2334
|
*
|
|
2089
2335
|
* Tool name must be `str_replace_based_edit_tool`.
|
|
2336
|
+
*
|
|
2337
|
+
* @deprecated Use textEditor_20250728 instead
|
|
2090
2338
|
*/
|
|
2091
2339
|
textEditor_20250429,
|
|
2340
|
+
/**
|
|
2341
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2342
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2343
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2344
|
+
*
|
|
2345
|
+
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
2346
|
+
*
|
|
2347
|
+
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
2348
|
+
*
|
|
2349
|
+
* Tool name must be `str_replace_based_edit_tool`.
|
|
2350
|
+
*
|
|
2351
|
+
* @param maxCharacters - Optional maximum number of characters to view in the file
|
|
2352
|
+
*/
|
|
2353
|
+
textEditor_20250728,
|
|
2354
|
+
/**
|
|
2355
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
2356
|
+
*
|
|
2357
|
+
* Tool name must be `web_fetch`.
|
|
2358
|
+
*
|
|
2359
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
2360
|
+
* @param allowedDomains - Only fetch from these domains
|
|
2361
|
+
* @param blockedDomains - Never fetch from these domains
|
|
2362
|
+
* @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
|
|
2363
|
+
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
2364
|
+
*/
|
|
2365
|
+
webFetch_20250910,
|
|
2092
2366
|
/**
|
|
2093
2367
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
2094
2368
|
*
|
|
@@ -2105,11 +2379,11 @@ var anthropicTools = {
|
|
|
2105
2379
|
// src/anthropic-provider.ts
|
|
2106
2380
|
function createAnthropic(options = {}) {
|
|
2107
2381
|
var _a;
|
|
2108
|
-
const baseURL = (_a = (0,
|
|
2109
|
-
const getHeaders = () => (0,
|
|
2382
|
+
const baseURL = (_a = (0, import_provider_utils15.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
2383
|
+
const getHeaders = () => (0, import_provider_utils15.withUserAgentSuffix)(
|
|
2110
2384
|
{
|
|
2111
2385
|
"anthropic-version": "2023-06-01",
|
|
2112
|
-
"x-api-key": (0,
|
|
2386
|
+
"x-api-key": (0, import_provider_utils15.loadApiKey)({
|
|
2113
2387
|
apiKey: options.apiKey,
|
|
2114
2388
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
2115
2389
|
description: "Anthropic"
|
|
@@ -2125,7 +2399,7 @@ function createAnthropic(options = {}) {
|
|
|
2125
2399
|
baseURL,
|
|
2126
2400
|
headers: getHeaders,
|
|
2127
2401
|
fetch: options.fetch,
|
|
2128
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
2402
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils15.generateId,
|
|
2129
2403
|
supportedUrls: () => ({
|
|
2130
2404
|
"image/*": [/^https?:\/\/.*$/]
|
|
2131
2405
|
})
|