@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.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@ai-sdk/provider-utils";
|
|
11
11
|
|
|
12
12
|
// src/version.ts
|
|
13
|
-
var VERSION = true ? "3.0.0-beta.
|
|
13
|
+
var VERSION = true ? "3.0.0-beta.23" : "0.0.0-test";
|
|
14
14
|
|
|
15
15
|
// src/anthropic-messages-language-model.ts
|
|
16
16
|
import {
|
|
@@ -156,6 +156,7 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
156
156
|
})
|
|
157
157
|
])
|
|
158
158
|
}),
|
|
159
|
+
// code execution results for code_execution_20250522 tool:
|
|
159
160
|
z2.object({
|
|
160
161
|
type: z2.literal("code_execution_tool_result"),
|
|
161
162
|
tool_use_id: z2.string(),
|
|
@@ -171,6 +172,62 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
171
172
|
error_code: z2.string()
|
|
172
173
|
})
|
|
173
174
|
])
|
|
175
|
+
}),
|
|
176
|
+
// bash code execution results for code_execution_20250825 tool:
|
|
177
|
+
z2.object({
|
|
178
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
179
|
+
tool_use_id: z2.string(),
|
|
180
|
+
content: z2.discriminatedUnion("type", [
|
|
181
|
+
z2.object({
|
|
182
|
+
type: z2.literal("bash_code_execution_result"),
|
|
183
|
+
content: z2.array(
|
|
184
|
+
z2.object({
|
|
185
|
+
type: z2.literal("bash_code_execution_output"),
|
|
186
|
+
file_id: z2.string()
|
|
187
|
+
})
|
|
188
|
+
),
|
|
189
|
+
stdout: z2.string(),
|
|
190
|
+
stderr: z2.string(),
|
|
191
|
+
return_code: z2.number()
|
|
192
|
+
}),
|
|
193
|
+
z2.object({
|
|
194
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
195
|
+
error_code: z2.string()
|
|
196
|
+
})
|
|
197
|
+
])
|
|
198
|
+
}),
|
|
199
|
+
// text editor code execution results for code_execution_20250825 tool:
|
|
200
|
+
z2.object({
|
|
201
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
202
|
+
tool_use_id: z2.string(),
|
|
203
|
+
content: z2.discriminatedUnion("type", [
|
|
204
|
+
z2.object({
|
|
205
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
206
|
+
error_code: z2.string()
|
|
207
|
+
}),
|
|
208
|
+
z2.object({
|
|
209
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
210
|
+
content: z2.string(),
|
|
211
|
+
file_type: z2.string(),
|
|
212
|
+
num_lines: z2.number().nullable(),
|
|
213
|
+
start_line: z2.number().nullable(),
|
|
214
|
+
total_lines: z2.number().nullable()
|
|
215
|
+
}),
|
|
216
|
+
z2.object({
|
|
217
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
218
|
+
is_file_update: z2.boolean()
|
|
219
|
+
}),
|
|
220
|
+
z2.object({
|
|
221
|
+
type: z2.literal(
|
|
222
|
+
"text_editor_code_execution_str_replace_result"
|
|
223
|
+
),
|
|
224
|
+
lines: z2.array(z2.string()).nullable(),
|
|
225
|
+
new_lines: z2.number().nullable(),
|
|
226
|
+
new_start: z2.number().nullable(),
|
|
227
|
+
old_lines: z2.number().nullable(),
|
|
228
|
+
old_start: z2.number().nullable()
|
|
229
|
+
})
|
|
230
|
+
])
|
|
174
231
|
})
|
|
175
232
|
])
|
|
176
233
|
),
|
|
@@ -271,6 +328,7 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
271
328
|
})
|
|
272
329
|
])
|
|
273
330
|
}),
|
|
331
|
+
// code execution results for code_execution_20250522 tool:
|
|
274
332
|
z2.object({
|
|
275
333
|
type: z2.literal("code_execution_tool_result"),
|
|
276
334
|
tool_use_id: z2.string(),
|
|
@@ -286,6 +344,62 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
286
344
|
error_code: z2.string()
|
|
287
345
|
})
|
|
288
346
|
])
|
|
347
|
+
}),
|
|
348
|
+
// bash code execution results for code_execution_20250825 tool:
|
|
349
|
+
z2.object({
|
|
350
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
351
|
+
tool_use_id: z2.string(),
|
|
352
|
+
content: z2.discriminatedUnion("type", [
|
|
353
|
+
z2.object({
|
|
354
|
+
type: z2.literal("bash_code_execution_result"),
|
|
355
|
+
content: z2.array(
|
|
356
|
+
z2.object({
|
|
357
|
+
type: z2.literal("bash_code_execution_output"),
|
|
358
|
+
file_id: z2.string()
|
|
359
|
+
})
|
|
360
|
+
),
|
|
361
|
+
stdout: z2.string(),
|
|
362
|
+
stderr: z2.string(),
|
|
363
|
+
return_code: z2.number()
|
|
364
|
+
}),
|
|
365
|
+
z2.object({
|
|
366
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
367
|
+
error_code: z2.string()
|
|
368
|
+
})
|
|
369
|
+
])
|
|
370
|
+
}),
|
|
371
|
+
// text editor code execution results for code_execution_20250825 tool:
|
|
372
|
+
z2.object({
|
|
373
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
374
|
+
tool_use_id: z2.string(),
|
|
375
|
+
content: z2.discriminatedUnion("type", [
|
|
376
|
+
z2.object({
|
|
377
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
378
|
+
error_code: z2.string()
|
|
379
|
+
}),
|
|
380
|
+
z2.object({
|
|
381
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
382
|
+
content: z2.string(),
|
|
383
|
+
file_type: z2.string(),
|
|
384
|
+
num_lines: z2.number().nullable(),
|
|
385
|
+
start_line: z2.number().nullable(),
|
|
386
|
+
total_lines: z2.number().nullable()
|
|
387
|
+
}),
|
|
388
|
+
z2.object({
|
|
389
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
390
|
+
is_file_update: z2.boolean()
|
|
391
|
+
}),
|
|
392
|
+
z2.object({
|
|
393
|
+
type: z2.literal(
|
|
394
|
+
"text_editor_code_execution_str_replace_result"
|
|
395
|
+
),
|
|
396
|
+
lines: z2.array(z2.string()).nullable(),
|
|
397
|
+
new_lines: z2.number().nullable(),
|
|
398
|
+
new_start: z2.number().nullable(),
|
|
399
|
+
old_lines: z2.number().nullable(),
|
|
400
|
+
old_start: z2.number().nullable()
|
|
401
|
+
})
|
|
402
|
+
])
|
|
289
403
|
})
|
|
290
404
|
])
|
|
291
405
|
}),
|
|
@@ -621,6 +735,14 @@ async function prepareTools({
|
|
|
621
735
|
});
|
|
622
736
|
break;
|
|
623
737
|
}
|
|
738
|
+
case "anthropic.code_execution_20250825": {
|
|
739
|
+
betas.add("code-execution-2025-08-25");
|
|
740
|
+
anthropicTools2.push({
|
|
741
|
+
type: "code_execution_20250825",
|
|
742
|
+
name: "code_execution"
|
|
743
|
+
});
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
624
746
|
case "anthropic.computer_20250124": {
|
|
625
747
|
betas.add("computer-use-2025-01-24");
|
|
626
748
|
anthropicTools2.push({
|
|
@@ -836,6 +958,99 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
836
958
|
return factory4(args);
|
|
837
959
|
};
|
|
838
960
|
|
|
961
|
+
// src/tool/code-execution_20250825.ts
|
|
962
|
+
import {
|
|
963
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
964
|
+
lazySchema as lazySchema7,
|
|
965
|
+
zodSchema as zodSchema7
|
|
966
|
+
} from "@ai-sdk/provider-utils";
|
|
967
|
+
import { z as z8 } from "zod/v4";
|
|
968
|
+
var codeExecution_20250825OutputSchema = lazySchema7(
|
|
969
|
+
() => zodSchema7(
|
|
970
|
+
z8.discriminatedUnion("type", [
|
|
971
|
+
z8.object({
|
|
972
|
+
type: z8.literal("bash_code_execution_result"),
|
|
973
|
+
content: z8.array(
|
|
974
|
+
z8.object({
|
|
975
|
+
type: z8.literal("bash_code_execution_output"),
|
|
976
|
+
file_id: z8.string()
|
|
977
|
+
})
|
|
978
|
+
),
|
|
979
|
+
stdout: z8.string(),
|
|
980
|
+
stderr: z8.string(),
|
|
981
|
+
return_code: z8.number()
|
|
982
|
+
}),
|
|
983
|
+
z8.object({
|
|
984
|
+
type: z8.literal("bash_code_execution_tool_result_error"),
|
|
985
|
+
error_code: z8.string()
|
|
986
|
+
}),
|
|
987
|
+
z8.object({
|
|
988
|
+
type: z8.literal("text_editor_code_execution_tool_result_error"),
|
|
989
|
+
error_code: z8.string()
|
|
990
|
+
}),
|
|
991
|
+
z8.object({
|
|
992
|
+
type: z8.literal("text_editor_code_execution_view_result"),
|
|
993
|
+
content: z8.string(),
|
|
994
|
+
file_type: z8.string(),
|
|
995
|
+
num_lines: z8.number().nullable(),
|
|
996
|
+
start_line: z8.number().nullable(),
|
|
997
|
+
total_lines: z8.number().nullable()
|
|
998
|
+
}),
|
|
999
|
+
z8.object({
|
|
1000
|
+
type: z8.literal("text_editor_code_execution_create_result"),
|
|
1001
|
+
is_file_update: z8.boolean()
|
|
1002
|
+
}),
|
|
1003
|
+
z8.object({
|
|
1004
|
+
type: z8.literal("text_editor_code_execution_str_replace_result"),
|
|
1005
|
+
lines: z8.array(z8.string()).nullable(),
|
|
1006
|
+
new_lines: z8.number().nullable(),
|
|
1007
|
+
new_start: z8.number().nullable(),
|
|
1008
|
+
old_lines: z8.number().nullable(),
|
|
1009
|
+
old_start: z8.number().nullable()
|
|
1010
|
+
})
|
|
1011
|
+
])
|
|
1012
|
+
)
|
|
1013
|
+
);
|
|
1014
|
+
var codeExecution_20250825InputSchema = lazySchema7(
|
|
1015
|
+
() => zodSchema7(
|
|
1016
|
+
z8.discriminatedUnion("type", [
|
|
1017
|
+
z8.object({
|
|
1018
|
+
type: z8.literal("bash_code_execution"),
|
|
1019
|
+
command: z8.string()
|
|
1020
|
+
}),
|
|
1021
|
+
z8.discriminatedUnion("command", [
|
|
1022
|
+
z8.object({
|
|
1023
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1024
|
+
command: z8.literal("view"),
|
|
1025
|
+
path: z8.string()
|
|
1026
|
+
}),
|
|
1027
|
+
z8.object({
|
|
1028
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1029
|
+
command: z8.literal("create"),
|
|
1030
|
+
path: z8.string(),
|
|
1031
|
+
file_text: z8.string().nullish()
|
|
1032
|
+
}),
|
|
1033
|
+
z8.object({
|
|
1034
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1035
|
+
command: z8.literal("str_replace"),
|
|
1036
|
+
path: z8.string(),
|
|
1037
|
+
old_str: z8.string(),
|
|
1038
|
+
new_str: z8.string()
|
|
1039
|
+
})
|
|
1040
|
+
])
|
|
1041
|
+
])
|
|
1042
|
+
)
|
|
1043
|
+
);
|
|
1044
|
+
var factory5 = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
1045
|
+
id: "anthropic.code_execution_20250825",
|
|
1046
|
+
name: "code_execution",
|
|
1047
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
1048
|
+
outputSchema: codeExecution_20250825OutputSchema
|
|
1049
|
+
});
|
|
1050
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
1051
|
+
return factory5(args);
|
|
1052
|
+
};
|
|
1053
|
+
|
|
839
1054
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
840
1055
|
function convertToString(data) {
|
|
841
1056
|
if (typeof data === "string") {
|
|
@@ -1023,6 +1238,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1023
1238
|
cache_control: void 0
|
|
1024
1239
|
};
|
|
1025
1240
|
}
|
|
1241
|
+
if (contentPart.mediaType === "application/pdf") {
|
|
1242
|
+
betas.add("pdfs-2024-09-25");
|
|
1243
|
+
return {
|
|
1244
|
+
type: "document",
|
|
1245
|
+
source: {
|
|
1246
|
+
type: "base64",
|
|
1247
|
+
media_type: contentPart.mediaType,
|
|
1248
|
+
data: contentPart.data
|
|
1249
|
+
},
|
|
1250
|
+
cache_control: void 0
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1026
1253
|
throw new UnsupportedFunctionalityError2({
|
|
1027
1254
|
functionality: `media type: ${contentPart.mediaType}`
|
|
1028
1255
|
});
|
|
@@ -1129,7 +1356,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1129
1356
|
}
|
|
1130
1357
|
case "tool-call": {
|
|
1131
1358
|
if (part.providerExecuted) {
|
|
1132
|
-
if (part.toolName === "code_execution"
|
|
1359
|
+
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")) {
|
|
1360
|
+
anthropicContent.push({
|
|
1361
|
+
type: "server_tool_use",
|
|
1362
|
+
id: part.toolCallId,
|
|
1363
|
+
name: part.input.type,
|
|
1364
|
+
// map back to subtool name
|
|
1365
|
+
input: part.input,
|
|
1366
|
+
cache_control: cacheControl
|
|
1367
|
+
});
|
|
1368
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1369
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1133
1370
|
anthropicContent.push({
|
|
1134
1371
|
type: "server_tool_use",
|
|
1135
1372
|
id: part.toolCallId,
|
|
@@ -1164,21 +1401,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1164
1401
|
});
|
|
1165
1402
|
break;
|
|
1166
1403
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1404
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1405
|
+
warnings.push({
|
|
1406
|
+
type: "other",
|
|
1407
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1408
|
+
});
|
|
1409
|
+
break;
|
|
1410
|
+
}
|
|
1411
|
+
if (output.value.type === "code_execution_result") {
|
|
1412
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1413
|
+
value: output.value,
|
|
1414
|
+
schema: codeExecution_20250522OutputSchema
|
|
1415
|
+
});
|
|
1416
|
+
anthropicContent.push({
|
|
1417
|
+
type: "code_execution_tool_result",
|
|
1418
|
+
tool_use_id: part.toolCallId,
|
|
1419
|
+
content: {
|
|
1420
|
+
type: codeExecutionOutput.type,
|
|
1421
|
+
stdout: codeExecutionOutput.stdout,
|
|
1422
|
+
stderr: codeExecutionOutput.stderr,
|
|
1423
|
+
return_code: codeExecutionOutput.return_code
|
|
1424
|
+
},
|
|
1425
|
+
cache_control: cacheControl
|
|
1426
|
+
});
|
|
1427
|
+
} else {
|
|
1428
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1429
|
+
value: output.value,
|
|
1430
|
+
schema: codeExecution_20250825OutputSchema
|
|
1431
|
+
});
|
|
1432
|
+
anthropicContent.push(
|
|
1433
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1434
|
+
type: "bash_code_execution_tool_result",
|
|
1435
|
+
tool_use_id: part.toolCallId,
|
|
1436
|
+
cache_control: cacheControl,
|
|
1437
|
+
content: codeExecutionOutput
|
|
1438
|
+
} : {
|
|
1439
|
+
type: "text_editor_code_execution_tool_result",
|
|
1440
|
+
tool_use_id: part.toolCallId,
|
|
1441
|
+
cache_control: cacheControl,
|
|
1442
|
+
content: codeExecutionOutput
|
|
1443
|
+
}
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1182
1446
|
break;
|
|
1183
1447
|
}
|
|
1184
1448
|
if (part.toolName === "web_fetch") {
|
|
@@ -1648,7 +1912,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1648
1912
|
break;
|
|
1649
1913
|
}
|
|
1650
1914
|
case "server_tool_use": {
|
|
1651
|
-
if (part.name === "
|
|
1915
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1916
|
+
content.push({
|
|
1917
|
+
type: "tool-call",
|
|
1918
|
+
toolCallId: part.id,
|
|
1919
|
+
toolName: "code_execution",
|
|
1920
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1921
|
+
providerExecuted: true
|
|
1922
|
+
});
|
|
1923
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1652
1924
|
content.push({
|
|
1653
1925
|
type: "tool-call",
|
|
1654
1926
|
toolCallId: part.id,
|
|
@@ -1744,6 +2016,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1744
2016
|
}
|
|
1745
2017
|
break;
|
|
1746
2018
|
}
|
|
2019
|
+
// code execution 20250522:
|
|
1747
2020
|
case "code_execution_tool_result": {
|
|
1748
2021
|
if (part.content.type === "code_execution_result") {
|
|
1749
2022
|
content.push({
|
|
@@ -1773,6 +2046,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1773
2046
|
}
|
|
1774
2047
|
break;
|
|
1775
2048
|
}
|
|
2049
|
+
// code execution 20250825:
|
|
2050
|
+
case "bash_code_execution_tool_result":
|
|
2051
|
+
case "text_editor_code_execution_tool_result": {
|
|
2052
|
+
content.push({
|
|
2053
|
+
type: "tool-result",
|
|
2054
|
+
toolCallId: part.tool_use_id,
|
|
2055
|
+
toolName: "code_execution",
|
|
2056
|
+
result: part.content,
|
|
2057
|
+
providerExecuted: true
|
|
2058
|
+
});
|
|
2059
|
+
break;
|
|
2060
|
+
}
|
|
1776
2061
|
}
|
|
1777
2062
|
}
|
|
1778
2063
|
return {
|
|
@@ -1889,7 +2174,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1889
2174
|
type: "tool-call",
|
|
1890
2175
|
toolCallId: value.content_block.id,
|
|
1891
2176
|
toolName: value.content_block.name,
|
|
1892
|
-
input: ""
|
|
2177
|
+
input: "",
|
|
2178
|
+
firstDelta: true
|
|
1893
2179
|
};
|
|
1894
2180
|
controller.enqueue(
|
|
1895
2181
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1901,18 +2187,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1901
2187
|
return;
|
|
1902
2188
|
}
|
|
1903
2189
|
case "server_tool_use": {
|
|
1904
|
-
if (
|
|
2190
|
+
if ([
|
|
2191
|
+
"web_fetch",
|
|
2192
|
+
"web_search",
|
|
2193
|
+
// code execution 20250825:
|
|
2194
|
+
"code_execution",
|
|
2195
|
+
// code execution 20250825 text editor:
|
|
2196
|
+
"text_editor_code_execution",
|
|
2197
|
+
// code execution 20250825 bash:
|
|
2198
|
+
"bash_code_execution"
|
|
2199
|
+
].includes(value.content_block.name)) {
|
|
1905
2200
|
contentBlocks[value.index] = {
|
|
1906
2201
|
type: "tool-call",
|
|
1907
2202
|
toolCallId: value.content_block.id,
|
|
1908
2203
|
toolName: value.content_block.name,
|
|
1909
2204
|
input: "",
|
|
1910
|
-
providerExecuted: true
|
|
2205
|
+
providerExecuted: true,
|
|
2206
|
+
firstDelta: true
|
|
1911
2207
|
};
|
|
2208
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1912
2209
|
controller.enqueue({
|
|
1913
2210
|
type: "tool-input-start",
|
|
1914
2211
|
id: value.content_block.id,
|
|
1915
|
-
toolName:
|
|
2212
|
+
toolName: mappedToolName,
|
|
1916
2213
|
providerExecuted: true
|
|
1917
2214
|
});
|
|
1918
2215
|
}
|
|
@@ -2004,6 +2301,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2004
2301
|
}
|
|
2005
2302
|
return;
|
|
2006
2303
|
}
|
|
2304
|
+
// code execution 20250522:
|
|
2007
2305
|
case "code_execution_tool_result": {
|
|
2008
2306
|
const part = value.content_block;
|
|
2009
2307
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2034,6 +2332,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2034
2332
|
}
|
|
2035
2333
|
return;
|
|
2036
2334
|
}
|
|
2335
|
+
// code execution 20250825:
|
|
2336
|
+
case "bash_code_execution_tool_result":
|
|
2337
|
+
case "text_editor_code_execution_tool_result": {
|
|
2338
|
+
const part = value.content_block;
|
|
2339
|
+
controller.enqueue({
|
|
2340
|
+
type: "tool-result",
|
|
2341
|
+
toolCallId: part.tool_use_id,
|
|
2342
|
+
toolName: "code_execution",
|
|
2343
|
+
result: part.content,
|
|
2344
|
+
providerExecuted: true
|
|
2345
|
+
});
|
|
2346
|
+
return;
|
|
2347
|
+
}
|
|
2037
2348
|
default: {
|
|
2038
2349
|
const _exhaustiveCheck = contentBlockType;
|
|
2039
2350
|
throw new Error(
|
|
@@ -2066,7 +2377,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2066
2377
|
type: "tool-input-end",
|
|
2067
2378
|
id: contentBlock.toolCallId
|
|
2068
2379
|
});
|
|
2069
|
-
|
|
2380
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2381
|
+
controller.enqueue({
|
|
2382
|
+
type: "tool-call",
|
|
2383
|
+
toolCallId: contentBlock.toolCallId,
|
|
2384
|
+
toolName,
|
|
2385
|
+
input: contentBlock.input,
|
|
2386
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2387
|
+
});
|
|
2070
2388
|
}
|
|
2071
2389
|
break;
|
|
2072
2390
|
}
|
|
@@ -2114,7 +2432,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2114
2432
|
}
|
|
2115
2433
|
case "input_json_delta": {
|
|
2116
2434
|
const contentBlock = contentBlocks[value.index];
|
|
2117
|
-
|
|
2435
|
+
let delta = value.delta.partial_json;
|
|
2436
|
+
if (delta.length === 0) {
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2118
2439
|
if (usesJsonResponseTool) {
|
|
2119
2440
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2120
2441
|
return;
|
|
@@ -2128,12 +2449,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2128
2449
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2129
2450
|
return;
|
|
2130
2451
|
}
|
|
2452
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2453
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2454
|
+
}
|
|
2131
2455
|
controller.enqueue({
|
|
2132
2456
|
type: "tool-input-delta",
|
|
2133
2457
|
id: contentBlock.toolCallId,
|
|
2134
2458
|
delta
|
|
2135
2459
|
});
|
|
2136
2460
|
contentBlock.input += delta;
|
|
2461
|
+
contentBlock.firstDelta = false;
|
|
2137
2462
|
}
|
|
2138
2463
|
return;
|
|
2139
2464
|
}
|
|
@@ -2221,15 +2546,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2221
2546
|
// src/tool/bash_20241022.ts
|
|
2222
2547
|
import {
|
|
2223
2548
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2224
|
-
lazySchema as
|
|
2225
|
-
zodSchema as
|
|
2549
|
+
lazySchema as lazySchema8,
|
|
2550
|
+
zodSchema as zodSchema8
|
|
2226
2551
|
} from "@ai-sdk/provider-utils";
|
|
2227
|
-
import { z as
|
|
2228
|
-
var bash_20241022InputSchema =
|
|
2229
|
-
() =>
|
|
2230
|
-
|
|
2231
|
-
command:
|
|
2232
|
-
restart:
|
|
2552
|
+
import { z as z9 } from "zod/v4";
|
|
2553
|
+
var bash_20241022InputSchema = lazySchema8(
|
|
2554
|
+
() => zodSchema8(
|
|
2555
|
+
z9.object({
|
|
2556
|
+
command: z9.string(),
|
|
2557
|
+
restart: z9.boolean().optional()
|
|
2233
2558
|
})
|
|
2234
2559
|
)
|
|
2235
2560
|
);
|
|
@@ -2242,15 +2567,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2242
2567
|
// src/tool/bash_20250124.ts
|
|
2243
2568
|
import {
|
|
2244
2569
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2245
|
-
lazySchema as
|
|
2246
|
-
zodSchema as
|
|
2570
|
+
lazySchema as lazySchema9,
|
|
2571
|
+
zodSchema as zodSchema9
|
|
2247
2572
|
} from "@ai-sdk/provider-utils";
|
|
2248
|
-
import { z as
|
|
2249
|
-
var bash_20250124InputSchema =
|
|
2250
|
-
() =>
|
|
2251
|
-
|
|
2252
|
-
command:
|
|
2253
|
-
restart:
|
|
2573
|
+
import { z as z10 } from "zod/v4";
|
|
2574
|
+
var bash_20250124InputSchema = lazySchema9(
|
|
2575
|
+
() => zodSchema9(
|
|
2576
|
+
z10.object({
|
|
2577
|
+
command: z10.string(),
|
|
2578
|
+
restart: z10.boolean().optional()
|
|
2254
2579
|
})
|
|
2255
2580
|
)
|
|
2256
2581
|
);
|
|
@@ -2263,14 +2588,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2263
2588
|
// src/tool/computer_20241022.ts
|
|
2264
2589
|
import {
|
|
2265
2590
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2266
|
-
lazySchema as
|
|
2267
|
-
zodSchema as
|
|
2591
|
+
lazySchema as lazySchema10,
|
|
2592
|
+
zodSchema as zodSchema10
|
|
2268
2593
|
} from "@ai-sdk/provider-utils";
|
|
2269
|
-
import { z as
|
|
2270
|
-
var computer_20241022InputSchema =
|
|
2271
|
-
() =>
|
|
2272
|
-
|
|
2273
|
-
action:
|
|
2594
|
+
import { z as z11 } from "zod/v4";
|
|
2595
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2596
|
+
() => zodSchema10(
|
|
2597
|
+
z11.object({
|
|
2598
|
+
action: z11.enum([
|
|
2274
2599
|
"key",
|
|
2275
2600
|
"type",
|
|
2276
2601
|
"mouse_move",
|
|
@@ -2282,8 +2607,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2282
2607
|
"screenshot",
|
|
2283
2608
|
"cursor_position"
|
|
2284
2609
|
]),
|
|
2285
|
-
coordinate:
|
|
2286
|
-
text:
|
|
2610
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2611
|
+
text: z11.string().optional()
|
|
2287
2612
|
})
|
|
2288
2613
|
)
|
|
2289
2614
|
);
|
|
@@ -2296,14 +2621,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2296
2621
|
// src/tool/computer_20250124.ts
|
|
2297
2622
|
import {
|
|
2298
2623
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2299
|
-
lazySchema as
|
|
2300
|
-
zodSchema as
|
|
2624
|
+
lazySchema as lazySchema11,
|
|
2625
|
+
zodSchema as zodSchema11
|
|
2301
2626
|
} from "@ai-sdk/provider-utils";
|
|
2302
|
-
import { z as
|
|
2303
|
-
var computer_20250124InputSchema =
|
|
2304
|
-
() =>
|
|
2305
|
-
|
|
2306
|
-
action:
|
|
2627
|
+
import { z as z12 } from "zod/v4";
|
|
2628
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2629
|
+
() => zodSchema11(
|
|
2630
|
+
z12.object({
|
|
2631
|
+
action: z12.enum([
|
|
2307
2632
|
"key",
|
|
2308
2633
|
"hold_key",
|
|
2309
2634
|
"type",
|
|
@@ -2321,12 +2646,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2321
2646
|
"wait",
|
|
2322
2647
|
"screenshot"
|
|
2323
2648
|
]),
|
|
2324
|
-
coordinate:
|
|
2325
|
-
duration:
|
|
2326
|
-
scroll_amount:
|
|
2327
|
-
scroll_direction:
|
|
2328
|
-
start_coordinate:
|
|
2329
|
-
text:
|
|
2649
|
+
coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2650
|
+
duration: z12.number().optional(),
|
|
2651
|
+
scroll_amount: z12.number().optional(),
|
|
2652
|
+
scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
|
|
2653
|
+
start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2654
|
+
text: z12.string().optional()
|
|
2330
2655
|
})
|
|
2331
2656
|
)
|
|
2332
2657
|
);
|
|
@@ -2339,37 +2664,11 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2339
2664
|
// src/tool/text-editor_20241022.ts
|
|
2340
2665
|
import {
|
|
2341
2666
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2342
|
-
lazySchema as lazySchema11,
|
|
2343
|
-
zodSchema as zodSchema11
|
|
2344
|
-
} from "@ai-sdk/provider-utils";
|
|
2345
|
-
import { z as z12 } from "zod/v4";
|
|
2346
|
-
var textEditor_20241022InputSchema = lazySchema11(
|
|
2347
|
-
() => zodSchema11(
|
|
2348
|
-
z12.object({
|
|
2349
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2350
|
-
path: z12.string(),
|
|
2351
|
-
file_text: z12.string().optional(),
|
|
2352
|
-
insert_line: z12.number().int().optional(),
|
|
2353
|
-
new_str: z12.string().optional(),
|
|
2354
|
-
old_str: z12.string().optional(),
|
|
2355
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2356
|
-
})
|
|
2357
|
-
)
|
|
2358
|
-
);
|
|
2359
|
-
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2360
|
-
id: "anthropic.text_editor_20241022",
|
|
2361
|
-
name: "str_replace_editor",
|
|
2362
|
-
inputSchema: textEditor_20241022InputSchema
|
|
2363
|
-
});
|
|
2364
|
-
|
|
2365
|
-
// src/tool/text-editor_20250124.ts
|
|
2366
|
-
import {
|
|
2367
|
-
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2368
2667
|
lazySchema as lazySchema12,
|
|
2369
2668
|
zodSchema as zodSchema12
|
|
2370
2669
|
} from "@ai-sdk/provider-utils";
|
|
2371
2670
|
import { z as z13 } from "zod/v4";
|
|
2372
|
-
var
|
|
2671
|
+
var textEditor_20241022InputSchema = lazySchema12(
|
|
2373
2672
|
() => zodSchema12(
|
|
2374
2673
|
z13.object({
|
|
2375
2674
|
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -2382,23 +2681,23 @@ var textEditor_20250124InputSchema = lazySchema12(
|
|
|
2382
2681
|
})
|
|
2383
2682
|
)
|
|
2384
2683
|
);
|
|
2385
|
-
var
|
|
2386
|
-
id: "anthropic.
|
|
2684
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2685
|
+
id: "anthropic.text_editor_20241022",
|
|
2387
2686
|
name: "str_replace_editor",
|
|
2388
|
-
inputSchema:
|
|
2687
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2389
2688
|
});
|
|
2390
2689
|
|
|
2391
|
-
// src/tool/text-
|
|
2690
|
+
// src/tool/text-editor_20250124.ts
|
|
2392
2691
|
import {
|
|
2393
|
-
createProviderDefinedToolFactory as
|
|
2692
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2394
2693
|
lazySchema as lazySchema13,
|
|
2395
2694
|
zodSchema as zodSchema13
|
|
2396
2695
|
} from "@ai-sdk/provider-utils";
|
|
2397
2696
|
import { z as z14 } from "zod/v4";
|
|
2398
|
-
var
|
|
2697
|
+
var textEditor_20250124InputSchema = lazySchema13(
|
|
2399
2698
|
() => zodSchema13(
|
|
2400
2699
|
z14.object({
|
|
2401
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2700
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2402
2701
|
path: z14.string(),
|
|
2403
2702
|
file_text: z14.string().optional(),
|
|
2404
2703
|
insert_line: z14.number().int().optional(),
|
|
@@ -2408,6 +2707,32 @@ var textEditor_20250429InputSchema = lazySchema13(
|
|
|
2408
2707
|
})
|
|
2409
2708
|
)
|
|
2410
2709
|
);
|
|
2710
|
+
var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
2711
|
+
id: "anthropic.text_editor_20250124",
|
|
2712
|
+
name: "str_replace_editor",
|
|
2713
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2714
|
+
});
|
|
2715
|
+
|
|
2716
|
+
// src/tool/text-editor_20250429.ts
|
|
2717
|
+
import {
|
|
2718
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
2719
|
+
lazySchema as lazySchema14,
|
|
2720
|
+
zodSchema as zodSchema14
|
|
2721
|
+
} from "@ai-sdk/provider-utils";
|
|
2722
|
+
import { z as z15 } from "zod/v4";
|
|
2723
|
+
var textEditor_20250429InputSchema = lazySchema14(
|
|
2724
|
+
() => zodSchema14(
|
|
2725
|
+
z15.object({
|
|
2726
|
+
command: z15.enum(["view", "create", "str_replace", "insert"]),
|
|
2727
|
+
path: z15.string(),
|
|
2728
|
+
file_text: z15.string().optional(),
|
|
2729
|
+
insert_line: z15.number().int().optional(),
|
|
2730
|
+
new_str: z15.string().optional(),
|
|
2731
|
+
old_str: z15.string().optional(),
|
|
2732
|
+
view_range: z15.array(z15.number().int()).optional()
|
|
2733
|
+
})
|
|
2734
|
+
)
|
|
2735
|
+
);
|
|
2411
2736
|
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
2412
2737
|
id: "anthropic.text_editor_20250429",
|
|
2413
2738
|
name: "str_replace_based_edit_tool",
|
|
@@ -2445,6 +2770,19 @@ var anthropicTools = {
|
|
|
2445
2770
|
* Tool name must be `code_execution`.
|
|
2446
2771
|
*/
|
|
2447
2772
|
codeExecution_20250522,
|
|
2773
|
+
/**
|
|
2774
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2775
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2776
|
+
* the API conversation.
|
|
2777
|
+
*
|
|
2778
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2779
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2780
|
+
*
|
|
2781
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2782
|
+
*
|
|
2783
|
+
* Tool name must be `code_execution`.
|
|
2784
|
+
*/
|
|
2785
|
+
codeExecution_20250825,
|
|
2448
2786
|
/**
|
|
2449
2787
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2450
2788
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|