@ai-sdk/anthropic 2.0.3 → 2.0.5
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 +13 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +388 -229
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +362 -203
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +21 -0
- package/dist/internal/index.d.ts +21 -0
- package/dist/internal/index.js +384 -225
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +362 -203
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
postJsonToApi,
|
|
12
12
|
resolve
|
|
13
13
|
} from "@ai-sdk/provider-utils";
|
|
14
|
-
import { z as
|
|
14
|
+
import { z as z5 } from "zod/v4";
|
|
15
15
|
|
|
16
16
|
// src/anthropic-error.ts
|
|
17
17
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
@@ -227,6 +227,14 @@ function prepareTools({
|
|
|
227
227
|
});
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
|
+
case "anthropic.code_execution_20250522": {
|
|
231
|
+
betas.add("code-execution-2025-05-22");
|
|
232
|
+
anthropicTools2.push({
|
|
233
|
+
type: "code_execution_20250522",
|
|
234
|
+
name: "code_execution"
|
|
235
|
+
});
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
230
238
|
default:
|
|
231
239
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
232
240
|
break;
|
|
@@ -294,6 +302,29 @@ import {
|
|
|
294
302
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
295
303
|
} from "@ai-sdk/provider";
|
|
296
304
|
import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
305
|
+
|
|
306
|
+
// src/tool/code-execution_20250522.ts
|
|
307
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
|
|
308
|
+
import { z as z4 } from "zod/v4";
|
|
309
|
+
var codeExecution_20250522OutputSchema = z4.object({
|
|
310
|
+
type: z4.literal("code_execution_result"),
|
|
311
|
+
stdout: z4.string(),
|
|
312
|
+
stderr: z4.string(),
|
|
313
|
+
return_code: z4.number()
|
|
314
|
+
});
|
|
315
|
+
var factory2 = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
316
|
+
id: "anthropic.code_execution_20250522",
|
|
317
|
+
name: "code_execution",
|
|
318
|
+
inputSchema: z4.object({
|
|
319
|
+
code: z4.string()
|
|
320
|
+
}),
|
|
321
|
+
outputSchema: codeExecution_20250522OutputSchema
|
|
322
|
+
});
|
|
323
|
+
var codeExecution_20250522 = (args = {}) => {
|
|
324
|
+
return factory2(args);
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// src/convert-to-anthropic-messages-prompt.ts
|
|
297
328
|
function convertToString(data) {
|
|
298
329
|
if (typeof data === "string") {
|
|
299
330
|
return Buffer.from(data, "base64").toString("utf-8");
|
|
@@ -593,6 +624,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
593
624
|
});
|
|
594
625
|
break;
|
|
595
626
|
}
|
|
627
|
+
if (part.toolName === "code_execution") {
|
|
628
|
+
anthropicContent.push({
|
|
629
|
+
type: "server_tool_use",
|
|
630
|
+
id: part.toolCallId,
|
|
631
|
+
name: "code_execution",
|
|
632
|
+
input: part.input,
|
|
633
|
+
cache_control: cacheControl
|
|
634
|
+
});
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
596
637
|
warnings.push({
|
|
597
638
|
type: "other",
|
|
598
639
|
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
@@ -635,6 +676,29 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
635
676
|
});
|
|
636
677
|
break;
|
|
637
678
|
}
|
|
679
|
+
if (part.toolName === "code_execution") {
|
|
680
|
+
const output = part.output;
|
|
681
|
+
if (output.type !== "json") {
|
|
682
|
+
warnings.push({
|
|
683
|
+
type: "other",
|
|
684
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
685
|
+
});
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
|
|
689
|
+
anthropicContent.push({
|
|
690
|
+
type: "code_execution_tool_result",
|
|
691
|
+
tool_use_id: part.toolCallId,
|
|
692
|
+
content: {
|
|
693
|
+
type: codeExecutionOutput.type,
|
|
694
|
+
stdout: codeExecutionOutput.stdout,
|
|
695
|
+
stderr: codeExecutionOutput.stderr,
|
|
696
|
+
return_code: codeExecutionOutput.return_code
|
|
697
|
+
},
|
|
698
|
+
cache_control: cacheControl
|
|
699
|
+
});
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
638
702
|
warnings.push({
|
|
639
703
|
type: "other",
|
|
640
704
|
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
@@ -725,36 +789,36 @@ function mapAnthropicStopReason({
|
|
|
725
789
|
|
|
726
790
|
// src/anthropic-messages-language-model.ts
|
|
727
791
|
var citationSchemas = {
|
|
728
|
-
webSearchResult:
|
|
729
|
-
type:
|
|
730
|
-
cited_text:
|
|
731
|
-
url:
|
|
732
|
-
title:
|
|
733
|
-
encrypted_index:
|
|
792
|
+
webSearchResult: z5.object({
|
|
793
|
+
type: z5.literal("web_search_result_location"),
|
|
794
|
+
cited_text: z5.string(),
|
|
795
|
+
url: z5.string(),
|
|
796
|
+
title: z5.string(),
|
|
797
|
+
encrypted_index: z5.string()
|
|
734
798
|
}),
|
|
735
|
-
pageLocation:
|
|
736
|
-
type:
|
|
737
|
-
cited_text:
|
|
738
|
-
document_index:
|
|
739
|
-
document_title:
|
|
740
|
-
start_page_number:
|
|
741
|
-
end_page_number:
|
|
799
|
+
pageLocation: z5.object({
|
|
800
|
+
type: z5.literal("page_location"),
|
|
801
|
+
cited_text: z5.string(),
|
|
802
|
+
document_index: z5.number(),
|
|
803
|
+
document_title: z5.string().nullable(),
|
|
804
|
+
start_page_number: z5.number(),
|
|
805
|
+
end_page_number: z5.number()
|
|
742
806
|
}),
|
|
743
|
-
charLocation:
|
|
744
|
-
type:
|
|
745
|
-
cited_text:
|
|
746
|
-
document_index:
|
|
747
|
-
document_title:
|
|
748
|
-
start_char_index:
|
|
749
|
-
end_char_index:
|
|
807
|
+
charLocation: z5.object({
|
|
808
|
+
type: z5.literal("char_location"),
|
|
809
|
+
cited_text: z5.string(),
|
|
810
|
+
document_index: z5.number(),
|
|
811
|
+
document_title: z5.string().nullable(),
|
|
812
|
+
start_char_index: z5.number(),
|
|
813
|
+
end_char_index: z5.number()
|
|
750
814
|
})
|
|
751
815
|
};
|
|
752
|
-
var citationSchema =
|
|
816
|
+
var citationSchema = z5.discriminatedUnion("type", [
|
|
753
817
|
citationSchemas.webSearchResult,
|
|
754
818
|
citationSchemas.pageLocation,
|
|
755
819
|
citationSchemas.charLocation
|
|
756
820
|
]);
|
|
757
|
-
var documentCitationSchema =
|
|
821
|
+
var documentCitationSchema = z5.discriminatedUnion("type", [
|
|
758
822
|
citationSchemas.pageLocation,
|
|
759
823
|
citationSchemas.charLocation
|
|
760
824
|
]);
|
|
@@ -1079,7 +1143,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1079
1143
|
break;
|
|
1080
1144
|
}
|
|
1081
1145
|
case "server_tool_use": {
|
|
1082
|
-
if (part.name === "web_search") {
|
|
1146
|
+
if (part.name === "web_search" || part.name === "code_execution") {
|
|
1083
1147
|
content.push({
|
|
1084
1148
|
type: "tool-call",
|
|
1085
1149
|
toolCallId: part.id,
|
|
@@ -1137,6 +1201,35 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1137
1201
|
}
|
|
1138
1202
|
break;
|
|
1139
1203
|
}
|
|
1204
|
+
case "code_execution_tool_result": {
|
|
1205
|
+
if (part.content.type === "code_execution_result") {
|
|
1206
|
+
content.push({
|
|
1207
|
+
type: "tool-result",
|
|
1208
|
+
toolCallId: part.tool_use_id,
|
|
1209
|
+
toolName: "code_execution",
|
|
1210
|
+
result: {
|
|
1211
|
+
type: part.content.type,
|
|
1212
|
+
stdout: part.content.stdout,
|
|
1213
|
+
stderr: part.content.stderr,
|
|
1214
|
+
return_code: part.content.return_code
|
|
1215
|
+
},
|
|
1216
|
+
providerExecuted: true
|
|
1217
|
+
});
|
|
1218
|
+
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
1219
|
+
content.push({
|
|
1220
|
+
type: "tool-result",
|
|
1221
|
+
toolCallId: part.tool_use_id,
|
|
1222
|
+
toolName: "code_execution",
|
|
1223
|
+
isError: true,
|
|
1224
|
+
result: {
|
|
1225
|
+
type: "code_execution_tool_result_error",
|
|
1226
|
+
errorCode: part.content.error_code
|
|
1227
|
+
},
|
|
1228
|
+
providerExecuted: true
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
break;
|
|
1232
|
+
}
|
|
1140
1233
|
}
|
|
1141
1234
|
}
|
|
1142
1235
|
return {
|
|
@@ -1262,7 +1355,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1262
1355
|
return;
|
|
1263
1356
|
}
|
|
1264
1357
|
case "server_tool_use": {
|
|
1265
|
-
if (value.content_block.name === "web_search") {
|
|
1358
|
+
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1266
1359
|
contentBlocks[value.index] = {
|
|
1267
1360
|
type: "tool-call",
|
|
1268
1361
|
toolCallId: value.content_block.id,
|
|
@@ -1327,6 +1420,36 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1327
1420
|
}
|
|
1328
1421
|
return;
|
|
1329
1422
|
}
|
|
1423
|
+
case "code_execution_tool_result": {
|
|
1424
|
+
const part = value.content_block;
|
|
1425
|
+
if (part.content.type === "code_execution_result") {
|
|
1426
|
+
controller.enqueue({
|
|
1427
|
+
type: "tool-result",
|
|
1428
|
+
toolCallId: part.tool_use_id,
|
|
1429
|
+
toolName: "code_execution",
|
|
1430
|
+
result: {
|
|
1431
|
+
type: part.content.type,
|
|
1432
|
+
stdout: part.content.stdout,
|
|
1433
|
+
stderr: part.content.stderr,
|
|
1434
|
+
return_code: part.content.return_code
|
|
1435
|
+
},
|
|
1436
|
+
providerExecuted: true
|
|
1437
|
+
});
|
|
1438
|
+
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
1439
|
+
controller.enqueue({
|
|
1440
|
+
type: "tool-result",
|
|
1441
|
+
toolCallId: part.tool_use_id,
|
|
1442
|
+
toolName: "code_execution",
|
|
1443
|
+
isError: true,
|
|
1444
|
+
result: {
|
|
1445
|
+
type: "code_execution_tool_result_error",
|
|
1446
|
+
errorCode: part.content.error_code
|
|
1447
|
+
},
|
|
1448
|
+
providerExecuted: true
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1330
1453
|
default: {
|
|
1331
1454
|
const _exhaustiveCheck = contentBlockType;
|
|
1332
1455
|
throw new Error(
|
|
@@ -1499,215 +1622,247 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1499
1622
|
};
|
|
1500
1623
|
}
|
|
1501
1624
|
};
|
|
1502
|
-
var anthropicMessagesResponseSchema =
|
|
1503
|
-
type:
|
|
1504
|
-
id:
|
|
1505
|
-
model:
|
|
1506
|
-
content:
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
type:
|
|
1510
|
-
text:
|
|
1511
|
-
citations:
|
|
1625
|
+
var anthropicMessagesResponseSchema = z5.object({
|
|
1626
|
+
type: z5.literal("message"),
|
|
1627
|
+
id: z5.string().nullish(),
|
|
1628
|
+
model: z5.string().nullish(),
|
|
1629
|
+
content: z5.array(
|
|
1630
|
+
z5.discriminatedUnion("type", [
|
|
1631
|
+
z5.object({
|
|
1632
|
+
type: z5.literal("text"),
|
|
1633
|
+
text: z5.string(),
|
|
1634
|
+
citations: z5.array(citationSchema).optional()
|
|
1512
1635
|
}),
|
|
1513
|
-
|
|
1514
|
-
type:
|
|
1515
|
-
thinking:
|
|
1516
|
-
signature:
|
|
1636
|
+
z5.object({
|
|
1637
|
+
type: z5.literal("thinking"),
|
|
1638
|
+
thinking: z5.string(),
|
|
1639
|
+
signature: z5.string()
|
|
1517
1640
|
}),
|
|
1518
|
-
|
|
1519
|
-
type:
|
|
1520
|
-
data:
|
|
1641
|
+
z5.object({
|
|
1642
|
+
type: z5.literal("redacted_thinking"),
|
|
1643
|
+
data: z5.string()
|
|
1521
1644
|
}),
|
|
1522
|
-
|
|
1523
|
-
type:
|
|
1524
|
-
id:
|
|
1525
|
-
name:
|
|
1526
|
-
input:
|
|
1645
|
+
z5.object({
|
|
1646
|
+
type: z5.literal("tool_use"),
|
|
1647
|
+
id: z5.string(),
|
|
1648
|
+
name: z5.string(),
|
|
1649
|
+
input: z5.unknown()
|
|
1527
1650
|
}),
|
|
1528
|
-
|
|
1529
|
-
type:
|
|
1530
|
-
id:
|
|
1531
|
-
name:
|
|
1532
|
-
input:
|
|
1651
|
+
z5.object({
|
|
1652
|
+
type: z5.literal("server_tool_use"),
|
|
1653
|
+
id: z5.string(),
|
|
1654
|
+
name: z5.string(),
|
|
1655
|
+
input: z5.record(z5.string(), z5.unknown()).nullish()
|
|
1533
1656
|
}),
|
|
1534
|
-
|
|
1535
|
-
type:
|
|
1536
|
-
tool_use_id:
|
|
1537
|
-
content:
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
type:
|
|
1541
|
-
url:
|
|
1542
|
-
title:
|
|
1543
|
-
encrypted_content:
|
|
1544
|
-
page_age:
|
|
1657
|
+
z5.object({
|
|
1658
|
+
type: z5.literal("web_search_tool_result"),
|
|
1659
|
+
tool_use_id: z5.string(),
|
|
1660
|
+
content: z5.union([
|
|
1661
|
+
z5.array(
|
|
1662
|
+
z5.object({
|
|
1663
|
+
type: z5.literal("web_search_result"),
|
|
1664
|
+
url: z5.string(),
|
|
1665
|
+
title: z5.string(),
|
|
1666
|
+
encrypted_content: z5.string(),
|
|
1667
|
+
page_age: z5.string().nullish()
|
|
1545
1668
|
})
|
|
1546
1669
|
),
|
|
1547
|
-
|
|
1548
|
-
type:
|
|
1549
|
-
error_code:
|
|
1670
|
+
z5.object({
|
|
1671
|
+
type: z5.literal("web_search_tool_result_error"),
|
|
1672
|
+
error_code: z5.string()
|
|
1673
|
+
})
|
|
1674
|
+
])
|
|
1675
|
+
}),
|
|
1676
|
+
z5.object({
|
|
1677
|
+
type: z5.literal("code_execution_tool_result"),
|
|
1678
|
+
tool_use_id: z5.string(),
|
|
1679
|
+
content: z5.union([
|
|
1680
|
+
z5.object({
|
|
1681
|
+
type: z5.literal("code_execution_result"),
|
|
1682
|
+
stdout: z5.string(),
|
|
1683
|
+
stderr: z5.string(),
|
|
1684
|
+
return_code: z5.number()
|
|
1685
|
+
}),
|
|
1686
|
+
z5.object({
|
|
1687
|
+
type: z5.literal("code_execution_tool_result_error"),
|
|
1688
|
+
error_code: z5.string()
|
|
1550
1689
|
})
|
|
1551
1690
|
])
|
|
1552
1691
|
})
|
|
1553
1692
|
])
|
|
1554
1693
|
),
|
|
1555
|
-
stop_reason:
|
|
1556
|
-
usage:
|
|
1557
|
-
input_tokens:
|
|
1558
|
-
output_tokens:
|
|
1559
|
-
cache_creation_input_tokens:
|
|
1560
|
-
cache_read_input_tokens:
|
|
1694
|
+
stop_reason: z5.string().nullish(),
|
|
1695
|
+
usage: z5.looseObject({
|
|
1696
|
+
input_tokens: z5.number(),
|
|
1697
|
+
output_tokens: z5.number(),
|
|
1698
|
+
cache_creation_input_tokens: z5.number().nullish(),
|
|
1699
|
+
cache_read_input_tokens: z5.number().nullish()
|
|
1561
1700
|
})
|
|
1562
1701
|
});
|
|
1563
|
-
var anthropicMessagesChunkSchema =
|
|
1564
|
-
|
|
1565
|
-
type:
|
|
1566
|
-
message:
|
|
1567
|
-
id:
|
|
1568
|
-
model:
|
|
1569
|
-
usage:
|
|
1570
|
-
input_tokens:
|
|
1571
|
-
output_tokens:
|
|
1572
|
-
cache_creation_input_tokens:
|
|
1573
|
-
cache_read_input_tokens:
|
|
1702
|
+
var anthropicMessagesChunkSchema = z5.discriminatedUnion("type", [
|
|
1703
|
+
z5.object({
|
|
1704
|
+
type: z5.literal("message_start"),
|
|
1705
|
+
message: z5.object({
|
|
1706
|
+
id: z5.string().nullish(),
|
|
1707
|
+
model: z5.string().nullish(),
|
|
1708
|
+
usage: z5.looseObject({
|
|
1709
|
+
input_tokens: z5.number(),
|
|
1710
|
+
output_tokens: z5.number(),
|
|
1711
|
+
cache_creation_input_tokens: z5.number().nullish(),
|
|
1712
|
+
cache_read_input_tokens: z5.number().nullish()
|
|
1574
1713
|
})
|
|
1575
1714
|
})
|
|
1576
1715
|
}),
|
|
1577
|
-
|
|
1578
|
-
type:
|
|
1579
|
-
index:
|
|
1580
|
-
content_block:
|
|
1581
|
-
|
|
1582
|
-
type:
|
|
1583
|
-
text:
|
|
1716
|
+
z5.object({
|
|
1717
|
+
type: z5.literal("content_block_start"),
|
|
1718
|
+
index: z5.number(),
|
|
1719
|
+
content_block: z5.discriminatedUnion("type", [
|
|
1720
|
+
z5.object({
|
|
1721
|
+
type: z5.literal("text"),
|
|
1722
|
+
text: z5.string()
|
|
1584
1723
|
}),
|
|
1585
|
-
|
|
1586
|
-
type:
|
|
1587
|
-
thinking:
|
|
1724
|
+
z5.object({
|
|
1725
|
+
type: z5.literal("thinking"),
|
|
1726
|
+
thinking: z5.string()
|
|
1588
1727
|
}),
|
|
1589
|
-
|
|
1590
|
-
type:
|
|
1591
|
-
id:
|
|
1592
|
-
name:
|
|
1728
|
+
z5.object({
|
|
1729
|
+
type: z5.literal("tool_use"),
|
|
1730
|
+
id: z5.string(),
|
|
1731
|
+
name: z5.string()
|
|
1593
1732
|
}),
|
|
1594
|
-
|
|
1595
|
-
type:
|
|
1596
|
-
data:
|
|
1733
|
+
z5.object({
|
|
1734
|
+
type: z5.literal("redacted_thinking"),
|
|
1735
|
+
data: z5.string()
|
|
1597
1736
|
}),
|
|
1598
|
-
|
|
1599
|
-
type:
|
|
1600
|
-
id:
|
|
1601
|
-
name:
|
|
1602
|
-
input:
|
|
1737
|
+
z5.object({
|
|
1738
|
+
type: z5.literal("server_tool_use"),
|
|
1739
|
+
id: z5.string(),
|
|
1740
|
+
name: z5.string(),
|
|
1741
|
+
input: z5.record(z5.string(), z5.unknown()).nullish()
|
|
1603
1742
|
}),
|
|
1604
|
-
|
|
1605
|
-
type:
|
|
1606
|
-
tool_use_id:
|
|
1607
|
-
content:
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
type:
|
|
1611
|
-
url:
|
|
1612
|
-
title:
|
|
1613
|
-
encrypted_content:
|
|
1614
|
-
page_age:
|
|
1743
|
+
z5.object({
|
|
1744
|
+
type: z5.literal("web_search_tool_result"),
|
|
1745
|
+
tool_use_id: z5.string(),
|
|
1746
|
+
content: z5.union([
|
|
1747
|
+
z5.array(
|
|
1748
|
+
z5.object({
|
|
1749
|
+
type: z5.literal("web_search_result"),
|
|
1750
|
+
url: z5.string(),
|
|
1751
|
+
title: z5.string(),
|
|
1752
|
+
encrypted_content: z5.string(),
|
|
1753
|
+
page_age: z5.string().nullish()
|
|
1615
1754
|
})
|
|
1616
1755
|
),
|
|
1617
|
-
|
|
1618
|
-
type:
|
|
1619
|
-
error_code:
|
|
1756
|
+
z5.object({
|
|
1757
|
+
type: z5.literal("web_search_tool_result_error"),
|
|
1758
|
+
error_code: z5.string()
|
|
1759
|
+
})
|
|
1760
|
+
])
|
|
1761
|
+
}),
|
|
1762
|
+
z5.object({
|
|
1763
|
+
type: z5.literal("code_execution_tool_result"),
|
|
1764
|
+
tool_use_id: z5.string(),
|
|
1765
|
+
content: z5.union([
|
|
1766
|
+
z5.object({
|
|
1767
|
+
type: z5.literal("code_execution_result"),
|
|
1768
|
+
stdout: z5.string(),
|
|
1769
|
+
stderr: z5.string(),
|
|
1770
|
+
return_code: z5.number()
|
|
1771
|
+
}),
|
|
1772
|
+
z5.object({
|
|
1773
|
+
type: z5.literal("code_execution_tool_result_error"),
|
|
1774
|
+
error_code: z5.string()
|
|
1620
1775
|
})
|
|
1621
1776
|
])
|
|
1622
1777
|
})
|
|
1623
1778
|
])
|
|
1624
1779
|
}),
|
|
1625
|
-
|
|
1626
|
-
type:
|
|
1627
|
-
index:
|
|
1628
|
-
delta:
|
|
1629
|
-
|
|
1630
|
-
type:
|
|
1631
|
-
partial_json:
|
|
1780
|
+
z5.object({
|
|
1781
|
+
type: z5.literal("content_block_delta"),
|
|
1782
|
+
index: z5.number(),
|
|
1783
|
+
delta: z5.discriminatedUnion("type", [
|
|
1784
|
+
z5.object({
|
|
1785
|
+
type: z5.literal("input_json_delta"),
|
|
1786
|
+
partial_json: z5.string()
|
|
1632
1787
|
}),
|
|
1633
|
-
|
|
1634
|
-
type:
|
|
1635
|
-
text:
|
|
1788
|
+
z5.object({
|
|
1789
|
+
type: z5.literal("text_delta"),
|
|
1790
|
+
text: z5.string()
|
|
1636
1791
|
}),
|
|
1637
|
-
|
|
1638
|
-
type:
|
|
1639
|
-
thinking:
|
|
1792
|
+
z5.object({
|
|
1793
|
+
type: z5.literal("thinking_delta"),
|
|
1794
|
+
thinking: z5.string()
|
|
1640
1795
|
}),
|
|
1641
|
-
|
|
1642
|
-
type:
|
|
1643
|
-
signature:
|
|
1796
|
+
z5.object({
|
|
1797
|
+
type: z5.literal("signature_delta"),
|
|
1798
|
+
signature: z5.string()
|
|
1644
1799
|
}),
|
|
1645
|
-
|
|
1646
|
-
type:
|
|
1800
|
+
z5.object({
|
|
1801
|
+
type: z5.literal("citations_delta"),
|
|
1647
1802
|
citation: citationSchema
|
|
1648
1803
|
})
|
|
1649
1804
|
])
|
|
1650
1805
|
}),
|
|
1651
|
-
|
|
1652
|
-
type:
|
|
1653
|
-
index:
|
|
1806
|
+
z5.object({
|
|
1807
|
+
type: z5.literal("content_block_stop"),
|
|
1808
|
+
index: z5.number()
|
|
1654
1809
|
}),
|
|
1655
|
-
|
|
1656
|
-
type:
|
|
1657
|
-
error:
|
|
1658
|
-
type:
|
|
1659
|
-
message:
|
|
1810
|
+
z5.object({
|
|
1811
|
+
type: z5.literal("error"),
|
|
1812
|
+
error: z5.object({
|
|
1813
|
+
type: z5.string(),
|
|
1814
|
+
message: z5.string()
|
|
1660
1815
|
})
|
|
1661
1816
|
}),
|
|
1662
|
-
|
|
1663
|
-
type:
|
|
1664
|
-
delta:
|
|
1665
|
-
usage:
|
|
1817
|
+
z5.object({
|
|
1818
|
+
type: z5.literal("message_delta"),
|
|
1819
|
+
delta: z5.object({ stop_reason: z5.string().nullish() }),
|
|
1820
|
+
usage: z5.object({ output_tokens: z5.number() })
|
|
1666
1821
|
}),
|
|
1667
|
-
|
|
1668
|
-
type:
|
|
1822
|
+
z5.object({
|
|
1823
|
+
type: z5.literal("message_stop")
|
|
1669
1824
|
}),
|
|
1670
|
-
|
|
1671
|
-
type:
|
|
1825
|
+
z5.object({
|
|
1826
|
+
type: z5.literal("ping")
|
|
1672
1827
|
})
|
|
1673
1828
|
]);
|
|
1674
|
-
var anthropicReasoningMetadataSchema =
|
|
1675
|
-
signature:
|
|
1676
|
-
redactedData:
|
|
1829
|
+
var anthropicReasoningMetadataSchema = z5.object({
|
|
1830
|
+
signature: z5.string().optional(),
|
|
1831
|
+
redactedData: z5.string().optional()
|
|
1677
1832
|
});
|
|
1678
1833
|
|
|
1679
1834
|
// src/tool/bash_20241022.ts
|
|
1680
1835
|
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
1681
|
-
import
|
|
1836
|
+
import z6 from "zod/v4";
|
|
1682
1837
|
var bash_20241022 = createProviderDefinedToolFactory({
|
|
1683
1838
|
id: "anthropic.bash_20241022",
|
|
1684
1839
|
name: "bash",
|
|
1685
|
-
inputSchema:
|
|
1686
|
-
command:
|
|
1687
|
-
restart:
|
|
1840
|
+
inputSchema: z6.object({
|
|
1841
|
+
command: z6.string(),
|
|
1842
|
+
restart: z6.boolean().optional()
|
|
1688
1843
|
})
|
|
1689
1844
|
});
|
|
1690
1845
|
|
|
1691
1846
|
// src/tool/bash_20250124.ts
|
|
1692
1847
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
1693
|
-
import
|
|
1848
|
+
import z7 from "zod/v4";
|
|
1694
1849
|
var bash_20250124 = createProviderDefinedToolFactory2({
|
|
1695
1850
|
id: "anthropic.bash_20250124",
|
|
1696
1851
|
name: "bash",
|
|
1697
|
-
inputSchema:
|
|
1698
|
-
command:
|
|
1699
|
-
restart:
|
|
1852
|
+
inputSchema: z7.object({
|
|
1853
|
+
command: z7.string(),
|
|
1854
|
+
restart: z7.boolean().optional()
|
|
1700
1855
|
})
|
|
1701
1856
|
});
|
|
1702
1857
|
|
|
1703
1858
|
// src/tool/computer_20241022.ts
|
|
1704
1859
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
|
|
1705
|
-
import { z as
|
|
1860
|
+
import { z as z8 } from "zod/v4";
|
|
1706
1861
|
var computer_20241022 = createProviderDefinedToolFactory3({
|
|
1707
1862
|
id: "anthropic.computer_20241022",
|
|
1708
1863
|
name: "computer",
|
|
1709
|
-
inputSchema:
|
|
1710
|
-
action:
|
|
1864
|
+
inputSchema: z8.object({
|
|
1865
|
+
action: z8.enum([
|
|
1711
1866
|
"key",
|
|
1712
1867
|
"type",
|
|
1713
1868
|
"mouse_move",
|
|
@@ -1719,19 +1874,19 @@ var computer_20241022 = createProviderDefinedToolFactory3({
|
|
|
1719
1874
|
"screenshot",
|
|
1720
1875
|
"cursor_position"
|
|
1721
1876
|
]),
|
|
1722
|
-
coordinate:
|
|
1723
|
-
text:
|
|
1877
|
+
coordinate: z8.array(z8.number().int()).optional(),
|
|
1878
|
+
text: z8.string().optional()
|
|
1724
1879
|
})
|
|
1725
1880
|
});
|
|
1726
1881
|
|
|
1727
1882
|
// src/tool/computer_20250124.ts
|
|
1728
1883
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
|
|
1729
|
-
import { z as
|
|
1884
|
+
import { z as z9 } from "zod/v4";
|
|
1730
1885
|
var computer_20250124 = createProviderDefinedToolFactory4({
|
|
1731
1886
|
id: "anthropic.computer_20250124",
|
|
1732
1887
|
name: "computer",
|
|
1733
|
-
inputSchema:
|
|
1734
|
-
action:
|
|
1888
|
+
inputSchema: z9.object({
|
|
1889
|
+
action: z9.enum([
|
|
1735
1890
|
"key",
|
|
1736
1891
|
"hold_key",
|
|
1737
1892
|
"type",
|
|
@@ -1749,38 +1904,21 @@ var computer_20250124 = createProviderDefinedToolFactory4({
|
|
|
1749
1904
|
"wait",
|
|
1750
1905
|
"screenshot"
|
|
1751
1906
|
]),
|
|
1752
|
-
coordinate:
|
|
1753
|
-
duration:
|
|
1754
|
-
scroll_amount:
|
|
1755
|
-
scroll_direction:
|
|
1756
|
-
start_coordinate:
|
|
1757
|
-
text:
|
|
1907
|
+
coordinate: z9.tuple([z9.number().int(), z9.number().int()]).optional(),
|
|
1908
|
+
duration: z9.number().optional(),
|
|
1909
|
+
scroll_amount: z9.number().optional(),
|
|
1910
|
+
scroll_direction: z9.enum(["up", "down", "left", "right"]).optional(),
|
|
1911
|
+
start_coordinate: z9.tuple([z9.number().int(), z9.number().int()]).optional(),
|
|
1912
|
+
text: z9.string().optional()
|
|
1758
1913
|
})
|
|
1759
1914
|
});
|
|
1760
1915
|
|
|
1761
1916
|
// src/tool/text-editor_20241022.ts
|
|
1762
1917
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
1763
|
-
import { z as
|
|
1918
|
+
import { z as z10 } from "zod/v4";
|
|
1764
1919
|
var textEditor_20241022 = createProviderDefinedToolFactory5({
|
|
1765
1920
|
id: "anthropic.text_editor_20241022",
|
|
1766
1921
|
name: "str_replace_editor",
|
|
1767
|
-
inputSchema: z9.object({
|
|
1768
|
-
command: z9.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1769
|
-
path: z9.string(),
|
|
1770
|
-
file_text: z9.string().optional(),
|
|
1771
|
-
insert_line: z9.number().int().optional(),
|
|
1772
|
-
new_str: z9.string().optional(),
|
|
1773
|
-
old_str: z9.string().optional(),
|
|
1774
|
-
view_range: z9.array(z9.number().int()).optional()
|
|
1775
|
-
})
|
|
1776
|
-
});
|
|
1777
|
-
|
|
1778
|
-
// src/tool/text-editor_20250124.ts
|
|
1779
|
-
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
1780
|
-
import { z as z10 } from "zod/v4";
|
|
1781
|
-
var textEditor_20250124 = createProviderDefinedToolFactory6({
|
|
1782
|
-
id: "anthropic.text_editor_20250124",
|
|
1783
|
-
name: "str_replace_editor",
|
|
1784
1922
|
inputSchema: z10.object({
|
|
1785
1923
|
command: z10.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1786
1924
|
path: z10.string(),
|
|
@@ -1792,14 +1930,14 @@ var textEditor_20250124 = createProviderDefinedToolFactory6({
|
|
|
1792
1930
|
})
|
|
1793
1931
|
});
|
|
1794
1932
|
|
|
1795
|
-
// src/tool/text-
|
|
1796
|
-
import { createProviderDefinedToolFactory as
|
|
1933
|
+
// src/tool/text-editor_20250124.ts
|
|
1934
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
1797
1935
|
import { z as z11 } from "zod/v4";
|
|
1798
|
-
var
|
|
1799
|
-
id: "anthropic.
|
|
1800
|
-
name: "
|
|
1936
|
+
var textEditor_20250124 = createProviderDefinedToolFactory6({
|
|
1937
|
+
id: "anthropic.text_editor_20250124",
|
|
1938
|
+
name: "str_replace_editor",
|
|
1801
1939
|
inputSchema: z11.object({
|
|
1802
|
-
command: z11.enum(["view", "create", "str_replace", "insert"]),
|
|
1940
|
+
command: z11.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1803
1941
|
path: z11.string(),
|
|
1804
1942
|
file_text: z11.string().optional(),
|
|
1805
1943
|
insert_line: z11.number().int().optional(),
|
|
@@ -1809,6 +1947,23 @@ var textEditor_20250429 = createProviderDefinedToolFactory7({
|
|
|
1809
1947
|
})
|
|
1810
1948
|
});
|
|
1811
1949
|
|
|
1950
|
+
// src/tool/text-editor_20250429.ts
|
|
1951
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
|
|
1952
|
+
import { z as z12 } from "zod/v4";
|
|
1953
|
+
var textEditor_20250429 = createProviderDefinedToolFactory7({
|
|
1954
|
+
id: "anthropic.text_editor_20250429",
|
|
1955
|
+
name: "str_replace_based_edit_tool",
|
|
1956
|
+
inputSchema: z12.object({
|
|
1957
|
+
command: z12.enum(["view", "create", "str_replace", "insert"]),
|
|
1958
|
+
path: z12.string(),
|
|
1959
|
+
file_text: z12.string().optional(),
|
|
1960
|
+
insert_line: z12.number().int().optional(),
|
|
1961
|
+
new_str: z12.string().optional(),
|
|
1962
|
+
old_str: z12.string().optional(),
|
|
1963
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
1964
|
+
})
|
|
1965
|
+
});
|
|
1966
|
+
|
|
1812
1967
|
// src/anthropic-tools.ts
|
|
1813
1968
|
var anthropicTools = {
|
|
1814
1969
|
/**
|
|
@@ -1870,7 +2025,11 @@ var anthropicTools = {
|
|
|
1870
2025
|
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
1871
2026
|
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
1872
2027
|
*/
|
|
1873
|
-
webSearch_20250305
|
|
2028
|
+
webSearch_20250305,
|
|
2029
|
+
/**
|
|
2030
|
+
* Creates a tool for executing Python code. Must have name "code_execution".
|
|
2031
|
+
*/
|
|
2032
|
+
codeExecution_20250522
|
|
1874
2033
|
};
|
|
1875
2034
|
export {
|
|
1876
2035
|
AnthropicMessagesLanguageModel,
|