The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): /personality /busy /approvals /footer /fast run the gateway's handler (slash.exec)
Teknium2c6a8f05574b
diff --git a/cli.py b/cli.pyindex 541e03dfc43..5ff9d2fdeb6 100644--- a/cli.py+++ b/cli.py@@ -1191,6 +1191,9 @@ class HermesCLI(CLIInitMixin, CLITuiRuntimeMixin, CLIProcessNotificationsMixin,entry = self._slash_handler(canonical)if entry is None:return self._process_unregistered_slash(cmd_original, cmd_lower)+ from hermes_cli.gateway_setting_commands import run as run_gateway_setting+ if run_gateway_setting(self, canonical, cmd_original):+ return True # a per-session setting the gateway's handler appliedmethod_name, pass_arg = entryhandler = getattr(self, method_name)result = handler(cmd_original) if pass_arg else handler()diff --git a/hermes_cli/gateway_setting_commands.py b/hermes_cli/gateway_setting_commands.pynew file mode 100644index 00000000000..5dd36fb1308--- /dev/null+++ b/hermes_cli/gateway_setting_commands.py@@ -0,0 +1,46 @@+"""Per-session setting commands of the classic CLI on the shared gateway (``slash.exec``).++On main ``/personality`` ``/busy`` ``/approvals`` ``/footer`` ``/fast`` changed this process's own+agent or config. Rewired, the session's agent lives in the gateway, so the gateway's handler+decides and applies the change (gateway/session_setting_commands.py; RULING §1: one behaviour per+command, every surface) and the CLI prints its reply. Client-side state the CLI itself enforces+(``/busy``: what Enter does while a turn runs) is mirrored locally after the owner accepts it.+"""+from __future__ import annotations++# Canonical command -> mirror(cli, arg) run after the owner applied it (None: nothing local).+_BUSY_MODES = frozenset({"queue", "steer", "interrupt"})+++def _mirror_busy(cli, arg):+ if arg.lower() in _BUSY_MODES:+ cli.busy_input_mode = arg.lower()+++GATEWAY_SETTINGS = {"personality": None, "busy": _mirror_busy, "approvals": None, "footer": None, "fast": None}+++def run(cli, canonical, cmd):+ """True when the gateway answered the command (the local handler must not run)."""+ from hermes_cli.gateway_side import connection_for+ if canonical not in GATEWAY_SETTINGS:+ return False+ connection = connection_for(cli)+ if connection is None:+ return False+ from cli import _cprint+ from hermes_cli.gateway_client import GatewayClientError+ parts = (cmd or "").strip().split(None, 1)+ arg = parts[1].strip() if len(parts) > 1 else ""+ try:+ reply = connection.call("slash.exec", session_id=cli.session_id,+ command=canonical + (" " + arg if arg else ""))+ except GatewayClientError as exc:+ _cprint(f" /{canonical}: {exc}")+ return True+ for line in str((reply or {}).get("output") or "").splitlines():+ _cprint(f" {line}" if line else "")+ mirror = GATEWAY_SETTINGS[canonical]+ if mirror is not None:+ mirror(cli, arg)+ return Truediff --git a/tests/hermes_cli/test_gateway_setting_commands.py b/tests/hermes_cli/test_gateway_setting_commands.pynew file mode 100644index 00000000000..70d88435a4d--- /dev/null+++ b/tests/hermes_cli/test_gateway_setting_commands.py@@ -0,0 +1,26 @@+"""Per-session settings typed in the classic CLI run the gateway's handler (slash.exec) when the+session is on the gateway; client-enforced state (/busy) is mirrored after the owner accepts."""+from types import SimpleNamespace++from hermes_cli import gateway_setting_commands+++class _Conn:+ closed = False++ def __init__(self):+ self.calls = []++ def call(self, method, **params):+ self.calls.append((method, params))+ return {"type": "exec", "output": "Busy input mode: queue"}+++def test_busy_runs_on_the_gateway_and_mirrors_the_mode(monkeypatch, capsys):+ conn = _Conn()+ monkeypatch.setattr("hermes_cli.gateway_side.connection_for", lambda cli: conn)+ cli = SimpleNamespace(session_id="local-s", busy_input_mode="interrupt")+ assert gateway_setting_commands.run(cli, "busy", "/busy queue") is True+ assert conn.calls == [("slash.exec", {"session_id": "local-s", "command": "busy queue"})]+ assert cli.busy_input_mode == "queue"+ assert gateway_setting_commands.run(cli, "history", "/history") is False # a local read stays local