Skip to content

The agent that grows with you

fix(update): sudo-prefix the manual kickstart hint for a LaunchDaemon run as a user

teknium1de93cb05fd9c
diff --git a/hermes_cli/dashboard_procs.py b/hermes_cli/dashboard_procs.py
index 70f6f003aa1..b0f7c2d3aa6 100644
--- a/hermes_cli/dashboard_procs.py
+++ b/hermes_cli/dashboard_procs.py
@@ -447,8 +447,11 @@ def _restart_killed_backends(
if _dash._restart_launchd_job(domain, label, old_pid):
print(f" ✓ restarted launchd job {target}")
else:
+ # A LaunchDaemon (system domain) can only be kickstarted by root; the hint must
+ # be the command that works from the shell the operator is actually in.
+ sudo = "sudo " if domain.startswith("system") and os.geteuid() != 0 else "" # windows-footgun: ok — launchd jobs exist only on macOS
failed_restarts.append(
- (target, f"launchd is not supervising a fresh process; run: launchctl kickstart -k {target}"))
+ (target, f"launchd is not supervising a fresh process; run: {sudo}launchctl kickstart -k {target}"))
unrecovered.append(pid)
elif pid in pid_cmdline:
respawn_candidates.append((pid, pid_cmdline[pid], pid_home.get(pid)))
diff --git a/tests/hermes_cli/test_update_stale_dashboard.py b/tests/hermes_cli/test_update_stale_dashboard.py
index c06dfbfa82e..ff2dca13901 100644
--- a/tests/hermes_cli/test_update_stale_dashboard.py
+++ b/tests/hermes_cli/test_update_stale_dashboard.py
@@ -993,7 +993,12 @@ class TestLaunchdSupervisedBackends:
restart_ok=False)
respawn.assert_not_called()
assert result["unrecovered"] == [9103]
- assert "launchctl kickstart -k gui/501/ai.hermes.dashboard" in capsys.readouterr().out
+ assert "run: launchctl kickstart -k gui/501/ai.hermes.dashboard" in capsys.readouterr().out
+
+ # A LaunchDaemon lives in the system domain: kickstart needs root, so a non-root hint says sudo.
+ with patch("hermes_cli.dashboard_procs.os.geteuid", return_value=501, create=True): # windows-footgun: ok — patch target string, create=True
+ self._run(9105, [("system", "ai.hermes.serve", list(self.ARGV), None)], restart_ok=False)
+ assert "run: sudo launchctl kickstart -k system/ai.hermes.serve" in capsys.readouterr().out
other = ("gui/501", "ai.hermes.other", ["hermes", "dashboard", "--port", "8300"], 777)
result, restart, respawn = self._run(9104, [other])