HarborForge.OpenclawPlugin: dev-2026-03-29 -> main #4

Merged
hzhang merged 15 commits from dev-2026-03-29 into main 2026-04-05 22:09:30 +00:00
Showing only changes of commit f3a38d6455 - Show all commits

View File

@@ -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;
}
}