@agi-cli/sdk 0.1.135 → 0.1.137
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/package.json +9 -5
- package/src/browser.ts +31 -0
- package/src/providers/src/catalog-manual.ts +2 -0
- package/src/providers/src/catalog.ts +56 -53
- package/src/providers/src/pricing.ts +23 -2
- package/src/providers/src/solforge-client.ts +29 -7
- package/src/providers/src/utils.ts +7 -2
- package/src/types/src/provider.ts +6 -1
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agi-cli/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.137",
|
|
4
4
|
"description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "nitishxyz",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/
|
|
7
|
+
"homepage": "https://github.com/nitishxyz/agi#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/nitishxyz/agi.git",
|
|
11
11
|
"directory": "packages/sdk"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/nitishxyz/agi/issues"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"main": "./src/index.ts",
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"import": "./src/index.ts",
|
|
22
22
|
"types": "./src/index.ts"
|
|
23
23
|
},
|
|
24
|
+
"./browser": {
|
|
25
|
+
"import": "./src/browser.ts",
|
|
26
|
+
"types": "./src/browser.ts"
|
|
27
|
+
},
|
|
24
28
|
"./tools/builtin/fs": {
|
|
25
29
|
"import": "./src/core/src/tools/builtin/fs/index.ts",
|
|
26
30
|
"types": "./src/core/src/tools/builtin/fs/index.ts"
|
package/src/browser.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// @agi-cli/sdk/browser - Browser-safe exports
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// This module exports only browser-compatible code (no Bun, no Node.js APIs).
|
|
5
|
+
// Use this entry point for web applications like web-sdk.
|
|
6
|
+
//
|
|
7
|
+
// Usage:
|
|
8
|
+
// import { estimateModelCostUsd, type ProviderId } from '@agi-cli/sdk/browser';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
// Types (pure TypeScript, no runtime dependencies)
|
|
12
|
+
export type {
|
|
13
|
+
ProviderId,
|
|
14
|
+
ModelInfo,
|
|
15
|
+
ModelProviderBinding,
|
|
16
|
+
ProviderCatalogEntry,
|
|
17
|
+
} from './types/src/index.ts';
|
|
18
|
+
|
|
19
|
+
// Pricing utilities (pure TypeScript)
|
|
20
|
+
export { estimateModelCostUsd } from './providers/src/pricing.ts';
|
|
21
|
+
|
|
22
|
+
// Catalog data (pure TypeScript)
|
|
23
|
+
export { catalog } from './providers/src/catalog-merged.ts';
|
|
24
|
+
|
|
25
|
+
// Provider utilities (pure TypeScript - imported directly to avoid pulling in Bun deps)
|
|
26
|
+
export {
|
|
27
|
+
isProviderId,
|
|
28
|
+
providerIds,
|
|
29
|
+
defaultModelFor,
|
|
30
|
+
hasModel,
|
|
31
|
+
} from './providers/src/utils.ts';
|
|
@@ -16,6 +16,8 @@ const isAllowedOpenAIModel = (id: string): boolean => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const isAllowedAnthropicModel = (id: string): boolean => {
|
|
19
|
+
if (id.includes('-3-5-') || id.includes('-3.5-')) return true;
|
|
20
|
+
if (id.match(/claude-(haiku|sonnet|opus)-3/)) return true;
|
|
19
21
|
if (id.includes('-4-') || id.includes('-4.')) return true;
|
|
20
22
|
if (id.match(/claude-(haiku|sonnet|opus)-4/)) return true;
|
|
21
23
|
return false;
|
|
@@ -1026,6 +1026,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1026
1026
|
input: 0.8,
|
|
1027
1027
|
output: 4,
|
|
1028
1028
|
cacheRead: 0.08,
|
|
1029
|
+
cacheWrite: 1,
|
|
1029
1030
|
},
|
|
1030
1031
|
limit: {
|
|
1031
1032
|
context: 200000,
|
|
@@ -1051,6 +1052,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1051
1052
|
input: 0.8,
|
|
1052
1053
|
output: 4,
|
|
1053
1054
|
cacheRead: 0.08,
|
|
1055
|
+
cacheWrite: 1,
|
|
1054
1056
|
},
|
|
1055
1057
|
limit: {
|
|
1056
1058
|
context: 200000,
|
|
@@ -1076,6 +1078,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1076
1078
|
input: 3,
|
|
1077
1079
|
output: 15,
|
|
1078
1080
|
cacheRead: 0.3,
|
|
1081
|
+
cacheWrite: 3.75,
|
|
1079
1082
|
},
|
|
1080
1083
|
limit: {
|
|
1081
1084
|
context: 200000,
|
|
@@ -1101,6 +1104,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1101
1104
|
input: 3,
|
|
1102
1105
|
output: 15,
|
|
1103
1106
|
cacheRead: 0.3,
|
|
1107
|
+
cacheWrite: 3.75,
|
|
1104
1108
|
},
|
|
1105
1109
|
limit: {
|
|
1106
1110
|
context: 200000,
|
|
@@ -1126,6 +1130,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1126
1130
|
input: 3,
|
|
1127
1131
|
output: 15,
|
|
1128
1132
|
cacheRead: 0.3,
|
|
1133
|
+
cacheWrite: 3.75,
|
|
1129
1134
|
},
|
|
1130
1135
|
limit: {
|
|
1131
1136
|
context: 200000,
|
|
@@ -1151,6 +1156,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1151
1156
|
input: 3,
|
|
1152
1157
|
output: 15,
|
|
1153
1158
|
cacheRead: 0.3,
|
|
1159
|
+
cacheWrite: 3.75,
|
|
1154
1160
|
},
|
|
1155
1161
|
limit: {
|
|
1156
1162
|
context: 200000,
|
|
@@ -1176,6 +1182,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1176
1182
|
input: 0.25,
|
|
1177
1183
|
output: 1.25,
|
|
1178
1184
|
cacheRead: 0.03,
|
|
1185
|
+
cacheWrite: 0.3,
|
|
1179
1186
|
},
|
|
1180
1187
|
limit: {
|
|
1181
1188
|
context: 200000,
|
|
@@ -1201,6 +1208,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1201
1208
|
input: 15,
|
|
1202
1209
|
output: 75,
|
|
1203
1210
|
cacheRead: 1.5,
|
|
1211
|
+
cacheWrite: 18.75,
|
|
1204
1212
|
},
|
|
1205
1213
|
limit: {
|
|
1206
1214
|
context: 200000,
|
|
@@ -1226,6 +1234,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1226
1234
|
input: 3,
|
|
1227
1235
|
output: 15,
|
|
1228
1236
|
cacheRead: 0.3,
|
|
1237
|
+
cacheWrite: 0.3,
|
|
1229
1238
|
},
|
|
1230
1239
|
limit: {
|
|
1231
1240
|
context: 200000,
|
|
@@ -1251,6 +1260,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1251
1260
|
input: 1,
|
|
1252
1261
|
output: 5,
|
|
1253
1262
|
cacheRead: 0.1,
|
|
1263
|
+
cacheWrite: 1.25,
|
|
1254
1264
|
},
|
|
1255
1265
|
limit: {
|
|
1256
1266
|
context: 200000,
|
|
@@ -1276,6 +1286,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1276
1286
|
input: 1,
|
|
1277
1287
|
output: 5,
|
|
1278
1288
|
cacheRead: 0.1,
|
|
1289
|
+
cacheWrite: 1.25,
|
|
1279
1290
|
},
|
|
1280
1291
|
limit: {
|
|
1281
1292
|
context: 200000,
|
|
@@ -1301,6 +1312,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1301
1312
|
input: 15,
|
|
1302
1313
|
output: 75,
|
|
1303
1314
|
cacheRead: 1.5,
|
|
1315
|
+
cacheWrite: 18.75,
|
|
1304
1316
|
},
|
|
1305
1317
|
limit: {
|
|
1306
1318
|
context: 200000,
|
|
@@ -1326,6 +1338,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1326
1338
|
input: 15,
|
|
1327
1339
|
output: 75,
|
|
1328
1340
|
cacheRead: 1.5,
|
|
1341
|
+
cacheWrite: 18.75,
|
|
1329
1342
|
},
|
|
1330
1343
|
limit: {
|
|
1331
1344
|
context: 200000,
|
|
@@ -1351,6 +1364,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1351
1364
|
input: 15,
|
|
1352
1365
|
output: 75,
|
|
1353
1366
|
cacheRead: 1.5,
|
|
1367
|
+
cacheWrite: 18.75,
|
|
1354
1368
|
},
|
|
1355
1369
|
limit: {
|
|
1356
1370
|
context: 200000,
|
|
@@ -1376,6 +1390,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1376
1390
|
input: 15,
|
|
1377
1391
|
output: 75,
|
|
1378
1392
|
cacheRead: 1.5,
|
|
1393
|
+
cacheWrite: 18.75,
|
|
1379
1394
|
},
|
|
1380
1395
|
limit: {
|
|
1381
1396
|
context: 200000,
|
|
@@ -1401,6 +1416,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1401
1416
|
input: 5,
|
|
1402
1417
|
output: 25,
|
|
1403
1418
|
cacheRead: 0.5,
|
|
1419
|
+
cacheWrite: 6.25,
|
|
1404
1420
|
},
|
|
1405
1421
|
limit: {
|
|
1406
1422
|
context: 200000,
|
|
@@ -1426,6 +1442,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1426
1442
|
input: 5,
|
|
1427
1443
|
output: 25,
|
|
1428
1444
|
cacheRead: 0.5,
|
|
1445
|
+
cacheWrite: 6.25,
|
|
1429
1446
|
},
|
|
1430
1447
|
limit: {
|
|
1431
1448
|
context: 200000,
|
|
@@ -1451,6 +1468,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1451
1468
|
input: 3,
|
|
1452
1469
|
output: 15,
|
|
1453
1470
|
cacheRead: 0.3,
|
|
1471
|
+
cacheWrite: 3.75,
|
|
1454
1472
|
},
|
|
1455
1473
|
limit: {
|
|
1456
1474
|
context: 200000,
|
|
@@ -1476,6 +1494,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1476
1494
|
input: 3,
|
|
1477
1495
|
output: 15,
|
|
1478
1496
|
cacheRead: 0.3,
|
|
1497
|
+
cacheWrite: 3.75,
|
|
1479
1498
|
},
|
|
1480
1499
|
limit: {
|
|
1481
1500
|
context: 200000,
|
|
@@ -1501,6 +1520,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1501
1520
|
input: 3,
|
|
1502
1521
|
output: 15,
|
|
1503
1522
|
cacheRead: 0.3,
|
|
1523
|
+
cacheWrite: 3.75,
|
|
1504
1524
|
},
|
|
1505
1525
|
limit: {
|
|
1506
1526
|
context: 200000,
|
|
@@ -1526,6 +1546,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
1526
1546
|
input: 3,
|
|
1527
1547
|
output: 15,
|
|
1528
1548
|
cacheRead: 0.3,
|
|
1549
|
+
cacheWrite: 3.75,
|
|
1529
1550
|
},
|
|
1530
1551
|
limit: {
|
|
1531
1552
|
context: 200000,
|
|
@@ -2213,6 +2234,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
2213
2234
|
input: 0.8,
|
|
2214
2235
|
output: 4,
|
|
2215
2236
|
cacheRead: 0.08,
|
|
2237
|
+
cacheWrite: 1,
|
|
2216
2238
|
},
|
|
2217
2239
|
limit: {
|
|
2218
2240
|
context: 200000,
|
|
@@ -2238,6 +2260,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
2238
2260
|
input: 15,
|
|
2239
2261
|
output: 75,
|
|
2240
2262
|
cacheRead: 1.5,
|
|
2263
|
+
cacheWrite: 18.75,
|
|
2241
2264
|
},
|
|
2242
2265
|
limit: {
|
|
2243
2266
|
context: 200000,
|
|
@@ -2263,6 +2286,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
2263
2286
|
input: 1,
|
|
2264
2287
|
output: 5,
|
|
2265
2288
|
cacheRead: 0.1,
|
|
2289
|
+
cacheWrite: 1.25,
|
|
2266
2290
|
},
|
|
2267
2291
|
limit: {
|
|
2268
2292
|
context: 200000,
|
|
@@ -2288,6 +2312,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
2288
2312
|
input: 15,
|
|
2289
2313
|
output: 75,
|
|
2290
2314
|
cacheRead: 1.5,
|
|
2315
|
+
cacheWrite: 18.75,
|
|
2291
2316
|
},
|
|
2292
2317
|
limit: {
|
|
2293
2318
|
context: 200000,
|
|
@@ -2313,6 +2338,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
2313
2338
|
input: 15,
|
|
2314
2339
|
output: 75,
|
|
2315
2340
|
cacheRead: 1.5,
|
|
2341
|
+
cacheWrite: 18.75,
|
|
2316
2342
|
},
|
|
2317
2343
|
limit: {
|
|
2318
2344
|
context: 200000,
|
|
@@ -2338,6 +2364,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
2338
2364
|
input: 5,
|
|
2339
2365
|
output: 25,
|
|
2340
2366
|
cacheRead: 0.5,
|
|
2367
|
+
cacheWrite: 6.25,
|
|
2341
2368
|
},
|
|
2342
2369
|
limit: {
|
|
2343
2370
|
context: 200000,
|
|
@@ -2363,6 +2390,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
2363
2390
|
input: 3,
|
|
2364
2391
|
output: 15,
|
|
2365
2392
|
cacheRead: 0.3,
|
|
2393
|
+
cacheWrite: 3.75,
|
|
2366
2394
|
},
|
|
2367
2395
|
limit: {
|
|
2368
2396
|
context: 200000,
|
|
@@ -2388,6 +2416,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
2388
2416
|
input: 3,
|
|
2389
2417
|
output: 15,
|
|
2390
2418
|
cacheRead: 0.3,
|
|
2419
|
+
cacheWrite: 3.75,
|
|
2391
2420
|
},
|
|
2392
2421
|
limit: {
|
|
2393
2422
|
context: 1000000,
|
|
@@ -3343,6 +3372,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
3343
3372
|
input: 0.28,
|
|
3344
3373
|
output: 1.15,
|
|
3345
3374
|
cacheRead: 0.28,
|
|
3375
|
+
cacheWrite: 1.15,
|
|
3346
3376
|
},
|
|
3347
3377
|
limit: {
|
|
3348
3378
|
context: 196600,
|
|
@@ -5258,6 +5288,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5258
5288
|
input: 3,
|
|
5259
5289
|
output: 15,
|
|
5260
5290
|
cacheRead: 0.75,
|
|
5291
|
+
cacheWrite: 15,
|
|
5261
5292
|
},
|
|
5262
5293
|
limit: {
|
|
5263
5294
|
context: 131072,
|
|
@@ -5283,6 +5314,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5283
5314
|
input: 3,
|
|
5284
5315
|
output: 15,
|
|
5285
5316
|
cacheRead: 0.75,
|
|
5317
|
+
cacheWrite: 15,
|
|
5286
5318
|
},
|
|
5287
5319
|
limit: {
|
|
5288
5320
|
context: 131072,
|
|
@@ -5308,6 +5340,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5308
5340
|
input: 0.3,
|
|
5309
5341
|
output: 0.5,
|
|
5310
5342
|
cacheRead: 0.075,
|
|
5343
|
+
cacheWrite: 0.5,
|
|
5311
5344
|
},
|
|
5312
5345
|
limit: {
|
|
5313
5346
|
context: 131072,
|
|
@@ -5333,6 +5366,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5333
5366
|
input: 0.3,
|
|
5334
5367
|
output: 0.5,
|
|
5335
5368
|
cacheRead: 0.075,
|
|
5369
|
+
cacheWrite: 0.5,
|
|
5336
5370
|
},
|
|
5337
5371
|
limit: {
|
|
5338
5372
|
context: 131072,
|
|
@@ -5358,6 +5392,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5358
5392
|
input: 3,
|
|
5359
5393
|
output: 15,
|
|
5360
5394
|
cacheRead: 0.75,
|
|
5395
|
+
cacheWrite: 15,
|
|
5361
5396
|
},
|
|
5362
5397
|
limit: {
|
|
5363
5398
|
context: 256000,
|
|
@@ -5383,6 +5418,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5383
5418
|
input: 0.2,
|
|
5384
5419
|
output: 0.5,
|
|
5385
5420
|
cacheRead: 0.05,
|
|
5421
|
+
cacheWrite: 0.05,
|
|
5386
5422
|
},
|
|
5387
5423
|
limit: {
|
|
5388
5424
|
context: 2000000,
|
|
@@ -5408,6 +5444,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5408
5444
|
input: 0.2,
|
|
5409
5445
|
output: 0.5,
|
|
5410
5446
|
cacheRead: 0.05,
|
|
5447
|
+
cacheWrite: 0.05,
|
|
5411
5448
|
},
|
|
5412
5449
|
limit: {
|
|
5413
5450
|
context: 2000000,
|
|
@@ -5623,59 +5660,6 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5623
5660
|
opencode: {
|
|
5624
5661
|
id: 'opencode',
|
|
5625
5662
|
models: [
|
|
5626
|
-
{
|
|
5627
|
-
id: 'alpha-gd4',
|
|
5628
|
-
label: 'Alpha GD4',
|
|
5629
|
-
modalities: {
|
|
5630
|
-
input: ['text'],
|
|
5631
|
-
output: ['text'],
|
|
5632
|
-
},
|
|
5633
|
-
toolCall: true,
|
|
5634
|
-
reasoning: true,
|
|
5635
|
-
attachment: false,
|
|
5636
|
-
temperature: true,
|
|
5637
|
-
knowledge: '2025-01',
|
|
5638
|
-
releaseDate: '2025-01-01',
|
|
5639
|
-
lastUpdated: '2025-01-01',
|
|
5640
|
-
openWeights: true,
|
|
5641
|
-
cost: {
|
|
5642
|
-
input: 0.5,
|
|
5643
|
-
output: 2,
|
|
5644
|
-
cacheRead: 0.15,
|
|
5645
|
-
},
|
|
5646
|
-
limit: {
|
|
5647
|
-
context: 262144,
|
|
5648
|
-
output: 32768,
|
|
5649
|
-
},
|
|
5650
|
-
provider: {
|
|
5651
|
-
npm: '@ai-sdk/anthropic',
|
|
5652
|
-
},
|
|
5653
|
-
},
|
|
5654
|
-
{
|
|
5655
|
-
id: 'alpha-glm-4.7',
|
|
5656
|
-
label: 'Alpha GLM-4.7',
|
|
5657
|
-
modalities: {
|
|
5658
|
-
input: ['text'],
|
|
5659
|
-
output: ['text'],
|
|
5660
|
-
},
|
|
5661
|
-
toolCall: true,
|
|
5662
|
-
reasoning: true,
|
|
5663
|
-
attachment: false,
|
|
5664
|
-
temperature: true,
|
|
5665
|
-
knowledge: '2025-04',
|
|
5666
|
-
releaseDate: '2025-12-22',
|
|
5667
|
-
lastUpdated: '2025-12-22',
|
|
5668
|
-
openWeights: true,
|
|
5669
|
-
cost: {
|
|
5670
|
-
input: 0.6,
|
|
5671
|
-
output: 2.2,
|
|
5672
|
-
cacheRead: 0.6,
|
|
5673
|
-
},
|
|
5674
|
-
limit: {
|
|
5675
|
-
context: 204800,
|
|
5676
|
-
output: 131072,
|
|
5677
|
-
},
|
|
5678
|
-
},
|
|
5679
5663
|
{
|
|
5680
5664
|
id: 'big-pickle',
|
|
5681
5665
|
label: 'Big Pickle',
|
|
@@ -5695,6 +5679,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5695
5679
|
input: 0,
|
|
5696
5680
|
output: 0,
|
|
5697
5681
|
cacheRead: 0,
|
|
5682
|
+
cacheWrite: 0,
|
|
5698
5683
|
},
|
|
5699
5684
|
limit: {
|
|
5700
5685
|
context: 200000,
|
|
@@ -5720,6 +5705,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5720
5705
|
input: 0.8,
|
|
5721
5706
|
output: 4,
|
|
5722
5707
|
cacheRead: 0.08,
|
|
5708
|
+
cacheWrite: 1,
|
|
5723
5709
|
},
|
|
5724
5710
|
limit: {
|
|
5725
5711
|
context: 200000,
|
|
@@ -5748,6 +5734,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5748
5734
|
input: 1,
|
|
5749
5735
|
output: 5,
|
|
5750
5736
|
cacheRead: 0.1,
|
|
5737
|
+
cacheWrite: 1.25,
|
|
5751
5738
|
},
|
|
5752
5739
|
limit: {
|
|
5753
5740
|
context: 200000,
|
|
@@ -5776,6 +5763,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5776
5763
|
input: 15,
|
|
5777
5764
|
output: 75,
|
|
5778
5765
|
cacheRead: 1.5,
|
|
5766
|
+
cacheWrite: 18.75,
|
|
5779
5767
|
},
|
|
5780
5768
|
limit: {
|
|
5781
5769
|
context: 200000,
|
|
@@ -5804,6 +5792,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5804
5792
|
input: 5,
|
|
5805
5793
|
output: 25,
|
|
5806
5794
|
cacheRead: 0.5,
|
|
5795
|
+
cacheWrite: 6.25,
|
|
5807
5796
|
},
|
|
5808
5797
|
limit: {
|
|
5809
5798
|
context: 200000,
|
|
@@ -5832,6 +5821,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5832
5821
|
input: 3,
|
|
5833
5822
|
output: 15,
|
|
5834
5823
|
cacheRead: 0.3,
|
|
5824
|
+
cacheWrite: 3.75,
|
|
5835
5825
|
},
|
|
5836
5826
|
limit: {
|
|
5837
5827
|
context: 1000000,
|
|
@@ -5860,6 +5850,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
5860
5850
|
input: 3,
|
|
5861
5851
|
output: 15,
|
|
5862
5852
|
cacheRead: 0.3,
|
|
5853
|
+
cacheWrite: 3.75,
|
|
5863
5854
|
},
|
|
5864
5855
|
limit: {
|
|
5865
5856
|
context: 1000000,
|
|
@@ -6270,6 +6261,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6270
6261
|
input: 0,
|
|
6271
6262
|
output: 0,
|
|
6272
6263
|
cacheRead: 0,
|
|
6264
|
+
cacheWrite: 0,
|
|
6273
6265
|
},
|
|
6274
6266
|
limit: {
|
|
6275
6267
|
context: 256000,
|
|
@@ -6407,6 +6399,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6407
6399
|
input: 0.6,
|
|
6408
6400
|
output: 2.2,
|
|
6409
6401
|
cacheRead: 0.11,
|
|
6402
|
+
cacheWrite: 0,
|
|
6410
6403
|
},
|
|
6411
6404
|
limit: {
|
|
6412
6405
|
context: 131072,
|
|
@@ -6432,6 +6425,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6432
6425
|
input: 0.2,
|
|
6433
6426
|
output: 1.1,
|
|
6434
6427
|
cacheRead: 0.03,
|
|
6428
|
+
cacheWrite: 0,
|
|
6435
6429
|
},
|
|
6436
6430
|
limit: {
|
|
6437
6431
|
context: 131072,
|
|
@@ -6457,6 +6451,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6457
6451
|
input: 0,
|
|
6458
6452
|
output: 0,
|
|
6459
6453
|
cacheRead: 0,
|
|
6454
|
+
cacheWrite: 0,
|
|
6460
6455
|
},
|
|
6461
6456
|
limit: {
|
|
6462
6457
|
context: 131072,
|
|
@@ -6506,6 +6501,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6506
6501
|
input: 0.6,
|
|
6507
6502
|
output: 2.2,
|
|
6508
6503
|
cacheRead: 0.11,
|
|
6504
|
+
cacheWrite: 0,
|
|
6509
6505
|
},
|
|
6510
6506
|
limit: {
|
|
6511
6507
|
context: 204800,
|
|
@@ -6555,6 +6551,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6555
6551
|
input: 0.6,
|
|
6556
6552
|
output: 2.2,
|
|
6557
6553
|
cacheRead: 0.11,
|
|
6554
|
+
cacheWrite: 0,
|
|
6558
6555
|
},
|
|
6559
6556
|
limit: {
|
|
6560
6557
|
context: 204800,
|
|
@@ -6590,6 +6587,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6590
6587
|
input: 0,
|
|
6591
6588
|
output: 0,
|
|
6592
6589
|
cacheRead: 0,
|
|
6590
|
+
cacheWrite: 0,
|
|
6593
6591
|
},
|
|
6594
6592
|
limit: {
|
|
6595
6593
|
context: 131072,
|
|
@@ -6615,6 +6613,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6615
6613
|
input: 0,
|
|
6616
6614
|
output: 0,
|
|
6617
6615
|
cacheRead: 0,
|
|
6616
|
+
cacheWrite: 0,
|
|
6618
6617
|
},
|
|
6619
6618
|
limit: {
|
|
6620
6619
|
context: 131072,
|
|
@@ -6640,6 +6639,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6640
6639
|
input: 0,
|
|
6641
6640
|
output: 0,
|
|
6642
6641
|
cacheRead: 0,
|
|
6642
|
+
cacheWrite: 0,
|
|
6643
6643
|
},
|
|
6644
6644
|
limit: {
|
|
6645
6645
|
context: 131072,
|
|
@@ -6689,6 +6689,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6689
6689
|
input: 0,
|
|
6690
6690
|
output: 0,
|
|
6691
6691
|
cacheRead: 0,
|
|
6692
|
+
cacheWrite: 0,
|
|
6692
6693
|
},
|
|
6693
6694
|
limit: {
|
|
6694
6695
|
context: 204800,
|
|
@@ -6738,6 +6739,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6738
6739
|
input: 0,
|
|
6739
6740
|
output: 0,
|
|
6740
6741
|
cacheRead: 0,
|
|
6742
|
+
cacheWrite: 0,
|
|
6741
6743
|
},
|
|
6742
6744
|
limit: {
|
|
6743
6745
|
context: 204800,
|
|
@@ -6763,6 +6765,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6763
6765
|
input: 0,
|
|
6764
6766
|
output: 0,
|
|
6765
6767
|
cacheRead: 0,
|
|
6768
|
+
cacheWrite: 0,
|
|
6766
6769
|
},
|
|
6767
6770
|
limit: {
|
|
6768
6771
|
context: 200000,
|
|
@@ -6,6 +6,8 @@ type ProviderName = ProviderId;
|
|
|
6
6
|
type UsageLike = {
|
|
7
7
|
inputTokens?: number | null;
|
|
8
8
|
outputTokens?: number | null;
|
|
9
|
+
cachedInputTokens?: number | null;
|
|
10
|
+
cacheCreationInputTokens?: number | null;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
type PricingEntry = {
|
|
@@ -119,7 +121,19 @@ export function estimateModelCostUsd(
|
|
|
119
121
|
typeof usage.inputTokens === 'number' ? usage.inputTokens : 0;
|
|
120
122
|
const outputTokens =
|
|
121
123
|
typeof usage.outputTokens === 'number' ? usage.outputTokens : 0;
|
|
122
|
-
|
|
124
|
+
const cachedInputTokens =
|
|
125
|
+
typeof usage.cachedInputTokens === 'number' ? usage.cachedInputTokens : 0;
|
|
126
|
+
const cacheCreationInputTokens =
|
|
127
|
+
typeof usage.cacheCreationInputTokens === 'number'
|
|
128
|
+
? usage.cacheCreationInputTokens
|
|
129
|
+
: 0;
|
|
130
|
+
if (
|
|
131
|
+
!inputTokens &&
|
|
132
|
+
!outputTokens &&
|
|
133
|
+
!cachedInputTokens &&
|
|
134
|
+
!cacheCreationInputTokens
|
|
135
|
+
)
|
|
136
|
+
return undefined;
|
|
123
137
|
|
|
124
138
|
// Prefer centralized catalog costs when available
|
|
125
139
|
const m = findCatalogModel(provider, model);
|
|
@@ -128,9 +142,16 @@ export function estimateModelCostUsd(
|
|
|
128
142
|
typeof m.cost?.input === 'number' ? m.cost.input : 0;
|
|
129
143
|
const outputPerMillion =
|
|
130
144
|
typeof m.cost?.output === 'number' ? m.cost.output : 0;
|
|
145
|
+
const cacheReadPerMillion =
|
|
146
|
+
typeof m.cost?.cacheRead === 'number' ? m.cost.cacheRead : 0;
|
|
147
|
+
const cacheWritePerMillion =
|
|
148
|
+
typeof m.cost?.cacheWrite === 'number' ? m.cost.cacheWrite : 0;
|
|
131
149
|
const inputCost = (inputTokens * inputPerMillion) / 1_000_000;
|
|
132
150
|
const outputCost = (outputTokens * outputPerMillion) / 1_000_000;
|
|
133
|
-
const
|
|
151
|
+
const cacheReadCost = (cachedInputTokens * cacheReadPerMillion) / 1_000_000;
|
|
152
|
+
const cacheWriteCost =
|
|
153
|
+
(cacheCreationInputTokens * cacheWritePerMillion) / 1_000_000;
|
|
154
|
+
const total = inputCost + outputCost + cacheReadCost + cacheWriteCost;
|
|
134
155
|
return Number.isFinite(total) ? Number(total.toFixed(6)) : undefined;
|
|
135
156
|
}
|
|
136
157
|
|
|
@@ -9,6 +9,34 @@ import { createOpenAI } from '@ai-sdk/openai';
|
|
|
9
9
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
10
10
|
import { addAnthropicCacheControl } from './anthropic-caching.ts';
|
|
11
11
|
|
|
12
|
+
function simplifyPaymentError(errMsg: string): string {
|
|
13
|
+
const lower = errMsg.toLowerCase();
|
|
14
|
+
if (
|
|
15
|
+
lower.includes('insufficient') ||
|
|
16
|
+
lower.includes('not enough') ||
|
|
17
|
+
lower.includes('balance')
|
|
18
|
+
) {
|
|
19
|
+
return 'Insufficient USDC balance';
|
|
20
|
+
}
|
|
21
|
+
if (lower.includes('simulation') || lower.includes('compute unit')) {
|
|
22
|
+
return 'Transaction simulation failed';
|
|
23
|
+
}
|
|
24
|
+
if (lower.includes('blockhash') || lower.includes('expired')) {
|
|
25
|
+
return 'Transaction expired, please retry';
|
|
26
|
+
}
|
|
27
|
+
if (lower.includes('timeout') || lower.includes('timed out')) {
|
|
28
|
+
return 'Transaction timed out';
|
|
29
|
+
}
|
|
30
|
+
if (lower.includes('rejected') || lower.includes('cancelled')) {
|
|
31
|
+
return 'Transaction rejected';
|
|
32
|
+
}
|
|
33
|
+
if (lower.includes('network') || lower.includes('connection')) {
|
|
34
|
+
return 'Network error';
|
|
35
|
+
}
|
|
36
|
+
const short = errMsg.split('.')[0].slice(0, 80);
|
|
37
|
+
return short.length < errMsg.length ? `${short}...` : errMsg;
|
|
38
|
+
}
|
|
39
|
+
|
|
12
40
|
const DEFAULT_BASE_URL = 'https://router.solforge.sh';
|
|
13
41
|
const DEFAULT_RPC_URL = 'https://api.mainnet-beta.solana.com';
|
|
14
42
|
const DEFAULT_MAX_ATTEMPTS = 3;
|
|
@@ -330,13 +358,7 @@ async function processSinglePayment(args: {
|
|
|
330
358
|
paymentPayload = await createPaymentPayload(args);
|
|
331
359
|
} catch (err) {
|
|
332
360
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
333
|
-
const
|
|
334
|
-
errMsg.toLowerCase().includes('insufficient') ||
|
|
335
|
-
errMsg.toLowerCase().includes('not enough') ||
|
|
336
|
-
errMsg.toLowerCase().includes('balance');
|
|
337
|
-
const userMsg = isInsufficientFunds
|
|
338
|
-
? 'Insufficient USDC balance in wallet for payment'
|
|
339
|
-
: `Payment failed: ${errMsg}`;
|
|
361
|
+
const userMsg = `Payment failed: ${simplifyPaymentError(errMsg)}`;
|
|
340
362
|
args.callbacks.onPaymentError?.(userMsg);
|
|
341
363
|
throw new Error(`Solforge: ${userMsg}`);
|
|
342
364
|
}
|
|
@@ -37,11 +37,16 @@ const PREFERRED_FAST_MODELS: Partial<Record<ProviderId, string[]>> = {
|
|
|
37
37
|
'gemini-2.5-flash-lite',
|
|
38
38
|
],
|
|
39
39
|
openrouter: [
|
|
40
|
+
'anthropic/claude-3.5-haiku',
|
|
40
41
|
'openai/gpt-4o-mini',
|
|
41
42
|
'google/gemini-2.0-flash-001',
|
|
42
|
-
'anthropic/claude-3.5-haiku',
|
|
43
43
|
],
|
|
44
|
-
opencode: ['
|
|
44
|
+
opencode: ['claude-3-5-haiku', 'gpt-5-nano', 'gemini-3-flash'],
|
|
45
|
+
solforge: [
|
|
46
|
+
'claude-3-5-haiku-latest',
|
|
47
|
+
'claude-3-5-haiku-20241022',
|
|
48
|
+
'codex-mini-latest',
|
|
49
|
+
],
|
|
45
50
|
zai: ['glm-4.5-flash', 'glm-4.5-air'],
|
|
46
51
|
};
|
|
47
52
|
|
|
@@ -33,7 +33,12 @@ export type ModelInfo = {
|
|
|
33
33
|
releaseDate?: string;
|
|
34
34
|
lastUpdated?: string;
|
|
35
35
|
openWeights?: boolean;
|
|
36
|
-
cost?: {
|
|
36
|
+
cost?: {
|
|
37
|
+
input?: number;
|
|
38
|
+
output?: number;
|
|
39
|
+
cacheRead?: number;
|
|
40
|
+
cacheWrite?: number;
|
|
41
|
+
};
|
|
37
42
|
limit?: { context?: number; output?: number };
|
|
38
43
|
provider?: ModelProviderBinding;
|
|
39
44
|
};
|