openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.35 kB
JavaScript
import{n as resolveLaunchAgentLabel}from"./launchd-label-Daj1UmUS.mjs";import{n as formatLaunchAgentGuiSessionError,s as launchAgentPlistExists}from"./launchd-runtime-CGjMI2Ve.mjs";import{f as assertNoSystemLaunchDaemonOwnership}from"./launchd-service-files-cH3YFqVS.mjs";import{r as repairLaunchAgentBootstrap}from"./launchd-BpufAYg5.mjs";
//!src/cli/daemon-cli/launchd-recovery.ts
const LAUNCH_AGENT_RECOVERY_MESSAGE=`Gateway LaunchAgent was installed but not loaded; re-bootstrapped launchd service.`;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}}export{recoverInstalledLaunchAgent as t};