@ai-sdk/anthropic 2.0.26 → 2.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +448 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +434 -96
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +108 -0
- package/dist/internal/index.d.ts +108 -0
- package/dist/internal/index.js +442 -108
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +433 -95
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@ai-sdk/provider-utils";
|
|
11
11
|
|
|
12
12
|
// src/version.ts
|
|
13
|
-
var VERSION = true ? "2.0.
|
|
13
|
+
var VERSION = true ? "2.0.28" : "0.0.0-test";
|
|
14
14
|
|
|
15
15
|
// src/anthropic-messages-language-model.ts
|
|
16
16
|
import {
|
|
@@ -156,6 +156,7 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
156
156
|
})
|
|
157
157
|
])
|
|
158
158
|
}),
|
|
159
|
+
// code execution results for code_execution_20250522 tool:
|
|
159
160
|
z2.object({
|
|
160
161
|
type: z2.literal("code_execution_tool_result"),
|
|
161
162
|
tool_use_id: z2.string(),
|
|
@@ -171,6 +172,62 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
171
172
|
error_code: z2.string()
|
|
172
173
|
})
|
|
173
174
|
])
|
|
175
|
+
}),
|
|
176
|
+
// bash code execution results for code_execution_20250825 tool:
|
|
177
|
+
z2.object({
|
|
178
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
179
|
+
tool_use_id: z2.string(),
|
|
180
|
+
content: z2.discriminatedUnion("type", [
|
|
181
|
+
z2.object({
|
|
182
|
+
type: z2.literal("bash_code_execution_result"),
|
|
183
|
+
content: z2.array(
|
|
184
|
+
z2.object({
|
|
185
|
+
type: z2.literal("bash_code_execution_output"),
|
|
186
|
+
file_id: z2.string()
|
|
187
|
+
})
|
|
188
|
+
),
|
|
189
|
+
stdout: z2.string(),
|
|
190
|
+
stderr: z2.string(),
|
|
191
|
+
return_code: z2.number()
|
|
192
|
+
}),
|
|
193
|
+
z2.object({
|
|
194
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
195
|
+
error_code: z2.string()
|
|
196
|
+
})
|
|
197
|
+
])
|
|
198
|
+
}),
|
|
199
|
+
// text editor code execution results for code_execution_20250825 tool:
|
|
200
|
+
z2.object({
|
|
201
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
202
|
+
tool_use_id: z2.string(),
|
|
203
|
+
content: z2.discriminatedUnion("type", [
|
|
204
|
+
z2.object({
|
|
205
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
206
|
+
error_code: z2.string()
|
|
207
|
+
}),
|
|
208
|
+
z2.object({
|
|
209
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
210
|
+
content: z2.string(),
|
|
211
|
+
file_type: z2.string(),
|
|
212
|
+
num_lines: z2.number().nullable(),
|
|
213
|
+
start_line: z2.number().nullable(),
|
|
214
|
+
total_lines: z2.number().nullable()
|
|
215
|
+
}),
|
|
216
|
+
z2.object({
|
|
217
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
218
|
+
is_file_update: z2.boolean()
|
|
219
|
+
}),
|
|
220
|
+
z2.object({
|
|
221
|
+
type: z2.literal(
|
|
222
|
+
"text_editor_code_execution_str_replace_result"
|
|
223
|
+
),
|
|
224
|
+
lines: z2.array(z2.string()).nullable(),
|
|
225
|
+
new_lines: z2.number().nullable(),
|
|
226
|
+
new_start: z2.number().nullable(),
|
|
227
|
+
old_lines: z2.number().nullable(),
|
|
228
|
+
old_start: z2.number().nullable()
|
|
229
|
+
})
|
|
230
|
+
])
|
|
174
231
|
})
|
|
175
232
|
])
|
|
176
233
|
),
|
|
@@ -271,6 +328,7 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
271
328
|
})
|
|
272
329
|
])
|
|
273
330
|
}),
|
|
331
|
+
// code execution results for code_execution_20250522 tool:
|
|
274
332
|
z2.object({
|
|
275
333
|
type: z2.literal("code_execution_tool_result"),
|
|
276
334
|
tool_use_id: z2.string(),
|
|
@@ -286,6 +344,62 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
286
344
|
error_code: z2.string()
|
|
287
345
|
})
|
|
288
346
|
])
|
|
347
|
+
}),
|
|
348
|
+
// bash code execution results for code_execution_20250825 tool:
|
|
349
|
+
z2.object({
|
|
350
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
351
|
+
tool_use_id: z2.string(),
|
|
352
|
+
content: z2.discriminatedUnion("type", [
|
|
353
|
+
z2.object({
|
|
354
|
+
type: z2.literal("bash_code_execution_result"),
|
|
355
|
+
content: z2.array(
|
|
356
|
+
z2.object({
|
|
357
|
+
type: z2.literal("bash_code_execution_output"),
|
|
358
|
+
file_id: z2.string()
|
|
359
|
+
})
|
|
360
|
+
),
|
|
361
|
+
stdout: z2.string(),
|
|
362
|
+
stderr: z2.string(),
|
|
363
|
+
return_code: z2.number()
|
|
364
|
+
}),
|
|
365
|
+
z2.object({
|
|
366
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
367
|
+
error_code: z2.string()
|
|
368
|
+
})
|
|
369
|
+
])
|
|
370
|
+
}),
|
|
371
|
+
// text editor code execution results for code_execution_20250825 tool:
|
|
372
|
+
z2.object({
|
|
373
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
374
|
+
tool_use_id: z2.string(),
|
|
375
|
+
content: z2.discriminatedUnion("type", [
|
|
376
|
+
z2.object({
|
|
377
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
378
|
+
error_code: z2.string()
|
|
379
|
+
}),
|
|
380
|
+
z2.object({
|
|
381
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
382
|
+
content: z2.string(),
|
|
383
|
+
file_type: z2.string(),
|
|
384
|
+
num_lines: z2.number().nullable(),
|
|
385
|
+
start_line: z2.number().nullable(),
|
|
386
|
+
total_lines: z2.number().nullable()
|
|
387
|
+
}),
|
|
388
|
+
z2.object({
|
|
389
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
390
|
+
is_file_update: z2.boolean()
|
|
391
|
+
}),
|
|
392
|
+
z2.object({
|
|
393
|
+
type: z2.literal(
|
|
394
|
+
"text_editor_code_execution_str_replace_result"
|
|
395
|
+
),
|
|
396
|
+
lines: z2.array(z2.string()).nullable(),
|
|
397
|
+
new_lines: z2.number().nullable(),
|
|
398
|
+
new_start: z2.number().nullable(),
|
|
399
|
+
old_lines: z2.number().nullable(),
|
|
400
|
+
old_start: z2.number().nullable()
|
|
401
|
+
})
|
|
402
|
+
])
|
|
289
403
|
})
|
|
290
404
|
])
|
|
291
405
|
}),
|
|
@@ -621,6 +735,14 @@ async function prepareTools({
|
|
|
621
735
|
});
|
|
622
736
|
break;
|
|
623
737
|
}
|
|
738
|
+
case "anthropic.code_execution_20250825": {
|
|
739
|
+
betas.add("code-execution-2025-08-25");
|
|
740
|
+
anthropicTools2.push({
|
|
741
|
+
type: "code_execution_20250825",
|
|
742
|
+
name: "code_execution"
|
|
743
|
+
});
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
624
746
|
case "anthropic.computer_20250124": {
|
|
625
747
|
betas.add("computer-use-2025-01-24");
|
|
626
748
|
anthropicTools2.push({
|
|
@@ -836,6 +958,99 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
836
958
|
return factory4(args);
|
|
837
959
|
};
|
|
838
960
|
|
|
961
|
+
// src/tool/code-execution_20250825.ts
|
|
962
|
+
import {
|
|
963
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
964
|
+
lazySchema as lazySchema7,
|
|
965
|
+
zodSchema as zodSchema7
|
|
966
|
+
} from "@ai-sdk/provider-utils";
|
|
967
|
+
import { z as z8 } from "zod/v4";
|
|
968
|
+
var codeExecution_20250825OutputSchema = lazySchema7(
|
|
969
|
+
() => zodSchema7(
|
|
970
|
+
z8.discriminatedUnion("type", [
|
|
971
|
+
z8.object({
|
|
972
|
+
type: z8.literal("bash_code_execution_result"),
|
|
973
|
+
content: z8.array(
|
|
974
|
+
z8.object({
|
|
975
|
+
type: z8.literal("bash_code_execution_output"),
|
|
976
|
+
file_id: z8.string()
|
|
977
|
+
})
|
|
978
|
+
),
|
|
979
|
+
stdout: z8.string(),
|
|
980
|
+
stderr: z8.string(),
|
|
981
|
+
return_code: z8.number()
|
|
982
|
+
}),
|
|
983
|
+
z8.object({
|
|
984
|
+
type: z8.literal("bash_code_execution_tool_result_error"),
|
|
985
|
+
error_code: z8.string()
|
|
986
|
+
}),
|
|
987
|
+
z8.object({
|
|
988
|
+
type: z8.literal("text_editor_code_execution_tool_result_error"),
|
|
989
|
+
error_code: z8.string()
|
|
990
|
+
}),
|
|
991
|
+
z8.object({
|
|
992
|
+
type: z8.literal("text_editor_code_execution_view_result"),
|
|
993
|
+
content: z8.string(),
|
|
994
|
+
file_type: z8.string(),
|
|
995
|
+
num_lines: z8.number().nullable(),
|
|
996
|
+
start_line: z8.number().nullable(),
|
|
997
|
+
total_lines: z8.number().nullable()
|
|
998
|
+
}),
|
|
999
|
+
z8.object({
|
|
1000
|
+
type: z8.literal("text_editor_code_execution_create_result"),
|
|
1001
|
+
is_file_update: z8.boolean()
|
|
1002
|
+
}),
|
|
1003
|
+
z8.object({
|
|
1004
|
+
type: z8.literal("text_editor_code_execution_str_replace_result"),
|
|
1005
|
+
lines: z8.array(z8.string()).nullable(),
|
|
1006
|
+
new_lines: z8.number().nullable(),
|
|
1007
|
+
new_start: z8.number().nullable(),
|
|
1008
|
+
old_lines: z8.number().nullable(),
|
|
1009
|
+
old_start: z8.number().nullable()
|
|
1010
|
+
})
|
|
1011
|
+
])
|
|
1012
|
+
)
|
|
1013
|
+
);
|
|
1014
|
+
var codeExecution_20250825InputSchema = lazySchema7(
|
|
1015
|
+
() => zodSchema7(
|
|
1016
|
+
z8.discriminatedUnion("type", [
|
|
1017
|
+
z8.object({
|
|
1018
|
+
type: z8.literal("bash_code_execution"),
|
|
1019
|
+
command: z8.string()
|
|
1020
|
+
}),
|
|
1021
|
+
z8.discriminatedUnion("command", [
|
|
1022
|
+
z8.object({
|
|
1023
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1024
|
+
command: z8.literal("view"),
|
|
1025
|
+
path: z8.string()
|
|
1026
|
+
}),
|
|
1027
|
+
z8.object({
|
|
1028
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1029
|
+
command: z8.literal("create"),
|
|
1030
|
+
path: z8.string(),
|
|
1031
|
+
file_text: z8.string().nullish()
|
|
1032
|
+
}),
|
|
1033
|
+
z8.object({
|
|
1034
|
+
type: z8.literal("text_editor_code_execution"),
|
|
1035
|
+
command: z8.literal("str_replace"),
|
|
1036
|
+
path: z8.string(),
|
|
1037
|
+
old_str: z8.string(),
|
|
1038
|
+
new_str: z8.string()
|
|
1039
|
+
})
|
|
1040
|
+
])
|
|
1041
|
+
])
|
|
1042
|
+
)
|
|
1043
|
+
);
|
|
1044
|
+
var factory5 = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
1045
|
+
id: "anthropic.code_execution_20250825",
|
|
1046
|
+
name: "code_execution",
|
|
1047
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
1048
|
+
outputSchema: codeExecution_20250825OutputSchema
|
|
1049
|
+
});
|
|
1050
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
1051
|
+
return factory5(args);
|
|
1052
|
+
};
|
|
1053
|
+
|
|
839
1054
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
840
1055
|
function convertToString(data) {
|
|
841
1056
|
if (typeof data === "string") {
|
|
@@ -1023,6 +1238,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1023
1238
|
cache_control: void 0
|
|
1024
1239
|
};
|
|
1025
1240
|
}
|
|
1241
|
+
if (contentPart.mediaType === "application/pdf") {
|
|
1242
|
+
betas.add("pdfs-2024-09-25");
|
|
1243
|
+
return {
|
|
1244
|
+
type: "document",
|
|
1245
|
+
source: {
|
|
1246
|
+
type: "base64",
|
|
1247
|
+
media_type: contentPart.mediaType,
|
|
1248
|
+
data: contentPart.data
|
|
1249
|
+
},
|
|
1250
|
+
cache_control: void 0
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1026
1253
|
throw new UnsupportedFunctionalityError2({
|
|
1027
1254
|
functionality: `media type: ${contentPart.mediaType}`
|
|
1028
1255
|
});
|
|
@@ -1126,7 +1353,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1126
1353
|
}
|
|
1127
1354
|
case "tool-call": {
|
|
1128
1355
|
if (part.providerExecuted) {
|
|
1129
|
-
if (part.toolName === "code_execution"
|
|
1356
|
+
if (part.toolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")) {
|
|
1357
|
+
anthropicContent.push({
|
|
1358
|
+
type: "server_tool_use",
|
|
1359
|
+
id: part.toolCallId,
|
|
1360
|
+
name: part.input.type,
|
|
1361
|
+
// map back to subtool name
|
|
1362
|
+
input: part.input,
|
|
1363
|
+
cache_control: cacheControl
|
|
1364
|
+
});
|
|
1365
|
+
} else if (part.toolName === "code_execution" || // code execution 20250522
|
|
1366
|
+
part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
1130
1367
|
anthropicContent.push({
|
|
1131
1368
|
type: "server_tool_use",
|
|
1132
1369
|
id: part.toolCallId,
|
|
@@ -1161,21 +1398,48 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1161
1398
|
});
|
|
1162
1399
|
break;
|
|
1163
1400
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1401
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
1402
|
+
warnings.push({
|
|
1403
|
+
type: "other",
|
|
1404
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
1405
|
+
});
|
|
1406
|
+
break;
|
|
1407
|
+
}
|
|
1408
|
+
if (output.value.type === "code_execution_result") {
|
|
1409
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1410
|
+
value: output.value,
|
|
1411
|
+
schema: codeExecution_20250522OutputSchema
|
|
1412
|
+
});
|
|
1413
|
+
anthropicContent.push({
|
|
1414
|
+
type: "code_execution_tool_result",
|
|
1415
|
+
tool_use_id: part.toolCallId,
|
|
1416
|
+
content: {
|
|
1417
|
+
type: codeExecutionOutput.type,
|
|
1418
|
+
stdout: codeExecutionOutput.stdout,
|
|
1419
|
+
stderr: codeExecutionOutput.stderr,
|
|
1420
|
+
return_code: codeExecutionOutput.return_code
|
|
1421
|
+
},
|
|
1422
|
+
cache_control: cacheControl
|
|
1423
|
+
});
|
|
1424
|
+
} else {
|
|
1425
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1426
|
+
value: output.value,
|
|
1427
|
+
schema: codeExecution_20250825OutputSchema
|
|
1428
|
+
});
|
|
1429
|
+
anthropicContent.push(
|
|
1430
|
+
codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
1431
|
+
type: "bash_code_execution_tool_result",
|
|
1432
|
+
tool_use_id: part.toolCallId,
|
|
1433
|
+
cache_control: cacheControl,
|
|
1434
|
+
content: codeExecutionOutput
|
|
1435
|
+
} : {
|
|
1436
|
+
type: "text_editor_code_execution_tool_result",
|
|
1437
|
+
tool_use_id: part.toolCallId,
|
|
1438
|
+
cache_control: cacheControl,
|
|
1439
|
+
content: codeExecutionOutput
|
|
1440
|
+
}
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1179
1443
|
break;
|
|
1180
1444
|
}
|
|
1181
1445
|
if (part.toolName === "web_fetch") {
|
|
@@ -1645,7 +1909,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1645
1909
|
break;
|
|
1646
1910
|
}
|
|
1647
1911
|
case "server_tool_use": {
|
|
1648
|
-
if (part.name === "
|
|
1912
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
1913
|
+
content.push({
|
|
1914
|
+
type: "tool-call",
|
|
1915
|
+
toolCallId: part.id,
|
|
1916
|
+
toolName: "code_execution",
|
|
1917
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
1918
|
+
providerExecuted: true
|
|
1919
|
+
});
|
|
1920
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1649
1921
|
content.push({
|
|
1650
1922
|
type: "tool-call",
|
|
1651
1923
|
toolCallId: part.id,
|
|
@@ -1741,6 +2013,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1741
2013
|
}
|
|
1742
2014
|
break;
|
|
1743
2015
|
}
|
|
2016
|
+
// code execution 20250522:
|
|
1744
2017
|
case "code_execution_tool_result": {
|
|
1745
2018
|
if (part.content.type === "code_execution_result") {
|
|
1746
2019
|
content.push({
|
|
@@ -1770,6 +2043,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1770
2043
|
}
|
|
1771
2044
|
break;
|
|
1772
2045
|
}
|
|
2046
|
+
// code execution 20250825:
|
|
2047
|
+
case "bash_code_execution_tool_result":
|
|
2048
|
+
case "text_editor_code_execution_tool_result": {
|
|
2049
|
+
content.push({
|
|
2050
|
+
type: "tool-result",
|
|
2051
|
+
toolCallId: part.tool_use_id,
|
|
2052
|
+
toolName: "code_execution",
|
|
2053
|
+
result: part.content,
|
|
2054
|
+
providerExecuted: true
|
|
2055
|
+
});
|
|
2056
|
+
break;
|
|
2057
|
+
}
|
|
1773
2058
|
}
|
|
1774
2059
|
}
|
|
1775
2060
|
return {
|
|
@@ -1886,7 +2171,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1886
2171
|
type: "tool-call",
|
|
1887
2172
|
toolCallId: value.content_block.id,
|
|
1888
2173
|
toolName: value.content_block.name,
|
|
1889
|
-
input: ""
|
|
2174
|
+
input: "",
|
|
2175
|
+
firstDelta: true
|
|
1890
2176
|
};
|
|
1891
2177
|
controller.enqueue(
|
|
1892
2178
|
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
@@ -1898,18 +2184,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1898
2184
|
return;
|
|
1899
2185
|
}
|
|
1900
2186
|
case "server_tool_use": {
|
|
1901
|
-
if (
|
|
2187
|
+
if ([
|
|
2188
|
+
"web_fetch",
|
|
2189
|
+
"web_search",
|
|
2190
|
+
// code execution 20250825:
|
|
2191
|
+
"code_execution",
|
|
2192
|
+
// code execution 20250825 text editor:
|
|
2193
|
+
"text_editor_code_execution",
|
|
2194
|
+
// code execution 20250825 bash:
|
|
2195
|
+
"bash_code_execution"
|
|
2196
|
+
].includes(value.content_block.name)) {
|
|
1902
2197
|
contentBlocks[value.index] = {
|
|
1903
2198
|
type: "tool-call",
|
|
1904
2199
|
toolCallId: value.content_block.id,
|
|
1905
2200
|
toolName: value.content_block.name,
|
|
1906
2201
|
input: "",
|
|
1907
|
-
providerExecuted: true
|
|
2202
|
+
providerExecuted: true,
|
|
2203
|
+
firstDelta: true
|
|
1908
2204
|
};
|
|
2205
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
1909
2206
|
controller.enqueue({
|
|
1910
2207
|
type: "tool-input-start",
|
|
1911
2208
|
id: value.content_block.id,
|
|
1912
|
-
toolName:
|
|
2209
|
+
toolName: mappedToolName,
|
|
1913
2210
|
providerExecuted: true
|
|
1914
2211
|
});
|
|
1915
2212
|
}
|
|
@@ -2001,6 +2298,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2001
2298
|
}
|
|
2002
2299
|
return;
|
|
2003
2300
|
}
|
|
2301
|
+
// code execution 20250522:
|
|
2004
2302
|
case "code_execution_tool_result": {
|
|
2005
2303
|
const part = value.content_block;
|
|
2006
2304
|
if (part.content.type === "code_execution_result") {
|
|
@@ -2031,6 +2329,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2031
2329
|
}
|
|
2032
2330
|
return;
|
|
2033
2331
|
}
|
|
2332
|
+
// code execution 20250825:
|
|
2333
|
+
case "bash_code_execution_tool_result":
|
|
2334
|
+
case "text_editor_code_execution_tool_result": {
|
|
2335
|
+
const part = value.content_block;
|
|
2336
|
+
controller.enqueue({
|
|
2337
|
+
type: "tool-result",
|
|
2338
|
+
toolCallId: part.tool_use_id,
|
|
2339
|
+
toolName: "code_execution",
|
|
2340
|
+
result: part.content,
|
|
2341
|
+
providerExecuted: true
|
|
2342
|
+
});
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2034
2345
|
default: {
|
|
2035
2346
|
const _exhaustiveCheck = contentBlockType;
|
|
2036
2347
|
throw new Error(
|
|
@@ -2063,7 +2374,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2063
2374
|
type: "tool-input-end",
|
|
2064
2375
|
id: contentBlock.toolCallId
|
|
2065
2376
|
});
|
|
2066
|
-
|
|
2377
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
2378
|
+
controller.enqueue({
|
|
2379
|
+
type: "tool-call",
|
|
2380
|
+
toolCallId: contentBlock.toolCallId,
|
|
2381
|
+
toolName,
|
|
2382
|
+
input: contentBlock.input,
|
|
2383
|
+
providerExecuted: contentBlock.providerExecuted
|
|
2384
|
+
});
|
|
2067
2385
|
}
|
|
2068
2386
|
break;
|
|
2069
2387
|
}
|
|
@@ -2111,7 +2429,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2111
2429
|
}
|
|
2112
2430
|
case "input_json_delta": {
|
|
2113
2431
|
const contentBlock = contentBlocks[value.index];
|
|
2114
|
-
|
|
2432
|
+
let delta = value.delta.partial_json;
|
|
2433
|
+
if (delta.length === 0) {
|
|
2434
|
+
return;
|
|
2435
|
+
}
|
|
2115
2436
|
if (usesJsonResponseTool) {
|
|
2116
2437
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
2117
2438
|
return;
|
|
@@ -2125,12 +2446,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2125
2446
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
2126
2447
|
return;
|
|
2127
2448
|
}
|
|
2449
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
2450
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
2451
|
+
}
|
|
2128
2452
|
controller.enqueue({
|
|
2129
2453
|
type: "tool-input-delta",
|
|
2130
2454
|
id: contentBlock.toolCallId,
|
|
2131
2455
|
delta
|
|
2132
2456
|
});
|
|
2133
2457
|
contentBlock.input += delta;
|
|
2458
|
+
contentBlock.firstDelta = false;
|
|
2134
2459
|
}
|
|
2135
2460
|
return;
|
|
2136
2461
|
}
|
|
@@ -2218,15 +2543,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2218
2543
|
// src/tool/bash_20241022.ts
|
|
2219
2544
|
import {
|
|
2220
2545
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2221
|
-
lazySchema as
|
|
2222
|
-
zodSchema as
|
|
2546
|
+
lazySchema as lazySchema8,
|
|
2547
|
+
zodSchema as zodSchema8
|
|
2223
2548
|
} from "@ai-sdk/provider-utils";
|
|
2224
|
-
import { z as
|
|
2225
|
-
var bash_20241022InputSchema =
|
|
2226
|
-
() =>
|
|
2227
|
-
|
|
2228
|
-
command:
|
|
2229
|
-
restart:
|
|
2549
|
+
import { z as z9 } from "zod/v4";
|
|
2550
|
+
var bash_20241022InputSchema = lazySchema8(
|
|
2551
|
+
() => zodSchema8(
|
|
2552
|
+
z9.object({
|
|
2553
|
+
command: z9.string(),
|
|
2554
|
+
restart: z9.boolean().optional()
|
|
2230
2555
|
})
|
|
2231
2556
|
)
|
|
2232
2557
|
);
|
|
@@ -2239,15 +2564,15 @@ var bash_20241022 = createProviderDefinedToolFactory2({
|
|
|
2239
2564
|
// src/tool/bash_20250124.ts
|
|
2240
2565
|
import {
|
|
2241
2566
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2242
|
-
lazySchema as
|
|
2243
|
-
zodSchema as
|
|
2567
|
+
lazySchema as lazySchema9,
|
|
2568
|
+
zodSchema as zodSchema9
|
|
2244
2569
|
} from "@ai-sdk/provider-utils";
|
|
2245
|
-
import { z as
|
|
2246
|
-
var bash_20250124InputSchema =
|
|
2247
|
-
() =>
|
|
2248
|
-
|
|
2249
|
-
command:
|
|
2250
|
-
restart:
|
|
2570
|
+
import { z as z10 } from "zod/v4";
|
|
2571
|
+
var bash_20250124InputSchema = lazySchema9(
|
|
2572
|
+
() => zodSchema9(
|
|
2573
|
+
z10.object({
|
|
2574
|
+
command: z10.string(),
|
|
2575
|
+
restart: z10.boolean().optional()
|
|
2251
2576
|
})
|
|
2252
2577
|
)
|
|
2253
2578
|
);
|
|
@@ -2260,14 +2585,14 @@ var bash_20250124 = createProviderDefinedToolFactory3({
|
|
|
2260
2585
|
// src/tool/computer_20241022.ts
|
|
2261
2586
|
import {
|
|
2262
2587
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2263
|
-
lazySchema as
|
|
2264
|
-
zodSchema as
|
|
2588
|
+
lazySchema as lazySchema10,
|
|
2589
|
+
zodSchema as zodSchema10
|
|
2265
2590
|
} from "@ai-sdk/provider-utils";
|
|
2266
|
-
import { z as
|
|
2267
|
-
var computer_20241022InputSchema =
|
|
2268
|
-
() =>
|
|
2269
|
-
|
|
2270
|
-
action:
|
|
2591
|
+
import { z as z11 } from "zod/v4";
|
|
2592
|
+
var computer_20241022InputSchema = lazySchema10(
|
|
2593
|
+
() => zodSchema10(
|
|
2594
|
+
z11.object({
|
|
2595
|
+
action: z11.enum([
|
|
2271
2596
|
"key",
|
|
2272
2597
|
"type",
|
|
2273
2598
|
"mouse_move",
|
|
@@ -2279,8 +2604,8 @@ var computer_20241022InputSchema = lazySchema9(
|
|
|
2279
2604
|
"screenshot",
|
|
2280
2605
|
"cursor_position"
|
|
2281
2606
|
]),
|
|
2282
|
-
coordinate:
|
|
2283
|
-
text:
|
|
2607
|
+
coordinate: z11.array(z11.number().int()).optional(),
|
|
2608
|
+
text: z11.string().optional()
|
|
2284
2609
|
})
|
|
2285
2610
|
)
|
|
2286
2611
|
);
|
|
@@ -2293,14 +2618,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
|
|
|
2293
2618
|
// src/tool/computer_20250124.ts
|
|
2294
2619
|
import {
|
|
2295
2620
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2296
|
-
lazySchema as
|
|
2297
|
-
zodSchema as
|
|
2621
|
+
lazySchema as lazySchema11,
|
|
2622
|
+
zodSchema as zodSchema11
|
|
2298
2623
|
} from "@ai-sdk/provider-utils";
|
|
2299
|
-
import { z as
|
|
2300
|
-
var computer_20250124InputSchema =
|
|
2301
|
-
() =>
|
|
2302
|
-
|
|
2303
|
-
action:
|
|
2624
|
+
import { z as z12 } from "zod/v4";
|
|
2625
|
+
var computer_20250124InputSchema = lazySchema11(
|
|
2626
|
+
() => zodSchema11(
|
|
2627
|
+
z12.object({
|
|
2628
|
+
action: z12.enum([
|
|
2304
2629
|
"key",
|
|
2305
2630
|
"hold_key",
|
|
2306
2631
|
"type",
|
|
@@ -2318,12 +2643,12 @@ var computer_20250124InputSchema = lazySchema10(
|
|
|
2318
2643
|
"wait",
|
|
2319
2644
|
"screenshot"
|
|
2320
2645
|
]),
|
|
2321
|
-
coordinate:
|
|
2322
|
-
duration:
|
|
2323
|
-
scroll_amount:
|
|
2324
|
-
scroll_direction:
|
|
2325
|
-
start_coordinate:
|
|
2326
|
-
text:
|
|
2646
|
+
coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2647
|
+
duration: z12.number().optional(),
|
|
2648
|
+
scroll_amount: z12.number().optional(),
|
|
2649
|
+
scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
|
|
2650
|
+
start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
|
|
2651
|
+
text: z12.string().optional()
|
|
2327
2652
|
})
|
|
2328
2653
|
)
|
|
2329
2654
|
);
|
|
@@ -2336,37 +2661,11 @@ var computer_20250124 = createProviderDefinedToolFactory5({
|
|
|
2336
2661
|
// src/tool/text-editor_20241022.ts
|
|
2337
2662
|
import {
|
|
2338
2663
|
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2339
|
-
lazySchema as lazySchema11,
|
|
2340
|
-
zodSchema as zodSchema11
|
|
2341
|
-
} from "@ai-sdk/provider-utils";
|
|
2342
|
-
import { z as z12 } from "zod/v4";
|
|
2343
|
-
var textEditor_20241022InputSchema = lazySchema11(
|
|
2344
|
-
() => zodSchema11(
|
|
2345
|
-
z12.object({
|
|
2346
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2347
|
-
path: z12.string(),
|
|
2348
|
-
file_text: z12.string().optional(),
|
|
2349
|
-
insert_line: z12.number().int().optional(),
|
|
2350
|
-
new_str: z12.string().optional(),
|
|
2351
|
-
old_str: z12.string().optional(),
|
|
2352
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2353
|
-
})
|
|
2354
|
-
)
|
|
2355
|
-
);
|
|
2356
|
-
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2357
|
-
id: "anthropic.text_editor_20241022",
|
|
2358
|
-
name: "str_replace_editor",
|
|
2359
|
-
inputSchema: textEditor_20241022InputSchema
|
|
2360
|
-
});
|
|
2361
|
-
|
|
2362
|
-
// src/tool/text-editor_20250124.ts
|
|
2363
|
-
import {
|
|
2364
|
-
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2365
2664
|
lazySchema as lazySchema12,
|
|
2366
2665
|
zodSchema as zodSchema12
|
|
2367
2666
|
} from "@ai-sdk/provider-utils";
|
|
2368
2667
|
import { z as z13 } from "zod/v4";
|
|
2369
|
-
var
|
|
2668
|
+
var textEditor_20241022InputSchema = lazySchema12(
|
|
2370
2669
|
() => zodSchema12(
|
|
2371
2670
|
z13.object({
|
|
2372
2671
|
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -2379,23 +2678,23 @@ var textEditor_20250124InputSchema = lazySchema12(
|
|
|
2379
2678
|
})
|
|
2380
2679
|
)
|
|
2381
2680
|
);
|
|
2382
|
-
var
|
|
2383
|
-
id: "anthropic.
|
|
2681
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2682
|
+
id: "anthropic.text_editor_20241022",
|
|
2384
2683
|
name: "str_replace_editor",
|
|
2385
|
-
inputSchema:
|
|
2684
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2386
2685
|
});
|
|
2387
2686
|
|
|
2388
|
-
// src/tool/text-
|
|
2687
|
+
// src/tool/text-editor_20250124.ts
|
|
2389
2688
|
import {
|
|
2390
|
-
createProviderDefinedToolFactory as
|
|
2689
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2391
2690
|
lazySchema as lazySchema13,
|
|
2392
2691
|
zodSchema as zodSchema13
|
|
2393
2692
|
} from "@ai-sdk/provider-utils";
|
|
2394
2693
|
import { z as z14 } from "zod/v4";
|
|
2395
|
-
var
|
|
2694
|
+
var textEditor_20250124InputSchema = lazySchema13(
|
|
2396
2695
|
() => zodSchema13(
|
|
2397
2696
|
z14.object({
|
|
2398
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2697
|
+
command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2399
2698
|
path: z14.string(),
|
|
2400
2699
|
file_text: z14.string().optional(),
|
|
2401
2700
|
insert_line: z14.number().int().optional(),
|
|
@@ -2405,6 +2704,32 @@ var textEditor_20250429InputSchema = lazySchema13(
|
|
|
2405
2704
|
})
|
|
2406
2705
|
)
|
|
2407
2706
|
);
|
|
2707
|
+
var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
2708
|
+
id: "anthropic.text_editor_20250124",
|
|
2709
|
+
name: "str_replace_editor",
|
|
2710
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2711
|
+
});
|
|
2712
|
+
|
|
2713
|
+
// src/tool/text-editor_20250429.ts
|
|
2714
|
+
import {
|
|
2715
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
2716
|
+
lazySchema as lazySchema14,
|
|
2717
|
+
zodSchema as zodSchema14
|
|
2718
|
+
} from "@ai-sdk/provider-utils";
|
|
2719
|
+
import { z as z15 } from "zod/v4";
|
|
2720
|
+
var textEditor_20250429InputSchema = lazySchema14(
|
|
2721
|
+
() => zodSchema14(
|
|
2722
|
+
z15.object({
|
|
2723
|
+
command: z15.enum(["view", "create", "str_replace", "insert"]),
|
|
2724
|
+
path: z15.string(),
|
|
2725
|
+
file_text: z15.string().optional(),
|
|
2726
|
+
insert_line: z15.number().int().optional(),
|
|
2727
|
+
new_str: z15.string().optional(),
|
|
2728
|
+
old_str: z15.string().optional(),
|
|
2729
|
+
view_range: z15.array(z15.number().int()).optional()
|
|
2730
|
+
})
|
|
2731
|
+
)
|
|
2732
|
+
);
|
|
2408
2733
|
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
2409
2734
|
id: "anthropic.text_editor_20250429",
|
|
2410
2735
|
name: "str_replace_based_edit_tool",
|
|
@@ -2442,6 +2767,19 @@ var anthropicTools = {
|
|
|
2442
2767
|
* Tool name must be `code_execution`.
|
|
2443
2768
|
*/
|
|
2444
2769
|
codeExecution_20250522,
|
|
2770
|
+
/**
|
|
2771
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2772
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2773
|
+
* the API conversation.
|
|
2774
|
+
*
|
|
2775
|
+
* The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
|
|
2776
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2777
|
+
*
|
|
2778
|
+
* This is the latest version with enhanced Bash support and file operations.
|
|
2779
|
+
*
|
|
2780
|
+
* Tool name must be `code_execution`.
|
|
2781
|
+
*/
|
|
2782
|
+
codeExecution_20250825,
|
|
2445
2783
|
/**
|
|
2446
2784
|
* Claude can interact with computer environments through the computer use tool, which
|
|
2447
2785
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|