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 entries = (plugins.entries as Record<string, unknown>) || {};
|
||||||
const entry = (entries.whispergate as Record<string, unknown>) || {};
|
const entry = (entries.whispergate as Record<string, unknown>) || {};
|
||||||
const cfg = (entry.config 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;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,12 +212,18 @@ export default {
|
|||||||
id: "whispergate",
|
id: "whispergate",
|
||||||
name: "WhisperGate",
|
name: "WhisperGate",
|
||||||
register(api: OpenClawPluginApi) {
|
register(api: OpenClawPluginApi) {
|
||||||
const baseConfig = (api.pluginConfig || {}) as WhisperGateConfig & {
|
// Merge pluginConfig with defaults (in case config is missing from openclaw.json)
|
||||||
enableDiscordControlTool?: boolean;
|
const baseConfig = {
|
||||||
discordControlApiBaseUrl?: string;
|
enableDiscordControlTool: true,
|
||||||
|
enableWhispergatePolicyTool: true,
|
||||||
|
discordControlApiBaseUrl: "http://127.0.0.1:8790",
|
||||||
|
...(api.pluginConfig || {}),
|
||||||
|
} as WhisperGateConfig & {
|
||||||
|
enableDiscordControlTool: boolean;
|
||||||
|
discordControlApiBaseUrl: string;
|
||||||
discordControlApiToken?: string;
|
discordControlApiToken?: string;
|
||||||
discordControlCallerId?: string;
|
discordControlCallerId?: string;
|
||||||
enableWhispergatePolicyTool?: boolean;
|
enableWhispergatePolicyTool: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const liveAtRegister = getLivePluginConfig(api, baseConfig as WhisperGateConfig);
|
const liveAtRegister = getLivePluginConfig(api, baseConfig as WhisperGateConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user