@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/internal/index.mjs
CHANGED
|
@@ -860,6 +860,20 @@ var anthropicLanguageModelOptions = z3.object({
|
|
|
860
860
|
type: z3.literal("ephemeral"),
|
|
861
861
|
ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
|
|
862
862
|
}).optional(),
|
|
863
|
+
/**
|
|
864
|
+
* Metadata to include with the request.
|
|
865
|
+
*
|
|
866
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
867
|
+
*/
|
|
868
|
+
metadata: z3.object({
|
|
869
|
+
/**
|
|
870
|
+
* An external identifier for the user associated with the request.
|
|
871
|
+
*
|
|
872
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
873
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
874
|
+
*/
|
|
875
|
+
userId: z3.string().optional()
|
|
876
|
+
}).optional(),
|
|
863
877
|
/**
|
|
864
878
|
* MCP servers to be utilized in this request.
|
|
865
879
|
*/
|
|
@@ -921,6 +935,12 @@ var anthropicLanguageModelOptions = z3.object({
|
|
|
921
935
|
* Example: Setting prefill to '{"' will make the model start its response with '{"'
|
|
922
936
|
*/
|
|
923
937
|
prefill: z3.string().optional(),
|
|
938
|
+
/**
|
|
939
|
+
* Service tier selection.
|
|
940
|
+
* - 'auto': Allow Anthropic to pick standard or priority based on availability.
|
|
941
|
+
* See https://docs.anthropic.com/en/api/messages
|
|
942
|
+
*/
|
|
943
|
+
serviceTier: z3.enum(["auto"]).optional(),
|
|
924
944
|
contextManagement: z3.object({
|
|
925
945
|
edits: z3.array(
|
|
926
946
|
z3.discriminatedUnion("type", [
|
|
@@ -1070,7 +1090,14 @@ var webSearch_20260209ArgsSchema = lazySchema4(
|
|
|
1070
1090
|
region: z5.string().optional(),
|
|
1071
1091
|
country: z5.string().optional(),
|
|
1072
1092
|
timezone: z5.string().optional()
|
|
1073
|
-
}).optional()
|
|
1093
|
+
}).optional(),
|
|
1094
|
+
allowedCallers: z5.array(
|
|
1095
|
+
z5.enum([
|
|
1096
|
+
"direct",
|
|
1097
|
+
"code_execution_20250825",
|
|
1098
|
+
"code_execution_20260120"
|
|
1099
|
+
])
|
|
1100
|
+
).optional()
|
|
1074
1101
|
})
|
|
1075
1102
|
)
|
|
1076
1103
|
);
|
|
@@ -1157,25 +1184,35 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
1157
1184
|
return factory3(args);
|
|
1158
1185
|
};
|
|
1159
1186
|
|
|
1160
|
-
// src/tool/web-fetch-
|
|
1187
|
+
// src/tool/web-fetch-20260309.ts
|
|
1161
1188
|
import {
|
|
1162
1189
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
1163
1190
|
lazySchema as lazySchema6,
|
|
1164
1191
|
zodSchema as zodSchema6
|
|
1165
1192
|
} from "@ai-sdk/provider-utils";
|
|
1166
1193
|
import { z as z7 } from "zod/v4";
|
|
1167
|
-
var
|
|
1194
|
+
var webFetch_20260309ArgsSchema = lazySchema6(
|
|
1168
1195
|
() => zodSchema6(
|
|
1169
1196
|
z7.object({
|
|
1170
1197
|
maxUses: z7.number().optional(),
|
|
1171
1198
|
allowedDomains: z7.array(z7.string()).optional(),
|
|
1172
1199
|
blockedDomains: z7.array(z7.string()).optional(),
|
|
1173
1200
|
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1174
|
-
maxContentTokens: z7.number().optional()
|
|
1201
|
+
maxContentTokens: z7.number().optional(),
|
|
1202
|
+
allowedCallers: z7.array(
|
|
1203
|
+
z7.enum([
|
|
1204
|
+
"direct",
|
|
1205
|
+
"code_execution_20250825",
|
|
1206
|
+
"code_execution_20260120"
|
|
1207
|
+
])
|
|
1208
|
+
).optional(),
|
|
1209
|
+
useCache: z7.boolean().optional(),
|
|
1210
|
+
deferLoading: z7.boolean().optional(),
|
|
1211
|
+
strict: z7.boolean().optional()
|
|
1175
1212
|
})
|
|
1176
1213
|
)
|
|
1177
1214
|
);
|
|
1178
|
-
var
|
|
1215
|
+
var webFetch_20260309OutputSchema = lazySchema6(
|
|
1179
1216
|
() => zodSchema6(
|
|
1180
1217
|
z7.object({
|
|
1181
1218
|
type: z7.literal("web_fetch_result"),
|
|
@@ -1201,7 +1238,7 @@ var webFetch_20260209OutputSchema = lazySchema6(
|
|
|
1201
1238
|
})
|
|
1202
1239
|
)
|
|
1203
1240
|
);
|
|
1204
|
-
var
|
|
1241
|
+
var webFetch_20260309InputSchema = lazySchema6(
|
|
1205
1242
|
() => zodSchema6(
|
|
1206
1243
|
z7.object({
|
|
1207
1244
|
url: z7.string()
|
|
@@ -1209,23 +1246,23 @@ var webFetch_20260209InputSchema = lazySchema6(
|
|
|
1209
1246
|
)
|
|
1210
1247
|
);
|
|
1211
1248
|
var factory4 = createProviderToolFactoryWithOutputSchema3({
|
|
1212
|
-
id: "anthropic.
|
|
1213
|
-
inputSchema:
|
|
1214
|
-
outputSchema:
|
|
1249
|
+
id: "anthropic.web_fetch_20260309",
|
|
1250
|
+
inputSchema: webFetch_20260309InputSchema,
|
|
1251
|
+
outputSchema: webFetch_20260309OutputSchema,
|
|
1215
1252
|
supportsDeferredResults: true
|
|
1216
1253
|
});
|
|
1217
|
-
var
|
|
1254
|
+
var webFetch_20260309 = (args = {}) => {
|
|
1218
1255
|
return factory4(args);
|
|
1219
1256
|
};
|
|
1220
1257
|
|
|
1221
|
-
// src/tool/web-fetch-
|
|
1258
|
+
// src/tool/web-fetch-20260209.ts
|
|
1222
1259
|
import {
|
|
1223
1260
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
|
|
1224
1261
|
lazySchema as lazySchema7,
|
|
1225
1262
|
zodSchema as zodSchema7
|
|
1226
1263
|
} from "@ai-sdk/provider-utils";
|
|
1227
1264
|
import { z as z8 } from "zod/v4";
|
|
1228
|
-
var
|
|
1265
|
+
var webFetch_20260209ArgsSchema = lazySchema7(
|
|
1229
1266
|
() => zodSchema7(
|
|
1230
1267
|
z8.object({
|
|
1231
1268
|
maxUses: z8.number().optional(),
|
|
@@ -1236,7 +1273,7 @@ var webFetch_20250910ArgsSchema = lazySchema7(
|
|
|
1236
1273
|
})
|
|
1237
1274
|
)
|
|
1238
1275
|
);
|
|
1239
|
-
var
|
|
1276
|
+
var webFetch_20260209OutputSchema = lazySchema7(
|
|
1240
1277
|
() => zodSchema7(
|
|
1241
1278
|
z8.object({
|
|
1242
1279
|
type: z8.literal("web_fetch_result"),
|
|
@@ -1262,7 +1299,7 @@ var webFetch_20250910OutputSchema = lazySchema7(
|
|
|
1262
1299
|
})
|
|
1263
1300
|
)
|
|
1264
1301
|
);
|
|
1265
|
-
var
|
|
1302
|
+
var webFetch_20260209InputSchema = lazySchema7(
|
|
1266
1303
|
() => zodSchema7(
|
|
1267
1304
|
z8.object({
|
|
1268
1305
|
url: z8.string()
|
|
@@ -1270,13 +1307,74 @@ var webFetch_20250910InputSchema = lazySchema7(
|
|
|
1270
1307
|
)
|
|
1271
1308
|
);
|
|
1272
1309
|
var factory5 = createProviderToolFactoryWithOutputSchema4({
|
|
1310
|
+
id: "anthropic.web_fetch_20260209",
|
|
1311
|
+
inputSchema: webFetch_20260209InputSchema,
|
|
1312
|
+
outputSchema: webFetch_20260209OutputSchema,
|
|
1313
|
+
supportsDeferredResults: true
|
|
1314
|
+
});
|
|
1315
|
+
var webFetch_20260209 = (args = {}) => {
|
|
1316
|
+
return factory5(args);
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
// src/tool/web-fetch-20250910.ts
|
|
1320
|
+
import {
|
|
1321
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
|
|
1322
|
+
lazySchema as lazySchema8,
|
|
1323
|
+
zodSchema as zodSchema8
|
|
1324
|
+
} from "@ai-sdk/provider-utils";
|
|
1325
|
+
import { z as z9 } from "zod/v4";
|
|
1326
|
+
var webFetch_20250910ArgsSchema = lazySchema8(
|
|
1327
|
+
() => zodSchema8(
|
|
1328
|
+
z9.object({
|
|
1329
|
+
maxUses: z9.number().optional(),
|
|
1330
|
+
allowedDomains: z9.array(z9.string()).optional(),
|
|
1331
|
+
blockedDomains: z9.array(z9.string()).optional(),
|
|
1332
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1333
|
+
maxContentTokens: z9.number().optional()
|
|
1334
|
+
})
|
|
1335
|
+
)
|
|
1336
|
+
);
|
|
1337
|
+
var webFetch_20250910OutputSchema = lazySchema8(
|
|
1338
|
+
() => zodSchema8(
|
|
1339
|
+
z9.object({
|
|
1340
|
+
type: z9.literal("web_fetch_result"),
|
|
1341
|
+
url: z9.string(),
|
|
1342
|
+
content: z9.object({
|
|
1343
|
+
type: z9.literal("document"),
|
|
1344
|
+
title: z9.string().nullable(),
|
|
1345
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1346
|
+
source: z9.union([
|
|
1347
|
+
z9.object({
|
|
1348
|
+
type: z9.literal("base64"),
|
|
1349
|
+
mediaType: z9.literal("application/pdf"),
|
|
1350
|
+
data: z9.string()
|
|
1351
|
+
}),
|
|
1352
|
+
z9.object({
|
|
1353
|
+
type: z9.literal("text"),
|
|
1354
|
+
mediaType: z9.literal("text/plain"),
|
|
1355
|
+
data: z9.string()
|
|
1356
|
+
})
|
|
1357
|
+
])
|
|
1358
|
+
}),
|
|
1359
|
+
retrievedAt: z9.string().nullable()
|
|
1360
|
+
})
|
|
1361
|
+
)
|
|
1362
|
+
);
|
|
1363
|
+
var webFetch_20250910InputSchema = lazySchema8(
|
|
1364
|
+
() => zodSchema8(
|
|
1365
|
+
z9.object({
|
|
1366
|
+
url: z9.string()
|
|
1367
|
+
})
|
|
1368
|
+
)
|
|
1369
|
+
);
|
|
1370
|
+
var factory6 = createProviderToolFactoryWithOutputSchema5({
|
|
1273
1371
|
id: "anthropic.web_fetch_20250910",
|
|
1274
1372
|
inputSchema: webFetch_20250910InputSchema,
|
|
1275
1373
|
outputSchema: webFetch_20250910OutputSchema,
|
|
1276
1374
|
supportsDeferredResults: true
|
|
1277
1375
|
});
|
|
1278
1376
|
var webFetch_20250910 = (args = {}) => {
|
|
1279
|
-
return
|
|
1377
|
+
return factory6(args);
|
|
1280
1378
|
};
|
|
1281
1379
|
|
|
1282
1380
|
// src/anthropic-prepare-tools.ts
|
|
@@ -1286,7 +1384,8 @@ async function prepareTools({
|
|
|
1286
1384
|
toolChoice,
|
|
1287
1385
|
disableParallelToolUse,
|
|
1288
1386
|
cacheControlValidator,
|
|
1289
|
-
supportsStructuredOutput
|
|
1387
|
+
supportsStructuredOutput,
|
|
1388
|
+
supportsStrictTools
|
|
1290
1389
|
}) {
|
|
1291
1390
|
var _a;
|
|
1292
1391
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1308,13 +1407,20 @@ async function prepareTools({
|
|
|
1308
1407
|
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1309
1408
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1310
1409
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1410
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1411
|
+
toolWarnings.push({
|
|
1412
|
+
type: "unsupported",
|
|
1413
|
+
feature: "strict",
|
|
1414
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1311
1417
|
anthropicTools2.push({
|
|
1312
1418
|
name: tool.name,
|
|
1313
1419
|
description: tool.description,
|
|
1314
1420
|
input_schema: tool.inputSchema,
|
|
1315
1421
|
cache_control: cacheControl,
|
|
1316
1422
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1317
|
-
...
|
|
1423
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1318
1424
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1319
1425
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1320
1426
|
...tool.inputExamples != null ? {
|
|
@@ -1343,7 +1449,6 @@ async function prepareTools({
|
|
|
1343
1449
|
break;
|
|
1344
1450
|
}
|
|
1345
1451
|
case "anthropic.code_execution_20250825": {
|
|
1346
|
-
betas.add("code-execution-2025-08-25");
|
|
1347
1452
|
anthropicTools2.push({
|
|
1348
1453
|
type: "code_execution_20250825",
|
|
1349
1454
|
name: "code_execution"
|
|
@@ -1461,7 +1566,6 @@ async function prepareTools({
|
|
|
1461
1566
|
break;
|
|
1462
1567
|
}
|
|
1463
1568
|
case "anthropic.web_fetch_20250910": {
|
|
1464
|
-
betas.add("web-fetch-2025-09-10");
|
|
1465
1569
|
const args = await validateTypes({
|
|
1466
1570
|
value: tool.args,
|
|
1467
1571
|
schema: webFetch_20250910ArgsSchema
|
|
@@ -1479,7 +1583,6 @@ async function prepareTools({
|
|
|
1479
1583
|
break;
|
|
1480
1584
|
}
|
|
1481
1585
|
case "anthropic.web_fetch_20260209": {
|
|
1482
|
-
betas.add("code-execution-web-tools-2026-02-09");
|
|
1483
1586
|
const args = await validateTypes({
|
|
1484
1587
|
value: tool.args,
|
|
1485
1588
|
schema: webFetch_20260209ArgsSchema
|
|
@@ -1496,6 +1599,27 @@ async function prepareTools({
|
|
|
1496
1599
|
});
|
|
1497
1600
|
break;
|
|
1498
1601
|
}
|
|
1602
|
+
case "anthropic.web_fetch_20260309": {
|
|
1603
|
+
const args = await validateTypes({
|
|
1604
|
+
value: tool.args,
|
|
1605
|
+
schema: webFetch_20260309ArgsSchema
|
|
1606
|
+
});
|
|
1607
|
+
anthropicTools2.push({
|
|
1608
|
+
type: "web_fetch_20260309",
|
|
1609
|
+
name: "web_fetch",
|
|
1610
|
+
max_uses: args.maxUses,
|
|
1611
|
+
allowed_domains: args.allowedDomains,
|
|
1612
|
+
blocked_domains: args.blockedDomains,
|
|
1613
|
+
citations: args.citations,
|
|
1614
|
+
max_content_tokens: args.maxContentTokens,
|
|
1615
|
+
allowed_callers: args.allowedCallers,
|
|
1616
|
+
use_cache: args.useCache,
|
|
1617
|
+
defer_loading: args.deferLoading,
|
|
1618
|
+
strict: args.strict,
|
|
1619
|
+
cache_control: void 0
|
|
1620
|
+
});
|
|
1621
|
+
break;
|
|
1622
|
+
}
|
|
1499
1623
|
case "anthropic.web_search_20250305": {
|
|
1500
1624
|
const args = await validateTypes({
|
|
1501
1625
|
value: tool.args,
|
|
@@ -1513,7 +1637,6 @@ async function prepareTools({
|
|
|
1513
1637
|
break;
|
|
1514
1638
|
}
|
|
1515
1639
|
case "anthropic.web_search_20260209": {
|
|
1516
|
-
betas.add("code-execution-web-tools-2026-02-09");
|
|
1517
1640
|
const args = await validateTypes({
|
|
1518
1641
|
value: tool.args,
|
|
1519
1642
|
schema: webSearch_20260209ArgsSchema
|
|
@@ -1525,12 +1648,12 @@ async function prepareTools({
|
|
|
1525
1648
|
allowed_domains: args.allowedDomains,
|
|
1526
1649
|
blocked_domains: args.blockedDomains,
|
|
1527
1650
|
user_location: args.userLocation,
|
|
1651
|
+
allowed_callers: args.allowedCallers,
|
|
1528
1652
|
cache_control: void 0
|
|
1529
1653
|
});
|
|
1530
1654
|
break;
|
|
1531
1655
|
}
|
|
1532
1656
|
case "anthropic.tool_search_regex_20251119": {
|
|
1533
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1534
1657
|
anthropicTools2.push({
|
|
1535
1658
|
type: "tool_search_tool_regex_20251119",
|
|
1536
1659
|
name: "tool_search_tool_regex"
|
|
@@ -1538,7 +1661,6 @@ async function prepareTools({
|
|
|
1538
1661
|
break;
|
|
1539
1662
|
}
|
|
1540
1663
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1541
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1542
1664
|
anthropicTools2.push({
|
|
1543
1665
|
type: "tool_search_tool_bm25_20251119",
|
|
1544
1666
|
name: "tool_search_tool_bm25"
|
|
@@ -1670,164 +1792,51 @@ import {
|
|
|
1670
1792
|
|
|
1671
1793
|
// src/tool/code-execution_20250522.ts
|
|
1672
1794
|
import {
|
|
1673
|
-
createProviderToolFactoryWithOutputSchema as
|
|
1674
|
-
lazySchema as
|
|
1675
|
-
zodSchema as
|
|
1795
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
1796
|
+
lazySchema as lazySchema9,
|
|
1797
|
+
zodSchema as zodSchema9
|
|
1676
1798
|
} from "@ai-sdk/provider-utils";
|
|
1677
|
-
import { z as
|
|
1678
|
-
var codeExecution_20250522OutputSchema =
|
|
1679
|
-
() =>
|
|
1680
|
-
|
|
1681
|
-
type:
|
|
1682
|
-
stdout:
|
|
1683
|
-
stderr:
|
|
1684
|
-
return_code:
|
|
1685
|
-
content:
|
|
1686
|
-
|
|
1687
|
-
type:
|
|
1688
|
-
file_id:
|
|
1799
|
+
import { z as z10 } from "zod/v4";
|
|
1800
|
+
var codeExecution_20250522OutputSchema = lazySchema9(
|
|
1801
|
+
() => zodSchema9(
|
|
1802
|
+
z10.object({
|
|
1803
|
+
type: z10.literal("code_execution_result"),
|
|
1804
|
+
stdout: z10.string(),
|
|
1805
|
+
stderr: z10.string(),
|
|
1806
|
+
return_code: z10.number(),
|
|
1807
|
+
content: z10.array(
|
|
1808
|
+
z10.object({
|
|
1809
|
+
type: z10.literal("code_execution_output"),
|
|
1810
|
+
file_id: z10.string()
|
|
1689
1811
|
})
|
|
1690
1812
|
).optional().default([])
|
|
1691
1813
|
})
|
|
1692
1814
|
)
|
|
1693
1815
|
);
|
|
1694
|
-
var codeExecution_20250522InputSchema =
|
|
1695
|
-
() =>
|
|
1696
|
-
|
|
1697
|
-
code:
|
|
1816
|
+
var codeExecution_20250522InputSchema = lazySchema9(
|
|
1817
|
+
() => zodSchema9(
|
|
1818
|
+
z10.object({
|
|
1819
|
+
code: z10.string()
|
|
1698
1820
|
})
|
|
1699
1821
|
)
|
|
1700
1822
|
);
|
|
1701
|
-
var
|
|
1823
|
+
var factory7 = createProviderToolFactoryWithOutputSchema6({
|
|
1702
1824
|
id: "anthropic.code_execution_20250522",
|
|
1703
1825
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1704
1826
|
outputSchema: codeExecution_20250522OutputSchema
|
|
1705
1827
|
});
|
|
1706
1828
|
var codeExecution_20250522 = (args = {}) => {
|
|
1707
|
-
return factory6(args);
|
|
1708
|
-
};
|
|
1709
|
-
|
|
1710
|
-
// src/tool/code-execution_20250825.ts
|
|
1711
|
-
import {
|
|
1712
|
-
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
1713
|
-
lazySchema as lazySchema9,
|
|
1714
|
-
zodSchema as zodSchema9
|
|
1715
|
-
} from "@ai-sdk/provider-utils";
|
|
1716
|
-
import { z as z10 } from "zod/v4";
|
|
1717
|
-
var codeExecution_20250825OutputSchema = lazySchema9(
|
|
1718
|
-
() => zodSchema9(
|
|
1719
|
-
z10.discriminatedUnion("type", [
|
|
1720
|
-
z10.object({
|
|
1721
|
-
type: z10.literal("code_execution_result"),
|
|
1722
|
-
stdout: z10.string(),
|
|
1723
|
-
stderr: z10.string(),
|
|
1724
|
-
return_code: z10.number(),
|
|
1725
|
-
content: z10.array(
|
|
1726
|
-
z10.object({
|
|
1727
|
-
type: z10.literal("code_execution_output"),
|
|
1728
|
-
file_id: z10.string()
|
|
1729
|
-
})
|
|
1730
|
-
).optional().default([])
|
|
1731
|
-
}),
|
|
1732
|
-
z10.object({
|
|
1733
|
-
type: z10.literal("bash_code_execution_result"),
|
|
1734
|
-
content: z10.array(
|
|
1735
|
-
z10.object({
|
|
1736
|
-
type: z10.literal("bash_code_execution_output"),
|
|
1737
|
-
file_id: z10.string()
|
|
1738
|
-
})
|
|
1739
|
-
),
|
|
1740
|
-
stdout: z10.string(),
|
|
1741
|
-
stderr: z10.string(),
|
|
1742
|
-
return_code: z10.number()
|
|
1743
|
-
}),
|
|
1744
|
-
z10.object({
|
|
1745
|
-
type: z10.literal("bash_code_execution_tool_result_error"),
|
|
1746
|
-
error_code: z10.string()
|
|
1747
|
-
}),
|
|
1748
|
-
z10.object({
|
|
1749
|
-
type: z10.literal("text_editor_code_execution_tool_result_error"),
|
|
1750
|
-
error_code: z10.string()
|
|
1751
|
-
}),
|
|
1752
|
-
z10.object({
|
|
1753
|
-
type: z10.literal("text_editor_code_execution_view_result"),
|
|
1754
|
-
content: z10.string(),
|
|
1755
|
-
file_type: z10.string(),
|
|
1756
|
-
num_lines: z10.number().nullable(),
|
|
1757
|
-
start_line: z10.number().nullable(),
|
|
1758
|
-
total_lines: z10.number().nullable()
|
|
1759
|
-
}),
|
|
1760
|
-
z10.object({
|
|
1761
|
-
type: z10.literal("text_editor_code_execution_create_result"),
|
|
1762
|
-
is_file_update: z10.boolean()
|
|
1763
|
-
}),
|
|
1764
|
-
z10.object({
|
|
1765
|
-
type: z10.literal("text_editor_code_execution_str_replace_result"),
|
|
1766
|
-
lines: z10.array(z10.string()).nullable(),
|
|
1767
|
-
new_lines: z10.number().nullable(),
|
|
1768
|
-
new_start: z10.number().nullable(),
|
|
1769
|
-
old_lines: z10.number().nullable(),
|
|
1770
|
-
old_start: z10.number().nullable()
|
|
1771
|
-
})
|
|
1772
|
-
])
|
|
1773
|
-
)
|
|
1774
|
-
);
|
|
1775
|
-
var codeExecution_20250825InputSchema = lazySchema9(
|
|
1776
|
-
() => zodSchema9(
|
|
1777
|
-
z10.discriminatedUnion("type", [
|
|
1778
|
-
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1779
|
-
z10.object({
|
|
1780
|
-
type: z10.literal("programmatic-tool-call"),
|
|
1781
|
-
code: z10.string()
|
|
1782
|
-
}),
|
|
1783
|
-
z10.object({
|
|
1784
|
-
type: z10.literal("bash_code_execution"),
|
|
1785
|
-
command: z10.string()
|
|
1786
|
-
}),
|
|
1787
|
-
z10.discriminatedUnion("command", [
|
|
1788
|
-
z10.object({
|
|
1789
|
-
type: z10.literal("text_editor_code_execution"),
|
|
1790
|
-
command: z10.literal("view"),
|
|
1791
|
-
path: z10.string()
|
|
1792
|
-
}),
|
|
1793
|
-
z10.object({
|
|
1794
|
-
type: z10.literal("text_editor_code_execution"),
|
|
1795
|
-
command: z10.literal("create"),
|
|
1796
|
-
path: z10.string(),
|
|
1797
|
-
file_text: z10.string().nullish()
|
|
1798
|
-
}),
|
|
1799
|
-
z10.object({
|
|
1800
|
-
type: z10.literal("text_editor_code_execution"),
|
|
1801
|
-
command: z10.literal("str_replace"),
|
|
1802
|
-
path: z10.string(),
|
|
1803
|
-
old_str: z10.string(),
|
|
1804
|
-
new_str: z10.string()
|
|
1805
|
-
})
|
|
1806
|
-
])
|
|
1807
|
-
])
|
|
1808
|
-
)
|
|
1809
|
-
);
|
|
1810
|
-
var factory7 = createProviderToolFactoryWithOutputSchema6({
|
|
1811
|
-
id: "anthropic.code_execution_20250825",
|
|
1812
|
-
inputSchema: codeExecution_20250825InputSchema,
|
|
1813
|
-
outputSchema: codeExecution_20250825OutputSchema,
|
|
1814
|
-
// Programmatic tool calling: tool results may be deferred to a later turn
|
|
1815
|
-
// when code execution triggers a client-executed tool that needs to be
|
|
1816
|
-
// resolved before the code execution result can be returned.
|
|
1817
|
-
supportsDeferredResults: true
|
|
1818
|
-
});
|
|
1819
|
-
var codeExecution_20250825 = (args = {}) => {
|
|
1820
1829
|
return factory7(args);
|
|
1821
1830
|
};
|
|
1822
1831
|
|
|
1823
|
-
// src/tool/code-
|
|
1832
|
+
// src/tool/code-execution_20250825.ts
|
|
1824
1833
|
import {
|
|
1825
1834
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
|
|
1826
1835
|
lazySchema as lazySchema10,
|
|
1827
1836
|
zodSchema as zodSchema10
|
|
1828
1837
|
} from "@ai-sdk/provider-utils";
|
|
1829
1838
|
import { z as z11 } from "zod/v4";
|
|
1830
|
-
var
|
|
1839
|
+
var codeExecution_20250825OutputSchema = lazySchema10(
|
|
1831
1840
|
() => zodSchema10(
|
|
1832
1841
|
z11.discriminatedUnion("type", [
|
|
1833
1842
|
z11.object({
|
|
@@ -1842,18 +1851,6 @@ var codeExecution_20260120OutputSchema = lazySchema10(
|
|
|
1842
1851
|
})
|
|
1843
1852
|
).optional().default([])
|
|
1844
1853
|
}),
|
|
1845
|
-
z11.object({
|
|
1846
|
-
type: z11.literal("encrypted_code_execution_result"),
|
|
1847
|
-
encrypted_stdout: z11.string(),
|
|
1848
|
-
stderr: z11.string(),
|
|
1849
|
-
return_code: z11.number(),
|
|
1850
|
-
content: z11.array(
|
|
1851
|
-
z11.object({
|
|
1852
|
-
type: z11.literal("code_execution_output"),
|
|
1853
|
-
file_id: z11.string()
|
|
1854
|
-
})
|
|
1855
|
-
).optional().default([])
|
|
1856
|
-
}),
|
|
1857
1854
|
z11.object({
|
|
1858
1855
|
type: z11.literal("bash_code_execution_result"),
|
|
1859
1856
|
content: z11.array(
|
|
@@ -1897,9 +1894,10 @@ var codeExecution_20260120OutputSchema = lazySchema10(
|
|
|
1897
1894
|
])
|
|
1898
1895
|
)
|
|
1899
1896
|
);
|
|
1900
|
-
var
|
|
1897
|
+
var codeExecution_20250825InputSchema = lazySchema10(
|
|
1901
1898
|
() => zodSchema10(
|
|
1902
1899
|
z11.discriminatedUnion("type", [
|
|
1900
|
+
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1903
1901
|
z11.object({
|
|
1904
1902
|
type: z11.literal("programmatic-tool-call"),
|
|
1905
1903
|
code: z11.string()
|
|
@@ -1932,35 +1930,159 @@ var codeExecution_20260120InputSchema = lazySchema10(
|
|
|
1932
1930
|
)
|
|
1933
1931
|
);
|
|
1934
1932
|
var factory8 = createProviderToolFactoryWithOutputSchema7({
|
|
1935
|
-
id: "anthropic.
|
|
1936
|
-
inputSchema:
|
|
1937
|
-
outputSchema:
|
|
1933
|
+
id: "anthropic.code_execution_20250825",
|
|
1934
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
1935
|
+
outputSchema: codeExecution_20250825OutputSchema,
|
|
1936
|
+
// Programmatic tool calling: tool results may be deferred to a later turn
|
|
1937
|
+
// when code execution triggers a client-executed tool that needs to be
|
|
1938
|
+
// resolved before the code execution result can be returned.
|
|
1938
1939
|
supportsDeferredResults: true
|
|
1939
1940
|
});
|
|
1940
|
-
var
|
|
1941
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
1941
1942
|
return factory8(args);
|
|
1942
1943
|
};
|
|
1943
1944
|
|
|
1944
|
-
// src/tool/
|
|
1945
|
+
// src/tool/code-execution_20260120.ts
|
|
1945
1946
|
import {
|
|
1946
1947
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
|
|
1947
1948
|
lazySchema as lazySchema11,
|
|
1948
1949
|
zodSchema as zodSchema11
|
|
1949
1950
|
} from "@ai-sdk/provider-utils";
|
|
1950
1951
|
import { z as z12 } from "zod/v4";
|
|
1951
|
-
var
|
|
1952
|
+
var codeExecution_20260120OutputSchema = lazySchema11(
|
|
1953
|
+
() => zodSchema11(
|
|
1954
|
+
z12.discriminatedUnion("type", [
|
|
1955
|
+
z12.object({
|
|
1956
|
+
type: z12.literal("code_execution_result"),
|
|
1957
|
+
stdout: z12.string(),
|
|
1958
|
+
stderr: z12.string(),
|
|
1959
|
+
return_code: z12.number(),
|
|
1960
|
+
content: z12.array(
|
|
1961
|
+
z12.object({
|
|
1962
|
+
type: z12.literal("code_execution_output"),
|
|
1963
|
+
file_id: z12.string()
|
|
1964
|
+
})
|
|
1965
|
+
).optional().default([])
|
|
1966
|
+
}),
|
|
1967
|
+
z12.object({
|
|
1968
|
+
type: z12.literal("encrypted_code_execution_result"),
|
|
1969
|
+
encrypted_stdout: z12.string(),
|
|
1970
|
+
stderr: z12.string(),
|
|
1971
|
+
return_code: z12.number(),
|
|
1972
|
+
content: z12.array(
|
|
1973
|
+
z12.object({
|
|
1974
|
+
type: z12.literal("code_execution_output"),
|
|
1975
|
+
file_id: z12.string()
|
|
1976
|
+
})
|
|
1977
|
+
).optional().default([])
|
|
1978
|
+
}),
|
|
1979
|
+
z12.object({
|
|
1980
|
+
type: z12.literal("bash_code_execution_result"),
|
|
1981
|
+
content: z12.array(
|
|
1982
|
+
z12.object({
|
|
1983
|
+
type: z12.literal("bash_code_execution_output"),
|
|
1984
|
+
file_id: z12.string()
|
|
1985
|
+
})
|
|
1986
|
+
),
|
|
1987
|
+
stdout: z12.string(),
|
|
1988
|
+
stderr: z12.string(),
|
|
1989
|
+
return_code: z12.number()
|
|
1990
|
+
}),
|
|
1991
|
+
z12.object({
|
|
1992
|
+
type: z12.literal("bash_code_execution_tool_result_error"),
|
|
1993
|
+
error_code: z12.string()
|
|
1994
|
+
}),
|
|
1995
|
+
z12.object({
|
|
1996
|
+
type: z12.literal("text_editor_code_execution_tool_result_error"),
|
|
1997
|
+
error_code: z12.string()
|
|
1998
|
+
}),
|
|
1999
|
+
z12.object({
|
|
2000
|
+
type: z12.literal("text_editor_code_execution_view_result"),
|
|
2001
|
+
content: z12.string(),
|
|
2002
|
+
file_type: z12.string(),
|
|
2003
|
+
num_lines: z12.number().nullable(),
|
|
2004
|
+
start_line: z12.number().nullable(),
|
|
2005
|
+
total_lines: z12.number().nullable()
|
|
2006
|
+
}),
|
|
2007
|
+
z12.object({
|
|
2008
|
+
type: z12.literal("text_editor_code_execution_create_result"),
|
|
2009
|
+
is_file_update: z12.boolean()
|
|
2010
|
+
}),
|
|
2011
|
+
z12.object({
|
|
2012
|
+
type: z12.literal("text_editor_code_execution_str_replace_result"),
|
|
2013
|
+
lines: z12.array(z12.string()).nullable(),
|
|
2014
|
+
new_lines: z12.number().nullable(),
|
|
2015
|
+
new_start: z12.number().nullable(),
|
|
2016
|
+
old_lines: z12.number().nullable(),
|
|
2017
|
+
old_start: z12.number().nullable()
|
|
2018
|
+
})
|
|
2019
|
+
])
|
|
2020
|
+
)
|
|
2021
|
+
);
|
|
2022
|
+
var codeExecution_20260120InputSchema = lazySchema11(
|
|
1952
2023
|
() => zodSchema11(
|
|
1953
|
-
z12.
|
|
2024
|
+
z12.discriminatedUnion("type", [
|
|
1954
2025
|
z12.object({
|
|
1955
|
-
type: z12.literal("
|
|
1956
|
-
|
|
2026
|
+
type: z12.literal("programmatic-tool-call"),
|
|
2027
|
+
code: z12.string()
|
|
2028
|
+
}),
|
|
2029
|
+
z12.object({
|
|
2030
|
+
type: z12.literal("bash_code_execution"),
|
|
2031
|
+
command: z12.string()
|
|
2032
|
+
}),
|
|
2033
|
+
z12.discriminatedUnion("command", [
|
|
2034
|
+
z12.object({
|
|
2035
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2036
|
+
command: z12.literal("view"),
|
|
2037
|
+
path: z12.string()
|
|
2038
|
+
}),
|
|
2039
|
+
z12.object({
|
|
2040
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2041
|
+
command: z12.literal("create"),
|
|
2042
|
+
path: z12.string(),
|
|
2043
|
+
file_text: z12.string().nullish()
|
|
2044
|
+
}),
|
|
2045
|
+
z12.object({
|
|
2046
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2047
|
+
command: z12.literal("str_replace"),
|
|
2048
|
+
path: z12.string(),
|
|
2049
|
+
old_str: z12.string(),
|
|
2050
|
+
new_str: z12.string()
|
|
2051
|
+
})
|
|
2052
|
+
])
|
|
2053
|
+
])
|
|
2054
|
+
)
|
|
2055
|
+
);
|
|
2056
|
+
var factory9 = createProviderToolFactoryWithOutputSchema8({
|
|
2057
|
+
id: "anthropic.code_execution_20260120",
|
|
2058
|
+
inputSchema: codeExecution_20260120InputSchema,
|
|
2059
|
+
outputSchema: codeExecution_20260120OutputSchema,
|
|
2060
|
+
supportsDeferredResults: true
|
|
2061
|
+
});
|
|
2062
|
+
var codeExecution_20260120 = (args = {}) => {
|
|
2063
|
+
return factory9(args);
|
|
2064
|
+
};
|
|
2065
|
+
|
|
2066
|
+
// src/tool/tool-search-regex_20251119.ts
|
|
2067
|
+
import {
|
|
2068
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
|
|
2069
|
+
lazySchema as lazySchema12,
|
|
2070
|
+
zodSchema as zodSchema12
|
|
2071
|
+
} from "@ai-sdk/provider-utils";
|
|
2072
|
+
import { z as z13 } from "zod/v4";
|
|
2073
|
+
var toolSearchRegex_20251119OutputSchema = lazySchema12(
|
|
2074
|
+
() => zodSchema12(
|
|
2075
|
+
z13.array(
|
|
2076
|
+
z13.object({
|
|
2077
|
+
type: z13.literal("tool_reference"),
|
|
2078
|
+
toolName: z13.string()
|
|
1957
2079
|
})
|
|
1958
2080
|
)
|
|
1959
2081
|
)
|
|
1960
2082
|
);
|
|
1961
|
-
var toolSearchRegex_20251119InputSchema =
|
|
1962
|
-
() =>
|
|
1963
|
-
|
|
2083
|
+
var toolSearchRegex_20251119InputSchema = lazySchema12(
|
|
2084
|
+
() => zodSchema12(
|
|
2085
|
+
z13.object({
|
|
1964
2086
|
/**
|
|
1965
2087
|
* A regex pattern to search for tools.
|
|
1966
2088
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1971,22 +2093,22 @@ var toolSearchRegex_20251119InputSchema = lazySchema11(
|
|
|
1971
2093
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1972
2094
|
* - "(?i)slack" - case-insensitive search
|
|
1973
2095
|
*/
|
|
1974
|
-
pattern:
|
|
2096
|
+
pattern: z13.string(),
|
|
1975
2097
|
/**
|
|
1976
2098
|
* Maximum number of tools to return. Optional.
|
|
1977
2099
|
*/
|
|
1978
|
-
limit:
|
|
2100
|
+
limit: z13.number().optional()
|
|
1979
2101
|
})
|
|
1980
2102
|
)
|
|
1981
2103
|
);
|
|
1982
|
-
var
|
|
2104
|
+
var factory10 = createProviderToolFactoryWithOutputSchema9({
|
|
1983
2105
|
id: "anthropic.tool_search_regex_20251119",
|
|
1984
2106
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
1985
2107
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
1986
2108
|
supportsDeferredResults: true
|
|
1987
2109
|
});
|
|
1988
2110
|
var toolSearchRegex_20251119 = (args = {}) => {
|
|
1989
|
-
return
|
|
2111
|
+
return factory10(args);
|
|
1990
2112
|
};
|
|
1991
2113
|
|
|
1992
2114
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
@@ -2065,14 +2187,17 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2065
2187
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2066
2188
|
});
|
|
2067
2189
|
}
|
|
2068
|
-
system = block.messages.map(({ content, providerOptions }) =>
|
|
2069
|
-
|
|
2070
|
-
text: content,
|
|
2071
|
-
cache_control: validator.getCacheControl(providerOptions, {
|
|
2190
|
+
system = block.messages.map(({ content, providerOptions }) => {
|
|
2191
|
+
const cc = validator.getCacheControl(providerOptions, {
|
|
2072
2192
|
type: "system message",
|
|
2073
2193
|
canCache: true
|
|
2074
|
-
})
|
|
2075
|
-
|
|
2194
|
+
});
|
|
2195
|
+
return {
|
|
2196
|
+
type: "text",
|
|
2197
|
+
text: content,
|
|
2198
|
+
cache_control: cc
|
|
2199
|
+
};
|
|
2200
|
+
});
|
|
2076
2201
|
break;
|
|
2077
2202
|
}
|
|
2078
2203
|
case "user": {
|
|
@@ -2649,7 +2774,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2649
2774
|
} catch (e) {
|
|
2650
2775
|
const extractedErrorCode = (_s = output.value) == null ? void 0 : _s.errorCode;
|
|
2651
2776
|
errorValue = {
|
|
2652
|
-
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "
|
|
2777
|
+
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
|
|
2653
2778
|
};
|
|
2654
2779
|
}
|
|
2655
2780
|
anthropicContent.push({
|
|
@@ -2657,7 +2782,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2657
2782
|
tool_use_id: part.toolCallId,
|
|
2658
2783
|
content: {
|
|
2659
2784
|
type: "web_fetch_tool_result_error",
|
|
2660
|
-
error_code: (_t = errorValue.errorCode) != null ? _t : "
|
|
2785
|
+
error_code: (_t = errorValue.errorCode) != null ? _t : "unavailable"
|
|
2661
2786
|
},
|
|
2662
2787
|
cache_control: cacheControl
|
|
2663
2788
|
});
|
|
@@ -2725,6 +2850,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2725
2850
|
}
|
|
2726
2851
|
if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
2727
2852
|
const output = part.output;
|
|
2853
|
+
if (output.type === "error-text" || output.type === "error-json") {
|
|
2854
|
+
anthropicContent.push({
|
|
2855
|
+
type: "tool_search_tool_result",
|
|
2856
|
+
tool_use_id: part.toolCallId,
|
|
2857
|
+
content: {
|
|
2858
|
+
type: "tool_search_tool_result_error",
|
|
2859
|
+
error_code: "unavailable"
|
|
2860
|
+
},
|
|
2861
|
+
cache_control: cacheControl
|
|
2862
|
+
});
|
|
2863
|
+
break;
|
|
2864
|
+
}
|
|
2728
2865
|
if (output.type !== "json") {
|
|
2729
2866
|
warnings.push({
|
|
2730
2867
|
type: "other",
|
|
@@ -2846,6 +2983,61 @@ function mapAnthropicStopReason({
|
|
|
2846
2983
|
}
|
|
2847
2984
|
|
|
2848
2985
|
// src/anthropic-messages-language-model.ts
|
|
2986
|
+
function isCustomReasoning(reasoning) {
|
|
2987
|
+
return reasoning !== void 0 && reasoning !== "provider-default";
|
|
2988
|
+
}
|
|
2989
|
+
function mapReasoningToProviderEffort({
|
|
2990
|
+
reasoning,
|
|
2991
|
+
effortMap,
|
|
2992
|
+
warnings
|
|
2993
|
+
}) {
|
|
2994
|
+
const mapped = effortMap[reasoning];
|
|
2995
|
+
if (mapped == null) {
|
|
2996
|
+
warnings.push({
|
|
2997
|
+
type: "unsupported",
|
|
2998
|
+
feature: "reasoning",
|
|
2999
|
+
details: `reasoning "${reasoning}" is not supported by this model.`
|
|
3000
|
+
});
|
|
3001
|
+
return void 0;
|
|
3002
|
+
}
|
|
3003
|
+
if (mapped !== reasoning) {
|
|
3004
|
+
warnings.push({
|
|
3005
|
+
type: "compatibility",
|
|
3006
|
+
feature: "reasoning",
|
|
3007
|
+
details: `reasoning "${reasoning}" is not directly supported by this model. mapped to effort "${mapped}".`
|
|
3008
|
+
});
|
|
3009
|
+
}
|
|
3010
|
+
return mapped;
|
|
3011
|
+
}
|
|
3012
|
+
var DEFAULT_REASONING_BUDGET_PERCENTAGES = {
|
|
3013
|
+
minimal: 0.02,
|
|
3014
|
+
low: 0.1,
|
|
3015
|
+
medium: 0.3,
|
|
3016
|
+
high: 0.6,
|
|
3017
|
+
xhigh: 0.9
|
|
3018
|
+
};
|
|
3019
|
+
function mapReasoningToProviderBudget({
|
|
3020
|
+
reasoning,
|
|
3021
|
+
maxOutputTokens,
|
|
3022
|
+
maxReasoningBudget,
|
|
3023
|
+
minReasoningBudget = 1024,
|
|
3024
|
+
budgetPercentages = DEFAULT_REASONING_BUDGET_PERCENTAGES,
|
|
3025
|
+
warnings
|
|
3026
|
+
}) {
|
|
3027
|
+
const pct = budgetPercentages[reasoning];
|
|
3028
|
+
if (pct == null) {
|
|
3029
|
+
warnings.push({
|
|
3030
|
+
type: "unsupported",
|
|
3031
|
+
feature: "reasoning",
|
|
3032
|
+
details: `reasoning "${reasoning}" is not supported by this model.`
|
|
3033
|
+
});
|
|
3034
|
+
return void 0;
|
|
3035
|
+
}
|
|
3036
|
+
return Math.min(
|
|
3037
|
+
maxReasoningBudget,
|
|
3038
|
+
Math.max(minReasoningBudget, Math.round(maxOutputTokens * pct))
|
|
3039
|
+
);
|
|
3040
|
+
}
|
|
2849
3041
|
function createCitationSource(citation, citationDocuments, generateId2) {
|
|
2850
3042
|
var _a;
|
|
2851
3043
|
if (citation.type === "web_search_result_location") {
|
|
@@ -2892,7 +3084,7 @@ function createCitationSource(citation, citationDocuments, generateId2) {
|
|
|
2892
3084
|
}
|
|
2893
3085
|
var AnthropicMessagesLanguageModel = class {
|
|
2894
3086
|
constructor(modelId, config) {
|
|
2895
|
-
this.specificationVersion = "
|
|
3087
|
+
this.specificationVersion = "v4";
|
|
2896
3088
|
var _a;
|
|
2897
3089
|
this.modelId = modelId;
|
|
2898
3090
|
this.config = config;
|
|
@@ -2931,10 +3123,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2931
3123
|
seed,
|
|
2932
3124
|
tools,
|
|
2933
3125
|
toolChoice,
|
|
3126
|
+
reasoning,
|
|
2934
3127
|
providerOptions,
|
|
2935
3128
|
stream
|
|
2936
3129
|
}) {
|
|
2937
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3130
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2938
3131
|
const warnings = [];
|
|
2939
3132
|
if (frequencyPenalty != null) {
|
|
2940
3133
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2989,10 +3182,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2989
3182
|
const {
|
|
2990
3183
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2991
3184
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3185
|
+
supportsAdaptiveThinking,
|
|
2992
3186
|
isKnownModel
|
|
2993
3187
|
} = getModelCapabilities(this.modelId);
|
|
2994
3188
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2995
|
-
const
|
|
3189
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
3190
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2996
3191
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2997
3192
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2998
3193
|
type: "function",
|
|
@@ -3020,6 +3215,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3020
3215
|
"anthropic.web_search_20250305": "web_search",
|
|
3021
3216
|
"anthropic.web_search_20260209": "web_search",
|
|
3022
3217
|
"anthropic.web_fetch_20250910": "web_fetch",
|
|
3218
|
+
"anthropic.web_fetch_20260309": "web_fetch",
|
|
3023
3219
|
"anthropic.web_fetch_20260209": "web_fetch",
|
|
3024
3220
|
"anthropic.tool_search_regex_20251119": "tool_search_tool_regex",
|
|
3025
3221
|
"anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
|
|
@@ -3027,11 +3223,25 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3027
3223
|
});
|
|
3028
3224
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
3029
3225
|
prompt,
|
|
3030
|
-
sendReasoning: (
|
|
3226
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
3031
3227
|
warnings,
|
|
3032
3228
|
cacheControlValidator,
|
|
3033
3229
|
toolNameMapping
|
|
3034
3230
|
});
|
|
3231
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3232
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3233
|
+
reasoning,
|
|
3234
|
+
supportsAdaptiveThinking,
|
|
3235
|
+
maxOutputTokensForModel,
|
|
3236
|
+
warnings
|
|
3237
|
+
});
|
|
3238
|
+
if (reasoningConfig != null) {
|
|
3239
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3240
|
+
if (reasoningConfig.effort != null) {
|
|
3241
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3035
3245
|
if (anthropicOptions == null ? void 0 : anthropicOptions.prefill) {
|
|
3036
3246
|
const lastMessage = messagesPrompt.messages[messagesPrompt.messages.length - 1];
|
|
3037
3247
|
if ((lastMessage == null ? void 0 : lastMessage.role) === "assistant") {
|
|
@@ -3053,9 +3263,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3053
3263
|
});
|
|
3054
3264
|
}
|
|
3055
3265
|
}
|
|
3056
|
-
const thinkingType = (
|
|
3266
|
+
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
3057
3267
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
3058
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3268
|
+
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
|
|
3059
3269
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
3060
3270
|
const baseArgs = {
|
|
3061
3271
|
// model id:
|
|
@@ -3071,7 +3281,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3071
3281
|
thinking: {
|
|
3072
3282
|
type: thinkingType,
|
|
3073
3283
|
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3074
|
-
...((
|
|
3284
|
+
...((_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) && {
|
|
3075
3285
|
display: anthropicOptions.thinking.display
|
|
3076
3286
|
}
|
|
3077
3287
|
}
|
|
@@ -3092,9 +3302,22 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3092
3302
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3093
3303
|
speed: anthropicOptions.speed
|
|
3094
3304
|
},
|
|
3305
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.metadata) && {
|
|
3306
|
+
metadata: {
|
|
3307
|
+
...anthropicOptions.metadata.userId && {
|
|
3308
|
+
user_id: anthropicOptions.metadata.userId
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
},
|
|
3312
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.serviceTier) && {
|
|
3313
|
+
service_tier: anthropicOptions.serviceTier
|
|
3314
|
+
},
|
|
3095
3315
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3096
3316
|
cache_control: anthropicOptions.cacheControl
|
|
3097
3317
|
},
|
|
3318
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3319
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3320
|
+
},
|
|
3098
3321
|
// mcp servers:
|
|
3099
3322
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3100
3323
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3247,7 +3470,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3247
3470
|
}
|
|
3248
3471
|
}
|
|
3249
3472
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.container) && anthropicOptions.container.skills && anthropicOptions.container.skills.length > 0) {
|
|
3250
|
-
betas.add("code-execution-2025-08-25");
|
|
3251
3473
|
betas.add("skills-2025-10-02");
|
|
3252
3474
|
betas.add("files-api-2025-04-14");
|
|
3253
3475
|
if (!(tools == null ? void 0 : tools.some(
|
|
@@ -3265,7 +3487,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3265
3487
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3266
3488
|
betas.add("fast-mode-2026-02-01");
|
|
3267
3489
|
}
|
|
3268
|
-
if (stream && ((
|
|
3490
|
+
if (stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true)) {
|
|
3269
3491
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3270
3492
|
}
|
|
3271
3493
|
const {
|
|
@@ -3279,13 +3501,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3279
3501
|
toolChoice: { type: "required" },
|
|
3280
3502
|
disableParallelToolUse: true,
|
|
3281
3503
|
cacheControlValidator,
|
|
3282
|
-
supportsStructuredOutput: false
|
|
3504
|
+
supportsStructuredOutput: false,
|
|
3505
|
+
supportsStrictTools
|
|
3283
3506
|
} : {
|
|
3284
3507
|
tools: tools != null ? tools : [],
|
|
3285
3508
|
toolChoice,
|
|
3286
3509
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3287
3510
|
cacheControlValidator,
|
|
3288
|
-
supportsStructuredOutput
|
|
3511
|
+
supportsStructuredOutput,
|
|
3512
|
+
supportsStrictTools
|
|
3289
3513
|
}
|
|
3290
3514
|
);
|
|
3291
3515
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3302,7 +3526,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3302
3526
|
...betas,
|
|
3303
3527
|
...toolsBetas,
|
|
3304
3528
|
...userSuppliedBetas,
|
|
3305
|
-
...(
|
|
3529
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3306
3530
|
]),
|
|
3307
3531
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3308
3532
|
toolNameMapping,
|
|
@@ -3639,6 +3863,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3639
3863
|
}
|
|
3640
3864
|
// code execution 20250522:
|
|
3641
3865
|
case "code_execution_tool_result": {
|
|
3866
|
+
if (markCodeExecutionDynamic) {
|
|
3867
|
+
content.push({
|
|
3868
|
+
type: "tool-result",
|
|
3869
|
+
toolCallId: part.tool_use_id,
|
|
3870
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
3871
|
+
isError: true,
|
|
3872
|
+
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."
|
|
3873
|
+
});
|
|
3874
|
+
break;
|
|
3875
|
+
}
|
|
3642
3876
|
if (part.content.type === "code_execution_result") {
|
|
3643
3877
|
content.push({
|
|
3644
3878
|
type: "tool-result",
|
|
@@ -3682,6 +3916,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3682
3916
|
// code execution 20250825:
|
|
3683
3917
|
case "bash_code_execution_tool_result":
|
|
3684
3918
|
case "text_editor_code_execution_tool_result": {
|
|
3919
|
+
if (markCodeExecutionDynamic) {
|
|
3920
|
+
content.push({
|
|
3921
|
+
type: "tool-result",
|
|
3922
|
+
toolCallId: part.tool_use_id,
|
|
3923
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
3924
|
+
isError: true,
|
|
3925
|
+
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."
|
|
3926
|
+
});
|
|
3927
|
+
break;
|
|
3928
|
+
}
|
|
3685
3929
|
content.push({
|
|
3686
3930
|
type: "tool-result",
|
|
3687
3931
|
toolCallId: part.tool_use_id,
|
|
@@ -4084,6 +4328,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4084
4328
|
}
|
|
4085
4329
|
// code execution 20250522:
|
|
4086
4330
|
case "code_execution_tool_result": {
|
|
4331
|
+
if (markCodeExecutionDynamic) {
|
|
4332
|
+
controller.enqueue({
|
|
4333
|
+
type: "tool-result",
|
|
4334
|
+
toolCallId: part.tool_use_id,
|
|
4335
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
4336
|
+
isError: true,
|
|
4337
|
+
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."
|
|
4338
|
+
});
|
|
4339
|
+
return;
|
|
4340
|
+
}
|
|
4087
4341
|
if (part.content.type === "code_execution_result") {
|
|
4088
4342
|
controller.enqueue({
|
|
4089
4343
|
type: "tool-result",
|
|
@@ -4127,6 +4381,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4127
4381
|
// code execution 20250825:
|
|
4128
4382
|
case "bash_code_execution_tool_result":
|
|
4129
4383
|
case "text_editor_code_execution_tool_result": {
|
|
4384
|
+
if (markCodeExecutionDynamic) {
|
|
4385
|
+
controller.enqueue({
|
|
4386
|
+
type: "tool-result",
|
|
4387
|
+
toolCallId: part.tool_use_id,
|
|
4388
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
4389
|
+
isError: true,
|
|
4390
|
+
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."
|
|
4391
|
+
});
|
|
4392
|
+
return;
|
|
4393
|
+
}
|
|
4130
4394
|
controller.enqueue({
|
|
4131
4395
|
type: "tool-result",
|
|
4132
4396
|
toolCallId: part.tool_use_id,
|
|
@@ -4565,42 +4829,49 @@ function getModelCapabilities(modelId) {
|
|
|
4565
4829
|
return {
|
|
4566
4830
|
maxOutputTokens: 128e3,
|
|
4567
4831
|
supportsStructuredOutput: true,
|
|
4832
|
+
supportsAdaptiveThinking: true,
|
|
4568
4833
|
isKnownModel: true
|
|
4569
4834
|
};
|
|
4570
4835
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4571
4836
|
return {
|
|
4572
4837
|
maxOutputTokens: 64e3,
|
|
4573
4838
|
supportsStructuredOutput: true,
|
|
4839
|
+
supportsAdaptiveThinking: false,
|
|
4574
4840
|
isKnownModel: true
|
|
4575
4841
|
};
|
|
4576
4842
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4577
4843
|
return {
|
|
4578
4844
|
maxOutputTokens: 32e3,
|
|
4579
4845
|
supportsStructuredOutput: true,
|
|
4846
|
+
supportsAdaptiveThinking: false,
|
|
4580
4847
|
isKnownModel: true
|
|
4581
4848
|
};
|
|
4582
4849
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4583
4850
|
return {
|
|
4584
4851
|
maxOutputTokens: 64e3,
|
|
4585
4852
|
supportsStructuredOutput: false,
|
|
4853
|
+
supportsAdaptiveThinking: false,
|
|
4586
4854
|
isKnownModel: true
|
|
4587
4855
|
};
|
|
4588
4856
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4589
4857
|
return {
|
|
4590
4858
|
maxOutputTokens: 32e3,
|
|
4591
4859
|
supportsStructuredOutput: false,
|
|
4860
|
+
supportsAdaptiveThinking: false,
|
|
4592
4861
|
isKnownModel: true
|
|
4593
4862
|
};
|
|
4594
4863
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4595
4864
|
return {
|
|
4596
4865
|
maxOutputTokens: 4096,
|
|
4597
4866
|
supportsStructuredOutput: false,
|
|
4867
|
+
supportsAdaptiveThinking: false,
|
|
4598
4868
|
isKnownModel: true
|
|
4599
4869
|
};
|
|
4600
4870
|
} else {
|
|
4601
4871
|
return {
|
|
4602
4872
|
maxOutputTokens: 4096,
|
|
4603
4873
|
supportsStructuredOutput: false,
|
|
4874
|
+
supportsAdaptiveThinking: false,
|
|
4604
4875
|
isKnownModel: false
|
|
4605
4876
|
};
|
|
4606
4877
|
}
|
|
@@ -4623,6 +4894,43 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4623
4894
|
}
|
|
4624
4895
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4625
4896
|
}
|
|
4897
|
+
function resolveAnthropicReasoningConfig({
|
|
4898
|
+
reasoning,
|
|
4899
|
+
supportsAdaptiveThinking,
|
|
4900
|
+
maxOutputTokensForModel,
|
|
4901
|
+
warnings
|
|
4902
|
+
}) {
|
|
4903
|
+
if (!isCustomReasoning(reasoning)) {
|
|
4904
|
+
return void 0;
|
|
4905
|
+
}
|
|
4906
|
+
if (reasoning === "none") {
|
|
4907
|
+
return { thinking: { type: "disabled" } };
|
|
4908
|
+
}
|
|
4909
|
+
if (supportsAdaptiveThinking) {
|
|
4910
|
+
const effort = mapReasoningToProviderEffort({
|
|
4911
|
+
reasoning,
|
|
4912
|
+
effortMap: {
|
|
4913
|
+
minimal: "low",
|
|
4914
|
+
low: "low",
|
|
4915
|
+
medium: "medium",
|
|
4916
|
+
high: "high",
|
|
4917
|
+
xhigh: "max"
|
|
4918
|
+
},
|
|
4919
|
+
warnings
|
|
4920
|
+
});
|
|
4921
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
4922
|
+
}
|
|
4923
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
4924
|
+
reasoning,
|
|
4925
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
4926
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
4927
|
+
warnings
|
|
4928
|
+
});
|
|
4929
|
+
if (budgetTokens == null) {
|
|
4930
|
+
return void 0;
|
|
4931
|
+
}
|
|
4932
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
4933
|
+
}
|
|
4626
4934
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4627
4935
|
return contextManagement ? {
|
|
4628
4936
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -4652,15 +4960,15 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4652
4960
|
// src/tool/bash_20241022.ts
|
|
4653
4961
|
import {
|
|
4654
4962
|
createProviderToolFactory as createProviderToolFactory2,
|
|
4655
|
-
lazySchema as
|
|
4656
|
-
zodSchema as
|
|
4963
|
+
lazySchema as lazySchema13,
|
|
4964
|
+
zodSchema as zodSchema13
|
|
4657
4965
|
} from "@ai-sdk/provider-utils";
|
|
4658
|
-
import { z as
|
|
4659
|
-
var bash_20241022InputSchema =
|
|
4660
|
-
() =>
|
|
4661
|
-
|
|
4662
|
-
command:
|
|
4663
|
-
restart:
|
|
4966
|
+
import { z as z14 } from "zod/v4";
|
|
4967
|
+
var bash_20241022InputSchema = lazySchema13(
|
|
4968
|
+
() => zodSchema13(
|
|
4969
|
+
z14.object({
|
|
4970
|
+
command: z14.string(),
|
|
4971
|
+
restart: z14.boolean().optional()
|
|
4664
4972
|
})
|
|
4665
4973
|
)
|
|
4666
4974
|
);
|
|
@@ -4672,15 +4980,15 @@ var bash_20241022 = createProviderToolFactory2({
|
|
|
4672
4980
|
// src/tool/bash_20250124.ts
|
|
4673
4981
|
import {
|
|
4674
4982
|
createProviderToolFactory as createProviderToolFactory3,
|
|
4675
|
-
lazySchema as
|
|
4676
|
-
zodSchema as
|
|
4983
|
+
lazySchema as lazySchema14,
|
|
4984
|
+
zodSchema as zodSchema14
|
|
4677
4985
|
} from "@ai-sdk/provider-utils";
|
|
4678
|
-
import { z as
|
|
4679
|
-
var bash_20250124InputSchema =
|
|
4680
|
-
() =>
|
|
4681
|
-
|
|
4682
|
-
command:
|
|
4683
|
-
restart:
|
|
4986
|
+
import { z as z15 } from "zod/v4";
|
|
4987
|
+
var bash_20250124InputSchema = lazySchema14(
|
|
4988
|
+
() => zodSchema14(
|
|
4989
|
+
z15.object({
|
|
4990
|
+
command: z15.string(),
|
|
4991
|
+
restart: z15.boolean().optional()
|
|
4684
4992
|
})
|
|
4685
4993
|
)
|
|
4686
4994
|
);
|
|
@@ -4692,14 +5000,14 @@ var bash_20250124 = createProviderToolFactory3({
|
|
|
4692
5000
|
// src/tool/computer_20241022.ts
|
|
4693
5001
|
import {
|
|
4694
5002
|
createProviderToolFactory as createProviderToolFactory4,
|
|
4695
|
-
lazySchema as
|
|
4696
|
-
zodSchema as
|
|
5003
|
+
lazySchema as lazySchema15,
|
|
5004
|
+
zodSchema as zodSchema15
|
|
4697
5005
|
} from "@ai-sdk/provider-utils";
|
|
4698
|
-
import { z as
|
|
4699
|
-
var computer_20241022InputSchema =
|
|
4700
|
-
() =>
|
|
4701
|
-
|
|
4702
|
-
action:
|
|
5006
|
+
import { z as z16 } from "zod/v4";
|
|
5007
|
+
var computer_20241022InputSchema = lazySchema15(
|
|
5008
|
+
() => zodSchema15(
|
|
5009
|
+
z16.object({
|
|
5010
|
+
action: z16.enum([
|
|
4703
5011
|
"key",
|
|
4704
5012
|
"type",
|
|
4705
5013
|
"mouse_move",
|
|
@@ -4711,8 +5019,8 @@ var computer_20241022InputSchema = lazySchema14(
|
|
|
4711
5019
|
"screenshot",
|
|
4712
5020
|
"cursor_position"
|
|
4713
5021
|
]),
|
|
4714
|
-
coordinate:
|
|
4715
|
-
text:
|
|
5022
|
+
coordinate: z16.array(z16.number().int()).optional(),
|
|
5023
|
+
text: z16.string().optional()
|
|
4716
5024
|
})
|
|
4717
5025
|
)
|
|
4718
5026
|
);
|
|
@@ -4724,14 +5032,14 @@ var computer_20241022 = createProviderToolFactory4({
|
|
|
4724
5032
|
// src/tool/computer_20250124.ts
|
|
4725
5033
|
import {
|
|
4726
5034
|
createProviderToolFactory as createProviderToolFactory5,
|
|
4727
|
-
lazySchema as
|
|
4728
|
-
zodSchema as
|
|
5035
|
+
lazySchema as lazySchema16,
|
|
5036
|
+
zodSchema as zodSchema16
|
|
4729
5037
|
} from "@ai-sdk/provider-utils";
|
|
4730
|
-
import { z as
|
|
4731
|
-
var computer_20250124InputSchema =
|
|
4732
|
-
() =>
|
|
4733
|
-
|
|
4734
|
-
action:
|
|
5038
|
+
import { z as z17 } from "zod/v4";
|
|
5039
|
+
var computer_20250124InputSchema = lazySchema16(
|
|
5040
|
+
() => zodSchema16(
|
|
5041
|
+
z17.object({
|
|
5042
|
+
action: z17.enum([
|
|
4735
5043
|
"key",
|
|
4736
5044
|
"hold_key",
|
|
4737
5045
|
"type",
|
|
@@ -4749,12 +5057,12 @@ var computer_20250124InputSchema = lazySchema15(
|
|
|
4749
5057
|
"wait",
|
|
4750
5058
|
"screenshot"
|
|
4751
5059
|
]),
|
|
4752
|
-
coordinate:
|
|
4753
|
-
duration:
|
|
4754
|
-
scroll_amount:
|
|
4755
|
-
scroll_direction:
|
|
4756
|
-
start_coordinate:
|
|
4757
|
-
text:
|
|
5060
|
+
coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5061
|
+
duration: z17.number().optional(),
|
|
5062
|
+
scroll_amount: z17.number().optional(),
|
|
5063
|
+
scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
|
|
5064
|
+
start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5065
|
+
text: z17.string().optional()
|
|
4758
5066
|
})
|
|
4759
5067
|
)
|
|
4760
5068
|
);
|
|
@@ -4766,14 +5074,14 @@ var computer_20250124 = createProviderToolFactory5({
|
|
|
4766
5074
|
// src/tool/computer_20251124.ts
|
|
4767
5075
|
import {
|
|
4768
5076
|
createProviderToolFactory as createProviderToolFactory6,
|
|
4769
|
-
lazySchema as
|
|
4770
|
-
zodSchema as
|
|
5077
|
+
lazySchema as lazySchema17,
|
|
5078
|
+
zodSchema as zodSchema17
|
|
4771
5079
|
} from "@ai-sdk/provider-utils";
|
|
4772
|
-
import { z as
|
|
4773
|
-
var computer_20251124InputSchema =
|
|
4774
|
-
() =>
|
|
4775
|
-
|
|
4776
|
-
action:
|
|
5080
|
+
import { z as z18 } from "zod/v4";
|
|
5081
|
+
var computer_20251124InputSchema = lazySchema17(
|
|
5082
|
+
() => zodSchema17(
|
|
5083
|
+
z18.object({
|
|
5084
|
+
action: z18.enum([
|
|
4777
5085
|
"key",
|
|
4778
5086
|
"hold_key",
|
|
4779
5087
|
"type",
|
|
@@ -4792,18 +5100,18 @@ var computer_20251124InputSchema = lazySchema16(
|
|
|
4792
5100
|
"screenshot",
|
|
4793
5101
|
"zoom"
|
|
4794
5102
|
]),
|
|
4795
|
-
coordinate:
|
|
4796
|
-
duration:
|
|
4797
|
-
region:
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
5103
|
+
coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5104
|
+
duration: z18.number().optional(),
|
|
5105
|
+
region: z18.tuple([
|
|
5106
|
+
z18.number().int(),
|
|
5107
|
+
z18.number().int(),
|
|
5108
|
+
z18.number().int(),
|
|
5109
|
+
z18.number().int()
|
|
4802
5110
|
]).optional(),
|
|
4803
|
-
scroll_amount:
|
|
4804
|
-
scroll_direction:
|
|
4805
|
-
start_coordinate:
|
|
4806
|
-
text:
|
|
5111
|
+
scroll_amount: z18.number().optional(),
|
|
5112
|
+
scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
|
|
5113
|
+
start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5114
|
+
text: z18.string().optional()
|
|
4807
5115
|
})
|
|
4808
5116
|
)
|
|
4809
5117
|
);
|
|
@@ -4815,43 +5123,43 @@ var computer_20251124 = createProviderToolFactory6({
|
|
|
4815
5123
|
// src/tool/memory_20250818.ts
|
|
4816
5124
|
import {
|
|
4817
5125
|
createProviderToolFactory as createProviderToolFactory7,
|
|
4818
|
-
lazySchema as
|
|
4819
|
-
zodSchema as
|
|
5126
|
+
lazySchema as lazySchema18,
|
|
5127
|
+
zodSchema as zodSchema18
|
|
4820
5128
|
} from "@ai-sdk/provider-utils";
|
|
4821
|
-
import { z as
|
|
4822
|
-
var memory_20250818InputSchema =
|
|
4823
|
-
() =>
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
command:
|
|
4827
|
-
path:
|
|
4828
|
-
view_range:
|
|
5129
|
+
import { z as z19 } from "zod/v4";
|
|
5130
|
+
var memory_20250818InputSchema = lazySchema18(
|
|
5131
|
+
() => zodSchema18(
|
|
5132
|
+
z19.discriminatedUnion("command", [
|
|
5133
|
+
z19.object({
|
|
5134
|
+
command: z19.literal("view"),
|
|
5135
|
+
path: z19.string(),
|
|
5136
|
+
view_range: z19.tuple([z19.number(), z19.number()]).optional()
|
|
4829
5137
|
}),
|
|
4830
|
-
|
|
4831
|
-
command:
|
|
4832
|
-
path:
|
|
4833
|
-
file_text:
|
|
5138
|
+
z19.object({
|
|
5139
|
+
command: z19.literal("create"),
|
|
5140
|
+
path: z19.string(),
|
|
5141
|
+
file_text: z19.string()
|
|
4834
5142
|
}),
|
|
4835
|
-
|
|
4836
|
-
command:
|
|
4837
|
-
path:
|
|
4838
|
-
old_str:
|
|
4839
|
-
new_str:
|
|
5143
|
+
z19.object({
|
|
5144
|
+
command: z19.literal("str_replace"),
|
|
5145
|
+
path: z19.string(),
|
|
5146
|
+
old_str: z19.string(),
|
|
5147
|
+
new_str: z19.string()
|
|
4840
5148
|
}),
|
|
4841
|
-
|
|
4842
|
-
command:
|
|
4843
|
-
path:
|
|
4844
|
-
insert_line:
|
|
4845
|
-
insert_text:
|
|
5149
|
+
z19.object({
|
|
5150
|
+
command: z19.literal("insert"),
|
|
5151
|
+
path: z19.string(),
|
|
5152
|
+
insert_line: z19.number(),
|
|
5153
|
+
insert_text: z19.string()
|
|
4846
5154
|
}),
|
|
4847
|
-
|
|
4848
|
-
command:
|
|
4849
|
-
path:
|
|
5155
|
+
z19.object({
|
|
5156
|
+
command: z19.literal("delete"),
|
|
5157
|
+
path: z19.string()
|
|
4850
5158
|
}),
|
|
4851
|
-
|
|
4852
|
-
command:
|
|
4853
|
-
old_path:
|
|
4854
|
-
new_path:
|
|
5159
|
+
z19.object({
|
|
5160
|
+
command: z19.literal("rename"),
|
|
5161
|
+
old_path: z19.string(),
|
|
5162
|
+
new_path: z19.string()
|
|
4855
5163
|
})
|
|
4856
5164
|
])
|
|
4857
5165
|
)
|
|
@@ -4864,37 +5172,11 @@ var memory_20250818 = createProviderToolFactory7({
|
|
|
4864
5172
|
// src/tool/text-editor_20241022.ts
|
|
4865
5173
|
import {
|
|
4866
5174
|
createProviderToolFactory as createProviderToolFactory8,
|
|
4867
|
-
lazySchema as lazySchema18,
|
|
4868
|
-
zodSchema as zodSchema18
|
|
4869
|
-
} from "@ai-sdk/provider-utils";
|
|
4870
|
-
import { z as z19 } from "zod/v4";
|
|
4871
|
-
var textEditor_20241022InputSchema = lazySchema18(
|
|
4872
|
-
() => zodSchema18(
|
|
4873
|
-
z19.object({
|
|
4874
|
-
command: z19.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
4875
|
-
path: z19.string(),
|
|
4876
|
-
file_text: z19.string().optional(),
|
|
4877
|
-
insert_line: z19.number().int().optional(),
|
|
4878
|
-
new_str: z19.string().optional(),
|
|
4879
|
-
insert_text: z19.string().optional(),
|
|
4880
|
-
old_str: z19.string().optional(),
|
|
4881
|
-
view_range: z19.array(z19.number().int()).optional()
|
|
4882
|
-
})
|
|
4883
|
-
)
|
|
4884
|
-
);
|
|
4885
|
-
var textEditor_20241022 = createProviderToolFactory8({
|
|
4886
|
-
id: "anthropic.text_editor_20241022",
|
|
4887
|
-
inputSchema: textEditor_20241022InputSchema
|
|
4888
|
-
});
|
|
4889
|
-
|
|
4890
|
-
// src/tool/text-editor_20250124.ts
|
|
4891
|
-
import {
|
|
4892
|
-
createProviderToolFactory as createProviderToolFactory9,
|
|
4893
5175
|
lazySchema as lazySchema19,
|
|
4894
5176
|
zodSchema as zodSchema19
|
|
4895
5177
|
} from "@ai-sdk/provider-utils";
|
|
4896
5178
|
import { z as z20 } from "zod/v4";
|
|
4897
|
-
var
|
|
5179
|
+
var textEditor_20241022InputSchema = lazySchema19(
|
|
4898
5180
|
() => zodSchema19(
|
|
4899
5181
|
z20.object({
|
|
4900
5182
|
command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -4908,22 +5190,22 @@ var textEditor_20250124InputSchema = lazySchema19(
|
|
|
4908
5190
|
})
|
|
4909
5191
|
)
|
|
4910
5192
|
);
|
|
4911
|
-
var
|
|
4912
|
-
id: "anthropic.
|
|
4913
|
-
inputSchema:
|
|
5193
|
+
var textEditor_20241022 = createProviderToolFactory8({
|
|
5194
|
+
id: "anthropic.text_editor_20241022",
|
|
5195
|
+
inputSchema: textEditor_20241022InputSchema
|
|
4914
5196
|
});
|
|
4915
5197
|
|
|
4916
|
-
// src/tool/text-
|
|
5198
|
+
// src/tool/text-editor_20250124.ts
|
|
4917
5199
|
import {
|
|
4918
|
-
createProviderToolFactory as
|
|
5200
|
+
createProviderToolFactory as createProviderToolFactory9,
|
|
4919
5201
|
lazySchema as lazySchema20,
|
|
4920
5202
|
zodSchema as zodSchema20
|
|
4921
5203
|
} from "@ai-sdk/provider-utils";
|
|
4922
5204
|
import { z as z21 } from "zod/v4";
|
|
4923
|
-
var
|
|
5205
|
+
var textEditor_20250124InputSchema = lazySchema20(
|
|
4924
5206
|
() => zodSchema20(
|
|
4925
5207
|
z21.object({
|
|
4926
|
-
command: z21.enum(["view", "create", "str_replace", "insert"]),
|
|
5208
|
+
command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
4927
5209
|
path: z21.string(),
|
|
4928
5210
|
file_text: z21.string().optional(),
|
|
4929
5211
|
insert_line: z21.number().int().optional(),
|
|
@@ -4934,51 +5216,77 @@ var textEditor_20250429InputSchema = lazySchema20(
|
|
|
4934
5216
|
})
|
|
4935
5217
|
)
|
|
4936
5218
|
);
|
|
4937
|
-
var
|
|
4938
|
-
id: "anthropic.
|
|
4939
|
-
inputSchema:
|
|
5219
|
+
var textEditor_20250124 = createProviderToolFactory9({
|
|
5220
|
+
id: "anthropic.text_editor_20250124",
|
|
5221
|
+
inputSchema: textEditor_20250124InputSchema
|
|
4940
5222
|
});
|
|
4941
5223
|
|
|
4942
|
-
// src/tool/
|
|
5224
|
+
// src/tool/text-editor_20250429.ts
|
|
4943
5225
|
import {
|
|
4944
|
-
|
|
5226
|
+
createProviderToolFactory as createProviderToolFactory10,
|
|
4945
5227
|
lazySchema as lazySchema21,
|
|
4946
5228
|
zodSchema as zodSchema21
|
|
4947
5229
|
} from "@ai-sdk/provider-utils";
|
|
4948
5230
|
import { z as z22 } from "zod/v4";
|
|
4949
|
-
var
|
|
5231
|
+
var textEditor_20250429InputSchema = lazySchema21(
|
|
4950
5232
|
() => zodSchema21(
|
|
4951
|
-
z22.
|
|
4952
|
-
z22.
|
|
4953
|
-
|
|
4954
|
-
|
|
5233
|
+
z22.object({
|
|
5234
|
+
command: z22.enum(["view", "create", "str_replace", "insert"]),
|
|
5235
|
+
path: z22.string(),
|
|
5236
|
+
file_text: z22.string().optional(),
|
|
5237
|
+
insert_line: z22.number().int().optional(),
|
|
5238
|
+
new_str: z22.string().optional(),
|
|
5239
|
+
insert_text: z22.string().optional(),
|
|
5240
|
+
old_str: z22.string().optional(),
|
|
5241
|
+
view_range: z22.array(z22.number().int()).optional()
|
|
5242
|
+
})
|
|
5243
|
+
)
|
|
5244
|
+
);
|
|
5245
|
+
var textEditor_20250429 = createProviderToolFactory10({
|
|
5246
|
+
id: "anthropic.text_editor_20250429",
|
|
5247
|
+
inputSchema: textEditor_20250429InputSchema
|
|
5248
|
+
});
|
|
5249
|
+
|
|
5250
|
+
// src/tool/tool-search-bm25_20251119.ts
|
|
5251
|
+
import {
|
|
5252
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema10,
|
|
5253
|
+
lazySchema as lazySchema22,
|
|
5254
|
+
zodSchema as zodSchema22
|
|
5255
|
+
} from "@ai-sdk/provider-utils";
|
|
5256
|
+
import { z as z23 } from "zod/v4";
|
|
5257
|
+
var toolSearchBm25_20251119OutputSchema = lazySchema22(
|
|
5258
|
+
() => zodSchema22(
|
|
5259
|
+
z23.array(
|
|
5260
|
+
z23.object({
|
|
5261
|
+
type: z23.literal("tool_reference"),
|
|
5262
|
+
toolName: z23.string()
|
|
4955
5263
|
})
|
|
4956
5264
|
)
|
|
4957
5265
|
)
|
|
4958
5266
|
);
|
|
4959
|
-
var toolSearchBm25_20251119InputSchema =
|
|
4960
|
-
() =>
|
|
4961
|
-
|
|
5267
|
+
var toolSearchBm25_20251119InputSchema = lazySchema22(
|
|
5268
|
+
() => zodSchema22(
|
|
5269
|
+
z23.object({
|
|
4962
5270
|
/**
|
|
4963
5271
|
* A natural language query to search for tools.
|
|
4964
5272
|
* Claude will use BM25 text search to find relevant tools.
|
|
4965
5273
|
*/
|
|
4966
|
-
query:
|
|
5274
|
+
query: z23.string(),
|
|
4967
5275
|
/**
|
|
4968
5276
|
* Maximum number of tools to return. Optional.
|
|
4969
5277
|
*/
|
|
4970
|
-
limit:
|
|
5278
|
+
limit: z23.number().optional()
|
|
4971
5279
|
})
|
|
4972
5280
|
)
|
|
4973
5281
|
);
|
|
4974
|
-
var
|
|
5282
|
+
var factory11 = createProviderToolFactoryWithOutputSchema10({
|
|
4975
5283
|
id: "anthropic.tool_search_bm25_20251119",
|
|
4976
5284
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
4977
5285
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
4978
5286
|
supportsDeferredResults: true
|
|
4979
5287
|
});
|
|
4980
5288
|
var toolSearchBm25_20251119 = (args = {}) => {
|
|
4981
|
-
return
|
|
5289
|
+
return factory11(args);
|
|
4982
5290
|
};
|
|
4983
5291
|
|
|
4984
5292
|
// src/anthropic-tools.ts
|
|
@@ -5135,6 +5443,22 @@ var anthropicTools = {
|
|
|
5135
5443
|
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
5136
5444
|
*/
|
|
5137
5445
|
webFetch_20260209,
|
|
5446
|
+
/**
|
|
5447
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
5448
|
+
* GA version (no beta header required). Includes caller restrictions, cache control,
|
|
5449
|
+
* deferred loading, and strict mode.
|
|
5450
|
+
*
|
|
5451
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
5452
|
+
* @param allowedDomains - Only fetch from these domains
|
|
5453
|
+
* @param blockedDomains - Never fetch from these domains
|
|
5454
|
+
* @param citations - Citations configuration for fetched documents
|
|
5455
|
+
* @param maxContentTokens - Max content tokens included in context
|
|
5456
|
+
* @param allowedCallers - Restrict callers (e.g. ["direct"] to prevent code_execution usage)
|
|
5457
|
+
* @param useCache - Whether to use cached content (set false for fresh content)
|
|
5458
|
+
* @param deferLoading - Defer loading until tool_search discovers it
|
|
5459
|
+
* @param strict - Enable strict schema validation
|
|
5460
|
+
*/
|
|
5461
|
+
webFetch_20260309,
|
|
5138
5462
|
/**
|
|
5139
5463
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
5140
5464
|
*
|
|
@@ -5185,6 +5509,7 @@ var anthropicTools = {
|
|
|
5185
5509
|
export {
|
|
5186
5510
|
AnthropicMessagesLanguageModel,
|
|
5187
5511
|
anthropicTools,
|
|
5512
|
+
getModelCapabilities,
|
|
5188
5513
|
prepareTools
|
|
5189
5514
|
};
|
|
5190
5515
|
//# sourceMappingURL=index.mjs.map
|