@ai-sdk/anthropic 3.0.119 → 3.0.120
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 +12 -0
- package/dist/index.d.mts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +834 -458
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +826 -446
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +74 -2
- package/dist/internal/index.d.ts +74 -2
- package/dist/internal/index.js +827 -451
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +825 -445
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +125 -14
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +23 -0
- package/src/anthropic-messages-language-model.ts +264 -6
- package/src/anthropic-messages-options.ts +12 -2
- package/src/anthropic-prepare-tools.ts +76 -0
- package/src/anthropic-tools.ts +25 -0
- package/src/convert-to-anthropic-messages-prompt.ts +77 -1
- package/src/tool/computer-toolset_20260801.ts +165 -0
package/dist/index.js
CHANGED
|
@@ -29,14 +29,14 @@ module.exports = __toCommonJS(index_exports);
|
|
|
29
29
|
|
|
30
30
|
// src/anthropic-provider.ts
|
|
31
31
|
var import_provider4 = require("@ai-sdk/provider");
|
|
32
|
-
var
|
|
32
|
+
var import_provider_utils27 = require("@ai-sdk/provider-utils");
|
|
33
33
|
|
|
34
34
|
// src/version.ts
|
|
35
|
-
var VERSION = true ? "3.0.
|
|
35
|
+
var VERSION = true ? "3.0.120" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
39
|
-
var
|
|
39
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
40
40
|
|
|
41
41
|
// src/anthropic-error.ts
|
|
42
42
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
@@ -142,7 +142,9 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
142
142
|
name: import_v42.z.string(),
|
|
143
143
|
input: import_v42.z.unknown(),
|
|
144
144
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
145
|
-
caller: anthropicToolCallCallerSchema.optional()
|
|
145
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
146
|
+
// Toolsets (e.g. computer toolset): name of the toolset this member call belongs to
|
|
147
|
+
toolset_name: import_v42.z.string().nullish()
|
|
146
148
|
}),
|
|
147
149
|
import_v42.z.object({
|
|
148
150
|
type: import_v42.z.literal("server_tool_use"),
|
|
@@ -443,7 +445,8 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
443
445
|
id: import_v42.z.string(),
|
|
444
446
|
name: import_v42.z.string(),
|
|
445
447
|
input: import_v42.z.unknown(),
|
|
446
|
-
caller: anthropicToolCallCallerSchema.optional()
|
|
448
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
449
|
+
toolset_name: import_v42.z.string().nullish()
|
|
447
450
|
})
|
|
448
451
|
])
|
|
449
452
|
).nullish(),
|
|
@@ -474,7 +477,9 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
474
477
|
// Programmatic tool calling: input may be present directly for deferred tool calls
|
|
475
478
|
input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional(),
|
|
476
479
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
477
|
-
caller: anthropicToolCallCallerSchema.optional()
|
|
480
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
481
|
+
// Toolsets (e.g. computer toolset): name of the toolset this member call belongs to
|
|
482
|
+
toolset_name: import_v42.z.string().nullish()
|
|
478
483
|
}),
|
|
479
484
|
import_v42.z.object({
|
|
480
485
|
type: import_v42.z.literal("redacted_thinking"),
|
|
@@ -885,7 +890,7 @@ var anthropicSystemMessageProviderOptions = import_v43.z.object({
|
|
|
885
890
|
* Overrides the effort level for the turn following this
|
|
886
891
|
* mid-conversation system message.
|
|
887
892
|
*
|
|
888
|
-
* Requires the `mid-conversation-
|
|
893
|
+
* Requires the `mid-conversation-output-config-2026-07-01` beta,
|
|
889
894
|
* which is added automatically.
|
|
890
895
|
*/
|
|
891
896
|
effort: import_v43.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
@@ -939,6 +944,11 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
939
944
|
*
|
|
940
945
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
941
946
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
947
|
+
*
|
|
948
|
+
* Models that always use adaptive thinking (e.g. `claude-opus-5-5`,
|
|
949
|
+
* `claude-fable-5-1`) reject `enabled` and `disabled`. For those models the
|
|
950
|
+
* provider drops the unsupported setting, emits a warning, and sends an
|
|
951
|
+
* adaptive thinking request. Use `effort` to control how much they think.
|
|
942
952
|
*/
|
|
943
953
|
thinking: import_v43.z.union([
|
|
944
954
|
import_v43.z.discriminatedUnion("type", [
|
|
@@ -1045,7 +1055,11 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
1045
1055
|
*/
|
|
1046
1056
|
toolStreaming: import_v43.z.boolean().optional(),
|
|
1047
1057
|
/**
|
|
1048
|
-
*
|
|
1058
|
+
* Controls how much effort the model spends on thinking, text responses,
|
|
1059
|
+
* and tool calls. On models that always use adaptive thinking
|
|
1060
|
+
* (e.g. `claude-opus-5-5`), effort is the main lever for latency and cost.
|
|
1061
|
+
*
|
|
1062
|
+
* The API default is `high` for most models and `medium` for `claude-opus-5-5`.
|
|
1049
1063
|
*/
|
|
1050
1064
|
effort: import_v43.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
1051
1065
|
/**
|
|
@@ -1250,91 +1264,102 @@ var advisor_20260301 = (args) => {
|
|
|
1250
1264
|
return factory(args);
|
|
1251
1265
|
};
|
|
1252
1266
|
|
|
1253
|
-
// src/tool/
|
|
1267
|
+
// src/tool/computer-toolset_20260801.ts
|
|
1254
1268
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1255
1269
|
var import_v45 = require("zod/v4");
|
|
1256
|
-
var
|
|
1270
|
+
var computerToolset_20260801Members = [
|
|
1271
|
+
"screenshot",
|
|
1272
|
+
"zoom",
|
|
1273
|
+
"left_click",
|
|
1274
|
+
"right_click",
|
|
1275
|
+
"middle_click",
|
|
1276
|
+
"double_click",
|
|
1277
|
+
"triple_click",
|
|
1278
|
+
"left_click_drag",
|
|
1279
|
+
"mouse_move",
|
|
1280
|
+
"left_mouse_down",
|
|
1281
|
+
"left_mouse_up",
|
|
1282
|
+
"cursor_position",
|
|
1283
|
+
"scroll",
|
|
1284
|
+
"type",
|
|
1285
|
+
"key",
|
|
1286
|
+
"hold_key",
|
|
1287
|
+
"wait"
|
|
1288
|
+
];
|
|
1289
|
+
var computerToolset_20260801InputSchema = (0, import_provider_utils4.lazySchema)(
|
|
1257
1290
|
() => (0, import_provider_utils4.zodSchema)(
|
|
1258
1291
|
import_v45.z.object({
|
|
1259
|
-
|
|
1292
|
+
action: import_v45.z.enum(computerToolset_20260801Members),
|
|
1293
|
+
coordinate: import_v45.z.tuple([import_v45.z.number().int(), import_v45.z.number().int()]).optional(),
|
|
1294
|
+
duration: import_v45.z.number().optional(),
|
|
1295
|
+
region: import_v45.z.tuple([
|
|
1296
|
+
import_v45.z.number().int(),
|
|
1297
|
+
import_v45.z.number().int(),
|
|
1298
|
+
import_v45.z.number().int(),
|
|
1299
|
+
import_v45.z.number().int()
|
|
1300
|
+
]).optional(),
|
|
1301
|
+
repeat: import_v45.z.number().int().optional(),
|
|
1302
|
+
scroll_amount: import_v45.z.number().optional(),
|
|
1303
|
+
scroll_direction: import_v45.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1304
|
+
start_coordinate: import_v45.z.tuple([import_v45.z.number().int(), import_v45.z.number().int()]).optional(),
|
|
1305
|
+
text: import_v45.z.string().optional()
|
|
1260
1306
|
})
|
|
1261
1307
|
)
|
|
1262
1308
|
);
|
|
1263
|
-
var
|
|
1309
|
+
var computerToolset_20260801ArgsSchema = (0, import_provider_utils4.lazySchema)(
|
|
1264
1310
|
() => (0, import_provider_utils4.zodSchema)(
|
|
1265
1311
|
import_v45.z.object({
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
view_range: import_v45.z.array(import_v45.z.number().int()).optional()
|
|
1312
|
+
configs: import_v45.z.partialRecord(
|
|
1313
|
+
import_v45.z.enum(computerToolset_20260801Members),
|
|
1314
|
+
import_v45.z.object({
|
|
1315
|
+
enabled: import_v45.z.boolean().optional(),
|
|
1316
|
+
deferLoading: import_v45.z.boolean().optional()
|
|
1317
|
+
})
|
|
1318
|
+
).optional()
|
|
1274
1319
|
})
|
|
1275
1320
|
)
|
|
1276
1321
|
);
|
|
1277
|
-
var
|
|
1278
|
-
id: "anthropic.
|
|
1279
|
-
inputSchema:
|
|
1322
|
+
var computerToolset_20260801 = (0, import_provider_utils4.createProviderToolFactory)({
|
|
1323
|
+
id: "anthropic.computer_toolset_20260801",
|
|
1324
|
+
inputSchema: computerToolset_20260801InputSchema
|
|
1280
1325
|
});
|
|
1281
|
-
var textEditor_20250728 = (args = {}) => {
|
|
1282
|
-
return factory2(args);
|
|
1283
|
-
};
|
|
1284
1326
|
|
|
1285
|
-
// src/tool/
|
|
1327
|
+
// src/tool/text-editor_20250728.ts
|
|
1286
1328
|
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1287
1329
|
var import_v46 = require("zod/v4");
|
|
1288
|
-
var
|
|
1330
|
+
var textEditor_20250728ArgsSchema = (0, import_provider_utils5.lazySchema)(
|
|
1289
1331
|
() => (0, import_provider_utils5.zodSchema)(
|
|
1290
1332
|
import_v46.z.object({
|
|
1291
|
-
|
|
1292
|
-
allowedDomains: import_v46.z.array(import_v46.z.string()).optional(),
|
|
1293
|
-
blockedDomains: import_v46.z.array(import_v46.z.string()).optional(),
|
|
1294
|
-
userLocation: import_v46.z.object({
|
|
1295
|
-
type: import_v46.z.literal("approximate"),
|
|
1296
|
-
city: import_v46.z.string().optional(),
|
|
1297
|
-
region: import_v46.z.string().optional(),
|
|
1298
|
-
country: import_v46.z.string().optional(),
|
|
1299
|
-
timezone: import_v46.z.string().optional()
|
|
1300
|
-
}).optional()
|
|
1333
|
+
maxCharacters: import_v46.z.number().optional()
|
|
1301
1334
|
})
|
|
1302
1335
|
)
|
|
1303
1336
|
);
|
|
1304
|
-
var
|
|
1305
|
-
() => (0, import_provider_utils5.zodSchema)(
|
|
1306
|
-
import_v46.z.array(
|
|
1307
|
-
import_v46.z.object({
|
|
1308
|
-
url: import_v46.z.string(),
|
|
1309
|
-
title: import_v46.z.string().nullable(),
|
|
1310
|
-
pageAge: import_v46.z.string().nullable(),
|
|
1311
|
-
encryptedContent: import_v46.z.string(),
|
|
1312
|
-
type: import_v46.z.literal("web_search_result")
|
|
1313
|
-
})
|
|
1314
|
-
)
|
|
1315
|
-
)
|
|
1316
|
-
);
|
|
1317
|
-
var webSearch_20260209InputSchema = (0, import_provider_utils5.lazySchema)(
|
|
1337
|
+
var textEditor_20250728InputSchema = (0, import_provider_utils5.lazySchema)(
|
|
1318
1338
|
() => (0, import_provider_utils5.zodSchema)(
|
|
1319
1339
|
import_v46.z.object({
|
|
1320
|
-
|
|
1340
|
+
command: import_v46.z.enum(["view", "create", "str_replace", "insert"]),
|
|
1341
|
+
path: import_v46.z.string(),
|
|
1342
|
+
file_text: import_v46.z.string().optional(),
|
|
1343
|
+
insert_line: import_v46.z.number().int().optional(),
|
|
1344
|
+
new_str: import_v46.z.string().optional(),
|
|
1345
|
+
insert_text: import_v46.z.string().optional(),
|
|
1346
|
+
old_str: import_v46.z.string().optional(),
|
|
1347
|
+
view_range: import_v46.z.array(import_v46.z.number().int()).optional()
|
|
1321
1348
|
})
|
|
1322
1349
|
)
|
|
1323
1350
|
);
|
|
1324
|
-
var
|
|
1325
|
-
id: "anthropic.
|
|
1326
|
-
inputSchema:
|
|
1327
|
-
outputSchema: webSearch_20260209OutputSchema,
|
|
1328
|
-
supportsDeferredResults: true
|
|
1351
|
+
var factory2 = (0, import_provider_utils5.createProviderToolFactory)({
|
|
1352
|
+
id: "anthropic.text_editor_20250728",
|
|
1353
|
+
inputSchema: textEditor_20250728InputSchema
|
|
1329
1354
|
});
|
|
1330
|
-
var
|
|
1331
|
-
return
|
|
1355
|
+
var textEditor_20250728 = (args = {}) => {
|
|
1356
|
+
return factory2(args);
|
|
1332
1357
|
};
|
|
1333
1358
|
|
|
1334
|
-
// src/tool/web-
|
|
1359
|
+
// src/tool/web-search_20260209.ts
|
|
1335
1360
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1336
1361
|
var import_v47 = require("zod/v4");
|
|
1337
|
-
var
|
|
1362
|
+
var webSearch_20260209ArgsSchema = (0, import_provider_utils6.lazySchema)(
|
|
1338
1363
|
() => (0, import_provider_utils6.zodSchema)(
|
|
1339
1364
|
import_v47.z.object({
|
|
1340
1365
|
maxUses: import_v47.z.number().optional(),
|
|
@@ -1350,7 +1375,7 @@ var webSearch_20250305ArgsSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
1350
1375
|
})
|
|
1351
1376
|
)
|
|
1352
1377
|
);
|
|
1353
|
-
var
|
|
1378
|
+
var webSearch_20260209OutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
1354
1379
|
() => (0, import_provider_utils6.zodSchema)(
|
|
1355
1380
|
import_v47.z.array(
|
|
1356
1381
|
import_v47.z.object({
|
|
@@ -1363,84 +1388,76 @@ var webSearch_20250305OutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
1363
1388
|
)
|
|
1364
1389
|
)
|
|
1365
1390
|
);
|
|
1366
|
-
var
|
|
1391
|
+
var webSearch_20260209InputSchema = (0, import_provider_utils6.lazySchema)(
|
|
1367
1392
|
() => (0, import_provider_utils6.zodSchema)(
|
|
1368
1393
|
import_v47.z.object({
|
|
1369
1394
|
query: import_v47.z.string()
|
|
1370
1395
|
})
|
|
1371
1396
|
)
|
|
1372
1397
|
);
|
|
1373
|
-
var
|
|
1374
|
-
id: "anthropic.
|
|
1375
|
-
inputSchema:
|
|
1376
|
-
outputSchema:
|
|
1398
|
+
var factory3 = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
|
|
1399
|
+
id: "anthropic.web_search_20260209",
|
|
1400
|
+
inputSchema: webSearch_20260209InputSchema,
|
|
1401
|
+
outputSchema: webSearch_20260209OutputSchema,
|
|
1377
1402
|
supportsDeferredResults: true
|
|
1378
1403
|
});
|
|
1379
|
-
var
|
|
1380
|
-
return
|
|
1404
|
+
var webSearch_20260209 = (args = {}) => {
|
|
1405
|
+
return factory3(args);
|
|
1381
1406
|
};
|
|
1382
1407
|
|
|
1383
|
-
// src/tool/web-
|
|
1408
|
+
// src/tool/web-search_20250305.ts
|
|
1384
1409
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1385
1410
|
var import_v48 = require("zod/v4");
|
|
1386
|
-
var
|
|
1411
|
+
var webSearch_20250305ArgsSchema = (0, import_provider_utils7.lazySchema)(
|
|
1387
1412
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1388
1413
|
import_v48.z.object({
|
|
1389
1414
|
maxUses: import_v48.z.number().optional(),
|
|
1390
1415
|
allowedDomains: import_v48.z.array(import_v48.z.string()).optional(),
|
|
1391
1416
|
blockedDomains: import_v48.z.array(import_v48.z.string()).optional(),
|
|
1392
|
-
|
|
1393
|
-
|
|
1417
|
+
userLocation: import_v48.z.object({
|
|
1418
|
+
type: import_v48.z.literal("approximate"),
|
|
1419
|
+
city: import_v48.z.string().optional(),
|
|
1420
|
+
region: import_v48.z.string().optional(),
|
|
1421
|
+
country: import_v48.z.string().optional(),
|
|
1422
|
+
timezone: import_v48.z.string().optional()
|
|
1423
|
+
}).optional()
|
|
1394
1424
|
})
|
|
1395
1425
|
)
|
|
1396
1426
|
);
|
|
1397
|
-
var
|
|
1427
|
+
var webSearch_20250305OutputSchema = (0, import_provider_utils7.lazySchema)(
|
|
1398
1428
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1399
|
-
import_v48.z.
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
content: import_v48.z.object({
|
|
1403
|
-
type: import_v48.z.literal("document"),
|
|
1429
|
+
import_v48.z.array(
|
|
1430
|
+
import_v48.z.object({
|
|
1431
|
+
url: import_v48.z.string(),
|
|
1404
1432
|
title: import_v48.z.string().nullable(),
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
data: import_v48.z.string()
|
|
1411
|
-
}),
|
|
1412
|
-
import_v48.z.object({
|
|
1413
|
-
type: import_v48.z.literal("text"),
|
|
1414
|
-
mediaType: import_v48.z.literal("text/plain"),
|
|
1415
|
-
data: import_v48.z.string()
|
|
1416
|
-
})
|
|
1417
|
-
])
|
|
1418
|
-
}),
|
|
1419
|
-
retrievedAt: import_v48.z.string().nullable()
|
|
1420
|
-
})
|
|
1433
|
+
pageAge: import_v48.z.string().nullable(),
|
|
1434
|
+
encryptedContent: import_v48.z.string(),
|
|
1435
|
+
type: import_v48.z.literal("web_search_result")
|
|
1436
|
+
})
|
|
1437
|
+
)
|
|
1421
1438
|
)
|
|
1422
1439
|
);
|
|
1423
|
-
var
|
|
1440
|
+
var webSearch_20250305InputSchema = (0, import_provider_utils7.lazySchema)(
|
|
1424
1441
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1425
1442
|
import_v48.z.object({
|
|
1426
|
-
|
|
1443
|
+
query: import_v48.z.string()
|
|
1427
1444
|
})
|
|
1428
1445
|
)
|
|
1429
1446
|
);
|
|
1430
|
-
var
|
|
1431
|
-
id: "anthropic.
|
|
1432
|
-
inputSchema:
|
|
1433
|
-
outputSchema:
|
|
1447
|
+
var factory4 = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
|
|
1448
|
+
id: "anthropic.web_search_20250305",
|
|
1449
|
+
inputSchema: webSearch_20250305InputSchema,
|
|
1450
|
+
outputSchema: webSearch_20250305OutputSchema,
|
|
1434
1451
|
supportsDeferredResults: true
|
|
1435
1452
|
});
|
|
1436
|
-
var
|
|
1437
|
-
return
|
|
1453
|
+
var webSearch_20250305 = (args = {}) => {
|
|
1454
|
+
return factory4(args);
|
|
1438
1455
|
};
|
|
1439
1456
|
|
|
1440
|
-
// src/tool/web-fetch-
|
|
1457
|
+
// src/tool/web-fetch-20260209.ts
|
|
1441
1458
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1442
1459
|
var import_v49 = require("zod/v4");
|
|
1443
|
-
var
|
|
1460
|
+
var webFetch_20260209ArgsSchema = (0, import_provider_utils8.lazySchema)(
|
|
1444
1461
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1445
1462
|
import_v49.z.object({
|
|
1446
1463
|
maxUses: import_v49.z.number().optional(),
|
|
@@ -1451,7 +1468,7 @@ var webFetch_20250910ArgsSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
1451
1468
|
})
|
|
1452
1469
|
)
|
|
1453
1470
|
);
|
|
1454
|
-
var
|
|
1471
|
+
var webFetch_20260209OutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
1455
1472
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1456
1473
|
import_v49.z.object({
|
|
1457
1474
|
type: import_v49.z.literal("web_fetch_result"),
|
|
@@ -1477,14 +1494,71 @@ var webFetch_20250910OutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
1477
1494
|
})
|
|
1478
1495
|
)
|
|
1479
1496
|
);
|
|
1480
|
-
var
|
|
1497
|
+
var webFetch_20260209InputSchema = (0, import_provider_utils8.lazySchema)(
|
|
1481
1498
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1482
1499
|
import_v49.z.object({
|
|
1483
1500
|
url: import_v49.z.string()
|
|
1484
1501
|
})
|
|
1485
1502
|
)
|
|
1486
1503
|
);
|
|
1487
|
-
var
|
|
1504
|
+
var factory5 = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
1505
|
+
id: "anthropic.web_fetch_20260209",
|
|
1506
|
+
inputSchema: webFetch_20260209InputSchema,
|
|
1507
|
+
outputSchema: webFetch_20260209OutputSchema,
|
|
1508
|
+
supportsDeferredResults: true
|
|
1509
|
+
});
|
|
1510
|
+
var webFetch_20260209 = (args = {}) => {
|
|
1511
|
+
return factory5(args);
|
|
1512
|
+
};
|
|
1513
|
+
|
|
1514
|
+
// src/tool/web-fetch-20250910.ts
|
|
1515
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1516
|
+
var import_v410 = require("zod/v4");
|
|
1517
|
+
var webFetch_20250910ArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1518
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1519
|
+
import_v410.z.object({
|
|
1520
|
+
maxUses: import_v410.z.number().optional(),
|
|
1521
|
+
allowedDomains: import_v410.z.array(import_v410.z.string()).optional(),
|
|
1522
|
+
blockedDomains: import_v410.z.array(import_v410.z.string()).optional(),
|
|
1523
|
+
citations: import_v410.z.object({ enabled: import_v410.z.boolean() }).optional(),
|
|
1524
|
+
maxContentTokens: import_v410.z.number().optional()
|
|
1525
|
+
})
|
|
1526
|
+
)
|
|
1527
|
+
);
|
|
1528
|
+
var webFetch_20250910OutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
1529
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1530
|
+
import_v410.z.object({
|
|
1531
|
+
type: import_v410.z.literal("web_fetch_result"),
|
|
1532
|
+
url: import_v410.z.string(),
|
|
1533
|
+
content: import_v410.z.object({
|
|
1534
|
+
type: import_v410.z.literal("document"),
|
|
1535
|
+
title: import_v410.z.string().nullable(),
|
|
1536
|
+
citations: import_v410.z.object({ enabled: import_v410.z.boolean() }).optional(),
|
|
1537
|
+
source: import_v410.z.union([
|
|
1538
|
+
import_v410.z.object({
|
|
1539
|
+
type: import_v410.z.literal("base64"),
|
|
1540
|
+
mediaType: import_v410.z.literal("application/pdf"),
|
|
1541
|
+
data: import_v410.z.string()
|
|
1542
|
+
}),
|
|
1543
|
+
import_v410.z.object({
|
|
1544
|
+
type: import_v410.z.literal("text"),
|
|
1545
|
+
mediaType: import_v410.z.literal("text/plain"),
|
|
1546
|
+
data: import_v410.z.string()
|
|
1547
|
+
})
|
|
1548
|
+
])
|
|
1549
|
+
}),
|
|
1550
|
+
retrievedAt: import_v410.z.string().nullable()
|
|
1551
|
+
})
|
|
1552
|
+
)
|
|
1553
|
+
);
|
|
1554
|
+
var webFetch_20250910InputSchema = (0, import_provider_utils9.lazySchema)(
|
|
1555
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1556
|
+
import_v410.z.object({
|
|
1557
|
+
url: import_v410.z.string()
|
|
1558
|
+
})
|
|
1559
|
+
)
|
|
1560
|
+
);
|
|
1561
|
+
var factory6 = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
|
|
1488
1562
|
id: "anthropic.web_fetch_20250910",
|
|
1489
1563
|
inputSchema: webFetch_20250910InputSchema,
|
|
1490
1564
|
outputSchema: webFetch_20250910OutputSchema,
|
|
@@ -1495,7 +1569,7 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
1495
1569
|
};
|
|
1496
1570
|
|
|
1497
1571
|
// src/anthropic-prepare-tools.ts
|
|
1498
|
-
var
|
|
1572
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1499
1573
|
async function prepareTools({
|
|
1500
1574
|
tools,
|
|
1501
1575
|
toolChoice,
|
|
@@ -1503,7 +1577,8 @@ async function prepareTools({
|
|
|
1503
1577
|
cacheControlValidator,
|
|
1504
1578
|
supportsStructuredOutput,
|
|
1505
1579
|
supportsStrictTools,
|
|
1506
|
-
defaultEagerInputStreaming = false
|
|
1580
|
+
defaultEagerInputStreaming = false,
|
|
1581
|
+
rejectsForcedToolUse = false
|
|
1507
1582
|
}) {
|
|
1508
1583
|
var _a, _b;
|
|
1509
1584
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1606,6 +1681,31 @@ async function prepareTools({
|
|
|
1606
1681
|
});
|
|
1607
1682
|
break;
|
|
1608
1683
|
}
|
|
1684
|
+
case "anthropic.computer_toolset_20260801": {
|
|
1685
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1686
|
+
value: tool.args,
|
|
1687
|
+
schema: computerToolset_20260801ArgsSchema
|
|
1688
|
+
});
|
|
1689
|
+
const configs = args.configs != null ? Object.fromEntries(
|
|
1690
|
+
Object.entries(args.configs).map(([member, config]) => [
|
|
1691
|
+
member,
|
|
1692
|
+
{
|
|
1693
|
+
...(config == null ? void 0 : config.enabled) != null && {
|
|
1694
|
+
enabled: config.enabled
|
|
1695
|
+
},
|
|
1696
|
+
...(config == null ? void 0 : config.deferLoading) != null && {
|
|
1697
|
+
defer_loading: config.deferLoading
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
])
|
|
1701
|
+
) : void 0;
|
|
1702
|
+
anthropicTools2.push({
|
|
1703
|
+
type: "computer_toolset_20260801",
|
|
1704
|
+
...configs != null && { configs },
|
|
1705
|
+
cache_control: void 0
|
|
1706
|
+
});
|
|
1707
|
+
break;
|
|
1708
|
+
}
|
|
1609
1709
|
case "anthropic.computer_20241022": {
|
|
1610
1710
|
betas.add("computer-use-2024-10-22");
|
|
1611
1711
|
anthropicTools2.push({
|
|
@@ -1646,7 +1746,7 @@ async function prepareTools({
|
|
|
1646
1746
|
break;
|
|
1647
1747
|
}
|
|
1648
1748
|
case "anthropic.text_editor_20250728": {
|
|
1649
|
-
const args = await (0,
|
|
1749
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1650
1750
|
value: tool.args,
|
|
1651
1751
|
schema: textEditor_20250728ArgsSchema
|
|
1652
1752
|
});
|
|
@@ -1686,7 +1786,7 @@ async function prepareTools({
|
|
|
1686
1786
|
}
|
|
1687
1787
|
case "anthropic.web_fetch_20250910": {
|
|
1688
1788
|
betas.add("web-fetch-2025-09-10");
|
|
1689
|
-
const args = await (0,
|
|
1789
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1690
1790
|
value: tool.args,
|
|
1691
1791
|
schema: webFetch_20250910ArgsSchema
|
|
1692
1792
|
});
|
|
@@ -1704,7 +1804,7 @@ async function prepareTools({
|
|
|
1704
1804
|
}
|
|
1705
1805
|
case "anthropic.web_fetch_20260209": {
|
|
1706
1806
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1707
|
-
const args = await (0,
|
|
1807
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1708
1808
|
value: tool.args,
|
|
1709
1809
|
schema: webFetch_20260209ArgsSchema
|
|
1710
1810
|
});
|
|
@@ -1721,7 +1821,7 @@ async function prepareTools({
|
|
|
1721
1821
|
break;
|
|
1722
1822
|
}
|
|
1723
1823
|
case "anthropic.web_search_20250305": {
|
|
1724
|
-
const args = await (0,
|
|
1824
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1725
1825
|
value: tool.args,
|
|
1726
1826
|
schema: webSearch_20250305ArgsSchema
|
|
1727
1827
|
});
|
|
@@ -1738,7 +1838,7 @@ async function prepareTools({
|
|
|
1738
1838
|
}
|
|
1739
1839
|
case "anthropic.web_search_20260209": {
|
|
1740
1840
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1741
|
-
const args = await (0,
|
|
1841
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1742
1842
|
value: tool.args,
|
|
1743
1843
|
schema: webSearch_20260209ArgsSchema
|
|
1744
1844
|
});
|
|
@@ -1769,7 +1869,7 @@ async function prepareTools({
|
|
|
1769
1869
|
}
|
|
1770
1870
|
case "anthropic.advisor_20260301": {
|
|
1771
1871
|
betas.add("advisor-tool-2026-03-01");
|
|
1772
|
-
const args = await (0,
|
|
1872
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1773
1873
|
value: tool.args,
|
|
1774
1874
|
schema: advisor_20260301ArgsSchema
|
|
1775
1875
|
});
|
|
@@ -1822,6 +1922,22 @@ async function prepareTools({
|
|
|
1822
1922
|
betas
|
|
1823
1923
|
};
|
|
1824
1924
|
case "required":
|
|
1925
|
+
if (rejectsForcedToolUse) {
|
|
1926
|
+
toolWarnings.push({
|
|
1927
|
+
type: "unsupported",
|
|
1928
|
+
feature: "toolChoice",
|
|
1929
|
+
details: `toolChoice 'required' is not supported by this model because it rejects forced tool use. Using 'auto' instead. Instruct the model to use a tool in the prompt and verify that a tool call was made.`
|
|
1930
|
+
});
|
|
1931
|
+
return {
|
|
1932
|
+
tools: anthropicTools2,
|
|
1933
|
+
toolChoice: {
|
|
1934
|
+
type: "auto",
|
|
1935
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
1936
|
+
},
|
|
1937
|
+
toolWarnings,
|
|
1938
|
+
betas
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1825
1941
|
return {
|
|
1826
1942
|
tools: anthropicTools2,
|
|
1827
1943
|
toolChoice: {
|
|
@@ -1834,6 +1950,24 @@ async function prepareTools({
|
|
|
1834
1950
|
case "none":
|
|
1835
1951
|
return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
|
|
1836
1952
|
case "tool":
|
|
1953
|
+
if (rejectsForcedToolUse) {
|
|
1954
|
+
toolWarnings.push({
|
|
1955
|
+
type: "unsupported",
|
|
1956
|
+
feature: "toolChoice",
|
|
1957
|
+
details: `toolChoice 'tool' is not supported by this model because it rejects forced tool use. Only the '${toolChoice.toolName}' tool is sent with 'auto' tool choice. Instruct the model to use the tool in the prompt and verify that a tool call was made.`
|
|
1958
|
+
});
|
|
1959
|
+
return {
|
|
1960
|
+
tools: anthropicTools2.filter(
|
|
1961
|
+
(tool) => "name" in tool && tool.name === toolChoice.toolName
|
|
1962
|
+
),
|
|
1963
|
+
toolChoice: {
|
|
1964
|
+
type: "auto",
|
|
1965
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
1966
|
+
},
|
|
1967
|
+
toolWarnings,
|
|
1968
|
+
betas
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1837
1971
|
return {
|
|
1838
1972
|
tools: anthropicTools2,
|
|
1839
1973
|
toolChoice: {
|
|
@@ -1907,35 +2041,35 @@ function convertAnthropicMessagesUsage({
|
|
|
1907
2041
|
|
|
1908
2042
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
1909
2043
|
var import_provider2 = require("@ai-sdk/provider");
|
|
1910
|
-
var
|
|
2044
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
1911
2045
|
|
|
1912
2046
|
// src/tool/code-execution_20250522.ts
|
|
1913
|
-
var
|
|
1914
|
-
var
|
|
1915
|
-
var codeExecution_20250522OutputSchema = (0,
|
|
1916
|
-
() => (0,
|
|
1917
|
-
|
|
1918
|
-
type:
|
|
1919
|
-
stdout:
|
|
1920
|
-
stderr:
|
|
1921
|
-
return_code:
|
|
1922
|
-
content:
|
|
1923
|
-
|
|
1924
|
-
type:
|
|
1925
|
-
file_id:
|
|
2047
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
2048
|
+
var import_v411 = require("zod/v4");
|
|
2049
|
+
var codeExecution_20250522OutputSchema = (0, import_provider_utils11.lazySchema)(
|
|
2050
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
2051
|
+
import_v411.z.object({
|
|
2052
|
+
type: import_v411.z.literal("code_execution_result"),
|
|
2053
|
+
stdout: import_v411.z.string(),
|
|
2054
|
+
stderr: import_v411.z.string(),
|
|
2055
|
+
return_code: import_v411.z.number(),
|
|
2056
|
+
content: import_v411.z.array(
|
|
2057
|
+
import_v411.z.object({
|
|
2058
|
+
type: import_v411.z.literal("code_execution_output"),
|
|
2059
|
+
file_id: import_v411.z.string()
|
|
1926
2060
|
})
|
|
1927
2061
|
).optional().default([])
|
|
1928
2062
|
})
|
|
1929
2063
|
)
|
|
1930
2064
|
);
|
|
1931
|
-
var codeExecution_20250522InputSchema = (0,
|
|
1932
|
-
() => (0,
|
|
1933
|
-
|
|
1934
|
-
code:
|
|
2065
|
+
var codeExecution_20250522InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
2066
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
2067
|
+
import_v411.z.object({
|
|
2068
|
+
code: import_v411.z.string()
|
|
1935
2069
|
})
|
|
1936
2070
|
)
|
|
1937
2071
|
);
|
|
1938
|
-
var factory7 = (0,
|
|
2072
|
+
var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
|
|
1939
2073
|
id: "anthropic.code_execution_20250522",
|
|
1940
2074
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1941
2075
|
outputSchema: codeExecution_20250522OutputSchema
|
|
@@ -1945,118 +2079,9 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
1945
2079
|
};
|
|
1946
2080
|
|
|
1947
2081
|
// src/tool/code-execution_20250825.ts
|
|
1948
|
-
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1949
|
-
var import_v411 = require("zod/v4");
|
|
1950
|
-
var codeExecution_20250825OutputSchema = (0, import_provider_utils11.lazySchema)(
|
|
1951
|
-
() => (0, import_provider_utils11.zodSchema)(
|
|
1952
|
-
import_v411.z.discriminatedUnion("type", [
|
|
1953
|
-
import_v411.z.object({
|
|
1954
|
-
type: import_v411.z.literal("code_execution_result"),
|
|
1955
|
-
stdout: import_v411.z.string(),
|
|
1956
|
-
stderr: import_v411.z.string(),
|
|
1957
|
-
return_code: import_v411.z.number(),
|
|
1958
|
-
content: import_v411.z.array(
|
|
1959
|
-
import_v411.z.object({
|
|
1960
|
-
type: import_v411.z.literal("code_execution_output"),
|
|
1961
|
-
file_id: import_v411.z.string()
|
|
1962
|
-
})
|
|
1963
|
-
).optional().default([])
|
|
1964
|
-
}),
|
|
1965
|
-
import_v411.z.object({
|
|
1966
|
-
type: import_v411.z.literal("bash_code_execution_result"),
|
|
1967
|
-
content: import_v411.z.array(
|
|
1968
|
-
import_v411.z.object({
|
|
1969
|
-
type: import_v411.z.literal("bash_code_execution_output"),
|
|
1970
|
-
file_id: import_v411.z.string()
|
|
1971
|
-
})
|
|
1972
|
-
),
|
|
1973
|
-
stdout: import_v411.z.string(),
|
|
1974
|
-
stderr: import_v411.z.string(),
|
|
1975
|
-
return_code: import_v411.z.number()
|
|
1976
|
-
}),
|
|
1977
|
-
import_v411.z.object({
|
|
1978
|
-
type: import_v411.z.literal("bash_code_execution_tool_result_error"),
|
|
1979
|
-
error_code: import_v411.z.string()
|
|
1980
|
-
}),
|
|
1981
|
-
import_v411.z.object({
|
|
1982
|
-
type: import_v411.z.literal("text_editor_code_execution_tool_result_error"),
|
|
1983
|
-
error_code: import_v411.z.string()
|
|
1984
|
-
}),
|
|
1985
|
-
import_v411.z.object({
|
|
1986
|
-
type: import_v411.z.literal("text_editor_code_execution_view_result"),
|
|
1987
|
-
content: import_v411.z.string(),
|
|
1988
|
-
file_type: import_v411.z.string(),
|
|
1989
|
-
num_lines: import_v411.z.number().nullable(),
|
|
1990
|
-
start_line: import_v411.z.number().nullable(),
|
|
1991
|
-
total_lines: import_v411.z.number().nullable()
|
|
1992
|
-
}),
|
|
1993
|
-
import_v411.z.object({
|
|
1994
|
-
type: import_v411.z.literal("text_editor_code_execution_create_result"),
|
|
1995
|
-
is_file_update: import_v411.z.boolean()
|
|
1996
|
-
}),
|
|
1997
|
-
import_v411.z.object({
|
|
1998
|
-
type: import_v411.z.literal("text_editor_code_execution_str_replace_result"),
|
|
1999
|
-
lines: import_v411.z.array(import_v411.z.string()).nullable(),
|
|
2000
|
-
new_lines: import_v411.z.number().nullable(),
|
|
2001
|
-
new_start: import_v411.z.number().nullable(),
|
|
2002
|
-
old_lines: import_v411.z.number().nullable(),
|
|
2003
|
-
old_start: import_v411.z.number().nullable()
|
|
2004
|
-
})
|
|
2005
|
-
])
|
|
2006
|
-
)
|
|
2007
|
-
);
|
|
2008
|
-
var codeExecution_20250825InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
2009
|
-
() => (0, import_provider_utils11.zodSchema)(
|
|
2010
|
-
import_v411.z.discriminatedUnion("type", [
|
|
2011
|
-
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
2012
|
-
import_v411.z.object({
|
|
2013
|
-
type: import_v411.z.literal("programmatic-tool-call"),
|
|
2014
|
-
code: import_v411.z.string()
|
|
2015
|
-
}),
|
|
2016
|
-
import_v411.z.object({
|
|
2017
|
-
type: import_v411.z.literal("bash_code_execution"),
|
|
2018
|
-
command: import_v411.z.string()
|
|
2019
|
-
}),
|
|
2020
|
-
import_v411.z.discriminatedUnion("command", [
|
|
2021
|
-
import_v411.z.object({
|
|
2022
|
-
type: import_v411.z.literal("text_editor_code_execution"),
|
|
2023
|
-
command: import_v411.z.literal("view"),
|
|
2024
|
-
path: import_v411.z.string()
|
|
2025
|
-
}),
|
|
2026
|
-
import_v411.z.object({
|
|
2027
|
-
type: import_v411.z.literal("text_editor_code_execution"),
|
|
2028
|
-
command: import_v411.z.literal("create"),
|
|
2029
|
-
path: import_v411.z.string(),
|
|
2030
|
-
file_text: import_v411.z.string().nullish()
|
|
2031
|
-
}),
|
|
2032
|
-
import_v411.z.object({
|
|
2033
|
-
type: import_v411.z.literal("text_editor_code_execution"),
|
|
2034
|
-
command: import_v411.z.literal("str_replace"),
|
|
2035
|
-
path: import_v411.z.string(),
|
|
2036
|
-
old_str: import_v411.z.string(),
|
|
2037
|
-
new_str: import_v411.z.string()
|
|
2038
|
-
})
|
|
2039
|
-
])
|
|
2040
|
-
])
|
|
2041
|
-
)
|
|
2042
|
-
);
|
|
2043
|
-
var factory8 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
|
|
2044
|
-
id: "anthropic.code_execution_20250825",
|
|
2045
|
-
inputSchema: codeExecution_20250825InputSchema,
|
|
2046
|
-
outputSchema: codeExecution_20250825OutputSchema,
|
|
2047
|
-
// Programmatic tool calling: tool results may be deferred to a later turn
|
|
2048
|
-
// when code execution triggers a client-executed tool that needs to be
|
|
2049
|
-
// resolved before the code execution result can be returned.
|
|
2050
|
-
supportsDeferredResults: true
|
|
2051
|
-
});
|
|
2052
|
-
var codeExecution_20250825 = (args = {}) => {
|
|
2053
|
-
return factory8(args);
|
|
2054
|
-
};
|
|
2055
|
-
|
|
2056
|
-
// src/tool/code-execution_20260120.ts
|
|
2057
2082
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2058
2083
|
var import_v412 = require("zod/v4");
|
|
2059
|
-
var
|
|
2084
|
+
var codeExecution_20250825OutputSchema = (0, import_provider_utils12.lazySchema)(
|
|
2060
2085
|
() => (0, import_provider_utils12.zodSchema)(
|
|
2061
2086
|
import_v412.z.discriminatedUnion("type", [
|
|
2062
2087
|
import_v412.z.object({
|
|
@@ -2071,18 +2096,6 @@ var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)
|
|
|
2071
2096
|
})
|
|
2072
2097
|
).optional().default([])
|
|
2073
2098
|
}),
|
|
2074
|
-
import_v412.z.object({
|
|
2075
|
-
type: import_v412.z.literal("encrypted_code_execution_result"),
|
|
2076
|
-
encrypted_stdout: import_v412.z.string(),
|
|
2077
|
-
stderr: import_v412.z.string(),
|
|
2078
|
-
return_code: import_v412.z.number(),
|
|
2079
|
-
content: import_v412.z.array(
|
|
2080
|
-
import_v412.z.object({
|
|
2081
|
-
type: import_v412.z.literal("code_execution_output"),
|
|
2082
|
-
file_id: import_v412.z.string()
|
|
2083
|
-
})
|
|
2084
|
-
).optional().default([])
|
|
2085
|
-
}),
|
|
2086
2099
|
import_v412.z.object({
|
|
2087
2100
|
type: import_v412.z.literal("bash_code_execution_result"),
|
|
2088
2101
|
content: import_v412.z.array(
|
|
@@ -2126,9 +2139,10 @@ var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)
|
|
|
2126
2139
|
])
|
|
2127
2140
|
)
|
|
2128
2141
|
);
|
|
2129
|
-
var
|
|
2142
|
+
var codeExecution_20250825InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
2130
2143
|
() => (0, import_provider_utils12.zodSchema)(
|
|
2131
2144
|
import_v412.z.discriminatedUnion("type", [
|
|
2145
|
+
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
2132
2146
|
import_v412.z.object({
|
|
2133
2147
|
type: import_v412.z.literal("programmatic-tool-call"),
|
|
2134
2148
|
code: import_v412.z.string()
|
|
@@ -2160,7 +2174,127 @@ var codeExecution_20260120InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
|
2160
2174
|
])
|
|
2161
2175
|
)
|
|
2162
2176
|
);
|
|
2163
|
-
var
|
|
2177
|
+
var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
|
|
2178
|
+
id: "anthropic.code_execution_20250825",
|
|
2179
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
2180
|
+
outputSchema: codeExecution_20250825OutputSchema,
|
|
2181
|
+
// Programmatic tool calling: tool results may be deferred to a later turn
|
|
2182
|
+
// when code execution triggers a client-executed tool that needs to be
|
|
2183
|
+
// resolved before the code execution result can be returned.
|
|
2184
|
+
supportsDeferredResults: true
|
|
2185
|
+
});
|
|
2186
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
2187
|
+
return factory8(args);
|
|
2188
|
+
};
|
|
2189
|
+
|
|
2190
|
+
// src/tool/code-execution_20260120.ts
|
|
2191
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2192
|
+
var import_v413 = require("zod/v4");
|
|
2193
|
+
var codeExecution_20260120OutputSchema = (0, import_provider_utils13.lazySchema)(
|
|
2194
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
2195
|
+
import_v413.z.discriminatedUnion("type", [
|
|
2196
|
+
import_v413.z.object({
|
|
2197
|
+
type: import_v413.z.literal("code_execution_result"),
|
|
2198
|
+
stdout: import_v413.z.string(),
|
|
2199
|
+
stderr: import_v413.z.string(),
|
|
2200
|
+
return_code: import_v413.z.number(),
|
|
2201
|
+
content: import_v413.z.array(
|
|
2202
|
+
import_v413.z.object({
|
|
2203
|
+
type: import_v413.z.literal("code_execution_output"),
|
|
2204
|
+
file_id: import_v413.z.string()
|
|
2205
|
+
})
|
|
2206
|
+
).optional().default([])
|
|
2207
|
+
}),
|
|
2208
|
+
import_v413.z.object({
|
|
2209
|
+
type: import_v413.z.literal("encrypted_code_execution_result"),
|
|
2210
|
+
encrypted_stdout: import_v413.z.string(),
|
|
2211
|
+
stderr: import_v413.z.string(),
|
|
2212
|
+
return_code: import_v413.z.number(),
|
|
2213
|
+
content: import_v413.z.array(
|
|
2214
|
+
import_v413.z.object({
|
|
2215
|
+
type: import_v413.z.literal("code_execution_output"),
|
|
2216
|
+
file_id: import_v413.z.string()
|
|
2217
|
+
})
|
|
2218
|
+
).optional().default([])
|
|
2219
|
+
}),
|
|
2220
|
+
import_v413.z.object({
|
|
2221
|
+
type: import_v413.z.literal("bash_code_execution_result"),
|
|
2222
|
+
content: import_v413.z.array(
|
|
2223
|
+
import_v413.z.object({
|
|
2224
|
+
type: import_v413.z.literal("bash_code_execution_output"),
|
|
2225
|
+
file_id: import_v413.z.string()
|
|
2226
|
+
})
|
|
2227
|
+
),
|
|
2228
|
+
stdout: import_v413.z.string(),
|
|
2229
|
+
stderr: import_v413.z.string(),
|
|
2230
|
+
return_code: import_v413.z.number()
|
|
2231
|
+
}),
|
|
2232
|
+
import_v413.z.object({
|
|
2233
|
+
type: import_v413.z.literal("bash_code_execution_tool_result_error"),
|
|
2234
|
+
error_code: import_v413.z.string()
|
|
2235
|
+
}),
|
|
2236
|
+
import_v413.z.object({
|
|
2237
|
+
type: import_v413.z.literal("text_editor_code_execution_tool_result_error"),
|
|
2238
|
+
error_code: import_v413.z.string()
|
|
2239
|
+
}),
|
|
2240
|
+
import_v413.z.object({
|
|
2241
|
+
type: import_v413.z.literal("text_editor_code_execution_view_result"),
|
|
2242
|
+
content: import_v413.z.string(),
|
|
2243
|
+
file_type: import_v413.z.string(),
|
|
2244
|
+
num_lines: import_v413.z.number().nullable(),
|
|
2245
|
+
start_line: import_v413.z.number().nullable(),
|
|
2246
|
+
total_lines: import_v413.z.number().nullable()
|
|
2247
|
+
}),
|
|
2248
|
+
import_v413.z.object({
|
|
2249
|
+
type: import_v413.z.literal("text_editor_code_execution_create_result"),
|
|
2250
|
+
is_file_update: import_v413.z.boolean()
|
|
2251
|
+
}),
|
|
2252
|
+
import_v413.z.object({
|
|
2253
|
+
type: import_v413.z.literal("text_editor_code_execution_str_replace_result"),
|
|
2254
|
+
lines: import_v413.z.array(import_v413.z.string()).nullable(),
|
|
2255
|
+
new_lines: import_v413.z.number().nullable(),
|
|
2256
|
+
new_start: import_v413.z.number().nullable(),
|
|
2257
|
+
old_lines: import_v413.z.number().nullable(),
|
|
2258
|
+
old_start: import_v413.z.number().nullable()
|
|
2259
|
+
})
|
|
2260
|
+
])
|
|
2261
|
+
)
|
|
2262
|
+
);
|
|
2263
|
+
var codeExecution_20260120InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
2264
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
2265
|
+
import_v413.z.discriminatedUnion("type", [
|
|
2266
|
+
import_v413.z.object({
|
|
2267
|
+
type: import_v413.z.literal("programmatic-tool-call"),
|
|
2268
|
+
code: import_v413.z.string()
|
|
2269
|
+
}),
|
|
2270
|
+
import_v413.z.object({
|
|
2271
|
+
type: import_v413.z.literal("bash_code_execution"),
|
|
2272
|
+
command: import_v413.z.string()
|
|
2273
|
+
}),
|
|
2274
|
+
import_v413.z.discriminatedUnion("command", [
|
|
2275
|
+
import_v413.z.object({
|
|
2276
|
+
type: import_v413.z.literal("text_editor_code_execution"),
|
|
2277
|
+
command: import_v413.z.literal("view"),
|
|
2278
|
+
path: import_v413.z.string()
|
|
2279
|
+
}),
|
|
2280
|
+
import_v413.z.object({
|
|
2281
|
+
type: import_v413.z.literal("text_editor_code_execution"),
|
|
2282
|
+
command: import_v413.z.literal("create"),
|
|
2283
|
+
path: import_v413.z.string(),
|
|
2284
|
+
file_text: import_v413.z.string().nullish()
|
|
2285
|
+
}),
|
|
2286
|
+
import_v413.z.object({
|
|
2287
|
+
type: import_v413.z.literal("text_editor_code_execution"),
|
|
2288
|
+
command: import_v413.z.literal("str_replace"),
|
|
2289
|
+
path: import_v413.z.string(),
|
|
2290
|
+
old_str: import_v413.z.string(),
|
|
2291
|
+
new_str: import_v413.z.string()
|
|
2292
|
+
})
|
|
2293
|
+
])
|
|
2294
|
+
])
|
|
2295
|
+
)
|
|
2296
|
+
);
|
|
2297
|
+
var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
|
|
2164
2298
|
id: "anthropic.code_execution_20260120",
|
|
2165
2299
|
inputSchema: codeExecution_20260120InputSchema,
|
|
2166
2300
|
outputSchema: codeExecution_20260120OutputSchema,
|
|
@@ -2171,21 +2305,21 @@ var codeExecution_20260120 = (args = {}) => {
|
|
|
2171
2305
|
};
|
|
2172
2306
|
|
|
2173
2307
|
// src/tool/tool-search-regex_20251119.ts
|
|
2174
|
-
var
|
|
2175
|
-
var
|
|
2176
|
-
var toolSearchRegex_20251119OutputSchema = (0,
|
|
2177
|
-
() => (0,
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
type:
|
|
2181
|
-
toolName:
|
|
2308
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2309
|
+
var import_v414 = require("zod/v4");
|
|
2310
|
+
var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2311
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2312
|
+
import_v414.z.array(
|
|
2313
|
+
import_v414.z.object({
|
|
2314
|
+
type: import_v414.z.literal("tool_reference"),
|
|
2315
|
+
toolName: import_v414.z.string()
|
|
2182
2316
|
})
|
|
2183
2317
|
)
|
|
2184
2318
|
)
|
|
2185
2319
|
);
|
|
2186
|
-
var toolSearchRegex_20251119InputSchema = (0,
|
|
2187
|
-
() => (0,
|
|
2188
|
-
|
|
2320
|
+
var toolSearchRegex_20251119InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2321
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2322
|
+
import_v414.z.object({
|
|
2189
2323
|
/**
|
|
2190
2324
|
* A regex pattern to search for tools.
|
|
2191
2325
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -2196,15 +2330,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
|
|
|
2196
2330
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
2197
2331
|
* - "(?i)slack" - case-insensitive search
|
|
2198
2332
|
*/
|
|
2199
|
-
pattern:
|
|
2333
|
+
pattern: import_v414.z.string(),
|
|
2200
2334
|
/**
|
|
2201
2335
|
* Maximum number of tools to return. Optional.
|
|
2202
2336
|
*/
|
|
2203
|
-
limit:
|
|
2337
|
+
limit: import_v414.z.number().optional()
|
|
2204
2338
|
})
|
|
2205
2339
|
)
|
|
2206
2340
|
);
|
|
2207
|
-
var factory10 = (0,
|
|
2341
|
+
var factory10 = (0, import_provider_utils14.createProviderToolFactoryWithOutputSchema)({
|
|
2208
2342
|
id: "anthropic.tool_search_regex_20251119",
|
|
2209
2343
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
2210
2344
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
@@ -2217,7 +2351,7 @@ var toolSearchRegex_20251119 = (args = {}) => {
|
|
|
2217
2351
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
2218
2352
|
function convertToString(data) {
|
|
2219
2353
|
if (typeof data === "string") {
|
|
2220
|
-
return new TextDecoder().decode((0,
|
|
2354
|
+
return new TextDecoder().decode((0, import_provider_utils15.convertBase64ToUint8Array)(data));
|
|
2221
2355
|
}
|
|
2222
2356
|
if (data instanceof Uint8Array) {
|
|
2223
2357
|
return new TextDecoder().decode(data);
|
|
@@ -2242,7 +2376,7 @@ function getUrlString(data) {
|
|
|
2242
2376
|
}
|
|
2243
2377
|
async function extractErrorValue(value) {
|
|
2244
2378
|
if (typeof value === "string") {
|
|
2245
|
-
const result = await (0,
|
|
2379
|
+
const result = await (0, import_provider_utils15.safeParseJSON)({ text: value });
|
|
2246
2380
|
if (result.success && typeof result.value === "object" && result.value !== null) {
|
|
2247
2381
|
return result.value;
|
|
2248
2382
|
}
|
|
@@ -2260,7 +2394,8 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2260
2394
|
sendReasoning,
|
|
2261
2395
|
warnings,
|
|
2262
2396
|
cacheControlValidator,
|
|
2263
|
-
toolNameMapping
|
|
2397
|
+
toolNameMapping,
|
|
2398
|
+
toolsetNames = {}
|
|
2264
2399
|
}) {
|
|
2265
2400
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2266
2401
|
const betas = /* @__PURE__ */ new Set();
|
|
@@ -2270,7 +2405,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2270
2405
|
const messages = [];
|
|
2271
2406
|
async function shouldEnableCitations(providerMetadata) {
|
|
2272
2407
|
var _a2, _b2;
|
|
2273
|
-
const anthropicOptions = await (0,
|
|
2408
|
+
const anthropicOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2274
2409
|
provider: "anthropic",
|
|
2275
2410
|
providerOptions: providerMetadata,
|
|
2276
2411
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2278,7 +2413,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2278
2413
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
2279
2414
|
}
|
|
2280
2415
|
async function getDocumentMetadata(providerMetadata) {
|
|
2281
|
-
const anthropicOptions = await (0,
|
|
2416
|
+
const anthropicOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2282
2417
|
provider: "anthropic",
|
|
2283
2418
|
providerOptions: providerMetadata,
|
|
2284
2419
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2298,7 +2433,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2298
2433
|
let toolChangeCount = 0;
|
|
2299
2434
|
let hasMidConversationOptions = false;
|
|
2300
2435
|
for (const { content: text, providerOptions } of block.messages) {
|
|
2301
|
-
const systemMessageOptions = await (0,
|
|
2436
|
+
const systemMessageOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2302
2437
|
provider: "anthropic",
|
|
2303
2438
|
providerOptions,
|
|
2304
2439
|
schema: anthropicSystemMessageProviderOptions
|
|
@@ -2363,7 +2498,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2363
2498
|
betas.add("mid-conversation-system-clear-at-2026-08-21");
|
|
2364
2499
|
}
|
|
2365
2500
|
if (systemMessages.some((message) => message.output_config != null)) {
|
|
2366
|
-
betas.add("mid-conversation-
|
|
2501
|
+
betas.add("mid-conversation-output-config-2026-07-01");
|
|
2367
2502
|
}
|
|
2368
2503
|
}
|
|
2369
2504
|
break;
|
|
@@ -2403,7 +2538,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2403
2538
|
} : {
|
|
2404
2539
|
type: "base64",
|
|
2405
2540
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
2406
|
-
data: (0,
|
|
2541
|
+
data: (0, import_provider_utils15.convertToBase64)(part.data)
|
|
2407
2542
|
},
|
|
2408
2543
|
cache_control: cacheControl
|
|
2409
2544
|
});
|
|
@@ -2423,7 +2558,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2423
2558
|
} : {
|
|
2424
2559
|
type: "base64",
|
|
2425
2560
|
media_type: "application/pdf",
|
|
2426
|
-
data: (0,
|
|
2561
|
+
data: (0, import_provider_utils15.convertToBase64)(part.data)
|
|
2427
2562
|
},
|
|
2428
2563
|
title: (_c = metadata.title) != null ? _c : part.filename,
|
|
2429
2564
|
...metadata.context && { context: metadata.context },
|
|
@@ -2567,7 +2702,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2567
2702
|
return void 0;
|
|
2568
2703
|
}
|
|
2569
2704
|
}
|
|
2570
|
-
}).filter(
|
|
2705
|
+
}).filter(import_provider_utils15.isNonNullable);
|
|
2571
2706
|
break;
|
|
2572
2707
|
case "text":
|
|
2573
2708
|
case "error-text":
|
|
@@ -2582,9 +2717,15 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2582
2717
|
contentValue = JSON.stringify(output.value);
|
|
2583
2718
|
break;
|
|
2584
2719
|
}
|
|
2720
|
+
const toolsetName = getAnthropicToolsetName({
|
|
2721
|
+
toolName: part.toolName,
|
|
2722
|
+
providerOptions: part.providerOptions,
|
|
2723
|
+
toolsetNames
|
|
2724
|
+
});
|
|
2585
2725
|
anthropicContent.push({
|
|
2586
2726
|
type: "tool_result",
|
|
2587
2727
|
tool_use_id: part.toolCallId,
|
|
2728
|
+
...toolsetName != null && { toolset_name: toolsetName },
|
|
2588
2729
|
content: contentValue,
|
|
2589
2730
|
is_error: output.type === "error-text" || output.type === "error-json" ? true : void 0,
|
|
2590
2731
|
cache_control: cacheControl
|
|
@@ -2646,7 +2787,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2646
2787
|
}
|
|
2647
2788
|
case "reasoning": {
|
|
2648
2789
|
if (sendReasoning) {
|
|
2649
|
-
const reasoningMetadata = await (0,
|
|
2790
|
+
const reasoningMetadata = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2650
2791
|
provider: "anthropic",
|
|
2651
2792
|
providerOptions: part.providerOptions,
|
|
2652
2793
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2782,6 +2923,31 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2782
2923
|
}
|
|
2783
2924
|
break;
|
|
2784
2925
|
}
|
|
2926
|
+
const toolsetName = getAnthropicToolsetName({
|
|
2927
|
+
toolName: part.toolName,
|
|
2928
|
+
providerOptions: part.providerOptions,
|
|
2929
|
+
toolsetNames
|
|
2930
|
+
});
|
|
2931
|
+
if (toolsetName != null) {
|
|
2932
|
+
const { action, ...memberInput } = typeof part.input === "object" && part.input !== null && !Array.isArray(part.input) ? part.input : {};
|
|
2933
|
+
if (typeof action !== "string") {
|
|
2934
|
+
warnings.push({
|
|
2935
|
+
type: "other",
|
|
2936
|
+
message: `toolset tool call for tool ${part.toolName} is missing the action`
|
|
2937
|
+
});
|
|
2938
|
+
break;
|
|
2939
|
+
}
|
|
2940
|
+
anthropicContent.push({
|
|
2941
|
+
type: "tool_use",
|
|
2942
|
+
id: part.toolCallId,
|
|
2943
|
+
name: action,
|
|
2944
|
+
toolset_name: toolsetName,
|
|
2945
|
+
input: memberInput,
|
|
2946
|
+
...caller && { caller },
|
|
2947
|
+
cache_control: cacheControl
|
|
2948
|
+
});
|
|
2949
|
+
break;
|
|
2950
|
+
}
|
|
2785
2951
|
anthropicContent.push({
|
|
2786
2952
|
type: "tool_use",
|
|
2787
2953
|
id: part.toolCallId,
|
|
@@ -2819,7 +2985,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2819
2985
|
let errorInfo = {};
|
|
2820
2986
|
try {
|
|
2821
2987
|
if (typeof output.value === "string") {
|
|
2822
|
-
errorInfo = (0,
|
|
2988
|
+
errorInfo = (0, import_provider_utils15.secureJsonParse)(output.value);
|
|
2823
2989
|
} else if (typeof output.value === "object" && output.value !== null) {
|
|
2824
2990
|
errorInfo = output.value;
|
|
2825
2991
|
}
|
|
@@ -2863,7 +3029,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2863
3029
|
break;
|
|
2864
3030
|
}
|
|
2865
3031
|
if (output.value.type === "code_execution_result") {
|
|
2866
|
-
const codeExecutionOutput = await (0,
|
|
3032
|
+
const codeExecutionOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2867
3033
|
value: output.value,
|
|
2868
3034
|
schema: codeExecution_20250522OutputSchema
|
|
2869
3035
|
});
|
|
@@ -2880,7 +3046,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2880
3046
|
cache_control: cacheControl
|
|
2881
3047
|
});
|
|
2882
3048
|
} else if (output.value.type === "encrypted_code_execution_result") {
|
|
2883
|
-
const codeExecutionOutput = await (0,
|
|
3049
|
+
const codeExecutionOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2884
3050
|
value: output.value,
|
|
2885
3051
|
schema: codeExecution_20260120OutputSchema
|
|
2886
3052
|
});
|
|
@@ -2899,7 +3065,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2899
3065
|
});
|
|
2900
3066
|
}
|
|
2901
3067
|
} else {
|
|
2902
|
-
const codeExecutionOutput = await (0,
|
|
3068
|
+
const codeExecutionOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2903
3069
|
value: output.value,
|
|
2904
3070
|
schema: codeExecution_20250825OutputSchema
|
|
2905
3071
|
});
|
|
@@ -2964,7 +3130,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2964
3130
|
});
|
|
2965
3131
|
break;
|
|
2966
3132
|
}
|
|
2967
|
-
const webFetchOutput = await (0,
|
|
3133
|
+
const webFetchOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2968
3134
|
value: output.value,
|
|
2969
3135
|
schema: webFetch_20250910OutputSchema
|
|
2970
3136
|
});
|
|
@@ -3013,7 +3179,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3013
3179
|
});
|
|
3014
3180
|
break;
|
|
3015
3181
|
}
|
|
3016
|
-
const webSearchOutput = await (0,
|
|
3182
|
+
const webSearchOutput = await (0, import_provider_utils15.validateTypes)({
|
|
3017
3183
|
value: output.value,
|
|
3018
3184
|
schema: webSearch_20250305OutputSchema
|
|
3019
3185
|
});
|
|
@@ -3041,7 +3207,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3041
3207
|
});
|
|
3042
3208
|
break;
|
|
3043
3209
|
}
|
|
3044
|
-
const toolSearchOutput = await (0,
|
|
3210
|
+
const toolSearchOutput = await (0, import_provider_utils15.validateTypes)({
|
|
3045
3211
|
value: output.value,
|
|
3046
3212
|
schema: toolSearchRegex_20251119OutputSchema
|
|
3047
3213
|
});
|
|
@@ -3069,7 +3235,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3069
3235
|
});
|
|
3070
3236
|
break;
|
|
3071
3237
|
}
|
|
3072
|
-
const advisorOutput = await (0,
|
|
3238
|
+
const advisorOutput = await (0, import_provider_utils15.validateTypes)({
|
|
3073
3239
|
value: output.value,
|
|
3074
3240
|
schema: advisor_20260301OutputSchema
|
|
3075
3241
|
});
|
|
@@ -3199,6 +3365,19 @@ function moveToolUseBlocksToEnd(content) {
|
|
|
3199
3365
|
flushSegment();
|
|
3200
3366
|
return result;
|
|
3201
3367
|
}
|
|
3368
|
+
function getAnthropicToolsetName({
|
|
3369
|
+
toolName,
|
|
3370
|
+
providerOptions,
|
|
3371
|
+
toolsetNames
|
|
3372
|
+
}) {
|
|
3373
|
+
var _a;
|
|
3374
|
+
const fromTools = toolsetNames[toolName];
|
|
3375
|
+
if (fromTools != null) {
|
|
3376
|
+
return fromTools;
|
|
3377
|
+
}
|
|
3378
|
+
const fromMetadata = (_a = providerOptions == null ? void 0 : providerOptions.anthropic) == null ? void 0 : _a.toolsetName;
|
|
3379
|
+
return typeof fromMetadata === "string" ? fromMetadata : void 0;
|
|
3380
|
+
}
|
|
3202
3381
|
function getAnthropicCaller(providerOptions) {
|
|
3203
3382
|
var _a;
|
|
3204
3383
|
const caller = (_a = providerOptions == null ? void 0 : providerOptions.anthropic) == null ? void 0 : _a.caller;
|
|
@@ -3436,13 +3615,31 @@ function getAnthropicCallerMetadata(caller) {
|
|
|
3436
3615
|
const callerInfo = getAnthropicCallerInfo(caller);
|
|
3437
3616
|
return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
|
|
3438
3617
|
}
|
|
3618
|
+
function getAnthropicToolsetNames(tools) {
|
|
3619
|
+
const toolsetNames = {};
|
|
3620
|
+
for (const tool of tools != null ? tools : []) {
|
|
3621
|
+
if (tool.type === "provider" && tool.id === "anthropic.computer_toolset_20260801") {
|
|
3622
|
+
toolsetNames[tool.name] = "computer";
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
return toolsetNames;
|
|
3626
|
+
}
|
|
3627
|
+
function toToolsetMemberInput({
|
|
3628
|
+
memberName,
|
|
3629
|
+
input
|
|
3630
|
+
}) {
|
|
3631
|
+
return {
|
|
3632
|
+
action: memberName,
|
|
3633
|
+
...typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
|
|
3634
|
+
};
|
|
3635
|
+
}
|
|
3439
3636
|
var AnthropicMessagesLanguageModel = class {
|
|
3440
3637
|
constructor(modelId, config) {
|
|
3441
3638
|
this.specificationVersion = "v3";
|
|
3442
3639
|
var _a;
|
|
3443
3640
|
this.modelId = modelId;
|
|
3444
3641
|
this.config = config;
|
|
3445
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
3642
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils16.generateId;
|
|
3446
3643
|
}
|
|
3447
3644
|
supportsUrl(url) {
|
|
3448
3645
|
return url.protocol === "https:";
|
|
@@ -3516,12 +3713,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3516
3713
|
}
|
|
3517
3714
|
}
|
|
3518
3715
|
const providerOptionsName = this.providerOptionsName;
|
|
3519
|
-
const canonicalOptions = await (0,
|
|
3716
|
+
const canonicalOptions = await (0, import_provider_utils16.parseProviderOptions)({
|
|
3520
3717
|
provider: "anthropic",
|
|
3521
3718
|
providerOptions,
|
|
3522
3719
|
schema: anthropicLanguageModelOptions
|
|
3523
3720
|
});
|
|
3524
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await (0,
|
|
3721
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils16.parseProviderOptions)({
|
|
3525
3722
|
provider: providerOptionsName,
|
|
3526
3723
|
providerOptions,
|
|
3527
3724
|
schema: anthropicLanguageModelOptions
|
|
@@ -3537,6 +3734,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3537
3734
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3538
3735
|
rejectsSamplingParameters,
|
|
3539
3736
|
rejectsThinkingDisabledAboveHighEffort,
|
|
3737
|
+
rejectsThinkingDisabled,
|
|
3738
|
+
rejectsForcedToolUse,
|
|
3540
3739
|
isKnownModel
|
|
3541
3740
|
} = getModelCapabilities(this.modelId);
|
|
3542
3741
|
if (!isKnownModel && maxOutputTokens == null) {
|
|
@@ -3576,7 +3775,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3576
3775
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
3577
3776
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
3578
3777
|
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
3579
|
-
|
|
3778
|
+
let useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
3779
|
+
if (!useStructuredOutput && rejectsForcedToolUse && supportsStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
|
|
3780
|
+
warnings.push({
|
|
3781
|
+
type: "unsupported",
|
|
3782
|
+
feature: "providerOptions.anthropic.structuredOutputMode",
|
|
3783
|
+
details: `structuredOutputMode 'jsonTool' is not supported by ${this.modelId} because it rejects forced tool use. Using 'outputFormat' instead.`
|
|
3784
|
+
});
|
|
3785
|
+
useStructuredOutput = true;
|
|
3786
|
+
}
|
|
3580
3787
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
3581
3788
|
type: "function",
|
|
3582
3789
|
name: "json",
|
|
@@ -3592,7 +3799,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3592
3799
|
}
|
|
3593
3800
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
3594
3801
|
const cacheControlValidator = new CacheControlValidator();
|
|
3595
|
-
const toolNameMapping = (0,
|
|
3802
|
+
const toolNameMapping = (0, import_provider_utils16.createToolNameMapping)({
|
|
3596
3803
|
tools,
|
|
3597
3804
|
providerToolNames: {
|
|
3598
3805
|
"anthropic.code_execution_20250522": "code_execution",
|
|
@@ -3600,6 +3807,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3600
3807
|
"anthropic.code_execution_20260120": "code_execution",
|
|
3601
3808
|
"anthropic.computer_20241022": "computer",
|
|
3602
3809
|
"anthropic.computer_20250124": "computer",
|
|
3810
|
+
"anthropic.computer_20251124": "computer",
|
|
3811
|
+
"anthropic.computer_toolset_20260801": "computer",
|
|
3603
3812
|
"anthropic.text_editor_20241022": "str_replace_editor",
|
|
3604
3813
|
"anthropic.text_editor_20250124": "str_replace_editor",
|
|
3605
3814
|
"anthropic.text_editor_20250429": "str_replace_based_edit_tool",
|
|
@@ -3616,13 +3825,34 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3616
3825
|
"anthropic.advisor_20260301": "advisor"
|
|
3617
3826
|
}
|
|
3618
3827
|
});
|
|
3828
|
+
const toolsetNames = getAnthropicToolsetNames(tools);
|
|
3619
3829
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
3620
3830
|
prompt,
|
|
3621
3831
|
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
3622
3832
|
warnings,
|
|
3623
3833
|
cacheControlValidator,
|
|
3624
|
-
toolNameMapping
|
|
3834
|
+
toolNameMapping,
|
|
3835
|
+
toolsetNames
|
|
3625
3836
|
});
|
|
3837
|
+
if (rejectsThinkingDisabled && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) != null) {
|
|
3838
|
+
const requestedThinking = anthropicOptions.thinking;
|
|
3839
|
+
const requestedType = "type" in requestedThinking ? requestedThinking.type : void 0;
|
|
3840
|
+
if (requestedType === "disabled") {
|
|
3841
|
+
warnings.push({
|
|
3842
|
+
type: "unsupported",
|
|
3843
|
+
feature: "providerOptions.anthropic.thinking",
|
|
3844
|
+
details: `thinking cannot be disabled for ${this.modelId}; it always uses adaptive thinking. The thinking setting has been removed. Lower 'effort' to reduce thinking.`
|
|
3845
|
+
});
|
|
3846
|
+
anthropicOptions.thinking = void 0;
|
|
3847
|
+
} else if (requestedType === "enabled") {
|
|
3848
|
+
warnings.push({
|
|
3849
|
+
type: "unsupported",
|
|
3850
|
+
feature: "providerOptions.anthropic.thinking",
|
|
3851
|
+
details: `budget-based thinking is not supported by ${this.modelId}; it always uses adaptive thinking. Using adaptive thinking instead. Use 'effort' to control how much the model thinks.`
|
|
3852
|
+
});
|
|
3853
|
+
anthropicOptions.thinking = { type: "adaptive" };
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3626
3856
|
const thinking = anthropicOptions == null ? void 0 : anthropicOptions.thinking;
|
|
3627
3857
|
const thinkingType = thinking != null && "type" in thinking ? thinking.type : void 0;
|
|
3628
3858
|
if (rejectsThinkingDisabledAboveHighEffort && thinkingType === "disabled" && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
|
|
@@ -3894,7 +4124,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3894
4124
|
cacheControlValidator,
|
|
3895
4125
|
supportsStructuredOutput: false,
|
|
3896
4126
|
supportsStrictTools,
|
|
3897
|
-
defaultEagerInputStreaming
|
|
4127
|
+
defaultEagerInputStreaming,
|
|
4128
|
+
rejectsForcedToolUse
|
|
3898
4129
|
} : {
|
|
3899
4130
|
tools: tools != null ? tools : [],
|
|
3900
4131
|
toolChoice,
|
|
@@ -3902,7 +4133,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3902
4133
|
cacheControlValidator,
|
|
3903
4134
|
supportsStructuredOutput,
|
|
3904
4135
|
supportsStrictTools,
|
|
3905
|
-
defaultEagerInputStreaming
|
|
4136
|
+
defaultEagerInputStreaming,
|
|
4137
|
+
rejectsForcedToolUse
|
|
3906
4138
|
}
|
|
3907
4139
|
);
|
|
3908
4140
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3931,15 +4163,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3931
4163
|
betas,
|
|
3932
4164
|
headers
|
|
3933
4165
|
}) {
|
|
3934
|
-
return (0,
|
|
3935
|
-
await (0,
|
|
4166
|
+
return (0, import_provider_utils16.combineHeaders)(
|
|
4167
|
+
await (0, import_provider_utils16.resolve)(this.config.headers),
|
|
3936
4168
|
headers,
|
|
3937
4169
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3938
4170
|
);
|
|
3939
4171
|
}
|
|
3940
4172
|
async getBetasFromHeaders(requestHeaders) {
|
|
3941
4173
|
var _a, _b;
|
|
3942
|
-
const configHeaders = await (0,
|
|
4174
|
+
const configHeaders = await (0, import_provider_utils16.resolve)(this.config.headers);
|
|
3943
4175
|
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3944
4176
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3945
4177
|
return new Set(
|
|
@@ -3981,7 +4213,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3981
4213
|
});
|
|
3982
4214
|
}
|
|
3983
4215
|
async doGenerate(options) {
|
|
3984
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4216
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3985
4217
|
const {
|
|
3986
4218
|
args,
|
|
3987
4219
|
warnings,
|
|
@@ -4005,12 +4237,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4005
4237
|
responseHeaders,
|
|
4006
4238
|
value: response,
|
|
4007
4239
|
rawValue: rawResponse
|
|
4008
|
-
} = await (0,
|
|
4240
|
+
} = await (0, import_provider_utils16.postJsonToApi)({
|
|
4009
4241
|
url: this.buildRequestUrl(false),
|
|
4010
4242
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
4011
4243
|
body: this.transformRequestBody(args, betas),
|
|
4012
4244
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
4013
|
-
successfulResponseHandler: (0,
|
|
4245
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
4014
4246
|
anthropicMessagesResponseSchema
|
|
4015
4247
|
),
|
|
4016
4248
|
abortSignal: options.abortSignal,
|
|
@@ -4097,6 +4329,24 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4097
4329
|
type: "text",
|
|
4098
4330
|
text: JSON.stringify(part.input)
|
|
4099
4331
|
});
|
|
4332
|
+
} else if (part.toolset_name != null) {
|
|
4333
|
+
content.push({
|
|
4334
|
+
type: "tool-call",
|
|
4335
|
+
toolCallId: part.id,
|
|
4336
|
+
toolName: toolNameMapping.toCustomToolName(part.toolset_name),
|
|
4337
|
+
input: JSON.stringify(
|
|
4338
|
+
toToolsetMemberInput({
|
|
4339
|
+
memberName: part.name,
|
|
4340
|
+
input: part.input
|
|
4341
|
+
})
|
|
4342
|
+
),
|
|
4343
|
+
providerMetadata: {
|
|
4344
|
+
anthropic: {
|
|
4345
|
+
toolsetName: part.toolset_name,
|
|
4346
|
+
...(_b = getAnthropicCallerMetadata(part.caller).providerMetadata) == null ? void 0 : _b.anthropic
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
});
|
|
4100
4350
|
} else {
|
|
4101
4351
|
content.push({
|
|
4102
4352
|
type: "tool-call",
|
|
@@ -4194,7 +4444,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4194
4444
|
case "web_fetch_tool_result": {
|
|
4195
4445
|
if (part.content.type === "web_fetch_result") {
|
|
4196
4446
|
citationDocuments.push({
|
|
4197
|
-
title: (
|
|
4447
|
+
title: (_c = part.content.content.title) != null ? _c : part.content.url,
|
|
4198
4448
|
mediaType: part.content.content.source.media_type
|
|
4199
4449
|
});
|
|
4200
4450
|
content.push({
|
|
@@ -4260,7 +4510,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4260
4510
|
title: result.title,
|
|
4261
4511
|
providerMetadata: {
|
|
4262
4512
|
anthropic: {
|
|
4263
|
-
pageAge: (
|
|
4513
|
+
pageAge: (_d = result.page_age) != null ? _d : null
|
|
4264
4514
|
}
|
|
4265
4515
|
}
|
|
4266
4516
|
});
|
|
@@ -4292,7 +4542,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4292
4542
|
stdout: part.content.stdout,
|
|
4293
4543
|
stderr: part.content.stderr,
|
|
4294
4544
|
return_code: part.content.return_code,
|
|
4295
|
-
content: (
|
|
4545
|
+
content: (_e = part.content.content) != null ? _e : []
|
|
4296
4546
|
}
|
|
4297
4547
|
});
|
|
4298
4548
|
} else if (part.content.type === "encrypted_code_execution_result") {
|
|
@@ -4305,7 +4555,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4305
4555
|
encrypted_stdout: part.content.encrypted_stdout,
|
|
4306
4556
|
stderr: part.content.stderr,
|
|
4307
4557
|
return_code: part.content.return_code,
|
|
4308
|
-
content: (
|
|
4558
|
+
content: (_f = part.content.content) != null ? _f : []
|
|
4309
4559
|
}
|
|
4310
4560
|
});
|
|
4311
4561
|
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
@@ -4427,13 +4677,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4427
4677
|
finishReason: response.stop_reason,
|
|
4428
4678
|
isJsonResponseFromTool
|
|
4429
4679
|
}),
|
|
4430
|
-
raw: (
|
|
4680
|
+
raw: (_g = response.stop_reason) != null ? _g : void 0
|
|
4431
4681
|
},
|
|
4432
4682
|
usage: convertAnthropicMessagesUsage({ usage: response.usage }),
|
|
4433
4683
|
request: { body: args },
|
|
4434
4684
|
response: {
|
|
4435
|
-
id: (
|
|
4436
|
-
modelId: (
|
|
4685
|
+
id: (_h = response.id) != null ? _h : void 0,
|
|
4686
|
+
modelId: (_i = response.model) != null ? _i : void 0,
|
|
4437
4687
|
headers: responseHeaders,
|
|
4438
4688
|
body: rawResponse
|
|
4439
4689
|
},
|
|
@@ -4506,12 +4756,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4506
4756
|
body.tools
|
|
4507
4757
|
);
|
|
4508
4758
|
const url = this.buildRequestUrl(true);
|
|
4509
|
-
const { responseHeaders, value: response } = await (0,
|
|
4759
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils16.postJsonToApi)({
|
|
4510
4760
|
url,
|
|
4511
4761
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
4512
4762
|
body: this.transformRequestBody(body, betas),
|
|
4513
4763
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
4514
|
-
successfulResponseHandler: (0,
|
|
4764
|
+
successfulResponseHandler: (0, import_provider_utils16.createEventSourceResponseHandler)(
|
|
4515
4765
|
anthropicMessagesChunkSchema
|
|
4516
4766
|
),
|
|
4517
4767
|
abortSignal: options.abortSignal,
|
|
@@ -4637,6 +4887,29 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4637
4887
|
type: "text-start",
|
|
4638
4888
|
id: String(value.index)
|
|
4639
4889
|
});
|
|
4890
|
+
} else if (part.toolset_name != null) {
|
|
4891
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
4892
|
+
const customToolName = toolNameMapping.toCustomToolName(
|
|
4893
|
+
part.toolset_name
|
|
4894
|
+
);
|
|
4895
|
+
const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
|
|
4896
|
+
contentBlocks[value.index] = {
|
|
4897
|
+
type: "tool-call",
|
|
4898
|
+
toolCallId: part.id,
|
|
4899
|
+
toolName: customToolName,
|
|
4900
|
+
input: hasNonEmptyInput ? JSON.stringify(part.input) : "",
|
|
4901
|
+
firstDelta: true,
|
|
4902
|
+
toolset: {
|
|
4903
|
+
name: part.toolset_name,
|
|
4904
|
+
memberName: part.name
|
|
4905
|
+
},
|
|
4906
|
+
...callerInfo && { caller: callerInfo }
|
|
4907
|
+
};
|
|
4908
|
+
controller.enqueue({
|
|
4909
|
+
type: "tool-input-start",
|
|
4910
|
+
id: part.id,
|
|
4911
|
+
toolName: customToolName
|
|
4912
|
+
});
|
|
4640
4913
|
} else {
|
|
4641
4914
|
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
4642
4915
|
const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
|
|
@@ -5030,6 +5303,25 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5030
5303
|
case "tool-call":
|
|
5031
5304
|
const isJsonResponseTool = usesJsonResponseTool && contentBlock.toolName === "json";
|
|
5032
5305
|
if (!isJsonResponseTool) {
|
|
5306
|
+
if (contentBlock.toolset != null) {
|
|
5307
|
+
let memberInput = {};
|
|
5308
|
+
try {
|
|
5309
|
+
memberInput = contentBlock.input === "" ? {} : (0, import_provider_utils16.secureJsonParse)(contentBlock.input);
|
|
5310
|
+
} catch (e) {
|
|
5311
|
+
memberInput = void 0;
|
|
5312
|
+
}
|
|
5313
|
+
contentBlock.input = memberInput === void 0 ? contentBlock.input : JSON.stringify(
|
|
5314
|
+
toToolsetMemberInput({
|
|
5315
|
+
memberName: contentBlock.toolset.memberName,
|
|
5316
|
+
input: memberInput
|
|
5317
|
+
})
|
|
5318
|
+
);
|
|
5319
|
+
controller.enqueue({
|
|
5320
|
+
type: "tool-input-delta",
|
|
5321
|
+
id: contentBlock.toolCallId,
|
|
5322
|
+
delta: contentBlock.input
|
|
5323
|
+
});
|
|
5324
|
+
}
|
|
5033
5325
|
controller.enqueue({
|
|
5034
5326
|
type: "tool-input-end",
|
|
5035
5327
|
id: contentBlock.toolCallId
|
|
@@ -5037,7 +5329,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5037
5329
|
let finalInput = contentBlock.input === "" ? "{}" : contentBlock.input;
|
|
5038
5330
|
if (contentBlock.providerToolName === "code_execution") {
|
|
5039
5331
|
try {
|
|
5040
|
-
const parsed = (0,
|
|
5332
|
+
const parsed = (0, import_provider_utils16.secureJsonParse)(finalInput);
|
|
5041
5333
|
if (parsed != null && typeof parsed === "object" && "code" in parsed && !("type" in parsed)) {
|
|
5042
5334
|
finalInput = JSON.stringify({
|
|
5043
5335
|
type: "programmatic-tool-call",
|
|
@@ -5058,10 +5350,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5058
5350
|
// tool was not explicitly provided. We therefore bypass the general validation by marking the
|
|
5059
5351
|
// tool as dynamic.
|
|
5060
5352
|
...markCodeExecutionDynamic && contentBlock.providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
5061
|
-
...contentBlock.caller && {
|
|
5353
|
+
...(contentBlock.caller || contentBlock.toolset) && {
|
|
5062
5354
|
providerMetadata: {
|
|
5063
5355
|
anthropic: {
|
|
5064
|
-
|
|
5356
|
+
...contentBlock.toolset && {
|
|
5357
|
+
toolsetName: contentBlock.toolset.name
|
|
5358
|
+
},
|
|
5359
|
+
...contentBlock.caller && {
|
|
5360
|
+
caller: contentBlock.caller
|
|
5361
|
+
}
|
|
5065
5362
|
}
|
|
5066
5363
|
}
|
|
5067
5364
|
}
|
|
@@ -5140,6 +5437,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5140
5437
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
5141
5438
|
return;
|
|
5142
5439
|
}
|
|
5440
|
+
if (contentBlock.toolset != null) {
|
|
5441
|
+
contentBlock.input += delta;
|
|
5442
|
+
return;
|
|
5443
|
+
}
|
|
5143
5444
|
if (contentBlock.firstDelta && contentBlock.providerToolInputType != null) {
|
|
5144
5445
|
delta = `{"type": "${contentBlock.providerToolInputType}",${delta.substring(1)}`;
|
|
5145
5446
|
}
|
|
@@ -5398,20 +5699,54 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5398
5699
|
}
|
|
5399
5700
|
};
|
|
5400
5701
|
function getModelCapabilities(modelId) {
|
|
5401
|
-
if (modelId.includes("claude-opus-5")) {
|
|
5702
|
+
if (modelId.includes("claude-opus-5-5")) {
|
|
5703
|
+
return {
|
|
5704
|
+
maxOutputTokens: 128e3,
|
|
5705
|
+
supportsStructuredOutput: true,
|
|
5706
|
+
rejectsSamplingParameters: true,
|
|
5707
|
+
rejectsThinkingDisabledAboveHighEffort: true,
|
|
5708
|
+
rejectsThinkingDisabled: true,
|
|
5709
|
+
rejectsForcedToolUse: true,
|
|
5710
|
+
isKnownModel: true
|
|
5711
|
+
};
|
|
5712
|
+
} else if (modelId.includes("claude-opus-5")) {
|
|
5402
5713
|
return {
|
|
5403
5714
|
maxOutputTokens: 128e3,
|
|
5404
5715
|
supportsStructuredOutput: true,
|
|
5405
5716
|
rejectsSamplingParameters: true,
|
|
5406
5717
|
rejectsThinkingDisabledAboveHighEffort: true,
|
|
5718
|
+
rejectsThinkingDisabled: false,
|
|
5719
|
+
rejectsForcedToolUse: false,
|
|
5720
|
+
isKnownModel: true
|
|
5721
|
+
};
|
|
5722
|
+
} else if (modelId.includes("claude-fable-5-1")) {
|
|
5723
|
+
return {
|
|
5724
|
+
maxOutputTokens: 128e3,
|
|
5725
|
+
supportsStructuredOutput: true,
|
|
5726
|
+
rejectsSamplingParameters: true,
|
|
5727
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5728
|
+
rejectsThinkingDisabled: true,
|
|
5729
|
+
rejectsForcedToolUse: true,
|
|
5407
5730
|
isKnownModel: true
|
|
5408
5731
|
};
|
|
5409
|
-
} else if (modelId.includes("claude-
|
|
5732
|
+
} else if (modelId.includes("claude-fable-5")) {
|
|
5410
5733
|
return {
|
|
5411
5734
|
maxOutputTokens: 128e3,
|
|
5412
5735
|
supportsStructuredOutput: true,
|
|
5413
5736
|
rejectsSamplingParameters: true,
|
|
5414
5737
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5738
|
+
rejectsThinkingDisabled: true,
|
|
5739
|
+
rejectsForcedToolUse: false,
|
|
5740
|
+
isKnownModel: true
|
|
5741
|
+
};
|
|
5742
|
+
} else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-sonnet-5")) {
|
|
5743
|
+
return {
|
|
5744
|
+
maxOutputTokens: 128e3,
|
|
5745
|
+
supportsStructuredOutput: true,
|
|
5746
|
+
rejectsSamplingParameters: true,
|
|
5747
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5748
|
+
rejectsThinkingDisabled: false,
|
|
5749
|
+
rejectsForcedToolUse: false,
|
|
5415
5750
|
isKnownModel: true
|
|
5416
5751
|
};
|
|
5417
5752
|
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
@@ -5420,6 +5755,8 @@ function getModelCapabilities(modelId) {
|
|
|
5420
5755
|
supportsStructuredOutput: true,
|
|
5421
5756
|
rejectsSamplingParameters: false,
|
|
5422
5757
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5758
|
+
rejectsThinkingDisabled: false,
|
|
5759
|
+
rejectsForcedToolUse: false,
|
|
5423
5760
|
isKnownModel: true
|
|
5424
5761
|
};
|
|
5425
5762
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
@@ -5428,6 +5765,8 @@ function getModelCapabilities(modelId) {
|
|
|
5428
5765
|
supportsStructuredOutput: true,
|
|
5429
5766
|
rejectsSamplingParameters: false,
|
|
5430
5767
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5768
|
+
rejectsThinkingDisabled: false,
|
|
5769
|
+
rejectsForcedToolUse: false,
|
|
5431
5770
|
isKnownModel: true
|
|
5432
5771
|
};
|
|
5433
5772
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
@@ -5436,6 +5775,8 @@ function getModelCapabilities(modelId) {
|
|
|
5436
5775
|
supportsStructuredOutput: true,
|
|
5437
5776
|
rejectsSamplingParameters: false,
|
|
5438
5777
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5778
|
+
rejectsThinkingDisabled: false,
|
|
5779
|
+
rejectsForcedToolUse: false,
|
|
5439
5780
|
isKnownModel: true
|
|
5440
5781
|
};
|
|
5441
5782
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
@@ -5444,6 +5785,8 @@ function getModelCapabilities(modelId) {
|
|
|
5444
5785
|
supportsStructuredOutput: false,
|
|
5445
5786
|
rejectsSamplingParameters: false,
|
|
5446
5787
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5788
|
+
rejectsThinkingDisabled: false,
|
|
5789
|
+
rejectsForcedToolUse: false,
|
|
5447
5790
|
isKnownModel: true
|
|
5448
5791
|
};
|
|
5449
5792
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
@@ -5452,6 +5795,8 @@ function getModelCapabilities(modelId) {
|
|
|
5452
5795
|
supportsStructuredOutput: false,
|
|
5453
5796
|
rejectsSamplingParameters: false,
|
|
5454
5797
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5798
|
+
rejectsThinkingDisabled: false,
|
|
5799
|
+
rejectsForcedToolUse: false,
|
|
5455
5800
|
isKnownModel: true
|
|
5456
5801
|
};
|
|
5457
5802
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
@@ -5460,6 +5805,8 @@ function getModelCapabilities(modelId) {
|
|
|
5460
5805
|
supportsStructuredOutput: false,
|
|
5461
5806
|
rejectsSamplingParameters: false,
|
|
5462
5807
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5808
|
+
rejectsThinkingDisabled: false,
|
|
5809
|
+
rejectsForcedToolUse: false,
|
|
5463
5810
|
isKnownModel: true
|
|
5464
5811
|
};
|
|
5465
5812
|
} else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
|
|
@@ -5468,6 +5815,8 @@ function getModelCapabilities(modelId) {
|
|
|
5468
5815
|
supportsStructuredOutput: false,
|
|
5469
5816
|
rejectsSamplingParameters: false,
|
|
5470
5817
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5818
|
+
rejectsThinkingDisabled: false,
|
|
5819
|
+
rejectsForcedToolUse: false,
|
|
5471
5820
|
isKnownModel: false
|
|
5472
5821
|
};
|
|
5473
5822
|
} else if (modelId.includes("claude-")) {
|
|
@@ -5476,6 +5825,8 @@ function getModelCapabilities(modelId) {
|
|
|
5476
5825
|
supportsStructuredOutput: true,
|
|
5477
5826
|
rejectsSamplingParameters: true,
|
|
5478
5827
|
rejectsThinkingDisabledAboveHighEffort: true,
|
|
5828
|
+
rejectsThinkingDisabled: false,
|
|
5829
|
+
rejectsForcedToolUse: false,
|
|
5479
5830
|
isKnownModel: false
|
|
5480
5831
|
};
|
|
5481
5832
|
} else {
|
|
@@ -5484,6 +5835,8 @@ function getModelCapabilities(modelId) {
|
|
|
5484
5835
|
supportsStructuredOutput: false,
|
|
5485
5836
|
rejectsSamplingParameters: false,
|
|
5486
5837
|
rejectsThinkingDisabledAboveHighEffort: false,
|
|
5838
|
+
rejectsThinkingDisabled: false,
|
|
5839
|
+
rejectsForcedToolUse: false,
|
|
5487
5840
|
isKnownModel: false
|
|
5488
5841
|
};
|
|
5489
5842
|
}
|
|
@@ -5499,7 +5852,7 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
5499
5852
|
hasWebTool20260209 = true;
|
|
5500
5853
|
continue;
|
|
5501
5854
|
}
|
|
5502
|
-
if (tool.name === "code_execution") {
|
|
5855
|
+
if ("name" in tool && tool.name === "code_execution") {
|
|
5503
5856
|
hasCodeExecutionTool = true;
|
|
5504
5857
|
break;
|
|
5505
5858
|
}
|
|
@@ -5544,44 +5897,44 @@ function mapAnthropicStopDetails(stopDetails) {
|
|
|
5544
5897
|
}
|
|
5545
5898
|
|
|
5546
5899
|
// src/tool/bash_20241022.ts
|
|
5547
|
-
var
|
|
5548
|
-
var
|
|
5549
|
-
var bash_20241022InputSchema = (0,
|
|
5550
|
-
() => (0,
|
|
5551
|
-
|
|
5552
|
-
command:
|
|
5553
|
-
restart:
|
|
5900
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
5901
|
+
var import_v415 = require("zod/v4");
|
|
5902
|
+
var bash_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
5903
|
+
() => (0, import_provider_utils17.zodSchema)(
|
|
5904
|
+
import_v415.z.object({
|
|
5905
|
+
command: import_v415.z.string(),
|
|
5906
|
+
restart: import_v415.z.boolean().optional()
|
|
5554
5907
|
})
|
|
5555
5908
|
)
|
|
5556
5909
|
);
|
|
5557
|
-
var bash_20241022 = (0,
|
|
5910
|
+
var bash_20241022 = (0, import_provider_utils17.createProviderToolFactory)({
|
|
5558
5911
|
id: "anthropic.bash_20241022",
|
|
5559
5912
|
inputSchema: bash_20241022InputSchema
|
|
5560
5913
|
});
|
|
5561
5914
|
|
|
5562
5915
|
// src/tool/bash_20250124.ts
|
|
5563
|
-
var
|
|
5564
|
-
var
|
|
5565
|
-
var bash_20250124InputSchema = (0,
|
|
5566
|
-
() => (0,
|
|
5567
|
-
|
|
5568
|
-
command:
|
|
5569
|
-
restart:
|
|
5916
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
5917
|
+
var import_v416 = require("zod/v4");
|
|
5918
|
+
var bash_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
5919
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
5920
|
+
import_v416.z.object({
|
|
5921
|
+
command: import_v416.z.string(),
|
|
5922
|
+
restart: import_v416.z.boolean().optional()
|
|
5570
5923
|
})
|
|
5571
5924
|
)
|
|
5572
5925
|
);
|
|
5573
|
-
var bash_20250124 = (0,
|
|
5926
|
+
var bash_20250124 = (0, import_provider_utils18.createProviderToolFactory)({
|
|
5574
5927
|
id: "anthropic.bash_20250124",
|
|
5575
5928
|
inputSchema: bash_20250124InputSchema
|
|
5576
5929
|
});
|
|
5577
5930
|
|
|
5578
5931
|
// src/tool/computer_20241022.ts
|
|
5579
|
-
var
|
|
5580
|
-
var
|
|
5581
|
-
var computer_20241022InputSchema = (0,
|
|
5582
|
-
() => (0,
|
|
5583
|
-
|
|
5584
|
-
action:
|
|
5932
|
+
var import_provider_utils19 = require("@ai-sdk/provider-utils");
|
|
5933
|
+
var import_v417 = require("zod/v4");
|
|
5934
|
+
var computer_20241022InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
5935
|
+
() => (0, import_provider_utils19.zodSchema)(
|
|
5936
|
+
import_v417.z.object({
|
|
5937
|
+
action: import_v417.z.enum([
|
|
5585
5938
|
"key",
|
|
5586
5939
|
"type",
|
|
5587
5940
|
"mouse_move",
|
|
@@ -5593,23 +5946,23 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
5593
5946
|
"screenshot",
|
|
5594
5947
|
"cursor_position"
|
|
5595
5948
|
]),
|
|
5596
|
-
coordinate:
|
|
5597
|
-
text:
|
|
5949
|
+
coordinate: import_v417.z.array(import_v417.z.number().int()).optional(),
|
|
5950
|
+
text: import_v417.z.string().optional()
|
|
5598
5951
|
})
|
|
5599
5952
|
)
|
|
5600
5953
|
);
|
|
5601
|
-
var computer_20241022 = (0,
|
|
5954
|
+
var computer_20241022 = (0, import_provider_utils19.createProviderToolFactory)({
|
|
5602
5955
|
id: "anthropic.computer_20241022",
|
|
5603
5956
|
inputSchema: computer_20241022InputSchema
|
|
5604
5957
|
});
|
|
5605
5958
|
|
|
5606
5959
|
// src/tool/computer_20250124.ts
|
|
5607
|
-
var
|
|
5608
|
-
var
|
|
5609
|
-
var computer_20250124InputSchema = (0,
|
|
5610
|
-
() => (0,
|
|
5611
|
-
|
|
5612
|
-
action:
|
|
5960
|
+
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
5961
|
+
var import_v418 = require("zod/v4");
|
|
5962
|
+
var computer_20250124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
5963
|
+
() => (0, import_provider_utils20.zodSchema)(
|
|
5964
|
+
import_v418.z.object({
|
|
5965
|
+
action: import_v418.z.enum([
|
|
5613
5966
|
"key",
|
|
5614
5967
|
"hold_key",
|
|
5615
5968
|
"type",
|
|
@@ -5627,27 +5980,27 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
5627
5980
|
"wait",
|
|
5628
5981
|
"screenshot"
|
|
5629
5982
|
]),
|
|
5630
|
-
coordinate:
|
|
5631
|
-
duration:
|
|
5632
|
-
scroll_amount:
|
|
5633
|
-
scroll_direction:
|
|
5634
|
-
start_coordinate:
|
|
5635
|
-
text:
|
|
5983
|
+
coordinate: import_v418.z.tuple([import_v418.z.number().int(), import_v418.z.number().int()]).optional(),
|
|
5984
|
+
duration: import_v418.z.number().optional(),
|
|
5985
|
+
scroll_amount: import_v418.z.number().optional(),
|
|
5986
|
+
scroll_direction: import_v418.z.enum(["up", "down", "left", "right"]).optional(),
|
|
5987
|
+
start_coordinate: import_v418.z.tuple([import_v418.z.number().int(), import_v418.z.number().int()]).optional(),
|
|
5988
|
+
text: import_v418.z.string().optional()
|
|
5636
5989
|
})
|
|
5637
5990
|
)
|
|
5638
5991
|
);
|
|
5639
|
-
var computer_20250124 = (0,
|
|
5992
|
+
var computer_20250124 = (0, import_provider_utils20.createProviderToolFactory)({
|
|
5640
5993
|
id: "anthropic.computer_20250124",
|
|
5641
5994
|
inputSchema: computer_20250124InputSchema
|
|
5642
5995
|
});
|
|
5643
5996
|
|
|
5644
5997
|
// src/tool/computer_20251124.ts
|
|
5645
|
-
var
|
|
5646
|
-
var
|
|
5647
|
-
var computer_20251124InputSchema = (0,
|
|
5648
|
-
() => (0,
|
|
5649
|
-
|
|
5650
|
-
action:
|
|
5998
|
+
var import_provider_utils21 = require("@ai-sdk/provider-utils");
|
|
5999
|
+
var import_v419 = require("zod/v4");
|
|
6000
|
+
var computer_20251124InputSchema = (0, import_provider_utils21.lazySchema)(
|
|
6001
|
+
() => (0, import_provider_utils21.zodSchema)(
|
|
6002
|
+
import_v419.z.object({
|
|
6003
|
+
action: import_v419.z.enum([
|
|
5651
6004
|
"key",
|
|
5652
6005
|
"hold_key",
|
|
5653
6006
|
"type",
|
|
@@ -5666,97 +6019,75 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
5666
6019
|
"screenshot",
|
|
5667
6020
|
"zoom"
|
|
5668
6021
|
]),
|
|
5669
|
-
coordinate:
|
|
5670
|
-
duration:
|
|
5671
|
-
region:
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
6022
|
+
coordinate: import_v419.z.tuple([import_v419.z.number().int(), import_v419.z.number().int()]).optional(),
|
|
6023
|
+
duration: import_v419.z.number().optional(),
|
|
6024
|
+
region: import_v419.z.tuple([
|
|
6025
|
+
import_v419.z.number().int(),
|
|
6026
|
+
import_v419.z.number().int(),
|
|
6027
|
+
import_v419.z.number().int(),
|
|
6028
|
+
import_v419.z.number().int()
|
|
5676
6029
|
]).optional(),
|
|
5677
|
-
scroll_amount:
|
|
5678
|
-
scroll_direction:
|
|
5679
|
-
start_coordinate:
|
|
5680
|
-
text:
|
|
6030
|
+
scroll_amount: import_v419.z.number().optional(),
|
|
6031
|
+
scroll_direction: import_v419.z.enum(["up", "down", "left", "right"]).optional(),
|
|
6032
|
+
start_coordinate: import_v419.z.tuple([import_v419.z.number().int(), import_v419.z.number().int()]).optional(),
|
|
6033
|
+
text: import_v419.z.string().optional()
|
|
5681
6034
|
})
|
|
5682
6035
|
)
|
|
5683
6036
|
);
|
|
5684
|
-
var computer_20251124 = (0,
|
|
6037
|
+
var computer_20251124 = (0, import_provider_utils21.createProviderToolFactory)({
|
|
5685
6038
|
id: "anthropic.computer_20251124",
|
|
5686
6039
|
inputSchema: computer_20251124InputSchema
|
|
5687
6040
|
});
|
|
5688
6041
|
|
|
5689
6042
|
// src/tool/memory_20250818.ts
|
|
5690
|
-
var
|
|
5691
|
-
var
|
|
5692
|
-
var memory_20250818InputSchema = (0,
|
|
5693
|
-
() => (0,
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
command:
|
|
5697
|
-
path:
|
|
5698
|
-
view_range:
|
|
6043
|
+
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
|
6044
|
+
var import_v420 = require("zod/v4");
|
|
6045
|
+
var memory_20250818InputSchema = (0, import_provider_utils22.lazySchema)(
|
|
6046
|
+
() => (0, import_provider_utils22.zodSchema)(
|
|
6047
|
+
import_v420.z.discriminatedUnion("command", [
|
|
6048
|
+
import_v420.z.object({
|
|
6049
|
+
command: import_v420.z.literal("view"),
|
|
6050
|
+
path: import_v420.z.string(),
|
|
6051
|
+
view_range: import_v420.z.tuple([import_v420.z.number(), import_v420.z.number()]).optional()
|
|
5699
6052
|
}),
|
|
5700
|
-
|
|
5701
|
-
command:
|
|
5702
|
-
path:
|
|
5703
|
-
file_text:
|
|
6053
|
+
import_v420.z.object({
|
|
6054
|
+
command: import_v420.z.literal("create"),
|
|
6055
|
+
path: import_v420.z.string(),
|
|
6056
|
+
file_text: import_v420.z.string()
|
|
5704
6057
|
}),
|
|
5705
|
-
|
|
5706
|
-
command:
|
|
5707
|
-
path:
|
|
5708
|
-
old_str:
|
|
5709
|
-
new_str:
|
|
6058
|
+
import_v420.z.object({
|
|
6059
|
+
command: import_v420.z.literal("str_replace"),
|
|
6060
|
+
path: import_v420.z.string(),
|
|
6061
|
+
old_str: import_v420.z.string(),
|
|
6062
|
+
new_str: import_v420.z.string()
|
|
5710
6063
|
}),
|
|
5711
|
-
|
|
5712
|
-
command:
|
|
5713
|
-
path:
|
|
5714
|
-
insert_line:
|
|
5715
|
-
insert_text:
|
|
6064
|
+
import_v420.z.object({
|
|
6065
|
+
command: import_v420.z.literal("insert"),
|
|
6066
|
+
path: import_v420.z.string(),
|
|
6067
|
+
insert_line: import_v420.z.number(),
|
|
6068
|
+
insert_text: import_v420.z.string()
|
|
5716
6069
|
}),
|
|
5717
|
-
|
|
5718
|
-
command:
|
|
5719
|
-
path:
|
|
6070
|
+
import_v420.z.object({
|
|
6071
|
+
command: import_v420.z.literal("delete"),
|
|
6072
|
+
path: import_v420.z.string()
|
|
5720
6073
|
}),
|
|
5721
|
-
|
|
5722
|
-
command:
|
|
5723
|
-
old_path:
|
|
5724
|
-
new_path:
|
|
6074
|
+
import_v420.z.object({
|
|
6075
|
+
command: import_v420.z.literal("rename"),
|
|
6076
|
+
old_path: import_v420.z.string(),
|
|
6077
|
+
new_path: import_v420.z.string()
|
|
5725
6078
|
})
|
|
5726
6079
|
])
|
|
5727
6080
|
)
|
|
5728
6081
|
);
|
|
5729
|
-
var memory_20250818 = (0,
|
|
6082
|
+
var memory_20250818 = (0, import_provider_utils22.createProviderToolFactory)({
|
|
5730
6083
|
id: "anthropic.memory_20250818",
|
|
5731
6084
|
inputSchema: memory_20250818InputSchema
|
|
5732
6085
|
});
|
|
5733
6086
|
|
|
5734
6087
|
// src/tool/text-editor_20241022.ts
|
|
5735
|
-
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
|
5736
|
-
var import_v420 = require("zod/v4");
|
|
5737
|
-
var textEditor_20241022InputSchema = (0, import_provider_utils22.lazySchema)(
|
|
5738
|
-
() => (0, import_provider_utils22.zodSchema)(
|
|
5739
|
-
import_v420.z.object({
|
|
5740
|
-
command: import_v420.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5741
|
-
path: import_v420.z.string(),
|
|
5742
|
-
file_text: import_v420.z.string().optional(),
|
|
5743
|
-
insert_line: import_v420.z.number().int().optional(),
|
|
5744
|
-
new_str: import_v420.z.string().optional(),
|
|
5745
|
-
insert_text: import_v420.z.string().optional(),
|
|
5746
|
-
old_str: import_v420.z.string().optional(),
|
|
5747
|
-
view_range: import_v420.z.array(import_v420.z.number().int()).optional()
|
|
5748
|
-
})
|
|
5749
|
-
)
|
|
5750
|
-
);
|
|
5751
|
-
var textEditor_20241022 = (0, import_provider_utils22.createProviderToolFactory)({
|
|
5752
|
-
id: "anthropic.text_editor_20241022",
|
|
5753
|
-
inputSchema: textEditor_20241022InputSchema
|
|
5754
|
-
});
|
|
5755
|
-
|
|
5756
|
-
// src/tool/text-editor_20250124.ts
|
|
5757
6088
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
5758
6089
|
var import_v421 = require("zod/v4");
|
|
5759
|
-
var
|
|
6090
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils23.lazySchema)(
|
|
5760
6091
|
() => (0, import_provider_utils23.zodSchema)(
|
|
5761
6092
|
import_v421.z.object({
|
|
5762
6093
|
command: import_v421.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -5770,18 +6101,18 @@ var textEditor_20250124InputSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
5770
6101
|
})
|
|
5771
6102
|
)
|
|
5772
6103
|
);
|
|
5773
|
-
var
|
|
5774
|
-
id: "anthropic.
|
|
5775
|
-
inputSchema:
|
|
6104
|
+
var textEditor_20241022 = (0, import_provider_utils23.createProviderToolFactory)({
|
|
6105
|
+
id: "anthropic.text_editor_20241022",
|
|
6106
|
+
inputSchema: textEditor_20241022InputSchema
|
|
5776
6107
|
});
|
|
5777
6108
|
|
|
5778
|
-
// src/tool/text-
|
|
6109
|
+
// src/tool/text-editor_20250124.ts
|
|
5779
6110
|
var import_provider_utils24 = require("@ai-sdk/provider-utils");
|
|
5780
6111
|
var import_v422 = require("zod/v4");
|
|
5781
|
-
var
|
|
6112
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils24.lazySchema)(
|
|
5782
6113
|
() => (0, import_provider_utils24.zodSchema)(
|
|
5783
6114
|
import_v422.z.object({
|
|
5784
|
-
command: import_v422.z.enum(["view", "create", "str_replace", "insert"]),
|
|
6115
|
+
command: import_v422.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5785
6116
|
path: import_v422.z.string(),
|
|
5786
6117
|
file_text: import_v422.z.string().optional(),
|
|
5787
6118
|
insert_line: import_v422.z.number().int().optional(),
|
|
@@ -5792,40 +6123,62 @@ var textEditor_20250429InputSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
5792
6123
|
})
|
|
5793
6124
|
)
|
|
5794
6125
|
);
|
|
5795
|
-
var
|
|
5796
|
-
id: "anthropic.
|
|
5797
|
-
inputSchema:
|
|
6126
|
+
var textEditor_20250124 = (0, import_provider_utils24.createProviderToolFactory)({
|
|
6127
|
+
id: "anthropic.text_editor_20250124",
|
|
6128
|
+
inputSchema: textEditor_20250124InputSchema
|
|
5798
6129
|
});
|
|
5799
6130
|
|
|
5800
|
-
// src/tool/
|
|
6131
|
+
// src/tool/text-editor_20250429.ts
|
|
5801
6132
|
var import_provider_utils25 = require("@ai-sdk/provider-utils");
|
|
5802
6133
|
var import_v423 = require("zod/v4");
|
|
5803
|
-
var
|
|
6134
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils25.lazySchema)(
|
|
5804
6135
|
() => (0, import_provider_utils25.zodSchema)(
|
|
5805
|
-
import_v423.z.
|
|
5806
|
-
import_v423.z.
|
|
5807
|
-
|
|
5808
|
-
|
|
6136
|
+
import_v423.z.object({
|
|
6137
|
+
command: import_v423.z.enum(["view", "create", "str_replace", "insert"]),
|
|
6138
|
+
path: import_v423.z.string(),
|
|
6139
|
+
file_text: import_v423.z.string().optional(),
|
|
6140
|
+
insert_line: import_v423.z.number().int().optional(),
|
|
6141
|
+
new_str: import_v423.z.string().optional(),
|
|
6142
|
+
insert_text: import_v423.z.string().optional(),
|
|
6143
|
+
old_str: import_v423.z.string().optional(),
|
|
6144
|
+
view_range: import_v423.z.array(import_v423.z.number().int()).optional()
|
|
6145
|
+
})
|
|
6146
|
+
)
|
|
6147
|
+
);
|
|
6148
|
+
var textEditor_20250429 = (0, import_provider_utils25.createProviderToolFactory)({
|
|
6149
|
+
id: "anthropic.text_editor_20250429",
|
|
6150
|
+
inputSchema: textEditor_20250429InputSchema
|
|
6151
|
+
});
|
|
6152
|
+
|
|
6153
|
+
// src/tool/tool-search-bm25_20251119.ts
|
|
6154
|
+
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
|
6155
|
+
var import_v424 = require("zod/v4");
|
|
6156
|
+
var toolSearchBm25_20251119OutputSchema = (0, import_provider_utils26.lazySchema)(
|
|
6157
|
+
() => (0, import_provider_utils26.zodSchema)(
|
|
6158
|
+
import_v424.z.array(
|
|
6159
|
+
import_v424.z.object({
|
|
6160
|
+
type: import_v424.z.literal("tool_reference"),
|
|
6161
|
+
toolName: import_v424.z.string()
|
|
5809
6162
|
})
|
|
5810
6163
|
)
|
|
5811
6164
|
)
|
|
5812
6165
|
);
|
|
5813
|
-
var toolSearchBm25_20251119InputSchema = (0,
|
|
5814
|
-
() => (0,
|
|
5815
|
-
|
|
6166
|
+
var toolSearchBm25_20251119InputSchema = (0, import_provider_utils26.lazySchema)(
|
|
6167
|
+
() => (0, import_provider_utils26.zodSchema)(
|
|
6168
|
+
import_v424.z.object({
|
|
5816
6169
|
/**
|
|
5817
6170
|
* A natural language query to search for tools.
|
|
5818
6171
|
* Claude will use BM25 text search to find relevant tools.
|
|
5819
6172
|
*/
|
|
5820
|
-
query:
|
|
6173
|
+
query: import_v424.z.string(),
|
|
5821
6174
|
/**
|
|
5822
6175
|
* Maximum number of tools to return. Optional.
|
|
5823
6176
|
*/
|
|
5824
|
-
limit:
|
|
6177
|
+
limit: import_v424.z.number().optional()
|
|
5825
6178
|
})
|
|
5826
6179
|
)
|
|
5827
6180
|
);
|
|
5828
|
-
var factory11 = (0,
|
|
6181
|
+
var factory11 = (0, import_provider_utils26.createProviderToolFactoryWithOutputSchema)({
|
|
5829
6182
|
id: "anthropic.tool_search_bm25_20251119",
|
|
5830
6183
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
5831
6184
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
@@ -5951,6 +6304,29 @@ var anthropicTools = {
|
|
|
5951
6304
|
* @param enableZoom - Enable zoom action. Set to true to allow Claude to zoom into specific screen regions. Default: false.
|
|
5952
6305
|
*/
|
|
5953
6306
|
computer_20251124,
|
|
6307
|
+
/**
|
|
6308
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
6309
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
6310
|
+
* (`computer_20251124` and earlier) on newer models.
|
|
6311
|
+
*
|
|
6312
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
6313
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
6314
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
6315
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
6316
|
+
* in one turn.
|
|
6317
|
+
*
|
|
6318
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
6319
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
6320
|
+
*
|
|
6321
|
+
* Does not require a beta header.
|
|
6322
|
+
*
|
|
6323
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
6324
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
6325
|
+
*
|
|
6326
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
6327
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
6328
|
+
*/
|
|
6329
|
+
computerToolset_20260801,
|
|
5954
6330
|
/**
|
|
5955
6331
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
5956
6332
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -6070,13 +6446,13 @@ var anthropicTools = {
|
|
|
6070
6446
|
var ANTHROPIC_API_URL = "https://api.anthropic.com";
|
|
6071
6447
|
var ANTHROPIC_API_VERSIONED_URL = `${ANTHROPIC_API_URL}/v1`;
|
|
6072
6448
|
function normalizeBaseURL(baseURL) {
|
|
6073
|
-
const baseURLWithoutTrailingSlash = (0,
|
|
6449
|
+
const baseURLWithoutTrailingSlash = (0, import_provider_utils27.withoutTrailingSlash)(baseURL);
|
|
6074
6450
|
return baseURLWithoutTrailingSlash === ANTHROPIC_API_URL ? ANTHROPIC_API_VERSIONED_URL : baseURLWithoutTrailingSlash;
|
|
6075
6451
|
}
|
|
6076
6452
|
function createAnthropic(options = {}) {
|
|
6077
6453
|
var _a, _b;
|
|
6078
6454
|
const baseURL = (_a = normalizeBaseURL(
|
|
6079
|
-
(0,
|
|
6455
|
+
(0, import_provider_utils27.loadOptionalSetting)({
|
|
6080
6456
|
settingValue: options.baseURL,
|
|
6081
6457
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
6082
6458
|
})
|
|
@@ -6090,13 +6466,13 @@ function createAnthropic(options = {}) {
|
|
|
6090
6466
|
}
|
|
6091
6467
|
const getHeaders = () => {
|
|
6092
6468
|
const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
|
|
6093
|
-
"x-api-key": (0,
|
|
6469
|
+
"x-api-key": (0, import_provider_utils27.loadApiKey)({
|
|
6094
6470
|
apiKey: options.apiKey,
|
|
6095
6471
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
6096
6472
|
description: "Anthropic"
|
|
6097
6473
|
})
|
|
6098
6474
|
};
|
|
6099
|
-
return (0,
|
|
6475
|
+
return (0, import_provider_utils27.withUserAgentSuffix)(
|
|
6100
6476
|
{
|
|
6101
6477
|
"anthropic-version": "2023-06-01",
|
|
6102
6478
|
...authHeaders,
|
|
@@ -6112,7 +6488,7 @@ function createAnthropic(options = {}) {
|
|
|
6112
6488
|
baseURL,
|
|
6113
6489
|
headers: getHeaders,
|
|
6114
6490
|
fetch: options.fetch,
|
|
6115
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
6491
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils27.generateId,
|
|
6116
6492
|
supportedUrls: () => ({
|
|
6117
6493
|
"image/*": [/^https?:\/\/.*$/],
|
|
6118
6494
|
"application/pdf": [/^https?:\/\/.*$/]
|