fix: load plugin config from api.pluginConfig

This commit is contained in:
nav
2026-03-30 11:47:42 +00:00
parent a2b965094d
commit 1ac75f429c

View File

@@ -26,6 +26,10 @@ function resolveOpenclawPath(config?: { openclawProfilePath?: string }): string
return require('path').join(home, '.openclaw');
}
function getPluginConfig(api: any): Record<string, unknown> {
return ((api?.pluginConfig as Record<string, unknown> | undefined) || {});
}
function resolveProxyAllowlist(config?: { proxyAllowlist?: unknown; 'proxy-allowlist'?: unknown }): string[] {
const value = config?.proxyAllowlist ?? config?.['proxy-allowlist'];
if (!Array.isArray(value)) return [];
@@ -33,13 +37,14 @@ function resolveProxyAllowlist(config?: { proxyAllowlist?: unknown; 'proxy-allow
}
// Plugin registration function
function register(api: any, config?: any) {
function register(api: any) {
const logger = api.logger || { info: console.log, error: console.error };
logger.info('PaddedCell plugin initializing...');
const openclawPath = resolveOpenclawPath(config);
const proxyAllowlist = resolveProxyAllowlist(config);
const pluginConfig = getPluginConfig(api);
const openclawPath = resolveOpenclawPath(pluginConfig as { openclawProfilePath?: string });
const proxyAllowlist = resolveProxyAllowlist(pluginConfig as { proxyAllowlist?: unknown; 'proxy-allowlist'?: unknown });
const binDir = require('path').join(openclawPath, 'bin');
// Register pcexec tool — pass a FACTORY function that receives context
@@ -112,10 +117,6 @@ function register(api: any, config?: any) {
async execute(_id: string, params: any) {
const command = params.command;
const proxyFor = params['proxy-for'];
logger.info('proxy-pcexec auth check', {
agentId,
proxyAllowlist,
});
if (!command) {
throw new Error('Missing required parameter: command');
}