# Remote OpenProgram machines

Each computer, Mac, Linux or Windows, runs its own OpenProgram. A computer paired with it lists its projects and conversations beside its own, marked with that machine, and opens, writes in, stops and approves them there. Nothing is copied.

1. **Page on B** App, browser or phone; talks only to B's Worker
2. **B's Worker** one WebSocket to A, with the device credential from pairing
3. **Lists** B's items plus A's items, marked as on A
4. **Actions** an action on A's conversation is forwarded to A unchanged
5. **Frames** A's frames for it return to the pages viewing it; A's files stay on A

## Terms

| Term | Means |
| --- | --- |
| Remote OpenProgram machine | A machine in the registry ([Machines and targets](https://fzkuji.github.io/OpenProgram/docs/reference/design/integrations/computer-use/machines-and-targets.html)) whose connection method is `openprogram`: the addresses of another computer's Worker and the device credential that signs B in there |
| Home of a conversation | The Worker whose log holds it. It runs every turn: its model accounts, tools, memory and files. Never changes by being viewed elsewhere |
| Device | Anything paired with a Worker: a phone, a browser, or another computer's Worker ([Paired devices](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/remote-web-access.html#paired-devices)) |

Different from an SSH machine. A project on an SSH host keeps its conversations on this computer and runs only commands there.

## Peers

| Peer | How another computer's work appears | Taken |
| --- | --- | --- |
| [T3 Code](https://github.com/pingdotgg/t3code) | Each computer is an environment. One app connects to several, groups their projects, and reads a linked machine's threads through a relay that proxies the same stream format read-only. Work never silently crosses environments | Several machines in one list; the same frames forwarded, no second transcript format; a conversation stays on its machine |
| DSH Mobile | The phone lists every paired computer and switches between them | Per-machine online state in the list |
| OpenClaw | One gateway with paired devices that approve each other | Pairing as the only way in |
| Warp, Nimbalyst, Cursor cloud agents | Conversations are copied through the vendor's sync service | Not taken: needs a service, and the files and accounts a turn needs would not follow |

## Decisions

| Question | Choice and reason |
| --- | --- |
| Who connects to A | B's Worker, not B's page. The credential stays in B's credential store and never reaches browser storage; every page of B, phone included, sees A without pairing with A itself. One connection per machine carries the lists and the online state; each page of B that acts on A's conversations gets a forwarded connection of its own, so A's replies reach that page and no other |
| Copy or forward | Forward. Lists come from A when B asks; a conversation's rows come from A when it is opened, page by page as on A itself. B writes nothing of A's to disk |
| Which actions go to A | Every WebSocket action that names a conversation whose home is A goes to A unchanged: opening, paging, sending, steering, stopping, approvals, branches. The rule is by conversation, so actions added later follow without a forwarding entry each |
| Lists | `list_projects` and `list_sessions` answer with B's items plus each connected machine's, each item carrying its `machine_id`; A's project ids become `@<machine>/<id>`. B asks A with `local_only`, so two computers paired both ways never list each other's lists back. The sidebar groups them as it groups an SSH machine's projects and shows the machine's connection dot |
| New conversation | Created on the project's machine. Choosing A's project creates it on A |
| Files, @ search, terminal | Read on A through A's own routes, as files on an SSH host are read through its shell. Second step |
| A offline | A's projects stay listed with the disconnected dot and open to nothing; no error page. B keeps no copy to show stale content from |
| Versions | A Worker names the `remote_machine` capability in its handshake. One that does not is not connected: the machine row says it needs an update and nothing is forwarded, so neither side reads frames it does not understand |
| Routing | B knows which machine each listed conversation lives on, and a conversation started in A's project belongs to A from its first frame. An id that is also one of B's own stays B's; frames from A naming another computer's conversation are dropped |
| Frames from A | Passed to the page unchanged, except those about A's Worker itself (functions, providers, build, its own lists), which would overwrite B's |
| Authority | B acts on A as A's owner, as any paired device does. Revoking B on A closes the connection at once |

## Operating A from B

A conversation on B can operate A's windows, screen and browsers with `computer_use` and `device="<A>"` ([Machines and targets](https://fzkuji.github.io/OpenProgram/docs/reference/design/integrations/computer-use/machines-and-targets.html#paired)).

| Side | Does |
| --- | --- |
| B, sending | Forwards the whole call (type, app, display, title, action, args, actions, code, timeout; never `device`) with A's device credential as a Bearer token to `POST /api/computer-use/call`, trying each pairing address in turn, 6 s to connect. Puts `[device=..., type=...]` before A's answer. Asks its own user once per target, with a rule key naming A (`studio window safari`, `studio screen`, `studio browser chrome`); listing calls ask nothing |
| A, receiving | Runs `computer_use` on A only, never on a device A reaches in turn, and answers `{text, images, is_error}`, images in base64. A's own settings hold: its whole screen stays off unless turned on there, its operating-system permissions apply, and its `tools.permission_rules` for `computer_use` apply: a deny rule refuses, and an ask rule refuses too, since nobody on A is asked |
| The switch | Let paired devices operate this computer (`computer_use.paired_devices`), off by default, in Settings → Devices → This computer on A. While off, A answers 403 `paired_devices_off` and B's call fails saying where to turn it on |
| Errors | A whose checks have failed for 45 s: answered at once, nothing sent, and checked again; A that has only just failed is still tried. B's `<devices>` says when A cannot be reached and when it is back. 401: B was revoked on A; pair again. 404: A runs an older OpenProgram; update it |
| Listing | B lists A's window, screen and browser while A is switched on, without asking A each turn: that would be a round trip to every paired computer on every turn, often to one asleep, and A refuses precisely with the targets it does have |

## Settings

Everything here is set up in the App; the command line stays as an equal alternative.

| Where | Does |
| --- | --- |
| Settings → Devices, on A | One list of computers and paired phones; a phone shows its last use and can be renamed or revoked. **Add device** asks what the device is first (Codex's and Claude's flows): *Phone or tablet* or *Another computer → Let it use this one* shows a QR code and the link carrying every address that is on, valid ten minutes and replaced when it runs out. Below the list, *Open this computer from*: Same Wi-Fi and Anywhere (below) |
| Settings → Devices → This computer, on A | **Let paired devices operate this computer**: off by default; on, a paired computer's conversations may operate A with `computer_use` |
| Settings → Devices, on B | **Add device → Another computer → Show its conversations here**: paste A's link. B redeems it at the first of its addresses that answers and the machine appears with its dot. Its menu has no Edit: it is added by pairing only |
| Phone or browser | Scans A's QR code and is signed in to A; nothing to install |
| Settings → Channels → Add bot → WeChat | The WeChat QR code drawn in the dialog, with its waiting, scanned, confirmed and expired states, from the existing `start_channel_login` action. The terminal command is no longer the only way |

## Ways in

|  | How | Applies |
| --- | --- | --- |
| Same Wi-Fi | A second listener, in the Worker's process and on the same app, bound to this computer's private network address, whose Origin the running server then answers; `web.lan` keeps the choice (`interfaces/server/lan_listener.py`). The address is the route's interface, or the addresses this computer's own name resolves to when a proxy tunnel holds the route; only 10/8, 172.16/12 and 192.168/16 count. A new network moves the listener on the next read | At once; the main bind stays loopback |
| Anywhere | `openprogram-tailnet` in the runtime's `bin/`, or in each sealed version's `bin/` for a command-line install, where every version build keeps or rebuilds it (Go, [apps/tailnet](https://github.com/Fzkuji/OpenProgram/tree/main/apps/tailnet)) embeds Tailscale through `tsnet` and listens with Tailscale Funnel on `https://<name>.<tailnet>.ts.net`, a public address with a real certificate. It proxies every request, WebSockets included, to the Worker's loopback port, keeping the Host and setting `X-Forwarded-Proto: https`, which owner auth believes from a loopback peer. `web.anywhere` keeps the switch | At once; the bind stays loopback |

The Worker runs the sidecar as a child, with this profile's Tailscale identity in `<state>/tailnet`, and reads its JSON state lines:

- `starting`
- `needs_login`, with Tailscale's sign-in link
- `needs_funnel`, with the admin link that turns on HTTPS and Funnel
- `running`, with the address, which the running server answers only while it lasts
- `error`, with what went wrong

A pairing link names every address: the first with `#pair=<code>`, each other as `&via=<origin>`. A browser ignores the rest; another OpenProgram keeps them all and tries them in order on every connection, as T3 Code tries each of a machine's routes.

Nothing is installed for it. The owner switches it on and signs in to Tailscale once in a browser (a free personal tailnet is enough), and turns on HTTPS and Funnel once if the tailnet has not.

A phone needs no app: it opens the address in its browser. Reaching the address is not signing in; a device still pairs with a one-time code, as on Same Wi-Fi.

Peers: Claude Code Remote Control and Codex remote control relay through their own servers, so a phone reaches the computer through the vendor. OpenProgram has no server to relay through, so it embeds `tsnet` instead.

OpenClaw and T3 Code also reach a computer from elsewhere through Tailscale, but ask the owner to install it.

## On the phone

The phone runs the same web UI, added to the Home Screen as a web app (`app/manifest.ts`, `appleWebApp` in `app/layout.tsx`). Notices come by Web Push straight from this computer; there is no OpenProgram server in between.

| Part | How |
| --- | --- |
| Keys | A VAPID key pair (P-256) made once per profile in `<state>/web_push/vapid.pem`; every POST carries an ES256 JWT for the push service's origin (RFC 8292) |
| Subscriptions | `PUT /api/push/subscription` stores the browser's endpoint and keys with the paired device, its language and its categories in `subscriptions.json` (0600). Only https endpoints on Apple, Google, Mozilla and Microsoft push hosts are accepted. Revoking the device drops them; a 404 or 410 from the push service drops one |
| When | Top-level `execution.updated` frames on the runtime event bus: paused waiting for an answer or a permission (needs you), completed (reply ready), failed (stopped with an error). One notice per execution state version |
| What | A fixed sentence in the device's language and the conversation's `/s/<id>`, encrypted with `aes128gcm` (RFC 8291). No conversation text leaves the computer, so the push service sees nothing of it |
| Tap | `public/sw.js` focuses an open OpenProgram window and asks it to open the conversation, or opens a new one |

Push needs https, so it works through Anywhere and not on Same Wi-Fi. On iPhone and iPad Safari allows it only for a web app opened from the Home Screen (iOS 16.4 and later); Settings says which of these is missing.

Peers: DSH Mobile sends Web Push from its computer to a Home Screen web app, with VAPID keys kept on the computer and no relay. Taken whole. Its native shell is left for later: the web app already has everything the shell would add except App Store presence.

## Implementation status

| Status | Items |
| --- | --- |
| Implemented | Pairing and device credentials, the pairing and device routes, `openprogram web pair` and `openprogram web devices`. The `openprogram` connection method (`host/machines/peer.py`), B's connection to A, merged lists, forwarding by conversation and new conversations on A (`interfaces/server/remote_machines/`). Operating A with `computer_use`, both sides and the switch (`computer_use/providers/paired.py`). Settings → Devices with Add device, the paired phones in the list and both ways in (`/api/auth/remote-access`), the embedded Tailscale sidecar built for macOS, Linux and Windows, the WeChat QR code |
| Implemented: phone | The Home Screen web app with Web Push from this computer (`interfaces/server/web_push.py`, `public/sw.js`, Settings → General → Notifications) |
| Not started | Files, @ search and terminal: their WebSocket requests that name the conversation are forwarded like any other, but the HTTP routes still read B's own disk. A native phone shell |

[Remote Web access](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/remote-web-access.html) · [Machines and targets](https://fzkuji.github.io/OpenProgram/docs/reference/design/integrations/computer-use/machines-and-targets.html) · [Channels](https://fzkuji.github.io/OpenProgram/docs/reference/design/channels/README.html)
