@ai-sdk/anthropic 2.0.0-alpha.9 → 2.0.0-beta.1
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 +85 -0
- package/dist/index.d.mts +104 -457
- package/dist/index.d.ts +104 -457
- package/dist/index.js +759 -340
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +865 -457
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +105 -364
- package/dist/internal/index.d.ts +105 -364
- package/dist/internal/index.js +755 -336
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +865 -457
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/internal/index.ts
|
|
@@ -27,7 +37,7 @@ module.exports = __toCommonJS(internal_exports);
|
|
|
27
37
|
|
|
28
38
|
// src/anthropic-messages-language-model.ts
|
|
29
39
|
var import_provider3 = require("@ai-sdk/provider");
|
|
30
|
-
var
|
|
40
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
31
41
|
var import_zod3 = require("zod");
|
|
32
42
|
|
|
33
43
|
// src/anthropic-error.ts
|
|
@@ -47,53 +57,89 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
|
|
|
47
57
|
|
|
48
58
|
// src/anthropic-messages-options.ts
|
|
49
59
|
var import_zod2 = require("zod");
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
var anthropicFilePartProviderOptions = import_zod2.z.object({
|
|
61
|
+
/**
|
|
62
|
+
* Citation configuration for this document.
|
|
63
|
+
* When enabled, this document will generate citations in the response.
|
|
64
|
+
*/
|
|
65
|
+
citations: import_zod2.z.object({
|
|
66
|
+
/**
|
|
67
|
+
* Enable citations for this document
|
|
68
|
+
*/
|
|
69
|
+
enabled: import_zod2.z.boolean()
|
|
70
|
+
}).optional(),
|
|
71
|
+
/**
|
|
72
|
+
* Custom title for the document.
|
|
73
|
+
* If not provided, the filename will be used.
|
|
74
|
+
*/
|
|
75
|
+
title: import_zod2.z.string().optional(),
|
|
76
|
+
/**
|
|
77
|
+
* Context about the document that will be passed to the model
|
|
78
|
+
* but not used towards cited content.
|
|
79
|
+
* Useful for storing document metadata as text or stringified JSON.
|
|
80
|
+
*/
|
|
81
|
+
context: import_zod2.z.string().optional()
|
|
56
82
|
});
|
|
57
83
|
var anthropicProviderOptions = import_zod2.z.object({
|
|
58
|
-
/**
|
|
59
|
-
Include reasoning content in requests sent to the model. Defaults to `true`.
|
|
60
|
-
|
|
61
|
-
If you are experiencing issues with the model handling requests involving
|
|
62
|
-
*/
|
|
63
84
|
sendReasoning: import_zod2.z.boolean().optional(),
|
|
64
85
|
thinking: import_zod2.z.object({
|
|
65
86
|
type: import_zod2.z.union([import_zod2.z.literal("enabled"), import_zod2.z.literal("disabled")]),
|
|
66
87
|
budgetTokens: import_zod2.z.number().optional()
|
|
67
|
-
}).optional()
|
|
88
|
+
}).optional()
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// src/anthropic-prepare-tools.ts
|
|
92
|
+
var import_provider = require("@ai-sdk/provider");
|
|
93
|
+
|
|
94
|
+
// src/tool/web-search_20250305.ts
|
|
95
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
96
|
+
var import_v4 = require("zod/v4");
|
|
97
|
+
var webSearch_20250305ArgsSchema = import_v4.z.object({
|
|
68
98
|
/**
|
|
69
|
-
*
|
|
70
|
-
* When provided, automatically adds the web search tool to the request.
|
|
99
|
+
* Maximum number of web searches Claude can perform during the conversation.
|
|
71
100
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*/
|
|
91
|
-
userLocation: webSearchLocationSchema.optional()
|
|
101
|
+
maxUses: import_v4.z.number().optional(),
|
|
102
|
+
/**
|
|
103
|
+
* Optional list of domains that Claude is allowed to search.
|
|
104
|
+
*/
|
|
105
|
+
allowedDomains: import_v4.z.array(import_v4.z.string()).optional(),
|
|
106
|
+
/**
|
|
107
|
+
* Optional list of domains that Claude should avoid when searching.
|
|
108
|
+
*/
|
|
109
|
+
blockedDomains: import_v4.z.array(import_v4.z.string()).optional(),
|
|
110
|
+
/**
|
|
111
|
+
* Optional user location information to provide geographically relevant search results.
|
|
112
|
+
*/
|
|
113
|
+
userLocation: import_v4.z.object({
|
|
114
|
+
type: import_v4.z.literal("approximate"),
|
|
115
|
+
city: import_v4.z.string().optional(),
|
|
116
|
+
region: import_v4.z.string().optional(),
|
|
117
|
+
country: import_v4.z.string().optional(),
|
|
118
|
+
timezone: import_v4.z.string().optional()
|
|
92
119
|
}).optional()
|
|
93
120
|
});
|
|
121
|
+
var webSearch_20250305OutputSchema = import_v4.z.array(
|
|
122
|
+
import_v4.z.object({
|
|
123
|
+
url: import_v4.z.string(),
|
|
124
|
+
title: import_v4.z.string(),
|
|
125
|
+
pageAge: import_v4.z.string().nullable(),
|
|
126
|
+
encryptedContent: import_v4.z.string(),
|
|
127
|
+
type: import_v4.z.string()
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
131
|
+
id: "anthropic.web_search_20250305",
|
|
132
|
+
name: "web_search",
|
|
133
|
+
inputSchema: import_v4.z.object({
|
|
134
|
+
query: import_v4.z.string()
|
|
135
|
+
}),
|
|
136
|
+
outputSchema: webSearch_20250305OutputSchema
|
|
137
|
+
});
|
|
138
|
+
var webSearch_20250305 = (args = {}) => {
|
|
139
|
+
return factory(args);
|
|
140
|
+
};
|
|
94
141
|
|
|
95
142
|
// src/anthropic-prepare-tools.ts
|
|
96
|
-
var import_provider = require("@ai-sdk/provider");
|
|
97
143
|
function isWebSearchTool(tool) {
|
|
98
144
|
return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
|
|
99
145
|
}
|
|
@@ -118,7 +164,7 @@ function prepareTools({
|
|
|
118
164
|
anthropicTools2.push({
|
|
119
165
|
name: tool.name,
|
|
120
166
|
description: tool.description,
|
|
121
|
-
input_schema: tool.
|
|
167
|
+
input_schema: tool.inputSchema
|
|
122
168
|
});
|
|
123
169
|
break;
|
|
124
170
|
case "provider-defined":
|
|
@@ -126,7 +172,7 @@ function prepareTools({
|
|
|
126
172
|
case "anthropic.computer_20250124":
|
|
127
173
|
betas.add("computer-use-2025-01-24");
|
|
128
174
|
anthropicTools2.push({
|
|
129
|
-
name:
|
|
175
|
+
name: "computer",
|
|
130
176
|
type: "computer_20250124",
|
|
131
177
|
display_width_px: tool.args.displayWidthPx,
|
|
132
178
|
display_height_px: tool.args.displayHeightPx,
|
|
@@ -136,7 +182,7 @@ function prepareTools({
|
|
|
136
182
|
case "anthropic.computer_20241022":
|
|
137
183
|
betas.add("computer-use-2024-10-22");
|
|
138
184
|
anthropicTools2.push({
|
|
139
|
-
name:
|
|
185
|
+
name: "computer",
|
|
140
186
|
type: "computer_20241022",
|
|
141
187
|
display_width_px: tool.args.displayWidthPx,
|
|
142
188
|
display_height_px: tool.args.displayHeightPx,
|
|
@@ -146,31 +192,43 @@ function prepareTools({
|
|
|
146
192
|
case "anthropic.text_editor_20250124":
|
|
147
193
|
betas.add("computer-use-2025-01-24");
|
|
148
194
|
anthropicTools2.push({
|
|
149
|
-
name:
|
|
195
|
+
name: "str_replace_editor",
|
|
150
196
|
type: "text_editor_20250124"
|
|
151
197
|
});
|
|
152
198
|
break;
|
|
153
199
|
case "anthropic.text_editor_20241022":
|
|
154
200
|
betas.add("computer-use-2024-10-22");
|
|
155
201
|
anthropicTools2.push({
|
|
156
|
-
name:
|
|
202
|
+
name: "str_replace_editor",
|
|
157
203
|
type: "text_editor_20241022"
|
|
158
204
|
});
|
|
159
205
|
break;
|
|
160
206
|
case "anthropic.bash_20250124":
|
|
161
207
|
betas.add("computer-use-2025-01-24");
|
|
162
208
|
anthropicTools2.push({
|
|
163
|
-
name:
|
|
209
|
+
name: "bash",
|
|
164
210
|
type: "bash_20250124"
|
|
165
211
|
});
|
|
166
212
|
break;
|
|
167
213
|
case "anthropic.bash_20241022":
|
|
168
214
|
betas.add("computer-use-2024-10-22");
|
|
169
215
|
anthropicTools2.push({
|
|
170
|
-
name:
|
|
216
|
+
name: "bash",
|
|
171
217
|
type: "bash_20241022"
|
|
172
218
|
});
|
|
173
219
|
break;
|
|
220
|
+
case "anthropic.web_search_20250305": {
|
|
221
|
+
const args = webSearch_20250305ArgsSchema.parse(tool.args);
|
|
222
|
+
anthropicTools2.push({
|
|
223
|
+
type: "web_search_20250305",
|
|
224
|
+
name: "web_search",
|
|
225
|
+
max_uses: args.maxUses,
|
|
226
|
+
allowed_domains: args.allowedDomains,
|
|
227
|
+
blocked_domains: args.blockedDomains,
|
|
228
|
+
user_location: args.userLocation
|
|
229
|
+
});
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
174
232
|
default:
|
|
175
233
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
176
234
|
break;
|
|
@@ -225,13 +283,29 @@ function prepareTools({
|
|
|
225
283
|
|
|
226
284
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
227
285
|
var import_provider2 = require("@ai-sdk/provider");
|
|
228
|
-
var
|
|
286
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
287
|
+
function convertToString(data) {
|
|
288
|
+
if (typeof data === "string") {
|
|
289
|
+
return Buffer.from(data, "base64").toString("utf-8");
|
|
290
|
+
}
|
|
291
|
+
if (data instanceof Uint8Array) {
|
|
292
|
+
return new TextDecoder().decode(data);
|
|
293
|
+
}
|
|
294
|
+
if (data instanceof URL) {
|
|
295
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
296
|
+
functionality: "URL-based text documents are not supported for citations"
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
300
|
+
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
301
|
+
});
|
|
302
|
+
}
|
|
229
303
|
async function convertToAnthropicMessagesPrompt({
|
|
230
304
|
prompt,
|
|
231
305
|
sendReasoning,
|
|
232
306
|
warnings
|
|
233
307
|
}) {
|
|
234
|
-
var _a, _b, _c;
|
|
308
|
+
var _a, _b, _c, _d, _e;
|
|
235
309
|
const betas = /* @__PURE__ */ new Set();
|
|
236
310
|
const blocks = groupIntoBlocks(prompt);
|
|
237
311
|
let system = void 0;
|
|
@@ -242,6 +316,26 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
242
316
|
const cacheControlValue = (_a2 = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a2 : anthropic == null ? void 0 : anthropic.cache_control;
|
|
243
317
|
return cacheControlValue;
|
|
244
318
|
}
|
|
319
|
+
async function shouldEnableCitations(providerMetadata) {
|
|
320
|
+
var _a2, _b2;
|
|
321
|
+
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
322
|
+
provider: "anthropic",
|
|
323
|
+
providerOptions: providerMetadata,
|
|
324
|
+
schema: anthropicFilePartProviderOptions
|
|
325
|
+
});
|
|
326
|
+
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
327
|
+
}
|
|
328
|
+
async function getDocumentMetadata(providerMetadata) {
|
|
329
|
+
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
330
|
+
provider: "anthropic",
|
|
331
|
+
providerOptions: providerMetadata,
|
|
332
|
+
schema: anthropicFilePartProviderOptions
|
|
333
|
+
});
|
|
334
|
+
return {
|
|
335
|
+
title: anthropicOptions == null ? void 0 : anthropicOptions.title,
|
|
336
|
+
context: anthropicOptions == null ? void 0 : anthropicOptions.context
|
|
337
|
+
};
|
|
338
|
+
}
|
|
245
339
|
for (let i = 0; i < blocks.length; i++) {
|
|
246
340
|
const block = blocks[i];
|
|
247
341
|
const isLastBlock = i === blocks.length - 1;
|
|
@@ -289,12 +383,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
289
383
|
} : {
|
|
290
384
|
type: "base64",
|
|
291
385
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
292
|
-
data: (0,
|
|
386
|
+
data: (0, import_provider_utils3.convertToBase64)(part.data)
|
|
293
387
|
},
|
|
294
388
|
cache_control: cacheControl
|
|
295
389
|
});
|
|
296
390
|
} else if (part.mediaType === "application/pdf") {
|
|
297
391
|
betas.add("pdfs-2024-09-25");
|
|
392
|
+
const enableCitations = await shouldEnableCitations(
|
|
393
|
+
part.providerOptions
|
|
394
|
+
);
|
|
395
|
+
const metadata = await getDocumentMetadata(
|
|
396
|
+
part.providerOptions
|
|
397
|
+
);
|
|
298
398
|
anthropicContent.push({
|
|
299
399
|
type: "document",
|
|
300
400
|
source: part.data instanceof URL ? {
|
|
@@ -303,7 +403,36 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
303
403
|
} : {
|
|
304
404
|
type: "base64",
|
|
305
405
|
media_type: "application/pdf",
|
|
306
|
-
data: (0,
|
|
406
|
+
data: (0, import_provider_utils3.convertToBase64)(part.data)
|
|
407
|
+
},
|
|
408
|
+
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
409
|
+
...metadata.context && { context: metadata.context },
|
|
410
|
+
...enableCitations && {
|
|
411
|
+
citations: { enabled: true }
|
|
412
|
+
},
|
|
413
|
+
cache_control: cacheControl
|
|
414
|
+
});
|
|
415
|
+
} else if (part.mediaType === "text/plain") {
|
|
416
|
+
const enableCitations = await shouldEnableCitations(
|
|
417
|
+
part.providerOptions
|
|
418
|
+
);
|
|
419
|
+
const metadata = await getDocumentMetadata(
|
|
420
|
+
part.providerOptions
|
|
421
|
+
);
|
|
422
|
+
anthropicContent.push({
|
|
423
|
+
type: "document",
|
|
424
|
+
source: part.data instanceof URL ? {
|
|
425
|
+
type: "url",
|
|
426
|
+
url: part.data.toString()
|
|
427
|
+
} : {
|
|
428
|
+
type: "text",
|
|
429
|
+
media_type: "text/plain",
|
|
430
|
+
data: convertToString(part.data)
|
|
431
|
+
},
|
|
432
|
+
title: (_c = metadata.title) != null ? _c : part.filename,
|
|
433
|
+
...metadata.context && { context: metadata.context },
|
|
434
|
+
...enableCitations && {
|
|
435
|
+
citations: { enabled: true }
|
|
307
436
|
},
|
|
308
437
|
cache_control: cacheControl
|
|
309
438
|
});
|
|
@@ -322,33 +451,53 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
322
451
|
for (let i2 = 0; i2 < content.length; i2++) {
|
|
323
452
|
const part = content[i2];
|
|
324
453
|
const isLastPart = i2 === content.length - 1;
|
|
325
|
-
const cacheControl = (
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
text:
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
454
|
+
const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastPart ? getCacheControl(message.providerOptions) : void 0;
|
|
455
|
+
const output = part.output;
|
|
456
|
+
let contentValue;
|
|
457
|
+
switch (output.type) {
|
|
458
|
+
case "content":
|
|
459
|
+
contentValue = output.value.map((contentPart) => {
|
|
460
|
+
switch (contentPart.type) {
|
|
461
|
+
case "text":
|
|
462
|
+
return {
|
|
463
|
+
type: "text",
|
|
464
|
+
text: contentPart.text,
|
|
465
|
+
cache_control: void 0
|
|
466
|
+
};
|
|
467
|
+
case "media": {
|
|
468
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
469
|
+
return {
|
|
470
|
+
type: "image",
|
|
471
|
+
source: {
|
|
472
|
+
type: "base64",
|
|
473
|
+
media_type: contentPart.mediaType,
|
|
474
|
+
data: contentPart.data
|
|
475
|
+
},
|
|
476
|
+
cache_control: void 0
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
480
|
+
functionality: `media type: ${contentPart.mediaType}`
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
break;
|
|
486
|
+
case "text":
|
|
487
|
+
case "error-text":
|
|
488
|
+
contentValue = output.value;
|
|
489
|
+
break;
|
|
490
|
+
case "json":
|
|
491
|
+
case "error-json":
|
|
492
|
+
default:
|
|
493
|
+
contentValue = JSON.stringify(output.value);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
347
496
|
anthropicContent.push({
|
|
348
497
|
type: "tool_result",
|
|
349
498
|
tool_use_id: part.toolCallId,
|
|
350
|
-
content:
|
|
351
|
-
is_error:
|
|
499
|
+
content: contentValue,
|
|
500
|
+
is_error: output.type === "error-text" || output.type === "error-json" ? true : void 0,
|
|
352
501
|
cache_control: cacheControl
|
|
353
502
|
});
|
|
354
503
|
}
|
|
@@ -372,7 +521,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
372
521
|
for (let k = 0; k < content.length; k++) {
|
|
373
522
|
const part = content[k];
|
|
374
523
|
const isLastContentPart = k === content.length - 1;
|
|
375
|
-
const cacheControl = (
|
|
524
|
+
const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
|
|
376
525
|
switch (part.type) {
|
|
377
526
|
case "text": {
|
|
378
527
|
anthropicContent.push({
|
|
@@ -389,7 +538,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
389
538
|
}
|
|
390
539
|
case "reasoning": {
|
|
391
540
|
if (sendReasoning) {
|
|
392
|
-
const reasoningMetadata = await (0,
|
|
541
|
+
const reasoningMetadata = await (0, import_provider_utils3.parseProviderOptions)({
|
|
393
542
|
provider: "anthropic",
|
|
394
543
|
providerOptions: part.providerOptions,
|
|
395
544
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -429,15 +578,65 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
429
578
|
break;
|
|
430
579
|
}
|
|
431
580
|
case "tool-call": {
|
|
581
|
+
if (part.providerExecuted) {
|
|
582
|
+
if (part.toolName === "web_search") {
|
|
583
|
+
anthropicContent.push({
|
|
584
|
+
type: "server_tool_use",
|
|
585
|
+
id: part.toolCallId,
|
|
586
|
+
name: "web_search",
|
|
587
|
+
input: part.input,
|
|
588
|
+
cache_control: cacheControl
|
|
589
|
+
});
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
warnings.push({
|
|
593
|
+
type: "other",
|
|
594
|
+
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
595
|
+
});
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
432
598
|
anthropicContent.push({
|
|
433
599
|
type: "tool_use",
|
|
434
600
|
id: part.toolCallId,
|
|
435
601
|
name: part.toolName,
|
|
436
|
-
input: part.
|
|
602
|
+
input: part.input,
|
|
437
603
|
cache_control: cacheControl
|
|
438
604
|
});
|
|
439
605
|
break;
|
|
440
606
|
}
|
|
607
|
+
case "tool-result": {
|
|
608
|
+
if (part.toolName === "web_search") {
|
|
609
|
+
const output = part.output;
|
|
610
|
+
if (output.type !== "json") {
|
|
611
|
+
warnings.push({
|
|
612
|
+
type: "other",
|
|
613
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
614
|
+
});
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
const webSearchOutput = webSearch_20250305OutputSchema.parse(
|
|
618
|
+
output.value
|
|
619
|
+
);
|
|
620
|
+
anthropicContent.push({
|
|
621
|
+
type: "web_search_tool_result",
|
|
622
|
+
tool_use_id: part.toolCallId,
|
|
623
|
+
content: webSearchOutput.map((result) => ({
|
|
624
|
+
url: result.url,
|
|
625
|
+
title: result.title,
|
|
626
|
+
page_age: result.pageAge,
|
|
627
|
+
encrypted_content: result.encryptedContent,
|
|
628
|
+
type: result.type
|
|
629
|
+
})),
|
|
630
|
+
cache_control: cacheControl
|
|
631
|
+
});
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
warnings.push({
|
|
635
|
+
type: "other",
|
|
636
|
+
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
637
|
+
});
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
441
640
|
}
|
|
442
641
|
}
|
|
443
642
|
}
|
|
@@ -521,13 +720,86 @@ function mapAnthropicStopReason({
|
|
|
521
720
|
}
|
|
522
721
|
|
|
523
722
|
// src/anthropic-messages-language-model.ts
|
|
723
|
+
var citationSchemas = {
|
|
724
|
+
webSearchResult: import_zod3.z.object({
|
|
725
|
+
type: import_zod3.z.literal("web_search_result_location"),
|
|
726
|
+
cited_text: import_zod3.z.string(),
|
|
727
|
+
url: import_zod3.z.string(),
|
|
728
|
+
title: import_zod3.z.string(),
|
|
729
|
+
encrypted_index: import_zod3.z.string()
|
|
730
|
+
}),
|
|
731
|
+
pageLocation: import_zod3.z.object({
|
|
732
|
+
type: import_zod3.z.literal("page_location"),
|
|
733
|
+
cited_text: import_zod3.z.string(),
|
|
734
|
+
document_index: import_zod3.z.number(),
|
|
735
|
+
document_title: import_zod3.z.string().nullable(),
|
|
736
|
+
start_page_number: import_zod3.z.number(),
|
|
737
|
+
end_page_number: import_zod3.z.number()
|
|
738
|
+
}),
|
|
739
|
+
charLocation: import_zod3.z.object({
|
|
740
|
+
type: import_zod3.z.literal("char_location"),
|
|
741
|
+
cited_text: import_zod3.z.string(),
|
|
742
|
+
document_index: import_zod3.z.number(),
|
|
743
|
+
document_title: import_zod3.z.string().nullable(),
|
|
744
|
+
start_char_index: import_zod3.z.number(),
|
|
745
|
+
end_char_index: import_zod3.z.number()
|
|
746
|
+
})
|
|
747
|
+
};
|
|
748
|
+
var citationSchema = import_zod3.z.discriminatedUnion("type", [
|
|
749
|
+
citationSchemas.webSearchResult,
|
|
750
|
+
citationSchemas.pageLocation,
|
|
751
|
+
citationSchemas.charLocation
|
|
752
|
+
]);
|
|
753
|
+
var documentCitationSchema = import_zod3.z.discriminatedUnion("type", [
|
|
754
|
+
citationSchemas.pageLocation,
|
|
755
|
+
citationSchemas.charLocation
|
|
756
|
+
]);
|
|
757
|
+
function processCitation(citation, citationDocuments, generateId2, onSource) {
|
|
758
|
+
if (citation.type === "page_location" || citation.type === "char_location") {
|
|
759
|
+
const source = createCitationSource(
|
|
760
|
+
citation,
|
|
761
|
+
citationDocuments,
|
|
762
|
+
generateId2
|
|
763
|
+
);
|
|
764
|
+
if (source) {
|
|
765
|
+
onSource(source);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
function createCitationSource(citation, citationDocuments, generateId2) {
|
|
770
|
+
var _a;
|
|
771
|
+
const documentInfo = citationDocuments[citation.document_index];
|
|
772
|
+
if (!documentInfo) {
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
const providerMetadata = citation.type === "page_location" ? {
|
|
776
|
+
citedText: citation.cited_text,
|
|
777
|
+
startPageNumber: citation.start_page_number,
|
|
778
|
+
endPageNumber: citation.end_page_number
|
|
779
|
+
} : {
|
|
780
|
+
citedText: citation.cited_text,
|
|
781
|
+
startCharIndex: citation.start_char_index,
|
|
782
|
+
endCharIndex: citation.end_char_index
|
|
783
|
+
};
|
|
784
|
+
return {
|
|
785
|
+
type: "source",
|
|
786
|
+
sourceType: "document",
|
|
787
|
+
id: generateId2(),
|
|
788
|
+
mediaType: documentInfo.mediaType,
|
|
789
|
+
title: (_a = citation.document_title) != null ? _a : documentInfo.title,
|
|
790
|
+
filename: documentInfo.filename,
|
|
791
|
+
providerMetadata: {
|
|
792
|
+
anthropic: providerMetadata
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
}
|
|
524
796
|
var AnthropicMessagesLanguageModel = class {
|
|
525
797
|
constructor(modelId, config) {
|
|
526
798
|
this.specificationVersion = "v2";
|
|
527
799
|
var _a;
|
|
528
800
|
this.modelId = modelId;
|
|
529
801
|
this.config = config;
|
|
530
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
802
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils4.generateId;
|
|
531
803
|
}
|
|
532
804
|
supportsUrl(url) {
|
|
533
805
|
return url.protocol === "https:";
|
|
@@ -594,9 +866,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
594
866
|
type: "function",
|
|
595
867
|
name: "json",
|
|
596
868
|
description: "Respond with a JSON object.",
|
|
597
|
-
|
|
869
|
+
inputSchema: responseFormat.schema
|
|
598
870
|
} : void 0;
|
|
599
|
-
const anthropicOptions = await (0,
|
|
871
|
+
const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
600
872
|
provider: "anthropic",
|
|
601
873
|
providerOptions,
|
|
602
874
|
schema: anthropicProviderOptions
|
|
@@ -657,27 +929,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
657
929
|
}
|
|
658
930
|
baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
|
|
659
931
|
}
|
|
660
|
-
let modifiedTools = tools;
|
|
661
|
-
let modifiedToolChoice = toolChoice;
|
|
662
|
-
if (anthropicOptions == null ? void 0 : anthropicOptions.webSearch) {
|
|
663
|
-
const webSearchTool = {
|
|
664
|
-
type: "web_search_20250305",
|
|
665
|
-
name: "web_search",
|
|
666
|
-
max_uses: anthropicOptions.webSearch.maxUses,
|
|
667
|
-
allowed_domains: anthropicOptions.webSearch.allowedDomains,
|
|
668
|
-
blocked_domains: anthropicOptions.webSearch.blockedDomains,
|
|
669
|
-
...anthropicOptions.webSearch.userLocation && {
|
|
670
|
-
user_location: {
|
|
671
|
-
type: anthropicOptions.webSearch.userLocation.type,
|
|
672
|
-
country: anthropicOptions.webSearch.userLocation.country,
|
|
673
|
-
city: anthropicOptions.webSearch.userLocation.city,
|
|
674
|
-
region: anthropicOptions.webSearch.userLocation.region,
|
|
675
|
-
timezone: anthropicOptions.webSearch.userLocation.timezone
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
modifiedTools = tools ? [...tools, webSearchTool] : [webSearchTool];
|
|
680
|
-
}
|
|
681
932
|
const {
|
|
682
933
|
tools: anthropicTools2,
|
|
683
934
|
toolChoice: anthropicToolChoice,
|
|
@@ -687,7 +938,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
687
938
|
jsonResponseTool != null ? {
|
|
688
939
|
tools: [jsonResponseTool],
|
|
689
940
|
toolChoice: { type: "tool", toolName: jsonResponseTool.name }
|
|
690
|
-
} : { tools:
|
|
941
|
+
} : { tools: tools != null ? tools : [], toolChoice }
|
|
691
942
|
);
|
|
692
943
|
return {
|
|
693
944
|
args: {
|
|
@@ -704,8 +955,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
704
955
|
betas,
|
|
705
956
|
headers
|
|
706
957
|
}) {
|
|
707
|
-
return (0,
|
|
708
|
-
await (0,
|
|
958
|
+
return (0, import_provider_utils4.combineHeaders)(
|
|
959
|
+
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
709
960
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
710
961
|
headers
|
|
711
962
|
);
|
|
@@ -718,19 +969,43 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
718
969
|
var _a, _b, _c;
|
|
719
970
|
return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
|
|
720
971
|
}
|
|
972
|
+
extractCitationDocuments(prompt) {
|
|
973
|
+
const isCitationPart = (part) => {
|
|
974
|
+
var _a, _b;
|
|
975
|
+
if (part.type !== "file") {
|
|
976
|
+
return false;
|
|
977
|
+
}
|
|
978
|
+
if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
|
|
979
|
+
return false;
|
|
980
|
+
}
|
|
981
|
+
const anthropic = (_a = part.providerOptions) == null ? void 0 : _a.anthropic;
|
|
982
|
+
const citationsConfig = anthropic == null ? void 0 : anthropic.citations;
|
|
983
|
+
return (_b = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b : false;
|
|
984
|
+
};
|
|
985
|
+
return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
|
|
986
|
+
var _a;
|
|
987
|
+
const filePart = part;
|
|
988
|
+
return {
|
|
989
|
+
title: (_a = filePart.filename) != null ? _a : "Untitled Document",
|
|
990
|
+
filename: filePart.filename,
|
|
991
|
+
mediaType: filePart.mediaType
|
|
992
|
+
};
|
|
993
|
+
});
|
|
994
|
+
}
|
|
721
995
|
async doGenerate(options) {
|
|
722
996
|
var _a, _b, _c, _d, _e;
|
|
723
997
|
const { args, warnings, betas, jsonResponseTool } = await this.getArgs(options);
|
|
998
|
+
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
724
999
|
const {
|
|
725
1000
|
responseHeaders,
|
|
726
1001
|
value: response,
|
|
727
1002
|
rawValue: rawResponse
|
|
728
|
-
} = await (0,
|
|
1003
|
+
} = await (0, import_provider_utils4.postJsonToApi)({
|
|
729
1004
|
url: this.buildRequestUrl(false),
|
|
730
1005
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
731
1006
|
body: this.transformRequestBody(args),
|
|
732
1007
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
733
|
-
successfulResponseHandler: (0,
|
|
1008
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
734
1009
|
anthropicMessagesResponseSchema
|
|
735
1010
|
),
|
|
736
1011
|
abortSignal: options.abortSignal,
|
|
@@ -742,6 +1017,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
742
1017
|
case "text": {
|
|
743
1018
|
if (jsonResponseTool == null) {
|
|
744
1019
|
content.push({ type: "text", text: part.text });
|
|
1020
|
+
if (part.citations) {
|
|
1021
|
+
for (const citation of part.citations) {
|
|
1022
|
+
processCitation(
|
|
1023
|
+
citation,
|
|
1024
|
+
citationDocuments,
|
|
1025
|
+
this.generateId,
|
|
1026
|
+
(source) => content.push(source)
|
|
1027
|
+
);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
745
1030
|
}
|
|
746
1031
|
break;
|
|
747
1032
|
}
|
|
@@ -777,42 +1062,68 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
777
1062
|
text: JSON.stringify(part.input)
|
|
778
1063
|
} : {
|
|
779
1064
|
type: "tool-call",
|
|
780
|
-
toolCallType: "function",
|
|
781
1065
|
toolCallId: part.id,
|
|
782
1066
|
toolName: part.name,
|
|
783
|
-
|
|
1067
|
+
input: JSON.stringify(part.input)
|
|
784
1068
|
}
|
|
785
1069
|
);
|
|
786
1070
|
break;
|
|
787
1071
|
}
|
|
788
1072
|
case "server_tool_use": {
|
|
789
|
-
|
|
1073
|
+
if (part.name === "web_search") {
|
|
1074
|
+
content.push({
|
|
1075
|
+
type: "tool-call",
|
|
1076
|
+
toolCallId: part.id,
|
|
1077
|
+
toolName: part.name,
|
|
1078
|
+
input: JSON.stringify(part.input),
|
|
1079
|
+
providerExecuted: true
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
break;
|
|
790
1083
|
}
|
|
791
1084
|
case "web_search_tool_result": {
|
|
792
1085
|
if (Array.isArray(part.content)) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1086
|
+
content.push({
|
|
1087
|
+
type: "tool-result",
|
|
1088
|
+
toolCallId: part.tool_use_id,
|
|
1089
|
+
toolName: "web_search",
|
|
1090
|
+
result: part.content.map((result) => {
|
|
1091
|
+
var _a2;
|
|
1092
|
+
return {
|
|
799
1093
|
url: result.url,
|
|
800
1094
|
title: result.title,
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1095
|
+
pageAge: (_a2 = result.page_age) != null ? _a2 : null,
|
|
1096
|
+
encryptedContent: result.encrypted_content,
|
|
1097
|
+
type: result.type
|
|
1098
|
+
};
|
|
1099
|
+
}),
|
|
1100
|
+
providerExecuted: true
|
|
1101
|
+
});
|
|
1102
|
+
for (const result of part.content) {
|
|
1103
|
+
content.push({
|
|
1104
|
+
type: "source",
|
|
1105
|
+
sourceType: "url",
|
|
1106
|
+
id: this.generateId(),
|
|
1107
|
+
url: result.url,
|
|
1108
|
+
title: result.title,
|
|
1109
|
+
providerMetadata: {
|
|
1110
|
+
anthropic: {
|
|
1111
|
+
pageAge: (_a = result.page_age) != null ? _a : null
|
|
806
1112
|
}
|
|
807
|
-
}
|
|
808
|
-
}
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
809
1115
|
}
|
|
810
|
-
} else
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
1116
|
+
} else {
|
|
1117
|
+
content.push({
|
|
1118
|
+
type: "tool-result",
|
|
1119
|
+
toolCallId: part.tool_use_id,
|
|
1120
|
+
toolName: "web_search",
|
|
1121
|
+
isError: true,
|
|
1122
|
+
result: {
|
|
1123
|
+
type: "web_search_tool_result_error",
|
|
1124
|
+
errorCode: part.content.error_code
|
|
1125
|
+
},
|
|
1126
|
+
providerExecuted: true
|
|
816
1127
|
});
|
|
817
1128
|
}
|
|
818
1129
|
break;
|
|
@@ -848,13 +1159,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
848
1159
|
}
|
|
849
1160
|
async doStream(options) {
|
|
850
1161
|
const { args, warnings, betas, jsonResponseTool } = await this.getArgs(options);
|
|
1162
|
+
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
851
1163
|
const body = { ...args, stream: true };
|
|
852
|
-
const { responseHeaders, value: response } = await (0,
|
|
1164
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
853
1165
|
url: this.buildRequestUrl(true),
|
|
854
1166
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
855
1167
|
body: this.transformRequestBody(body),
|
|
856
1168
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
857
|
-
successfulResponseHandler: (0,
|
|
1169
|
+
successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
|
|
858
1170
|
anthropicMessagesChunkSchema
|
|
859
1171
|
),
|
|
860
1172
|
abortSignal: options.abortSignal,
|
|
@@ -866,10 +1178,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
866
1178
|
outputTokens: void 0,
|
|
867
1179
|
totalTokens: void 0
|
|
868
1180
|
};
|
|
869
|
-
const
|
|
1181
|
+
const contentBlocks = {};
|
|
870
1182
|
let providerMetadata = void 0;
|
|
871
1183
|
let blockType = void 0;
|
|
872
|
-
const config = this.config;
|
|
873
1184
|
const generateId2 = this.generateId;
|
|
874
1185
|
return {
|
|
875
1186
|
stream: response.pipeThrough(
|
|
@@ -879,6 +1190,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
879
1190
|
},
|
|
880
1191
|
transform(chunk, controller) {
|
|
881
1192
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1193
|
+
if (options.includeRawChunks) {
|
|
1194
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1195
|
+
}
|
|
882
1196
|
if (!chunk.success) {
|
|
883
1197
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
884
1198
|
return;
|
|
@@ -892,61 +1206,113 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
892
1206
|
const contentBlockType = value.content_block.type;
|
|
893
1207
|
blockType = contentBlockType;
|
|
894
1208
|
switch (contentBlockType) {
|
|
895
|
-
case "text":
|
|
1209
|
+
case "text": {
|
|
1210
|
+
contentBlocks[value.index] = { type: "text" };
|
|
1211
|
+
controller.enqueue({
|
|
1212
|
+
type: "text-start",
|
|
1213
|
+
id: String(value.index)
|
|
1214
|
+
});
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
896
1217
|
case "thinking": {
|
|
1218
|
+
contentBlocks[value.index] = { type: "reasoning" };
|
|
1219
|
+
controller.enqueue({
|
|
1220
|
+
type: "reasoning-start",
|
|
1221
|
+
id: String(value.index)
|
|
1222
|
+
});
|
|
897
1223
|
return;
|
|
898
1224
|
}
|
|
899
1225
|
case "redacted_thinking": {
|
|
1226
|
+
contentBlocks[value.index] = { type: "reasoning" };
|
|
900
1227
|
controller.enqueue({
|
|
901
|
-
type: "reasoning",
|
|
902
|
-
|
|
1228
|
+
type: "reasoning-start",
|
|
1229
|
+
id: String(value.index),
|
|
903
1230
|
providerMetadata: {
|
|
904
1231
|
anthropic: {
|
|
905
1232
|
redactedData: value.content_block.data
|
|
906
1233
|
}
|
|
907
1234
|
}
|
|
908
1235
|
});
|
|
909
|
-
controller.enqueue({ type: "reasoning-part-finish" });
|
|
910
1236
|
return;
|
|
911
1237
|
}
|
|
912
1238
|
case "tool_use": {
|
|
913
|
-
|
|
1239
|
+
contentBlocks[value.index] = jsonResponseTool != null ? { type: "text" } : {
|
|
1240
|
+
type: "tool-call",
|
|
914
1241
|
toolCallId: value.content_block.id,
|
|
915
1242
|
toolName: value.content_block.name,
|
|
916
|
-
|
|
1243
|
+
input: ""
|
|
917
1244
|
};
|
|
1245
|
+
controller.enqueue(
|
|
1246
|
+
jsonResponseTool != null ? { type: "text-start", id: String(value.index) } : {
|
|
1247
|
+
type: "tool-input-start",
|
|
1248
|
+
id: String(value.index),
|
|
1249
|
+
toolName: value.content_block.name
|
|
1250
|
+
}
|
|
1251
|
+
);
|
|
918
1252
|
return;
|
|
919
1253
|
}
|
|
920
1254
|
case "server_tool_use": {
|
|
1255
|
+
if (value.content_block.name === "web_search") {
|
|
1256
|
+
contentBlocks[value.index] = {
|
|
1257
|
+
type: "tool-call",
|
|
1258
|
+
toolCallId: value.content_block.id,
|
|
1259
|
+
toolName: value.content_block.name,
|
|
1260
|
+
input: "",
|
|
1261
|
+
providerExecuted: true
|
|
1262
|
+
};
|
|
1263
|
+
controller.enqueue({
|
|
1264
|
+
type: "tool-input-start",
|
|
1265
|
+
id: value.content_block.id,
|
|
1266
|
+
toolName: value.content_block.name,
|
|
1267
|
+
providerExecuted: true
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
921
1270
|
return;
|
|
922
1271
|
}
|
|
923
1272
|
case "web_search_tool_result": {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1273
|
+
const part = value.content_block;
|
|
1274
|
+
if (Array.isArray(part.content)) {
|
|
1275
|
+
controller.enqueue({
|
|
1276
|
+
type: "tool-result",
|
|
1277
|
+
toolCallId: part.tool_use_id,
|
|
1278
|
+
toolName: "web_search",
|
|
1279
|
+
result: part.content.map((result) => {
|
|
1280
|
+
var _a2;
|
|
1281
|
+
return {
|
|
931
1282
|
url: result.url,
|
|
932
1283
|
title: result.title,
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1284
|
+
pageAge: (_a2 = result.page_age) != null ? _a2 : null,
|
|
1285
|
+
encryptedContent: result.encrypted_content,
|
|
1286
|
+
type: result.type
|
|
1287
|
+
};
|
|
1288
|
+
}),
|
|
1289
|
+
providerExecuted: true
|
|
1290
|
+
});
|
|
1291
|
+
for (const result of part.content) {
|
|
1292
|
+
controller.enqueue({
|
|
1293
|
+
type: "source",
|
|
1294
|
+
sourceType: "url",
|
|
1295
|
+
id: generateId2(),
|
|
1296
|
+
url: result.url,
|
|
1297
|
+
title: result.title,
|
|
1298
|
+
providerMetadata: {
|
|
1299
|
+
anthropic: {
|
|
1300
|
+
pageAge: (_a = result.page_age) != null ? _a : null
|
|
938
1301
|
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
941
1304
|
}
|
|
942
|
-
} else
|
|
1305
|
+
} else {
|
|
943
1306
|
controller.enqueue({
|
|
944
|
-
type: "
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1307
|
+
type: "tool-result",
|
|
1308
|
+
toolCallId: part.tool_use_id,
|
|
1309
|
+
toolName: "web_search",
|
|
1310
|
+
isError: true,
|
|
1311
|
+
result: {
|
|
1312
|
+
type: "web_search_tool_result_error",
|
|
1313
|
+
errorCode: part.content.error_code
|
|
1314
|
+
},
|
|
1315
|
+
providerExecuted: true
|
|
950
1316
|
});
|
|
951
1317
|
}
|
|
952
1318
|
return;
|
|
@@ -960,18 +1326,34 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
960
1326
|
}
|
|
961
1327
|
}
|
|
962
1328
|
case "content_block_stop": {
|
|
963
|
-
if (
|
|
964
|
-
const contentBlock =
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
}
|
|
1329
|
+
if (contentBlocks[value.index] != null) {
|
|
1330
|
+
const contentBlock = contentBlocks[value.index];
|
|
1331
|
+
switch (contentBlock.type) {
|
|
1332
|
+
case "text": {
|
|
1333
|
+
controller.enqueue({
|
|
1334
|
+
type: "text-end",
|
|
1335
|
+
id: String(value.index)
|
|
1336
|
+
});
|
|
1337
|
+
break;
|
|
1338
|
+
}
|
|
1339
|
+
case "reasoning": {
|
|
1340
|
+
controller.enqueue({
|
|
1341
|
+
type: "reasoning-end",
|
|
1342
|
+
id: String(value.index)
|
|
1343
|
+
});
|
|
1344
|
+
break;
|
|
1345
|
+
}
|
|
1346
|
+
case "tool-call":
|
|
1347
|
+
if (jsonResponseTool == null) {
|
|
1348
|
+
controller.enqueue({
|
|
1349
|
+
type: "tool-input-end",
|
|
1350
|
+
id: contentBlock.toolCallId
|
|
1351
|
+
});
|
|
1352
|
+
controller.enqueue(contentBlock);
|
|
1353
|
+
}
|
|
1354
|
+
break;
|
|
973
1355
|
}
|
|
974
|
-
delete
|
|
1356
|
+
delete contentBlocks[value.index];
|
|
975
1357
|
}
|
|
976
1358
|
blockType = void 0;
|
|
977
1359
|
return;
|
|
@@ -984,54 +1366,68 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
984
1366
|
return;
|
|
985
1367
|
}
|
|
986
1368
|
controller.enqueue({
|
|
987
|
-
type: "text",
|
|
988
|
-
|
|
1369
|
+
type: "text-delta",
|
|
1370
|
+
id: String(value.index),
|
|
1371
|
+
delta: value.delta.text
|
|
989
1372
|
});
|
|
990
1373
|
return;
|
|
991
1374
|
}
|
|
992
1375
|
case "thinking_delta": {
|
|
993
1376
|
controller.enqueue({
|
|
994
|
-
type: "reasoning",
|
|
995
|
-
|
|
1377
|
+
type: "reasoning-delta",
|
|
1378
|
+
id: String(value.index),
|
|
1379
|
+
delta: value.delta.thinking
|
|
996
1380
|
});
|
|
997
1381
|
return;
|
|
998
1382
|
}
|
|
999
1383
|
case "signature_delta": {
|
|
1000
1384
|
if (blockType === "thinking") {
|
|
1001
1385
|
controller.enqueue({
|
|
1002
|
-
type: "reasoning",
|
|
1003
|
-
|
|
1386
|
+
type: "reasoning-delta",
|
|
1387
|
+
id: String(value.index),
|
|
1388
|
+
delta: "",
|
|
1004
1389
|
providerMetadata: {
|
|
1005
1390
|
anthropic: {
|
|
1006
1391
|
signature: value.delta.signature
|
|
1007
1392
|
}
|
|
1008
1393
|
}
|
|
1009
1394
|
});
|
|
1010
|
-
controller.enqueue({ type: "reasoning-part-finish" });
|
|
1011
1395
|
}
|
|
1012
1396
|
return;
|
|
1013
1397
|
}
|
|
1014
1398
|
case "input_json_delta": {
|
|
1015
|
-
const contentBlock =
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
jsonResponseTool != null ? {
|
|
1021
|
-
type: "text",
|
|
1022
|
-
text: value.delta.partial_json
|
|
1023
|
-
} : {
|
|
1024
|
-
type: "tool-call-delta",
|
|
1025
|
-
toolCallType: "function",
|
|
1026
|
-
toolCallId: contentBlock.toolCallId,
|
|
1027
|
-
toolName: contentBlock.toolName,
|
|
1028
|
-
argsTextDelta: value.delta.partial_json
|
|
1399
|
+
const contentBlock = contentBlocks[value.index];
|
|
1400
|
+
const delta = value.delta.partial_json;
|
|
1401
|
+
if (jsonResponseTool == null) {
|
|
1402
|
+
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
1403
|
+
return;
|
|
1029
1404
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1405
|
+
controller.enqueue({
|
|
1406
|
+
type: "tool-input-delta",
|
|
1407
|
+
id: contentBlock.toolCallId,
|
|
1408
|
+
delta
|
|
1409
|
+
});
|
|
1410
|
+
contentBlock.input += delta;
|
|
1411
|
+
} else {
|
|
1412
|
+
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
controller.enqueue({
|
|
1416
|
+
type: "tool-input-delta",
|
|
1417
|
+
id: contentBlock.toolCallId,
|
|
1418
|
+
delta
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1032
1421
|
return;
|
|
1033
1422
|
}
|
|
1034
1423
|
case "citations_delta": {
|
|
1424
|
+
const citation = value.delta.citation;
|
|
1425
|
+
processCitation(
|
|
1426
|
+
citation,
|
|
1427
|
+
citationDocuments,
|
|
1428
|
+
generateId2,
|
|
1429
|
+
(source) => controller.enqueue(source)
|
|
1430
|
+
);
|
|
1035
1431
|
return;
|
|
1036
1432
|
}
|
|
1037
1433
|
default: {
|
|
@@ -1100,7 +1496,8 @@ var anthropicMessagesResponseSchema = import_zod3.z.object({
|
|
|
1100
1496
|
import_zod3.z.discriminatedUnion("type", [
|
|
1101
1497
|
import_zod3.z.object({
|
|
1102
1498
|
type: import_zod3.z.literal("text"),
|
|
1103
|
-
text: import_zod3.z.string()
|
|
1499
|
+
text: import_zod3.z.string(),
|
|
1500
|
+
citations: import_zod3.z.array(citationSchema).optional()
|
|
1104
1501
|
}),
|
|
1105
1502
|
import_zod3.z.object({
|
|
1106
1503
|
type: import_zod3.z.literal("thinking"),
|
|
@@ -1239,13 +1636,7 @@ var anthropicMessagesChunkSchema = import_zod3.z.discriminatedUnion("type", [
|
|
|
1239
1636
|
}),
|
|
1240
1637
|
import_zod3.z.object({
|
|
1241
1638
|
type: import_zod3.z.literal("citations_delta"),
|
|
1242
|
-
citation:
|
|
1243
|
-
type: import_zod3.z.literal("web_search_result_location"),
|
|
1244
|
-
cited_text: import_zod3.z.string(),
|
|
1245
|
-
url: import_zod3.z.string(),
|
|
1246
|
-
title: import_zod3.z.string(),
|
|
1247
|
-
encrypted_index: import_zod3.z.string()
|
|
1248
|
-
})
|
|
1639
|
+
citation: citationSchema
|
|
1249
1640
|
})
|
|
1250
1641
|
])
|
|
1251
1642
|
}),
|
|
@@ -1277,151 +1668,179 @@ var anthropicReasoningMetadataSchema = import_zod3.z.object({
|
|
|
1277
1668
|
redactedData: import_zod3.z.string().optional()
|
|
1278
1669
|
});
|
|
1279
1670
|
|
|
1280
|
-
// src/
|
|
1281
|
-
var
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1284
|
-
|
|
1671
|
+
// src/tool/bash_20241022.ts
|
|
1672
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1673
|
+
var import_v42 = __toESM(require("zod/v4"));
|
|
1674
|
+
var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
1675
|
+
id: "anthropic.bash_20241022",
|
|
1676
|
+
name: "bash",
|
|
1677
|
+
inputSchema: import_v42.default.object({
|
|
1678
|
+
command: import_v42.default.string(),
|
|
1679
|
+
restart: import_v42.default.boolean().optional()
|
|
1680
|
+
})
|
|
1285
1681
|
});
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
command: import_zod4.z.string(),
|
|
1298
|
-
restart: import_zod4.z.boolean().optional()
|
|
1682
|
+
|
|
1683
|
+
// src/tool/bash_20250124.ts
|
|
1684
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1685
|
+
var import_v43 = __toESM(require("zod/v4"));
|
|
1686
|
+
var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
|
|
1687
|
+
id: "anthropic.bashTool_20250124",
|
|
1688
|
+
name: "bash",
|
|
1689
|
+
inputSchema: import_v43.default.object({
|
|
1690
|
+
command: import_v43.default.string(),
|
|
1691
|
+
restart: import_v43.default.boolean().optional()
|
|
1692
|
+
})
|
|
1299
1693
|
});
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1694
|
+
|
|
1695
|
+
// src/tool/computer_20241022.ts
|
|
1696
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1697
|
+
var import_v44 = require("zod/v4");
|
|
1698
|
+
var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
|
|
1699
|
+
id: "anthropic.computer_20241022",
|
|
1700
|
+
name: "computer",
|
|
1701
|
+
inputSchema: import_v44.z.object({
|
|
1702
|
+
action: import_v44.z.enum([
|
|
1703
|
+
"key",
|
|
1704
|
+
"type",
|
|
1705
|
+
"mouse_move",
|
|
1706
|
+
"left_click",
|
|
1707
|
+
"left_click_drag",
|
|
1708
|
+
"right_click",
|
|
1709
|
+
"middle_click",
|
|
1710
|
+
"double_click",
|
|
1711
|
+
"screenshot",
|
|
1712
|
+
"cursor_position"
|
|
1713
|
+
]),
|
|
1714
|
+
coordinate: import_v44.z.array(import_v44.z.number().int()).optional(),
|
|
1715
|
+
text: import_v44.z.string().optional()
|
|
1716
|
+
})
|
|
1318
1717
|
});
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1718
|
+
|
|
1719
|
+
// src/tool/computer_20250124.ts
|
|
1720
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1721
|
+
var import_v45 = require("zod/v4");
|
|
1722
|
+
var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1723
|
+
id: "anthropic.computer_20250124",
|
|
1724
|
+
name: "computer",
|
|
1725
|
+
inputSchema: import_v45.z.object({
|
|
1726
|
+
action: import_v45.z.enum([
|
|
1727
|
+
"key",
|
|
1728
|
+
"hold_key",
|
|
1729
|
+
"type",
|
|
1730
|
+
"cursor_position",
|
|
1731
|
+
"mouse_move",
|
|
1732
|
+
"left_mouse_down",
|
|
1733
|
+
"left_mouse_up",
|
|
1734
|
+
"left_click",
|
|
1735
|
+
"left_click_drag",
|
|
1736
|
+
"right_click",
|
|
1737
|
+
"middle_click",
|
|
1738
|
+
"double_click",
|
|
1739
|
+
"triple_click",
|
|
1740
|
+
"scroll",
|
|
1741
|
+
"wait",
|
|
1742
|
+
"screenshot"
|
|
1743
|
+
]),
|
|
1744
|
+
coordinate: import_v45.z.tuple([import_v45.z.number().int(), import_v45.z.number().int()]).optional(),
|
|
1745
|
+
duration: import_v45.z.number().optional(),
|
|
1746
|
+
scroll_amount: import_v45.z.number().optional(),
|
|
1747
|
+
scroll_direction: import_v45.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1748
|
+
start_coordinate: import_v45.z.tuple([import_v45.z.number().int(), import_v45.z.number().int()]).optional(),
|
|
1749
|
+
text: import_v45.z.string().optional()
|
|
1750
|
+
})
|
|
1337
1751
|
});
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
"left_click_drag",
|
|
1355
|
-
"right_click",
|
|
1356
|
-
"middle_click",
|
|
1357
|
-
"double_click",
|
|
1358
|
-
"screenshot",
|
|
1359
|
-
"cursor_position"
|
|
1360
|
-
]),
|
|
1361
|
-
coordinate: import_zod4.z.array(import_zod4.z.number().int()).optional(),
|
|
1362
|
-
text: import_zod4.z.string().optional()
|
|
1752
|
+
|
|
1753
|
+
// src/tool/text-editor_20241022.ts
|
|
1754
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1755
|
+
var import_v46 = require("zod/v4");
|
|
1756
|
+
var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1757
|
+
id: "anthropic.text_editor_20241022",
|
|
1758
|
+
name: "str_replace_editor",
|
|
1759
|
+
inputSchema: import_v46.z.object({
|
|
1760
|
+
command: import_v46.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1761
|
+
path: import_v46.z.string(),
|
|
1762
|
+
file_text: import_v46.z.string().optional(),
|
|
1763
|
+
insert_line: import_v46.z.number().int().optional(),
|
|
1764
|
+
new_str: import_v46.z.string().optional(),
|
|
1765
|
+
old_str: import_v46.z.string().optional(),
|
|
1766
|
+
view_range: import_v46.z.array(import_v46.z.number().int()).optional()
|
|
1767
|
+
})
|
|
1363
1768
|
});
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
"key",
|
|
1381
|
-
"hold_key",
|
|
1382
|
-
"type",
|
|
1383
|
-
"cursor_position",
|
|
1384
|
-
"mouse_move",
|
|
1385
|
-
"left_mouse_down",
|
|
1386
|
-
"left_mouse_up",
|
|
1387
|
-
"left_click",
|
|
1388
|
-
"left_click_drag",
|
|
1389
|
-
"right_click",
|
|
1390
|
-
"middle_click",
|
|
1391
|
-
"double_click",
|
|
1392
|
-
"triple_click",
|
|
1393
|
-
"scroll",
|
|
1394
|
-
"wait",
|
|
1395
|
-
"screenshot"
|
|
1396
|
-
]),
|
|
1397
|
-
coordinate: import_zod4.z.tuple([import_zod4.z.number().int(), import_zod4.z.number().int()]).optional(),
|
|
1398
|
-
duration: import_zod4.z.number().optional(),
|
|
1399
|
-
scroll_amount: import_zod4.z.number().optional(),
|
|
1400
|
-
scroll_direction: import_zod4.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1401
|
-
start_coordinate: import_zod4.z.tuple([import_zod4.z.number().int(), import_zod4.z.number().int()]).optional(),
|
|
1402
|
-
text: import_zod4.z.string().optional()
|
|
1769
|
+
|
|
1770
|
+
// src/tool/text-editor_20250124.ts
|
|
1771
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1772
|
+
var import_v47 = require("zod/v4");
|
|
1773
|
+
var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1774
|
+
id: "anthropic.text_editor_20250124",
|
|
1775
|
+
name: "str_replace_editor",
|
|
1776
|
+
inputSchema: import_v47.z.object({
|
|
1777
|
+
command: import_v47.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1778
|
+
path: import_v47.z.string(),
|
|
1779
|
+
file_text: import_v47.z.string().optional(),
|
|
1780
|
+
insert_line: import_v47.z.number().int().optional(),
|
|
1781
|
+
new_str: import_v47.z.string().optional(),
|
|
1782
|
+
old_str: import_v47.z.string().optional(),
|
|
1783
|
+
view_range: import_v47.z.array(import_v47.z.number().int()).optional()
|
|
1784
|
+
})
|
|
1403
1785
|
});
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
type: "provider-defined",
|
|
1407
|
-
id: "anthropic.computer_20250124",
|
|
1408
|
-
args: {
|
|
1409
|
-
displayWidthPx: options.displayWidthPx,
|
|
1410
|
-
displayHeightPx: options.displayHeightPx,
|
|
1411
|
-
displayNumber: options.displayNumber
|
|
1412
|
-
},
|
|
1413
|
-
parameters: Computer20250124Parameters,
|
|
1414
|
-
execute: options.execute,
|
|
1415
|
-
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1416
|
-
};
|
|
1417
|
-
}
|
|
1786
|
+
|
|
1787
|
+
// src/anthropic-tools.ts
|
|
1418
1788
|
var anthropicTools = {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1789
|
+
/**
|
|
1790
|
+
* Creates a tool for running a bash command. Must have name "bash".
|
|
1791
|
+
*
|
|
1792
|
+
* Image results are supported.
|
|
1793
|
+
*
|
|
1794
|
+
* @param execute - The function to execute the tool. Optional.
|
|
1795
|
+
*/
|
|
1796
|
+
bash_20241022,
|
|
1797
|
+
/**
|
|
1798
|
+
* Creates a tool for running a bash command. Must have name "bash".
|
|
1799
|
+
*
|
|
1800
|
+
* Image results are supported.
|
|
1801
|
+
*
|
|
1802
|
+
* @param execute - The function to execute the tool. Optional.
|
|
1803
|
+
*/
|
|
1804
|
+
bash_20250124,
|
|
1805
|
+
/**
|
|
1806
|
+
* Creates a tool for editing text. Must have name "str_replace_editor".
|
|
1807
|
+
*/
|
|
1808
|
+
textEditor_20241022,
|
|
1809
|
+
/**
|
|
1810
|
+
* Creates a tool for editing text. Must have name "str_replace_editor".
|
|
1811
|
+
*/
|
|
1812
|
+
textEditor_20250124,
|
|
1813
|
+
/**
|
|
1814
|
+
* Creates a tool for executing actions on a computer. Must have name "computer".
|
|
1815
|
+
*
|
|
1816
|
+
* Image results are supported.
|
|
1817
|
+
*
|
|
1818
|
+
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
1819
|
+
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
1820
|
+
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
1821
|
+
*/
|
|
1822
|
+
computer_20241022,
|
|
1823
|
+
/**
|
|
1824
|
+
* Creates a tool for executing actions on a computer. Must have name "computer".
|
|
1825
|
+
*
|
|
1826
|
+
* Image results are supported.
|
|
1827
|
+
*
|
|
1828
|
+
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
1829
|
+
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
1830
|
+
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
1831
|
+
* @param execute - The function to execute the tool. Optional.
|
|
1832
|
+
*/
|
|
1833
|
+
computer_20250124,
|
|
1834
|
+
/**
|
|
1835
|
+
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
1836
|
+
* Must have name "web_search".
|
|
1837
|
+
*
|
|
1838
|
+
* @param maxUses - Maximum number of web searches Claude can perform during the conversation.
|
|
1839
|
+
* @param allowedDomains - Optional list of domains that Claude is allowed to search.
|
|
1840
|
+
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
1841
|
+
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
1842
|
+
*/
|
|
1843
|
+
webSearch_20250305
|
|
1425
1844
|
};
|
|
1426
1845
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1427
1846
|
0 && (module.exports = {
|