@ai-sdk/anthropic 2.1.0-beta.1 → 2.1.0-beta.11
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 +88 -0
- package/dist/index.d.mts +114 -10
- package/dist/index.d.ts +114 -10
- package/dist/index.js +682 -389
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +665 -372
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +131 -15
- package/dist/internal/index.d.ts +131 -15
- package/dist/internal/index.js +662 -377
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +647 -362
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
VERSION: () => VERSION,
|
|
33
34
|
anthropic: () => anthropic,
|
|
34
35
|
createAnthropic: () => createAnthropic
|
|
35
36
|
});
|
|
@@ -37,12 +38,15 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
38
|
|
|
38
39
|
// src/anthropic-provider.ts
|
|
39
40
|
var import_provider4 = require("@ai-sdk/provider");
|
|
40
|
-
var
|
|
41
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
42
|
+
|
|
43
|
+
// src/version.ts
|
|
44
|
+
var VERSION = true ? "2.1.0-beta.11" : "0.0.0-test";
|
|
41
45
|
|
|
42
46
|
// src/anthropic-messages-language-model.ts
|
|
43
47
|
var import_provider3 = require("@ai-sdk/provider");
|
|
44
|
-
var
|
|
45
|
-
var
|
|
48
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
49
|
+
var import_v47 = require("zod/v4");
|
|
46
50
|
|
|
47
51
|
// src/anthropic-error.ts
|
|
48
52
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
@@ -116,58 +120,110 @@ function getCacheControl(providerMetadata) {
|
|
|
116
120
|
return cacheControlValue;
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
// src/tool/
|
|
123
|
+
// src/tool/text-editor_20250728.ts
|
|
120
124
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
121
125
|
var import_v43 = require("zod/v4");
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
126
|
+
var textEditor_20250728ArgsSchema = import_v43.z.object({
|
|
127
|
+
maxCharacters: import_v43.z.number().optional()
|
|
128
|
+
});
|
|
129
|
+
var factory = (0, import_provider_utils2.createProviderDefinedToolFactory)({
|
|
130
|
+
id: "anthropic.text_editor_20250728",
|
|
131
|
+
name: "str_replace_based_edit_tool",
|
|
132
|
+
inputSchema: import_v43.z.object({
|
|
133
|
+
command: import_v43.z.enum(["view", "create", "str_replace", "insert"]),
|
|
134
|
+
path: import_v43.z.string(),
|
|
135
|
+
file_text: import_v43.z.string().optional(),
|
|
136
|
+
insert_line: import_v43.z.number().int().optional(),
|
|
137
|
+
new_str: import_v43.z.string().optional(),
|
|
138
|
+
old_str: import_v43.z.string().optional(),
|
|
139
|
+
view_range: import_v43.z.array(import_v43.z.number().int()).optional()
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
var textEditor_20250728 = (args = {}) => {
|
|
143
|
+
return factory(args);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// src/tool/web-search_20250305.ts
|
|
147
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
148
|
+
var import_v44 = require("zod/v4");
|
|
149
|
+
var webSearch_20250305ArgsSchema = import_v44.z.object({
|
|
150
|
+
maxUses: import_v44.z.number().optional(),
|
|
151
|
+
allowedDomains: import_v44.z.array(import_v44.z.string()).optional(),
|
|
152
|
+
blockedDomains: import_v44.z.array(import_v44.z.string()).optional(),
|
|
153
|
+
userLocation: import_v44.z.object({
|
|
154
|
+
type: import_v44.z.literal("approximate"),
|
|
155
|
+
city: import_v44.z.string().optional(),
|
|
156
|
+
region: import_v44.z.string().optional(),
|
|
157
|
+
country: import_v44.z.string().optional(),
|
|
158
|
+
timezone: import_v44.z.string().optional()
|
|
144
159
|
}).optional()
|
|
145
160
|
});
|
|
146
|
-
var webSearch_20250305OutputSchema =
|
|
147
|
-
|
|
148
|
-
url:
|
|
149
|
-
title:
|
|
150
|
-
pageAge:
|
|
151
|
-
encryptedContent:
|
|
152
|
-
type:
|
|
161
|
+
var webSearch_20250305OutputSchema = import_v44.z.array(
|
|
162
|
+
import_v44.z.object({
|
|
163
|
+
url: import_v44.z.string(),
|
|
164
|
+
title: import_v44.z.string(),
|
|
165
|
+
pageAge: import_v44.z.string().nullable(),
|
|
166
|
+
encryptedContent: import_v44.z.string(),
|
|
167
|
+
type: import_v44.z.literal("web_search_result")
|
|
153
168
|
})
|
|
154
169
|
);
|
|
155
|
-
var
|
|
170
|
+
var factory2 = (0, import_provider_utils3.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
156
171
|
id: "anthropic.web_search_20250305",
|
|
157
172
|
name: "web_search",
|
|
158
|
-
inputSchema:
|
|
159
|
-
query:
|
|
173
|
+
inputSchema: import_v44.z.object({
|
|
174
|
+
query: import_v44.z.string()
|
|
160
175
|
}),
|
|
161
176
|
outputSchema: webSearch_20250305OutputSchema
|
|
162
177
|
});
|
|
163
178
|
var webSearch_20250305 = (args = {}) => {
|
|
164
|
-
return
|
|
179
|
+
return factory2(args);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/tool/web-fetch-20250910.ts
|
|
183
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
184
|
+
var import_v45 = require("zod/v4");
|
|
185
|
+
var webFetch_20250910ArgsSchema = import_v45.z.object({
|
|
186
|
+
maxUses: import_v45.z.number().optional(),
|
|
187
|
+
allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
|
|
188
|
+
blockedDomains: import_v45.z.array(import_v45.z.string()).optional(),
|
|
189
|
+
citations: import_v45.z.object({ enabled: import_v45.z.boolean() }).optional(),
|
|
190
|
+
maxContentTokens: import_v45.z.number().optional()
|
|
191
|
+
});
|
|
192
|
+
var webFetch_20250910OutputSchema = import_v45.z.object({
|
|
193
|
+
type: import_v45.z.literal("web_fetch_result"),
|
|
194
|
+
url: import_v45.z.string(),
|
|
195
|
+
content: import_v45.z.object({
|
|
196
|
+
type: import_v45.z.literal("document"),
|
|
197
|
+
title: import_v45.z.string(),
|
|
198
|
+
citations: import_v45.z.object({ enabled: import_v45.z.boolean() }).optional(),
|
|
199
|
+
source: import_v45.z.union([
|
|
200
|
+
import_v45.z.object({
|
|
201
|
+
type: import_v45.z.literal("base64"),
|
|
202
|
+
mediaType: import_v45.z.literal("application/pdf"),
|
|
203
|
+
data: import_v45.z.string()
|
|
204
|
+
}),
|
|
205
|
+
import_v45.z.object({
|
|
206
|
+
type: import_v45.z.literal("text"),
|
|
207
|
+
mediaType: import_v45.z.literal("text/plain"),
|
|
208
|
+
data: import_v45.z.string()
|
|
209
|
+
})
|
|
210
|
+
])
|
|
211
|
+
}),
|
|
212
|
+
retrievedAt: import_v45.z.string().nullable()
|
|
213
|
+
});
|
|
214
|
+
var factory3 = (0, import_provider_utils4.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
215
|
+
id: "anthropic.web_fetch_20250910",
|
|
216
|
+
name: "web_fetch",
|
|
217
|
+
inputSchema: import_v45.z.object({
|
|
218
|
+
url: import_v45.z.string()
|
|
219
|
+
}),
|
|
220
|
+
outputSchema: webFetch_20250910OutputSchema
|
|
221
|
+
});
|
|
222
|
+
var webFetch_20250910 = (args = {}) => {
|
|
223
|
+
return factory3(args);
|
|
165
224
|
};
|
|
166
225
|
|
|
167
226
|
// src/anthropic-prepare-tools.ts
|
|
168
|
-
function isWebSearchTool(tool) {
|
|
169
|
-
return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
|
|
170
|
-
}
|
|
171
227
|
function prepareTools({
|
|
172
228
|
tools,
|
|
173
229
|
toolChoice,
|
|
@@ -181,12 +237,8 @@ function prepareTools({
|
|
|
181
237
|
}
|
|
182
238
|
const anthropicTools2 = [];
|
|
183
239
|
for (const tool of tools) {
|
|
184
|
-
if (isWebSearchTool(tool)) {
|
|
185
|
-
anthropicTools2.push(tool);
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
240
|
switch (tool.type) {
|
|
189
|
-
case "function":
|
|
241
|
+
case "function": {
|
|
190
242
|
const cacheControl = getCacheControl(tool.providerOptions);
|
|
191
243
|
anthropicTools2.push({
|
|
192
244
|
name: tool.name,
|
|
@@ -195,9 +247,18 @@ function prepareTools({
|
|
|
195
247
|
cache_control: cacheControl
|
|
196
248
|
});
|
|
197
249
|
break;
|
|
198
|
-
|
|
250
|
+
}
|
|
251
|
+
case "provider-defined": {
|
|
199
252
|
switch (tool.id) {
|
|
200
|
-
case "anthropic.
|
|
253
|
+
case "anthropic.code_execution_20250522": {
|
|
254
|
+
betas.add("code-execution-2025-05-22");
|
|
255
|
+
anthropicTools2.push({
|
|
256
|
+
type: "code_execution_20250522",
|
|
257
|
+
name: "code_execution"
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case "anthropic.computer_20250124": {
|
|
201
262
|
betas.add("computer-use-2025-01-24");
|
|
202
263
|
anthropicTools2.push({
|
|
203
264
|
name: "computer",
|
|
@@ -207,7 +268,8 @@ function prepareTools({
|
|
|
207
268
|
display_number: tool.args.displayNumber
|
|
208
269
|
});
|
|
209
270
|
break;
|
|
210
|
-
|
|
271
|
+
}
|
|
272
|
+
case "anthropic.computer_20241022": {
|
|
211
273
|
betas.add("computer-use-2024-10-22");
|
|
212
274
|
anthropicTools2.push({
|
|
213
275
|
name: "computer",
|
|
@@ -217,41 +279,70 @@ function prepareTools({
|
|
|
217
279
|
display_number: tool.args.displayNumber
|
|
218
280
|
});
|
|
219
281
|
break;
|
|
220
|
-
|
|
282
|
+
}
|
|
283
|
+
case "anthropic.text_editor_20250124": {
|
|
221
284
|
betas.add("computer-use-2025-01-24");
|
|
222
285
|
anthropicTools2.push({
|
|
223
286
|
name: "str_replace_editor",
|
|
224
287
|
type: "text_editor_20250124"
|
|
225
288
|
});
|
|
226
289
|
break;
|
|
227
|
-
|
|
290
|
+
}
|
|
291
|
+
case "anthropic.text_editor_20241022": {
|
|
228
292
|
betas.add("computer-use-2024-10-22");
|
|
229
293
|
anthropicTools2.push({
|
|
230
294
|
name: "str_replace_editor",
|
|
231
295
|
type: "text_editor_20241022"
|
|
232
296
|
});
|
|
233
297
|
break;
|
|
234
|
-
|
|
298
|
+
}
|
|
299
|
+
case "anthropic.text_editor_20250429": {
|
|
235
300
|
betas.add("computer-use-2025-01-24");
|
|
236
301
|
anthropicTools2.push({
|
|
237
302
|
name: "str_replace_based_edit_tool",
|
|
238
303
|
type: "text_editor_20250429"
|
|
239
304
|
});
|
|
240
305
|
break;
|
|
241
|
-
|
|
306
|
+
}
|
|
307
|
+
case "anthropic.text_editor_20250728": {
|
|
308
|
+
const args = textEditor_20250728ArgsSchema.parse(tool.args);
|
|
309
|
+
anthropicTools2.push({
|
|
310
|
+
name: "str_replace_based_edit_tool",
|
|
311
|
+
type: "text_editor_20250728",
|
|
312
|
+
max_characters: args.maxCharacters
|
|
313
|
+
});
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
case "anthropic.bash_20250124": {
|
|
242
317
|
betas.add("computer-use-2025-01-24");
|
|
243
318
|
anthropicTools2.push({
|
|
244
319
|
name: "bash",
|
|
245
320
|
type: "bash_20250124"
|
|
246
321
|
});
|
|
247
322
|
break;
|
|
248
|
-
|
|
323
|
+
}
|
|
324
|
+
case "anthropic.bash_20241022": {
|
|
249
325
|
betas.add("computer-use-2024-10-22");
|
|
250
326
|
anthropicTools2.push({
|
|
251
327
|
name: "bash",
|
|
252
328
|
type: "bash_20241022"
|
|
253
329
|
});
|
|
254
330
|
break;
|
|
331
|
+
}
|
|
332
|
+
case "anthropic.web_fetch_20250910": {
|
|
333
|
+
betas.add("web-fetch-2025-09-10");
|
|
334
|
+
const args = webFetch_20250910ArgsSchema.parse(tool.args);
|
|
335
|
+
anthropicTools2.push({
|
|
336
|
+
type: "web_fetch_20250910",
|
|
337
|
+
name: "web_fetch",
|
|
338
|
+
max_uses: args.maxUses,
|
|
339
|
+
allowed_domains: args.allowedDomains,
|
|
340
|
+
blocked_domains: args.blockedDomains,
|
|
341
|
+
citations: args.citations,
|
|
342
|
+
max_content_tokens: args.maxContentTokens
|
|
343
|
+
});
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
255
346
|
case "anthropic.web_search_20250305": {
|
|
256
347
|
const args = webSearch_20250305ArgsSchema.parse(tool.args);
|
|
257
348
|
anthropicTools2.push({
|
|
@@ -264,22 +355,17 @@ function prepareTools({
|
|
|
264
355
|
});
|
|
265
356
|
break;
|
|
266
357
|
}
|
|
267
|
-
|
|
268
|
-
betas.add("code-execution-2025-05-22");
|
|
269
|
-
anthropicTools2.push({
|
|
270
|
-
type: "code_execution_20250522",
|
|
271
|
-
name: "code_execution"
|
|
272
|
-
});
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
default:
|
|
358
|
+
default: {
|
|
276
359
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
277
360
|
break;
|
|
361
|
+
}
|
|
278
362
|
}
|
|
279
363
|
break;
|
|
280
|
-
|
|
364
|
+
}
|
|
365
|
+
default: {
|
|
281
366
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
282
367
|
break;
|
|
368
|
+
}
|
|
283
369
|
}
|
|
284
370
|
}
|
|
285
371
|
if (toolChoice == null) {
|
|
@@ -336,27 +422,27 @@ function prepareTools({
|
|
|
336
422
|
|
|
337
423
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
338
424
|
var import_provider2 = require("@ai-sdk/provider");
|
|
339
|
-
var
|
|
425
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
340
426
|
|
|
341
427
|
// src/tool/code-execution_20250522.ts
|
|
342
|
-
var
|
|
343
|
-
var
|
|
344
|
-
var codeExecution_20250522OutputSchema =
|
|
345
|
-
type:
|
|
346
|
-
stdout:
|
|
347
|
-
stderr:
|
|
348
|
-
return_code:
|
|
428
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
429
|
+
var import_v46 = require("zod/v4");
|
|
430
|
+
var codeExecution_20250522OutputSchema = import_v46.z.object({
|
|
431
|
+
type: import_v46.z.literal("code_execution_result"),
|
|
432
|
+
stdout: import_v46.z.string(),
|
|
433
|
+
stderr: import_v46.z.string(),
|
|
434
|
+
return_code: import_v46.z.number()
|
|
349
435
|
});
|
|
350
|
-
var
|
|
436
|
+
var factory4 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
351
437
|
id: "anthropic.code_execution_20250522",
|
|
352
438
|
name: "code_execution",
|
|
353
|
-
inputSchema:
|
|
354
|
-
code:
|
|
439
|
+
inputSchema: import_v46.z.object({
|
|
440
|
+
code: import_v46.z.string()
|
|
355
441
|
}),
|
|
356
442
|
outputSchema: codeExecution_20250522OutputSchema
|
|
357
443
|
});
|
|
358
444
|
var codeExecution_20250522 = (args = {}) => {
|
|
359
|
-
return
|
|
445
|
+
return factory4(args);
|
|
360
446
|
};
|
|
361
447
|
|
|
362
448
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
@@ -381,14 +467,14 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
381
467
|
sendReasoning,
|
|
382
468
|
warnings
|
|
383
469
|
}) {
|
|
384
|
-
var _a, _b, _c, _d, _e;
|
|
470
|
+
var _a, _b, _c, _d, _e, _f;
|
|
385
471
|
const betas = /* @__PURE__ */ new Set();
|
|
386
472
|
const blocks = groupIntoBlocks(prompt);
|
|
387
473
|
let system = void 0;
|
|
388
474
|
const messages = [];
|
|
389
475
|
async function shouldEnableCitations(providerMetadata) {
|
|
390
476
|
var _a2, _b2;
|
|
391
|
-
const anthropicOptions = await (0,
|
|
477
|
+
const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
|
|
392
478
|
provider: "anthropic",
|
|
393
479
|
providerOptions: providerMetadata,
|
|
394
480
|
schema: anthropicFilePartProviderOptions
|
|
@@ -396,7 +482,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
396
482
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
397
483
|
}
|
|
398
484
|
async function getDocumentMetadata(providerMetadata) {
|
|
399
|
-
const anthropicOptions = await (0,
|
|
485
|
+
const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
|
|
400
486
|
provider: "anthropic",
|
|
401
487
|
providerOptions: providerMetadata,
|
|
402
488
|
schema: anthropicFilePartProviderOptions
|
|
@@ -453,7 +539,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
453
539
|
} : {
|
|
454
540
|
type: "base64",
|
|
455
541
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
456
|
-
data: (0,
|
|
542
|
+
data: (0, import_provider_utils6.convertToBase64)(part.data)
|
|
457
543
|
},
|
|
458
544
|
cache_control: cacheControl
|
|
459
545
|
});
|
|
@@ -473,7 +559,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
473
559
|
} : {
|
|
474
560
|
type: "base64",
|
|
475
561
|
media_type: "application/pdf",
|
|
476
|
-
data: (0,
|
|
562
|
+
data: (0, import_provider_utils6.convertToBase64)(part.data)
|
|
477
563
|
},
|
|
478
564
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
479
565
|
...metadata.context && { context: metadata.context },
|
|
@@ -557,6 +643,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
557
643
|
case "error-text":
|
|
558
644
|
contentValue = output.value;
|
|
559
645
|
break;
|
|
646
|
+
case "execution-denied":
|
|
647
|
+
contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
|
|
648
|
+
break;
|
|
560
649
|
case "json":
|
|
561
650
|
case "error-json":
|
|
562
651
|
default:
|
|
@@ -591,7 +680,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
591
680
|
for (let k = 0; k < content.length; k++) {
|
|
592
681
|
const part = content[k];
|
|
593
682
|
const isLastContentPart = k === content.length - 1;
|
|
594
|
-
const cacheControl = (
|
|
683
|
+
const cacheControl = (_f = getCacheControl(part.providerOptions)) != null ? _f : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
|
|
595
684
|
switch (part.type) {
|
|
596
685
|
case "text": {
|
|
597
686
|
anthropicContent.push({
|
|
@@ -608,7 +697,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
608
697
|
}
|
|
609
698
|
case "reasoning": {
|
|
610
699
|
if (sendReasoning) {
|
|
611
|
-
const reasoningMetadata = await (0,
|
|
700
|
+
const reasoningMetadata = await (0, import_provider_utils6.parseProviderOptions)({
|
|
612
701
|
provider: "anthropic",
|
|
613
702
|
providerOptions: part.providerOptions,
|
|
614
703
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -649,30 +738,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
649
738
|
}
|
|
650
739
|
case "tool-call": {
|
|
651
740
|
if (part.providerExecuted) {
|
|
652
|
-
if (part.toolName === "web_search") {
|
|
741
|
+
if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
653
742
|
anthropicContent.push({
|
|
654
743
|
type: "server_tool_use",
|
|
655
744
|
id: part.toolCallId,
|
|
656
|
-
name:
|
|
745
|
+
name: part.toolName,
|
|
657
746
|
input: part.input,
|
|
658
747
|
cache_control: cacheControl
|
|
659
748
|
});
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
type: "server_tool_use",
|
|
665
|
-
id: part.toolCallId,
|
|
666
|
-
name: "code_execution",
|
|
667
|
-
input: part.input,
|
|
668
|
-
cache_control: cacheControl
|
|
749
|
+
} else {
|
|
750
|
+
warnings.push({
|
|
751
|
+
type: "other",
|
|
752
|
+
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
669
753
|
});
|
|
670
|
-
break;
|
|
671
754
|
}
|
|
672
|
-
warnings.push({
|
|
673
|
-
type: "other",
|
|
674
|
-
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
675
|
-
});
|
|
676
755
|
break;
|
|
677
756
|
}
|
|
678
757
|
anthropicContent.push({
|
|
@@ -685,7 +764,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
685
764
|
break;
|
|
686
765
|
}
|
|
687
766
|
case "tool-result": {
|
|
688
|
-
if (part.toolName === "
|
|
767
|
+
if (part.toolName === "code_execution") {
|
|
689
768
|
const output = part.output;
|
|
690
769
|
if (output.type !== "json") {
|
|
691
770
|
warnings.push({
|
|
@@ -694,24 +773,21 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
694
773
|
});
|
|
695
774
|
break;
|
|
696
775
|
}
|
|
697
|
-
const
|
|
698
|
-
output.value
|
|
699
|
-
);
|
|
776
|
+
const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
|
|
700
777
|
anthropicContent.push({
|
|
701
|
-
type: "
|
|
778
|
+
type: "code_execution_tool_result",
|
|
702
779
|
tool_use_id: part.toolCallId,
|
|
703
|
-
content:
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
})),
|
|
780
|
+
content: {
|
|
781
|
+
type: codeExecutionOutput.type,
|
|
782
|
+
stdout: codeExecutionOutput.stdout,
|
|
783
|
+
stderr: codeExecutionOutput.stderr,
|
|
784
|
+
return_code: codeExecutionOutput.return_code
|
|
785
|
+
},
|
|
710
786
|
cache_control: cacheControl
|
|
711
787
|
});
|
|
712
788
|
break;
|
|
713
789
|
}
|
|
714
|
-
if (part.toolName === "
|
|
790
|
+
if (part.toolName === "web_fetch") {
|
|
715
791
|
const output = part.output;
|
|
716
792
|
if (output.type !== "json") {
|
|
717
793
|
warnings.push({
|
|
@@ -720,20 +796,57 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
720
796
|
});
|
|
721
797
|
break;
|
|
722
798
|
}
|
|
723
|
-
const
|
|
799
|
+
const webFetchOutput = webFetch_20250910OutputSchema.parse(
|
|
800
|
+
output.value
|
|
801
|
+
);
|
|
724
802
|
anthropicContent.push({
|
|
725
|
-
type: "
|
|
803
|
+
type: "web_fetch_tool_result",
|
|
726
804
|
tool_use_id: part.toolCallId,
|
|
727
805
|
content: {
|
|
728
|
-
type:
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
806
|
+
type: "web_fetch_result",
|
|
807
|
+
url: webFetchOutput.url,
|
|
808
|
+
retrieved_at: webFetchOutput.retrievedAt,
|
|
809
|
+
content: {
|
|
810
|
+
type: "document",
|
|
811
|
+
title: webFetchOutput.content.title,
|
|
812
|
+
citations: webFetchOutput.content.citations,
|
|
813
|
+
source: {
|
|
814
|
+
type: webFetchOutput.content.source.type,
|
|
815
|
+
media_type: webFetchOutput.content.source.mediaType,
|
|
816
|
+
data: webFetchOutput.content.source.data
|
|
817
|
+
}
|
|
818
|
+
}
|
|
732
819
|
},
|
|
733
820
|
cache_control: cacheControl
|
|
734
821
|
});
|
|
735
822
|
break;
|
|
736
823
|
}
|
|
824
|
+
if (part.toolName === "web_search") {
|
|
825
|
+
const output = part.output;
|
|
826
|
+
if (output.type !== "json") {
|
|
827
|
+
warnings.push({
|
|
828
|
+
type: "other",
|
|
829
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
830
|
+
});
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
const webSearchOutput = webSearch_20250305OutputSchema.parse(
|
|
834
|
+
output.value
|
|
835
|
+
);
|
|
836
|
+
anthropicContent.push({
|
|
837
|
+
type: "web_search_tool_result",
|
|
838
|
+
tool_use_id: part.toolCallId,
|
|
839
|
+
content: webSearchOutput.map((result) => ({
|
|
840
|
+
url: result.url,
|
|
841
|
+
title: result.title,
|
|
842
|
+
page_age: result.pageAge,
|
|
843
|
+
encrypted_content: result.encryptedContent,
|
|
844
|
+
type: result.type
|
|
845
|
+
})),
|
|
846
|
+
cache_control: cacheControl
|
|
847
|
+
});
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
737
850
|
warnings.push({
|
|
738
851
|
type: "other",
|
|
739
852
|
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
@@ -827,36 +940,36 @@ function mapAnthropicStopReason({
|
|
|
827
940
|
|
|
828
941
|
// src/anthropic-messages-language-model.ts
|
|
829
942
|
var citationSchemas = {
|
|
830
|
-
webSearchResult:
|
|
831
|
-
type:
|
|
832
|
-
cited_text:
|
|
833
|
-
url:
|
|
834
|
-
title:
|
|
835
|
-
encrypted_index:
|
|
943
|
+
webSearchResult: import_v47.z.object({
|
|
944
|
+
type: import_v47.z.literal("web_search_result_location"),
|
|
945
|
+
cited_text: import_v47.z.string(),
|
|
946
|
+
url: import_v47.z.string(),
|
|
947
|
+
title: import_v47.z.string(),
|
|
948
|
+
encrypted_index: import_v47.z.string()
|
|
836
949
|
}),
|
|
837
|
-
pageLocation:
|
|
838
|
-
type:
|
|
839
|
-
cited_text:
|
|
840
|
-
document_index:
|
|
841
|
-
document_title:
|
|
842
|
-
start_page_number:
|
|
843
|
-
end_page_number:
|
|
950
|
+
pageLocation: import_v47.z.object({
|
|
951
|
+
type: import_v47.z.literal("page_location"),
|
|
952
|
+
cited_text: import_v47.z.string(),
|
|
953
|
+
document_index: import_v47.z.number(),
|
|
954
|
+
document_title: import_v47.z.string().nullable(),
|
|
955
|
+
start_page_number: import_v47.z.number(),
|
|
956
|
+
end_page_number: import_v47.z.number()
|
|
844
957
|
}),
|
|
845
|
-
charLocation:
|
|
846
|
-
type:
|
|
847
|
-
cited_text:
|
|
848
|
-
document_index:
|
|
849
|
-
document_title:
|
|
850
|
-
start_char_index:
|
|
851
|
-
end_char_index:
|
|
958
|
+
charLocation: import_v47.z.object({
|
|
959
|
+
type: import_v47.z.literal("char_location"),
|
|
960
|
+
cited_text: import_v47.z.string(),
|
|
961
|
+
document_index: import_v47.z.number(),
|
|
962
|
+
document_title: import_v47.z.string().nullable(),
|
|
963
|
+
start_char_index: import_v47.z.number(),
|
|
964
|
+
end_char_index: import_v47.z.number()
|
|
852
965
|
})
|
|
853
966
|
};
|
|
854
|
-
var citationSchema =
|
|
967
|
+
var citationSchema = import_v47.z.discriminatedUnion("type", [
|
|
855
968
|
citationSchemas.webSearchResult,
|
|
856
969
|
citationSchemas.pageLocation,
|
|
857
970
|
citationSchemas.charLocation
|
|
858
971
|
]);
|
|
859
|
-
var documentCitationSchema =
|
|
972
|
+
var documentCitationSchema = import_v47.z.discriminatedUnion("type", [
|
|
860
973
|
citationSchemas.pageLocation,
|
|
861
974
|
citationSchemas.charLocation
|
|
862
975
|
]);
|
|
@@ -901,11 +1014,11 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
901
1014
|
}
|
|
902
1015
|
var AnthropicMessagesLanguageModel = class {
|
|
903
1016
|
constructor(modelId, config) {
|
|
904
|
-
this.specificationVersion = "
|
|
1017
|
+
this.specificationVersion = "v3";
|
|
905
1018
|
var _a;
|
|
906
1019
|
this.modelId = modelId;
|
|
907
1020
|
this.config = config;
|
|
908
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1021
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
|
|
909
1022
|
}
|
|
910
1023
|
supportsUrl(url) {
|
|
911
1024
|
return url.protocol === "https:";
|
|
@@ -974,7 +1087,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
974
1087
|
description: "Respond with a JSON object.",
|
|
975
1088
|
inputSchema: responseFormat.schema
|
|
976
1089
|
} : void 0;
|
|
977
|
-
const anthropicOptions = await (0,
|
|
1090
|
+
const anthropicOptions = await (0, import_provider_utils7.parseProviderOptions)({
|
|
978
1091
|
provider: "anthropic",
|
|
979
1092
|
providerOptions,
|
|
980
1093
|
schema: anthropicProviderOptions
|
|
@@ -1066,8 +1179,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1066
1179
|
betas,
|
|
1067
1180
|
headers
|
|
1068
1181
|
}) {
|
|
1069
|
-
return (0,
|
|
1070
|
-
await (0,
|
|
1182
|
+
return (0, import_provider_utils7.combineHeaders)(
|
|
1183
|
+
await (0, import_provider_utils7.resolve)(this.config.headers),
|
|
1071
1184
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
1072
1185
|
headers
|
|
1073
1186
|
);
|
|
@@ -1104,19 +1217,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1104
1217
|
});
|
|
1105
1218
|
}
|
|
1106
1219
|
async doGenerate(options) {
|
|
1107
|
-
var _a, _b, _c, _d, _e;
|
|
1220
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1108
1221
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1109
1222
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1110
1223
|
const {
|
|
1111
1224
|
responseHeaders,
|
|
1112
1225
|
value: response,
|
|
1113
1226
|
rawValue: rawResponse
|
|
1114
|
-
} = await (0,
|
|
1227
|
+
} = await (0, import_provider_utils7.postJsonToApi)({
|
|
1115
1228
|
url: this.buildRequestUrl(false),
|
|
1116
1229
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1117
1230
|
body: this.transformRequestBody(args),
|
|
1118
1231
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1119
|
-
successfulResponseHandler: (0,
|
|
1232
|
+
successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
|
|
1120
1233
|
anthropicMessagesResponseSchema
|
|
1121
1234
|
),
|
|
1122
1235
|
abortSignal: options.abortSignal,
|
|
@@ -1181,7 +1294,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1181
1294
|
break;
|
|
1182
1295
|
}
|
|
1183
1296
|
case "server_tool_use": {
|
|
1184
|
-
if (part.name === "web_search" || part.name === "code_execution") {
|
|
1297
|
+
if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
1185
1298
|
content.push({
|
|
1186
1299
|
type: "tool-call",
|
|
1187
1300
|
toolCallId: part.id,
|
|
@@ -1192,6 +1305,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1192
1305
|
}
|
|
1193
1306
|
break;
|
|
1194
1307
|
}
|
|
1308
|
+
case "web_fetch_tool_result": {
|
|
1309
|
+
if (part.content.type === "web_fetch_result") {
|
|
1310
|
+
content.push({
|
|
1311
|
+
type: "tool-result",
|
|
1312
|
+
toolCallId: part.tool_use_id,
|
|
1313
|
+
toolName: "web_fetch",
|
|
1314
|
+
result: {
|
|
1315
|
+
type: "web_fetch_result",
|
|
1316
|
+
url: part.content.url,
|
|
1317
|
+
retrievedAt: part.content.retrieved_at,
|
|
1318
|
+
content: {
|
|
1319
|
+
type: part.content.content.type,
|
|
1320
|
+
title: part.content.content.title,
|
|
1321
|
+
citations: part.content.content.citations,
|
|
1322
|
+
source: {
|
|
1323
|
+
type: part.content.content.source.type,
|
|
1324
|
+
mediaType: part.content.content.source.media_type,
|
|
1325
|
+
data: part.content.content.source.data
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
},
|
|
1329
|
+
providerExecuted: true
|
|
1330
|
+
});
|
|
1331
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1332
|
+
content.push({
|
|
1333
|
+
type: "tool-result",
|
|
1334
|
+
toolCallId: part.tool_use_id,
|
|
1335
|
+
toolName: "web_fetch",
|
|
1336
|
+
isError: true,
|
|
1337
|
+
result: {
|
|
1338
|
+
type: "web_fetch_tool_result_error",
|
|
1339
|
+
errorCode: part.content.error_code
|
|
1340
|
+
},
|
|
1341
|
+
providerExecuted: true
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
break;
|
|
1345
|
+
}
|
|
1195
1346
|
case "web_search_tool_result": {
|
|
1196
1347
|
if (Array.isArray(part.content)) {
|
|
1197
1348
|
content.push({
|
|
@@ -1293,7 +1444,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1293
1444
|
providerMetadata: {
|
|
1294
1445
|
anthropic: {
|
|
1295
1446
|
usage: response.usage,
|
|
1296
|
-
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
|
|
1447
|
+
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
|
|
1448
|
+
stopSequence: (_f = response.stop_sequence) != null ? _f : null
|
|
1297
1449
|
}
|
|
1298
1450
|
}
|
|
1299
1451
|
};
|
|
@@ -1302,12 +1454,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1302
1454
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1303
1455
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1304
1456
|
const body = { ...args, stream: true };
|
|
1305
|
-
const { responseHeaders, value: response } = await (0,
|
|
1457
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
|
|
1306
1458
|
url: this.buildRequestUrl(true),
|
|
1307
1459
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1308
1460
|
body: this.transformRequestBody(body),
|
|
1309
1461
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1310
|
-
successfulResponseHandler: (0,
|
|
1462
|
+
successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(
|
|
1311
1463
|
anthropicMessagesChunkSchema
|
|
1312
1464
|
),
|
|
1313
1465
|
abortSignal: options.abortSignal,
|
|
@@ -1320,7 +1472,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1320
1472
|
totalTokens: void 0
|
|
1321
1473
|
};
|
|
1322
1474
|
const contentBlocks = {};
|
|
1323
|
-
let
|
|
1475
|
+
let rawUsage = void 0;
|
|
1476
|
+
let cacheCreationInputTokens = null;
|
|
1477
|
+
let stopSequence = null;
|
|
1324
1478
|
let blockType = void 0;
|
|
1325
1479
|
const generateId3 = this.generateId;
|
|
1326
1480
|
return {
|
|
@@ -1330,7 +1484,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1330
1484
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1331
1485
|
},
|
|
1332
1486
|
transform(chunk, controller) {
|
|
1333
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1487
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1334
1488
|
if (options.includeRawChunks) {
|
|
1335
1489
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1336
1490
|
}
|
|
@@ -1393,7 +1547,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1393
1547
|
return;
|
|
1394
1548
|
}
|
|
1395
1549
|
case "server_tool_use": {
|
|
1396
|
-
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1550
|
+
if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1397
1551
|
contentBlocks[value.index] = {
|
|
1398
1552
|
type: "tool-call",
|
|
1399
1553
|
toolCallId: value.content_block.id,
|
|
@@ -1410,6 +1564,44 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1410
1564
|
}
|
|
1411
1565
|
return;
|
|
1412
1566
|
}
|
|
1567
|
+
case "web_fetch_tool_result": {
|
|
1568
|
+
const part = value.content_block;
|
|
1569
|
+
if (part.content.type === "web_fetch_result") {
|
|
1570
|
+
controller.enqueue({
|
|
1571
|
+
type: "tool-result",
|
|
1572
|
+
toolCallId: part.tool_use_id,
|
|
1573
|
+
toolName: "web_fetch",
|
|
1574
|
+
result: {
|
|
1575
|
+
type: "web_fetch_result",
|
|
1576
|
+
url: part.content.url,
|
|
1577
|
+
retrievedAt: part.content.retrieved_at,
|
|
1578
|
+
content: {
|
|
1579
|
+
type: part.content.content.type,
|
|
1580
|
+
title: part.content.content.title,
|
|
1581
|
+
citations: part.content.content.citations,
|
|
1582
|
+
source: {
|
|
1583
|
+
type: part.content.content.source.type,
|
|
1584
|
+
mediaType: part.content.content.source.media_type,
|
|
1585
|
+
data: part.content.content.source.data
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
1591
|
+
controller.enqueue({
|
|
1592
|
+
type: "tool-result",
|
|
1593
|
+
toolCallId: part.tool_use_id,
|
|
1594
|
+
toolName: "web_fetch",
|
|
1595
|
+
isError: true,
|
|
1596
|
+
result: {
|
|
1597
|
+
type: "web_fetch_tool_result_error",
|
|
1598
|
+
errorCode: part.content.error_code
|
|
1599
|
+
},
|
|
1600
|
+
providerExecuted: true
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1413
1605
|
case "web_search_tool_result": {
|
|
1414
1606
|
const part = value.content_block;
|
|
1415
1607
|
if (Array.isArray(part.content)) {
|
|
@@ -1612,12 +1804,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1612
1804
|
case "message_start": {
|
|
1613
1805
|
usage.inputTokens = value.message.usage.input_tokens;
|
|
1614
1806
|
usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
usage: value.message.usage,
|
|
1618
|
-
cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
|
|
1619
|
-
}
|
|
1807
|
+
rawUsage = {
|
|
1808
|
+
...value.message.usage
|
|
1620
1809
|
};
|
|
1810
|
+
cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
|
|
1621
1811
|
controller.enqueue({
|
|
1622
1812
|
type: "response-metadata",
|
|
1623
1813
|
id: (_d = value.message.id) != null ? _d : void 0,
|
|
@@ -1632,6 +1822,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1632
1822
|
finishReason: value.delta.stop_reason,
|
|
1633
1823
|
isJsonResponseFromTool: usesJsonResponseTool
|
|
1634
1824
|
});
|
|
1825
|
+
stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
|
|
1826
|
+
rawUsage = {
|
|
1827
|
+
...rawUsage,
|
|
1828
|
+
...value.usage
|
|
1829
|
+
};
|
|
1635
1830
|
return;
|
|
1636
1831
|
}
|
|
1637
1832
|
case "message_stop": {
|
|
@@ -1639,7 +1834,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1639
1834
|
type: "finish",
|
|
1640
1835
|
finishReason,
|
|
1641
1836
|
usage,
|
|
1642
|
-
providerMetadata
|
|
1837
|
+
providerMetadata: {
|
|
1838
|
+
anthropic: {
|
|
1839
|
+
usage: rawUsage != null ? rawUsage : null,
|
|
1840
|
+
cacheCreationInputTokens,
|
|
1841
|
+
stopSequence
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1643
1844
|
});
|
|
1644
1845
|
return;
|
|
1645
1846
|
}
|
|
@@ -1660,247 +1861,303 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1660
1861
|
};
|
|
1661
1862
|
}
|
|
1662
1863
|
};
|
|
1663
|
-
var anthropicMessagesResponseSchema =
|
|
1664
|
-
type:
|
|
1665
|
-
id:
|
|
1666
|
-
model:
|
|
1667
|
-
content:
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
type:
|
|
1671
|
-
text:
|
|
1672
|
-
citations:
|
|
1864
|
+
var anthropicMessagesResponseSchema = import_v47.z.object({
|
|
1865
|
+
type: import_v47.z.literal("message"),
|
|
1866
|
+
id: import_v47.z.string().nullish(),
|
|
1867
|
+
model: import_v47.z.string().nullish(),
|
|
1868
|
+
content: import_v47.z.array(
|
|
1869
|
+
import_v47.z.discriminatedUnion("type", [
|
|
1870
|
+
import_v47.z.object({
|
|
1871
|
+
type: import_v47.z.literal("text"),
|
|
1872
|
+
text: import_v47.z.string(),
|
|
1873
|
+
citations: import_v47.z.array(citationSchema).optional()
|
|
1673
1874
|
}),
|
|
1674
|
-
|
|
1675
|
-
type:
|
|
1676
|
-
thinking:
|
|
1677
|
-
signature:
|
|
1875
|
+
import_v47.z.object({
|
|
1876
|
+
type: import_v47.z.literal("thinking"),
|
|
1877
|
+
thinking: import_v47.z.string(),
|
|
1878
|
+
signature: import_v47.z.string()
|
|
1678
1879
|
}),
|
|
1679
|
-
|
|
1680
|
-
type:
|
|
1681
|
-
data:
|
|
1880
|
+
import_v47.z.object({
|
|
1881
|
+
type: import_v47.z.literal("redacted_thinking"),
|
|
1882
|
+
data: import_v47.z.string()
|
|
1682
1883
|
}),
|
|
1683
|
-
|
|
1684
|
-
type:
|
|
1685
|
-
id:
|
|
1686
|
-
name:
|
|
1687
|
-
input:
|
|
1884
|
+
import_v47.z.object({
|
|
1885
|
+
type: import_v47.z.literal("tool_use"),
|
|
1886
|
+
id: import_v47.z.string(),
|
|
1887
|
+
name: import_v47.z.string(),
|
|
1888
|
+
input: import_v47.z.unknown()
|
|
1688
1889
|
}),
|
|
1689
|
-
|
|
1690
|
-
type:
|
|
1691
|
-
id:
|
|
1692
|
-
name:
|
|
1693
|
-
input:
|
|
1890
|
+
import_v47.z.object({
|
|
1891
|
+
type: import_v47.z.literal("server_tool_use"),
|
|
1892
|
+
id: import_v47.z.string(),
|
|
1893
|
+
name: import_v47.z.string(),
|
|
1894
|
+
input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
|
|
1694
1895
|
}),
|
|
1695
|
-
|
|
1696
|
-
type:
|
|
1697
|
-
tool_use_id:
|
|
1698
|
-
content:
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1896
|
+
import_v47.z.object({
|
|
1897
|
+
type: import_v47.z.literal("web_fetch_tool_result"),
|
|
1898
|
+
tool_use_id: import_v47.z.string(),
|
|
1899
|
+
content: import_v47.z.union([
|
|
1900
|
+
import_v47.z.object({
|
|
1901
|
+
type: import_v47.z.literal("web_fetch_result"),
|
|
1902
|
+
url: import_v47.z.string(),
|
|
1903
|
+
retrieved_at: import_v47.z.string(),
|
|
1904
|
+
content: import_v47.z.object({
|
|
1905
|
+
type: import_v47.z.literal("document"),
|
|
1906
|
+
title: import_v47.z.string().nullable(),
|
|
1907
|
+
citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
|
|
1908
|
+
source: import_v47.z.object({
|
|
1909
|
+
type: import_v47.z.literal("text"),
|
|
1910
|
+
media_type: import_v47.z.string(),
|
|
1911
|
+
data: import_v47.z.string()
|
|
1912
|
+
})
|
|
1913
|
+
})
|
|
1914
|
+
}),
|
|
1915
|
+
import_v47.z.object({
|
|
1916
|
+
type: import_v47.z.literal("web_fetch_tool_result_error"),
|
|
1917
|
+
error_code: import_v47.z.string()
|
|
1918
|
+
})
|
|
1919
|
+
])
|
|
1920
|
+
}),
|
|
1921
|
+
import_v47.z.object({
|
|
1922
|
+
type: import_v47.z.literal("web_search_tool_result"),
|
|
1923
|
+
tool_use_id: import_v47.z.string(),
|
|
1924
|
+
content: import_v47.z.union([
|
|
1925
|
+
import_v47.z.array(
|
|
1926
|
+
import_v47.z.object({
|
|
1927
|
+
type: import_v47.z.literal("web_search_result"),
|
|
1928
|
+
url: import_v47.z.string(),
|
|
1929
|
+
title: import_v47.z.string(),
|
|
1930
|
+
encrypted_content: import_v47.z.string(),
|
|
1931
|
+
page_age: import_v47.z.string().nullish()
|
|
1706
1932
|
})
|
|
1707
1933
|
),
|
|
1708
|
-
|
|
1709
|
-
type:
|
|
1710
|
-
error_code:
|
|
1934
|
+
import_v47.z.object({
|
|
1935
|
+
type: import_v47.z.literal("web_search_tool_result_error"),
|
|
1936
|
+
error_code: import_v47.z.string()
|
|
1711
1937
|
})
|
|
1712
1938
|
])
|
|
1713
1939
|
}),
|
|
1714
|
-
|
|
1715
|
-
type:
|
|
1716
|
-
tool_use_id:
|
|
1717
|
-
content:
|
|
1718
|
-
|
|
1719
|
-
type:
|
|
1720
|
-
stdout:
|
|
1721
|
-
stderr:
|
|
1722
|
-
return_code:
|
|
1940
|
+
import_v47.z.object({
|
|
1941
|
+
type: import_v47.z.literal("code_execution_tool_result"),
|
|
1942
|
+
tool_use_id: import_v47.z.string(),
|
|
1943
|
+
content: import_v47.z.union([
|
|
1944
|
+
import_v47.z.object({
|
|
1945
|
+
type: import_v47.z.literal("code_execution_result"),
|
|
1946
|
+
stdout: import_v47.z.string(),
|
|
1947
|
+
stderr: import_v47.z.string(),
|
|
1948
|
+
return_code: import_v47.z.number()
|
|
1723
1949
|
}),
|
|
1724
|
-
|
|
1725
|
-
type:
|
|
1726
|
-
error_code:
|
|
1950
|
+
import_v47.z.object({
|
|
1951
|
+
type: import_v47.z.literal("code_execution_tool_result_error"),
|
|
1952
|
+
error_code: import_v47.z.string()
|
|
1727
1953
|
})
|
|
1728
1954
|
])
|
|
1729
1955
|
})
|
|
1730
1956
|
])
|
|
1731
1957
|
),
|
|
1732
|
-
stop_reason:
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1958
|
+
stop_reason: import_v47.z.string().nullish(),
|
|
1959
|
+
stop_sequence: import_v47.z.string().nullish(),
|
|
1960
|
+
usage: import_v47.z.looseObject({
|
|
1961
|
+
input_tokens: import_v47.z.number(),
|
|
1962
|
+
output_tokens: import_v47.z.number(),
|
|
1963
|
+
cache_creation_input_tokens: import_v47.z.number().nullish(),
|
|
1964
|
+
cache_read_input_tokens: import_v47.z.number().nullish()
|
|
1738
1965
|
})
|
|
1739
1966
|
});
|
|
1740
|
-
var anthropicMessagesChunkSchema =
|
|
1741
|
-
|
|
1742
|
-
type:
|
|
1743
|
-
message:
|
|
1744
|
-
id:
|
|
1745
|
-
model:
|
|
1746
|
-
usage:
|
|
1747
|
-
input_tokens:
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
cache_read_input_tokens: import_v45.z.number().nullish()
|
|
1967
|
+
var anthropicMessagesChunkSchema = import_v47.z.discriminatedUnion("type", [
|
|
1968
|
+
import_v47.z.object({
|
|
1969
|
+
type: import_v47.z.literal("message_start"),
|
|
1970
|
+
message: import_v47.z.object({
|
|
1971
|
+
id: import_v47.z.string().nullish(),
|
|
1972
|
+
model: import_v47.z.string().nullish(),
|
|
1973
|
+
usage: import_v47.z.looseObject({
|
|
1974
|
+
input_tokens: import_v47.z.number(),
|
|
1975
|
+
cache_creation_input_tokens: import_v47.z.number().nullish(),
|
|
1976
|
+
cache_read_input_tokens: import_v47.z.number().nullish()
|
|
1751
1977
|
})
|
|
1752
1978
|
})
|
|
1753
1979
|
}),
|
|
1754
|
-
|
|
1755
|
-
type:
|
|
1756
|
-
index:
|
|
1757
|
-
content_block:
|
|
1758
|
-
|
|
1759
|
-
type:
|
|
1760
|
-
text:
|
|
1980
|
+
import_v47.z.object({
|
|
1981
|
+
type: import_v47.z.literal("content_block_start"),
|
|
1982
|
+
index: import_v47.z.number(),
|
|
1983
|
+
content_block: import_v47.z.discriminatedUnion("type", [
|
|
1984
|
+
import_v47.z.object({
|
|
1985
|
+
type: import_v47.z.literal("text"),
|
|
1986
|
+
text: import_v47.z.string()
|
|
1761
1987
|
}),
|
|
1762
|
-
|
|
1763
|
-
type:
|
|
1764
|
-
thinking:
|
|
1988
|
+
import_v47.z.object({
|
|
1989
|
+
type: import_v47.z.literal("thinking"),
|
|
1990
|
+
thinking: import_v47.z.string()
|
|
1765
1991
|
}),
|
|
1766
|
-
|
|
1767
|
-
type:
|
|
1768
|
-
id:
|
|
1769
|
-
name:
|
|
1992
|
+
import_v47.z.object({
|
|
1993
|
+
type: import_v47.z.literal("tool_use"),
|
|
1994
|
+
id: import_v47.z.string(),
|
|
1995
|
+
name: import_v47.z.string()
|
|
1770
1996
|
}),
|
|
1771
|
-
|
|
1772
|
-
type:
|
|
1773
|
-
data:
|
|
1997
|
+
import_v47.z.object({
|
|
1998
|
+
type: import_v47.z.literal("redacted_thinking"),
|
|
1999
|
+
data: import_v47.z.string()
|
|
1774
2000
|
}),
|
|
1775
|
-
|
|
1776
|
-
type:
|
|
1777
|
-
id:
|
|
1778
|
-
name:
|
|
1779
|
-
input:
|
|
2001
|
+
import_v47.z.object({
|
|
2002
|
+
type: import_v47.z.literal("server_tool_use"),
|
|
2003
|
+
id: import_v47.z.string(),
|
|
2004
|
+
name: import_v47.z.string(),
|
|
2005
|
+
input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
|
|
1780
2006
|
}),
|
|
1781
|
-
|
|
1782
|
-
type:
|
|
1783
|
-
tool_use_id:
|
|
1784
|
-
content:
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2007
|
+
import_v47.z.object({
|
|
2008
|
+
type: import_v47.z.literal("web_fetch_tool_result"),
|
|
2009
|
+
tool_use_id: import_v47.z.string(),
|
|
2010
|
+
content: import_v47.z.union([
|
|
2011
|
+
import_v47.z.object({
|
|
2012
|
+
type: import_v47.z.literal("web_fetch_result"),
|
|
2013
|
+
url: import_v47.z.string(),
|
|
2014
|
+
retrieved_at: import_v47.z.string(),
|
|
2015
|
+
content: import_v47.z.object({
|
|
2016
|
+
type: import_v47.z.literal("document"),
|
|
2017
|
+
title: import_v47.z.string().nullable(),
|
|
2018
|
+
citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
|
|
2019
|
+
source: import_v47.z.object({
|
|
2020
|
+
type: import_v47.z.literal("text"),
|
|
2021
|
+
media_type: import_v47.z.string(),
|
|
2022
|
+
data: import_v47.z.string()
|
|
2023
|
+
})
|
|
2024
|
+
})
|
|
2025
|
+
}),
|
|
2026
|
+
import_v47.z.object({
|
|
2027
|
+
type: import_v47.z.literal("web_fetch_tool_result_error"),
|
|
2028
|
+
error_code: import_v47.z.string()
|
|
2029
|
+
})
|
|
2030
|
+
])
|
|
2031
|
+
}),
|
|
2032
|
+
import_v47.z.object({
|
|
2033
|
+
type: import_v47.z.literal("web_search_tool_result"),
|
|
2034
|
+
tool_use_id: import_v47.z.string(),
|
|
2035
|
+
content: import_v47.z.union([
|
|
2036
|
+
import_v47.z.array(
|
|
2037
|
+
import_v47.z.object({
|
|
2038
|
+
type: import_v47.z.literal("web_search_result"),
|
|
2039
|
+
url: import_v47.z.string(),
|
|
2040
|
+
title: import_v47.z.string(),
|
|
2041
|
+
encrypted_content: import_v47.z.string(),
|
|
2042
|
+
page_age: import_v47.z.string().nullish()
|
|
1792
2043
|
})
|
|
1793
2044
|
),
|
|
1794
|
-
|
|
1795
|
-
type:
|
|
1796
|
-
error_code:
|
|
2045
|
+
import_v47.z.object({
|
|
2046
|
+
type: import_v47.z.literal("web_search_tool_result_error"),
|
|
2047
|
+
error_code: import_v47.z.string()
|
|
1797
2048
|
})
|
|
1798
2049
|
])
|
|
1799
2050
|
}),
|
|
1800
|
-
|
|
1801
|
-
type:
|
|
1802
|
-
tool_use_id:
|
|
1803
|
-
content:
|
|
1804
|
-
|
|
1805
|
-
type:
|
|
1806
|
-
stdout:
|
|
1807
|
-
stderr:
|
|
1808
|
-
return_code:
|
|
2051
|
+
import_v47.z.object({
|
|
2052
|
+
type: import_v47.z.literal("code_execution_tool_result"),
|
|
2053
|
+
tool_use_id: import_v47.z.string(),
|
|
2054
|
+
content: import_v47.z.union([
|
|
2055
|
+
import_v47.z.object({
|
|
2056
|
+
type: import_v47.z.literal("code_execution_result"),
|
|
2057
|
+
stdout: import_v47.z.string(),
|
|
2058
|
+
stderr: import_v47.z.string(),
|
|
2059
|
+
return_code: import_v47.z.number()
|
|
1809
2060
|
}),
|
|
1810
|
-
|
|
1811
|
-
type:
|
|
1812
|
-
error_code:
|
|
2061
|
+
import_v47.z.object({
|
|
2062
|
+
type: import_v47.z.literal("code_execution_tool_result_error"),
|
|
2063
|
+
error_code: import_v47.z.string()
|
|
1813
2064
|
})
|
|
1814
2065
|
])
|
|
1815
2066
|
})
|
|
1816
2067
|
])
|
|
1817
2068
|
}),
|
|
1818
|
-
|
|
1819
|
-
type:
|
|
1820
|
-
index:
|
|
1821
|
-
delta:
|
|
1822
|
-
|
|
1823
|
-
type:
|
|
1824
|
-
partial_json:
|
|
2069
|
+
import_v47.z.object({
|
|
2070
|
+
type: import_v47.z.literal("content_block_delta"),
|
|
2071
|
+
index: import_v47.z.number(),
|
|
2072
|
+
delta: import_v47.z.discriminatedUnion("type", [
|
|
2073
|
+
import_v47.z.object({
|
|
2074
|
+
type: import_v47.z.literal("input_json_delta"),
|
|
2075
|
+
partial_json: import_v47.z.string()
|
|
1825
2076
|
}),
|
|
1826
|
-
|
|
1827
|
-
type:
|
|
1828
|
-
text:
|
|
2077
|
+
import_v47.z.object({
|
|
2078
|
+
type: import_v47.z.literal("text_delta"),
|
|
2079
|
+
text: import_v47.z.string()
|
|
1829
2080
|
}),
|
|
1830
|
-
|
|
1831
|
-
type:
|
|
1832
|
-
thinking:
|
|
2081
|
+
import_v47.z.object({
|
|
2082
|
+
type: import_v47.z.literal("thinking_delta"),
|
|
2083
|
+
thinking: import_v47.z.string()
|
|
1833
2084
|
}),
|
|
1834
|
-
|
|
1835
|
-
type:
|
|
1836
|
-
signature:
|
|
2085
|
+
import_v47.z.object({
|
|
2086
|
+
type: import_v47.z.literal("signature_delta"),
|
|
2087
|
+
signature: import_v47.z.string()
|
|
1837
2088
|
}),
|
|
1838
|
-
|
|
1839
|
-
type:
|
|
2089
|
+
import_v47.z.object({
|
|
2090
|
+
type: import_v47.z.literal("citations_delta"),
|
|
1840
2091
|
citation: citationSchema
|
|
1841
2092
|
})
|
|
1842
2093
|
])
|
|
1843
2094
|
}),
|
|
1844
|
-
|
|
1845
|
-
type:
|
|
1846
|
-
index:
|
|
2095
|
+
import_v47.z.object({
|
|
2096
|
+
type: import_v47.z.literal("content_block_stop"),
|
|
2097
|
+
index: import_v47.z.number()
|
|
1847
2098
|
}),
|
|
1848
|
-
|
|
1849
|
-
type:
|
|
1850
|
-
error:
|
|
1851
|
-
type:
|
|
1852
|
-
message:
|
|
2099
|
+
import_v47.z.object({
|
|
2100
|
+
type: import_v47.z.literal("error"),
|
|
2101
|
+
error: import_v47.z.object({
|
|
2102
|
+
type: import_v47.z.string(),
|
|
2103
|
+
message: import_v47.z.string()
|
|
1853
2104
|
})
|
|
1854
2105
|
}),
|
|
1855
|
-
|
|
1856
|
-
type:
|
|
1857
|
-
delta:
|
|
1858
|
-
|
|
2106
|
+
import_v47.z.object({
|
|
2107
|
+
type: import_v47.z.literal("message_delta"),
|
|
2108
|
+
delta: import_v47.z.object({
|
|
2109
|
+
stop_reason: import_v47.z.string().nullish(),
|
|
2110
|
+
stop_sequence: import_v47.z.string().nullish()
|
|
2111
|
+
}),
|
|
2112
|
+
usage: import_v47.z.looseObject({
|
|
2113
|
+
output_tokens: import_v47.z.number(),
|
|
2114
|
+
cache_creation_input_tokens: import_v47.z.number().nullish()
|
|
2115
|
+
})
|
|
1859
2116
|
}),
|
|
1860
|
-
|
|
1861
|
-
type:
|
|
2117
|
+
import_v47.z.object({
|
|
2118
|
+
type: import_v47.z.literal("message_stop")
|
|
1862
2119
|
}),
|
|
1863
|
-
|
|
1864
|
-
type:
|
|
2120
|
+
import_v47.z.object({
|
|
2121
|
+
type: import_v47.z.literal("ping")
|
|
1865
2122
|
})
|
|
1866
2123
|
]);
|
|
1867
|
-
var anthropicReasoningMetadataSchema =
|
|
1868
|
-
signature:
|
|
1869
|
-
redactedData:
|
|
2124
|
+
var anthropicReasoningMetadataSchema = import_v47.z.object({
|
|
2125
|
+
signature: import_v47.z.string().optional(),
|
|
2126
|
+
redactedData: import_v47.z.string().optional()
|
|
1870
2127
|
});
|
|
1871
2128
|
|
|
1872
2129
|
// src/tool/bash_20241022.ts
|
|
1873
|
-
var
|
|
1874
|
-
var
|
|
1875
|
-
var bash_20241022 = (0,
|
|
2130
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
2131
|
+
var import_v48 = __toESM(require("zod/v4"));
|
|
2132
|
+
var bash_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1876
2133
|
id: "anthropic.bash_20241022",
|
|
1877
2134
|
name: "bash",
|
|
1878
|
-
inputSchema:
|
|
1879
|
-
command:
|
|
1880
|
-
restart:
|
|
2135
|
+
inputSchema: import_v48.default.object({
|
|
2136
|
+
command: import_v48.default.string(),
|
|
2137
|
+
restart: import_v48.default.boolean().optional()
|
|
1881
2138
|
})
|
|
1882
2139
|
});
|
|
1883
2140
|
|
|
1884
2141
|
// src/tool/bash_20250124.ts
|
|
1885
|
-
var
|
|
1886
|
-
var
|
|
1887
|
-
var bash_20250124 = (0,
|
|
2142
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
2143
|
+
var import_v49 = __toESM(require("zod/v4"));
|
|
2144
|
+
var bash_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1888
2145
|
id: "anthropic.bash_20250124",
|
|
1889
2146
|
name: "bash",
|
|
1890
|
-
inputSchema:
|
|
1891
|
-
command:
|
|
1892
|
-
restart:
|
|
2147
|
+
inputSchema: import_v49.default.object({
|
|
2148
|
+
command: import_v49.default.string(),
|
|
2149
|
+
restart: import_v49.default.boolean().optional()
|
|
1893
2150
|
})
|
|
1894
2151
|
});
|
|
1895
2152
|
|
|
1896
2153
|
// src/tool/computer_20241022.ts
|
|
1897
|
-
var
|
|
1898
|
-
var
|
|
1899
|
-
var computer_20241022 = (0,
|
|
2154
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
2155
|
+
var import_v410 = require("zod/v4");
|
|
2156
|
+
var computer_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1900
2157
|
id: "anthropic.computer_20241022",
|
|
1901
2158
|
name: "computer",
|
|
1902
|
-
inputSchema:
|
|
1903
|
-
action:
|
|
2159
|
+
inputSchema: import_v410.z.object({
|
|
2160
|
+
action: import_v410.z.enum([
|
|
1904
2161
|
"key",
|
|
1905
2162
|
"type",
|
|
1906
2163
|
"mouse_move",
|
|
@@ -1912,19 +2169,19 @@ var computer_20241022 = (0, import_provider_utils8.createProviderDefinedToolFact
|
|
|
1912
2169
|
"screenshot",
|
|
1913
2170
|
"cursor_position"
|
|
1914
2171
|
]),
|
|
1915
|
-
coordinate:
|
|
1916
|
-
text:
|
|
2172
|
+
coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
|
|
2173
|
+
text: import_v410.z.string().optional()
|
|
1917
2174
|
})
|
|
1918
2175
|
});
|
|
1919
2176
|
|
|
1920
2177
|
// src/tool/computer_20250124.ts
|
|
1921
|
-
var
|
|
1922
|
-
var
|
|
1923
|
-
var computer_20250124 = (0,
|
|
2178
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
2179
|
+
var import_v411 = require("zod/v4");
|
|
2180
|
+
var computer_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1924
2181
|
id: "anthropic.computer_20250124",
|
|
1925
2182
|
name: "computer",
|
|
1926
|
-
inputSchema:
|
|
1927
|
-
action:
|
|
2183
|
+
inputSchema: import_v411.z.object({
|
|
2184
|
+
action: import_v411.z.enum([
|
|
1928
2185
|
"key",
|
|
1929
2186
|
"hold_key",
|
|
1930
2187
|
"type",
|
|
@@ -1942,63 +2199,63 @@ var computer_20250124 = (0, import_provider_utils9.createProviderDefinedToolFact
|
|
|
1942
2199
|
"wait",
|
|
1943
2200
|
"screenshot"
|
|
1944
2201
|
]),
|
|
1945
|
-
coordinate:
|
|
1946
|
-
duration:
|
|
1947
|
-
scroll_amount:
|
|
1948
|
-
scroll_direction:
|
|
1949
|
-
start_coordinate:
|
|
1950
|
-
text:
|
|
2202
|
+
coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
|
|
2203
|
+
duration: import_v411.z.number().optional(),
|
|
2204
|
+
scroll_amount: import_v411.z.number().optional(),
|
|
2205
|
+
scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
|
|
2206
|
+
start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
|
|
2207
|
+
text: import_v411.z.string().optional()
|
|
1951
2208
|
})
|
|
1952
2209
|
});
|
|
1953
2210
|
|
|
1954
2211
|
// src/tool/text-editor_20241022.ts
|
|
1955
|
-
var
|
|
1956
|
-
var
|
|
1957
|
-
var textEditor_20241022 = (0,
|
|
2212
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2213
|
+
var import_v412 = require("zod/v4");
|
|
2214
|
+
var textEditor_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
1958
2215
|
id: "anthropic.text_editor_20241022",
|
|
1959
2216
|
name: "str_replace_editor",
|
|
1960
|
-
inputSchema:
|
|
1961
|
-
command:
|
|
1962
|
-
path:
|
|
1963
|
-
file_text:
|
|
1964
|
-
insert_line:
|
|
1965
|
-
new_str:
|
|
1966
|
-
old_str:
|
|
1967
|
-
view_range:
|
|
2217
|
+
inputSchema: import_v412.z.object({
|
|
2218
|
+
command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2219
|
+
path: import_v412.z.string(),
|
|
2220
|
+
file_text: import_v412.z.string().optional(),
|
|
2221
|
+
insert_line: import_v412.z.number().int().optional(),
|
|
2222
|
+
new_str: import_v412.z.string().optional(),
|
|
2223
|
+
old_str: import_v412.z.string().optional(),
|
|
2224
|
+
view_range: import_v412.z.array(import_v412.z.number().int()).optional()
|
|
1968
2225
|
})
|
|
1969
2226
|
});
|
|
1970
2227
|
|
|
1971
2228
|
// src/tool/text-editor_20250124.ts
|
|
1972
|
-
var
|
|
1973
|
-
var
|
|
1974
|
-
var textEditor_20250124 = (0,
|
|
2229
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2230
|
+
var import_v413 = require("zod/v4");
|
|
2231
|
+
var textEditor_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
1975
2232
|
id: "anthropic.text_editor_20250124",
|
|
1976
2233
|
name: "str_replace_editor",
|
|
1977
|
-
inputSchema:
|
|
1978
|
-
command:
|
|
1979
|
-
path:
|
|
1980
|
-
file_text:
|
|
1981
|
-
insert_line:
|
|
1982
|
-
new_str:
|
|
1983
|
-
old_str:
|
|
1984
|
-
view_range:
|
|
2234
|
+
inputSchema: import_v413.z.object({
|
|
2235
|
+
command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2236
|
+
path: import_v413.z.string(),
|
|
2237
|
+
file_text: import_v413.z.string().optional(),
|
|
2238
|
+
insert_line: import_v413.z.number().int().optional(),
|
|
2239
|
+
new_str: import_v413.z.string().optional(),
|
|
2240
|
+
old_str: import_v413.z.string().optional(),
|
|
2241
|
+
view_range: import_v413.z.array(import_v413.z.number().int()).optional()
|
|
1985
2242
|
})
|
|
1986
2243
|
});
|
|
1987
2244
|
|
|
1988
2245
|
// src/tool/text-editor_20250429.ts
|
|
1989
|
-
var
|
|
1990
|
-
var
|
|
1991
|
-
var textEditor_20250429 = (0,
|
|
2246
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2247
|
+
var import_v414 = require("zod/v4");
|
|
2248
|
+
var textEditor_20250429 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
1992
2249
|
id: "anthropic.text_editor_20250429",
|
|
1993
2250
|
name: "str_replace_based_edit_tool",
|
|
1994
|
-
inputSchema:
|
|
1995
|
-
command:
|
|
1996
|
-
path:
|
|
1997
|
-
file_text:
|
|
1998
|
-
insert_line:
|
|
1999
|
-
new_str:
|
|
2000
|
-
old_str:
|
|
2001
|
-
view_range:
|
|
2251
|
+
inputSchema: import_v414.z.object({
|
|
2252
|
+
command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
|
|
2253
|
+
path: import_v414.z.string(),
|
|
2254
|
+
file_text: import_v414.z.string().optional(),
|
|
2255
|
+
insert_line: import_v414.z.number().int().optional(),
|
|
2256
|
+
new_str: import_v414.z.string().optional(),
|
|
2257
|
+
old_str: import_v414.z.string().optional(),
|
|
2258
|
+
view_range: import_v414.z.array(import_v414.z.number().int()).optional()
|
|
2002
2259
|
})
|
|
2003
2260
|
});
|
|
2004
2261
|
|
|
@@ -2064,6 +2321,8 @@ var anthropicTools = {
|
|
|
2064
2321
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2065
2322
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2066
2323
|
*
|
|
2324
|
+
* Supported models: Claude Sonnet 3.5
|
|
2325
|
+
*
|
|
2067
2326
|
* Tool name must be `str_replace_editor`.
|
|
2068
2327
|
*/
|
|
2069
2328
|
textEditor_20241022,
|
|
@@ -2072,6 +2331,8 @@ var anthropicTools = {
|
|
|
2072
2331
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2073
2332
|
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2074
2333
|
*
|
|
2334
|
+
* Supported models: Claude Sonnet 3.7
|
|
2335
|
+
*
|
|
2075
2336
|
* Tool name must be `str_replace_editor`.
|
|
2076
2337
|
*/
|
|
2077
2338
|
textEditor_20250124,
|
|
@@ -2083,8 +2344,36 @@ var anthropicTools = {
|
|
|
2083
2344
|
* Note: This version does not support the "undo_edit" command.
|
|
2084
2345
|
*
|
|
2085
2346
|
* Tool name must be `str_replace_based_edit_tool`.
|
|
2347
|
+
*
|
|
2348
|
+
* @deprecated Use textEditor_20250728 instead
|
|
2086
2349
|
*/
|
|
2087
2350
|
textEditor_20250429,
|
|
2351
|
+
/**
|
|
2352
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2353
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2354
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2355
|
+
*
|
|
2356
|
+
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
2357
|
+
*
|
|
2358
|
+
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
2359
|
+
*
|
|
2360
|
+
* Tool name must be `str_replace_based_edit_tool`.
|
|
2361
|
+
*
|
|
2362
|
+
* @param maxCharacters - Optional maximum number of characters to view in the file
|
|
2363
|
+
*/
|
|
2364
|
+
textEditor_20250728,
|
|
2365
|
+
/**
|
|
2366
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
2367
|
+
*
|
|
2368
|
+
* Tool name must be `web_fetch`.
|
|
2369
|
+
*
|
|
2370
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
2371
|
+
* @param allowedDomains - Only fetch from these domains
|
|
2372
|
+
* @param blockedDomains - Never fetch from these domains
|
|
2373
|
+
* @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
|
|
2374
|
+
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
2375
|
+
*/
|
|
2376
|
+
webFetch_20250910,
|
|
2088
2377
|
/**
|
|
2089
2378
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
2090
2379
|
*
|
|
@@ -2101,16 +2390,19 @@ var anthropicTools = {
|
|
|
2101
2390
|
// src/anthropic-provider.ts
|
|
2102
2391
|
function createAnthropic(options = {}) {
|
|
2103
2392
|
var _a;
|
|
2104
|
-
const baseURL = (_a = (0,
|
|
2105
|
-
const getHeaders = () => (
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2393
|
+
const baseURL = (_a = (0, import_provider_utils15.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
2394
|
+
const getHeaders = () => (0, import_provider_utils15.withUserAgentSuffix)(
|
|
2395
|
+
{
|
|
2396
|
+
"anthropic-version": "2023-06-01",
|
|
2397
|
+
"x-api-key": (0, import_provider_utils15.loadApiKey)({
|
|
2398
|
+
apiKey: options.apiKey,
|
|
2399
|
+
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
2400
|
+
description: "Anthropic"
|
|
2401
|
+
}),
|
|
2402
|
+
...options.headers
|
|
2403
|
+
},
|
|
2404
|
+
`ai-sdk/anthropic/${VERSION}`
|
|
2405
|
+
);
|
|
2114
2406
|
const createChatModel = (modelId) => {
|
|
2115
2407
|
var _a2;
|
|
2116
2408
|
return new AnthropicMessagesLanguageModel(modelId, {
|
|
@@ -2118,7 +2410,7 @@ function createAnthropic(options = {}) {
|
|
|
2118
2410
|
baseURL,
|
|
2119
2411
|
headers: getHeaders,
|
|
2120
2412
|
fetch: options.fetch,
|
|
2121
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
2413
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils15.generateId,
|
|
2122
2414
|
supportedUrls: () => ({
|
|
2123
2415
|
"image/*": [/^https?:\/\/.*$/]
|
|
2124
2416
|
})
|
|
@@ -2147,6 +2439,7 @@ function createAnthropic(options = {}) {
|
|
|
2147
2439
|
var anthropic = createAnthropic();
|
|
2148
2440
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2149
2441
|
0 && (module.exports = {
|
|
2442
|
+
VERSION,
|
|
2150
2443
|
anthropic,
|
|
2151
2444
|
createAnthropic
|
|
2152
2445
|
});
|