The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): warn in --status about the plain-HTTP address browsers open
unsupportedpastelsc7bf749b7b9b
diff --git a/hermes_cli/webapp_launcher.py b/hermes_cli/webapp_launcher.pyindex b4b3c403706..d0146e23442 100644--- a/hermes_cli/webapp_launcher.py+++ b/hermes_cli/webapp_launcher.py@@ -203,6 +203,15 @@ def _plain_http_note(url: str) -> str | None:return PLAIN_HTTP_NOTE+def _browser_address(target: Path, settings, served_url: str) -> str:+ """Where a browser opens the Webapp the gateway serves at *served_url* (its loopback dial origin), as+ ``webapp-launch`` works it out behind sign-in: ``webapp.public_url`` when set, else the LAN address+ Web Access registered Nous sign-in for, else *served_url*. Read from *target*'s config now, not from+ when the gateway started."""+ from hermes_cli.webapp_access import registered_lan_origin+ return settings.public_url or registered_lan_origin(target, urlsplit(served_url).port) or served_url++def _status(target: Path) -> int:try:response = _control(target, "webapp-status")@@ -219,10 +228,11 @@ def _status(target: Path) -> int:status = response["result"]if status["state"] == "serving":print(f"Serving at {status['url']}")- if note := _plain_http_note(status["url"]):- print(note)from gateway.webapp_listener import webapp_settings- if not webapp_settings(target).enabled:+ settings = webapp_settings(target)+ if note := _plain_http_note(_browser_address(target, settings, status["url"])):+ print(note)+ if not settings.enabled:print(f"{target / 'config.yaml'} no longer turns the Webapp on: it stops at the next gateway restart "f"({RESTART_COMMAND}).")elif status["state"] == "starting":diff --git a/tests/hermes_cli/test_webapp_launcher.py b/tests/hermes_cli/test_webapp_launcher.pyindex c2a51ca806c..0ba0aaceb60 100644--- a/tests/hermes_cli/test_webapp_launcher.py+++ b/tests/hermes_cli/test_webapp_launcher.py@@ -6,6 +6,7 @@ over the control socket and opens it. It never serves anything itself. ``--sign-the gateway did, waits for a gateway that is still starting, and replaces the stored credentialitself only when no gateway runs."""+import jsonfrom argparse import Namespacefrom pathlib import Path@@ -444,11 +445,39 @@ def test_a_webapp_opened_over_plain_http_on_the_lan_says_what_the_browser_loses(assert _says_what_plain_http_loses(capsys.readouterr().out)-def test_status_of_a_webapp_served_over_plain_http_on_the_lan_says_what_the_browser_loses(world, capsys):- world["answers"]["webapp-status"] = {"ok": True, "result": {- "state": "serving", "url": "http://10.0.1.170:9120", "reason": None}}+def _register_lan_sign_in(world, address: str, port: int = 9120) -> None:+ """Web Access Start registered Nous sign-in for ``http://<address>:<port>``, this machine's LAN address."""+ from hermes_cli import webapp_access+ record = world["root"] / "webapp" / "sign-in-registration.json"+ record.parent.mkdir(mode=0o700, parents=True, exist_ok=True)+ record.write_text(json.dumps({"portal": "https://portal.example", "client_id": "agent:x",+ "callback": f"http://{address}:{port}/auth/callback"}) + "\n", encoding="utf-8")+ world["monkeypatch"].setattr(webapp_access, "lan_address", lambda: address)++[email protected]("browser_address", ["public_url", "lan_sign_in"])+def test_status_of_a_webapp_browsers_open_over_plain_http_on_the_lan_says_what_the_browser_loses(+ world, capsys, browser_address):+ """The gateway reports its loopback dial origin; browsers open webapp.public_url, else the LAN address+ Web Access registered sign-in for, as hermes webapp does. --status warns about that address."""+ if browser_address == "public_url":+ _home(world["root"], "webapp:\n enabled: true\n host: 0.0.0.0\n public_url: http://192.168.1.20:9120\n")+ else:+ _home(world["root"], "webapp:\n enabled: true\n host: 0.0.0.0\n")+ _register_lan_sign_in(world, "192.168.1.20")assert launcher.cmd_webapp(_args(status=True)) == 0- assert _says_what_plain_http_loses(capsys.readouterr().out)+ out = capsys.readouterr().out+ assert "Serving at http://127.0.0.1:9120" in out+ assert _says_what_plain_http_loses(out)++[email protected]("public_url", ["", "https://hermes.example.ts.net"])+def test_status_gets_no_plain_http_warning_when_browsers_open_a_secure_address(world, capsys, public_url):+ """A wildcard bind with no public URL or LAN sign-in opens loopback; an HTTPS public URL is secure."""+ _home(world["root"], "webapp:\n enabled: true\n host: 0.0.0.0\n"+ + (f" public_url: {public_url}\n" if public_url else ""))+ assert launcher.cmd_webapp(_args(status=True)) == 0+ assert "plain http" not in capsys.readouterr().out.lower()@pytest.mark.parametrize("url", ["http://127.0.0.1:9120/", "http://127.0.0.2:9120/", "http://localhost:9120/",diff --git a/website/docs/user-guide/desktop.md b/website/docs/user-guide/desktop.mdindex edd02cded40..9fca2edd581 100644--- a/website/docs/user-guide/desktop.md+++ b/website/docs/user-guide/desktop.md@@ -85,7 +85,8 @@ links serve only a Webapp that needs no sign-in. HTTPS is strongly recommended raddress other than loopback (`http://localhost` and `http://127.0.0.1` count as secure): the botscreen viewer, the microphone (dictation and live voice) and system notifications. The bot screen andlive voice say so instead of opening. `hermes webapp` and `hermes webapp --status` print a note when-the address they give is plain HTTP on another host. To keep these features, open the Webapp over+the address a browser opens (`webapp.public_url`, else the LAN address **Start** registered sign-in+for) is plain HTTP on another host. To keep these features, open the Webapp overHTTPS (`webapp.public_url`) or through an SSH tunnel to `127.0.0.1`.:::warning Treat Webapp access like access to Hermes on the host