@ai-sdk/anthropic 2.0.0-beta.1 → 2.0.0-beta.11
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 +79 -0
- package/dist/index.d.mts +19 -29
- package/dist/index.d.ts +19 -29
- package/dist/index.js +323 -270
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -43
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +14 -1
- package/dist/internal/index.d.ts +14 -1
- package/dist/internal/index.js +319 -266
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +96 -43
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -37,21 +37,21 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
37
|
|
|
38
38
|
// src/anthropic-provider.ts
|
|
39
39
|
var import_provider4 = require("@ai-sdk/provider");
|
|
40
|
-
var
|
|
40
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
41
41
|
|
|
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,82 +60,95 @@ 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:
|
|
92
|
-
}).optional()
|
|
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
|
+
}).optional(),
|
|
93
|
+
/**
|
|
94
|
+
* Whether to disable parallel function calling during tool use. Default is false.
|
|
95
|
+
* When set to true, Claude will use at most one tool per response.
|
|
96
|
+
*/
|
|
97
|
+
disableParallelToolUse: import_v42.z.boolean().optional()
|
|
93
98
|
});
|
|
94
99
|
|
|
95
100
|
// src/anthropic-prepare-tools.ts
|
|
96
101
|
var import_provider = require("@ai-sdk/provider");
|
|
97
102
|
|
|
103
|
+
// src/get-cache-control.ts
|
|
104
|
+
function getCacheControl(providerMetadata) {
|
|
105
|
+
var _a;
|
|
106
|
+
const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
107
|
+
const cacheControlValue = (_a = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a : anthropic2 == null ? void 0 : anthropic2.cache_control;
|
|
108
|
+
return cacheControlValue;
|
|
109
|
+
}
|
|
110
|
+
|
|
98
111
|
// src/tool/web-search_20250305.ts
|
|
99
112
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
100
|
-
var
|
|
101
|
-
var webSearch_20250305ArgsSchema =
|
|
113
|
+
var import_v43 = require("zod/v4");
|
|
114
|
+
var webSearch_20250305ArgsSchema = import_v43.z.object({
|
|
102
115
|
/**
|
|
103
116
|
* Maximum number of web searches Claude can perform during the conversation.
|
|
104
117
|
*/
|
|
105
|
-
maxUses:
|
|
118
|
+
maxUses: import_v43.z.number().optional(),
|
|
106
119
|
/**
|
|
107
120
|
* Optional list of domains that Claude is allowed to search.
|
|
108
121
|
*/
|
|
109
|
-
allowedDomains:
|
|
122
|
+
allowedDomains: import_v43.z.array(import_v43.z.string()).optional(),
|
|
110
123
|
/**
|
|
111
124
|
* Optional list of domains that Claude should avoid when searching.
|
|
112
125
|
*/
|
|
113
|
-
blockedDomains:
|
|
126
|
+
blockedDomains: import_v43.z.array(import_v43.z.string()).optional(),
|
|
114
127
|
/**
|
|
115
128
|
* Optional user location information to provide geographically relevant search results.
|
|
116
129
|
*/
|
|
117
|
-
userLocation:
|
|
118
|
-
type:
|
|
119
|
-
city:
|
|
120
|
-
region:
|
|
121
|
-
country:
|
|
122
|
-
timezone:
|
|
130
|
+
userLocation: import_v43.z.object({
|
|
131
|
+
type: import_v43.z.literal("approximate"),
|
|
132
|
+
city: import_v43.z.string().optional(),
|
|
133
|
+
region: import_v43.z.string().optional(),
|
|
134
|
+
country: import_v43.z.string().optional(),
|
|
135
|
+
timezone: import_v43.z.string().optional()
|
|
123
136
|
}).optional()
|
|
124
137
|
});
|
|
125
|
-
var webSearch_20250305OutputSchema =
|
|
126
|
-
|
|
127
|
-
url:
|
|
128
|
-
title:
|
|
129
|
-
pageAge:
|
|
130
|
-
encryptedContent:
|
|
131
|
-
type:
|
|
138
|
+
var webSearch_20250305OutputSchema = import_v43.z.array(
|
|
139
|
+
import_v43.z.object({
|
|
140
|
+
url: import_v43.z.string(),
|
|
141
|
+
title: import_v43.z.string(),
|
|
142
|
+
pageAge: import_v43.z.string().nullable(),
|
|
143
|
+
encryptedContent: import_v43.z.string(),
|
|
144
|
+
type: import_v43.z.string()
|
|
132
145
|
})
|
|
133
146
|
);
|
|
134
147
|
var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
135
148
|
id: "anthropic.web_search_20250305",
|
|
136
149
|
name: "web_search",
|
|
137
|
-
inputSchema:
|
|
138
|
-
query:
|
|
150
|
+
inputSchema: import_v43.z.object({
|
|
151
|
+
query: import_v43.z.string()
|
|
139
152
|
}),
|
|
140
153
|
outputSchema: webSearch_20250305OutputSchema
|
|
141
154
|
});
|
|
@@ -149,7 +162,8 @@ function isWebSearchTool(tool) {
|
|
|
149
162
|
}
|
|
150
163
|
function prepareTools({
|
|
151
164
|
tools,
|
|
152
|
-
toolChoice
|
|
165
|
+
toolChoice,
|
|
166
|
+
disableParallelToolUse
|
|
153
167
|
}) {
|
|
154
168
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
155
169
|
const toolWarnings = [];
|
|
@@ -165,10 +179,12 @@ function prepareTools({
|
|
|
165
179
|
}
|
|
166
180
|
switch (tool.type) {
|
|
167
181
|
case "function":
|
|
182
|
+
const cacheControl = getCacheControl(tool.providerOptions);
|
|
168
183
|
anthropicTools2.push({
|
|
169
184
|
name: tool.name,
|
|
170
185
|
description: tool.description,
|
|
171
|
-
input_schema: tool.inputSchema
|
|
186
|
+
input_schema: tool.inputSchema,
|
|
187
|
+
cache_control: cacheControl
|
|
172
188
|
});
|
|
173
189
|
break;
|
|
174
190
|
case "provider-defined":
|
|
@@ -207,6 +223,13 @@ function prepareTools({
|
|
|
207
223
|
type: "text_editor_20241022"
|
|
208
224
|
});
|
|
209
225
|
break;
|
|
226
|
+
case "anthropic.text_editor_20250429":
|
|
227
|
+
betas.add("computer-use-2025-01-24");
|
|
228
|
+
anthropicTools2.push({
|
|
229
|
+
name: "str_replace_based_edit_tool",
|
|
230
|
+
type: "text_editor_20250429"
|
|
231
|
+
});
|
|
232
|
+
break;
|
|
210
233
|
case "anthropic.bash_20250124":
|
|
211
234
|
betas.add("computer-use-2025-01-24");
|
|
212
235
|
anthropicTools2.push({
|
|
@@ -246,7 +269,7 @@ function prepareTools({
|
|
|
246
269
|
if (toolChoice == null) {
|
|
247
270
|
return {
|
|
248
271
|
tools: anthropicTools2,
|
|
249
|
-
toolChoice: void 0,
|
|
272
|
+
toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
|
|
250
273
|
toolWarnings,
|
|
251
274
|
betas
|
|
252
275
|
};
|
|
@@ -256,14 +279,20 @@ function prepareTools({
|
|
|
256
279
|
case "auto":
|
|
257
280
|
return {
|
|
258
281
|
tools: anthropicTools2,
|
|
259
|
-
toolChoice: {
|
|
282
|
+
toolChoice: {
|
|
283
|
+
type: "auto",
|
|
284
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
285
|
+
},
|
|
260
286
|
toolWarnings,
|
|
261
287
|
betas
|
|
262
288
|
};
|
|
263
289
|
case "required":
|
|
264
290
|
return {
|
|
265
291
|
tools: anthropicTools2,
|
|
266
|
-
toolChoice: {
|
|
292
|
+
toolChoice: {
|
|
293
|
+
type: "any",
|
|
294
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
295
|
+
},
|
|
267
296
|
toolWarnings,
|
|
268
297
|
betas
|
|
269
298
|
};
|
|
@@ -272,7 +301,11 @@ function prepareTools({
|
|
|
272
301
|
case "tool":
|
|
273
302
|
return {
|
|
274
303
|
tools: anthropicTools2,
|
|
275
|
-
toolChoice: {
|
|
304
|
+
toolChoice: {
|
|
305
|
+
type: "tool",
|
|
306
|
+
name: toolChoice.toolName,
|
|
307
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
308
|
+
},
|
|
276
309
|
toolWarnings,
|
|
277
310
|
betas
|
|
278
311
|
};
|
|
@@ -314,12 +347,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
314
347
|
const blocks = groupIntoBlocks(prompt);
|
|
315
348
|
let system = void 0;
|
|
316
349
|
const messages = [];
|
|
317
|
-
function getCacheControl(providerMetadata) {
|
|
318
|
-
var _a2;
|
|
319
|
-
const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
320
|
-
const cacheControlValue = (_a2 = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a2 : anthropic2 == null ? void 0 : anthropic2.cache_control;
|
|
321
|
-
return cacheControlValue;
|
|
322
|
-
}
|
|
323
350
|
async function shouldEnableCitations(providerMetadata) {
|
|
324
351
|
var _a2, _b2;
|
|
325
352
|
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
@@ -725,36 +752,36 @@ function mapAnthropicStopReason({
|
|
|
725
752
|
|
|
726
753
|
// src/anthropic-messages-language-model.ts
|
|
727
754
|
var citationSchemas = {
|
|
728
|
-
webSearchResult:
|
|
729
|
-
type:
|
|
730
|
-
cited_text:
|
|
731
|
-
url:
|
|
732
|
-
title:
|
|
733
|
-
encrypted_index:
|
|
755
|
+
webSearchResult: import_v44.z.object({
|
|
756
|
+
type: import_v44.z.literal("web_search_result_location"),
|
|
757
|
+
cited_text: import_v44.z.string(),
|
|
758
|
+
url: import_v44.z.string(),
|
|
759
|
+
title: import_v44.z.string(),
|
|
760
|
+
encrypted_index: import_v44.z.string()
|
|
734
761
|
}),
|
|
735
|
-
pageLocation:
|
|
736
|
-
type:
|
|
737
|
-
cited_text:
|
|
738
|
-
document_index:
|
|
739
|
-
document_title:
|
|
740
|
-
start_page_number:
|
|
741
|
-
end_page_number:
|
|
762
|
+
pageLocation: import_v44.z.object({
|
|
763
|
+
type: import_v44.z.literal("page_location"),
|
|
764
|
+
cited_text: import_v44.z.string(),
|
|
765
|
+
document_index: import_v44.z.number(),
|
|
766
|
+
document_title: import_v44.z.string().nullable(),
|
|
767
|
+
start_page_number: import_v44.z.number(),
|
|
768
|
+
end_page_number: import_v44.z.number()
|
|
742
769
|
}),
|
|
743
|
-
charLocation:
|
|
744
|
-
type:
|
|
745
|
-
cited_text:
|
|
746
|
-
document_index:
|
|
747
|
-
document_title:
|
|
748
|
-
start_char_index:
|
|
749
|
-
end_char_index:
|
|
770
|
+
charLocation: import_v44.z.object({
|
|
771
|
+
type: import_v44.z.literal("char_location"),
|
|
772
|
+
cited_text: import_v44.z.string(),
|
|
773
|
+
document_index: import_v44.z.number(),
|
|
774
|
+
document_title: import_v44.z.string().nullable(),
|
|
775
|
+
start_char_index: import_v44.z.number(),
|
|
776
|
+
end_char_index: import_v44.z.number()
|
|
750
777
|
})
|
|
751
778
|
};
|
|
752
|
-
var citationSchema =
|
|
779
|
+
var citationSchema = import_v44.z.discriminatedUnion("type", [
|
|
753
780
|
citationSchemas.webSearchResult,
|
|
754
781
|
citationSchemas.pageLocation,
|
|
755
782
|
citationSchemas.charLocation
|
|
756
783
|
]);
|
|
757
|
-
var documentCitationSchema =
|
|
784
|
+
var documentCitationSchema = import_v44.z.discriminatedUnion("type", [
|
|
758
785
|
citationSchemas.pageLocation,
|
|
759
786
|
citationSchemas.charLocation
|
|
760
787
|
]);
|
|
@@ -941,8 +968,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
941
968
|
} = prepareTools(
|
|
942
969
|
jsonResponseTool != null ? {
|
|
943
970
|
tools: [jsonResponseTool],
|
|
944
|
-
toolChoice: { type: "tool", toolName: jsonResponseTool.name }
|
|
945
|
-
|
|
971
|
+
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
972
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
973
|
+
} : {
|
|
974
|
+
tools: tools != null ? tools : [],
|
|
975
|
+
toolChoice,
|
|
976
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
977
|
+
}
|
|
946
978
|
);
|
|
947
979
|
return {
|
|
948
980
|
args: {
|
|
@@ -952,7 +984,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
952
984
|
},
|
|
953
985
|
warnings: [...warnings, ...toolWarnings],
|
|
954
986
|
betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
|
|
955
|
-
jsonResponseTool
|
|
987
|
+
usesJsonResponseTool: jsonResponseTool != null
|
|
956
988
|
};
|
|
957
989
|
}
|
|
958
990
|
async getHeaders({
|
|
@@ -998,7 +1030,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
998
1030
|
}
|
|
999
1031
|
async doGenerate(options) {
|
|
1000
1032
|
var _a, _b, _c, _d, _e;
|
|
1001
|
-
const { args, warnings, betas,
|
|
1033
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1002
1034
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1003
1035
|
const {
|
|
1004
1036
|
responseHeaders,
|
|
@@ -1019,7 +1051,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1019
1051
|
for (const part of response.content) {
|
|
1020
1052
|
switch (part.type) {
|
|
1021
1053
|
case "text": {
|
|
1022
|
-
if (
|
|
1054
|
+
if (!usesJsonResponseTool) {
|
|
1023
1055
|
content.push({ type: "text", text: part.text });
|
|
1024
1056
|
if (part.citations) {
|
|
1025
1057
|
for (const citation of part.citations) {
|
|
@@ -1061,7 +1093,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1061
1093
|
case "tool_use": {
|
|
1062
1094
|
content.push(
|
|
1063
1095
|
// when a json response tool is used, the tool call becomes the text:
|
|
1064
|
-
|
|
1096
|
+
usesJsonResponseTool ? {
|
|
1065
1097
|
type: "text",
|
|
1066
1098
|
text: JSON.stringify(part.input)
|
|
1067
1099
|
} : {
|
|
@@ -1138,7 +1170,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1138
1170
|
content,
|
|
1139
1171
|
finishReason: mapAnthropicStopReason({
|
|
1140
1172
|
finishReason: response.stop_reason,
|
|
1141
|
-
isJsonResponseFromTool:
|
|
1173
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1142
1174
|
}),
|
|
1143
1175
|
usage: {
|
|
1144
1176
|
inputTokens: response.usage.input_tokens,
|
|
@@ -1156,13 +1188,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1156
1188
|
warnings,
|
|
1157
1189
|
providerMetadata: {
|
|
1158
1190
|
anthropic: {
|
|
1191
|
+
usage: response.usage,
|
|
1159
1192
|
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
|
|
1160
1193
|
}
|
|
1161
1194
|
}
|
|
1162
1195
|
};
|
|
1163
1196
|
}
|
|
1164
1197
|
async doStream(options) {
|
|
1165
|
-
const { args, warnings, betas,
|
|
1198
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1166
1199
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1167
1200
|
const body = { ...args, stream: true };
|
|
1168
1201
|
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
@@ -1240,16 +1273,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1240
1273
|
return;
|
|
1241
1274
|
}
|
|
1242
1275
|
case "tool_use": {
|
|
1243
|
-
contentBlocks[value.index] =
|
|
1276
|
+
contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
|
|
1244
1277
|
type: "tool-call",
|
|
1245
1278
|
toolCallId: value.content_block.id,
|
|
1246
1279
|
toolName: value.content_block.name,
|
|
1247
1280
|
input: ""
|
|
1248
1281
|
};
|
|
1249
1282
|
controller.enqueue(
|
|
1250
|
-
|
|
1283
|
+
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
1251
1284
|
type: "tool-input-start",
|
|
1252
|
-
id:
|
|
1285
|
+
id: value.content_block.id,
|
|
1253
1286
|
toolName: value.content_block.name
|
|
1254
1287
|
}
|
|
1255
1288
|
);
|
|
@@ -1348,7 +1381,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1348
1381
|
break;
|
|
1349
1382
|
}
|
|
1350
1383
|
case "tool-call":
|
|
1351
|
-
if (
|
|
1384
|
+
if (!usesJsonResponseTool) {
|
|
1352
1385
|
controller.enqueue({
|
|
1353
1386
|
type: "tool-input-end",
|
|
1354
1387
|
id: contentBlock.toolCallId
|
|
@@ -1366,7 +1399,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1366
1399
|
const deltaType = value.delta.type;
|
|
1367
1400
|
switch (deltaType) {
|
|
1368
1401
|
case "text_delta": {
|
|
1369
|
-
if (
|
|
1402
|
+
if (usesJsonResponseTool) {
|
|
1370
1403
|
return;
|
|
1371
1404
|
}
|
|
1372
1405
|
controller.enqueue({
|
|
@@ -1402,16 +1435,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1402
1435
|
case "input_json_delta": {
|
|
1403
1436
|
const contentBlock = contentBlocks[value.index];
|
|
1404
1437
|
const delta = value.delta.partial_json;
|
|
1405
|
-
if (
|
|
1406
|
-
if ((contentBlock == null ? void 0 : contentBlock.type) !== "
|
|
1438
|
+
if (usesJsonResponseTool) {
|
|
1439
|
+
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
1407
1440
|
return;
|
|
1408
1441
|
}
|
|
1409
1442
|
controller.enqueue({
|
|
1410
|
-
type: "
|
|
1411
|
-
id:
|
|
1443
|
+
type: "text-delta",
|
|
1444
|
+
id: String(value.index),
|
|
1412
1445
|
delta
|
|
1413
1446
|
});
|
|
1414
|
-
contentBlock.input += delta;
|
|
1415
1447
|
} else {
|
|
1416
1448
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
1417
1449
|
return;
|
|
@@ -1421,6 +1453,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1421
1453
|
id: contentBlock.toolCallId,
|
|
1422
1454
|
delta
|
|
1423
1455
|
});
|
|
1456
|
+
contentBlock.input += delta;
|
|
1424
1457
|
}
|
|
1425
1458
|
return;
|
|
1426
1459
|
}
|
|
@@ -1447,6 +1480,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1447
1480
|
usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
|
|
1448
1481
|
providerMetadata = {
|
|
1449
1482
|
anthropic: {
|
|
1483
|
+
usage: value.message.usage,
|
|
1450
1484
|
cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
|
|
1451
1485
|
}
|
|
1452
1486
|
};
|
|
@@ -1462,7 +1496,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1462
1496
|
usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
|
|
1463
1497
|
finishReason = mapAnthropicStopReason({
|
|
1464
1498
|
finishReason: value.delta.stop_reason,
|
|
1465
|
-
isJsonResponseFromTool:
|
|
1499
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1466
1500
|
});
|
|
1467
1501
|
return;
|
|
1468
1502
|
}
|
|
@@ -1492,218 +1526,215 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1492
1526
|
};
|
|
1493
1527
|
}
|
|
1494
1528
|
};
|
|
1495
|
-
var anthropicMessagesResponseSchema =
|
|
1496
|
-
type:
|
|
1497
|
-
id:
|
|
1498
|
-
model:
|
|
1499
|
-
content:
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
type:
|
|
1503
|
-
text:
|
|
1504
|
-
citations:
|
|
1529
|
+
var anthropicMessagesResponseSchema = import_v44.z.object({
|
|
1530
|
+
type: import_v44.z.literal("message"),
|
|
1531
|
+
id: import_v44.z.string().nullish(),
|
|
1532
|
+
model: import_v44.z.string().nullish(),
|
|
1533
|
+
content: import_v44.z.array(
|
|
1534
|
+
import_v44.z.discriminatedUnion("type", [
|
|
1535
|
+
import_v44.z.object({
|
|
1536
|
+
type: import_v44.z.literal("text"),
|
|
1537
|
+
text: import_v44.z.string(),
|
|
1538
|
+
citations: import_v44.z.array(citationSchema).optional()
|
|
1505
1539
|
}),
|
|
1506
|
-
|
|
1507
|
-
type:
|
|
1508
|
-
thinking:
|
|
1509
|
-
signature:
|
|
1540
|
+
import_v44.z.object({
|
|
1541
|
+
type: import_v44.z.literal("thinking"),
|
|
1542
|
+
thinking: import_v44.z.string(),
|
|
1543
|
+
signature: import_v44.z.string()
|
|
1510
1544
|
}),
|
|
1511
|
-
|
|
1512
|
-
type:
|
|
1513
|
-
data:
|
|
1545
|
+
import_v44.z.object({
|
|
1546
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1547
|
+
data: import_v44.z.string()
|
|
1514
1548
|
}),
|
|
1515
|
-
|
|
1516
|
-
type:
|
|
1517
|
-
id:
|
|
1518
|
-
name:
|
|
1519
|
-
input:
|
|
1549
|
+
import_v44.z.object({
|
|
1550
|
+
type: import_v44.z.literal("tool_use"),
|
|
1551
|
+
id: import_v44.z.string(),
|
|
1552
|
+
name: import_v44.z.string(),
|
|
1553
|
+
input: import_v44.z.unknown()
|
|
1520
1554
|
}),
|
|
1521
|
-
|
|
1522
|
-
type:
|
|
1523
|
-
id:
|
|
1524
|
-
name:
|
|
1525
|
-
input:
|
|
1555
|
+
import_v44.z.object({
|
|
1556
|
+
type: import_v44.z.literal("server_tool_use"),
|
|
1557
|
+
id: import_v44.z.string(),
|
|
1558
|
+
name: import_v44.z.string(),
|
|
1559
|
+
input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
|
|
1526
1560
|
}),
|
|
1527
|
-
|
|
1528
|
-
type:
|
|
1529
|
-
tool_use_id:
|
|
1530
|
-
content:
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
type:
|
|
1534
|
-
url:
|
|
1535
|
-
title:
|
|
1536
|
-
encrypted_content:
|
|
1537
|
-
page_age:
|
|
1561
|
+
import_v44.z.object({
|
|
1562
|
+
type: import_v44.z.literal("web_search_tool_result"),
|
|
1563
|
+
tool_use_id: import_v44.z.string(),
|
|
1564
|
+
content: import_v44.z.union([
|
|
1565
|
+
import_v44.z.array(
|
|
1566
|
+
import_v44.z.object({
|
|
1567
|
+
type: import_v44.z.literal("web_search_result"),
|
|
1568
|
+
url: import_v44.z.string(),
|
|
1569
|
+
title: import_v44.z.string(),
|
|
1570
|
+
encrypted_content: import_v44.z.string(),
|
|
1571
|
+
page_age: import_v44.z.string().nullish()
|
|
1538
1572
|
})
|
|
1539
1573
|
),
|
|
1540
|
-
|
|
1541
|
-
type:
|
|
1542
|
-
error_code:
|
|
1574
|
+
import_v44.z.object({
|
|
1575
|
+
type: import_v44.z.literal("web_search_tool_result_error"),
|
|
1576
|
+
error_code: import_v44.z.string()
|
|
1543
1577
|
})
|
|
1544
1578
|
])
|
|
1545
1579
|
})
|
|
1546
1580
|
])
|
|
1547
1581
|
),
|
|
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: import_zod3.z.object({
|
|
1555
|
-
web_search_requests: import_zod3.z.number()
|
|
1556
|
-
}).nullish()
|
|
1582
|
+
stop_reason: import_v44.z.string().nullish(),
|
|
1583
|
+
usage: import_v44.z.looseObject({
|
|
1584
|
+
input_tokens: import_v44.z.number(),
|
|
1585
|
+
output_tokens: import_v44.z.number(),
|
|
1586
|
+
cache_creation_input_tokens: import_v44.z.number().nullish(),
|
|
1587
|
+
cache_read_input_tokens: import_v44.z.number().nullish()
|
|
1557
1588
|
})
|
|
1558
1589
|
});
|
|
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:
|
|
1590
|
+
var anthropicMessagesChunkSchema = import_v44.z.discriminatedUnion("type", [
|
|
1591
|
+
import_v44.z.object({
|
|
1592
|
+
type: import_v44.z.literal("message_start"),
|
|
1593
|
+
message: import_v44.z.object({
|
|
1594
|
+
id: import_v44.z.string().nullish(),
|
|
1595
|
+
model: import_v44.z.string().nullish(),
|
|
1596
|
+
usage: import_v44.z.looseObject({
|
|
1597
|
+
input_tokens: import_v44.z.number(),
|
|
1598
|
+
output_tokens: import_v44.z.number(),
|
|
1599
|
+
cache_creation_input_tokens: import_v44.z.number().nullish(),
|
|
1600
|
+
cache_read_input_tokens: import_v44.z.number().nullish()
|
|
1570
1601
|
})
|
|
1571
1602
|
})
|
|
1572
1603
|
}),
|
|
1573
|
-
|
|
1574
|
-
type:
|
|
1575
|
-
index:
|
|
1576
|
-
content_block:
|
|
1577
|
-
|
|
1578
|
-
type:
|
|
1579
|
-
text:
|
|
1604
|
+
import_v44.z.object({
|
|
1605
|
+
type: import_v44.z.literal("content_block_start"),
|
|
1606
|
+
index: import_v44.z.number(),
|
|
1607
|
+
content_block: import_v44.z.discriminatedUnion("type", [
|
|
1608
|
+
import_v44.z.object({
|
|
1609
|
+
type: import_v44.z.literal("text"),
|
|
1610
|
+
text: import_v44.z.string()
|
|
1580
1611
|
}),
|
|
1581
|
-
|
|
1582
|
-
type:
|
|
1583
|
-
thinking:
|
|
1612
|
+
import_v44.z.object({
|
|
1613
|
+
type: import_v44.z.literal("thinking"),
|
|
1614
|
+
thinking: import_v44.z.string()
|
|
1584
1615
|
}),
|
|
1585
|
-
|
|
1586
|
-
type:
|
|
1587
|
-
id:
|
|
1588
|
-
name:
|
|
1616
|
+
import_v44.z.object({
|
|
1617
|
+
type: import_v44.z.literal("tool_use"),
|
|
1618
|
+
id: import_v44.z.string(),
|
|
1619
|
+
name: import_v44.z.string()
|
|
1589
1620
|
}),
|
|
1590
|
-
|
|
1591
|
-
type:
|
|
1592
|
-
data:
|
|
1621
|
+
import_v44.z.object({
|
|
1622
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1623
|
+
data: import_v44.z.string()
|
|
1593
1624
|
}),
|
|
1594
|
-
|
|
1595
|
-
type:
|
|
1596
|
-
id:
|
|
1597
|
-
name:
|
|
1598
|
-
input:
|
|
1625
|
+
import_v44.z.object({
|
|
1626
|
+
type: import_v44.z.literal("server_tool_use"),
|
|
1627
|
+
id: import_v44.z.string(),
|
|
1628
|
+
name: import_v44.z.string(),
|
|
1629
|
+
input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
|
|
1599
1630
|
}),
|
|
1600
|
-
|
|
1601
|
-
type:
|
|
1602
|
-
tool_use_id:
|
|
1603
|
-
content:
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
type:
|
|
1607
|
-
url:
|
|
1608
|
-
title:
|
|
1609
|
-
encrypted_content:
|
|
1610
|
-
page_age:
|
|
1631
|
+
import_v44.z.object({
|
|
1632
|
+
type: import_v44.z.literal("web_search_tool_result"),
|
|
1633
|
+
tool_use_id: import_v44.z.string(),
|
|
1634
|
+
content: import_v44.z.union([
|
|
1635
|
+
import_v44.z.array(
|
|
1636
|
+
import_v44.z.object({
|
|
1637
|
+
type: import_v44.z.literal("web_search_result"),
|
|
1638
|
+
url: import_v44.z.string(),
|
|
1639
|
+
title: import_v44.z.string(),
|
|
1640
|
+
encrypted_content: import_v44.z.string(),
|
|
1641
|
+
page_age: import_v44.z.string().nullish()
|
|
1611
1642
|
})
|
|
1612
1643
|
),
|
|
1613
|
-
|
|
1614
|
-
type:
|
|
1615
|
-
error_code:
|
|
1644
|
+
import_v44.z.object({
|
|
1645
|
+
type: import_v44.z.literal("web_search_tool_result_error"),
|
|
1646
|
+
error_code: import_v44.z.string()
|
|
1616
1647
|
})
|
|
1617
1648
|
])
|
|
1618
1649
|
})
|
|
1619
1650
|
])
|
|
1620
1651
|
}),
|
|
1621
|
-
|
|
1622
|
-
type:
|
|
1623
|
-
index:
|
|
1624
|
-
delta:
|
|
1625
|
-
|
|
1626
|
-
type:
|
|
1627
|
-
partial_json:
|
|
1652
|
+
import_v44.z.object({
|
|
1653
|
+
type: import_v44.z.literal("content_block_delta"),
|
|
1654
|
+
index: import_v44.z.number(),
|
|
1655
|
+
delta: import_v44.z.discriminatedUnion("type", [
|
|
1656
|
+
import_v44.z.object({
|
|
1657
|
+
type: import_v44.z.literal("input_json_delta"),
|
|
1658
|
+
partial_json: import_v44.z.string()
|
|
1628
1659
|
}),
|
|
1629
|
-
|
|
1630
|
-
type:
|
|
1631
|
-
text:
|
|
1660
|
+
import_v44.z.object({
|
|
1661
|
+
type: import_v44.z.literal("text_delta"),
|
|
1662
|
+
text: import_v44.z.string()
|
|
1632
1663
|
}),
|
|
1633
|
-
|
|
1634
|
-
type:
|
|
1635
|
-
thinking:
|
|
1664
|
+
import_v44.z.object({
|
|
1665
|
+
type: import_v44.z.literal("thinking_delta"),
|
|
1666
|
+
thinking: import_v44.z.string()
|
|
1636
1667
|
}),
|
|
1637
|
-
|
|
1638
|
-
type:
|
|
1639
|
-
signature:
|
|
1668
|
+
import_v44.z.object({
|
|
1669
|
+
type: import_v44.z.literal("signature_delta"),
|
|
1670
|
+
signature: import_v44.z.string()
|
|
1640
1671
|
}),
|
|
1641
|
-
|
|
1642
|
-
type:
|
|
1672
|
+
import_v44.z.object({
|
|
1673
|
+
type: import_v44.z.literal("citations_delta"),
|
|
1643
1674
|
citation: citationSchema
|
|
1644
1675
|
})
|
|
1645
1676
|
])
|
|
1646
1677
|
}),
|
|
1647
|
-
|
|
1648
|
-
type:
|
|
1649
|
-
index:
|
|
1678
|
+
import_v44.z.object({
|
|
1679
|
+
type: import_v44.z.literal("content_block_stop"),
|
|
1680
|
+
index: import_v44.z.number()
|
|
1650
1681
|
}),
|
|
1651
|
-
|
|
1652
|
-
type:
|
|
1653
|
-
error:
|
|
1654
|
-
type:
|
|
1655
|
-
message:
|
|
1682
|
+
import_v44.z.object({
|
|
1683
|
+
type: import_v44.z.literal("error"),
|
|
1684
|
+
error: import_v44.z.object({
|
|
1685
|
+
type: import_v44.z.string(),
|
|
1686
|
+
message: import_v44.z.string()
|
|
1656
1687
|
})
|
|
1657
1688
|
}),
|
|
1658
|
-
|
|
1659
|
-
type:
|
|
1660
|
-
delta:
|
|
1661
|
-
usage:
|
|
1689
|
+
import_v44.z.object({
|
|
1690
|
+
type: import_v44.z.literal("message_delta"),
|
|
1691
|
+
delta: import_v44.z.object({ stop_reason: import_v44.z.string().nullish() }),
|
|
1692
|
+
usage: import_v44.z.object({ output_tokens: import_v44.z.number() })
|
|
1662
1693
|
}),
|
|
1663
|
-
|
|
1664
|
-
type:
|
|
1694
|
+
import_v44.z.object({
|
|
1695
|
+
type: import_v44.z.literal("message_stop")
|
|
1665
1696
|
}),
|
|
1666
|
-
|
|
1667
|
-
type:
|
|
1697
|
+
import_v44.z.object({
|
|
1698
|
+
type: import_v44.z.literal("ping")
|
|
1668
1699
|
})
|
|
1669
1700
|
]);
|
|
1670
|
-
var anthropicReasoningMetadataSchema =
|
|
1671
|
-
signature:
|
|
1672
|
-
redactedData:
|
|
1701
|
+
var anthropicReasoningMetadataSchema = import_v44.z.object({
|
|
1702
|
+
signature: import_v44.z.string().optional(),
|
|
1703
|
+
redactedData: import_v44.z.string().optional()
|
|
1673
1704
|
});
|
|
1674
1705
|
|
|
1675
1706
|
// src/tool/bash_20241022.ts
|
|
1676
1707
|
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1677
|
-
var
|
|
1708
|
+
var import_v45 = __toESM(require("zod/v4"));
|
|
1678
1709
|
var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
1679
1710
|
id: "anthropic.bash_20241022",
|
|
1680
1711
|
name: "bash",
|
|
1681
|
-
inputSchema:
|
|
1682
|
-
command:
|
|
1683
|
-
restart:
|
|
1712
|
+
inputSchema: import_v45.default.object({
|
|
1713
|
+
command: import_v45.default.string(),
|
|
1714
|
+
restart: import_v45.default.boolean().optional()
|
|
1684
1715
|
})
|
|
1685
1716
|
});
|
|
1686
1717
|
|
|
1687
1718
|
// src/tool/bash_20250124.ts
|
|
1688
1719
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1689
|
-
var
|
|
1720
|
+
var import_v46 = __toESM(require("zod/v4"));
|
|
1690
1721
|
var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
|
|
1691
1722
|
id: "anthropic.bashTool_20250124",
|
|
1692
1723
|
name: "bash",
|
|
1693
|
-
inputSchema:
|
|
1694
|
-
command:
|
|
1695
|
-
restart:
|
|
1724
|
+
inputSchema: import_v46.default.object({
|
|
1725
|
+
command: import_v46.default.string(),
|
|
1726
|
+
restart: import_v46.default.boolean().optional()
|
|
1696
1727
|
})
|
|
1697
1728
|
});
|
|
1698
1729
|
|
|
1699
1730
|
// src/tool/computer_20241022.ts
|
|
1700
1731
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1701
|
-
var
|
|
1732
|
+
var import_v47 = require("zod/v4");
|
|
1702
1733
|
var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
|
|
1703
1734
|
id: "anthropic.computer_20241022",
|
|
1704
1735
|
name: "computer",
|
|
1705
|
-
inputSchema:
|
|
1706
|
-
action:
|
|
1736
|
+
inputSchema: import_v47.z.object({
|
|
1737
|
+
action: import_v47.z.enum([
|
|
1707
1738
|
"key",
|
|
1708
1739
|
"type",
|
|
1709
1740
|
"mouse_move",
|
|
@@ -1715,19 +1746,19 @@ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFact
|
|
|
1715
1746
|
"screenshot",
|
|
1716
1747
|
"cursor_position"
|
|
1717
1748
|
]),
|
|
1718
|
-
coordinate:
|
|
1719
|
-
text:
|
|
1749
|
+
coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
|
|
1750
|
+
text: import_v47.z.string().optional()
|
|
1720
1751
|
})
|
|
1721
1752
|
});
|
|
1722
1753
|
|
|
1723
1754
|
// src/tool/computer_20250124.ts
|
|
1724
1755
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1725
|
-
var
|
|
1756
|
+
var import_v48 = require("zod/v4");
|
|
1726
1757
|
var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1727
1758
|
id: "anthropic.computer_20250124",
|
|
1728
1759
|
name: "computer",
|
|
1729
|
-
inputSchema:
|
|
1730
|
-
action:
|
|
1760
|
+
inputSchema: import_v48.z.object({
|
|
1761
|
+
action: import_v48.z.enum([
|
|
1731
1762
|
"key",
|
|
1732
1763
|
"hold_key",
|
|
1733
1764
|
"type",
|
|
@@ -1745,46 +1776,63 @@ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFact
|
|
|
1745
1776
|
"wait",
|
|
1746
1777
|
"screenshot"
|
|
1747
1778
|
]),
|
|
1748
|
-
coordinate:
|
|
1749
|
-
duration:
|
|
1750
|
-
scroll_amount:
|
|
1751
|
-
scroll_direction:
|
|
1752
|
-
start_coordinate:
|
|
1753
|
-
text:
|
|
1779
|
+
coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
|
|
1780
|
+
duration: import_v48.z.number().optional(),
|
|
1781
|
+
scroll_amount: import_v48.z.number().optional(),
|
|
1782
|
+
scroll_direction: import_v48.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1783
|
+
start_coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
|
|
1784
|
+
text: import_v48.z.string().optional()
|
|
1754
1785
|
})
|
|
1755
1786
|
});
|
|
1756
1787
|
|
|
1757
1788
|
// src/tool/text-editor_20241022.ts
|
|
1758
1789
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1759
|
-
var
|
|
1790
|
+
var import_v49 = require("zod/v4");
|
|
1760
1791
|
var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1761
1792
|
id: "anthropic.text_editor_20241022",
|
|
1762
1793
|
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:
|
|
1794
|
+
inputSchema: import_v49.z.object({
|
|
1795
|
+
command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1796
|
+
path: import_v49.z.string(),
|
|
1797
|
+
file_text: import_v49.z.string().optional(),
|
|
1798
|
+
insert_line: import_v49.z.number().int().optional(),
|
|
1799
|
+
new_str: import_v49.z.string().optional(),
|
|
1800
|
+
old_str: import_v49.z.string().optional(),
|
|
1801
|
+
view_range: import_v49.z.array(import_v49.z.number().int()).optional()
|
|
1771
1802
|
})
|
|
1772
1803
|
});
|
|
1773
1804
|
|
|
1774
1805
|
// src/tool/text-editor_20250124.ts
|
|
1775
1806
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1776
|
-
var
|
|
1807
|
+
var import_v410 = require("zod/v4");
|
|
1777
1808
|
var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1778
1809
|
id: "anthropic.text_editor_20250124",
|
|
1779
1810
|
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:
|
|
1811
|
+
inputSchema: import_v410.z.object({
|
|
1812
|
+
command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1813
|
+
path: import_v410.z.string(),
|
|
1814
|
+
file_text: import_v410.z.string().optional(),
|
|
1815
|
+
insert_line: import_v410.z.number().int().optional(),
|
|
1816
|
+
new_str: import_v410.z.string().optional(),
|
|
1817
|
+
old_str: import_v410.z.string().optional(),
|
|
1818
|
+
view_range: import_v410.z.array(import_v410.z.number().int()).optional()
|
|
1819
|
+
})
|
|
1820
|
+
});
|
|
1821
|
+
|
|
1822
|
+
// src/tool/text-editor_20250429.ts
|
|
1823
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1824
|
+
var import_v411 = require("zod/v4");
|
|
1825
|
+
var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1826
|
+
id: "anthropic.text_editor_20250429",
|
|
1827
|
+
name: "str_replace_based_edit_tool",
|
|
1828
|
+
inputSchema: import_v411.z.object({
|
|
1829
|
+
command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
|
|
1830
|
+
path: import_v411.z.string(),
|
|
1831
|
+
file_text: import_v411.z.string().optional(),
|
|
1832
|
+
insert_line: import_v411.z.number().int().optional(),
|
|
1833
|
+
new_str: import_v411.z.string().optional(),
|
|
1834
|
+
old_str: import_v411.z.string().optional(),
|
|
1835
|
+
view_range: import_v411.z.array(import_v411.z.number().int()).optional()
|
|
1788
1836
|
})
|
|
1789
1837
|
});
|
|
1790
1838
|
|
|
@@ -1814,6 +1862,11 @@ var anthropicTools = {
|
|
|
1814
1862
|
* Creates a tool for editing text. Must have name "str_replace_editor".
|
|
1815
1863
|
*/
|
|
1816
1864
|
textEditor_20250124,
|
|
1865
|
+
/**
|
|
1866
|
+
* Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
|
|
1867
|
+
* Note: This version does not support the "undo_edit" command.
|
|
1868
|
+
*/
|
|
1869
|
+
textEditor_20250429,
|
|
1817
1870
|
/**
|
|
1818
1871
|
* Creates a tool for executing actions on a computer. Must have name "computer".
|
|
1819
1872
|
*
|
|
@@ -1850,10 +1903,10 @@ var anthropicTools = {
|
|
|
1850
1903
|
// src/anthropic-provider.ts
|
|
1851
1904
|
function createAnthropic(options = {}) {
|
|
1852
1905
|
var _a;
|
|
1853
|
-
const baseURL = (_a = (0,
|
|
1906
|
+
const baseURL = (_a = (0, import_provider_utils12.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
1854
1907
|
const getHeaders = () => ({
|
|
1855
1908
|
"anthropic-version": "2023-06-01",
|
|
1856
|
-
"x-api-key": (0,
|
|
1909
|
+
"x-api-key": (0, import_provider_utils12.loadApiKey)({
|
|
1857
1910
|
apiKey: options.apiKey,
|
|
1858
1911
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
1859
1912
|
description: "Anthropic"
|
|
@@ -1867,7 +1920,7 @@ function createAnthropic(options = {}) {
|
|
|
1867
1920
|
baseURL,
|
|
1868
1921
|
headers: getHeaders,
|
|
1869
1922
|
fetch: options.fetch,
|
|
1870
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
1923
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils12.generateId,
|
|
1871
1924
|
supportedUrls: () => ({
|
|
1872
1925
|
"image/*": [/^https?:\/\/.*$/]
|
|
1873
1926
|
})
|