Add channel health diagnostics and gateway recovery fixes (#855)

This commit is contained in:
Lingxuan Zuo
2026-04-15 13:51:02 +08:00
committed by GitHub
Unverified
parent 6acd8acf5a
commit 1f39d1a8a7
22 changed files with 1868 additions and 52 deletions

View File

@@ -1634,6 +1634,51 @@ export async function sanitizeOpenClawConfig(): Promise<void> {
pluginsObj.allow = allowArr;
}
// ── acpx legacy config/install cleanup ─────────────────────
// Older OpenClaw releases allowed plugins.entries.acpx.config.command
// and expectedVersion overrides. Current bundled acpx schema rejects
// them, which causes the Gateway to fail validation before startup.
// Strip those keys and drop stale installs metadata that still points
// at an older bundled OpenClaw tree so the current bundled plugin can
// be re-registered cleanly.
const acpxEntry = isPlainRecord(pEntries.acpx) ? pEntries.acpx as Record<string, unknown> : null;
const acpxConfig = acpxEntry && isPlainRecord(acpxEntry.config)
? acpxEntry.config as Record<string, unknown>
: null;
if (acpxConfig) {
for (const legacyKey of ['command', 'expectedVersion'] as const) {
if (legacyKey in acpxConfig) {
delete acpxConfig[legacyKey];
modified = true;
console.log(`[sanitize] Removed legacy plugins.entries.acpx.config.${legacyKey}`);
}
}
}
const installs = isPlainRecord(pluginsObj.installs) ? pluginsObj.installs as Record<string, unknown> : null;
const acpxInstall = installs && isPlainRecord(installs.acpx) ? installs.acpx as Record<string, unknown> : null;
if (acpxInstall) {
const currentBundledAcpxDir = join(getOpenClawResolvedDir(), 'dist', 'extensions', 'acpx').replace(/\\/g, '/');
const sourcePath = typeof acpxInstall.sourcePath === 'string' ? acpxInstall.sourcePath : '';
const installPath = typeof acpxInstall.installPath === 'string' ? acpxInstall.installPath : '';
const normalizedSourcePath = sourcePath.replace(/\\/g, '/');
const normalizedInstallPath = installPath.replace(/\\/g, '/');
const pointsAtDifferentBundledTree = [normalizedSourcePath, normalizedInstallPath].some(
(candidate) => candidate.includes('/node_modules/.pnpm/openclaw@') && candidate !== currentBundledAcpxDir,
);
const pointsAtMissingPath = (sourcePath && !(await fileExists(sourcePath)))
|| (installPath && !(await fileExists(installPath)));
if (pointsAtDifferentBundledTree || pointsAtMissingPath) {
delete installs.acpx;
if (Object.keys(installs).length === 0) {
delete pluginsObj.installs;
}
modified = true;
console.log('[sanitize] Removed stale plugins.installs.acpx metadata');
}
}
const installedFeishuId = await resolveInstalledFeishuPluginId();
const configuredFeishuId =
FEISHU_PLUGIN_ID_CANDIDATES.find((id) => allowArr.includes(id))