@blockrun/clawrouter 0.9.32 → 0.9.34
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/README.md +157 -369
- package/dist/cli.js +26 -37
- package/dist/cli.js.map +1 -1
- package/dist/index.js +28 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,8 @@ var MODEL_ALIASES = {
|
|
|
3
3
|
// Claude - short names (backend uses bare model names without anthropic/ prefix)
|
|
4
4
|
claude: "claude-sonnet-4",
|
|
5
5
|
sonnet: "claude-sonnet-4",
|
|
6
|
+
"sonnet-4.6": "claude-sonnet-4",
|
|
7
|
+
"sonnet-4-6": "claude-sonnet-4",
|
|
6
8
|
opus: "claude-opus-4",
|
|
7
9
|
"opus-4": "claude-opus-4",
|
|
8
10
|
haiku: "claude-haiku-4.5",
|
|
@@ -1735,44 +1737,27 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
1735
1737
|
]
|
|
1736
1738
|
}
|
|
1737
1739
|
},
|
|
1738
|
-
// Eco tier configs -
|
|
1740
|
+
// Eco tier configs - absolute cheapest (blockrun/eco)
|
|
1739
1741
|
ecoTiers: {
|
|
1740
1742
|
SIMPLE: {
|
|
1741
|
-
primary: "
|
|
1742
|
-
// $0.
|
|
1743
|
-
fallback: [
|
|
1744
|
-
"moonshot/kimi-k2.5",
|
|
1745
|
-
"nvidia/gpt-oss-120b",
|
|
1746
|
-
"deepseek/deepseek-chat",
|
|
1747
|
-
"google/gemini-2.5-flash"
|
|
1748
|
-
]
|
|
1743
|
+
primary: "nvidia/gpt-oss-120b",
|
|
1744
|
+
// FREE! $0.00/$0.00
|
|
1745
|
+
fallback: ["google/gemini-2.5-flash", "deepseek/deepseek-chat", "minimax/minimax-m2.5"]
|
|
1749
1746
|
},
|
|
1750
1747
|
MEDIUM: {
|
|
1751
|
-
primary: "
|
|
1752
|
-
// $0.
|
|
1753
|
-
fallback: [
|
|
1754
|
-
"minimax/minimax-m2.5",
|
|
1755
|
-
// $0.30/$1.20 - cheap with reasoning
|
|
1756
|
-
"xai/grok-code-fast-1",
|
|
1757
|
-
"google/gemini-2.5-flash",
|
|
1758
|
-
"moonshot/kimi-k2.5"
|
|
1759
|
-
]
|
|
1748
|
+
primary: "google/gemini-2.5-flash",
|
|
1749
|
+
// $0.15/$0.60 - cheapest capable
|
|
1750
|
+
fallback: ["deepseek/deepseek-chat", "nvidia/gpt-oss-120b", "minimax/minimax-m2.5"]
|
|
1760
1751
|
},
|
|
1761
1752
|
COMPLEX: {
|
|
1762
|
-
primary: "
|
|
1763
|
-
// $0.
|
|
1764
|
-
fallback: [
|
|
1765
|
-
"minimax/minimax-m2.5",
|
|
1766
|
-
// $0.30/$1.20 - cheap with reasoning
|
|
1767
|
-
"deepseek/deepseek-chat",
|
|
1768
|
-
"google/gemini-2.5-flash",
|
|
1769
|
-
"openai/gpt-4o-mini"
|
|
1770
|
-
]
|
|
1753
|
+
primary: "google/gemini-2.5-flash",
|
|
1754
|
+
// $0.15/$0.60 - 1M context handles complexity
|
|
1755
|
+
fallback: ["deepseek/deepseek-chat", "xai/grok-4-0709", "minimax/minimax-m2.5"]
|
|
1771
1756
|
},
|
|
1772
1757
|
REASONING: {
|
|
1773
|
-
primary: "
|
|
1774
|
-
// $0.
|
|
1775
|
-
fallback: ["deepseek/deepseek-reasoner", "
|
|
1758
|
+
primary: "xai/grok-4-1-fast-reasoning",
|
|
1759
|
+
// $0.20/$0.50 - was MORE expensive than AUTO!
|
|
1760
|
+
fallback: ["deepseek/deepseek-reasoner", "minimax/minimax-m2.5"]
|
|
1776
1761
|
}
|
|
1777
1762
|
},
|
|
1778
1763
|
// Premium tier configs - best quality (blockrun/premium)
|
|
@@ -3583,7 +3568,7 @@ async function checkForUpdates() {
|
|
|
3583
3568
|
// src/config.ts
|
|
3584
3569
|
var DEFAULT_PORT = 8402;
|
|
3585
3570
|
var PROXY_PORT = (() => {
|
|
3586
|
-
const envPort = process
|
|
3571
|
+
const envPort = process["env"].BLOCKRUN_PROXY_PORT;
|
|
3587
3572
|
if (envPort) {
|
|
3588
3573
|
const parsed = parseInt(envPort, 10);
|
|
3589
3574
|
if (!isNaN(parsed) && parsed > 0 && parsed < 65536) {
|
|
@@ -4631,10 +4616,12 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
4631
4616
|
console.log(
|
|
4632
4617
|
`[ClawRouter] Received model: "${parsed.model}" -> normalized: "${normalizedModel}"${wasAlias ? ` -> alias: "${resolvedModel}"` : ""}${routingProfile ? `, profile: ${routingProfile}` : ""}`
|
|
4633
4618
|
);
|
|
4634
|
-
if (
|
|
4635
|
-
parsed.model
|
|
4619
|
+
if (!isRoutingProfile) {
|
|
4620
|
+
if (parsed.model !== resolvedModel) {
|
|
4621
|
+
parsed.model = resolvedModel;
|
|
4622
|
+
bodyModified = true;
|
|
4623
|
+
}
|
|
4636
4624
|
modelId = resolvedModel;
|
|
4637
|
-
bodyModified = true;
|
|
4638
4625
|
}
|
|
4639
4626
|
if (isRoutingProfile) {
|
|
4640
4627
|
if (routingProfile === "free") {
|
|
@@ -5144,9 +5131,11 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5144
5131
|
body: responseBody,
|
|
5145
5132
|
status: upstream.status,
|
|
5146
5133
|
headers: responseHeaders,
|
|
5147
|
-
model:
|
|
5134
|
+
model: actualModelUsed
|
|
5148
5135
|
});
|
|
5149
|
-
console.log(
|
|
5136
|
+
console.log(
|
|
5137
|
+
`[ClawRouter] Cached response for ${actualModelUsed} (${responseBody.length} bytes)`
|
|
5138
|
+
);
|
|
5150
5139
|
}
|
|
5151
5140
|
try {
|
|
5152
5141
|
const rspJson = JSON.parse(responseBody.toString());
|
|
@@ -5255,7 +5244,7 @@ async function resolveOrGenerateWalletKey() {
|
|
|
5255
5244
|
const account = privateKeyToAccount3(saved);
|
|
5256
5245
|
return { key: saved, address: account.address, source: "saved" };
|
|
5257
5246
|
}
|
|
5258
|
-
const envKey = process
|
|
5247
|
+
const envKey = process["env"].BLOCKRUN_WALLET_KEY;
|
|
5259
5248
|
if (typeof envKey === "string" && envKey.startsWith("0x") && envKey.length === 66) {
|
|
5260
5249
|
const account = privateKeyToAccount3(envKey);
|
|
5261
5250
|
return { key: envKey, address: account.address, source: "env" };
|
|
@@ -5476,7 +5465,7 @@ function injectModelsConfig(logger) {
|
|
|
5476
5465
|
{ id: "eco", alias: "eco" },
|
|
5477
5466
|
{ id: "premium", alias: "premium" },
|
|
5478
5467
|
{ id: "free", alias: "free" },
|
|
5479
|
-
{ id: "sonnet", alias: "sonnet" },
|
|
5468
|
+
{ id: "sonnet", alias: "sonnet-4.6" },
|
|
5480
5469
|
{ id: "opus", alias: "opus" },
|
|
5481
5470
|
{ id: "haiku", alias: "haiku" },
|
|
5482
5471
|
{ id: "gpt5", alias: "gpt5" },
|
|
@@ -5753,7 +5742,7 @@ var plugin = {
|
|
|
5753
5742
|
description: "Smart LLM router \u2014 30+ models, x402 micropayments, 78% cost savings",
|
|
5754
5743
|
version: VERSION,
|
|
5755
5744
|
async register(api) {
|
|
5756
|
-
const isDisabled = process
|
|
5745
|
+
const isDisabled = process["env"].CLAWROUTER_DISABLED === "true" || process["env"].CLAWROUTER_DISABLED === "1";
|
|
5757
5746
|
if (isDisabled) {
|
|
5758
5747
|
api.logger.info("ClawRouter disabled (CLAWROUTER_DISABLED=true). Using default routing.");
|
|
5759
5748
|
return;
|