@blockrun/clawrouter 0.12.56 → 0.12.61
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 +93 -51
- package/dist/cli.js +456 -68
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +34 -0
- package/dist/index.js +601 -84
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/reinstall.sh +96 -17
- package/scripts/update.sh +93 -17
package/package.json
CHANGED
package/scripts/reinstall.sh
CHANGED
|
@@ -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
|
-
#
|
|
53
|
-
echo "→
|
|
54
|
-
|
|
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 = [
|
|
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="$
|
|
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
|
|
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
|
-
|
|
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,7 +311,7 @@ try {
|
|
|
240
311
|
changed = true;
|
|
241
312
|
}
|
|
242
313
|
|
|
243
|
-
//
|
|
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',
|
|
@@ -259,12 +330,16 @@ try {
|
|
|
259
330
|
}
|
|
260
331
|
|
|
261
332
|
const allowlist = config.agents.defaults.models;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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]) {
|
|
266
340
|
delete allowlist[key];
|
|
267
341
|
changed = true;
|
|
342
|
+
removed++;
|
|
268
343
|
}
|
|
269
344
|
}
|
|
270
345
|
let added = 0;
|
|
@@ -278,7 +353,11 @@ try {
|
|
|
278
353
|
if (added > 0) {
|
|
279
354
|
changed = true;
|
|
280
355
|
console.log(' Added ' + added + ' models to allowlist (' + TOP_MODELS.length + ' total)');
|
|
281
|
-
}
|
|
356
|
+
}
|
|
357
|
+
if (removed > 0) {
|
|
358
|
+
console.log(' Removed ' + removed + ' deprecated models from allowlist');
|
|
359
|
+
}
|
|
360
|
+
if (added === 0 && removed === 0) {
|
|
282
361
|
console.log(' Allowlist already up to date');
|
|
283
362
|
}
|
|
284
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:
|
|
69
|
-
|
|
70
|
-
|
|
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 =
|
|
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
|
-
|
|
177
|
+
run_dependency_install "$PLUGIN_DIR"
|
|
110
178
|
fi
|
|
111
179
|
|
|
112
180
|
# ── Step 5: Verify wallet survived ─────────────────────────────
|
|
@@ -191,7 +259,7 @@ if (!fs.existsSync(configPath)) {
|
|
|
191
259
|
try {
|
|
192
260
|
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
193
261
|
|
|
194
|
-
//
|
|
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',
|
|
@@ -209,11 +277,15 @@ try {
|
|
|
209
277
|
}
|
|
210
278
|
|
|
211
279
|
const allowlist = config.agents.defaults.models;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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]) {
|
|
216
287
|
delete allowlist[key];
|
|
288
|
+
removed++;
|
|
217
289
|
}
|
|
218
290
|
}
|
|
219
291
|
let added = 0;
|
|
@@ -230,9 +302,13 @@ try {
|
|
|
230
302
|
fs.writeFileSync(tmpPath, JSON.stringify(config, null, 2));
|
|
231
303
|
fs.renameSync(tmpPath, configPath);
|
|
232
304
|
|
|
305
|
+
if (removed > 0) {
|
|
306
|
+
console.log(' Removed ' + removed + ' deprecated models from allowlist');
|
|
307
|
+
}
|
|
233
308
|
if (added > 0) {
|
|
234
309
|
console.log(' Added ' + added + ' models to allowlist (' + TOP_MODELS.length + ' total)');
|
|
235
|
-
}
|
|
310
|
+
}
|
|
311
|
+
if (added === 0 && removed === 0) {
|
|
236
312
|
console.log(' Allowlist already up to date');
|
|
237
313
|
}
|
|
238
314
|
} catch (err) {
|