@ai-sdk/anthropic 2.0.0-alpha.9 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +156 -0
- package/dist/index.d.mts +123 -480
- package/dist/index.d.ts +123 -480
- package/dist/index.js +975 -503
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +938 -477
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +119 -365
- package/dist/internal/index.d.ts +119 -365
- package/dist/internal/index.js +971 -499
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +938 -477
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
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,17 +37,17 @@ 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
|
|
31
|
-
var
|
|
40
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
41
|
+
var import_v44 = require("zod/v4");
|
|
32
42
|
|
|
33
43
|
// src/anthropic-error.ts
|
|
34
44
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
35
|
-
var
|
|
36
|
-
var anthropicErrorDataSchema =
|
|
37
|
-
type:
|
|
38
|
-
error:
|
|
39
|
-
type:
|
|
40
|
-
message:
|
|
45
|
+
var import_v4 = require("zod/v4");
|
|
46
|
+
var anthropicErrorDataSchema = import_v4.z.object({
|
|
47
|
+
type: import_v4.z.literal("error"),
|
|
48
|
+
error: import_v4.z.object({
|
|
49
|
+
type: import_v4.z.string(),
|
|
50
|
+
message: import_v4.z.string()
|
|
41
51
|
})
|
|
42
52
|
});
|
|
43
53
|
var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
@@ -46,60 +56,110 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
|
|
|
46
56
|
});
|
|
47
57
|
|
|
48
58
|
// src/anthropic-messages-options.ts
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
type: import_zod2.z.literal("approximate"),
|
|
52
|
-
city: import_zod2.z.string().optional(),
|
|
53
|
-
region: import_zod2.z.string().optional(),
|
|
54
|
-
country: import_zod2.z.string(),
|
|
55
|
-
timezone: import_zod2.z.string().optional()
|
|
56
|
-
});
|
|
57
|
-
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
|
-
sendReasoning: import_zod2.z.boolean().optional(),
|
|
64
|
-
thinking: import_zod2.z.object({
|
|
65
|
-
type: import_zod2.z.union([import_zod2.z.literal("enabled"), import_zod2.z.literal("disabled")]),
|
|
66
|
-
budgetTokens: import_zod2.z.number().optional()
|
|
67
|
-
}).optional(),
|
|
59
|
+
var import_v42 = require("zod/v4");
|
|
60
|
+
var anthropicFilePartProviderOptions = import_v42.z.object({
|
|
68
61
|
/**
|
|
69
|
-
*
|
|
70
|
-
* When
|
|
62
|
+
* Citation configuration for this document.
|
|
63
|
+
* When enabled, this document will generate citations in the response.
|
|
71
64
|
*/
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Limit the number of searches per request (optional)
|
|
75
|
-
* Defaults to 5 if not specified
|
|
76
|
-
*/
|
|
77
|
-
maxUses: import_zod2.z.number().min(1).max(20).optional(),
|
|
78
|
-
/**
|
|
79
|
-
* Only include results from these domains (optional)
|
|
80
|
-
* Cannot be used with blockedDomains
|
|
81
|
-
*/
|
|
82
|
-
allowedDomains: import_zod2.z.array(import_zod2.z.string()).optional(),
|
|
65
|
+
citations: import_v42.z.object({
|
|
83
66
|
/**
|
|
84
|
-
*
|
|
85
|
-
* Cannot be used with allowedDomains
|
|
67
|
+
* Enable citations for this document
|
|
86
68
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
69
|
+
enabled: import_v42.z.boolean()
|
|
70
|
+
}).optional(),
|
|
71
|
+
/**
|
|
72
|
+
* Custom title for the document.
|
|
73
|
+
* If not provided, the filename will be used.
|
|
74
|
+
*/
|
|
75
|
+
title: import_v42.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_v42.z.string().optional()
|
|
82
|
+
});
|
|
83
|
+
var anthropicProviderOptions = import_v42.z.object({
|
|
84
|
+
sendReasoning: import_v42.z.boolean().optional(),
|
|
85
|
+
thinking: import_v42.z.object({
|
|
86
|
+
type: import_v42.z.union([import_v42.z.literal("enabled"), import_v42.z.literal("disabled")]),
|
|
87
|
+
budgetTokens: import_v42.z.number().optional()
|
|
88
|
+
}).optional(),
|
|
89
|
+
/**
|
|
90
|
+
* Whether to disable parallel function calling during tool use. Default is false.
|
|
91
|
+
* When set to true, Claude will use at most one tool per response.
|
|
92
|
+
*/
|
|
93
|
+
disableParallelToolUse: import_v42.z.boolean().optional()
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
// src/anthropic-prepare-tools.ts
|
|
96
97
|
var import_provider = require("@ai-sdk/provider");
|
|
98
|
+
|
|
99
|
+
// src/get-cache-control.ts
|
|
100
|
+
function getCacheControl(providerMetadata) {
|
|
101
|
+
var _a;
|
|
102
|
+
const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
103
|
+
const cacheControlValue = (_a = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a : anthropic == null ? void 0 : anthropic.cache_control;
|
|
104
|
+
return cacheControlValue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/tool/web-search_20250305.ts
|
|
108
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
109
|
+
var import_v43 = require("zod/v4");
|
|
110
|
+
var webSearch_20250305ArgsSchema = import_v43.z.object({
|
|
111
|
+
/**
|
|
112
|
+
* Maximum number of web searches Claude can perform during the conversation.
|
|
113
|
+
*/
|
|
114
|
+
maxUses: import_v43.z.number().optional(),
|
|
115
|
+
/**
|
|
116
|
+
* Optional list of domains that Claude is allowed to search.
|
|
117
|
+
*/
|
|
118
|
+
allowedDomains: import_v43.z.array(import_v43.z.string()).optional(),
|
|
119
|
+
/**
|
|
120
|
+
* Optional list of domains that Claude should avoid when searching.
|
|
121
|
+
*/
|
|
122
|
+
blockedDomains: import_v43.z.array(import_v43.z.string()).optional(),
|
|
123
|
+
/**
|
|
124
|
+
* Optional user location information to provide geographically relevant search results.
|
|
125
|
+
*/
|
|
126
|
+
userLocation: import_v43.z.object({
|
|
127
|
+
type: import_v43.z.literal("approximate"),
|
|
128
|
+
city: import_v43.z.string().optional(),
|
|
129
|
+
region: import_v43.z.string().optional(),
|
|
130
|
+
country: import_v43.z.string().optional(),
|
|
131
|
+
timezone: import_v43.z.string().optional()
|
|
132
|
+
}).optional()
|
|
133
|
+
});
|
|
134
|
+
var webSearch_20250305OutputSchema = import_v43.z.array(
|
|
135
|
+
import_v43.z.object({
|
|
136
|
+
url: import_v43.z.string(),
|
|
137
|
+
title: import_v43.z.string(),
|
|
138
|
+
pageAge: import_v43.z.string().nullable(),
|
|
139
|
+
encryptedContent: import_v43.z.string(),
|
|
140
|
+
type: import_v43.z.string()
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
144
|
+
id: "anthropic.web_search_20250305",
|
|
145
|
+
name: "web_search",
|
|
146
|
+
inputSchema: import_v43.z.object({
|
|
147
|
+
query: import_v43.z.string()
|
|
148
|
+
}),
|
|
149
|
+
outputSchema: webSearch_20250305OutputSchema
|
|
150
|
+
});
|
|
151
|
+
var webSearch_20250305 = (args = {}) => {
|
|
152
|
+
return factory(args);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/anthropic-prepare-tools.ts
|
|
97
156
|
function isWebSearchTool(tool) {
|
|
98
157
|
return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
|
|
99
158
|
}
|
|
100
159
|
function prepareTools({
|
|
101
160
|
tools,
|
|
102
|
-
toolChoice
|
|
161
|
+
toolChoice,
|
|
162
|
+
disableParallelToolUse
|
|
103
163
|
}) {
|
|
104
164
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
105
165
|
const toolWarnings = [];
|
|
@@ -115,10 +175,12 @@ function prepareTools({
|
|
|
115
175
|
}
|
|
116
176
|
switch (tool.type) {
|
|
117
177
|
case "function":
|
|
178
|
+
const cacheControl = getCacheControl(tool.providerOptions);
|
|
118
179
|
anthropicTools2.push({
|
|
119
180
|
name: tool.name,
|
|
120
181
|
description: tool.description,
|
|
121
|
-
input_schema: tool.
|
|
182
|
+
input_schema: tool.inputSchema,
|
|
183
|
+
cache_control: cacheControl
|
|
122
184
|
});
|
|
123
185
|
break;
|
|
124
186
|
case "provider-defined":
|
|
@@ -126,7 +188,7 @@ function prepareTools({
|
|
|
126
188
|
case "anthropic.computer_20250124":
|
|
127
189
|
betas.add("computer-use-2025-01-24");
|
|
128
190
|
anthropicTools2.push({
|
|
129
|
-
name:
|
|
191
|
+
name: "computer",
|
|
130
192
|
type: "computer_20250124",
|
|
131
193
|
display_width_px: tool.args.displayWidthPx,
|
|
132
194
|
display_height_px: tool.args.displayHeightPx,
|
|
@@ -136,7 +198,7 @@ function prepareTools({
|
|
|
136
198
|
case "anthropic.computer_20241022":
|
|
137
199
|
betas.add("computer-use-2024-10-22");
|
|
138
200
|
anthropicTools2.push({
|
|
139
|
-
name:
|
|
201
|
+
name: "computer",
|
|
140
202
|
type: "computer_20241022",
|
|
141
203
|
display_width_px: tool.args.displayWidthPx,
|
|
142
204
|
display_height_px: tool.args.displayHeightPx,
|
|
@@ -146,31 +208,50 @@ function prepareTools({
|
|
|
146
208
|
case "anthropic.text_editor_20250124":
|
|
147
209
|
betas.add("computer-use-2025-01-24");
|
|
148
210
|
anthropicTools2.push({
|
|
149
|
-
name:
|
|
211
|
+
name: "str_replace_editor",
|
|
150
212
|
type: "text_editor_20250124"
|
|
151
213
|
});
|
|
152
214
|
break;
|
|
153
215
|
case "anthropic.text_editor_20241022":
|
|
154
216
|
betas.add("computer-use-2024-10-22");
|
|
155
217
|
anthropicTools2.push({
|
|
156
|
-
name:
|
|
218
|
+
name: "str_replace_editor",
|
|
157
219
|
type: "text_editor_20241022"
|
|
158
220
|
});
|
|
159
221
|
break;
|
|
222
|
+
case "anthropic.text_editor_20250429":
|
|
223
|
+
betas.add("computer-use-2025-01-24");
|
|
224
|
+
anthropicTools2.push({
|
|
225
|
+
name: "str_replace_based_edit_tool",
|
|
226
|
+
type: "text_editor_20250429"
|
|
227
|
+
});
|
|
228
|
+
break;
|
|
160
229
|
case "anthropic.bash_20250124":
|
|
161
230
|
betas.add("computer-use-2025-01-24");
|
|
162
231
|
anthropicTools2.push({
|
|
163
|
-
name:
|
|
232
|
+
name: "bash",
|
|
164
233
|
type: "bash_20250124"
|
|
165
234
|
});
|
|
166
235
|
break;
|
|
167
236
|
case "anthropic.bash_20241022":
|
|
168
237
|
betas.add("computer-use-2024-10-22");
|
|
169
238
|
anthropicTools2.push({
|
|
170
|
-
name:
|
|
239
|
+
name: "bash",
|
|
171
240
|
type: "bash_20241022"
|
|
172
241
|
});
|
|
173
242
|
break;
|
|
243
|
+
case "anthropic.web_search_20250305": {
|
|
244
|
+
const args = webSearch_20250305ArgsSchema.parse(tool.args);
|
|
245
|
+
anthropicTools2.push({
|
|
246
|
+
type: "web_search_20250305",
|
|
247
|
+
name: "web_search",
|
|
248
|
+
max_uses: args.maxUses,
|
|
249
|
+
allowed_domains: args.allowedDomains,
|
|
250
|
+
blocked_domains: args.blockedDomains,
|
|
251
|
+
user_location: args.userLocation
|
|
252
|
+
});
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
174
255
|
default:
|
|
175
256
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
176
257
|
break;
|
|
@@ -184,7 +265,7 @@ function prepareTools({
|
|
|
184
265
|
if (toolChoice == null) {
|
|
185
266
|
return {
|
|
186
267
|
tools: anthropicTools2,
|
|
187
|
-
toolChoice: void 0,
|
|
268
|
+
toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
|
|
188
269
|
toolWarnings,
|
|
189
270
|
betas
|
|
190
271
|
};
|
|
@@ -194,14 +275,20 @@ function prepareTools({
|
|
|
194
275
|
case "auto":
|
|
195
276
|
return {
|
|
196
277
|
tools: anthropicTools2,
|
|
197
|
-
toolChoice: {
|
|
278
|
+
toolChoice: {
|
|
279
|
+
type: "auto",
|
|
280
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
281
|
+
},
|
|
198
282
|
toolWarnings,
|
|
199
283
|
betas
|
|
200
284
|
};
|
|
201
285
|
case "required":
|
|
202
286
|
return {
|
|
203
287
|
tools: anthropicTools2,
|
|
204
|
-
toolChoice: {
|
|
288
|
+
toolChoice: {
|
|
289
|
+
type: "any",
|
|
290
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
291
|
+
},
|
|
205
292
|
toolWarnings,
|
|
206
293
|
betas
|
|
207
294
|
};
|
|
@@ -210,7 +297,11 @@ function prepareTools({
|
|
|
210
297
|
case "tool":
|
|
211
298
|
return {
|
|
212
299
|
tools: anthropicTools2,
|
|
213
|
-
toolChoice: {
|
|
300
|
+
toolChoice: {
|
|
301
|
+
type: "tool",
|
|
302
|
+
name: toolChoice.toolName,
|
|
303
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
304
|
+
},
|
|
214
305
|
toolWarnings,
|
|
215
306
|
betas
|
|
216
307
|
};
|
|
@@ -225,22 +316,52 @@ function prepareTools({
|
|
|
225
316
|
|
|
226
317
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
227
318
|
var import_provider2 = require("@ai-sdk/provider");
|
|
228
|
-
var
|
|
319
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
320
|
+
function convertToString(data) {
|
|
321
|
+
if (typeof data === "string") {
|
|
322
|
+
return Buffer.from(data, "base64").toString("utf-8");
|
|
323
|
+
}
|
|
324
|
+
if (data instanceof Uint8Array) {
|
|
325
|
+
return new TextDecoder().decode(data);
|
|
326
|
+
}
|
|
327
|
+
if (data instanceof URL) {
|
|
328
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
329
|
+
functionality: "URL-based text documents are not supported for citations"
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
333
|
+
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
334
|
+
});
|
|
335
|
+
}
|
|
229
336
|
async function convertToAnthropicMessagesPrompt({
|
|
230
337
|
prompt,
|
|
231
338
|
sendReasoning,
|
|
232
339
|
warnings
|
|
233
340
|
}) {
|
|
234
|
-
var _a, _b, _c;
|
|
341
|
+
var _a, _b, _c, _d, _e;
|
|
235
342
|
const betas = /* @__PURE__ */ new Set();
|
|
236
343
|
const blocks = groupIntoBlocks(prompt);
|
|
237
344
|
let system = void 0;
|
|
238
345
|
const messages = [];
|
|
239
|
-
function
|
|
240
|
-
var _a2;
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
346
|
+
async function shouldEnableCitations(providerMetadata) {
|
|
347
|
+
var _a2, _b2;
|
|
348
|
+
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
349
|
+
provider: "anthropic",
|
|
350
|
+
providerOptions: providerMetadata,
|
|
351
|
+
schema: anthropicFilePartProviderOptions
|
|
352
|
+
});
|
|
353
|
+
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
354
|
+
}
|
|
355
|
+
async function getDocumentMetadata(providerMetadata) {
|
|
356
|
+
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
357
|
+
provider: "anthropic",
|
|
358
|
+
providerOptions: providerMetadata,
|
|
359
|
+
schema: anthropicFilePartProviderOptions
|
|
360
|
+
});
|
|
361
|
+
return {
|
|
362
|
+
title: anthropicOptions == null ? void 0 : anthropicOptions.title,
|
|
363
|
+
context: anthropicOptions == null ? void 0 : anthropicOptions.context
|
|
364
|
+
};
|
|
244
365
|
}
|
|
245
366
|
for (let i = 0; i < blocks.length; i++) {
|
|
246
367
|
const block = blocks[i];
|
|
@@ -289,12 +410,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
289
410
|
} : {
|
|
290
411
|
type: "base64",
|
|
291
412
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
292
|
-
data: (0,
|
|
413
|
+
data: (0, import_provider_utils3.convertToBase64)(part.data)
|
|
293
414
|
},
|
|
294
415
|
cache_control: cacheControl
|
|
295
416
|
});
|
|
296
417
|
} else if (part.mediaType === "application/pdf") {
|
|
297
418
|
betas.add("pdfs-2024-09-25");
|
|
419
|
+
const enableCitations = await shouldEnableCitations(
|
|
420
|
+
part.providerOptions
|
|
421
|
+
);
|
|
422
|
+
const metadata = await getDocumentMetadata(
|
|
423
|
+
part.providerOptions
|
|
424
|
+
);
|
|
298
425
|
anthropicContent.push({
|
|
299
426
|
type: "document",
|
|
300
427
|
source: part.data instanceof URL ? {
|
|
@@ -303,7 +430,36 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
303
430
|
} : {
|
|
304
431
|
type: "base64",
|
|
305
432
|
media_type: "application/pdf",
|
|
306
|
-
data: (0,
|
|
433
|
+
data: (0, import_provider_utils3.convertToBase64)(part.data)
|
|
434
|
+
},
|
|
435
|
+
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
436
|
+
...metadata.context && { context: metadata.context },
|
|
437
|
+
...enableCitations && {
|
|
438
|
+
citations: { enabled: true }
|
|
439
|
+
},
|
|
440
|
+
cache_control: cacheControl
|
|
441
|
+
});
|
|
442
|
+
} else if (part.mediaType === "text/plain") {
|
|
443
|
+
const enableCitations = await shouldEnableCitations(
|
|
444
|
+
part.providerOptions
|
|
445
|
+
);
|
|
446
|
+
const metadata = await getDocumentMetadata(
|
|
447
|
+
part.providerOptions
|
|
448
|
+
);
|
|
449
|
+
anthropicContent.push({
|
|
450
|
+
type: "document",
|
|
451
|
+
source: part.data instanceof URL ? {
|
|
452
|
+
type: "url",
|
|
453
|
+
url: part.data.toString()
|
|
454
|
+
} : {
|
|
455
|
+
type: "text",
|
|
456
|
+
media_type: "text/plain",
|
|
457
|
+
data: convertToString(part.data)
|
|
458
|
+
},
|
|
459
|
+
title: (_c = metadata.title) != null ? _c : part.filename,
|
|
460
|
+
...metadata.context && { context: metadata.context },
|
|
461
|
+
...enableCitations && {
|
|
462
|
+
citations: { enabled: true }
|
|
307
463
|
},
|
|
308
464
|
cache_control: cacheControl
|
|
309
465
|
});
|
|
@@ -322,33 +478,53 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
322
478
|
for (let i2 = 0; i2 < content.length; i2++) {
|
|
323
479
|
const part = content[i2];
|
|
324
480
|
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
|
-
|
|
481
|
+
const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastPart ? getCacheControl(message.providerOptions) : void 0;
|
|
482
|
+
const output = part.output;
|
|
483
|
+
let contentValue;
|
|
484
|
+
switch (output.type) {
|
|
485
|
+
case "content":
|
|
486
|
+
contentValue = output.value.map((contentPart) => {
|
|
487
|
+
switch (contentPart.type) {
|
|
488
|
+
case "text":
|
|
489
|
+
return {
|
|
490
|
+
type: "text",
|
|
491
|
+
text: contentPart.text,
|
|
492
|
+
cache_control: void 0
|
|
493
|
+
};
|
|
494
|
+
case "media": {
|
|
495
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
496
|
+
return {
|
|
497
|
+
type: "image",
|
|
498
|
+
source: {
|
|
499
|
+
type: "base64",
|
|
500
|
+
media_type: contentPart.mediaType,
|
|
501
|
+
data: contentPart.data
|
|
502
|
+
},
|
|
503
|
+
cache_control: void 0
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
507
|
+
functionality: `media type: ${contentPart.mediaType}`
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
break;
|
|
513
|
+
case "text":
|
|
514
|
+
case "error-text":
|
|
515
|
+
contentValue = output.value;
|
|
516
|
+
break;
|
|
517
|
+
case "json":
|
|
518
|
+
case "error-json":
|
|
519
|
+
default:
|
|
520
|
+
contentValue = JSON.stringify(output.value);
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
347
523
|
anthropicContent.push({
|
|
348
524
|
type: "tool_result",
|
|
349
525
|
tool_use_id: part.toolCallId,
|
|
350
|
-
content:
|
|
351
|
-
is_error:
|
|
526
|
+
content: contentValue,
|
|
527
|
+
is_error: output.type === "error-text" || output.type === "error-json" ? true : void 0,
|
|
352
528
|
cache_control: cacheControl
|
|
353
529
|
});
|
|
354
530
|
}
|
|
@@ -372,7 +548,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
372
548
|
for (let k = 0; k < content.length; k++) {
|
|
373
549
|
const part = content[k];
|
|
374
550
|
const isLastContentPart = k === content.length - 1;
|
|
375
|
-
const cacheControl = (
|
|
551
|
+
const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
|
|
376
552
|
switch (part.type) {
|
|
377
553
|
case "text": {
|
|
378
554
|
anthropicContent.push({
|
|
@@ -389,7 +565,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
389
565
|
}
|
|
390
566
|
case "reasoning": {
|
|
391
567
|
if (sendReasoning) {
|
|
392
|
-
const reasoningMetadata = await (0,
|
|
568
|
+
const reasoningMetadata = await (0, import_provider_utils3.parseProviderOptions)({
|
|
393
569
|
provider: "anthropic",
|
|
394
570
|
providerOptions: part.providerOptions,
|
|
395
571
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -429,15 +605,65 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
429
605
|
break;
|
|
430
606
|
}
|
|
431
607
|
case "tool-call": {
|
|
608
|
+
if (part.providerExecuted) {
|
|
609
|
+
if (part.toolName === "web_search") {
|
|
610
|
+
anthropicContent.push({
|
|
611
|
+
type: "server_tool_use",
|
|
612
|
+
id: part.toolCallId,
|
|
613
|
+
name: "web_search",
|
|
614
|
+
input: part.input,
|
|
615
|
+
cache_control: cacheControl
|
|
616
|
+
});
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
warnings.push({
|
|
620
|
+
type: "other",
|
|
621
|
+
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
622
|
+
});
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
432
625
|
anthropicContent.push({
|
|
433
626
|
type: "tool_use",
|
|
434
627
|
id: part.toolCallId,
|
|
435
628
|
name: part.toolName,
|
|
436
|
-
input: part.
|
|
629
|
+
input: part.input,
|
|
437
630
|
cache_control: cacheControl
|
|
438
631
|
});
|
|
439
632
|
break;
|
|
440
633
|
}
|
|
634
|
+
case "tool-result": {
|
|
635
|
+
if (part.toolName === "web_search") {
|
|
636
|
+
const output = part.output;
|
|
637
|
+
if (output.type !== "json") {
|
|
638
|
+
warnings.push({
|
|
639
|
+
type: "other",
|
|
640
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
641
|
+
});
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
const webSearchOutput = webSearch_20250305OutputSchema.parse(
|
|
645
|
+
output.value
|
|
646
|
+
);
|
|
647
|
+
anthropicContent.push({
|
|
648
|
+
type: "web_search_tool_result",
|
|
649
|
+
tool_use_id: part.toolCallId,
|
|
650
|
+
content: webSearchOutput.map((result) => ({
|
|
651
|
+
url: result.url,
|
|
652
|
+
title: result.title,
|
|
653
|
+
page_age: result.pageAge,
|
|
654
|
+
encrypted_content: result.encryptedContent,
|
|
655
|
+
type: result.type
|
|
656
|
+
})),
|
|
657
|
+
cache_control: cacheControl
|
|
658
|
+
});
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
warnings.push({
|
|
662
|
+
type: "other",
|
|
663
|
+
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
664
|
+
});
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
441
667
|
}
|
|
442
668
|
}
|
|
443
669
|
}
|
|
@@ -521,13 +747,86 @@ function mapAnthropicStopReason({
|
|
|
521
747
|
}
|
|
522
748
|
|
|
523
749
|
// src/anthropic-messages-language-model.ts
|
|
750
|
+
var citationSchemas = {
|
|
751
|
+
webSearchResult: import_v44.z.object({
|
|
752
|
+
type: import_v44.z.literal("web_search_result_location"),
|
|
753
|
+
cited_text: import_v44.z.string(),
|
|
754
|
+
url: import_v44.z.string(),
|
|
755
|
+
title: import_v44.z.string(),
|
|
756
|
+
encrypted_index: import_v44.z.string()
|
|
757
|
+
}),
|
|
758
|
+
pageLocation: import_v44.z.object({
|
|
759
|
+
type: import_v44.z.literal("page_location"),
|
|
760
|
+
cited_text: import_v44.z.string(),
|
|
761
|
+
document_index: import_v44.z.number(),
|
|
762
|
+
document_title: import_v44.z.string().nullable(),
|
|
763
|
+
start_page_number: import_v44.z.number(),
|
|
764
|
+
end_page_number: import_v44.z.number()
|
|
765
|
+
}),
|
|
766
|
+
charLocation: import_v44.z.object({
|
|
767
|
+
type: import_v44.z.literal("char_location"),
|
|
768
|
+
cited_text: import_v44.z.string(),
|
|
769
|
+
document_index: import_v44.z.number(),
|
|
770
|
+
document_title: import_v44.z.string().nullable(),
|
|
771
|
+
start_char_index: import_v44.z.number(),
|
|
772
|
+
end_char_index: import_v44.z.number()
|
|
773
|
+
})
|
|
774
|
+
};
|
|
775
|
+
var citationSchema = import_v44.z.discriminatedUnion("type", [
|
|
776
|
+
citationSchemas.webSearchResult,
|
|
777
|
+
citationSchemas.pageLocation,
|
|
778
|
+
citationSchemas.charLocation
|
|
779
|
+
]);
|
|
780
|
+
var documentCitationSchema = import_v44.z.discriminatedUnion("type", [
|
|
781
|
+
citationSchemas.pageLocation,
|
|
782
|
+
citationSchemas.charLocation
|
|
783
|
+
]);
|
|
784
|
+
function processCitation(citation, citationDocuments, generateId2, onSource) {
|
|
785
|
+
if (citation.type === "page_location" || citation.type === "char_location") {
|
|
786
|
+
const source = createCitationSource(
|
|
787
|
+
citation,
|
|
788
|
+
citationDocuments,
|
|
789
|
+
generateId2
|
|
790
|
+
);
|
|
791
|
+
if (source) {
|
|
792
|
+
onSource(source);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
function createCitationSource(citation, citationDocuments, generateId2) {
|
|
797
|
+
var _a;
|
|
798
|
+
const documentInfo = citationDocuments[citation.document_index];
|
|
799
|
+
if (!documentInfo) {
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
const providerMetadata = citation.type === "page_location" ? {
|
|
803
|
+
citedText: citation.cited_text,
|
|
804
|
+
startPageNumber: citation.start_page_number,
|
|
805
|
+
endPageNumber: citation.end_page_number
|
|
806
|
+
} : {
|
|
807
|
+
citedText: citation.cited_text,
|
|
808
|
+
startCharIndex: citation.start_char_index,
|
|
809
|
+
endCharIndex: citation.end_char_index
|
|
810
|
+
};
|
|
811
|
+
return {
|
|
812
|
+
type: "source",
|
|
813
|
+
sourceType: "document",
|
|
814
|
+
id: generateId2(),
|
|
815
|
+
mediaType: documentInfo.mediaType,
|
|
816
|
+
title: (_a = citation.document_title) != null ? _a : documentInfo.title,
|
|
817
|
+
filename: documentInfo.filename,
|
|
818
|
+
providerMetadata: {
|
|
819
|
+
anthropic: providerMetadata
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
}
|
|
524
823
|
var AnthropicMessagesLanguageModel = class {
|
|
525
824
|
constructor(modelId, config) {
|
|
526
825
|
this.specificationVersion = "v2";
|
|
527
826
|
var _a;
|
|
528
827
|
this.modelId = modelId;
|
|
529
828
|
this.config = config;
|
|
530
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
829
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils4.generateId;
|
|
531
830
|
}
|
|
532
831
|
supportsUrl(url) {
|
|
533
832
|
return url.protocol === "https:";
|
|
@@ -594,9 +893,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
594
893
|
type: "function",
|
|
595
894
|
name: "json",
|
|
596
895
|
description: "Respond with a JSON object.",
|
|
597
|
-
|
|
896
|
+
inputSchema: responseFormat.schema
|
|
598
897
|
} : void 0;
|
|
599
|
-
const anthropicOptions = await (0,
|
|
898
|
+
const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
600
899
|
provider: "anthropic",
|
|
601
900
|
providerOptions,
|
|
602
901
|
schema: anthropicProviderOptions
|
|
@@ -657,27 +956,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
657
956
|
}
|
|
658
957
|
baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
|
|
659
958
|
}
|
|
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
959
|
const {
|
|
682
960
|
tools: anthropicTools2,
|
|
683
961
|
toolChoice: anthropicToolChoice,
|
|
@@ -686,8 +964,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
686
964
|
} = prepareTools(
|
|
687
965
|
jsonResponseTool != null ? {
|
|
688
966
|
tools: [jsonResponseTool],
|
|
689
|
-
toolChoice: { type: "tool", toolName: jsonResponseTool.name }
|
|
690
|
-
|
|
967
|
+
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
968
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
969
|
+
} : {
|
|
970
|
+
tools: tools != null ? tools : [],
|
|
971
|
+
toolChoice,
|
|
972
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
973
|
+
}
|
|
691
974
|
);
|
|
692
975
|
return {
|
|
693
976
|
args: {
|
|
@@ -697,15 +980,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
697
980
|
},
|
|
698
981
|
warnings: [...warnings, ...toolWarnings],
|
|
699
982
|
betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
|
|
700
|
-
jsonResponseTool
|
|
983
|
+
usesJsonResponseTool: jsonResponseTool != null
|
|
701
984
|
};
|
|
702
985
|
}
|
|
703
986
|
async getHeaders({
|
|
704
987
|
betas,
|
|
705
988
|
headers
|
|
706
989
|
}) {
|
|
707
|
-
return (0,
|
|
708
|
-
await (0,
|
|
990
|
+
return (0, import_provider_utils4.combineHeaders)(
|
|
991
|
+
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
709
992
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
710
993
|
headers
|
|
711
994
|
);
|
|
@@ -718,19 +1001,43 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
718
1001
|
var _a, _b, _c;
|
|
719
1002
|
return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
|
|
720
1003
|
}
|
|
1004
|
+
extractCitationDocuments(prompt) {
|
|
1005
|
+
const isCitationPart = (part) => {
|
|
1006
|
+
var _a, _b;
|
|
1007
|
+
if (part.type !== "file") {
|
|
1008
|
+
return false;
|
|
1009
|
+
}
|
|
1010
|
+
if (part.mediaType !== "application/pdf" && part.mediaType !== "text/plain") {
|
|
1011
|
+
return false;
|
|
1012
|
+
}
|
|
1013
|
+
const anthropic = (_a = part.providerOptions) == null ? void 0 : _a.anthropic;
|
|
1014
|
+
const citationsConfig = anthropic == null ? void 0 : anthropic.citations;
|
|
1015
|
+
return (_b = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b : false;
|
|
1016
|
+
};
|
|
1017
|
+
return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
|
|
1018
|
+
var _a;
|
|
1019
|
+
const filePart = part;
|
|
1020
|
+
return {
|
|
1021
|
+
title: (_a = filePart.filename) != null ? _a : "Untitled Document",
|
|
1022
|
+
filename: filePart.filename,
|
|
1023
|
+
mediaType: filePart.mediaType
|
|
1024
|
+
};
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
721
1027
|
async doGenerate(options) {
|
|
722
1028
|
var _a, _b, _c, _d, _e;
|
|
723
|
-
const { args, warnings, betas,
|
|
1029
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1030
|
+
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
724
1031
|
const {
|
|
725
1032
|
responseHeaders,
|
|
726
1033
|
value: response,
|
|
727
1034
|
rawValue: rawResponse
|
|
728
|
-
} = await (0,
|
|
1035
|
+
} = await (0, import_provider_utils4.postJsonToApi)({
|
|
729
1036
|
url: this.buildRequestUrl(false),
|
|
730
1037
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
731
1038
|
body: this.transformRequestBody(args),
|
|
732
1039
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
733
|
-
successfulResponseHandler: (0,
|
|
1040
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
734
1041
|
anthropicMessagesResponseSchema
|
|
735
1042
|
),
|
|
736
1043
|
abortSignal: options.abortSignal,
|
|
@@ -740,8 +1047,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
740
1047
|
for (const part of response.content) {
|
|
741
1048
|
switch (part.type) {
|
|
742
1049
|
case "text": {
|
|
743
|
-
if (
|
|
1050
|
+
if (!usesJsonResponseTool) {
|
|
744
1051
|
content.push({ type: "text", text: part.text });
|
|
1052
|
+
if (part.citations) {
|
|
1053
|
+
for (const citation of part.citations) {
|
|
1054
|
+
processCitation(
|
|
1055
|
+
citation,
|
|
1056
|
+
citationDocuments,
|
|
1057
|
+
this.generateId,
|
|
1058
|
+
(source) => content.push(source)
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
745
1062
|
}
|
|
746
1063
|
break;
|
|
747
1064
|
}
|
|
@@ -772,47 +1089,73 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
772
1089
|
case "tool_use": {
|
|
773
1090
|
content.push(
|
|
774
1091
|
// when a json response tool is used, the tool call becomes the text:
|
|
775
|
-
|
|
1092
|
+
usesJsonResponseTool ? {
|
|
776
1093
|
type: "text",
|
|
777
1094
|
text: JSON.stringify(part.input)
|
|
778
1095
|
} : {
|
|
779
1096
|
type: "tool-call",
|
|
780
|
-
toolCallType: "function",
|
|
781
1097
|
toolCallId: part.id,
|
|
782
1098
|
toolName: part.name,
|
|
783
|
-
|
|
1099
|
+
input: JSON.stringify(part.input)
|
|
784
1100
|
}
|
|
785
1101
|
);
|
|
786
1102
|
break;
|
|
787
1103
|
}
|
|
788
1104
|
case "server_tool_use": {
|
|
789
|
-
|
|
1105
|
+
if (part.name === "web_search") {
|
|
1106
|
+
content.push({
|
|
1107
|
+
type: "tool-call",
|
|
1108
|
+
toolCallId: part.id,
|
|
1109
|
+
toolName: part.name,
|
|
1110
|
+
input: JSON.stringify(part.input),
|
|
1111
|
+
providerExecuted: true
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
break;
|
|
790
1115
|
}
|
|
791
1116
|
case "web_search_tool_result": {
|
|
792
1117
|
if (Array.isArray(part.content)) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1118
|
+
content.push({
|
|
1119
|
+
type: "tool-result",
|
|
1120
|
+
toolCallId: part.tool_use_id,
|
|
1121
|
+
toolName: "web_search",
|
|
1122
|
+
result: part.content.map((result) => {
|
|
1123
|
+
var _a2;
|
|
1124
|
+
return {
|
|
799
1125
|
url: result.url,
|
|
800
1126
|
title: result.title,
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1127
|
+
pageAge: (_a2 = result.page_age) != null ? _a2 : null,
|
|
1128
|
+
encryptedContent: result.encrypted_content,
|
|
1129
|
+
type: result.type
|
|
1130
|
+
};
|
|
1131
|
+
}),
|
|
1132
|
+
providerExecuted: true
|
|
1133
|
+
});
|
|
1134
|
+
for (const result of part.content) {
|
|
1135
|
+
content.push({
|
|
1136
|
+
type: "source",
|
|
1137
|
+
sourceType: "url",
|
|
1138
|
+
id: this.generateId(),
|
|
1139
|
+
url: result.url,
|
|
1140
|
+
title: result.title,
|
|
1141
|
+
providerMetadata: {
|
|
1142
|
+
anthropic: {
|
|
1143
|
+
pageAge: (_a = result.page_age) != null ? _a : null
|
|
806
1144
|
}
|
|
807
|
-
}
|
|
808
|
-
}
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
809
1147
|
}
|
|
810
|
-
} else
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
1148
|
+
} else {
|
|
1149
|
+
content.push({
|
|
1150
|
+
type: "tool-result",
|
|
1151
|
+
toolCallId: part.tool_use_id,
|
|
1152
|
+
toolName: "web_search",
|
|
1153
|
+
isError: true,
|
|
1154
|
+
result: {
|
|
1155
|
+
type: "web_search_tool_result_error",
|
|
1156
|
+
errorCode: part.content.error_code
|
|
1157
|
+
},
|
|
1158
|
+
providerExecuted: true
|
|
816
1159
|
});
|
|
817
1160
|
}
|
|
818
1161
|
break;
|
|
@@ -823,7 +1166,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
823
1166
|
content,
|
|
824
1167
|
finishReason: mapAnthropicStopReason({
|
|
825
1168
|
finishReason: response.stop_reason,
|
|
826
|
-
isJsonResponseFromTool:
|
|
1169
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
827
1170
|
}),
|
|
828
1171
|
usage: {
|
|
829
1172
|
inputTokens: response.usage.input_tokens,
|
|
@@ -841,20 +1184,22 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
841
1184
|
warnings,
|
|
842
1185
|
providerMetadata: {
|
|
843
1186
|
anthropic: {
|
|
1187
|
+
usage: response.usage,
|
|
844
1188
|
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
|
|
845
1189
|
}
|
|
846
1190
|
}
|
|
847
1191
|
};
|
|
848
1192
|
}
|
|
849
1193
|
async doStream(options) {
|
|
850
|
-
const { args, warnings, betas,
|
|
1194
|
+
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1195
|
+
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
851
1196
|
const body = { ...args, stream: true };
|
|
852
|
-
const { responseHeaders, value: response } = await (0,
|
|
1197
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
853
1198
|
url: this.buildRequestUrl(true),
|
|
854
1199
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
855
1200
|
body: this.transformRequestBody(body),
|
|
856
1201
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
857
|
-
successfulResponseHandler: (0,
|
|
1202
|
+
successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
|
|
858
1203
|
anthropicMessagesChunkSchema
|
|
859
1204
|
),
|
|
860
1205
|
abortSignal: options.abortSignal,
|
|
@@ -866,10 +1211,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
866
1211
|
outputTokens: void 0,
|
|
867
1212
|
totalTokens: void 0
|
|
868
1213
|
};
|
|
869
|
-
const
|
|
1214
|
+
const contentBlocks = {};
|
|
870
1215
|
let providerMetadata = void 0;
|
|
871
1216
|
let blockType = void 0;
|
|
872
|
-
const config = this.config;
|
|
873
1217
|
const generateId2 = this.generateId;
|
|
874
1218
|
return {
|
|
875
1219
|
stream: response.pipeThrough(
|
|
@@ -879,6 +1223,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
879
1223
|
},
|
|
880
1224
|
transform(chunk, controller) {
|
|
881
1225
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1226
|
+
if (options.includeRawChunks) {
|
|
1227
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1228
|
+
}
|
|
882
1229
|
if (!chunk.success) {
|
|
883
1230
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
884
1231
|
return;
|
|
@@ -892,61 +1239,113 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
892
1239
|
const contentBlockType = value.content_block.type;
|
|
893
1240
|
blockType = contentBlockType;
|
|
894
1241
|
switch (contentBlockType) {
|
|
895
|
-
case "text":
|
|
1242
|
+
case "text": {
|
|
1243
|
+
contentBlocks[value.index] = { type: "text" };
|
|
1244
|
+
controller.enqueue({
|
|
1245
|
+
type: "text-start",
|
|
1246
|
+
id: String(value.index)
|
|
1247
|
+
});
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
896
1250
|
case "thinking": {
|
|
1251
|
+
contentBlocks[value.index] = { type: "reasoning" };
|
|
1252
|
+
controller.enqueue({
|
|
1253
|
+
type: "reasoning-start",
|
|
1254
|
+
id: String(value.index)
|
|
1255
|
+
});
|
|
897
1256
|
return;
|
|
898
1257
|
}
|
|
899
1258
|
case "redacted_thinking": {
|
|
1259
|
+
contentBlocks[value.index] = { type: "reasoning" };
|
|
900
1260
|
controller.enqueue({
|
|
901
|
-
type: "reasoning",
|
|
902
|
-
|
|
1261
|
+
type: "reasoning-start",
|
|
1262
|
+
id: String(value.index),
|
|
903
1263
|
providerMetadata: {
|
|
904
1264
|
anthropic: {
|
|
905
1265
|
redactedData: value.content_block.data
|
|
906
1266
|
}
|
|
907
1267
|
}
|
|
908
1268
|
});
|
|
909
|
-
controller.enqueue({ type: "reasoning-part-finish" });
|
|
910
1269
|
return;
|
|
911
1270
|
}
|
|
912
1271
|
case "tool_use": {
|
|
913
|
-
|
|
1272
|
+
contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
|
|
1273
|
+
type: "tool-call",
|
|
914
1274
|
toolCallId: value.content_block.id,
|
|
915
1275
|
toolName: value.content_block.name,
|
|
916
|
-
|
|
1276
|
+
input: ""
|
|
917
1277
|
};
|
|
1278
|
+
controller.enqueue(
|
|
1279
|
+
usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
1280
|
+
type: "tool-input-start",
|
|
1281
|
+
id: value.content_block.id,
|
|
1282
|
+
toolName: value.content_block.name
|
|
1283
|
+
}
|
|
1284
|
+
);
|
|
918
1285
|
return;
|
|
919
1286
|
}
|
|
920
1287
|
case "server_tool_use": {
|
|
1288
|
+
if (value.content_block.name === "web_search") {
|
|
1289
|
+
contentBlocks[value.index] = {
|
|
1290
|
+
type: "tool-call",
|
|
1291
|
+
toolCallId: value.content_block.id,
|
|
1292
|
+
toolName: value.content_block.name,
|
|
1293
|
+
input: "",
|
|
1294
|
+
providerExecuted: true
|
|
1295
|
+
};
|
|
1296
|
+
controller.enqueue({
|
|
1297
|
+
type: "tool-input-start",
|
|
1298
|
+
id: value.content_block.id,
|
|
1299
|
+
toolName: value.content_block.name,
|
|
1300
|
+
providerExecuted: true
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
921
1303
|
return;
|
|
922
1304
|
}
|
|
923
1305
|
case "web_search_tool_result": {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1306
|
+
const part = value.content_block;
|
|
1307
|
+
if (Array.isArray(part.content)) {
|
|
1308
|
+
controller.enqueue({
|
|
1309
|
+
type: "tool-result",
|
|
1310
|
+
toolCallId: part.tool_use_id,
|
|
1311
|
+
toolName: "web_search",
|
|
1312
|
+
result: part.content.map((result) => {
|
|
1313
|
+
var _a2;
|
|
1314
|
+
return {
|
|
931
1315
|
url: result.url,
|
|
932
1316
|
title: result.title,
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1317
|
+
pageAge: (_a2 = result.page_age) != null ? _a2 : null,
|
|
1318
|
+
encryptedContent: result.encrypted_content,
|
|
1319
|
+
type: result.type
|
|
1320
|
+
};
|
|
1321
|
+
}),
|
|
1322
|
+
providerExecuted: true
|
|
1323
|
+
});
|
|
1324
|
+
for (const result of part.content) {
|
|
1325
|
+
controller.enqueue({
|
|
1326
|
+
type: "source",
|
|
1327
|
+
sourceType: "url",
|
|
1328
|
+
id: generateId2(),
|
|
1329
|
+
url: result.url,
|
|
1330
|
+
title: result.title,
|
|
1331
|
+
providerMetadata: {
|
|
1332
|
+
anthropic: {
|
|
1333
|
+
pageAge: (_a = result.page_age) != null ? _a : null
|
|
938
1334
|
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
941
1337
|
}
|
|
942
|
-
} else
|
|
1338
|
+
} else {
|
|
943
1339
|
controller.enqueue({
|
|
944
|
-
type: "
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1340
|
+
type: "tool-result",
|
|
1341
|
+
toolCallId: part.tool_use_id,
|
|
1342
|
+
toolName: "web_search",
|
|
1343
|
+
isError: true,
|
|
1344
|
+
result: {
|
|
1345
|
+
type: "web_search_tool_result_error",
|
|
1346
|
+
errorCode: part.content.error_code
|
|
1347
|
+
},
|
|
1348
|
+
providerExecuted: true
|
|
950
1349
|
});
|
|
951
1350
|
}
|
|
952
1351
|
return;
|
|
@@ -960,18 +1359,34 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
960
1359
|
}
|
|
961
1360
|
}
|
|
962
1361
|
case "content_block_stop": {
|
|
963
|
-
if (
|
|
964
|
-
const contentBlock =
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
}
|
|
1362
|
+
if (contentBlocks[value.index] != null) {
|
|
1363
|
+
const contentBlock = contentBlocks[value.index];
|
|
1364
|
+
switch (contentBlock.type) {
|
|
1365
|
+
case "text": {
|
|
1366
|
+
controller.enqueue({
|
|
1367
|
+
type: "text-end",
|
|
1368
|
+
id: String(value.index)
|
|
1369
|
+
});
|
|
1370
|
+
break;
|
|
1371
|
+
}
|
|
1372
|
+
case "reasoning": {
|
|
1373
|
+
controller.enqueue({
|
|
1374
|
+
type: "reasoning-end",
|
|
1375
|
+
id: String(value.index)
|
|
1376
|
+
});
|
|
1377
|
+
break;
|
|
1378
|
+
}
|
|
1379
|
+
case "tool-call":
|
|
1380
|
+
if (!usesJsonResponseTool) {
|
|
1381
|
+
controller.enqueue({
|
|
1382
|
+
type: "tool-input-end",
|
|
1383
|
+
id: contentBlock.toolCallId
|
|
1384
|
+
});
|
|
1385
|
+
controller.enqueue(contentBlock);
|
|
1386
|
+
}
|
|
1387
|
+
break;
|
|
973
1388
|
}
|
|
974
|
-
delete
|
|
1389
|
+
delete contentBlocks[value.index];
|
|
975
1390
|
}
|
|
976
1391
|
blockType = void 0;
|
|
977
1392
|
return;
|
|
@@ -980,58 +1395,72 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
980
1395
|
const deltaType = value.delta.type;
|
|
981
1396
|
switch (deltaType) {
|
|
982
1397
|
case "text_delta": {
|
|
983
|
-
if (
|
|
1398
|
+
if (usesJsonResponseTool) {
|
|
984
1399
|
return;
|
|
985
1400
|
}
|
|
986
1401
|
controller.enqueue({
|
|
987
|
-
type: "text",
|
|
988
|
-
|
|
1402
|
+
type: "text-delta",
|
|
1403
|
+
id: String(value.index),
|
|
1404
|
+
delta: value.delta.text
|
|
989
1405
|
});
|
|
990
1406
|
return;
|
|
991
1407
|
}
|
|
992
1408
|
case "thinking_delta": {
|
|
993
1409
|
controller.enqueue({
|
|
994
|
-
type: "reasoning",
|
|
995
|
-
|
|
1410
|
+
type: "reasoning-delta",
|
|
1411
|
+
id: String(value.index),
|
|
1412
|
+
delta: value.delta.thinking
|
|
996
1413
|
});
|
|
997
1414
|
return;
|
|
998
1415
|
}
|
|
999
1416
|
case "signature_delta": {
|
|
1000
1417
|
if (blockType === "thinking") {
|
|
1001
1418
|
controller.enqueue({
|
|
1002
|
-
type: "reasoning",
|
|
1003
|
-
|
|
1419
|
+
type: "reasoning-delta",
|
|
1420
|
+
id: String(value.index),
|
|
1421
|
+
delta: "",
|
|
1004
1422
|
providerMetadata: {
|
|
1005
1423
|
anthropic: {
|
|
1006
1424
|
signature: value.delta.signature
|
|
1007
1425
|
}
|
|
1008
1426
|
}
|
|
1009
1427
|
});
|
|
1010
|
-
controller.enqueue({ type: "reasoning-part-finish" });
|
|
1011
1428
|
}
|
|
1012
1429
|
return;
|
|
1013
1430
|
}
|
|
1014
1431
|
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
|
|
1432
|
+
const contentBlock = contentBlocks[value.index];
|
|
1433
|
+
const delta = value.delta.partial_json;
|
|
1434
|
+
if (usesJsonResponseTool) {
|
|
1435
|
+
if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
|
|
1436
|
+
return;
|
|
1029
1437
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1438
|
+
controller.enqueue({
|
|
1439
|
+
type: "text-delta",
|
|
1440
|
+
id: String(value.index),
|
|
1441
|
+
delta
|
|
1442
|
+
});
|
|
1443
|
+
} else {
|
|
1444
|
+
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
controller.enqueue({
|
|
1448
|
+
type: "tool-input-delta",
|
|
1449
|
+
id: contentBlock.toolCallId,
|
|
1450
|
+
delta
|
|
1451
|
+
});
|
|
1452
|
+
contentBlock.input += delta;
|
|
1453
|
+
}
|
|
1032
1454
|
return;
|
|
1033
1455
|
}
|
|
1034
1456
|
case "citations_delta": {
|
|
1457
|
+
const citation = value.delta.citation;
|
|
1458
|
+
processCitation(
|
|
1459
|
+
citation,
|
|
1460
|
+
citationDocuments,
|
|
1461
|
+
generateId2,
|
|
1462
|
+
(source) => controller.enqueue(source)
|
|
1463
|
+
);
|
|
1035
1464
|
return;
|
|
1036
1465
|
}
|
|
1037
1466
|
default: {
|
|
@@ -1047,6 +1476,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1047
1476
|
usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
|
|
1048
1477
|
providerMetadata = {
|
|
1049
1478
|
anthropic: {
|
|
1479
|
+
usage: value.message.usage,
|
|
1050
1480
|
cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
|
|
1051
1481
|
}
|
|
1052
1482
|
};
|
|
@@ -1062,7 +1492,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1062
1492
|
usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
|
|
1063
1493
|
finishReason = mapAnthropicStopReason({
|
|
1064
1494
|
finishReason: value.delta.stop_reason,
|
|
1065
|
-
isJsonResponseFromTool:
|
|
1495
|
+
isJsonResponseFromTool: usesJsonResponseTool
|
|
1066
1496
|
});
|
|
1067
1497
|
return;
|
|
1068
1498
|
}
|
|
@@ -1092,336 +1522,378 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1092
1522
|
};
|
|
1093
1523
|
}
|
|
1094
1524
|
};
|
|
1095
|
-
var anthropicMessagesResponseSchema =
|
|
1096
|
-
type:
|
|
1097
|
-
id:
|
|
1098
|
-
model:
|
|
1099
|
-
content:
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
type:
|
|
1103
|
-
text:
|
|
1525
|
+
var anthropicMessagesResponseSchema = import_v44.z.object({
|
|
1526
|
+
type: import_v44.z.literal("message"),
|
|
1527
|
+
id: import_v44.z.string().nullish(),
|
|
1528
|
+
model: import_v44.z.string().nullish(),
|
|
1529
|
+
content: import_v44.z.array(
|
|
1530
|
+
import_v44.z.discriminatedUnion("type", [
|
|
1531
|
+
import_v44.z.object({
|
|
1532
|
+
type: import_v44.z.literal("text"),
|
|
1533
|
+
text: import_v44.z.string(),
|
|
1534
|
+
citations: import_v44.z.array(citationSchema).optional()
|
|
1104
1535
|
}),
|
|
1105
|
-
|
|
1106
|
-
type:
|
|
1107
|
-
thinking:
|
|
1108
|
-
signature:
|
|
1536
|
+
import_v44.z.object({
|
|
1537
|
+
type: import_v44.z.literal("thinking"),
|
|
1538
|
+
thinking: import_v44.z.string(),
|
|
1539
|
+
signature: import_v44.z.string()
|
|
1109
1540
|
}),
|
|
1110
|
-
|
|
1111
|
-
type:
|
|
1112
|
-
data:
|
|
1541
|
+
import_v44.z.object({
|
|
1542
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1543
|
+
data: import_v44.z.string()
|
|
1113
1544
|
}),
|
|
1114
|
-
|
|
1115
|
-
type:
|
|
1116
|
-
id:
|
|
1117
|
-
name:
|
|
1118
|
-
input:
|
|
1545
|
+
import_v44.z.object({
|
|
1546
|
+
type: import_v44.z.literal("tool_use"),
|
|
1547
|
+
id: import_v44.z.string(),
|
|
1548
|
+
name: import_v44.z.string(),
|
|
1549
|
+
input: import_v44.z.unknown()
|
|
1119
1550
|
}),
|
|
1120
|
-
|
|
1121
|
-
type:
|
|
1122
|
-
id:
|
|
1123
|
-
name:
|
|
1124
|
-
input:
|
|
1551
|
+
import_v44.z.object({
|
|
1552
|
+
type: import_v44.z.literal("server_tool_use"),
|
|
1553
|
+
id: import_v44.z.string(),
|
|
1554
|
+
name: import_v44.z.string(),
|
|
1555
|
+
input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
|
|
1125
1556
|
}),
|
|
1126
|
-
|
|
1127
|
-
type:
|
|
1128
|
-
tool_use_id:
|
|
1129
|
-
content:
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
type:
|
|
1133
|
-
url:
|
|
1134
|
-
title:
|
|
1135
|
-
encrypted_content:
|
|
1136
|
-
page_age:
|
|
1557
|
+
import_v44.z.object({
|
|
1558
|
+
type: import_v44.z.literal("web_search_tool_result"),
|
|
1559
|
+
tool_use_id: import_v44.z.string(),
|
|
1560
|
+
content: import_v44.z.union([
|
|
1561
|
+
import_v44.z.array(
|
|
1562
|
+
import_v44.z.object({
|
|
1563
|
+
type: import_v44.z.literal("web_search_result"),
|
|
1564
|
+
url: import_v44.z.string(),
|
|
1565
|
+
title: import_v44.z.string(),
|
|
1566
|
+
encrypted_content: import_v44.z.string(),
|
|
1567
|
+
page_age: import_v44.z.string().nullish()
|
|
1137
1568
|
})
|
|
1138
1569
|
),
|
|
1139
|
-
|
|
1140
|
-
type:
|
|
1141
|
-
error_code:
|
|
1570
|
+
import_v44.z.object({
|
|
1571
|
+
type: import_v44.z.literal("web_search_tool_result_error"),
|
|
1572
|
+
error_code: import_v44.z.string()
|
|
1142
1573
|
})
|
|
1143
1574
|
])
|
|
1144
1575
|
})
|
|
1145
1576
|
])
|
|
1146
1577
|
),
|
|
1147
|
-
stop_reason:
|
|
1148
|
-
usage:
|
|
1149
|
-
input_tokens:
|
|
1150
|
-
output_tokens:
|
|
1151
|
-
cache_creation_input_tokens:
|
|
1152
|
-
cache_read_input_tokens:
|
|
1153
|
-
server_tool_use: import_zod3.z.object({
|
|
1154
|
-
web_search_requests: import_zod3.z.number()
|
|
1155
|
-
}).nullish()
|
|
1578
|
+
stop_reason: import_v44.z.string().nullish(),
|
|
1579
|
+
usage: import_v44.z.looseObject({
|
|
1580
|
+
input_tokens: import_v44.z.number(),
|
|
1581
|
+
output_tokens: import_v44.z.number(),
|
|
1582
|
+
cache_creation_input_tokens: import_v44.z.number().nullish(),
|
|
1583
|
+
cache_read_input_tokens: import_v44.z.number().nullish()
|
|
1156
1584
|
})
|
|
1157
1585
|
});
|
|
1158
|
-
var anthropicMessagesChunkSchema =
|
|
1159
|
-
|
|
1160
|
-
type:
|
|
1161
|
-
message:
|
|
1162
|
-
id:
|
|
1163
|
-
model:
|
|
1164
|
-
usage:
|
|
1165
|
-
input_tokens:
|
|
1166
|
-
output_tokens:
|
|
1167
|
-
cache_creation_input_tokens:
|
|
1168
|
-
cache_read_input_tokens:
|
|
1586
|
+
var anthropicMessagesChunkSchema = import_v44.z.discriminatedUnion("type", [
|
|
1587
|
+
import_v44.z.object({
|
|
1588
|
+
type: import_v44.z.literal("message_start"),
|
|
1589
|
+
message: import_v44.z.object({
|
|
1590
|
+
id: import_v44.z.string().nullish(),
|
|
1591
|
+
model: import_v44.z.string().nullish(),
|
|
1592
|
+
usage: import_v44.z.looseObject({
|
|
1593
|
+
input_tokens: import_v44.z.number(),
|
|
1594
|
+
output_tokens: import_v44.z.number(),
|
|
1595
|
+
cache_creation_input_tokens: import_v44.z.number().nullish(),
|
|
1596
|
+
cache_read_input_tokens: import_v44.z.number().nullish()
|
|
1169
1597
|
})
|
|
1170
1598
|
})
|
|
1171
1599
|
}),
|
|
1172
|
-
|
|
1173
|
-
type:
|
|
1174
|
-
index:
|
|
1175
|
-
content_block:
|
|
1176
|
-
|
|
1177
|
-
type:
|
|
1178
|
-
text:
|
|
1600
|
+
import_v44.z.object({
|
|
1601
|
+
type: import_v44.z.literal("content_block_start"),
|
|
1602
|
+
index: import_v44.z.number(),
|
|
1603
|
+
content_block: import_v44.z.discriminatedUnion("type", [
|
|
1604
|
+
import_v44.z.object({
|
|
1605
|
+
type: import_v44.z.literal("text"),
|
|
1606
|
+
text: import_v44.z.string()
|
|
1179
1607
|
}),
|
|
1180
|
-
|
|
1181
|
-
type:
|
|
1182
|
-
thinking:
|
|
1608
|
+
import_v44.z.object({
|
|
1609
|
+
type: import_v44.z.literal("thinking"),
|
|
1610
|
+
thinking: import_v44.z.string()
|
|
1183
1611
|
}),
|
|
1184
|
-
|
|
1185
|
-
type:
|
|
1186
|
-
id:
|
|
1187
|
-
name:
|
|
1612
|
+
import_v44.z.object({
|
|
1613
|
+
type: import_v44.z.literal("tool_use"),
|
|
1614
|
+
id: import_v44.z.string(),
|
|
1615
|
+
name: import_v44.z.string()
|
|
1188
1616
|
}),
|
|
1189
|
-
|
|
1190
|
-
type:
|
|
1191
|
-
data:
|
|
1617
|
+
import_v44.z.object({
|
|
1618
|
+
type: import_v44.z.literal("redacted_thinking"),
|
|
1619
|
+
data: import_v44.z.string()
|
|
1192
1620
|
}),
|
|
1193
|
-
|
|
1194
|
-
type:
|
|
1195
|
-
id:
|
|
1196
|
-
name:
|
|
1197
|
-
input:
|
|
1621
|
+
import_v44.z.object({
|
|
1622
|
+
type: import_v44.z.literal("server_tool_use"),
|
|
1623
|
+
id: import_v44.z.string(),
|
|
1624
|
+
name: import_v44.z.string(),
|
|
1625
|
+
input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
|
|
1198
1626
|
}),
|
|
1199
|
-
|
|
1200
|
-
type:
|
|
1201
|
-
tool_use_id:
|
|
1202
|
-
content:
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
type:
|
|
1206
|
-
url:
|
|
1207
|
-
title:
|
|
1208
|
-
encrypted_content:
|
|
1209
|
-
page_age:
|
|
1627
|
+
import_v44.z.object({
|
|
1628
|
+
type: import_v44.z.literal("web_search_tool_result"),
|
|
1629
|
+
tool_use_id: import_v44.z.string(),
|
|
1630
|
+
content: import_v44.z.union([
|
|
1631
|
+
import_v44.z.array(
|
|
1632
|
+
import_v44.z.object({
|
|
1633
|
+
type: import_v44.z.literal("web_search_result"),
|
|
1634
|
+
url: import_v44.z.string(),
|
|
1635
|
+
title: import_v44.z.string(),
|
|
1636
|
+
encrypted_content: import_v44.z.string(),
|
|
1637
|
+
page_age: import_v44.z.string().nullish()
|
|
1210
1638
|
})
|
|
1211
1639
|
),
|
|
1212
|
-
|
|
1213
|
-
type:
|
|
1214
|
-
error_code:
|
|
1640
|
+
import_v44.z.object({
|
|
1641
|
+
type: import_v44.z.literal("web_search_tool_result_error"),
|
|
1642
|
+
error_code: import_v44.z.string()
|
|
1215
1643
|
})
|
|
1216
1644
|
])
|
|
1217
1645
|
})
|
|
1218
1646
|
])
|
|
1219
1647
|
}),
|
|
1220
|
-
|
|
1221
|
-
type:
|
|
1222
|
-
index:
|
|
1223
|
-
delta:
|
|
1224
|
-
|
|
1225
|
-
type:
|
|
1226
|
-
partial_json:
|
|
1648
|
+
import_v44.z.object({
|
|
1649
|
+
type: import_v44.z.literal("content_block_delta"),
|
|
1650
|
+
index: import_v44.z.number(),
|
|
1651
|
+
delta: import_v44.z.discriminatedUnion("type", [
|
|
1652
|
+
import_v44.z.object({
|
|
1653
|
+
type: import_v44.z.literal("input_json_delta"),
|
|
1654
|
+
partial_json: import_v44.z.string()
|
|
1227
1655
|
}),
|
|
1228
|
-
|
|
1229
|
-
type:
|
|
1230
|
-
text:
|
|
1656
|
+
import_v44.z.object({
|
|
1657
|
+
type: import_v44.z.literal("text_delta"),
|
|
1658
|
+
text: import_v44.z.string()
|
|
1231
1659
|
}),
|
|
1232
|
-
|
|
1233
|
-
type:
|
|
1234
|
-
thinking:
|
|
1660
|
+
import_v44.z.object({
|
|
1661
|
+
type: import_v44.z.literal("thinking_delta"),
|
|
1662
|
+
thinking: import_v44.z.string()
|
|
1235
1663
|
}),
|
|
1236
|
-
|
|
1237
|
-
type:
|
|
1238
|
-
signature:
|
|
1664
|
+
import_v44.z.object({
|
|
1665
|
+
type: import_v44.z.literal("signature_delta"),
|
|
1666
|
+
signature: import_v44.z.string()
|
|
1239
1667
|
}),
|
|
1240
|
-
|
|
1241
|
-
type:
|
|
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
|
-
})
|
|
1668
|
+
import_v44.z.object({
|
|
1669
|
+
type: import_v44.z.literal("citations_delta"),
|
|
1670
|
+
citation: citationSchema
|
|
1249
1671
|
})
|
|
1250
1672
|
])
|
|
1251
1673
|
}),
|
|
1252
|
-
|
|
1253
|
-
type:
|
|
1254
|
-
index:
|
|
1674
|
+
import_v44.z.object({
|
|
1675
|
+
type: import_v44.z.literal("content_block_stop"),
|
|
1676
|
+
index: import_v44.z.number()
|
|
1255
1677
|
}),
|
|
1256
|
-
|
|
1257
|
-
type:
|
|
1258
|
-
error:
|
|
1259
|
-
type:
|
|
1260
|
-
message:
|
|
1678
|
+
import_v44.z.object({
|
|
1679
|
+
type: import_v44.z.literal("error"),
|
|
1680
|
+
error: import_v44.z.object({
|
|
1681
|
+
type: import_v44.z.string(),
|
|
1682
|
+
message: import_v44.z.string()
|
|
1261
1683
|
})
|
|
1262
1684
|
}),
|
|
1263
|
-
|
|
1264
|
-
type:
|
|
1265
|
-
delta:
|
|
1266
|
-
usage:
|
|
1685
|
+
import_v44.z.object({
|
|
1686
|
+
type: import_v44.z.literal("message_delta"),
|
|
1687
|
+
delta: import_v44.z.object({ stop_reason: import_v44.z.string().nullish() }),
|
|
1688
|
+
usage: import_v44.z.object({ output_tokens: import_v44.z.number() })
|
|
1267
1689
|
}),
|
|
1268
|
-
|
|
1269
|
-
type:
|
|
1690
|
+
import_v44.z.object({
|
|
1691
|
+
type: import_v44.z.literal("message_stop")
|
|
1270
1692
|
}),
|
|
1271
|
-
|
|
1272
|
-
type:
|
|
1693
|
+
import_v44.z.object({
|
|
1694
|
+
type: import_v44.z.literal("ping")
|
|
1273
1695
|
})
|
|
1274
1696
|
]);
|
|
1275
|
-
var anthropicReasoningMetadataSchema =
|
|
1276
|
-
signature:
|
|
1277
|
-
redactedData:
|
|
1697
|
+
var anthropicReasoningMetadataSchema = import_v44.z.object({
|
|
1698
|
+
signature: import_v44.z.string().optional(),
|
|
1699
|
+
redactedData: import_v44.z.string().optional()
|
|
1278
1700
|
});
|
|
1279
1701
|
|
|
1280
|
-
// src/
|
|
1281
|
-
var
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1284
|
-
|
|
1702
|
+
// src/tool/bash_20241022.ts
|
|
1703
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1704
|
+
var import_v45 = __toESM(require("zod/v4"));
|
|
1705
|
+
var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
1706
|
+
id: "anthropic.bash_20241022",
|
|
1707
|
+
name: "bash",
|
|
1708
|
+
inputSchema: import_v45.default.object({
|
|
1709
|
+
command: import_v45.default.string(),
|
|
1710
|
+
restart: import_v45.default.boolean().optional()
|
|
1711
|
+
})
|
|
1285
1712
|
});
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
command: import_zod4.z.string(),
|
|
1298
|
-
restart: import_zod4.z.boolean().optional()
|
|
1713
|
+
|
|
1714
|
+
// src/tool/bash_20250124.ts
|
|
1715
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1716
|
+
var import_v46 = __toESM(require("zod/v4"));
|
|
1717
|
+
var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
|
|
1718
|
+
id: "anthropic.bashTool_20250124",
|
|
1719
|
+
name: "bash",
|
|
1720
|
+
inputSchema: import_v46.default.object({
|
|
1721
|
+
command: import_v46.default.string(),
|
|
1722
|
+
restart: import_v46.default.boolean().optional()
|
|
1723
|
+
})
|
|
1299
1724
|
});
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1725
|
+
|
|
1726
|
+
// src/tool/computer_20241022.ts
|
|
1727
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1728
|
+
var import_v47 = require("zod/v4");
|
|
1729
|
+
var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
|
|
1730
|
+
id: "anthropic.computer_20241022",
|
|
1731
|
+
name: "computer",
|
|
1732
|
+
inputSchema: import_v47.z.object({
|
|
1733
|
+
action: import_v47.z.enum([
|
|
1734
|
+
"key",
|
|
1735
|
+
"type",
|
|
1736
|
+
"mouse_move",
|
|
1737
|
+
"left_click",
|
|
1738
|
+
"left_click_drag",
|
|
1739
|
+
"right_click",
|
|
1740
|
+
"middle_click",
|
|
1741
|
+
"double_click",
|
|
1742
|
+
"screenshot",
|
|
1743
|
+
"cursor_position"
|
|
1744
|
+
]),
|
|
1745
|
+
coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
|
|
1746
|
+
text: import_v47.z.string().optional()
|
|
1747
|
+
})
|
|
1318
1748
|
});
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1749
|
+
|
|
1750
|
+
// src/tool/computer_20250124.ts
|
|
1751
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1752
|
+
var import_v48 = require("zod/v4");
|
|
1753
|
+
var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1754
|
+
id: "anthropic.computer_20250124",
|
|
1755
|
+
name: "computer",
|
|
1756
|
+
inputSchema: import_v48.z.object({
|
|
1757
|
+
action: import_v48.z.enum([
|
|
1758
|
+
"key",
|
|
1759
|
+
"hold_key",
|
|
1760
|
+
"type",
|
|
1761
|
+
"cursor_position",
|
|
1762
|
+
"mouse_move",
|
|
1763
|
+
"left_mouse_down",
|
|
1764
|
+
"left_mouse_up",
|
|
1765
|
+
"left_click",
|
|
1766
|
+
"left_click_drag",
|
|
1767
|
+
"right_click",
|
|
1768
|
+
"middle_click",
|
|
1769
|
+
"double_click",
|
|
1770
|
+
"triple_click",
|
|
1771
|
+
"scroll",
|
|
1772
|
+
"wait",
|
|
1773
|
+
"screenshot"
|
|
1774
|
+
]),
|
|
1775
|
+
coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
|
|
1776
|
+
duration: import_v48.z.number().optional(),
|
|
1777
|
+
scroll_amount: import_v48.z.number().optional(),
|
|
1778
|
+
scroll_direction: import_v48.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1779
|
+
start_coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
|
|
1780
|
+
text: import_v48.z.string().optional()
|
|
1781
|
+
})
|
|
1337
1782
|
});
|
|
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()
|
|
1783
|
+
|
|
1784
|
+
// src/tool/text-editor_20241022.ts
|
|
1785
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1786
|
+
var import_v49 = require("zod/v4");
|
|
1787
|
+
var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1788
|
+
id: "anthropic.text_editor_20241022",
|
|
1789
|
+
name: "str_replace_editor",
|
|
1790
|
+
inputSchema: import_v49.z.object({
|
|
1791
|
+
command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1792
|
+
path: import_v49.z.string(),
|
|
1793
|
+
file_text: import_v49.z.string().optional(),
|
|
1794
|
+
insert_line: import_v49.z.number().int().optional(),
|
|
1795
|
+
new_str: import_v49.z.string().optional(),
|
|
1796
|
+
old_str: import_v49.z.string().optional(),
|
|
1797
|
+
view_range: import_v49.z.array(import_v49.z.number().int()).optional()
|
|
1798
|
+
})
|
|
1363
1799
|
});
|
|
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()
|
|
1800
|
+
|
|
1801
|
+
// src/tool/text-editor_20250124.ts
|
|
1802
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1803
|
+
var import_v410 = require("zod/v4");
|
|
1804
|
+
var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1805
|
+
id: "anthropic.text_editor_20250124",
|
|
1806
|
+
name: "str_replace_editor",
|
|
1807
|
+
inputSchema: import_v410.z.object({
|
|
1808
|
+
command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1809
|
+
path: import_v410.z.string(),
|
|
1810
|
+
file_text: import_v410.z.string().optional(),
|
|
1811
|
+
insert_line: import_v410.z.number().int().optional(),
|
|
1812
|
+
new_str: import_v410.z.string().optional(),
|
|
1813
|
+
old_str: import_v410.z.string().optional(),
|
|
1814
|
+
view_range: import_v410.z.array(import_v410.z.number().int()).optional()
|
|
1815
|
+
})
|
|
1403
1816
|
});
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1817
|
+
|
|
1818
|
+
// src/tool/text-editor_20250429.ts
|
|
1819
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1820
|
+
var import_v411 = require("zod/v4");
|
|
1821
|
+
var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1822
|
+
id: "anthropic.text_editor_20250429",
|
|
1823
|
+
name: "str_replace_based_edit_tool",
|
|
1824
|
+
inputSchema: import_v411.z.object({
|
|
1825
|
+
command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
|
|
1826
|
+
path: import_v411.z.string(),
|
|
1827
|
+
file_text: import_v411.z.string().optional(),
|
|
1828
|
+
insert_line: import_v411.z.number().int().optional(),
|
|
1829
|
+
new_str: import_v411.z.string().optional(),
|
|
1830
|
+
old_str: import_v411.z.string().optional(),
|
|
1831
|
+
view_range: import_v411.z.array(import_v411.z.number().int()).optional()
|
|
1832
|
+
})
|
|
1833
|
+
});
|
|
1834
|
+
|
|
1835
|
+
// src/anthropic-tools.ts
|
|
1418
1836
|
var anthropicTools = {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1837
|
+
/**
|
|
1838
|
+
* Creates a tool for running a bash command. Must have name "bash".
|
|
1839
|
+
*
|
|
1840
|
+
* Image results are supported.
|
|
1841
|
+
*
|
|
1842
|
+
* @param execute - The function to execute the tool. Optional.
|
|
1843
|
+
*/
|
|
1844
|
+
bash_20241022,
|
|
1845
|
+
/**
|
|
1846
|
+
* Creates a tool for running a bash command. Must have name "bash".
|
|
1847
|
+
*
|
|
1848
|
+
* Image results are supported.
|
|
1849
|
+
*
|
|
1850
|
+
* @param execute - The function to execute the tool. Optional.
|
|
1851
|
+
*/
|
|
1852
|
+
bash_20250124,
|
|
1853
|
+
/**
|
|
1854
|
+
* Creates a tool for editing text. Must have name "str_replace_editor".
|
|
1855
|
+
*/
|
|
1856
|
+
textEditor_20241022,
|
|
1857
|
+
/**
|
|
1858
|
+
* Creates a tool for editing text. Must have name "str_replace_editor".
|
|
1859
|
+
*/
|
|
1860
|
+
textEditor_20250124,
|
|
1861
|
+
/**
|
|
1862
|
+
* Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
|
|
1863
|
+
* Note: This version does not support the "undo_edit" command.
|
|
1864
|
+
*/
|
|
1865
|
+
textEditor_20250429,
|
|
1866
|
+
/**
|
|
1867
|
+
* Creates a tool for executing actions on a computer. Must have name "computer".
|
|
1868
|
+
*
|
|
1869
|
+
* Image results are supported.
|
|
1870
|
+
*
|
|
1871
|
+
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
1872
|
+
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
1873
|
+
* @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.
|
|
1874
|
+
*/
|
|
1875
|
+
computer_20241022,
|
|
1876
|
+
/**
|
|
1877
|
+
* Creates a tool for executing actions on a computer. Must have name "computer".
|
|
1878
|
+
*
|
|
1879
|
+
* Image results are supported.
|
|
1880
|
+
*
|
|
1881
|
+
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
1882
|
+
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
1883
|
+
* @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.
|
|
1884
|
+
* @param execute - The function to execute the tool. Optional.
|
|
1885
|
+
*/
|
|
1886
|
+
computer_20250124,
|
|
1887
|
+
/**
|
|
1888
|
+
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
1889
|
+
* Must have name "web_search".
|
|
1890
|
+
*
|
|
1891
|
+
* @param maxUses - Maximum number of web searches Claude can perform during the conversation.
|
|
1892
|
+
* @param allowedDomains - Optional list of domains that Claude is allowed to search.
|
|
1893
|
+
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
1894
|
+
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
1895
|
+
*/
|
|
1896
|
+
webSearch_20250305
|
|
1425
1897
|
};
|
|
1426
1898
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1427
1899
|
0 && (module.exports = {
|