diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py index 7a9951dd5..bd970d9ca 100644 --- a/hermes_cli/gateway.py +++ b/hermes_cli/gateway.py @@ -3588,6 +3588,86 @@ def _launchctl_bootstrap( ) +def _launchd_reload_log_path() -> Path: + """Path the launchd reload watchdog tails for persistent-orphan detection.""" + return get_hermes_home() / "logs" / "launchd-reload.log" + + +def _append_launchd_reload_log(message: str) -> None: + """Append a timestamped line to the launchd reload log (best-effort).""" + path = _launchd_reload_log_path() + try: + path.parent.mkdir(parents=True, exist_ok=True) + from datetime import datetime as _dt + + stamp = _dt.now().astimezone().strftime("%Y-%m-%d %H:%M:%S %z") + with path.open("a", encoding="utf-8") as fh: + fh.write(f"[{stamp}] {message}\n") + except OSError: + pass + + +def _launchctl_label_registered(label: str) -> bool: + """True when ``launchctl list