@ai-sdk/anthropic 2.1.0-beta.4 → 2.1.0-beta.5
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 +13 -0
- package/dist/index.d.mts +105 -3
- package/dist/index.d.ts +105 -3
- package/dist/index.js +651 -377
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +631 -357
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +122 -6
- package/dist/internal/index.d.ts +122 -6
- package/dist/internal/index.js +645 -371
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +630 -356
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
postJsonToApi,
|
|
12
12
|
resolve
|
|
13
13
|
} from "@ai-sdk/provider-utils";
|
|
14
|
-
import { z as
|
|
14
|
+
import { z as z7 } from "zod/v4";
|
|
15
15
|
|
|
16
16
|
// src/anthropic-error.ts
|
|
17
17
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
@@ -87,58 +87,110 @@ function getCacheControl(providerMetadata) {
|
|
|
87
87
|
return cacheControlValue;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
// src/tool/text-editor_20250728.ts
|
|
91
|
+
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
92
|
+
import { z as z3 } from "zod/v4";
|
|
93
|
+
var textEditor_20250728ArgsSchema = z3.object({
|
|
94
|
+
maxCharacters: z3.number().optional()
|
|
95
|
+
});
|
|
96
|
+
var factory = createProviderDefinedToolFactory({
|
|
97
|
+
id: "anthropic.text_editor_20250728",
|
|
98
|
+
name: "str_replace_based_edit_tool",
|
|
99
|
+
inputSchema: z3.object({
|
|
100
|
+
command: z3.enum(["view", "create", "str_replace", "insert"]),
|
|
101
|
+
path: z3.string(),
|
|
102
|
+
file_text: z3.string().optional(),
|
|
103
|
+
insert_line: z3.number().int().optional(),
|
|
104
|
+
new_str: z3.string().optional(),
|
|
105
|
+
old_str: z3.string().optional(),
|
|
106
|
+
view_range: z3.array(z3.number().int()).optional()
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
var textEditor_20250728 = (args = {}) => {
|
|
110
|
+
return factory(args);
|
|
111
|
+
};
|
|
112
|
+
|
|
90
113
|
// src/tool/web-search_20250305.ts
|
|
91
114
|
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
92
|
-
import { z as
|
|
93
|
-
var webSearch_20250305ArgsSchema =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* Optional list of domains that Claude should avoid when searching.
|
|
104
|
-
*/
|
|
105
|
-
blockedDomains: z3.array(z3.string()).optional(),
|
|
106
|
-
/**
|
|
107
|
-
* Optional user location information to provide geographically relevant search results.
|
|
108
|
-
*/
|
|
109
|
-
userLocation: z3.object({
|
|
110
|
-
type: z3.literal("approximate"),
|
|
111
|
-
city: z3.string().optional(),
|
|
112
|
-
region: z3.string().optional(),
|
|
113
|
-
country: z3.string().optional(),
|
|
114
|
-
timezone: z3.string().optional()
|
|
115
|
+
import { z as z4 } from "zod/v4";
|
|
116
|
+
var webSearch_20250305ArgsSchema = z4.object({
|
|
117
|
+
maxUses: z4.number().optional(),
|
|
118
|
+
allowedDomains: z4.array(z4.string()).optional(),
|
|
119
|
+
blockedDomains: z4.array(z4.string()).optional(),
|
|
120
|
+
userLocation: z4.object({
|
|
121
|
+
type: z4.literal("approximate"),
|
|
122
|
+
city: z4.string().optional(),
|
|
123
|
+
region: z4.string().optional(),
|
|
124
|
+
country: z4.string().optional(),
|
|
125
|
+
timezone: z4.string().optional()
|
|
115
126
|
}).optional()
|
|
116
127
|
});
|
|
117
|
-
var webSearch_20250305OutputSchema =
|
|
118
|
-
|
|
119
|
-
url:
|
|
120
|
-
title:
|
|
121
|
-
pageAge:
|
|
122
|
-
encryptedContent:
|
|
123
|
-
type:
|
|
128
|
+
var webSearch_20250305OutputSchema = z4.array(
|
|
129
|
+
z4.object({
|
|
130
|
+
url: z4.string(),
|
|
131
|
+
title: z4.string(),
|
|
132
|
+
pageAge: z4.string().nullable(),
|
|
133
|
+
encryptedContent: z4.string(),
|
|
134
|
+
type: z4.literal("web_search_result")
|
|
124
135
|
})
|
|
125
136
|
);
|
|
126
|
-
var
|
|
137
|
+
var factory2 = createProviderDefinedToolFactoryWithOutputSchema({
|
|
127
138
|
id: "anthropic.web_search_20250305",
|
|
128
139
|
name: "web_search",
|
|
129
|
-
inputSchema:
|
|
130
|
-
query:
|
|
140
|
+
inputSchema: z4.object({
|
|
141
|
+
query: z4.string()
|
|
131
142
|
}),
|
|
132
143
|
outputSchema: webSearch_20250305OutputSchema
|
|
133
144
|
});
|
|
134
145
|
var webSearch_20250305 = (args = {}) => {
|
|
135
|
-
return
|
|
146
|
+
return factory2(args);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/tool/web-fetch-20250910.ts
|
|
150
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
|
|
151
|
+
import { z as z5 } from "zod/v4";
|
|
152
|
+
var webFetch_20250910ArgsSchema = z5.object({
|
|
153
|
+
maxUses: z5.number().optional(),
|
|
154
|
+
allowedDomains: z5.array(z5.string()).optional(),
|
|
155
|
+
blockedDomains: z5.array(z5.string()).optional(),
|
|
156
|
+
citations: z5.object({ enabled: z5.boolean() }).optional(),
|
|
157
|
+
maxContentTokens: z5.number().optional()
|
|
158
|
+
});
|
|
159
|
+
var webFetch_20250910OutputSchema = z5.object({
|
|
160
|
+
type: z5.literal("web_fetch_result"),
|
|
161
|
+
url: z5.string(),
|
|
162
|
+
content: z5.object({
|
|
163
|
+
type: z5.literal("document"),
|
|
164
|
+
title: z5.string(),
|
|
165
|
+
citations: z5.object({ enabled: z5.boolean() }).optional(),
|
|
166
|
+
source: z5.union([
|
|
167
|
+
z5.object({
|
|
168
|
+
type: z5.literal("base64"),
|
|
169
|
+
mediaType: z5.literal("application/pdf"),
|
|
170
|
+
data: z5.string()
|
|
171
|
+
}),
|
|
172
|
+
z5.object({
|
|
173
|
+
type: z5.literal("text"),
|
|
174
|
+
mediaType: z5.literal("text/plain"),
|
|
175
|
+
data: z5.string()
|
|
176
|
+
})
|
|
177
|
+
])
|
|
178
|
+
}),
|
|
179
|
+
retrievedAt: z5.string().nullable()
|
|
180
|
+
});
|
|
181
|
+
var factory3 = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
182
|
+
id: "anthropic.web_fetch_20250910",
|
|
183
|
+
name: "web_fetch",
|
|
184
|
+
inputSchema: z5.object({
|
|
185
|
+
url: z5.string()
|
|
186
|
+
}),
|
|
187
|
+
outputSchema: webFetch_20250910OutputSchema
|
|
188
|
+
});
|
|
189
|
+
var webFetch_20250910 = (args = {}) => {
|
|
190
|
+
return factory3(args);
|
|
136
191
|
};
|
|
137
192
|
|
|
138
193
|
// src/anthropic-prepare-tools.ts
|
|
139
|
-
function isWebSearchTool(tool) {
|
|
140
|
-
return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
|
|
141
|
-
}
|
|
142
194
|
function prepareTools({
|
|
143
195
|
tools,
|
|
144
196
|
toolChoice,
|
|
@@ -152,12 +204,8 @@ function prepareTools({
|
|
|
152
204
|
}
|
|
153
205
|
const anthropicTools2 = [];
|
|
154
206
|
for (const tool of tools) {
|
|
155
|
-
if (isWebSearchTool(tool)) {
|
|
156
|
-
anthropicTools2.push(tool);
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
207
|
switch (tool.type) {
|
|
160
|
-
case "function":
|
|
208
|
+
case "function": {
|
|
161
209
|
const cacheControl = getCacheControl(tool.providerOptions);
|
|
162
210
|
anthropicTools2.push({
|
|
163
211
|
name: tool.name,
|
|
@@ -166,9 +214,18 @@ function prepareTools({
|
|
|
166
214
|
cache_control: cacheControl
|
|
167
215
|
});
|
|
168
216
|
break;
|
|
169
|
-
|
|
217
|
+
}
|
|
218
|
+
case "provider-defined": {
|
|
170
219
|
switch (tool.id) {
|
|
171
|
-
case "anthropic.
|
|
220
|
+
case "anthropic.code_execution_20250522": {
|
|
221
|
+
betas.add("code-execution-2025-05-22");
|
|
222
|
+
anthropicTools2.push({
|
|
223
|
+
type: "code_execution_20250522",
|
|
224
|
+
name: "code_execution"
|
|
225
|
+
});
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case "anthropic.computer_20250124": {
|
|
172
229
|
betas.add("computer-use-2025-01-24");
|
|
173
230
|
anthropicTools2.push({
|
|
174
231
|
name: "computer",
|
|
@@ -178,7 +235,8 @@ function prepareTools({
|
|
|
178
235
|
display_number: tool.args.displayNumber
|
|
179
236
|
});
|
|
180
237
|
break;
|
|
181
|
-
|
|
238
|
+
}
|
|
239
|
+
case "anthropic.computer_20241022": {
|
|
182
240
|
betas.add("computer-use-2024-10-22");
|
|
183
241
|
anthropicTools2.push({
|
|
184
242
|
name: "computer",
|
|
@@ -188,41 +246,70 @@ function prepareTools({
|
|
|
188
246
|
display_number: tool.args.displayNumber
|
|
189
247
|
});
|
|
190
248
|
break;
|
|
191
|
-
|
|
249
|
+
}
|
|
250
|
+
case "anthropic.text_editor_20250124": {
|
|
192
251
|
betas.add("computer-use-2025-01-24");
|
|
193
252
|
anthropicTools2.push({
|
|
194
253
|
name: "str_replace_editor",
|
|
195
254
|
type: "text_editor_20250124"
|
|
196
255
|
});
|
|
197
256
|
break;
|
|
198
|
-
|
|
257
|
+
}
|
|
258
|
+
case "anthropic.text_editor_20241022": {
|
|
199
259
|
betas.add("computer-use-2024-10-22");
|
|
200
260
|
anthropicTools2.push({
|
|
201
261
|
name: "str_replace_editor",
|
|
202
262
|
type: "text_editor_20241022"
|
|
203
263
|
});
|
|
204
264
|
break;
|
|
205
|
-
|
|
265
|
+
}
|
|
266
|
+
case "anthropic.text_editor_20250429": {
|
|
206
267
|
betas.add("computer-use-2025-01-24");
|
|
207
268
|
anthropicTools2.push({
|
|
208
269
|
name: "str_replace_based_edit_tool",
|
|
209
270
|
type: "text_editor_20250429"
|
|
210
271
|
});
|
|
211
272
|
break;
|
|
212
|
-
|
|
273
|
+
}
|
|
274
|
+
case "anthropic.text_editor_20250728": {
|
|
275
|
+
const args = textEditor_20250728ArgsSchema.parse(tool.args);
|
|
276
|
+
anthropicTools2.push({
|
|
277
|
+
name: "str_replace_based_edit_tool",
|
|
278
|
+
type: "text_editor_20250728",
|
|
279
|
+
max_characters: args.maxCharacters
|
|
280
|
+
});
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
case "anthropic.bash_20250124": {
|
|
213
284
|
betas.add("computer-use-2025-01-24");
|
|
214
285
|
anthropicTools2.push({
|
|
215
286
|
name: "bash",
|
|
216
287
|
type: "bash_20250124"
|
|
217
288
|
});
|
|
218
289
|
break;
|
|
219
|
-
|
|
290
|
+
}
|
|
291
|
+
case "anthropic.bash_20241022": {
|
|
220
292
|
betas.add("computer-use-2024-10-22");
|
|
221
293
|
anthropicTools2.push({
|
|
222
294
|
name: "bash",
|
|
223
295
|
type: "bash_20241022"
|
|
224
296
|
});
|
|
225
297
|
break;
|
|
298
|
+
}
|
|
299
|
+
case "anthropic.web_fetch_20250910": {
|
|
300
|
+
betas.add("web-fetch-2025-09-10");
|
|
301
|
+
const args = webFetch_20250910ArgsSchema.parse(tool.args);
|
|
302
|
+
anthropicTools2.push({
|
|
303
|
+
type: "web_fetch_20250910",
|
|
304
|
+
name: "web_fetch",
|
|
305
|
+
max_uses: args.maxUses,
|
|
306
|
+
allowed_domains: args.allowedDomains,
|
|
307
|
+
blocked_domains: args.blockedDomains,
|
|
308
|
+
citations: args.citations,
|
|
309
|
+
max_content_tokens: args.maxContentTokens
|
|
310
|
+
});
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
226
313
|
case "anthropic.web_search_20250305": {
|
|
227
314
|
const args = webSearch_20250305ArgsSchema.parse(tool.args);
|
|
228
315
|
anthropicTools2.push({
|
|
@@ -235,22 +322,17 @@ function prepareTools({
|
|
|
235
322
|
});
|
|
236
323
|
break;
|
|
237
324
|
}
|
|
238
|
-
|
|
239
|
-
betas.add("code-execution-2025-05-22");
|
|
240
|
-
anthropicTools2.push({
|
|
241
|
-
type: "code_execution_20250522",
|
|
242
|
-
name: "code_execution"
|
|
243
|
-
});
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
default:
|
|
325
|
+
default: {
|
|
247
326
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
248
327
|
break;
|
|
328
|
+
}
|
|
249
329
|
}
|
|
250
330
|
break;
|
|
251
|
-
|
|
331
|
+
}
|
|
332
|
+
default: {
|
|
252
333
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
253
334
|
break;
|
|
335
|
+
}
|
|
254
336
|
}
|
|
255
337
|
}
|
|
256
338
|
if (toolChoice == null) {
|
|
@@ -312,24 +394,24 @@ import {
|
|
|
312
394
|
import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
313
395
|
|
|
314
396
|
// src/tool/code-execution_20250522.ts
|
|
315
|
-
import { createProviderDefinedToolFactoryWithOutputSchema as
|
|
316
|
-
import { z as
|
|
317
|
-
var codeExecution_20250522OutputSchema =
|
|
318
|
-
type:
|
|
319
|
-
stdout:
|
|
320
|
-
stderr:
|
|
321
|
-
return_code:
|
|
397
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@ai-sdk/provider-utils";
|
|
398
|
+
import { z as z6 } from "zod/v4";
|
|
399
|
+
var codeExecution_20250522OutputSchema = z6.object({
|
|
400
|
+
type: z6.literal("code_execution_result"),
|
|
401
|
+
stdout: z6.string(),
|
|
402
|
+
stderr: z6.string(),
|
|
403
|
+
return_code: z6.number()
|
|
322
404
|
});
|
|
323
|
-
var
|
|
405
|
+
var factory4 = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
324
406
|
id: "anthropic.code_execution_20250522",
|
|
325
407
|
name: "code_execution",
|
|
326
|
-
inputSchema:
|
|
327
|
-
code:
|
|
408
|
+
inputSchema: z6.object({
|
|
409
|
+
code: z6.string()
|
|
328
410
|
}),
|
|
329
411
|
outputSchema: codeExecution_20250522OutputSchema
|
|
330
412
|
});
|
|
331
413
|
var codeExecution_20250522 = (args = {}) => {
|
|
332
|
-
return
|
|
414
|
+
return factory4(args);
|
|
333
415
|
};
|
|
334
416
|
|
|
335
417
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
@@ -622,30 +704,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
622
704
|
}
|
|
623
705
|
case "tool-call": {
|
|
624
706
|
if (part.providerExecuted) {
|
|
625
|
-
if (part.toolName === "web_search") {
|
|
707
|
+
if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
626
708
|
anthropicContent.push({
|
|
627
709
|
type: "server_tool_use",
|
|
628
710
|
id: part.toolCallId,
|
|
629
|
-
name:
|
|
711
|
+
name: part.toolName,
|
|
630
712
|
input: part.input,
|
|
631
713
|
cache_control: cacheControl
|
|
632
714
|
});
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
type: "server_tool_use",
|
|
638
|
-
id: part.toolCallId,
|
|
639
|
-
name: "code_execution",
|
|
640
|
-
input: part.input,
|
|
641
|
-
cache_control: cacheControl
|
|
715
|
+
} else {
|
|
716
|
+
warnings.push({
|
|
717
|
+
type: "other",
|
|
718
|
+
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
642
719
|
});
|
|
643
|
-
break;
|
|
644
720
|
}
|
|
645
|
-
warnings.push({
|
|
646
|
-
type: "other",
|
|
647
|
-
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
648
|
-
});
|
|
649
721
|
break;
|
|
650
722
|
}
|
|
651
723
|
anthropicContent.push({
|
|
@@ -658,7 +730,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
658
730
|
break;
|
|
659
731
|
}
|
|
660
732
|
case "tool-result": {
|
|
661
|
-
if (part.toolName === "
|
|
733
|
+
if (part.toolName === "code_execution") {
|
|
662
734
|
const output = part.output;
|
|
663
735
|
if (output.type !== "json") {
|
|
664
736
|
warnings.push({
|
|
@@ -667,24 +739,21 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
667
739
|
});
|
|
668
740
|
break;
|
|
669
741
|
}
|
|
670
|
-
const
|
|
671
|
-
output.value
|
|
672
|
-
);
|
|
742
|
+
const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
|
|
673
743
|
anthropicContent.push({
|
|
674
|
-
type: "
|
|
744
|
+
type: "code_execution_tool_result",
|
|
675
745
|
tool_use_id: part.toolCallId,
|
|
676
|
-
content:
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
})),
|
|
746
|
+
content: {
|
|
747
|
+
type: codeExecutionOutput.type,
|
|
748
|
+
stdout: codeExecutionOutput.stdout,
|
|
749
|
+
stderr: codeExecutionOutput.stderr,
|
|
750
|
+
return_code: codeExecutionOutput.return_code
|
|
751
|
+
},
|
|
683
752
|
cache_control: cacheControl
|
|
684
753
|
});
|
|
685
754
|
break;
|
|
686
755
|
}
|
|
687
|
-
if (part.toolName === "
|
|
756
|
+
if (part.toolName === "web_fetch") {
|
|
688
757
|
const output = part.output;
|
|
689
758
|
if (output.type !== "json") {
|
|
690
759
|
warnings.push({
|
|
@@ -693,20 +762,57 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
693
762
|
});
|
|
694
763
|
break;
|
|
695
764
|
}
|
|
696
|
-
const
|
|
765
|
+
const webFetchOutput = webFetch_20250910OutputSchema.parse(
|
|
766
|
+
output.value
|
|
767
|
+
);
|
|
697
768
|
anthropicContent.push({
|
|
698
|
-
type: "
|
|
769
|
+
type: "web_fetch_tool_result",
|
|
699
770
|
tool_use_id: part.toolCallId,
|
|
700
771
|
content: {
|
|
701
|
-
type:
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
772
|
+
type: "web_fetch_result",
|
|
773
|
+
url: webFetchOutput.url,
|
|
774
|
+
retrieved_at: webFetchOutput.retrievedAt,
|
|
775
|
+
content: {
|
|
776
|
+
type: "document",
|
|
777
|
+
title: webFetchOutput.content.title,
|
|
778
|
+
citations: webFetchOutput.content.citations,
|
|
779
|
+
source: {
|
|
780
|
+
type: webFetchOutput.content.source.type,
|
|
781
|
+
media_type: webFetchOutput.content.source.mediaType,
|
|
782
|
+
data: webFetchOutput.content.source.data
|
|
783
|
+
}
|
|
784
|
+
}
|
|
705
785
|
},
|
|
706
786
|
cache_control: cacheControl
|
|
707
787
|
});
|
|
708
788
|
break;
|
|
709
789
|
}
|
|
790
|
+
if (part.toolName === "web_search") {
|
|
791
|
+
const output = part.output;
|
|
792
|
+
if (output.type !== "json") {
|
|
793
|
+
warnings.push({
|
|
794
|
+
type: "other",
|
|
795
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
796
|
+
});
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
const webSearchOutput = webSearch_20250305OutputSchema.parse(
|
|
800
|
+
output.value
|
|
801
|
+
);
|
|
802
|
+
anthropicContent.push({
|
|
803
|
+
type: "web_search_tool_result",
|
|
804
|
+
tool_use_id: part.toolCallId,
|
|
805
|
+
content: webSearchOutput.map((result) => ({
|
|
806
|
+
url: result.url,
|
|
807
|
+
title: result.title,
|
|
808
|
+
page_age: result.pageAge,
|
|
809
|
+
encrypted_content: result.encryptedContent,
|
|
810
|
+
type: result.type
|
|
811
|
+
})),
|
|
812
|
+
cache_control: cacheControl
|
|
813
|
+
});
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
710
816
|
warnings.push({
|
|
711
817
|
type: "other",
|
|
712
818
|
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
@@ -800,36 +906,36 @@ function mapAnthropicStopReason({
|
|
|
800
906
|
|
|
801
907
|
// src/anthropic-messages-language-model.ts
|
|
802
908
|
var citationSchemas = {
|
|
803
|
-
webSearchResult:
|
|
804
|
-
type:
|
|
805
|
-
cited_text:
|
|
806
|
-
url:
|
|
807
|
-
title:
|
|
808
|
-
encrypted_index:
|
|
909
|
+
webSearchResult: z7.object({
|
|
910
|
+
type: z7.literal("web_search_result_location"),
|
|
911
|
+
cited_text: z7.string(),
|
|
912
|
+
url: z7.string(),
|
|
913
|
+
title: z7.string(),
|
|
914
|
+
encrypted_index: z7.string()
|
|
809
915
|
}),
|
|
810
|
-
pageLocation:
|
|
811
|
-
type:
|
|
812
|
-
cited_text:
|
|
813
|
-
document_index:
|
|
814
|
-
document_title:
|
|
815
|
-
start_page_number:
|
|
816
|
-
end_page_number:
|
|
916
|
+
pageLocation: z7.object({
|
|
917
|
+
type: z7.literal("page_location"),
|
|
918
|
+
cited_text: z7.string(),
|
|
919
|
+
document_index: z7.number(),
|
|
920
|
+
document_title: z7.string().nullable(),
|
|
921
|
+
start_page_number: z7.number(),
|
|
922
|
+
end_page_number: z7.number()
|
|
817
923
|
}),
|
|
818
|
-
charLocation:
|
|
819
|
-
type:
|
|
820
|
-
cited_text:
|
|
821
|
-
document_index:
|
|
822
|
-
document_title:
|
|
823
|
-
start_char_index:
|
|
824
|
-
end_char_index:
|
|
924
|
+
charLocation: z7.object({
|
|
925
|
+
type: z7.literal("char_location"),
|
|
926
|
+
cited_text: z7.string(),
|
|
927
|
+
document_index: z7.number(),
|
|
928
|
+
document_title: z7.string().nullable(),
|
|
929
|
+
start_char_index: z7.number(),
|
|
930
|
+
end_char_index: z7.number()
|
|
825
931
|
})
|
|
826
932
|
};
|
|
827
|
-
var citationSchema =
|
|
933
|
+
var citationSchema = z7.discriminatedUnion("type", [
|
|
828
934
|
citationSchemas.webSearchResult,
|
|
829
935
|
citationSchemas.pageLocation,
|
|
830
936
|
citationSchemas.charLocation
|
|
831
937
|
]);
|
|
832
|
-
var documentCitationSchema =
|
|
938
|
+
var documentCitationSchema = z7.discriminatedUnion("type", [
|
|
833
939
|
citationSchemas.pageLocation,
|
|
834
940
|
citationSchemas.charLocation
|
|
835
941
|
]);
|
|
@@ -1154,7 +1260,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1154
1260
|
break;
|
|
1155
1261
|
}
|
|
1156
1262
|
case "server_tool_use": {
|
|
1157
|
-
if (part.name === "web_search" || part.name === "code_execution") {
|
|
1263
|
+
if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1158
1264
|
content.push({
|
|
1159
1265
|
type: "tool-call",
|
|
1160
1266
|
toolCallId: part.id,
|
|
@@ -1165,6 +1271,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1165
1271
|
}
|
|
1166
1272
|
break;
|
|
1167
1273
|
}
|
|
1274
|
+
case "web_fetch_tool_result": {
|
|
1275
|
+
if (part.content.type === "web_fetch_result") {
|
|
1276
|
+
content.push({
|
|
1277
|
+
type: "tool-result",
|
|
1278
|
+
toolCallId: part.tool_use_id,
|
|
1279
|
+
toolName: "web_fetch",
|
|
1280
|
+
result: {
|
|
1281
|
+
type: "web_fetch_result",
|
|
1282
|
+
url: part.content.url,
|
|
1283
|
+
retrievedAt: part.content.retrieved_at,
|
|
1284
|
+
content: {
|
|
1285
|
+
type: part.content.content.type,
|
|
1286
|
+
title: part.content.content.title,
|
|
1287
|
+
citations: part.content.content.citations,
|
|
1288
|
+
source: {
|
|
1289
|
+
type: part.content.content.source.type,
|
|
1290
|
+
mediaType: part.content.content.source.media_type,
|
|
1291
|
+
data: part.content.content.source.data
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
providerExecuted: true
|
|
1296
|
+
});
|
|
1297
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1298
|
+
content.push({
|
|
1299
|
+
type: "tool-result",
|
|
1300
|
+
toolCallId: part.tool_use_id,
|
|
1301
|
+
toolName: "web_fetch",
|
|
1302
|
+
isError: true,
|
|
1303
|
+
result: {
|
|
1304
|
+
type: "web_fetch_tool_result_error",
|
|
1305
|
+
errorCode: part.content.error_code
|
|
1306
|
+
},
|
|
1307
|
+
providerExecuted: true
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
break;
|
|
1311
|
+
}
|
|
1168
1312
|
case "web_search_tool_result": {
|
|
1169
1313
|
if (Array.isArray(part.content)) {
|
|
1170
1314
|
content.push({
|
|
@@ -1293,7 +1437,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1293
1437
|
totalTokens: void 0
|
|
1294
1438
|
};
|
|
1295
1439
|
const contentBlocks = {};
|
|
1296
|
-
let
|
|
1440
|
+
let rawUsage = void 0;
|
|
1441
|
+
let cacheCreationInputTokens = null;
|
|
1297
1442
|
let blockType = void 0;
|
|
1298
1443
|
const generateId2 = this.generateId;
|
|
1299
1444
|
return {
|
|
@@ -1366,7 +1511,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1366
1511
|
return;
|
|
1367
1512
|
}
|
|
1368
1513
|
case "server_tool_use": {
|
|
1369
|
-
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1514
|
+
if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1370
1515
|
contentBlocks[value.index] = {
|
|
1371
1516
|
type: "tool-call",
|
|
1372
1517
|
toolCallId: value.content_block.id,
|
|
@@ -1383,6 +1528,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1383
1528
|
}
|
|
1384
1529
|
return;
|
|
1385
1530
|
}
|
|
1531
|
+
case "web_fetch_tool_result": {
|
|
1532
|
+
const part = value.content_block;
|
|
1533
|
+
if (part.content.type === "web_fetch_result") {
|
|
1534
|
+
controller.enqueue({
|
|
1535
|
+
type: "tool-result",
|
|
1536
|
+
toolCallId: part.tool_use_id,
|
|
1537
|
+
toolName: "web_fetch",
|
|
1538
|
+
result: {
|
|
1539
|
+
type: "web_fetch_result",
|
|
1540
|
+
url: part.content.url,
|
|
1541
|
+
retrievedAt: part.content.retrieved_at,
|
|
1542
|
+
content: {
|
|
1543
|
+
type: part.content.content.type,
|
|
1544
|
+
title: part.content.content.title,
|
|
1545
|
+
citations: part.content.content.citations,
|
|
1546
|
+
source: {
|
|
1547
|
+
type: part.content.content.source.type,
|
|
1548
|
+
mediaType: part.content.content.source.media_type,
|
|
1549
|
+
data: part.content.content.source.data
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1555
|
+
controller.enqueue({
|
|
1556
|
+
type: "tool-result",
|
|
1557
|
+
toolCallId: part.tool_use_id,
|
|
1558
|
+
toolName: "web_fetch",
|
|
1559
|
+
isError: true,
|
|
1560
|
+
result: {
|
|
1561
|
+
type: "web_fetch_tool_result_error",
|
|
1562
|
+
errorCode: part.content.error_code
|
|
1563
|
+
},
|
|
1564
|
+
providerExecuted: true
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1386
1569
|
case "web_search_tool_result": {
|
|
1387
1570
|
const part = value.content_block;
|
|
1388
1571
|
if (Array.isArray(part.content)) {
|
|
@@ -1585,12 +1768,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1585
1768
|
case "message_start": {
|
|
1586
1769
|
usage.inputTokens = value.message.usage.input_tokens;
|
|
1587
1770
|
usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
usage: value.message.usage,
|
|
1591
|
-
cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
|
|
1592
|
-
}
|
|
1771
|
+
rawUsage = {
|
|
1772
|
+
...value.message.usage
|
|
1593
1773
|
};
|
|
1774
|
+
cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
|
|
1594
1775
|
controller.enqueue({
|
|
1595
1776
|
type: "response-metadata",
|
|
1596
1777
|
id: (_d = value.message.id) != null ? _d : void 0,
|
|
@@ -1605,6 +1786,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1605
1786
|
finishReason: value.delta.stop_reason,
|
|
1606
1787
|
isJsonResponseFromTool: usesJsonResponseTool
|
|
1607
1788
|
});
|
|
1789
|
+
rawUsage = {
|
|
1790
|
+
...rawUsage,
|
|
1791
|
+
...value.usage
|
|
1792
|
+
};
|
|
1608
1793
|
return;
|
|
1609
1794
|
}
|
|
1610
1795
|
case "message_stop": {
|
|
@@ -1612,7 +1797,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1612
1797
|
type: "finish",
|
|
1613
1798
|
finishReason,
|
|
1614
1799
|
usage,
|
|
1615
|
-
providerMetadata
|
|
1800
|
+
providerMetadata: {
|
|
1801
|
+
anthropic: {
|
|
1802
|
+
usage: rawUsage != null ? rawUsage : null,
|
|
1803
|
+
cacheCreationInputTokens
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1616
1806
|
});
|
|
1617
1807
|
return;
|
|
1618
1808
|
}
|
|
@@ -1633,247 +1823,299 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1633
1823
|
};
|
|
1634
1824
|
}
|
|
1635
1825
|
};
|
|
1636
|
-
var anthropicMessagesResponseSchema =
|
|
1637
|
-
type:
|
|
1638
|
-
id:
|
|
1639
|
-
model:
|
|
1640
|
-
content:
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
type:
|
|
1644
|
-
text:
|
|
1645
|
-
citations:
|
|
1826
|
+
var anthropicMessagesResponseSchema = z7.object({
|
|
1827
|
+
type: z7.literal("message"),
|
|
1828
|
+
id: z7.string().nullish(),
|
|
1829
|
+
model: z7.string().nullish(),
|
|
1830
|
+
content: z7.array(
|
|
1831
|
+
z7.discriminatedUnion("type", [
|
|
1832
|
+
z7.object({
|
|
1833
|
+
type: z7.literal("text"),
|
|
1834
|
+
text: z7.string(),
|
|
1835
|
+
citations: z7.array(citationSchema).optional()
|
|
1646
1836
|
}),
|
|
1647
|
-
|
|
1648
|
-
type:
|
|
1649
|
-
thinking:
|
|
1650
|
-
signature:
|
|
1837
|
+
z7.object({
|
|
1838
|
+
type: z7.literal("thinking"),
|
|
1839
|
+
thinking: z7.string(),
|
|
1840
|
+
signature: z7.string()
|
|
1651
1841
|
}),
|
|
1652
|
-
|
|
1653
|
-
type:
|
|
1654
|
-
data:
|
|
1842
|
+
z7.object({
|
|
1843
|
+
type: z7.literal("redacted_thinking"),
|
|
1844
|
+
data: z7.string()
|
|
1655
1845
|
}),
|
|
1656
|
-
|
|
1657
|
-
type:
|
|
1658
|
-
id:
|
|
1659
|
-
name:
|
|
1660
|
-
input:
|
|
1846
|
+
z7.object({
|
|
1847
|
+
type: z7.literal("tool_use"),
|
|
1848
|
+
id: z7.string(),
|
|
1849
|
+
name: z7.string(),
|
|
1850
|
+
input: z7.unknown()
|
|
1661
1851
|
}),
|
|
1662
|
-
|
|
1663
|
-
type:
|
|
1664
|
-
id:
|
|
1665
|
-
name:
|
|
1666
|
-
input:
|
|
1852
|
+
z7.object({
|
|
1853
|
+
type: z7.literal("server_tool_use"),
|
|
1854
|
+
id: z7.string(),
|
|
1855
|
+
name: z7.string(),
|
|
1856
|
+
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1667
1857
|
}),
|
|
1668
|
-
|
|
1669
|
-
type:
|
|
1670
|
-
tool_use_id:
|
|
1671
|
-
content:
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1858
|
+
z7.object({
|
|
1859
|
+
type: z7.literal("web_fetch_tool_result"),
|
|
1860
|
+
tool_use_id: z7.string(),
|
|
1861
|
+
content: z7.union([
|
|
1862
|
+
z7.object({
|
|
1863
|
+
type: z7.literal("web_fetch_result"),
|
|
1864
|
+
url: z7.string(),
|
|
1865
|
+
retrieved_at: z7.string(),
|
|
1866
|
+
content: z7.object({
|
|
1867
|
+
type: z7.literal("document"),
|
|
1868
|
+
title: z7.string(),
|
|
1869
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1870
|
+
source: z7.object({
|
|
1871
|
+
type: z7.literal("text"),
|
|
1872
|
+
media_type: z7.string(),
|
|
1873
|
+
data: z7.string()
|
|
1874
|
+
})
|
|
1875
|
+
})
|
|
1876
|
+
}),
|
|
1877
|
+
z7.object({
|
|
1878
|
+
type: z7.literal("web_fetch_tool_result_error"),
|
|
1879
|
+
error_code: z7.string()
|
|
1880
|
+
})
|
|
1881
|
+
])
|
|
1882
|
+
}),
|
|
1883
|
+
z7.object({
|
|
1884
|
+
type: z7.literal("web_search_tool_result"),
|
|
1885
|
+
tool_use_id: z7.string(),
|
|
1886
|
+
content: z7.union([
|
|
1887
|
+
z7.array(
|
|
1888
|
+
z7.object({
|
|
1889
|
+
type: z7.literal("web_search_result"),
|
|
1890
|
+
url: z7.string(),
|
|
1891
|
+
title: z7.string(),
|
|
1892
|
+
encrypted_content: z7.string(),
|
|
1893
|
+
page_age: z7.string().nullish()
|
|
1679
1894
|
})
|
|
1680
1895
|
),
|
|
1681
|
-
|
|
1682
|
-
type:
|
|
1683
|
-
error_code:
|
|
1896
|
+
z7.object({
|
|
1897
|
+
type: z7.literal("web_search_tool_result_error"),
|
|
1898
|
+
error_code: z7.string()
|
|
1684
1899
|
})
|
|
1685
1900
|
])
|
|
1686
1901
|
}),
|
|
1687
|
-
|
|
1688
|
-
type:
|
|
1689
|
-
tool_use_id:
|
|
1690
|
-
content:
|
|
1691
|
-
|
|
1692
|
-
type:
|
|
1693
|
-
stdout:
|
|
1694
|
-
stderr:
|
|
1695
|
-
return_code:
|
|
1902
|
+
z7.object({
|
|
1903
|
+
type: z7.literal("code_execution_tool_result"),
|
|
1904
|
+
tool_use_id: z7.string(),
|
|
1905
|
+
content: z7.union([
|
|
1906
|
+
z7.object({
|
|
1907
|
+
type: z7.literal("code_execution_result"),
|
|
1908
|
+
stdout: z7.string(),
|
|
1909
|
+
stderr: z7.string(),
|
|
1910
|
+
return_code: z7.number()
|
|
1696
1911
|
}),
|
|
1697
|
-
|
|
1698
|
-
type:
|
|
1699
|
-
error_code:
|
|
1912
|
+
z7.object({
|
|
1913
|
+
type: z7.literal("code_execution_tool_result_error"),
|
|
1914
|
+
error_code: z7.string()
|
|
1700
1915
|
})
|
|
1701
1916
|
])
|
|
1702
1917
|
})
|
|
1703
1918
|
])
|
|
1704
1919
|
),
|
|
1705
|
-
stop_reason:
|
|
1706
|
-
usage:
|
|
1707
|
-
input_tokens:
|
|
1708
|
-
output_tokens:
|
|
1709
|
-
cache_creation_input_tokens:
|
|
1710
|
-
cache_read_input_tokens:
|
|
1920
|
+
stop_reason: z7.string().nullish(),
|
|
1921
|
+
usage: z7.looseObject({
|
|
1922
|
+
input_tokens: z7.number(),
|
|
1923
|
+
output_tokens: z7.number(),
|
|
1924
|
+
cache_creation_input_tokens: z7.number().nullish(),
|
|
1925
|
+
cache_read_input_tokens: z7.number().nullish()
|
|
1711
1926
|
})
|
|
1712
1927
|
});
|
|
1713
|
-
var anthropicMessagesChunkSchema =
|
|
1714
|
-
|
|
1715
|
-
type:
|
|
1716
|
-
message:
|
|
1717
|
-
id:
|
|
1718
|
-
model:
|
|
1719
|
-
usage:
|
|
1720
|
-
input_tokens:
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
cache_read_input_tokens: z5.number().nullish()
|
|
1928
|
+
var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
|
|
1929
|
+
z7.object({
|
|
1930
|
+
type: z7.literal("message_start"),
|
|
1931
|
+
message: z7.object({
|
|
1932
|
+
id: z7.string().nullish(),
|
|
1933
|
+
model: z7.string().nullish(),
|
|
1934
|
+
usage: z7.looseObject({
|
|
1935
|
+
input_tokens: z7.number(),
|
|
1936
|
+
cache_creation_input_tokens: z7.number().nullish(),
|
|
1937
|
+
cache_read_input_tokens: z7.number().nullish()
|
|
1724
1938
|
})
|
|
1725
1939
|
})
|
|
1726
1940
|
}),
|
|
1727
|
-
|
|
1728
|
-
type:
|
|
1729
|
-
index:
|
|
1730
|
-
content_block:
|
|
1731
|
-
|
|
1732
|
-
type:
|
|
1733
|
-
text:
|
|
1941
|
+
z7.object({
|
|
1942
|
+
type: z7.literal("content_block_start"),
|
|
1943
|
+
index: z7.number(),
|
|
1944
|
+
content_block: z7.discriminatedUnion("type", [
|
|
1945
|
+
z7.object({
|
|
1946
|
+
type: z7.literal("text"),
|
|
1947
|
+
text: z7.string()
|
|
1734
1948
|
}),
|
|
1735
|
-
|
|
1736
|
-
type:
|
|
1737
|
-
thinking:
|
|
1949
|
+
z7.object({
|
|
1950
|
+
type: z7.literal("thinking"),
|
|
1951
|
+
thinking: z7.string()
|
|
1738
1952
|
}),
|
|
1739
|
-
|
|
1740
|
-
type:
|
|
1741
|
-
id:
|
|
1742
|
-
name:
|
|
1953
|
+
z7.object({
|
|
1954
|
+
type: z7.literal("tool_use"),
|
|
1955
|
+
id: z7.string(),
|
|
1956
|
+
name: z7.string()
|
|
1743
1957
|
}),
|
|
1744
|
-
|
|
1745
|
-
type:
|
|
1746
|
-
data:
|
|
1958
|
+
z7.object({
|
|
1959
|
+
type: z7.literal("redacted_thinking"),
|
|
1960
|
+
data: z7.string()
|
|
1747
1961
|
}),
|
|
1748
|
-
|
|
1749
|
-
type:
|
|
1750
|
-
id:
|
|
1751
|
-
name:
|
|
1752
|
-
input:
|
|
1962
|
+
z7.object({
|
|
1963
|
+
type: z7.literal("server_tool_use"),
|
|
1964
|
+
id: z7.string(),
|
|
1965
|
+
name: z7.string(),
|
|
1966
|
+
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1753
1967
|
}),
|
|
1754
|
-
|
|
1755
|
-
type:
|
|
1756
|
-
tool_use_id:
|
|
1757
|
-
content:
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1968
|
+
z7.object({
|
|
1969
|
+
type: z7.literal("web_fetch_tool_result"),
|
|
1970
|
+
tool_use_id: z7.string(),
|
|
1971
|
+
content: z7.union([
|
|
1972
|
+
z7.object({
|
|
1973
|
+
type: z7.literal("web_fetch_result"),
|
|
1974
|
+
url: z7.string(),
|
|
1975
|
+
retrieved_at: z7.string(),
|
|
1976
|
+
content: z7.object({
|
|
1977
|
+
type: z7.literal("document"),
|
|
1978
|
+
title: z7.string(),
|
|
1979
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1980
|
+
source: z7.object({
|
|
1981
|
+
type: z7.literal("text"),
|
|
1982
|
+
media_type: z7.string(),
|
|
1983
|
+
data: z7.string()
|
|
1984
|
+
})
|
|
1985
|
+
})
|
|
1986
|
+
}),
|
|
1987
|
+
z7.object({
|
|
1988
|
+
type: z7.literal("web_fetch_tool_result_error"),
|
|
1989
|
+
error_code: z7.string()
|
|
1990
|
+
})
|
|
1991
|
+
])
|
|
1992
|
+
}),
|
|
1993
|
+
z7.object({
|
|
1994
|
+
type: z7.literal("web_search_tool_result"),
|
|
1995
|
+
tool_use_id: z7.string(),
|
|
1996
|
+
content: z7.union([
|
|
1997
|
+
z7.array(
|
|
1998
|
+
z7.object({
|
|
1999
|
+
type: z7.literal("web_search_result"),
|
|
2000
|
+
url: z7.string(),
|
|
2001
|
+
title: z7.string(),
|
|
2002
|
+
encrypted_content: z7.string(),
|
|
2003
|
+
page_age: z7.string().nullish()
|
|
1765
2004
|
})
|
|
1766
2005
|
),
|
|
1767
|
-
|
|
1768
|
-
type:
|
|
1769
|
-
error_code:
|
|
2006
|
+
z7.object({
|
|
2007
|
+
type: z7.literal("web_search_tool_result_error"),
|
|
2008
|
+
error_code: z7.string()
|
|
1770
2009
|
})
|
|
1771
2010
|
])
|
|
1772
2011
|
}),
|
|
1773
|
-
|
|
1774
|
-
type:
|
|
1775
|
-
tool_use_id:
|
|
1776
|
-
content:
|
|
1777
|
-
|
|
1778
|
-
type:
|
|
1779
|
-
stdout:
|
|
1780
|
-
stderr:
|
|
1781
|
-
return_code:
|
|
2012
|
+
z7.object({
|
|
2013
|
+
type: z7.literal("code_execution_tool_result"),
|
|
2014
|
+
tool_use_id: z7.string(),
|
|
2015
|
+
content: z7.union([
|
|
2016
|
+
z7.object({
|
|
2017
|
+
type: z7.literal("code_execution_result"),
|
|
2018
|
+
stdout: z7.string(),
|
|
2019
|
+
stderr: z7.string(),
|
|
2020
|
+
return_code: z7.number()
|
|
1782
2021
|
}),
|
|
1783
|
-
|
|
1784
|
-
type:
|
|
1785
|
-
error_code:
|
|
2022
|
+
z7.object({
|
|
2023
|
+
type: z7.literal("code_execution_tool_result_error"),
|
|
2024
|
+
error_code: z7.string()
|
|
1786
2025
|
})
|
|
1787
2026
|
])
|
|
1788
2027
|
})
|
|
1789
2028
|
])
|
|
1790
2029
|
}),
|
|
1791
|
-
|
|
1792
|
-
type:
|
|
1793
|
-
index:
|
|
1794
|
-
delta:
|
|
1795
|
-
|
|
1796
|
-
type:
|
|
1797
|
-
partial_json:
|
|
2030
|
+
z7.object({
|
|
2031
|
+
type: z7.literal("content_block_delta"),
|
|
2032
|
+
index: z7.number(),
|
|
2033
|
+
delta: z7.discriminatedUnion("type", [
|
|
2034
|
+
z7.object({
|
|
2035
|
+
type: z7.literal("input_json_delta"),
|
|
2036
|
+
partial_json: z7.string()
|
|
1798
2037
|
}),
|
|
1799
|
-
|
|
1800
|
-
type:
|
|
1801
|
-
text:
|
|
2038
|
+
z7.object({
|
|
2039
|
+
type: z7.literal("text_delta"),
|
|
2040
|
+
text: z7.string()
|
|
1802
2041
|
}),
|
|
1803
|
-
|
|
1804
|
-
type:
|
|
1805
|
-
thinking:
|
|
2042
|
+
z7.object({
|
|
2043
|
+
type: z7.literal("thinking_delta"),
|
|
2044
|
+
thinking: z7.string()
|
|
1806
2045
|
}),
|
|
1807
|
-
|
|
1808
|
-
type:
|
|
1809
|
-
signature:
|
|
2046
|
+
z7.object({
|
|
2047
|
+
type: z7.literal("signature_delta"),
|
|
2048
|
+
signature: z7.string()
|
|
1810
2049
|
}),
|
|
1811
|
-
|
|
1812
|
-
type:
|
|
2050
|
+
z7.object({
|
|
2051
|
+
type: z7.literal("citations_delta"),
|
|
1813
2052
|
citation: citationSchema
|
|
1814
2053
|
})
|
|
1815
2054
|
])
|
|
1816
2055
|
}),
|
|
1817
|
-
|
|
1818
|
-
type:
|
|
1819
|
-
index:
|
|
2056
|
+
z7.object({
|
|
2057
|
+
type: z7.literal("content_block_stop"),
|
|
2058
|
+
index: z7.number()
|
|
1820
2059
|
}),
|
|
1821
|
-
|
|
1822
|
-
type:
|
|
1823
|
-
error:
|
|
1824
|
-
type:
|
|
1825
|
-
message:
|
|
2060
|
+
z7.object({
|
|
2061
|
+
type: z7.literal("error"),
|
|
2062
|
+
error: z7.object({
|
|
2063
|
+
type: z7.string(),
|
|
2064
|
+
message: z7.string()
|
|
1826
2065
|
})
|
|
1827
2066
|
}),
|
|
1828
|
-
|
|
1829
|
-
type:
|
|
1830
|
-
delta:
|
|
1831
|
-
usage:
|
|
2067
|
+
z7.object({
|
|
2068
|
+
type: z7.literal("message_delta"),
|
|
2069
|
+
delta: z7.object({ stop_reason: z7.string().nullish() }),
|
|
2070
|
+
usage: z7.looseObject({
|
|
2071
|
+
output_tokens: z7.number(),
|
|
2072
|
+
cache_creation_input_tokens: z7.number().nullish()
|
|
2073
|
+
})
|
|
1832
2074
|
}),
|
|
1833
|
-
|
|
1834
|
-
type:
|
|
2075
|
+
z7.object({
|
|
2076
|
+
type: z7.literal("message_stop")
|
|
1835
2077
|
}),
|
|
1836
|
-
|
|
1837
|
-
type:
|
|
2078
|
+
z7.object({
|
|
2079
|
+
type: z7.literal("ping")
|
|
1838
2080
|
})
|
|
1839
2081
|
]);
|
|
1840
|
-
var anthropicReasoningMetadataSchema =
|
|
1841
|
-
signature:
|
|
1842
|
-
redactedData:
|
|
2082
|
+
var anthropicReasoningMetadataSchema = z7.object({
|
|
2083
|
+
signature: z7.string().optional(),
|
|
2084
|
+
redactedData: z7.string().optional()
|
|
1843
2085
|
});
|
|
1844
2086
|
|
|
1845
2087
|
// src/tool/bash_20241022.ts
|
|
1846
|
-
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
1847
|
-
import
|
|
1848
|
-
var bash_20241022 =
|
|
2088
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
2089
|
+
import z8 from "zod/v4";
|
|
2090
|
+
var bash_20241022 = createProviderDefinedToolFactory2({
|
|
1849
2091
|
id: "anthropic.bash_20241022",
|
|
1850
2092
|
name: "bash",
|
|
1851
|
-
inputSchema:
|
|
1852
|
-
command:
|
|
1853
|
-
restart:
|
|
2093
|
+
inputSchema: z8.object({
|
|
2094
|
+
command: z8.string(),
|
|
2095
|
+
restart: z8.boolean().optional()
|
|
1854
2096
|
})
|
|
1855
2097
|
});
|
|
1856
2098
|
|
|
1857
2099
|
// src/tool/bash_20250124.ts
|
|
1858
|
-
import { createProviderDefinedToolFactory as
|
|
1859
|
-
import
|
|
1860
|
-
var bash_20250124 =
|
|
2100
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
|
|
2101
|
+
import z9 from "zod/v4";
|
|
2102
|
+
var bash_20250124 = createProviderDefinedToolFactory3({
|
|
1861
2103
|
id: "anthropic.bash_20250124",
|
|
1862
2104
|
name: "bash",
|
|
1863
|
-
inputSchema:
|
|
1864
|
-
command:
|
|
1865
|
-
restart:
|
|
2105
|
+
inputSchema: z9.object({
|
|
2106
|
+
command: z9.string(),
|
|
2107
|
+
restart: z9.boolean().optional()
|
|
1866
2108
|
})
|
|
1867
2109
|
});
|
|
1868
2110
|
|
|
1869
2111
|
// src/tool/computer_20241022.ts
|
|
1870
|
-
import { createProviderDefinedToolFactory as
|
|
1871
|
-
import { z as
|
|
1872
|
-
var computer_20241022 =
|
|
2112
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
|
|
2113
|
+
import { z as z10 } from "zod/v4";
|
|
2114
|
+
var computer_20241022 = createProviderDefinedToolFactory4({
|
|
1873
2115
|
id: "anthropic.computer_20241022",
|
|
1874
2116
|
name: "computer",
|
|
1875
|
-
inputSchema:
|
|
1876
|
-
action:
|
|
2117
|
+
inputSchema: z10.object({
|
|
2118
|
+
action: z10.enum([
|
|
1877
2119
|
"key",
|
|
1878
2120
|
"type",
|
|
1879
2121
|
"mouse_move",
|
|
@@ -1885,19 +2127,19 @@ var computer_20241022 = createProviderDefinedToolFactory3({
|
|
|
1885
2127
|
"screenshot",
|
|
1886
2128
|
"cursor_position"
|
|
1887
2129
|
]),
|
|
1888
|
-
coordinate:
|
|
1889
|
-
text:
|
|
2130
|
+
coordinate: z10.array(z10.number().int()).optional(),
|
|
2131
|
+
text: z10.string().optional()
|
|
1890
2132
|
})
|
|
1891
2133
|
});
|
|
1892
2134
|
|
|
1893
2135
|
// src/tool/computer_20250124.ts
|
|
1894
|
-
import { createProviderDefinedToolFactory as
|
|
1895
|
-
import { z as
|
|
1896
|
-
var computer_20250124 =
|
|
2136
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
2137
|
+
import { z as z11 } from "zod/v4";
|
|
2138
|
+
var computer_20250124 = createProviderDefinedToolFactory5({
|
|
1897
2139
|
id: "anthropic.computer_20250124",
|
|
1898
2140
|
name: "computer",
|
|
1899
|
-
inputSchema:
|
|
1900
|
-
action:
|
|
2141
|
+
inputSchema: z11.object({
|
|
2142
|
+
action: z11.enum([
|
|
1901
2143
|
"key",
|
|
1902
2144
|
"hold_key",
|
|
1903
2145
|
"type",
|
|
@@ -1915,63 +2157,63 @@ var computer_20250124 = createProviderDefinedToolFactory4({
|
|
|
1915
2157
|
"wait",
|
|
1916
2158
|
"screenshot"
|
|
1917
2159
|
]),
|
|
1918
|
-
coordinate:
|
|
1919
|
-
duration:
|
|
1920
|
-
scroll_amount:
|
|
1921
|
-
scroll_direction:
|
|
1922
|
-
start_coordinate:
|
|
1923
|
-
text:
|
|
2160
|
+
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2161
|
+
duration: z11.number().optional(),
|
|
2162
|
+
scroll_amount: z11.number().optional(),
|
|
2163
|
+
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2164
|
+
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2165
|
+
text: z11.string().optional()
|
|
1924
2166
|
})
|
|
1925
2167
|
});
|
|
1926
2168
|
|
|
1927
2169
|
// src/tool/text-editor_20241022.ts
|
|
1928
|
-
import { createProviderDefinedToolFactory as
|
|
1929
|
-
import { z as
|
|
1930
|
-
var textEditor_20241022 =
|
|
2170
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
2171
|
+
import { z as z12 } from "zod/v4";
|
|
2172
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
1931
2173
|
id: "anthropic.text_editor_20241022",
|
|
1932
2174
|
name: "str_replace_editor",
|
|
1933
|
-
inputSchema:
|
|
1934
|
-
command:
|
|
1935
|
-
path:
|
|
1936
|
-
file_text:
|
|
1937
|
-
insert_line:
|
|
1938
|
-
new_str:
|
|
1939
|
-
old_str:
|
|
1940
|
-
view_range:
|
|
2175
|
+
inputSchema: z12.object({
|
|
2176
|
+
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2177
|
+
path: z12.string(),
|
|
2178
|
+
file_text: z12.string().optional(),
|
|
2179
|
+
insert_line: z12.number().int().optional(),
|
|
2180
|
+
new_str: z12.string().optional(),
|
|
2181
|
+
old_str: z12.string().optional(),
|
|
2182
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
1941
2183
|
})
|
|
1942
2184
|
});
|
|
1943
2185
|
|
|
1944
2186
|
// src/tool/text-editor_20250124.ts
|
|
1945
|
-
import { createProviderDefinedToolFactory as
|
|
1946
|
-
import { z as
|
|
1947
|
-
var textEditor_20250124 =
|
|
2187
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
|
|
2188
|
+
import { z as z13 } from "zod/v4";
|
|
2189
|
+
var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
1948
2190
|
id: "anthropic.text_editor_20250124",
|
|
1949
2191
|
name: "str_replace_editor",
|
|
1950
|
-
inputSchema:
|
|
1951
|
-
command:
|
|
1952
|
-
path:
|
|
1953
|
-
file_text:
|
|
1954
|
-
insert_line:
|
|
1955
|
-
new_str:
|
|
1956
|
-
old_str:
|
|
1957
|
-
view_range:
|
|
2192
|
+
inputSchema: z13.object({
|
|
2193
|
+
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2194
|
+
path: z13.string(),
|
|
2195
|
+
file_text: z13.string().optional(),
|
|
2196
|
+
insert_line: z13.number().int().optional(),
|
|
2197
|
+
new_str: z13.string().optional(),
|
|
2198
|
+
old_str: z13.string().optional(),
|
|
2199
|
+
view_range: z13.array(z13.number().int()).optional()
|
|
1958
2200
|
})
|
|
1959
2201
|
});
|
|
1960
2202
|
|
|
1961
2203
|
// src/tool/text-editor_20250429.ts
|
|
1962
|
-
import { createProviderDefinedToolFactory as
|
|
1963
|
-
import { z as
|
|
1964
|
-
var textEditor_20250429 =
|
|
2204
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory8 } from "@ai-sdk/provider-utils";
|
|
2205
|
+
import { z as z14 } from "zod/v4";
|
|
2206
|
+
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
1965
2207
|
id: "anthropic.text_editor_20250429",
|
|
1966
2208
|
name: "str_replace_based_edit_tool",
|
|
1967
|
-
inputSchema:
|
|
1968
|
-
command:
|
|
1969
|
-
path:
|
|
1970
|
-
file_text:
|
|
1971
|
-
insert_line:
|
|
1972
|
-
new_str:
|
|
1973
|
-
old_str:
|
|
1974
|
-
view_range:
|
|
2209
|
+
inputSchema: z14.object({
|
|
2210
|
+
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2211
|
+
path: z14.string(),
|
|
2212
|
+
file_text: z14.string().optional(),
|
|
2213
|
+
insert_line: z14.number().int().optional(),
|
|
2214
|
+
new_str: z14.string().optional(),
|
|
2215
|
+
old_str: z14.string().optional(),
|
|
2216
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
1975
2217
|
})
|
|
1976
2218
|
});
|
|
1977
2219
|
|
|
@@ -2037,6 +2279,8 @@ var anthropicTools = {
|
|
|
2037
2279
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2038
2280
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2039
2281
|
*
|
|
2282
|
+
* Supported models: Claude Sonnet 3.5
|
|
2283
|
+
*
|
|
2040
2284
|
* Tool name must be `str_replace_editor`.
|
|
2041
2285
|
*/
|
|
2042
2286
|
textEditor_20241022,
|
|
@@ -2045,6 +2289,8 @@ var anthropicTools = {
|
|
|
2045
2289
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2046
2290
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2047
2291
|
*
|
|
2292
|
+
* Supported models: Claude Sonnet 3.7
|
|
2293
|
+
*
|
|
2048
2294
|
* Tool name must be `str_replace_editor`.
|
|
2049
2295
|
*/
|
|
2050
2296
|
textEditor_20250124,
|
|
@@ -2056,8 +2302,36 @@ var anthropicTools = {
|
|
|
2056
2302
|
* Note: This version does not support the "undo_edit" command.
|
|
2057
2303
|
*
|
|
2058
2304
|
* Tool name must be `str_replace_based_edit_tool`.
|
|
2305
|
+
*
|
|
2306
|
+
* @deprecated Use textEditor_20250728 instead
|
|
2059
2307
|
*/
|
|
2060
2308
|
textEditor_20250429,
|
|
2309
|
+
/**
|
|
2310
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2311
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2312
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2313
|
+
*
|
|
2314
|
+
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
2315
|
+
*
|
|
2316
|
+
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
2317
|
+
*
|
|
2318
|
+
* Tool name must be `str_replace_based_edit_tool`.
|
|
2319
|
+
*
|
|
2320
|
+
* @param maxCharacters - Optional maximum number of characters to view in the file
|
|
2321
|
+
*/
|
|
2322
|
+
textEditor_20250728,
|
|
2323
|
+
/**
|
|
2324
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
2325
|
+
*
|
|
2326
|
+
* Tool name must be `web_fetch`.
|
|
2327
|
+
*
|
|
2328
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
2329
|
+
* @param allowedDomains - Only fetch from these domains
|
|
2330
|
+
* @param blockedDomains - Never fetch from these domains
|
|
2331
|
+
* @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
|
|
2332
|
+
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
2333
|
+
*/
|
|
2334
|
+
webFetch_20250910,
|
|
2061
2335
|
/**
|
|
2062
2336
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
2063
2337
|
*
|