Skip to content

Commit 2fa531c

Browse files
committed
fix: auto-clean stale plugins.allow entries during reinstall/update
AI agents sometimes add bare plugin names like "wallet" to plugins.allow (e.g. trying to enable an OpenClaw built-in), causing: - "plugin not found: wallet" warning on every gateway start - ClawRouter not loading if "clawrouter" gets overwritten Both reinstall.sh and update.sh now strip any bare single-word entries that aren't in the known bundled OpenClaw plugin list, preserving scoped packages (@scope/name) and slash-prefixed IDs. "clawrouter" is always removed here and re-added cleanly later in the script.
1 parent ec2975d commit 2fa531c

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blockrun/clawrouter",
3-
"version": "0.12.117",
3+
"version": "0.12.118",
44
"description": "Smart LLM router — save 85% on inference costs. 55+ models (11 free), one wallet, x402 micropayments.",
55
"type": "module",
66
"main": "dist/index.js",

scripts/reinstall.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,31 @@ try {
172172
// Clean plugin entries
173173
if (c.plugins?.entries?.clawrouter) delete c.plugins.entries.clawrouter;
174174
if (c.plugins?.installs?.clawrouter) delete c.plugins.installs.clawrouter;
175-
// Clean plugins.allow (removes stale clawrouter reference)
175+
176+
// Clean plugins.allow — remove clawrouter (will be re-added after install)
177+
// and strip any non-bundled plugin names that don't exist (e.g. "wallet" added
178+
// by an AI agent trying to fix a different problem — causes a warning on every start).
176179
if (Array.isArray(c.plugins?.allow)) {
177-
c.plugins.allow = c.plugins.allow.filter(p => p !== 'clawrouter' && p !== '@blockrun/clawrouter');
180+
const BUNDLED_OPENCLAW_PLUGINS = [
181+
// OpenClaw v2026.x bundled plugin IDs (safe to keep in allow list)
182+
'http', 'mcp', 'computer-use', 'browser', 'code', 'image', 'voice',
183+
'search', 'memory', 'calendar', 'email', 'slack', 'discord', 'telegram',
184+
'whatsapp', 'matrix', 'teams', 'notion', 'github', 'jira', 'linear',
185+
'comfyui', 'crossmint',
186+
];
187+
const before = c.plugins.allow.length;
188+
c.plugins.allow = c.plugins.allow.filter(p => {
189+
if (p === 'clawrouter' || p === '@blockrun/clawrouter') return false; // re-added later
190+
if (BUNDLED_OPENCLAW_PLUGINS.includes(p)) return true; // known-good bundled plugins
191+
// Keep entries that look like npm package names (scoped or plain)
192+
if (p.startsWith('@') || p.includes('/')) return true;
193+
// Drop bare single-word entries that aren't bundled (e.g. "wallet" added by mistake)
194+
return false;
195+
});
196+
const removed = before - c.plugins.allow.length;
197+
if (removed > 0) console.log(' Removed ' + removed + ' stale plugins.allow entry(ies)');
178198
}
199+
179200
atomicWrite(f, JSON.stringify(c, null, 2));
180201
console.log(' Config cleaned');
181202
"

scripts/update.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,41 @@ const configPath = '$CONFIG_PATH';
172172
if (!fs.existsSync(configPath)) process.exit(0);
173173
try {
174174
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
175+
let changed = false;
176+
177+
// Remove stale plugin entry
175178
const entries = config?.plugins?.entries;
176179
if (entries && entries.clawrouter) {
177180
delete entries.clawrouter;
181+
changed = true;
182+
console.log(' Removed stale plugin entry');
183+
}
184+
185+
// Clean plugins.allow — remove clawrouter (re-added later) and any stale bare
186+
// single-word entries that aren't bundled OpenClaw plugins (e.g. "wallet" added
187+
// by an AI agent — shows a warning on every gateway start).
188+
if (Array.isArray(config?.plugins?.allow)) {
189+
const BUNDLED = [
190+
'http','mcp','computer-use','browser','code','image','voice',
191+
'search','memory','calendar','email','slack','discord','telegram',
192+
'whatsapp','matrix','teams','notion','github','jira','linear',
193+
'comfyui','crossmint',
194+
];
195+
const before = config.plugins.allow.length;
196+
config.plugins.allow = config.plugins.allow.filter(p => {
197+
if (p === 'clawrouter' || p === '@blockrun/clawrouter') return false;
198+
if (BUNDLED.includes(p)) return true;
199+
if (p.startsWith('@') || p.includes('/')) return true;
200+
return false;
201+
});
202+
const removed = before - config.plugins.allow.length;
203+
if (removed > 0) { changed = true; console.log(' Removed ' + removed + ' stale plugins.allow entry(ies)'); }
204+
}
205+
206+
if (changed) {
178207
const tmp = configPath + '.tmp.' + process.pid;
179208
fs.writeFileSync(tmp, JSON.stringify(config, null, 2));
180209
fs.renameSync(tmp, configPath);
181-
console.log(' Removed stale plugin entry');
182210
} else {
183211
console.log(' Config clean');
184212
}

0 commit comments

Comments
 (0)