UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

40 lines (39 loc) • 1.63 kB
import { n as resolveLaunchAgentLabel } from "./launchd-label-DdmmL_TH.mjs"; import { d as assertNoSystemLaunchDaemonOwnership } from "./launchd-service-files-BgSRMq9s.mjs"; import { n as formatLaunchAgentGuiSessionError, s as launchAgentPlistExists } from "./launchd-runtime-DS9pQoDc.mjs"; import { a as repairLaunchAgentBootstrap } from "./launchd-BlyjKZEQ.mjs"; //#region src/cli/daemon-cli/launchd-recovery.ts const LAUNCH_AGENT_RECOVERY_MESSAGE = "Gateway LaunchAgent was installed but not loaded; re-bootstrapped launchd service."; /** Re-bootstrap an installed but unloaded LaunchAgent after a daemon start/restart command. */ async function recoverInstalledLaunchAgent(e) { if (process.platform !== "darwin") return null; const t = e.env ?? process.env; await assertNoSystemLaunchDaemonOwnership(resolveLaunchAgentLabel(t)); if (!await launchAgentPlistExists(t).catch(() => false)) return null; const n = await repairLaunchAgentBootstrap({ env: t, deadline: e.deadline }).catch(() => ({ ok: false, status: "bootstrap-failed" })); if (!n.ok) { if (n.status === "system-launchdaemon-conflict" || n.status === "system-launchdaemon-unverifiable") throw new Error(n.detail); if (n.status === "gui-session-unavailable") { const t = e.result === "started" ? "openclaw gateway start" : "openclaw gateway restart"; throw new Error(formatLaunchAgentGuiSessionError({ detail: n.detail, domain: n.domain, actionHint: t })); } return null; } return { result: e.result, loaded: true, message: LAUNCH_AGENT_RECOVERY_MESSAGE }; } //#endregion export { recoverInstalledLaunchAgent as t };