@ai-sdk/anthropic 2.0.27 → 2.0.28
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 +6 -0
- package/dist/index.d.mts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +436 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +422 -96
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +108 -0
- package/dist/internal/index.d.ts +108 -0
- package/dist/internal/index.js +430 -108
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +421 -95
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -28,14 +28,14 @@ module.exports = __toCommonJS(src_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/anthropic-provider.ts
|
|
30
30
|
var import_provider4 = require("@ai-sdk/provider");
|
|
31
|
-
var
|
|
31
|
+
var import_provider_utils19 = require("@ai-sdk/provider-utils");
|
|
32
32
|
|
|
33
33
|
// src/version.ts
|
|
34
|
-
var VERSION = true ? "2.0.
|
|
34
|
+
var VERSION = true ? "2.0.28" : "0.0.0-test";
|
|
35
35
|
|
|
36
36
|
// src/anthropic-messages-language-model.ts
|
|
37
37
|
var import_provider3 = require("@ai-sdk/provider");
|
|
38
|
-
var
|
|
38
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
39
39
|
|
|
40
40
|
// src/anthropic-error.ts
|
|
41
41
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
@@ -163,6 +163,7 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
163
163
|
})
|
|
164
164
|
])
|
|
165
165
|
}),
|
|
166
|
+
// code execution results for code_execution_20250522 tool:
|
|
166
167
|
import_v42.z.object({
|
|
167
168
|
type: import_v42.z.literal("code_execution_tool_result"),
|
|
168
169
|
tool_use_id: import_v42.z.string(),
|
|
@@ -178,6 +179,62 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
178
179
|
error_code: import_v42.z.string()
|
|
179
180
|
})
|
|
180
181
|
])
|
|
182
|
+
}),
|
|
183
|
+
// bash code execution results for code_execution_20250825 tool:
|
|
184
|
+
import_v42.z.object({
|
|
185
|
+
type: import_v42.z.literal("bash_code_execution_tool_result"),
|
|
186
|
+
tool_use_id: import_v42.z.string(),
|
|
187
|
+
content: import_v42.z.discriminatedUnion("type", [
|
|
188
|
+
import_v42.z.object({
|
|
189
|
+
type: import_v42.z.literal("bash_code_execution_result"),
|
|
190
|
+
content: import_v42.z.array(
|
|
191
|
+
import_v42.z.object({
|
|
192
|
+
type: import_v42.z.literal("bash_code_execution_output"),
|
|
193
|
+
file_id: import_v42.z.string()
|
|
194
|
+
})
|
|
195
|
+
),
|
|
196
|
+
stdout: import_v42.z.string(),
|
|
197
|
+
stderr: import_v42.z.string(),
|
|
198
|
+
return_code: import_v42.z.number()
|
|
199
|
+
}),
|
|
200
|
+
import_v42.z.object({
|
|
201
|
+
type: import_v42.z.literal("bash_code_execution_tool_result_error"),
|
|
202
|
+
error_code: import_v42.z.string()
|
|
203
|
+
})
|
|
204
|
+
])
|
|
205
|
+
}),
|
|
206
|
+
// text editor code execution results for code_execution_20250825 tool:
|
|
207
|
+
import_v42.z.object({
|
|
208
|
+
type: import_v42.z.literal("text_editor_code_execution_tool_result"),
|
|
209
|
+
tool_use_id: import_v42.z.string(),
|
|
210
|
+
content: import_v42.z.discriminatedUnion("type", [
|
|
211
|
+
import_v42.z.object({
|
|
212
|
+
type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
|
|
213
|
+
error_code: import_v42.z.string()
|
|
214
|
+
}),
|
|
215
|
+
import_v42.z.object({
|
|
216
|
+
type: import_v42.z.literal("text_editor_code_execution_view_result"),
|
|
217
|
+
content: import_v42.z.string(),
|
|
218
|
+
file_type: import_v42.z.string(),
|
|
219
|
+
num_lines: import_v42.z.number().nullable(),
|
|
220
|
+
start_line: import_v42.z.number().nullable(),
|
|
221
|
+
total_lines: import_v42.z.number().nullable()
|
|
222
|
+
}),
|
|
223
|
+
import_v42.z.object({
|
|
224
|
+
type: import_v42.z.literal("text_editor_code_execution_create_result"),
|
|
225
|
+
is_file_update: import_v42.z.boolean()
|
|
226
|
+
}),
|
|
227
|
+
import_v42.z.object({
|
|
228
|
+
type: import_v42.z.literal(
|
|
229
|
+
"text_editor_code_execution_str_replace_result"
|
|
230
|
+
),
|
|
231
|
+
lines: import_v42.z.array(import_v42.z.string()).nullable(),
|
|
232
|
+
new_lines: import_v42.z.number().nullable(),
|
|
233
|
+
new_start: import_v42.z.number().nullable(),
|
|
234
|
+
old_lines: import_v42.z.number().nullable(),
|
|
235
|
+
old_start: import_v42.z.number().nullable()
|
|
236
|
+
})
|
|
237
|
+
])
|
|
181
238
|
})
|
|
182
239
|
])
|
|
183
240
|
),
|
|
@@ -278,6 +335,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
278
335
|
})
|
|
279
336
|
])
|
|
280
337
|
}),
|
|
338
|
+
// code execution results for code_execution_20250522 tool:
|
|
281
339
|
import_v42.z.object({
|
|
282
340
|
type: import_v42.z.literal("code_execution_tool_result"),
|
|
283
341
|
tool_use_id: import_v42.z.string(),
|
|
@@ -293,6 +351,62 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
293
351
|
error_code: import_v42.z.string()
|
|
294
352
|
})
|
|
295
353
|
])
|
|
354
|
+
}),
|
|
355
|
+
// bash code execution results for code_execution_20250825 tool:
|
|
356
|
+
import_v42.z.object({
|
|
357
|
+
type: import_v42.z.literal("bash_code_execution_tool_result"),
|
|
358
|
+
tool_use_id: import_v42.z.string(),
|
|
359
|
+
content: import_v42.z.discriminatedUnion("type", [
|
|
360
|
+
import_v42.z.object({
|
|
361
|
+
type: import_v42.z.literal("bash_code_execution_result"),
|
|
362
|
+
content: import_v42.z.array(
|
|
363
|
+
import_v42.z.object({
|
|
364
|
+
type: import_v42.z.literal("bash_code_execution_output"),
|
|
365
|
+
file_id: import_v42.z.string()
|
|
366
|
+
})
|
|
367
|
+
),
|
|
368
|
+
stdout: import_v42.z.string(),
|
|
369
|
+
stderr: import_v42.z.string(),
|
|
370
|
+
return_code: import_v42.z.number()
|
|
371
|
+
}),
|
|
372
|
+
import_v42.z.object({
|
|
373
|
+
type: import_v42.z.literal("bash_code_execution_tool_result_error"),
|
|
374
|
+
error_code: import_v42.z.string()
|
|
375
|
+
})
|
|
376
|
+
])
|
|
377
|
+
}),
|
|
378
|
+
// text editor code execution results for code_execution_20250825 tool:
|
|
379
|
+
import_v42.z.object({
|
|
380
|
+
type: import_v42.z.literal("text_editor_code_execution_tool_result"),
|
|
381
|
+
tool_use_id: import_v42.z.string(),
|
|
382
|
+
content: import_v42.z.discriminatedUnion("type", [
|
|
383
|
+
import_v42.z.object({
|
|
384
|
+
type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
|
|
385
|
+
error_code: import_v42.z.string()
|
|
386
|
+
}),
|
|
387
|
+
import_v42.z.object({
|
|
388
|
+
type: import_v42.z.literal("text_editor_code_execution_view_result"),
|
|
389
|
+
content: import_v42.z.string(),
|
|
390
|
+
file_type: import_v42.z.string(),
|
|
391
|
+
num_lines: import_v42.z.number().nullable(),
|
|
392
|
+
start_line: import_v42.z.number().nullable(),
|
|
393
|
+
total_lines: import_v42.z.number().nullable()
|
|
394
|
+
}),
|
|
395
|
+
import_v42.z.object({
|
|
396
|
+
type: import_v42.z.literal("text_editor_code_execution_create_result"),
|
|
397
|
+
is_file_update: import_v42.z.boolean()
|
|
398
|
+
}),
|
|
399
|
+
import_v42.z.object({
|
|
400
|
+
type: import_v42.z.literal(
|
|
401
|
+
"text_editor_code_execution_str_replace_result"
|
|
402
|
+
),
|
|
403
|
+
lines: import_v42.z.array(import_v42.z.string()).nullable(),
|
|
404
|
+
new_lines: import_v42.z.number().nullable(),
|
|
405
|
+
new_start: import_v42.z.number().nullable(),
|
|
406
|
+
old_lines: import_v42.z.number().nullable(),
|
|
407
|
+
old_start: import_v42.z.number().nullable()
|
|
408
|
+
})
|
|
409
|
+
])
|
|
296
410
|
})
|
|
297
411
|
])
|
|
298
412
|
}),
|
|
@@ -618,6 +732,14 @@ async function prepareTools({
|
|
|
618
732
|
});
|
|
619
733
|
break;
|
|
620
734
|
}
|
|
735
|
+
case "anthropic.code_execution_20250825": {
|
|
736
|
+
betas.add("code-execution-2025-08-25");
|
|
737
|
+
anthropicTools2.push({
|
|
738
|
+
type: "code_execution_20250825",
|
|
739
|
+
name: "code_execution"
|
|
740
|
+
});
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
621
743
|
case "anthropic.computer_20250124": {
|
|
622
744
|
betas.add("computer-use-2025-01-24");
|
|
623
745
|
anthropicTools2.push({
|
|
@@ -791,7 +913,7 @@ async function prepareTools({
|
|
|
791
913
|
|
|
792
914
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
793
915
|
var import_provider2 = require("@ai-sdk/provider");
|
|
794
|
-
var
|
|
916
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
795
917
|
|
|
796
918
|
// src/tool/code-execution_20250522.ts
|
|
797
919
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
@@ -823,6 +945,95 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
823
945
|
return factory4(args);
|
|
824
946
|
};
|
|
825
947
|
|
|
948
|
+
// src/tool/code-execution_20250825.ts
|
|
949
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
950
|
+
var import_v48 = require("zod/v4");
|
|
951
|
+
var codeExecution_20250825OutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
952
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
953
|
+
import_v48.z.discriminatedUnion("type", [
|
|
954
|
+
import_v48.z.object({
|
|
955
|
+
type: import_v48.z.literal("bash_code_execution_result"),
|
|
956
|
+
content: import_v48.z.array(
|
|
957
|
+
import_v48.z.object({
|
|
958
|
+
type: import_v48.z.literal("bash_code_execution_output"),
|
|
959
|
+
file_id: import_v48.z.string()
|
|
960
|
+
})
|
|
961
|
+
),
|
|
962
|
+
stdout: import_v48.z.string(),
|
|
963
|
+
stderr: import_v48.z.string(),
|
|
964
|
+
return_code: import_v48.z.number()
|
|
965
|
+
}),
|
|
966
|
+
import_v48.z.object({
|
|
967
|
+
type: import_v48.z.literal("bash_code_execution_tool_result_error"),
|
|
968
|
+
error_code: import_v48.z.string()
|
|
969
|
+
}),
|
|
970
|
+
import_v48.z.object({
|
|
971
|
+
type: import_v48.z.literal("text_editor_code_execution_tool_result_error"),
|
|
972
|
+
error_code: import_v48.z.string()
|
|
973
|
+
}),
|
|
974
|
+
import_v48.z.object({
|
|
975
|
+
type: import_v48.z.literal("text_editor_code_execution_view_result"),
|
|
976
|
+
content: import_v48.z.string(),
|
|
977
|
+
file_type: import_v48.z.string(),
|
|
978
|
+
num_lines: import_v48.z.number().nullable(),
|
|
979
|
+
start_line: import_v48.z.number().nullable(),
|
|
980
|
+
total_lines: import_v48.z.number().nullable()
|
|
981
|
+
}),
|
|
982
|
+
import_v48.z.object({
|
|
983
|
+
type: import_v48.z.literal("text_editor_code_execution_create_result"),
|
|
984
|
+
is_file_update: import_v48.z.boolean()
|
|
985
|
+
}),
|
|
986
|
+
import_v48.z.object({
|
|
987
|
+
type: import_v48.z.literal("text_editor_code_execution_str_replace_result"),
|
|
988
|
+
lines: import_v48.z.array(import_v48.z.string()).nullable(),
|
|
989
|
+
new_lines: import_v48.z.number().nullable(),
|
|
990
|
+
new_start: import_v48.z.number().nullable(),
|
|
991
|
+
old_lines: import_v48.z.number().nullable(),
|
|
992
|
+
old_start: import_v48.z.number().nullable()
|
|
993
|
+
})
|
|
994
|
+
])
|
|
995
|
+
)
|
|
996
|
+
);
|
|
997
|
+
var codeExecution_20250825InputSchema = (0, import_provider_utils9.lazySchema)(
|
|
998
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
999
|
+
import_v48.z.discriminatedUnion("type", [
|
|
1000
|
+
import_v48.z.object({
|
|
1001
|
+
type: import_v48.z.literal("bash_code_execution"),
|
|
1002
|
+
command: import_v48.z.string()
|
|
1003
|
+
}),
|
|
1004
|
+
import_v48.z.discriminatedUnion("command", [
|
|
1005
|
+
import_v48.z.object({
|
|
1006
|
+
type: import_v48.z.literal("text_editor_code_execution"),
|
|
1007
|
+
command: import_v48.z.literal("view"),
|
|
1008
|
+
path: import_v48.z.string()
|
|
1009
|
+
}),
|
|
1010
|
+
import_v48.z.object({
|
|
1011
|
+
type: import_v48.z.literal("text_editor_code_execution"),
|
|
1012
|
+
command: import_v48.z.literal("create"),
|
|
1013
|
+
path: import_v48.z.string(),
|
|
1014
|
+
file_text: import_v48.z.string().nullish()
|
|
1015
|
+
}),
|
|
1016
|
+
import_v48.z.object({
|
|
1017
|
+
type: import_v48.z.literal("text_editor_code_execution"),
|
|
1018
|
+
command: import_v48.z.literal("str_replace"),
|
|
1019
|
+
path: import_v48.z.string(),
|
|
1020
|
+
old_str: import_v48.z.string(),
|
|
1021
|
+
new_str: import_v48.z.string()
|
|
1022
|
+
})
|
|
1023
|
+
])
|
|
1024
|
+
])
|
|
1025
|
+
)
|
|
1026
|
+
);
|
|
1027
|
+
var factory5 = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
1028
|
+
id: "anthropic.code_execution_20250825",
|
|
1029
|
+
name: "code_execution",
|
|
1030
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
1031
|
+
outputSchema: codeExecution_20250825OutputSchema
|
|
1032
|
+
});
|
|
1033
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
1034
|
+
return factory5(args);
|
|
1035
|
+
};
|
|
1036
|
+
|
|
826
1037
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
827
1038
|
function convertToString(data) {
|
|
828
1039
|
if (typeof data === "string") {
|
|
@@ -852,7 +1063,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
852
1063
|
const messages = [];
|
|
853
1064
|
async function shouldEnableCitations(providerMetadata) {
|
|
854
1065
|
var _a2, _b2;
|
|
855
|
-
const anthropicOptions = await (0,
|
|
1066
|
+
const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
|
|
856
1067
|
provider: "anthropic",
|
|
857
1068
|
providerOptions: providerMetadata,
|
|
858
1069
|
schema: anthropicFilePartProviderOptions
|
|
@@ -860,7 +1071,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
860
1071
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
861
1072
|
}
|
|
862
1073
|
async function getDocumentMetadata(providerMetadata) {
|
|
863
|
-
const anthropicOptions = await (0,
|
|
1074
|
+
const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
|
|
864
1075
|
provider: "anthropic",
|
|
865
1076
|
providerOptions: providerMetadata,
|
|
866
1077
|
schema: anthropicFilePartProviderOptions
|
|
@@ -917,7 +1128,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
917
1128
|
} : {
|
|
918
1129
|
type: "base64",
|
|
919
1130
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
920
|
-
data: (0,
|
|
1131
|
+
data: (0, import_provider_utils10.convertToBase64)(part.data)
|
|
921
1132
|
},
|
|
922
1133
|
cache_control: cacheControl
|
|
923
1134
|
});
|
|
@@ -937,7 +1148,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
937
1148
|
} : {
|
|
938
1149
|
type: "base64",
|
|
939
1150
|
media_type: "application/pdf",
|
|
940
|
-
data: (0,
|
|
1151
|
+
data: (0, import_provider_utils10.convertToBase64)(part.data)
|
|
941
1152
|
},
|
|
942
1153
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
943
1154
|
...metadata.context && { context: metadata.context },
|
|
@@ -1084,7 +1295,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1084
1295
|
}
|
|
1085
1296
|
case "reasoning": {
|
|
1086
1297
|
if (sendReasoning) {
|
|
1087
|
-
const reasoningMetadata = await (0,
|
|
1298
|
+
const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
|
|
1088
1299
|
provider: "anthropic",
|
|
1089
1300
|
providerOptions: part.providerOptions,
|
|
1090
1301
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -1125,7 +1336,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1125
1336
|
}
|
|
1126
1337
|
case "tool-call": {
|
|
1127
1338
|
if (part.providerExecuted) {
|
|
1128
|
-
if (part.toolName === "code_execution"
|
|
1339
|
+
if (part.toolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")) {
|
|
1340
|
+
anthropicContent.push({
|
|
1341
|
+
type: "server_tool_use",
|
|
1342
|
+
id: part.toolCallId,
|
|
1343
|
+
name: part.input.type,
|
|
1344
|
+
// map back to subtool name
|
|
1345
|
+
input: part.input,
|
|
1346
|
+
cache_control: cacheControl
|
|
1347
|
+
});
|
|
1348
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1349
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1129
1350
|
anthropicContent.push({
|
|
1130
1351
|
type: "server_tool_use",
|
|
1131
1352
|
id: part.toolCallId,
|
|
@@ -1160,21 +1381,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1160
1381
|
});
|
|
1161
1382
|
break;
|
|
1162
1383
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1384
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1385
|
+
warnings.push({
|
|
1386
|
+
type: "other",
|
|
1387
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1388
|
+
});
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
if (output.value.type === "code_execution_result") {
|
|
1392
|
+
const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
|
|
1393
|
+
value: output.value,
|
|
1394
|
+
schema: codeExecution_20250522OutputSchema
|
|
1395
|
+
});
|
|
1396
|
+
anthropicContent.push({
|
|
1397
|
+
type: "code_execution_tool_result",
|
|
1398
|
+
tool_use_id: part.toolCallId,
|
|
1399
|
+
content: {
|
|
1400
|
+
type: codeExecutionOutput.type,
|
|
1401
|
+
stdout: codeExecutionOutput.stdout,
|
|
1402
|
+
stderr: codeExecutionOutput.stderr,
|
|
1403
|
+
return_code: codeExecutionOutput.return_code
|
|
1404
|
+
},
|
|
1405
|
+
cache_control: cacheControl
|
|
1406
|
+
});
|
|
1407
|
+
} else {
|
|
1408
|
+
const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
|
|
1409
|
+
value: output.value,
|
|
1410
|
+
schema: codeExecution_20250825OutputSchema
|
|
1411
|
+
});
|
|
1412
|
+
anthropicContent.push(
|
|
1413
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1414
|
+
type: "bash_code_execution_tool_result",
|
|
1415
|
+
tool_use_id: part.toolCallId,
|
|
1416
|
+
cache_control: cacheControl,
|
|
1417
|
+
content: codeExecutionOutput
|
|
1418
|
+
} : {
|
|
1419
|
+
type: "text_editor_code_execution_tool_result",
|
|
1420
|
+
tool_use_id: part.toolCallId,
|
|
1421
|
+
cache_control: cacheControl,
|
|
1422
|
+
content: codeExecutionOutput
|
|
1423
|
+
}
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1178
1426
|
break;
|
|
1179
1427
|
}
|
|
1180
1428
|
if (part.toolName === "web_fetch") {
|
|
@@ -1186,7 +1434,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1186
1434
|
});
|
|
1187
1435
|
break;
|
|
1188
1436
|
}
|
|
1189
|
-
const webFetchOutput = await (0,
|
|
1437
|
+
const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
|
|
1190
1438
|
value: output.value,
|
|
1191
1439
|
schema: webFetch_20250910OutputSchema
|
|
1192
1440
|
});
|
|
@@ -1221,7 +1469,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1221
1469
|
});
|
|
1222
1470
|
break;
|
|
1223
1471
|
}
|
|
1224
|
-
const webSearchOutput = await (0,
|
|
1472
|
+
const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
|
|
1225
1473
|
value: output.value,
|
|
1226
1474
|
schema: webSearch_20250305OutputSchema
|
|
1227
1475
|
});
|
|
@@ -1366,7 +1614,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1366
1614
|
var _a;
|
|
1367
1615
|
this.modelId = modelId;
|
|
1368
1616
|
this.config = config;
|
|
1369
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1617
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
|
|
1370
1618
|
}
|
|
1371
1619
|
supportsUrl(url) {
|
|
1372
1620
|
return url.protocol === "https:";
|
|
@@ -1435,7 +1683,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1435
1683
|
description: "Respond with a JSON object.",
|
|
1436
1684
|
inputSchema: responseFormat.schema
|
|
1437
1685
|
} : void 0;
|
|
1438
|
-
const anthropicOptions = await (0,
|
|
1686
|
+
const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
|
|
1439
1687
|
provider: "anthropic",
|
|
1440
1688
|
providerOptions,
|
|
1441
1689
|
schema: anthropicProviderOptions
|
|
@@ -1527,8 +1775,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1527
1775
|
betas,
|
|
1528
1776
|
headers
|
|
1529
1777
|
}) {
|
|
1530
|
-
return (0,
|
|
1531
|
-
await (0,
|
|
1778
|
+
return (0, import_provider_utils11.combineHeaders)(
|
|
1779
|
+
await (0, import_provider_utils11.resolve)(this.config.headers),
|
|
1532
1780
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
1533
1781
|
headers
|
|
1534
1782
|
);
|
|
@@ -1572,12 +1820,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1572
1820
|
responseHeaders,
|
|
1573
1821
|
value: response,
|
|
1574
1822
|
rawValue: rawResponse
|
|
1575
|
-
} = await (0,
|
|
1823
|
+
} = await (0, import_provider_utils11.postJsonToApi)({
|
|
1576
1824
|
url: this.buildRequestUrl(false),
|
|
1577
1825
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1578
1826
|
body: this.transformRequestBody(args),
|
|
1579
1827
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1580
|
-
successfulResponseHandler: (0,
|
|
1828
|
+
successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
|
|
1581
1829
|
anthropicMessagesResponseSchema
|
|
1582
1830
|
),
|
|
1583
1831
|
abortSignal: options.abortSignal,
|
|
@@ -1644,7 +1892,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1644
1892
|
break;
|
|
1645
1893
|
}
|
|
1646
1894
|
case "server_tool_use": {
|
|
1647
|
-
if (part.name === "
|
|
1895
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1896
|
+
content.push({
|
|
1897
|
+
type: "tool-call",
|
|
1898
|
+
toolCallId: part.id,
|
|
1899
|
+
toolName: "code_execution",
|
|
1900
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1901
|
+
providerExecuted: true
|
|
1902
|
+
});
|
|
1903
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1648
1904
|
content.push({
|
|
1649
1905
|
type: "tool-call",
|
|
1650
1906
|
toolCallId: part.id,
|
|
@@ -1740,6 +1996,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1740
1996
|
}
|
|
1741
1997
|
break;
|
|
1742
1998
|
}
|
|
1999
|
+
// code execution 20250522:
|
|
1743
2000
|
case "code_execution_tool_result": {
|
|
1744
2001
|
if (part.content.type === "code_execution_result") {
|
|
1745
2002
|
content.push({
|
|
@@ -1769,6 +2026,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1769
2026
|
}
|
|
1770
2027
|
break;
|
|
1771
2028
|
}
|
|
2029
|
+
// code execution 20250825:
|
|
2030
|
+
case "bash_code_execution_tool_result":
|
|
2031
|
+
case "text_editor_code_execution_tool_result": {
|
|
2032
|
+
content.push({
|
|
2033
|
+
type: "tool-result",
|
|
2034
|
+
toolCallId: part.tool_use_id,
|
|
2035
|
+
toolName: "code_execution",
|
|
2036
|
+
result: part.content,
|
|
2037
|
+
providerExecuted: true
|
|
2038
|
+
});
|
|
2039
|
+
break;
|
|
2040
|
+
}
|
|
1772
2041
|
}
|
|
1773
2042
|
}
|
|
1774
2043
|
return {
|
|
@@ -1804,12 +2073,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1804
2073
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1805
2074
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1806
2075
|
const body = { ...args, stream: true };
|
|
1807
|
-
const { responseHeaders, value: response } = await (0,
|
|
2076
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
|
|
1808
2077
|
url: this.buildRequestUrl(true),
|
|
1809
2078
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1810
2079
|
body: this.transformRequestBody(body),
|
|
1811
2080
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1812
|
-
successfulResponseHandler: (0,
|
|
2081
|
+
successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
|
|
1813
2082
|
anthropicMessagesChunkSchema
|
|
1814
2083
|
),
|
|
1815
2084
|
abortSignal: options.abortSignal,
|
|
@@ -1885,7 +2154,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1885
2154
|
type: "tool-call",
|
|
1886
2155
|
toolCallId: value.content_block.id,
|
|
1887
2156
|
toolName: value.content_block.name,
|
|
1888
|
-
input: ""
|
|
2157
|
+
input: "",
|
|
2158
|
+
firstDelta: true
|
|
1889
2159
|
};
|
|
1890
2160
|
controller.enqueue(
|
|
1891
2161
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1897,18 +2167,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1897
2167
|
return;
|
|
1898
2168
|
}
|
|
1899
2169
|
case "server_tool_use": {
|
|
1900
|
-
if (
|
|
2170
|
+
if ([
|
|
2171
|
+
"web_fetch",
|
|
2172
|
+
"web_search",
|
|
2173
|
+
// code execution 20250825:
|
|
2174
|
+
"code_execution",
|
|
2175
|
+
// code execution 20250825 text editor:
|
|
2176
|
+
"text_editor_code_execution",
|
|
2177
|
+
// code execution 20250825 bash:
|
|
2178
|
+
"bash_code_execution"
|
|
2179
|
+
].includes(value.content_block.name)) {
|
|
1901
2180
|
contentBlocks[value.index] = {
|
|
1902
2181
|
type: "tool-call",
|
|
1903
2182
|
toolCallId: value.content_block.id,
|
|
1904
2183
|
toolName: value.content_block.name,
|
|
1905
2184
|
input: "",
|
|
1906
|
-
providerExecuted: true
|
|
2185
|
+
providerExecuted: true,
|
|
2186
|
+
firstDelta: true
|
|
1907
2187
|
};
|
|
2188
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1908
2189
|
controller.enqueue({
|
|
1909
2190
|
type: "tool-input-start",
|
|
1910
2191
|
id: value.content_block.id,
|
|
1911
|
-
toolName:
|
|
2192
|
+
toolName: mappedToolName,
|
|
1912
2193
|
providerExecuted: true
|
|
1913
2194
|
});
|
|
1914
2195
|
}
|
|
@@ -2000,6 +2281,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2000
2281
|
}
|
|
2001
2282
|
return;
|
|
2002
2283
|
}
|
|
2284
|
+
// code execution 20250522:
|
|
2003
2285
|
case "code_execution_tool_result": {
|
|
2004
2286
|
const part = value.content_block;
|
|
2005
2287
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2030,6 +2312,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2030
2312
|
}
|
|
2031
2313
|
return;
|
|
2032
2314
|
}
|
|
2315
|
+
// code execution 20250825:
|
|
2316
|
+
case "bash_code_execution_tool_result":
|
|
2317
|
+
case "text_editor_code_execution_tool_result": {
|
|
2318
|
+
const part = value.content_block;
|
|
2319
|
+
controller.enqueue({
|
|
2320
|
+
type: "tool-result",
|
|
2321
|
+
toolCallId: part.tool_use_id,
|
|
2322
|
+
toolName: "code_execution",
|
|
2323
|
+
result: part.content,
|
|
2324
|
+
providerExecuted: true
|
|
2325
|
+
});
|
|
2326
|
+
return;
|
|
2327
|
+
}
|
|
2033
2328
|
default: {
|
|
2034
2329
|
const _exhaustiveCheck = contentBlockType;
|
|
2035
2330
|
throw new Error(
|
|
@@ -2062,7 +2357,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2062
2357
|
type: "tool-input-end",
|
|
2063
2358
|
id: contentBlock.toolCallId
|
|
2064
2359
|
});
|
|
2065
|
-
|
|
2360
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2361
|
+
controller.enqueue({
|
|
2362
|
+
type: "tool-call",
|
|
2363
|
+
toolCallId: contentBlock.toolCallId,
|
|
2364
|
+
toolName,
|
|
2365
|
+
input: contentBlock.input,
|
|
2366
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2367
|
+
});
|
|
2066
2368
|
}
|
|
2067
2369
|
break;
|
|
2068
2370
|
}
|
|
@@ -2110,7 +2412,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2110
2412
|
}
|
|
2111
2413
|
case "input_json_delta": {
|
|
2112
2414
|
const contentBlock = contentBlocks[value.index];
|
|
2113
|
-
|
|
2415
|
+
let delta = value.delta.partial_json;
|
|
2416
|
+
if (delta.length === 0) {
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2114
2419
|
if (usesJsonResponseTool) {
|
|
2115
2420
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2116
2421
|
return;
|
|
@@ -2124,12 +2429,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2124
2429
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2125
2430
|
return;
|
|
2126
2431
|
}
|
|
2432
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2433
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2434
|
+
}
|
|
2127
2435
|
controller.enqueue({
|
|
2128
2436
|
type: "tool-input-delta",
|
|
2129
2437
|
id: contentBlock.toolCallId,
|
|
2130
2438
|
delta
|
|
2131
2439
|
});
|
|
2132
2440
|
contentBlock.input += delta;
|
|
2441
|
+
contentBlock.firstDelta = false;
|
|
2133
2442
|
}
|
|
2134
2443
|
return;
|
|
2135
2444
|
}
|
|
@@ -2215,46 +2524,46 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2215
2524
|
};
|
|
2216
2525
|
|
|
2217
2526
|
// src/tool/bash_20241022.ts
|
|
2218
|
-
var
|
|
2219
|
-
var
|
|
2220
|
-
var bash_20241022InputSchema = (0,
|
|
2221
|
-
() => (0,
|
|
2222
|
-
|
|
2223
|
-
command:
|
|
2224
|
-
restart:
|
|
2527
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2528
|
+
var import_v49 = require("zod/v4");
|
|
2529
|
+
var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
2530
|
+
() => (0, import_provider_utils12.zodSchema)(
|
|
2531
|
+
import_v49.z.object({
|
|
2532
|
+
command: import_v49.z.string(),
|
|
2533
|
+
restart: import_v49.z.boolean().optional()
|
|
2225
2534
|
})
|
|
2226
2535
|
)
|
|
2227
2536
|
);
|
|
2228
|
-
var bash_20241022 = (0,
|
|
2537
|
+
var bash_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
2229
2538
|
id: "anthropic.bash_20241022",
|
|
2230
2539
|
name: "bash",
|
|
2231
2540
|
inputSchema: bash_20241022InputSchema
|
|
2232
2541
|
});
|
|
2233
2542
|
|
|
2234
2543
|
// src/tool/bash_20250124.ts
|
|
2235
|
-
var
|
|
2236
|
-
var
|
|
2237
|
-
var bash_20250124InputSchema = (0,
|
|
2238
|
-
() => (0,
|
|
2239
|
-
|
|
2240
|
-
command:
|
|
2241
|
-
restart:
|
|
2544
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2545
|
+
var import_v410 = require("zod/v4");
|
|
2546
|
+
var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
2547
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
2548
|
+
import_v410.z.object({
|
|
2549
|
+
command: import_v410.z.string(),
|
|
2550
|
+
restart: import_v410.z.boolean().optional()
|
|
2242
2551
|
})
|
|
2243
2552
|
)
|
|
2244
2553
|
);
|
|
2245
|
-
var bash_20250124 = (0,
|
|
2554
|
+
var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
2246
2555
|
id: "anthropic.bash_20250124",
|
|
2247
2556
|
name: "bash",
|
|
2248
2557
|
inputSchema: bash_20250124InputSchema
|
|
2249
2558
|
});
|
|
2250
2559
|
|
|
2251
2560
|
// src/tool/computer_20241022.ts
|
|
2252
|
-
var
|
|
2253
|
-
var
|
|
2254
|
-
var computer_20241022InputSchema = (0,
|
|
2255
|
-
() => (0,
|
|
2256
|
-
|
|
2257
|
-
action:
|
|
2561
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2562
|
+
var import_v411 = require("zod/v4");
|
|
2563
|
+
var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2564
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2565
|
+
import_v411.z.object({
|
|
2566
|
+
action: import_v411.z.enum([
|
|
2258
2567
|
"key",
|
|
2259
2568
|
"type",
|
|
2260
2569
|
"mouse_move",
|
|
@@ -2266,24 +2575,24 @@ var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
|
2266
2575
|
"screenshot",
|
|
2267
2576
|
"cursor_position"
|
|
2268
2577
|
]),
|
|
2269
|
-
coordinate:
|
|
2270
|
-
text:
|
|
2578
|
+
coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
|
|
2579
|
+
text: import_v411.z.string().optional()
|
|
2271
2580
|
})
|
|
2272
2581
|
)
|
|
2273
2582
|
);
|
|
2274
|
-
var computer_20241022 = (0,
|
|
2583
|
+
var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
2275
2584
|
id: "anthropic.computer_20241022",
|
|
2276
2585
|
name: "computer",
|
|
2277
2586
|
inputSchema: computer_20241022InputSchema
|
|
2278
2587
|
});
|
|
2279
2588
|
|
|
2280
2589
|
// src/tool/computer_20250124.ts
|
|
2281
|
-
var
|
|
2282
|
-
var
|
|
2283
|
-
var computer_20250124InputSchema = (0,
|
|
2284
|
-
() => (0,
|
|
2285
|
-
|
|
2286
|
-
action:
|
|
2590
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2591
|
+
var import_v412 = require("zod/v4");
|
|
2592
|
+
var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
2593
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
2594
|
+
import_v412.z.object({
|
|
2595
|
+
action: import_v412.z.enum([
|
|
2287
2596
|
"key",
|
|
2288
2597
|
"hold_key",
|
|
2289
2598
|
"type",
|
|
@@ -2301,47 +2610,25 @@ var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
2301
2610
|
"wait",
|
|
2302
2611
|
"screenshot"
|
|
2303
2612
|
]),
|
|
2304
|
-
coordinate:
|
|
2305
|
-
duration:
|
|
2306
|
-
scroll_amount:
|
|
2307
|
-
scroll_direction:
|
|
2308
|
-
start_coordinate:
|
|
2309
|
-
text:
|
|
2613
|
+
coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
|
|
2614
|
+
duration: import_v412.z.number().optional(),
|
|
2615
|
+
scroll_amount: import_v412.z.number().optional(),
|
|
2616
|
+
scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
|
|
2617
|
+
start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
|
|
2618
|
+
text: import_v412.z.string().optional()
|
|
2310
2619
|
})
|
|
2311
2620
|
)
|
|
2312
2621
|
);
|
|
2313
|
-
var computer_20250124 = (0,
|
|
2622
|
+
var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
2314
2623
|
id: "anthropic.computer_20250124",
|
|
2315
2624
|
name: "computer",
|
|
2316
2625
|
inputSchema: computer_20250124InputSchema
|
|
2317
2626
|
});
|
|
2318
2627
|
|
|
2319
2628
|
// src/tool/text-editor_20241022.ts
|
|
2320
|
-
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2321
|
-
var import_v412 = require("zod/v4");
|
|
2322
|
-
var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
2323
|
-
() => (0, import_provider_utils15.zodSchema)(
|
|
2324
|
-
import_v412.z.object({
|
|
2325
|
-
command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2326
|
-
path: import_v412.z.string(),
|
|
2327
|
-
file_text: import_v412.z.string().optional(),
|
|
2328
|
-
insert_line: import_v412.z.number().int().optional(),
|
|
2329
|
-
new_str: import_v412.z.string().optional(),
|
|
2330
|
-
old_str: import_v412.z.string().optional(),
|
|
2331
|
-
view_range: import_v412.z.array(import_v412.z.number().int()).optional()
|
|
2332
|
-
})
|
|
2333
|
-
)
|
|
2334
|
-
);
|
|
2335
|
-
var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
2336
|
-
id: "anthropic.text_editor_20241022",
|
|
2337
|
-
name: "str_replace_editor",
|
|
2338
|
-
inputSchema: textEditor_20241022InputSchema
|
|
2339
|
-
});
|
|
2340
|
-
|
|
2341
|
-
// src/tool/text-editor_20250124.ts
|
|
2342
2629
|
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
2343
2630
|
var import_v413 = require("zod/v4");
|
|
2344
|
-
var
|
|
2631
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
2345
2632
|
() => (0, import_provider_utils16.zodSchema)(
|
|
2346
2633
|
import_v413.z.object({
|
|
2347
2634
|
command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -2354,19 +2641,19 @@ var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
|
2354
2641
|
})
|
|
2355
2642
|
)
|
|
2356
2643
|
);
|
|
2357
|
-
var
|
|
2358
|
-
id: "anthropic.
|
|
2644
|
+
var textEditor_20241022 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
|
|
2645
|
+
id: "anthropic.text_editor_20241022",
|
|
2359
2646
|
name: "str_replace_editor",
|
|
2360
|
-
inputSchema:
|
|
2647
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2361
2648
|
});
|
|
2362
2649
|
|
|
2363
|
-
// src/tool/text-
|
|
2650
|
+
// src/tool/text-editor_20250124.ts
|
|
2364
2651
|
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
2365
2652
|
var import_v414 = require("zod/v4");
|
|
2366
|
-
var
|
|
2653
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
2367
2654
|
() => (0, import_provider_utils17.zodSchema)(
|
|
2368
2655
|
import_v414.z.object({
|
|
2369
|
-
command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
|
|
2656
|
+
command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2370
2657
|
path: import_v414.z.string(),
|
|
2371
2658
|
file_text: import_v414.z.string().optional(),
|
|
2372
2659
|
insert_line: import_v414.z.number().int().optional(),
|
|
@@ -2376,7 +2663,29 @@ var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
2376
2663
|
})
|
|
2377
2664
|
)
|
|
2378
2665
|
);
|
|
2379
|
-
var
|
|
2666
|
+
var textEditor_20250124 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
|
|
2667
|
+
id: "anthropic.text_editor_20250124",
|
|
2668
|
+
name: "str_replace_editor",
|
|
2669
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2670
|
+
});
|
|
2671
|
+
|
|
2672
|
+
// src/tool/text-editor_20250429.ts
|
|
2673
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
2674
|
+
var import_v415 = require("zod/v4");
|
|
2675
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
2676
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
2677
|
+
import_v415.z.object({
|
|
2678
|
+
command: import_v415.z.enum(["view", "create", "str_replace", "insert"]),
|
|
2679
|
+
path: import_v415.z.string(),
|
|
2680
|
+
file_text: import_v415.z.string().optional(),
|
|
2681
|
+
insert_line: import_v415.z.number().int().optional(),
|
|
2682
|
+
new_str: import_v415.z.string().optional(),
|
|
2683
|
+
old_str: import_v415.z.string().optional(),
|
|
2684
|
+
view_range: import_v415.z.array(import_v415.z.number().int()).optional()
|
|
2685
|
+
})
|
|
2686
|
+
)
|
|
2687
|
+
);
|
|
2688
|
+
var textEditor_20250429 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
|
|
2380
2689
|
id: "anthropic.text_editor_20250429",
|
|
2381
2690
|
name: "str_replace_based_edit_tool",
|
|
2382
2691
|
inputSchema: textEditor_20250429InputSchema
|
|
@@ -2413,6 +2722,19 @@ var anthropicTools = {
|
|
|
2413
2722
|
* Tool name must be `code_execution`.
|
|
2414
2723
|
*/
|
|
2415
2724
|
codeExecution_20250522,
|
|
2725
|
+
/**
|
|
2726
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2727
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2728
|
+
* the API conversation.
|
|
2729
|
+
*
|
|
2730
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2731
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2732
|
+
*
|
|
2733
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2734
|
+
*
|
|
2735
|
+
* Tool name must be `code_execution`.
|
|
2736
|
+
*/
|
|
2737
|
+
codeExecution_20250825,
|
|
2416
2738
|
/**
|
|
2417
2739
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2418
2740
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -2513,11 +2835,11 @@ var anthropicTools = {
|
|
|
2513
2835
|
// src/anthropic-provider.ts
|
|
2514
2836
|
function createAnthropic(options = {}) {
|
|
2515
2837
|
var _a;
|
|
2516
|
-
const baseURL = (_a = (0,
|
|
2517
|
-
const getHeaders = () => (0,
|
|
2838
|
+
const baseURL = (_a = (0, import_provider_utils19.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
2839
|
+
const getHeaders = () => (0, import_provider_utils19.withUserAgentSuffix)(
|
|
2518
2840
|
{
|
|
2519
2841
|
"anthropic-version": "2023-06-01",
|
|
2520
|
-
"x-api-key": (0,
|
|
2842
|
+
"x-api-key": (0, import_provider_utils19.loadApiKey)({
|
|
2521
2843
|
apiKey: options.apiKey,
|
|
2522
2844
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
2523
2845
|
description: "Anthropic"
|
|
@@ -2533,7 +2855,7 @@ function createAnthropic(options = {}) {
|
|
|
2533
2855
|
baseURL,
|
|
2534
2856
|
headers: getHeaders,
|
|
2535
2857
|
fetch: options.fetch,
|
|
2536
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
2858
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils19.generateId,
|
|
2537
2859
|
supportedUrls: () => ({
|
|
2538
2860
|
"image/*": [/^https?:\/\/.*$/]
|
|
2539
2861
|
})
|