fix(gateway): recognize Atomic desktop-gateway.py in gateway detection

Atomic Hermes' bundled desktop runner (desktop-gateway.py) shares
HERMES_HOME with the CLI but was not recognized by the gateway
command-line matcher, so `gateway run --replace` skipped the
terminate-and-scoped-lock-handoff path and collided with the desktop
runner's still-held scoped locks (e.g. the Discord bot-token lock),
leaving Discord responses down until the desktop gateway was killed by
hand. Recognize desktop-gateway.py as a gateway entrypoint in
_gateway_command_subcommand, covering both live process detection and
the PID-record metadata fallback.

Co-authored-by: namhyuk kim <happykimnh@icloud.com>
This commit is contained in:
Hermes Agent
2026-09-25 11:04:04 -05:00
committed by brooklyn!
parent c953b2a03e
commit 85c7e87fc7
2 changed files with 21 additions and 0 deletions

View File

@@ -552,6 +552,12 @@ def _gateway_command_subcommand(command: str | None) -> str | None:
# Gateway-dedicated entrypoints carry no subcommand to inspect.
if any(t == "gateway/run.py" or t.endswith("/gateway/run.py") for t in tokens):
return "run"
# Atomic Hermes' bundled desktop runner shares HERMES_HOME with the CLI; without this,
# `gateway run --replace` does not recognise it as a running gateway, skips the
# terminate-and-scoped-lock-handoff path, and collides with its still-held scoped locks
# (e.g. the Discord bot-token lock). See #22418.
if any(b == "desktop-gateway.py" for b in basenames):
return "run"
if any(b in ("hermes-gateway", "hermes-gateway.exe") for b in basenames):
return "run"
joined = " ".join(tokens)

View File

@@ -58,3 +58,18 @@ def test_accepts_real_gateway_run(cmd):
assert matches(cmd) is True
# Atomic Hermes' bundled desktop runner (regression for #22418): it shares
# HERMES_HOME with the CLI and must be recognised as a gateway so
# ``gateway run --replace`` enters the replace/lock-handoff path instead of
# colliding with the desktop runner's still-held scoped locks.
ATOMIC_DESKTOP = (
"/Applications/Atomic Hermes.app/Contents/Resources/python-server/python "
"/Applications/Atomic Hermes.app/Contents/Resources/python-server/desktop-gateway.py"
)
def test_accepts_atomic_desktop_gateway():
assert matches(ATOMIC_DESKTOP) is True
assert matches_runtime(ATOMIC_DESKTOP) is True