@ai-sdk/anthropic 2.0.3 → 2.0.4
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 +6 -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 +1 -1
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
postJsonToApi,
|
|
22
22
|
resolve
|
|
23
23
|
} from "@ai-sdk/provider-utils";
|
|
24
|
-
import { z as
|
|
24
|
+
import { z as z5 } from "zod/v4";
|
|
25
25
|
|
|
26
26
|
// src/anthropic-error.ts
|
|
27
27
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
@@ -237,6 +237,14 @@ function prepareTools({
|
|
|
237
237
|
});
|
|
238
238
|
break;
|
|
239
239
|
}
|
|
240
|
+
case "anthropic.code_execution_20250522": {
|
|
241
|
+
betas.add("code-execution-2025-05-22");
|
|
242
|
+
anthropicTools2.push({
|
|
243
|
+
type: "code_execution_20250522",
|
|
244
|
+
name: "code_execution"
|
|
245
|
+
});
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
240
248
|
default:
|
|
241
249
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
242
250
|
break;
|
|
@@ -304,6 +312,29 @@ import {
|
|
|
304
312
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
305
313
|
} from "@ai-sdk/provider";
|
|
306
314
|
import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
315
|
+
|
|
316
|
+
// src/tool/code-execution_20250522.ts
|
|
317
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
|
|
318
|
+
import { z as z4 } from "zod/v4";
|
|
319
|
+
var codeExecution_20250522OutputSchema = z4.object({
|
|
320
|
+
type: z4.literal("code_execution_result"),
|
|
321
|
+
stdout: z4.string(),
|
|
322
|
+
stderr: z4.string(),
|
|
323
|
+
return_code: z4.number()
|
|
324
|
+
});
|
|
325
|
+
var factory2 = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
326
|
+
id: "anthropic.code_execution_20250522",
|
|
327
|
+
name: "code_execution",
|
|
328
|
+
inputSchema: z4.object({
|
|
329
|
+
code: z4.string()
|
|
330
|
+
}),
|
|
331
|
+
outputSchema: codeExecution_20250522OutputSchema
|
|
332
|
+
});
|
|
333
|
+
var codeExecution_20250522 = (args = {}) => {
|
|
334
|
+
return factory2(args);
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// src/convert-to-anthropic-messages-prompt.ts
|
|
307
338
|
function convertToString(data) {
|
|
308
339
|
if (typeof data === "string") {
|
|
309
340
|
return Buffer.from(data, "base64").toString("utf-8");
|
|
@@ -603,6 +634,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
603
634
|
});
|
|
604
635
|
break;
|
|
605
636
|
}
|
|
637
|
+
if (part.toolName === "code_execution") {
|
|
638
|
+
anthropicContent.push({
|
|
639
|
+
type: "server_tool_use",
|
|
640
|
+
id: part.toolCallId,
|
|
641
|
+
name: "code_execution",
|
|
642
|
+
input: part.input,
|
|
643
|
+
cache_control: cacheControl
|
|
644
|
+
});
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
606
647
|
warnings.push({
|
|
607
648
|
type: "other",
|
|
608
649
|
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
@@ -645,6 +686,29 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
645
686
|
});
|
|
646
687
|
break;
|
|
647
688
|
}
|
|
689
|
+
if (part.toolName === "code_execution") {
|
|
690
|
+
const output = part.output;
|
|
691
|
+
if (output.type !== "json") {
|
|
692
|
+
warnings.push({
|
|
693
|
+
type: "other",
|
|
694
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
695
|
+
});
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
|
|
699
|
+
anthropicContent.push({
|
|
700
|
+
type: "code_execution_tool_result",
|
|
701
|
+
tool_use_id: part.toolCallId,
|
|
702
|
+
content: {
|
|
703
|
+
type: codeExecutionOutput.type,
|
|
704
|
+
stdout: codeExecutionOutput.stdout,
|
|
705
|
+
stderr: codeExecutionOutput.stderr,
|
|
706
|
+
return_code: codeExecutionOutput.return_code
|
|
707
|
+
},
|
|
708
|
+
cache_control: cacheControl
|
|
709
|
+
});
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
648
712
|
warnings.push({
|
|
649
713
|
type: "other",
|
|
650
714
|
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
@@ -735,36 +799,36 @@ function mapAnthropicStopReason({
|
|
|
735
799
|
|
|
736
800
|
// src/anthropic-messages-language-model.ts
|
|
737
801
|
var citationSchemas = {
|
|
738
|
-
webSearchResult:
|
|
739
|
-
type:
|
|
740
|
-
cited_text:
|
|
741
|
-
url:
|
|
742
|
-
title:
|
|
743
|
-
encrypted_index:
|
|
802
|
+
webSearchResult: z5.object({
|
|
803
|
+
type: z5.literal("web_search_result_location"),
|
|
804
|
+
cited_text: z5.string(),
|
|
805
|
+
url: z5.string(),
|
|
806
|
+
title: z5.string(),
|
|
807
|
+
encrypted_index: z5.string()
|
|
744
808
|
}),
|
|
745
|
-
pageLocation:
|
|
746
|
-
type:
|
|
747
|
-
cited_text:
|
|
748
|
-
document_index:
|
|
749
|
-
document_title:
|
|
750
|
-
start_page_number:
|
|
751
|
-
end_page_number:
|
|
809
|
+
pageLocation: z5.object({
|
|
810
|
+
type: z5.literal("page_location"),
|
|
811
|
+
cited_text: z5.string(),
|
|
812
|
+
document_index: z5.number(),
|
|
813
|
+
document_title: z5.string().nullable(),
|
|
814
|
+
start_page_number: z5.number(),
|
|
815
|
+
end_page_number: z5.number()
|
|
752
816
|
}),
|
|
753
|
-
charLocation:
|
|
754
|
-
type:
|
|
755
|
-
cited_text:
|
|
756
|
-
document_index:
|
|
757
|
-
document_title:
|
|
758
|
-
start_char_index:
|
|
759
|
-
end_char_index:
|
|
817
|
+
charLocation: z5.object({
|
|
818
|
+
type: z5.literal("char_location"),
|
|
819
|
+
cited_text: z5.string(),
|
|
820
|
+
document_index: z5.number(),
|
|
821
|
+
document_title: z5.string().nullable(),
|
|
822
|
+
start_char_index: z5.number(),
|
|
823
|
+
end_char_index: z5.number()
|
|
760
824
|
})
|
|
761
825
|
};
|
|
762
|
-
var citationSchema =
|
|
826
|
+
var citationSchema = z5.discriminatedUnion("type", [
|
|
763
827
|
citationSchemas.webSearchResult,
|
|
764
828
|
citationSchemas.pageLocation,
|
|
765
829
|
citationSchemas.charLocation
|
|
766
830
|
]);
|
|
767
|
-
var documentCitationSchema =
|
|
831
|
+
var documentCitationSchema = z5.discriminatedUnion("type", [
|
|
768
832
|
citationSchemas.pageLocation,
|
|
769
833
|
citationSchemas.charLocation
|
|
770
834
|
]);
|
|
@@ -1089,7 +1153,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1089
1153
|
break;
|
|
1090
1154
|
}
|
|
1091
1155
|
case "server_tool_use": {
|
|
1092
|
-
if (part.name === "web_search") {
|
|
1156
|
+
if (part.name === "web_search" || part.name === "code_execution") {
|
|
1093
1157
|
content.push({
|
|
1094
1158
|
type: "tool-call",
|
|
1095
1159
|
toolCallId: part.id,
|
|
@@ -1147,6 +1211,35 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1147
1211
|
}
|
|
1148
1212
|
break;
|
|
1149
1213
|
}
|
|
1214
|
+
case "code_execution_tool_result": {
|
|
1215
|
+
if (part.content.type === "code_execution_result") {
|
|
1216
|
+
content.push({
|
|
1217
|
+
type: "tool-result",
|
|
1218
|
+
toolCallId: part.tool_use_id,
|
|
1219
|
+
toolName: "code_execution",
|
|
1220
|
+
result: {
|
|
1221
|
+
type: part.content.type,
|
|
1222
|
+
stdout: part.content.stdout,
|
|
1223
|
+
stderr: part.content.stderr,
|
|
1224
|
+
return_code: part.content.return_code
|
|
1225
|
+
},
|
|
1226
|
+
providerExecuted: true
|
|
1227
|
+
});
|
|
1228
|
+
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
1229
|
+
content.push({
|
|
1230
|
+
type: "tool-result",
|
|
1231
|
+
toolCallId: part.tool_use_id,
|
|
1232
|
+
toolName: "code_execution",
|
|
1233
|
+
isError: true,
|
|
1234
|
+
result: {
|
|
1235
|
+
type: "code_execution_tool_result_error",
|
|
1236
|
+
errorCode: part.content.error_code
|
|
1237
|
+
},
|
|
1238
|
+
providerExecuted: true
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
break;
|
|
1242
|
+
}
|
|
1150
1243
|
}
|
|
1151
1244
|
}
|
|
1152
1245
|
return {
|
|
@@ -1272,7 +1365,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1272
1365
|
return;
|
|
1273
1366
|
}
|
|
1274
1367
|
case "server_tool_use": {
|
|
1275
|
-
if (value.content_block.name === "web_search") {
|
|
1368
|
+
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1276
1369
|
contentBlocks[value.index] = {
|
|
1277
1370
|
type: "tool-call",
|
|
1278
1371
|
toolCallId: value.content_block.id,
|
|
@@ -1337,6 +1430,36 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1337
1430
|
}
|
|
1338
1431
|
return;
|
|
1339
1432
|
}
|
|
1433
|
+
case "code_execution_tool_result": {
|
|
1434
|
+
const part = value.content_block;
|
|
1435
|
+
if (part.content.type === "code_execution_result") {
|
|
1436
|
+
controller.enqueue({
|
|
1437
|
+
type: "tool-result",
|
|
1438
|
+
toolCallId: part.tool_use_id,
|
|
1439
|
+
toolName: "code_execution",
|
|
1440
|
+
result: {
|
|
1441
|
+
type: part.content.type,
|
|
1442
|
+
stdout: part.content.stdout,
|
|
1443
|
+
stderr: part.content.stderr,
|
|
1444
|
+
return_code: part.content.return_code
|
|
1445
|
+
},
|
|
1446
|
+
providerExecuted: true
|
|
1447
|
+
});
|
|
1448
|
+
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
1449
|
+
controller.enqueue({
|
|
1450
|
+
type: "tool-result",
|
|
1451
|
+
toolCallId: part.tool_use_id,
|
|
1452
|
+
toolName: "code_execution",
|
|
1453
|
+
isError: true,
|
|
1454
|
+
result: {
|
|
1455
|
+
type: "code_execution_tool_result_error",
|
|
1456
|
+
errorCode: part.content.error_code
|
|
1457
|
+
},
|
|
1458
|
+
providerExecuted: true
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1340
1463
|
default: {
|
|
1341
1464
|
const _exhaustiveCheck = contentBlockType;
|
|
1342
1465
|
throw new Error(
|
|
@@ -1509,215 +1632,247 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1509
1632
|
};
|
|
1510
1633
|
}
|
|
1511
1634
|
};
|
|
1512
|
-
var anthropicMessagesResponseSchema =
|
|
1513
|
-
type:
|
|
1514
|
-
id:
|
|
1515
|
-
model:
|
|
1516
|
-
content:
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
type:
|
|
1520
|
-
text:
|
|
1521
|
-
citations:
|
|
1635
|
+
var anthropicMessagesResponseSchema = z5.object({
|
|
1636
|
+
type: z5.literal("message"),
|
|
1637
|
+
id: z5.string().nullish(),
|
|
1638
|
+
model: z5.string().nullish(),
|
|
1639
|
+
content: z5.array(
|
|
1640
|
+
z5.discriminatedUnion("type", [
|
|
1641
|
+
z5.object({
|
|
1642
|
+
type: z5.literal("text"),
|
|
1643
|
+
text: z5.string(),
|
|
1644
|
+
citations: z5.array(citationSchema).optional()
|
|
1522
1645
|
}),
|
|
1523
|
-
|
|
1524
|
-
type:
|
|
1525
|
-
thinking:
|
|
1526
|
-
signature:
|
|
1646
|
+
z5.object({
|
|
1647
|
+
type: z5.literal("thinking"),
|
|
1648
|
+
thinking: z5.string(),
|
|
1649
|
+
signature: z5.string()
|
|
1527
1650
|
}),
|
|
1528
|
-
|
|
1529
|
-
type:
|
|
1530
|
-
data:
|
|
1651
|
+
z5.object({
|
|
1652
|
+
type: z5.literal("redacted_thinking"),
|
|
1653
|
+
data: z5.string()
|
|
1531
1654
|
}),
|
|
1532
|
-
|
|
1533
|
-
type:
|
|
1534
|
-
id:
|
|
1535
|
-
name:
|
|
1536
|
-
input:
|
|
1655
|
+
z5.object({
|
|
1656
|
+
type: z5.literal("tool_use"),
|
|
1657
|
+
id: z5.string(),
|
|
1658
|
+
name: z5.string(),
|
|
1659
|
+
input: z5.unknown()
|
|
1537
1660
|
}),
|
|
1538
|
-
|
|
1539
|
-
type:
|
|
1540
|
-
id:
|
|
1541
|
-
name:
|
|
1542
|
-
input:
|
|
1661
|
+
z5.object({
|
|
1662
|
+
type: z5.literal("server_tool_use"),
|
|
1663
|
+
id: z5.string(),
|
|
1664
|
+
name: z5.string(),
|
|
1665
|
+
input: z5.record(z5.string(), z5.unknown()).nullish()
|
|
1543
1666
|
}),
|
|
1544
|
-
|
|
1545
|
-
type:
|
|
1546
|
-
tool_use_id:
|
|
1547
|
-
content:
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
type:
|
|
1551
|
-
url:
|
|
1552
|
-
title:
|
|
1553
|
-
encrypted_content:
|
|
1554
|
-
page_age:
|
|
1667
|
+
z5.object({
|
|
1668
|
+
type: z5.literal("web_search_tool_result"),
|
|
1669
|
+
tool_use_id: z5.string(),
|
|
1670
|
+
content: z5.union([
|
|
1671
|
+
z5.array(
|
|
1672
|
+
z5.object({
|
|
1673
|
+
type: z5.literal("web_search_result"),
|
|
1674
|
+
url: z5.string(),
|
|
1675
|
+
title: z5.string(),
|
|
1676
|
+
encrypted_content: z5.string(),
|
|
1677
|
+
page_age: z5.string().nullish()
|
|
1555
1678
|
})
|
|
1556
1679
|
),
|
|
1557
|
-
|
|
1558
|
-
type:
|
|
1559
|
-
error_code:
|
|
1680
|
+
z5.object({
|
|
1681
|
+
type: z5.literal("web_search_tool_result_error"),
|
|
1682
|
+
error_code: z5.string()
|
|
1683
|
+
})
|
|
1684
|
+
])
|
|
1685
|
+
}),
|
|
1686
|
+
z5.object({
|
|
1687
|
+
type: z5.literal("code_execution_tool_result"),
|
|
1688
|
+
tool_use_id: z5.string(),
|
|
1689
|
+
content: z5.union([
|
|
1690
|
+
z5.object({
|
|
1691
|
+
type: z5.literal("code_execution_result"),
|
|
1692
|
+
stdout: z5.string(),
|
|
1693
|
+
stderr: z5.string(),
|
|
1694
|
+
return_code: z5.number()
|
|
1695
|
+
}),
|
|
1696
|
+
z5.object({
|
|
1697
|
+
type: z5.literal("code_execution_tool_result_error"),
|
|
1698
|
+
error_code: z5.string()
|
|
1560
1699
|
})
|
|
1561
1700
|
])
|
|
1562
1701
|
})
|
|
1563
1702
|
])
|
|
1564
1703
|
),
|
|
1565
|
-
stop_reason:
|
|
1566
|
-
usage:
|
|
1567
|
-
input_tokens:
|
|
1568
|
-
output_tokens:
|
|
1569
|
-
cache_creation_input_tokens:
|
|
1570
|
-
cache_read_input_tokens:
|
|
1704
|
+
stop_reason: z5.string().nullish(),
|
|
1705
|
+
usage: z5.looseObject({
|
|
1706
|
+
input_tokens: z5.number(),
|
|
1707
|
+
output_tokens: z5.number(),
|
|
1708
|
+
cache_creation_input_tokens: z5.number().nullish(),
|
|
1709
|
+
cache_read_input_tokens: z5.number().nullish()
|
|
1571
1710
|
})
|
|
1572
1711
|
});
|
|
1573
|
-
var anthropicMessagesChunkSchema =
|
|
1574
|
-
|
|
1575
|
-
type:
|
|
1576
|
-
message:
|
|
1577
|
-
id:
|
|
1578
|
-
model:
|
|
1579
|
-
usage:
|
|
1580
|
-
input_tokens:
|
|
1581
|
-
output_tokens:
|
|
1582
|
-
cache_creation_input_tokens:
|
|
1583
|
-
cache_read_input_tokens:
|
|
1712
|
+
var anthropicMessagesChunkSchema = z5.discriminatedUnion("type", [
|
|
1713
|
+
z5.object({
|
|
1714
|
+
type: z5.literal("message_start"),
|
|
1715
|
+
message: z5.object({
|
|
1716
|
+
id: z5.string().nullish(),
|
|
1717
|
+
model: z5.string().nullish(),
|
|
1718
|
+
usage: z5.looseObject({
|
|
1719
|
+
input_tokens: z5.number(),
|
|
1720
|
+
output_tokens: z5.number(),
|
|
1721
|
+
cache_creation_input_tokens: z5.number().nullish(),
|
|
1722
|
+
cache_read_input_tokens: z5.number().nullish()
|
|
1584
1723
|
})
|
|
1585
1724
|
})
|
|
1586
1725
|
}),
|
|
1587
|
-
|
|
1588
|
-
type:
|
|
1589
|
-
index:
|
|
1590
|
-
content_block:
|
|
1591
|
-
|
|
1592
|
-
type:
|
|
1593
|
-
text:
|
|
1726
|
+
z5.object({
|
|
1727
|
+
type: z5.literal("content_block_start"),
|
|
1728
|
+
index: z5.number(),
|
|
1729
|
+
content_block: z5.discriminatedUnion("type", [
|
|
1730
|
+
z5.object({
|
|
1731
|
+
type: z5.literal("text"),
|
|
1732
|
+
text: z5.string()
|
|
1594
1733
|
}),
|
|
1595
|
-
|
|
1596
|
-
type:
|
|
1597
|
-
thinking:
|
|
1734
|
+
z5.object({
|
|
1735
|
+
type: z5.literal("thinking"),
|
|
1736
|
+
thinking: z5.string()
|
|
1598
1737
|
}),
|
|
1599
|
-
|
|
1600
|
-
type:
|
|
1601
|
-
id:
|
|
1602
|
-
name:
|
|
1738
|
+
z5.object({
|
|
1739
|
+
type: z5.literal("tool_use"),
|
|
1740
|
+
id: z5.string(),
|
|
1741
|
+
name: z5.string()
|
|
1603
1742
|
}),
|
|
1604
|
-
|
|
1605
|
-
type:
|
|
1606
|
-
data:
|
|
1743
|
+
z5.object({
|
|
1744
|
+
type: z5.literal("redacted_thinking"),
|
|
1745
|
+
data: z5.string()
|
|
1607
1746
|
}),
|
|
1608
|
-
|
|
1609
|
-
type:
|
|
1610
|
-
id:
|
|
1611
|
-
name:
|
|
1612
|
-
input:
|
|
1747
|
+
z5.object({
|
|
1748
|
+
type: z5.literal("server_tool_use"),
|
|
1749
|
+
id: z5.string(),
|
|
1750
|
+
name: z5.string(),
|
|
1751
|
+
input: z5.record(z5.string(), z5.unknown()).nullish()
|
|
1613
1752
|
}),
|
|
1614
|
-
|
|
1615
|
-
type:
|
|
1616
|
-
tool_use_id:
|
|
1617
|
-
content:
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
type:
|
|
1621
|
-
url:
|
|
1622
|
-
title:
|
|
1623
|
-
encrypted_content:
|
|
1624
|
-
page_age:
|
|
1753
|
+
z5.object({
|
|
1754
|
+
type: z5.literal("web_search_tool_result"),
|
|
1755
|
+
tool_use_id: z5.string(),
|
|
1756
|
+
content: z5.union([
|
|
1757
|
+
z5.array(
|
|
1758
|
+
z5.object({
|
|
1759
|
+
type: z5.literal("web_search_result"),
|
|
1760
|
+
url: z5.string(),
|
|
1761
|
+
title: z5.string(),
|
|
1762
|
+
encrypted_content: z5.string(),
|
|
1763
|
+
page_age: z5.string().nullish()
|
|
1625
1764
|
})
|
|
1626
1765
|
),
|
|
1627
|
-
|
|
1628
|
-
type:
|
|
1629
|
-
error_code:
|
|
1766
|
+
z5.object({
|
|
1767
|
+
type: z5.literal("web_search_tool_result_error"),
|
|
1768
|
+
error_code: z5.string()
|
|
1769
|
+
})
|
|
1770
|
+
])
|
|
1771
|
+
}),
|
|
1772
|
+
z5.object({
|
|
1773
|
+
type: z5.literal("code_execution_tool_result"),
|
|
1774
|
+
tool_use_id: z5.string(),
|
|
1775
|
+
content: z5.union([
|
|
1776
|
+
z5.object({
|
|
1777
|
+
type: z5.literal("code_execution_result"),
|
|
1778
|
+
stdout: z5.string(),
|
|
1779
|
+
stderr: z5.string(),
|
|
1780
|
+
return_code: z5.number()
|
|
1781
|
+
}),
|
|
1782
|
+
z5.object({
|
|
1783
|
+
type: z5.literal("code_execution_tool_result_error"),
|
|
1784
|
+
error_code: z5.string()
|
|
1630
1785
|
})
|
|
1631
1786
|
])
|
|
1632
1787
|
})
|
|
1633
1788
|
])
|
|
1634
1789
|
}),
|
|
1635
|
-
|
|
1636
|
-
type:
|
|
1637
|
-
index:
|
|
1638
|
-
delta:
|
|
1639
|
-
|
|
1640
|
-
type:
|
|
1641
|
-
partial_json:
|
|
1790
|
+
z5.object({
|
|
1791
|
+
type: z5.literal("content_block_delta"),
|
|
1792
|
+
index: z5.number(),
|
|
1793
|
+
delta: z5.discriminatedUnion("type", [
|
|
1794
|
+
z5.object({
|
|
1795
|
+
type: z5.literal("input_json_delta"),
|
|
1796
|
+
partial_json: z5.string()
|
|
1642
1797
|
}),
|
|
1643
|
-
|
|
1644
|
-
type:
|
|
1645
|
-
text:
|
|
1798
|
+
z5.object({
|
|
1799
|
+
type: z5.literal("text_delta"),
|
|
1800
|
+
text: z5.string()
|
|
1646
1801
|
}),
|
|
1647
|
-
|
|
1648
|
-
type:
|
|
1649
|
-
thinking:
|
|
1802
|
+
z5.object({
|
|
1803
|
+
type: z5.literal("thinking_delta"),
|
|
1804
|
+
thinking: z5.string()
|
|
1650
1805
|
}),
|
|
1651
|
-
|
|
1652
|
-
type:
|
|
1653
|
-
signature:
|
|
1806
|
+
z5.object({
|
|
1807
|
+
type: z5.literal("signature_delta"),
|
|
1808
|
+
signature: z5.string()
|
|
1654
1809
|
}),
|
|
1655
|
-
|
|
1656
|
-
type:
|
|
1810
|
+
z5.object({
|
|
1811
|
+
type: z5.literal("citations_delta"),
|
|
1657
1812
|
citation: citationSchema
|
|
1658
1813
|
})
|
|
1659
1814
|
])
|
|
1660
1815
|
}),
|
|
1661
|
-
|
|
1662
|
-
type:
|
|
1663
|
-
index:
|
|
1816
|
+
z5.object({
|
|
1817
|
+
type: z5.literal("content_block_stop"),
|
|
1818
|
+
index: z5.number()
|
|
1664
1819
|
}),
|
|
1665
|
-
|
|
1666
|
-
type:
|
|
1667
|
-
error:
|
|
1668
|
-
type:
|
|
1669
|
-
message:
|
|
1820
|
+
z5.object({
|
|
1821
|
+
type: z5.literal("error"),
|
|
1822
|
+
error: z5.object({
|
|
1823
|
+
type: z5.string(),
|
|
1824
|
+
message: z5.string()
|
|
1670
1825
|
})
|
|
1671
1826
|
}),
|
|
1672
|
-
|
|
1673
|
-
type:
|
|
1674
|
-
delta:
|
|
1675
|
-
usage:
|
|
1827
|
+
z5.object({
|
|
1828
|
+
type: z5.literal("message_delta"),
|
|
1829
|
+
delta: z5.object({ stop_reason: z5.string().nullish() }),
|
|
1830
|
+
usage: z5.object({ output_tokens: z5.number() })
|
|
1676
1831
|
}),
|
|
1677
|
-
|
|
1678
|
-
type:
|
|
1832
|
+
z5.object({
|
|
1833
|
+
type: z5.literal("message_stop")
|
|
1679
1834
|
}),
|
|
1680
|
-
|
|
1681
|
-
type:
|
|
1835
|
+
z5.object({
|
|
1836
|
+
type: z5.literal("ping")
|
|
1682
1837
|
})
|
|
1683
1838
|
]);
|
|
1684
|
-
var anthropicReasoningMetadataSchema =
|
|
1685
|
-
signature:
|
|
1686
|
-
redactedData:
|
|
1839
|
+
var anthropicReasoningMetadataSchema = z5.object({
|
|
1840
|
+
signature: z5.string().optional(),
|
|
1841
|
+
redactedData: z5.string().optional()
|
|
1687
1842
|
});
|
|
1688
1843
|
|
|
1689
1844
|
// src/tool/bash_20241022.ts
|
|
1690
1845
|
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
1691
|
-
import
|
|
1846
|
+
import z6 from "zod/v4";
|
|
1692
1847
|
var bash_20241022 = createProviderDefinedToolFactory({
|
|
1693
1848
|
id: "anthropic.bash_20241022",
|
|
1694
1849
|
name: "bash",
|
|
1695
|
-
inputSchema:
|
|
1696
|
-
command:
|
|
1697
|
-
restart:
|
|
1850
|
+
inputSchema: z6.object({
|
|
1851
|
+
command: z6.string(),
|
|
1852
|
+
restart: z6.boolean().optional()
|
|
1698
1853
|
})
|
|
1699
1854
|
});
|
|
1700
1855
|
|
|
1701
1856
|
// src/tool/bash_20250124.ts
|
|
1702
1857
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
1703
|
-
import
|
|
1858
|
+
import z7 from "zod/v4";
|
|
1704
1859
|
var bash_20250124 = createProviderDefinedToolFactory2({
|
|
1705
1860
|
id: "anthropic.bash_20250124",
|
|
1706
1861
|
name: "bash",
|
|
1707
|
-
inputSchema:
|
|
1708
|
-
command:
|
|
1709
|
-
restart:
|
|
1862
|
+
inputSchema: z7.object({
|
|
1863
|
+
command: z7.string(),
|
|
1864
|
+
restart: z7.boolean().optional()
|
|
1710
1865
|
})
|
|
1711
1866
|
});
|
|
1712
1867
|
|
|
1713
1868
|
// src/tool/computer_20241022.ts
|
|
1714
1869
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
|
|
1715
|
-
import { z as
|
|
1870
|
+
import { z as z8 } from "zod/v4";
|
|
1716
1871
|
var computer_20241022 = createProviderDefinedToolFactory3({
|
|
1717
1872
|
id: "anthropic.computer_20241022",
|
|
1718
1873
|
name: "computer",
|
|
1719
|
-
inputSchema:
|
|
1720
|
-
action:
|
|
1874
|
+
inputSchema: z8.object({
|
|
1875
|
+
action: z8.enum([
|
|
1721
1876
|
"key",
|
|
1722
1877
|
"type",
|
|
1723
1878
|
"mouse_move",
|
|
@@ -1729,19 +1884,19 @@ var computer_20241022 = createProviderDefinedToolFactory3({
|
|
|
1729
1884
|
"screenshot",
|
|
1730
1885
|
"cursor_position"
|
|
1731
1886
|
]),
|
|
1732
|
-
coordinate:
|
|
1733
|
-
text:
|
|
1887
|
+
coordinate: z8.array(z8.number().int()).optional(),
|
|
1888
|
+
text: z8.string().optional()
|
|
1734
1889
|
})
|
|
1735
1890
|
});
|
|
1736
1891
|
|
|
1737
1892
|
// src/tool/computer_20250124.ts
|
|
1738
1893
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
|
|
1739
|
-
import { z as
|
|
1894
|
+
import { z as z9 } from "zod/v4";
|
|
1740
1895
|
var computer_20250124 = createProviderDefinedToolFactory4({
|
|
1741
1896
|
id: "anthropic.computer_20250124",
|
|
1742
1897
|
name: "computer",
|
|
1743
|
-
inputSchema:
|
|
1744
|
-
action:
|
|
1898
|
+
inputSchema: z9.object({
|
|
1899
|
+
action: z9.enum([
|
|
1745
1900
|
"key",
|
|
1746
1901
|
"hold_key",
|
|
1747
1902
|
"type",
|
|
@@ -1759,38 +1914,21 @@ var computer_20250124 = createProviderDefinedToolFactory4({
|
|
|
1759
1914
|
"wait",
|
|
1760
1915
|
"screenshot"
|
|
1761
1916
|
]),
|
|
1762
|
-
coordinate:
|
|
1763
|
-
duration:
|
|
1764
|
-
scroll_amount:
|
|
1765
|
-
scroll_direction:
|
|
1766
|
-
start_coordinate:
|
|
1767
|
-
text:
|
|
1917
|
+
coordinate: z9.tuple([z9.number().int(), z9.number().int()]).optional(),
|
|
1918
|
+
duration: z9.number().optional(),
|
|
1919
|
+
scroll_amount: z9.number().optional(),
|
|
1920
|
+
scroll_direction: z9.enum(["up", "down", "left", "right"]).optional(),
|
|
1921
|
+
start_coordinate: z9.tuple([z9.number().int(), z9.number().int()]).optional(),
|
|
1922
|
+
text: z9.string().optional()
|
|
1768
1923
|
})
|
|
1769
1924
|
});
|
|
1770
1925
|
|
|
1771
1926
|
// src/tool/text-editor_20241022.ts
|
|
1772
1927
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
1773
|
-
import { z as
|
|
1928
|
+
import { z as z10 } from "zod/v4";
|
|
1774
1929
|
var textEditor_20241022 = createProviderDefinedToolFactory5({
|
|
1775
1930
|
id: "anthropic.text_editor_20241022",
|
|
1776
1931
|
name: "str_replace_editor",
|
|
1777
|
-
inputSchema: z9.object({
|
|
1778
|
-
command: z9.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1779
|
-
path: z9.string(),
|
|
1780
|
-
file_text: z9.string().optional(),
|
|
1781
|
-
insert_line: z9.number().int().optional(),
|
|
1782
|
-
new_str: z9.string().optional(),
|
|
1783
|
-
old_str: z9.string().optional(),
|
|
1784
|
-
view_range: z9.array(z9.number().int()).optional()
|
|
1785
|
-
})
|
|
1786
|
-
});
|
|
1787
|
-
|
|
1788
|
-
// src/tool/text-editor_20250124.ts
|
|
1789
|
-
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
1790
|
-
import { z as z10 } from "zod/v4";
|
|
1791
|
-
var textEditor_20250124 = createProviderDefinedToolFactory6({
|
|
1792
|
-
id: "anthropic.text_editor_20250124",
|
|
1793
|
-
name: "str_replace_editor",
|
|
1794
1932
|
inputSchema: z10.object({
|
|
1795
1933
|
command: z10.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1796
1934
|
path: z10.string(),
|
|
@@ -1802,14 +1940,14 @@ var textEditor_20250124 = createProviderDefinedToolFactory6({
|
|
|
1802
1940
|
})
|
|
1803
1941
|
});
|
|
1804
1942
|
|
|
1805
|
-
// src/tool/text-
|
|
1806
|
-
import { createProviderDefinedToolFactory as
|
|
1943
|
+
// src/tool/text-editor_20250124.ts
|
|
1944
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
1807
1945
|
import { z as z11 } from "zod/v4";
|
|
1808
|
-
var
|
|
1809
|
-
id: "anthropic.
|
|
1810
|
-
name: "
|
|
1946
|
+
var textEditor_20250124 = createProviderDefinedToolFactory6({
|
|
1947
|
+
id: "anthropic.text_editor_20250124",
|
|
1948
|
+
name: "str_replace_editor",
|
|
1811
1949
|
inputSchema: z11.object({
|
|
1812
|
-
command: z11.enum(["view", "create", "str_replace", "insert"]),
|
|
1950
|
+
command: z11.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1813
1951
|
path: z11.string(),
|
|
1814
1952
|
file_text: z11.string().optional(),
|
|
1815
1953
|
insert_line: z11.number().int().optional(),
|
|
@@ -1819,6 +1957,23 @@ var textEditor_20250429 = createProviderDefinedToolFactory7({
|
|
|
1819
1957
|
})
|
|
1820
1958
|
});
|
|
1821
1959
|
|
|
1960
|
+
// src/tool/text-editor_20250429.ts
|
|
1961
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
|
|
1962
|
+
import { z as z12 } from "zod/v4";
|
|
1963
|
+
var textEditor_20250429 = createProviderDefinedToolFactory7({
|
|
1964
|
+
id: "anthropic.text_editor_20250429",
|
|
1965
|
+
name: "str_replace_based_edit_tool",
|
|
1966
|
+
inputSchema: z12.object({
|
|
1967
|
+
command: z12.enum(["view", "create", "str_replace", "insert"]),
|
|
1968
|
+
path: z12.string(),
|
|
1969
|
+
file_text: z12.string().optional(),
|
|
1970
|
+
insert_line: z12.number().int().optional(),
|
|
1971
|
+
new_str: z12.string().optional(),
|
|
1972
|
+
old_str: z12.string().optional(),
|
|
1973
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
1974
|
+
})
|
|
1975
|
+
});
|
|
1976
|
+
|
|
1822
1977
|
// src/anthropic-tools.ts
|
|
1823
1978
|
var anthropicTools = {
|
|
1824
1979
|
/**
|
|
@@ -1880,7 +2035,11 @@ var anthropicTools = {
|
|
|
1880
2035
|
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
1881
2036
|
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
1882
2037
|
*/
|
|
1883
|
-
webSearch_20250305
|
|
2038
|
+
webSearch_20250305,
|
|
2039
|
+
/**
|
|
2040
|
+
* Creates a tool for executing Python code. Must have name "code_execution".
|
|
2041
|
+
*/
|
|
2042
|
+
codeExecution_20250522
|
|
1884
2043
|
};
|
|
1885
2044
|
|
|
1886
2045
|
// src/anthropic-provider.ts
|