@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/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@ai-sdk/provider-utils";
|
|
11
11
|
|
|
12
12
|
// src/version.ts
|
|
13
|
-
var VERSION = true ? "3.0.0-beta.
|
|
13
|
+
var VERSION = true ? "3.0.0-beta.24" : "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({
|
|
@@ -695,6 +817,14 @@ async function prepareTools({
|
|
|
695
817
|
});
|
|
696
818
|
break;
|
|
697
819
|
}
|
|
820
|
+
case "anthropic.memory_20250818": {
|
|
821
|
+
betas.add("context-management-2025-06-27");
|
|
822
|
+
anthropicTools2.push({
|
|
823
|
+
name: "memory",
|
|
824
|
+
type: "memory_20250818"
|
|
825
|
+
});
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
698
828
|
case "anthropic.web_fetch_20250910": {
|
|
699
829
|
betas.add("web-fetch-2025-09-10");
|
|
700
830
|
const args = await validateTypes({
|
|
@@ -836,6 +966,99 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
836
966
|
return factory4(args);
|
|
837
967
|
};
|
|
838
968
|
|
|
969
|
+
// src/tool/code-execution_20250825.ts
|
|
970
|
+
import {
|
|
971
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
972
|
+
lazySchema as lazySchema7,
|
|
973
|
+
zodSchema as zodSchema7
|
|
974
|
+
} from "@ai-sdk/provider-utils";
|
|
975
|
+
import { z as z8 } from "zod/v4";
|
|
976
|
+
var codeExecution_20250825OutputSchema = lazySchema7(
|
|
977
|
+
() => zodSchema7(
|
|
978
|
+
z8.discriminatedUnion("type", [
|
|
979
|
+
z8.object({
|
|
980
|
+
type: z8.literal("bash_code_execution_result"),
|
|
981
|
+
content: z8.array(
|
|
982
|
+
z8.object({
|
|
983
|
+
type: z8.literal("bash_code_execution_output"),
|
|
984
|
+
file_id: z8.string()
|
|
985
|
+
})
|
|
986
|
+
),
|
|
987
|
+
stdout: z8.string(),
|
|
988
|
+
stderr: z8.string(),
|
|
989
|
+
return_code: z8.number()
|
|
990
|
+
}),
|
|
991
|
+
z8.object({
|
|
992
|
+
type: z8.literal("bash_code_execution_tool_result_error"),
|
|
993
|
+
error_code: z8.string()
|
|
994
|
+
}),
|
|
995
|
+
z8.object({
|
|
996
|
+
type: z8.literal("text_editor_code_execution_tool_result_error"),
|
|
997
|
+
error_code: z8.string()
|
|
998
|
+
}),
|
|
999
|
+
z8.object({
|
|
1000
|
+
type: z8.literal("text_editor_code_execution_view_result"),
|
|
1001
|
+
content: z8.string(),
|
|
1002
|
+
file_type: z8.string(),
|
|
1003
|
+
num_lines: z8.number().nullable(),
|
|
1004
|
+
start_line: z8.number().nullable(),
|
|
1005
|
+
total_lines: z8.number().nullable()
|
|
1006
|
+
}),
|
|
1007
|
+
z8.object({
|
|
1008
|
+
type: z8.literal("text_editor_code_execution_create_result"),
|
|
1009
|
+
is_file_update: z8.boolean()
|
|
1010
|
+
}),
|
|
1011
|
+
z8.object({
|
|
1012
|
+
type: z8.literal("text_editor_code_execution_str_replace_result"),
|
|
1013
|
+
lines: z8.array(z8.string()).nullable(),
|
|
1014
|
+
new_lines: z8.number().nullable(),
|
|
1015
|
+
new_start: z8.number().nullable(),
|
|
1016
|
+
old_lines: z8.number().nullable(),
|
|
1017
|
+
old_start: z8.number().nullable()
|
|
1018
|
+
})
|
|
1019
|
+
])
|
|
1020
|
+
)
|
|
1021
|
+
);
|
|
1022
|
+
var codeExecution_20250825InputSchema = lazySchema7(
|
|
1023
|
+
() => zodSchema7(
|
|
1024
|
+
z8.discriminatedUnion("type", [
|
|
1025
|
+
z8.object({
|
|
1026
|
+
type: z8.literal("bash_code_execution"),
|
|
1027
|
+
command: z8.string()
|
|
1028
|
+
}),
|
|
1029
|
+
z8.discriminatedUnion("command", [
|
|
1030
|
+
z8.object({
|
|
1031
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1032
|
+
command: z8.literal("view"),
|
|
1033
|
+
path: z8.string()
|
|
1034
|
+
}),
|
|
1035
|
+
z8.object({
|
|
1036
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1037
|
+
command: z8.literal("create"),
|
|
1038
|
+
path: z8.string(),
|
|
1039
|
+
file_text: z8.string().nullish()
|
|
1040
|
+
}),
|
|
1041
|
+
z8.object({
|
|
1042
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1043
|
+
command: z8.literal("str_replace"),
|
|
1044
|
+
path: z8.string(),
|
|
1045
|
+
old_str: z8.string(),
|
|
1046
|
+
new_str: z8.string()
|
|
1047
|
+
})
|
|
1048
|
+
])
|
|
1049
|
+
])
|
|
1050
|
+
)
|
|
1051
|
+
);
|
|
1052
|
+
var factory5 = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
1053
|
+
id: "anthropic.code_execution_20250825",
|
|
1054
|
+
name: "code_execution",
|
|
1055
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
1056
|
+
outputSchema: codeExecution_20250825OutputSchema
|
|
1057
|
+
});
|
|
1058
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
1059
|
+
return factory5(args);
|
|
1060
|
+
};
|
|
1061
|
+
|
|
839
1062
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
840
1063
|
function convertToString(data) {
|
|
841
1064
|
if (typeof data === "string") {
|
|
@@ -1141,7 +1364,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1141
1364
|
}
|
|
1142
1365
|
case "tool-call": {
|
|
1143
1366
|
if (part.providerExecuted) {
|
|
1144
|
-
if (part.toolName === "code_execution"
|
|
1367
|
+
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")) {
|
|
1368
|
+
anthropicContent.push({
|
|
1369
|
+
type: "server_tool_use",
|
|
1370
|
+
id: part.toolCallId,
|
|
1371
|
+
name: part.input.type,
|
|
1372
|
+
// map back to subtool name
|
|
1373
|
+
input: part.input,
|
|
1374
|
+
cache_control: cacheControl
|
|
1375
|
+
});
|
|
1376
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1377
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1145
1378
|
anthropicContent.push({
|
|
1146
1379
|
type: "server_tool_use",
|
|
1147
1380
|
id: part.toolCallId,
|
|
@@ -1176,21 +1409,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1176
1409
|
});
|
|
1177
1410
|
break;
|
|
1178
1411
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1412
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1413
|
+
warnings.push({
|
|
1414
|
+
type: "other",
|
|
1415
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1416
|
+
});
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
if (output.value.type === "code_execution_result") {
|
|
1420
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1421
|
+
value: output.value,
|
|
1422
|
+
schema: codeExecution_20250522OutputSchema
|
|
1423
|
+
});
|
|
1424
|
+
anthropicContent.push({
|
|
1425
|
+
type: "code_execution_tool_result",
|
|
1426
|
+
tool_use_id: part.toolCallId,
|
|
1427
|
+
content: {
|
|
1428
|
+
type: codeExecutionOutput.type,
|
|
1429
|
+
stdout: codeExecutionOutput.stdout,
|
|
1430
|
+
stderr: codeExecutionOutput.stderr,
|
|
1431
|
+
return_code: codeExecutionOutput.return_code
|
|
1432
|
+
},
|
|
1433
|
+
cache_control: cacheControl
|
|
1434
|
+
});
|
|
1435
|
+
} else {
|
|
1436
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1437
|
+
value: output.value,
|
|
1438
|
+
schema: codeExecution_20250825OutputSchema
|
|
1439
|
+
});
|
|
1440
|
+
anthropicContent.push(
|
|
1441
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1442
|
+
type: "bash_code_execution_tool_result",
|
|
1443
|
+
tool_use_id: part.toolCallId,
|
|
1444
|
+
cache_control: cacheControl,
|
|
1445
|
+
content: codeExecutionOutput
|
|
1446
|
+
} : {
|
|
1447
|
+
type: "text_editor_code_execution_tool_result",
|
|
1448
|
+
tool_use_id: part.toolCallId,
|
|
1449
|
+
cache_control: cacheControl,
|
|
1450
|
+
content: codeExecutionOutput
|
|
1451
|
+
}
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1194
1454
|
break;
|
|
1195
1455
|
}
|
|
1196
1456
|
if (part.toolName === "web_fetch") {
|
|
@@ -1660,7 +1920,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1660
1920
|
break;
|
|
1661
1921
|
}
|
|
1662
1922
|
case "server_tool_use": {
|
|
1663
|
-
if (part.name === "
|
|
1923
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1924
|
+
content.push({
|
|
1925
|
+
type: "tool-call",
|
|
1926
|
+
toolCallId: part.id,
|
|
1927
|
+
toolName: "code_execution",
|
|
1928
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1929
|
+
providerExecuted: true
|
|
1930
|
+
});
|
|
1931
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1664
1932
|
content.push({
|
|
1665
1933
|
type: "tool-call",
|
|
1666
1934
|
toolCallId: part.id,
|
|
@@ -1756,6 +2024,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1756
2024
|
}
|
|
1757
2025
|
break;
|
|
1758
2026
|
}
|
|
2027
|
+
// code execution 20250522:
|
|
1759
2028
|
case "code_execution_tool_result": {
|
|
1760
2029
|
if (part.content.type === "code_execution_result") {
|
|
1761
2030
|
content.push({
|
|
@@ -1785,6 +2054,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1785
2054
|
}
|
|
1786
2055
|
break;
|
|
1787
2056
|
}
|
|
2057
|
+
// code execution 20250825:
|
|
2058
|
+
case "bash_code_execution_tool_result":
|
|
2059
|
+
case "text_editor_code_execution_tool_result": {
|
|
2060
|
+
content.push({
|
|
2061
|
+
type: "tool-result",
|
|
2062
|
+
toolCallId: part.tool_use_id,
|
|
2063
|
+
toolName: "code_execution",
|
|
2064
|
+
result: part.content,
|
|
2065
|
+
providerExecuted: true
|
|
2066
|
+
});
|
|
2067
|
+
break;
|
|
2068
|
+
}
|
|
1788
2069
|
}
|
|
1789
2070
|
}
|
|
1790
2071
|
return {
|
|
@@ -1901,7 +2182,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1901
2182
|
type: "tool-call",
|
|
1902
2183
|
toolCallId: value.content_block.id,
|
|
1903
2184
|
toolName: value.content_block.name,
|
|
1904
|
-
input: ""
|
|
2185
|
+
input: "",
|
|
2186
|
+
firstDelta: true
|
|
1905
2187
|
};
|
|
1906
2188
|
controller.enqueue(
|
|
1907
2189
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1913,18 +2195,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1913
2195
|
return;
|
|
1914
2196
|
}
|
|
1915
2197
|
case "server_tool_use": {
|
|
1916
|
-
if (
|
|
2198
|
+
if ([
|
|
2199
|
+
"web_fetch",
|
|
2200
|
+
"web_search",
|
|
2201
|
+
// code execution 20250825:
|
|
2202
|
+
"code_execution",
|
|
2203
|
+
// code execution 20250825 text editor:
|
|
2204
|
+
"text_editor_code_execution",
|
|
2205
|
+
// code execution 20250825 bash:
|
|
2206
|
+
"bash_code_execution"
|
|
2207
|
+
].includes(value.content_block.name)) {
|
|
1917
2208
|
contentBlocks[value.index] = {
|
|
1918
2209
|
type: "tool-call",
|
|
1919
2210
|
toolCallId: value.content_block.id,
|
|
1920
2211
|
toolName: value.content_block.name,
|
|
1921
2212
|
input: "",
|
|
1922
|
-
providerExecuted: true
|
|
2213
|
+
providerExecuted: true,
|
|
2214
|
+
firstDelta: true
|
|
1923
2215
|
};
|
|
2216
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1924
2217
|
controller.enqueue({
|
|
1925
2218
|
type: "tool-input-start",
|
|
1926
2219
|
id: value.content_block.id,
|
|
1927
|
-
toolName:
|
|
2220
|
+
toolName: mappedToolName,
|
|
1928
2221
|
providerExecuted: true
|
|
1929
2222
|
});
|
|
1930
2223
|
}
|
|
@@ -2016,6 +2309,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2016
2309
|
}
|
|
2017
2310
|
return;
|
|
2018
2311
|
}
|
|
2312
|
+
// code execution 20250522:
|
|
2019
2313
|
case "code_execution_tool_result": {
|
|
2020
2314
|
const part = value.content_block;
|
|
2021
2315
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2046,6 +2340,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2046
2340
|
}
|
|
2047
2341
|
return;
|
|
2048
2342
|
}
|
|
2343
|
+
// code execution 20250825:
|
|
2344
|
+
case "bash_code_execution_tool_result":
|
|
2345
|
+
case "text_editor_code_execution_tool_result": {
|
|
2346
|
+
const part = value.content_block;
|
|
2347
|
+
controller.enqueue({
|
|
2348
|
+
type: "tool-result",
|
|
2349
|
+
toolCallId: part.tool_use_id,
|
|
2350
|
+
toolName: "code_execution",
|
|
2351
|
+
result: part.content,
|
|
2352
|
+
providerExecuted: true
|
|
2353
|
+
});
|
|
2354
|
+
return;
|
|
2355
|
+
}
|
|
2049
2356
|
default: {
|
|
2050
2357
|
const _exhaustiveCheck = contentBlockType;
|
|
2051
2358
|
throw new Error(
|
|
@@ -2078,7 +2385,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2078
2385
|
type: "tool-input-end",
|
|
2079
2386
|
id: contentBlock.toolCallId
|
|
2080
2387
|
});
|
|
2081
|
-
|
|
2388
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2389
|
+
controller.enqueue({
|
|
2390
|
+
type: "tool-call",
|
|
2391
|
+
toolCallId: contentBlock.toolCallId,
|
|
2392
|
+
toolName,
|
|
2393
|
+
input: contentBlock.input,
|
|
2394
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2395
|
+
});
|
|
2082
2396
|
}
|
|
2083
2397
|
break;
|
|
2084
2398
|
}
|
|
@@ -2126,7 +2440,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2126
2440
|
}
|
|
2127
2441
|
case "input_json_delta": {
|
|
2128
2442
|
const contentBlock = contentBlocks[value.index];
|
|
2129
|
-
|
|
2443
|
+
let delta = value.delta.partial_json;
|
|
2444
|
+
if (delta.length === 0) {
|
|
2445
|
+
return;
|
|
2446
|
+
}
|
|
2130
2447
|
if (usesJsonResponseTool) {
|
|
2131
2448
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2132
2449
|
return;
|
|
@@ -2140,12 +2457,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2140
2457
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2141
2458
|
return;
|
|
2142
2459
|
}
|
|
2460
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2461
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2462
|
+
}
|
|
2143
2463
|
controller.enqueue({
|
|
2144
2464
|
type: "tool-input-delta",
|
|
2145
2465
|
id: contentBlock.toolCallId,
|
|
2146
2466
|
delta
|
|
2147
2467
|
});
|
|
2148
2468
|
contentBlock.input += delta;
|
|
2469
|
+
contentBlock.firstDelta = false;
|
|
2149
2470
|
}
|
|
2150
2471
|
return;
|
|
2151
2472
|
}
|
|
@@ -2233,15 +2554,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2233
2554
|
// src/tool/bash_20241022.ts
|
|
2234
2555
|
import {
|
|
2235
2556
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2236
|
-
lazySchema as
|
|
2237
|
-
zodSchema as
|
|
2557
|
+
lazySchema as lazySchema8,
|
|
2558
|
+
zodSchema as zodSchema8
|
|
2238
2559
|
} from "@ai-sdk/provider-utils";
|
|
2239
|
-
import { z as
|
|
2240
|
-
var bash_20241022InputSchema =
|
|
2241
|
-
() =>
|
|
2242
|
-
|
|
2243
|
-
command:
|
|
2244
|
-
restart:
|
|
2560
|
+
import { z as z9 } from "zod/v4";
|
|
2561
|
+
var bash_20241022InputSchema = lazySchema8(
|
|
2562
|
+
() => zodSchema8(
|
|
2563
|
+
z9.object({
|
|
2564
|
+
command: z9.string(),
|
|
2565
|
+
restart: z9.boolean().optional()
|
|
2245
2566
|
})
|
|
2246
2567
|
)
|
|
2247
2568
|
);
|
|
@@ -2254,15 +2575,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2254
2575
|
// src/tool/bash_20250124.ts
|
|
2255
2576
|
import {
|
|
2256
2577
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2257
|
-
lazySchema as
|
|
2258
|
-
zodSchema as
|
|
2578
|
+
lazySchema as lazySchema9,
|
|
2579
|
+
zodSchema as zodSchema9
|
|
2259
2580
|
} from "@ai-sdk/provider-utils";
|
|
2260
|
-
import { z as
|
|
2261
|
-
var bash_20250124InputSchema =
|
|
2262
|
-
() =>
|
|
2263
|
-
|
|
2264
|
-
command:
|
|
2265
|
-
restart:
|
|
2581
|
+
import { z as z10 } from "zod/v4";
|
|
2582
|
+
var bash_20250124InputSchema = lazySchema9(
|
|
2583
|
+
() => zodSchema9(
|
|
2584
|
+
z10.object({
|
|
2585
|
+
command: z10.string(),
|
|
2586
|
+
restart: z10.boolean().optional()
|
|
2266
2587
|
})
|
|
2267
2588
|
)
|
|
2268
2589
|
);
|
|
@@ -2275,14 +2596,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2275
2596
|
// src/tool/computer_20241022.ts
|
|
2276
2597
|
import {
|
|
2277
2598
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2278
|
-
lazySchema as
|
|
2279
|
-
zodSchema as
|
|
2599
|
+
lazySchema as lazySchema10,
|
|
2600
|
+
zodSchema as zodSchema10
|
|
2280
2601
|
} from "@ai-sdk/provider-utils";
|
|
2281
|
-
import { z as
|
|
2282
|
-
var computer_20241022InputSchema =
|
|
2283
|
-
() =>
|
|
2284
|
-
|
|
2285
|
-
action:
|
|
2602
|
+
import { z as z11 } from "zod/v4";
|
|
2603
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2604
|
+
() => zodSchema10(
|
|
2605
|
+
z11.object({
|
|
2606
|
+
action: z11.enum([
|
|
2286
2607
|
"key",
|
|
2287
2608
|
"type",
|
|
2288
2609
|
"mouse_move",
|
|
@@ -2294,8 +2615,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2294
2615
|
"screenshot",
|
|
2295
2616
|
"cursor_position"
|
|
2296
2617
|
]),
|
|
2297
|
-
coordinate:
|
|
2298
|
-
text:
|
|
2618
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2619
|
+
text: z11.string().optional()
|
|
2299
2620
|
})
|
|
2300
2621
|
)
|
|
2301
2622
|
);
|
|
@@ -2308,14 +2629,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2308
2629
|
// src/tool/computer_20250124.ts
|
|
2309
2630
|
import {
|
|
2310
2631
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2311
|
-
lazySchema as
|
|
2312
|
-
zodSchema as
|
|
2632
|
+
lazySchema as lazySchema11,
|
|
2633
|
+
zodSchema as zodSchema11
|
|
2313
2634
|
} from "@ai-sdk/provider-utils";
|
|
2314
|
-
import { z as
|
|
2315
|
-
var computer_20250124InputSchema =
|
|
2316
|
-
() =>
|
|
2317
|
-
|
|
2318
|
-
action:
|
|
2635
|
+
import { z as z12 } from "zod/v4";
|
|
2636
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2637
|
+
() => zodSchema11(
|
|
2638
|
+
z12.object({
|
|
2639
|
+
action: z12.enum([
|
|
2319
2640
|
"key",
|
|
2320
2641
|
"hold_key",
|
|
2321
2642
|
"type",
|
|
@@ -2333,12 +2654,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2333
2654
|
"wait",
|
|
2334
2655
|
"screenshot"
|
|
2335
2656
|
]),
|
|
2336
|
-
coordinate:
|
|
2337
|
-
duration:
|
|
2338
|
-
scroll_amount:
|
|
2339
|
-
scroll_direction:
|
|
2340
|
-
start_coordinate:
|
|
2341
|
-
text:
|
|
2657
|
+
coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2658
|
+
duration: z12.number().optional(),
|
|
2659
|
+
scroll_amount: z12.number().optional(),
|
|
2660
|
+
scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
|
|
2661
|
+
start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2662
|
+
text: z12.string().optional()
|
|
2342
2663
|
})
|
|
2343
2664
|
)
|
|
2344
2665
|
);
|
|
@@ -2348,27 +2669,77 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2348
2669
|
inputSchema: computer_20250124InputSchema
|
|
2349
2670
|
});
|
|
2350
2671
|
|
|
2351
|
-
// src/tool/
|
|
2672
|
+
// src/tool/memory_20250818.ts
|
|
2352
2673
|
import {
|
|
2353
2674
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2354
|
-
lazySchema as
|
|
2355
|
-
zodSchema as
|
|
2675
|
+
lazySchema as lazySchema12,
|
|
2676
|
+
zodSchema as zodSchema12
|
|
2356
2677
|
} from "@ai-sdk/provider-utils";
|
|
2357
|
-
import { z as
|
|
2358
|
-
var
|
|
2359
|
-
() =>
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2678
|
+
import { z as z13 } from "zod/v4";
|
|
2679
|
+
var memory_20250818InputSchema = lazySchema12(
|
|
2680
|
+
() => zodSchema12(
|
|
2681
|
+
z13.discriminatedUnion("command", [
|
|
2682
|
+
z13.object({
|
|
2683
|
+
command: z13.literal("view"),
|
|
2684
|
+
path: z13.string(),
|
|
2685
|
+
view_range: z13.tuple([z13.number(), z13.number()]).optional()
|
|
2686
|
+
}),
|
|
2687
|
+
z13.object({
|
|
2688
|
+
command: z13.literal("create"),
|
|
2689
|
+
path: z13.string(),
|
|
2690
|
+
file_text: z13.string()
|
|
2691
|
+
}),
|
|
2692
|
+
z13.object({
|
|
2693
|
+
command: z13.literal("str_replace"),
|
|
2694
|
+
path: z13.string(),
|
|
2695
|
+
old_str: z13.string(),
|
|
2696
|
+
new_str: z13.string()
|
|
2697
|
+
}),
|
|
2698
|
+
z13.object({
|
|
2699
|
+
command: z13.literal("insert"),
|
|
2700
|
+
path: z13.string(),
|
|
2701
|
+
insert_line: z13.number(),
|
|
2702
|
+
insert_text: z13.string()
|
|
2703
|
+
}),
|
|
2704
|
+
z13.object({
|
|
2705
|
+
command: z13.literal("delete"),
|
|
2706
|
+
path: z13.string()
|
|
2707
|
+
}),
|
|
2708
|
+
z13.object({
|
|
2709
|
+
command: z13.literal("rename"),
|
|
2710
|
+
old_path: z13.string(),
|
|
2711
|
+
new_path: z13.string()
|
|
2712
|
+
})
|
|
2713
|
+
])
|
|
2714
|
+
)
|
|
2715
|
+
);
|
|
2716
|
+
var memory_20250818 = createProviderDefinedToolFactory6({
|
|
2717
|
+
id: "anthropic.memory_20250818",
|
|
2718
|
+
name: "memory",
|
|
2719
|
+
inputSchema: memory_20250818InputSchema
|
|
2720
|
+
});
|
|
2721
|
+
|
|
2722
|
+
// src/tool/text-editor_20241022.ts
|
|
2723
|
+
import {
|
|
2724
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2725
|
+
lazySchema as lazySchema13,
|
|
2726
|
+
zodSchema as zodSchema13
|
|
2727
|
+
} from "@ai-sdk/provider-utils";
|
|
2728
|
+
import { z as z14 } from "zod/v4";
|
|
2729
|
+
var textEditor_20241022InputSchema = lazySchema13(
|
|
2730
|
+
() => zodSchema13(
|
|
2731
|
+
z14.object({
|
|
2732
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2733
|
+
path: z14.string(),
|
|
2734
|
+
file_text: z14.string().optional(),
|
|
2735
|
+
insert_line: z14.number().int().optional(),
|
|
2736
|
+
new_str: z14.string().optional(),
|
|
2737
|
+
old_str: z14.string().optional(),
|
|
2738
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
2368
2739
|
})
|
|
2369
2740
|
)
|
|
2370
2741
|
);
|
|
2371
|
-
var textEditor_20241022 =
|
|
2742
|
+
var textEditor_20241022 = createProviderDefinedToolFactory7({
|
|
2372
2743
|
id: "anthropic.text_editor_20241022",
|
|
2373
2744
|
name: "str_replace_editor",
|
|
2374
2745
|
inputSchema: textEditor_20241022InputSchema
|
|
@@ -2376,25 +2747,25 @@ var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
|
2376
2747
|
|
|
2377
2748
|
// src/tool/text-editor_20250124.ts
|
|
2378
2749
|
import {
|
|
2379
|
-
createProviderDefinedToolFactory as
|
|
2380
|
-
lazySchema as
|
|
2381
|
-
zodSchema as
|
|
2750
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
2751
|
+
lazySchema as lazySchema14,
|
|
2752
|
+
zodSchema as zodSchema14
|
|
2382
2753
|
} from "@ai-sdk/provider-utils";
|
|
2383
|
-
import { z as
|
|
2384
|
-
var textEditor_20250124InputSchema =
|
|
2385
|
-
() =>
|
|
2386
|
-
|
|
2387
|
-
command:
|
|
2388
|
-
path:
|
|
2389
|
-
file_text:
|
|
2390
|
-
insert_line:
|
|
2391
|
-
new_str:
|
|
2392
|
-
old_str:
|
|
2393
|
-
view_range:
|
|
2754
|
+
import { z as z15 } from "zod/v4";
|
|
2755
|
+
var textEditor_20250124InputSchema = lazySchema14(
|
|
2756
|
+
() => zodSchema14(
|
|
2757
|
+
z15.object({
|
|
2758
|
+
command: z15.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2759
|
+
path: z15.string(),
|
|
2760
|
+
file_text: z15.string().optional(),
|
|
2761
|
+
insert_line: z15.number().int().optional(),
|
|
2762
|
+
new_str: z15.string().optional(),
|
|
2763
|
+
old_str: z15.string().optional(),
|
|
2764
|
+
view_range: z15.array(z15.number().int()).optional()
|
|
2394
2765
|
})
|
|
2395
2766
|
)
|
|
2396
2767
|
);
|
|
2397
|
-
var textEditor_20250124 =
|
|
2768
|
+
var textEditor_20250124 = createProviderDefinedToolFactory8({
|
|
2398
2769
|
id: "anthropic.text_editor_20250124",
|
|
2399
2770
|
name: "str_replace_editor",
|
|
2400
2771
|
inputSchema: textEditor_20250124InputSchema
|
|
@@ -2402,25 +2773,25 @@ var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
|
2402
2773
|
|
|
2403
2774
|
// src/tool/text-editor_20250429.ts
|
|
2404
2775
|
import {
|
|
2405
|
-
createProviderDefinedToolFactory as
|
|
2406
|
-
lazySchema as
|
|
2407
|
-
zodSchema as
|
|
2776
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
|
|
2777
|
+
lazySchema as lazySchema15,
|
|
2778
|
+
zodSchema as zodSchema15
|
|
2408
2779
|
} from "@ai-sdk/provider-utils";
|
|
2409
|
-
import { z as
|
|
2410
|
-
var textEditor_20250429InputSchema =
|
|
2411
|
-
() =>
|
|
2412
|
-
|
|
2413
|
-
command:
|
|
2414
|
-
path:
|
|
2415
|
-
file_text:
|
|
2416
|
-
insert_line:
|
|
2417
|
-
new_str:
|
|
2418
|
-
old_str:
|
|
2419
|
-
view_range:
|
|
2780
|
+
import { z as z16 } from "zod/v4";
|
|
2781
|
+
var textEditor_20250429InputSchema = lazySchema15(
|
|
2782
|
+
() => zodSchema15(
|
|
2783
|
+
z16.object({
|
|
2784
|
+
command: z16.enum(["view", "create", "str_replace", "insert"]),
|
|
2785
|
+
path: z16.string(),
|
|
2786
|
+
file_text: z16.string().optional(),
|
|
2787
|
+
insert_line: z16.number().int().optional(),
|
|
2788
|
+
new_str: z16.string().optional(),
|
|
2789
|
+
old_str: z16.string().optional(),
|
|
2790
|
+
view_range: z16.array(z16.number().int()).optional()
|
|
2420
2791
|
})
|
|
2421
2792
|
)
|
|
2422
2793
|
);
|
|
2423
|
-
var textEditor_20250429 =
|
|
2794
|
+
var textEditor_20250429 = createProviderDefinedToolFactory9({
|
|
2424
2795
|
id: "anthropic.text_editor_20250429",
|
|
2425
2796
|
name: "str_replace_based_edit_tool",
|
|
2426
2797
|
inputSchema: textEditor_20250429InputSchema
|
|
@@ -2457,6 +2828,19 @@ var anthropicTools = {
|
|
|
2457
2828
|
* Tool name must be `code_execution`.
|
|
2458
2829
|
*/
|
|
2459
2830
|
codeExecution_20250522,
|
|
2831
|
+
/**
|
|
2832
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2833
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2834
|
+
* the API conversation.
|
|
2835
|
+
*
|
|
2836
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2837
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2838
|
+
*
|
|
2839
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2840
|
+
*
|
|
2841
|
+
* Tool name must be `code_execution`.
|
|
2842
|
+
*/
|
|
2843
|
+
codeExecution_20250825,
|
|
2460
2844
|
/**
|
|
2461
2845
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2462
2846
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -2483,6 +2867,17 @@ var anthropicTools = {
|
|
|
2483
2867
|
* @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.
|
|
2484
2868
|
*/
|
|
2485
2869
|
computer_20250124,
|
|
2870
|
+
/**
|
|
2871
|
+
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
2872
|
+
* Claude can create, read, update, and delete files that persist between sessions,
|
|
2873
|
+
* allowing it to build knowledge over time without keeping everything in the context window.
|
|
2874
|
+
* The memory tool operates client-side—you control where and how the data is stored through your own infrastructure.
|
|
2875
|
+
*
|
|
2876
|
+
* Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
|
|
2877
|
+
*
|
|
2878
|
+
* Tool name must be `memory`.
|
|
2879
|
+
*/
|
|
2880
|
+
memory_20250818,
|
|
2486
2881
|
/**
|
|
2487
2882
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2488
2883
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|