@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/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@ai-sdk/provider-utils";
|
|
11
11
|
|
|
12
12
|
// src/version.ts
|
|
13
|
-
var VERSION = true ? "2.1.0-beta.
|
|
13
|
+
var VERSION = true ? "2.1.0-beta.5" : "0.0.0-test";
|
|
14
14
|
|
|
15
15
|
// src/anthropic-messages-language-model.ts
|
|
16
16
|
import {
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
postJsonToApi,
|
|
26
26
|
resolve
|
|
27
27
|
} from "@ai-sdk/provider-utils";
|
|
28
|
-
import { z as
|
|
28
|
+
import { z as z7 } from "zod/v4";
|
|
29
29
|
|
|
30
30
|
// src/anthropic-error.ts
|
|
31
31
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
@@ -101,58 +101,110 @@ function getCacheControl(providerMetadata) {
|
|
|
101
101
|
return cacheControlValue;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
// src/tool/text-editor_20250728.ts
|
|
105
|
+
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
106
|
+
import { z as z3 } from "zod/v4";
|
|
107
|
+
var textEditor_20250728ArgsSchema = z3.object({
|
|
108
|
+
maxCharacters: z3.number().optional()
|
|
109
|
+
});
|
|
110
|
+
var factory = createProviderDefinedToolFactory({
|
|
111
|
+
id: "anthropic.text_editor_20250728",
|
|
112
|
+
name: "str_replace_based_edit_tool",
|
|
113
|
+
inputSchema: z3.object({
|
|
114
|
+
command: z3.enum(["view", "create", "str_replace", "insert"]),
|
|
115
|
+
path: z3.string(),
|
|
116
|
+
file_text: z3.string().optional(),
|
|
117
|
+
insert_line: z3.number().int().optional(),
|
|
118
|
+
new_str: z3.string().optional(),
|
|
119
|
+
old_str: z3.string().optional(),
|
|
120
|
+
view_range: z3.array(z3.number().int()).optional()
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
var textEditor_20250728 = (args = {}) => {
|
|
124
|
+
return factory(args);
|
|
125
|
+
};
|
|
126
|
+
|
|
104
127
|
// src/tool/web-search_20250305.ts
|
|
105
128
|
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
106
|
-
import { z as
|
|
107
|
-
var webSearch_20250305ArgsSchema =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
* Optional list of domains that Claude should avoid when searching.
|
|
118
|
-
*/
|
|
119
|
-
blockedDomains: z3.array(z3.string()).optional(),
|
|
120
|
-
/**
|
|
121
|
-
* Optional user location information to provide geographically relevant search results.
|
|
122
|
-
*/
|
|
123
|
-
userLocation: z3.object({
|
|
124
|
-
type: z3.literal("approximate"),
|
|
125
|
-
city: z3.string().optional(),
|
|
126
|
-
region: z3.string().optional(),
|
|
127
|
-
country: z3.string().optional(),
|
|
128
|
-
timezone: z3.string().optional()
|
|
129
|
+
import { z as z4 } from "zod/v4";
|
|
130
|
+
var webSearch_20250305ArgsSchema = z4.object({
|
|
131
|
+
maxUses: z4.number().optional(),
|
|
132
|
+
allowedDomains: z4.array(z4.string()).optional(),
|
|
133
|
+
blockedDomains: z4.array(z4.string()).optional(),
|
|
134
|
+
userLocation: z4.object({
|
|
135
|
+
type: z4.literal("approximate"),
|
|
136
|
+
city: z4.string().optional(),
|
|
137
|
+
region: z4.string().optional(),
|
|
138
|
+
country: z4.string().optional(),
|
|
139
|
+
timezone: z4.string().optional()
|
|
129
140
|
}).optional()
|
|
130
141
|
});
|
|
131
|
-
var webSearch_20250305OutputSchema =
|
|
132
|
-
|
|
133
|
-
url:
|
|
134
|
-
title:
|
|
135
|
-
pageAge:
|
|
136
|
-
encryptedContent:
|
|
137
|
-
type:
|
|
142
|
+
var webSearch_20250305OutputSchema = z4.array(
|
|
143
|
+
z4.object({
|
|
144
|
+
url: z4.string(),
|
|
145
|
+
title: z4.string(),
|
|
146
|
+
pageAge: z4.string().nullable(),
|
|
147
|
+
encryptedContent: z4.string(),
|
|
148
|
+
type: z4.literal("web_search_result")
|
|
138
149
|
})
|
|
139
150
|
);
|
|
140
|
-
var
|
|
151
|
+
var factory2 = createProviderDefinedToolFactoryWithOutputSchema({
|
|
141
152
|
id: "anthropic.web_search_20250305",
|
|
142
153
|
name: "web_search",
|
|
143
|
-
inputSchema:
|
|
144
|
-
query:
|
|
154
|
+
inputSchema: z4.object({
|
|
155
|
+
query: z4.string()
|
|
145
156
|
}),
|
|
146
157
|
outputSchema: webSearch_20250305OutputSchema
|
|
147
158
|
});
|
|
148
159
|
var webSearch_20250305 = (args = {}) => {
|
|
149
|
-
return
|
|
160
|
+
return factory2(args);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// src/tool/web-fetch-20250910.ts
|
|
164
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
|
|
165
|
+
import { z as z5 } from "zod/v4";
|
|
166
|
+
var webFetch_20250910ArgsSchema = z5.object({
|
|
167
|
+
maxUses: z5.number().optional(),
|
|
168
|
+
allowedDomains: z5.array(z5.string()).optional(),
|
|
169
|
+
blockedDomains: z5.array(z5.string()).optional(),
|
|
170
|
+
citations: z5.object({ enabled: z5.boolean() }).optional(),
|
|
171
|
+
maxContentTokens: z5.number().optional()
|
|
172
|
+
});
|
|
173
|
+
var webFetch_20250910OutputSchema = z5.object({
|
|
174
|
+
type: z5.literal("web_fetch_result"),
|
|
175
|
+
url: z5.string(),
|
|
176
|
+
content: z5.object({
|
|
177
|
+
type: z5.literal("document"),
|
|
178
|
+
title: z5.string(),
|
|
179
|
+
citations: z5.object({ enabled: z5.boolean() }).optional(),
|
|
180
|
+
source: z5.union([
|
|
181
|
+
z5.object({
|
|
182
|
+
type: z5.literal("base64"),
|
|
183
|
+
mediaType: z5.literal("application/pdf"),
|
|
184
|
+
data: z5.string()
|
|
185
|
+
}),
|
|
186
|
+
z5.object({
|
|
187
|
+
type: z5.literal("text"),
|
|
188
|
+
mediaType: z5.literal("text/plain"),
|
|
189
|
+
data: z5.string()
|
|
190
|
+
})
|
|
191
|
+
])
|
|
192
|
+
}),
|
|
193
|
+
retrievedAt: z5.string().nullable()
|
|
194
|
+
});
|
|
195
|
+
var factory3 = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
196
|
+
id: "anthropic.web_fetch_20250910",
|
|
197
|
+
name: "web_fetch",
|
|
198
|
+
inputSchema: z5.object({
|
|
199
|
+
url: z5.string()
|
|
200
|
+
}),
|
|
201
|
+
outputSchema: webFetch_20250910OutputSchema
|
|
202
|
+
});
|
|
203
|
+
var webFetch_20250910 = (args = {}) => {
|
|
204
|
+
return factory3(args);
|
|
150
205
|
};
|
|
151
206
|
|
|
152
207
|
// src/anthropic-prepare-tools.ts
|
|
153
|
-
function isWebSearchTool(tool) {
|
|
154
|
-
return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
|
|
155
|
-
}
|
|
156
208
|
function prepareTools({
|
|
157
209
|
tools,
|
|
158
210
|
toolChoice,
|
|
@@ -166,12 +218,8 @@ function prepareTools({
|
|
|
166
218
|
}
|
|
167
219
|
const anthropicTools2 = [];
|
|
168
220
|
for (const tool of tools) {
|
|
169
|
-
if (isWebSearchTool(tool)) {
|
|
170
|
-
anthropicTools2.push(tool);
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
221
|
switch (tool.type) {
|
|
174
|
-
case "function":
|
|
222
|
+
case "function": {
|
|
175
223
|
const cacheControl = getCacheControl(tool.providerOptions);
|
|
176
224
|
anthropicTools2.push({
|
|
177
225
|
name: tool.name,
|
|
@@ -180,9 +228,18 @@ function prepareTools({
|
|
|
180
228
|
cache_control: cacheControl
|
|
181
229
|
});
|
|
182
230
|
break;
|
|
183
|
-
|
|
231
|
+
}
|
|
232
|
+
case "provider-defined": {
|
|
184
233
|
switch (tool.id) {
|
|
185
|
-
case "anthropic.
|
|
234
|
+
case "anthropic.code_execution_20250522": {
|
|
235
|
+
betas.add("code-execution-2025-05-22");
|
|
236
|
+
anthropicTools2.push({
|
|
237
|
+
type: "code_execution_20250522",
|
|
238
|
+
name: "code_execution"
|
|
239
|
+
});
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
case "anthropic.computer_20250124": {
|
|
186
243
|
betas.add("computer-use-2025-01-24");
|
|
187
244
|
anthropicTools2.push({
|
|
188
245
|
name: "computer",
|
|
@@ -192,7 +249,8 @@ function prepareTools({
|
|
|
192
249
|
display_number: tool.args.displayNumber
|
|
193
250
|
});
|
|
194
251
|
break;
|
|
195
|
-
|
|
252
|
+
}
|
|
253
|
+
case "anthropic.computer_20241022": {
|
|
196
254
|
betas.add("computer-use-2024-10-22");
|
|
197
255
|
anthropicTools2.push({
|
|
198
256
|
name: "computer",
|
|
@@ -202,41 +260,70 @@ function prepareTools({
|
|
|
202
260
|
display_number: tool.args.displayNumber
|
|
203
261
|
});
|
|
204
262
|
break;
|
|
205
|
-
|
|
263
|
+
}
|
|
264
|
+
case "anthropic.text_editor_20250124": {
|
|
206
265
|
betas.add("computer-use-2025-01-24");
|
|
207
266
|
anthropicTools2.push({
|
|
208
267
|
name: "str_replace_editor",
|
|
209
268
|
type: "text_editor_20250124"
|
|
210
269
|
});
|
|
211
270
|
break;
|
|
212
|
-
|
|
271
|
+
}
|
|
272
|
+
case "anthropic.text_editor_20241022": {
|
|
213
273
|
betas.add("computer-use-2024-10-22");
|
|
214
274
|
anthropicTools2.push({
|
|
215
275
|
name: "str_replace_editor",
|
|
216
276
|
type: "text_editor_20241022"
|
|
217
277
|
});
|
|
218
278
|
break;
|
|
219
|
-
|
|
279
|
+
}
|
|
280
|
+
case "anthropic.text_editor_20250429": {
|
|
220
281
|
betas.add("computer-use-2025-01-24");
|
|
221
282
|
anthropicTools2.push({
|
|
222
283
|
name: "str_replace_based_edit_tool",
|
|
223
284
|
type: "text_editor_20250429"
|
|
224
285
|
});
|
|
225
286
|
break;
|
|
226
|
-
|
|
287
|
+
}
|
|
288
|
+
case "anthropic.text_editor_20250728": {
|
|
289
|
+
const args = textEditor_20250728ArgsSchema.parse(tool.args);
|
|
290
|
+
anthropicTools2.push({
|
|
291
|
+
name: "str_replace_based_edit_tool",
|
|
292
|
+
type: "text_editor_20250728",
|
|
293
|
+
max_characters: args.maxCharacters
|
|
294
|
+
});
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
case "anthropic.bash_20250124": {
|
|
227
298
|
betas.add("computer-use-2025-01-24");
|
|
228
299
|
anthropicTools2.push({
|
|
229
300
|
name: "bash",
|
|
230
301
|
type: "bash_20250124"
|
|
231
302
|
});
|
|
232
303
|
break;
|
|
233
|
-
|
|
304
|
+
}
|
|
305
|
+
case "anthropic.bash_20241022": {
|
|
234
306
|
betas.add("computer-use-2024-10-22");
|
|
235
307
|
anthropicTools2.push({
|
|
236
308
|
name: "bash",
|
|
237
309
|
type: "bash_20241022"
|
|
238
310
|
});
|
|
239
311
|
break;
|
|
312
|
+
}
|
|
313
|
+
case "anthropic.web_fetch_20250910": {
|
|
314
|
+
betas.add("web-fetch-2025-09-10");
|
|
315
|
+
const args = webFetch_20250910ArgsSchema.parse(tool.args);
|
|
316
|
+
anthropicTools2.push({
|
|
317
|
+
type: "web_fetch_20250910",
|
|
318
|
+
name: "web_fetch",
|
|
319
|
+
max_uses: args.maxUses,
|
|
320
|
+
allowed_domains: args.allowedDomains,
|
|
321
|
+
blocked_domains: args.blockedDomains,
|
|
322
|
+
citations: args.citations,
|
|
323
|
+
max_content_tokens: args.maxContentTokens
|
|
324
|
+
});
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
240
327
|
case "anthropic.web_search_20250305": {
|
|
241
328
|
const args = webSearch_20250305ArgsSchema.parse(tool.args);
|
|
242
329
|
anthropicTools2.push({
|
|
@@ -249,22 +336,17 @@ function prepareTools({
|
|
|
249
336
|
});
|
|
250
337
|
break;
|
|
251
338
|
}
|
|
252
|
-
|
|
253
|
-
betas.add("code-execution-2025-05-22");
|
|
254
|
-
anthropicTools2.push({
|
|
255
|
-
type: "code_execution_20250522",
|
|
256
|
-
name: "code_execution"
|
|
257
|
-
});
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
default:
|
|
339
|
+
default: {
|
|
261
340
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
262
341
|
break;
|
|
342
|
+
}
|
|
263
343
|
}
|
|
264
344
|
break;
|
|
265
|
-
|
|
345
|
+
}
|
|
346
|
+
default: {
|
|
266
347
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
267
348
|
break;
|
|
349
|
+
}
|
|
268
350
|
}
|
|
269
351
|
}
|
|
270
352
|
if (toolChoice == null) {
|
|
@@ -326,24 +408,24 @@ import {
|
|
|
326
408
|
import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
327
409
|
|
|
328
410
|
// src/tool/code-execution_20250522.ts
|
|
329
|
-
import { createProviderDefinedToolFactoryWithOutputSchema as
|
|
330
|
-
import { z as
|
|
331
|
-
var codeExecution_20250522OutputSchema =
|
|
332
|
-
type:
|
|
333
|
-
stdout:
|
|
334
|
-
stderr:
|
|
335
|
-
return_code:
|
|
411
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@ai-sdk/provider-utils";
|
|
412
|
+
import { z as z6 } from "zod/v4";
|
|
413
|
+
var codeExecution_20250522OutputSchema = z6.object({
|
|
414
|
+
type: z6.literal("code_execution_result"),
|
|
415
|
+
stdout: z6.string(),
|
|
416
|
+
stderr: z6.string(),
|
|
417
|
+
return_code: z6.number()
|
|
336
418
|
});
|
|
337
|
-
var
|
|
419
|
+
var factory4 = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
338
420
|
id: "anthropic.code_execution_20250522",
|
|
339
421
|
name: "code_execution",
|
|
340
|
-
inputSchema:
|
|
341
|
-
code:
|
|
422
|
+
inputSchema: z6.object({
|
|
423
|
+
code: z6.string()
|
|
342
424
|
}),
|
|
343
425
|
outputSchema: codeExecution_20250522OutputSchema
|
|
344
426
|
});
|
|
345
427
|
var codeExecution_20250522 = (args = {}) => {
|
|
346
|
-
return
|
|
428
|
+
return factory4(args);
|
|
347
429
|
};
|
|
348
430
|
|
|
349
431
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
@@ -636,30 +718,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
636
718
|
}
|
|
637
719
|
case "tool-call": {
|
|
638
720
|
if (part.providerExecuted) {
|
|
639
|
-
if (part.toolName === "web_search") {
|
|
721
|
+
if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
640
722
|
anthropicContent.push({
|
|
641
723
|
type: "server_tool_use",
|
|
642
724
|
id: part.toolCallId,
|
|
643
|
-
name:
|
|
725
|
+
name: part.toolName,
|
|
644
726
|
input: part.input,
|
|
645
727
|
cache_control: cacheControl
|
|
646
728
|
});
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
type: "server_tool_use",
|
|
652
|
-
id: part.toolCallId,
|
|
653
|
-
name: "code_execution",
|
|
654
|
-
input: part.input,
|
|
655
|
-
cache_control: cacheControl
|
|
729
|
+
} else {
|
|
730
|
+
warnings.push({
|
|
731
|
+
type: "other",
|
|
732
|
+
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
656
733
|
});
|
|
657
|
-
break;
|
|
658
734
|
}
|
|
659
|
-
warnings.push({
|
|
660
|
-
type: "other",
|
|
661
|
-
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
662
|
-
});
|
|
663
735
|
break;
|
|
664
736
|
}
|
|
665
737
|
anthropicContent.push({
|
|
@@ -672,7 +744,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
672
744
|
break;
|
|
673
745
|
}
|
|
674
746
|
case "tool-result": {
|
|
675
|
-
if (part.toolName === "
|
|
747
|
+
if (part.toolName === "code_execution") {
|
|
676
748
|
const output = part.output;
|
|
677
749
|
if (output.type !== "json") {
|
|
678
750
|
warnings.push({
|
|
@@ -681,24 +753,21 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
681
753
|
});
|
|
682
754
|
break;
|
|
683
755
|
}
|
|
684
|
-
const
|
|
685
|
-
output.value
|
|
686
|
-
);
|
|
756
|
+
const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
|
|
687
757
|
anthropicContent.push({
|
|
688
|
-
type: "
|
|
758
|
+
type: "code_execution_tool_result",
|
|
689
759
|
tool_use_id: part.toolCallId,
|
|
690
|
-
content:
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
})),
|
|
760
|
+
content: {
|
|
761
|
+
type: codeExecutionOutput.type,
|
|
762
|
+
stdout: codeExecutionOutput.stdout,
|
|
763
|
+
stderr: codeExecutionOutput.stderr,
|
|
764
|
+
return_code: codeExecutionOutput.return_code
|
|
765
|
+
},
|
|
697
766
|
cache_control: cacheControl
|
|
698
767
|
});
|
|
699
768
|
break;
|
|
700
769
|
}
|
|
701
|
-
if (part.toolName === "
|
|
770
|
+
if (part.toolName === "web_fetch") {
|
|
702
771
|
const output = part.output;
|
|
703
772
|
if (output.type !== "json") {
|
|
704
773
|
warnings.push({
|
|
@@ -707,20 +776,57 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
707
776
|
});
|
|
708
777
|
break;
|
|
709
778
|
}
|
|
710
|
-
const
|
|
779
|
+
const webFetchOutput = webFetch_20250910OutputSchema.parse(
|
|
780
|
+
output.value
|
|
781
|
+
);
|
|
711
782
|
anthropicContent.push({
|
|
712
|
-
type: "
|
|
783
|
+
type: "web_fetch_tool_result",
|
|
713
784
|
tool_use_id: part.toolCallId,
|
|
714
785
|
content: {
|
|
715
|
-
type:
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
786
|
+
type: "web_fetch_result",
|
|
787
|
+
url: webFetchOutput.url,
|
|
788
|
+
retrieved_at: webFetchOutput.retrievedAt,
|
|
789
|
+
content: {
|
|
790
|
+
type: "document",
|
|
791
|
+
title: webFetchOutput.content.title,
|
|
792
|
+
citations: webFetchOutput.content.citations,
|
|
793
|
+
source: {
|
|
794
|
+
type: webFetchOutput.content.source.type,
|
|
795
|
+
media_type: webFetchOutput.content.source.mediaType,
|
|
796
|
+
data: webFetchOutput.content.source.data
|
|
797
|
+
}
|
|
798
|
+
}
|
|
719
799
|
},
|
|
720
800
|
cache_control: cacheControl
|
|
721
801
|
});
|
|
722
802
|
break;
|
|
723
803
|
}
|
|
804
|
+
if (part.toolName === "web_search") {
|
|
805
|
+
const output = part.output;
|
|
806
|
+
if (output.type !== "json") {
|
|
807
|
+
warnings.push({
|
|
808
|
+
type: "other",
|
|
809
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
810
|
+
});
|
|
811
|
+
break;
|
|
812
|
+
}
|
|
813
|
+
const webSearchOutput = webSearch_20250305OutputSchema.parse(
|
|
814
|
+
output.value
|
|
815
|
+
);
|
|
816
|
+
anthropicContent.push({
|
|
817
|
+
type: "web_search_tool_result",
|
|
818
|
+
tool_use_id: part.toolCallId,
|
|
819
|
+
content: webSearchOutput.map((result) => ({
|
|
820
|
+
url: result.url,
|
|
821
|
+
title: result.title,
|
|
822
|
+
page_age: result.pageAge,
|
|
823
|
+
encrypted_content: result.encryptedContent,
|
|
824
|
+
type: result.type
|
|
825
|
+
})),
|
|
826
|
+
cache_control: cacheControl
|
|
827
|
+
});
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
724
830
|
warnings.push({
|
|
725
831
|
type: "other",
|
|
726
832
|
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
@@ -814,36 +920,36 @@ function mapAnthropicStopReason({
|
|
|
814
920
|
|
|
815
921
|
// src/anthropic-messages-language-model.ts
|
|
816
922
|
var citationSchemas = {
|
|
817
|
-
webSearchResult:
|
|
818
|
-
type:
|
|
819
|
-
cited_text:
|
|
820
|
-
url:
|
|
821
|
-
title:
|
|
822
|
-
encrypted_index:
|
|
923
|
+
webSearchResult: z7.object({
|
|
924
|
+
type: z7.literal("web_search_result_location"),
|
|
925
|
+
cited_text: z7.string(),
|
|
926
|
+
url: z7.string(),
|
|
927
|
+
title: z7.string(),
|
|
928
|
+
encrypted_index: z7.string()
|
|
823
929
|
}),
|
|
824
|
-
pageLocation:
|
|
825
|
-
type:
|
|
826
|
-
cited_text:
|
|
827
|
-
document_index:
|
|
828
|
-
document_title:
|
|
829
|
-
start_page_number:
|
|
830
|
-
end_page_number:
|
|
930
|
+
pageLocation: z7.object({
|
|
931
|
+
type: z7.literal("page_location"),
|
|
932
|
+
cited_text: z7.string(),
|
|
933
|
+
document_index: z7.number(),
|
|
934
|
+
document_title: z7.string().nullable(),
|
|
935
|
+
start_page_number: z7.number(),
|
|
936
|
+
end_page_number: z7.number()
|
|
831
937
|
}),
|
|
832
|
-
charLocation:
|
|
833
|
-
type:
|
|
834
|
-
cited_text:
|
|
835
|
-
document_index:
|
|
836
|
-
document_title:
|
|
837
|
-
start_char_index:
|
|
838
|
-
end_char_index:
|
|
938
|
+
charLocation: z7.object({
|
|
939
|
+
type: z7.literal("char_location"),
|
|
940
|
+
cited_text: z7.string(),
|
|
941
|
+
document_index: z7.number(),
|
|
942
|
+
document_title: z7.string().nullable(),
|
|
943
|
+
start_char_index: z7.number(),
|
|
944
|
+
end_char_index: z7.number()
|
|
839
945
|
})
|
|
840
946
|
};
|
|
841
|
-
var citationSchema =
|
|
947
|
+
var citationSchema = z7.discriminatedUnion("type", [
|
|
842
948
|
citationSchemas.webSearchResult,
|
|
843
949
|
citationSchemas.pageLocation,
|
|
844
950
|
citationSchemas.charLocation
|
|
845
951
|
]);
|
|
846
|
-
var documentCitationSchema =
|
|
952
|
+
var documentCitationSchema = z7.discriminatedUnion("type", [
|
|
847
953
|
citationSchemas.pageLocation,
|
|
848
954
|
citationSchemas.charLocation
|
|
849
955
|
]);
|
|
@@ -1168,7 +1274,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1168
1274
|
break;
|
|
1169
1275
|
}
|
|
1170
1276
|
case "server_tool_use": {
|
|
1171
|
-
if (part.name === "web_search" || part.name === "code_execution") {
|
|
1277
|
+
if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1172
1278
|
content.push({
|
|
1173
1279
|
type: "tool-call",
|
|
1174
1280
|
toolCallId: part.id,
|
|
@@ -1179,6 +1285,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1179
1285
|
}
|
|
1180
1286
|
break;
|
|
1181
1287
|
}
|
|
1288
|
+
case "web_fetch_tool_result": {
|
|
1289
|
+
if (part.content.type === "web_fetch_result") {
|
|
1290
|
+
content.push({
|
|
1291
|
+
type: "tool-result",
|
|
1292
|
+
toolCallId: part.tool_use_id,
|
|
1293
|
+
toolName: "web_fetch",
|
|
1294
|
+
result: {
|
|
1295
|
+
type: "web_fetch_result",
|
|
1296
|
+
url: part.content.url,
|
|
1297
|
+
retrievedAt: part.content.retrieved_at,
|
|
1298
|
+
content: {
|
|
1299
|
+
type: part.content.content.type,
|
|
1300
|
+
title: part.content.content.title,
|
|
1301
|
+
citations: part.content.content.citations,
|
|
1302
|
+
source: {
|
|
1303
|
+
type: part.content.content.source.type,
|
|
1304
|
+
mediaType: part.content.content.source.media_type,
|
|
1305
|
+
data: part.content.content.source.data
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
providerExecuted: true
|
|
1310
|
+
});
|
|
1311
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1312
|
+
content.push({
|
|
1313
|
+
type: "tool-result",
|
|
1314
|
+
toolCallId: part.tool_use_id,
|
|
1315
|
+
toolName: "web_fetch",
|
|
1316
|
+
isError: true,
|
|
1317
|
+
result: {
|
|
1318
|
+
type: "web_fetch_tool_result_error",
|
|
1319
|
+
errorCode: part.content.error_code
|
|
1320
|
+
},
|
|
1321
|
+
providerExecuted: true
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
break;
|
|
1325
|
+
}
|
|
1182
1326
|
case "web_search_tool_result": {
|
|
1183
1327
|
if (Array.isArray(part.content)) {
|
|
1184
1328
|
content.push({
|
|
@@ -1307,7 +1451,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1307
1451
|
totalTokens: void 0
|
|
1308
1452
|
};
|
|
1309
1453
|
const contentBlocks = {};
|
|
1310
|
-
let
|
|
1454
|
+
let rawUsage = void 0;
|
|
1455
|
+
let cacheCreationInputTokens = null;
|
|
1311
1456
|
let blockType = void 0;
|
|
1312
1457
|
const generateId3 = this.generateId;
|
|
1313
1458
|
return {
|
|
@@ -1380,7 +1525,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1380
1525
|
return;
|
|
1381
1526
|
}
|
|
1382
1527
|
case "server_tool_use": {
|
|
1383
|
-
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1528
|
+
if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1384
1529
|
contentBlocks[value.index] = {
|
|
1385
1530
|
type: "tool-call",
|
|
1386
1531
|
toolCallId: value.content_block.id,
|
|
@@ -1397,6 +1542,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1397
1542
|
}
|
|
1398
1543
|
return;
|
|
1399
1544
|
}
|
|
1545
|
+
case "web_fetch_tool_result": {
|
|
1546
|
+
const part = value.content_block;
|
|
1547
|
+
if (part.content.type === "web_fetch_result") {
|
|
1548
|
+
controller.enqueue({
|
|
1549
|
+
type: "tool-result",
|
|
1550
|
+
toolCallId: part.tool_use_id,
|
|
1551
|
+
toolName: "web_fetch",
|
|
1552
|
+
result: {
|
|
1553
|
+
type: "web_fetch_result",
|
|
1554
|
+
url: part.content.url,
|
|
1555
|
+
retrievedAt: part.content.retrieved_at,
|
|
1556
|
+
content: {
|
|
1557
|
+
type: part.content.content.type,
|
|
1558
|
+
title: part.content.content.title,
|
|
1559
|
+
citations: part.content.content.citations,
|
|
1560
|
+
source: {
|
|
1561
|
+
type: part.content.content.source.type,
|
|
1562
|
+
mediaType: part.content.content.source.media_type,
|
|
1563
|
+
data: part.content.content.source.data
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1569
|
+
controller.enqueue({
|
|
1570
|
+
type: "tool-result",
|
|
1571
|
+
toolCallId: part.tool_use_id,
|
|
1572
|
+
toolName: "web_fetch",
|
|
1573
|
+
isError: true,
|
|
1574
|
+
result: {
|
|
1575
|
+
type: "web_fetch_tool_result_error",
|
|
1576
|
+
errorCode: part.content.error_code
|
|
1577
|
+
},
|
|
1578
|
+
providerExecuted: true
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1400
1583
|
case "web_search_tool_result": {
|
|
1401
1584
|
const part = value.content_block;
|
|
1402
1585
|
if (Array.isArray(part.content)) {
|
|
@@ -1599,12 +1782,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1599
1782
|
case "message_start": {
|
|
1600
1783
|
usage.inputTokens = value.message.usage.input_tokens;
|
|
1601
1784
|
usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
usage: value.message.usage,
|
|
1605
|
-
cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
|
|
1606
|
-
}
|
|
1785
|
+
rawUsage = {
|
|
1786
|
+
...value.message.usage
|
|
1607
1787
|
};
|
|
1788
|
+
cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
|
|
1608
1789
|
controller.enqueue({
|
|
1609
1790
|
type: "response-metadata",
|
|
1610
1791
|
id: (_d = value.message.id) != null ? _d : void 0,
|
|
@@ -1619,6 +1800,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1619
1800
|
finishReason: value.delta.stop_reason,
|
|
1620
1801
|
isJsonResponseFromTool: usesJsonResponseTool
|
|
1621
1802
|
});
|
|
1803
|
+
rawUsage = {
|
|
1804
|
+
...rawUsage,
|
|
1805
|
+
...value.usage
|
|
1806
|
+
};
|
|
1622
1807
|
return;
|
|
1623
1808
|
}
|
|
1624
1809
|
case "message_stop": {
|
|
@@ -1626,7 +1811,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1626
1811
|
type: "finish",
|
|
1627
1812
|
finishReason,
|
|
1628
1813
|
usage,
|
|
1629
|
-
providerMetadata
|
|
1814
|
+
providerMetadata: {
|
|
1815
|
+
anthropic: {
|
|
1816
|
+
usage: rawUsage != null ? rawUsage : null,
|
|
1817
|
+
cacheCreationInputTokens
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1630
1820
|
});
|
|
1631
1821
|
return;
|
|
1632
1822
|
}
|
|
@@ -1647,247 +1837,299 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1647
1837
|
};
|
|
1648
1838
|
}
|
|
1649
1839
|
};
|
|
1650
|
-
var anthropicMessagesResponseSchema =
|
|
1651
|
-
type:
|
|
1652
|
-
id:
|
|
1653
|
-
model:
|
|
1654
|
-
content:
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
type:
|
|
1658
|
-
text:
|
|
1659
|
-
citations:
|
|
1840
|
+
var anthropicMessagesResponseSchema = z7.object({
|
|
1841
|
+
type: z7.literal("message"),
|
|
1842
|
+
id: z7.string().nullish(),
|
|
1843
|
+
model: z7.string().nullish(),
|
|
1844
|
+
content: z7.array(
|
|
1845
|
+
z7.discriminatedUnion("type", [
|
|
1846
|
+
z7.object({
|
|
1847
|
+
type: z7.literal("text"),
|
|
1848
|
+
text: z7.string(),
|
|
1849
|
+
citations: z7.array(citationSchema).optional()
|
|
1660
1850
|
}),
|
|
1661
|
-
|
|
1662
|
-
type:
|
|
1663
|
-
thinking:
|
|
1664
|
-
signature:
|
|
1851
|
+
z7.object({
|
|
1852
|
+
type: z7.literal("thinking"),
|
|
1853
|
+
thinking: z7.string(),
|
|
1854
|
+
signature: z7.string()
|
|
1665
1855
|
}),
|
|
1666
|
-
|
|
1667
|
-
type:
|
|
1668
|
-
data:
|
|
1856
|
+
z7.object({
|
|
1857
|
+
type: z7.literal("redacted_thinking"),
|
|
1858
|
+
data: z7.string()
|
|
1669
1859
|
}),
|
|
1670
|
-
|
|
1671
|
-
type:
|
|
1672
|
-
id:
|
|
1673
|
-
name:
|
|
1674
|
-
input:
|
|
1860
|
+
z7.object({
|
|
1861
|
+
type: z7.literal("tool_use"),
|
|
1862
|
+
id: z7.string(),
|
|
1863
|
+
name: z7.string(),
|
|
1864
|
+
input: z7.unknown()
|
|
1675
1865
|
}),
|
|
1676
|
-
|
|
1677
|
-
type:
|
|
1678
|
-
id:
|
|
1679
|
-
name:
|
|
1680
|
-
input:
|
|
1866
|
+
z7.object({
|
|
1867
|
+
type: z7.literal("server_tool_use"),
|
|
1868
|
+
id: z7.string(),
|
|
1869
|
+
name: z7.string(),
|
|
1870
|
+
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1681
1871
|
}),
|
|
1682
|
-
|
|
1683
|
-
type:
|
|
1684
|
-
tool_use_id:
|
|
1685
|
-
content:
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1872
|
+
z7.object({
|
|
1873
|
+
type: z7.literal("web_fetch_tool_result"),
|
|
1874
|
+
tool_use_id: z7.string(),
|
|
1875
|
+
content: z7.union([
|
|
1876
|
+
z7.object({
|
|
1877
|
+
type: z7.literal("web_fetch_result"),
|
|
1878
|
+
url: z7.string(),
|
|
1879
|
+
retrieved_at: z7.string(),
|
|
1880
|
+
content: z7.object({
|
|
1881
|
+
type: z7.literal("document"),
|
|
1882
|
+
title: z7.string(),
|
|
1883
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1884
|
+
source: z7.object({
|
|
1885
|
+
type: z7.literal("text"),
|
|
1886
|
+
media_type: z7.string(),
|
|
1887
|
+
data: z7.string()
|
|
1888
|
+
})
|
|
1889
|
+
})
|
|
1890
|
+
}),
|
|
1891
|
+
z7.object({
|
|
1892
|
+
type: z7.literal("web_fetch_tool_result_error"),
|
|
1893
|
+
error_code: z7.string()
|
|
1894
|
+
})
|
|
1895
|
+
])
|
|
1896
|
+
}),
|
|
1897
|
+
z7.object({
|
|
1898
|
+
type: z7.literal("web_search_tool_result"),
|
|
1899
|
+
tool_use_id: z7.string(),
|
|
1900
|
+
content: z7.union([
|
|
1901
|
+
z7.array(
|
|
1902
|
+
z7.object({
|
|
1903
|
+
type: z7.literal("web_search_result"),
|
|
1904
|
+
url: z7.string(),
|
|
1905
|
+
title: z7.string(),
|
|
1906
|
+
encrypted_content: z7.string(),
|
|
1907
|
+
page_age: z7.string().nullish()
|
|
1693
1908
|
})
|
|
1694
1909
|
),
|
|
1695
|
-
|
|
1696
|
-
type:
|
|
1697
|
-
error_code:
|
|
1910
|
+
z7.object({
|
|
1911
|
+
type: z7.literal("web_search_tool_result_error"),
|
|
1912
|
+
error_code: z7.string()
|
|
1698
1913
|
})
|
|
1699
1914
|
])
|
|
1700
1915
|
}),
|
|
1701
|
-
|
|
1702
|
-
type:
|
|
1703
|
-
tool_use_id:
|
|
1704
|
-
content:
|
|
1705
|
-
|
|
1706
|
-
type:
|
|
1707
|
-
stdout:
|
|
1708
|
-
stderr:
|
|
1709
|
-
return_code:
|
|
1916
|
+
z7.object({
|
|
1917
|
+
type: z7.literal("code_execution_tool_result"),
|
|
1918
|
+
tool_use_id: z7.string(),
|
|
1919
|
+
content: z7.union([
|
|
1920
|
+
z7.object({
|
|
1921
|
+
type: z7.literal("code_execution_result"),
|
|
1922
|
+
stdout: z7.string(),
|
|
1923
|
+
stderr: z7.string(),
|
|
1924
|
+
return_code: z7.number()
|
|
1710
1925
|
}),
|
|
1711
|
-
|
|
1712
|
-
type:
|
|
1713
|
-
error_code:
|
|
1926
|
+
z7.object({
|
|
1927
|
+
type: z7.literal("code_execution_tool_result_error"),
|
|
1928
|
+
error_code: z7.string()
|
|
1714
1929
|
})
|
|
1715
1930
|
])
|
|
1716
1931
|
})
|
|
1717
1932
|
])
|
|
1718
1933
|
),
|
|
1719
|
-
stop_reason:
|
|
1720
|
-
usage:
|
|
1721
|
-
input_tokens:
|
|
1722
|
-
output_tokens:
|
|
1723
|
-
cache_creation_input_tokens:
|
|
1724
|
-
cache_read_input_tokens:
|
|
1934
|
+
stop_reason: z7.string().nullish(),
|
|
1935
|
+
usage: z7.looseObject({
|
|
1936
|
+
input_tokens: z7.number(),
|
|
1937
|
+
output_tokens: z7.number(),
|
|
1938
|
+
cache_creation_input_tokens: z7.number().nullish(),
|
|
1939
|
+
cache_read_input_tokens: z7.number().nullish()
|
|
1725
1940
|
})
|
|
1726
1941
|
});
|
|
1727
|
-
var anthropicMessagesChunkSchema =
|
|
1728
|
-
|
|
1729
|
-
type:
|
|
1730
|
-
message:
|
|
1731
|
-
id:
|
|
1732
|
-
model:
|
|
1733
|
-
usage:
|
|
1734
|
-
input_tokens:
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
cache_read_input_tokens: z5.number().nullish()
|
|
1942
|
+
var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
|
|
1943
|
+
z7.object({
|
|
1944
|
+
type: z7.literal("message_start"),
|
|
1945
|
+
message: z7.object({
|
|
1946
|
+
id: z7.string().nullish(),
|
|
1947
|
+
model: z7.string().nullish(),
|
|
1948
|
+
usage: z7.looseObject({
|
|
1949
|
+
input_tokens: z7.number(),
|
|
1950
|
+
cache_creation_input_tokens: z7.number().nullish(),
|
|
1951
|
+
cache_read_input_tokens: z7.number().nullish()
|
|
1738
1952
|
})
|
|
1739
1953
|
})
|
|
1740
1954
|
}),
|
|
1741
|
-
|
|
1742
|
-
type:
|
|
1743
|
-
index:
|
|
1744
|
-
content_block:
|
|
1745
|
-
|
|
1746
|
-
type:
|
|
1747
|
-
text:
|
|
1955
|
+
z7.object({
|
|
1956
|
+
type: z7.literal("content_block_start"),
|
|
1957
|
+
index: z7.number(),
|
|
1958
|
+
content_block: z7.discriminatedUnion("type", [
|
|
1959
|
+
z7.object({
|
|
1960
|
+
type: z7.literal("text"),
|
|
1961
|
+
text: z7.string()
|
|
1748
1962
|
}),
|
|
1749
|
-
|
|
1750
|
-
type:
|
|
1751
|
-
thinking:
|
|
1963
|
+
z7.object({
|
|
1964
|
+
type: z7.literal("thinking"),
|
|
1965
|
+
thinking: z7.string()
|
|
1752
1966
|
}),
|
|
1753
|
-
|
|
1754
|
-
type:
|
|
1755
|
-
id:
|
|
1756
|
-
name:
|
|
1967
|
+
z7.object({
|
|
1968
|
+
type: z7.literal("tool_use"),
|
|
1969
|
+
id: z7.string(),
|
|
1970
|
+
name: z7.string()
|
|
1757
1971
|
}),
|
|
1758
|
-
|
|
1759
|
-
type:
|
|
1760
|
-
data:
|
|
1972
|
+
z7.object({
|
|
1973
|
+
type: z7.literal("redacted_thinking"),
|
|
1974
|
+
data: z7.string()
|
|
1761
1975
|
}),
|
|
1762
|
-
|
|
1763
|
-
type:
|
|
1764
|
-
id:
|
|
1765
|
-
name:
|
|
1766
|
-
input:
|
|
1976
|
+
z7.object({
|
|
1977
|
+
type: z7.literal("server_tool_use"),
|
|
1978
|
+
id: z7.string(),
|
|
1979
|
+
name: z7.string(),
|
|
1980
|
+
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1767
1981
|
}),
|
|
1768
|
-
|
|
1769
|
-
type:
|
|
1770
|
-
tool_use_id:
|
|
1771
|
-
content:
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1982
|
+
z7.object({
|
|
1983
|
+
type: z7.literal("web_fetch_tool_result"),
|
|
1984
|
+
tool_use_id: z7.string(),
|
|
1985
|
+
content: z7.union([
|
|
1986
|
+
z7.object({
|
|
1987
|
+
type: z7.literal("web_fetch_result"),
|
|
1988
|
+
url: z7.string(),
|
|
1989
|
+
retrieved_at: z7.string(),
|
|
1990
|
+
content: z7.object({
|
|
1991
|
+
type: z7.literal("document"),
|
|
1992
|
+
title: z7.string(),
|
|
1993
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1994
|
+
source: z7.object({
|
|
1995
|
+
type: z7.literal("text"),
|
|
1996
|
+
media_type: z7.string(),
|
|
1997
|
+
data: z7.string()
|
|
1998
|
+
})
|
|
1999
|
+
})
|
|
2000
|
+
}),
|
|
2001
|
+
z7.object({
|
|
2002
|
+
type: z7.literal("web_fetch_tool_result_error"),
|
|
2003
|
+
error_code: z7.string()
|
|
2004
|
+
})
|
|
2005
|
+
])
|
|
2006
|
+
}),
|
|
2007
|
+
z7.object({
|
|
2008
|
+
type: z7.literal("web_search_tool_result"),
|
|
2009
|
+
tool_use_id: z7.string(),
|
|
2010
|
+
content: z7.union([
|
|
2011
|
+
z7.array(
|
|
2012
|
+
z7.object({
|
|
2013
|
+
type: z7.literal("web_search_result"),
|
|
2014
|
+
url: z7.string(),
|
|
2015
|
+
title: z7.string(),
|
|
2016
|
+
encrypted_content: z7.string(),
|
|
2017
|
+
page_age: z7.string().nullish()
|
|
1779
2018
|
})
|
|
1780
2019
|
),
|
|
1781
|
-
|
|
1782
|
-
type:
|
|
1783
|
-
error_code:
|
|
2020
|
+
z7.object({
|
|
2021
|
+
type: z7.literal("web_search_tool_result_error"),
|
|
2022
|
+
error_code: z7.string()
|
|
1784
2023
|
})
|
|
1785
2024
|
])
|
|
1786
2025
|
}),
|
|
1787
|
-
|
|
1788
|
-
type:
|
|
1789
|
-
tool_use_id:
|
|
1790
|
-
content:
|
|
1791
|
-
|
|
1792
|
-
type:
|
|
1793
|
-
stdout:
|
|
1794
|
-
stderr:
|
|
1795
|
-
return_code:
|
|
2026
|
+
z7.object({
|
|
2027
|
+
type: z7.literal("code_execution_tool_result"),
|
|
2028
|
+
tool_use_id: z7.string(),
|
|
2029
|
+
content: z7.union([
|
|
2030
|
+
z7.object({
|
|
2031
|
+
type: z7.literal("code_execution_result"),
|
|
2032
|
+
stdout: z7.string(),
|
|
2033
|
+
stderr: z7.string(),
|
|
2034
|
+
return_code: z7.number()
|
|
1796
2035
|
}),
|
|
1797
|
-
|
|
1798
|
-
type:
|
|
1799
|
-
error_code:
|
|
2036
|
+
z7.object({
|
|
2037
|
+
type: z7.literal("code_execution_tool_result_error"),
|
|
2038
|
+
error_code: z7.string()
|
|
1800
2039
|
})
|
|
1801
2040
|
])
|
|
1802
2041
|
})
|
|
1803
2042
|
])
|
|
1804
2043
|
}),
|
|
1805
|
-
|
|
1806
|
-
type:
|
|
1807
|
-
index:
|
|
1808
|
-
delta:
|
|
1809
|
-
|
|
1810
|
-
type:
|
|
1811
|
-
partial_json:
|
|
2044
|
+
z7.object({
|
|
2045
|
+
type: z7.literal("content_block_delta"),
|
|
2046
|
+
index: z7.number(),
|
|
2047
|
+
delta: z7.discriminatedUnion("type", [
|
|
2048
|
+
z7.object({
|
|
2049
|
+
type: z7.literal("input_json_delta"),
|
|
2050
|
+
partial_json: z7.string()
|
|
1812
2051
|
}),
|
|
1813
|
-
|
|
1814
|
-
type:
|
|
1815
|
-
text:
|
|
2052
|
+
z7.object({
|
|
2053
|
+
type: z7.literal("text_delta"),
|
|
2054
|
+
text: z7.string()
|
|
1816
2055
|
}),
|
|
1817
|
-
|
|
1818
|
-
type:
|
|
1819
|
-
thinking:
|
|
2056
|
+
z7.object({
|
|
2057
|
+
type: z7.literal("thinking_delta"),
|
|
2058
|
+
thinking: z7.string()
|
|
1820
2059
|
}),
|
|
1821
|
-
|
|
1822
|
-
type:
|
|
1823
|
-
signature:
|
|
2060
|
+
z7.object({
|
|
2061
|
+
type: z7.literal("signature_delta"),
|
|
2062
|
+
signature: z7.string()
|
|
1824
2063
|
}),
|
|
1825
|
-
|
|
1826
|
-
type:
|
|
2064
|
+
z7.object({
|
|
2065
|
+
type: z7.literal("citations_delta"),
|
|
1827
2066
|
citation: citationSchema
|
|
1828
2067
|
})
|
|
1829
2068
|
])
|
|
1830
2069
|
}),
|
|
1831
|
-
|
|
1832
|
-
type:
|
|
1833
|
-
index:
|
|
2070
|
+
z7.object({
|
|
2071
|
+
type: z7.literal("content_block_stop"),
|
|
2072
|
+
index: z7.number()
|
|
1834
2073
|
}),
|
|
1835
|
-
|
|
1836
|
-
type:
|
|
1837
|
-
error:
|
|
1838
|
-
type:
|
|
1839
|
-
message:
|
|
2074
|
+
z7.object({
|
|
2075
|
+
type: z7.literal("error"),
|
|
2076
|
+
error: z7.object({
|
|
2077
|
+
type: z7.string(),
|
|
2078
|
+
message: z7.string()
|
|
1840
2079
|
})
|
|
1841
2080
|
}),
|
|
1842
|
-
|
|
1843
|
-
type:
|
|
1844
|
-
delta:
|
|
1845
|
-
usage:
|
|
2081
|
+
z7.object({
|
|
2082
|
+
type: z7.literal("message_delta"),
|
|
2083
|
+
delta: z7.object({ stop_reason: z7.string().nullish() }),
|
|
2084
|
+
usage: z7.looseObject({
|
|
2085
|
+
output_tokens: z7.number(),
|
|
2086
|
+
cache_creation_input_tokens: z7.number().nullish()
|
|
2087
|
+
})
|
|
1846
2088
|
}),
|
|
1847
|
-
|
|
1848
|
-
type:
|
|
2089
|
+
z7.object({
|
|
2090
|
+
type: z7.literal("message_stop")
|
|
1849
2091
|
}),
|
|
1850
|
-
|
|
1851
|
-
type:
|
|
2092
|
+
z7.object({
|
|
2093
|
+
type: z7.literal("ping")
|
|
1852
2094
|
})
|
|
1853
2095
|
]);
|
|
1854
|
-
var anthropicReasoningMetadataSchema =
|
|
1855
|
-
signature:
|
|
1856
|
-
redactedData:
|
|
2096
|
+
var anthropicReasoningMetadataSchema = z7.object({
|
|
2097
|
+
signature: z7.string().optional(),
|
|
2098
|
+
redactedData: z7.string().optional()
|
|
1857
2099
|
});
|
|
1858
2100
|
|
|
1859
2101
|
// src/tool/bash_20241022.ts
|
|
1860
|
-
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
1861
|
-
import
|
|
1862
|
-
var bash_20241022 =
|
|
2102
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
2103
|
+
import z8 from "zod/v4";
|
|
2104
|
+
var bash_20241022 = createProviderDefinedToolFactory2({
|
|
1863
2105
|
id: "anthropic.bash_20241022",
|
|
1864
2106
|
name: "bash",
|
|
1865
|
-
inputSchema:
|
|
1866
|
-
command:
|
|
1867
|
-
restart:
|
|
2107
|
+
inputSchema: z8.object({
|
|
2108
|
+
command: z8.string(),
|
|
2109
|
+
restart: z8.boolean().optional()
|
|
1868
2110
|
})
|
|
1869
2111
|
});
|
|
1870
2112
|
|
|
1871
2113
|
// src/tool/bash_20250124.ts
|
|
1872
|
-
import { createProviderDefinedToolFactory as
|
|
1873
|
-
import
|
|
1874
|
-
var bash_20250124 =
|
|
2114
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
|
|
2115
|
+
import z9 from "zod/v4";
|
|
2116
|
+
var bash_20250124 = createProviderDefinedToolFactory3({
|
|
1875
2117
|
id: "anthropic.bash_20250124",
|
|
1876
2118
|
name: "bash",
|
|
1877
|
-
inputSchema:
|
|
1878
|
-
command:
|
|
1879
|
-
restart:
|
|
2119
|
+
inputSchema: z9.object({
|
|
2120
|
+
command: z9.string(),
|
|
2121
|
+
restart: z9.boolean().optional()
|
|
1880
2122
|
})
|
|
1881
2123
|
});
|
|
1882
2124
|
|
|
1883
2125
|
// src/tool/computer_20241022.ts
|
|
1884
|
-
import { createProviderDefinedToolFactory as
|
|
1885
|
-
import { z as
|
|
1886
|
-
var computer_20241022 =
|
|
2126
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
|
|
2127
|
+
import { z as z10 } from "zod/v4";
|
|
2128
|
+
var computer_20241022 = createProviderDefinedToolFactory4({
|
|
1887
2129
|
id: "anthropic.computer_20241022",
|
|
1888
2130
|
name: "computer",
|
|
1889
|
-
inputSchema:
|
|
1890
|
-
action:
|
|
2131
|
+
inputSchema: z10.object({
|
|
2132
|
+
action: z10.enum([
|
|
1891
2133
|
"key",
|
|
1892
2134
|
"type",
|
|
1893
2135
|
"mouse_move",
|
|
@@ -1899,19 +2141,19 @@ var computer_20241022 = createProviderDefinedToolFactory3({
|
|
|
1899
2141
|
"screenshot",
|
|
1900
2142
|
"cursor_position"
|
|
1901
2143
|
]),
|
|
1902
|
-
coordinate:
|
|
1903
|
-
text:
|
|
2144
|
+
coordinate: z10.array(z10.number().int()).optional(),
|
|
2145
|
+
text: z10.string().optional()
|
|
1904
2146
|
})
|
|
1905
2147
|
});
|
|
1906
2148
|
|
|
1907
2149
|
// src/tool/computer_20250124.ts
|
|
1908
|
-
import { createProviderDefinedToolFactory as
|
|
1909
|
-
import { z as
|
|
1910
|
-
var computer_20250124 =
|
|
2150
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
|
|
2151
|
+
import { z as z11 } from "zod/v4";
|
|
2152
|
+
var computer_20250124 = createProviderDefinedToolFactory5({
|
|
1911
2153
|
id: "anthropic.computer_20250124",
|
|
1912
2154
|
name: "computer",
|
|
1913
|
-
inputSchema:
|
|
1914
|
-
action:
|
|
2155
|
+
inputSchema: z11.object({
|
|
2156
|
+
action: z11.enum([
|
|
1915
2157
|
"key",
|
|
1916
2158
|
"hold_key",
|
|
1917
2159
|
"type",
|
|
@@ -1929,63 +2171,63 @@ var computer_20250124 = createProviderDefinedToolFactory4({
|
|
|
1929
2171
|
"wait",
|
|
1930
2172
|
"screenshot"
|
|
1931
2173
|
]),
|
|
1932
|
-
coordinate:
|
|
1933
|
-
duration:
|
|
1934
|
-
scroll_amount:
|
|
1935
|
-
scroll_direction:
|
|
1936
|
-
start_coordinate:
|
|
1937
|
-
text:
|
|
2174
|
+
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2175
|
+
duration: z11.number().optional(),
|
|
2176
|
+
scroll_amount: z11.number().optional(),
|
|
2177
|
+
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2178
|
+
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2179
|
+
text: z11.string().optional()
|
|
1938
2180
|
})
|
|
1939
2181
|
});
|
|
1940
2182
|
|
|
1941
2183
|
// src/tool/text-editor_20241022.ts
|
|
1942
|
-
import { createProviderDefinedToolFactory as
|
|
1943
|
-
import { z as
|
|
1944
|
-
var textEditor_20241022 =
|
|
2184
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
2185
|
+
import { z as z12 } from "zod/v4";
|
|
2186
|
+
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
1945
2187
|
id: "anthropic.text_editor_20241022",
|
|
1946
2188
|
name: "str_replace_editor",
|
|
1947
|
-
inputSchema:
|
|
1948
|
-
command:
|
|
1949
|
-
path:
|
|
1950
|
-
file_text:
|
|
1951
|
-
insert_line:
|
|
1952
|
-
new_str:
|
|
1953
|
-
old_str:
|
|
1954
|
-
view_range:
|
|
2189
|
+
inputSchema: z12.object({
|
|
2190
|
+
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2191
|
+
path: z12.string(),
|
|
2192
|
+
file_text: z12.string().optional(),
|
|
2193
|
+
insert_line: z12.number().int().optional(),
|
|
2194
|
+
new_str: z12.string().optional(),
|
|
2195
|
+
old_str: z12.string().optional(),
|
|
2196
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
1955
2197
|
})
|
|
1956
2198
|
});
|
|
1957
2199
|
|
|
1958
2200
|
// src/tool/text-editor_20250124.ts
|
|
1959
|
-
import { createProviderDefinedToolFactory as
|
|
1960
|
-
import { z as
|
|
1961
|
-
var textEditor_20250124 =
|
|
2201
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
|
|
2202
|
+
import { z as z13 } from "zod/v4";
|
|
2203
|
+
var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
1962
2204
|
id: "anthropic.text_editor_20250124",
|
|
1963
2205
|
name: "str_replace_editor",
|
|
1964
|
-
inputSchema:
|
|
1965
|
-
command:
|
|
1966
|
-
path:
|
|
1967
|
-
file_text:
|
|
1968
|
-
insert_line:
|
|
1969
|
-
new_str:
|
|
1970
|
-
old_str:
|
|
1971
|
-
view_range:
|
|
2206
|
+
inputSchema: z13.object({
|
|
2207
|
+
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2208
|
+
path: z13.string(),
|
|
2209
|
+
file_text: z13.string().optional(),
|
|
2210
|
+
insert_line: z13.number().int().optional(),
|
|
2211
|
+
new_str: z13.string().optional(),
|
|
2212
|
+
old_str: z13.string().optional(),
|
|
2213
|
+
view_range: z13.array(z13.number().int()).optional()
|
|
1972
2214
|
})
|
|
1973
2215
|
});
|
|
1974
2216
|
|
|
1975
2217
|
// src/tool/text-editor_20250429.ts
|
|
1976
|
-
import { createProviderDefinedToolFactory as
|
|
1977
|
-
import { z as
|
|
1978
|
-
var textEditor_20250429 =
|
|
2218
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory8 } from "@ai-sdk/provider-utils";
|
|
2219
|
+
import { z as z14 } from "zod/v4";
|
|
2220
|
+
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
1979
2221
|
id: "anthropic.text_editor_20250429",
|
|
1980
2222
|
name: "str_replace_based_edit_tool",
|
|
1981
|
-
inputSchema:
|
|
1982
|
-
command:
|
|
1983
|
-
path:
|
|
1984
|
-
file_text:
|
|
1985
|
-
insert_line:
|
|
1986
|
-
new_str:
|
|
1987
|
-
old_str:
|
|
1988
|
-
view_range:
|
|
2223
|
+
inputSchema: z14.object({
|
|
2224
|
+
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2225
|
+
path: z14.string(),
|
|
2226
|
+
file_text: z14.string().optional(),
|
|
2227
|
+
insert_line: z14.number().int().optional(),
|
|
2228
|
+
new_str: z14.string().optional(),
|
|
2229
|
+
old_str: z14.string().optional(),
|
|
2230
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
1989
2231
|
})
|
|
1990
2232
|
});
|
|
1991
2233
|
|
|
@@ -2051,6 +2293,8 @@ var anthropicTools = {
|
|
|
2051
2293
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2052
2294
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2053
2295
|
*
|
|
2296
|
+
* Supported models: Claude Sonnet 3.5
|
|
2297
|
+
*
|
|
2054
2298
|
* Tool name must be `str_replace_editor`.
|
|
2055
2299
|
*/
|
|
2056
2300
|
textEditor_20241022,
|
|
@@ -2059,6 +2303,8 @@ var anthropicTools = {
|
|
|
2059
2303
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2060
2304
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2061
2305
|
*
|
|
2306
|
+
* Supported models: Claude Sonnet 3.7
|
|
2307
|
+
*
|
|
2062
2308
|
* Tool name must be `str_replace_editor`.
|
|
2063
2309
|
*/
|
|
2064
2310
|
textEditor_20250124,
|
|
@@ -2070,8 +2316,36 @@ var anthropicTools = {
|
|
|
2070
2316
|
* Note: This version does not support the "undo_edit" command.
|
|
2071
2317
|
*
|
|
2072
2318
|
* Tool name must be `str_replace_based_edit_tool`.
|
|
2319
|
+
*
|
|
2320
|
+
* @deprecated Use textEditor_20250728 instead
|
|
2073
2321
|
*/
|
|
2074
2322
|
textEditor_20250429,
|
|
2323
|
+
/**
|
|
2324
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2325
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2326
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2327
|
+
*
|
|
2328
|
+
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
2329
|
+
*
|
|
2330
|
+
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
2331
|
+
*
|
|
2332
|
+
* Tool name must be `str_replace_based_edit_tool`.
|
|
2333
|
+
*
|
|
2334
|
+
* @param maxCharacters - Optional maximum number of characters to view in the file
|
|
2335
|
+
*/
|
|
2336
|
+
textEditor_20250728,
|
|
2337
|
+
/**
|
|
2338
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
2339
|
+
*
|
|
2340
|
+
* Tool name must be `web_fetch`.
|
|
2341
|
+
*
|
|
2342
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
2343
|
+
* @param allowedDomains - Only fetch from these domains
|
|
2344
|
+
* @param blockedDomains - Never fetch from these domains
|
|
2345
|
+
* @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.
|
|
2346
|
+
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
2347
|
+
*/
|
|
2348
|
+
webFetch_20250910,
|
|
2075
2349
|
/**
|
|
2076
2350
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
2077
2351
|
*
|