@ai-sdk/anthropic 2.0.27 → 2.0.28
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 +3 -3
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 ? "2.0.
|
|
13
|
+
var VERSION = true ? "2.0.28" : "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") {
|
|
@@ -1138,7 +1353,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1138
1353
|
}
|
|
1139
1354
|
case "tool-call": {
|
|
1140
1355
|
if (part.providerExecuted) {
|
|
1141
|
-
if (part.toolName === "code_execution"
|
|
1356
|
+
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")) {
|
|
1357
|
+
anthropicContent.push({
|
|
1358
|
+
type: "server_tool_use",
|
|
1359
|
+
id: part.toolCallId,
|
|
1360
|
+
name: part.input.type,
|
|
1361
|
+
// map back to subtool name
|
|
1362
|
+
input: part.input,
|
|
1363
|
+
cache_control: cacheControl
|
|
1364
|
+
});
|
|
1365
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1366
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1142
1367
|
anthropicContent.push({
|
|
1143
1368
|
type: "server_tool_use",
|
|
1144
1369
|
id: part.toolCallId,
|
|
@@ -1173,21 +1398,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1173
1398
|
});
|
|
1174
1399
|
break;
|
|
1175
1400
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1401
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1402
|
+
warnings.push({
|
|
1403
|
+
type: "other",
|
|
1404
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1405
|
+
});
|
|
1406
|
+
break;
|
|
1407
|
+
}
|
|
1408
|
+
if (output.value.type === "code_execution_result") {
|
|
1409
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1410
|
+
value: output.value,
|
|
1411
|
+
schema: codeExecution_20250522OutputSchema
|
|
1412
|
+
});
|
|
1413
|
+
anthropicContent.push({
|
|
1414
|
+
type: "code_execution_tool_result",
|
|
1415
|
+
tool_use_id: part.toolCallId,
|
|
1416
|
+
content: {
|
|
1417
|
+
type: codeExecutionOutput.type,
|
|
1418
|
+
stdout: codeExecutionOutput.stdout,
|
|
1419
|
+
stderr: codeExecutionOutput.stderr,
|
|
1420
|
+
return_code: codeExecutionOutput.return_code
|
|
1421
|
+
},
|
|
1422
|
+
cache_control: cacheControl
|
|
1423
|
+
});
|
|
1424
|
+
} else {
|
|
1425
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1426
|
+
value: output.value,
|
|
1427
|
+
schema: codeExecution_20250825OutputSchema
|
|
1428
|
+
});
|
|
1429
|
+
anthropicContent.push(
|
|
1430
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1431
|
+
type: "bash_code_execution_tool_result",
|
|
1432
|
+
tool_use_id: part.toolCallId,
|
|
1433
|
+
cache_control: cacheControl,
|
|
1434
|
+
content: codeExecutionOutput
|
|
1435
|
+
} : {
|
|
1436
|
+
type: "text_editor_code_execution_tool_result",
|
|
1437
|
+
tool_use_id: part.toolCallId,
|
|
1438
|
+
cache_control: cacheControl,
|
|
1439
|
+
content: codeExecutionOutput
|
|
1440
|
+
}
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1191
1443
|
break;
|
|
1192
1444
|
}
|
|
1193
1445
|
if (part.toolName === "web_fetch") {
|
|
@@ -1657,7 +1909,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1657
1909
|
break;
|
|
1658
1910
|
}
|
|
1659
1911
|
case "server_tool_use": {
|
|
1660
|
-
if (part.name === "
|
|
1912
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1913
|
+
content.push({
|
|
1914
|
+
type: "tool-call",
|
|
1915
|
+
toolCallId: part.id,
|
|
1916
|
+
toolName: "code_execution",
|
|
1917
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1918
|
+
providerExecuted: true
|
|
1919
|
+
});
|
|
1920
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1661
1921
|
content.push({
|
|
1662
1922
|
type: "tool-call",
|
|
1663
1923
|
toolCallId: part.id,
|
|
@@ -1753,6 +2013,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1753
2013
|
}
|
|
1754
2014
|
break;
|
|
1755
2015
|
}
|
|
2016
|
+
// code execution 20250522:
|
|
1756
2017
|
case "code_execution_tool_result": {
|
|
1757
2018
|
if (part.content.type === "code_execution_result") {
|
|
1758
2019
|
content.push({
|
|
@@ -1782,6 +2043,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1782
2043
|
}
|
|
1783
2044
|
break;
|
|
1784
2045
|
}
|
|
2046
|
+
// code execution 20250825:
|
|
2047
|
+
case "bash_code_execution_tool_result":
|
|
2048
|
+
case "text_editor_code_execution_tool_result": {
|
|
2049
|
+
content.push({
|
|
2050
|
+
type: "tool-result",
|
|
2051
|
+
toolCallId: part.tool_use_id,
|
|
2052
|
+
toolName: "code_execution",
|
|
2053
|
+
result: part.content,
|
|
2054
|
+
providerExecuted: true
|
|
2055
|
+
});
|
|
2056
|
+
break;
|
|
2057
|
+
}
|
|
1785
2058
|
}
|
|
1786
2059
|
}
|
|
1787
2060
|
return {
|
|
@@ -1898,7 +2171,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1898
2171
|
type: "tool-call",
|
|
1899
2172
|
toolCallId: value.content_block.id,
|
|
1900
2173
|
toolName: value.content_block.name,
|
|
1901
|
-
input: ""
|
|
2174
|
+
input: "",
|
|
2175
|
+
firstDelta: true
|
|
1902
2176
|
};
|
|
1903
2177
|
controller.enqueue(
|
|
1904
2178
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1910,18 +2184,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1910
2184
|
return;
|
|
1911
2185
|
}
|
|
1912
2186
|
case "server_tool_use": {
|
|
1913
|
-
if (
|
|
2187
|
+
if ([
|
|
2188
|
+
"web_fetch",
|
|
2189
|
+
"web_search",
|
|
2190
|
+
// code execution 20250825:
|
|
2191
|
+
"code_execution",
|
|
2192
|
+
// code execution 20250825 text editor:
|
|
2193
|
+
"text_editor_code_execution",
|
|
2194
|
+
// code execution 20250825 bash:
|
|
2195
|
+
"bash_code_execution"
|
|
2196
|
+
].includes(value.content_block.name)) {
|
|
1914
2197
|
contentBlocks[value.index] = {
|
|
1915
2198
|
type: "tool-call",
|
|
1916
2199
|
toolCallId: value.content_block.id,
|
|
1917
2200
|
toolName: value.content_block.name,
|
|
1918
2201
|
input: "",
|
|
1919
|
-
providerExecuted: true
|
|
2202
|
+
providerExecuted: true,
|
|
2203
|
+
firstDelta: true
|
|
1920
2204
|
};
|
|
2205
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1921
2206
|
controller.enqueue({
|
|
1922
2207
|
type: "tool-input-start",
|
|
1923
2208
|
id: value.content_block.id,
|
|
1924
|
-
toolName:
|
|
2209
|
+
toolName: mappedToolName,
|
|
1925
2210
|
providerExecuted: true
|
|
1926
2211
|
});
|
|
1927
2212
|
}
|
|
@@ -2013,6 +2298,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2013
2298
|
}
|
|
2014
2299
|
return;
|
|
2015
2300
|
}
|
|
2301
|
+
// code execution 20250522:
|
|
2016
2302
|
case "code_execution_tool_result": {
|
|
2017
2303
|
const part = value.content_block;
|
|
2018
2304
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2043,6 +2329,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2043
2329
|
}
|
|
2044
2330
|
return;
|
|
2045
2331
|
}
|
|
2332
|
+
// code execution 20250825:
|
|
2333
|
+
case "bash_code_execution_tool_result":
|
|
2334
|
+
case "text_editor_code_execution_tool_result": {
|
|
2335
|
+
const part = value.content_block;
|
|
2336
|
+
controller.enqueue({
|
|
2337
|
+
type: "tool-result",
|
|
2338
|
+
toolCallId: part.tool_use_id,
|
|
2339
|
+
toolName: "code_execution",
|
|
2340
|
+
result: part.content,
|
|
2341
|
+
providerExecuted: true
|
|
2342
|
+
});
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2046
2345
|
default: {
|
|
2047
2346
|
const _exhaustiveCheck = contentBlockType;
|
|
2048
2347
|
throw new Error(
|
|
@@ -2075,7 +2374,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2075
2374
|
type: "tool-input-end",
|
|
2076
2375
|
id: contentBlock.toolCallId
|
|
2077
2376
|
});
|
|
2078
|
-
|
|
2377
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2378
|
+
controller.enqueue({
|
|
2379
|
+
type: "tool-call",
|
|
2380
|
+
toolCallId: contentBlock.toolCallId,
|
|
2381
|
+
toolName,
|
|
2382
|
+
input: contentBlock.input,
|
|
2383
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2384
|
+
});
|
|
2079
2385
|
}
|
|
2080
2386
|
break;
|
|
2081
2387
|
}
|
|
@@ -2123,7 +2429,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2123
2429
|
}
|
|
2124
2430
|
case "input_json_delta": {
|
|
2125
2431
|
const contentBlock = contentBlocks[value.index];
|
|
2126
|
-
|
|
2432
|
+
let delta = value.delta.partial_json;
|
|
2433
|
+
if (delta.length === 0) {
|
|
2434
|
+
return;
|
|
2435
|
+
}
|
|
2127
2436
|
if (usesJsonResponseTool) {
|
|
2128
2437
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2129
2438
|
return;
|
|
@@ -2137,12 +2446,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2137
2446
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2138
2447
|
return;
|
|
2139
2448
|
}
|
|
2449
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2450
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2451
|
+
}
|
|
2140
2452
|
controller.enqueue({
|
|
2141
2453
|
type: "tool-input-delta",
|
|
2142
2454
|
id: contentBlock.toolCallId,
|
|
2143
2455
|
delta
|
|
2144
2456
|
});
|
|
2145
2457
|
contentBlock.input += delta;
|
|
2458
|
+
contentBlock.firstDelta = false;
|
|
2146
2459
|
}
|
|
2147
2460
|
return;
|
|
2148
2461
|
}
|
|
@@ -2230,15 +2543,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2230
2543
|
// src/tool/bash_20241022.ts
|
|
2231
2544
|
import {
|
|
2232
2545
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2233
|
-
lazySchema as
|
|
2234
|
-
zodSchema as
|
|
2546
|
+
lazySchema as lazySchema8,
|
|
2547
|
+
zodSchema as zodSchema8
|
|
2235
2548
|
} from "@ai-sdk/provider-utils";
|
|
2236
|
-
import { z as
|
|
2237
|
-
var bash_20241022InputSchema =
|
|
2238
|
-
() =>
|
|
2239
|
-
|
|
2240
|
-
command:
|
|
2241
|
-
restart:
|
|
2549
|
+
import { z as z9 } from "zod/v4";
|
|
2550
|
+
var bash_20241022InputSchema = lazySchema8(
|
|
2551
|
+
() => zodSchema8(
|
|
2552
|
+
z9.object({
|
|
2553
|
+
command: z9.string(),
|
|
2554
|
+
restart: z9.boolean().optional()
|
|
2242
2555
|
})
|
|
2243
2556
|
)
|
|
2244
2557
|
);
|
|
@@ -2251,15 +2564,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2251
2564
|
// src/tool/bash_20250124.ts
|
|
2252
2565
|
import {
|
|
2253
2566
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2254
|
-
lazySchema as
|
|
2255
|
-
zodSchema as
|
|
2567
|
+
lazySchema as lazySchema9,
|
|
2568
|
+
zodSchema as zodSchema9
|
|
2256
2569
|
} from "@ai-sdk/provider-utils";
|
|
2257
|
-
import { z as
|
|
2258
|
-
var bash_20250124InputSchema =
|
|
2259
|
-
() =>
|
|
2260
|
-
|
|
2261
|
-
command:
|
|
2262
|
-
restart:
|
|
2570
|
+
import { z as z10 } from "zod/v4";
|
|
2571
|
+
var bash_20250124InputSchema = lazySchema9(
|
|
2572
|
+
() => zodSchema9(
|
|
2573
|
+
z10.object({
|
|
2574
|
+
command: z10.string(),
|
|
2575
|
+
restart: z10.boolean().optional()
|
|
2263
2576
|
})
|
|
2264
2577
|
)
|
|
2265
2578
|
);
|
|
@@ -2272,14 +2585,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2272
2585
|
// src/tool/computer_20241022.ts
|
|
2273
2586
|
import {
|
|
2274
2587
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2275
|
-
lazySchema as
|
|
2276
|
-
zodSchema as
|
|
2588
|
+
lazySchema as lazySchema10,
|
|
2589
|
+
zodSchema as zodSchema10
|
|
2277
2590
|
} from "@ai-sdk/provider-utils";
|
|
2278
|
-
import { z as
|
|
2279
|
-
var computer_20241022InputSchema =
|
|
2280
|
-
() =>
|
|
2281
|
-
|
|
2282
|
-
action:
|
|
2591
|
+
import { z as z11 } from "zod/v4";
|
|
2592
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2593
|
+
() => zodSchema10(
|
|
2594
|
+
z11.object({
|
|
2595
|
+
action: z11.enum([
|
|
2283
2596
|
"key",
|
|
2284
2597
|
"type",
|
|
2285
2598
|
"mouse_move",
|
|
@@ -2291,8 +2604,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2291
2604
|
"screenshot",
|
|
2292
2605
|
"cursor_position"
|
|
2293
2606
|
]),
|
|
2294
|
-
coordinate:
|
|
2295
|
-
text:
|
|
2607
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2608
|
+
text: z11.string().optional()
|
|
2296
2609
|
})
|
|
2297
2610
|
)
|
|
2298
2611
|
);
|
|
@@ -2305,14 +2618,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2305
2618
|
// src/tool/computer_20250124.ts
|
|
2306
2619
|
import {
|
|
2307
2620
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2308
|
-
lazySchema as
|
|
2309
|
-
zodSchema as
|
|
2621
|
+
lazySchema as lazySchema11,
|
|
2622
|
+
zodSchema as zodSchema11
|
|
2310
2623
|
} from "@ai-sdk/provider-utils";
|
|
2311
|
-
import { z as
|
|
2312
|
-
var computer_20250124InputSchema =
|
|
2313
|
-
() =>
|
|
2314
|
-
|
|
2315
|
-
action:
|
|
2624
|
+
import { z as z12 } from "zod/v4";
|
|
2625
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2626
|
+
() => zodSchema11(
|
|
2627
|
+
z12.object({
|
|
2628
|
+
action: z12.enum([
|
|
2316
2629
|
"key",
|
|
2317
2630
|
"hold_key",
|
|
2318
2631
|
"type",
|
|
@@ -2330,12 +2643,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2330
2643
|
"wait",
|
|
2331
2644
|
"screenshot"
|
|
2332
2645
|
]),
|
|
2333
|
-
coordinate:
|
|
2334
|
-
duration:
|
|
2335
|
-
scroll_amount:
|
|
2336
|
-
scroll_direction:
|
|
2337
|
-
start_coordinate:
|
|
2338
|
-
text:
|
|
2646
|
+
coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2647
|
+
duration: z12.number().optional(),
|
|
2648
|
+
scroll_amount: z12.number().optional(),
|
|
2649
|
+
scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
|
|
2650
|
+
start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2651
|
+
text: z12.string().optional()
|
|
2339
2652
|
})
|
|
2340
2653
|
)
|
|
2341
2654
|
);
|
|
@@ -2348,37 +2661,11 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2348
2661
|
// src/tool/text-editor_20241022.ts
|
|
2349
2662
|
import {
|
|
2350
2663
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2351
|
-
lazySchema as lazySchema11,
|
|
2352
|
-
zodSchema as zodSchema11
|
|
2353
|
-
} from "@ai-sdk/provider-utils";
|
|
2354
|
-
import { z as z12 } from "zod/v4";
|
|
2355
|
-
var textEditor_20241022InputSchema = lazySchema11(
|
|
2356
|
-
() => zodSchema11(
|
|
2357
|
-
z12.object({
|
|
2358
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2359
|
-
path: z12.string(),
|
|
2360
|
-
file_text: z12.string().optional(),
|
|
2361
|
-
insert_line: z12.number().int().optional(),
|
|
2362
|
-
new_str: z12.string().optional(),
|
|
2363
|
-
old_str: z12.string().optional(),
|
|
2364
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2365
|
-
})
|
|
2366
|
-
)
|
|
2367
|
-
);
|
|
2368
|
-
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2369
|
-
id: "anthropic.text_editor_20241022",
|
|
2370
|
-
name: "str_replace_editor",
|
|
2371
|
-
inputSchema: textEditor_20241022InputSchema
|
|
2372
|
-
});
|
|
2373
|
-
|
|
2374
|
-
// src/tool/text-editor_20250124.ts
|
|
2375
|
-
import {
|
|
2376
|
-
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2377
2664
|
lazySchema as lazySchema12,
|
|
2378
2665
|
zodSchema as zodSchema12
|
|
2379
2666
|
} from "@ai-sdk/provider-utils";
|
|
2380
2667
|
import { z as z13 } from "zod/v4";
|
|
2381
|
-
var
|
|
2668
|
+
var textEditor_20241022InputSchema = lazySchema12(
|
|
2382
2669
|
() => zodSchema12(
|
|
2383
2670
|
z13.object({
|
|
2384
2671
|
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -2391,23 +2678,23 @@ var textEditor_20250124InputSchema = lazySchema12(
|
|
|
2391
2678
|
})
|
|
2392
2679
|
)
|
|
2393
2680
|
);
|
|
2394
|
-
var
|
|
2395
|
-
id: "anthropic.
|
|
2681
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2682
|
+
id: "anthropic.text_editor_20241022",
|
|
2396
2683
|
name: "str_replace_editor",
|
|
2397
|
-
inputSchema:
|
|
2684
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2398
2685
|
});
|
|
2399
2686
|
|
|
2400
|
-
// src/tool/text-
|
|
2687
|
+
// src/tool/text-editor_20250124.ts
|
|
2401
2688
|
import {
|
|
2402
|
-
createProviderDefinedToolFactory as
|
|
2689
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2403
2690
|
lazySchema as lazySchema13,
|
|
2404
2691
|
zodSchema as zodSchema13
|
|
2405
2692
|
} from "@ai-sdk/provider-utils";
|
|
2406
2693
|
import { z as z14 } from "zod/v4";
|
|
2407
|
-
var
|
|
2694
|
+
var textEditor_20250124InputSchema = lazySchema13(
|
|
2408
2695
|
() => zodSchema13(
|
|
2409
2696
|
z14.object({
|
|
2410
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2697
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2411
2698
|
path: z14.string(),
|
|
2412
2699
|
file_text: z14.string().optional(),
|
|
2413
2700
|
insert_line: z14.number().int().optional(),
|
|
@@ -2417,6 +2704,32 @@ var textEditor_20250429InputSchema = lazySchema13(
|
|
|
2417
2704
|
})
|
|
2418
2705
|
)
|
|
2419
2706
|
);
|
|
2707
|
+
var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
2708
|
+
id: "anthropic.text_editor_20250124",
|
|
2709
|
+
name: "str_replace_editor",
|
|
2710
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2711
|
+
});
|
|
2712
|
+
|
|
2713
|
+
// src/tool/text-editor_20250429.ts
|
|
2714
|
+
import {
|
|
2715
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
2716
|
+
lazySchema as lazySchema14,
|
|
2717
|
+
zodSchema as zodSchema14
|
|
2718
|
+
} from "@ai-sdk/provider-utils";
|
|
2719
|
+
import { z as z15 } from "zod/v4";
|
|
2720
|
+
var textEditor_20250429InputSchema = lazySchema14(
|
|
2721
|
+
() => zodSchema14(
|
|
2722
|
+
z15.object({
|
|
2723
|
+
command: z15.enum(["view", "create", "str_replace", "insert"]),
|
|
2724
|
+
path: z15.string(),
|
|
2725
|
+
file_text: z15.string().optional(),
|
|
2726
|
+
insert_line: z15.number().int().optional(),
|
|
2727
|
+
new_str: z15.string().optional(),
|
|
2728
|
+
old_str: z15.string().optional(),
|
|
2729
|
+
view_range: z15.array(z15.number().int()).optional()
|
|
2730
|
+
})
|
|
2731
|
+
)
|
|
2732
|
+
);
|
|
2420
2733
|
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
2421
2734
|
id: "anthropic.text_editor_20250429",
|
|
2422
2735
|
name: "str_replace_based_edit_tool",
|
|
@@ -2454,6 +2767,19 @@ var anthropicTools = {
|
|
|
2454
2767
|
* Tool name must be `code_execution`.
|
|
2455
2768
|
*/
|
|
2456
2769
|
codeExecution_20250522,
|
|
2770
|
+
/**
|
|
2771
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2772
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2773
|
+
* the API conversation.
|
|
2774
|
+
*
|
|
2775
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2776
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2777
|
+
*
|
|
2778
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2779
|
+
*
|
|
2780
|
+
* Tool name must be `code_execution`.
|
|
2781
|
+
*/
|
|
2782
|
+
codeExecution_20250825,
|
|
2457
2783
|
/**
|
|
2458
2784
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2459
2785
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|