@blockrun/clawrouter 0.12.55 → 0.12.60

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.55",
3
+ "version": "0.12.60",
4
4
  "description": "Smart LLM router — save 92% on inference costs. 41+ models, one wallet, x402 micropayments.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,7 +1,66 @@
1
1
  #!/bin/bash
2
2
  set -e
3
+ set -o pipefail
3
4
 
4
5
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ PLUGIN_DIR="$HOME/.openclaw/extensions/clawrouter"
7
+ CONFIG_PATH="$HOME/.openclaw/openclaw.json"
8
+ WALLET_FILE="$HOME/.openclaw/blockrun/wallet.key"
9
+ WALLET_BACKUP=""
10
+ PLUGIN_BACKUP=""
11
+ CONFIG_BACKUP=""
12
+
13
+ cleanup_backups() {
14
+ if [ -n "$PLUGIN_BACKUP" ] && [ -d "$PLUGIN_BACKUP" ]; then
15
+ rm -rf "$PLUGIN_BACKUP"
16
+ fi
17
+ if [ -n "$CONFIG_BACKUP" ] && [ -f "$CONFIG_BACKUP" ]; then
18
+ rm -f "$CONFIG_BACKUP"
19
+ fi
20
+ }
21
+
22
+ restore_previous_install() {
23
+ local exit_code=$?
24
+
25
+ if [ "$exit_code" -ne 0 ]; then
26
+ echo ""
27
+ echo "✗ Reinstall failed. Restoring previous ClawRouter install..."
28
+
29
+ if [ -d "$PLUGIN_DIR" ] && [ "$PLUGIN_DIR" != "$PLUGIN_BACKUP" ]; then
30
+ rm -rf "$PLUGIN_DIR"
31
+ fi
32
+
33
+ if [ -n "$PLUGIN_BACKUP" ] && [ -d "$PLUGIN_BACKUP" ]; then
34
+ mv "$PLUGIN_BACKUP" "$PLUGIN_DIR"
35
+ echo " ✓ Restored previous plugin files"
36
+ fi
37
+
38
+ if [ -n "$CONFIG_BACKUP" ] && [ -f "$CONFIG_BACKUP" ]; then
39
+ cp "$CONFIG_BACKUP" "$CONFIG_PATH"
40
+ echo " ✓ Restored previous OpenClaw config"
41
+ fi
42
+ fi
43
+
44
+ cleanup_backups
45
+ }
46
+
47
+ run_dependency_install() {
48
+ local plugin_dir="$1"
49
+ local log_file
50
+ log_file="$(mktemp -t clawrouter-reinstall-npm.XXXXXX.log)"
51
+
52
+ if (cd "$plugin_dir" && npm install --omit=dev >"$log_file" 2>&1); then
53
+ tail -1 "$log_file"
54
+ rm -f "$log_file"
55
+ else
56
+ echo " npm install failed. Last 20 log lines:" >&2
57
+ tail -20 "$log_file" >&2 || true
58
+ echo " Full log: $log_file" >&2
59
+ return 1
60
+ fi
61
+ }
62
+
63
+ trap restore_previous_install EXIT
5
64
 
