@ai-sdk/anthropic 2.0.0-beta.2 → 2.0.0-beta.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 +19 -0
- package/dist/index.d.mts +5 -23
- package/dist/index.d.ts +5 -23
- package/dist/index.js +249 -249
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +249 -249
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +21 -21
- 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
|
]);
|
|
@@ -952,7 +952,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
952
952
|
},
|
|
953
953
|
warnings: [...warnings, ...toolWarnings],
|
|
954
954
|
betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
|
|
955
|
-
jsonResponseTool
|
|
955
|
+
usesJsonResponseTool: jsonResponseTool != null
|
|
956
956
|
};
|
|
957
957
|
}
|
|
958
958
|
async getHeaders({
|
|
@@ -998,7 +998,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
998
998
|
}
|
|
999
999
|
async doGenerate(options) {
|
|
1000
1000
|
var _a, _b, _c, _d, _e;
|
|
1001
|
-
const { args, warnings, betas,
|
|
1001
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1002
1002
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1003
1003
|
const {
|
|
1004
1004
|
responseHeaders,
|
|
@@ -1019,7 +1019,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1019
1019
|
for (const part of response.content) {
|
|
1020
1020
|
switch (part.type) {
|
|
1021
1021
|
case "text": {
|
|
1022
|
-
if (
|
|
1022
|
+
if (!usesJsonResponseTool) {
|
|
1023
1023
|
content.push({ type: "text", text: part.text });
|
|
1024
1024
|
if (part.citations) {
|
|
1025
1025
|
for (const citation of part.citations) {
|
|
@@ -1061,7 +1061,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1061
1061
|
case "tool_use": {
|
|
1062
1062
|
content.push(
|
|
1063
1063
|
// when a json response tool is used, the tool call becomes the text:
|
|
1064
|
-
|
|
1064
|
+
usesJsonResponseTool ? {
|
|
1065
1065
|
type: "text",
|
|
1066
1066
|
text: JSON.stringify(part.input)
|
|
1067
1067
|
} : {
|
|
@@ -1138,7 +1138,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1138
1138
|
content,
|
|
1139
1139
|
finishReason: mapAnthropicStopReason({
|
|
1140
1140
|
finishReason: response.stop_reason,
|
|
1141
|
-
isJsonResponseFromTool:
|
|
1141
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1142
1142
|
}),
|
|
1143
1143
|
usage: {
|
|
1144
1144
|
inputTokens: response.usage.input_tokens,
|
|
@@ -1162,7 +1162,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1162
1162
|
};
|
|
1163
1163
|
}
|
|
1164
1164
|
async doStream(options) {
|
|
1165
|
-
const { args, warnings, betas,
|
|
1165
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1166
1166
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1167
1167
|
const body = { ...args, stream: true };
|
|
1168
1168
|
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
@@ -1240,14 +1240,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1240
1240
|
return;
|
|
1241
1241
|
}
|
|
1242
1242
|
case "tool_use": {
|
|
1243
|
-
contentBlocks[value.index] =
|
|
1243
|
+
contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
|
|
1244
1244
|
type: "tool-call",
|
|
1245
1245
|
toolCallId: value.content_block.id,
|
|
1246
1246
|
toolName: value.content_block.name,
|
|
1247
1247
|
input: ""
|
|
1248
1248
|
};
|
|
1249
1249
|
controller.enqueue(
|
|
1250
|
-
|
|
1250
|
+
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
1251
1251
|
type: "tool-input-start",
|
|
1252
1252
|
id: value.content_block.id,
|
|
1253
1253
|
toolName: value.content_block.name
|
|
@@ -1348,7 +1348,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1348
1348
|
break;
|
|
1349
1349
|
}
|
|
1350
1350
|
case "tool-call":
|
|
1351
|
-
if (
|
|
1351
|
+
if (!usesJsonResponseTool) {
|
|
1352
1352
|
controller.enqueue({
|
|
1353
1353
|
type: "tool-input-end",
|
|
1354
1354
|
id: contentBlock.toolCallId
|
|
@@ -1366,7 +1366,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1366
1366
|
const deltaType = value.delta.type;
|
|
1367
1367
|
switch (deltaType) {
|
|
1368
1368
|
case "text_delta": {
|
|
1369
|
-
if (
|
|
1369
|
+
if (usesJsonResponseTool) {
|
|
1370
1370
|
return;
|
|
1371
1371
|
}
|
|
1372
1372
|
controller.enqueue({
|
|
@@ -1402,16 +1402,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1402
1402
|
case "input_json_delta": {
|
|
1403
1403
|
const contentBlock = contentBlocks[value.index];
|
|
1404
1404
|
const delta = value.delta.partial_json;
|
|
1405
|
-
if (
|
|
1406
|
-
if ((contentBlock == null ? void 0 : contentBlock.type) !== "
|
|
1405
|
+
if (usesJsonResponseTool) {
|
|
1406
|
+
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
1407
1407
|
return;
|
|
1408
1408
|
}
|
|
1409
1409
|
controller.enqueue({
|
|
1410
|
-
type: "
|
|
1411
|
-
id:
|
|
1410
|
+
type: "text-delta",
|
|
1411
|
+
id: String(value.index),
|
|
1412
1412
|
delta
|
|
1413
1413
|
});
|
|
1414
|
-
contentBlock.input += delta;
|
|
1415
1414
|
} else {
|
|
1416
1415
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
1417
1416
|
return;
|
|
@@ -1421,6 +1420,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1421
1420
|
id: contentBlock.toolCallId,
|
|
1422
1421
|
delta
|
|
1423
1422
|
});
|
|
1423
|
+
contentBlock.input += delta;
|
|
1424
1424
|
}
|
|
1425
1425
|
return;
|
|
1426
1426
|
}
|
|
@@ -1462,7 +1462,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1462
1462
|
usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
|
|
1463
1463
|
finishReason = mapAnthropicStopReason({
|
|
1464
1464
|
finishReason: value.delta.stop_reason,
|
|
1465
|
-
isJsonResponseFromTool:
|
|
1465
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1466
1466
|
});
|
|
1467
1467
|
return;
|
|
1468
1468
|
}
|
|
@@ -1492,218 +1492,218 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1492
1492
|
};
|
|
1493
1493
|
}
|
|
1494
1494
|
};
|
|
1495
|
-
var anthropicMessagesResponseSchema =
|
|
1496
|
-
type:
|
|
1497
|
-
id:
|
|
1498
|
-
model:
|
|
1499
|
-
content:
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
type:
|
|
1503
|
-
text:
|
|
1504
|
-
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()
|
|
1505
1505
|
}),
|
|
1506
|
-
|
|
1507
|
-
type:
|
|
1508
|
-
thinking:
|
|
1509
|
-
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()
|
|
1510
1510
|
}),
|
|
1511
|
-
|
|
1512
|
-
type:
|
|
1513
|
-
data:
|
|
1511
|
+
import_v44.z.object({
|
|
1512
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1513
|
+
data: import_v44.z.string()
|
|
1514
1514
|
}),
|
|
1515
|
-
|
|
1516
|
-
type:
|
|
1517
|
-
id:
|
|
1518
|
-
name:
|
|
1519
|
-
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()
|
|
1520
1520
|
}),
|
|
1521
|
-
|
|
1522
|
-
type:
|
|
1523
|
-
id:
|
|
1524
|
-
name:
|
|
1525
|
-
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()
|
|
1526
1526
|
}),
|
|
1527
|
-
|
|
1528
|
-
type:
|
|
1529
|
-
tool_use_id:
|
|
1530
|
-
content:
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
type:
|
|
1534
|
-
url:
|
|
1535
|
-
title:
|
|
1536
|
-
encrypted_content:
|
|
1537
|
-
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()
|
|
1538
1538
|
})
|
|
1539
1539
|
),
|
|
1540
|
-
|
|
1541
|
-
type:
|
|
1542
|
-
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()
|
|
1543
1543
|
})
|
|
1544
1544
|
])
|
|
1545
1545
|
})
|
|
1546
1546
|
])
|
|
1547
1547
|
),
|
|
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:
|
|
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()
|
|
1556
1556
|
}).nullish()
|
|
1557
1557
|
})
|
|
1558
1558
|
});
|
|
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:
|
|
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()
|
|
1570
1570
|
})
|
|
1571
1571
|
})
|
|
1572
1572
|
}),
|
|
1573
|
-
|
|
1574
|
-
type:
|
|
1575
|
-
index:
|
|
1576
|
-
content_block:
|
|
1577
|
-
|
|
1578
|
-
type:
|
|
1579
|
-
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()
|
|
1580
1580
|
}),
|
|
1581
|
-
|
|
1582
|
-
type:
|
|
1583
|
-
thinking:
|
|
1581
|
+
import_v44.z.object({
|
|
1582
|
+
type: import_v44.z.literal("thinking"),
|
|
1583
|
+
thinking: import_v44.z.string()
|
|
1584
1584
|
}),
|
|
1585
|
-
|
|
1586
|
-
type:
|
|
1587
|
-
id:
|
|
1588
|
-
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()
|
|
1589
1589
|
}),
|
|
1590
|
-
|
|
1591
|
-
type:
|
|
1592
|
-
data:
|
|
1590
|
+
import_v44.z.object({
|
|
1591
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1592
|
+
data: import_v44.z.string()
|
|
1593
1593
|
}),
|
|
1594
|
-
|
|
1595
|
-
type:
|
|
1596
|
-
id:
|
|
1597
|
-
name:
|
|
1598
|
-
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()
|
|
1599
1599
|
}),
|
|
1600
|
-
|
|
1601
|
-
type:
|
|
1602
|
-
tool_use_id:
|
|
1603
|
-
content:
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
type:
|
|
1607
|
-
url:
|
|
1608
|
-
title:
|
|
1609
|
-
encrypted_content:
|
|
1610
|
-
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()
|
|
1611
1611
|
})
|
|
1612
1612
|
),
|
|
1613
|
-
|
|
1614
|
-
type:
|
|
1615
|
-
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()
|
|
1616
1616
|
})
|
|
1617
1617
|
])
|
|
1618
1618
|
})
|
|
1619
1619
|
])
|
|
1620
1620
|
}),
|
|
1621
|
-
|
|
1622
|
-
type:
|
|
1623
|
-
index:
|
|
1624
|
-
delta:
|
|
1625
|
-
|
|
1626
|
-
type:
|
|
1627
|
-
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()
|
|
1628
1628
|
}),
|
|
1629
|
-
|
|
1630
|
-
type:
|
|
1631
|
-
text:
|
|
1629
|
+
import_v44.z.object({
|
|
1630
|
+
type: import_v44.z.literal("text_delta"),
|
|
1631
|
+
text: import_v44.z.string()
|
|
1632
1632
|
}),
|
|
1633
|
-
|
|
1634
|
-
type:
|
|
1635
|
-
thinking:
|
|
1633
|
+
import_v44.z.object({
|
|
1634
|
+
type: import_v44.z.literal("thinking_delta"),
|
|
1635
|
+
thinking: import_v44.z.string()
|
|
1636
1636
|
}),
|
|
1637
|
-
|
|
1638
|
-
type:
|
|
1639
|
-
signature:
|
|
1637
|
+
import_v44.z.object({
|
|
1638
|
+
type: import_v44.z.literal("signature_delta"),
|
|
1639
|
+
signature: import_v44.z.string()
|
|
1640
1640
|
}),
|
|
1641
|
-
|
|
1642
|
-
type:
|
|
1641
|
+
import_v44.z.object({
|
|
1642
|
+
type: import_v44.z.literal("citations_delta"),
|
|
1643
1643
|
citation: citationSchema
|
|
1644
1644
|
})
|
|
1645
1645
|
])
|
|
1646
1646
|
}),
|
|
1647
|
-
|
|
1648
|
-
type:
|
|
1649
|
-
index:
|
|
1647
|
+
import_v44.z.object({
|
|
1648
|
+
type: import_v44.z.literal("content_block_stop"),
|
|
1649
|
+
index: import_v44.z.number()
|
|
1650
1650
|
}),
|
|
1651
|
-
|
|
1652
|
-
type:
|
|
1653
|
-
error:
|
|
1654
|
-
type:
|
|
1655
|
-
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()
|
|
1656
1656
|
})
|
|
1657
1657
|
}),
|
|
1658
|
-
|
|
1659
|
-
type:
|
|
1660
|
-
delta:
|
|
1661
|
-
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() })
|
|
1662
1662
|
}),
|
|
1663
|
-
|
|
1664
|
-
type:
|
|
1663
|
+
import_v44.z.object({
|
|
1664
|
+
type: import_v44.z.literal("message_stop")
|
|
1665
1665
|
}),
|
|
1666
|
-
|
|
1667
|
-
type:
|
|
1666
|
+
import_v44.z.object({
|
|
1667
|
+
type: import_v44.z.literal("ping")
|
|
1668
1668
|
})
|
|
1669
1669
|
]);
|
|
1670
|
-
var anthropicReasoningMetadataSchema =
|
|
1671
|
-
signature:
|
|
1672
|
-
redactedData:
|
|
1670
|
+
var anthropicReasoningMetadataSchema = import_v44.z.object({
|
|
1671
|
+
signature: import_v44.z.string().optional(),
|
|
1672
|
+
redactedData: import_v44.z.string().optional()
|
|
1673
1673
|
});
|
|
1674
1674
|
|
|
1675
1675
|
// src/tool/bash_20241022.ts
|
|
1676
1676
|
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1677
|
-
var
|
|
1677
|
+
var import_v45 = __toESM(require("zod/v4"));
|
|
1678
1678
|
var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
1679
1679
|
id: "anthropic.bash_20241022",
|
|
1680
1680
|
name: "bash",
|
|
1681
|
-
inputSchema:
|
|
1682
|
-
command:
|
|
1683
|
-
restart:
|
|
1681
|
+
inputSchema: import_v45.default.object({
|
|
1682
|
+
command: import_v45.default.string(),
|
|
1683
|
+
restart: import_v45.default.boolean().optional()
|
|
1684
1684
|
})
|
|
1685
1685
|
});
|
|
1686
1686
|
|
|
1687
1687
|
// src/tool/bash_20250124.ts
|
|
1688
1688
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1689
|
-
var
|
|
1689
|
+
var import_v46 = __toESM(require("zod/v4"));
|
|
1690
1690
|
var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
|
|
1691
1691
|
id: "anthropic.bashTool_20250124",
|
|
1692
1692
|
name: "bash",
|
|
1693
|
-
inputSchema:
|
|
1694
|
-
command:
|
|
1695
|
-
restart:
|
|
1693
|
+
inputSchema: import_v46.default.object({
|
|
1694
|
+
command: import_v46.default.string(),
|
|
1695
|
+
restart: import_v46.default.boolean().optional()
|
|
1696
1696
|
})
|
|
1697
1697
|
});
|
|
1698
1698
|
|
|
1699
1699
|
// src/tool/computer_20241022.ts
|
|
1700
1700
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1701
|
-
var
|
|
1701
|
+
var import_v47 = require("zod/v4");
|
|
1702
1702
|
var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
|
|
1703
1703
|
id: "anthropic.computer_20241022",
|
|
1704
1704
|
name: "computer",
|
|
1705
|
-
inputSchema:
|
|
1706
|
-
action:
|
|
1705
|
+
inputSchema: import_v47.z.object({
|
|
1706
|
+
action: import_v47.z.enum([
|
|
1707
1707
|
"key",
|
|
1708
1708
|
"type",
|
|
1709
1709
|
"mouse_move",
|
|
@@ -1715,19 +1715,19 @@ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFact
|
|
|
1715
1715
|
"screenshot",
|
|
1716
1716
|
"cursor_position"
|
|
1717
1717
|
]),
|
|
1718
|
-
coordinate:
|
|
1719
|
-
text:
|
|
1718
|
+
coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
|
|
1719
|
+
text: import_v47.z.string().optional()
|
|
1720
1720
|
})
|
|
1721
1721
|
});
|
|
1722
1722
|
|
|
1723
1723
|
// src/tool/computer_20250124.ts
|
|
1724
1724
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1725
|
-
var
|
|
1725
|
+
var import_v48 = require("zod/v4");
|
|
1726
1726
|
var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1727
1727
|
id: "anthropic.computer_20250124",
|
|
1728
1728
|
name: "computer",
|
|
1729
|
-
inputSchema:
|
|
1730
|
-
action:
|
|
1729
|
+
inputSchema: import_v48.z.object({
|
|
1730
|
+
action: import_v48.z.enum([
|
|
1731
1731
|
"key",
|
|
1732
1732
|
"hold_key",
|
|
1733
1733
|
"type",
|
|
@@ -1745,46 +1745,46 @@ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFact
|
|
|
1745
1745
|
"wait",
|
|
1746
1746
|
"screenshot"
|
|
1747
1747
|
]),
|
|
1748
|
-
coordinate:
|
|
1749
|
-
duration:
|
|
1750
|
-
scroll_amount:
|
|
1751
|
-
scroll_direction:
|
|
1752
|
-
start_coordinate:
|
|
1753
|
-
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()
|
|
1754
1754
|
})
|
|
1755
1755
|
});
|
|
1756
1756
|
|
|
1757
1757
|
// src/tool/text-editor_20241022.ts
|
|
1758
1758
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1759
|
-
var
|
|
1759
|
+
var import_v49 = require("zod/v4");
|
|
1760
1760
|
var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1761
1761
|
id: "anthropic.text_editor_20241022",
|
|
1762
1762
|
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:
|
|
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()
|
|
1771
1771
|
})
|
|
1772
1772
|
});
|
|
1773
1773
|
|
|
1774
1774
|
// src/tool/text-editor_20250124.ts
|
|
1775
1775
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1776
|
-
var
|
|
1776
|
+
var import_v410 = require("zod/v4");
|
|
1777
1777
|
var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1778
1778
|
id: "anthropic.text_editor_20250124",
|
|
1779
1779
|
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:
|
|
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()
|
|
1788
1788
|
})
|
|
1789
1789
|
});
|
|
1790
1790
|
|