@blockrun/clawrouter 0.12.73 → 0.12.75
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 +4 -4
- package/dist/cli.js +279 -63
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +279 -63
- package/dist/index.js.map +1 -1
- package/docs/clawrouter-vs-openrouter-llm-routing-comparison.md +2 -2
- package/docs/smart-llm-router-14-dimension-classifier.md +4 -4
- package/package.json +2 -2
- package/skills/clawrouter/SKILL.md +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -183,7 +183,7 @@ 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" | "free";
|
|
187
187
|
};
|
|
188
188
|
type RouterOptions = {
|
|
189
189
|
config: RoutingConfig;
|
|
@@ -250,6 +250,8 @@ 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>;
|
|
253
255
|
overrides: OverridesConfig;
|
|
254
256
|
};
|
|
255
257
|
|
package/dist/index.js
CHANGED
|
@@ -32906,9 +32906,27 @@ var MODEL_ALIASES = {
|
|
|
32906
32906
|
// delisted 2026-03-12
|
|
32907
32907
|
"xai/grok-3-fast": "xai/grok-4-fast-reasoning",
|
|
32908
32908
|
// delisted (too expensive)
|
|
32909
|
-
// NVIDIA
|
|
32909
|
+
// NVIDIA — existing alias kept for backward compat
|
|
32910
32910
|
nvidia: "nvidia/gpt-oss-120b",
|
|
32911
32911
|
"gpt-120b": "nvidia/gpt-oss-120b",
|
|
32912
|
+
"gpt-20b": "nvidia/gpt-oss-20b",
|
|
32913
|
+
// Free model aliases — "-free" suffix for models with paid twins
|
|
32914
|
+
"deepseek-free": "nvidia/deepseek-v3.2",
|
|
32915
|
+
"mistral-free": "nvidia/mistral-large-3-675b",
|
|
32916
|
+
"glm-free": "nvidia/glm-4.7",
|
|
32917
|
+
"llama-free": "nvidia/llama-4-maverick",
|
|
32918
|
+
// Bare-name aliases for unique free models
|
|
32919
|
+
nemotron: "nvidia/nemotron-ultra-253b",
|
|
32920
|
+
"nemotron-ultra": "nvidia/nemotron-ultra-253b",
|
|
32921
|
+
"nemotron-253b": "nvidia/nemotron-ultra-253b",
|
|
32922
|
+
"nemotron-super": "nvidia/nemotron-super-49b",
|
|
32923
|
+
"nemotron-49b": "nvidia/nemotron-super-49b",
|
|
32924
|
+
"nemotron-120b": "nvidia/nemotron-3-super-120b",
|
|
32925
|
+
devstral: "nvidia/devstral-2-123b",
|
|
32926
|
+
"devstral-2": "nvidia/devstral-2-123b",
|
|
32927
|
+
"qwen-coder": "nvidia/qwen3-coder-480b",
|
|
32928
|
+
"qwen-coder-free": "nvidia/qwen3-coder-480b",
|
|
32929
|
+
maverick: "nvidia/llama-4-maverick",
|
|
32912
32930
|
// MiniMax
|
|
32913
32931
|
minimax: "minimax/minimax-m2.7",
|
|
32914
32932
|
"minimax-m2.7": "minimax/minimax-m2.7",
|
|
@@ -32955,11 +32973,11 @@ var BLOCKRUN_MODELS = [
|
|
|
32955
32973
|
},
|
|
32956
32974
|
{
|
|
32957
32975
|
id: "free",
|
|
32958
|
-
name: "Free (
|
|
32976
|
+
name: "Free (Smart Router - 11 NVIDIA Models)",
|
|
32959
32977
|
inputPrice: 0,
|
|
32960
32978
|
outputPrice: 0,
|
|
32961
|
-
contextWindow:
|
|
32962
|
-
maxOutput:
|
|
32979
|
+
contextWindow: 131072,
|
|
32980
|
+
maxOutput: 16384
|
|
32963
32981
|
},
|
|
32964
32982
|
{
|
|
32965
32983
|
id: "eco",
|
|
@@ -33464,18 +33482,116 @@ var BLOCKRUN_MODELS = [
|
|
|
33464
33482
|
agentic: true,
|
|
33465
33483
|
toolCalling: true
|
|
33466
33484
|
},
|
|
33467
|
-
// NVIDIA - Free
|
|
33485
|
+
// NVIDIA - Free models (hosted by NVIDIA, billingMode: "free" on server)
|
|
33486
|
+
// toolCalling intentionally omitted on all free models: structured function
|
|
33487
|
+
// calling support unverified. Excluded from tool-heavy routing paths.
|
|
33468
33488
|
{
|
|
33469
33489
|
id: "nvidia/gpt-oss-120b",
|
|
33470
|
-
name: "
|
|
33490
|
+
name: "[Free] GPT-OSS 120B",
|
|
33471
33491
|
version: "120b",
|
|
33472
33492
|
inputPrice: 0,
|
|
33473
33493
|
outputPrice: 0,
|
|
33474
33494
|
contextWindow: 128e3,
|
|
33475
33495
|
maxOutput: 16384
|
|
33476
|
-
// toolCalling intentionally omitted: free model, structured function
|
|
33477
|
-
// calling support unverified. Excluded from tool-heavy routing paths.
|
|
33478
33496
|
},
|
|
33497
|
+
{
|
|
33498
|
+
id: "nvidia/gpt-oss-20b",
|
|
33499
|
+
name: "[Free] GPT-OSS 20B",
|
|
33500
|
+
version: "20b",
|
|
33501
|
+
inputPrice: 0,
|
|
33502
|
+
outputPrice: 0,
|
|
33503
|
+
contextWindow: 128e3,
|
|
33504
|
+
maxOutput: 16384
|
|
33505
|
+
},
|
|
33506
|
+
{
|
|
33507
|
+
id: "nvidia/nemotron-ultra-253b",
|
|
33508
|
+
name: "[Free] Nemotron Ultra 253B",
|
|
33509
|
+
version: "253b",
|
|
33510
|
+
inputPrice: 0,
|
|
33511
|
+
outputPrice: 0,
|
|
33512
|
+
contextWindow: 131072,
|
|
33513
|
+
maxOutput: 16384,
|
|
33514
|
+
reasoning: true
|
|
33515
|
+
},
|
|
33516
|
+
{
|
|
33517
|
+
id: "nvidia/nemotron-3-super-120b",
|
|
33518
|
+
name: "[Free] Nemotron 3 Super 120B",
|
|
33519
|
+
version: "3-super-120b",
|
|
33520
|
+
inputPrice: 0,
|
|
33521
|
+
outputPrice: 0,
|
|
33522
|
+
contextWindow: 131072,
|
|
33523
|
+
maxOutput: 16384,
|
|
33524
|
+
reasoning: true
|
|
33525
|
+
},
|
|
33526
|
+
{
|
|
33527
|
+
id: "nvidia/nemotron-super-49b",
|
|
33528
|
+
name: "[Free] Nemotron Super 49B",
|
|
33529
|
+
version: "super-49b",
|
|
33530
|
+
inputPrice: 0,
|
|
33531
|
+
outputPrice: 0,
|
|
33532
|
+
contextWindow: 131072,
|
|
33533
|
+
maxOutput: 16384,
|
|
33534
|
+
reasoning: true
|
|
33535
|
+
},
|
|
33536
|
+
{
|
|
33537
|
+
id: "nvidia/deepseek-v3.2",
|
|
33538
|
+
name: "[Free] DeepSeek V3.2",
|
|
33539
|
+
version: "v3.2",
|
|
33540
|
+
inputPrice: 0,
|
|
33541
|
+
outputPrice: 0,
|
|
33542
|
+
contextWindow: 131072,
|
|
33543
|
+
maxOutput: 16384,
|
|
33544
|
+
reasoning: true
|
|
33545
|
+
},
|
|
33546
|
+
{
|
|
33547
|
+
id: "nvidia/mistral-large-3-675b",
|
|
33548
|
+
name: "[Free] Mistral Large 675B",
|
|
33549
|
+
version: "3-675b",
|
|
33550
|
+
inputPrice: 0,
|
|
33551
|
+
outputPrice: 0,
|
|
33552
|
+
contextWindow: 131072,
|
|
33553
|
+
maxOutput: 16384,
|
|
33554
|
+
reasoning: true
|
|
33555
|
+
},
|
|
33556
|
+
{
|
|
33557
|
+
id: "nvidia/qwen3-coder-480b",
|
|
33558
|
+
name: "[Free] Qwen3 Coder 480B",
|
|
33559
|
+
version: "480b",
|
|
33560
|
+
inputPrice: 0,
|
|
33561
|
+
outputPrice: 0,
|
|
33562
|
+
contextWindow: 131072,
|
|
33563
|
+
maxOutput: 16384
|
|
33564
|
+
},
|
|
33565
|
+
{
|
|
33566
|
+
id: "nvidia/devstral-2-123b",
|
|
33567
|
+
name: "[Free] Devstral 2 123B",
|
|
33568
|
+
version: "2-123b",
|
|
33569
|
+
inputPrice: 0,
|
|
33570
|
+
outputPrice: 0,
|
|
33571
|
+
contextWindow: 131072,
|
|
33572
|
+
maxOutput: 16384
|
|
33573
|
+
},
|
|
33574
|
+
{
|
|
33575
|
+
id: "nvidia/glm-4.7",
|
|
33576
|
+
name: "[Free] GLM-4.7",
|
|
33577
|
+
version: "4.7",
|
|
33578
|
+
inputPrice: 0,
|
|
33579
|
+
outputPrice: 0,
|
|
33580
|
+
contextWindow: 131072,
|
|
33581
|
+
maxOutput: 16384,
|
|
33582
|
+
reasoning: true
|
|
33583
|
+
},
|
|
33584
|
+
{
|
|
33585
|
+
id: "nvidia/llama-4-maverick",
|
|
33586
|
+
name: "[Free] Llama 4 Maverick",
|
|
33587
|
+
version: "4-maverick",
|
|
33588
|
+
inputPrice: 0,
|
|
33589
|
+
outputPrice: 0,
|
|
33590
|
+
contextWindow: 131072,
|
|
33591
|
+
maxOutput: 16384,
|
|
33592
|
+
reasoning: true
|
|
33593
|
+
},
|
|
33594
|
+
// NVIDIA - Paid models
|
|
33479
33595
|
{
|
|
33480
33596
|
id: "nvidia/kimi-k2.5",
|
|
33481
33597
|
name: "NVIDIA Kimi K2.5",
|
|
@@ -43601,7 +43717,11 @@ var RulesStrategy = class {
|
|
|
43601
43717
|
let tierConfigs;
|
|
43602
43718
|
let profileSuffix;
|
|
43603
43719
|
let profile;
|
|
43604
|
-
if (routingProfile === "
|
|
43720
|
+
if (routingProfile === "free" && config.freeTiers) {
|
|
43721
|
+
tierConfigs = config.freeTiers;
|
|
43722
|
+
profileSuffix = " | free";
|
|
43723
|
+
profile = "free";
|
|
43724
|
+
} else if (routingProfile === "eco" && config.ecoTiers) {
|
|
43605
43725
|
tierConfigs = config.ecoTiers;
|
|
43606
43726
|
profileSuffix = " | eco";
|
|
43607
43727
|
profile = "eco";
|
|
@@ -44790,39 +44910,50 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
44790
44910
|
]
|
|
44791
44911
|
}
|
|
44792
44912
|
},
|
|
44793
|
-
// Eco tier configs - absolute cheapest (blockrun/eco)
|
|
44913
|
+
// Eco tier configs - absolute cheapest, free-first (blockrun/eco)
|
|
44794
44914
|
ecoTiers: {
|
|
44795
44915
|
SIMPLE: {
|
|
44796
44916
|
primary: "nvidia/gpt-oss-120b",
|
|
44797
|
-
//
|
|
44917
|
+
// FREE! $0.00/$0.00
|
|
44798
44918
|
fallback: [
|
|
44919
|
+
"nvidia/gpt-oss-20b",
|
|
44920
|
+
// FREE — smaller, faster
|
|
44799
44921
|
"google/gemini-3.1-flash-lite",
|
|
44800
44922
|
// $0.25/$1.50 — newest flash-lite
|
|
44801
44923
|
"openai/gpt-5.4-nano",
|
|
44802
44924
|
// $0.20/$1.25 — fast nano
|
|
44803
44925
|
"google/gemini-2.5-flash-lite",
|
|
44804
|
-
//
|
|
44926
|
+
// $0.10/$0.40
|
|
44805
44927
|
"xai/grok-4-fast-non-reasoning"
|
|
44806
|
-
//
|
|
44928
|
+
// $0.20/$0.50
|
|
44807
44929
|
]
|
|
44808
44930
|
},
|
|
44809
44931
|
MEDIUM: {
|
|
44810
|
-
primary: "
|
|
44811
|
-
//
|
|
44932
|
+
primary: "nvidia/deepseek-v3.2",
|
|
44933
|
+
// FREE — DeepSeek V3.2 quality at zero cost
|
|
44812
44934
|
fallback: [
|
|
44935
|
+
"nvidia/gpt-oss-120b",
|
|
44936
|
+
// FREE fallback
|
|
44937
|
+
"google/gemini-3.1-flash-lite",
|
|
44938
|
+
// $0.25/$1.50
|
|
44813
44939
|
"openai/gpt-5.4-nano",
|
|
44814
|
-
// $0.20/$1.25
|
|
44940
|
+
// $0.20/$1.25
|
|
44815
44941
|
"google/gemini-2.5-flash-lite",
|
|
44816
|
-
//
|
|
44942
|
+
// $0.10/$0.40
|
|
44817
44943
|
"xai/grok-4-fast-non-reasoning",
|
|
44818
|
-
"google/gemini-2.5-flash"
|
|
44819
|
-
"nvidia/gpt-oss-120b"
|
|
44944
|
+
"google/gemini-2.5-flash"
|
|
44820
44945
|
]
|
|
44821
44946
|
},
|
|
44822
44947
|
COMPLEX: {
|
|
44823
|
-
primary: "
|
|
44824
|
-
//
|
|
44948
|
+
primary: "nvidia/nemotron-ultra-253b",
|
|
44949
|
+
// FREE — 253B reasoning model
|
|
44825
44950
|
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
|
|
44826
44957
|
"google/gemini-2.5-flash-lite",
|
|
44827
44958
|
"xai/grok-4-0709",
|
|
44828
44959
|
"google/gemini-2.5-flash",
|
|
@@ -44831,8 +44962,13 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
44831
44962
|
},
|
|
44832
44963
|
REASONING: {
|
|
44833
44964
|
primary: "xai/grok-4-1-fast-reasoning",
|
|
44834
|
-
//
|
|
44835
|
-
fallback: [
|
|
44965
|
+
// $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
|
+
]
|
|
44836
44972
|
}
|
|
44837
44973
|
},
|
|
44838
44974
|
// Premium tier configs - best quality (blockrun/premium)
|
|
@@ -44946,6 +45082,73 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
44946
45082
|
]
|
|
44947
45083
|
}
|
|
44948
45084
|
},
|
|
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
|
+
},
|
|
44949
45152
|
overrides: {
|
|
44950
45153
|
maxTokensForceComplex: 1e5,
|
|
44951
45154
|
structuredOutputMinTier: "MEDIUM",
|
|
@@ -47176,11 +47379,36 @@ var ROUTING_PROFILES = /* @__PURE__ */ new Set([
|
|
|
47176
47379
|
"premium"
|
|
47177
47380
|
]);
|
|
47178
47381
|
var FREE_MODEL = "nvidia/gpt-oss-120b";
|
|
47382
|
+
var FREE_MODELS = /* @__PURE__ */ new Set([
|
|
47383
|
+
"nvidia/gpt-oss-120b",
|
|
47384
|
+
"nvidia/gpt-oss-20b",
|
|
47385
|
+
"nvidia/nemotron-ultra-253b",
|
|
47386
|
+
"nvidia/nemotron-3-super-120b",
|
|
47387
|
+
"nvidia/nemotron-super-49b",
|
|
47388
|
+
"nvidia/deepseek-v3.2",
|
|
47389
|
+
"nvidia/mistral-large-3-675b",
|
|
47390
|
+
"nvidia/qwen3-coder-480b",
|
|
47391
|
+
"nvidia/devstral-2-123b",
|
|
47392
|
+
"nvidia/glm-4.7",
|
|
47393
|
+
"nvidia/llama-4-maverick"
|
|
47394
|
+
]);
|
|
47179
47395
|
var FREE_TIER_CONFIGS = {
|
|
47180
|
-
SIMPLE: {
|
|
47181
|
-
|
|
47182
|
-
|
|
47183
|
-
|
|
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
|
+
}
|
|
47184
47412
|
};
|
|
47185
47413
|
var freeRequestCount = 0;
|
|
47186
47414
|
var MAX_MESSAGES = 200;
|
|
@@ -49192,30 +49420,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49192
49420
|
modelId = resolvedModel;
|
|
49193
49421
|
}
|
|
49194
49422
|
if (isRoutingProfile) {
|
|
49195
|
-
|
|
49196
|
-
const freeModel = "nvidia/gpt-oss-120b";
|
|
49197
|
-
console.log(`[ClawRouter] Free profile - using ${freeModel} directly`);
|
|
49198
|
-
parsed.model = freeModel;
|
|
49199
|
-
modelId = freeModel;
|
|
49200
|
-
bodyModified = true;
|
|
49201
|
-
freeRequestCount++;
|
|
49202
|
-
if (freeRequestCount % 5 === 0) {
|
|
49203
|
-
balanceFallbackNotice = `> **\u{1F4A1} Tip:** Not satisfied with free model quality? Fund your wallet to unlock deepseek-chat, gemini-flash, and 30+ premium models \u2014 starting at $0.001/request.
|
|
49204
|
-
|
|
49205
|
-
`;
|
|
49206
|
-
}
|
|
49207
|
-
routingDecision = {
|
|
49208
|
-
model: freeModel,
|
|
49209
|
-
tier: "SIMPLE",
|
|
49210
|
-
confidence: 1,
|
|
49211
|
-
method: "rules",
|
|
49212
|
-
reasoning: "free profile",
|
|
49213
|
-
costEstimate: 0,
|
|
49214
|
-
baselineCost: 0,
|
|
49215
|
-
savings: 1,
|
|
49216
|
-
tierConfigs: FREE_TIER_CONFIGS
|
|
49217
|
-
};
|
|
49218
|
-
} else {
|
|
49423
|
+
{
|
|
49219
49424
|
effectiveSessionId = getSessionId(req.headers) ?? deriveSessionId(parsedMessages);
|
|
49220
49425
|
const existingSession = effectiveSessionId ? sessionStore.getSession(effectiveSessionId) : void 0;
|
|
49221
49426
|
const rawPrompt = lastUserMsg?.content;
|
|
@@ -49331,6 +49536,14 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49331
49536
|
}
|
|
49332
49537
|
}
|
|
49333
49538
|
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
|
+
}
|
|
49334
49547
|
}
|
|
49335
49548
|
}
|
|
49336
49549
|
if (!effectiveSessionId && parsedMessages.length > 0) {
|
|
@@ -49426,7 +49639,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49426
49639
|
}
|
|
49427
49640
|
deduplicator.markInflight(dedupKey);
|
|
49428
49641
|
let estimatedCostMicros;
|
|
49429
|
-
let isFreeModel = modelId
|
|
49642
|
+
let isFreeModel = FREE_MODELS.has(modelId ?? "");
|
|
49430
49643
|
if (modelId && !options.skipBalanceCheck && !isFreeModel) {
|
|
49431
49644
|
const estimated = estimateAmount(modelId, body.length, maxTokens);
|
|
49432
49645
|
if (estimated) {
|
|
@@ -49435,13 +49648,16 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49435
49648
|
const sufficiency = await balanceMonitor.checkSufficient(bufferedCostMicros);
|
|
49436
49649
|
if (sufficiency.info.isEmpty || !sufficiency.sufficient) {
|
|
49437
49650
|
const originalModel = modelId;
|
|
49651
|
+
const fallbackTier = routingDecision?.tier ?? "SIMPLE";
|
|
49652
|
+
const freeTierConfig = FREE_TIER_CONFIGS[fallbackTier];
|
|
49653
|
+
const freeModel = freeTierConfig.primary;
|
|
49438
49654
|
console.log(
|
|
49439
|
-
`[ClawRouter] Wallet ${sufficiency.info.isEmpty ? "empty" : "insufficient"} (${sufficiency.info.balanceUSD}), falling back to free model: ${
|
|
49655
|
+
`[ClawRouter] Wallet ${sufficiency.info.isEmpty ? "empty" : "insufficient"} (${sufficiency.info.balanceUSD}), falling back to free model: ${freeModel} (tier: ${fallbackTier}, requested: ${originalModel})`
|
|
49440
49656
|
);
|
|
49441
|
-
modelId =
|
|
49657
|
+
modelId = freeModel;
|
|
49442
49658
|
isFreeModel = true;
|
|
49443
49659
|
const parsed = JSON.parse(body.toString());
|
|
49444
|
-
parsed.model =
|
|
49660
|
+
parsed.model = freeModel;
|
|
49445
49661
|
body = Buffer.from(JSON.stringify(parsed));
|
|
49446
49662
|
balanceFallbackNotice = sufficiency.info.isEmpty ? `> **\u26A0\uFE0F Wallet empty** \u2014 using free model. Fund your wallet to use ${originalModel}.
|
|
49447
49663
|
|
|
@@ -49450,7 +49666,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49450
49666
|
`;
|
|
49451
49667
|
freeRequestCount++;
|
|
49452
49668
|
if (freeRequestCount % 5 === 0) {
|
|
49453
|
-
balanceFallbackNotice = `> **\u{1F4A1} Tip:**
|
|
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.
|
|
49454
49670
|
|
|
49455
49671
|
`;
|
|
49456
49672
|
}
|
|
@@ -49498,7 +49714,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49498
49714
|
const isComplexOrAgentic = hasTools || routingDecision?.tier === "COMPLEX" || routingDecision?.tier === "REASONING";
|
|
49499
49715
|
if (isComplexOrAgentic) {
|
|
49500
49716
|
const canAffordAnyNonFreeModel = BLOCKRUN_MODELS.some((m) => {
|
|
49501
|
-
if (m.id
|
|
49717
|
+
if (FREE_MODELS.has(m.id)) return false;
|
|
49502
49718
|
const est = estimateAmount(m.id, body.length, maxTokens);
|
|
49503
49719
|
return est !== void 0 && Number(est) / 1e6 <= remainingUsd;
|
|
49504
49720
|
});
|
|
@@ -49523,7 +49739,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49523
49739
|
deduplicator.removeInflight(dedupKey);
|
|
49524
49740
|
return;
|
|
49525
49741
|
}
|
|
49526
|
-
} else if (!routingDecision && modelId && modelId
|
|
49742
|
+
} else if (!routingDecision && modelId && !FREE_MODELS.has(modelId)) {
|
|
49527
49743
|
const est = estimateAmount(modelId, body.length, maxTokens);
|
|
49528
49744
|
const canAfford = !est || Number(est) / 1e6 <= remainingUsd;
|
|
49529
49745
|
if (!canAfford) {
|
|
@@ -49664,14 +49880,14 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
49664
49880
|
const remainingUsd = options.maxCostPerRunUsd - runCostUsd;
|
|
49665
49881
|
const beforeFilter = [...modelsToTry];
|
|
49666
49882
|
modelsToTry = modelsToTry.filter((m) => {
|
|
49667
|
-
if (m
|
|
49883
|
+
if (FREE_MODELS.has(m)) return true;
|
|
49668
49884
|
const est = estimateAmount(m, body.length, maxTokens);
|
|
49669
49885
|
if (!est) return true;
|
|
49670
49886
|
return Number(est) / 1e6 <= remainingUsd;
|
|
49671
49887
|
});
|
|
49672
49888
|
const excluded = beforeFilter.filter((m) => !modelsToTry.includes(m));
|
|
49673
49889
|
const isComplexOrAgenticFilter = hasTools || routingDecision?.tier === "COMPLEX" || routingDecision?.tier === "REASONING" || routingDecision === void 0;
|
|
49674
|
-
const filteredToFreeOnly = modelsToTry.length > 0 && modelsToTry.every((m) => m
|
|
49890
|
+
const filteredToFreeOnly = modelsToTry.length > 0 && modelsToTry.every((m) => FREE_MODELS.has(m));
|
|
49675
49891
|
if (isComplexOrAgenticFilter && filteredToFreeOnly) {
|
|
49676
49892
|
const budgetSummary = `$${Math.max(0, remainingUsd).toFixed(4)} remaining (limit: $${options.maxCostPerRunUsd})`;
|
|
49677
49893
|
console.log(
|
|
@@ -49709,7 +49925,7 @@ data: [DONE]
|
|
|
49709
49925
|
`[ClawRouter] Budget downgrade (${budgetSummary}): excluded ${excluded.join(", ")}`
|
|
49710
49926
|
);
|
|
49711
49927
|
const fromModel = excluded[0];
|
|
49712
|
-
const usingFree = modelsToTry.length === 1 && modelsToTry[0]
|
|
49928
|
+
const usingFree = modelsToTry.length === 1 && FREE_MODELS.has(modelsToTry[0]);
|
|
49713
49929
|
if (usingFree) {
|
|
49714
49930
|
budgetDowngradeNotice = `> **\u26A0\uFE0F Budget cap reached** ($${runCostUsd.toFixed(4)}/$${options.maxCostPerRunUsd}) \u2014 downgraded to free model. Quality may be reduced. Increase \`maxCostPerRun\` to continue with ${fromModel}.
|
|
49715
49931
|
|
|
@@ -49763,7 +49979,7 @@ data: [DONE]
|
|
|
49763
49979
|
upstream = result.response;
|
|
49764
49980
|
actualModelUsed = tryModel;
|
|
49765
49981
|
console.log(`[ClawRouter] Success with model: ${tryModel}`);
|
|
49766
|
-
if (options.maxCostPerRunUsd && effectiveSessionId && tryModel
|
|
49982
|
+
if (options.maxCostPerRunUsd && effectiveSessionId && !FREE_MODELS.has(tryModel)) {
|
|
49767
49983
|
const costEst = estimateAmount(tryModel, body.length, maxTokens);
|
|
49768
49984
|
if (costEst) {
|
|
49769
49985
|
sessionStore.addSessionCost(effectiveSessionId, BigInt(costEst));
|
|
@@ -49783,7 +49999,7 @@ data: [DONE]
|
|
|
49783
49999
|
const isPaymentErr = /payment.*verification.*failed|payment.*settlement.*failed|insufficient.*funds|transaction_simulation_failed/i.test(
|
|
49784
50000
|
result.errorBody || ""
|
|
49785
50001
|
);
|
|
49786
|
-
if (isPaymentErr && tryModel
|
|
50002
|
+
if (isPaymentErr && !FREE_MODELS.has(tryModel) && !isLastAttempt) {
|
|
49787
50003
|
failedAttempts.push({
|
|
49788
50004
|
...failedAttempts[failedAttempts.length - 1],
|
|
49789
50005
|
reason: "payment_error"
|