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