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