# Remote access: phone, other computers and hosted agents One Namma Agent instance is the brain. Your phone, a second computer and the web are *clients* of it. The instance can run on your desktop, on a home server or on a free Oracle Cloud VM. Every client is a **linked device** with its own key that you can revoke at any time. None of this is required. The desktop app and the web UI work on their own, with no phone, tunnel or hosting. Linking devices is optional. ``` Android app ─┐ ┌─ Telegram / WhatsApp / Discord / Slack / Signal Desktop app ─┼── device keys ──► Namma Agent (desktop · home server · OCI VM) Browser ─┘ └─ routines, watchers, memory, projects, Learning Room ``` ## 0. Two desktop modes | | This computer (default) | Hosted agent | |---|---|---| | Where chats, tools and memory live | On this PC | On your server (Oracle free tier, any VPS) | | What the desktop app does | Runs the agent | Shows the server's agent; runs nothing locally | | Phones link through | The desktop (*Allow phones on this Wi-Fi*) | The desktop, which relays to the server, or the server's own HTTPS address | | Switch | Tray → **Runs on**, or Settings → Devices → *Where your agent runs* | same | ### Hosted agent over SSH (no open ports, no HTTPS) Tray → **Runs on → Hosted agent…** → *Over SSH*: enter `ubuntu@` (or a `~/.ssh/config` alias) and pick your SSH key. The desktop opens an SSH port forward to the agent's `127.0.0.1:8000` on the server, which is what `ssh -L 8000:localhost:8000` does by hand. It then makes a pairing code on the server over SSH (`namma devices pair --json`, run as the agent's own user) and pairs, so it holds its own revocable key even when the server has a master token. Nothing is exposed to the internet, and the traffic is encrypted by SSH. It uses the system's OpenSSH client (built into Windows 10+, macOS, Linux) with `BatchMode`: it never asks for or stores a password. A key with a passphrase must be in ssh-agent. If `sudo` on the server needs a password, the app asks you for a code from `namma devices pair` instead. The tunnel reconnects by itself if the connection drops. ### Phones through the desktop (hosted mode) With the desktop in hosted mode, Settings → Devices → **Allow phones on this Wi-Fi** starts a relay on port 8765. Phones on the Wi-Fi connect to the desktop, which passes every request and the live `/ws` socket to the server. The relay adds no credentials: each phone pairs with the **server** and carries its own key, and the relay marks its requests as forwarded, so the server treats them as remote and requires that key. The QR the desktop shows points at the relay. The app also finds it under **On this Wi-Fi**. ### A hosted agent stays set up Once connected, the desktop keeps the hosted agent. Switching to **This computer** (tray *Runs on*, or Settings → Devices) doesn't forget it: *Switch to …* goes back with no code. If the server can't be reached (no network, the VPS rebooting), the app shows **Reconnecting** and keeps trying on its own; it only asks you to set it up again when the server refuses the login (SSH key refused, host key changed, or this computer's key was revoked). *Forget hosted agent* removes it on purpose. ### Several routes to one agent The same agent can often be reached more than one way: over SSH, at its public address (`server.public_url`, a tunnel), or at a home-network address. After connecting, the desktop and the phone learn the agent's other addresses and switch between them when the one in use stops answering — the device key works on all of them, since it's one server. | From | To | Works when | |---|---|---| | Desktop | VPS over SSH | Anywhere with internet | | Desktop or phone | Agent at its public URL / tunnel | Anywhere | | Phone | Desktop (LAN listener) or VPS through the desktop's relay | Same Wi-Fi only (phones have no SSH) | | Phone | Agent running on the phone itself | Always — see the Android README | ## 1. Ways to reach your agent | Where the agent runs | How the phone reaches it | Command / setting | |---|---|---| | Your desktop, phone on the same Wi-Fi | LAN address, e.g. `http://192.168.1.20:8000` | `namma serve --lan` (or `server.host: 0.0.0.0`) | | Your desktop, phone anywhere | A free tunnel | `namma serve --tunnel cloudflared` (or `ngrok`) | | Any machine on your Tailscale tailnet | Its tailnet name / 100.x address | install Tailscale on both and use `--lan` | | Oracle Cloud / VPS | A public HTTPS address | Caddy in front + `server.public_url` (see §5) | ### From the desktop app: "Allow phones on this Wi-Fi" The desktop app's engine normally listens only to the computer itself, so a phone can't reach it. Open **Settings → Devices** and turn on **Allow phones on this Wi-Fi**. The engine then also listens on your network (port 8765 by default). Every phone still has to pair, and the setting stays on across restarts. Below the switch, **Share over the internet** opens a free cloudflared or ngrok tunnel so a phone away from home can connect too. The phone app also searches the Wi-Fi for agents by itself (**On this Wi-Fi** on the connect screen), so you rarely need to type an address. ## 2. Link a device Pairing QRs carry a plain web address, `http(s):///pair#code=…`. Any camera app opens it: the agent serves a small page that hands the code to the app (**Open in the Namma Agent app**) and shows it for typing. The code is in the URL fragment, so it never reaches server logs. The app's own scanner reads the same QR directly, including QRs drawn inverted (light on dark) in a terminal. 1. **Make a pairing code** on the agent, using any one of these: - **Desktop / web:** Settings → **Devices** → *Pair a phone or computer*. You get a code and a QR. - **Telegram:** send `/pair` to your bot. You get the QR as a photo. - **Server terminal:** run `namma devices pair`. The QR is drawn in the terminal. 2. **On the phone,** open the app → **Scan pairing QR code**. You can also type the server address and the code. 3. The phone gets its own key. Only a hash of the key is stored on the agent. Codes work **once** and **expire after 10 minutes**. Pairing attempts are rate-limited per address. To revoke a device, use Settings → Devices, or the app's More → Linked devices, or run `namma devices revoke `. A revoked key stops working immediately. ## 3. Develop and test from source You can run the agent straight from a git checkout and drive it from the Android app: ```bash # phone on the same Wi-Fi python -m namma_agent serve --lan # phone anywhere (needs cloudflared: winget install --id Cloudflare.cloudflared) python -m namma_agent serve --tunnel cloudflared ``` Both commands print a pairing code and a QR. Scan it with the app and you are connected. In both modes **every caller other than this computer must present a device key**, so the internet can't reach the agent in the window before you pair. The tunnel's address is used only for that run; nothing is written to your config. Tips: - The Windows firewall asks the first time Python listens on the LAN. Allow it for *Private* networks. - **Android emulator:** the computer running the emulator is `10.0.2.2` from inside it, e.g. `http://10.0.2.2:8765`. Wi-Fi discovery doesn't cross the emulator's virtual network, so type the address there. - `ngrok` works the same way: run `namma serve --tunnel ngrok` after `ngrok config add-authtoken …`. - Building the app itself is covered in [mobile/android/README.md](../mobile/android/README.md). ## 4. The desktop app as a client (hosted-agent mode) - Tray → **Runs on → Hosted agent…** (or open a `namma://pair?...` link). Choose *Over SSH* (see §0) or *Address + pairing code* for an agent with its own address. - The desktop gets its own device key, stored with the OS keychain (Electron `safeStorage`). - Tray → **Runs on → This computer** (or Settings → Devices → *Use this computer*) goes back to the local engine and revokes the remote key. ## 5. Host it (Oracle Cloud free tier or any VPS) Install the agent with [DEPLOY_ORACLE.md](DEPLOY_ORACLE.md) or [DEPLOY_VPS.md](DEPLOY_VPS.md). For the desktop, and for phones at home through the desktop, SSH is enough (§0). Only if phones should reach the server directly from anywhere, put HTTPS in front of it: ```bash sudo apt install -y caddy # /etc/caddy/Caddyfile agent.example.com { reverse_proxy 127.0.0.1:8000 } sudo systemctl reload caddy ``` Then set, in `data/user_config.yaml` (or with Settings → Devices → *Address other devices use*): ```yaml server: public_url: https://agent.example.com # goes into every pairing QR auth_token: "" # master token; strongly recommended on a public server require_key_for_remote: true # never accept key-less callers from outside ``` Without a domain, a Cloudflare named tunnel or Tailscale avoids opening ports. Requests relayed by a proxy on the same box (those carrying `X-Forwarded-For`) are treated as **remote**, so Caddy can't accidentally make every caller look local. ## 6. What a linked device can do Everything the app shows: chats with live streaming, tool steps and approvals, Projects (chats, documents, notes, the coding agent's workspace), the Learning Room (paths, lessons, question cards, insights), personas and specialists, memory, routines and watchers, models, toolsets, skills, MCP servers, messaging-channel status and trust, and device management. A linked device can't shut down, update or uninstall the instance, and it can't drive the desktop window hooks. Those stay on the machine itself. ## 7. Notifications on the phone Routine results, watcher alerts, reminders and `send_message` all land in the **app inbox**. It counts as a messaging channel whenever a device is linked. The app checks the inbox in the background every 15 minutes (Android's minimum) and shows a notification. While the app is open, updates arrive live over the socket. ## 8. Security summary | Situation | Who gets in | |---|---| | `server.auth_token` set | The master token or a live device key, from anywhere | | No master token, request from this machine | Allowed (the desktop app) | | No master token, remote request, no device ever linked | Allowed, which is the old behaviour. Avoid it on public servers: set `require_key_for_remote` | | No master token, remote request, a device was ever linked | Device key required, even after every device is revoked | | `namma serve --lan/--tunnel`, or `require_key_for_remote: true` | Device key required for every remote caller | The HTTP API and the `/ws` WebSocket use the same rules.