fix: skip removed openclaw deps preflight
This commit is contained in:
@@ -254,13 +254,22 @@ async function runRuntimeDepsRepair(
|
|||||||
launchContext: GatewayLaunchContext,
|
launchContext: GatewayLaunchContext,
|
||||||
timeoutMs = DEFAULT_RUNTIME_DEPS_PREFLIGHT_TIMEOUT_MS,
|
timeoutMs = DEFAULT_RUNTIME_DEPS_PREFLIGHT_TIMEOUT_MS,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const inspected = await runPluginsDepsCommand(launchContext, [
|
let inspected: { report: OpenClawRuntimeDepsReport; stdout: string; stderr: string };
|
||||||
'plugins',
|
try {
|
||||||
'deps',
|
inspected = await runPluginsDepsCommand(launchContext, [
|
||||||
'--json',
|
'plugins',
|
||||||
'--package-root',
|
'deps',
|
||||||
launchContext.openclawDir,
|
'--json',
|
||||||
], timeoutMs);
|
'--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 removedStaleRoot = maybeRemoveStaleInstallRoot(launchContext, inspected.report);
|
||||||
const missingBefore = Array.isArray(inspected.report.missing) ? inspected.report.missing.length : 0;
|
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'})`);
|
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(
|
function runPluginsDepsCommand(
|
||||||
launchContext: GatewayLaunchContext,
|
launchContext: GatewayLaunchContext,
|
||||||
args: string[],
|
args: string[],
|
||||||
|
|||||||
23
tests/unit/openclaw-runtime-deps.test.ts
Normal file
23
tests/unit/openclaw-runtime-deps.test.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { isOpenClawRuntimeDepsCommandUnavailableMessage } from '@electron/gateway/runtime-deps';
|
||||||
|
|
||||||
|
describe('OpenClaw runtime dependency preflight compatibility', () => {
|
||||||
|
it('treats the removed plugins deps --json CLI as unavailable', () => {
|
||||||
|
expect(
|
||||||
|
isOpenClawRuntimeDepsCommandUnavailableMessage([
|
||||||
|
'OpenClaw runtime dependency preflight failed (code=1, signal=none)',
|
||||||
|
"error: unknown option '--json'",
|
||||||
|
'Usage: openclaw plugins [options] [command]',
|
||||||
|
].join('\n')),
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not hide unrelated OpenClaw preflight failures', () => {
|
||||||
|
expect(
|
||||||
|
isOpenClawRuntimeDepsCommandUnavailableMessage([
|
||||||
|
'OpenClaw runtime dependency preflight failed (code=1, signal=none)',
|
||||||
|
'Error: Cannot find module sqlite-vec',
|
||||||
|
].join('\n')),
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user