openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
76 lines (75 loc) • 3.48 kB
JavaScript
import { n as isNodeRuntime } from "./runtime-binary-BczyKE0p.mjs";
import { n as resolveOpenClawPackageRoot } from "./openclaw-root-BGdnWXIW.mjs";
import { o as isDefaultInstallIdentity } from "./paths-BP0DYpE8.mjs";
import { n as SUPPORTED_NODE_VERSIONS, s as formatUnsupportedNodeVersionMessage } from "./node-version-Dq_scYWR.mjs";
import { i as nodeRuntimeFailure } from "./node-sqlite-C2ThNhQ8.mjs";
import { n as readInstallOwner, t as formatInstallOwnerMessage } from "./install-owner-lgHfm2Mr.mjs";
import { n as detectRuntime } from "./runtime-guard-DSJRAu63.mjs";
import { c as summarizeGatewayServiceLayout } from "./service-layout-Cwf6zauj.mjs";
import { n as resolveGatewayService } from "./service-BFsg6EmN.mjs";
import { o as resolveNodeRuntimeInfo } from "./runtime-paths-CNOx8gw6.mjs";
//#region src/commands/node-runtime-diagnostics.ts
/** Read-only Node findings shared by Doctor and status commands. */
const CHECK_ID = "core/doctor/node-runtime";
/** Inspect the CLI and recorded service without starting or repairing the service. */
async function collectNodeRuntimeFindings(env = process.env) {
const findings = [];
const cliRuntime = await detectRuntime();
if (cliRuntime.kind === "node" && cliRuntime.sqliteProbe) {
const failure = nodeRuntimeFailure(cliRuntime.version, cliRuntime.sqliteProbe);
if (failure) {
const installOwner = await readInstallOwner(await resolveOpenClawPackageRoot({
moduleUrl: import.meta.url,
argv1: process.argv[1]
}));
findings.push({
checkId: CHECK_ID,
severity: "error",
source: "cli",
message: failure,
requirement: SUPPORTED_NODE_VERSIONS,
target: cliRuntime.execPath ?? void 0,
fixHint: installOwner ? formatInstallOwnerMessage(installOwner) : formatUnsupportedNodeVersionMessage(cliRuntime.version)
});
}
}
if (!isDefaultInstallIdentity(env)) return findings;
try {
const command = await resolveGatewayService().readCommand(env, { timeoutMs: 5e3 });
const executable = command?.programArguments[0];
if (executable && isNodeRuntime(executable)) {
const runtime = await resolveNodeRuntimeInfo(executable, {
...env,
...command.environment
});
if (runtime.status === "probe-failed") throw runtime.error;
if (runtime.status === "unsupported") {
const layout = await summarizeGatewayServiceLayout(command);
const owner = await readInstallOwner(layout?.packageRootReal ?? layout?.packageRoot ?? null);
findings.push({
checkId: CHECK_ID,
severity: "warning",
source: "gateway-service",
message: `Gateway service Node ${runtime.version ?? "unknown"} is unsupported. Required: ${SUPPORTED_NODE_VERSIONS}.`,
requirement: SUPPORTED_NODE_VERSIONS,
fixHint: owner ? formatInstallOwnerMessage(owner) : [
...runtime.capabilityError ? [runtime.capabilityError] : [],
formatUnsupportedNodeVersionMessage(runtime.version),
"After switching Node, refresh a managed Gateway with `openclaw gateway install --force`; for an externally managed service, have its deployment owner update the launcher."
].join("\n")
});
}
}
} catch {
findings.push({
checkId: CHECK_ID,
severity: "warning",
source: "gateway-service",
message: "The recorded Gateway service Node runtime could not be inspected.",
fixHint: "Run `openclaw gateway status --deep` and check access to its recorded executable."
});
}
return findings;
}
//#endregion
export { collectNodeRuntimeFindings as t };