@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/internal/index.mjs
CHANGED
|
@@ -142,6 +142,7 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
142
142
|
})
|
|
143
143
|
])
|
|
144
144
|
}),
|
|
145
|
+
// code execution results for code_execution_20250522 tool:
|
|
145
146
|
z2.object({
|
|
146
147
|
type: z2.literal("code_execution_tool_result"),
|
|
147
148
|
tool_use_id: z2.string(),
|
|
@@ -157,6 +158,62 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
157
158
|
error_code: z2.string()
|
|
158
159
|
})
|
|
159
160
|
])
|
|
161
|
+
}),
|
|
162
|
+
// bash code execution results for code_execution_20250825 tool:
|
|
163
|
+
z2.object({
|
|
164
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
165
|
+
tool_use_id: z2.string(),
|
|
166
|
+
content: z2.discriminatedUnion("type", [
|
|
167
|
+
z2.object({
|
|
168
|
+
type: z2.literal("bash_code_execution_result"),
|
|
169
|
+
content: z2.array(
|
|
170
|
+
z2.object({
|
|
171
|
+
type: z2.literal("bash_code_execution_output"),
|
|
172
|
+
file_id: z2.string()
|
|
173
|
+
})
|
|
174
|
+
),
|
|
175
|
+
stdout: z2.string(),
|
|
176
|
+
stderr: z2.string(),
|
|
177
|
+
return_code: z2.number()
|
|
178
|
+
}),
|
|
179
|
+
z2.object({
|
|
180
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
181
|
+
error_code: z2.string()
|
|
182
|
+
})
|
|
183
|
+
])
|
|
184
|
+
}),
|
|
185
|
+
// text editor code execution results for code_execution_20250825 tool:
|
|
186
|
+
z2.object({
|
|
187
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
188
|
+
tool_use_id: z2.string(),
|
|
189
|
+
content: z2.discriminatedUnion("type", [
|
|
190
|
+
z2.object({
|
|
191
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
192
|
+
error_code: z2.string()
|
|
193
|
+
}),
|
|
194
|
+
z2.object({
|
|
195
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
196
|
+
content: z2.string(),
|
|
197
|
+
file_type: z2.string(),
|
|
198
|
+
num_lines: z2.number().nullable(),
|
|
199
|
+
start_line: z2.number().nullable(),
|
|
200
|
+
total_lines: z2.number().nullable()
|
|
201
|
+
}),
|
|
202
|
+
z2.object({
|
|
203
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
204
|
+
is_file_update: z2.boolean()
|
|
205
|
+
}),
|
|
206
|
+
z2.object({
|
|
207
|
+
type: z2.literal(
|
|
208
|
+
"text_editor_code_execution_str_replace_result"
|
|
209
|
+
),
|
|
210
|
+
lines: z2.array(z2.string()).nullable(),
|
|
211
|
+
new_lines: z2.number().nullable(),
|
|
212
|
+
new_start: z2.number().nullable(),
|
|
213
|
+
old_lines: z2.number().nullable(),
|
|
214
|
+
old_start: z2.number().nullable()
|
|
215
|
+
})
|
|
216
|
+
])
|
|
160
217
|
})
|
|
161
218
|
])
|
|
162
219
|
),
|
|
@@ -257,6 +314,7 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
257
314
|
})
|
|
258
315
|
])
|
|
259
316
|
}),
|
|
317
|
+
// code execution results for code_execution_20250522 tool:
|
|
260
318
|
z2.object({
|
|
261
319
|
type: z2.literal("code_execution_tool_result"),
|
|
262
320
|
tool_use_id: z2.string(),
|
|
@@ -272,6 +330,62 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
272
330
|
error_code: z2.string()
|
|
273
331
|
})
|
|
274
332
|
])
|
|
333
|
+
}),
|
|
334
|
+
// bash code execution results for code_execution_20250825 tool:
|
|
335
|
+
z2.object({
|
|
336
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
337
|
+
tool_use_id: z2.string(),
|
|
338
|
+
content: z2.discriminatedUnion("type", [
|
|
339
|
+
z2.object({
|
|
340
|
+
type: z2.literal("bash_code_execution_result"),
|
|
341
|
+
content: z2.array(
|
|
342
|
+
z2.object({
|
|
343
|
+
type: z2.literal("bash_code_execution_output"),
|
|
344
|
+
file_id: z2.string()
|
|
345
|
+
})
|
|
346
|
+
),
|
|
347
|
+
stdout: z2.string(),
|
|
348
|
+
stderr: z2.string(),
|
|
349
|
+
return_code: z2.number()
|
|
350
|
+
}),
|
|
351
|
+
z2.object({
|
|
352
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
353
|
+
error_code: z2.string()
|
|
354
|
+
})
|
|
355
|
+
])
|
|
356
|
+
}),
|
|
357
|
+
// text editor code execution results for code_execution_20250825 tool:
|
|
358
|
+
z2.object({
|
|
359
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
360
|
+
tool_use_id: z2.string(),
|
|
361
|
+
content: z2.discriminatedUnion("type", [
|
|
362
|
+
z2.object({
|
|
363
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
364
|
+
error_code: z2.string()
|
|
365
|
+
}),
|
|
366
|
+
z2.object({
|
|
367
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
368
|
+
content: z2.string(),
|
|
369
|
+
file_type: z2.string(),
|
|
370
|
+
num_lines: z2.number().nullable(),
|
|
371
|
+
start_line: z2.number().nullable(),
|
|
372
|
+
total_lines: z2.number().nullable()
|
|
373
|
+
}),
|
|
374
|
+
z2.object({
|
|
375
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
376
|
+
is_file_update: z2.boolean()
|
|
377
|
+
}),
|
|
378
|
+
z2.object({
|
|
379
|
+
type: z2.literal(
|
|
380
|
+
"text_editor_code_execution_str_replace_result"
|
|
381
|
+
),
|
|
382
|
+
lines: z2.array(z2.string()).nullable(),
|
|
383
|
+
new_lines: z2.number().nullable(),
|
|
384
|
+
new_start: z2.number().nullable(),
|
|
385
|
+
old_lines: z2.number().nullable(),
|
|
386
|
+
old_start: z2.number().nullable()
|
|
387
|
+
})
|
|
388
|
+
])
|
|
275
389
|
})
|
|
276
390
|
])
|
|
277
391
|
}),
|
|
@@ -607,6 +721,14 @@ async function prepareTools({
|
|
|
607
721
|
});
|
|
608
722
|
break;
|
|
609
723
|
}
|
|
724
|
+
case "anthropic.code_execution_20250825": {
|
|
725
|
+
betas.add("code-execution-2025-08-25");
|
|
726
|
+
anthropicTools2.push({
|
|
727
|
+
type: "code_execution_20250825",
|
|
728
|
+
name: "code_execution"
|
|
729
|
+
});
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
610
732
|
case "anthropic.computer_20250124": {
|
|
611
733
|
betas.add("computer-use-2025-01-24");
|
|
612
734
|
anthropicTools2.push({
|
|
@@ -822,6 +944,99 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
822
944
|
return factory4(args);
|
|
823
945
|
};
|
|
824
946
|
|
|
947
|
+
// src/tool/code-execution_20250825.ts
|
|
948
|
+
import {
|
|
949
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
950
|
+
lazySchema as lazySchema7,
|
|
951
|
+
zodSchema as zodSchema7
|
|
952
|
+
} from "@ai-sdk/provider-utils";
|
|
953
|
+
import { z as z8 } from "zod/v4";
|
|
954
|
+
var codeExecution_20250825OutputSchema = lazySchema7(
|
|
955
|
+
() => zodSchema7(
|
|
956
|
+
z8.discriminatedUnion("type", [
|
|
957
|
+
z8.object({
|
|
958
|
+
type: z8.literal("bash_code_execution_result"),
|
|
959
|
+
content: z8.array(
|
|
960
|
+
z8.object({
|
|
961
|
+
type: z8.literal("bash_code_execution_output"),
|
|
962
|
+
file_id: z8.string()
|
|
963
|
+
})
|
|
964
|
+
),
|
|
965
|
+
stdout: z8.string(),
|
|
966
|
+
stderr: z8.string(),
|
|
967
|
+
return_code: z8.number()
|
|
968
|
+
}),
|
|
969
|
+
z8.object({
|
|
970
|
+
type: z8.literal("bash_code_execution_tool_result_error"),
|
|
971
|
+
error_code: z8.string()
|
|
972
|
+
}),
|
|
973
|
+
z8.object({
|
|
974
|
+
type: z8.literal("text_editor_code_execution_tool_result_error"),
|
|
975
|
+
error_code: z8.string()
|
|
976
|
+
}),
|
|
977
|
+
z8.object({
|
|
978
|
+
type: z8.literal("text_editor_code_execution_view_result"),
|
|
979
|
+
content: z8.string(),
|
|
980
|
+
file_type: z8.string(),
|
|
981
|
+
num_lines: z8.number().nullable(),
|
|
982
|
+
start_line: z8.number().nullable(),
|
|
983
|
+
total_lines: z8.number().nullable()
|
|
984
|
+
}),
|
|
985
|
+
z8.object({
|
|
986
|
+
type: z8.literal("text_editor_code_execution_create_result"),
|
|
987
|
+
is_file_update: z8.boolean()
|
|
988
|
+
}),
|
|
989
|
+
z8.object({
|
|
990
|
+
type: z8.literal("text_editor_code_execution_str_replace_result"),
|
|
991
|
+
lines: z8.array(z8.string()).nullable(),
|
|
992
|
+
new_lines: z8.number().nullable(),
|
|
993
|
+
new_start: z8.number().nullable(),
|
|
994
|
+
old_lines: z8.number().nullable(),
|
|
995
|
+
old_start: z8.number().nullable()
|
|
996
|
+
})
|
|
997
|
+
])
|
|
998
|
+
)
|
|
999
|
+
);
|
|
1000
|
+
var codeExecution_20250825InputSchema = lazySchema7(
|
|
1001
|
+
() => zodSchema7(
|
|
1002
|
+
z8.discriminatedUnion("type", [
|
|
1003
|
+
z8.object({
|
|
1004
|
+
type: z8.literal("bash_code_execution"),
|
|
1005
|
+
command: z8.string()
|
|
1006
|
+
}),
|
|
1007
|
+
z8.discriminatedUnion("command", [
|
|
1008
|
+
z8.object({
|
|
1009
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1010
|
+
command: z8.literal("view"),
|
|
1011
|
+
path: z8.string()
|
|
1012
|
+
}),
|
|
1013
|
+
z8.object({
|
|
1014
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1015
|
+
command: z8.literal("create"),
|
|
1016
|
+
path: z8.string(),
|
|
1017
|
+
file_text: z8.string().nullish()
|
|
1018
|
+
}),
|
|
1019
|
+
z8.object({
|
|
1020
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1021
|
+
command: z8.literal("str_replace"),
|
|
1022
|
+
path: z8.string(),
|
|
1023
|
+
old_str: z8.string(),
|
|
1024
|
+
new_str: z8.string()
|
|
1025
|
+
})
|
|
1026
|
+
])
|
|
1027
|
+
])
|
|
1028
|
+
)
|
|
1029
|
+
);
|
|
1030
|
+
var factory5 = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
1031
|
+
id: "anthropic.code_execution_20250825",
|
|
1032
|
+
name: "code_execution",
|
|
1033
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
1034
|
+
outputSchema: codeExecution_20250825OutputSchema
|
|
1035
|
+
});
|
|
1036
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
1037
|
+
return factory5(args);
|
|
1038
|
+
};
|
|
1039
|
+
|
|
825
1040
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
826
1041
|
function convertToString(data) {
|
|
827
1042
|
if (typeof data === "string") {
|
|
@@ -1009,6 +1224,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1009
1224
|
cache_control: void 0
|
|
1010
1225
|
};
|
|
1011
1226
|
}
|
|
1227
|
+
if (contentPart.mediaType === "application/pdf") {
|
|
1228
|
+
betas.add("pdfs-2024-09-25");
|
|
1229
|
+
return {
|
|
1230
|
+
type: "document",
|
|
1231
|
+
source: {
|
|
1232
|
+
type: "base64",
|
|
1233
|
+
media_type: contentPart.mediaType,
|
|
1234
|
+
data: contentPart.data
|
|
1235
|
+
},
|
|
1236
|
+
cache_control: void 0
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1012
1239
|
throw new UnsupportedFunctionalityError2({
|
|
1013
1240
|
functionality: `media type: ${contentPart.mediaType}`
|
|
1014
1241
|
});
|
|
@@ -1115,7 +1342,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1115
1342
|
}
|
|
1116
1343
|
case "tool-call": {
|
|
1117
1344
|
if (part.providerExecuted) {
|
|
1118
|
-
if (part.toolName === "code_execution"
|
|
1345
|
+
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")) {
|
|
1346
|
+
anthropicContent.push({
|
|
1347
|
+
type: "server_tool_use",
|
|
1348
|
+
id: part.toolCallId,
|
|
1349
|
+
name: part.input.type,
|
|
1350
|
+
// map back to subtool name
|
|
1351
|
+
input: part.input,
|
|
1352
|
+
cache_control: cacheControl
|
|
1353
|
+
});
|
|
1354
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1355
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1119
1356
|
anthropicContent.push({
|
|
1120
1357
|
type: "server_tool_use",
|
|
1121
1358
|
id: part.toolCallId,
|
|
@@ -1150,21 +1387,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1150
1387
|
});
|
|
1151
1388
|
break;
|
|
1152
1389
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1390
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1391
|
+
warnings.push({
|
|
1392
|
+
type: "other",
|
|
1393
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1394
|
+
});
|
|
1395
|
+
break;
|
|
1396
|
+
}
|
|
1397
|
+
if (output.value.type === "code_execution_result") {
|
|
1398
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1399
|
+
value: output.value,
|
|
1400
|
+
schema: codeExecution_20250522OutputSchema
|
|
1401
|
+
});
|
|
1402
|
+
anthropicContent.push({
|
|
1403
|
+
type: "code_execution_tool_result",
|
|
1404
|
+
tool_use_id: part.toolCallId,
|
|
1405
|
+
content: {
|
|
1406
|
+
type: codeExecutionOutput.type,
|
|
1407
|
+
stdout: codeExecutionOutput.stdout,
|
|
1408
|
+
stderr: codeExecutionOutput.stderr,
|
|
1409
|
+
return_code: codeExecutionOutput.return_code
|
|
1410
|
+
},
|
|
1411
|
+
cache_control: cacheControl
|
|
1412
|
+
});
|
|
1413
|
+
} else {
|
|
1414
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1415
|
+
value: output.value,
|
|
1416
|
+
schema: codeExecution_20250825OutputSchema
|
|
1417
|
+
});
|
|
1418
|
+
anthropicContent.push(
|
|
1419
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1420
|
+
type: "bash_code_execution_tool_result",
|
|
1421
|
+
tool_use_id: part.toolCallId,
|
|
1422
|
+
cache_control: cacheControl,
|
|
1423
|
+
content: codeExecutionOutput
|
|
1424
|
+
} : {
|
|
1425
|
+
type: "text_editor_code_execution_tool_result",
|
|
1426
|
+
tool_use_id: part.toolCallId,
|
|
1427
|
+
cache_control: cacheControl,
|
|
1428
|
+
content: codeExecutionOutput
|
|
1429
|
+
}
|
|
1430
|
+
);
|
|
1431
|
+
}
|
|
1168
1432
|
break;
|
|
1169
1433
|
}
|
|
1170
1434
|
if (part.toolName === "web_fetch") {
|
|
@@ -1634,7 +1898,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1634
1898
|
break;
|
|
1635
1899
|
}
|
|
1636
1900
|
case "server_tool_use": {
|
|
1637
|
-
if (part.name === "
|
|
1901
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1902
|
+
content.push({
|
|
1903
|
+
type: "tool-call",
|
|
1904
|
+
toolCallId: part.id,
|
|
1905
|
+
toolName: "code_execution",
|
|
1906
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1907
|
+
providerExecuted: true
|
|
1908
|
+
});
|
|
1909
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1638
1910
|
content.push({
|
|
1639
1911
|
type: "tool-call",
|
|
1640
1912
|
toolCallId: part.id,
|
|
@@ -1730,6 +2002,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1730
2002
|
}
|
|
1731
2003
|
break;
|
|
1732
2004
|
}
|
|
2005
|
+
// code execution 20250522:
|
|
1733
2006
|
case "code_execution_tool_result": {
|
|
1734
2007
|
if (part.content.type === "code_execution_result") {
|
|
1735
2008
|
content.push({
|
|
@@ -1759,6 +2032,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1759
2032
|
}
|
|
1760
2033
|
break;
|
|
1761
2034
|
}
|
|
2035
|
+
// code execution 20250825:
|
|
2036
|
+
case "bash_code_execution_tool_result":
|
|
2037
|
+
case "text_editor_code_execution_tool_result": {
|
|
2038
|
+
content.push({
|
|
2039
|
+
type: "tool-result",
|
|
2040
|
+
toolCallId: part.tool_use_id,
|
|
2041
|
+
toolName: "code_execution",
|
|
2042
|
+
result: part.content,
|
|
2043
|
+
providerExecuted: true
|
|
2044
|
+
});
|
|
2045
|
+
break;
|
|
2046
|
+
}
|
|
1762
2047
|
}
|
|
1763
2048
|
}
|
|
1764
2049
|
return {
|
|
@@ -1875,7 +2160,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1875
2160
|
type: "tool-call",
|
|
1876
2161
|
toolCallId: value.content_block.id,
|
|
1877
2162
|
toolName: value.content_block.name,
|
|
1878
|
-
input: ""
|
|
2163
|
+
input: "",
|
|
2164
|
+
firstDelta: true
|
|
1879
2165
|
};
|
|
1880
2166
|
controller.enqueue(
|
|
1881
2167
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1887,18 +2173,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1887
2173
|
return;
|
|
1888
2174
|
}
|
|
1889
2175
|
case "server_tool_use": {
|
|
1890
|
-
if (
|
|
2176
|
+
if ([
|
|
2177
|
+
"web_fetch",
|
|
2178
|
+
"web_search",
|
|
2179
|
+
// code execution 20250825:
|
|
2180
|
+
"code_execution",
|
|
2181
|
+
// code execution 20250825 text editor:
|
|
2182
|
+
"text_editor_code_execution",
|
|
2183
|
+
// code execution 20250825 bash:
|
|
2184
|
+
"bash_code_execution"
|
|
2185
|
+
].includes(value.content_block.name)) {
|
|
1891
2186
|
contentBlocks[value.index] = {
|
|
1892
2187
|
type: "tool-call",
|
|
1893
2188
|
toolCallId: value.content_block.id,
|
|
1894
2189
|
toolName: value.content_block.name,
|
|
1895
2190
|
input: "",
|
|
1896
|
-
providerExecuted: true
|
|
2191
|
+
providerExecuted: true,
|
|
2192
|
+
firstDelta: true
|
|
1897
2193
|
};
|
|
2194
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1898
2195
|
controller.enqueue({
|
|
1899
2196
|
type: "tool-input-start",
|
|
1900
2197
|
id: value.content_block.id,
|
|
1901
|
-
toolName:
|
|
2198
|
+
toolName: mappedToolName,
|
|
1902
2199
|
providerExecuted: true
|
|
1903
2200
|
});
|
|
1904
2201
|
}
|
|
@@ -1990,6 +2287,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1990
2287
|
}
|
|
1991
2288
|
return;
|
|
1992
2289
|
}
|
|
2290
|
+
// code execution 20250522:
|
|
1993
2291
|
case "code_execution_tool_result": {
|
|
1994
2292
|
const part = value.content_block;
|
|
1995
2293
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2020,6 +2318,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2020
2318
|
}
|
|
2021
2319
|
return;
|
|
2022
2320
|
}
|
|
2321
|
+
// code execution 20250825:
|
|
2322
|
+
case "bash_code_execution_tool_result":
|
|
2323
|
+
case "text_editor_code_execution_tool_result": {
|
|
2324
|
+
const part = value.content_block;
|
|
2325
|
+
controller.enqueue({
|
|
2326
|
+
type: "tool-result",
|
|
2327
|
+
toolCallId: part.tool_use_id,
|
|
2328
|
+
toolName: "code_execution",
|
|
2329
|
+
result: part.content,
|
|
2330
|
+
providerExecuted: true
|
|
2331
|
+
});
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2023
2334
|
default: {
|
|
2024
2335
|
const _exhaustiveCheck = contentBlockType;
|
|
2025
2336
|
throw new Error(
|
|
@@ -2052,7 +2363,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2052
2363
|
type: "tool-input-end",
|
|
2053
2364
|
id: contentBlock.toolCallId
|
|
2054
2365
|
});
|
|
2055
|
-
|
|
2366
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2367
|
+
controller.enqueue({
|
|
2368
|
+
type: "tool-call",
|
|
2369
|
+
toolCallId: contentBlock.toolCallId,
|
|
2370
|
+
toolName,
|
|
2371
|
+
input: contentBlock.input,
|
|
2372
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2373
|
+
});
|
|
2056
2374
|
}
|
|
2057
2375
|
break;
|
|
2058
2376
|
}
|
|
@@ -2100,7 +2418,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2100
2418
|
}
|
|
2101
2419
|
case "input_json_delta": {
|
|
2102
2420
|
const contentBlock = contentBlocks[value.index];
|
|
2103
|
-
|
|
2421
|
+
let delta = value.delta.partial_json;
|
|
2422
|
+
if (delta.length === 0) {
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2104
2425
|
if (usesJsonResponseTool) {
|
|
2105
2426
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2106
2427
|
return;
|
|
@@ -2114,12 +2435,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2114
2435
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2115
2436
|
return;
|
|
2116
2437
|
}
|
|
2438
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2439
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2440
|
+
}
|
|
2117
2441
|
controller.enqueue({
|
|
2118
2442
|
type: "tool-input-delta",
|
|
2119
2443
|
id: contentBlock.toolCallId,
|
|
2120
2444
|
delta
|
|
2121
2445
|
});
|
|
2122
2446
|
contentBlock.input += delta;
|
|
2447
|
+
contentBlock.firstDelta = false;
|
|
2123
2448
|
}
|
|
2124
2449
|
return;
|
|
2125
2450
|
}
|
|
@@ -2207,15 +2532,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2207
2532
|
// src/tool/bash_20241022.ts
|
|
2208
2533
|
import {
|
|
2209
2534
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2210
|
-
lazySchema as
|
|
2211
|
-
zodSchema as
|
|
2535
|
+
lazySchema as lazySchema8,
|
|
2536
|
+
zodSchema as zodSchema8
|
|
2212
2537
|
} from "@ai-sdk/provider-utils";
|
|
2213
|
-
import { z as
|
|
2214
|
-
var bash_20241022InputSchema =
|
|
2215
|
-
() =>
|
|
2216
|
-
|
|
2217
|
-
command:
|
|
2218
|
-
restart:
|
|
2538
|
+
import { z as z9 } from "zod/v4";
|
|
2539
|
+
var bash_20241022InputSchema = lazySchema8(
|
|
2540
|
+
() => zodSchema8(
|
|
2541
|
+
z9.object({
|
|
2542
|
+
command: z9.string(),
|
|
2543
|
+
restart: z9.boolean().optional()
|
|
2219
2544
|
})
|
|
2220
2545
|
)
|
|
2221
2546
|
);
|
|
@@ -2228,15 +2553,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2228
2553
|
// src/tool/bash_20250124.ts
|
|
2229
2554
|
import {
|
|
2230
2555
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2231
|
-
lazySchema as
|
|
2232
|
-
zodSchema as
|
|
2556
|
+
lazySchema as lazySchema9,
|
|
2557
|
+
zodSchema as zodSchema9
|
|
2233
2558
|
} from "@ai-sdk/provider-utils";
|
|
2234
|
-
import { z as
|
|
2235
|
-
var bash_20250124InputSchema =
|
|
2236
|
-
() =>
|
|
2237
|
-
|
|
2238
|
-
command:
|
|
2239
|
-
restart:
|
|
2559
|
+
import { z as z10 } from "zod/v4";
|
|
2560
|
+
var bash_20250124InputSchema = lazySchema9(
|
|
2561
|
+
() => zodSchema9(
|
|
2562
|
+
z10.object({
|
|
2563
|
+
command: z10.string(),
|
|
2564
|
+
restart: z10.boolean().optional()
|
|
2240
2565
|
})
|
|
2241
2566
|
)
|
|
2242
2567
|
);
|
|
@@ -2249,14 +2574,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2249
2574
|
// src/tool/computer_20241022.ts
|
|
2250
2575
|
import {
|
|
2251
2576
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2252
|
-
lazySchema as
|
|
2253
|
-
zodSchema as
|
|
2577
|
+
lazySchema as lazySchema10,
|
|
2578
|
+
zodSchema as zodSchema10
|
|
2254
2579
|
} from "@ai-sdk/provider-utils";
|
|
2255
|
-
import { z as
|
|
2256
|
-
var computer_20241022InputSchema =
|
|
2257
|
-
() =>
|
|
2258
|
-
|
|
2259
|
-
action:
|
|
2580
|
+
import { z as z11 } from "zod/v4";
|
|
2581
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2582
|
+
() => zodSchema10(
|
|
2583
|
+
z11.object({
|
|
2584
|
+
action: z11.enum([
|
|
2260
2585
|
"key",
|
|
2261
2586
|
"type",
|
|
2262
2587
|
"mouse_move",
|
|
@@ -2268,8 +2593,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2268
2593
|
"screenshot",
|
|
2269
2594
|
"cursor_position"
|
|
2270
2595
|
]),
|
|
2271
|
-
coordinate:
|
|
2272
|
-
text:
|
|
2596
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2597
|
+
text: z11.string().optional()
|
|
2273
2598
|
})
|
|
2274
2599
|
)
|
|
2275
2600
|
);
|
|
@@ -2282,14 +2607,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2282
2607
|
// src/tool/computer_20250124.ts
|
|
2283
2608
|
import {
|
|
2284
2609
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2285
|
-
lazySchema as
|
|
2286
|
-
zodSchema as
|
|
2610
|
+
lazySchema as lazySchema11,
|
|
2611
|
+
zodSchema as zodSchema11
|
|
2287
2612
|
} from "@ai-sdk/provider-utils";
|
|
2288
|
-
import { z as
|
|
2289
|
-
var computer_20250124InputSchema =
|
|
2290
|
-
() =>
|
|
2291
|
-
|
|
2292
|
-
action:
|
|
2613
|
+
import { z as z12 } from "zod/v4";
|
|
2614
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2615
|
+
() => zodSchema11(
|
|
2616
|
+
z12.object({
|
|
2617
|
+
action: z12.enum([
|
|
2293
2618
|
"key",
|
|
2294
2619
|
"hold_key",
|
|
2295
2620
|
"type",
|
|
@@ -2307,12 +2632,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2307
2632
|
"wait",
|
|
2308
2633
|
"screenshot"
|
|
2309
2634
|
]),
|
|
2310
|
-
coordinate:
|
|
2311
|
-
duration:
|
|
2312
|
-
scroll_amount:
|
|
2313
|
-
scroll_direction:
|
|
2314
|
-
start_coordinate:
|
|
2315
|
-
text:
|
|
2635
|
+
coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2636
|
+
duration: z12.number().optional(),
|
|
2637
|
+
scroll_amount: z12.number().optional(),
|
|
2638
|
+
scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
|
|
2639
|
+
start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2640
|
+
text: z12.string().optional()
|
|
2316
2641
|
})
|
|
2317
2642
|
)
|
|
2318
2643
|
);
|
|
@@ -2325,37 +2650,11 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2325
2650
|
// src/tool/text-editor_20241022.ts
|
|
2326
2651
|
import {
|
|
2327
2652
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2328
|
-
lazySchema as lazySchema11,
|
|
2329
|
-
zodSchema as zodSchema11
|
|
2330
|
-
} from "@ai-sdk/provider-utils";
|
|
2331
|
-
import { z as z12 } from "zod/v4";
|
|
2332
|
-
var textEditor_20241022InputSchema = lazySchema11(
|
|
2333
|
-
() => zodSchema11(
|
|
2334
|
-
z12.object({
|
|
2335
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2336
|
-
path: z12.string(),
|
|
2337
|
-
file_text: z12.string().optional(),
|
|
2338
|
-
insert_line: z12.number().int().optional(),
|
|
2339
|
-
new_str: z12.string().optional(),
|
|
2340
|
-
old_str: z12.string().optional(),
|
|
2341
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2342
|
-
})
|
|
2343
|
-
)
|
|
2344
|
-
);
|
|
2345
|
-
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2346
|
-
id: "anthropic.text_editor_20241022",
|
|
2347
|
-
name: "str_replace_editor",
|
|
2348
|
-
inputSchema: textEditor_20241022InputSchema
|
|
2349
|
-
});
|
|
2350
|
-
|
|
2351
|
-
// src/tool/text-editor_20250124.ts
|
|
2352
|
-
import {
|
|
2353
|
-
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2354
2653
|
lazySchema as lazySchema12,
|
|
2355
2654
|
zodSchema as zodSchema12
|
|
2356
2655
|
} from "@ai-sdk/provider-utils";
|
|
2357
2656
|
import { z as z13 } from "zod/v4";
|
|
2358
|
-
var
|
|
2657
|
+
var textEditor_20241022InputSchema = lazySchema12(
|
|
2359
2658
|
() => zodSchema12(
|
|
2360
2659
|
z13.object({
|
|
2361
2660
|
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -2368,23 +2667,23 @@ var textEditor_20250124InputSchema = lazySchema12(
|
|
|
2368
2667
|
})
|
|
2369
2668
|
)
|
|
2370
2669
|
);
|
|
2371
|
-
var
|
|
2372
|
-
id: "anthropic.
|
|
2670
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2671
|
+
id: "anthropic.text_editor_20241022",
|
|
2373
2672
|
name: "str_replace_editor",
|
|
2374
|
-
inputSchema:
|
|
2673
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2375
2674
|
});
|
|
2376
2675
|
|
|
2377
|
-
// src/tool/text-
|
|
2676
|
+
// src/tool/text-editor_20250124.ts
|
|
2378
2677
|
import {
|
|
2379
|
-
createProviderDefinedToolFactory as
|
|
2678
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2380
2679
|
lazySchema as lazySchema13,
|
|
2381
2680
|
zodSchema as zodSchema13
|
|
2382
2681
|
} from "@ai-sdk/provider-utils";
|
|
2383
2682
|
import { z as z14 } from "zod/v4";
|
|
2384
|
-
var
|
|
2683
|
+
var textEditor_20250124InputSchema = lazySchema13(
|
|
2385
2684
|
() => zodSchema13(
|
|
2386
2685
|
z14.object({
|
|
2387
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2686
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2388
2687
|
path: z14.string(),
|
|
2389
2688
|
file_text: z14.string().optional(),
|
|
2390
2689
|
insert_line: z14.number().int().optional(),
|
|
@@ -2394,6 +2693,32 @@ var textEditor_20250429InputSchema = lazySchema13(
|
|
|
2394
2693
|
})
|
|
2395
2694
|
)
|
|
2396
2695
|
);
|
|
2696
|
+
var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
2697
|
+
id: "anthropic.text_editor_20250124",
|
|
2698
|
+
name: "str_replace_editor",
|
|
2699
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2700
|
+
});
|
|
2701
|
+
|
|
2702
|
+
// src/tool/text-editor_20250429.ts
|
|
2703
|
+
import {
|
|
2704
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
2705
|
+
lazySchema as lazySchema14,
|
|
2706
|
+
zodSchema as zodSchema14
|
|
2707
|
+
} from "@ai-sdk/provider-utils";
|
|
2708
|
+
import { z as z15 } from "zod/v4";
|
|
2709
|
+
var textEditor_20250429InputSchema = lazySchema14(
|
|
2710
|
+
() => zodSchema14(
|
|
2711
|
+
z15.object({
|
|
2712
|
+
command: z15.enum(["view", "create", "str_replace", "insert"]),
|
|
2713
|
+
path: z15.string(),
|
|
2714
|
+
file_text: z15.string().optional(),
|
|
2715
|
+
insert_line: z15.number().int().optional(),
|
|
2716
|
+
new_str: z15.string().optional(),
|
|
2717
|
+
old_str: z15.string().optional(),
|
|
2718
|
+
view_range: z15.array(z15.number().int()).optional()
|
|
2719
|
+
})
|
|
2720
|
+
)
|
|
2721
|
+
);
|
|
2397
2722
|
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
2398
2723
|
id: "anthropic.text_editor_20250429",
|
|
2399
2724
|
name: "str_replace_based_edit_tool",
|
|
@@ -2431,6 +2756,19 @@ var anthropicTools = {
|
|
|
2431
2756
|
* Tool name must be `code_execution`.
|
|
2432
2757
|
*/
|
|
2433
2758
|
codeExecution_20250522,
|
|
2759
|
+
/**
|
|
2760
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2761
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2762
|
+
* the API conversation.
|
|
2763
|
+
*
|
|
2764
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2765
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2766
|
+
*
|
|
2767
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2768
|
+
*
|
|
2769
|
+
* Tool name must be `code_execution`.
|
|
2770
|
+
*/
|
|
2771
|
+
codeExecution_20250825,
|
|
2434
2772
|
/**
|
|
2435
2773
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2436
2774
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|