6
65
  kill_port_processes() {
7
66
  local port="$1"
@@ -29,9 +88,6 @@ echo "🦞 ClawRouter Reinstall"
29
88
  echo ""
30
89
 
31
90
  # 0. Back up wallet key BEFORE removing anything
32
- WALLET_FILE="$HOME/.openclaw/blockrun/wallet.key"
33
- WALLET_BACKUP=""
34
-
35
91
  echo "→ Backing up wallet..."
36
92
  if [ -f "$WALLET_FILE" ]; then
37
93
  WALLET_KEY=$(cat "$WALLET_FILE" | tr -d '[:space:]')
@@ -49,9 +105,22 @@ else
49
105
  fi
50
106
  echo ""
51
107
 
52
- # 1. Remove plugin files
53
- echo "→ Removing plugin files..."
54
- rm -rf ~/.openclaw/extensions/clawrouter
108
+ # 0.5 Back up existing install for rollback
109
+ echo "→ Backing up existing install..."
110
+ if [ -d "$PLUGIN_DIR" ]; then
111
+ PLUGIN_BACKUP="$HOME/.openclaw/extensions/clawrouter.backup.$(date +%s)"
112
+ mv "$PLUGIN_DIR" "$PLUGIN_BACKUP"
113
+ echo " ✓ Plugin files staged at: $PLUGIN_BACKUP"
114
+ else
115
+ echo " ℹ No existing plugin files found"
116
+ fi
117
+
118
+ if [ -f "$CONFIG_PATH" ]; then
119
+ CONFIG_BACKUP="$CONFIG_PATH.clawrouter-reinstall.$(date +%s).bak"
120
+ cp "$CONFIG_PATH" "$CONFIG_BACKUP"
121
+ echo " ✓ Config backed up to: $CONFIG_BACKUP"
122
+ fi
123
+ echo ""
55
124
 
56
125
  # 2. Clean config entries
57
126
  echo "→ Cleaning config entries..."
@@ -86,7 +155,10 @@ if (Array.isArray(c.plugins?.allow)) {
86
155
  c.plugins.allow = c.plugins.allow.filter(p => p !== 'clawrouter' && p !== '@blockrun/clawrouter');
87
156
  }
88
157
  // Remove deprecated model aliases from picker
89
- const deprecated = ['blockrun/mini', 'blockrun/nvidia', 'blockrun/gpt', 'blockrun/o3', 'blockrun/grok'];
158
+ const deprecated = [
159
+ 'blockrun/xai/grok-code-fast-1', // delisted 2026-03-12
160
+ 'blockrun/xai/grok-3-fast', // removed (too expensive)
161
+ ];
90
162
  if (c.agents?.defaults?.models) {
91
163
  for (const key of deprecated) {
92
164
  if (c.agents.defaults.models[key]) {
@@ -188,11 +260,11 @@ openclaw plugins install @blockrun/clawrouter
188
260
 
189
261
  # 6.1. Verify installation (check dist/ files exist)
190
262
  echo "→ Verifying installation..."
191
- DIST_PATH="$HOME/.openclaw/extensions/clawrouter/dist/index.js"
263
+ DIST_PATH="$PLUGIN_DIR/dist/index.js"
192
264
  if [ ! -f "$DIST_PATH" ]; then
193
265
  echo " ⚠️ dist/ files missing, clearing npm cache and retrying..."
194
266
  npm cache clean --force 2>/dev/null || true
195
- rm -rf ~/.openclaw/extensions/clawrouter
267
+ rm -rf "$PLUGIN_DIR"
196
268
  openclaw plugins install @blockrun/clawrouter
197
269
 
198
270
  if [ ! -f "$DIST_PATH" ]; then
@@ -205,10 +277,9 @@ echo " ✓ dist/index.js verified"
205
277
 
206
278
  # 6.1b. Ensure all dependencies are installed (Solana, x402, etc.)
207
279
  # openclaw's plugin installer may skip native deps like @solana/kit.
208
- PLUGIN_DIR="$HOME/.openclaw/extensions/clawrouter"
209
280
  if [ -d "$PLUGIN_DIR" ] && [ -f "$PLUGIN_DIR/package.json" ]; then
210
281
  echo "→ Installing dependencies (Solana, x402, etc.)..."
211
- (cd "$PLUGIN_DIR" && npm install --omit=dev 2>&1 | tail -1)
282
+ run_dependency_install "$PLUGIN_DIR"
212
283
  fi
213
284
 
214
285
  # 6.2. Populate model allowlist so top BlockRun models appear in /model picker
@@ -240,14 +311,15 @@ try {
240
311
  changed = true;
241
312
  }
242
313
 
243
- // Top 16 models for the /model picker
314
+ // Curated models for the /model picker
244
315
  const TOP_MODELS = [
245
316
  'auto', 'free', 'eco', 'premium',
246
317
  'anthropic/claude-sonnet-4.6', 'anthropic/claude-opus-4.6', 'anthropic/claude-haiku-4.5',
247
318
  'openai/gpt-5.4', 'openai/gpt-5.3', 'openai/gpt-5.3-codex', 'openai/gpt-4o', 'openai/o3',
248
319
  'google/gemini-3.1-pro', 'google/gemini-3-flash-preview',
249
320
  'deepseek/deepseek-chat', 'moonshot/kimi-k2.5',
250
- 'xai/grok-3', 'minimax/minimax-m2.5'
321
+ 'xai/grok-3', 'minimax/minimax-m2.5',
322
+ 'zai/glm-5', 'zai/glm-5-turbo'
251
323
  ];
252
324
 
253
325
  if (!config.agents) config.agents = {};
@@ -258,12 +330,16 @@ try {
258
330
  }
259
331
 
260
332
  const allowlist = config.agents.defaults.models;
261
- // Clean out old blockrun entries not in TOP_MODELS
262
- const topSet = new Set(TOP_MODELS.map(id => 'blockrun/' + id));
263
- for (const key of Object.keys(allowlist)) {
264
- if (key.startsWith('blockrun/') && !topSet.has(key)) {
333
+ const DEPRECATED_MODELS = [
334
+ 'blockrun/xai/grok-code-fast-1',
335
+ 'blockrun/xai/grok-3-fast'
336
+ ];
337
+ let removed = 0;
338
+ for (const key of DEPRECATED_MODELS) {
339
+ if (allowlist[key]) {
265
340
  delete allowlist[key];
266
341
  changed = true;
342
+ removed++;
267
343
  }
268
344
  }
269
345
  let added = 0;
@@ -277,7 +353,11 @@ try {
277
353
  if (added > 0) {
278
354
  changed = true;
279
355
  console.log(' Added ' + added + ' models to allowlist (' + TOP_MODELS.length + ' total)');
280
- } else {
356
+ }
357
+ if (removed > 0) {
358
+ console.log(' Removed ' + removed + ' deprecated models from allowlist');
359
+ }
360
+ if (added === 0 && removed === 0) {
281
361
  console.log(' Allowlist already up to date');
282
362
  }
283
363
  if (changed) {
package/scripts/update.sh CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/bin/bash
2
2
  set -e
3
+ set -o pipefail
3
4
 
4
5
  # ─────────────────────────────────────────────────────────────
5
6
  # ClawRouter Update Script
@@ -7,8 +8,64 @@ set -e
7
8
  # restores it if the update process somehow wiped it.
8
9
  # ─────────────────────────────────────────────────────────────
9
10
 
11
+ PLUGIN_DIR="$HOME/.openclaw/extensions/clawrouter"
12
+ CONFIG_PATH="$HOME/.openclaw/openclaw.json"
10
13
  WALLET_FILE="$HOME/.openclaw/blockrun/wallet.key"
11
14
  WALLET_BACKUP=""
15
+ PLUGIN_BACKUP=""
16
+ CONFIG_BACKUP=""
17
+
18
+ cleanup_backups() {
19
+ if [ -n "$PLUGIN_BACKUP" ] && [ -d "$PLUGIN_BACKUP" ]; then
20
+ rm -rf "$PLUGIN_BACKUP"
21
+ fi
22
+ if [ -n "$CONFIG_BACKUP" ] && [ -f "$CONFIG_BACKUP" ]; then
23
+ rm -f "$CONFIG_BACKUP"
24
+ fi
25
+ }
26
+
27
+ restore_previous_install() {
28
+ local exit_code=$?
29
+
30
+ if [ "$exit_code" -ne 0 ]; then
31
+ echo ""
32
+ echo "✗ Update failed. Restoring previous ClawRouter install..."
33
+
34
+ if [ -d "$PLUGIN_DIR" ] && [ "$PLUGIN_DIR" != "$PLUGIN_BACKUP" ]; then
35
+ rm -rf "$PLUGIN_DIR"
36
+ fi
37
+
38
+ if [ -n "$PLUGIN_BACKUP" ] && [ -d "$PLUGIN_BACKUP" ]; then
39
+ mv "$PLUGIN_BACKUP" "$PLUGIN_DIR"
40
+ echo " ✓ Restored previous plugin files"
41
+ fi
42
+
43
+ if [ -n "$CONFIG_BACKUP" ] && [ -f "$CONFIG_BACKUP" ]; then
44
+ cp "$CONFIG_BACKUP" "$CONFIG_PATH"
45
+ echo " ✓ Restored previous OpenClaw config"
46
+ fi
47
+ fi
48
+
49
+ cleanup_backups
50
+ }
51
+
52
+ run_dependency_install() {
53
+ local plugin_dir="$1"
54
+ local log_file
55
+ log_file="$(mktemp -t clawrouter-update-npm.XXXXXX.log)"
56
+
57
+ if (cd "$plugin_dir" && npm install --omit=dev >"$log_file" 2>&1); then
58
+ tail -1 "$log_file"
59
+ rm -f "$log_file"
60
+ else
61
+ echo " npm install failed. Last 20 log lines:" >&2
62
+ tail -20 "$log_file" >&2 || true
63
+ echo " Full log: $log_file" >&2
64
+ return 1
65
+ fi
66
+ }
67
+
68
+ trap restore_previous_install EXIT
12
69
 
13
70
  # ── Step 1: Back up wallet key ─────────────────────────────────
14
71
  echo "🦞 ClawRouter Update"
@@ -49,6 +106,23 @@ fi
49
106
 
50
107
  echo ""
51
108
 
109
+ echo "→ Backing up existing install..."
110
+ if [ -d "$PLUGIN_DIR" ]; then
111
+ PLUGIN_BACKUP="$HOME/.openclaw/extensions/clawrouter.backup.$(date +%s)"
112
+ mv "$PLUGIN_DIR" "$PLUGIN_BACKUP"
113
+ echo " ✓ Plugin files staged at: $PLUGIN_BACKUP"
114
+ else
115
+ echo " ℹ No existing plugin files found"
116
+ fi
117
+
118
+ if [ -f "$CONFIG_PATH" ]; then
119
+ CONFIG_BACKUP="$CONFIG_PATH.clawrouter-update.$(date +%s).bak"
120
+ cp "$CONFIG_PATH" "$CONFIG_BACKUP"
121
+ echo " ✓ Config backed up to: $CONFIG_BACKUP"
122
+ fi
123
+
124
+ echo ""
125
+
52
126
  # ── Step 2: Kill old proxy ──────────────────────────────────────
53
127
  echo "→ Stopping old proxy..."
54
128
  kill_port_processes() {
@@ -65,19 +139,14 @@ kill_port_processes() {
65
139
  }
66
140
  kill_port_processes 8402
67
141
 
68
- # ── Step 3: Remove old plugin files ────────────────────────────
69
- echo "→ Removing old plugin files..."
70
- rm -rf ~/.openclaw/extensions/clawrouter
71
-
72
- # ── Step 3b: Clean stale plugin entry from config ─────────────
73
- # After deleting plugin files, openclaw's config validator rejects
74
- # the orphaned plugins.entries.clawrouter reference. Remove it so
75
- # the fresh install in Step 4 can proceed.
142
+ # ── Step 3: Clean stale plugin entry from config ──────────────
143
+ # The old plugin dir is staged in a backup above. Remove the stale
144
+ # plugin entry so a fresh install can proceed, and restore it on error.
76
145
  echo "→ Cleaning config..."
77
146
  node -e "
78
147
  const fs = require('fs');
79
148
  const path = require('path');
80
- const configPath = path.join(require('os').homedir(), '.openclaw', 'openclaw.json');
149
+ const configPath = '$CONFIG_PATH';
81
150
  if (!fs.existsSync(configPath)) process.exit(0);
82
151
  try {
83
152
  const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
@@ -103,10 +172,9 @@ openclaw plugins install @blockrun/clawrouter
103
172
  # ── Step 4b: Ensure all dependencies are installed ────────────
104
173
  # openclaw's plugin installer may skip native/optional deps like @solana/kit.
105
174
  # Run npm install in the plugin directory to fill any gaps.
106
- PLUGIN_DIR="$HOME/.openclaw/extensions/clawrouter"
107
175
  if [ -d "$PLUGIN_DIR" ] && [ -f "$PLUGIN_DIR/package.json" ]; then
108
176
  echo "→ Installing dependencies (Solana, x402, etc.)..."
109
- (cd "$PLUGIN_DIR" && npm install --omit=dev 2>&1 | tail -1)
177
+ run_dependency_install "$PLUGIN_DIR"
110
178
  fi
111
179
 
112
180
  # ── Step 5: Verify wallet survived ─────────────────────────────
@@ -191,14 +259,15 @@ if (!fs.existsSync(configPath)) {
191
259
  try {
192
260
  const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
193
261
 
194
- // Top 16 models for the /model picker
262
+ // Curated models for the /model picker
195
263
  const TOP_MODELS = [
196
264
  'auto', 'free', 'eco', 'premium',
197
265
  'anthropic/claude-sonnet-4.6', 'anthropic/claude-opus-4.6', 'anthropic/claude-haiku-4.5',
198
266
  'openai/gpt-5.4', 'openai/gpt-5.3', 'openai/gpt-5.3-codex', 'openai/gpt-4o', 'openai/o3',
199
267
  'google/gemini-3.1-pro', 'google/gemini-3-flash-preview',
200
268
  'deepseek/deepseek-chat', 'moonshot/kimi-k2.5',
201
- 'xai/grok-3', 'minimax/minimax-m2.5'
269
+ 'xai/grok-3', 'minimax/minimax-m2.5',
270
+ 'zai/glm-5', 'zai/glm-5-turbo'
202
271
  ];
203
272
 
204
273
  if (!config.agents) config.agents = {};
@@ -208,11 +277,15 @@ try {
208
277
  }
209
278
 
210
279
  const allowlist = config.agents.defaults.models;
211
- // Clean out old blockrun entries not in TOP_MODELS
212
- const topSet = new Set(TOP_MODELS.map(id => 'blockrun/' + id));
213
- for (const key of Object.keys(allowlist)) {
214
- if (key.startsWith('blockrun/') && !topSet.has(key)) {
280
+ const DEPRECATED_MODELS = [
281
+ 'blockrun/xai/grok-code-fast-1',
282
+ 'blockrun/xai/grok-3-fast'
283
+ ];
284
+ let removed = 0;
285
+ for (const key of DEPRECATED_MODELS) {
286
+ if (allowlist[key]) {
215
287
  delete allowlist[key];
288
+ removed++;
216
289
  }
217
290
  }
218
291
  let added = 0;
@@ -229,9 +302,13 @@ try {
229
302
  fs.writeFileSync(tmpPath, JSON.stringify(config, null, 2));
230
303
  fs.renameSync(tmpPath, configPath);
231
304
 
305
+ if (removed > 0) {
306
+ console.log(' Removed ' + removed + ' deprecated models from allowlist');
307
+ }
232
308
  if (added > 0) {
233
309
  console.log(' Added ' + added + ' models to allowlist (' + TOP_MODELS.length + ' total)');
234
- } else {
310
+ }
311
+ if (added === 0 && removed === 0) {
235
312
  console.log(' Allowlist already up to date');
236
313
  }
237
314
  } catch (err) {