@blockrun/clawrouter 0.12.64 → 0.12.66

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/clawrouter",
3
- "version": "0.12.64",
3
+ "version": "0.12.66",
4
4
  "description": "Smart LLM router — save 85% on inference costs. 46+ models, one wallet, x402 micropayments.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -127,6 +127,11 @@ echo "→ Cleaning config entries..."
127
127
  node -e "
128
128
  const f = require('os').homedir() + '/.openclaw/openclaw.json';
129
129
  const fs = require('fs');
130
+ function atomicWrite(filePath, data) {
131
+ const tmpPath = filePath + '.tmp.' + process.pid;
132
+ fs.writeFileSync(tmpPath, data);
133
+ fs.renameSync(tmpPath, filePath);
134
+ }
130
135
  if (!fs.existsSync(f)) {
131
136
  console.log(' No openclaw.json found, skipping');
132
137
  process.exit(0);
@@ -167,7 +172,7 @@ if (c.agents?.defaults?.models) {
167
172
  }
168
173
  }
169
174
  }
170
- fs.writeFileSync(f, JSON.stringify(c, null, 2));
175
+ atomicWrite(f, JSON.stringify(c, null, 2));
171
176
  console.log(' Config cleaned');
172
177
  "
173
178
 
@@ -177,7 +182,7 @@ kill_port_processes 8402
177
182
 
178
183
  # 3.1. Remove stale models.json so it gets regenerated with apiKey
179
184
  echo "→ Cleaning models cache..."
