From bdda14e17087af35fe6c14e955ab742479351105 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 2 May 2026 02:51:00 +0100 Subject: [PATCH] refactor: trim daemon service manager exports --- src/daemon/launchd-restart-handoff.ts | 8 ++++---- src/daemon/launchd.ts | 6 +++--- src/daemon/systemd-linger.ts | 2 +- src/daemon/systemd.ts | 13 ++++--------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/daemon/launchd-restart-handoff.ts b/src/daemon/launchd-restart-handoff.ts index 6ce4e45dd59..b33988fb3e9 100644 --- a/src/daemon/launchd-restart-handoff.ts +++ b/src/daemon/launchd-restart-handoff.ts @@ -8,15 +8,15 @@ import { sanitizeForLog } from "../terminal/ansi.js"; import { resolveGatewayLaunchAgentLabel } from "./constants.js"; import { renderPosixRestartLogSetup } from "./restart-logs.js"; -export type LaunchdRestartHandoffMode = "kickstart" | "start-after-exit"; +type LaunchdRestartHandoffMode = "kickstart" | "start-after-exit"; -export type LaunchdRestartHandoffResult = { +type LaunchdRestartHandoffResult = { ok: boolean; pid?: number; detail?: string; }; -export type LaunchdRestartTarget = { +type LaunchdRestartTarget = { domain: string; label: string; plistPath: string; @@ -77,7 +77,7 @@ function resolveLaunchAgentLabel(env?: Record): stri return assertValidLaunchAgentLabel(resolveGatewayLaunchAgentLabel(env?.OPENCLAW_PROFILE)); } -export function resolveLaunchdRestartTarget( +function resolveLaunchdRestartTarget( env: Record = process.env, ): LaunchdRestartTarget { const domain = resolveGuiDomain(); diff --git a/src/daemon/launchd.ts b/src/daemon/launchd.ts index b33ded905dc..4b35b3f3c6c 100644 --- a/src/daemon/launchd.ts +++ b/src/daemon/launchd.ts @@ -181,7 +181,7 @@ export async function readLaunchAgentProgramArguments( return readLaunchAgentProgramArgumentsFromFile(plistPath); } -export function buildLaunchAgentPlist({ +function buildLaunchAgentPlist({ label = GATEWAY_LAUNCH_AGENT_LABEL, comment, programArguments, @@ -344,7 +344,7 @@ async function ensureLaunchAgentEnvironmentDirectories( } } -export type LaunchctlPrintInfo = { +type LaunchctlPrintInfo = { state?: string; pid?: number; lastExitStatus?: number; @@ -433,7 +433,7 @@ export async function readLaunchAgentRuntime( }; } -export type LaunchAgentBootstrapRepairResult = +type LaunchAgentBootstrapRepairResult = | { ok: true; status: "repaired" | "already-loaded" } | { ok: false; status: "bootstrap-failed" | "kickstart-failed"; detail?: string }; diff --git a/src/daemon/systemd-linger.ts b/src/daemon/systemd-linger.ts index 33067e725a7..d4459ff09e5 100644 --- a/src/daemon/systemd-linger.ts +++ b/src/daemon/systemd-linger.ts @@ -18,7 +18,7 @@ function resolveLoginctlUser(env: Record): string | } } -export type SystemdUserLingerStatus = { +type SystemdUserLingerStatus = { user: string; linger: "yes" | "no"; }; diff --git a/src/daemon/systemd.ts b/src/daemon/systemd.ts index 710eeeb9556..67747a31704 100644 --- a/src/daemon/systemd.ts +++ b/src/daemon/systemd.ts @@ -27,11 +27,7 @@ import type { GatewayServiceManageArgs, GatewayServiceRestartResult, } from "./service-types.js"; -import { - enableSystemdUserLinger, - readSystemdUserLingerStatus, - type SystemdUserLingerStatus, -} from "./systemd-linger.js"; +import { enableSystemdUserLinger, readSystemdUserLingerStatus } from "./systemd-linger.js"; import { classifySystemdUnavailableDetail, isSystemctlMissingDetail, @@ -67,7 +63,6 @@ export function resolveSystemdUserUnitPath(env: GatewayServiceEnv): string { } export { enableSystemdUserLinger, readSystemdUserLingerStatus }; -export type { SystemdUserLingerStatus }; // Unit file parsing/rendering: see systemd-unit.ts @@ -235,7 +230,7 @@ async function resolveSystemdEnvironmentFiles(params: { return { environment: resolved }; } -export type SystemdServiceInfo = { +type SystemdServiceInfo = { activeState?: string; subState?: string; mainPid?: number; @@ -804,7 +799,7 @@ export async function readSystemdServiceRuntime( lastExitReason: parsed.execMainCode, }; } -export type LegacySystemdUnit = { +type LegacySystemdUnit = { name: string; unitPath: string; enabled: boolean; @@ -819,7 +814,7 @@ async function isSystemctlAvailable(env: GatewayServiceEnv): Promise { return !isSystemctlMissing(readSystemctlDetail(res)); } -export async function findLegacySystemdUnits(env: GatewayServiceEnv): Promise { +async function findLegacySystemdUnits(env: GatewayServiceEnv): Promise { const results: LegacySystemdUnit[] = []; const systemctlAvailable = await isSystemctlAvailable(env); for (const name of LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES) {