fix: skip removed openclaw deps preflight

This commit is contained in:
inman
2026-05-13 22:01:55 +08:00
parent 86795078f7
commit 043d0f0bfe
2 changed files with 47 additions and 7 deletions

View File

@@ -254,13 +254,22 @@ async function runRuntimeDepsRepair(
launchContext: GatewayLaunchContext,
timeoutMs = DEFAULT_RUNTIME_DEPS_PREFLIGHT_TIMEOUT_MS,
): Promise<void> {
const inspected = await runPluginsDepsCommand(launchContext, [
'plugins',
'deps',
'--json',
'--package-root',
launchContext.openclawDir,
], timeoutMs);
let inspected: { report: OpenClawRuntimeDepsReport; stdout: string; stderr: string };
try {
inspected = await runPluginsDepsCommand(launchContext, [
'plugins',
'deps',
'--json',
'--package-root',
launchContext.openclawDir,
], timeoutMs);
} catch (error) {
if (isOpenClawRuntimeDepsCommandUnavailableMessage(error instanceof Error ? error.message : String(error))) {
logger.warn('[plugins] OpenClaw plugins deps preflight is unavailable in this OpenClaw version; skipping legacy runtime dependency preflight.');
return;
}
throw error;
}
const removedStaleRoot = maybeRemoveStaleInstallRoot(launchContext, inspected.report);
const missingBefore = Array.isArray(inspected.report.missing) ? inspected.report.missing.length : 0;
@@ -309,6 +318,14 @@ async function runRuntimeDepsRepair(
logger.info(`[plugins] OpenClaw runtime dependency preflight complete (missing=${missingAfter}, repaired=${repairedCount}, reset=${removedStaleRoot ? 'yes' : 'no'}, local=${localMaterialized ? 'yes' : 'no'}, npm=${npmRepaired ? 'yes' : 'no'})`);
}
export function isOpenClawRuntimeDepsCommandUnavailableMessage(message: string): boolean {
const normalized = message.toLowerCase();
return normalized.includes("unknown option '--json'")
|| normalized.includes("unknown command 'deps'")
|| normalized.includes('unknown command "deps"')
|| (normalized.includes('usage: openclaw plugins') && normalized.includes('unknown subcommand'));
}
function runPluginsDepsCommand(
launchContext: GatewayLaunchContext,
args: string[],