Files
openclaw/src/commands/status.node-mode.ts
Luke 88ca0b2c3f fix(status): handle node-only hosts on current main (#56718)
* Status: handle node-only hosts

* Status: address follow-up review nits

* Changelog: note node-only status fix

* Status: lazy-load node-only helper
2026-03-29 21:12:08 +11:00

76 lines
2.0 KiB
TypeScript

import { DEFAULT_GATEWAY_PORT } from "../config/paths.js";
import { loadNodeHostConfig } from "../node-host/config.js";
type NodeOnlyServiceLike = {
installed: boolean | null;
loaded?: boolean | null;
externallyManaged?: boolean;
runtime?:
| {
status?: string;
pid?: number;
}
| undefined;
runtimeShort?: string | null;
};
export type NodeOnlyGatewayInfo = {
gatewayTarget: string;
gatewayValue: string;
connectionDetails: string;
};
function resolveNodeGatewayTarget(gateway?: { host?: string; port?: number }): string {
return gateway?.host
? `${gateway.host}:${gateway.port ?? DEFAULT_GATEWAY_PORT}`
: "(gateway address unknown)";
}
function hasRunningRuntime(
runtime:
| {
status?: string;
pid?: number;
}
| undefined,
): boolean {
return runtime?.status === "running" || typeof runtime?.pid === "number";
}
function isNodeServiceActive(node: NodeOnlyServiceLike): boolean {
if (node.installed !== true) {
return false;
}
if (node.externallyManaged === true) {
return true;
}
if (node.loaded === true) {
return true;
}
if (hasRunningRuntime(node.runtime)) {
return true;
}
return typeof node.runtimeShort === "string" && node.runtimeShort.startsWith("running");
}
export async function resolveNodeOnlyGatewayInfo(params: {
daemon: Pick<NodeOnlyServiceLike, "installed">;
node: NodeOnlyServiceLike;
}): Promise<NodeOnlyGatewayInfo | null> {
if (params.daemon.installed !== false || !isNodeServiceActive(params.node)) {
return null;
}
const gatewayTarget = resolveNodeGatewayTarget((await loadNodeHostConfig())?.gateway);
return {
gatewayTarget,
gatewayValue: `node → ${gatewayTarget} · no local gateway`,
connectionDetails: [
"Node-only mode detected",
"Local gateway: not expected on this machine",
`Remote gateway target: ${gatewayTarget}`,
"Inspect the remote gateway host for live channel and health details.",
].join("\n"),
};
}