diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-08-07 23:10:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-07 23:10:28 +0300 |
| commit | 50ddc06f00ec69ede35fd5488a260dec2b74e98a (patch) | |
| tree | 2a01f30600ccfea600040476703cf7de50087156 /src/integration/assets/hermes/__init__.py | |
| parent | 7d77e927eba265ea864485bf99411abcf62d977d (diff) | |
feat: support all agent integrations on windows (#2496)
Diffstat (limited to 'src/integration/assets/hermes/__init__.py')
| -rw-r--r-- | src/integration/assets/hermes/__init__.py | 70 |
1 files changed, 28 insertions, 42 deletions
diff --git a/src/integration/assets/hermes/__init__.py b/src/integration/assets/hermes/__init__.py index 9b1d51e2..e99fc29e 100644 --- a/src/integration/assets/hermes/__init__.py +++ b/src/integration/assets/hermes/__init__.py @@ -1,14 +1,12 @@ """Hermes plugin installed by Herdr to report resumable session identity.""" # HERDR_INTEGRATION_ID=hermes -# HERDR_INTEGRATION_VERSION=4 +# HERDR_INTEGRATION_VERSION=5 from __future__ import annotations -import json import os -import random -import socket +import subprocess import time _SOURCE = "herdr:hermes" @@ -16,43 +14,37 @@ _AGENT = "hermes" _INTERACTIVE_PLATFORMS = {"cli", "tui", "desktop", "acp"} -def _base_params() -> tuple[str, str] | None: +def _pane_id() -> str | None: if os.environ.get("HERDR_ENV") != "1": return None - pane_id = os.environ.get("HERDR_PANE_ID", "").strip() - socket_path = os.environ.get("HERDR_SOCKET_PATH", "").strip() - if not pane_id or not socket_path: - return None - return pane_id, socket_path + return os.environ.get("HERDR_PANE_ID", "").strip() or None -def _send(method: str, params: dict) -> None: - base = _base_params() - if base is None: +def _send_session(session_id: str, start_source: str) -> None: + pane_id = _pane_id() + if pane_id is None: return - pane_id, socket_path = base - params = { - "pane_id": pane_id, - "source": _SOURCE, - "agent": _AGENT, - "seq": time.time_ns(), - **params, - } - request = { - "id": f"{_SOURCE}:{int(time.time() * 1000)}:{random.randrange(1_000_000):06d}", - "method": method, - "params": params, - } + command = [ + os.environ.get("HERDR_BIN_PATH") or "herdr", + "pane", + "report-agent-session", + pane_id, + "--source", + _SOURCE, + "--agent", + _AGENT, + "--seq", + str(time.time_ns()), + "--agent-session-id", + session_id, + "--session-start-source", + start_source, + ] try: - client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - client.settimeout(0.5) - client.connect(socket_path) - client.sendall((json.dumps(request) + "\n").encode("utf-8")) - try: - client.recv(4096) - except Exception: - pass - client.close() + kwargs = {"timeout": 1, "stdout": subprocess.DEVNULL, "stderr": subprocess.DEVNULL} + if os.name == "nt": + kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW + subprocess.run(command, check=False, **kwargs) except Exception: pass @@ -63,13 +55,7 @@ def _report_session(start_source: str, **kwargs) -> None: session_id = kwargs.get("session_id") if not isinstance(session_id, str) or not session_id: return - _send( - "pane.report_agent_session", - { - "agent_session_id": session_id, - "session_start_source": start_source, - }, - ) + _send_session(session_id, start_source) def _session_started(**kwargs) -> None: |
