From 6454004d662975c0d3063cb2b1b31622b8d2f5d4 Mon Sep 17 00:00:00 2001 From: zhi Date: Thu, 5 Mar 2026 12:44:39 +0000 Subject: [PATCH] fix: correct OpenClaw config order - load.paths before allow - OpenClaw validates plugin exists in load.paths before allowing it in allow list - Reorder: 1) load.paths, 2) allow, 3) entries --- install.mjs | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/install.mjs b/install.mjs index 1282356..cecf888 100755 --- a/install.mjs +++ b/install.mjs @@ -95,7 +95,7 @@ function getOpenclawConfig(pathKey, defaultValue = undefined) { } function setOpenclawConfig(pathKey, value) { - const cmd = `openclaw config set ${pathKey} --json '${JSON.stringify(value)}'`; + const cmd = `openclaw config set ${pathKey} '${JSON.stringify(value)}' --json`; execSync(cmd, { cwd: __dirname, encoding: 'utf8' }); } @@ -365,7 +365,25 @@ async function configure(env) { log('\n Configuring OpenClaw plugin...', 'blue'); try { - // 1. Add to plugins.allow + // 1. Add plugin path to plugins.load.paths FIRST (required for validation) + const currentPaths = getOpenclawConfig('plugins.load.paths', []); + log(` Current paths: ${JSON.stringify(currentPaths)}`, 'blue'); + log(` DIST_DIR: ${DIST_DIR}`, 'blue'); + if (!currentPaths.includes(DIST_DIR)) { + currentPaths.push(DIST_DIR); + log(` Adding plugin path...`, 'blue'); + try { + setOpenclawConfig('plugins.load.paths', currentPaths); + logSuccess(`Added ${DIST_DIR} to plugins.load.paths`); + } catch (err) { + logError(`Failed to set paths: ${err.message}`); + throw err; + } + } else { + log(' Plugin path already in plugins.load.paths', 'green'); + } + + // 2. Add to plugins.allow (after path is set) const allowList = getOpenclawConfig('plugins.allow', []); if (!allowList.includes(PLUGIN_NAME)) { allowList.push(PLUGIN_NAME); @@ -375,7 +393,7 @@ async function configure(env) { log(' Already in plugins.allow', 'green'); } - // 2. Add plugin entry + // 3. Add plugin entry const plugins = getOpenclawConfig('plugins', {}); plugins.entries = plugins.entries || {}; plugins.entries[PLUGIN_NAME] = { @@ -387,16 +405,6 @@ async function configure(env) { }; setOpenclawConfig('plugins', plugins); logSuccess(`Configured ${PLUGIN_NAME} plugin entry`); - - // 3. Add plugin path to plugins.load.paths - const currentPaths = getOpenclawConfig('plugins.load.paths', []); - if (!currentPaths.includes(DIST_DIR)) { - currentPaths.push(DIST_DIR); - setOpenclawConfig('plugins.load.paths', currentPaths); - logSuccess(`Added ${DIST_DIR} to plugins.load.paths`); - } else { - log(' Plugin path already in plugins.load.paths', 'green'); - } } catch (err) { logWarning(`Failed to configure OpenClaw: ${err.message}`); log(' Please manually configure:', 'yellow');