# login-bridge Hand a human the agent's browser for one login. Hermes' browser tool drives a **copy** of your browser profile. That is enough to *reuse* a session, but not to *create* one — a password, a 2FA prompt, or a CAPTCHA needs a person. This plugin publishes that profile on a virtual display behind a token-gated HTTPS noVNC endpoint. You finish the login from any device, including a phone, and the cookies you create are inherited by the agent's next profile snapshot. ``` Xvfb ─→ your real browser profile ─→ x11vnc (loopback) ─→ websockify (TLS + token) ─→ you ``` Nothing outside `$HERMES_HOME/login-bridge` is ever written. No nginx snippet, no systemd unit, no system path. ## Install ```bash hermes plugins install kfastov/hermes-plugin-login-bridge hermes plugins enable browser/login-bridge ``` System dependencies: ```bash # Debian / Ubuntu apt-get install -y xvfb x11vnc websockify novnc openssl # Fedora dnf install -y xorg-x11-server-Xvfb x11vnc python3-websockify novnc openssl # Arch pacman -S --needed xorg-server-xvfb x11vnc python-websockify novnc openssl ``` Check everything at once: ``` /loginbridge doctor ``` ## Use Ask the agent, or drive it directly: | Action | Slash command | Tool call | | --- | --- | --- | | Start and get a link | `/loginbridge https://github.com/login` | `login_bridge action=start url=…` | | Show the running session | `/loginbridge status` | `login_bridge action=status` | | Stop and revoke the token | `/loginbridge stop` | `login_bridge action=stop` | | Check dependencies/config | `/loginbridge doctor` | `login_bridge action=doctor` | `/loginbridge` with no argument returns the current session, or starts one if none is running. ## Configuration Everything is optional; defaults work on a standard Linux host. Settings live under `plugins.entries.login-bridge.settings` in `~/.hermes/config.yaml` and follow the same shape as the Hermes webhook platform. ```yaml plugins: entries: login-bridge: settings: host: "0.0.0.0" # bind interface port: 8443 # websockify serves TLS + noVNC here directly public_url: "" # e.g. https://vnc.example.com when behind a proxy tls_mode: "auto" # auto | self_signed | files | off cert_file: "" # with key_file, for a real certificate key_file: "" geometry: "1280x1600" # portrait, sized for phones idle_timeout_min: 30 # 0 disables the timeout ``` | Key | Default | Meaning | | --- | --- | --- | | `host` | `0.0.0.0` | Bind interface. Use `127.0.0.1` behind a reverse proxy. | | `port` | `8443` | Public port. websockify serves it; no system web server is touched. | | `public_url` | *(detect)* | Externally visible base URL. Overrides `host`/`port` in the generated link. | | `public_host` | *(detect)* | Hostname for the link when `public_url` is unset. | | `tls_mode` | `auto` | `auto` (cert files if given, else managed self-signed), `self_signed`, `files`, `off`. | | `cert_file` / `key_file` | — | Real certificate; must be set together. | | `display` | `:77` | X display for the virtual screen. | | `geometry` | `1280x1600` | Virtual screen size. | | `profile_dir` | *(Hermes profile)* | Browser user-data-dir. The default is what makes logins transfer to the agent. | | `browser_binary` | *(detect)* | Chrome / Chromium / Edge / Brave. | | `browser_args` | `[]` | Extra browser flags. | | `default_url` | `about:blank` | Page opened by a bare `start`. | | `idle_timeout_min` | `30` | Auto-stop after N minutes; `0` disables. | | `novnc_root` | *(detect)* | Directory holding `vnc.html`. | ### Behind a reverse proxy Terminate TLS upstream, bind locally, and tell the plugin its public address: ```yaml host: "127.0.0.1" tls_mode: "off" public_url: "https://vnc.example.com" ``` ## Security model - **The link is the credential.** Anyone holding it controls that browser profile. It is single-session and dies with `stop` or the idle timeout. - **Token gate.** websockify's `TokenFile` maps an opaque per-session token to the loopback VNC port. Reaching the port without the token gets you nowhere. The token file is written `0600` before any content lands in it. - **x11vnc is loopback-only** and password-less by design: it is unreachable from the network, and the token plus transport layer are the real gate. - **TLS by default.** With no configuration the plugin issues and reuses a self-signed certificate in its own state directory. Supply `cert_file` / `key_file` for a real one, or `tls_mode: off` when a proxy handles it. - **Bounded lifetime.** The session stops itself after `idle_timeout_min`. ## Implementation notes | Module | Responsibility | | --- | --- | | `settings.py` | Validated, typed configuration. The only reader of plugin config. | | `processes.py` | Child supervision with PID-reuse-safe handles and zombie detection. | | `readiness.py` | Real readiness probes (X socket, TCP port, window presence) — no sleeps. | | `security.py` | TLS material and per-session token issue/revoke. | | `session.py` | Durable, atomically-written session state. | | `bridge.py` | Composition and lifecycle. | | `reporting.py` | All user-facing wording. | Two details worth calling out: - **PIDs are not identity.** Each handle stores the kernel start time, and a PID whose start time no longer matches is never signalled — otherwise a recycled PID could get an unrelated process killed. Zombies are detected via process state, since an unreaped child still answers `kill(pid, 0)`. - **Failed starts leave nothing behind.** If any component fails to become ready, every process already started is torn down and the token is revoked before the error is returned. ## Tests ```bash python3 -m pytest ``` 60 tests, no network and no X server required. ## License MIT