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