1+ // Shared daemon install runtime/path helpers for service plan generation.
12import fs from "node:fs" ;
23import path from "node:path" ;
34import { resolvePreferredNodePath } from "../daemon/runtime-paths.js" ;
@@ -7,12 +8,14 @@ import {
78} from "./daemon-install-runtime-warning.js" ;
89import type { GatewayDaemonRuntime } from "./daemon-runtime.js" ;
910
11+ /** Detect source-checkout dev mode from the current CLI entrypoint. */
1012export function resolveGatewayDevMode ( argv : string [ ] = process . argv ) : boolean {
1113 const entry = argv [ 1 ] ;
1214 const normalizedEntry = entry ?. replaceAll ( "\\" , "/" ) ;
1315 return normalizedEntry ?. includes ( "/src/" ) && normalizedEntry . endsWith ( ".ts" ) ;
1416}
1517
18+ /** Resolve dev-mode and Node path inputs for daemon service install planning. */
1619export async function resolveDaemonInstallRuntimeInputs ( params : {
1720 env : Record < string , string | undefined > ;
1821 runtime : GatewayDaemonRuntime ;
@@ -29,6 +32,7 @@ export async function resolveDaemonInstallRuntimeInputs(params: {
2932 return { devMode, nodePath } ;
3033}
3134
35+ /** Emit runtime warnings for daemon install command arguments. */
3236export async function emitDaemonInstallRuntimeWarning ( params : {
3337 env : Record < string , string | undefined > ;
3438 runtime : GatewayDaemonRuntime ;
@@ -45,6 +49,7 @@ export async function emitDaemonInstallRuntimeWarning(params: {
4549 } ) ;
4650}
4751
52+ /** Return the Node binary directory that should be added to daemon PATH. */
4853export function resolveDaemonNodeBinDir ( nodePath ?: string ) : string [ ] | undefined {
4954 const trimmed = nodePath ?. trim ( ) ;
5055 if ( ! trimmed || ! path . isAbsolute ( trimmed ) ) {
@@ -86,6 +91,7 @@ function addUniquePathDir(dirs: string[], dir: string | undefined): void {
8691 dirs . push ( dir ) ;
8792}
8893
94+ /** Resolve the OpenClaw CLI binary directory from argv/PATH for daemon PATH. */
8995export function resolveDaemonOpenClawBinDir (
9096 params : {
9197 argv ?: string [ ] ;
@@ -133,6 +139,7 @@ export function resolveDaemonOpenClawBinDir(
133139 return dirs . length > 0 ? dirs : undefined ;
134140}
135141
142+ /** Merge Node and OpenClaw binary directories for the daemon service PATH. */
136143export function resolveDaemonServicePathDirs ( params : {
137144 nodePath ?: string ;
138145 argv ?: string [ ] ;
0 commit comments