refactor(commands): share daemon runtime warning helper

This commit is contained in:
Peter Steinberger
2026-02-18 23:08:40 +00:00
parent 3ce615ff06
commit c0c10f42e2
4 changed files with 117 additions and 30 deletions

View File

@@ -3,16 +3,14 @@ import { collectConfigEnvVars } from "../config/env-vars.js";
import type { OpenClawConfig } from "../config/types.js";
import { resolveGatewayLaunchAgentLabel } from "../daemon/constants.js";
import { resolveGatewayProgramArguments } from "../daemon/program-args.js";
import {
renderSystemNodeWarning,
resolvePreferredNodePath,
resolveSystemNodeInfo,
} from "../daemon/runtime-paths.js";
import { resolvePreferredNodePath } from "../daemon/runtime-paths.js";
import { buildServiceEnvironment } from "../daemon/service-env.js";
import {
emitNodeRuntimeWarning,
type DaemonInstallWarnFn,
} from "./daemon-install-runtime-warning.js";
import type { GatewayDaemonRuntime } from "./daemon-runtime.js";
type WarnFn = (message: string, title?: string) => void;
export type GatewayInstallPlan = {
programArguments: string[];
workingDirectory?: string;
@@ -32,7 +30,7 @@ export async function buildGatewayInstallPlan(params: {
token?: string;
devMode?: boolean;
nodePath?: string;
warn?: WarnFn;
warn?: DaemonInstallWarnFn;
/** Full config to extract env vars from (env vars + inline env keys). */
config?: OpenClawConfig;
}): Promise<GatewayInstallPlan> {
@@ -49,13 +47,13 @@ export async function buildGatewayInstallPlan(params: {
runtime: params.runtime,
nodePath,
});
if (params.runtime === "node") {
const systemNode = await resolveSystemNodeInfo({ env: params.env });
const warning = renderSystemNodeWarning(systemNode, programArguments[0]);
if (warning) {
params.warn?.(warning, "Gateway runtime");
}
}
await emitNodeRuntimeWarning({
env: params.env,
runtime: params.runtime,
nodeProgram: programArguments[0],
warn: params.warn,
title: "Gateway runtime",
});
const serviceEnvironment = buildServiceEnvironment({
env: params.env,
port: params.port,