fix: add default values for optional config fields
- Add default values for enableDiscordControlTool, enableWhispergatePolicyTool, discordControlApiBaseUrl, enableDebugLogs, debugLogChannelIds - Merge defaults in both baseConfig and getLivePluginConfig - Fixes issue where whispergateway_tools tool was not exposed due to missing config fields in openclaw.json
This commit is contained in:
@@ -116,7 +116,17 @@ function getLivePluginConfig(api: OpenClawPluginApi, fallback: WhisperGateConfig
|
||||
const entries = (plugins.entries as Record<string, unknown>) || {};
|
||||
const entry = (entries.whispergate as Record<string, unknown>) || {};
|
||||
const cfg = (entry.config as Record<string, unknown>) || {};
|
||||
if (Object.keys(cfg).length > 0) return cfg as unknown as WhisperGateConfig;
|
||||
if (Object.keys(cfg).length > 0) {
|
||||
// Merge with defaults to ensure optional fields have values
|
||||
return {
|
||||
enableDiscordControlTool: true,
|
||||
enableWhispergatePolicyTool: true,
|
||||
discordControlApiBaseUrl: "http://127.0.0.1:8790",
|
||||
enableDebugLogs: false,
|
||||
debugLogChannelIds: [],
|
||||
...cfg,
|
||||
} as WhisperGateConfig;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
@@ -202,12 +212,18 @@ export default {
|
||||
id: "whispergate",
|
||||
name: "WhisperGate",
|
||||
register(api: OpenClawPluginApi) {
|
||||
const baseConfig = (api.pluginConfig || {}) as WhisperGateConfig & {
|
||||
enableDiscordControlTool?: boolean;
|
||||
discordControlApiBaseUrl?: string;
|
||||
// Merge pluginConfig with defaults (in case config is missing from openclaw.json)
|
||||
const baseConfig = {
|
||||
enableDiscordControlTool: true,
|
||||
enableWhispergatePolicyTool: true,
|
||||
discordControlApiBaseUrl: "http://127.0.0.1:8790",
|
||||
...(api.pluginConfig || {}),
|
||||
} as WhisperGateConfig & {
|
||||
enableDiscordControlTool: boolean;
|
||||
discordControlApiBaseUrl: string;
|
||||
discordControlApiToken?: string;
|
||||
discordControlCallerId?: string;
|
||||
enableWhispergatePolicyTool?: boolean;
|
||||
enableWhispergatePolicyTool: boolean;
|
||||
};
|
||||
|
||||
const liveAtRegister = getLivePluginConfig(api, baseConfig as WhisperGateConfig);
|
||||
|
||||
Reference in New Issue
Block a user