@ai-sdk/anthropic 3.0.0-beta.21 → 3.0.0-beta.23
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 +12 -0
- package/dist/index.d.mts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +448 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +434 -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 +442 -108
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +433 -95
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
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 ? "3.0.0-beta.
|
|
34
|
+
var VERSION = true ? "3.0.0-beta.23" : "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 },
|
|
@@ -1010,6 +1221,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1010
1221
|
cache_control: void 0
|
|
1011
1222
|
};
|
|
1012
1223
|
}
|
|
1224
|
+
if (contentPart.mediaType === "application/pdf") {
|
|
1225
|
+
betas.add("pdfs-2024-09-25");
|
|
1226
|
+
return {
|
|
1227
|
+
type: "document",
|
|
1228
|
+
source: {
|
|
1229
|
+
type: "base64",
|
|
1230
|
+
media_type: contentPart.mediaType,
|
|
1231
|
+
data: contentPart.data
|
|
1232
|
+
},
|
|
1233
|
+
cache_control: void 0
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1013
1236
|
throw new import_provider2.UnsupportedFunctionalityError({
|
|
1014
1237
|
functionality: `media type: ${contentPart.mediaType}`
|
|
1015
1238
|
});
|
|
@@ -1075,7 +1298,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1075
1298
|
}
|
|
1076
1299
|
case "reasoning": {
|
|
1077
1300
|
if (sendReasoning) {
|
|
1078
|
-
const reasoningMetadata = await (0,
|
|
1301
|
+
const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
|
|
1079
1302
|
provider: "anthropic",
|
|
1080
1303
|
providerOptions: part.providerOptions,
|
|
1081
1304
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -1116,7 +1339,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1116
1339
|
}
|
|
1117
1340
|
case "tool-call": {
|
|
1118
1341
|
if (part.providerExecuted) {
|
|
1119
|
-
if (part.toolName === "code_execution"
|
|
1342
|
+
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")) {
|
|
1343
|
+
anthropicContent.push({
|
|
1344
|
+
type: "server_tool_use",
|
|
1345
|
+
id: part.toolCallId,
|
|
1346
|
+
name: part.input.type,
|
|
1347
|
+
// map back to subtool name
|
|
1348
|
+
input: part.input,
|
|
1349
|
+
cache_control: cacheControl
|
|
1350
|
+
});
|
|
1351
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1352
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1120
1353
|
anthropicContent.push({
|
|
1121
1354
|
type: "server_tool_use",
|
|
1122
1355
|
id: part.toolCallId,
|
|
@@ -1151,21 +1384,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1151
1384
|
});
|
|
1152
1385
|
break;
|
|
1153
1386
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1387
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1388
|
+
warnings.push({
|
|
1389
|
+
type: "other",
|
|
1390
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1391
|
+
});
|
|
1392
|
+
break;
|
|
1393
|
+
}
|
|
1394
|
+
if (output.value.type === "code_execution_result") {
|
|
1395
|
+
const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
|
|
1396
|
+
value: output.value,
|
|
1397
|
+
schema: codeExecution_20250522OutputSchema
|
|
1398
|
+
});
|
|
1399
|
+
anthropicContent.push({
|
|
1400
|
+
type: "code_execution_tool_result",
|
|
1401
|
+
tool_use_id: part.toolCallId,
|
|
1402
|
+
content: {
|
|
1403
|
+
type: codeExecutionOutput.type,
|
|
1404
|
+
stdout: codeExecutionOutput.stdout,
|
|
1405
|
+
stderr: codeExecutionOutput.stderr,
|
|
1406
|
+
return_code: codeExecutionOutput.return_code
|
|
1407
|
+
},
|
|
1408
|
+
cache_control: cacheControl
|
|
1409
|
+
});
|
|
1410
|
+
} else {
|
|
1411
|
+
const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
|
|
1412
|
+
value: output.value,
|
|
1413
|
+
schema: codeExecution_20250825OutputSchema
|
|
1414
|
+
});
|
|
1415
|
+
anthropicContent.push(
|
|
1416
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1417
|
+
type: "bash_code_execution_tool_result",
|
|
1418
|
+
tool_use_id: part.toolCallId,
|
|
1419
|
+
cache_control: cacheControl,
|
|
1420
|
+
content: codeExecutionOutput
|
|
1421
|
+
} : {
|
|
1422
|
+
type: "text_editor_code_execution_tool_result",
|
|
1423
|
+
tool_use_id: part.toolCallId,
|
|
1424
|
+
cache_control: cacheControl,
|
|
1425
|
+
content: codeExecutionOutput
|
|
1426
|
+
}
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1169
1429
|
break;
|
|
1170
1430
|
}
|
|
1171
1431
|
if (part.toolName === "web_fetch") {
|
|
@@ -1177,7 +1437,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1177
1437
|
});
|
|
1178
1438
|
break;
|
|
1179
1439
|
}
|
|
1180
|
-
const webFetchOutput = await (0,
|
|
1440
|
+
const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
|
|
1181
1441
|
value: output.value,
|
|
1182
1442
|
schema: webFetch_20250910OutputSchema
|
|
1183
1443
|
});
|
|
@@ -1212,7 +1472,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1212
1472
|
});
|
|
1213
1473
|
break;
|
|
1214
1474
|
}
|
|
1215
|
-
const webSearchOutput = await (0,
|
|
1475
|
+
const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
|
|
1216
1476
|
value: output.value,
|
|
1217
1477
|
schema: webSearch_20250305OutputSchema
|
|
1218
1478
|
});
|
|
@@ -1357,7 +1617,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1357
1617
|
var _a;
|
|
1358
1618
|
this.modelId = modelId;
|
|
1359
1619
|
this.config = config;
|
|
1360
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1620
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
|
|
1361
1621
|
}
|
|
1362
1622
|
supportsUrl(url) {
|
|
1363
1623
|
return url.protocol === "https:";
|
|
@@ -1426,7 +1686,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1426
1686
|
description: "Respond with a JSON object.",
|
|
1427
1687
|
inputSchema: responseFormat.schema
|
|
1428
1688
|
} : void 0;
|
|
1429
|
-
const anthropicOptions = await (0,
|
|
1689
|
+
const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
|
|
1430
1690
|
provider: "anthropic",
|
|
1431
1691
|
providerOptions,
|
|
1432
1692
|
schema: anthropicProviderOptions
|
|
@@ -1518,8 +1778,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1518
1778
|
betas,
|
|
1519
1779
|
headers
|
|
1520
1780
|
}) {
|
|
1521
|
-
return (0,
|
|
1522
|
-
await (0,
|
|
1781
|
+
return (0, import_provider_utils11.combineHeaders)(
|
|
1782
|
+
await (0, import_provider_utils11.resolve)(this.config.headers),
|
|
1523
1783
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
1524
1784
|
headers
|
|
1525
1785
|
);
|
|
@@ -1563,12 +1823,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1563
1823
|
responseHeaders,
|
|
1564
1824
|
value: response,
|
|
1565
1825
|
rawValue: rawResponse
|
|
1566
|
-
} = await (0,
|
|
1826
|
+
} = await (0, import_provider_utils11.postJsonToApi)({
|
|
1567
1827
|
url: this.buildRequestUrl(false),
|
|
1568
1828
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1569
1829
|
body: this.transformRequestBody(args),
|
|
1570
1830
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1571
|
-
successfulResponseHandler: (0,
|
|
1831
|
+
successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
|
|
1572
1832
|
anthropicMessagesResponseSchema
|
|
1573
1833
|
),
|
|
1574
1834
|
abortSignal: options.abortSignal,
|
|
@@ -1635,7 +1895,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1635
1895
|
break;
|
|
1636
1896
|
}
|
|
1637
1897
|
case "server_tool_use": {
|
|
1638
|
-
if (part.name === "
|
|
1898
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1899
|
+
content.push({
|
|
1900
|
+
type: "tool-call",
|
|
1901
|
+
toolCallId: part.id,
|
|
1902
|
+
toolName: "code_execution",
|
|
1903
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1904
|
+
providerExecuted: true
|
|
1905
|
+
});
|
|
1906
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1639
1907
|
content.push({
|
|
1640
1908
|
type: "tool-call",
|
|
1641
1909
|
toolCallId: part.id,
|
|
@@ -1731,6 +1999,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1731
1999
|
}
|
|
1732
2000
|
break;
|
|
1733
2001
|
}
|
|
2002
|
+
// code execution 20250522:
|
|
1734
2003
|
case "code_execution_tool_result": {
|
|
1735
2004
|
if (part.content.type === "code_execution_result") {
|
|
1736
2005
|
content.push({
|
|
@@ -1760,6 +2029,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1760
2029
|
}
|
|
1761
2030
|
break;
|
|
1762
2031
|
}
|
|
2032
|
+
// code execution 20250825:
|
|
2033
|
+
case "bash_code_execution_tool_result":
|
|
2034
|
+
case "text_editor_code_execution_tool_result": {
|
|
2035
|
+
content.push({
|
|
2036
|
+
type: "tool-result",
|
|
2037
|
+
toolCallId: part.tool_use_id,
|
|
2038
|
+
toolName: "code_execution",
|
|
2039
|
+
result: part.content,
|
|
2040
|
+
providerExecuted: true
|
|
2041
|
+
});
|
|
2042
|
+
break;
|
|
2043
|
+
}
|
|
1763
2044
|
}
|
|
1764
2045
|
}
|
|
1765
2046
|
return {
|
|
@@ -1795,12 +2076,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1795
2076
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1796
2077
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1797
2078
|
const body = { ...args, stream: true };
|
|
1798
|
-
const { responseHeaders, value: response } = await (0,
|
|
2079
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
|
|
1799
2080
|
url: this.buildRequestUrl(true),
|
|
1800
2081
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1801
2082
|
body: this.transformRequestBody(body),
|
|
1802
2083
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1803
|
-
successfulResponseHandler: (0,
|
|
2084
|
+
successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
|
|
1804
2085
|
anthropicMessagesChunkSchema
|
|
1805
2086
|
),
|
|
1806
2087
|
abortSignal: options.abortSignal,
|
|
@@ -1876,7 +2157,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1876
2157
|
type: "tool-call",
|
|
1877
2158
|
toolCallId: value.content_block.id,
|
|
1878
2159
|
toolName: value.content_block.name,
|
|
1879
|
-
input: ""
|
|
2160
|
+
input: "",
|
|
2161
|
+
firstDelta: true
|
|
1880
2162
|
};
|
|
1881
2163
|
controller.enqueue(
|
|
1882
2164
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1888,18 +2170,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1888
2170
|
return;
|
|
1889
2171
|
}
|
|
1890
2172
|
case "server_tool_use": {
|
|
1891
|
-
if (
|
|
2173
|
+
if ([
|
|
2174
|
+
"web_fetch",
|
|
2175
|
+
"web_search",
|
|
2176
|
+
// code execution 20250825:
|
|
2177
|
+
"code_execution",
|
|
2178
|
+
// code execution 20250825 text editor:
|
|
2179
|
+
"text_editor_code_execution",
|
|
2180
|
+
// code execution 20250825 bash:
|
|
2181
|
+
"bash_code_execution"
|
|
2182
|
+
].includes(value.content_block.name)) {
|
|
1892
2183
|
contentBlocks[value.index] = {
|
|
1893
2184
|
type: "tool-call",
|
|
1894
2185
|
toolCallId: value.content_block.id,
|
|
1895
2186
|
toolName: value.content_block.name,
|
|
1896
2187
|
input: "",
|
|
1897
|
-
providerExecuted: true
|
|
2188
|
+
providerExecuted: true,
|
|
2189
|
+
firstDelta: true
|
|
1898
2190
|
};
|
|
2191
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1899
2192
|
controller.enqueue({
|
|
1900
2193
|
type: "tool-input-start",
|
|
1901
2194
|
id: value.content_block.id,
|
|
1902
|
-
toolName:
|
|
2195
|
+
toolName: mappedToolName,
|
|
1903
2196
|
providerExecuted: true
|
|
1904
2197
|
});
|
|
1905
2198
|
}
|
|
@@ -1991,6 +2284,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1991
2284
|
}
|
|
1992
2285
|
return;
|
|
1993
2286
|
}
|
|
2287
|
+
// code execution 20250522:
|
|
1994
2288
|
case "code_execution_tool_result": {
|
|
1995
2289
|
const part = value.content_block;
|
|
1996
2290
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2021,6 +2315,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2021
2315
|
}
|
|
2022
2316
|
return;
|
|
2023
2317
|
}
|
|
2318
|
+
// code execution 20250825:
|
|
2319
|
+
case "bash_code_execution_tool_result":
|
|
2320
|
+
case "text_editor_code_execution_tool_result": {
|
|
2321
|
+
const part = value.content_block;
|
|
2322
|
+
controller.enqueue({
|
|
2323
|
+
type: "tool-result",
|
|
2324
|
+
toolCallId: part.tool_use_id,
|
|
2325
|
+
toolName: "code_execution",
|
|
2326
|
+
result: part.content,
|
|
2327
|
+
providerExecuted: true
|
|
2328
|
+
});
|
|
2329
|
+
return;
|
|
2330
|
+
}
|
|
2024
2331
|
default: {
|
|
2025
2332
|
const _exhaustiveCheck = contentBlockType;
|
|
2026
2333
|
throw new Error(
|
|
@@ -2053,7 +2360,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2053
2360
|
type: "tool-input-end",
|
|
2054
2361
|
id: contentBlock.toolCallId
|
|
2055
2362
|
});
|
|
2056
|
-
|
|
2363
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2364
|
+
controller.enqueue({
|
|
2365
|
+
type: "tool-call",
|
|
2366
|
+
toolCallId: contentBlock.toolCallId,
|
|
2367
|
+
toolName,
|
|
2368
|
+
input: contentBlock.input,
|
|
2369
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2370
|
+
});
|
|
2057
2371
|
}
|
|
2058
2372
|
break;
|
|
2059
2373
|
}
|
|
@@ -2101,7 +2415,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2101
2415
|
}
|
|
2102
2416
|
case "input_json_delta": {
|
|
2103
2417
|
const contentBlock = contentBlocks[value.index];
|
|
2104
|
-
|
|
2418
|
+
let delta = value.delta.partial_json;
|
|
2419
|
+
if (delta.length === 0) {
|
|
2420
|
+
return;
|
|
2421
|
+
}
|
|
2105
2422
|
if (usesJsonResponseTool) {
|
|
2106
2423
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2107
2424
|
return;
|
|
@@ -2115,12 +2432,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2115
2432
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2116
2433
|
return;
|
|
2117
2434
|
}
|
|
2435
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2436
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2437
|
+
}
|
|
2118
2438
|
controller.enqueue({
|
|
2119
2439
|
type: "tool-input-delta",
|
|
2120
2440
|
id: contentBlock.toolCallId,
|
|
2121
2441
|
delta
|
|
2122
2442
|
});
|
|
2123
2443
|
contentBlock.input += delta;
|
|
2444
|
+
contentBlock.firstDelta = false;
|
|
2124
2445
|
}
|
|
2125
2446
|
return;
|
|
2126
2447
|
}
|
|
@@ -2206,46 +2527,46 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2206
2527
|
};
|
|
2207
2528
|
|
|
2208
2529
|
// src/tool/bash_20241022.ts
|
|
2209
|
-
var
|
|
2210
|
-
var
|
|
2211
|
-
var bash_20241022InputSchema = (0,
|
|
2212
|
-
() => (0,
|
|
2213
|
-
|
|
2214
|
-
command:
|
|
2215
|
-
restart:
|
|
2530
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2531
|
+
var import_v49 = require("zod/v4");
|
|
2532
|
+
var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
2533
|
+
() => (0, import_provider_utils12.zodSchema)(
|
|
2534
|
+
import_v49.z.object({
|
|
2535
|
+
command: import_v49.z.string(),
|
|
2536
|
+
restart: import_v49.z.boolean().optional()
|
|
2216
2537
|
})
|
|
2217
2538
|
)
|
|
2218
2539
|
);
|
|
2219
|
-
var bash_20241022 = (0,
|
|
2540
|
+
var bash_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
2220
2541
|
id: "anthropic.bash_20241022",
|
|
2221
2542
|
name: "bash",
|
|
2222
2543
|
inputSchema: bash_20241022InputSchema
|
|
2223
2544
|
});
|
|
2224
2545
|
|
|
2225
2546
|
// src/tool/bash_20250124.ts
|
|
2226
|
-
var
|
|
2227
|
-
var
|
|
2228
|
-
var bash_20250124InputSchema = (0,
|
|
2229
|
-
() => (0,
|
|
2230
|
-
|
|
2231
|
-
command:
|
|
2232
|
-
restart:
|
|
2547
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2548
|
+
var import_v410 = require("zod/v4");
|
|
2549
|
+
var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
2550
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
2551
|
+
import_v410.z.object({
|
|
2552
|
+
command: import_v410.z.string(),
|
|
2553
|
+
restart: import_v410.z.boolean().optional()
|
|
2233
2554
|
})
|
|
2234
2555
|
)
|
|
2235
2556
|
);
|
|
2236
|
-
var bash_20250124 = (0,
|
|
2557
|
+
var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
2237
2558
|
id: "anthropic.bash_20250124",
|
|
2238
2559
|
name: "bash",
|
|
2239
2560
|
inputSchema: bash_20250124InputSchema
|
|
2240
2561
|
});
|
|
2241
2562
|
|
|
2242
2563
|
// src/tool/computer_20241022.ts
|
|
2243
|
-
var
|
|
2244
|
-
var
|
|
2245
|
-
var computer_20241022InputSchema = (0,
|
|
2246
|
-
() => (0,
|
|
2247
|
-
|
|
2248
|
-
action:
|
|
2564
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2565
|
+
var import_v411 = require("zod/v4");
|
|
2566
|
+
var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2567
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2568
|
+
import_v411.z.object({
|
|
2569
|
+
action: import_v411.z.enum([
|
|
2249
2570
|
"key",
|
|
2250
2571
|
"type",
|
|
2251
2572
|
"mouse_move",
|
|
@@ -2257,24 +2578,24 @@ var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
|
2257
2578
|
"screenshot",
|
|
2258
2579
|
"cursor_position"
|
|
2259
2580
|
]),
|
|
2260
|
-
coordinate:
|
|
2261
|
-
text:
|
|
2581
|
+
coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
|
|
2582
|
+
text: import_v411.z.string().optional()
|
|
2262
2583
|
})
|
|
2263
2584
|
)
|
|
2264
2585
|
);
|
|
2265
|
-
var computer_20241022 = (0,
|
|
2586
|
+
var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
2266
2587
|
id: "anthropic.computer_20241022",
|
|
2267
2588
|
name: "computer",
|
|
2268
2589
|
inputSchema: computer_20241022InputSchema
|
|
2269
2590
|
});
|
|
2270
2591
|
|
|
2271
2592
|
// src/tool/computer_20250124.ts
|
|
2272
|
-
var
|
|
2273
|
-
var
|
|
2274
|
-
var computer_20250124InputSchema = (0,
|
|
2275
|
-
() => (0,
|
|
2276
|
-
|
|
2277
|
-
action:
|
|
2593
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2594
|
+
var import_v412 = require("zod/v4");
|
|
2595
|
+
var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
2596
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
2597
|
+
import_v412.z.object({
|
|
2598
|
+
action: import_v412.z.enum([
|
|
2278
2599
|
"key",
|
|
2279
2600
|
"hold_key",
|
|
2280
2601
|
"type",
|
|
@@ -2292,47 +2613,25 @@ var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
2292
2613
|
"wait",
|
|
2293
2614
|
"screenshot"
|
|
2294
2615
|
]),
|
|
2295
|
-
coordinate:
|
|
2296
|
-
duration:
|
|
2297
|
-
scroll_amount:
|
|
2298
|
-
scroll_direction:
|
|
2299
|
-
start_coordinate:
|
|
2300
|
-
text:
|
|
2616
|
+
coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
|
|
2617
|
+
duration: import_v412.z.number().optional(),
|
|
2618
|
+
scroll_amount: import_v412.z.number().optional(),
|
|
2619
|
+
scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
|
|
2620
|
+
start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
|
|
2621
|
+
text: import_v412.z.string().optional()
|
|
2301
2622
|
})
|
|
2302
2623
|
)
|
|
2303
2624
|
);
|
|
2304
|
-
var computer_20250124 = (0,
|
|
2625
|
+
var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
2305
2626
|
id: "anthropic.computer_20250124",
|
|
2306
2627
|
name: "computer",
|
|
2307
2628
|
inputSchema: computer_20250124InputSchema
|
|
2308
2629
|
});
|
|
2309
2630
|
|
|
2310
2631
|
// src/tool/text-editor_20241022.ts
|
|
2311
|
-
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2312
|
-
var import_v412 = require("zod/v4");
|
|
2313
|
-
var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
2314
|
-
() => (0, import_provider_utils15.zodSchema)(
|
|
2315
|
-
import_v412.z.object({
|
|
2316
|
-
command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2317
|
-
path: import_v412.z.string(),
|
|
2318
|
-
file_text: import_v412.z.string().optional(),
|
|
2319
|
-
insert_line: import_v412.z.number().int().optional(),
|
|
2320
|
-
new_str: import_v412.z.string().optional(),
|
|
2321
|
-
old_str: import_v412.z.string().optional(),
|
|
2322
|
-
view_range: import_v412.z.array(import_v412.z.number().int()).optional()
|
|
2323
|
-
})
|
|
2324
|
-
)
|
|
2325
|
-
);
|
|
2326
|
-
var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
2327
|
-
id: "anthropic.text_editor_20241022",
|
|
2328
|
-
name: "str_replace_editor",
|
|
2329
|
-
inputSchema: textEditor_20241022InputSchema
|
|
2330
|
-
});
|
|
2331
|
-
|
|
2332
|
-
// src/tool/text-editor_20250124.ts
|
|
2333
2632
|
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
2334
2633
|
var import_v413 = require("zod/v4");
|
|
2335
|
-
var
|
|
2634
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
2336
2635
|
() => (0, import_provider_utils16.zodSchema)(
|
|
2337
2636
|
import_v413.z.object({
|
|
2338
2637
|
command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -2345,19 +2644,19 @@ var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
|
2345
2644
|
})
|
|
2346
2645
|
)
|
|
2347
2646
|
);
|
|
2348
|
-
var
|
|
2349
|
-
id: "anthropic.
|
|
2647
|
+
var textEditor_20241022 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
|
|
2648
|
+
id: "anthropic.text_editor_20241022",
|
|
2350
2649
|
name: "str_replace_editor",
|
|
2351
|
-
inputSchema:
|
|
2650
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2352
2651
|
});
|
|
2353
2652
|
|
|
2354
|
-
// src/tool/text-
|
|
2653
|
+
// src/tool/text-editor_20250124.ts
|
|
2355
2654
|
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
2356
2655
|
var import_v414 = require("zod/v4");
|
|
2357
|
-
var
|
|
2656
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
2358
2657
|
() => (0, import_provider_utils17.zodSchema)(
|
|
2359
2658
|
import_v414.z.object({
|
|
2360
|
-
command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
|
|
2659
|
+
command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2361
2660
|
path: import_v414.z.string(),
|
|
2362
2661
|
file_text: import_v414.z.string().optional(),
|
|
2363
2662
|
insert_line: import_v414.z.number().int().optional(),
|
|
@@ -2367,7 +2666,29 @@ var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
2367
2666
|
})
|
|
2368
2667
|
)
|
|
2369
2668
|
);
|
|
2370
|
-
var
|
|
2669
|
+
var textEditor_20250124 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
|
|
2670
|
+
id: "anthropic.text_editor_20250124",
|
|
2671
|
+
name: "str_replace_editor",
|
|
2672
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2673
|
+
});
|
|
2674
|
+
|
|
2675
|
+
// src/tool/text-editor_20250429.ts
|
|
2676
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
2677
|
+
var import_v415 = require("zod/v4");
|
|
2678
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
2679
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
2680
|
+
import_v415.z.object({
|
|
2681
|
+
command: import_v415.z.enum(["view", "create", "str_replace", "insert"]),
|
|
2682
|
+
path: import_v415.z.string(),
|
|
2683
|
+
file_text: import_v415.z.string().optional(),
|
|
2684
|
+
insert_line: import_v415.z.number().int().optional(),
|
|
2685
|
+
new_str: import_v415.z.string().optional(),
|
|
2686
|
+
old_str: import_v415.z.string().optional(),
|
|
2687
|
+
view_range: import_v415.z.array(import_v415.z.number().int()).optional()
|
|
2688
|
+
})
|
|
2689
|
+
)
|
|
2690
|
+
);
|
|
2691
|
+
var textEditor_20250429 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
|
|
2371
2692
|
id: "anthropic.text_editor_20250429",
|
|
2372
2693
|
name: "str_replace_based_edit_tool",
|
|
2373
2694
|
inputSchema: textEditor_20250429InputSchema
|
|
@@ -2404,6 +2725,19 @@ var anthropicTools = {
|
|
|
2404
2725
|
* Tool name must be `code_execution`.
|
|
2405
2726
|
*/
|
|
2406
2727
|
codeExecution_20250522,
|
|
2728
|
+
/**
|
|
2729
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2730
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2731
|
+
* the API conversation.
|
|
2732
|
+
*
|
|
2733
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2734
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2735
|
+
*
|
|
2736
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2737
|
+
*
|
|
2738
|
+
* Tool name must be `code_execution`.
|
|
2739
|
+
*/
|
|
2740
|
+
codeExecution_20250825,
|
|
2407
2741
|
/**
|
|
2408
2742
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2409
2743
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -2504,11 +2838,11 @@ var anthropicTools = {
|
|
|
2504
2838
|
// src/anthropic-provider.ts
|
|
2505
2839
|
function createAnthropic(options = {}) {
|
|
2506
2840
|
var _a;
|
|
2507
|
-
const baseURL = (_a = (0,
|
|
2508
|
-
const getHeaders = () => (0,
|
|
2841
|
+
const baseURL = (_a = (0, import_provider_utils19.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
2842
|
+
const getHeaders = () => (0, import_provider_utils19.withUserAgentSuffix)(
|
|
2509
2843
|
{
|
|
2510
2844
|
"anthropic-version": "2023-06-01",
|
|
2511
|
-
"x-api-key": (0,
|
|
2845
|
+
"x-api-key": (0, import_provider_utils19.loadApiKey)({
|
|
2512
2846
|
apiKey: options.apiKey,
|
|
2513
2847
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
2514
2848
|
description: "Anthropic"
|
|
@@ -2524,7 +2858,7 @@ function createAnthropic(options = {}) {
|
|
|
2524
2858
|
baseURL,
|
|
2525
2859
|
headers: getHeaders,
|
|
2526
2860
|
fetch: options.fetch,
|
|
2527
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
2861
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils19.generateId,
|
|
2528
2862
|
supportedUrls: () => ({
|
|
2529
2863
|
"image/*": [/^https?:\/\/.*$/]
|
|
2530
2864
|
})
|