@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/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") {
|
|
@@ -1127,7 +1342,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1127
1342
|
}
|
|
1128
1343
|
case "tool-call": {
|
|
1129
1344
|
if (part.providerExecuted) {
|
|
1130
|
-
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") {
|
|
1131
1356
|
anthropicContent.push({
|
|
1132
1357
|
type: "server_tool_use",
|
|
1133
1358
|
id: part.toolCallId,
|
|
@@ -1162,21 +1387,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1162
1387
|
});
|
|
1163
1388
|
break;
|
|
1164
1389
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
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
|
+
}
|
|
1180
1432
|
break;
|
|
1181
1433
|
}
|
|
1182
1434
|
if (part.toolName === "web_fetch") {
|
|
@@ -1646,7 +1898,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1646
1898
|
break;
|
|
1647
1899
|
}
|
|
1648
1900
|
case "server_tool_use": {
|
|
1649
|
-
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") {
|
|
1650
1910
|
content.push({
|
|
1651
1911
|
type: "tool-call",
|
|
1652
1912
|
toolCallId: part.id,
|
|
@@ -1742,6 +2002,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1742
2002
|
}
|
|
1743
2003
|
break;
|
|
1744
2004
|
}
|
|
2005
|
+
// code execution 20250522:
|
|
1745
2006
|
case "code_execution_tool_result": {
|
|
1746
2007
|
if (part.content.type === "code_execution_result") {
|
|
1747
2008
|
content.push({
|
|
@@ -1771,6 +2032,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1771
2032
|
}
|
|
1772
2033
|
break;
|
|
1773
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
|
+
}
|
|
1774
2047
|
}
|
|
1775
2048
|
}
|
|
1776
2049
|
return {
|
|
@@ -1887,7 +2160,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1887
2160
|
type: "tool-call",
|
|
1888
2161
|
toolCallId: value.content_block.id,
|
|
1889
2162
|
toolName: value.content_block.name,
|
|
1890
|
-
input: ""
|
|
2163
|
+
input: "",
|
|
2164
|
+
firstDelta: true
|
|
1891
2165
|
};
|
|
1892
2166
|
controller.enqueue(
|
|
1893
2167
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1899,18 +2173,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1899
2173
|
return;
|
|
1900
2174
|
}
|
|
1901
2175
|
case "server_tool_use": {
|
|
1902
|
-
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)) {
|
|
1903
2186
|
contentBlocks[value.index] = {
|
|
1904
2187
|
type: "tool-call",
|
|
1905
2188
|
toolCallId: value.content_block.id,
|
|
1906
2189
|
toolName: value.content_block.name,
|
|
1907
2190
|
input: "",
|
|
1908
|
-
providerExecuted: true
|
|
2191
|
+
providerExecuted: true,
|
|
2192
|
+
firstDelta: true
|
|
1909
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;
|
|
1910
2195
|
controller.enqueue({
|
|
1911
2196
|
type: "tool-input-start",
|
|
1912
2197
|
id: value.content_block.id,
|
|
1913
|
-
toolName:
|
|
2198
|
+
toolName: mappedToolName,
|
|
1914
2199
|
providerExecuted: true
|
|
1915
2200
|
});
|
|
1916
2201
|
}
|
|
@@ -2002,6 +2287,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2002
2287
|
}
|
|
2003
2288
|
return;
|
|
2004
2289
|
}
|
|
2290
|
+
// code execution 20250522:
|
|
2005
2291
|
case "code_execution_tool_result": {
|
|
2006
2292
|
const part = value.content_block;
|
|
2007
2293
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2032,6 +2318,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2032
2318
|
}
|
|
2033
2319
|
return;
|
|
2034
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
|
+
}
|
|
2035
2334
|
default: {
|
|
2036
2335
|
const _exhaustiveCheck = contentBlockType;
|
|
2037
2336
|
throw new Error(
|
|
@@ -2064,7 +2363,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2064
2363
|
type: "tool-input-end",
|
|
2065
2364
|
id: contentBlock.toolCallId
|
|
2066
2365
|
});
|
|
2067
|
-
|
|
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
|
+
});
|
|
2068
2374
|
}
|
|
2069
2375
|
break;
|
|
2070
2376
|
}
|
|
@@ -2112,7 +2418,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2112
2418
|
}
|
|
2113
2419
|
case "input_json_delta": {
|
|
2114
2420
|
const contentBlock = contentBlocks[value.index];
|
|
2115
|
-
|
|
2421
|
+
let delta = value.delta.partial_json;
|
|
2422
|
+
if (delta.length === 0) {
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2116
2425
|
if (usesJsonResponseTool) {
|
|
2117
2426
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2118
2427
|
return;
|
|
@@ -2126,12 +2435,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2126
2435
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2127
2436
|
return;
|
|
2128
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
|
+
}
|
|
2129
2441
|
controller.enqueue({
|
|
2130
2442
|
type: "tool-input-delta",
|
|
2131
2443
|
id: contentBlock.toolCallId,
|
|
2132
2444
|
delta
|
|
2133
2445
|
});
|
|
2134
2446
|
contentBlock.input += delta;
|
|
2447
|
+
contentBlock.firstDelta = false;
|
|
2135
2448
|
}
|
|
2136
2449
|
return;
|
|
2137
2450
|
}
|
|
@@ -2219,15 +2532,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2219
2532
|
// src/tool/bash_20241022.ts
|
|
2220
2533
|
import {
|
|
2221
2534
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2222
|
-
lazySchema as
|
|
2223
|
-
zodSchema as
|
|
2535
|
+
lazySchema as lazySchema8,
|
|
2536
|
+
zodSchema as zodSchema8
|
|
2224
2537
|
} from "@ai-sdk/provider-utils";
|
|
2225
|
-
import { z as
|
|
2226
|
-
var bash_20241022InputSchema =
|
|
2227
|
-
() =>
|
|
2228
|
-
|
|
2229
|
-
command:
|
|
2230
|
-
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()
|
|
2231
2544
|
})
|
|
2232
2545
|
)
|
|
2233
2546
|
);
|
|
@@ -2240,15 +2553,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2240
2553
|
// src/tool/bash_20250124.ts
|
|
2241
2554
|
import {
|
|
2242
2555
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2243
|
-
lazySchema as
|
|
2244
|
-
zodSchema as
|
|
2556
|
+
lazySchema as lazySchema9,
|
|
2557
|
+
zodSchema as zodSchema9
|
|
2245
2558
|
} from "@ai-sdk/provider-utils";
|
|
2246
|
-
import { z as
|
|
2247
|
-
var bash_20250124InputSchema =
|
|
2248
|
-
() =>
|
|
2249
|
-
|
|
2250
|
-
command:
|
|
2251
|
-
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()
|
|
2252
2565
|
})
|
|
2253
2566
|
)
|
|
2254
2567
|
);
|
|
@@ -2261,14 +2574,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2261
2574
|
// src/tool/computer_20241022.ts
|
|
2262
2575
|
import {
|
|
2263
2576
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2264
|
-
lazySchema as
|
|
2265
|
-
zodSchema as
|
|
2577
|
+
lazySchema as lazySchema10,
|
|
2578
|
+
zodSchema as zodSchema10
|
|
2266
2579
|
} from "@ai-sdk/provider-utils";
|
|
2267
|
-
import { z as
|
|
2268
|
-
var computer_20241022InputSchema =
|
|
2269
|
-
() =>
|
|
2270
|
-
|
|
2271
|
-
action:
|
|
2580
|
+
import { z as z11 } from "zod/v4";
|
|
2581
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2582
|
+
() => zodSchema10(
|
|
2583
|
+
z11.object({
|
|
2584
|
+
action: z11.enum([
|
|
2272
2585
|
"key",
|
|
2273
2586
|
"type",
|
|
2274
2587
|
"mouse_move",
|
|
@@ -2280,8 +2593,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2280
2593
|
"screenshot",
|
|
2281
2594
|
"cursor_position"
|
|
2282
2595
|
]),
|
|
2283
|
-
coordinate:
|
|
2284
|
-
text:
|
|
2596
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2597
|
+
text: z11.string().optional()
|
|
2285
2598
|
})
|
|
2286
2599
|
)
|
|
2287
2600
|
);
|
|
@@ -2294,14 +2607,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2294
2607
|
// src/tool/computer_20250124.ts
|
|
2295
2608
|
import {
|
|
2296
2609
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2297
|
-
lazySchema as
|
|
2298
|
-
zodSchema as
|
|
2610
|
+
lazySchema as lazySchema11,
|
|
2611
|
+
zodSchema as zodSchema11
|
|
2299
2612
|
} from "@ai-sdk/provider-utils";
|
|
2300
|
-
import { z as
|
|
2301
|
-
var computer_20250124InputSchema =
|
|
2302
|
-
() =>
|
|
2303
|
-
|
|
2304
|
-
action:
|
|
2613
|
+
import { z as z12 } from "zod/v4";
|
|
2614
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2615
|
+
() => zodSchema11(
|
|
2616
|
+
z12.object({
|
|
2617
|
+
action: z12.enum([
|
|
2305
2618
|
"key",
|
|
2306
2619
|
"hold_key",
|
|
2307
2620
|
"type",
|
|
@@ -2319,12 +2632,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2319
2632
|
"wait",
|
|
2320
2633
|
"screenshot"
|
|
2321
2634
|
]),
|
|
2322
|
-
coordinate:
|
|
2323
|
-
duration:
|
|
2324
|
-
scroll_amount:
|
|
2325
|
-
scroll_direction:
|
|
2326
|
-
start_coordinate:
|
|
2327
|
-
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()
|
|
2328
2641
|
})
|
|
2329
2642
|
)
|
|
2330
2643
|
);
|
|
@@ -2337,37 +2650,11 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2337
2650
|
// src/tool/text-editor_20241022.ts
|
|
2338
2651
|
import {
|
|
2339
2652
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2340
|
-
lazySchema as lazySchema11,
|
|
2341
|
-
zodSchema as zodSchema11
|
|
2342
|
-
} from "@ai-sdk/provider-utils";
|
|
2343
|
-
import { z as z12 } from "zod/v4";
|
|
2344
|
-
var textEditor_20241022InputSchema = lazySchema11(
|
|
2345
|
-
() => zodSchema11(
|
|
2346
|
-
z12.object({
|
|
2347
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2348
|
-
path: z12.string(),
|
|
2349
|
-
file_text: z12.string().optional(),
|
|
2350
|
-
insert_line: z12.number().int().optional(),
|
|
2351
|
-
new_str: z12.string().optional(),
|
|
2352
|
-
old_str: z12.string().optional(),
|
|
2353
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2354
|
-
})
|
|
2355
|
-
)
|
|
2356
|
-
);
|
|
2357
|
-
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2358
|
-
id: "anthropic.text_editor_20241022",
|
|
2359
|
-
name: "str_replace_editor",
|
|
2360
|
-
inputSchema: textEditor_20241022InputSchema
|
|
2361
|
-
});
|
|
2362
|
-
|
|
2363
|
-
// src/tool/text-editor_20250124.ts
|
|
2364
|
-
import {
|
|
2365
|
-
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2366
2653
|
lazySchema as lazySchema12,
|
|
2367
2654
|
zodSchema as zodSchema12
|
|
2368
2655
|
} from "@ai-sdk/provider-utils";
|
|
2369
2656
|
import { z as z13 } from "zod/v4";
|
|
2370
|
-
var
|
|
2657
|
+
var textEditor_20241022InputSchema = lazySchema12(
|
|
2371
2658
|
() => zodSchema12(
|
|
2372
2659
|
z13.object({
|
|
2373
2660
|
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -2380,23 +2667,23 @@ var textEditor_20250124InputSchema = lazySchema12(
|
|
|
2380
2667
|
})
|
|
2381
2668
|
)
|
|
2382
2669
|
);
|
|
2383
|
-
var
|
|
2384
|
-
id: "anthropic.
|
|
2670
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2671
|
+
id: "anthropic.text_editor_20241022",
|
|
2385
2672
|
name: "str_replace_editor",
|
|
2386
|
-
inputSchema:
|
|
2673
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2387
2674
|
});
|
|
2388
2675
|
|
|
2389
|
-
// src/tool/text-
|
|
2676
|
+
// src/tool/text-editor_20250124.ts
|
|
2390
2677
|
import {
|
|
2391
|
-
createProviderDefinedToolFactory as
|
|
2678
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2392
2679
|
lazySchema as lazySchema13,
|
|
2393
2680
|
zodSchema as zodSchema13
|
|
2394
2681
|
} from "@ai-sdk/provider-utils";
|
|
2395
2682
|
import { z as z14 } from "zod/v4";
|
|
2396
|
-
var
|
|
2683
|
+
var textEditor_20250124InputSchema = lazySchema13(
|
|
2397
2684
|
() => zodSchema13(
|
|
2398
2685
|
z14.object({
|
|
2399
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2686
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2400
2687
|
path: z14.string(),
|
|
2401
2688
|
file_text: z14.string().optional(),
|
|
2402
2689
|
insert_line: z14.number().int().optional(),
|
|
@@ -2406,6 +2693,32 @@ var textEditor_20250429InputSchema = lazySchema13(
|
|
|
2406
2693
|
})
|
|
2407
2694
|
)
|
|
2408
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
|
+
);
|
|
2409
2722
|
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
2410
2723
|
id: "anthropic.text_editor_20250429",
|
|
2411
2724
|
name: "str_replace_based_edit_tool",
|
|
@@ -2443,6 +2756,19 @@ var anthropicTools = {
|
|
|
2443
2756
|
* Tool name must be `code_execution`.
|
|
2444
2757
|
*/
|
|
2445
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,
|
|
2446
2772
|
/**
|
|
2447
2773
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2448
2774
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|