@blockrun/clawrouter 0.12.77 → 0.12.79
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 +8 -9
- package/dist/cli.js +14 -144
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +27 -146
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/reinstall.sh +16 -6
- package/scripts/update.sh +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -183,12 +183,12 @@ type RoutingDecision = {
|
|
|
183
183
|
/** Which tier configs were used (auto/eco/premium/agentic) — avoids re-derivation in proxy */
|
|
184
184
|
tierConfigs?: Record<Tier, TierConfig>;
|
|
185
185
|
/** Which routing profile was applied */
|
|
186
|
-
profile?: "auto" | "eco" | "premium" | "agentic"
|
|
186
|
+
profile?: "auto" | "eco" | "premium" | "agentic";
|
|
187
187
|
};
|
|
188
188
|
type RouterOptions = {
|
|
189
189
|
config: RoutingConfig;
|
|
190
190
|
modelPricing: Map<string, ModelPricing>;
|
|
191
|
-
routingProfile?: "
|
|
191
|
+
routingProfile?: "eco" | "auto" | "premium";
|
|
192
192
|
hasTools?: boolean;
|
|
193
193
|
};
|
|
194
194
|
type TierConfig = {
|
|
@@ -250,8 +250,6 @@ type RoutingConfig = {
|
|
|
250
250
|
ecoTiers?: Record<Tier, TierConfig>;
|
|
251
251
|
/** Tier configs for premium profile - best quality (blockrun/premium) */
|
|
252
252
|
premiumTiers?: Record<Tier, TierConfig>;
|
|
253
|
-
/** Tier configs for free profile - NVIDIA free models only (blockrun/free) */
|
|
254
|
-
freeTiers?: Record<Tier, TierConfig>;
|
|
255
253
|
overrides: OverridesConfig;
|
|
256
254
|
};
|
|
257
255
|
|
package/dist/index.js
CHANGED
|
@@ -32935,10 +32935,12 @@ var MODEL_ALIASES = {
|
|
|
32935
32935
|
glm: "zai/glm-5",
|
|
32936
32936
|
"glm-5": "zai/glm-5",
|
|
32937
32937
|
"glm-5-turbo": "zai/glm-5-turbo",
|
|
32938
|
+
// Free alias — points to strongest free model
|
|
32939
|
+
free: "nvidia/nemotron-ultra-253b",
|
|
32938
32940
|
// Routing profile aliases (common variations)
|
|
32939
32941
|
"auto-router": "auto",
|
|
32940
32942
|
router: "auto"
|
|
32941
|
-
// Note: auto,
|
|
32943
|
+
// Note: auto, eco, premium are virtual routing profiles registered in BLOCKRUN_MODELS
|
|
32942
32944
|
// They don't need aliases since they're already top-level model IDs
|
|
32943
32945
|
};
|
|
32944
32946
|
function resolveModelAlias(model) {
|
|
@@ -32971,14 +32973,6 @@ var BLOCKRUN_MODELS = [
|
|
|
32971
32973
|
contextWindow: 105e4,
|
|
32972
32974
|
maxOutput: 128e3
|
|
32973
32975
|
},
|
|
32974
|
-
{
|
|
32975
|
-
id: "free",
|
|
32976
|
-
name: "Free (Smart Router - 11 NVIDIA Models)",
|
|
32977
|
-
inputPrice: 0,
|
|
32978
|
-
outputPrice: 0,
|
|
32979
|
-
contextWindow: 131072,
|
|
32980
|
-
maxOutput: 16384
|
|
32981
|
-
},
|
|
32982
32976
|
{
|
|
32983
32977
|
id: "eco",
|
|
32984
32978
|
name: "Eco (Smart Router - Cost Optimized)",
|
|
@@ -43717,11 +43711,7 @@ var RulesStrategy = class {
|
|
|
43717
43711
|
let tierConfigs;
|
|
43718
43712
|
let profileSuffix;
|
|
43719
43713
|
let profile;
|
|
43720
|
-
if (routingProfile === "
|
|
43721
|
-
tierConfigs = config.freeTiers;
|
|
43722
|
-
profileSuffix = " | free";
|
|
43723
|
-
profile = "free";
|
|
43724
|
-
} else if (routingProfile === "eco" && config.ecoTiers) {
|
|
43714
|
+
if (routingProfile === "eco" && config.ecoTiers) {
|
|
43725
43715
|
tierConfigs = config.ecoTiers;
|
|
43726
43716
|
profileSuffix = " | eco";
|
|
43727
43717
|
profile = "eco";
|
|
@@ -44910,7 +44900,7 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
44910
44900
|
]
|
|
44911
44901
|
}
|
|
44912
44902
|
},
|
|
44913
|
-
// Eco tier configs - absolute cheapest
|
|
44903
|
+
// Eco tier configs - absolute cheapest (blockrun/eco)
|
|
44914
44904
|
ecoTiers: {
|
|
44915
44905
|
SIMPLE: {
|
|
44916
44906
|
primary: "nvidia/gpt-oss-120b",
|
|
@@ -44929,13 +44919,9 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
44929
44919
|
]
|
|
44930
44920
|
},
|
|
44931
44921
|
MEDIUM: {
|
|
44932
|
-
primary: "
|
|
44933
|
-
//
|
|
44922
|
+
primary: "google/gemini-3.1-flash-lite",
|
|
44923
|
+
// $0.25/$1.50 — newest flash-lite
|
|
44934
44924
|
fallback: [
|
|
44935
|
-
"nvidia/gpt-oss-120b",
|
|
44936
|
-
// FREE fallback
|
|
44937
|
-
"google/gemini-3.1-flash-lite",
|
|
44938
|
-
// $0.25/$1.50
|
|
44939
44925
|
"openai/gpt-5.4-nano",
|
|
44940
44926
|
// $0.20/$1.25
|
|
44941
44927
|
"google/gemini-2.5-flash-lite",
|
|
@@ -44945,15 +44931,9 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
44945
44931
|
]
|
|
44946
44932
|
},
|
|
44947
44933
|
COMPLEX: {
|
|
44948
|
-
primary: "
|
|
44949
|
-
//
|
|
44934
|
+
primary: "google/gemini-3.1-flash-lite",
|
|
44935
|
+
// $0.25/$1.50
|
|
44950
44936
|
fallback: [
|
|
44951
|
-
"nvidia/mistral-large-3-675b",
|
|
44952
|
-
// FREE — 675B brute-force
|
|
44953
|
-
"nvidia/deepseek-v3.2",
|
|
44954
|
-
// FREE
|
|
44955
|
-
"google/gemini-3.1-flash-lite",
|
|
44956
|
-
// $0.25/$1.50
|
|
44957
44937
|
"google/gemini-2.5-flash-lite",
|
|
44958
44938
|
"xai/grok-4-0709",
|
|
44959
44939
|
"google/gemini-2.5-flash",
|
|
@@ -44963,12 +44943,7 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
44963
44943
|
REASONING: {
|
|
44964
44944
|
primary: "xai/grok-4-1-fast-reasoning",
|
|
44965
44945
|
// $0.20/$0.50
|
|
44966
|
-
fallback: [
|
|
44967
|
-
"xai/grok-4-fast-reasoning",
|
|
44968
|
-
"nvidia/nemotron-ultra-253b",
|
|
44969
|
-
// FREE reasoning fallback
|
|
44970
|
-
"deepseek/deepseek-reasoner"
|
|
44971
|
-
]
|
|
44946
|
+
fallback: ["xai/grok-4-fast-reasoning", "deepseek/deepseek-reasoner"]
|
|
44972
44947
|
}
|
|
44973
44948
|
},
|
|
44974
44949
|
// Premium tier configs - best quality (blockrun/premium)
|
|
@@ -45082,73 +45057,6 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
45082
45057
|
]
|
|
45083
45058
|
}
|
|
45084
45059
|
},
|
|
45085
|
-
// Free tier configs - NVIDIA free models, smart-routed by task type (blockrun/free)
|
|
45086
|
-
freeTiers: {
|
|
45087
|
-
SIMPLE: {
|
|
45088
|
-
primary: "nvidia/gpt-oss-20b",
|
|
45089
|
-
// Fastest: small 20B for simple tasks
|
|
45090
|
-
fallback: [
|
|
45091
|
-
"nvidia/gpt-oss-120b",
|
|
45092
|
-
// Solid general-purpose
|
|
45093
|
-
"nvidia/nemotron-super-49b",
|
|
45094
|
-
// Thinking mode
|
|
45095
|
-
"nvidia/llama-4-maverick",
|
|
45096
|
-
// MoE broad coverage
|
|
45097
|
-
"nvidia/glm-4.7"
|
|
45098
|
-
// Thinking mode
|
|
45099
|
-
]
|
|
45100
|
-
},
|
|
45101
|
-
MEDIUM: {
|
|
45102
|
-
primary: "nvidia/deepseek-v3.2",
|
|
45103
|
-
// DeepSeek V3.2 quality, zero cost
|
|
45104
|
-
fallback: [
|
|
45105
|
-
"nvidia/gpt-oss-120b",
|
|
45106
|
-
// Strong 120B general-purpose
|
|
45107
|
-
"nvidia/nemotron-super-49b",
|
|
45108
|
-
// Thinking mode
|
|
45109
|
-
"nvidia/mistral-large-3-675b",
|
|
45110
|
-
// Largest Mistral
|
|
45111
|
-
"nvidia/llama-4-maverick",
|
|
45112
|
-
// MoE breadth
|
|
45113
|
-
"nvidia/glm-4.7"
|
|
45114
|
-
// Thinking mode
|
|
45115
|
-
]
|
|
45116
|
-
},
|
|
45117
|
-
COMPLEX: {
|
|
45118
|
-
primary: "nvidia/nemotron-ultra-253b",
|
|
45119
|
-
// Strongest free: 253B reasoning
|
|
45120
|
-
fallback: [
|
|
45121
|
-
"nvidia/mistral-large-3-675b",
|
|
45122
|
-
// 675B massive params
|
|
45123
|
-
"nvidia/deepseek-v3.2",
|
|
45124
|
-
// V3.2 quality
|
|
45125
|
-
"nvidia/nemotron-3-super-120b",
|
|
45126
|
-
// Thinking mode MoE
|
|
45127
|
-
"nvidia/qwen3-coder-480b",
|
|
45128
|
-
// 480B MoE for code-heavy tasks
|
|
45129
|
-
"nvidia/devstral-2-123b",
|
|
45130
|
-
// Coding-focused
|
|
45131
|
-
"nvidia/gpt-oss-120b"
|
|
45132
|
-
// Last resort
|
|
45133
|
-
]
|
|
45134
|
-
},
|
|
45135
|
-
REASONING: {
|
|
45136
|
-
primary: "nvidia/nemotron-ultra-253b",
|
|
45137
|
-
// Best free reasoning: 253B
|
|
45138
|
-
fallback: [
|
|
45139
|
-
"nvidia/nemotron-3-super-120b",
|
|
45140
|
-
// Thinking mode MoE
|
|
45141
|
-
"nvidia/nemotron-super-49b",
|
|
45142
|
-
// Thinking mode
|
|
45143
|
-
"nvidia/deepseek-v3.2",
|
|
45144
|
-
// DeepSeek reasoning
|
|
45145
|
-
"nvidia/mistral-large-3-675b",
|
|
45146
|
-
// Brute-force params
|
|
45147
|
-
"nvidia/glm-4.7"
|
|
45148
|
-
// GLM thinking mode
|
|
45149
|
-
]
|
|
45150
|
-
}
|
|
45151
|
-
},
|
|
45152
45060
|
overrides: {
|
|
45153
45061
|
maxTokensForceComplex: 1e5,
|
|
45154
45062
|
structuredOutputMinTier: "MEDIUM",
|
|
@@ -47369,8 +47277,6 @@ var BLOCKRUN_SOLANA_API = "https://sol.blockrun.ai/api";
|
|
|
47369
47277
|
var IMAGE_DIR = join8(homedir5(), ".openclaw", "blockrun", "images");
|
|
47370
47278
|
var AUTO_MODEL = "blockrun/auto";
|
|
47371
47279
|
var ROUTING_PROFILES = /* @__PURE__ */ new Set([
|
|
47372
|
-
"blockrun/free",
|
|
47373
|
-
"free",
|
|
47374
47280
|
"blockrun/eco",
|
|
47375
47281
|
"eco",
|
|
47376
47282
|
"blockrun/auto",
|
|
@@ -47392,25 +47298,6 @@ var FREE_MODELS = /* @__PURE__ */ new Set([
|
|
|
47392
47298
|
"nvidia/glm-4.7",
|
|
47393
47299
|
"nvidia/llama-4-maverick"
|
|
47394
47300
|
]);
|
|
47395
|
-
var FREE_TIER_CONFIGS = {
|
|
47396
|
-
SIMPLE: {
|
|
47397
|
-
primary: "nvidia/gpt-oss-20b",
|
|
47398
|
-
fallback: ["nvidia/gpt-oss-120b", "nvidia/nemotron-super-49b"]
|
|
47399
|
-
},
|
|
47400
|
-
MEDIUM: {
|
|
47401
|
-
primary: "nvidia/deepseek-v3.2",
|
|
47402
|
-
fallback: ["nvidia/gpt-oss-120b", "nvidia/nemotron-super-49b"]
|
|
47403
|
-
},
|
|
47404
|
-
COMPLEX: {
|
|
47405
|
-
primary: "nvidia/nemotron-ultra-253b",
|
|
47406
|
-
fallback: ["nvidia/mistral-large-3-675b", "nvidia/deepseek-v3.2", "nvidia/gpt-oss-120b"]
|
|
47407
|
-
},
|
|
47408
|
-
REASONING: {
|
|
47409
|
-
primary: "nvidia/nemotron-ultra-253b",
|
|
47410
|
-
fallback: ["nvidia/nemotron-3-super-120b", "nvidia/deepseek-v3.2"]
|
|
47411
|
-
}
|
|
47412
|
-
};
|
|
47413
|
-
var freeRequestCount = 0;
|
|
47414
47301
|
var MAX_MESSAGES = 200;
|
|
47415
47302
|
var CONTEXT_LIMIT_KB = 5120;
|
|
47416
47303
|
var HEARTBEAT_INTERVAL_MS = 2e3;
|
|
@@ -48916,7 +48803,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
48916
48803
|
const estimatedTokens = Math.ceil(fullText.length / 4);
|
|
48917
48804
|
const normalizedModel2 = typeof parsed.model === "string" ? parsed.model.trim().toLowerCase() : "";
|
|
48918
48805
|
const profileName = normalizedModel2.replace("blockrun/", "");
|
|
48919
|
-
const debugProfile = ["
|
|
48806
|
+
const debugProfile = ["eco", "auto", "premium"].includes(profileName) ? profileName : "auto";
|
|
48920
48807
|
const scoring = classifyByRules(
|
|
48921
48808
|
debugPrompt,
|
|
48922
48809
|
systemPrompt,
|
|
@@ -49536,14 +49423,6 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49536
49423
|
}
|
|
49537
49424
|
}
|
|
49538
49425
|
options.onRouted?.(routingDecision);
|
|
49539
|
-
if (routingProfile === "free") {
|
|
49540
|
-
freeRequestCount++;
|
|
49541
|
-
if (freeRequestCount % 5 === 0) {
|
|
49542
|
-
balanceFallbackNotice = `> **\u{1F4A1} Tip:** Free tier gives you 11 NVIDIA models. Want Claude, GPT-5, or Gemini? Fund your wallet \u2014 starting at $0.001/request.
|
|
49543
|
-
|
|
49544
|
-
`;
|
|
49545
|
-
}
|
|
49546
|
-
}
|
|
49547
49426
|
}
|
|
49548
49427
|
}
|
|
49549
49428
|
if (!effectiveSessionId && parsedMessages.length > 0) {
|
|
@@ -49648,28 +49527,19 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49648
49527
|
const sufficiency = await balanceMonitor.checkSufficient(bufferedCostMicros);
|
|
49649
49528
|
if (sufficiency.info.isEmpty || !sufficiency.sufficient) {
|
|
49650
49529
|
const originalModel = modelId;
|
|
49651
|
-
const fallbackTier = routingDecision?.tier ?? "SIMPLE";
|
|
49652
|
-
const freeTierConfig = FREE_TIER_CONFIGS[fallbackTier];
|
|
49653
|
-
const freeModel = freeTierConfig.primary;
|
|
49654
49530
|
console.log(
|
|
49655
|
-
`[ClawRouter] Wallet ${sufficiency.info.isEmpty ? "empty" : "insufficient"} (${sufficiency.info.balanceUSD}), falling back to free model: ${
|
|
49531
|
+
`[ClawRouter] Wallet ${sufficiency.info.isEmpty ? "empty" : "insufficient"} (${sufficiency.info.balanceUSD}), falling back to free model: ${FREE_MODEL} (requested: ${originalModel})`
|
|
49656
49532
|
);
|
|
49657
|
-
modelId =
|
|
49533
|
+
modelId = FREE_MODEL;
|
|
49658
49534
|
isFreeModel = true;
|
|
49659
49535
|
const parsed = JSON.parse(body.toString());
|
|
49660
|
-
parsed.model =
|
|
49536
|
+
parsed.model = FREE_MODEL;
|
|
49661
49537
|
body = Buffer.from(JSON.stringify(parsed));
|
|
49662
49538
|
balanceFallbackNotice = sufficiency.info.isEmpty ? `> **\u26A0\uFE0F Wallet empty** \u2014 using free model. Fund your wallet to use ${originalModel}.
|
|
49663
49539
|
|
|
49664
49540
|
` : `> **\u26A0\uFE0F Insufficient balance** (${sufficiency.info.balanceUSD}) \u2014 using free model instead of ${originalModel}.
|
|
49665
49541
|
|
|
49666
49542
|
`;
|
|
49667
|
-
freeRequestCount++;
|
|
49668
|
-
if (freeRequestCount % 5 === 0) {
|
|
49669
|
-
balanceFallbackNotice = `> **\u{1F4A1} Tip:** Free tier gives you 11 NVIDIA models. Want Claude, GPT-5, or Gemini? Fund your wallet \u2014 starting at $0.001/request.
|
|
49670
|
-
|
|
49671
|
-
`;
|
|
49672
|
-
}
|
|
49673
49543
|
options.onLowBalance?.({
|
|
49674
49544
|
balanceUSD: sufficiency.info.balanceUSD,
|
|
49675
49545
|
walletAddress: sufficiency.info.walletAddress
|
|
@@ -51117,7 +50987,6 @@ function injectModelsConfig(logger) {
|
|
|
51117
50987
|
}
|
|
51118
50988
|
const TOP_MODELS = [
|
|
51119
50989
|
"auto",
|
|
51120
|
-
"free",
|
|
51121
50990
|
"eco",
|
|
51122
50991
|
"premium",
|
|
51123
50992
|
"anthropic/claude-sonnet-4.6",
|
|
@@ -51133,7 +51002,19 @@ function injectModelsConfig(logger) {
|
|
|
51133
51002
|
"deepseek/deepseek-chat",
|
|
51134
51003
|
"moonshot/kimi-k2.5",
|
|
51135
51004
|
"xai/grok-3",
|
|
51136
|
-
"minimax/minimax-m2.5"
|
|
51005
|
+
"minimax/minimax-m2.5",
|
|
51006
|
+
// Free NVIDIA models
|
|
51007
|
+
"nvidia/gpt-oss-120b",
|
|
51008
|
+
"nvidia/gpt-oss-20b",
|
|
51009
|
+
"nvidia/nemotron-ultra-253b",
|
|
51010
|
+
"nvidia/deepseek-v3.2",
|
|
51011
|
+
"nvidia/mistral-large-3-675b",
|
|
51012
|
+
"nvidia/qwen3-coder-480b",
|
|
51013
|
+
"nvidia/devstral-2-123b",
|
|
51014
|
+
"nvidia/llama-4-maverick",
|
|
51015
|
+
"nvidia/nemotron-3-super-120b",
|
|
51016
|
+
"nvidia/nemotron-super-49b",
|
|
51017
|
+
"nvidia/glm-4.7"
|
|
51137
51018
|
];
|
|
51138
51019
|
if (!defaults.models || typeof defaults.models !== "object" || Array.isArray(defaults.models)) {
|
|
51139
51020
|
defaults.models = {};
|