fix(gateway): resolve startup hang caused by qqbot plugin manifest ID mismatch & stderr flood (#718)

This commit is contained in:
paisley
2026-03-30 18:27:48 +08:00
committed by GitHub
Unverified
parent aa2e4eae14
commit ec8db0be75
6 changed files with 115 additions and 12 deletions

View File

@@ -22,6 +22,7 @@ import {
const OPENCLAW_DIR = join(homedir(), '.openclaw');
const CONFIG_FILE = join(OPENCLAW_DIR, 'openclaw.json');
const WECOM_PLUGIN_ID = 'wecom';
const QQBOT_PLUGIN_ID = 'openclaw-qqbot';
const WECHAT_PLUGIN_ID = OPENCLAW_WECHAT_CHANNEL_TYPE;
const FEISHU_PLUGIN_ID_CANDIDATES = ['openclaw-lark', 'feishu-openclaw-plugin'] as const;
const DEFAULT_ACCOUNT_ID = 'default';
@@ -465,14 +466,33 @@ async function ensurePluginAllowlist(currentConfig: OpenClawConfig, channelType:
if (channelType === 'qqbot') {
if (!currentConfig.plugins) {
currentConfig.plugins = {};
}
currentConfig.plugins.enabled = true;
const allow = Array.isArray(currentConfig.plugins.allow)
? currentConfig.plugins.allow as string[]
: [];
if (!allow.includes('qqbot')) {
currentConfig.plugins.allow = [...allow, 'qqbot'];
currentConfig.plugins = {
allow: [QQBOT_PLUGIN_ID],
enabled: true,
entries: {
[QQBOT_PLUGIN_ID]: { enabled: true }
}
};
} else {
currentConfig.plugins.enabled = true;
const allow: string[] = Array.isArray(currentConfig.plugins.allow)
? (currentConfig.plugins.allow as string[])
: [];
// Normalize: remove bare 'qqbot' and ensure the actual manifest ID is present.
const normalizedAllow = allow.filter((pluginId) => pluginId !== 'qqbot');
if (!normalizedAllow.includes(QQBOT_PLUGIN_ID)) {
currentConfig.plugins.allow = [...normalizedAllow, QQBOT_PLUGIN_ID];
} else if (normalizedAllow.length !== allow.length) {
currentConfig.plugins.allow = normalizedAllow;
}
if (!currentConfig.plugins.entries) {
currentConfig.plugins.entries = {};
}
if (!currentConfig.plugins.entries[QQBOT_PLUGIN_ID]) {
currentConfig.plugins.entries[QQBOT_PLUGIN_ID] = {};
}
currentConfig.plugins.entries[QQBOT_PLUGIN_ID].enabled = true;
}
}

View File

@@ -1436,6 +1436,35 @@ export async function sanitizeOpenClawConfig(): Promise<void> {
modified = true;
}
// ── qqbot → openclaw-qqbot migration ────────────────────────
// The qqbot npm package (@tencent-connect/openclaw-qqbot) declares
// id="openclaw-qqbot" in its manifest, but older ClawX versions
// wrote bare "qqbot" into plugins.allow. Migrate to the manifest ID
// so the Gateway can resolve the plugin correctly.
const LEGACY_QQBOT_ID = 'qqbot';
const NEW_QQBOT_ID = 'openclaw-qqbot';
if (Array.isArray(pluginsObj.allow)) {
const allowArr = pluginsObj.allow as string[];
const legacyIdx = allowArr.indexOf(LEGACY_QQBOT_ID);
if (legacyIdx !== -1) {
if (!allowArr.includes(NEW_QQBOT_ID)) {
allowArr[legacyIdx] = NEW_QQBOT_ID;
} else {
allowArr.splice(legacyIdx, 1);
}
console.log(`[sanitize] Migrated plugins.allow: ${LEGACY_QQBOT_ID}${NEW_QQBOT_ID}`);
modified = true;
}
}
if (pEntries?.[LEGACY_QQBOT_ID]) {
if (!pEntries[NEW_QQBOT_ID]) {
pEntries[NEW_QQBOT_ID] = pEntries[LEGACY_QQBOT_ID];
}
delete pEntries[LEGACY_QQBOT_ID];
console.log(`[sanitize] Migrated plugins.entries: ${LEGACY_QQBOT_ID}${NEW_QQBOT_ID}`);
modified = true;
}
// ── Remove bare 'feishu' when canonical feishu plugin is present ──
// The Gateway binary automatically adds bare 'feishu' to plugins.allow
// because the official plugin registers the 'feishu' channel.