@ai-sdk/anthropic 3.0.0-beta.22 → 3.0.0-beta.24
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") {
|
|
@@ -1127,7 +1350,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1127
1350
|
}
|
|
1128
1351
|
case "tool-call": {
|
|
1129
1352
|
if (part.providerExecuted) {
|
|
1130
|
-
if (part.toolName === "code_execution"
|
|
1353
|
+
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")) {
|
|
1354
|
+
anthropicContent.push({
|
|
1355
|
+
type: "server_tool_use",
|
|
1356
|
+
id: part.toolCallId,
|
|
1357
|
+
name: part.input.type,
|
|
1358
|
+
// map back to subtool name
|
|
1359
|
+
input: part.input,
|
|
1360
|
+
cache_control: cacheControl
|
|
1361
|
+
});
|
|
1362
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1363
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1131
1364
|
anthropicContent.push({
|
|
1132
1365
|
type: "server_tool_use",
|
|
1133
1366
|
id: part.toolCallId,
|
|
@@ -1162,21 +1395,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1162
1395
|
});
|
|
1163
1396
|
break;
|
|
1164
1397
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1398
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1399
|
+
warnings.push({
|
|
1400
|
+
type: "other",
|
|
1401
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1402
|
+
});
|
|
1403
|
+
break;
|
|
1404
|
+
}
|
|
1405
|
+
if (output.value.type === "code_execution_result") {
|
|
1406
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1407
|
+
value: output.value,
|
|
1408
|
+
schema: codeExecution_20250522OutputSchema
|
|
1409
|
+
});
|
|
1410
|
+
anthropicContent.push({
|
|
1411
|
+
type: "code_execution_tool_result",
|
|
1412
|
+
tool_use_id: part.toolCallId,
|
|
1413
|
+
content: {
|
|
1414
|
+
type: codeExecutionOutput.type,
|
|
1415
|
+
stdout: codeExecutionOutput.stdout,
|
|
1416
|
+
stderr: codeExecutionOutput.stderr,
|
|
1417
|
+
return_code: codeExecutionOutput.return_code
|
|
1418
|
+
},
|
|
1419
|
+
cache_control: cacheControl
|
|
1420
|
+
});
|
|
1421
|
+
} else {
|
|
1422
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1423
|
+
value: output.value,
|
|
1424
|
+
schema: codeExecution_20250825OutputSchema
|
|
1425
|
+
});
|
|
1426
|
+
anthropicContent.push(
|
|
1427
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1428
|
+
type: "bash_code_execution_tool_result",
|
|
1429
|
+
tool_use_id: part.toolCallId,
|
|
1430
|
+
cache_control: cacheControl,
|
|
1431
|
+
content: codeExecutionOutput
|
|
1432
|
+
} : {
|
|
1433
|
+
type: "text_editor_code_execution_tool_result",
|
|
1434
|
+
tool_use_id: part.toolCallId,
|
|
1435
|
+
cache_control: cacheControl,
|
|
1436
|
+
content: codeExecutionOutput
|
|
1437
|
+
}
|
|
1438
|
+
);
|
|
1439
|
+
}
|
|
1180
1440
|
break;
|
|
1181
1441
|
}
|
|
1182
1442
|
if (part.toolName === "web_fetch") {
|
|
@@ -1646,7 +1906,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1646
1906
|
break;
|
|
1647
1907
|
}
|
|
1648
1908
|
case "server_tool_use": {
|
|
1649
|
-
if (part.name === "
|
|
1909
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1910
|
+
content.push({
|
|
1911
|
+
type: "tool-call",
|
|
1912
|
+
toolCallId: part.id,
|
|
1913
|
+
toolName: "code_execution",
|
|
1914
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1915
|
+
providerExecuted: true
|
|
1916
|
+
});
|
|
1917
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1650
1918
|
content.push({
|
|
1651
1919
|
type: "tool-call",
|
|
1652
1920
|
toolCallId: part.id,
|
|
@@ -1742,6 +2010,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1742
2010
|
}
|
|
1743
2011
|
break;
|
|
1744
2012
|
}
|
|
2013
|
+
// code execution 20250522:
|
|
1745
2014
|
case "code_execution_tool_result": {
|
|
1746
2015
|
if (part.content.type === "code_execution_result") {
|
|
1747
2016
|
content.push({
|
|
@@ -1771,6 +2040,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1771
2040
|
}
|
|
1772
2041
|
break;
|
|
1773
2042
|
}
|
|
2043
|
+
// code execution 20250825:
|
|
2044
|
+
case "bash_code_execution_tool_result":
|
|
2045
|
+
case "text_editor_code_execution_tool_result": {
|
|
2046
|
+
content.push({
|
|
2047
|
+
type: "tool-result",
|
|
2048
|
+
toolCallId: part.tool_use_id,
|
|
2049
|
+
toolName: "code_execution",
|
|
2050
|
+
result: part.content,
|
|
2051
|
+
providerExecuted: true
|
|
2052
|
+
});
|
|
2053
|
+
break;
|
|
2054
|
+
}
|
|
1774
2055
|
}
|
|
1775
2056
|
}
|
|
1776
2057
|
return {
|
|
@@ -1887,7 +2168,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1887
2168
|
type: "tool-call",
|
|
1888
2169
|
toolCallId: value.content_block.id,
|
|
1889
2170
|
toolName: value.content_block.name,
|
|
1890
|
-
input: ""
|
|
2171
|
+
input: "",
|
|
2172
|
+
firstDelta: true
|
|
1891
2173
|
};
|
|
1892
2174
|
controller.enqueue(
|
|
1893
2175
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1899,18 +2181,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1899
2181
|
return;
|
|
1900
2182
|
}
|
|
1901
2183
|
case "server_tool_use": {
|
|
1902
|
-
if (
|
|
2184
|
+
if ([
|
|
2185
|
+
"web_fetch",
|
|
2186
|
+
"web_search",
|
|
2187
|
+
// code execution 20250825:
|
|
2188
|
+
"code_execution",
|
|
2189
|
+
// code execution 20250825 text editor:
|
|
2190
|
+
"text_editor_code_execution",
|
|
2191
|
+
// code execution 20250825 bash:
|
|
2192
|
+
"bash_code_execution"
|
|
2193
|
+
].includes(value.content_block.name)) {
|
|
1903
2194
|
contentBlocks[value.index] = {
|
|
1904
2195
|
type: "tool-call",
|
|
1905
2196
|
toolCallId: value.content_block.id,
|
|
1906
2197
|
toolName: value.content_block.name,
|
|
1907
2198
|
input: "",
|
|
1908
|
-
providerExecuted: true
|
|
2199
|
+
providerExecuted: true,
|
|
2200
|
+
firstDelta: true
|
|
1909
2201
|
};
|
|
2202
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1910
2203
|
controller.enqueue({
|
|
1911
2204
|
type: "tool-input-start",
|
|
1912
2205
|
id: value.content_block.id,
|
|
1913
|
-
toolName:
|
|
2206
|
+
toolName: mappedToolName,
|
|
1914
2207
|
providerExecuted: true
|
|
1915
2208
|
});
|
|
1916
2209
|
}
|
|
@@ -2002,6 +2295,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2002
2295
|
}
|
|
2003
2296
|
return;
|
|
2004
2297
|
}
|
|
2298
|
+
// code execution 20250522:
|
|
2005
2299
|
case "code_execution_tool_result": {
|
|
2006
2300
|
const part = value.content_block;
|
|
2007
2301
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2032,6 +2326,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2032
2326
|
}
|
|
2033
2327
|
return;
|
|
2034
2328
|
}
|
|
2329
|
+
// code execution 20250825:
|
|
2330
|
+
case "bash_code_execution_tool_result":
|
|
2331
|
+
case "text_editor_code_execution_tool_result": {
|
|
2332
|
+
const part = value.content_block;
|
|
2333
|
+
controller.enqueue({
|
|
2334
|
+
type: "tool-result",
|
|
2335
|
+
toolCallId: part.tool_use_id,
|
|
2336
|
+
toolName: "code_execution",
|
|
2337
|
+
result: part.content,
|
|
2338
|
+
providerExecuted: true
|
|
2339
|
+
});
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2035
2342
|
default: {
|
|
2036
2343
|
const _exhaustiveCheck = contentBlockType;
|
|
2037
2344
|
throw new Error(
|
|
@@ -2064,7 +2371,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2064
2371
|
type: "tool-input-end",
|
|
2065
2372
|
id: contentBlock.toolCallId
|
|
2066
2373
|
});
|
|
2067
|
-
|
|
2374
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2375
|
+
controller.enqueue({
|
|
2376
|
+
type: "tool-call",
|
|
2377
|
+
toolCallId: contentBlock.toolCallId,
|
|
2378
|
+
toolName,
|
|
2379
|
+
input: contentBlock.input,
|
|
2380
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2381
|
+
});
|
|
2068
2382
|
}
|
|
2069
2383
|
break;
|
|
2070
2384
|
}
|
|
@@ -2112,7 +2426,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2112
2426
|
}
|
|
2113
2427
|
case "input_json_delta": {
|
|
2114
2428
|
const contentBlock = contentBlocks[value.index];
|
|
2115
|
-
|
|
2429
|
+
let delta = value.delta.partial_json;
|
|
2430
|
+
if (delta.length === 0) {
|
|
2431
|
+
return;
|
|
2432
|
+
}
|
|
2116
2433
|
if (usesJsonResponseTool) {
|
|
2117
2434
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2118
2435
|
return;
|
|
@@ -2126,12 +2443,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2126
2443
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2127
2444
|
return;
|
|
2128
2445
|
}
|
|
2446
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2447
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2448
|
+
}
|
|
2129
2449
|
controller.enqueue({
|
|
2130
2450
|
type: "tool-input-delta",
|
|
2131
2451
|
id: contentBlock.toolCallId,
|
|
2132
2452
|
delta
|
|
2133
2453
|
});
|
|
2134
2454
|
contentBlock.input += delta;
|
|
2455
|
+
contentBlock.firstDelta = false;
|
|
2135
2456
|
}
|
|
2136
2457
|
return;
|
|
2137
2458
|
}
|
|
@@ -2219,15 +2540,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2219
2540
|
// src/tool/bash_20241022.ts
|
|
2220
2541
|
import {
|
|
2221
2542
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2222
|
-
lazySchema as
|
|
2223
|
-
zodSchema as
|
|
2543
|
+
lazySchema as lazySchema8,
|
|
2544
|
+
zodSchema as zodSchema8
|
|
2224
2545
|
} from "@ai-sdk/provider-utils";
|
|
2225
|
-
import { z as
|
|
2226
|
-
var bash_20241022InputSchema =
|
|
2227
|
-
() =>
|
|
2228
|
-
|
|
2229
|
-
command:
|
|
2230
|
-
restart:
|
|
2546
|
+
import { z as z9 } from "zod/v4";
|
|
2547
|
+
var bash_20241022InputSchema = lazySchema8(
|
|
2548
|
+
() => zodSchema8(
|
|
2549
|
+
z9.object({
|
|
2550
|
+
command: z9.string(),
|
|
2551
|
+
restart: z9.boolean().optional()
|
|
2231
2552
|
})
|
|
2232
2553
|
)
|
|
2233
2554
|
);
|
|
@@ -2240,15 +2561,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2240
2561
|
// src/tool/bash_20250124.ts
|
|
2241
2562
|
import {
|
|
2242
2563
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2243
|
-
lazySchema as
|
|
2244
|
-
zodSchema as
|
|
2564
|
+
lazySchema as lazySchema9,
|
|
2565
|
+
zodSchema as zodSchema9
|
|
2245
2566
|
} from "@ai-sdk/provider-utils";
|
|
2246
|
-
import { z as
|
|
2247
|
-
var bash_20250124InputSchema =
|
|
2248
|
-
() =>
|
|
2249
|
-
|
|
2250
|
-
command:
|
|
2251
|
-
restart:
|
|
2567
|
+
import { z as z10 } from "zod/v4";
|
|
2568
|
+
var bash_20250124InputSchema = lazySchema9(
|
|
2569
|
+
() => zodSchema9(
|
|
2570
|
+
z10.object({
|
|
2571
|
+
command: z10.string(),
|
|
2572
|
+
restart: z10.boolean().optional()
|
|
2252
2573
|
})
|
|
2253
2574
|
)
|
|
2254
2575
|
);
|
|
@@ -2261,14 +2582,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2261
2582
|
// src/tool/computer_20241022.ts
|
|
2262
2583
|
import {
|
|
2263
2584
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2264
|
-
lazySchema as
|
|
2265
|
-
zodSchema as
|
|
2585
|
+
lazySchema as lazySchema10,
|
|
2586
|
+
zodSchema as zodSchema10
|
|
2266
2587
|
} from "@ai-sdk/provider-utils";
|
|
2267
|
-
import { z as
|
|
2268
|
-
var computer_20241022InputSchema =
|
|
2269
|
-
() =>
|
|
2270
|
-
|
|
2271
|
-
action:
|
|
2588
|
+
import { z as z11 } from "zod/v4";
|
|
2589
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2590
|
+
() => zodSchema10(
|
|
2591
|
+
z11.object({
|
|
2592
|
+
action: z11.enum([
|
|
2272
2593
|
"key",
|
|
2273
2594
|
"type",
|
|
2274
2595
|
"mouse_move",
|
|
@@ -2280,8 +2601,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2280
2601
|
"screenshot",
|
|
2281
2602
|
"cursor_position"
|
|
2282
2603
|
]),
|
|
2283
|
-
coordinate:
|
|
2284
|
-
text:
|
|
2604
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2605
|
+
text: z11.string().optional()
|
|
2285
2606
|
})
|
|
2286
2607
|
)
|
|
2287
2608
|
);
|
|
@@ -2294,14 +2615,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2294
2615
|
// src/tool/computer_20250124.ts
|
|
2295
2616
|
import {
|
|
2296
2617
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2297
|
-
lazySchema as
|
|
2298
|
-
zodSchema as
|
|
2618
|
+
lazySchema as lazySchema11,
|
|
2619
|
+
zodSchema as zodSchema11
|
|
2299
2620
|
} from "@ai-sdk/provider-utils";
|
|
2300
|
-
import { z as
|
|
2301
|
-
var computer_20250124InputSchema =
|
|
2302
|
-
() =>
|
|
2303
|
-
|
|
2304
|
-
action:
|
|
2621
|
+
import { z as z12 } from "zod/v4";
|
|
2622
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2623
|
+
() => zodSchema11(
|
|
2624
|
+
z12.object({
|
|
2625
|
+
action: z12.enum([
|
|
2305
2626
|
"key",
|
|
2306
2627
|
"hold_key",
|
|
2307
2628
|
"type",
|
|
@@ -2319,12 +2640,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2319
2640
|
"wait",
|
|
2320
2641
|
"screenshot"
|
|
2321
2642
|
]),
|
|
2322
|
-
coordinate:
|
|
2323
|
-
duration:
|
|
2324
|
-
scroll_amount:
|
|
2325
|
-
scroll_direction:
|
|
2326
|
-
start_coordinate:
|
|
2327
|
-
text:
|
|
2643
|
+
coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2644
|
+
duration: z12.number().optional(),
|
|
2645
|
+
scroll_amount: z12.number().optional(),
|
|
2646
|
+
scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
|
|
2647
|
+
start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2648
|
+
text: z12.string().optional()
|
|
2328
2649
|
})
|
|
2329
2650
|
)
|
|
2330
2651
|
);
|
|
@@ -2334,27 +2655,77 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2334
2655
|
inputSchema: computer_20250124InputSchema
|
|
2335
2656
|
});
|
|
2336
2657
|
|
|
2337
|
-
// src/tool/
|
|
2658
|
+
// src/tool/memory_20250818.ts
|
|
2338
2659
|
import {
|
|
2339
2660
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2340
|
-
lazySchema as
|
|
2341
|
-
zodSchema as
|
|
2661
|
+
lazySchema as lazySchema12,
|
|
2662
|
+
zodSchema as zodSchema12
|
|
2342
2663
|
} from "@ai-sdk/provider-utils";
|
|
2343
|
-
import { z as
|
|
2344
|
-
var
|
|
2345
|
-
() =>
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2664
|
+
import { z as z13 } from "zod/v4";
|
|
2665
|
+
var memory_20250818InputSchema = lazySchema12(
|
|
2666
|
+
() => zodSchema12(
|
|
2667
|
+
z13.discriminatedUnion("command", [
|
|
2668
|
+
z13.object({
|
|
2669
|
+
command: z13.literal("view"),
|
|
2670
|
+
path: z13.string(),
|
|
2671
|
+
view_range: z13.tuple([z13.number(), z13.number()]).optional()
|
|
2672
|
+
}),
|
|
2673
|
+
z13.object({
|
|
2674
|
+
command: z13.literal("create"),
|
|
2675
|
+
path: z13.string(),
|
|
2676
|
+
file_text: z13.string()
|
|
2677
|
+
}),
|
|
2678
|
+
z13.object({
|
|
2679
|
+
command: z13.literal("str_replace"),
|
|
2680
|
+
path: z13.string(),
|
|
2681
|
+
old_str: z13.string(),
|
|
2682
|
+
new_str: z13.string()
|
|
2683
|
+
}),
|
|
2684
|
+
z13.object({
|
|
2685
|
+
command: z13.literal("insert"),
|
|
2686
|
+
path: z13.string(),
|
|
2687
|
+
insert_line: z13.number(),
|
|
2688
|
+
insert_text: z13.string()
|
|
2689
|
+
}),
|
|
2690
|
+
z13.object({
|
|
2691
|
+
command: z13.literal("delete"),
|
|
2692
|
+
path: z13.string()
|
|
2693
|
+
}),
|
|
2694
|
+
z13.object({
|
|
2695
|
+
command: z13.literal("rename"),
|
|
2696
|
+
old_path: z13.string(),
|
|
2697
|
+
new_path: z13.string()
|
|
2698
|
+
})
|
|
2699
|
+
])
|
|
2700
|
+
)
|
|
2701
|
+
);
|
|
2702
|
+
var memory_20250818 = createProviderDefinedToolFactory6({
|
|
2703
|
+
id: "anthropic.memory_20250818",
|
|
2704
|
+
name: "memory",
|
|
2705
|
+
inputSchema: memory_20250818InputSchema
|
|
2706
|
+
});
|
|
2707
|
+
|
|
2708
|
+
// src/tool/text-editor_20241022.ts
|
|
2709
|
+
import {
|
|
2710
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2711
|
+
lazySchema as lazySchema13,
|
|
2712
|
+
zodSchema as zodSchema13
|
|
2713
|
+
} from "@ai-sdk/provider-utils";
|
|
2714
|
+
import { z as z14 } from "zod/v4";
|
|
2715
|
+
var textEditor_20241022InputSchema = lazySchema13(
|
|
2716
|
+
() => zodSchema13(
|
|
2717
|
+
z14.object({
|
|
2718
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2719
|
+
path: z14.string(),
|
|
2720
|
+
file_text: z14.string().optional(),
|
|
2721
|
+
insert_line: z14.number().int().optional(),
|
|
2722
|
+
new_str: z14.string().optional(),
|
|
2723
|
+
old_str: z14.string().optional(),
|
|
2724
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
2354
2725
|
})
|
|
2355
2726
|
)
|
|
2356
2727
|
);
|
|
2357
|
-
var textEditor_20241022 =
|
|
2728
|
+
var textEditor_20241022 = createProviderDefinedToolFactory7({
|
|
2358
2729
|
id: "anthropic.text_editor_20241022",
|
|
2359
2730
|
name: "str_replace_editor",
|
|
2360
2731
|
inputSchema: textEditor_20241022InputSchema
|
|
@@ -2362,25 +2733,25 @@ var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
|
2362
2733
|
|
|
2363
2734
|
// src/tool/text-editor_20250124.ts
|
|
2364
2735
|
import {
|
|
2365
|
-
createProviderDefinedToolFactory as
|
|
2366
|
-
lazySchema as
|
|
2367
|
-
zodSchema as
|
|
2736
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
2737
|
+
lazySchema as lazySchema14,
|
|
2738
|
+
zodSchema as zodSchema14
|
|
2368
2739
|
} from "@ai-sdk/provider-utils";
|
|
2369
|
-
import { z as
|
|
2370
|
-
var textEditor_20250124InputSchema =
|
|
2371
|
-
() =>
|
|
2372
|
-
|
|
2373
|
-
command:
|
|
2374
|
-
path:
|
|
2375
|
-
file_text:
|
|
2376
|
-
insert_line:
|
|
2377
|
-
new_str:
|
|
2378
|
-
old_str:
|
|
2379
|
-
view_range:
|
|
2740
|
+
import { z as z15 } from "zod/v4";
|
|
2741
|
+
var textEditor_20250124InputSchema = lazySchema14(
|
|
2742
|
+
() => zodSchema14(
|
|
2743
|
+
z15.object({
|
|
2744
|
+
command: z15.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2745
|
+
path: z15.string(),
|
|
2746
|
+
file_text: z15.string().optional(),
|
|
2747
|
+
insert_line: z15.number().int().optional(),
|
|
2748
|
+
new_str: z15.string().optional(),
|
|
2749
|
+
old_str: z15.string().optional(),
|
|
2750
|
+
view_range: z15.array(z15.number().int()).optional()
|
|
2380
2751
|
})
|
|
2381
2752
|
)
|
|
2382
2753
|
);
|
|
2383
|
-
var textEditor_20250124 =
|
|
2754
|
+
var textEditor_20250124 = createProviderDefinedToolFactory8({
|
|
2384
2755
|
id: "anthropic.text_editor_20250124",
|
|
2385
2756
|
name: "str_replace_editor",
|
|
2386
2757
|
inputSchema: textEditor_20250124InputSchema
|
|
@@ -2388,25 +2759,25 @@ var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
|
2388
2759
|
|
|
2389
2760
|
// src/tool/text-editor_20250429.ts
|
|
2390
2761
|
import {
|
|
2391
|
-
createProviderDefinedToolFactory as
|
|
2392
|
-
lazySchema as
|
|
2393
|
-
zodSchema as
|
|
2762
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
|
|
2763
|
+
lazySchema as lazySchema15,
|
|
2764
|
+
zodSchema as zodSchema15
|
|
2394
2765
|
} from "@ai-sdk/provider-utils";
|
|
2395
|
-
import { z as
|
|
2396
|
-
var textEditor_20250429InputSchema =
|
|
2397
|
-
() =>
|
|
2398
|
-
|
|
2399
|
-
command:
|
|
2400
|
-
path:
|
|
2401
|
-
file_text:
|
|
2402
|
-
insert_line:
|
|
2403
|
-
new_str:
|
|
2404
|
-
old_str:
|
|
2405
|
-
view_range:
|
|
2766
|
+
import { z as z16 } from "zod/v4";
|
|
2767
|
+
var textEditor_20250429InputSchema = lazySchema15(
|
|
2768
|
+
() => zodSchema15(
|
|
2769
|
+
z16.object({
|
|
2770
|
+
command: z16.enum(["view", "create", "str_replace", "insert"]),
|
|
2771
|
+
path: z16.string(),
|
|
2772
|
+
file_text: z16.string().optional(),
|
|
2773
|
+
insert_line: z16.number().int().optional(),
|
|
2774
|
+
new_str: z16.string().optional(),
|
|
2775
|
+
old_str: z16.string().optional(),
|
|
2776
|
+
view_range: z16.array(z16.number().int()).optional()
|
|
2406
2777
|
})
|
|
2407
2778
|
)
|
|
2408
2779
|
);
|
|
2409
|
-
var textEditor_20250429 =
|
|
2780
|
+
var textEditor_20250429 = createProviderDefinedToolFactory9({
|
|
2410
2781
|
id: "anthropic.text_editor_20250429",
|
|
2411
2782
|
name: "str_replace_based_edit_tool",
|
|
2412
2783
|
inputSchema: textEditor_20250429InputSchema
|
|
@@ -2443,6 +2814,19 @@ var anthropicTools = {
|
|
|
2443
2814
|
* Tool name must be `code_execution`.
|
|
2444
2815
|
*/
|
|
2445
2816
|
codeExecution_20250522,
|
|
2817
|
+
/**
|
|
2818
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2819
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2820
|
+
* the API conversation.
|
|
2821
|
+
*
|
|
2822
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2823
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2824
|
+
*
|
|
2825
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2826
|
+
*
|
|
2827
|
+
* Tool name must be `code_execution`.
|
|
2828
|
+
*/
|
|
2829
|
+
codeExecution_20250825,
|
|
2446
2830
|
/**
|
|
2447
2831
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2448
2832
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -2469,6 +2853,17 @@ var anthropicTools = {
|
|
|
2469
2853
|
* @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.
|
|
2470
2854
|
*/
|
|
2471
2855
|
computer_20250124,
|
|
2856
|
+
/**
|
|
2857
|
+
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
2858
|
+
* Claude can create, read, update, and delete files that persist between sessions,
|
|
2859
|
+
* allowing it to build knowledge over time without keeping everything in the context window.
|
|
2860
|
+
* The memory tool operates client-side—you control where and how the data is stored through your own infrastructure.
|
|
2861
|
+
*
|
|
2862
|
+
* Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
|
|
2863
|
+
*
|
|
2864
|
+
* Tool name must be `memory`.
|
|
2865
|
+
*/
|
|
2866
|
+
memory_20250818,
|
|
2472
2867
|
/**
|
|
2473
2868
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2474
2869
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|