From f3a38d64556d914fccd7759ab92de1c999bfd2df Mon Sep 17 00:00:00 2001 From: orion Date: Sat, 4 Apr 2026 17:30:56 +0000 Subject: [PATCH] fix: verify plugin config during install --- scripts/install.mjs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/install.mjs b/scripts/install.mjs index f7dea8b..54c66e7 100644 --- a/scripts/install.mjs +++ b/scripts/install.mjs @@ -98,6 +98,14 @@ function setOpenclawConfig(key, value) { exec(`openclaw config set ${key} '${JSON.stringify(value)}' --json`, { silent: true }); } +function assertConfigValue(key, predicate, description) { + const value = getOpenclawConfig(key, undefined); + if (!predicate(value)) { + throw new Error(`Config verification failed for ${key}: ${description}`); + } + return value; +} + function unsetOpenclawConfig(key) { try { exec(`openclaw config unset ${key}`, { silent: true }); } catch {} } @@ -359,6 +367,7 @@ async function configure() { paths.push(destDir); setOpenclawConfig('plugins.load.paths', paths); } + assertConfigValue('plugins.load.paths', (value) => Array.isArray(value) && value.includes(destDir), `missing ${destDir}`); logOk(`plugins.load.paths includes ${destDir}`); const allow = getOpenclawConfig('plugins.allow', []); @@ -366,6 +375,7 @@ async function configure() { allow.push(PLUGIN_NAME); setOpenclawConfig('plugins.allow', allow); } + assertConfigValue('plugins.allow', (value) => Array.isArray(value) && value.includes(PLUGIN_NAME), `missing ${PLUGIN_NAME}`); logOk(`plugins.allow includes ${PLUGIN_NAME}`); const enabledKey = `plugins.entries.${PLUGIN_NAME}.enabled`; @@ -376,6 +386,8 @@ async function configure() { if (getOpenclawConfig(configEnabledKey, undefined) === undefined) { setOpenclawConfig(configEnabledKey, true); } + assertConfigValue(enabledKey, (value) => value === true, 'expected true'); + assertConfigValue(configEnabledKey, (value) => value === true, 'expected true'); if (options.installMonitor === 'yes') { const binaryPath = join(openclawPath, 'plugins', PLUGIN_NAME, 'bin', 'HarborForge.Monitor'); @@ -383,13 +395,15 @@ async function configure() { if (getOpenclawConfig(managedMonitorKey, undefined) === undefined) { setOpenclawConfig(managedMonitorKey, binaryPath); } + assertConfigValue(managedMonitorKey, (value) => value === binaryPath, `expected ${binaryPath}`); logOk(`managedMonitor configured → ${binaryPath}`); } logOk('Plugin configured (remember to set apiKey in plugins.entries.harbor-forge.config)'); } catch (err) { - logWarn(`Config failed: ${err.message}`); + logErr(`Config failed: ${err.message}`); + throw err; } }