@ai-sdk/anthropic 3.0.0-beta.22 → 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 +6 -0
- package/dist/index.d.mts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +436 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +422 -96
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +108 -0
- package/dist/internal/index.d.ts +108 -0
- package/dist/internal/index.js +430 -108
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +421 -95
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +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") {
|
|
@@ -1141,7 +1356,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1141
1356
|
}
|
|
1142
1357
|
case "tool-call": {
|
|
1143
1358
|
if (part.providerExecuted) {
|
|
1144
|
-
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") {
|
|
1145
1370
|
anthropicContent.push({
|
|
1146
1371
|
type: "server_tool_use",
|
|
1147
1372
|
id: part.toolCallId,
|
|
@@ -1176,21 +1401,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1176
1401
|
});
|
|
1177
1402
|
break;
|
|
1178
1403
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
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
|
+
}
|
|
1194
1446
|
break;
|
|
1195
1447
|
}
|
|
1196
1448
|
if (part.toolName === "web_fetch") {
|
|
@@ -1660,7 +1912,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1660
1912
|
break;
|
|
1661
1913
|
}
|
|
1662
1914
|
case "server_tool_use": {
|
|
1663
|
-
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") {
|
|
1664
1924
|
content.push({
|
|
1665
1925
|
type: "tool-call",
|
|
1666
1926
|
toolCallId: part.id,
|
|
@@ -1756,6 +2016,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1756
2016
|
}
|
|
1757
2017
|
break;
|
|
1758
2018
|
}
|
|
2019
|
+
// code execution 20250522:
|
|
1759
2020
|
case "code_execution_tool_result": {
|
|
1760
2021
|
if (part.content.type === "code_execution_result") {
|
|
1761
2022
|
content.push({
|
|
@@ -1785,6 +2046,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1785
2046
|
}
|
|
1786
2047
|
break;
|
|
1787
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
|
+
}
|
|
1788
2061
|
}
|
|
1789
2062
|
}
|
|
1790
2063
|
return {
|
|
@@ -1901,7 +2174,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1901
2174
|
type: "tool-call",
|
|
1902
2175
|
toolCallId: value.content_block.id,
|
|
1903
2176
|
toolName: value.content_block.name,
|
|
1904
|
-
input: ""
|
|
2177
|
+
input: "",
|
|
2178
|
+
firstDelta: true
|
|
1905
2179
|
};
|
|
1906
2180
|
controller.enqueue(
|
|
1907
2181
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1913,18 +2187,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1913
2187
|
return;
|
|
1914
2188
|
}
|
|
1915
2189
|
case "server_tool_use": {
|
|
1916
|
-
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)) {
|
|
1917
2200
|
contentBlocks[value.index] = {
|
|
1918
2201
|
type: "tool-call",
|
|
1919
2202
|
toolCallId: value.content_block.id,
|
|
1920
2203
|
toolName: value.content_block.name,
|
|
1921
2204
|
input: "",
|
|
1922
|
-
providerExecuted: true
|
|
2205
|
+
providerExecuted: true,
|
|
2206
|
+
firstDelta: true
|
|
1923
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;
|
|
1924
2209
|
controller.enqueue({
|
|
1925
2210
|
type: "tool-input-start",
|
|
1926
2211
|
id: value.content_block.id,
|
|
1927
|
-
toolName:
|
|
2212
|
+
toolName: mappedToolName,
|
|
1928
2213
|
providerExecuted: true
|
|
1929
2214
|
});
|
|
1930
2215
|
}
|
|
@@ -2016,6 +2301,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2016
2301
|
}
|
|
2017
2302
|
return;
|
|
2018
2303
|
}
|
|
2304
|
+
// code execution 20250522:
|
|
2019
2305
|
case "code_execution_tool_result": {
|
|
2020
2306
|
const part = value.content_block;
|
|
2021
2307
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2046,6 +2332,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2046
2332
|
}
|
|
2047
2333
|
return;
|
|
2048
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
|
+
}
|
|
2049
2348
|
default: {
|
|
2050
2349
|
const _exhaustiveCheck = contentBlockType;
|
|
2051
2350
|
throw new Error(
|
|
@@ -2078,7 +2377,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2078
2377
|
type: "tool-input-end",
|
|
2079
2378
|
id: contentBlock.toolCallId
|
|
2080
2379
|
});
|
|
2081
|
-
|
|
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
|
+
});
|
|
2082
2388
|
}
|
|
2083
2389
|
break;
|
|
2084
2390
|
}
|
|
@@ -2126,7 +2432,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2126
2432
|
}
|
|
2127
2433
|
case "input_json_delta": {
|
|
2128
2434
|
const contentBlock = contentBlocks[value.index];
|
|
2129
|
-
|
|
2435
|
+
let delta = value.delta.partial_json;
|
|
2436
|
+
if (delta.length === 0) {
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2130
2439
|
if (usesJsonResponseTool) {
|
|
2131
2440
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2132
2441
|
return;
|
|
@@ -2140,12 +2449,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2140
2449
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2141
2450
|
return;
|
|
2142
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
|
+
}
|
|
2143
2455
|
controller.enqueue({
|
|
2144
2456
|
type: "tool-input-delta",
|
|
2145
2457
|
id: contentBlock.toolCallId,
|
|
2146
2458
|
delta
|
|
2147
2459
|
});
|
|
2148
2460
|
contentBlock.input += delta;
|
|
2461
|
+
contentBlock.firstDelta = false;
|
|
2149
2462
|
}
|
|
2150
2463
|
return;
|
|
2151
2464
|
}
|
|
@@ -2233,15 +2546,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2233
2546
|
// src/tool/bash_20241022.ts
|
|
2234
2547
|
import {
|
|
2235
2548
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2236
|
-
lazySchema as
|
|
2237
|
-
zodSchema as
|
|
2549
|
+
lazySchema as lazySchema8,
|
|
2550
|
+
zodSchema as zodSchema8
|
|
2238
2551
|
} from "@ai-sdk/provider-utils";
|
|
2239
|
-
import { z as
|
|
2240
|
-
var bash_20241022InputSchema =
|
|
2241
|
-
() =>
|
|
2242
|
-
|
|
2243
|
-
command:
|
|
2244
|
-
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()
|
|
2245
2558
|
})
|
|
2246
2559
|
)
|
|
2247
2560
|
);
|
|
@@ -2254,15 +2567,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2254
2567
|
// src/tool/bash_20250124.ts
|
|
2255
2568
|
import {
|
|
2256
2569
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2257
|
-
lazySchema as
|
|
2258
|
-
zodSchema as
|
|
2570
|
+
lazySchema as lazySchema9,
|
|
2571
|
+
zodSchema as zodSchema9
|
|
2259
2572
|
} from "@ai-sdk/provider-utils";
|
|
2260
|
-
import { z as
|
|
2261
|
-
var bash_20250124InputSchema =
|
|
2262
|
-
() =>
|
|
2263
|
-
|
|
2264
|
-
command:
|
|
2265
|
-
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()
|
|
2266
2579
|
})
|
|
2267
2580
|
)
|
|
2268
2581
|
);
|
|
@@ -2275,14 +2588,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2275
2588
|
// src/tool/computer_20241022.ts
|
|
2276
2589
|
import {
|
|
2277
2590
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2278
|
-
lazySchema as
|
|
2279
|
-
zodSchema as
|
|
2591
|
+
lazySchema as lazySchema10,
|
|
2592
|
+
zodSchema as zodSchema10
|
|
2280
2593
|
} from "@ai-sdk/provider-utils";
|
|
2281
|
-
import { z as
|
|
2282
|
-
var computer_20241022InputSchema =
|
|
2283
|
-
() =>
|
|
2284
|
-
|
|
2285
|
-
action:
|
|
2594
|
+
import { z as z11 } from "zod/v4";
|
|
2595
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2596
|
+
() => zodSchema10(
|
|
2597
|
+
z11.object({
|
|
2598
|
+
action: z11.enum([
|
|
2286
2599
|
"key",
|
|
2287
2600
|
"type",
|
|
2288
2601
|
"mouse_move",
|
|
@@ -2294,8 +2607,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2294
2607
|
"screenshot",
|
|
2295
2608
|
"cursor_position"
|
|
2296
2609
|
]),
|
|
2297
|
-
coordinate:
|
|
2298
|
-
text:
|
|
2610
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2611
|
+
text: z11.string().optional()
|
|
2299
2612
|
})
|
|
2300
2613
|
)
|
|
2301
2614
|
);
|
|
@@ -2308,14 +2621,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2308
2621
|
// src/tool/computer_20250124.ts
|
|
2309
2622
|
import {
|
|
2310
2623
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2311
|
-
lazySchema as
|
|
2312
|
-
zodSchema as
|
|
2624
|
+
lazySchema as lazySchema11,
|
|
2625
|
+
zodSchema as zodSchema11
|
|
2313
2626
|
} from "@ai-sdk/provider-utils";
|
|
2314
|
-
import { z as
|
|
2315
|
-
var computer_20250124InputSchema =
|
|
2316
|
-
() =>
|
|
2317
|
-
|
|
2318
|
-
action:
|
|
2627
|
+
import { z as z12 } from "zod/v4";
|
|
2628
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2629
|
+
() => zodSchema11(
|
|
2630
|
+
z12.object({
|
|
2631
|
+
action: z12.enum([
|
|
2319
2632
|
"key",
|
|
2320
2633
|
"hold_key",
|
|
2321
2634
|
"type",
|
|
@@ -2333,12 +2646,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2333
2646
|
"wait",
|
|
2334
2647
|
"screenshot"
|
|
2335
2648
|
]),
|
|
2336
|
-
coordinate:
|
|
2337
|
-
duration:
|
|
2338
|
-
scroll_amount:
|
|
2339
|
-
scroll_direction:
|
|
2340
|
-
start_coordinate:
|
|
2341
|
-
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()
|
|
2342
2655
|
})
|
|
2343
2656
|
)
|
|
2344
2657
|
);
|
|
@@ -2351,37 +2664,11 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2351
2664
|
// src/tool/text-editor_20241022.ts
|
|
2352
2665
|
import {
|
|
2353
2666
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2354
|
-
lazySchema as lazySchema11,
|
|
2355
|
-
zodSchema as zodSchema11
|
|
2356
|
-
} from "@ai-sdk/provider-utils";
|
|
2357
|
-
import { z as z12 } from "zod/v4";
|
|
2358
|
-
var textEditor_20241022InputSchema = lazySchema11(
|
|
2359
|
-
() => zodSchema11(
|
|
2360
|
-
z12.object({
|
|
2361
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2362
|
-
path: z12.string(),
|
|
2363
|
-
file_text: z12.string().optional(),
|
|
2364
|
-
insert_line: z12.number().int().optional(),
|
|
2365
|
-
new_str: z12.string().optional(),
|
|
2366
|
-
old_str: z12.string().optional(),
|
|
2367
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2368
|
-
})
|
|
2369
|
-
)
|
|
2370
|
-
);
|
|
2371
|
-
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2372
|
-
id: "anthropic.text_editor_20241022",
|
|
2373
|
-
name: "str_replace_editor",
|
|
2374
|
-
inputSchema: textEditor_20241022InputSchema
|
|
2375
|
-
});
|
|
2376
|
-
|
|
2377
|
-
// src/tool/text-editor_20250124.ts
|
|
2378
|
-
import {
|
|
2379
|
-
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2380
2667
|
lazySchema as lazySchema12,
|
|
2381
2668
|
zodSchema as zodSchema12
|
|
2382
2669
|
} from "@ai-sdk/provider-utils";
|
|
2383
2670
|
import { z as z13 } from "zod/v4";
|
|
2384
|
-
var
|
|
2671
|
+
var textEditor_20241022InputSchema = lazySchema12(
|
|
2385
2672
|
() => zodSchema12(
|
|
2386
2673
|
z13.object({
|
|
2387
2674
|
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -2394,23 +2681,23 @@ var textEditor_20250124InputSchema = lazySchema12(
|
|
|
2394
2681
|
})
|
|
2395
2682
|
)
|
|
2396
2683
|
);
|
|
2397
|
-
var
|
|
2398
|
-
id: "anthropic.
|
|
2684
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2685
|
+
id: "anthropic.text_editor_20241022",
|
|
2399
2686
|
name: "str_replace_editor",
|
|
2400
|
-
inputSchema:
|
|
2687
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2401
2688
|
});
|
|
2402
2689
|
|
|
2403
|
-
// src/tool/text-
|
|
2690
|
+
// src/tool/text-editor_20250124.ts
|
|
2404
2691
|
import {
|
|
2405
|
-
createProviderDefinedToolFactory as
|
|
2692
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2406
2693
|
lazySchema as lazySchema13,
|
|
2407
2694
|
zodSchema as zodSchema13
|
|
2408
2695
|
} from "@ai-sdk/provider-utils";
|
|
2409
2696
|
import { z as z14 } from "zod/v4";
|
|
2410
|
-
var
|
|
2697
|
+
var textEditor_20250124InputSchema = lazySchema13(
|
|
2411
2698
|
() => zodSchema13(
|
|
2412
2699
|
z14.object({
|
|
2413
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2700
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2414
2701
|
path: z14.string(),
|
|
2415
2702
|
file_text: z14.string().optional(),
|
|
2416
2703
|
insert_line: z14.number().int().optional(),
|
|
@@ -2420,6 +2707,32 @@ var textEditor_20250429InputSchema = lazySchema13(
|
|
|
2420
2707
|
})
|
|
2421
2708
|
)
|
|
2422
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
|
+
);
|
|
2423
2736
|
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
2424
2737
|
id: "anthropic.text_editor_20250429",
|
|
2425
2738
|
name: "str_replace_based_edit_tool",
|
|
@@ -2457,6 +2770,19 @@ var anthropicTools = {
|
|
|
2457
2770
|
* Tool name must be `code_execution`.
|
|
2458
2771
|
*/
|
|
2459
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,
|
|
2460
2786
|
/**
|
|
2461
2787
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2462
2788
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|