@ai-sdk/anthropic 2.1.0-beta.1 → 2.1.0-beta.10
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 +78 -0
- package/dist/index.d.mts +114 -10
- package/dist/index.d.ts +114 -10
- package/dist/index.js +677 -387
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +660 -370
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +131 -15
- package/dist/internal/index.d.ts +131 -15
- package/dist/internal/index.js +657 -375
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +642 -360
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
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
|
]);
|
|
@@ -874,7 +980,7 @@ function createCitationSource(citation, citationDocuments, generateId2) {
|
|
|
874
980
|
}
|
|
875
981
|
var AnthropicMessagesLanguageModel = class {
|
|
876
982
|
constructor(modelId, config) {
|
|
877
|
-
this.specificationVersion = "
|
|
983
|
+
this.specificationVersion = "v3";
|
|
878
984
|
var _a;
|
|
879
985
|
this.modelId = modelId;
|
|
880
986
|
this.config = config;
|
|
@@ -1077,7 +1183,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1077
1183
|
});
|
|
1078
1184
|
}
|
|
1079
1185
|
async doGenerate(options) {
|
|
1080
|
-
var _a, _b, _c, _d, _e;
|
|
1186
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1081
1187
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1082
1188
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1083
1189
|
const {
|
|
@@ -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({
|
|
@@ -1266,7 +1410,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1266
1410
|
providerMetadata: {
|
|
1267
1411
|
anthropic: {
|
|
1268
1412
|
usage: response.usage,
|
|
1269
|
-
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
|
|
1413
|
+
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
|
|
1414
|
+
stopSequence: (_f = response.stop_sequence) != null ? _f : null
|
|
1270
1415
|
}
|
|
1271
1416
|
}
|
|
1272
1417
|
};
|
|
@@ -1293,7 +1438,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1293
1438
|
totalTokens: void 0
|
|
1294
1439
|
};
|
|
1295
1440
|
const contentBlocks = {};
|
|
1296
|
-
let
|
|
1441
|
+
let rawUsage = void 0;
|
|
1442
|
+
let cacheCreationInputTokens = null;
|
|
1443
|
+
let stopSequence = null;
|
|
1297
1444
|
let blockType = void 0;
|
|
1298
1445
|
const generateId2 = this.generateId;
|
|
1299
1446
|
return {
|
|
@@ -1303,7 +1450,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1303
1450
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1304
1451
|
},
|
|
1305
1452
|
transform(chunk, controller) {
|
|
1306
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1453
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1307
1454
|
if (options.includeRawChunks) {
|
|
1308
1455
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1309
1456
|
}
|
|
@@ -1366,7 +1513,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1366
1513
|
return;
|
|
1367
1514
|
}
|
|
1368
1515
|
case "server_tool_use": {
|
|
1369
|
-
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1516
|
+
if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1370
1517
|
contentBlocks[value.index] = {
|
|
1371
1518
|
type: "tool-call",
|
|
1372
1519
|
toolCallId: value.content_block.id,
|
|
@@ -1383,6 +1530,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1383
1530
|
}
|
|
1384
1531
|
return;
|
|
1385
1532
|
}
|
|
1533
|
+
case "web_fetch_tool_result": {
|
|
1534
|
+
const part = value.content_block;
|
|
1535
|
+
if (part.content.type === "web_fetch_result") {
|
|
1536
|
+
controller.enqueue({
|
|
1537
|
+
type: "tool-result",
|
|
1538
|
+
toolCallId: part.tool_use_id,
|
|
1539
|
+
toolName: "web_fetch",
|
|
1540
|
+
result: {
|
|
1541
|
+
type: "web_fetch_result",
|
|
1542
|
+
url: part.content.url,
|
|
1543
|
+
retrievedAt: part.content.retrieved_at,
|
|
1544
|
+
content: {
|
|
1545
|
+
type: part.content.content.type,
|
|
1546
|
+
title: part.content.content.title,
|
|
1547
|
+
citations: part.content.content.citations,
|
|
1548
|
+
source: {
|
|
1549
|
+
type: part.content.content.source.type,
|
|
1550
|
+
mediaType: part.content.content.source.media_type,
|
|
1551
|
+
data: part.content.content.source.data
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1557
|
+
controller.enqueue({
|
|
1558
|
+
type: "tool-result",
|
|
1559
|
+
toolCallId: part.tool_use_id,
|
|
1560
|
+
toolName: "web_fetch",
|
|
1561
|
+
isError: true,
|
|
1562
|
+
result: {
|
|
1563
|
+
type: "web_fetch_tool_result_error",
|
|
1564
|
+
errorCode: part.content.error_code
|
|
1565
|
+
},
|
|
1566
|
+
providerExecuted: true
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1386
1571
|
case "web_search_tool_result": {
|
|
1387
1572
|
const part = value.content_block;
|
|
1388
1573
|
if (Array.isArray(part.content)) {
|
|
@@ -1585,12 +1770,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1585
1770
|
case "message_start": {
|
|
1586
1771
|
usage.inputTokens = value.message.usage.input_tokens;
|
|
1587
1772
|
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
|
-
}
|
|
1773
|
+
rawUsage = {
|
|
1774
|
+
...value.message.usage
|
|
1593
1775
|
};
|
|
1776
|
+
cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
|
|
1594
1777
|
controller.enqueue({
|
|
1595
1778
|
type: "response-metadata",
|
|
1596
1779
|
id: (_d = value.message.id) != null ? _d : void 0,
|
|
@@ -1605,6 +1788,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1605
1788
|
finishReason: value.delta.stop_reason,
|
|
1606
1789
|
isJsonResponseFromTool: usesJsonResponseTool
|
|
1607
1790
|
});
|
|
1791
|
+
stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
|
|
1792
|
+
rawUsage = {
|
|
1793
|
+
...rawUsage,
|
|
1794
|
+
...value.usage
|
|
1795
|
+
};
|
|
1608
1796
|
return;
|
|
1609
1797
|
}
|
|
1610
1798
|
case "message_stop": {
|
|
@@ -1612,7 +1800,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1612
1800
|
type: "finish",
|
|
1613
1801
|
finishReason,
|
|
1614
1802
|
usage,
|
|
1615
|
-
providerMetadata
|
|
1803
|
+
providerMetadata: {
|
|
1804
|
+
anthropic: {
|
|
1805
|
+
usage: rawUsage != null ? rawUsage : null,
|
|
1806
|
+
cacheCreationInputTokens,
|
|
1807
|
+
stopSequence
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1616
1810
|
});
|
|
1617
1811
|
return;
|
|
1618
1812
|
}
|
|
@@ -1633,247 +1827,303 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1633
1827
|
};
|
|
1634
1828
|
}
|
|
1635
1829
|
};
|
|
1636
|
-
var anthropicMessagesResponseSchema =
|
|
1637
|
-
type:
|
|
1638
|
-
id:
|
|
1639
|
-
model:
|
|
1640
|
-
content:
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
type:
|
|
1644
|
-
text:
|
|
1645
|
-
citations:
|
|
1830
|
+
var anthropicMessagesResponseSchema = z7.object({
|
|
1831
|
+
type: z7.literal("message"),
|
|
1832
|
+
id: z7.string().nullish(),
|
|
1833
|
+
model: z7.string().nullish(),
|
|
1834
|
+
content: z7.array(
|
|
1835
|
+
z7.discriminatedUnion("type", [
|
|
1836
|
+
z7.object({
|
|
1837
|
+
type: z7.literal("text"),
|
|
1838
|
+
text: z7.string(),
|
|
1839
|
+
citations: z7.array(citationSchema).optional()
|
|
1646
1840
|
}),
|
|
1647
|
-
|
|
1648
|
-
type:
|
|
1649
|
-
thinking:
|
|
1650
|
-
signature:
|
|
1841
|
+
z7.object({
|
|
1842
|
+
type: z7.literal("thinking"),
|
|
1843
|
+
thinking: z7.string(),
|
|
1844
|
+
signature: z7.string()
|
|
1651
1845
|
}),
|
|
1652
|
-
|
|
1653
|
-
type:
|
|
1654
|
-
data:
|
|
1846
|
+
z7.object({
|
|
1847
|
+
type: z7.literal("redacted_thinking"),
|
|
1848
|
+
data: z7.string()
|
|
1655
1849
|
}),
|
|
1656
|
-
|
|
1657
|
-
type:
|
|
1658
|
-
id:
|
|
1659
|
-
name:
|
|
1660
|
-
input:
|
|
1850
|
+
z7.object({
|
|
1851
|
+
type: z7.literal("tool_use"),
|
|
1852
|
+
id: z7.string(),
|
|
1853
|
+
name: z7.string(),
|
|
1854
|
+
input: z7.unknown()
|
|
1661
1855
|
}),
|
|
1662
|
-
|
|
1663
|
-
type:
|
|
1664
|
-
id:
|
|
1665
|
-
name:
|
|
1666
|
-
input:
|
|
1856
|
+
z7.object({
|
|
1857
|
+
type: z7.literal("server_tool_use"),
|
|
1858
|
+
id: z7.string(),
|
|
1859
|
+
name: z7.string(),
|
|
1860
|
+
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1667
1861
|
}),
|
|
1668
|
-
|
|
1669
|
-
type:
|
|
1670
|
-
tool_use_id:
|
|
1671
|
-
content:
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1862
|
+
z7.object({
|
|
1863
|
+
type: z7.literal("web_fetch_tool_result"),
|
|
1864
|
+
tool_use_id: z7.string(),
|
|
1865
|
+
content: z7.union([
|
|
1866
|
+
z7.object({
|
|
1867
|
+
type: z7.literal("web_fetch_result"),
|
|
1868
|
+
url: z7.string(),
|
|
1869
|
+
retrieved_at: z7.string(),
|
|
1870
|
+
content: z7.object({
|
|
1871
|
+
type: z7.literal("document"),
|
|
1872
|
+
title: z7.string().nullable(),
|
|
1873
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1874
|
+
source: z7.object({
|
|
1875
|
+
type: z7.literal("text"),
|
|
1876
|
+
media_type: z7.string(),
|
|
1877
|
+
data: z7.string()
|
|
1878
|
+
})
|
|
1879
|
+
})
|
|
1880
|
+
}),
|
|
1881
|
+
z7.object({
|
|
1882
|
+
type: z7.literal("web_fetch_tool_result_error"),
|
|
1883
|
+
error_code: z7.string()
|
|
1884
|
+
})
|
|
1885
|
+
])
|
|
1886
|
+
}),
|
|
1887
|
+
z7.object({
|
|
1888
|
+
type: z7.literal("web_search_tool_result"),
|
|
1889
|
+
tool_use_id: z7.string(),
|
|
1890
|
+
content: z7.union([
|
|
1891
|
+
z7.array(
|
|
1892
|
+
z7.object({
|
|
1893
|
+
type: z7.literal("web_search_result"),
|
|
1894
|
+
url: z7.string(),
|
|
1895
|
+
title: z7.string(),
|
|
1896
|
+
encrypted_content: z7.string(),
|
|
1897
|
+
page_age: z7.string().nullish()
|
|
1679
1898
|
})
|
|
1680
1899
|
),
|
|
1681
|
-
|
|
1682
|
-
type:
|
|
1683
|
-
error_code:
|
|
1900
|
+
z7.object({
|
|
1901
|
+
type: z7.literal("web_search_tool_result_error"),
|
|
1902
|
+
error_code: z7.string()
|
|
1684
1903
|
})
|
|
1685
1904
|
])
|
|
1686
1905
|
}),
|
|
1687
|
-
|
|
1688
|
-
type:
|
|
1689
|
-
tool_use_id:
|
|
1690
|
-
content:
|
|
1691
|
-
|
|
1692
|
-
type:
|
|
1693
|
-
stdout:
|
|
1694
|
-
stderr:
|
|
1695
|
-
return_code:
|
|
1906
|
+
z7.object({
|
|
1907
|
+
type: z7.literal("code_execution_tool_result"),
|
|
1908
|
+
tool_use_id: z7.string(),
|
|
1909
|
+
content: z7.union([
|
|
1910
|
+
z7.object({
|
|
1911
|
+
type: z7.literal("code_execution_result"),
|
|
1912
|
+
stdout: z7.string(),
|
|
1913
|
+
stderr: z7.string(),
|
|
1914
|
+
return_code: z7.number()
|
|
1696
1915
|
}),
|
|
1697
|
-
|
|
1698
|
-
type:
|
|
1699
|
-
error_code:
|
|
1916
|
+
z7.object({
|
|
1917
|
+
type: z7.literal("code_execution_tool_result_error"),
|
|
1918
|
+
error_code: z7.string()
|
|
1700
1919
|
})
|
|
1701
1920
|
])
|
|
1702
1921
|
})
|
|
1703
1922
|
])
|
|
1704
1923
|
),
|
|
1705
|
-
stop_reason:
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1924
|
+
stop_reason: z7.string().nullish(),
|
|
1925
|
+
stop_sequence: z7.string().nullish(),
|
|
1926
|
+
usage: z7.looseObject({
|
|
1927
|
+
input_tokens: z7.number(),
|
|
1928
|
+
output_tokens: z7.number(),
|
|
1929
|
+
cache_creation_input_tokens: z7.number().nullish(),
|
|
1930
|
+
cache_read_input_tokens: z7.number().nullish()
|
|
1711
1931
|
})
|
|
1712
1932
|
});
|
|
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()
|
|
1933
|
+
var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
|
|
1934
|
+
z7.object({
|
|
1935
|
+
type: z7.literal("message_start"),
|
|
1936
|
+
message: z7.object({
|
|
1937
|
+
id: z7.string().nullish(),
|
|
1938
|
+
model: z7.string().nullish(),
|
|
1939
|
+
usage: z7.looseObject({
|
|
1940
|
+
input_tokens: z7.number(),
|
|
1941
|
+
cache_creation_input_tokens: z7.number().nullish(),
|
|
1942
|
+
cache_read_input_tokens: z7.number().nullish()
|
|
1724
1943
|
})
|
|
1725
1944
|
})
|
|
1726
1945
|
}),
|
|
1727
|
-
|
|
1728
|
-
type:
|
|
1729
|
-
index:
|
|
1730
|
-
content_block:
|
|
1731
|
-
|
|
1732
|
-
type:
|
|
1733
|
-
text:
|
|
1946
|
+
z7.object({
|
|
1947
|
+
type: z7.literal("content_block_start"),
|
|
1948
|
+
index: z7.number(),
|
|
1949
|
+
content_block: z7.discriminatedUnion("type", [
|
|
1950
|
+
z7.object({
|
|
1951
|
+
type: z7.literal("text"),
|
|
1952
|
+
text: z7.string()
|
|
1734
1953
|
}),
|
|
1735
|
-
|
|
1736
|
-
type:
|
|
1737
|
-
thinking:
|
|
1954
|
+
z7.object({
|
|
1955
|
+
type: z7.literal("thinking"),
|
|
1956
|
+
thinking: z7.string()
|
|
1738
1957
|
}),
|
|
1739
|
-
|
|
1740
|
-
type:
|
|
1741
|
-
id:
|
|
1742
|
-
name:
|
|
1958
|
+
z7.object({
|
|
1959
|
+
type: z7.literal("tool_use"),
|
|
1960
|
+
id: z7.string(),
|
|
1961
|
+
name: z7.string()
|
|
1743
1962
|
}),
|
|
1744
|
-
|
|
1745
|
-
type:
|
|
1746
|
-
data:
|
|
1963
|
+
z7.object({
|
|
1964
|
+
type: z7.literal("redacted_thinking"),
|
|
1965
|
+
data: z7.string()
|
|
1747
1966
|
}),
|
|
1748
|
-
|
|
1749
|
-
type:
|
|
1750
|
-
id:
|
|
1751
|
-
name:
|
|
1752
|
-
input:
|
|
1967
|
+
z7.object({
|
|
1968
|
+
type: z7.literal("server_tool_use"),
|
|
1969
|
+
id: z7.string(),
|
|
1970
|
+
name: z7.string(),
|
|
1971
|
+
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1753
1972
|
}),
|
|
1754
|
-
|
|
1755
|
-
type:
|
|
1756
|
-
tool_use_id:
|
|
1757
|
-
content:
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1973
|
+
z7.object({
|
|
1974
|
+
type: z7.literal("web_fetch_tool_result"),
|
|
1975
|
+
tool_use_id: z7.string(),
|
|
1976
|
+
content: z7.union([
|
|
1977
|
+
z7.object({
|
|
1978
|
+
type: z7.literal("web_fetch_result"),
|
|
1979
|
+
url: z7.string(),
|
|
1980
|
+
retrieved_at: z7.string(),
|
|
1981
|
+
content: z7.object({
|
|
1982
|
+
type: z7.literal("document"),
|
|
1983
|
+
title: z7.string().nullable(),
|
|
1984
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1985
|
+
source: z7.object({
|
|
1986
|
+
type: z7.literal("text"),
|
|
1987
|
+
media_type: z7.string(),
|
|
1988
|
+
data: z7.string()
|
|
1989
|
+
})
|
|
1990
|
+
})
|
|
1991
|
+
}),
|
|
1992
|
+
z7.object({
|
|
1993
|
+
type: z7.literal("web_fetch_tool_result_error"),
|
|
1994
|
+
error_code: z7.string()
|
|
1995
|
+
})
|
|
1996
|
+
])
|
|
1997
|
+
}),
|
|
1998
|
+
z7.object({
|
|
1999
|
+
type: z7.literal("web_search_tool_result"),
|
|
2000
|
+
tool_use_id: z7.string(),
|
|
2001
|
+
content: z7.union([
|
|
2002
|
+
z7.array(
|
|
2003
|
+
z7.object({
|
|
2004
|
+
type: z7.literal("web_search_result"),
|
|
2005
|
+
url: z7.string(),
|
|
2006
|
+
title: z7.string(),
|
|
2007
|
+
encrypted_content: z7.string(),
|
|
2008
|
+
page_age: z7.string().nullish()
|
|
1765
2009
|
})
|
|
1766
2010
|
),
|
|
1767
|
-
|
|
1768
|
-
type:
|
|
1769
|
-
error_code:
|
|
2011
|
+
z7.object({
|
|
2012
|
+
type: z7.literal("web_search_tool_result_error"),
|
|
2013
|
+
error_code: z7.string()
|
|
1770
2014
|
})
|
|
1771
2015
|
])
|
|
1772
2016
|
}),
|
|
1773
|
-
|
|
1774
|
-
type:
|
|
1775
|
-
tool_use_id:
|
|
1776
|
-
content:
|
|
1777
|
-
|
|
1778
|
-
type:
|
|
1779
|
-
stdout:
|
|
1780
|
-
stderr:
|
|
1781
|
-
return_code:
|
|
2017
|
+
z7.object({
|
|
2018
|
+
type: z7.literal("code_execution_tool_result"),
|
|
2019
|
+
tool_use_id: z7.string(),
|
|
2020
|
+
content: z7.union([
|
|
2021
|
+
z7.object({
|
|
2022
|
+
type: z7.literal("code_execution_result"),
|
|
2023
|
+
stdout: z7.string(),
|
|
2024
|
+
stderr: z7.string(),
|
|
2025
|
+
return_code: z7.number()
|
|
1782
2026
|
}),
|
|
1783
|
-
|
|
1784
|
-
type:
|
|
1785
|
-
error_code:
|
|
2027
|
+
z7.object({
|
|
2028
|
+
type: z7.literal("code_execution_tool_result_error"),
|
|
2029
|
+
error_code: z7.string()
|
|
1786
2030
|
})
|
|
1787
2031
|
])
|
|
1788
2032
|
})
|
|
1789
2033
|
])
|
|
1790
2034
|
}),
|
|
1791
|
-
|
|
1792
|
-
type:
|
|
1793
|
-
index:
|
|
1794
|
-
delta:
|
|
1795
|
-
|
|
1796
|
-
type:
|
|
1797
|
-
partial_json:
|
|
2035
|
+
z7.object({
|
|
2036
|
+
type: z7.literal("content_block_delta"),
|
|
2037
|
+
index: z7.number(),
|
|
2038
|
+
delta: z7.discriminatedUnion("type", [
|
|
2039
|
+
z7.object({
|
|
2040
|
+
type: z7.literal("input_json_delta"),
|
|
2041
|
+
partial_json: z7.string()
|
|
1798
2042
|
}),
|
|
1799
|
-
|
|
1800
|
-
type:
|
|
1801
|
-
text:
|
|
2043
|
+
z7.object({
|
|
2044
|
+
type: z7.literal("text_delta"),
|
|
2045
|
+
text: z7.string()
|
|
1802
2046
|
}),
|
|
1803
|
-
|
|
1804
|
-
type:
|
|
1805
|
-
thinking:
|
|
2047
|
+
z7.object({
|
|
2048
|
+
type: z7.literal("thinking_delta"),
|
|
2049
|
+
thinking: z7.string()
|
|
1806
2050
|
}),
|
|
1807
|
-
|
|
1808
|
-
type:
|
|
1809
|
-
signature:
|
|
2051
|
+
z7.object({
|
|
2052
|
+
type: z7.literal("signature_delta"),
|
|
2053
|
+
signature: z7.string()
|
|
1810
2054
|
}),
|
|
1811
|
-
|
|
1812
|
-
type:
|
|
2055
|
+
z7.object({
|
|
2056
|
+
type: z7.literal("citations_delta"),
|
|
1813
2057
|
citation: citationSchema
|
|
1814
2058
|
})
|
|
1815
2059
|
])
|
|
1816
2060
|
}),
|
|
1817
|
-
|
|
1818
|
-
type:
|
|
1819
|
-
index:
|
|
2061
|
+
z7.object({
|
|
2062
|
+
type: z7.literal("content_block_stop"),
|
|
2063
|
+
index: z7.number()
|
|
1820
2064
|
}),
|
|
1821
|
-
|
|
1822
|
-
type:
|
|
1823
|
-
error:
|
|
1824
|
-
type:
|
|
1825
|
-
message:
|
|
2065
|
+
z7.object({
|
|
2066
|
+
type: z7.literal("error"),
|
|
2067
|
+
error: z7.object({
|
|
2068
|
+
type: z7.string(),
|
|
2069
|
+
message: z7.string()
|
|
1826
2070
|
})
|
|
1827
2071
|
}),
|
|
1828
|
-
|
|
1829
|
-
type:
|
|
1830
|
-
delta:
|
|
1831
|
-
|
|
2072
|
+
z7.object({
|
|
2073
|
+
type: z7.literal("message_delta"),
|
|
2074
|
+
delta: z7.object({
|
|
2075
|
+
stop_reason: z7.string().nullish(),
|
|
2076
|
+
stop_sequence: z7.string().nullish()
|
|
2077
|
+
}),
|
|
2078
|
+
usage: z7.looseObject({
|
|
2079
|
+
output_tokens: z7.number(),
|
|
2080
|
+
cache_creation_input_tokens: z7.number().nullish()
|
|
2081
|
+
})
|
|
1832
2082
|
}),
|
|
1833
|
-
|
|
1834
|
-
type:
|
|
2083
|
+
z7.object({
|
|
2084
|
+
type: z7.literal("message_stop")
|
|
1835
2085
|
}),
|
|
1836
|
-
|
|
1837
|
-
type:
|
|
2086
|
+
z7.object({
|
|
2087
|
+
type: z7.literal("ping")
|
|
1838
2088
|
})
|
|
1839
2089
|
]);
|
|
1840
|
-
var anthropicReasoningMetadataSchema =
|
|
1841
|
-
signature:
|
|
1842
|
-
redactedData:
|
|
2090
|
+
var anthropicReasoningMetadataSchema = z7.object({
|
|
2091
|
+
signature: z7.string().optional(),
|
|
2092
|
+
redactedData: z7.string().optional()
|
|
1843
2093
|
});
|
|
1844
2094
|
|
|
1845
2095
|
// src/tool/bash_20241022.ts
|
|
1846
|
-
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
1847
|
-
import
|
|
1848
|
-
var bash_20241022 =
|
|
2096
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
2097
|
+
import z8 from "zod/v4";
|
|
2098
|
+
var bash_20241022 = createProviderDefinedToolFactory2({
|
|
1849
2099
|
id: "anthropic.bash_20241022",
|
|
1850
2100
|
name: "bash",
|
|
1851
|
-
inputSchema:
|
|
1852
|
-
command:
|
|
1853
|
-
restart:
|
|
2101
|
+
inputSchema: z8.object({
|
|
2102
|
+
command: z8.string(),
|
|
2103
|
+
restart: z8.boolean().optional()
|
|
1854
2104
|
})
|
|
1855
2105
|
});
|
|
1856
2106
|
|
|
1857
2107
|
// src/tool/bash_20250124.ts
|
|
1858
|
-
import { createProviderDefinedToolFactory as
|
|
1859
|
-
import
|
|
1860
|
-
var bash_20250124 =
|
|
2108
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
|
|
2109
|
+
import z9 from "zod/v4";
|
|
2110
|
+
var bash_20250124 = createProviderDefinedToolFactory3({
|
|
1861
2111
|
id: "anthropic.bash_20250124",
|
|
1862
2112
|
name: "bash",
|
|
1863
|
-
inputSchema:
|
|
1864
|
-
command:
|
|
1865
|
-
restart:
|
|
2113
|
+
inputSchema: z9.object({
|
|
2114
|
+
command: z9.string(),
|
|
2115
|
+
restart: z9.boolean().optional()
|
|
1866
2116
|
})
|
|
1867
2117
|
});
|
|
1868
2118
|
|
|
1869
2119
|
// src/tool/computer_20241022.ts
|
|
1870
|
-
import { createProviderDefinedToolFactory as
|
|
1871
|
-
import { z as
|
|
1872
|
-
var computer_20241022 =
|
|
2120
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
|
|
2121
|
+
import { z as z10 } from "zod/v4";
|
|
2122
|
+
var computer_20241022 = createProviderDefinedToolFactory4({
|
|
1873
2123
|
id: "anthropic.computer_20241022",
|
|
1874
2124
|
name: "computer",
|
|
1875
|
-
inputSchema:
|
|
1876
|
-
action:
|
|
2125
|
+
inputSchema: z10.object({
|
|
2126
|
+
action: z10.enum([
|
|
1877
2127
|
"key",
|
|
1878
2128
|
"type",
|
|
1879
2129
|
"mouse_move",
|
|
@@ -1885,19 +2135,19 @@ var computer_20241022 = createProviderDefinedToolFactory3({
|
|
|
1885
2135
|
"screenshot",
|
|
1886
2136
|
"cursor_position"
|
|
1887
2137
|
]),
|
|
1888
|
-
coordinate:
|
|
1889
|
-
text:
|
|
2138
|
+
coordinate: z10.array(z10.number().int()).optional(),
|
|
2139
|
+
text: z10.string().optional()
|
|
1890
2140
|
})
|
|
1891
2141
|
});
|
|
1892
2142
|
|
|
1893
2143
|
// src/tool/computer_20250124.ts
|
|
1894
|
-
import { createProviderDefinedToolFactory as
|
|
1895
|
-
import { z as
|
|
1896
|
-
var computer_20250124 =
|
|
2144
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
2145
|
+
import { z as z11 } from "zod/v4";
|
|
2146
|
+
var computer_20250124 = createProviderDefinedToolFactory5({
|
|
1897
2147
|
id: "anthropic.computer_20250124",
|
|
1898
2148
|
name: "computer",
|
|
1899
|
-
inputSchema:
|
|
1900
|
-
action:
|
|
2149
|
+
inputSchema: z11.object({
|
|
2150
|
+
action: z11.enum([
|
|
1901
2151
|
"key",
|
|
1902
2152
|
"hold_key",
|
|
1903
2153
|
"type",
|
|
@@ -1915,63 +2165,63 @@ var computer_20250124 = createProviderDefinedToolFactory4({
|
|
|
1915
2165
|
"wait",
|
|
1916
2166
|
"screenshot"
|
|
1917
2167
|
]),
|
|
1918
|
-
coordinate:
|
|
1919
|
-
duration:
|
|
1920
|
-
scroll_amount:
|
|
1921
|
-
scroll_direction:
|
|
1922
|
-
start_coordinate:
|
|
1923
|
-
text:
|
|
2168
|
+
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2169
|
+
duration: z11.number().optional(),
|
|
2170
|
+
scroll_amount: z11.number().optional(),
|
|
2171
|
+
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2172
|
+
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2173
|
+
text: z11.string().optional()
|
|
1924
2174
|
})
|
|
1925
2175
|
});
|
|
1926
2176
|
|
|
1927
2177
|
// src/tool/text-editor_20241022.ts
|
|
1928
|
-
import { createProviderDefinedToolFactory as
|
|
1929
|
-
import { z as
|
|
1930
|
-
var textEditor_20241022 =
|
|
2178
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
2179
|
+
import { z as z12 } from "zod/v4";
|
|
2180
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
1931
2181
|
id: "anthropic.text_editor_20241022",
|
|
1932
2182
|
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:
|
|
2183
|
+
inputSchema: z12.object({
|
|
2184
|
+
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2185
|
+
path: z12.string(),
|
|
2186
|
+
file_text: z12.string().optional(),
|
|
2187
|
+
insert_line: z12.number().int().optional(),
|
|
2188
|
+
new_str: z12.string().optional(),
|
|
2189
|
+
old_str: z12.string().optional(),
|
|
2190
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
1941
2191
|
})
|
|
1942
2192
|
});
|
|
1943
2193
|
|
|
1944
2194
|
// src/tool/text-editor_20250124.ts
|
|
1945
|
-
import { createProviderDefinedToolFactory as
|
|
1946
|
-
import { z as
|
|
1947
|
-
var textEditor_20250124 =
|
|
2195
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
|
|
2196
|
+
import { z as z13 } from "zod/v4";
|
|
2197
|
+
var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
1948
2198
|
id: "anthropic.text_editor_20250124",
|
|
1949
2199
|
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:
|
|
2200
|
+
inputSchema: z13.object({
|
|
2201
|
+
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2202
|
+
path: z13.string(),
|
|
2203
|
+
file_text: z13.string().optional(),
|
|
2204
|
+
insert_line: z13.number().int().optional(),
|
|
2205
|
+
new_str: z13.string().optional(),
|
|
2206
|
+
old_str: z13.string().optional(),
|
|
2207
|
+
view_range: z13.array(z13.number().int()).optional()
|
|
1958
2208
|
})
|
|
1959
2209
|
});
|
|
1960
2210
|
|
|
1961
2211
|
// src/tool/text-editor_20250429.ts
|
|
1962
|
-
import { createProviderDefinedToolFactory as
|
|
1963
|
-
import { z as
|
|
1964
|
-
var textEditor_20250429 =
|
|
2212
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory8 } from "@ai-sdk/provider-utils";
|
|
2213
|
+
import { z as z14 } from "zod/v4";
|
|
2214
|
+
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
1965
2215
|
id: "anthropic.text_editor_20250429",
|
|
1966
2216
|
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:
|
|
2217
|
+
inputSchema: z14.object({
|
|
2218
|
+
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2219
|
+
path: z14.string(),
|
|
2220
|
+
file_text: z14.string().optional(),
|
|
2221
|
+
insert_line: z14.number().int().optional(),
|
|
2222
|
+
new_str: z14.string().optional(),
|
|
2223
|
+
old_str: z14.string().optional(),
|
|
2224
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
1975
2225
|
})
|
|
1976
2226
|
});
|
|
1977
2227
|
|
|
@@ -2037,6 +2287,8 @@ var anthropicTools = {
|
|
|
2037
2287
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2038
2288
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2039
2289
|
*
|
|
2290
|
+
* Supported models: Claude Sonnet 3.5
|
|
2291
|
+
*
|
|
2040
2292
|
* Tool name must be `str_replace_editor`.
|
|
2041
2293
|
*/
|
|
2042
2294
|
textEditor_20241022,
|
|
@@ -2045,6 +2297,8 @@ var anthropicTools = {
|
|
|
2045
2297
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2046
2298
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2047
2299
|
*
|
|
2300
|
+
* Supported models: Claude Sonnet 3.7
|
|
2301
|
+
*
|
|
2048
2302
|
* Tool name must be `str_replace_editor`.
|
|
2049
2303
|
*/
|
|
2050
2304
|
textEditor_20250124,
|
|
@@ -2056,8 +2310,36 @@ var anthropicTools = {
|
|
|
2056
2310
|
* Note: This version does not support the "undo_edit" command.
|
|
2057
2311
|
*
|
|
2058
2312
|
* Tool name must be `str_replace_based_edit_tool`.
|
|
2313
|
+
*
|
|
2314
|
+
* @deprecated Use textEditor_20250728 instead
|
|
2059
2315
|
*/
|
|
2060
2316
|
textEditor_20250429,
|
|
2317
|
+
/**
|
|
2318
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2319
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2320
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2321
|
+
*
|
|
2322
|
+
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
2323
|
+
*
|
|
2324
|
+
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
2325
|
+
*
|
|
2326
|
+
* Tool name must be `str_replace_based_edit_tool`.
|
|
2327
|
+
*
|
|
2328
|
+
* @param maxCharacters - Optional maximum number of characters to view in the file
|
|
2329
|
+
*/
|
|
2330
|
+
textEditor_20250728,
|
|
2331
|
+
/**
|
|
2332
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
2333
|
+
*
|
|
2334
|
+
* Tool name must be `web_fetch`.
|
|
2335
|
+
*
|
|
2336
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
2337
|
+
* @param allowedDomains - Only fetch from these domains
|
|
2338
|
+
* @param blockedDomains - Never fetch from these domains
|
|
2339
|
+
* @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.
|
|
2340
|
+
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
2341
|
+
*/
|
|
2342
|
+
webFetch_20250910,
|
|
2061
2343
|
/**
|
|
2062
2344
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
2063
2345
|
*
|