The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): open the Webapp's public URL to sign in when webapp.public_url is set
emozilla7e2972f24975
diff --git a/gateway/webapp_listener.py b/gateway/webapp_listener.pyindex d327218a610..25317c65702 100644--- a/gateway/webapp_listener.py+++ b/gateway/webapp_listener.py@@ -292,7 +292,11 @@ def register_control_verbs(runner, home) -> None:from hermes_cli.web_server_surface import private_launchif not private_launch(web.app.state):# Behind the dashboard's sign-in the page asks for it; a launch link opens only a private Webapp.- return {"url": f"{status['url']}/{query}", "private": False, "expires_in_seconds": None, "sign_in": True}+ # With webapp.public_url set (the listener's own public URL), sign-in returns to a callback on+ # that URL and checks a state cookie set where it started, so the browser starts there too.+ # Native clients keep the loopback address.+ address = getattr(web.app.state, "listener_public_url", "") or status["url"]+ return {"url": f"{address}/{query}", "private": False, "expires_in_seconds": None, "sign_in": True}if not _one_use_links_work():return {"url": f"{status['url']}/{query}#hermes-session={web._SESSION_TOKEN}", "private": True,"expires_in_seconds": None}diff --git a/tests/gateway/test_webapp_listener.py b/tests/gateway/test_webapp_listener.pyindex 22f0c2f5d58..7c62b7a1aea 100644--- a/tests/gateway/test_webapp_listener.py+++ b/tests/gateway/test_webapp_listener.py@@ -200,6 +200,25 @@ def test_behind_the_dashboard_sign_in_the_launcher_gets_the_webapp_address(monkeassert not getattr(state, "webapp_window_tickets", None)[email protected](("public_url", "params", "opened"), [+ ("https://webapp.example.net", {}, "https://webapp.example.net/"),+ ("https://example.net:8443/hermes", {"profile": "work"}, "https://example.net:8443/hermes/?profile=work"),+])+def test_behind_its_own_public_url_the_launcher_opens_that_url_to_sign_in(monkeypatch, tmp_path, public_url,+ params, opened):+ # Sign-in keeps its state cookie on the address the browser opened and returns to a callback on+ # webapp.public_url, so the launcher opens that URL, path prefix kept; a sign-in started on the+ # loopback address could never finish. Native clients keep the loopback address.+ runner, _, _ = _start_runtime_api(+ monkeypatch, tmp_path, f"webapp:\n enabled: true\n port: 9555\n public_url: {public_url}\n")+ # The gateway's dashboard mount records webapp.public_url as the listener's own public URL.+ state = SimpleNamespace(ui_surface="webapp", auth_required=True, listener_public_url=public_url)+ runner.session_api.app = SimpleNamespace(web=SimpleNamespace(_SESSION_TOKEN="s" * 43, app=SimpleNamespace(state=state)))+ result = _ask(runner, "webapp-launch", params=params)["result"]+ assert result == {"url": opened, "private": False, "expires_in_seconds": None, "sign_in": True}+ assert runner.webapp_status["url"] == "http://127.0.0.1:9555"++def _serving_runner(monkeypatch, tmp_path):runner, _, _ = _start_runtime_api(monkeypatch, tmp_path, "webapp:\n enabled: true\n port: 9555\n")# The gateway mounts the dashboard app as the Webapp surface on a private (loopback) listener.diff --git a/tests/gateway/test_webapp_public_url.py b/tests/gateway/test_webapp_public_url.pyindex 70e7dda621f..d942f0905dc 100644--- a/tests/gateway/test_webapp_public_url.py+++ b/tests/gateway/test_webapp_public_url.py@@ -113,6 +113,13 @@ def test_the_webapps_public_url_engages_sign_in_on_a_loopback_bind(own_url):assert own_url["launch"]["sign_in"] is True+def test_hermes_webapp_opens_the_webapps_public_url_to_sign_in(own_url):+ # The sign-in callback is on the public URL, so the browser starts there too; native clients+ # keep the loopback address.+ assert own_url["launch"]["url"] == f"{WEBAPP_URL}/"+ assert own_url["api_origin"].startswith("http://127.0.0.1:")++def test_the_webapp_trusts_only_its_own_public_host(own_url):assert own_url["state"]["trusted_public_hosts"] == ["webapp.example.net"]assert own_url["probe_host_status_code"] == 200diff --git a/website/docs/reference/cli-commands.md b/website/docs/reference/cli-commands.mdindex f593ca8c120..99e2ac9cda4 100644--- a/website/docs/reference/cli-commands.md+++ b/website/docs/reference/cli-commands.md@@ -1945,10 +1945,11 @@ For a named profile served by the default gateway (`hermes -p work webapp`), theprofile.Behind the dashboard sign-in gate (`webapp.host: 0.0.0.0` or `::`, or `webapp.public_url` set), the-command opens the Webapp's address instead of a one-use link, and you sign in there with your dashboard-account. When the gateway cannot serve the Webapp, the command says why; the gateway reads its Webapp-settings when it starts, so run `hermes gateway restart` after fixing the cause. A Webapp bundle that-is not built yet is the exception: this command builds it, and the running gateway serves it at once.+command opens the Webapp's address instead of a one-use link (with `webapp.public_url` set, that URL,+where sign-in returns), and you sign in there with your dashboard account. When the gateway cannot+serve the Webapp, the command says why; the gateway reads its Webapp settings when it starts, so run+`hermes gateway restart` after fixing the cause. A Webapp bundle that is not built yet is the+exception: this command builds it, and the running gateway serves it at once.| Option | Description ||--------|-------------|diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.mdindex 6a160b322fb..c828472e2a3 100644--- a/website/docs/user-guide/configuration.md+++ b/website/docs/user-guide/configuration.md@@ -3180,7 +3180,7 @@ webapp:- `port` — when the port is taken, the gateway likewise serves native clients only and `hermes webapp --status` reports why. It also replaces the Webapp's browser sign-in, since another program may have received it, so open tabs need `hermes webapp` again once the port is free.- `public_url` — set it when a reverse proxy or tunnel you run serves the Webapp at its own address (forwarding to `host:port`). It turns on dashboard sign-in even on a loopback `host`, it is the one outside hostname the Webapp accepts requests for, and sign-in callbacks are built on it. Without a sign-in provider the gateway serves native clients only, as for `0.0.0.0`. It must be an `http://` or `https://` address with no credentials, query or fragment; anything else keeps the Webapp off. `dashboard.public_url` is for `hermes dashboard` and never applies to the Webapp.-Sign-in turns on when `host` is `0.0.0.0` or `::`, or when `public_url` is set, whatever the host. `hermes webapp` then opens the Webapp's address for you to sign in with your dashboard account: its one-use links only open a Webapp that needs no sign-in. Native clients (the CLI, TUI and Desktop app) never sign in: the gateway's listener for them never asks for it, whatever the config says.+Sign-in turns on when `host` is `0.0.0.0` or `::`, or when `public_url` is set, whatever the host. `hermes webapp` then opens the Webapp's address (`public_url` when set, where sign-in returns) for you to sign in with your dashboard account: its one-use links only open a Webapp that needs no sign-in. Native clients (the CLI, TUI and Desktop app) never sign in: the gateway's listener for them never asks for it, whatever the config says.The Webapp settings are read from the config of the gateway that serves the profile: the default profile's config for named profiles it serves, a standalone profile's own config otherwise.diff --git a/website/docs/user-guide/desktop.md b/website/docs/user-guide/desktop.mdindex 3929358c21c..6b3288b0be5 100644--- a/website/docs/user-guide/desktop.md+++ b/website/docs/user-guide/desktop.md@@ -66,9 +66,10 @@ serves share its Webapp; a standalone profile's own gateway serves its own when[dashboard sign-in gate](./features/web-dashboard.md#authentication-gated-mode) (username and passwordfor a trusted LAN or VPN, OAuth/OIDC for anything internet-facing). Behind a reverse proxy or tunnelyou run, keep the loopback host and set `webapp.public_url` to the address it serves instead; that-requires the same sign-in. `hermes webapp` then opens the Webapp's address, where you sign in with your-dashboard account; one-use links serve only a Webapp that needs no sign-in. HTTPS is strongly-recommended remotely and browsers require it for some microphone and clipboard features.+requires the same sign-in. `hermes webapp` then opens the Webapp's address (`webapp.public_url` when+set), where you sign in with your dashboard account; one-use links serve only a Webapp that needs no+sign-in. HTTPS is strongly recommended remotely and browsers require it for some microphone and+clipboard features.:::warning Treat Webapp access like access to Hermes on the hostA signed-in Webapp user can run arbitrary commands as the OS account running Hermes, run agent tools,