fix: add default values for optional config fields #3

Merged
hzhang merged 34 commits from feat/whispergate-mvp into main 2026-02-27 15:31:33 +00:00
Showing only changes of commit a4836097e4 - Show all commits

View File

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