@fairyhunter13/ai-anthropic 3.0.58-fork.2 → 3.0.58-fork.21
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 +101 -4
- package/dist/index.d.mts +85 -6
- package/dist/index.d.ts +85 -6
- package/dist/index.js +696 -376
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +671 -347
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +124 -14
- package/dist/internal/index.d.ts +124 -14
- package/dist/internal/index.js +690 -368
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +670 -345
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +53 -6
- package/package.json +7 -7
- package/src/anthropic-messages-api.ts +31 -7
- package/src/anthropic-messages-language-model.ts +272 -36
- package/src/anthropic-messages-options.ts +24 -0
- package/src/anthropic-prepare-tools.ts +50 -14
- package/src/anthropic-provider.ts +8 -8
- package/src/anthropic-tools.ts +18 -0
- package/src/convert-anthropic-messages-usage.ts +2 -2
- package/src/convert-to-anthropic-messages-prompt.ts +47 -27
- package/src/get-cache-control.ts +5 -5
- package/src/internal/index.ts +4 -1
- package/src/map-anthropic-stop-reason.ts +2 -2
- package/src/tool/web-fetch-20260309.ts +182 -0
- package/src/tool/web-search_20260209.ts +17 -0
package/dist/index.js
CHANGED
|
@@ -18,25 +18,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
VERSION: () => VERSION,
|
|
24
24
|
anthropic: () => anthropic,
|
|
25
25
|
createAnthropic: () => createAnthropic,
|
|
26
26
|
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
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 ? "
|
|
35
|
+
var VERSION = true ? "4.0.0-beta.12" : "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");
|
|
@@ -881,6 +881,20 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
881
881
|
type: import_v43.z.literal("ephemeral"),
|
|
882
882
|
ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
|
|
883
883
|
}).optional(),
|
|
884
|
+
/**
|
|
885
|
+
* Metadata to include with the request.
|
|
886
|
+
*
|
|
887
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
888
|
+
*/
|
|
889
|
+
metadata: import_v43.z.object({
|
|
890
|
+
/**
|
|
891
|
+
* An external identifier for the user associated with the request.
|
|
892
|
+
*
|
|
893
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
894
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
895
|
+
*/
|
|
896
|
+
userId: import_v43.z.string().optional()
|
|
897
|
+
}).optional(),
|
|
884
898
|
/**
|
|
885
899
|
* MCP servers to be utilized in this request.
|
|
886
900
|
*/
|
|
@@ -942,6 +956,12 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
942
956
|
* Example: Setting prefill to '{"' will make the model start its response with '{"'
|
|
943
957
|
*/
|
|
944
958
|
prefill: import_v43.z.string().optional(),
|
|
959
|
+
/**
|
|
960
|
+
* Service tier selection.
|
|
961
|
+
* - 'auto': Allow Anthropic to pick standard or priority based on availability.
|
|
962
|
+
* See https://docs.anthropic.com/en/api/messages
|
|
963
|
+
*/
|
|
964
|
+
serviceTier: import_v43.z.enum(["auto"]).optional(),
|
|
945
965
|
contextManagement: import_v43.z.object({
|
|
946
966
|
edits: import_v43.z.array(
|
|
947
967
|
import_v43.z.discriminatedUnion("type", [
|
|
@@ -1085,7 +1105,14 @@ var webSearch_20260209ArgsSchema = (0, import_provider_utils5.lazySchema)(
|
|
|
1085
1105
|
region: import_v45.z.string().optional(),
|
|
1086
1106
|
country: import_v45.z.string().optional(),
|
|
1087
1107
|
timezone: import_v45.z.string().optional()
|
|
1088
|
-
}).optional()
|
|
1108
|
+
}).optional(),
|
|
1109
|
+
allowedCallers: import_v45.z.array(
|
|
1110
|
+
import_v45.z.enum([
|
|
1111
|
+
"direct",
|
|
1112
|
+
"code_execution_20250825",
|
|
1113
|
+
"code_execution_20260120"
|
|
1114
|
+
])
|
|
1115
|
+
).optional()
|
|
1089
1116
|
})
|
|
1090
1117
|
)
|
|
1091
1118
|
);
|
|
@@ -1168,21 +1195,31 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
1168
1195
|
return factory3(args);
|
|
1169
1196
|
};
|
|
1170
1197
|
|
|
1171
|
-
// src/tool/web-fetch-
|
|
1198
|
+
// src/tool/web-fetch-20260309.ts
|
|
1172
1199
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1173
1200
|
var import_v47 = require("zod/v4");
|
|
1174
|
-
var
|
|
1201
|
+
var webFetch_20260309ArgsSchema = (0, import_provider_utils7.lazySchema)(
|
|
1175
1202
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1176
1203
|
import_v47.z.object({
|
|
1177
1204
|
maxUses: import_v47.z.number().optional(),
|
|
1178
1205
|
allowedDomains: import_v47.z.array(import_v47.z.string()).optional(),
|
|
1179
1206
|
blockedDomains: import_v47.z.array(import_v47.z.string()).optional(),
|
|
1180
1207
|
citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
|
|
1181
|
-
maxContentTokens: import_v47.z.number().optional()
|
|
1208
|
+
maxContentTokens: import_v47.z.number().optional(),
|
|
1209
|
+
allowedCallers: import_v47.z.array(
|
|
1210
|
+
import_v47.z.enum([
|
|
1211
|
+
"direct",
|
|
1212
|
+
"code_execution_20250825",
|
|
1213
|
+
"code_execution_20260120"
|
|
1214
|
+
])
|
|
1215
|
+
).optional(),
|
|
1216
|
+
useCache: import_v47.z.boolean().optional(),
|
|
1217
|
+
deferLoading: import_v47.z.boolean().optional(),
|
|
1218
|
+
strict: import_v47.z.boolean().optional()
|
|
1182
1219
|
})
|
|
1183
1220
|
)
|
|
1184
1221
|
);
|
|
1185
|
-
var
|
|
1222
|
+
var webFetch_20260309OutputSchema = (0, import_provider_utils7.lazySchema)(
|
|
1186
1223
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1187
1224
|
import_v47.z.object({
|
|
1188
1225
|
type: import_v47.z.literal("web_fetch_result"),
|
|
@@ -1208,7 +1245,7 @@ var webFetch_20260209OutputSchema = (0, import_provider_utils7.lazySchema)(
|
|
|
1208
1245
|
})
|
|
1209
1246
|
)
|
|
1210
1247
|
);
|
|
1211
|
-
var
|
|
1248
|
+
var webFetch_20260309InputSchema = (0, import_provider_utils7.lazySchema)(
|
|
1212
1249
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1213
1250
|
import_v47.z.object({
|
|
1214
1251
|
url: import_v47.z.string()
|
|
@@ -1216,19 +1253,19 @@ var webFetch_20260209InputSchema = (0, import_provider_utils7.lazySchema)(
|
|
|
1216
1253
|
)
|
|
1217
1254
|
);
|
|
1218
1255
|
var factory4 = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
|
|
1219
|
-
id: "anthropic.
|
|
1220
|
-
inputSchema:
|
|
1221
|
-
outputSchema:
|
|
1256
|
+
id: "anthropic.web_fetch_20260309",
|
|
1257
|
+
inputSchema: webFetch_20260309InputSchema,
|
|
1258
|
+
outputSchema: webFetch_20260309OutputSchema,
|
|
1222
1259
|
supportsDeferredResults: true
|
|
1223
1260
|
});
|
|
1224
|
-
var
|
|
1261
|
+
var webFetch_20260309 = (args = {}) => {
|
|
1225
1262
|
return factory4(args);
|
|
1226
1263
|
};
|
|
1227
1264
|
|
|
1228
|
-
// src/tool/web-fetch-
|
|
1265
|
+
// src/tool/web-fetch-20260209.ts
|
|
1229
1266
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1230
1267
|
var import_v48 = require("zod/v4");
|
|
1231
|
-
var
|
|
1268
|
+
var webFetch_20260209ArgsSchema = (0, import_provider_utils8.lazySchema)(
|
|
1232
1269
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1233
1270
|
import_v48.z.object({
|
|
1234
1271
|
maxUses: import_v48.z.number().optional(),
|
|
@@ -1239,7 +1276,7 @@ var webFetch_20250910ArgsSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
1239
1276
|
})
|
|
1240
1277
|
)
|
|
1241
1278
|
);
|
|
1242
|
-
var
|
|
1279
|
+
var webFetch_20260209OutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
1243
1280
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1244
1281
|
import_v48.z.object({
|
|
1245
1282
|
type: import_v48.z.literal("web_fetch_result"),
|
|
@@ -1265,7 +1302,7 @@ var webFetch_20250910OutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
1265
1302
|
})
|
|
1266
1303
|
)
|
|
1267
1304
|
);
|
|
1268
|
-
var
|
|
1305
|
+
var webFetch_20260209InputSchema = (0, import_provider_utils8.lazySchema)(
|
|
1269
1306
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1270
1307
|
import_v48.z.object({
|
|
1271
1308
|
url: import_v48.z.string()
|
|
@@ -1273,23 +1310,81 @@ var webFetch_20250910InputSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
1273
1310
|
)
|
|
1274
1311
|
);
|
|
1275
1312
|
var factory5 = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
1313
|
+
id: "anthropic.web_fetch_20260209",
|
|
1314
|
+
inputSchema: webFetch_20260209InputSchema,
|
|
1315
|
+
outputSchema: webFetch_20260209OutputSchema,
|
|
1316
|
+
supportsDeferredResults: true
|
|
1317
|
+
});
|
|
1318
|
+
var webFetch_20260209 = (args = {}) => {
|
|
1319
|
+
return factory5(args);
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1322
|
+
// src/tool/web-fetch-20250910.ts
|
|
1323
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1324
|
+
var import_v49 = require("zod/v4");
|
|
1325
|
+
var webFetch_20250910ArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1326
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1327
|
+
import_v49.z.object({
|
|
1328
|
+
maxUses: import_v49.z.number().optional(),
|
|
1329
|
+
allowedDomains: import_v49.z.array(import_v49.z.string()).optional(),
|
|
1330
|
+
blockedDomains: import_v49.z.array(import_v49.z.string()).optional(),
|
|
1331
|
+
citations: import_v49.z.object({ enabled: import_v49.z.boolean() }).optional(),
|
|
1332
|
+
maxContentTokens: import_v49.z.number().optional()
|
|
1333
|
+
})
|
|
1334
|
+
)
|
|
1335
|
+
);
|
|
1336
|
+
var webFetch_20250910OutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
1337
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1338
|
+
import_v49.z.object({
|
|
1339
|
+
type: import_v49.z.literal("web_fetch_result"),
|
|
1340
|
+
url: import_v49.z.string(),
|
|
1341
|
+
content: import_v49.z.object({
|
|
1342
|
+
type: import_v49.z.literal("document"),
|
|
1343
|
+
title: import_v49.z.string().nullable(),
|
|
1344
|
+
citations: import_v49.z.object({ enabled: import_v49.z.boolean() }).optional(),
|
|
1345
|
+
source: import_v49.z.union([
|
|
1346
|
+
import_v49.z.object({
|
|
1347
|
+
type: import_v49.z.literal("base64"),
|
|
1348
|
+
mediaType: import_v49.z.literal("application/pdf"),
|
|
1349
|
+
data: import_v49.z.string()
|
|
1350
|
+
}),
|
|
1351
|
+
import_v49.z.object({
|
|
1352
|
+
type: import_v49.z.literal("text"),
|
|
1353
|
+
mediaType: import_v49.z.literal("text/plain"),
|
|
1354
|
+
data: import_v49.z.string()
|
|
1355
|
+
})
|
|
1356
|
+
])
|
|
1357
|
+
}),
|
|
1358
|
+
retrievedAt: import_v49.z.string().nullable()
|
|
1359
|
+
})
|
|
1360
|
+
)
|
|
1361
|
+
);
|
|
1362
|
+
var webFetch_20250910InputSchema = (0, import_provider_utils9.lazySchema)(
|
|
1363
|
+
() => (0, import_provider_utils9.zodSchema)(
|
|
1364
|
+
import_v49.z.object({
|
|
1365
|
+
url: import_v49.z.string()
|
|
1366
|
+
})
|
|
1367
|
+
)
|
|
1368
|
+
);
|
|
1369
|
+
var factory6 = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
|
|
1276
1370
|
id: "anthropic.web_fetch_20250910",
|
|
1277
1371
|
inputSchema: webFetch_20250910InputSchema,
|
|
1278
1372
|
outputSchema: webFetch_20250910OutputSchema,
|
|
1279
1373
|
supportsDeferredResults: true
|
|
1280
1374
|
});
|
|
1281
1375
|
var webFetch_20250910 = (args = {}) => {
|
|
1282
|
-
return
|
|
1376
|
+
return factory6(args);
|
|
1283
1377
|
};
|
|
1284
1378
|
|
|
1285
1379
|
// src/anthropic-prepare-tools.ts
|
|
1286
|
-
var
|
|
1380
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1287
1381
|
async function prepareTools({
|
|
1288
1382
|
tools,
|
|
1289
1383
|
toolChoice,
|
|
1290
1384
|
disableParallelToolUse,
|
|
1291
1385
|
cacheControlValidator,
|
|
1292
|
-
supportsStructuredOutput
|
|
1386
|
+
supportsStructuredOutput,
|
|
1387
|
+
supportsStrictTools
|
|
1293
1388
|
}) {
|
|
1294
1389
|
var _a;
|
|
1295
1390
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1311,13 +1406,20 @@ async function prepareTools({
|
|
|
1311
1406
|
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1312
1407
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1313
1408
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1409
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1410
|
+
toolWarnings.push({
|
|
1411
|
+
type: "unsupported",
|
|
1412
|
+
feature: "strict",
|
|
1413
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1314
1416
|
anthropicTools2.push({
|
|
1315
1417
|
name: tool.name,
|
|
1316
1418
|
description: tool.description,
|
|
1317
1419
|
input_schema: tool.inputSchema,
|
|
1318
1420
|
cache_control: cacheControl,
|
|
1319
1421
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1320
|
-
...
|
|
1422
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1321
1423
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1322
1424
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1323
1425
|
...tool.inputExamples != null ? {
|
|
@@ -1346,7 +1448,6 @@ async function prepareTools({
|
|
|
1346
1448
|
break;
|
|
1347
1449
|
}
|
|
1348
1450
|
case "anthropic.code_execution_20250825": {
|
|
1349
|
-
betas.add("code-execution-2025-08-25");
|
|
1350
1451
|
anthropicTools2.push({
|
|
1351
1452
|
type: "code_execution_20250825",
|
|
1352
1453
|
name: "code_execution"
|
|
@@ -1425,7 +1526,7 @@ async function prepareTools({
|
|
|
1425
1526
|
break;
|
|
1426
1527
|
}
|
|
1427
1528
|
case "anthropic.text_editor_20250728": {
|
|
1428
|
-
const args = await (0,
|
|
1529
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1429
1530
|
value: tool.args,
|
|
1430
1531
|
schema: textEditor_20250728ArgsSchema
|
|
1431
1532
|
});
|
|
@@ -1464,8 +1565,7 @@ async function prepareTools({
|
|
|
1464
1565
|
break;
|
|
1465
1566
|
}
|
|
1466
1567
|
case "anthropic.web_fetch_20250910": {
|
|
1467
|
-
|
|
1468
|
-
const args = await (0, import_provider_utils9.validateTypes)({
|
|
1568
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1469
1569
|
value: tool.args,
|
|
1470
1570
|
schema: webFetch_20250910ArgsSchema
|
|
1471
1571
|
});
|
|
@@ -1482,8 +1582,7 @@ async function prepareTools({
|
|
|
1482
1582
|
break;
|
|
1483
1583
|
}
|
|
1484
1584
|
case "anthropic.web_fetch_20260209": {
|
|
1485
|
-
|
|
1486
|
-
const args = await (0, import_provider_utils9.validateTypes)({
|
|
1585
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1487
1586
|
value: tool.args,
|
|
1488
1587
|
schema: webFetch_20260209ArgsSchema
|
|
1489
1588
|
});
|
|
@@ -1499,8 +1598,29 @@ async function prepareTools({
|
|
|
1499
1598
|
});
|
|
1500
1599
|
break;
|
|
1501
1600
|
}
|
|
1601
|
+
case "anthropic.web_fetch_20260309": {
|
|
1602
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1603
|
+
value: tool.args,
|
|
1604
|
+
schema: webFetch_20260309ArgsSchema
|
|
1605
|
+
});
|
|
1606
|
+
anthropicTools2.push({
|
|
1607
|
+
type: "web_fetch_20260309",
|
|
1608
|
+
name: "web_fetch",
|
|
1609
|
+
max_uses: args.maxUses,
|
|
1610
|
+
allowed_domains: args.allowedDomains,
|
|
1611
|
+
blocked_domains: args.blockedDomains,
|
|
1612
|
+
citations: args.citations,
|
|
1613
|
+
max_content_tokens: args.maxContentTokens,
|
|
1614
|
+
allowed_callers: args.allowedCallers,
|
|
1615
|
+
use_cache: args.useCache,
|
|
1616
|
+
defer_loading: args.deferLoading,
|
|
1617
|
+
strict: args.strict,
|
|
1618
|
+
cache_control: void 0
|
|
1619
|
+
});
|
|
1620
|
+
break;
|
|
1621
|
+
}
|
|
1502
1622
|
case "anthropic.web_search_20250305": {
|
|
1503
|
-
const args = await (0,
|
|
1623
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1504
1624
|
value: tool.args,
|
|
1505
1625
|
schema: webSearch_20250305ArgsSchema
|
|
1506
1626
|
});
|
|
@@ -1516,8 +1636,7 @@ async function prepareTools({
|
|
|
1516
1636
|
break;
|
|
1517
1637
|
}
|
|
1518
1638
|
case "anthropic.web_search_20260209": {
|
|
1519
|
-
|
|
1520
|
-
const args = await (0, import_provider_utils9.validateTypes)({
|
|
1639
|
+
const args = await (0, import_provider_utils10.validateTypes)({
|
|
1521
1640
|
value: tool.args,
|
|
1522
1641
|
schema: webSearch_20260209ArgsSchema
|
|
1523
1642
|
});
|
|
@@ -1528,12 +1647,12 @@ async function prepareTools({
|
|
|
1528
1647
|
allowed_domains: args.allowedDomains,
|
|
1529
1648
|
blocked_domains: args.blockedDomains,
|
|
1530
1649
|
user_location: args.userLocation,
|
|
1650
|
+
allowed_callers: args.allowedCallers,
|
|
1531
1651
|
cache_control: void 0
|
|
1532
1652
|
});
|
|
1533
1653
|
break;
|
|
1534
1654
|
}
|
|
1535
1655
|
case "anthropic.tool_search_regex_20251119": {
|
|
1536
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1537
1656
|
anthropicTools2.push({
|
|
1538
1657
|
type: "tool_search_tool_regex_20251119",
|
|
1539
1658
|
name: "tool_search_tool_regex"
|
|
@@ -1541,7 +1660,6 @@ async function prepareTools({
|
|
|
1541
1660
|
break;
|
|
1542
1661
|
}
|
|
1543
1662
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1544
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1545
1663
|
anthropicTools2.push({
|
|
1546
1664
|
type: "tool_search_tool_bm25_20251119",
|
|
1547
1665
|
name: "tool_search_tool_bm25"
|
|
@@ -1661,156 +1779,47 @@ function convertAnthropicMessagesUsage({
|
|
|
1661
1779
|
|
|
1662
1780
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
1663
1781
|
var import_provider2 = require("@ai-sdk/provider");
|
|
1664
|
-
var
|
|
1782
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
1665
1783
|
|
|
1666
1784
|
// src/tool/code-execution_20250522.ts
|
|
1667
|
-
var
|
|
1668
|
-
var
|
|
1669
|
-
var codeExecution_20250522OutputSchema = (0,
|
|
1670
|
-
() => (0,
|
|
1671
|
-
|
|
1672
|
-
type:
|
|
1673
|
-
stdout:
|
|
1674
|
-
stderr:
|
|
1675
|
-
return_code:
|
|
1676
|
-
content:
|
|
1677
|
-
|
|
1678
|
-
type:
|
|
1679
|
-
file_id:
|
|
1785
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1786
|
+
var import_v410 = require("zod/v4");
|
|
1787
|
+
var codeExecution_20250522OutputSchema = (0, import_provider_utils11.lazySchema)(
|
|
1788
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
1789
|
+
import_v410.z.object({
|
|
1790
|
+
type: import_v410.z.literal("code_execution_result"),
|
|
1791
|
+
stdout: import_v410.z.string(),
|
|
1792
|
+
stderr: import_v410.z.string(),
|
|
1793
|
+
return_code: import_v410.z.number(),
|
|
1794
|
+
content: import_v410.z.array(
|
|
1795
|
+
import_v410.z.object({
|
|
1796
|
+
type: import_v410.z.literal("code_execution_output"),
|
|
1797
|
+
file_id: import_v410.z.string()
|
|
1680
1798
|
})
|
|
1681
1799
|
).optional().default([])
|
|
1682
1800
|
})
|
|
1683
1801
|
)
|
|
1684
1802
|
);
|
|
1685
|
-
var codeExecution_20250522InputSchema = (0,
|
|
1686
|
-
() => (0,
|
|
1687
|
-
|
|
1688
|
-
code:
|
|
1803
|
+
var codeExecution_20250522InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
1804
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
1805
|
+
import_v410.z.object({
|
|
1806
|
+
code: import_v410.z.string()
|
|
1689
1807
|
})
|
|
1690
1808
|
)
|
|
1691
1809
|
);
|
|
1692
|
-
var
|
|
1810
|
+
var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
|
|
1693
1811
|
id: "anthropic.code_execution_20250522",
|
|
1694
1812
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1695
1813
|
outputSchema: codeExecution_20250522OutputSchema
|
|
1696
1814
|
});
|
|
1697
1815
|
var codeExecution_20250522 = (args = {}) => {
|
|
1698
|
-
return factory6(args);
|
|
1699
|
-
};
|
|
1700
|
-
|
|
1701
|
-
// src/tool/code-execution_20250825.ts
|
|
1702
|
-
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1703
|
-
var import_v410 = require("zod/v4");
|
|
1704
|
-
var codeExecution_20250825OutputSchema = (0, import_provider_utils11.lazySchema)(
|
|
1705
|
-
() => (0, import_provider_utils11.zodSchema)(
|
|
1706
|
-
import_v410.z.discriminatedUnion("type", [
|
|
1707
|
-
import_v410.z.object({
|
|
1708
|
-
type: import_v410.z.literal("code_execution_result"),
|
|
1709
|
-
stdout: import_v410.z.string(),
|
|
1710
|
-
stderr: import_v410.z.string(),
|
|
1711
|
-
return_code: import_v410.z.number(),
|
|
1712
|
-
content: import_v410.z.array(
|
|
1713
|
-
import_v410.z.object({
|
|
1714
|
-
type: import_v410.z.literal("code_execution_output"),
|
|
1715
|
-
file_id: import_v410.z.string()
|
|
1716
|
-
})
|
|
1717
|
-
).optional().default([])
|
|
1718
|
-
}),
|
|
1719
|
-
import_v410.z.object({
|
|
1720
|
-
type: import_v410.z.literal("bash_code_execution_result"),
|
|
1721
|
-
content: import_v410.z.array(
|
|
1722
|
-
import_v410.z.object({
|
|
1723
|
-
type: import_v410.z.literal("bash_code_execution_output"),
|
|
1724
|
-
file_id: import_v410.z.string()
|
|
1725
|
-
})
|
|
1726
|
-
),
|
|
1727
|
-
stdout: import_v410.z.string(),
|
|
1728
|
-
stderr: import_v410.z.string(),
|
|
1729
|
-
return_code: import_v410.z.number()
|
|
1730
|
-
}),
|
|
1731
|
-
import_v410.z.object({
|
|
1732
|
-
type: import_v410.z.literal("bash_code_execution_tool_result_error"),
|
|
1733
|
-
error_code: import_v410.z.string()
|
|
1734
|
-
}),
|
|
1735
|
-
import_v410.z.object({
|
|
1736
|
-
type: import_v410.z.literal("text_editor_code_execution_tool_result_error"),
|
|
1737
|
-
error_code: import_v410.z.string()
|
|
1738
|
-
}),
|
|
1739
|
-
import_v410.z.object({
|
|
1740
|
-
type: import_v410.z.literal("text_editor_code_execution_view_result"),
|
|
1741
|
-
content: import_v410.z.string(),
|
|
1742
|
-
file_type: import_v410.z.string(),
|
|
1743
|
-
num_lines: import_v410.z.number().nullable(),
|
|
1744
|
-
start_line: import_v410.z.number().nullable(),
|
|
1745
|
-
total_lines: import_v410.z.number().nullable()
|
|
1746
|
-
}),
|
|
1747
|
-
import_v410.z.object({
|
|
1748
|
-
type: import_v410.z.literal("text_editor_code_execution_create_result"),
|
|
1749
|
-
is_file_update: import_v410.z.boolean()
|
|
1750
|
-
}),
|
|
1751
|
-
import_v410.z.object({
|
|
1752
|
-
type: import_v410.z.literal("text_editor_code_execution_str_replace_result"),
|
|
1753
|
-
lines: import_v410.z.array(import_v410.z.string()).nullable(),
|
|
1754
|
-
new_lines: import_v410.z.number().nullable(),
|
|
1755
|
-
new_start: import_v410.z.number().nullable(),
|
|
1756
|
-
old_lines: import_v410.z.number().nullable(),
|
|
1757
|
-
old_start: import_v410.z.number().nullable()
|
|
1758
|
-
})
|
|
1759
|
-
])
|
|
1760
|
-
)
|
|
1761
|
-
);
|
|
1762
|
-
var codeExecution_20250825InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
1763
|
-
() => (0, import_provider_utils11.zodSchema)(
|
|
1764
|
-
import_v410.z.discriminatedUnion("type", [
|
|
1765
|
-
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1766
|
-
import_v410.z.object({
|
|
1767
|
-
type: import_v410.z.literal("programmatic-tool-call"),
|
|
1768
|
-
code: import_v410.z.string()
|
|
1769
|
-
}),
|
|
1770
|
-
import_v410.z.object({
|
|
1771
|
-
type: import_v410.z.literal("bash_code_execution"),
|
|
1772
|
-
command: import_v410.z.string()
|
|
1773
|
-
}),
|
|
1774
|
-
import_v410.z.discriminatedUnion("command", [
|
|
1775
|
-
import_v410.z.object({
|
|
1776
|
-
type: import_v410.z.literal("text_editor_code_execution"),
|
|
1777
|
-
command: import_v410.z.literal("view"),
|
|
1778
|
-
path: import_v410.z.string()
|
|
1779
|
-
}),
|
|
1780
|
-
import_v410.z.object({
|
|
1781
|
-
type: import_v410.z.literal("text_editor_code_execution"),
|
|
1782
|
-
command: import_v410.z.literal("create"),
|
|
1783
|
-
path: import_v410.z.string(),
|
|
1784
|
-
file_text: import_v410.z.string().nullish()
|
|
1785
|
-
}),
|
|
1786
|
-
import_v410.z.object({
|
|
1787
|
-
type: import_v410.z.literal("text_editor_code_execution"),
|
|
1788
|
-
command: import_v410.z.literal("str_replace"),
|
|
1789
|
-
path: import_v410.z.string(),
|
|
1790
|
-
old_str: import_v410.z.string(),
|
|
1791
|
-
new_str: import_v410.z.string()
|
|
1792
|
-
})
|
|
1793
|
-
])
|
|
1794
|
-
])
|
|
1795
|
-
)
|
|
1796
|
-
);
|
|
1797
|
-
var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSchema)({
|
|
1798
|
-
id: "anthropic.code_execution_20250825",
|
|
1799
|
-
inputSchema: codeExecution_20250825InputSchema,
|
|
1800
|
-
outputSchema: codeExecution_20250825OutputSchema,
|
|
1801
|
-
// Programmatic tool calling: tool results may be deferred to a later turn
|
|
1802
|
-
// when code execution triggers a client-executed tool that needs to be
|
|
1803
|
-
// resolved before the code execution result can be returned.
|
|
1804
|
-
supportsDeferredResults: true
|
|
1805
|
-
});
|
|
1806
|
-
var codeExecution_20250825 = (args = {}) => {
|
|
1807
1816
|
return factory7(args);
|
|
1808
1817
|
};
|
|
1809
1818
|
|
|
1810
|
-
// src/tool/code-
|
|
1819
|
+
// src/tool/code-execution_20250825.ts
|
|
1811
1820
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1812
1821
|
var import_v411 = require("zod/v4");
|
|
1813
|
-
var
|
|
1822
|
+
var codeExecution_20250825OutputSchema = (0, import_provider_utils12.lazySchema)(
|
|
1814
1823
|
() => (0, import_provider_utils12.zodSchema)(
|
|
1815
1824
|
import_v411.z.discriminatedUnion("type", [
|
|
1816
1825
|
import_v411.z.object({
|
|
@@ -1825,18 +1834,6 @@ var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)
|
|
|
1825
1834
|
})
|
|
1826
1835
|
).optional().default([])
|
|
1827
1836
|
}),
|
|
1828
|
-
import_v411.z.object({
|
|
1829
|
-
type: import_v411.z.literal("encrypted_code_execution_result"),
|
|
1830
|
-
encrypted_stdout: import_v411.z.string(),
|
|
1831
|
-
stderr: import_v411.z.string(),
|
|
1832
|
-
return_code: import_v411.z.number(),
|
|
1833
|
-
content: import_v411.z.array(
|
|
1834
|
-
import_v411.z.object({
|
|
1835
|
-
type: import_v411.z.literal("code_execution_output"),
|
|
1836
|
-
file_id: import_v411.z.string()
|
|
1837
|
-
})
|
|
1838
|
-
).optional().default([])
|
|
1839
|
-
}),
|
|
1840
1837
|
import_v411.z.object({
|
|
1841
1838
|
type: import_v411.z.literal("bash_code_execution_result"),
|
|
1842
1839
|
content: import_v411.z.array(
|
|
@@ -1880,9 +1877,10 @@ var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)
|
|
|
1880
1877
|
])
|
|
1881
1878
|
)
|
|
1882
1879
|
);
|
|
1883
|
-
var
|
|
1880
|
+
var codeExecution_20250825InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
1884
1881
|
() => (0, import_provider_utils12.zodSchema)(
|
|
1885
1882
|
import_v411.z.discriminatedUnion("type", [
|
|
1883
|
+
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1886
1884
|
import_v411.z.object({
|
|
1887
1885
|
type: import_v411.z.literal("programmatic-tool-call"),
|
|
1888
1886
|
code: import_v411.z.string()
|
|
@@ -1915,31 +1913,151 @@ var codeExecution_20260120InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
|
1915
1913
|
)
|
|
1916
1914
|
);
|
|
1917
1915
|
var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
|
|
1918
|
-
id: "anthropic.
|
|
1919
|
-
inputSchema:
|
|
1920
|
-
outputSchema:
|
|
1916
|
+
id: "anthropic.code_execution_20250825",
|
|
1917
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
1918
|
+
outputSchema: codeExecution_20250825OutputSchema,
|
|
1919
|
+
// Programmatic tool calling: tool results may be deferred to a later turn
|
|
1920
|
+
// when code execution triggers a client-executed tool that needs to be
|
|
1921
|
+
// resolved before the code execution result can be returned.
|
|
1921
1922
|
supportsDeferredResults: true
|
|
1922
1923
|
});
|
|
1923
|
-
var
|
|
1924
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
1924
1925
|
return factory8(args);
|
|
1925
1926
|
};
|
|
1926
1927
|
|
|
1927
|
-
// src/tool/
|
|
1928
|
+
// src/tool/code-execution_20260120.ts
|
|
1928
1929
|
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
1929
1930
|
var import_v412 = require("zod/v4");
|
|
1930
|
-
var
|
|
1931
|
+
var codeExecution_20260120OutputSchema = (0, import_provider_utils13.lazySchema)(
|
|
1931
1932
|
() => (0, import_provider_utils13.zodSchema)(
|
|
1932
|
-
import_v412.z.
|
|
1933
|
+
import_v412.z.discriminatedUnion("type", [
|
|
1934
|
+
import_v412.z.object({
|
|
1935
|
+
type: import_v412.z.literal("code_execution_result"),
|
|
1936
|
+
stdout: import_v412.z.string(),
|
|
1937
|
+
stderr: import_v412.z.string(),
|
|
1938
|
+
return_code: import_v412.z.number(),
|
|
1939
|
+
content: import_v412.z.array(
|
|
1940
|
+
import_v412.z.object({
|
|
1941
|
+
type: import_v412.z.literal("code_execution_output"),
|
|
1942
|
+
file_id: import_v412.z.string()
|
|
1943
|
+
})
|
|
1944
|
+
).optional().default([])
|
|
1945
|
+
}),
|
|
1933
1946
|
import_v412.z.object({
|
|
1934
|
-
type: import_v412.z.literal("
|
|
1935
|
-
|
|
1947
|
+
type: import_v412.z.literal("encrypted_code_execution_result"),
|
|
1948
|
+
encrypted_stdout: import_v412.z.string(),
|
|
1949
|
+
stderr: import_v412.z.string(),
|
|
1950
|
+
return_code: import_v412.z.number(),
|
|
1951
|
+
content: import_v412.z.array(
|
|
1952
|
+
import_v412.z.object({
|
|
1953
|
+
type: import_v412.z.literal("code_execution_output"),
|
|
1954
|
+
file_id: import_v412.z.string()
|
|
1955
|
+
})
|
|
1956
|
+
).optional().default([])
|
|
1957
|
+
}),
|
|
1958
|
+
import_v412.z.object({
|
|
1959
|
+
type: import_v412.z.literal("bash_code_execution_result"),
|
|
1960
|
+
content: import_v412.z.array(
|
|
1961
|
+
import_v412.z.object({
|
|
1962
|
+
type: import_v412.z.literal("bash_code_execution_output"),
|
|
1963
|
+
file_id: import_v412.z.string()
|
|
1964
|
+
})
|
|
1965
|
+
),
|
|
1966
|
+
stdout: import_v412.z.string(),
|
|
1967
|
+
stderr: import_v412.z.string(),
|
|
1968
|
+
return_code: import_v412.z.number()
|
|
1969
|
+
}),
|
|
1970
|
+
import_v412.z.object({
|
|
1971
|
+
type: import_v412.z.literal("bash_code_execution_tool_result_error"),
|
|
1972
|
+
error_code: import_v412.z.string()
|
|
1973
|
+
}),
|
|
1974
|
+
import_v412.z.object({
|
|
1975
|
+
type: import_v412.z.literal("text_editor_code_execution_tool_result_error"),
|
|
1976
|
+
error_code: import_v412.z.string()
|
|
1977
|
+
}),
|
|
1978
|
+
import_v412.z.object({
|
|
1979
|
+
type: import_v412.z.literal("text_editor_code_execution_view_result"),
|
|
1980
|
+
content: import_v412.z.string(),
|
|
1981
|
+
file_type: import_v412.z.string(),
|
|
1982
|
+
num_lines: import_v412.z.number().nullable(),
|
|
1983
|
+
start_line: import_v412.z.number().nullable(),
|
|
1984
|
+
total_lines: import_v412.z.number().nullable()
|
|
1985
|
+
}),
|
|
1986
|
+
import_v412.z.object({
|
|
1987
|
+
type: import_v412.z.literal("text_editor_code_execution_create_result"),
|
|
1988
|
+
is_file_update: import_v412.z.boolean()
|
|
1989
|
+
}),
|
|
1990
|
+
import_v412.z.object({
|
|
1991
|
+
type: import_v412.z.literal("text_editor_code_execution_str_replace_result"),
|
|
1992
|
+
lines: import_v412.z.array(import_v412.z.string()).nullable(),
|
|
1993
|
+
new_lines: import_v412.z.number().nullable(),
|
|
1994
|
+
new_start: import_v412.z.number().nullable(),
|
|
1995
|
+
old_lines: import_v412.z.number().nullable(),
|
|
1996
|
+
old_start: import_v412.z.number().nullable()
|
|
1936
1997
|
})
|
|
1937
|
-
)
|
|
1998
|
+
])
|
|
1938
1999
|
)
|
|
1939
2000
|
);
|
|
1940
|
-
var
|
|
2001
|
+
var codeExecution_20260120InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
1941
2002
|
() => (0, import_provider_utils13.zodSchema)(
|
|
1942
|
-
import_v412.z.
|
|
2003
|
+
import_v412.z.discriminatedUnion("type", [
|
|
2004
|
+
import_v412.z.object({
|
|
2005
|
+
type: import_v412.z.literal("programmatic-tool-call"),
|
|
2006
|
+
code: import_v412.z.string()
|
|
2007
|
+
}),
|
|
2008
|
+
import_v412.z.object({
|
|
2009
|
+
type: import_v412.z.literal("bash_code_execution"),
|
|
2010
|
+
command: import_v412.z.string()
|
|
2011
|
+
}),
|
|
2012
|
+
import_v412.z.discriminatedUnion("command", [
|
|
2013
|
+
import_v412.z.object({
|
|
2014
|
+
type: import_v412.z.literal("text_editor_code_execution"),
|
|
2015
|
+
command: import_v412.z.literal("view"),
|
|
2016
|
+
path: import_v412.z.string()
|
|
2017
|
+
}),
|
|
2018
|
+
import_v412.z.object({
|
|
2019
|
+
type: import_v412.z.literal("text_editor_code_execution"),
|
|
2020
|
+
command: import_v412.z.literal("create"),
|
|
2021
|
+
path: import_v412.z.string(),
|
|
2022
|
+
file_text: import_v412.z.string().nullish()
|
|
2023
|
+
}),
|
|
2024
|
+
import_v412.z.object({
|
|
2025
|
+
type: import_v412.z.literal("text_editor_code_execution"),
|
|
2026
|
+
command: import_v412.z.literal("str_replace"),
|
|
2027
|
+
path: import_v412.z.string(),
|
|
2028
|
+
old_str: import_v412.z.string(),
|
|
2029
|
+
new_str: import_v412.z.string()
|
|
2030
|
+
})
|
|
2031
|
+
])
|
|
2032
|
+
])
|
|
2033
|
+
)
|
|
2034
|
+
);
|
|
2035
|
+
var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
|
|
2036
|
+
id: "anthropic.code_execution_20260120",
|
|
2037
|
+
inputSchema: codeExecution_20260120InputSchema,
|
|
2038
|
+
outputSchema: codeExecution_20260120OutputSchema,
|
|
2039
|
+
supportsDeferredResults: true
|
|
2040
|
+
});
|
|
2041
|
+
var codeExecution_20260120 = (args = {}) => {
|
|
2042
|
+
return factory9(args);
|
|
2043
|
+
};
|
|
2044
|
+
|
|
2045
|
+
// src/tool/tool-search-regex_20251119.ts
|
|
2046
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2047
|
+
var import_v413 = require("zod/v4");
|
|
2048
|
+
var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2049
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2050
|
+
import_v413.z.array(
|
|
2051
|
+
import_v413.z.object({
|
|
2052
|
+
type: import_v413.z.literal("tool_reference"),
|
|
2053
|
+
toolName: import_v413.z.string()
|
|
2054
|
+
})
|
|
2055
|
+
)
|
|
2056
|
+
)
|
|
2057
|
+
);
|
|
2058
|
+
var toolSearchRegex_20251119InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2059
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2060
|
+
import_v413.z.object({
|
|
1943
2061
|
/**
|
|
1944
2062
|
* A regex pattern to search for tools.
|
|
1945
2063
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1950,28 +2068,28 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
|
|
|
1950
2068
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1951
2069
|
* - "(?i)slack" - case-insensitive search
|
|
1952
2070
|
*/
|
|
1953
|
-
pattern:
|
|
2071
|
+
pattern: import_v413.z.string(),
|
|
1954
2072
|
/**
|
|
1955
2073
|
* Maximum number of tools to return. Optional.
|
|
1956
2074
|
*/
|
|
1957
|
-
limit:
|
|
2075
|
+
limit: import_v413.z.number().optional()
|
|
1958
2076
|
})
|
|
1959
2077
|
)
|
|
1960
2078
|
);
|
|
1961
|
-
var
|
|
2079
|
+
var factory10 = (0, import_provider_utils14.createProviderToolFactoryWithOutputSchema)({
|
|
1962
2080
|
id: "anthropic.tool_search_regex_20251119",
|
|
1963
2081
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
1964
2082
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
1965
2083
|
supportsDeferredResults: true
|
|
1966
2084
|
});
|
|
1967
2085
|
var toolSearchRegex_20251119 = (args = {}) => {
|
|
1968
|
-
return
|
|
2086
|
+
return factory10(args);
|
|
1969
2087
|
};
|
|
1970
2088
|
|
|
1971
2089
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
1972
2090
|
function convertToString(data) {
|
|
1973
2091
|
if (typeof data === "string") {
|
|
1974
|
-
return new TextDecoder().decode((0,
|
|
2092
|
+
return new TextDecoder().decode((0, import_provider_utils15.convertBase64ToUint8Array)(data));
|
|
1975
2093
|
}
|
|
1976
2094
|
if (data instanceof Uint8Array) {
|
|
1977
2095
|
return new TextDecoder().decode(data);
|
|
@@ -2015,7 +2133,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2015
2133
|
const messages = [];
|
|
2016
2134
|
async function shouldEnableCitations(providerMetadata) {
|
|
2017
2135
|
var _a2, _b2;
|
|
2018
|
-
const anthropicOptions = await (0,
|
|
2136
|
+
const anthropicOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2019
2137
|
provider: "anthropic",
|
|
2020
2138
|
providerOptions: providerMetadata,
|
|
2021
2139
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2023,7 +2141,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2023
2141
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
2024
2142
|
}
|
|
2025
2143
|
async function getDocumentMetadata(providerMetadata) {
|
|
2026
|
-
const anthropicOptions = await (0,
|
|
2144
|
+
const anthropicOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2027
2145
|
provider: "anthropic",
|
|
2028
2146
|
providerOptions: providerMetadata,
|
|
2029
2147
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2044,14 +2162,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2044
2162
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2045
2163
|
});
|
|
2046
2164
|
}
|
|
2047
|
-
system = block.messages.map(({ content, providerOptions }) =>
|
|
2048
|
-
|
|
2049
|
-
text: content,
|
|
2050
|
-
cache_control: validator.getCacheControl(providerOptions, {
|
|
2165
|
+
system = block.messages.map(({ content, providerOptions }) => {
|
|
2166
|
+
const cc = validator.getCacheControl(providerOptions, {
|
|
2051
2167
|
type: "system message",
|
|
2052
2168
|
canCache: true
|
|
2053
|
-
})
|
|
2054
|
-
|
|
2169
|
+
});
|
|
2170
|
+
return {
|
|
2171
|
+
type: "text",
|
|
2172
|
+
text: content,
|
|
2173
|
+
cache_control: cc
|
|
2174
|
+
};
|
|
2175
|
+
});
|
|
2055
2176
|
break;
|
|
2056
2177
|
}
|
|
2057
2178
|
case "user": {
|
|
@@ -2104,7 +2225,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2104
2225
|
} : {
|
|
2105
2226
|
type: "base64",
|
|
2106
2227
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
2107
|
-
data: (0,
|
|
2228
|
+
data: (0, import_provider_utils15.convertToBase64)(part.data)
|
|
2108
2229
|
},
|
|
2109
2230
|
cache_control: cacheControl
|
|
2110
2231
|
});
|
|
@@ -2124,7 +2245,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2124
2245
|
} : {
|
|
2125
2246
|
type: "base64",
|
|
2126
2247
|
media_type: "application/pdf",
|
|
2127
|
-
data: (0,
|
|
2248
|
+
data: (0, import_provider_utils15.convertToBase64)(part.data)
|
|
2128
2249
|
},
|
|
2129
2250
|
title: (_c = metadata.title) != null ? _c : part.filename,
|
|
2130
2251
|
...metadata.context && { context: metadata.context },
|
|
@@ -2262,7 +2383,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2262
2383
|
return void 0;
|
|
2263
2384
|
}
|
|
2264
2385
|
}
|
|
2265
|
-
}).filter(
|
|
2386
|
+
}).filter(import_provider_utils15.isNonNullable);
|
|
2266
2387
|
break;
|
|
2267
2388
|
case "text":
|
|
2268
2389
|
case "error-text":
|
|
@@ -2338,7 +2459,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2338
2459
|
}
|
|
2339
2460
|
case "reasoning": {
|
|
2340
2461
|
if (sendReasoning) {
|
|
2341
|
-
const reasoningMetadata = await (0,
|
|
2462
|
+
const reasoningMetadata = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2342
2463
|
provider: "anthropic",
|
|
2343
2464
|
providerOptions: part.providerOptions,
|
|
2344
2465
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2544,7 +2665,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2544
2665
|
break;
|
|
2545
2666
|
}
|
|
2546
2667
|
if (output.value.type === "code_execution_result") {
|
|
2547
|
-
const codeExecutionOutput = await (0,
|
|
2668
|
+
const codeExecutionOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2548
2669
|
value: output.value,
|
|
2549
2670
|
schema: codeExecution_20250522OutputSchema
|
|
2550
2671
|
});
|
|
@@ -2561,7 +2682,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2561
2682
|
cache_control: cacheControl
|
|
2562
2683
|
});
|
|
2563
2684
|
} else if (output.value.type === "encrypted_code_execution_result") {
|
|
2564
|
-
const codeExecutionOutput = await (0,
|
|
2685
|
+
const codeExecutionOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2565
2686
|
value: output.value,
|
|
2566
2687
|
schema: codeExecution_20260120OutputSchema
|
|
2567
2688
|
});
|
|
@@ -2580,7 +2701,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2580
2701
|
});
|
|
2581
2702
|
}
|
|
2582
2703
|
} else {
|
|
2583
|
-
const codeExecutionOutput = await (0,
|
|
2704
|
+
const codeExecutionOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2584
2705
|
value: output.value,
|
|
2585
2706
|
schema: codeExecution_20250825OutputSchema
|
|
2586
2707
|
});
|
|
@@ -2628,7 +2749,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2628
2749
|
} catch (e) {
|
|
2629
2750
|
const extractedErrorCode = (_s = output.value) == null ? void 0 : _s.errorCode;
|
|
2630
2751
|
errorValue = {
|
|
2631
|
-
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "
|
|
2752
|
+
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
|
|
2632
2753
|
};
|
|
2633
2754
|
}
|
|
2634
2755
|
anthropicContent.push({
|
|
@@ -2636,7 +2757,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2636
2757
|
tool_use_id: part.toolCallId,
|
|
2637
2758
|
content: {
|
|
2638
2759
|
type: "web_fetch_tool_result_error",
|
|
2639
|
-
error_code: (_t = errorValue.errorCode) != null ? _t : "
|
|
2760
|
+
error_code: (_t = errorValue.errorCode) != null ? _t : "unavailable"
|
|
2640
2761
|
},
|
|
2641
2762
|
cache_control: cacheControl
|
|
2642
2763
|
});
|
|
@@ -2649,7 +2770,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2649
2770
|
});
|
|
2650
2771
|
break;
|
|
2651
2772
|
}
|
|
2652
|
-
const webFetchOutput = await (0,
|
|
2773
|
+
const webFetchOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2653
2774
|
value: output.value,
|
|
2654
2775
|
schema: webFetch_20250910OutputSchema
|
|
2655
2776
|
});
|
|
@@ -2684,7 +2805,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2684
2805
|
});
|
|
2685
2806
|
break;
|
|
2686
2807
|
}
|
|
2687
|
-
const webSearchOutput = await (0,
|
|
2808
|
+
const webSearchOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2688
2809
|
value: output.value,
|
|
2689
2810
|
schema: webSearch_20250305OutputSchema
|
|
2690
2811
|
});
|
|
@@ -2704,6 +2825,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2704
2825
|
}
|
|
2705
2826
|
if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
2706
2827
|
const output = part.output;
|
|
2828
|
+
if (output.type === "error-text" || output.type === "error-json") {
|
|
2829
|
+
anthropicContent.push({
|
|
2830
|
+
type: "tool_search_tool_result",
|
|
2831
|
+
tool_use_id: part.toolCallId,
|
|
2832
|
+
content: {
|
|
2833
|
+
type: "tool_search_tool_result_error",
|
|
2834
|
+
error_code: "unavailable"
|
|
2835
|
+
},
|
|
2836
|
+
cache_control: cacheControl
|
|
2837
|
+
});
|
|
2838
|
+
break;
|
|
2839
|
+
}
|
|
2707
2840
|
if (output.type !== "json") {
|
|
2708
2841
|
warnings.push({
|
|
2709
2842
|
type: "other",
|
|
@@ -2711,7 +2844,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2711
2844
|
});
|
|
2712
2845
|
break;
|
|
2713
2846
|
}
|
|
2714
|
-
const toolSearchOutput = await (0,
|
|
2847
|
+
const toolSearchOutput = await (0, import_provider_utils15.validateTypes)({
|
|
2715
2848
|
value: output.value,
|
|
2716
2849
|
schema: toolSearchRegex_20251119OutputSchema
|
|
2717
2850
|
});
|
|
@@ -2825,6 +2958,61 @@ function mapAnthropicStopReason({
|
|
|
2825
2958
|
}
|
|
2826
2959
|
|
|
2827
2960
|
// src/anthropic-messages-language-model.ts
|
|
2961
|
+
function isCustomReasoning(reasoning) {
|
|
2962
|
+
return reasoning !== void 0 && reasoning !== "provider-default";
|
|
2963
|
+
}
|
|
2964
|
+
function mapReasoningToProviderEffort({
|
|
2965
|
+
reasoning,
|
|
2966
|
+
effortMap,
|
|
2967
|
+
warnings
|
|
2968
|
+
}) {
|
|
2969
|
+
const mapped = effortMap[reasoning];
|
|
2970
|
+
if (mapped == null) {
|
|
2971
|
+
warnings.push({
|
|
2972
|
+
type: "unsupported",
|
|
2973
|
+
feature: "reasoning",
|
|
2974
|
+
details: `reasoning "${reasoning}" is not supported by this model.`
|
|
2975
|
+
});
|
|
2976
|
+
return void 0;
|
|
2977
|
+
}
|
|
2978
|
+
if (mapped !== reasoning) {
|
|
2979
|
+
warnings.push({
|
|
2980
|
+
type: "compatibility",
|
|
2981
|
+
feature: "reasoning",
|
|
2982
|
+
details: `reasoning "${reasoning}" is not directly supported by this model. mapped to effort "${mapped}".`
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2985
|
+
return mapped;
|
|
2986
|
+
}
|
|
2987
|
+
var DEFAULT_REASONING_BUDGET_PERCENTAGES = {
|
|
2988
|
+
minimal: 0.02,
|
|
2989
|
+
low: 0.1,
|
|
2990
|
+
medium: 0.3,
|
|
2991
|
+
high: 0.6,
|
|
2992
|
+
xhigh: 0.9
|
|
2993
|
+
};
|
|
2994
|
+
function mapReasoningToProviderBudget({
|
|
2995
|
+
reasoning,
|
|
2996
|
+
maxOutputTokens,
|
|
2997
|
+
maxReasoningBudget,
|
|
2998
|
+
minReasoningBudget = 1024,
|
|
2999
|
+
budgetPercentages = DEFAULT_REASONING_BUDGET_PERCENTAGES,
|
|
3000
|
+
warnings
|
|
3001
|
+
}) {
|
|
3002
|
+
const pct = budgetPercentages[reasoning];
|
|
3003
|
+
if (pct == null) {
|
|
3004
|
+
warnings.push({
|
|
3005
|
+
type: "unsupported",
|
|
3006
|
+
feature: "reasoning",
|
|
3007
|
+
details: `reasoning "${reasoning}" is not supported by this model.`
|
|
3008
|
+
});
|
|
3009
|
+
return void 0;
|
|
3010
|
+
}
|
|
3011
|
+
return Math.min(
|
|
3012
|
+
maxReasoningBudget,
|
|
3013
|
+
Math.max(minReasoningBudget, Math.round(maxOutputTokens * pct))
|
|
3014
|
+
);
|
|
3015
|
+
}
|
|
2828
3016
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
2829
3017
|
var _a;
|
|
2830
3018
|
if (citation.type === "web_search_result_location") {
|
|
@@ -2871,11 +3059,11 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
2871
3059
|
}
|
|
2872
3060
|
var AnthropicMessagesLanguageModel = class {
|
|
2873
3061
|
constructor(modelId, config) {
|
|
2874
|
-
this.specificationVersion = "
|
|
3062
|
+
this.specificationVersion = "v4";
|
|
2875
3063
|
var _a;
|
|
2876
3064
|
this.modelId = modelId;
|
|
2877
3065
|
this.config = config;
|
|
2878
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
3066
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils16.generateId;
|
|
2879
3067
|
}
|
|
2880
3068
|
supportsUrl(url) {
|
|
2881
3069
|
return url.protocol === "https:";
|
|
@@ -2910,10 +3098,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2910
3098
|
seed,
|
|
2911
3099
|
tools,
|
|
2912
3100
|
toolChoice,
|
|
3101
|
+
reasoning,
|
|
2913
3102
|
providerOptions,
|
|
2914
3103
|
stream
|
|
2915
3104
|
}) {
|
|
2916
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3105
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2917
3106
|
const warnings = [];
|
|
2918
3107
|
if (frequencyPenalty != null) {
|
|
2919
3108
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2949,12 +3138,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2949
3138
|
}
|
|
2950
3139
|
}
|
|
2951
3140
|
const providerOptionsName = this.providerOptionsName;
|
|
2952
|
-
const canonicalOptions = await (0,
|
|
3141
|
+
const canonicalOptions = await (0, import_provider_utils16.parseProviderOptions)({
|
|
2953
3142
|
provider: "anthropic",
|
|
2954
3143
|
providerOptions,
|
|
2955
3144
|
schema: anthropicLanguageModelOptions
|
|
2956
3145
|
});
|
|
2957
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await (0,
|
|
3146
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils16.parseProviderOptions)({
|
|
2958
3147
|
provider: providerOptionsName,
|
|
2959
3148
|
providerOptions,
|
|
2960
3149
|
schema: anthropicLanguageModelOptions
|
|
@@ -2968,10 +3157,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2968
3157
|
const {
|
|
2969
3158
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2970
3159
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3160
|
+
supportsAdaptiveThinking,
|
|
2971
3161
|
isKnownModel
|
|
2972
3162
|
} = getModelCapabilities(this.modelId);
|
|
2973
3163
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2974
|
-
const
|
|
3164
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
3165
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2975
3166
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2976
3167
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2977
3168
|
type: "function",
|
|
@@ -2981,7 +3172,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2981
3172
|
} : void 0;
|
|
2982
3173
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
2983
3174
|
const cacheControlValidator = new CacheControlValidator();
|
|
2984
|
-
const toolNameMapping = (0,
|
|
3175
|
+
const toolNameMapping = (0, import_provider_utils16.createToolNameMapping)({
|
|
2985
3176
|
tools,
|
|
2986
3177
|
providerToolNames: {
|
|
2987
3178
|
"anthropic.code_execution_20250522": "code_execution",
|
|
@@ -2999,6 +3190,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2999
3190
|
"anthropic.web_search_20250305": "web_search",
|
|
3000
3191
|
"anthropic.web_search_20260209": "web_search",
|
|
3001
3192
|
"anthropic.web_fetch_20250910": "web_fetch",
|
|
3193
|
+
"anthropic.web_fetch_20260309": "web_fetch",
|
|
3002
3194
|
"anthropic.web_fetch_20260209": "web_fetch",
|
|
3003
3195
|
"anthropic.tool_search_regex_20251119": "tool_search_tool_regex",
|
|
3004
3196
|
"anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
|
|
@@ -3006,11 +3198,25 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3006
3198
|
});
|
|
3007
3199
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
3008
3200
|
prompt,
|
|
3009
|
-
sendReasoning: (
|
|
3201
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
3010
3202
|
warnings,
|
|
3011
3203
|
cacheControlValidator,
|
|
3012
3204
|
toolNameMapping
|
|
3013
3205
|
});
|
|
3206
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3207
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3208
|
+
reasoning,
|
|
3209
|
+
supportsAdaptiveThinking,
|
|
3210
|
+
maxOutputTokensForModel,
|
|
3211
|
+
warnings
|
|
3212
|
+
});
|
|
3213
|
+
if (reasoningConfig != null) {
|
|
3214
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3215
|
+
if (reasoningConfig.effort != null) {
|
|
3216
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3014
3220
|
if (anthropicOptions == null ? void 0 : anthropicOptions.prefill) {
|
|
3015
3221
|
const lastMessage = messagesPrompt.messages[messagesPrompt.messages.length - 1];
|
|
3016
3222
|
if ((lastMessage == null ? void 0 : lastMessage.role) === "assistant") {
|
|
@@ -3032,9 +3238,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3032
3238
|
});
|
|
3033
3239
|
}
|
|
3034
3240
|
}
|
|
3035
|
-
const thinkingType = (
|
|
3241
|
+
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
3036
3242
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
3037
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3243
|
+
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
|
|
3038
3244
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
3039
3245
|
const baseArgs = {
|
|
3040
3246
|
// model id:
|
|
@@ -3050,7 +3256,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3050
3256
|
thinking: {
|
|
3051
3257
|
type: thinkingType,
|
|
3052
3258
|
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3053
|
-
...((
|
|
3259
|
+
...((_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.type) !== "disabled" && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display) && {
|
|
3054
3260
|
display: anthropicOptions.thinking.display
|
|
3055
3261
|
}
|
|
3056
3262
|
}
|
|
@@ -3071,9 +3277,22 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3071
3277
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3072
3278
|
speed: anthropicOptions.speed
|
|
3073
3279
|
},
|
|
3280
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.metadata) && {
|
|
3281
|
+
metadata: {
|
|
3282
|
+
...anthropicOptions.metadata.userId && {
|
|
3283
|
+
user_id: anthropicOptions.metadata.userId
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
},
|
|
3287
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.serviceTier) && {
|
|
3288
|
+
service_tier: anthropicOptions.serviceTier
|
|
3289
|
+
},
|
|
3074
3290
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3075
3291
|
cache_control: anthropicOptions.cacheControl
|
|
3076
3292
|
},
|
|
3293
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3294
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3295
|
+
},
|
|
3077
3296
|
// mcp servers:
|
|
3078
3297
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3079
3298
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3226,7 +3445,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3226
3445
|
}
|
|
3227
3446
|
}
|
|
3228
3447
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.container) && anthropicOptions.container.skills && anthropicOptions.container.skills.length > 0) {
|
|
3229
|
-
betas.add("code-execution-2025-08-25");
|
|
3230
3448
|
betas.add("skills-2025-10-02");
|
|
3231
3449
|
betas.add("files-api-2025-04-14");
|
|
3232
3450
|
if (!(tools == null ? void 0 : tools.some(
|
|
@@ -3244,7 +3462,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3244
3462
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3245
3463
|
betas.add("fast-mode-2026-02-01");
|
|
3246
3464
|
}
|
|
3247
|
-
if (stream && ((
|
|
3465
|
+
if (stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true)) {
|
|
3248
3466
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3249
3467
|
}
|
|
3250
3468
|
const {
|
|
@@ -3258,13 +3476,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3258
3476
|
toolChoice: { type: "required" },
|
|
3259
3477
|
disableParallelToolUse: true,
|
|
3260
3478
|
cacheControlValidator,
|
|
3261
|
-
supportsStructuredOutput: false
|
|
3479
|
+
supportsStructuredOutput: false,
|
|
3480
|
+
supportsStrictTools
|
|
3262
3481
|
} : {
|
|
3263
3482
|
tools: tools != null ? tools : [],
|
|
3264
3483
|
toolChoice,
|
|
3265
3484
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3266
3485
|
cacheControlValidator,
|
|
3267
|
-
supportsStructuredOutput
|
|
3486
|
+
supportsStructuredOutput,
|
|
3487
|
+
supportsStrictTools
|
|
3268
3488
|
}
|
|
3269
3489
|
);
|
|
3270
3490
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3281,7 +3501,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3281
3501
|
...betas,
|
|
3282
3502
|
...toolsBetas,
|
|
3283
3503
|
...userSuppliedBetas,
|
|
3284
|
-
...(
|
|
3504
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3285
3505
|
]),
|
|
3286
3506
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3287
3507
|
toolNameMapping,
|
|
@@ -3293,15 +3513,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3293
3513
|
betas,
|
|
3294
3514
|
headers
|
|
3295
3515
|
}) {
|
|
3296
|
-
return (0,
|
|
3297
|
-
await (0,
|
|
3516
|
+
return (0, import_provider_utils16.combineHeaders)(
|
|
3517
|
+
await (0, import_provider_utils16.resolve)(this.config.headers),
|
|
3298
3518
|
headers,
|
|
3299
3519
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3300
3520
|
);
|
|
3301
3521
|
}
|
|
3302
3522
|
async getBetasFromHeaders(requestHeaders) {
|
|
3303
3523
|
var _a, _b;
|
|
3304
|
-
const configHeaders = await (0,
|
|
3524
|
+
const configHeaders = await (0, import_provider_utils16.resolve)(this.config.headers);
|
|
3305
3525
|
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3306
3526
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3307
3527
|
return new Set(
|
|
@@ -3367,12 +3587,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3367
3587
|
responseHeaders,
|
|
3368
3588
|
value: response,
|
|
3369
3589
|
rawValue: rawResponse
|
|
3370
|
-
} = await (0,
|
|
3590
|
+
} = await (0, import_provider_utils16.postJsonToApi)({
|
|
3371
3591
|
url: this.buildRequestUrl(false),
|
|
3372
3592
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3373
3593
|
body: this.transformRequestBody(args, betas),
|
|
3374
3594
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3375
|
-
successfulResponseHandler: (0,
|
|
3595
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
3376
3596
|
anthropicMessagesResponseSchema
|
|
3377
3597
|
),
|
|
3378
3598
|
abortSignal: options.abortSignal,
|
|
@@ -3618,6 +3838,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3618
3838
|
}
|
|
3619
3839
|
// code execution 20250522:
|
|
3620
3840
|
case "code_execution_tool_result": {
|
|
3841
|
+
if (markCodeExecutionDynamic) {
|
|
3842
|
+
content.push({
|
|
3843
|
+
type: "tool-result",
|
|
3844
|
+
toolCallId: part.tool_use_id,
|
|
3845
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
3846
|
+
isError: true,
|
|
3847
|
+
result: "STOP: code_execution is disabled. Do NOT wrap web_search or web_fetch in Python code. Call web_search and web_fetch as DIRECT tool calls \u2014 they are standalone tools, not Python functions."
|
|
3848
|
+
});
|
|
3849
|
+
break;
|
|
3850
|
+
}
|
|
3621
3851
|
if (part.content.type === "code_execution_result") {
|
|
3622
3852
|
content.push({
|
|
3623
3853
|
type: "tool-result",
|
|
@@ -3661,6 +3891,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3661
3891
|
// code execution 20250825:
|
|
3662
3892
|
case "bash_code_execution_tool_result":
|
|
3663
3893
|
case "text_editor_code_execution_tool_result": {
|
|
3894
|
+
if (markCodeExecutionDynamic) {
|
|
3895
|
+
content.push({
|
|
3896
|
+
type: "tool-result",
|
|
3897
|
+
toolCallId: part.tool_use_id,
|
|
3898
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
3899
|
+
isError: true,
|
|
3900
|
+
result: "STOP: code_execution is disabled. Do NOT wrap web_search or web_fetch in Python code. Call web_search and web_fetch as DIRECT tool calls \u2014 they are standalone tools, not Python functions."
|
|
3901
|
+
});
|
|
3902
|
+
break;
|
|
3903
|
+
}
|
|
3664
3904
|
content.push({
|
|
3665
3905
|
type: "tool-result",
|
|
3666
3906
|
toolCallId: part.tool_use_id,
|
|
@@ -3787,12 +4027,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3787
4027
|
body.tools
|
|
3788
4028
|
);
|
|
3789
4029
|
const url = this.buildRequestUrl(true);
|
|
3790
|
-
const { responseHeaders, value: response } = await (0,
|
|
4030
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils16.postJsonToApi)({
|
|
3791
4031
|
url,
|
|
3792
4032
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3793
4033
|
body: this.transformRequestBody(body, betas),
|
|
3794
4034
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3795
|
-
successfulResponseHandler: (0,
|
|
4035
|
+
successfulResponseHandler: (0, import_provider_utils16.createEventSourceResponseHandler)(
|
|
3796
4036
|
anthropicMessagesChunkSchema
|
|
3797
4037
|
),
|
|
3798
4038
|
abortSignal: options.abortSignal,
|
|
@@ -4063,6 +4303,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4063
4303
|
}
|
|
4064
4304
|
// code execution 20250522:
|
|
4065
4305
|
case "code_execution_tool_result": {
|
|
4306
|
+
if (markCodeExecutionDynamic) {
|
|
4307
|
+
controller.enqueue({
|
|
4308
|
+
type: "tool-result",
|
|
4309
|
+
toolCallId: part.tool_use_id,
|
|
4310
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
4311
|
+
isError: true,
|
|
4312
|
+
result: "STOP: code_execution is disabled. Do NOT wrap web_search or web_fetch in Python code. Call web_search and web_fetch as DIRECT tool calls \u2014 they are standalone tools, not Python functions."
|
|
4313
|
+
});
|
|
4314
|
+
return;
|
|
4315
|
+
}
|
|
4066
4316
|
if (part.content.type === "code_execution_result") {
|
|
4067
4317
|
controller.enqueue({
|
|
4068
4318
|
type: "tool-result",
|
|
@@ -4106,6 +4356,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4106
4356
|
// code execution 20250825:
|
|
4107
4357
|
case "bash_code_execution_tool_result":
|
|
4108
4358
|
case "text_editor_code_execution_tool_result": {
|
|
4359
|
+
if (markCodeExecutionDynamic) {
|
|
4360
|
+
controller.enqueue({
|
|
4361
|
+
type: "tool-result",
|
|
4362
|
+
toolCallId: part.tool_use_id,
|
|
4363
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
4364
|
+
isError: true,
|
|
4365
|
+
result: "STOP: code_execution is disabled. Do NOT wrap web_search or web_fetch in Python code. Call web_search and web_fetch as DIRECT tool calls \u2014 they are standalone tools, not Python functions."
|
|
4366
|
+
});
|
|
4367
|
+
return;
|
|
4368
|
+
}
|
|
4109
4369
|
controller.enqueue({
|
|
4110
4370
|
type: "tool-result",
|
|
4111
4371
|
toolCallId: part.tool_use_id,
|
|
@@ -4544,42 +4804,49 @@ function getModelCapabilities(modelId) {
|
|
|
4544
4804
|
return {
|
|
4545
4805
|
maxOutputTokens: 128e3,
|
|
4546
4806
|
supportsStructuredOutput: true,
|
|
4807
|
+
supportsAdaptiveThinking: true,
|
|
4547
4808
|
isKnownModel: true
|
|
4548
4809
|
};
|
|
4549
4810
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4550
4811
|
return {
|
|
4551
4812
|
maxOutputTokens: 64e3,
|
|
4552
4813
|
supportsStructuredOutput: true,
|
|
4814
|
+
supportsAdaptiveThinking: false,
|
|
4553
4815
|
isKnownModel: true
|
|
4554
4816
|
};
|
|
4555
4817
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4556
4818
|
return {
|
|
4557
4819
|
maxOutputTokens: 32e3,
|
|
4558
4820
|
supportsStructuredOutput: true,
|
|
4821
|
+
supportsAdaptiveThinking: false,
|
|
4559
4822
|
isKnownModel: true
|
|
4560
4823
|
};
|
|
4561
4824
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4562
4825
|
return {
|
|
4563
4826
|
maxOutputTokens: 64e3,
|
|
4564
4827
|
supportsStructuredOutput: false,
|
|
4828
|
+
supportsAdaptiveThinking: false,
|
|
4565
4829
|
isKnownModel: true
|
|
4566
4830
|
};
|
|
4567
4831
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4568
4832
|
return {
|
|
4569
4833
|
maxOutputTokens: 32e3,
|
|
4570
4834
|
supportsStructuredOutput: false,
|
|
4835
|
+
supportsAdaptiveThinking: false,
|
|
4571
4836
|
isKnownModel: true
|
|
4572
4837
|
};
|
|
4573
4838
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4574
4839
|
return {
|
|
4575
4840
|
maxOutputTokens: 4096,
|
|
4576
4841
|
supportsStructuredOutput: false,
|
|
4842
|
+
supportsAdaptiveThinking: false,
|
|
4577
4843
|
isKnownModel: true
|
|
4578
4844
|
};
|
|
4579
4845
|
} else {
|
|
4580
4846
|
return {
|
|
4581
4847
|
maxOutputTokens: 4096,
|
|
4582
4848
|
supportsStructuredOutput: false,
|
|
4849
|
+
supportsAdaptiveThinking: false,
|
|
4583
4850
|
isKnownModel: false
|
|
4584
4851
|
};
|
|
4585
4852
|
}
|
|
@@ -4602,6 +4869,43 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4602
4869
|
}
|
|
4603
4870
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4604
4871
|
}
|
|
4872
|
+
function resolveAnthropicReasoningConfig({
|
|
4873
|
+
reasoning,
|
|
4874
|
+
supportsAdaptiveThinking,
|
|
4875
|
+
maxOutputTokensForModel,
|
|
4876
|
+
warnings
|
|
4877
|
+
}) {
|
|
4878
|
+
if (!isCustomReasoning(reasoning)) {
|
|
4879
|
+
return void 0;
|
|
4880
|
+
}
|
|
4881
|
+
if (reasoning === "none") {
|
|
4882
|
+
return { thinking: { type: "disabled" } };
|
|
4883
|
+
}
|
|
4884
|
+
if (supportsAdaptiveThinking) {
|
|
4885
|
+
const effort = mapReasoningToProviderEffort({
|
|
4886
|
+
reasoning,
|
|
4887
|
+
effortMap: {
|
|
4888
|
+
minimal: "low",
|
|
4889
|
+
low: "low",
|
|
4890
|
+
medium: "medium",
|
|
4891
|
+
high: "high",
|
|
4892
|
+
xhigh: "max"
|
|
4893
|
+
},
|
|
4894
|
+
warnings
|
|
4895
|
+
});
|
|
4896
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
4897
|
+
}
|
|
4898
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
4899
|
+
reasoning,
|
|
4900
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
4901
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
4902
|
+
warnings
|
|
4903
|
+
});
|
|
4904
|
+
if (budgetTokens == null) {
|
|
4905
|
+
return void 0;
|
|
4906
|
+
}
|
|
4907
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
4908
|
+
}
|
|
4605
4909
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4606
4910
|
return contextManagement ? {
|
|
4607
4911
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -4629,44 +4933,44 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4629
4933
|
}
|
|
4630
4934
|
|
|
4631
4935
|
// src/tool/bash_20241022.ts
|
|
4632
|
-
var
|
|
4633
|
-
var
|
|
4634
|
-
var bash_20241022InputSchema = (0,
|
|
4635
|
-
() => (0,
|
|
4636
|
-
|
|
4637
|
-
command:
|
|
4638
|
-
restart:
|
|
4936
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
4937
|
+
var import_v414 = require("zod/v4");
|
|
4938
|
+
var bash_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
4939
|
+
() => (0, import_provider_utils17.zodSchema)(
|
|
4940
|
+
import_v414.z.object({
|
|
4941
|
+
command: import_v414.z.string(),
|
|
4942
|
+
restart: import_v414.z.boolean().optional()
|
|
4639
4943
|
})
|
|
4640
4944
|
)
|
|
4641
4945
|
);
|
|
4642
|
-
var bash_20241022 = (0,
|
|
4946
|
+
var bash_20241022 = (0, import_provider_utils17.createProviderToolFactory)({
|
|
4643
4947
|
id: "anthropic.bash_20241022",
|
|
4644
4948
|
inputSchema: bash_20241022InputSchema
|
|
4645
4949
|
});
|
|
4646
4950
|
|
|
4647
4951
|
// src/tool/bash_20250124.ts
|
|
4648
|
-
var
|
|
4649
|
-
var
|
|
4650
|
-
var bash_20250124InputSchema = (0,
|
|
4651
|
-
() => (0,
|
|
4652
|
-
|
|
4653
|
-
command:
|
|
4654
|
-
restart:
|
|
4952
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
4953
|
+
var import_v415 = require("zod/v4");
|
|
4954
|
+
var bash_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
4955
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
4956
|
+
import_v415.z.object({
|
|
4957
|
+
command: import_v415.z.string(),
|
|
4958
|
+
restart: import_v415.z.boolean().optional()
|
|
4655
4959
|
})
|
|
4656
4960
|
)
|
|
4657
4961
|
);
|
|
4658
|
-
var bash_20250124 = (0,
|
|
4962
|
+
var bash_20250124 = (0, import_provider_utils18.createProviderToolFactory)({
|
|
4659
4963
|
id: "anthropic.bash_20250124",
|
|
4660
4964
|
inputSchema: bash_20250124InputSchema
|
|
4661
4965
|
});
|
|
4662
4966
|
|
|
4663
4967
|
// src/tool/computer_20241022.ts
|
|
4664
|
-
var
|
|
4665
|
-
var
|
|
4666
|
-
var computer_20241022InputSchema = (0,
|
|
4667
|
-
() => (0,
|
|
4668
|
-
|
|
4669
|
-
action:
|
|
4968
|
+
var import_provider_utils19 = require("@ai-sdk/provider-utils");
|
|
4969
|
+
var import_v416 = require("zod/v4");
|
|
4970
|
+
var computer_20241022InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
4971
|
+
() => (0, import_provider_utils19.zodSchema)(
|
|
4972
|
+
import_v416.z.object({
|
|
4973
|
+
action: import_v416.z.enum([
|
|
4670
4974
|
"key",
|
|
4671
4975
|
"type",
|
|
4672
4976
|
"mouse_move",
|
|
@@ -4678,23 +4982,23 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
4678
4982
|
"screenshot",
|
|
4679
4983
|
"cursor_position"
|
|
4680
4984
|
]),
|
|
4681
|
-
coordinate:
|
|
4682
|
-
text:
|
|
4985
|
+
coordinate: import_v416.z.array(import_v416.z.number().int()).optional(),
|
|
4986
|
+
text: import_v416.z.string().optional()
|
|
4683
4987
|
})
|
|
4684
4988
|
)
|
|
4685
4989
|
);
|
|
4686
|
-
var computer_20241022 = (0,
|
|
4990
|
+
var computer_20241022 = (0, import_provider_utils19.createProviderToolFactory)({
|
|
4687
4991
|
id: "anthropic.computer_20241022",
|
|
4688
4992
|
inputSchema: computer_20241022InputSchema
|
|
4689
4993
|
});
|
|
4690
4994
|
|
|
4691
4995
|
// src/tool/computer_20250124.ts
|
|
4692
|
-
var
|
|
4693
|
-
var
|
|
4694
|
-
var computer_20250124InputSchema = (0,
|
|
4695
|
-
() => (0,
|
|
4696
|
-
|
|
4697
|
-
action:
|
|
4996
|
+
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
4997
|
+
var import_v417 = require("zod/v4");
|
|
4998
|
+
var computer_20250124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
4999
|
+
() => (0, import_provider_utils20.zodSchema)(
|
|
5000
|
+
import_v417.z.object({
|
|
5001
|
+
action: import_v417.z.enum([
|
|
4698
5002
|
"key",
|
|
4699
5003
|
"hold_key",
|
|
4700
5004
|
"type",
|
|
@@ -4712,27 +5016,27 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
4712
5016
|
"wait",
|
|
4713
5017
|
"screenshot"
|
|
4714
5018
|
]),
|
|
4715
|
-
coordinate:
|
|
4716
|
-
duration:
|
|
4717
|
-
scroll_amount:
|
|
4718
|
-
scroll_direction:
|
|
4719
|
-
start_coordinate:
|
|
4720
|
-
text:
|
|
5019
|
+
coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
|
|
5020
|
+
duration: import_v417.z.number().optional(),
|
|
5021
|
+
scroll_amount: import_v417.z.number().optional(),
|
|
5022
|
+
scroll_direction: import_v417.z.enum(["up", "down", "left", "right"]).optional(),
|
|
5023
|
+
start_coordinate: import_v417.z.tuple([import_v417.z.number().int(), import_v417.z.number().int()]).optional(),
|
|
5024
|
+
text: import_v417.z.string().optional()
|
|
4721
5025
|
})
|
|
4722
5026
|
)
|
|
4723
5027
|
);
|
|
4724
|
-
var computer_20250124 = (0,
|
|
5028
|
+
var computer_20250124 = (0, import_provider_utils20.createProviderToolFactory)({
|
|
4725
5029
|
id: "anthropic.computer_20250124",
|
|
4726
5030
|
inputSchema: computer_20250124InputSchema
|
|
4727
5031
|
});
|
|
4728
5032
|
|
|
4729
5033
|
// src/tool/computer_20251124.ts
|
|
4730
|
-
var
|
|
4731
|
-
var
|
|
4732
|
-
var computer_20251124InputSchema = (0,
|
|
4733
|
-
() => (0,
|
|
4734
|
-
|
|
4735
|
-
action:
|
|
5034
|
+
var import_provider_utils21 = require("@ai-sdk/provider-utils");
|
|
5035
|
+
var import_v418 = require("zod/v4");
|
|
5036
|
+
var computer_20251124InputSchema = (0, import_provider_utils21.lazySchema)(
|
|
5037
|
+
() => (0, import_provider_utils21.zodSchema)(
|
|
5038
|
+
import_v418.z.object({
|
|
5039
|
+
action: import_v418.z.enum([
|
|
4736
5040
|
"key",
|
|
4737
5041
|
"hold_key",
|
|
4738
5042
|
"type",
|
|
@@ -4751,97 +5055,75 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
4751
5055
|
"screenshot",
|
|
4752
5056
|
"zoom"
|
|
4753
5057
|
]),
|
|
4754
|
-
coordinate:
|
|
4755
|
-
duration:
|
|
4756
|
-
region:
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
5058
|
+
coordinate: import_v418.z.tuple([import_v418.z.number().int(), import_v418.z.number().int()]).optional(),
|
|
5059
|
+
duration: import_v418.z.number().optional(),
|
|
5060
|
+
region: import_v418.z.tuple([
|
|
5061
|
+
import_v418.z.number().int(),
|
|
5062
|
+
import_v418.z.number().int(),
|
|
5063
|
+
import_v418.z.number().int(),
|
|
5064
|
+
import_v418.z.number().int()
|
|
4761
5065
|
]).optional(),
|
|
4762
|
-
scroll_amount:
|
|
4763
|
-
scroll_direction:
|
|
4764
|
-
start_coordinate:
|
|
4765
|
-
text:
|
|
5066
|
+
scroll_amount: import_v418.z.number().optional(),
|
|
5067
|
+
scroll_direction: import_v418.z.enum(["up", "down", "left", "right"]).optional(),
|
|
5068
|
+
start_coordinate: import_v418.z.tuple([import_v418.z.number().int(), import_v418.z.number().int()]).optional(),
|
|
5069
|
+
text: import_v418.z.string().optional()
|
|
4766
5070
|
})
|
|
4767
5071
|
)
|
|
4768
5072
|
);
|
|
4769
|
-
var computer_20251124 = (0,
|
|
5073
|
+
var computer_20251124 = (0, import_provider_utils21.createProviderToolFactory)({
|
|
4770
5074
|
id: "anthropic.computer_20251124",
|
|
4771
5075
|
inputSchema: computer_20251124InputSchema
|
|
4772
5076
|
});
|
|
4773
5077
|
|
|
4774
5078
|
// src/tool/memory_20250818.ts
|
|
4775
|
-
var
|
|
4776
|
-
var
|
|
4777
|
-
var memory_20250818InputSchema = (0,
|
|
4778
|
-
() => (0,
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
command:
|
|
4782
|
-
path:
|
|
4783
|
-
view_range:
|
|
5079
|
+
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
|
5080
|
+
var import_v419 = require("zod/v4");
|
|
5081
|
+
var memory_20250818InputSchema = (0, import_provider_utils22.lazySchema)(
|
|
5082
|
+
() => (0, import_provider_utils22.zodSchema)(
|
|
5083
|
+
import_v419.z.discriminatedUnion("command", [
|
|
5084
|
+
import_v419.z.object({
|
|
5085
|
+
command: import_v419.z.literal("view"),
|
|
5086
|
+
path: import_v419.z.string(),
|
|
5087
|
+
view_range: import_v419.z.tuple([import_v419.z.number(), import_v419.z.number()]).optional()
|
|
4784
5088
|
}),
|
|
4785
|
-
|
|
4786
|
-
command:
|
|
4787
|
-
path:
|
|
4788
|
-
file_text:
|
|
5089
|
+
import_v419.z.object({
|
|
5090
|
+
command: import_v419.z.literal("create"),
|
|
5091
|
+
path: import_v419.z.string(),
|
|
5092
|
+
file_text: import_v419.z.string()
|
|
4789
5093
|
}),
|
|
4790
|
-
|
|
4791
|
-
command:
|
|
4792
|
-
path:
|
|
4793
|
-
old_str:
|
|
4794
|
-
new_str:
|
|
5094
|
+
import_v419.z.object({
|
|
5095
|
+
command: import_v419.z.literal("str_replace"),
|
|
5096
|
+
path: import_v419.z.string(),
|
|
5097
|
+
old_str: import_v419.z.string(),
|
|
5098
|
+
new_str: import_v419.z.string()
|
|
4795
5099
|
}),
|
|
4796
|
-
|
|
4797
|
-
command:
|
|
4798
|
-
path:
|
|
4799
|
-
insert_line:
|
|
4800
|
-
insert_text:
|
|
5100
|
+
import_v419.z.object({
|
|
5101
|
+
command: import_v419.z.literal("insert"),
|
|
5102
|
+
path: import_v419.z.string(),
|
|
5103
|
+
insert_line: import_v419.z.number(),
|
|
5104
|
+
insert_text: import_v419.z.string()
|
|
4801
5105
|
}),
|
|
4802
|
-
|
|
4803
|
-
command:
|
|
4804
|
-
path:
|
|
5106
|
+
import_v419.z.object({
|
|
5107
|
+
command: import_v419.z.literal("delete"),
|
|
5108
|
+
path: import_v419.z.string()
|
|
4805
5109
|
}),
|
|
4806
|
-
|
|
4807
|
-
command:
|
|
4808
|
-
old_path:
|
|
4809
|
-
new_path:
|
|
5110
|
+
import_v419.z.object({
|
|
5111
|
+
command: import_v419.z.literal("rename"),
|
|
5112
|
+
old_path: import_v419.z.string(),
|
|
5113
|
+
new_path: import_v419.z.string()
|
|
4810
5114
|
})
|
|
4811
5115
|
])
|
|
4812
5116
|
)
|
|
4813
5117
|
);
|
|
4814
|
-
var memory_20250818 = (0,
|
|
5118
|
+
var memory_20250818 = (0, import_provider_utils22.createProviderToolFactory)({
|
|
4815
5119
|
id: "anthropic.memory_20250818",
|
|
4816
5120
|
inputSchema: memory_20250818InputSchema
|
|
4817
5121
|
});
|
|
4818
5122
|
|
|
4819
5123
|
// src/tool/text-editor_20241022.ts
|
|
4820
|
-
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
|
4821
|
-
var import_v419 = require("zod/v4");
|
|
4822
|
-
var textEditor_20241022InputSchema = (0, import_provider_utils22.lazySchema)(
|
|
4823
|
-
() => (0, import_provider_utils22.zodSchema)(
|
|
4824
|
-
import_v419.z.object({
|
|
4825
|
-
command: import_v419.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
4826
|
-
path: import_v419.z.string(),
|
|
4827
|
-
file_text: import_v419.z.string().optional(),
|
|
4828
|
-
insert_line: import_v419.z.number().int().optional(),
|
|
4829
|
-
new_str: import_v419.z.string().optional(),
|
|
4830
|
-
insert_text: import_v419.z.string().optional(),
|
|
4831
|
-
old_str: import_v419.z.string().optional(),
|
|
4832
|
-
view_range: import_v419.z.array(import_v419.z.number().int()).optional()
|
|
4833
|
-
})
|
|
4834
|
-
)
|
|
4835
|
-
);
|
|
4836
|
-
var textEditor_20241022 = (0, import_provider_utils22.createProviderToolFactory)({
|
|
4837
|
-
id: "anthropic.text_editor_20241022",
|
|
4838
|
-
inputSchema: textEditor_20241022InputSchema
|
|
4839
|
-
});
|
|
4840
|
-
|
|
4841
|
-
// src/tool/text-editor_20250124.ts
|
|
4842
5124
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
4843
5125
|
var import_v420 = require("zod/v4");
|
|
4844
|
-
var
|
|
5126
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils23.lazySchema)(
|
|
4845
5127
|
() => (0, import_provider_utils23.zodSchema)(
|
|
4846
5128
|
import_v420.z.object({
|
|
4847
5129
|
command: import_v420.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -4855,18 +5137,18 @@ var textEditor_20250124InputSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
4855
5137
|
})
|
|
4856
5138
|
)
|
|
4857
5139
|
);
|
|
4858
|
-
var
|
|
4859
|
-
id: "anthropic.
|
|
4860
|
-
inputSchema:
|
|
5140
|
+
var textEditor_20241022 = (0, import_provider_utils23.createProviderToolFactory)({
|
|
5141
|
+
id: "anthropic.text_editor_20241022",
|
|
5142
|
+
inputSchema: textEditor_20241022InputSchema
|
|
4861
5143
|
});
|
|
4862
5144
|
|
|
4863
|
-
// src/tool/text-
|
|
5145
|
+
// src/tool/text-editor_20250124.ts
|
|
4864
5146
|
var import_provider_utils24 = require("@ai-sdk/provider-utils");
|
|
4865
5147
|
var import_v421 = require("zod/v4");
|
|
4866
|
-
var
|
|
5148
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils24.lazySchema)(
|
|
4867
5149
|
() => (0, import_provider_utils24.zodSchema)(
|
|
4868
5150
|
import_v421.z.object({
|
|
4869
|
-
command: import_v421.z.enum(["view", "create", "str_replace", "insert"]),
|
|
5151
|
+
command: import_v421.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
4870
5152
|
path: import_v421.z.string(),
|
|
4871
5153
|
file_text: import_v421.z.string().optional(),
|
|
4872
5154
|
insert_line: import_v421.z.number().int().optional(),
|
|
@@ -4877,47 +5159,69 @@ var textEditor_20250429InputSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
4877
5159
|
})
|
|
4878
5160
|
)
|
|
4879
5161
|
);
|
|
4880
|
-
var
|
|
4881
|
-
id: "anthropic.
|
|
4882
|
-
inputSchema:
|
|
5162
|
+
var textEditor_20250124 = (0, import_provider_utils24.createProviderToolFactory)({
|
|
5163
|
+
id: "anthropic.text_editor_20250124",
|
|
5164
|
+
inputSchema: textEditor_20250124InputSchema
|
|
4883
5165
|
});
|
|
4884
5166
|
|
|
4885
|
-
// src/tool/
|
|
5167
|
+
// src/tool/text-editor_20250429.ts
|
|
4886
5168
|
var import_provider_utils25 = require("@ai-sdk/provider-utils");
|
|
4887
5169
|
var import_v422 = require("zod/v4");
|
|
4888
|
-
var
|
|
5170
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils25.lazySchema)(
|
|
4889
5171
|
() => (0, import_provider_utils25.zodSchema)(
|
|
4890
|
-
import_v422.z.
|
|
4891
|
-
import_v422.z.
|
|
4892
|
-
|
|
4893
|
-
|
|
5172
|
+
import_v422.z.object({
|
|
5173
|
+
command: import_v422.z.enum(["view", "create", "str_replace", "insert"]),
|
|
5174
|
+
path: import_v422.z.string(),
|
|
5175
|
+
file_text: import_v422.z.string().optional(),
|
|
5176
|
+
insert_line: import_v422.z.number().int().optional(),
|
|
5177
|
+
new_str: import_v422.z.string().optional(),
|
|
5178
|
+
insert_text: import_v422.z.string().optional(),
|
|
5179
|
+
old_str: import_v422.z.string().optional(),
|
|
5180
|
+
view_range: import_v422.z.array(import_v422.z.number().int()).optional()
|
|
5181
|
+
})
|
|
5182
|
+
)
|
|
5183
|
+
);
|
|
5184
|
+
var textEditor_20250429 = (0, import_provider_utils25.createProviderToolFactory)({
|
|
5185
|
+
id: "anthropic.text_editor_20250429",
|
|
5186
|
+
inputSchema: textEditor_20250429InputSchema
|
|
5187
|
+
});
|
|
5188
|
+
|
|
5189
|
+
// src/tool/tool-search-bm25_20251119.ts
|
|
5190
|
+
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
|
5191
|
+
var import_v423 = require("zod/v4");
|
|
5192
|
+
var toolSearchBm25_20251119OutputSchema = (0, import_provider_utils26.lazySchema)(
|
|
5193
|
+
() => (0, import_provider_utils26.zodSchema)(
|
|
5194
|
+
import_v423.z.array(
|
|
5195
|
+
import_v423.z.object({
|
|
5196
|
+
type: import_v423.z.literal("tool_reference"),
|
|
5197
|
+
toolName: import_v423.z.string()
|
|
4894
5198
|
})
|
|
4895
5199
|
)
|
|
4896
5200
|
)
|
|
4897
5201
|
);
|
|
4898
|
-
var toolSearchBm25_20251119InputSchema = (0,
|
|
4899
|
-
() => (0,
|
|
4900
|
-
|
|
5202
|
+
var toolSearchBm25_20251119InputSchema = (0, import_provider_utils26.lazySchema)(
|
|
5203
|
+
() => (0, import_provider_utils26.zodSchema)(
|
|
5204
|
+
import_v423.z.object({
|
|
4901
5205
|
/**
|
|
4902
5206
|
* A natural language query to search for tools.
|
|
4903
5207
|
* Claude will use BM25 text search to find relevant tools.
|
|
4904
5208
|
*/
|
|
4905
|
-
query:
|
|
5209
|
+
query: import_v423.z.string(),
|
|
4906
5210
|
/**
|
|
4907
5211
|
* Maximum number of tools to return. Optional.
|
|
4908
5212
|
*/
|
|
4909
|
-
limit:
|
|
5213
|
+
limit: import_v423.z.number().optional()
|
|
4910
5214
|
})
|
|
4911
5215
|
)
|
|
4912
5216
|
);
|
|
4913
|
-
var
|
|
5217
|
+
var factory11 = (0, import_provider_utils26.createProviderToolFactoryWithOutputSchema)({
|
|
4914
5218
|
id: "anthropic.tool_search_bm25_20251119",
|
|
4915
5219
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
4916
5220
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
4917
5221
|
supportsDeferredResults: true
|
|
4918
5222
|
});
|
|
4919
5223
|
var toolSearchBm25_20251119 = (args = {}) => {
|
|
4920
|
-
return
|
|
5224
|
+
return factory11(args);
|
|
4921
5225
|
};
|
|
4922
5226
|
|
|
4923
5227
|
// src/anthropic-tools.ts
|
|
@@ -5074,6 +5378,22 @@ var anthropicTools = {
|
|
|
5074
5378
|
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
5075
5379
|
*/
|
|
5076
5380
|
webFetch_20260209,
|
|
5381
|
+
/**
|
|
5382
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
5383
|
+
* GA version (no beta header required). Includes caller restrictions, cache control,
|
|
5384
|
+
* deferred loading, and strict mode.
|
|
5385
|
+
*
|
|
5386
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
5387
|
+
* @param allowedDomains - Only fetch from these domains
|
|
5388
|
+
* @param blockedDomains - Never fetch from these domains
|
|
5389
|
+
* @param citations - Citations configuration for fetched documents
|
|
5390
|
+
* @param maxContentTokens - Max content tokens included in context
|
|
5391
|
+
* @param allowedCallers - Restrict callers (e.g. ["direct"] to prevent code_execution usage)
|
|
5392
|
+
* @param useCache - Whether to use cached content (set false for fresh content)
|
|
5393
|
+
* @param deferLoading - Defer loading until tool_search discovers it
|
|
5394
|
+
* @param strict - Enable strict schema validation
|
|
5395
|
+
*/
|
|
5396
|
+
webFetch_20260309,
|
|
5077
5397
|
/**
|
|
5078
5398
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
5079
5399
|
*
|
|
@@ -5125,8 +5445,8 @@ var anthropicTools = {
|
|
|
5125
5445
|
// src/anthropic-provider.ts
|
|
5126
5446
|
function createAnthropic(options = {}) {
|
|
5127
5447
|
var _a, _b;
|
|
5128
|
-
const baseURL = (_a = (0,
|
|
5129
|
-
(0,
|
|
5448
|
+
const baseURL = (_a = (0, import_provider_utils27.withoutTrailingSlash)(
|
|
5449
|
+
(0, import_provider_utils27.loadOptionalSetting)({
|
|
5130
5450
|
settingValue: options.baseURL,
|
|
5131
5451
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
5132
5452
|
})
|
|
@@ -5140,13 +5460,13 @@ function createAnthropic(options = {}) {
|
|
|
5140
5460
|
}
|
|
5141
5461
|
const getHeaders = () => {
|
|
5142
5462
|
const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
|
|
5143
|
-
"x-api-key": (0,
|
|
5463
|
+
"x-api-key": (0, import_provider_utils27.loadApiKey)({
|
|
5144
5464
|
apiKey: options.apiKey,
|
|
5145
5465
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
5146
5466
|
description: "Anthropic"
|
|
5147
5467
|
})
|
|
5148
5468
|
};
|
|
5149
|
-
return (0,
|
|
5469
|
+
return (0, import_provider_utils27.withUserAgentSuffix)(
|
|
5150
5470
|
{
|
|
5151
5471
|
"anthropic-version": "2023-06-01",
|
|
5152
5472
|
...authHeaders,
|
|
@@ -5162,7 +5482,7 @@ function createAnthropic(options = {}) {
|
|
|
5162
5482
|
baseURL,
|
|
5163
5483
|
headers: getHeaders,
|
|
5164
5484
|
fetch: options.fetch,
|
|
5165
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
5485
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils27.generateId,
|
|
5166
5486
|
supportedUrls: () => ({
|
|
5167
5487
|
"image/*": [/^https?:\/\/.*$/],
|
|
5168
5488
|
"application/pdf": [/^https?:\/\/.*$/]
|
|
@@ -5177,7 +5497,7 @@ function createAnthropic(options = {}) {
|
|
|
5177
5497
|
}
|
|
5178
5498
|
return createChatModel(modelId);
|
|
5179
5499
|
};
|
|
5180
|
-
provider.specificationVersion = "
|
|
5500
|
+
provider.specificationVersion = "v4";
|
|
5181
5501
|
provider.languageModel = createChatModel;
|
|
5182
5502
|
provider.chat = createChatModel;
|
|
5183
5503
|
provider.messages = createChatModel;
|