@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/internal/index.js
CHANGED
|
@@ -38,16 +38,16 @@ module.exports = __toCommonJS(internal_exports);
|
|
|
38
38
|
// src/anthropic-messages-language-model.ts
|
|
39
39
|
var import_provider3 = require("@ai-sdk/provider");
|
|
40
40
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
41
|
-
var
|
|
41
|
+
var import_v44 = require("zod/v4");
|
|
42
42
|
|
|
43
43
|
// src/anthropic-error.ts
|
|
44
44
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
45
|
-
var
|
|
46
|
-
var anthropicErrorDataSchema =
|
|
47
|
-
type:
|
|
48
|
-
error:
|
|
49
|
-
type:
|
|
50
|
-
message:
|
|
45
|
+
var import_v4 = require("zod/v4");
|
|
46
|
+
var anthropicErrorDataSchema = import_v4.z.object({
|
|
47
|
+
type: import_v4.z.literal("error"),
|
|
48
|
+
error: import_v4.z.object({
|
|
49
|
+
type: import_v4.z.string(),
|
|
50
|
+
message: import_v4.z.string()
|
|
51
51
|
})
|
|
52
52
|
});
|
|
53
53
|
var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
@@ -56,82 +56,95 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
// src/anthropic-messages-options.ts
|
|
59
|
-
var
|
|
60
|
-
var anthropicFilePartProviderOptions =
|
|
59
|
+
var import_v42 = require("zod/v4");
|
|
60
|
+
var anthropicFilePartProviderOptions = import_v42.z.object({
|
|
61
61
|
/**
|
|
62
62
|
* Citation configuration for this document.
|
|
63
63
|
* When enabled, this document will generate citations in the response.
|
|
64
64
|
*/
|
|
65
|
-
citations:
|
|
65
|
+
citations: import_v42.z.object({
|
|
66
66
|
/**
|
|
67
67
|
* Enable citations for this document
|
|
68
68
|
*/
|
|
69
|
-
enabled:
|
|
69
|
+
enabled: import_v42.z.boolean()
|
|
70
70
|
}).optional(),
|
|
71
71
|
/**
|
|
72
72
|
* Custom title for the document.
|
|
73
73
|
* If not provided, the filename will be used.
|
|
74
74
|
*/
|
|
75
|
-
title:
|
|
75
|
+
title: import_v42.z.string().optional(),
|
|
76
76
|
/**
|
|
77
77
|
* Context about the document that will be passed to the model
|
|
78
78
|
* but not used towards cited content.
|
|
79
79
|
* Useful for storing document metadata as text or stringified JSON.
|
|
80
80
|
*/
|
|
81
|
-
context:
|
|
81
|
+
context: import_v42.z.string().optional()
|
|
82
82
|
});
|
|
83
|
-
var anthropicProviderOptions =
|
|
84
|
-
sendReasoning:
|
|
85
|
-
thinking:
|
|
86
|
-
type:
|
|
87
|
-
budgetTokens:
|
|
88
|
-
}).optional()
|
|
83
|
+
var anthropicProviderOptions = import_v42.z.object({
|
|
84
|
+
sendReasoning: import_v42.z.boolean().optional(),
|
|
85
|
+
thinking: import_v42.z.object({
|
|
86
|
+
type: import_v42.z.union([import_v42.z.literal("enabled"), import_v42.z.literal("disabled")]),
|
|
87
|
+
budgetTokens: import_v42.z.number().optional()
|
|
88
|
+
}).optional(),
|
|
89
|
+
/**
|
|
90
|
+
* Whether to disable parallel function calling during tool use. Default is false.
|
|
91
|
+
* When set to true, Claude will use at most one tool per response.
|
|
92
|
+
*/
|
|
93
|
+
disableParallelToolUse: import_v42.z.boolean().optional()
|
|
89
94
|
});
|
|
90
95
|
|
|
91
96
|
// src/anthropic-prepare-tools.ts
|
|
92
97
|
var import_provider = require("@ai-sdk/provider");
|
|
93
98
|
|
|
99
|
+
// src/get-cache-control.ts
|
|
100
|
+
function getCacheControl(providerMetadata) {
|
|
101
|
+
var _a;
|
|
102
|
+
const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
103
|
+
const cacheControlValue = (_a = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a : anthropic == null ? void 0 : anthropic.cache_control;
|
|
104
|
+
return cacheControlValue;
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
// src/tool/web-search_20250305.ts
|
|
95
108
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
96
|
-
var
|
|
97
|
-
var webSearch_20250305ArgsSchema =
|
|
109
|
+
var import_v43 = require("zod/v4");
|
|
110
|
+
var webSearch_20250305ArgsSchema = import_v43.z.object({
|
|
98
111
|
/**
|
|
99
112
|
* Maximum number of web searches Claude can perform during the conversation.
|
|
100
113
|
*/
|
|
101
|
-
maxUses:
|
|
114
|
+
maxUses: import_v43.z.number().optional(),
|
|
102
115
|
/**
|
|
103
116
|
* Optional list of domains that Claude is allowed to search.
|
|
104
117
|
*/
|
|
105
|
-
allowedDomains:
|
|
118
|
+
allowedDomains: import_v43.z.array(import_v43.z.string()).optional(),
|
|
106
119
|
/**
|
|
107
120
|
* Optional list of domains that Claude should avoid when searching.
|
|
108
121
|
*/
|
|
109
|
-
blockedDomains:
|
|
122
|
+
blockedDomains: import_v43.z.array(import_v43.z.string()).optional(),
|
|
110
123
|
/**
|
|
111
124
|
* Optional user location information to provide geographically relevant search results.
|
|
112
125
|
*/
|
|
113
|
-
userLocation:
|
|
114
|
-
type:
|
|
115
|
-
city:
|
|
116
|
-
region:
|
|
117
|
-
country:
|
|
118
|
-
timezone:
|
|
126
|
+
userLocation: import_v43.z.object({
|
|
127
|
+
type: import_v43.z.literal("approximate"),
|
|
128
|
+
city: import_v43.z.string().optional(),
|
|
129
|
+
region: import_v43.z.string().optional(),
|
|
130
|
+
country: import_v43.z.string().optional(),
|
|
131
|
+
timezone: import_v43.z.string().optional()
|
|
119
132
|
}).optional()
|
|
120
133
|
});
|
|
121
|
-
var webSearch_20250305OutputSchema =
|
|
122
|
-
|
|
123
|
-
url:
|
|
124
|
-
title:
|
|
125
|
-
pageAge:
|
|
126
|
-
encryptedContent:
|
|
127
|
-
type:
|
|
134
|
+
var webSearch_20250305OutputSchema = import_v43.z.array(
|
|
135
|
+
import_v43.z.object({
|
|
136
|
+
url: import_v43.z.string(),
|
|
137
|
+
title: import_v43.z.string(),
|
|
138
|
+
pageAge: import_v43.z.string().nullable(),
|
|
139
|
+
encryptedContent: import_v43.z.string(),
|
|
140
|
+
type: import_v43.z.string()
|
|
128
141
|
})
|
|
129
142
|
);
|
|
130
143
|
var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
131
144
|
id: "anthropic.web_search_20250305",
|
|
132
145
|
name: "web_search",
|
|
133
|
-
inputSchema:
|
|
134
|
-
query:
|
|
146
|
+
inputSchema: import_v43.z.object({
|
|
147
|
+
query: import_v43.z.string()
|
|
135
148
|
}),
|
|
136
149
|
outputSchema: webSearch_20250305OutputSchema
|
|
137
150
|
});
|
|
@@ -145,7 +158,8 @@ function isWebSearchTool(tool) {
|
|
|
145
158
|
}
|
|
146
159
|
function prepareTools({
|
|
147
160
|
tools,
|
|
148
|
-
toolChoice
|
|
161
|
+
toolChoice,
|
|
162
|
+
disableParallelToolUse
|
|
149
163
|
}) {
|
|
150
164
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
151
165
|
const toolWarnings = [];
|
|
@@ -161,10 +175,12 @@ function prepareTools({
|
|
|
161
175
|
}
|
|
162
176
|
switch (tool.type) {
|
|
163
177
|
case "function":
|
|
178
|
+
const cacheControl = getCacheControl(tool.providerOptions);
|
|
164
179
|
anthropicTools2.push({
|
|
165
180
|
name: tool.name,
|
|
166
181
|
description: tool.description,
|
|
167
|
-
input_schema: tool.inputSchema
|
|
182
|
+
input_schema: tool.inputSchema,
|
|
183
|
+
cache_control: cacheControl
|
|
168
184
|
});
|
|
169
185
|
break;
|
|
170
186
|
case "provider-defined":
|
|
@@ -203,6 +219,13 @@ function prepareTools({
|
|
|
203
219
|
type: "text_editor_20241022"
|
|
204
220
|
});
|
|
205
221
|
break;
|
|
222
|
+
case "anthropic.text_editor_20250429":
|
|
223
|
+
betas.add("computer-use-2025-01-24");
|
|
224
|
+
anthropicTools2.push({
|
|
225
|
+
name: "str_replace_based_edit_tool",
|
|
226
|
+
type: "text_editor_20250429"
|
|
227
|
+
});
|
|
228
|
+
break;
|
|
206
229
|
case "anthropic.bash_20250124":
|
|
207
230
|
betas.add("computer-use-2025-01-24");
|
|
208
231
|
anthropicTools2.push({
|
|
@@ -242,7 +265,7 @@ function prepareTools({
|
|
|
242
265
|
if (toolChoice == null) {
|
|
243
266
|
return {
|
|
244
267
|
tools: anthropicTools2,
|
|
245
|
-
toolChoice: void 0,
|
|
268
|
+
toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
|
|
246
269
|
toolWarnings,
|
|
247
270
|
betas
|
|
248
271
|
};
|
|
@@ -252,14 +275,20 @@ function prepareTools({
|
|
|
252
275
|
case "auto":
|
|
253
276
|
return {
|
|
254
277
|
tools: anthropicTools2,
|
|
255
|
-
toolChoice: {
|
|
278
|
+
toolChoice: {
|
|
279
|
+
type: "auto",
|
|
280
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
281
|
+
},
|
|
256
282
|
toolWarnings,
|
|
257
283
|
betas
|
|
258
284
|
};
|
|
259
285
|
case "required":
|
|
260
286
|
return {
|
|
261
287
|
tools: anthropicTools2,
|
|
262
|
-
toolChoice: {
|
|
288
|
+
toolChoice: {
|
|
289
|
+
type: "any",
|
|
290
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
291
|
+
},
|
|
263
292
|
toolWarnings,
|
|
264
293
|
betas
|
|
265
294
|
};
|
|
@@ -268,7 +297,11 @@ function prepareTools({
|
|
|
268
297
|
case "tool":
|
|
269
298
|
return {
|
|
270
299
|
tools: anthropicTools2,
|
|
271
|
-
toolChoice: {
|
|
300
|
+
toolChoice: {
|
|
301
|
+
type: "tool",
|
|
302
|
+
name: toolChoice.toolName,
|
|
303
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
304
|
+
},
|
|
272
305
|
toolWarnings,
|
|
273
306
|
betas
|
|
274
307
|
};
|
|
@@ -310,12 +343,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
310
343
|
const blocks = groupIntoBlocks(prompt);
|
|
311
344
|
let system = void 0;
|
|
312
345
|
const messages = [];
|
|
313
|
-
function getCacheControl(providerMetadata) {
|
|
314
|
-
var _a2;
|
|
315
|
-
const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
316
|
-
const cacheControlValue = (_a2 = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a2 : anthropic == null ? void 0 : anthropic.cache_control;
|
|
317
|
-
return cacheControlValue;
|
|
318
|
-
}
|
|
319
346
|
async function shouldEnableCitations(providerMetadata) {
|
|
320
347
|
var _a2, _b2;
|
|
321
348
|
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
@@ -721,36 +748,36 @@ function mapAnthropicStopReason({
|
|
|
721
748
|
|
|
722
749
|
// src/anthropic-messages-language-model.ts
|
|
723
750
|
var citationSchemas = {
|
|
724
|
-
webSearchResult:
|
|
725
|
-
type:
|
|
726
|
-
cited_text:
|
|
727
|
-
url:
|
|
728
|
-
title:
|
|
729
|
-
encrypted_index:
|
|
751
|
+
webSearchResult: import_v44.z.object({
|
|
752
|
+
type: import_v44.z.literal("web_search_result_location"),
|
|
753
|
+
cited_text: import_v44.z.string(),
|
|
754
|
+
url: import_v44.z.string(),
|
|
755
|
+
title: import_v44.z.string(),
|
|
756
|
+
encrypted_index: import_v44.z.string()
|
|
730
757
|
}),
|
|
731
|
-
pageLocation:
|
|
732
|
-
type:
|
|
733
|
-
cited_text:
|
|
734
|
-
document_index:
|
|
735
|
-
document_title:
|
|
736
|
-
start_page_number:
|
|
737
|
-
end_page_number:
|
|
758
|
+
pageLocation: import_v44.z.object({
|
|
759
|
+
type: import_v44.z.literal("page_location"),
|
|
760
|
+
cited_text: import_v44.z.string(),
|
|
761
|
+
document_index: import_v44.z.number(),
|
|
762
|
+
document_title: import_v44.z.string().nullable(),
|
|
763
|
+
start_page_number: import_v44.z.number(),
|
|
764
|
+
end_page_number: import_v44.z.number()
|
|
738
765
|
}),
|
|
739
|
-
charLocation:
|
|
740
|
-
type:
|
|
741
|
-
cited_text:
|
|
742
|
-
document_index:
|
|
743
|
-
document_title:
|
|
744
|
-
start_char_index:
|
|
745
|
-
end_char_index:
|
|
766
|
+
charLocation: import_v44.z.object({
|
|
767
|
+
type: import_v44.z.literal("char_location"),
|
|
768
|
+
cited_text: import_v44.z.string(),
|
|
769
|
+
document_index: import_v44.z.number(),
|
|
770
|
+
document_title: import_v44.z.string().nullable(),
|
|
771
|
+
start_char_index: import_v44.z.number(),
|
|
772
|
+
end_char_index: import_v44.z.number()
|
|
746
773
|
})
|
|
747
774
|
};
|
|
748
|
-
var citationSchema =
|
|
775
|
+
var citationSchema = import_v44.z.discriminatedUnion("type", [
|
|
749
776
|
citationSchemas.webSearchResult,
|
|
750
777
|
citationSchemas.pageLocation,
|
|
751
778
|
citationSchemas.charLocation
|
|
752
779
|
]);
|
|
753
|
-
var documentCitationSchema =
|
|
780
|
+
var documentCitationSchema = import_v44.z.discriminatedUnion("type", [
|
|
754
781
|
citationSchemas.pageLocation,
|
|
755
782
|
citationSchemas.charLocation
|
|
756
783
|
]);
|
|
@@ -937,8 +964,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
937
964
|
} = prepareTools(
|
|
938
965
|
jsonResponseTool != null ? {
|
|
939
966
|
tools: [jsonResponseTool],
|
|
940
|
-
toolChoice: { type: "tool", toolName: jsonResponseTool.name }
|
|
941
|
-
|
|
967
|
+
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
968
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
969
|
+
} : {
|
|
970
|
+
tools: tools != null ? tools : [],
|
|
971
|
+
toolChoice,
|
|
972
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
973
|
+
}
|
|
942
974
|
);
|
|
943
975
|
return {
|
|
944
976
|
args: {
|
|
@@ -948,7 +980,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
948
980
|
},
|
|
949
981
|
warnings: [...warnings, ...toolWarnings],
|
|
950
982
|
betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
|
|
951
|
-
jsonResponseTool
|
|
983
|
+
usesJsonResponseTool: jsonResponseTool != null
|
|
952
984
|
};
|
|
953
985
|
}
|
|
954
986
|
async getHeaders({
|
|
@@ -994,7 +1026,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
994
1026
|
}
|
|
995
1027
|
async doGenerate(options) {
|
|
996
1028
|
var _a, _b, _c, _d, _e;
|
|
997
|
-
const { args, warnings, betas,
|
|
1029
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
998
1030
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
999
1031
|
const {
|
|
1000
1032
|
responseHeaders,
|
|
@@ -1015,7 +1047,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1015
1047
|
for (const part of response.content) {
|
|
1016
1048
|
switch (part.type) {
|
|
1017
1049
|
case "text": {
|
|
1018
|
-
if (
|
|
1050
|
+
if (!usesJsonResponseTool) {
|
|
1019
1051
|
content.push({ type: "text", text: part.text });
|
|
1020
1052
|
if (part.citations) {
|
|
1021
1053
|
for (const citation of part.citations) {
|
|
@@ -1057,7 +1089,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1057
1089
|
case "tool_use": {
|
|
1058
1090
|
content.push(
|
|
1059
1091
|
// when a json response tool is used, the tool call becomes the text:
|
|
1060
|
-
|
|
1092
|
+
usesJsonResponseTool ? {
|
|
1061
1093
|
type: "text",
|
|
1062
1094
|
text: JSON.stringify(part.input)
|
|
1063
1095
|
} : {
|
|
@@ -1134,7 +1166,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1134
1166
|
content,
|
|
1135
1167
|
finishReason: mapAnthropicStopReason({
|
|
1136
1168
|
finishReason: response.stop_reason,
|
|
1137
|
-
isJsonResponseFromTool:
|
|
1169
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1138
1170
|
}),
|
|
1139
1171
|
usage: {
|
|
1140
1172
|
inputTokens: response.usage.input_tokens,
|
|
@@ -1152,13 +1184,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1152
1184
|
warnings,
|
|
1153
1185
|
providerMetadata: {
|
|
1154
1186
|
anthropic: {
|
|
1187
|
+
usage: response.usage,
|
|
1155
1188
|
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
|
|
1156
1189
|
}
|
|
1157
1190
|
}
|
|
1158
1191
|
};
|
|
1159
1192
|
}
|
|
1160
1193
|
async doStream(options) {
|
|
1161
|
-
const { args, warnings, betas,
|
|
1194
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1162
1195
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1163
1196
|
const body = { ...args, stream: true };
|
|
1164
1197
|
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
@@ -1236,16 +1269,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1236
1269
|
return;
|
|
1237
1270
|
}
|
|
1238
1271
|
case "tool_use": {
|
|
1239
|
-
contentBlocks[value.index] =
|
|
1272
|
+
contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
|
|
1240
1273
|
type: "tool-call",
|
|
1241
1274
|
toolCallId: value.content_block.id,
|
|
1242
1275
|
toolName: value.content_block.name,
|
|
1243
1276
|
input: ""
|
|
1244
1277
|
};
|
|
1245
1278
|
controller.enqueue(
|
|
1246
|
-
|
|
1279
|
+
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
1247
1280
|
type: "tool-input-start",
|
|
1248
|
-
id:
|
|
1281
|
+
id: value.content_block.id,
|
|
1249
1282
|
toolName: value.content_block.name
|
|
1250
1283
|
}
|
|
1251
1284
|
);
|
|
@@ -1344,7 +1377,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1344
1377
|
break;
|
|
1345
1378
|
}
|
|
1346
1379
|
case "tool-call":
|
|
1347
|
-
if (
|
|
1380
|
+
if (!usesJsonResponseTool) {
|
|
1348
1381
|
controller.enqueue({
|
|
1349
1382
|
type: "tool-input-end",
|
|
1350
1383
|
id: contentBlock.toolCallId
|
|
@@ -1362,7 +1395,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1362
1395
|
const deltaType = value.delta.type;
|
|
1363
1396
|
switch (deltaType) {
|
|
1364
1397
|
case "text_delta": {
|
|
1365
|
-
if (
|
|
1398
|
+
if (usesJsonResponseTool) {
|
|
1366
1399
|
return;
|
|
1367
1400
|
}
|
|
1368
1401
|
controller.enqueue({
|
|
@@ -1398,16 +1431,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1398
1431
|
case "input_json_delta": {
|
|
1399
1432
|
const contentBlock = contentBlocks[value.index];
|
|
1400
1433
|
const delta = value.delta.partial_json;
|
|
1401
|
-
if (
|
|
1402
|
-
if ((contentBlock == null ? void 0 : contentBlock.type) !== "
|
|
1434
|
+
if (usesJsonResponseTool) {
|
|
1435
|
+
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
1403
1436
|
return;
|
|
1404
1437
|
}
|
|
1405
1438
|
controller.enqueue({
|
|
1406
|
-
type: "
|
|
1407
|
-
id:
|
|
1439
|
+
type: "text-delta",
|
|
1440
|
+
id: String(value.index),
|
|
1408
1441
|
delta
|
|
1409
1442
|
});
|
|
1410
|
-
contentBlock.input += delta;
|
|
1411
1443
|
} else {
|
|
1412
1444
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
1413
1445
|
return;
|
|
@@ -1417,6 +1449,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1417
1449
|
id: contentBlock.toolCallId,
|
|
1418
1450
|
delta
|
|
1419
1451
|
});
|
|
1452
|
+
contentBlock.input += delta;
|
|
1420
1453
|
}
|
|
1421
1454
|
return;
|
|
1422
1455
|
}
|
|
@@ -1443,6 +1476,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1443
1476
|
usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
|
|
1444
1477
|
providerMetadata = {
|
|
1445
1478
|
anthropic: {
|
|
1479
|
+
usage: value.message.usage,
|
|
1446
1480
|
cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
|
|
1447
1481
|
}
|
|
1448
1482
|
};
|
|
@@ -1458,7 +1492,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1458
1492
|
usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
|
|
1459
1493
|
finishReason = mapAnthropicStopReason({
|
|
1460
1494
|
finishReason: value.delta.stop_reason,
|
|
1461
|
-
isJsonResponseFromTool:
|
|
1495
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1462
1496
|
});
|
|
1463
1497
|
return;
|
|
1464
1498
|
}
|
|
@@ -1488,218 +1522,215 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1488
1522
|
};
|
|
1489
1523
|
}
|
|
1490
1524
|
};
|
|
1491
|
-
var anthropicMessagesResponseSchema =
|
|
1492
|
-
type:
|
|
1493
|
-
id:
|
|
1494
|
-
model:
|
|
1495
|
-
content:
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
type:
|
|
1499
|
-
text:
|
|
1500
|
-
citations:
|
|
1525
|
+
var anthropicMessagesResponseSchema = import_v44.z.object({
|
|
1526
|
+
type: import_v44.z.literal("message"),
|
|
1527
|
+
id: import_v44.z.string().nullish(),
|
|
1528
|
+
model: import_v44.z.string().nullish(),
|
|
1529
|
+
content: import_v44.z.array(
|
|
1530
|
+
import_v44.z.discriminatedUnion("type", [
|
|
1531
|
+
import_v44.z.object({
|
|
1532
|
+
type: import_v44.z.literal("text"),
|
|
1533
|
+
text: import_v44.z.string(),
|
|
1534
|
+
citations: import_v44.z.array(citationSchema).optional()
|
|
1501
1535
|
}),
|
|
1502
|
-
|
|
1503
|
-
type:
|
|
1504
|
-
thinking:
|
|
1505
|
-
signature:
|
|
1536
|
+
import_v44.z.object({
|
|
1537
|
+
type: import_v44.z.literal("thinking"),
|
|
1538
|
+
thinking: import_v44.z.string(),
|
|
1539
|
+
signature: import_v44.z.string()
|
|
1506
1540
|
}),
|
|
1507
|
-
|
|
1508
|
-
type:
|
|
1509
|
-
data:
|
|
1541
|
+
import_v44.z.object({
|
|
1542
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1543
|
+
data: import_v44.z.string()
|
|
1510
1544
|
}),
|
|
1511
|
-
|
|
1512
|
-
type:
|
|
1513
|
-
id:
|
|
1514
|
-
name:
|
|
1515
|
-
input:
|
|
1545
|
+
import_v44.z.object({
|
|
1546
|
+
type: import_v44.z.literal("tool_use"),
|
|
1547
|
+
id: import_v44.z.string(),
|
|
1548
|
+
name: import_v44.z.string(),
|
|
1549
|
+
input: import_v44.z.unknown()
|
|
1516
1550
|
}),
|
|
1517
|
-
|
|
1518
|
-
type:
|
|
1519
|
-
id:
|
|
1520
|
-
name:
|
|
1521
|
-
input:
|
|
1551
|
+
import_v44.z.object({
|
|
1552
|
+
type: import_v44.z.literal("server_tool_use"),
|
|
1553
|
+
id: import_v44.z.string(),
|
|
1554
|
+
name: import_v44.z.string(),
|
|
1555
|
+
input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
|
|
1522
1556
|
}),
|
|
1523
|
-
|
|
1524
|
-
type:
|
|
1525
|
-
tool_use_id:
|
|
1526
|
-
content:
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
type:
|
|
1530
|
-
url:
|
|
1531
|
-
title:
|
|
1532
|
-
encrypted_content:
|
|
1533
|
-
page_age:
|
|
1557
|
+
import_v44.z.object({
|
|
1558
|
+
type: import_v44.z.literal("web_search_tool_result"),
|
|
1559
|
+
tool_use_id: import_v44.z.string(),
|
|
1560
|
+
content: import_v44.z.union([
|
|
1561
|
+
import_v44.z.array(
|
|
1562
|
+
import_v44.z.object({
|
|
1563
|
+
type: import_v44.z.literal("web_search_result"),
|
|
1564
|
+
url: import_v44.z.string(),
|
|
1565
|
+
title: import_v44.z.string(),
|
|
1566
|
+
encrypted_content: import_v44.z.string(),
|
|
1567
|
+
page_age: import_v44.z.string().nullish()
|
|
1534
1568
|
})
|
|
1535
1569
|
),
|
|
1536
|
-
|
|
1537
|
-
type:
|
|
1538
|
-
error_code:
|
|
1570
|
+
import_v44.z.object({
|
|
1571
|
+
type: import_v44.z.literal("web_search_tool_result_error"),
|
|
1572
|
+
error_code: import_v44.z.string()
|
|
1539
1573
|
})
|
|
1540
1574
|
])
|
|
1541
1575
|
})
|
|
1542
1576
|
])
|
|
1543
1577
|
),
|
|
1544
|
-
stop_reason:
|
|
1545
|
-
usage:
|
|
1546
|
-
input_tokens:
|
|
1547
|
-
output_tokens:
|
|
1548
|
-
cache_creation_input_tokens:
|
|
1549
|
-
cache_read_input_tokens:
|
|
1550
|
-
server_tool_use: import_zod3.z.object({
|
|
1551
|
-
web_search_requests: import_zod3.z.number()
|
|
1552
|
-
}).nullish()
|
|
1578
|
+
stop_reason: import_v44.z.string().nullish(),
|
|
1579
|
+
usage: import_v44.z.looseObject({
|
|
1580
|
+
input_tokens: import_v44.z.number(),
|
|
1581
|
+
output_tokens: import_v44.z.number(),
|
|
1582
|
+
cache_creation_input_tokens: import_v44.z.number().nullish(),
|
|
1583
|
+
cache_read_input_tokens: import_v44.z.number().nullish()
|
|
1553
1584
|
})
|
|
1554
1585
|
});
|
|
1555
|
-
var anthropicMessagesChunkSchema =
|
|
1556
|
-
|
|
1557
|
-
type:
|
|
1558
|
-
message:
|
|
1559
|
-
id:
|
|
1560
|
-
model:
|
|
1561
|
-
usage:
|
|
1562
|
-
input_tokens:
|
|
1563
|
-
output_tokens:
|
|
1564
|
-
cache_creation_input_tokens:
|
|
1565
|
-
cache_read_input_tokens:
|
|
1586
|
+
var anthropicMessagesChunkSchema = import_v44.z.discriminatedUnion("type", [
|
|
1587
|
+
import_v44.z.object({
|
|
1588
|
+
type: import_v44.z.literal("message_start"),
|
|
1589
|
+
message: import_v44.z.object({
|
|
1590
|
+
id: import_v44.z.string().nullish(),
|
|
1591
|
+
model: import_v44.z.string().nullish(),
|
|
1592
|
+
usage: import_v44.z.looseObject({
|
|
1593
|
+
input_tokens: import_v44.z.number(),
|
|
1594
|
+
output_tokens: import_v44.z.number(),
|
|
1595
|
+
cache_creation_input_tokens: import_v44.z.number().nullish(),
|
|
1596
|
+
cache_read_input_tokens: import_v44.z.number().nullish()
|
|
1566
1597
|
})
|
|
1567
1598
|
})
|
|
1568
1599
|
}),
|
|
1569
|
-
|
|
1570
|
-
type:
|
|
1571
|
-
index:
|
|
1572
|
-
content_block:
|
|
1573
|
-
|
|
1574
|
-
type:
|
|
1575
|
-
text:
|
|
1600
|
+
import_v44.z.object({
|
|
1601
|
+
type: import_v44.z.literal("content_block_start"),
|
|
1602
|
+
index: import_v44.z.number(),
|
|
1603
|
+
content_block: import_v44.z.discriminatedUnion("type", [
|
|
1604
|
+
import_v44.z.object({
|
|
1605
|
+
type: import_v44.z.literal("text"),
|
|
1606
|
+
text: import_v44.z.string()
|
|
1576
1607
|
}),
|
|
1577
|
-
|
|
1578
|
-
type:
|
|
1579
|
-
thinking:
|
|
1608
|
+
import_v44.z.object({
|
|
1609
|
+
type: import_v44.z.literal("thinking"),
|
|
1610
|
+
thinking: import_v44.z.string()
|
|
1580
1611
|
}),
|
|
1581
|
-
|
|
1582
|
-
type:
|
|
1583
|
-
id:
|
|
1584
|
-
name:
|
|
1612
|
+
import_v44.z.object({
|
|
1613
|
+
type: import_v44.z.literal("tool_use"),
|
|
1614
|
+
id: import_v44.z.string(),
|
|
1615
|
+
name: import_v44.z.string()
|
|
1585
1616
|
}),
|
|
1586
|
-
|
|
1587
|
-
type:
|
|
1588
|
-
data:
|
|
1617
|
+
import_v44.z.object({
|
|
1618
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1619
|
+
data: import_v44.z.string()
|
|
1589
1620
|
}),
|
|
1590
|
-
|
|
1591
|
-
type:
|
|
1592
|
-
id:
|
|
1593
|
-
name:
|
|
1594
|
-
input:
|
|
1621
|
+
import_v44.z.object({
|
|
1622
|
+
type: import_v44.z.literal("server_tool_use"),
|
|
1623
|
+
id: import_v44.z.string(),
|
|
1624
|
+
name: import_v44.z.string(),
|
|
1625
|
+
input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
|
|
1595
1626
|
}),
|
|
1596
|
-
|
|
1597
|
-
type:
|
|
1598
|
-
tool_use_id:
|
|
1599
|
-
content:
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
type:
|
|
1603
|
-
url:
|
|
1604
|
-
title:
|
|
1605
|
-
encrypted_content:
|
|
1606
|
-
page_age:
|
|
1627
|
+
import_v44.z.object({
|
|
1628
|
+
type: import_v44.z.literal("web_search_tool_result"),
|
|
1629
|
+
tool_use_id: import_v44.z.string(),
|
|
1630
|
+
content: import_v44.z.union([
|
|
1631
|
+
import_v44.z.array(
|
|
1632
|
+
import_v44.z.object({
|
|
1633
|
+
type: import_v44.z.literal("web_search_result"),
|
|
1634
|
+
url: import_v44.z.string(),
|
|
1635
|
+
title: import_v44.z.string(),
|
|
1636
|
+
encrypted_content: import_v44.z.string(),
|
|
1637
|
+
page_age: import_v44.z.string().nullish()
|
|
1607
1638
|
})
|
|
1608
1639
|
),
|
|
1609
|
-
|
|
1610
|
-
type:
|
|
1611
|
-
error_code:
|
|
1640
|
+
import_v44.z.object({
|
|
1641
|
+
type: import_v44.z.literal("web_search_tool_result_error"),
|
|
1642
|
+
error_code: import_v44.z.string()
|
|
1612
1643
|
})
|
|
1613
1644
|
])
|
|
1614
1645
|
})
|
|
1615
1646
|
])
|
|
1616
1647
|
}),
|
|
1617
|
-
|
|
1618
|
-
type:
|
|
1619
|
-
index:
|
|
1620
|
-
delta:
|
|
1621
|
-
|
|
1622
|
-
type:
|
|
1623
|
-
partial_json:
|
|
1648
|
+
import_v44.z.object({
|
|
1649
|
+
type: import_v44.z.literal("content_block_delta"),
|
|
1650
|
+
index: import_v44.z.number(),
|
|
1651
|
+
delta: import_v44.z.discriminatedUnion("type", [
|
|
1652
|
+
import_v44.z.object({
|
|
1653
|
+
type: import_v44.z.literal("input_json_delta"),
|
|
1654
|
+
partial_json: import_v44.z.string()
|
|
1624
1655
|
}),
|
|
1625
|
-
|
|
1626
|
-
type:
|
|
1627
|
-
text:
|
|
1656
|
+
import_v44.z.object({
|
|
1657
|
+
type: import_v44.z.literal("text_delta"),
|
|
1658
|
+
text: import_v44.z.string()
|
|
1628
1659
|
}),
|
|
1629
|
-
|
|
1630
|
-
type:
|
|
1631
|
-
thinking:
|
|
1660
|
+
import_v44.z.object({
|
|
1661
|
+
type: import_v44.z.literal("thinking_delta"),
|
|
1662
|
+
thinking: import_v44.z.string()
|
|
1632
1663
|
}),
|
|
1633
|
-
|
|
1634
|
-
type:
|
|
1635
|
-
signature:
|
|
1664
|
+
import_v44.z.object({
|
|
1665
|
+
type: import_v44.z.literal("signature_delta"),
|
|
1666
|
+
signature: import_v44.z.string()
|
|
1636
1667
|
}),
|
|
1637
|
-
|
|
1638
|
-
type:
|
|
1668
|
+
import_v44.z.object({
|
|
1669
|
+
type: import_v44.z.literal("citations_delta"),
|
|
1639
1670
|
citation: citationSchema
|
|
1640
1671
|
})
|
|
1641
1672
|
])
|
|
1642
1673
|
}),
|
|
1643
|
-
|
|
1644
|
-
type:
|
|
1645
|
-
index:
|
|
1674
|
+
import_v44.z.object({
|
|
1675
|
+
type: import_v44.z.literal("content_block_stop"),
|
|
1676
|
+
index: import_v44.z.number()
|
|
1646
1677
|
}),
|
|
1647
|
-
|
|
1648
|
-
type:
|
|
1649
|
-
error:
|
|
1650
|
-
type:
|
|
1651
|
-
message:
|
|
1678
|
+
import_v44.z.object({
|
|
1679
|
+
type: import_v44.z.literal("error"),
|
|
1680
|
+
error: import_v44.z.object({
|
|
1681
|
+
type: import_v44.z.string(),
|
|
1682
|
+
message: import_v44.z.string()
|
|
1652
1683
|
})
|
|
1653
1684
|
}),
|
|
1654
|
-
|
|
1655
|
-
type:
|
|
1656
|
-
delta:
|
|
1657
|
-
usage:
|
|
1685
|
+
import_v44.z.object({
|
|
1686
|
+
type: import_v44.z.literal("message_delta"),
|
|
1687
|
+
delta: import_v44.z.object({ stop_reason: import_v44.z.string().nullish() }),
|
|
1688
|
+
usage: import_v44.z.object({ output_tokens: import_v44.z.number() })
|
|
1658
1689
|
}),
|
|
1659
|
-
|
|
1660
|
-
type:
|
|
1690
|
+
import_v44.z.object({
|
|
1691
|
+
type: import_v44.z.literal("message_stop")
|
|
1661
1692
|
}),
|
|
1662
|
-
|
|
1663
|
-
type:
|
|
1693
|
+
import_v44.z.object({
|
|
1694
|
+
type: import_v44.z.literal("ping")
|
|
1664
1695
|
})
|
|
1665
1696
|
]);
|
|
1666
|
-
var anthropicReasoningMetadataSchema =
|
|
1667
|
-
signature:
|
|
1668
|
-
redactedData:
|
|
1697
|
+
var anthropicReasoningMetadataSchema = import_v44.z.object({
|
|
1698
|
+
signature: import_v44.z.string().optional(),
|
|
1699
|
+
redactedData: import_v44.z.string().optional()
|
|
1669
1700
|
});
|
|
1670
1701
|
|
|
1671
1702
|
// src/tool/bash_20241022.ts
|
|
1672
1703
|
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1673
|
-
var
|
|
1704
|
+
var import_v45 = __toESM(require("zod/v4"));
|
|
1674
1705
|
var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
1675
1706
|
id: "anthropic.bash_20241022",
|
|
1676
1707
|
name: "bash",
|
|
1677
|
-
inputSchema:
|
|
1678
|
-
command:
|
|
1679
|
-
restart:
|
|
1708
|
+
inputSchema: import_v45.default.object({
|
|
1709
|
+
command: import_v45.default.string(),
|
|
1710
|
+
restart: import_v45.default.boolean().optional()
|
|
1680
1711
|
})
|
|
1681
1712
|
});
|
|
1682
1713
|
|
|
1683
1714
|
// src/tool/bash_20250124.ts
|
|
1684
1715
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1685
|
-
var
|
|
1716
|
+
var import_v46 = __toESM(require("zod/v4"));
|
|
1686
1717
|
var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
|
|
1687
1718
|
id: "anthropic.bashTool_20250124",
|
|
1688
1719
|
name: "bash",
|
|
1689
|
-
inputSchema:
|
|
1690
|
-
command:
|
|
1691
|
-
restart:
|
|
1720
|
+
inputSchema: import_v46.default.object({
|
|
1721
|
+
command: import_v46.default.string(),
|
|
1722
|
+
restart: import_v46.default.boolean().optional()
|
|
1692
1723
|
})
|
|
1693
1724
|
});
|
|
1694
1725
|
|
|
1695
1726
|
// src/tool/computer_20241022.ts
|
|
1696
1727
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1697
|
-
var
|
|
1728
|
+
var import_v47 = require("zod/v4");
|
|
1698
1729
|
var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
|
|
1699
1730
|
id: "anthropic.computer_20241022",
|
|
1700
1731
|
name: "computer",
|
|
1701
|
-
inputSchema:
|
|
1702
|
-
action:
|
|
1732
|
+
inputSchema: import_v47.z.object({
|
|
1733
|
+
action: import_v47.z.enum([
|
|
1703
1734
|
"key",
|
|
1704
1735
|
"type",
|
|
1705
1736
|
"mouse_move",
|
|
@@ -1711,19 +1742,19 @@ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFact
|
|
|
1711
1742
|
"screenshot",
|
|
1712
1743
|
"cursor_position"
|
|
1713
1744
|
]),
|
|
1714
|
-
coordinate:
|
|
1715
|
-
text:
|
|
1745
|
+
coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
|
|
1746
|
+
text: import_v47.z.string().optional()
|
|
1716
1747
|
})
|
|
1717
1748
|
});
|
|
1718
1749
|
|
|
1719
1750
|
// src/tool/computer_20250124.ts
|
|
1720
1751
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1721
|
-
var
|
|
1752
|
+
var import_v48 = require("zod/v4");
|
|
1722
1753
|
var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1723
1754
|
id: "anthropic.computer_20250124",
|
|
1724
1755
|
name: "computer",
|
|
1725
|
-
inputSchema:
|
|
1726
|
-
action:
|
|
1756
|
+
inputSchema: import_v48.z.object({
|
|
1757
|
+
action: import_v48.z.enum([
|
|
1727
1758
|
"key",
|
|
1728
1759
|
"hold_key",
|
|
1729
1760
|
"type",
|
|
@@ -1741,46 +1772,63 @@ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFact
|
|
|
1741
1772
|
"wait",
|
|
1742
1773
|
"screenshot"
|
|
1743
1774
|
]),
|
|
1744
|
-
coordinate:
|
|
1745
|
-
duration:
|
|
1746
|
-
scroll_amount:
|
|
1747
|
-
scroll_direction:
|
|
1748
|
-
start_coordinate:
|
|
1749
|
-
text:
|
|
1775
|
+
coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
|
|
1776
|
+
duration: import_v48.z.number().optional(),
|
|
1777
|
+
scroll_amount: import_v48.z.number().optional(),
|
|
1778
|
+
scroll_direction: import_v48.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1779
|
+
start_coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
|
|
1780
|
+
text: import_v48.z.string().optional()
|
|
1750
1781
|
})
|
|
1751
1782
|
});
|
|
1752
1783
|
|
|
1753
1784
|
// src/tool/text-editor_20241022.ts
|
|
1754
1785
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1755
|
-
var
|
|
1786
|
+
var import_v49 = require("zod/v4");
|
|
1756
1787
|
var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1757
1788
|
id: "anthropic.text_editor_20241022",
|
|
1758
1789
|
name: "str_replace_editor",
|
|
1759
|
-
inputSchema:
|
|
1760
|
-
command:
|
|
1761
|
-
path:
|
|
1762
|
-
file_text:
|
|
1763
|
-
insert_line:
|
|
1764
|
-
new_str:
|
|
1765
|
-
old_str:
|
|
1766
|
-
view_range:
|
|
1790
|
+
inputSchema: import_v49.z.object({
|
|
1791
|
+
command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1792
|
+
path: import_v49.z.string(),
|
|
1793
|
+
file_text: import_v49.z.string().optional(),
|
|
1794
|
+
insert_line: import_v49.z.number().int().optional(),
|
|
1795
|
+
new_str: import_v49.z.string().optional(),
|
|
1796
|
+
old_str: import_v49.z.string().optional(),
|
|
1797
|
+
view_range: import_v49.z.array(import_v49.z.number().int()).optional()
|
|
1767
1798
|
})
|
|
1768
1799
|
});
|
|
1769
1800
|
|
|
1770
1801
|
// src/tool/text-editor_20250124.ts
|
|
1771
1802
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1772
|
-
var
|
|
1803
|
+
var import_v410 = require("zod/v4");
|
|
1773
1804
|
var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1774
1805
|
id: "anthropic.text_editor_20250124",
|
|
1775
1806
|
name: "str_replace_editor",
|
|
1776
|
-
inputSchema:
|
|
1777
|
-
command:
|
|
1778
|
-
path:
|
|
1779
|
-
file_text:
|
|
1780
|
-
insert_line:
|
|
1781
|
-
new_str:
|
|
1782
|
-
old_str:
|
|
1783
|
-
view_range:
|
|
1807
|
+
inputSchema: import_v410.z.object({
|
|
1808
|
+
command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1809
|
+
path: import_v410.z.string(),
|
|
1810
|
+
file_text: import_v410.z.string().optional(),
|
|
1811
|
+
insert_line: import_v410.z.number().int().optional(),
|
|
1812
|
+
new_str: import_v410.z.string().optional(),
|
|
1813
|
+
old_str: import_v410.z.string().optional(),
|
|
1814
|
+
view_range: import_v410.z.array(import_v410.z.number().int()).optional()
|
|
1815
|
+
})
|
|
1816
|
+
});
|
|
1817
|
+
|
|
1818
|
+
// src/tool/text-editor_20250429.ts
|
|
1819
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1820
|
+
var import_v411 = require("zod/v4");
|
|
1821
|
+
var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1822
|
+
id: "anthropic.text_editor_20250429",
|
|
1823
|
+
name: "str_replace_based_edit_tool",
|
|
1824
|
+
inputSchema: import_v411.z.object({
|
|
1825
|
+
command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
|
|
1826
|
+
path: import_v411.z.string(),
|
|
1827
|
+
file_text: import_v411.z.string().optional(),
|
|
1828
|
+
insert_line: import_v411.z.number().int().optional(),
|
|
1829
|
+
new_str: import_v411.z.string().optional(),
|
|
1830
|
+
old_str: import_v411.z.string().optional(),
|
|
1831
|
+
view_range: import_v411.z.array(import_v411.z.number().int()).optional()
|
|
1784
1832
|
})
|
|
1785
1833
|
});
|
|
1786
1834
|
|
|
@@ -1810,6 +1858,11 @@ var anthropicTools = {
|
|
|
1810
1858
|
* Creates a tool for editing text. Must have name "str_replace_editor".
|
|
1811
1859
|
*/
|
|
1812
1860
|
textEditor_20250124,
|
|
1861
|
+
/**
|
|
1862
|
+
* Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
|
|
1863
|
+
* Note: This version does not support the "undo_edit" command.
|
|
1864
|
+
*/
|
|
1865
|
+
textEditor_20250429,
|
|
1813
1866
|
/**
|
|
1814
1867
|
* Creates a tool for executing actions on a computer. Must have name "computer".
|
|
1815
1868
|
*
|