@ai-sdk/anthropic 2.0.27 → 2.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +141 -0
- package/dist/index.d.ts +141 -0
- package/dist/index.js +510 -123
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +502 -107
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +147 -0
- package/dist/internal/index.d.ts +147 -0
- package/dist/internal/index.js +504 -117
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +501 -106
- 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({
|
|
@@ -681,6 +803,14 @@ async function prepareTools({
|
|
|
681
803
|
});
|
|
682
804
|
break;
|
|
683
805
|
}
|
|
806
|
+
case "anthropic.memory_20250818": {
|
|
807
|
+
betas.add("context-management-2025-06-27");
|
|
808
|
+
anthropicTools2.push({
|
|
809
|
+
name: "memory",
|
|
810
|
+
type: "memory_20250818"
|
|
811
|
+
});
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
684
814
|
case "anthropic.web_fetch_20250910": {
|
|
685
815
|
betas.add("web-fetch-2025-09-10");
|
|
686
816
|
const args = await validateTypes({
|
|
@@ -822,6 +952,99 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
822
952
|
return factory4(args);
|
|
823
953
|
};
|
|
824
954
|
|
|
955
|
+
// src/tool/code-execution_20250825.ts
|
|
956
|
+
import {
|
|
957
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
958
|
+
lazySchema as lazySchema7,
|
|
959
|
+
zodSchema as zodSchema7
|
|
960
|
+
} from "@ai-sdk/provider-utils";
|
|
961
|
+
import { z as z8 } from "zod/v4";
|
|
962
|
+
var codeExecution_20250825OutputSchema = lazySchema7(
|
|
963
|
+
() => zodSchema7(
|
|
964
|
+
z8.discriminatedUnion("type", [
|
|
965
|
+
z8.object({
|
|
966
|
+
type: z8.literal("bash_code_execution_result"),
|
|
967
|
+
content: z8.array(
|
|
968
|
+
z8.object({
|
|
969
|
+
type: z8.literal("bash_code_execution_output"),
|
|
970
|
+
file_id: z8.string()
|
|
971
|
+
})
|
|
972
|
+
),
|
|
973
|
+
stdout: z8.string(),
|
|
974
|
+
stderr: z8.string(),
|
|
975
|
+
return_code: z8.number()
|
|
976
|
+
}),
|
|
977
|
+
z8.object({
|
|
978
|
+
type: z8.literal("bash_code_execution_tool_result_error"),
|
|
979
|
+
error_code: z8.string()
|
|
980
|
+
}),
|
|
981
|
+
z8.object({
|
|
982
|
+
type: z8.literal("text_editor_code_execution_tool_result_error"),
|
|
983
|
+
error_code: z8.string()
|
|
984
|
+
}),
|
|
985
|
+
z8.object({
|
|
986
|
+
type: z8.literal("text_editor_code_execution_view_result"),
|
|
987
|
+
content: z8.string(),
|
|
988
|
+
file_type: z8.string(),
|
|
989
|
+
num_lines: z8.number().nullable(),
|
|
990
|
+
start_line: z8.number().nullable(),
|
|
991
|
+
total_lines: z8.number().nullable()
|
|
992
|
+
}),
|
|
993
|
+
z8.object({
|
|
994
|
+
type: z8.literal("text_editor_code_execution_create_result"),
|
|
995
|
+
is_file_update: z8.boolean()
|
|
996
|
+
}),
|
|
997
|
+
z8.object({
|
|
998
|
+
type: z8.literal("text_editor_code_execution_str_replace_result"),
|
|
999
|
+
lines: z8.array(z8.string()).nullable(),
|
|
1000
|
+
new_lines: z8.number().nullable(),
|
|
1001
|
+
new_start: z8.number().nullable(),
|
|
1002
|
+
old_lines: z8.number().nullable(),
|
|
1003
|
+
old_start: z8.number().nullable()
|
|
1004
|
+
})
|
|
1005
|
+
])
|
|
1006
|
+
)
|
|
1007
|
+
);
|
|
1008
|
+
var codeExecution_20250825InputSchema = lazySchema7(
|
|
1009
|
+
() => zodSchema7(
|
|
1010
|
+
z8.discriminatedUnion("type", [
|
|
1011
|
+
z8.object({
|
|
1012
|
+
type: z8.literal("bash_code_execution"),
|
|
1013
|
+
command: z8.string()
|
|
1014
|
+
}),
|
|
1015
|
+
z8.discriminatedUnion("command", [
|
|
1016
|
+
z8.object({
|
|
1017
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1018
|
+
command: z8.literal("view"),
|
|
1019
|
+
path: z8.string()
|
|
1020
|
+
}),
|
|
1021
|
+
z8.object({
|
|
1022
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1023
|
+
command: z8.literal("create"),
|
|
1024
|
+
path: z8.string(),
|
|
1025
|
+
file_text: z8.string().nullish()
|
|
1026
|
+
}),
|
|
1027
|
+
z8.object({
|
|
1028
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1029
|
+
command: z8.literal("str_replace"),
|
|
1030
|
+
path: z8.string(),
|
|
1031
|
+
old_str: z8.string(),
|
|
1032
|
+
new_str: z8.string()
|
|
1033
|
+
})
|
|
1034
|
+
])
|
|
1035
|
+
])
|
|
1036
|
+
)
|
|
1037
|
+
);
|
|
1038
|
+
var factory5 = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
1039
|
+
id: "anthropic.code_execution_20250825",
|
|
1040
|
+
name: "code_execution",
|
|
1041
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
1042
|
+
outputSchema: codeExecution_20250825OutputSchema
|
|
1043
|
+
});
|
|
1044
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
1045
|
+
return factory5(args);
|
|
1046
|
+
};
|
|
1047
|
+
|
|
825
1048
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
826
1049
|
function convertToString(data) {
|
|
827
1050
|
if (typeof data === "string") {
|
|
@@ -1124,7 +1347,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1124
1347
|
}
|
|
1125
1348
|
case "tool-call": {
|
|
1126
1349
|
if (part.providerExecuted) {
|
|
1127
|
-
if (part.toolName === "code_execution"
|
|
1350
|
+
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")) {
|
|
1351
|
+
anthropicContent.push({
|
|
1352
|
+
type: "server_tool_use",
|
|
1353
|
+
id: part.toolCallId,
|
|
1354
|
+
name: part.input.type,
|
|
1355
|
+
// map back to subtool name
|
|
1356
|
+
input: part.input,
|
|
1357
|
+
cache_control: cacheControl
|
|
1358
|
+
});
|
|
1359
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1360
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1128
1361
|
anthropicContent.push({
|
|
1129
1362
|
type: "server_tool_use",
|
|
1130
1363
|
id: part.toolCallId,
|
|
@@ -1159,21 +1392,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1159
1392
|
});
|
|
1160
1393
|
break;
|
|
1161
1394
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1395
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1396
|
+
warnings.push({
|
|
1397
|
+
type: "other",
|
|
1398
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1399
|
+
});
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
if (output.value.type === "code_execution_result") {
|
|
1403
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1404
|
+
value: output.value,
|
|
1405
|
+
schema: codeExecution_20250522OutputSchema
|
|
1406
|
+
});
|
|
1407
|
+
anthropicContent.push({
|
|
1408
|
+
type: "code_execution_tool_result",
|
|
1409
|
+
tool_use_id: part.toolCallId,
|
|
1410
|
+
content: {
|
|
1411
|
+
type: codeExecutionOutput.type,
|
|
1412
|
+
stdout: codeExecutionOutput.stdout,
|
|
1413
|
+
stderr: codeExecutionOutput.stderr,
|
|
1414
|
+
return_code: codeExecutionOutput.return_code
|
|
1415
|
+
},
|
|
1416
|
+
cache_control: cacheControl
|
|
1417
|
+
});
|
|
1418
|
+
} else {
|
|
1419
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1420
|
+
value: output.value,
|
|
1421
|
+
schema: codeExecution_20250825OutputSchema
|
|
1422
|
+
});
|
|
1423
|
+
anthropicContent.push(
|
|
1424
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1425
|
+
type: "bash_code_execution_tool_result",
|
|
1426
|
+
tool_use_id: part.toolCallId,
|
|
1427
|
+
cache_control: cacheControl,
|
|
1428
|
+
content: codeExecutionOutput
|
|
1429
|
+
} : {
|
|
1430
|
+
type: "text_editor_code_execution_tool_result",
|
|
1431
|
+
tool_use_id: part.toolCallId,
|
|
1432
|
+
cache_control: cacheControl,
|
|
1433
|
+
content: codeExecutionOutput
|
|
1434
|
+
}
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1177
1437
|
break;
|
|
1178
1438
|
}
|
|
1179
1439
|
if (part.toolName === "web_fetch") {
|
|
@@ -1643,7 +1903,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1643
1903
|
break;
|
|
1644
1904
|
}
|
|
1645
1905
|
case "server_tool_use": {
|
|
1646
|
-
if (part.name === "
|
|
1906
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1907
|
+
content.push({
|
|
1908
|
+
type: "tool-call",
|
|
1909
|
+
toolCallId: part.id,
|
|
1910
|
+
toolName: "code_execution",
|
|
1911
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1912
|
+
providerExecuted: true
|
|
1913
|
+
});
|
|
1914
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1647
1915
|
content.push({
|
|
1648
1916
|
type: "tool-call",
|
|
1649
1917
|
toolCallId: part.id,
|
|
@@ -1739,6 +2007,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1739
2007
|
}
|
|
1740
2008
|
break;
|
|
1741
2009
|
}
|
|
2010
|
+
// code execution 20250522:
|
|
1742
2011
|
case "code_execution_tool_result": {
|
|
1743
2012
|
if (part.content.type === "code_execution_result") {
|
|
1744
2013
|
content.push({
|
|
@@ -1768,6 +2037,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1768
2037
|
}
|
|
1769
2038
|
break;
|
|
1770
2039
|
}
|
|
2040
|
+
// code execution 20250825:
|
|
2041
|
+
case "bash_code_execution_tool_result":
|
|
2042
|
+
case "text_editor_code_execution_tool_result": {
|
|
2043
|
+
content.push({
|
|
2044
|
+
type: "tool-result",
|
|
2045
|
+
toolCallId: part.tool_use_id,
|
|
2046
|
+
toolName: "code_execution",
|
|
2047
|
+
result: part.content,
|
|
2048
|
+
providerExecuted: true
|
|
2049
|
+
});
|
|
2050
|
+
break;
|
|
2051
|
+
}
|
|
1771
2052
|
}
|
|
1772
2053
|
}
|
|
1773
2054
|
return {
|
|
@@ -1884,7 +2165,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1884
2165
|
type: "tool-call",
|
|
1885
2166
|
toolCallId: value.content_block.id,
|
|
1886
2167
|
toolName: value.content_block.name,
|
|
1887
|
-
input: ""
|
|
2168
|
+
input: "",
|
|
2169
|
+
firstDelta: true
|
|
1888
2170
|
};
|
|
1889
2171
|
controller.enqueue(
|
|
1890
2172
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1896,18 +2178,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1896
2178
|
return;
|
|
1897
2179
|
}
|
|
1898
2180
|
case "server_tool_use": {
|
|
1899
|
-
if (
|
|
2181
|
+
if ([
|
|
2182
|
+
"web_fetch",
|
|
2183
|
+
"web_search",
|
|
2184
|
+
// code execution 20250825:
|
|
2185
|
+
"code_execution",
|
|
2186
|
+
// code execution 20250825 text editor:
|
|
2187
|
+
"text_editor_code_execution",
|
|
2188
|
+
// code execution 20250825 bash:
|
|
2189
|
+
"bash_code_execution"
|
|
2190
|
+
].includes(value.content_block.name)) {
|
|
1900
2191
|
contentBlocks[value.index] = {
|
|
1901
2192
|
type: "tool-call",
|
|
1902
2193
|
toolCallId: value.content_block.id,
|
|
1903
2194
|
toolName: value.content_block.name,
|
|
1904
2195
|
input: "",
|
|
1905
|
-
providerExecuted: true
|
|
2196
|
+
providerExecuted: true,
|
|
2197
|
+
firstDelta: true
|
|
1906
2198
|
};
|
|
2199
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1907
2200
|
controller.enqueue({
|
|
1908
2201
|
type: "tool-input-start",
|
|
1909
2202
|
id: value.content_block.id,
|
|
1910
|
-
toolName:
|
|
2203
|
+
toolName: mappedToolName,
|
|
1911
2204
|
providerExecuted: true
|
|
1912
2205
|
});
|
|
1913
2206
|
}
|
|
@@ -1999,6 +2292,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1999
2292
|
}
|
|
2000
2293
|
return;
|
|
2001
2294
|
}
|
|
2295
|
+
// code execution 20250522:
|
|
2002
2296
|
case "code_execution_tool_result": {
|
|
2003
2297
|
const part = value.content_block;
|
|
2004
2298
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2029,6 +2323,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2029
2323
|
}
|
|
2030
2324
|
return;
|
|
2031
2325
|
}
|
|
2326
|
+
// code execution 20250825:
|
|
2327
|
+
case "bash_code_execution_tool_result":
|
|
2328
|
+
case "text_editor_code_execution_tool_result": {
|
|
2329
|
+
const part = value.content_block;
|
|
2330
|
+
controller.enqueue({
|
|
2331
|
+
type: "tool-result",
|
|
2332
|
+
toolCallId: part.tool_use_id,
|
|
2333
|
+
toolName: "code_execution",
|
|
2334
|
+
result: part.content,
|
|
2335
|
+
providerExecuted: true
|
|
2336
|
+
});
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2032
2339
|
default: {
|
|
2033
2340
|
const _exhaustiveCheck = contentBlockType;
|
|
2034
2341
|
throw new Error(
|
|
@@ -2061,7 +2368,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2061
2368
|
type: "tool-input-end",
|
|
2062
2369
|
id: contentBlock.toolCallId
|
|
2063
2370
|
});
|
|
2064
|
-
|
|
2371
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2372
|
+
controller.enqueue({
|
|
2373
|
+
type: "tool-call",
|
|
2374
|
+
toolCallId: contentBlock.toolCallId,
|
|
2375
|
+
toolName,
|
|
2376
|
+
input: contentBlock.input,
|
|
2377
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2378
|
+
});
|
|
2065
2379
|
}
|
|
2066
2380
|
break;
|
|
2067
2381
|
}
|
|
@@ -2109,7 +2423,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2109
2423
|
}
|
|
2110
2424
|
case "input_json_delta": {
|
|
2111
2425
|
const contentBlock = contentBlocks[value.index];
|
|
2112
|
-
|
|
2426
|
+
let delta = value.delta.partial_json;
|
|
2427
|
+
if (delta.length === 0) {
|
|
2428
|
+
return;
|
|
2429
|
+
}
|
|
2113
2430
|
if (usesJsonResponseTool) {
|
|
2114
2431
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2115
2432
|
return;
|
|
@@ -2123,12 +2440,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2123
2440
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2124
2441
|
return;
|
|
2125
2442
|
}
|
|
2443
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2444
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2445
|
+
}
|
|
2126
2446
|
controller.enqueue({
|
|
2127
2447
|
type: "tool-input-delta",
|
|
2128
2448
|
id: contentBlock.toolCallId,
|
|
2129
2449
|
delta
|
|
2130
2450
|
});
|
|
2131
2451
|
contentBlock.input += delta;
|
|
2452
|
+
contentBlock.firstDelta = false;
|
|
2132
2453
|
}
|
|
2133
2454
|
return;
|
|
2134
2455
|
}
|
|
@@ -2216,15 +2537,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2216
2537
|
// src/tool/bash_20241022.ts
|
|
2217
2538
|
import {
|
|
2218
2539
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2219
|
-
lazySchema as
|
|
2220
|
-
zodSchema as
|
|
2540
|
+
lazySchema as lazySchema8,
|
|
2541
|
+
zodSchema as zodSchema8
|
|
2221
2542
|
} from "@ai-sdk/provider-utils";
|
|
2222
|
-
import { z as
|
|
2223
|
-
var bash_20241022InputSchema =
|
|
2224
|
-
() =>
|
|
2225
|
-
|
|
2226
|
-
command:
|
|
2227
|
-
restart:
|
|
2543
|
+
import { z as z9 } from "zod/v4";
|
|
2544
|
+
var bash_20241022InputSchema = lazySchema8(
|
|
2545
|
+
() => zodSchema8(
|
|
2546
|
+
z9.object({
|
|
2547
|
+
command: z9.string(),
|
|
2548
|
+
restart: z9.boolean().optional()
|
|
2228
2549
|
})
|
|
2229
2550
|
)
|
|
2230
2551
|
);
|
|
@@ -2237,15 +2558,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2237
2558
|
// src/tool/bash_20250124.ts
|
|
2238
2559
|
import {
|
|
2239
2560
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2240
|
-
lazySchema as
|
|
2241
|
-
zodSchema as
|
|
2561
|
+
lazySchema as lazySchema9,
|
|
2562
|
+
zodSchema as zodSchema9
|
|
2242
2563
|
} from "@ai-sdk/provider-utils";
|
|
2243
|
-
import { z as
|
|
2244
|
-
var bash_20250124InputSchema =
|
|
2245
|
-
() =>
|
|
2246
|
-
|
|
2247
|
-
command:
|
|
2248
|
-
restart:
|
|
2564
|
+
import { z as z10 } from "zod/v4";
|
|
2565
|
+
var bash_20250124InputSchema = lazySchema9(
|
|
2566
|
+
() => zodSchema9(
|
|
2567
|
+
z10.object({
|
|
2568
|
+
command: z10.string(),
|
|
2569
|
+
restart: z10.boolean().optional()
|
|
2249
2570
|
})
|
|
2250
2571
|
)
|
|
2251
2572
|
);
|
|
@@ -2258,14 +2579,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2258
2579
|
// src/tool/computer_20241022.ts
|
|
2259
2580
|
import {
|
|
2260
2581
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2261
|
-
lazySchema as
|
|
2262
|
-
zodSchema as
|
|
2582
|
+
lazySchema as lazySchema10,
|
|
2583
|
+
zodSchema as zodSchema10
|
|
2263
2584
|
} from "@ai-sdk/provider-utils";
|
|
2264
|
-
import { z as
|
|
2265
|
-
var computer_20241022InputSchema =
|
|
2266
|
-
() =>
|
|
2267
|
-
|
|
2268
|
-
action:
|
|
2585
|
+
import { z as z11 } from "zod/v4";
|
|
2586
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2587
|
+
() => zodSchema10(
|
|
2588
|
+
z11.object({
|
|
2589
|
+
action: z11.enum([
|
|
2269
2590
|
"key",
|
|
2270
2591
|
"type",
|
|
2271
2592
|
"mouse_move",
|
|
@@ -2277,8 +2598,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2277
2598
|
"screenshot",
|
|
2278
2599
|
"cursor_position"
|
|
2279
2600
|
]),
|
|
2280
|
-
coordinate:
|
|
2281
|
-
text:
|
|
2601
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2602
|
+
text: z11.string().optional()
|
|
2282
2603
|
})
|
|
2283
2604
|
)
|
|
2284
2605
|
);
|
|
@@ -2291,14 +2612,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2291
2612
|
// src/tool/computer_20250124.ts
|
|
2292
2613
|
import {
|
|
2293
2614
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2294
|
-
lazySchema as
|
|
2295
|
-
zodSchema as
|
|
2615
|
+
lazySchema as lazySchema11,
|
|
2616
|
+
zodSchema as zodSchema11
|
|
2296
2617
|
} from "@ai-sdk/provider-utils";
|
|
2297
|
-
import { z as
|
|
2298
|
-
var computer_20250124InputSchema =
|
|
2299
|
-
() =>
|
|
2300
|
-
|
|
2301
|
-
action:
|
|
2618
|
+
import { z as z12 } from "zod/v4";
|
|
2619
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2620
|
+
() => zodSchema11(
|
|
2621
|
+
z12.object({
|
|
2622
|
+
action: z12.enum([
|
|
2302
2623
|
"key",
|
|
2303
2624
|
"hold_key",
|
|
2304
2625
|
"type",
|
|
@@ -2316,12 +2637,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2316
2637
|
"wait",
|
|
2317
2638
|
"screenshot"
|
|
2318
2639
|
]),
|
|
2319
|
-
coordinate:
|
|
2320
|
-
duration:
|
|
2321
|
-
scroll_amount:
|
|
2322
|
-
scroll_direction:
|
|
2323
|
-
start_coordinate:
|
|
2324
|
-
text:
|
|
2640
|
+
coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2641
|
+
duration: z12.number().optional(),
|
|
2642
|
+
scroll_amount: z12.number().optional(),
|
|
2643
|
+
scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
|
|
2644
|
+
start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2645
|
+
text: z12.string().optional()
|
|
2325
2646
|
})
|
|
2326
2647
|
)
|
|
2327
2648
|
);
|
|
@@ -2331,27 +2652,77 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2331
2652
|
inputSchema: computer_20250124InputSchema
|
|
2332
2653
|
});
|
|
2333
2654
|
|
|
2334
|
-
// src/tool/
|
|
2655
|
+
// src/tool/memory_20250818.ts
|
|
2335
2656
|
import {
|
|
2336
2657
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2337
|
-
lazySchema as
|
|
2338
|
-
zodSchema as
|
|
2658
|
+
lazySchema as lazySchema12,
|
|
2659
|
+
zodSchema as zodSchema12
|
|
2339
2660
|
} from "@ai-sdk/provider-utils";
|
|
2340
|
-
import { z as
|
|
2341
|
-
var
|
|
2342
|
-
() =>
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2661
|
+
import { z as z13 } from "zod/v4";
|
|
2662
|
+
var memory_20250818InputSchema = lazySchema12(
|
|
2663
|
+
() => zodSchema12(
|
|
2664
|
+
z13.discriminatedUnion("command", [
|
|
2665
|
+
z13.object({
|
|
2666
|
+
command: z13.literal("view"),
|
|
2667
|
+
path: z13.string(),
|
|
2668
|
+
view_range: z13.tuple([z13.number(), z13.number()]).optional()
|
|
2669
|
+
}),
|
|
2670
|
+
z13.object({
|
|
2671
|
+
command: z13.literal("create"),
|
|
2672
|
+
path: z13.string(),
|
|
2673
|
+
file_text: z13.string()
|
|
2674
|
+
}),
|
|
2675
|
+
z13.object({
|
|
2676
|
+
command: z13.literal("str_replace"),
|
|
2677
|
+
path: z13.string(),
|
|
2678
|
+
old_str: z13.string(),
|
|
2679
|
+
new_str: z13.string()
|
|
2680
|
+
}),
|
|
2681
|
+
z13.object({
|
|
2682
|
+
command: z13.literal("insert"),
|
|
2683
|
+
path: z13.string(),
|
|
2684
|
+
insert_line: z13.number(),
|
|
2685
|
+
insert_text: z13.string()
|
|
2686
|
+
}),
|
|
2687
|
+
z13.object({
|
|
2688
|
+
command: z13.literal("delete"),
|
|
2689
|
+
path: z13.string()
|
|
2690
|
+
}),
|
|
2691
|
+
z13.object({
|
|
2692
|
+
command: z13.literal("rename"),
|
|
2693
|
+
old_path: z13.string(),
|
|
2694
|
+
new_path: z13.string()
|
|
2695
|
+
})
|
|
2696
|
+
])
|
|
2697
|
+
)
|
|
2698
|
+
);
|
|
2699
|
+
var memory_20250818 = createProviderDefinedToolFactory6({
|
|
2700
|
+
id: "anthropic.memory_20250818",
|
|
2701
|
+
name: "memory",
|
|
2702
|
+
inputSchema: memory_20250818InputSchema
|
|
2703
|
+
});
|
|
2704
|
+
|
|
2705
|
+
// src/tool/text-editor_20241022.ts
|
|
2706
|
+
import {
|
|
2707
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2708
|
+
lazySchema as lazySchema13,
|
|
2709
|
+
zodSchema as zodSchema13
|
|
2710
|
+
} from "@ai-sdk/provider-utils";
|
|
2711
|
+
import { z as z14 } from "zod/v4";
|
|
2712
|
+
var textEditor_20241022InputSchema = lazySchema13(
|
|
2713
|
+
() => zodSchema13(
|
|
2714
|
+
z14.object({
|
|
2715
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2716
|
+
path: z14.string(),
|
|
2717
|
+
file_text: z14.string().optional(),
|
|
2718
|
+
insert_line: z14.number().int().optional(),
|
|
2719
|
+
new_str: z14.string().optional(),
|
|
2720
|
+
old_str: z14.string().optional(),
|
|
2721
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
2351
2722
|
})
|
|
2352
2723
|
)
|
|
2353
2724
|
);
|
|
2354
|
-
var textEditor_20241022 =
|
|
2725
|
+
var textEditor_20241022 = createProviderDefinedToolFactory7({
|
|
2355
2726
|
id: "anthropic.text_editor_20241022",
|
|
2356
2727
|
name: "str_replace_editor",
|
|
2357
2728
|
inputSchema: textEditor_20241022InputSchema
|
|
@@ -2359,25 +2730,25 @@ var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
|
2359
2730
|
|
|
2360
2731
|
// src/tool/text-editor_20250124.ts
|
|
2361
2732
|
import {
|
|
2362
|
-
createProviderDefinedToolFactory as
|
|
2363
|
-
lazySchema as
|
|
2364
|
-
zodSchema as
|
|
2733
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
2734
|
+
lazySchema as lazySchema14,
|
|
2735
|
+
zodSchema as zodSchema14
|
|
2365
2736
|
} from "@ai-sdk/provider-utils";
|
|
2366
|
-
import { z as
|
|
2367
|
-
var textEditor_20250124InputSchema =
|
|
2368
|
-
() =>
|
|
2369
|
-
|
|
2370
|
-
command:
|
|
2371
|
-
path:
|
|
2372
|
-
file_text:
|
|
2373
|
-
insert_line:
|
|
2374
|
-
new_str:
|
|
2375
|
-
old_str:
|
|
2376
|
-
view_range:
|
|
2737
|
+
import { z as z15 } from "zod/v4";
|
|
2738
|
+
var textEditor_20250124InputSchema = lazySchema14(
|
|
2739
|
+
() => zodSchema14(
|
|
2740
|
+
z15.object({
|
|
2741
|
+
command: z15.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2742
|
+
path: z15.string(),
|
|
2743
|
+
file_text: z15.string().optional(),
|
|
2744
|
+
insert_line: z15.number().int().optional(),
|
|
2745
|
+
new_str: z15.string().optional(),
|
|
2746
|
+
old_str: z15.string().optional(),
|
|
2747
|
+
view_range: z15.array(z15.number().int()).optional()
|
|
2377
2748
|
})
|
|
2378
2749
|
)
|
|
2379
2750
|
);
|
|
2380
|
-
var textEditor_20250124 =
|
|
2751
|
+
var textEditor_20250124 = createProviderDefinedToolFactory8({
|
|
2381
2752
|
id: "anthropic.text_editor_20250124",
|
|
2382
2753
|
name: "str_replace_editor",
|
|
2383
2754
|
inputSchema: textEditor_20250124InputSchema
|
|
@@ -2385,25 +2756,25 @@ var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
|
2385
2756
|
|
|
2386
2757
|
// src/tool/text-editor_20250429.ts
|
|
2387
2758
|
import {
|
|
2388
|
-
createProviderDefinedToolFactory as
|
|
2389
|
-
lazySchema as
|
|
2390
|
-
zodSchema as
|
|
2759
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
|
|
2760
|
+
lazySchema as lazySchema15,
|
|
2761
|
+
zodSchema as zodSchema15
|
|
2391
2762
|
} from "@ai-sdk/provider-utils";
|
|
2392
|
-
import { z as
|
|
2393
|
-
var textEditor_20250429InputSchema =
|
|
2394
|
-
() =>
|
|
2395
|
-
|
|
2396
|
-
command:
|
|
2397
|
-
path:
|
|
2398
|
-
file_text:
|
|
2399
|
-
insert_line:
|
|
2400
|
-
new_str:
|
|
2401
|
-
old_str:
|
|
2402
|
-
view_range:
|
|
2763
|
+
import { z as z16 } from "zod/v4";
|
|
2764
|
+
var textEditor_20250429InputSchema = lazySchema15(
|
|
2765
|
+
() => zodSchema15(
|
|
2766
|
+
z16.object({
|
|
2767
|
+
command: z16.enum(["view", "create", "str_replace", "insert"]),
|
|
2768
|
+
path: z16.string(),
|
|
2769
|
+
file_text: z16.string().optional(),
|
|
2770
|
+
insert_line: z16.number().int().optional(),
|
|
2771
|
+
new_str: z16.string().optional(),
|
|
2772
|
+
old_str: z16.string().optional(),
|
|
2773
|
+
view_range: z16.array(z16.number().int()).optional()
|
|
2403
2774
|
})
|
|
2404
2775
|
)
|
|
2405
2776
|
);
|
|
2406
|
-
var textEditor_20250429 =
|
|
2777
|
+
var textEditor_20250429 = createProviderDefinedToolFactory9({
|
|
2407
2778
|
id: "anthropic.text_editor_20250429",
|
|
2408
2779
|
name: "str_replace_based_edit_tool",
|
|
2409
2780
|
inputSchema: textEditor_20250429InputSchema
|
|
@@ -2440,6 +2811,19 @@ var anthropicTools = {
|
|
|
2440
2811
|
* Tool name must be `code_execution`.
|
|
2441
2812
|
*/
|
|
2442
2813
|
codeExecution_20250522,
|
|
2814
|
+
/**
|
|
2815
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2816
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2817
|
+
* the API conversation.
|
|
2818
|
+
*
|
|
2819
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2820
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2821
|
+
*
|
|
2822
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2823
|
+
*
|
|
2824
|
+
* Tool name must be `code_execution`.
|
|
2825
|
+
*/
|
|
2826
|
+
codeExecution_20250825,
|
|
2443
2827
|
/**
|
|
2444
2828
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2445
2829
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -2466,6 +2850,17 @@ var anthropicTools = {
|
|
|
2466
2850
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
2467
2851
|
*/
|
|
2468
2852
|
computer_20250124,
|
|
2853
|
+
/**
|
|
2854
|
+
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
2855
|
+
* Claude can create, read, update, and delete files that persist between sessions,
|
|
2856
|
+
* allowing it to build knowledge over time without keeping everything in the context window.
|
|
2857
|
+
* The memory tool operates client-side—you control where and how the data is stored through your own infrastructure.
|
|
2858
|
+
*
|
|
2859
|
+
* Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
|
|
2860
|
+
*
|
|
2861
|
+
* Tool name must be `memory`.
|
|
2862
|
+
*/
|
|
2863
|
+
memory_20250818,
|
|
2469
2864
|
/**
|
|
2470
2865
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2471
2866
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|