The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): share breakaway marker constant
QDung2100a1cca56480f
diff --git a/hermes_cli/_subprocess_compat.py b/hermes_cli/_subprocess_compat.pyindex 3813bfaab82..66f0d90a0b1 100644--- a/hermes_cli/_subprocess_compat.py+++ b/hermes_cli/_subprocess_compat.py@@ -50,6 +50,9 @@ __all__ = [IS_WINDOWS = sys.platform == "win32"+# Private launcher-to-child metadata. This is diagnostic state, not user config.+_WINDOWS_GATEWAY_BREAKAWAY_ENV = "_HERMES_GATEWAY_BREAKAWAY"+def split_command_line(line: str) -> list[str]:"""Split a user-supplied command line into tokens, Windows-safely.diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex 614d44b86d9..11eca304ecf 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -68,9 +68,6 @@ from hermes_cli.colors import Colors, colorlogger = logging.getLogger(__name__)-# Private launcher-to-child metadata. This is diagnostic state, not user config.-_WINDOWS_GATEWAY_BREAKAWAY_ENV = "_HERMES_GATEWAY_BREAKAWAY"-# =============================================================================# Process Management (for manual gateway runs)# =============================================================================@@ -2070,6 +2067,8 @@ def _windows_gateway_breakaway_state() -> bool | None:"""Consume private spawn metadata without guessing for older launchers."""if not is_windows():return None+ from hermes_cli._subprocess_compat import _WINDOWS_GATEWAY_BREAKAWAY_ENV+value = os.environ.pop(_WINDOWS_GATEWAY_BREAKAWAY_ENV, None)if value == "1":return Truediff --git a/hermes_cli/gateway_windows.py b/hermes_cli/gateway_windows.pyindex d31a70d8e2f..59a1d285421 100644--- a/hermes_cli/gateway_windows.py+++ b/hermes_cli/gateway_windows.py@@ -41,6 +41,7 @@ from pathlib import Pathfrom xml.sax.saxutils import escapefrom hermes_cli._subprocess_compat import (+ _WINDOWS_GATEWAY_BREAKAWAY_ENV,windows_detach_flags,windows_detach_flags_without_breakaway,windows_hide_flags,@@ -48,9 +49,6 @@ from hermes_cli._subprocess_compat import (logger = logging.getLogger(__name__)-# Private launcher-to-child metadata. This is diagnostic state, not user config.-_GATEWAY_BREAKAWAY_ENV = "_HERMES_GATEWAY_BREAKAWAY"-# Short timeouts: schtasks occasionally wedges and we don't want to hang forever._SCHTASKS_TIMEOUT_S = 15_SCHTASKS_NO_OUTPUT_TIMEOUT_S = 30@@ -919,7 +917,7 @@ def _spawn_detached(script_path: Path | None = None) -> int:# Inherit PATH etc. from the current env, overlay our required vars.env = {**os.environ, **env_overlay}- primary_env = {**env, _GATEWAY_BREAKAWAY_ENV: "1"}+ primary_env = {**env, _WINDOWS_GATEWAY_BREAKAWAY_ENV: "1"}# CREATE_NEW_PROCESS_GROUP 0x00000200 — child gets its own group, won't# receive Ctrl+C from our group@@ -971,7 +969,7 @@ def _spawn_detached(script_path: Path | None = None) -> int:error_code,)flags_no_breakaway = windows_detach_flags_without_breakaway()- fallback_env = {**env, _GATEWAY_BREAKAWAY_ENV: "0"}+ fallback_env = {**env, _WINDOWS_GATEWAY_BREAKAWAY_ENV: "0"}with open(stray_log, "ab", buffering=0) as log_fh:proc = subprocess.Popen(argv,