mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-28 09:21:31 +00:00
* fix(gateway): evict unresponsive node sockets Co-authored-by: hoangsaga123 <hoangsaga123@gmail.com> * fix(nodes): align invoke timeout semantics * fix(node): preserve managed connection settings * docs(changelog): note node connection fixes * fix(node): redact service credentials in status * fix(systemd): preserve escaped operator values * fix(node): carry explicit plaintext service mode * fix(systemd): avoid promoting stale shell references * fix(node): clear fingerprints for plaintext runs * docs(changelog): defer node notes to release * fix(nodes): normalize forwarded system run timeout * fix(systemd): preserve operator environment values * fix(nodes): type normalized invoke payload --------- Co-authored-by: hoangsaga123 <hoangsaga123@gmail.com>
92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
/** Node-based daemon install plan builder for managed gateway services. */
|
|
import { formatNodeServiceDescription } from "../daemon/constants.js";
|
|
import { resolveNodeProgramArguments } from "../daemon/program-args.js";
|
|
import { buildNodeServiceEnvironment } from "../daemon/service-env.js";
|
|
import type { GatewayServiceEnvironmentValueSource } from "../daemon/service-types.js";
|
|
import {
|
|
emitDaemonInstallRuntimeWarning,
|
|
resolveDaemonInstallRuntimeInputs,
|
|
resolveDaemonNodeBinDir,
|
|
} from "./daemon-install-plan.shared.js";
|
|
import type { DaemonInstallWarnFn } from "./daemon-install-runtime-warning.js";
|
|
import type { GatewayDaemonRuntime } from "./daemon-runtime.js";
|
|
|
|
type NodeInstallPlan = {
|
|
programArguments: string[];
|
|
workingDirectory?: string;
|
|
environment: Record<string, string | undefined>;
|
|
environmentValueSources?: Record<string, GatewayServiceEnvironmentValueSource | undefined>;
|
|
description?: string;
|
|
};
|
|
|
|
function buildNodeInstallEnvironmentValueSources(): Record<
|
|
string,
|
|
GatewayServiceEnvironmentValueSource | undefined
|
|
> {
|
|
return {
|
|
OPENCLAW_GATEWAY_TOKEN: "file",
|
|
OPENCLAW_GATEWAY_PASSWORD: "file", // pragma: allowlist secret
|
|
};
|
|
}
|
|
|
|
/** Builds launch arguments, environment, and metadata for a Node daemon service install. */
|
|
export async function buildNodeInstallPlan(params: {
|
|
env: Record<string, string | undefined>;
|
|
host: string;
|
|
port: number;
|
|
contextPath?: string;
|
|
tls?: boolean;
|
|
tlsFingerprint?: string;
|
|
nodeId?: string;
|
|
displayName?: string;
|
|
runtime: GatewayDaemonRuntime;
|
|
devMode?: boolean;
|
|
nodePath?: string;
|
|
warn?: DaemonInstallWarnFn;
|
|
}): Promise<NodeInstallPlan> {
|
|
const { devMode, nodePath } = await resolveDaemonInstallRuntimeInputs({
|
|
env: params.env,
|
|
runtime: params.runtime,
|
|
devMode: params.devMode,
|
|
nodePath: params.nodePath,
|
|
});
|
|
const { programArguments, workingDirectory } = await resolveNodeProgramArguments({
|
|
host: params.host,
|
|
port: params.port,
|
|
contextPath: params.contextPath,
|
|
tls: params.tls,
|
|
tlsFingerprint: params.tlsFingerprint,
|
|
nodeId: params.nodeId,
|
|
displayName: params.displayName,
|
|
dev: devMode,
|
|
runtime: params.runtime,
|
|
nodePath,
|
|
});
|
|
|
|
await emitDaemonInstallRuntimeWarning({
|
|
env: params.env,
|
|
runtime: params.runtime,
|
|
programArguments,
|
|
warn: params.warn,
|
|
title: "Node daemon runtime",
|
|
});
|
|
|
|
const environment = buildNodeServiceEnvironment({
|
|
env: params.env,
|
|
// Match the gateway install path so supervised node services keep the chosen
|
|
// node toolchain on PATH for sibling binaries like npm/pnpm when needed.
|
|
extraPathDirs: resolveDaemonNodeBinDir(nodePath),
|
|
});
|
|
const description = formatNodeServiceDescription({
|
|
version: environment.OPENCLAW_SERVICE_VERSION,
|
|
});
|
|
|
|
return {
|
|
programArguments,
|
|
workingDirectory,
|
|
environment,
|
|
environmentValueSources: buildNodeInstallEnvironmentValueSources(),
|
|
description,
|
|
};
|
|
}
|