180
- rm -f ~/.openclaw/agents/main/agent/models.json 2>/dev/null || true
185
+ rm -f ~/.openclaw/agents/*/agent/models.json 2>/dev/null || true
181
186
 
182
187
  # 4. Inject auth profile (ensures blockrun provider is recognized)
183
188
  echo "→ Injecting auth profile..."
@@ -187,6 +192,11 @@ const fs = require('fs');
187
192
  const path = require('path');
188
193
  const authDir = path.join(os.homedir(), '.openclaw', 'agents', 'main', 'agent');
189
194
  const authPath = path.join(authDir, 'auth-profiles.json');
195
+ function atomicWrite(filePath, data) {
196
+ const tmpPath = filePath + '.tmp.' + process.pid;
197
+ fs.writeFileSync(tmpPath, data);
198
+ fs.renameSync(tmpPath, filePath);
199
+ }
190
200
 
191
201
  // Create directory if needed
192
202
  fs.mkdirSync(authDir, { recursive: true });
@@ -216,7 +226,7 @@ if (!store.profiles[profileKey]) {
216
226
  provider: 'blockrun',
217
227
  key: 'x402-proxy-handles-auth'
218
228
  };
219
- fs.writeFileSync(authPath, JSON.stringify(store, null, 2));
229
+ atomicWrite(authPath, JSON.stringify(store, null, 2));
220
230
  console.log(' Auth profile created');
221
231
  } else {
222
232
  console.log(' Auth profile already exists');
@@ -230,6 +240,11 @@ const os = require('os');
230
240
  const fs = require('fs');
231
241
  const path = require('path');
232
242
  const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
243
+ function atomicWrite(filePath, data) {
244
+ const tmpPath = filePath + '.tmp.' + process.pid;
245
+ fs.writeFileSync(tmpPath, data);
246
+ fs.renameSync(tmpPath, filePath);
247
+ }
233
248
 
234
249
  if (fs.existsSync(configPath)) {
235
250
  try {
@@ -244,7 +259,7 @@ if (fs.existsSync(configPath)) {
244
259
  }
245
260
 
246
261
  if (changed) {
247
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
262
+ atomicWrite(configPath, JSON.stringify(config, null, 2));
248
263
  }
249
264
  } catch (e) {
250
265
  console.log(' Could not update config:', e.message);
@@ -288,6 +303,11 @@ node -e "
288
303
  const os = require('os');
289
304
  const fs = require('fs');
290
305
  const path = require('path');
306
+ function atomicWrite(filePath, data) {
307
+ const tmpPath = filePath + '.tmp.' + process.pid;
308
+ fs.writeFileSync(tmpPath, data);
309
+ fs.renameSync(tmpPath, filePath);
310
+ }
291
311
 
292
312
  const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
293
313
  if (!fs.existsSync(configPath)) {
@@ -365,7 +385,7 @@ try {
365
385
  console.log(' Allowlist already up to date');
366
386
  }
367
387
  if (changed) {
368
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
388
+ atomicWrite(configPath, JSON.stringify(config, null, 2));
369
389
  }
370
390
  } catch (err) {
371
391
  console.log(' Could not update config:', err.message);
@@ -379,6 +399,11 @@ const os = require('os');
379
399
  const fs = require('fs');
380
400
  const path = require('path');
381
401
  const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
402
+ function atomicWrite(filePath, data) {
403
+ const tmpPath = filePath + '.tmp.' + process.pid;
404
+ fs.writeFileSync(tmpPath, data);
405
+ fs.renameSync(tmpPath, filePath);
406
+ }
382
407
 
383
408
  if (fs.existsSync(configPath)) {
384
409
  try {
@@ -396,7 +421,7 @@ if (fs.existsSync(configPath)) {
396
421
  console.log(' Plugin already in allow list');
397
422
  }
398
423
 
399
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
424
+ atomicWrite(configPath, JSON.stringify(config, null, 2));
400
425
  } catch (e) {
401
426
  console.log(' Could not update config:', e.message);
402
427
  }
package/scripts/update.sh CHANGED
@@ -218,6 +218,11 @@ const fs = require('fs');
218
218
  const path = require('path');
219
219
  const authDir = path.join(os.homedir(), '.openclaw', 'agents', 'main', 'agent');
220
220
  const authPath = path.join(authDir, 'auth-profiles.json');
221
+ function atomicWrite(filePath, data) {
222
+ const tmpPath = filePath + '.tmp.' + process.pid;
223
+ fs.writeFileSync(tmpPath, data);
224
+ fs.renameSync(tmpPath, filePath);
225
+ }
221
226
 
222
227
  fs.mkdirSync(authDir, { recursive: true });
223
228
 
@@ -232,7 +237,7 @@ if (fs.existsSync(authPath)) {
232
237
  const profileKey = 'blockrun:default';
233
238
  if (!store.profiles[profileKey]) {
234
239
  store.profiles[profileKey] = { type: 'api_key', provider: 'blockrun', key: 'x402-proxy-handles-auth' };
235
- fs.writeFileSync(authPath, JSON.stringify(store, null, 2));
240
+ atomicWrite(authPath, JSON.stringify(store, null, 2));
236
241
  console.log(' Auth profile created');
237
242
  } else {
238
243
  console.log(' Auth profile already exists');
@@ -1,157 +0,0 @@
1
- # ClawRouter vs OpenRouter
2
-
3
- OpenRouter is a popular LLM routing service. Here's why ClawRouter is built differently — and why it matters for agents.
4
-
5
- ## TL;DR
6
-
7
- **OpenRouter is built for developers. ClawRouter is built for agents.**
8
-
9
- | Aspect | OpenRouter | ClawRouter |
10
- | ------------------ | ------------------------------------- | -------------------------------------- |
11
- | **Setup** | Human creates account, pastes API key | Agent generates wallet, receives funds |
12
- | **Authentication** | API key (shared secret) | Wallet signature (cryptographic) |
13
- | **Payment** | Prepaid balance (custodial) | Per-request USDC (non-custodial) |
14
- | **Routing** | Server-side, proprietary | Client-side, open source, <1ms |
15
- | **Rate limits** | Per-key quotas | None (your wallet, your limits) |
16
- | **Empty balance** | Request fails | Auto-fallback to free tier |
17
-
18
- ---
19
-
20
- ## The Problem with API Keys
21
-
22
- OpenRouter (and every traditional LLM gateway) uses API keys for authentication. This breaks agent autonomy:
23
-
24
- ### 1. Key Leakage in LLM Context
25
-
26
- **OpenClaw Issue [#11202](https://github.com/openclaw/openclaw/issues/11202)**: API keys configured in `openclaw.json` are resolved and serialized into every LLM request payload. Every provider sees every other provider's keys.
27
-
28
- > "OpenRouter sees your NVIDIA key, Anthropic sees your Google key... keys are sent on every turn."
29
-
30
- **ClawRouter**: No API keys. Authentication happens via cryptographic wallet signatures. There's nothing to leak because there are no shared secrets.
31
-
32
- ### 2. Rate Limit Hell
33
-
34
- **OpenClaw Issue [#8615](https://github.com/openclaw/openclaw/issues/8615)**: Single API key support means heavy users hit rate limits (429 errors) quickly. Users request multi-key load balancing, but that's just patching a broken model.
35
-
36
- **ClawRouter**: Non-custodial wallets. You control your own keys. No shared rate limits. Scale by funding more wallets if needed.
37
-
38
- ### 3. Setup Friction
39
-
40
- **OpenClaw Issues [#16257](https://github.com/openclaw/openclaw/issues/16257), [#16226](https://github.com/openclaw/openclaw/issues/16226)**: Latest installer skips model selection, shows "No auth configured for provider anthropic". Users can't even get started without debugging config.
41
-
42
- **ClawRouter**: One-line install. 30+ models auto-configured. No API keys to paste.
43
-
44
- ### 4. Model Path Collision
45
-
46
- **OpenClaw Issue [#2373](https://github.com/openclaw/openclaw/issues/2373)**: `openrouter/auto` is broken because OpenClaw prefixes all OpenRouter models with `openrouter/`, so the actual model becomes `openrouter/openrouter/auto`.
47
-
48
- **ClawRouter**: Clean namespace. `blockrun/auto` just works. No prefix collision.
49
-
50
- ### 5. False Billing Errors
51
-
52
- **OpenClaw Issue [#16237](https://github.com/openclaw/openclaw/issues/16237)**: The regex `/\b402\b/` falsely matches normal content (e.g., "402 calories") as a billing error, replacing valid AI responses with error messages.
53
-
54
- **ClawRouter**: Native x402 protocol support. Precise error handling. No regex hacks.
55
-
56
- ### 6. Unknown Model Failures
57
-
58
- **OpenClaw Issues [#16277](https://github.com/openclaw/openclaw/issues/16277), [#10687](https://github.com/openclaw/openclaw/issues/10687)**: Static model catalog causes "Unknown model" errors when providers add new models or during sub-agent spawns.
59
-
60
- **ClawRouter**: 30+ models pre-configured, auto-updated catalog.
61
-
62
- ---
63
-
64
- ## Agent-Native: Why It Matters
65
-
66
- Traditional LLM gateways require a human in the loop:
67
-
68
- ```
69
- Traditional Flow (Human-in-the-loop):
70
- Human → creates account → gets API key → pastes into config → agent runs
71
-
72
- Agent-Native Flow (Fully autonomous):
73
- Agent → generates wallet → receives USDC → pays per request → runs
74
- ```
75
-
76
- | Capability | OpenRouter | ClawRouter |
77
- | -------------------- | ----------------------- | -------------------------- |
78
- | **Account creation** | Requires human | Agent generates wallet |
79
- | **Authentication** | Shared secret (API key) | Cryptographic signature |
80
- | **Payment** | Human prepays balance | Agent pays per request |
81
- | **Funds custody** | They hold your money | You hold your keys |
82
- | **Empty balance** | Request fails | Auto-fallback to free tier |
83
-
84
- ### The x402 Difference
85
-
86
- ```
87
- Request → 402 Response (price: $0.003)
88
- → Agent's wallet signs payment
89
- → Response delivered
90
-
91
- No accounts. No API keys. No human intervention.
92
- ```
93
-
94
- **Agents can:**
95
-
96
- - Spawn with a fresh wallet
97
- - Receive funds programmatically
98
- - Pay for exactly what they use
99
- - Never trust a third party with their funds
100
-
101
- ---
102
-
103
- ## Routing: Cloud vs Local
104
-
105
- ### OpenRouter
106
-
107
- - Routing decisions happen on OpenRouter's servers
108
- - You trust their proprietary algorithm
109
- - No visibility into why a model was chosen
110
- - Adds latency for every request
111
-
112
- ### ClawRouter
113
-
114
- - **100% local routing** — 15-dimension weighted scoring runs on YOUR machine
115
- - **<1ms decisions** — no API calls for routing
116
- - **Open source** — inspect the exact scoring logic in [`src/router.ts`](../src/router.ts)
117
- - **Transparent** — see why each model is chosen
118
-
119
- ---
120
-
121
- ## Quick Start
122
-
123
- Already using OpenRouter? Switch in 60 seconds:
124
-
125
- ```bash
126
- # 1. Install ClawRouter
127
- curl -fsSL https://blockrun.ai/ClawRouter-update | bash
128
-
129
- # 2. Restart gateway
130
- openclaw gateway restart
131
-
132
- # 3. Fund wallet (address shown during install)
133
- # $5 USDC on Base = thousands of requests
134
-
135
- # 4. Switch model
136
- /model blockrun/auto
137
- ```
138
-
139
- Your OpenRouter config stays intact — ClawRouter is additive, not replacement.
140
-
141
- ---
142
-
143
- ## Summary
144
-
145
- > **OpenRouter**: Built for developers who paste API keys
146
- >
147
- > **ClawRouter**: Built for agents that manage their own wallets
148
-
149
- The future of AI isn't humans configuring API keys. It's agents autonomously acquiring and paying for resources.
150
-
151
- ---
152
-
153
- <div align="center">
154
-
155
- **Questions?** [Telegram](https://t.me/blockrunAI) · [X](https://x.com/BlockRunAI) · [GitHub](https://github.com/BlockRunAI/ClawRouter)
156
-
157
- </div>