@blockrun/clawrouter 0.9.39 → 0.10.1

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/dist/cli.js CHANGED
@@ -1199,10 +1199,10 @@ var DEFAULT_ROUTING_CONFIG = {
1199
1199
  tiers: {
1200
1200
  SIMPLE: {
1201
1201
  primary: "moonshot/kimi-k2.5",
1202
- // $0.50/$2.40 - best quality/price for simple tasks
1202
+ // $0.60/$3.00 - best quality/price for simple tasks
1203
1203
  fallback: [
1204
- "google/gemini-2.5-flash",
1205
- // 1M context, cost-effective
1204
+ "google/gemini-2.5-flash-lite",
1205
+ // 1M context, ultra cheap ($0.10/$0.40)
1206
1206
  "nvidia/gpt-oss-120b",
1207
1207
  // FREE fallback
1208
1208
  "deepseek/deepseek-chat"
@@ -1212,26 +1212,28 @@ var DEFAULT_ROUTING_CONFIG = {
1212
1212
  primary: "xai/grok-code-fast-1",
1213
1213
  // Code specialist, $0.20/$1.50
1214
1214
  fallback: [
1215
- "google/gemini-2.5-flash",
1216
- // 1M context, cost-effective
1215
+ "google/gemini-2.5-flash-lite",
1216
+ // 1M context, ultra cheap ($0.10/$0.40)
1217
1217
  "deepseek/deepseek-chat",
1218
1218
  "xai/grok-4-1-fast-non-reasoning"
1219
1219
  // Upgraded Grok 4.1
1220
1220
  ]
1221
1221
  },
1222
1222
  COMPLEX: {
1223
- primary: "google/gemini-3-pro-preview",
1224
- // Latest Gemini - upgraded from 2.5
1223
+ primary: "google/gemini-3.1-pro-preview",
1224
+ // Newest Gemini 3.1 - upgraded from 3.0
1225
1225
  fallback: [
1226
- "google/gemini-2.5-flash",
1227
- // CRITICAL: 1M context, cheap failsafe before expensive models
1226
+ "google/gemini-2.5-flash-lite",
1227
+ // CRITICAL: 1M context, ultra-cheap failsafe ($0.10/$0.40)
1228
+ "google/gemini-3-pro-preview",
1229
+ // 3.0 fallback
1228
1230
  "google/gemini-2.5-pro",
1229
1231
  "deepseek/deepseek-chat",
1230
1232
  "xai/grok-4-0709",
1231
1233
  "openai/gpt-5.2",
1232
1234
  // Newer and cheaper input than gpt-4o
1233
1235
  "openai/gpt-4o",
1234
- "claude-sonnet-4"
1236
+ "anthropic/claude-sonnet-4.6"
1235
1237
  ]
1236
1238
  },
1237
1239
  REASONING: {
@@ -1251,17 +1253,17 @@ var DEFAULT_ROUTING_CONFIG = {
1251
1253
  SIMPLE: {
1252
1254
  primary: "nvidia/gpt-oss-120b",
1253
1255
  // FREE! $0.00/$0.00
1254
- fallback: ["google/gemini-2.5-flash", "deepseek/deepseek-chat"]
1256
+ fallback: ["google/gemini-2.5-flash-lite", "deepseek/deepseek-chat"]
1255
1257
  },
1256
1258
  MEDIUM: {
1257
- primary: "google/gemini-2.5-flash",
1258
- // $0.15/$0.60 - cheapest capable
1259
+ primary: "google/gemini-2.5-flash-lite",
1260
+ // $0.10/$0.40 - cheapest capable with 1M context
1259
1261
  fallback: ["deepseek/deepseek-chat", "nvidia/gpt-oss-120b"]
1260
1262
  },
1261
1263
  COMPLEX: {
1262
- primary: "google/gemini-2.5-flash",
1263
- // $0.15/$0.60 - 1M context handles complexity
1264
- fallback: ["deepseek/deepseek-chat", "xai/grok-4-0709"]
1264
+ primary: "google/gemini-2.5-flash-lite",
1265
+ // $0.10/$0.40 - 1M context handles complexity
1266
+ fallback: ["google/gemini-2.5-flash", "deepseek/deepseek-chat", "xai/grok-4-0709"]
1265
1267
  },
1266
1268
  REASONING: {
1267
1269
  primary: "xai/grok-4-1-fast-reasoning",
@@ -1274,8 +1276,12 @@ var DEFAULT_ROUTING_CONFIG = {
1274
1276
  premiumTiers: {
1275
1277
  SIMPLE: {
1276
1278
  primary: "moonshot/kimi-k2.5",
1277
- // $0.50/$2.40 - good for simple coding
1278
- fallback: ["claude-haiku-4.5", "google/gemini-2.5-flash", "xai/grok-code-fast-1"]
1279
+ // $0.60/$3.00 - good for simple coding
1280
+ fallback: [
1281
+ "anthropic/claude-haiku-4.5",
1282
+ "google/gemini-2.5-flash-lite",
1283
+ "xai/grok-code-fast-1"
1284
+ ]
1279
1285
  },
1280
1286
  MEDIUM: {
1281
1287
  primary: "openai/gpt-5.2-codex",
@@ -1284,26 +1290,28 @@ var DEFAULT_ROUTING_CONFIG = {
1284
1290
  "moonshot/kimi-k2.5",
1285
1291
  "google/gemini-2.5-pro",
1286
1292
  "xai/grok-4-0709",
1287
- "claude-sonnet-4"
1293
+ "anthropic/claude-sonnet-4.6"
1288
1294
  ]
1289
1295
  },
1290
1296
  COMPLEX: {
1291
- primary: "claude-opus-4",
1297
+ primary: "anthropic/claude-opus-4.6",
1292
1298
  // Best quality for complex tasks
1293
1299
  fallback: [
1294
1300
  "openai/gpt-5.2-codex",
1295
- "claude-opus-4",
1296
- "claude-sonnet-4",
1301
+ "anthropic/claude-opus-4.6",
1302
+ "anthropic/claude-sonnet-4.6",
1303
+ "google/gemini-3.1-pro-preview",
1304
+ // Newest Gemini
1297
1305
  "google/gemini-3-pro-preview",
1298
1306
  "moonshot/kimi-k2.5"
1299
1307
  ]
1300
1308
  },
1301
1309
  REASONING: {
1302
- primary: "claude-sonnet-4",
1310
+ primary: "anthropic/claude-sonnet-4.6",
1303
1311
  // $3/$15 - best for reasoning/instructions
1304
1312
  fallback: [
1305
- "claude-opus-4",
1306
- "claude-opus-4",
1313
+ "anthropic/claude-opus-4.6",
1314
+ "anthropic/claude-opus-4.6",
1307
1315
  "openai/o4-mini",
1308
1316
  // Newer and cheaper than o3 ($1.10 vs $2.00)
1309
1317
  "openai/o3",
@@ -1316,27 +1324,37 @@ var DEFAULT_ROUTING_CONFIG = {
1316
1324
  SIMPLE: {
1317
1325
  primary: "moonshot/kimi-k2.5",
1318
1326
  // Cheaper than Haiku ($0.5/$2.4 vs $1/$5), larger context
1319
- fallback: ["claude-haiku-4.5", "xai/grok-4-1-fast-non-reasoning", "openai/gpt-4o-mini"]
1327
+ fallback: [
1328
+ "anthropic/claude-haiku-4.5",
1329
+ "xai/grok-4-1-fast-non-reasoning",
1330
+ "openai/gpt-4o-mini"
1331
+ ]
1320
1332
  },
1321
1333
  MEDIUM: {
1322
1334
  primary: "xai/grok-code-fast-1",
1323
1335
  // Code specialist for agentic coding
1324
- fallback: ["moonshot/kimi-k2.5", "claude-haiku-4.5", "claude-sonnet-4"]
1336
+ fallback: ["moonshot/kimi-k2.5", "anthropic/claude-haiku-4.5", "claude-sonnet-4"]
1325
1337
  },
1326
1338
  COMPLEX: {
1327
- primary: "claude-sonnet-4",
1339
+ primary: "anthropic/claude-sonnet-4.6",
1328
1340
  fallback: [
1329
- "claude-opus-4",
1341
+ "anthropic/claude-opus-4.6",
1330
1342
  // Latest Opus - best agentic
1331
1343
  "openai/gpt-5.2",
1344
+ "google/gemini-3.1-pro-preview",
1345
+ // Newest Gemini
1332
1346
  "google/gemini-3-pro-preview",
1333
1347
  "xai/grok-4-0709"
1334
1348
  ]
1335
1349
  },
1336
1350
  REASONING: {
1337
- primary: "claude-sonnet-4",
1351
+ primary: "anthropic/claude-sonnet-4.6",
1338
1352
  // Strong tool use + reasoning for agentic tasks
1339
- fallback: ["claude-opus-4", "xai/grok-4-1-fast-reasoning", "deepseek/deepseek-reasoner"]
1353
+ fallback: [
1354
+ "anthropic/claude-opus-4.6",
1355
+ "xai/grok-4-1-fast-reasoning",
1356
+ "deepseek/deepseek-reasoner"
1357
+ ]
1340
1358
  }
1341
1359
  },
1342
1360
  overrides: {
@@ -1420,35 +1438,37 @@ function route(prompt, systemPrompt, maxOutputTokens, options) {
1420
1438
 
1421
1439
  // src/models.ts
1422
1440
  var MODEL_ALIASES = {
1423
- // Claude - short names (backend uses bare model names without anthropic/ prefix)
1424
- claude: "claude-sonnet-4",
1425
- sonnet: "claude-sonnet-4",
1426
- "sonnet-4.6": "claude-sonnet-4",
1427
- "sonnet-4-6": "claude-sonnet-4",
1428
- opus: "claude-opus-4",
1429
- "opus-4": "claude-opus-4",
1430
- haiku: "claude-haiku-4.5",
1441
+ // Claude - use newest versions (4.6)
1442
+ claude: "anthropic/claude-sonnet-4.6",
1443
+ sonnet: "anthropic/claude-sonnet-4.6",
1444
+ "sonnet-4": "anthropic/claude-sonnet-4.6",
1445
+ "sonnet-4.6": "anthropic/claude-sonnet-4.6",
1446
+ "sonnet-4-6": "anthropic/claude-sonnet-4.6",
1447
+ opus: "anthropic/claude-opus-4.6",
1448
+ "opus-4": "anthropic/claude-opus-4.6",
1449
+ "opus-4.6": "anthropic/claude-opus-4.6",
1450
+ "opus-4-6": "anthropic/claude-opus-4.6",
1451
+ haiku: "anthropic/claude-haiku-4.5",
1431
1452
  // Claude - provider/shortname patterns (common in agent frameworks)
1432
- "anthropic/sonnet": "claude-sonnet-4",
1433
- "anthropic/opus": "claude-opus-4",
1434
- "anthropic/haiku": "claude-haiku-4.5",
1435
- "anthropic/claude": "claude-sonnet-4",
1436
- // Backward compatibility - various formats all route to backend names
1437
- "anthropic/claude-sonnet-4": "claude-sonnet-4",
1438
- "anthropic/claude-sonnet-4-6": "claude-sonnet-4",
1439
- "anthropic/claude-sonnet-4.6": "claude-sonnet-4",
1440
- "anthropic/claude-opus-4": "claude-opus-4",
1441
- "anthropic/claude-opus-4-6": "claude-opus-4",
1442
- "anthropic/claude-opus-4.6": "claude-opus-4",
1443
- "anthropic/claude-haiku-4": "claude-haiku-4.5",
1444
- "anthropic/claude-haiku-4-5": "claude-haiku-4.5",
1445
- "anthropic/claude-haiku-4.5": "claude-haiku-4.5",
1453
+ "anthropic/sonnet": "anthropic/claude-sonnet-4.6",
1454
+ "anthropic/opus": "anthropic/claude-opus-4.6",
1455
+ "anthropic/haiku": "anthropic/claude-haiku-4.5",
1456
+ "anthropic/claude": "anthropic/claude-sonnet-4.6",
1457
+ // Backward compatibility - map all variants to 4.6
1458
+ "anthropic/claude-sonnet-4": "anthropic/claude-sonnet-4.6",
1459
+ "anthropic/claude-sonnet-4-6": "anthropic/claude-sonnet-4.6",
1460
+ "anthropic/claude-opus-4": "anthropic/claude-opus-4.6",
1461
+ "anthropic/claude-opus-4-6": "anthropic/claude-opus-4.6",
1462
+ "anthropic/claude-opus-4.5": "anthropic/claude-opus-4.6",
1463
+ "anthropic/claude-haiku-4": "anthropic/claude-haiku-4.5",
1464
+ "anthropic/claude-haiku-4-5": "anthropic/claude-haiku-4.5",
1446
1465
  // OpenAI
1447
1466
  gpt: "openai/gpt-4o",
1448
1467
  gpt4: "openai/gpt-4o",
1449
1468
  gpt5: "openai/gpt-5.2",
1450
1469
  codex: "openai/gpt-5.2-codex",
1451
1470
  mini: "openai/gpt-4o-mini",
1471
+ o1: "openai/o1",
1452
1472
  o3: "openai/o3",
1453
1473
  // DeepSeek
1454
1474
  deepseek: "deepseek/deepseek-chat",
@@ -1524,6 +1544,7 @@ var BLOCKRUN_MODELS = [
1524
1544
  {
1525
1545
  id: "openai/gpt-5.2",
1526
1546
  name: "GPT-5.2",
1547
+ version: "5.2",
1527
1548
  inputPrice: 1.75,
1528
1549
  outputPrice: 14,
1529
1550
  contextWindow: 4e5,
@@ -1535,6 +1556,7 @@ var BLOCKRUN_MODELS = [
1535
1556
  {
1536
1557
  id: "openai/gpt-5-mini",
1537
1558
  name: "GPT-5 Mini",
1559
+ version: "5.0",
1538
1560
  inputPrice: 0.25,
1539
1561
  outputPrice: 2,
1540
1562
  contextWindow: 2e5,
@@ -1543,6 +1565,7 @@ var BLOCKRUN_MODELS = [
1543
1565
  {
1544
1566
  id: "openai/gpt-5-nano",
1545
1567
  name: "GPT-5 Nano",
1568
+ version: "5.0",
1546
1569
  inputPrice: 0.05,
1547
1570
  outputPrice: 0.4,
1548
1571
  contextWindow: 128e3,
@@ -1551,6 +1574,7 @@ var BLOCKRUN_MODELS = [
1551
1574
  {
1552
1575
  id: "openai/gpt-5.2-pro",
1553
1576
  name: "GPT-5.2 Pro",
1577
+ version: "5.2",
1554
1578
  inputPrice: 21,
1555
1579
  outputPrice: 168,
1556
1580
  contextWindow: 4e5,
@@ -1561,8 +1585,9 @@ var BLOCKRUN_MODELS = [
1561
1585
  {
1562
1586
  id: "openai/gpt-5.2-codex",
1563
1587
  name: "GPT-5.2 Codex",
1564
- inputPrice: 2.5,
1565
- outputPrice: 12,
1588
+ version: "5.2",
1589
+ inputPrice: 1.75,
1590
+ outputPrice: 14,
1566
1591
  contextWindow: 128e3,
1567
1592
  maxOutput: 32e3,
1568
1593
  agentic: true
@@ -1571,6 +1596,7 @@ var BLOCKRUN_MODELS = [
1571
1596
  {
1572
1597
  id: "openai/gpt-4.1",
1573
1598
  name: "GPT-4.1",
1599
+ version: "4.1",
1574
1600
  inputPrice: 2,
1575
1601
  outputPrice: 8,
1576
1602
  contextWindow: 128e3,
@@ -1580,15 +1606,25 @@ var BLOCKRUN_MODELS = [
1580
1606
  {
1581
1607
  id: "openai/gpt-4.1-mini",
1582
1608
  name: "GPT-4.1 Mini",
1609
+ version: "4.1",
1583
1610
  inputPrice: 0.4,
1584
1611
  outputPrice: 1.6,
1585
1612
  contextWindow: 128e3,
1586
1613
  maxOutput: 16384
1587
1614
  },
1588
- // gpt-4.1-nano removed - replaced by gpt-5-nano
1615
+ {
1616
+ id: "openai/gpt-4.1-nano",
1617
+ name: "GPT-4.1 Nano",
1618
+ version: "4.1",
1619
+ inputPrice: 0.1,
1620
+ outputPrice: 0.4,
1621
+ contextWindow: 128e3,
1622
+ maxOutput: 16384
1623
+ },
1589
1624
  {
1590
1625
  id: "openai/gpt-4o",
1591
1626
  name: "GPT-4o",
1627
+ version: "4o",
1592
1628
  inputPrice: 2.5,
1593
1629
  outputPrice: 10,
1594
1630
  contextWindow: 128e3,
@@ -1599,15 +1635,37 @@ var BLOCKRUN_MODELS = [
1599
1635
  {
1600
1636
  id: "openai/gpt-4o-mini",
1601
1637
  name: "GPT-4o Mini",
1638
+ version: "4o-mini",
1602
1639
  inputPrice: 0.15,
1603
1640
  outputPrice: 0.6,
1604
1641
  contextWindow: 128e3,
1605
1642
  maxOutput: 16384
1606
1643
  },
1607
- // OpenAI O-series (Reasoning) - o1/o1-mini removed, replaced by o3/o4
1644
+ // OpenAI O-series (Reasoning)
1645
+ {
1646
+ id: "openai/o1",
1647
+ name: "o1",
1648
+ version: "1",
1649
+ inputPrice: 15,
1650
+ outputPrice: 60,
1651
+ contextWindow: 2e5,
1652
+ maxOutput: 1e5,
1653
+ reasoning: true
1654
+ },
1655
+ {
1656
+ id: "openai/o1-mini",
1657
+ name: "o1-mini",
1658
+ version: "1-mini",
1659
+ inputPrice: 1.1,
1660
+ outputPrice: 4.4,
1661
+ contextWindow: 128e3,
1662
+ maxOutput: 65536,
1663
+ reasoning: true
1664
+ },
1608
1665
  {
1609
1666
  id: "openai/o3",
1610
1667
  name: "o3",
1668
+ version: "3",
1611
1669
  inputPrice: 2,
1612
1670
  outputPrice: 8,
1613
1671
  contextWindow: 2e5,
@@ -1617,6 +1675,7 @@ var BLOCKRUN_MODELS = [
1617
1675
  {
1618
1676
  id: "openai/o3-mini",
1619
1677
  name: "o3-mini",
1678
+ version: "3-mini",
1620
1679
  inputPrice: 1.1,
1621
1680
  outputPrice: 4.4,
1622
1681
  contextWindow: 128e3,
@@ -1626,6 +1685,7 @@ var BLOCKRUN_MODELS = [
1626
1685
  {
1627
1686
  id: "openai/o4-mini",
1628
1687
  name: "o4-mini",
1688
+ version: "4-mini",
1629
1689
  inputPrice: 1.1,
1630
1690
  outputPrice: 4.4,
1631
1691
  contextWindow: 128e3,
@@ -1633,10 +1693,11 @@ var BLOCKRUN_MODELS = [
1633
1693
  reasoning: true
1634
1694
  },
1635
1695
  // Anthropic - all Claude models excel at agentic workflows
1636
- // Backend uses bare model names (claude-sonnet-4, not anthropic/claude-sonnet-4-6)
1696
+ // Use newest versions (4.6) with full provider prefix
1637
1697
  {
1638
- id: "claude-haiku-4.5",
1698
+ id: "anthropic/claude-haiku-4.5",
1639
1699
  name: "Claude Haiku 4.5",
1700
+ version: "4.5",
1640
1701
  inputPrice: 1,
1641
1702
  outputPrice: 5,
1642
1703
  contextWindow: 2e5,
@@ -1644,8 +1705,9 @@ var BLOCKRUN_MODELS = [
1644
1705
  agentic: true
1645
1706
  },
1646
1707
  {
1647
- id: "claude-sonnet-4",
1708
+ id: "anthropic/claude-sonnet-4.6",
1648
1709
  name: "Claude Sonnet 4.6",
1710
+ version: "4.6",
1649
1711
  inputPrice: 3,
1650
1712
  outputPrice: 15,
1651
1713
  contextWindow: 2e5,
@@ -1654,19 +1716,32 @@ var BLOCKRUN_MODELS = [
1654
1716
  agentic: true
1655
1717
  },
1656
1718
  {
1657
- id: "claude-opus-4",
1719
+ id: "anthropic/claude-opus-4.6",
1658
1720
  name: "Claude Opus 4.6",
1659
- inputPrice: 15,
1660
- outputPrice: 75,
1721
+ version: "4.6",
1722
+ inputPrice: 5,
1723
+ outputPrice: 25,
1661
1724
  contextWindow: 2e5,
1662
1725
  maxOutput: 32e3,
1663
1726
  reasoning: true,
1664
1727
  agentic: true
1665
1728
  },
1666
1729
  // Google
1730
+ {
1731
+ id: "google/gemini-3.1-pro-preview",
1732
+ name: "Gemini 3.1 Pro Preview",
1733
+ version: "3.1",
1734
+ inputPrice: 2,
1735
+ outputPrice: 12,
1736
+ contextWindow: 105e4,
1737
+ maxOutput: 65536,
1738
+ reasoning: true,
1739
+ vision: true
1740
+ },
1667
1741
  {
1668
1742
  id: "google/gemini-3-pro-preview",
1669
1743
  name: "Gemini 3 Pro Preview",
1744
+ version: "3.0",
1670
1745
  inputPrice: 2,
1671
1746
  outputPrice: 12,
1672
1747
  contextWindow: 105e4,
@@ -1674,9 +1749,20 @@ var BLOCKRUN_MODELS = [
1674
1749
  reasoning: true,
1675
1750
  vision: true
1676
1751
  },
1752
+ {
1753
+ id: "google/gemini-3-flash-preview",
1754
+ name: "Gemini 3 Flash Preview",
1755
+ version: "3.0",
1756
+ inputPrice: 0.5,
1757
+ outputPrice: 3,
1758
+ contextWindow: 1e6,
1759
+ maxOutput: 65536,
1760
+ vision: true
1761
+ },
1677
1762
  {
1678
1763
  id: "google/gemini-2.5-pro",
1679
1764
  name: "Gemini 2.5 Pro",
1765
+ version: "2.5",
1680
1766
  inputPrice: 1.25,
1681
1767
  outputPrice: 10,
1682
1768
  contextWindow: 105e4,
@@ -1687,8 +1773,18 @@ var BLOCKRUN_MODELS = [
1687
1773
  {
1688
1774
  id: "google/gemini-2.5-flash",
1689
1775
  name: "Gemini 2.5 Flash",
1690
- inputPrice: 0.15,
1691
- outputPrice: 0.6,
1776
+ version: "2.5",
1777
+ inputPrice: 0.3,
1778
+ outputPrice: 2.5,
1779
+ contextWindow: 1e6,
1780
+ maxOutput: 65536
1781
+ },
1782
+ {
1783
+ id: "google/gemini-2.5-flash-lite",
1784
+ name: "Gemini 2.5 Flash Lite",
1785
+ version: "2.5",
1786
+ inputPrice: 0.1,
1787
+ outputPrice: 0.4,
1692
1788
  contextWindow: 1e6,
1693
1789
  maxOutput: 65536
1694
1790
  },
@@ -1696,6 +1792,7 @@ var BLOCKRUN_MODELS = [
1696
1792
  {
1697
1793
  id: "deepseek/deepseek-chat",
1698
1794
  name: "DeepSeek V3.2 Chat",
1795
+ version: "3.2",
1699
1796
  inputPrice: 0.28,
1700
1797
  outputPrice: 0.42,
1701
1798
  contextWindow: 128e3,
@@ -1704,6 +1801,7 @@ var BLOCKRUN_MODELS = [
1704
1801
  {
1705
1802
  id: "deepseek/deepseek-reasoner",
1706
1803
  name: "DeepSeek V3.2 Reasoner",
1804
+ version: "3.2",
1707
1805
  inputPrice: 0.28,
1708
1806
  outputPrice: 0.42,
1709
1807
  contextWindow: 128e3,
@@ -1714,8 +1812,9 @@ var BLOCKRUN_MODELS = [
1714
1812
  {
1715
1813
  id: "moonshot/kimi-k2.5",
1716
1814
  name: "Kimi K2.5",
1717
- inputPrice: 0.5,
1718
- outputPrice: 2.4,
1815
+ version: "k2.5",
1816
+ inputPrice: 0.6,
1817
+ outputPrice: 3,
1719
1818
  contextWindow: 262144,
1720
1819
  maxOutput: 8192,
1721
1820
  reasoning: true,
@@ -1726,6 +1825,7 @@ var BLOCKRUN_MODELS = [
1726
1825
  {
1727
1826
  id: "xai/grok-3",
1728
1827
  name: "Grok 3",
1828
+ version: "3",
1729
1829
  inputPrice: 3,
1730
1830
  outputPrice: 15,
1731
1831
  contextWindow: 131072,
@@ -1736,6 +1836,7 @@ var BLOCKRUN_MODELS = [
1736
1836
  {
1737
1837
  id: "xai/grok-3-mini",
1738
1838
  name: "Grok 3 Mini",
1839
+ version: "3-mini",
1739
1840
  inputPrice: 0.3,
1740
1841
  outputPrice: 0.5,
1741
1842
  contextWindow: 131072,
@@ -1745,6 +1846,7 @@ var BLOCKRUN_MODELS = [
1745
1846
  {
1746
1847
  id: "xai/grok-4-fast-reasoning",
1747
1848
  name: "Grok 4 Fast Reasoning",
1849
+ version: "4",
1748
1850
  inputPrice: 0.2,
1749
1851
  outputPrice: 0.5,
1750
1852
  contextWindow: 131072,
@@ -1754,6 +1856,7 @@ var BLOCKRUN_MODELS = [
1754
1856
  {
1755
1857
  id: "xai/grok-4-fast-non-reasoning",
1756
1858
  name: "Grok 4 Fast",
1859
+ version: "4",
1757
1860
  inputPrice: 0.2,
1758
1861
  outputPrice: 0.5,
1759
1862
  contextWindow: 131072,
@@ -1762,6 +1865,7 @@ var BLOCKRUN_MODELS = [
1762
1865
  {
1763
1866
  id: "xai/grok-4-1-fast-reasoning",
1764
1867
  name: "Grok 4.1 Fast Reasoning",
1868
+ version: "4.1",
1765
1869
  inputPrice: 0.2,
1766
1870
  outputPrice: 0.5,
1767
1871
  contextWindow: 131072,
@@ -1771,6 +1875,7 @@ var BLOCKRUN_MODELS = [
1771
1875
  {
1772
1876
  id: "xai/grok-4-1-fast-non-reasoning",
1773
1877
  name: "Grok 4.1 Fast",
1878
+ version: "4.1",
1774
1879
  inputPrice: 0.2,
1775
1880
  outputPrice: 0.5,
1776
1881
  contextWindow: 131072,
@@ -1779,6 +1884,7 @@ var BLOCKRUN_MODELS = [
1779
1884
  {
1780
1885
  id: "xai/grok-code-fast-1",
1781
1886
  name: "Grok Code Fast",
1887
+ version: "1",
1782
1888
  inputPrice: 0.2,
1783
1889
  outputPrice: 1.5,
1784
1890
  contextWindow: 131072,
@@ -1789,17 +1895,28 @@ var BLOCKRUN_MODELS = [
1789
1895
  {
1790
1896
  id: "xai/grok-4-0709",
1791
1897
  name: "Grok 4 (0709)",
1898
+ version: "4-0709",
1792
1899
  inputPrice: 0.2,
1793
1900
  outputPrice: 1.5,
1794
1901
  contextWindow: 131072,
1795
1902
  maxOutput: 16384,
1796
1903
  reasoning: true
1797
1904
  },
1798
- // grok-2-vision removed - old, 0 transactions
1905
+ {
1906
+ id: "xai/grok-2-vision",
1907
+ name: "Grok 2 Vision",
1908
+ version: "2",
1909
+ inputPrice: 2,
1910
+ outputPrice: 10,
1911
+ contextWindow: 131072,
1912
+ maxOutput: 16384,
1913
+ vision: true
1914
+ },
1799
1915
  // MiniMax
1800
1916
  {
1801
1917
  id: "minimax/minimax-m2.5",
1802
1918
  name: "MiniMax M2.5",
1919
+ version: "m2.5",
1803
1920
  inputPrice: 0.3,
1804
1921
  outputPrice: 1.2,
1805
1922
  contextWindow: 204800,
@@ -1811,6 +1928,7 @@ var BLOCKRUN_MODELS = [
1811
1928
  {
1812
1929
  id: "nvidia/gpt-oss-120b",
1813
1930
  name: "NVIDIA GPT-OSS 120B",
1931
+ version: "120b",
1814
1932
  inputPrice: 0,
1815
1933
  outputPrice: 0,
1816
1934
  contextWindow: 128e3,
@@ -1819,6 +1937,7 @@ var BLOCKRUN_MODELS = [
1819
1937
  {
1820
1938
  id: "nvidia/kimi-k2.5",
1821
1939
  name: "NVIDIA Kimi K2.5",
1940
+ version: "k2.5",
1822
1941
  inputPrice: 0.55,
1823
1942
  outputPrice: 2.5,
1824
1943
  contextWindow: 262144,
@@ -5124,6 +5243,282 @@ async function resolveOrGenerateWalletKey() {
5124
5243
  return { key, address, source: "generated" };
5125
5244
  }
5126
5245
 
5246
+ // src/doctor.ts
5247
+ import { platform, arch, freemem, totalmem } from "os";
5248
+ function formatBytes(bytes) {
5249
+ const gb = bytes / (1024 * 1024 * 1024);
5250
+ return `${gb.toFixed(1)}GB`;
5251
+ }
5252
+ function green(text) {
5253
+ return `\x1B[32m\u2713\x1B[0m ${text}`;
5254
+ }
5255
+ function red(text) {
5256
+ return `\x1B[31m\u2717\x1B[0m ${text}`;
5257
+ }
5258
+ function yellow(text) {
5259
+ return `\x1B[33m\u26A0\x1B[0m ${text}`;
5260
+ }
5261
+ function collectSystemInfo() {
5262
+ return {
5263
+ os: `${platform()} ${arch()}`,
5264
+ arch: arch(),
5265
+ nodeVersion: process.version,
5266
+ memoryFree: formatBytes(freemem()),
5267
+ memoryTotal: formatBytes(totalmem())
5268
+ };
5269
+ }
5270
+ async function collectWalletInfo() {
5271
+ try {
5272
+ const { key, address, source } = await resolveOrGenerateWalletKey();
5273
+ if (!key || !address) {
5274
+ return {
5275
+ exists: false,
5276
+ valid: false,
5277
+ address: null,
5278
+ balance: null,
5279
+ isLow: false,
5280
+ isEmpty: true,
5281
+ source: null
5282
+ };
5283
+ }
5284
+ const monitor = new BalanceMonitor(address);
5285
+ try {
5286
+ const balanceInfo = await monitor.checkBalance();
5287
+ return {
5288
+ exists: true,
5289
+ valid: true,
5290
+ address,
5291
+ balance: balanceInfo.balanceUSD,
5292
+ isLow: balanceInfo.isLow,
5293
+ isEmpty: balanceInfo.isEmpty,
5294
+ source
5295
+ };
5296
+ } catch {
5297
+ return {
5298
+ exists: true,
5299
+ valid: true,
5300
+ address,
5301
+ balance: null,
5302
+ isLow: false,
5303
+ isEmpty: false,
5304
+ source
5305
+ };
5306
+ }
5307
+ } catch {
5308
+ return {
5309
+ exists: false,
5310
+ valid: false,
5311
+ address: null,
5312
+ balance: null,
5313
+ isLow: false,
5314
+ isEmpty: true,
5315
+ source: null
5316
+ };
5317
+ }
5318
+ }
5319
+ async function collectNetworkInfo() {
5320
+ const port = getProxyPort();
5321
+ let blockrunReachable = false;
5322
+ let blockrunLatency = null;
5323
+ try {
5324
+ const start = Date.now();
5325
+ const response = await fetch("https://blockrun.ai/api/v1/models", {
5326
+ method: "GET",
5327
+ signal: AbortSignal.timeout(1e4)
5328
+ });
5329
+ blockrunLatency = Date.now() - start;
5330
+ blockrunReachable = response.ok || response.status === 402;
5331
+ } catch {
5332
+ blockrunReachable = false;
5333
+ }
5334
+ let proxyRunning = false;
5335
+ try {
5336
+ const response = await fetch(`http://127.0.0.1:${port}/health`, {
5337
+ method: "GET",
5338
+ signal: AbortSignal.timeout(3e3)
5339
+ });
5340
+ proxyRunning = response.ok;
5341
+ } catch {
5342
+ proxyRunning = false;
5343
+ }
5344
+ return {
5345
+ blockrunApi: { reachable: blockrunReachable, latencyMs: blockrunLatency },
5346
+ localProxy: { running: proxyRunning, port }
5347
+ };
5348
+ }
5349
+ async function collectLogInfo() {
5350
+ try {
5351
+ const stats = await getStats(1);
5352
+ return {
5353
+ requestsLast24h: stats.totalRequests,
5354
+ costLast24h: `$${stats.totalCost.toFixed(4)}`,
5355
+ errorsFound: 0
5356
+ // TODO: parse error logs
5357
+ };
5358
+ } catch {
5359
+ return {
5360
+ requestsLast24h: 0,
5361
+ costLast24h: "$0.00",
5362
+ errorsFound: 0
5363
+ };
5364
+ }
5365
+ }
5366
+ function identifyIssues(result) {
5367
+ const issues = [];
5368
+ if (!result.wallet.exists) {
5369
+ issues.push("No wallet found");
5370
+ }
5371
+ if (result.wallet.isEmpty) {
5372
+ issues.push("Wallet is empty - need to fund with USDC on Base");
5373
+ } else if (result.wallet.isLow) {
5374
+ issues.push("Wallet balance is low (< $1.00)");
5375
+ }
5376
+ if (!result.network.blockrunApi.reachable) {
5377
+ issues.push("Cannot reach BlockRun API - check internet connection");
5378
+ }
5379
+ if (!result.network.localProxy.running) {
5380
+ issues.push(`Local proxy not running on port ${result.network.localProxy.port}`);
5381
+ }
5382
+ return issues;
5383
+ }
5384
+ function printDiagnostics(result) {
5385
+ console.log("\n\u{1F50D} Collecting diagnostics...\n");
5386
+ console.log("System");
5387
+ console.log(` ${green(`OS: ${result.system.os}`)}`);
5388
+ console.log(` ${green(`Node: ${result.system.nodeVersion}`)}`);
5389
+ console.log(` ${green(`Memory: ${result.system.memoryFree} free / ${result.system.memoryTotal}`)}`);
5390
+ console.log("\nWallet");
5391
+ if (result.wallet.exists && result.wallet.valid) {
5392
+ console.log(` ${green(`Key: ${WALLET_FILE} (${result.wallet.source})`)}`);
5393
+ console.log(` ${green(`Address: ${result.wallet.address}`)}`);
5394
+ if (result.wallet.isEmpty) {
5395
+ console.log(` ${red(`Balance: $0.00 - NEED TO FUND!`)}`);
5396
+ } else if (result.wallet.isLow) {
5397
+ console.log(` ${yellow(`Balance: ${result.wallet.balance} (low)`)}`);
5398
+ } else if (result.wallet.balance) {
5399
+ console.log(` ${green(`Balance: ${result.wallet.balance}`)}`);
5400
+ } else {
5401
+ console.log(` ${yellow(`Balance: checking...`)}`);
5402
+ }
5403
+ } else {
5404
+ console.log(` ${red("No wallet found")}`);
5405
+ }
5406
+ console.log("\nNetwork");
5407
+ if (result.network.blockrunApi.reachable) {
5408
+ console.log(` ${green(`BlockRun API: reachable (${result.network.blockrunApi.latencyMs}ms)`)}`);
5409
+ } else {
5410
+ console.log(` ${red("BlockRun API: unreachable")}`);
5411
+ }
5412
+ if (result.network.localProxy.running) {
5413
+ console.log(` ${green(`Local proxy: running on :${result.network.localProxy.port}`)}`);
5414
+ } else {
5415
+ console.log(` ${red(`Local proxy: not running on :${result.network.localProxy.port}`)}`);
5416
+ }
5417
+ console.log("\nLogs");
5418
+ console.log(` ${green(`Last 24h: ${result.logs.requestsLast24h} requests, ${result.logs.costLast24h} spent`)}`);
5419
+ if (result.logs.errorsFound > 0) {
5420
+ console.log(` ${yellow(`${result.logs.errorsFound} errors found in logs`)}`);
5421
+ }
5422
+ if (result.issues.length > 0) {
5423
+ console.log("\n\u26A0\uFE0F Issues Found:");
5424
+ for (const issue of result.issues) {
5425
+ console.log(` \u2022 ${issue}`);
5426
+ }
5427
+ }
5428
+ }
5429
+ async function analyzeWithAI(diagnostics, userQuestion) {
5430
+ if (diagnostics.wallet.isEmpty) {
5431
+ console.log("\n\u{1F4B3} Wallet is empty - cannot call AI for analysis.");
5432
+ console.log(` Fund your wallet with USDC on Base: ${diagnostics.wallet.address}`);
5433
+ console.log(" Get USDC: https://www.coinbase.com/price/usd-coin");
5434
+ console.log(" Bridge to Base: https://bridge.base.org\n");
5435
+ return;
5436
+ }
5437
+ console.log("\n\u{1F4E4} Sending to Claude Opus 4.6...\n");
5438
+ try {
5439
+ const { key } = await resolveOrGenerateWalletKey();
5440
+ const { fetch: paymentFetch } = createPaymentFetch(key);
5441
+ const response = await paymentFetch(
5442
+ "https://blockrun.ai/api/v1/chat/completions",
5443
+ {
5444
+ method: "POST",
5445
+ headers: { "Content-Type": "application/json" },
5446
+ body: JSON.stringify({
5447
+ model: "anthropic/claude-opus-4.6",
5448
+ stream: false,
5449
+ messages: [
5450
+ {
5451
+ role: "system",
5452
+ content: `You are a technical support expert for BlockRun and ClawRouter.
5453
+ Analyze the diagnostics and:
5454
+ 1. Identify the root cause of any issues
5455
+ 2. Provide specific, actionable fix commands (bash)
5456
+ 3. Explain why the issue occurred briefly
5457
+ 4. Be concise but thorough
5458
+ 5. Format commands in code blocks`
5459
+ },
5460
+ {
5461
+ role: "user",
5462
+ content: userQuestion ? `Here are my system diagnostics:
5463
+
5464
+ ${JSON.stringify(diagnostics, null, 2)}
5465
+
5466
+ User's question: ${userQuestion}` : `Here are my system diagnostics:
5467
+
5468
+ ${JSON.stringify(diagnostics, null, 2)}
5469
+
5470
+ Please analyze and help me fix any issues.`
5471
+ }
5472
+ ],
5473
+ max_tokens: 1e3
5474
+ })
5475
+ },
5476
+ void 0
5477
+ );
5478
+ if (!response.ok) {
5479
+ const text = await response.text();
5480
+ console.log(`Error: ${response.status} - ${text}`);
5481
+ return;
5482
+ }
5483
+ const data = await response.json();
5484
+ const content = data.choices?.[0]?.message?.content;
5485
+ if (content) {
5486
+ console.log("\u{1F916} AI Analysis:\n");
5487
+ console.log(content);
5488
+ console.log();
5489
+ } else {
5490
+ console.log("Error: No response from AI");
5491
+ }
5492
+ } catch (err) {
5493
+ console.log(`
5494
+ Error calling AI: ${err instanceof Error ? err.message : String(err)}`);
5495
+ console.log("Try again or check your wallet balance.\n");
5496
+ }
5497
+ }
5498
+ async function runDoctor(userQuestion) {
5499
+ console.log(`
5500
+ \u{1FA7A} BlockRun Doctor v${VERSION}
5501
+ `);
5502
+ const [system, wallet, network, logs] = await Promise.all([
5503
+ collectSystemInfo(),
5504
+ collectWalletInfo(),
5505
+ collectNetworkInfo(),
5506
+ collectLogInfo()
5507
+ ]);
5508
+ const result = {
5509
+ version: VERSION,
5510
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
5511
+ system,
5512
+ wallet,
5513
+ network,
5514
+ logs,
5515
+ issues: []
5516
+ };
5517
+ result.issues = identifyIssues(result);
5518
+ printDiagnostics(result);
5519
+ await analyzeWithAI(result, userQuestion);
5520
+ }
5521
+
5127
5522
  // src/cli.ts
5128
5523
  function printHelp() {
5129
5524
  console.log(`
@@ -5131,12 +5526,17 @@ ClawRouter v${VERSION} - Smart LLM Router
5131
5526
 
5132
5527
  Usage:
5133
5528
  clawrouter [options]
5529
+ clawrouter doctor Run AI-powered diagnostics
5134
5530
 
5135
5531
  Options:
5136
5532
  --version, -v Show version number
5137
5533
  --help, -h Show this help message
5138
5534
  --port <number> Port to listen on (default: ${getProxyPort()})
5139
5535
 
5536
+ Commands:
5537
+ doctor [question] Diagnose issues and get AI-powered fix suggestions
5538
+ Optional: Add your question for targeted help
5539
+
5140
5540
  Examples:
5141
5541
  # Start standalone proxy (survives gateway restarts)
5142
5542
  npx @blockrun/clawrouter
@@ -5144,6 +5544,12 @@ Examples:
5144
5544
  # Start on custom port
5145
5545
  npx @blockrun/clawrouter --port 9000
5146
5546
 
5547
+ # Run diagnostics when something isn't working
5548
+ npx @blockrun/clawrouter doctor
5549
+
5550
+ # Ask a specific question
5551
+ npx @blockrun/clawrouter doctor "why is my request failing?"
5552
+
5147
5553
  # Production deployment with PM2
5148
5554
  pm2 start "npx @blockrun/clawrouter" --name clawrouter
5149
5555
 
@@ -5155,13 +5561,15 @@ For more info: https://github.com/BlockRunAI/ClawRouter
5155
5561
  `);
5156
5562
  }
5157
5563
  function parseArgs(args) {
5158
- const result = { version: false, help: false, port: void 0 };
5564
+ const result = { version: false, help: false, doctor: false, port: void 0 };
5159
5565
  for (let i = 0; i < args.length; i++) {
5160
5566
  const arg = args[i];
5161
5567
  if (arg === "--version" || arg === "-v") {
5162
5568
  result.version = true;
5163
5569
  } else if (arg === "--help" || arg === "-h") {
5164
5570
  result.help = true;
5571
+ } else if (arg === "doctor" || arg === "--doctor") {
5572
+ result.doctor = true;
5165
5573
  } else if (arg === "--port" && args[i + 1]) {
5166
5574
  result.port = parseInt(args[i + 1], 10);
5167
5575
  i++;
@@ -5179,6 +5587,13 @@ async function main() {
5179
5587
  printHelp();
5180
5588
  process.exit(0);
5181
5589
  }
5590
+ if (args.doctor) {
5591
+ const rawArgs = process.argv.slice(2);
5592
+ const doctorIndex = rawArgs.findIndex((a) => a === "doctor" || a === "--doctor");
5593
+ const userQuestion = rawArgs.slice(doctorIndex + 1).join(" ").trim() || void 0;
5594
+ await runDoctor(userQuestion);
5595
+ process.exit(0);
5596
+ }
5182
5597
  const { key: walletKey, address, source } = await resolveOrGenerateWalletKey();
5183
5598
  if (source === "generated") {
5184
5599
  console.log(`[ClawRouter] Generated new wallet: ${address}`);