@blockrun/clawrouter 0.8.18 → 0.8.20
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 +17 -17
- package/dist/cli.js +57 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,10 +21,10 @@ One wallet, 30+ models, zero API keys.
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
23
|
```
|
|
24
|
-
"What is 2+2?" →
|
|
25
|
-
"Summarize this article" →
|
|
26
|
-
"Build a React component" →
|
|
27
|
-
"Prove this theorem" →
|
|
24
|
+
"What is 2+2?" → NVIDIA Kimi $0.001/M saved ~100%
|
|
25
|
+
"Summarize this article" → Grok Code Fast $1.50/M saved 94%
|
|
26
|
+
"Build a React component" → Gemini 2.5 Pro $10.00/M best balance
|
|
27
|
+
"Prove this theorem" → Grok 4.1 Fast $0.50/M reasoning
|
|
28
28
|
"Run 50 parallel searches"→ Kimi K2.5 $2.40/M agentic swarm
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -112,18 +112,18 @@ Request → Weighted Scorer (15 dimensions)
|
|
|
112
112
|
└── Low confidence → Default to MEDIUM tier → Done
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
No external classifier calls. Ambiguous queries default to the MEDIUM tier (
|
|
115
|
+
No external classifier calls. Ambiguous queries default to the MEDIUM tier (Grok Code Fast) — fast, cheap, and good enough for most tasks.
|
|
116
116
|
|
|
117
117
|
**Deep dive:** [15-dimension scoring weights](docs/configuration.md#scoring-weights) | [Architecture](docs/architecture.md)
|
|
118
118
|
|
|
119
119
|
### Tier → Model Mapping
|
|
120
120
|
|
|
121
|
-
| Tier | Primary Model | Cost/M
|
|
122
|
-
| --------- | --------------------- |
|
|
123
|
-
| SIMPLE |
|
|
124
|
-
| MEDIUM | grok-code-fast-1 | $1.50
|
|
125
|
-
| COMPLEX | gemini-2.5-pro | $10.00
|
|
126
|
-
| REASONING | grok-4-fast-reasoning | $0.50
|
|
121
|
+
| Tier | Primary Model | Cost/M | Savings vs Opus |
|
|
122
|
+
| --------- | --------------------- | ------- | --------------- |
|
|
123
|
+
| SIMPLE | nvidia/kimi-k2.5 | $0.001 | **~100%** |
|
|
124
|
+
| MEDIUM | grok-code-fast-1 | $1.50 | **94.0%** |
|
|
125
|
+
| COMPLEX | gemini-2.5-pro | $10.00 | **60.0%** |
|
|
126
|
+
| REASONING | grok-4-1-fast-reasoning | $0.50 | **98.0%** |
|
|
127
127
|
|
|
128
128
|
Special rule: 2+ reasoning markers → REASONING at 0.97 confidence.
|
|
129
129
|
|
|
@@ -144,13 +144,13 @@ ClawRouter v0.5+ includes intelligent features that work automatically:
|
|
|
144
144
|
|
|
145
145
|
| Tier | % of Traffic | Cost/M |
|
|
146
146
|
| ------------------- | ------------ | ----------- |
|
|
147
|
-
| SIMPLE | ~45% | $0.
|
|
148
|
-
| MEDIUM | ~35% | $
|
|
149
|
-
| COMPLEX | ~15% | $
|
|
150
|
-
| REASONING | ~5% | $
|
|
151
|
-
| **Blended average** | | **$
|
|
147
|
+
| SIMPLE | ~45% | $0.001 |
|
|
148
|
+
| MEDIUM | ~35% | $1.50 |
|
|
149
|
+
| COMPLEX | ~15% | $10.00 |
|
|
150
|
+
| REASONING | ~5% | $0.50 |
|
|
151
|
+
| **Blended average** | | **$2.05/M** |
|
|
152
152
|
|
|
153
|
-
Compared to **$
|
|
153
|
+
Compared to **$25/M** for Claude Opus = **92% savings** on a typical workload.
|
|
154
154
|
|
|
155
155
|
---
|
|
156
156
|
|
package/dist/cli.js
CHANGED
|
@@ -2233,6 +2233,42 @@ function getSessionId(headers, headerName = DEFAULT_SESSION_CONFIG.headerName) {
|
|
|
2233
2233
|
return void 0;
|
|
2234
2234
|
}
|
|
2235
2235
|
|
|
2236
|
+
// src/updater.ts
|
|
2237
|
+
var NPM_REGISTRY = "https://registry.npmjs.org/@blockrun/clawrouter/latest";
|
|
2238
|
+
var UPDATE_URL = "https://blockrun.ai/ClawRouter-update";
|
|
2239
|
+
var CHECK_TIMEOUT_MS = 5e3;
|
|
2240
|
+
function compareSemver(a, b) {
|
|
2241
|
+
const pa = a.split(".").map(Number);
|
|
2242
|
+
const pb = b.split(".").map(Number);
|
|
2243
|
+
for (let i = 0; i < 3; i++) {
|
|
2244
|
+
if ((pa[i] || 0) > (pb[i] || 0)) return 1;
|
|
2245
|
+
if ((pa[i] || 0) < (pb[i] || 0)) return -1;
|
|
2246
|
+
}
|
|
2247
|
+
return 0;
|
|
2248
|
+
}
|
|
2249
|
+
async function checkForUpdates() {
|
|
2250
|
+
try {
|
|
2251
|
+
const controller = new AbortController();
|
|
2252
|
+
const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS);
|
|
2253
|
+
const res = await fetch(NPM_REGISTRY, {
|
|
2254
|
+
signal: controller.signal,
|
|
2255
|
+
headers: { Accept: "application/json" }
|
|
2256
|
+
});
|
|
2257
|
+
clearTimeout(timeout);
|
|
2258
|
+
if (!res.ok) return;
|
|
2259
|
+
const data = await res.json();
|
|
2260
|
+
const latest = data.version;
|
|
2261
|
+
if (!latest) return;
|
|
2262
|
+
if (compareSemver(latest, VERSION) > 0) {
|
|
2263
|
+
console.log("");
|
|
2264
|
+
console.log(`\x1B[33m\u2B06\uFE0F ClawRouter ${latest} available (you have ${VERSION})\x1B[0m`);
|
|
2265
|
+
console.log(` Run: \x1B[36mcurl -fsSL ${UPDATE_URL} | bash\x1B[0m`);
|
|
2266
|
+
console.log("");
|
|
2267
|
+
}
|
|
2268
|
+
} catch {
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2236
2272
|
// src/proxy.ts
|
|
2237
2273
|
var BLOCKRUN_API = "https://blockrun.ai/api";
|
|
2238
2274
|
var AUTO_MODEL = "blockrun/auto";
|
|
@@ -2276,8 +2312,28 @@ function transformPaymentError(errorBody) {
|
|
|
2276
2312
|
});
|
|
2277
2313
|
}
|
|
2278
2314
|
}
|
|
2315
|
+
if (innerJson.invalidReason === "invalid_payload") {
|
|
2316
|
+
return JSON.stringify({
|
|
2317
|
+
error: {
|
|
2318
|
+
message: "Payment signature invalid. This may be a temporary issue.",
|
|
2319
|
+
type: "invalid_payload",
|
|
2320
|
+
help: "Try again. If this persists, reinstall ClawRouter: curl -fsSL https://blockrun.ai/ClawRouter-update | bash"
|
|
2321
|
+
}
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2279
2324
|
}
|
|
2280
2325
|
}
|
|
2326
|
+
if (parsed.error === "Settlement failed" || parsed.details?.includes("Settlement failed")) {
|
|
2327
|
+
const details = parsed.details || "";
|
|
2328
|
+
const gasError = details.includes("unable to estimate gas");
|
|
2329
|
+
return JSON.stringify({
|
|
2330
|
+
error: {
|
|
2331
|
+
message: gasError ? "Payment failed: network congestion or gas issue. Try again." : "Payment settlement failed. Try again in a moment.",
|
|
2332
|
+
type: "settlement_failed",
|
|
2333
|
+
help: "This is usually temporary. If it persists, try: /model free"
|
|
2334
|
+
}
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2281
2337
|
} catch {
|
|
2282
2338
|
}
|
|
2283
2339
|
return errorBody;
|
|
@@ -2778,6 +2834,7 @@ async function startProxy(options) {
|
|
|
2778
2834
|
const port = addr.port;
|
|
2779
2835
|
const baseUrl = `http://127.0.0.1:${port}`;
|
|
2780
2836
|
options.onReady?.(port);
|
|
2837
|
+
checkForUpdates();
|
|
2781
2838
|
server.on("error", (err) => {
|
|
2782
2839
|
console.error(`[ClawRouter] Server runtime error: ${err.message}`);
|
|
2783
2840
|
options.onError?.(err);
|