@ai-sdk/anthropic 2.0.0-beta.2 → 2.0.0-beta.3
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 +4 -22
- package/dist/index.d.ts +4 -22
- package/dist/index.js +254 -250
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +254 -250
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +26 -22
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.js
CHANGED
|
@@ -38,16 +38,16 @@ module.exports = __toCommonJS(internal_exports);
|
|
|
38
38
|
// src/anthropic-messages-language-model.ts
|
|
39
39
|
var import_provider3 = require("@ai-sdk/provider");
|
|
40
40
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
41
|
-
var
|
|
41
|
+
var import_v44 = require("zod/v4");
|
|
42
42
|
|
|
43
43
|
// src/anthropic-error.ts
|
|
44
44
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
45
|
-
var
|
|
46
|
-
var anthropicErrorDataSchema =
|
|
47
|
-
type:
|
|
48
|
-
error:
|
|
49
|
-
type:
|
|
50
|
-
message:
|
|
45
|
+
var import_v4 = require("zod/v4");
|
|
46
|
+
var anthropicErrorDataSchema = import_v4.z.object({
|
|
47
|
+
type: import_v4.z.literal("error"),
|
|
48
|
+
error: import_v4.z.object({
|
|
49
|
+
type: import_v4.z.string(),
|
|
50
|
+
message: import_v4.z.string()
|
|
51
51
|
})
|
|
52
52
|
});
|
|
53
53
|
var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
@@ -56,35 +56,35 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
// src/anthropic-messages-options.ts
|
|
59
|
-
var
|
|
60
|
-
var anthropicFilePartProviderOptions =
|
|
59
|
+
var import_v42 = require("zod/v4");
|
|
60
|
+
var anthropicFilePartProviderOptions = import_v42.z.object({
|
|
61
61
|
/**
|
|
62
62
|
* Citation configuration for this document.
|
|
63
63
|
* When enabled, this document will generate citations in the response.
|
|
64
64
|
*/
|
|
65
|
-
citations:
|
|
65
|
+
citations: import_v42.z.object({
|
|
66
66
|
/**
|
|
67
67
|
* Enable citations for this document
|
|
68
68
|
*/
|
|
69
|
-
enabled:
|
|
69
|
+
enabled: import_v42.z.boolean()
|
|
70
70
|
}).optional(),
|
|
71
71
|
/**
|
|
72
72
|
* Custom title for the document.
|
|
73
73
|
* If not provided, the filename will be used.
|
|
74
74
|
*/
|
|
75
|
-
title:
|
|
75
|
+
title: import_v42.z.string().optional(),
|
|
76
76
|
/**
|
|
77
77
|
* Context about the document that will be passed to the model
|
|
78
78
|
* but not used towards cited content.
|
|
79
79
|
* Useful for storing document metadata as text or stringified JSON.
|
|
80
80
|
*/
|
|
81
|
-
context:
|
|
81
|
+
context: import_v42.z.string().optional()
|
|
82
82
|
});
|
|
83
|
-
var anthropicProviderOptions =
|
|
84
|
-
sendReasoning:
|
|
85
|
-
thinking:
|
|
86
|
-
type:
|
|
87
|
-
budgetTokens:
|
|
83
|
+
var anthropicProviderOptions = import_v42.z.object({
|
|
84
|
+
sendReasoning: import_v42.z.boolean().optional(),
|
|
85
|
+
thinking: import_v42.z.object({
|
|
86
|
+
type: import_v42.z.union([import_v42.z.literal("enabled"), import_v42.z.literal("disabled")]),
|
|
87
|
+
budgetTokens: import_v42.z.number().optional()
|
|
88
88
|
}).optional()
|
|
89
89
|
});
|
|
90
90
|
|
|
@@ -93,45 +93,45 @@ var import_provider = require("@ai-sdk/provider");
|
|
|
93
93
|
|
|
94
94
|
// src/tool/web-search_20250305.ts
|
|
95
95
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
96
|
-
var
|
|
97
|
-
var webSearch_20250305ArgsSchema =
|
|
96
|
+
var import_v43 = require("zod/v4");
|
|
97
|
+
var webSearch_20250305ArgsSchema = import_v43.z.object({
|
|
98
98
|
/**
|
|
99
99
|
* Maximum number of web searches Claude can perform during the conversation.
|
|
100
100
|
*/
|
|
101
|
-
maxUses:
|
|
101
|
+
maxUses: import_v43.z.number().optional(),
|
|
102
102
|
/**
|
|
103
103
|
* Optional list of domains that Claude is allowed to search.
|
|
104
104
|
*/
|
|
105
|
-
allowedDomains:
|
|
105
|
+
allowedDomains: import_v43.z.array(import_v43.z.string()).optional(),
|
|
106
106
|
/**
|
|
107
107
|
* Optional list of domains that Claude should avoid when searching.
|
|
108
108
|
*/
|
|
109
|
-
blockedDomains:
|
|
109
|
+
blockedDomains: import_v43.z.array(import_v43.z.string()).optional(),
|
|
110
110
|
/**
|
|
111
111
|
* Optional user location information to provide geographically relevant search results.
|
|
112
112
|
*/
|
|
113
|
-
userLocation:
|
|
114
|
-
type:
|
|
115
|
-
city:
|
|
116
|
-
region:
|
|
117
|
-
country:
|
|
118
|
-
timezone:
|
|
113
|
+
userLocation: import_v43.z.object({
|
|
114
|
+
type: import_v43.z.literal("approximate"),
|
|
115
|
+
city: import_v43.z.string().optional(),
|
|
116
|
+
region: import_v43.z.string().optional(),
|
|
117
|
+
country: import_v43.z.string().optional(),
|
|
118
|
+
timezone: import_v43.z.string().optional()
|
|
119
119
|
}).optional()
|
|
120
120
|
});
|
|
121
|
-
var webSearch_20250305OutputSchema =
|
|
122
|
-
|
|
123
|
-
url:
|
|
124
|
-
title:
|
|
125
|
-
pageAge:
|
|
126
|
-
encryptedContent:
|
|
127
|
-
type:
|
|
121
|
+
var webSearch_20250305OutputSchema = import_v43.z.array(
|
|
122
|
+
import_v43.z.object({
|
|
123
|
+
url: import_v43.z.string(),
|
|
124
|
+
title: import_v43.z.string(),
|
|
125
|
+
pageAge: import_v43.z.string().nullable(),
|
|
126
|
+
encryptedContent: import_v43.z.string(),
|
|
127
|
+
type: import_v43.z.string()
|
|
128
128
|
})
|
|
129
129
|
);
|
|
130
130
|
var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
131
131
|
id: "anthropic.web_search_20250305",
|
|
132
132
|
name: "web_search",
|
|
133
|
-
inputSchema:
|
|
134
|
-
query:
|
|
133
|
+
inputSchema: import_v43.z.object({
|
|
134
|
+
query: import_v43.z.string()
|
|
135
135
|
}),
|
|
136
136
|
outputSchema: webSearch_20250305OutputSchema
|
|
137
137
|
});
|
|
@@ -721,36 +721,36 @@ function mapAnthropicStopReason({
|
|
|
721
721
|
|
|
722
722
|
// src/anthropic-messages-language-model.ts
|
|
723
723
|
var citationSchemas = {
|
|
724
|
-
webSearchResult:
|
|
725
|
-
type:
|
|
726
|
-
cited_text:
|
|
727
|
-
url:
|
|
728
|
-
title:
|
|
729
|
-
encrypted_index:
|
|
724
|
+
webSearchResult: import_v44.z.object({
|
|
725
|
+
type: import_v44.z.literal("web_search_result_location"),
|
|
726
|
+
cited_text: import_v44.z.string(),
|
|
727
|
+
url: import_v44.z.string(),
|
|
728
|
+
title: import_v44.z.string(),
|
|
729
|
+
encrypted_index: import_v44.z.string()
|
|
730
730
|
}),
|
|
731
|
-
pageLocation:
|
|
732
|
-
type:
|
|
733
|
-
cited_text:
|
|
734
|
-
document_index:
|
|
735
|
-
document_title:
|
|
736
|
-
start_page_number:
|
|
737
|
-
end_page_number:
|
|
731
|
+
pageLocation: import_v44.z.object({
|
|
732
|
+
type: import_v44.z.literal("page_location"),
|
|
733
|
+
cited_text: import_v44.z.string(),
|
|
734
|
+
document_index: import_v44.z.number(),
|
|
735
|
+
document_title: import_v44.z.string().nullable(),
|
|
736
|
+
start_page_number: import_v44.z.number(),
|
|
737
|
+
end_page_number: import_v44.z.number()
|
|
738
738
|
}),
|
|
739
|
-
charLocation:
|
|
740
|
-
type:
|
|
741
|
-
cited_text:
|
|
742
|
-
document_index:
|
|
743
|
-
document_title:
|
|
744
|
-
start_char_index:
|
|
745
|
-
end_char_index:
|
|
739
|
+
charLocation: import_v44.z.object({
|
|
740
|
+
type: import_v44.z.literal("char_location"),
|
|
741
|
+
cited_text: import_v44.z.string(),
|
|
742
|
+
document_index: import_v44.z.number(),
|
|
743
|
+
document_title: import_v44.z.string().nullable(),
|
|
744
|
+
start_char_index: import_v44.z.number(),
|
|
745
|
+
end_char_index: import_v44.z.number()
|
|
746
746
|
})
|
|
747
747
|
};
|
|
748
|
-
var citationSchema =
|
|
748
|
+
var citationSchema = import_v44.z.discriminatedUnion("type", [
|
|
749
749
|
citationSchemas.webSearchResult,
|
|
750
750
|
citationSchemas.pageLocation,
|
|
751
751
|
citationSchemas.charLocation
|
|
752
752
|
]);
|
|
753
|
-
var documentCitationSchema =
|
|
753
|
+
var documentCitationSchema = import_v44.z.discriminatedUnion("type", [
|
|
754
754
|
citationSchemas.pageLocation,
|
|
755
755
|
citationSchemas.charLocation
|
|
756
756
|
]);
|
|
@@ -947,8 +947,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
947
947
|
tool_choice: anthropicToolChoice
|
|
948
948
|
},
|
|
949
949
|
warnings: [...warnings, ...toolWarnings],
|
|
950
|
-
betas: /* @__PURE__ */ new Set([
|
|
951
|
-
|
|
950
|
+
betas: /* @__PURE__ */ new Set([
|
|
951
|
+
"fine-grained-tool-streaming-2025-05-14",
|
|
952
|
+
...messagesBetas,
|
|
953
|
+
...toolsBetas
|
|
954
|
+
]),
|
|
955
|
+
usesJsonResponseTool: jsonResponseTool != null
|
|
952
956
|
};
|
|
953
957
|
}
|
|
954
958
|
async getHeaders({
|
|
@@ -994,7 +998,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
994
998
|
}
|
|
995
999
|
async doGenerate(options) {
|
|
996
1000
|
var _a, _b, _c, _d, _e;
|
|
997
|
-
const { args, warnings, betas,
|
|
1001
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
998
1002
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
999
1003
|
const {
|
|
1000
1004
|
responseHeaders,
|
|
@@ -1015,7 +1019,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1015
1019
|
for (const part of response.content) {
|
|
1016
1020
|
switch (part.type) {
|
|
1017
1021
|
case "text": {
|
|
1018
|
-
if (
|
|
1022
|
+
if (!usesJsonResponseTool) {
|
|
1019
1023
|
content.push({ type: "text", text: part.text });
|
|
1020
1024
|
if (part.citations) {
|
|
1021
1025
|
for (const citation of part.citations) {
|
|
@@ -1057,7 +1061,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1057
1061
|
case "tool_use": {
|
|
1058
1062
|
content.push(
|
|
1059
1063
|
// when a json response tool is used, the tool call becomes the text:
|
|
1060
|
-
|
|
1064
|
+
usesJsonResponseTool ? {
|
|
1061
1065
|
type: "text",
|
|
1062
1066
|
text: JSON.stringify(part.input)
|
|
1063
1067
|
} : {
|
|
@@ -1134,7 +1138,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1134
1138
|
content,
|
|
1135
1139
|
finishReason: mapAnthropicStopReason({
|
|
1136
1140
|
finishReason: response.stop_reason,
|
|
1137
|
-
isJsonResponseFromTool:
|
|
1141
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1138
1142
|
}),
|
|
1139
1143
|
usage: {
|
|
1140
1144
|
inputTokens: response.usage.input_tokens,
|
|
@@ -1158,7 +1162,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1158
1162
|
};
|
|
1159
1163
|
}
|
|
1160
1164
|
async doStream(options) {
|
|
1161
|
-
const { args, warnings, betas,
|
|
1165
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1162
1166
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1163
1167
|
const body = { ...args, stream: true };
|
|
1164
1168
|
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
@@ -1236,14 +1240,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1236
1240
|
return;
|
|
1237
1241
|
}
|
|
1238
1242
|
case "tool_use": {
|
|
1239
|
-
contentBlocks[value.index] =
|
|
1243
|
+
contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
|
|
1240
1244
|
type: "tool-call",
|
|
1241
1245
|
toolCallId: value.content_block.id,
|
|
1242
1246
|
toolName: value.content_block.name,
|
|
1243
1247
|
input: ""
|
|
1244
1248
|
};
|
|
1245
1249
|
controller.enqueue(
|
|
1246
|
-
|
|
1250
|
+
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
1247
1251
|
type: "tool-input-start",
|
|
1248
1252
|
id: value.content_block.id,
|
|
1249
1253
|
toolName: value.content_block.name
|
|
@@ -1344,7 +1348,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1344
1348
|
break;
|
|
1345
1349
|
}
|
|
1346
1350
|
case "tool-call":
|
|
1347
|
-
if (
|
|
1351
|
+
if (!usesJsonResponseTool) {
|
|
1348
1352
|
controller.enqueue({
|
|
1349
1353
|
type: "tool-input-end",
|
|
1350
1354
|
id: contentBlock.toolCallId
|
|
@@ -1362,7 +1366,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1362
1366
|
const deltaType = value.delta.type;
|
|
1363
1367
|
switch (deltaType) {
|
|
1364
1368
|
case "text_delta": {
|
|
1365
|
-
if (
|
|
1369
|
+
if (usesJsonResponseTool) {
|
|
1366
1370
|
return;
|
|
1367
1371
|
}
|
|
1368
1372
|
controller.enqueue({
|
|
@@ -1398,16 +1402,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1398
1402
|
case "input_json_delta": {
|
|
1399
1403
|
const contentBlock = contentBlocks[value.index];
|
|
1400
1404
|
const delta = value.delta.partial_json;
|
|
1401
|
-
if (
|
|
1402
|
-
if ((contentBlock == null ? void 0 : contentBlock.type) !== "
|
|
1405
|
+
if (usesJsonResponseTool) {
|
|
1406
|
+
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
1403
1407
|
return;
|
|
1404
1408
|
}
|
|
1405
1409
|
controller.enqueue({
|
|
1406
|
-
type: "
|
|
1407
|
-
id:
|
|
1410
|
+
type: "text-delta",
|
|
1411
|
+
id: String(value.index),
|
|
1408
1412
|
delta
|
|
1409
1413
|
});
|
|
1410
|
-
contentBlock.input += delta;
|
|
1411
1414
|
} else {
|
|
1412
1415
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
1413
1416
|
return;
|
|
@@ -1417,6 +1420,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1417
1420
|
id: contentBlock.toolCallId,
|
|
1418
1421
|
delta
|
|
1419
1422
|
});
|
|
1423
|
+
contentBlock.input += delta;
|
|
1420
1424
|
}
|
|
1421
1425
|
return;
|
|
1422
1426
|
}
|
|
@@ -1458,7 +1462,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1458
1462
|
usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
|
|
1459
1463
|
finishReason = mapAnthropicStopReason({
|
|
1460
1464
|
finishReason: value.delta.stop_reason,
|
|
1461
|
-
isJsonResponseFromTool:
|
|
1465
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1462
1466
|
});
|
|
1463
1467
|
return;
|
|
1464
1468
|
}
|
|
@@ -1488,218 +1492,218 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1488
1492
|
};
|
|
1489
1493
|
}
|
|
1490
1494
|
};
|
|
1491
|
-
var anthropicMessagesResponseSchema =
|
|
1492
|
-
type:
|
|
1493
|
-
id:
|
|
1494
|
-
model:
|
|
1495
|
-
content:
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
type:
|
|
1499
|
-
text:
|
|
1500
|
-
citations:
|
|
1495
|
+
var anthropicMessagesResponseSchema = import_v44.z.object({
|
|
1496
|
+
type: import_v44.z.literal("message"),
|
|
1497
|
+
id: import_v44.z.string().nullish(),
|
|
1498
|
+
model: import_v44.z.string().nullish(),
|
|
1499
|
+
content: import_v44.z.array(
|
|
1500
|
+
import_v44.z.discriminatedUnion("type", [
|
|
1501
|
+
import_v44.z.object({
|
|
1502
|
+
type: import_v44.z.literal("text"),
|
|
1503
|
+
text: import_v44.z.string(),
|
|
1504
|
+
citations: import_v44.z.array(citationSchema).optional()
|
|
1501
1505
|
}),
|
|
1502
|
-
|
|
1503
|
-
type:
|
|
1504
|
-
thinking:
|
|
1505
|
-
signature:
|
|
1506
|
+
import_v44.z.object({
|
|
1507
|
+
type: import_v44.z.literal("thinking"),
|
|
1508
|
+
thinking: import_v44.z.string(),
|
|
1509
|
+
signature: import_v44.z.string()
|
|
1506
1510
|
}),
|
|
1507
|
-
|
|
1508
|
-
type:
|
|
1509
|
-
data:
|
|
1511
|
+
import_v44.z.object({
|
|
1512
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1513
|
+
data: import_v44.z.string()
|
|
1510
1514
|
}),
|
|
1511
|
-
|
|
1512
|
-
type:
|
|
1513
|
-
id:
|
|
1514
|
-
name:
|
|
1515
|
-
input:
|
|
1515
|
+
import_v44.z.object({
|
|
1516
|
+
type: import_v44.z.literal("tool_use"),
|
|
1517
|
+
id: import_v44.z.string(),
|
|
1518
|
+
name: import_v44.z.string(),
|
|
1519
|
+
input: import_v44.z.unknown()
|
|
1516
1520
|
}),
|
|
1517
|
-
|
|
1518
|
-
type:
|
|
1519
|
-
id:
|
|
1520
|
-
name:
|
|
1521
|
-
input:
|
|
1521
|
+
import_v44.z.object({
|
|
1522
|
+
type: import_v44.z.literal("server_tool_use"),
|
|
1523
|
+
id: import_v44.z.string(),
|
|
1524
|
+
name: import_v44.z.string(),
|
|
1525
|
+
input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
|
|
1522
1526
|
}),
|
|
1523
|
-
|
|
1524
|
-
type:
|
|
1525
|
-
tool_use_id:
|
|
1526
|
-
content:
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
type:
|
|
1530
|
-
url:
|
|
1531
|
-
title:
|
|
1532
|
-
encrypted_content:
|
|
1533
|
-
page_age:
|
|
1527
|
+
import_v44.z.object({
|
|
1528
|
+
type: import_v44.z.literal("web_search_tool_result"),
|
|
1529
|
+
tool_use_id: import_v44.z.string(),
|
|
1530
|
+
content: import_v44.z.union([
|
|
1531
|
+
import_v44.z.array(
|
|
1532
|
+
import_v44.z.object({
|
|
1533
|
+
type: import_v44.z.literal("web_search_result"),
|
|
1534
|
+
url: import_v44.z.string(),
|
|
1535
|
+
title: import_v44.z.string(),
|
|
1536
|
+
encrypted_content: import_v44.z.string(),
|
|
1537
|
+
page_age: import_v44.z.string().nullish()
|
|
1534
1538
|
})
|
|
1535
1539
|
),
|
|
1536
|
-
|
|
1537
|
-
type:
|
|
1538
|
-
error_code:
|
|
1540
|
+
import_v44.z.object({
|
|
1541
|
+
type: import_v44.z.literal("web_search_tool_result_error"),
|
|
1542
|
+
error_code: import_v44.z.string()
|
|
1539
1543
|
})
|
|
1540
1544
|
])
|
|
1541
1545
|
})
|
|
1542
1546
|
])
|
|
1543
1547
|
),
|
|
1544
|
-
stop_reason:
|
|
1545
|
-
usage:
|
|
1546
|
-
input_tokens:
|
|
1547
|
-
output_tokens:
|
|
1548
|
-
cache_creation_input_tokens:
|
|
1549
|
-
cache_read_input_tokens:
|
|
1550
|
-
server_tool_use:
|
|
1551
|
-
web_search_requests:
|
|
1548
|
+
stop_reason: import_v44.z.string().nullish(),
|
|
1549
|
+
usage: import_v44.z.object({
|
|
1550
|
+
input_tokens: import_v44.z.number(),
|
|
1551
|
+
output_tokens: import_v44.z.number(),
|
|
1552
|
+
cache_creation_input_tokens: import_v44.z.number().nullish(),
|
|
1553
|
+
cache_read_input_tokens: import_v44.z.number().nullish(),
|
|
1554
|
+
server_tool_use: import_v44.z.object({
|
|
1555
|
+
web_search_requests: import_v44.z.number()
|
|
1552
1556
|
}).nullish()
|
|
1553
1557
|
})
|
|
1554
1558
|
});
|
|
1555
|
-
var anthropicMessagesChunkSchema =
|
|
1556
|
-
|
|
1557
|
-
type:
|
|
1558
|
-
message:
|
|
1559
|
-
id:
|
|
1560
|
-
model:
|
|
1561
|
-
usage:
|
|
1562
|
-
input_tokens:
|
|
1563
|
-
output_tokens:
|
|
1564
|
-
cache_creation_input_tokens:
|
|
1565
|
-
cache_read_input_tokens:
|
|
1559
|
+
var anthropicMessagesChunkSchema = import_v44.z.discriminatedUnion("type", [
|
|
1560
|
+
import_v44.z.object({
|
|
1561
|
+
type: import_v44.z.literal("message_start"),
|
|
1562
|
+
message: import_v44.z.object({
|
|
1563
|
+
id: import_v44.z.string().nullish(),
|
|
1564
|
+
model: import_v44.z.string().nullish(),
|
|
1565
|
+
usage: import_v44.z.object({
|
|
1566
|
+
input_tokens: import_v44.z.number(),
|
|
1567
|
+
output_tokens: import_v44.z.number(),
|
|
1568
|
+
cache_creation_input_tokens: import_v44.z.number().nullish(),
|
|
1569
|
+
cache_read_input_tokens: import_v44.z.number().nullish()
|
|
1566
1570
|
})
|
|
1567
1571
|
})
|
|
1568
1572
|
}),
|
|
1569
|
-
|
|
1570
|
-
type:
|
|
1571
|
-
index:
|
|
1572
|
-
content_block:
|
|
1573
|
-
|
|
1574
|
-
type:
|
|
1575
|
-
text:
|
|
1573
|
+
import_v44.z.object({
|
|
1574
|
+
type: import_v44.z.literal("content_block_start"),
|
|
1575
|
+
index: import_v44.z.number(),
|
|
1576
|
+
content_block: import_v44.z.discriminatedUnion("type", [
|
|
1577
|
+
import_v44.z.object({
|
|
1578
|
+
type: import_v44.z.literal("text"),
|
|
1579
|
+
text: import_v44.z.string()
|
|
1576
1580
|
}),
|
|
1577
|
-
|
|
1578
|
-
type:
|
|
1579
|
-
thinking:
|
|
1581
|
+
import_v44.z.object({
|
|
1582
|
+
type: import_v44.z.literal("thinking"),
|
|
1583
|
+
thinking: import_v44.z.string()
|
|
1580
1584
|
}),
|
|
1581
|
-
|
|
1582
|
-
type:
|
|
1583
|
-
id:
|
|
1584
|
-
name:
|
|
1585
|
+
import_v44.z.object({
|
|
1586
|
+
type: import_v44.z.literal("tool_use"),
|
|
1587
|
+
id: import_v44.z.string(),
|
|
1588
|
+
name: import_v44.z.string()
|
|
1585
1589
|
}),
|
|
1586
|
-
|
|
1587
|
-
type:
|
|
1588
|
-
data:
|
|
1590
|
+
import_v44.z.object({
|
|
1591
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1592
|
+
data: import_v44.z.string()
|
|
1589
1593
|
}),
|
|
1590
|
-
|
|
1591
|
-
type:
|
|
1592
|
-
id:
|
|
1593
|
-
name:
|
|
1594
|
-
input:
|
|
1594
|
+
import_v44.z.object({
|
|
1595
|
+
type: import_v44.z.literal("server_tool_use"),
|
|
1596
|
+
id: import_v44.z.string(),
|
|
1597
|
+
name: import_v44.z.string(),
|
|
1598
|
+
input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
|
|
1595
1599
|
}),
|
|
1596
|
-
|
|
1597
|
-
type:
|
|
1598
|
-
tool_use_id:
|
|
1599
|
-
content:
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
type:
|
|
1603
|
-
url:
|
|
1604
|
-
title:
|
|
1605
|
-
encrypted_content:
|
|
1606
|
-
page_age:
|
|
1600
|
+
import_v44.z.object({
|
|
1601
|
+
type: import_v44.z.literal("web_search_tool_result"),
|
|
1602
|
+
tool_use_id: import_v44.z.string(),
|
|
1603
|
+
content: import_v44.z.union([
|
|
1604
|
+
import_v44.z.array(
|
|
1605
|
+
import_v44.z.object({
|
|
1606
|
+
type: import_v44.z.literal("web_search_result"),
|
|
1607
|
+
url: import_v44.z.string(),
|
|
1608
|
+
title: import_v44.z.string(),
|
|
1609
|
+
encrypted_content: import_v44.z.string(),
|
|
1610
|
+
page_age: import_v44.z.string().nullish()
|
|
1607
1611
|
})
|
|
1608
1612
|
),
|
|
1609
|
-
|
|
1610
|
-
type:
|
|
1611
|
-
error_code:
|
|
1613
|
+
import_v44.z.object({
|
|
1614
|
+
type: import_v44.z.literal("web_search_tool_result_error"),
|
|
1615
|
+
error_code: import_v44.z.string()
|
|
1612
1616
|
})
|
|
1613
1617
|
])
|
|
1614
1618
|
})
|
|
1615
1619
|
])
|
|
1616
1620
|
}),
|
|
1617
|
-
|
|
1618
|
-
type:
|
|
1619
|
-
index:
|
|
1620
|
-
delta:
|
|
1621
|
-
|
|
1622
|
-
type:
|
|
1623
|
-
partial_json:
|
|
1621
|
+
import_v44.z.object({
|
|
1622
|
+
type: import_v44.z.literal("content_block_delta"),
|
|
1623
|
+
index: import_v44.z.number(),
|
|
1624
|
+
delta: import_v44.z.discriminatedUnion("type", [
|
|
1625
|
+
import_v44.z.object({
|
|
1626
|
+
type: import_v44.z.literal("input_json_delta"),
|
|
1627
|
+
partial_json: import_v44.z.string()
|
|
1624
1628
|
}),
|
|
1625
|
-
|
|
1626
|
-
type:
|
|
1627
|
-
text:
|
|
1629
|
+
import_v44.z.object({
|
|
1630
|
+
type: import_v44.z.literal("text_delta"),
|
|
1631
|
+
text: import_v44.z.string()
|
|
1628
1632
|
}),
|
|
1629
|
-
|
|
1630
|
-
type:
|
|
1631
|
-
thinking:
|
|
1633
|
+
import_v44.z.object({
|
|
1634
|
+
type: import_v44.z.literal("thinking_delta"),
|
|
1635
|
+
thinking: import_v44.z.string()
|
|
1632
1636
|
}),
|
|
1633
|
-
|
|
1634
|
-
type:
|
|
1635
|
-
signature:
|
|
1637
|
+
import_v44.z.object({
|
|
1638
|
+
type: import_v44.z.literal("signature_delta"),
|
|
1639
|
+
signature: import_v44.z.string()
|
|
1636
1640
|
}),
|
|
1637
|
-
|
|
1638
|
-
type:
|
|
1641
|
+
import_v44.z.object({
|
|
1642
|
+
type: import_v44.z.literal("citations_delta"),
|
|
1639
1643
|
citation: citationSchema
|
|
1640
1644
|
})
|
|
1641
1645
|
])
|
|
1642
1646
|
}),
|
|
1643
|
-
|
|
1644
|
-
type:
|
|
1645
|
-
index:
|
|
1647
|
+
import_v44.z.object({
|
|
1648
|
+
type: import_v44.z.literal("content_block_stop"),
|
|
1649
|
+
index: import_v44.z.number()
|
|
1646
1650
|
}),
|
|
1647
|
-
|
|
1648
|
-
type:
|
|
1649
|
-
error:
|
|
1650
|
-
type:
|
|
1651
|
-
message:
|
|
1651
|
+
import_v44.z.object({
|
|
1652
|
+
type: import_v44.z.literal("error"),
|
|
1653
|
+
error: import_v44.z.object({
|
|
1654
|
+
type: import_v44.z.string(),
|
|
1655
|
+
message: import_v44.z.string()
|
|
1652
1656
|
})
|
|
1653
1657
|
}),
|
|
1654
|
-
|
|
1655
|
-
type:
|
|
1656
|
-
delta:
|
|
1657
|
-
usage:
|
|
1658
|
+
import_v44.z.object({
|
|
1659
|
+
type: import_v44.z.literal("message_delta"),
|
|
1660
|
+
delta: import_v44.z.object({ stop_reason: import_v44.z.string().nullish() }),
|
|
1661
|
+
usage: import_v44.z.object({ output_tokens: import_v44.z.number() })
|
|
1658
1662
|
}),
|
|
1659
|
-
|
|
1660
|
-
type:
|
|
1663
|
+
import_v44.z.object({
|
|
1664
|
+
type: import_v44.z.literal("message_stop")
|
|
1661
1665
|
}),
|
|
1662
|
-
|
|
1663
|
-
type:
|
|
1666
|
+
import_v44.z.object({
|
|
1667
|
+
type: import_v44.z.literal("ping")
|
|
1664
1668
|
})
|
|
1665
1669
|
]);
|
|
1666
|
-
var anthropicReasoningMetadataSchema =
|
|
1667
|
-
signature:
|
|
1668
|
-
redactedData:
|
|
1670
|
+
var anthropicReasoningMetadataSchema = import_v44.z.object({
|
|
1671
|
+
signature: import_v44.z.string().optional(),
|
|
1672
|
+
redactedData: import_v44.z.string().optional()
|
|
1669
1673
|
});
|
|
1670
1674
|
|
|
1671
1675
|
// src/tool/bash_20241022.ts
|
|
1672
1676
|
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1673
|
-
var
|
|
1677
|
+
var import_v45 = __toESM(require("zod/v4"));
|
|
1674
1678
|
var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
1675
1679
|
id: "anthropic.bash_20241022",
|
|
1676
1680
|
name: "bash",
|
|
1677
|
-
inputSchema:
|
|
1678
|
-
command:
|
|
1679
|
-
restart:
|
|
1681
|
+
inputSchema: import_v45.default.object({
|
|
1682
|
+
command: import_v45.default.string(),
|
|
1683
|
+
restart: import_v45.default.boolean().optional()
|
|
1680
1684
|
})
|
|
1681
1685
|
});
|
|
1682
1686
|
|
|
1683
1687
|
// src/tool/bash_20250124.ts
|
|
1684
1688
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1685
|
-
var
|
|
1689
|
+
var import_v46 = __toESM(require("zod/v4"));
|
|
1686
1690
|
var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
|
|
1687
1691
|
id: "anthropic.bashTool_20250124",
|
|
1688
1692
|
name: "bash",
|
|
1689
|
-
inputSchema:
|
|
1690
|
-
command:
|
|
1691
|
-
restart:
|
|
1693
|
+
inputSchema: import_v46.default.object({
|
|
1694
|
+
command: import_v46.default.string(),
|
|
1695
|
+
restart: import_v46.default.boolean().optional()
|
|
1692
1696
|
})
|
|
1693
1697
|
});
|
|
1694
1698
|
|
|
1695
1699
|
// src/tool/computer_20241022.ts
|
|
1696
1700
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1697
|
-
var
|
|
1701
|
+
var import_v47 = require("zod/v4");
|
|
1698
1702
|
var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
|
|
1699
1703
|
id: "anthropic.computer_20241022",
|
|
1700
1704
|
name: "computer",
|
|
1701
|
-
inputSchema:
|
|
1702
|
-
action:
|
|
1705
|
+
inputSchema: import_v47.z.object({
|
|
1706
|
+
action: import_v47.z.enum([
|
|
1703
1707
|
"key",
|
|
1704
1708
|
"type",
|
|
1705
1709
|
"mouse_move",
|
|
@@ -1711,19 +1715,19 @@ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFact
|
|
|
1711
1715
|
"screenshot",
|
|
1712
1716
|
"cursor_position"
|
|
1713
1717
|
]),
|
|
1714
|
-
coordinate:
|
|
1715
|
-
text:
|
|
1718
|
+
coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
|
|
1719
|
+
text: import_v47.z.string().optional()
|
|
1716
1720
|
})
|
|
1717
1721
|
});
|
|
1718
1722
|
|
|
1719
1723
|
// src/tool/computer_20250124.ts
|
|
1720
1724
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1721
|
-
var
|
|
1725
|
+
var import_v48 = require("zod/v4");
|
|
1722
1726
|
var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1723
1727
|
id: "anthropic.computer_20250124",
|
|
1724
1728
|
name: "computer",
|
|
1725
|
-
inputSchema:
|
|
1726
|
-
action:
|
|
1729
|
+
inputSchema: import_v48.z.object({
|
|
1730
|
+
action: import_v48.z.enum([
|
|
1727
1731
|
"key",
|
|
1728
1732
|
"hold_key",
|
|
1729
1733
|
"type",
|
|
@@ -1741,46 +1745,46 @@ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFact
|
|
|
1741
1745
|
"wait",
|
|
1742
1746
|
"screenshot"
|
|
1743
1747
|
]),
|
|
1744
|
-
coordinate:
|
|
1745
|
-
duration:
|
|
1746
|
-
scroll_amount:
|
|
1747
|
-
scroll_direction:
|
|
1748
|
-
start_coordinate:
|
|
1749
|
-
text:
|
|
1748
|
+
coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
|
|
1749
|
+
duration: import_v48.z.number().optional(),
|
|
1750
|
+
scroll_amount: import_v48.z.number().optional(),
|
|
1751
|
+
scroll_direction: import_v48.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1752
|
+
start_coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
|
|
1753
|
+
text: import_v48.z.string().optional()
|
|
1750
1754
|
})
|
|
1751
1755
|
});
|
|
1752
1756
|
|
|
1753
1757
|
// src/tool/text-editor_20241022.ts
|
|
1754
1758
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1755
|
-
var
|
|
1759
|
+
var import_v49 = require("zod/v4");
|
|
1756
1760
|
var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1757
1761
|
id: "anthropic.text_editor_20241022",
|
|
1758
1762
|
name: "str_replace_editor",
|
|
1759
|
-
inputSchema:
|
|
1760
|
-
command:
|
|
1761
|
-
path:
|
|
1762
|
-
file_text:
|
|
1763
|
-
insert_line:
|
|
1764
|
-
new_str:
|
|
1765
|
-
old_str:
|
|
1766
|
-
view_range:
|
|
1763
|
+
inputSchema: import_v49.z.object({
|
|
1764
|
+
command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1765
|
+
path: import_v49.z.string(),
|
|
1766
|
+
file_text: import_v49.z.string().optional(),
|
|
1767
|
+
insert_line: import_v49.z.number().int().optional(),
|
|
1768
|
+
new_str: import_v49.z.string().optional(),
|
|
1769
|
+
old_str: import_v49.z.string().optional(),
|
|
1770
|
+
view_range: import_v49.z.array(import_v49.z.number().int()).optional()
|
|
1767
1771
|
})
|
|
1768
1772
|
});
|
|
1769
1773
|
|
|
1770
1774
|
// src/tool/text-editor_20250124.ts
|
|
1771
1775
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1772
|
-
var
|
|
1776
|
+
var import_v410 = require("zod/v4");
|
|
1773
1777
|
var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1774
1778
|
id: "anthropic.text_editor_20250124",
|
|
1775
1779
|
name: "str_replace_editor",
|
|
1776
|
-
inputSchema:
|
|
1777
|
-
command:
|
|
1778
|
-
path:
|
|
1779
|
-
file_text:
|
|
1780
|
-
insert_line:
|
|
1781
|
-
new_str:
|
|
1782
|
-
old_str:
|
|
1783
|
-
view_range:
|
|
1780
|
+
inputSchema: import_v410.z.object({
|
|
1781
|
+
command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1782
|
+
path: import_v410.z.string(),
|
|
1783
|
+
file_text: import_v410.z.string().optional(),
|
|
1784
|
+
insert_line: import_v410.z.number().int().optional(),
|
|
1785
|
+
new_str: import_v410.z.string().optional(),
|
|
1786
|
+
old_str: import_v410.z.string().optional(),
|
|
1787
|
+
view_range: import_v410.z.array(import_v410.z.number().int()).optional()
|
|
1784
1788
|
})
|
|
1785
1789
|
});
|
|
1786
1790
|
|