# flow-remote command reference

> Every flow-remote command with its synopsis, flags and effect, for pairing, grants, listing sessions, attaching and checking the daemon and sync.

`flow-remote` is the daemon and command-line tool behind Puddles: it pairs your devices, manages what each one may do, lists and opens another device's terminal sessions, and reports what the daemon and its sync are doing. The Puddle page in the app does most of this for you; this page is the reference for running it yourself or from a script. For the concepts, see [Pair devices with flow-remote](https://flow.worldbreakstudios.com/docs/sync/flow-remote.md).

## Where the binary is

`flow-remote` ships inside the app, beside Flow's other command-line tools, at `Flow.app/Contents/MacOS/flow-remote`. It is **not** on your `PATH`, and **Install command-line tools** does not link it. Run it by its full path:

```sh
/Applications/Flow.app/Contents/MacOS/flow-remote --help
```

While Puddles is on (Settings › Experiments › **Puddles**), the app runs `flow-remote serve` for you. You only need `serve` yourself to run the daemon by hand.

## Conventions

- **`<device>`** is a device id, a unique prefix of one (4 or more characters), or a device name. If the text could mean more than one device, the command refuses and asks for the id.
- Every command takes `--help` (or `-h`). `--` ends the options.
- `--json` prints machine-readable output where a command lists it, and is an error elsewhere.
- Every failure is one line on stderr and exit status `1`. Success is exit status `0`.
- `HOME` must be set to an absolute path. Nothing is looked for relative to the working directory.
- State lives in `~/.flow/remote`, or in `$FLOW_REMOTE_DIR` when it is set.
- Commands that talk to "the daemon" need `flow-remote serve` running for the same state directory. Without it they fail with "flow-remote is not running on this device", except `devices`, `revoke`, `grant` and `deny`, which then work on the stored device list directly.

## Command summary

| Command | Needs the daemon | Effect |
|---|---|---|
| `serve` | (is the daemon) | run the daemon in the foreground |
| `pair` | yes | print a one-time pairing token, then approve the device that joins |
| `join` | no | pair with another device, reading its token from stdin |
| `devices [--json]` | no | list the paired devices |
| `revoke <device>` | no | forget a device and close its connections |
| `grant <device> open\|create` | no | let a paired device open or create sessions here |
| `deny <device> open\|create` | no | take that back |
| `ping <device>` | no | check that a paired device answers |
| `sessions <device> [--json]` | no | list a paired device's terminal sessions |
| `attach <device> <session>` | no | open a paired device's session live in this terminal |
| `attach <device> --new` | no | have that device's Flow create a session, then open it |
| `status [--json]` | yes | what the daemon is doing |
| `sync status [--json]` | yes | what the daemon's sync is doing |

## serve

```text
flow-remote serve [--bind tailscale|lan|loopback|tailcat|IP] [--port N] [--settings PATH]
                  [--sessions-index PATH] [--bus PATH] [--sink-db PATH] [--started-by-app]
```

Runs the daemon in the foreground: the network listener for your other devices and the local control socket for this device's commands. One daemon runs per state directory; a second one refuses to start.

`serve` refuses to start unless Puddles is on: `features.remote` must be `true` in `~/.flow/settings.json`, or in the file `--settings` names. It reads the flag once, at start; switching Puddles off later does not stop a daemon you started by hand.

| Flag | Value | Default | Effect |
|---|---|---|---|
| `--bind` | `tailscale` | (none) | listen on the tailnet IPv4 only; an error if there is none. With no `--bind`: the tailnet IPv4 when Tailscale is up, else loopback with a notice |
| | `lan` | | listen on every interface (opt-in). A literal `0.0.0.0` or `::` is refused; use `lan` |
| | `loopback` | | listen on `127.0.0.1`; nothing to advertise, so no pairing token can be made |
| | an IP address | | listen on that address |
| | `tailcat` | | run a tailcat tunnel server in the daemon and listen inside it; reaches other networks through public relays, with no Tailscale account. Opt-in only |
| `--port` | integer | `47633` | the listening port |
| `--settings` | absolute path | `~/.flow/settings.json` | the settings file the Puddles flag is read from |
| `--sessions-index` | absolute path | none | the app's index of groups and tab titles, so listings carry them |
| `--bus` | absolute path | `~/.flow/bus.sock` | the app's command socket, which creating sessions and the app's verbs ask |
| `--sink-db` | absolute path | none | the app's sync store (`sink.db`); without it the daemon serves without sync |
| `--started-by-app` | (flag) | off | for Flow's own use: marks a daemon the app may stop when Puddles turns off |

Tailscale is found through its CLI: the macOS app's binary at `/Applications/Tailscale.app/Contents/MacOS/Tailscale` first, then `PATH`. A loopback address is never put in a pairing token.

## pair

```sh
flow-remote pair
```

Asks the daemon for a one-time pairing token and prints it: single use, valid for 5 minutes, one pairing waiting at a time. It then waits for the other device, shows the name and id that device gave and a six-digit confirmation code, and asks `Pair with this device? [y/N]`. `y` or `yes` (any case) approves; anything else, Ctrl-C, or no answer within 60 seconds of the other device arriving refuses.

`pair` needs a terminal on both stdin and stdout and takes no arguments. Approve only when your other device shows the same code: the name is whatever that device chose.

## join

```sh
flow-remote join
```

Reads a pairing token from stdin (on a terminal it prompts `Pairing token:` and switches echo off), dials the other device and pairs, printing `Confirmation code: NNNNNN`. Approve on the other device if it shows the same code. It ends with `Paired with <name> (<id>).` Echo is switched back on however it ends, Ctrl-C included.

The token is never taken as an argument: `flow-remote join fr1.…` is an error. A token from a script can be piped in:

```sh
pbpaste | flow-remote join
```

## devices

```sh
flow-remote devices [--json]
```

Lists the paired devices: `ID`, `NAME`, `LINK` (`connected` or `-`), `LAST SEEN` and `CAPABILITIES`. Capabilities are `sessions.list` (every paired device), `sessions.attach` (granted **open**) and `sessions.create` (granted **create**). With no daemon running it reads the stored list, and nothing shows as connected.

## revoke

```sh
flow-remote revoke <device>
```

Forgets the device and, through a running daemon, closes its connections at once: `Revoked Studio (a1b2…); closed 2 connection(s).` With no daemon it edits the stored list, and the daemon refuses that device from its next request or handshake. Revoking is one-sided; remove this device on the other one too.

## grant and deny

```sh
flow-remote grant <device> open|create
flow-remote deny <device> open|create
```

| Word | Capability | Lets the device |
|---|---|---|
| `open` | `sessions.attach` | watch this device's terminal sessions and type into them: full shell access here |
| `create` | `sessions.create` | have Flow on this device create terminal sessions |

Both are off by default. `deny … open` through a running daemon ends that device's live views at once and leaves its other links alone. Listing can't be granted or denied: it is what being paired means (use `revoke`). These are the same switches as **Can open my sessions** and **Can create sessions** on the Puddle page.

## ping

```sh
flow-remote ping <device>
```

Dials the device with this device's identity and prints the round trip: `Studio (a1b2…) answered in 3.2 ms (API v…)`. A success also updates the device's last-seen time.

## sessions

```sh
flow-remote sessions <device> [--json]
```

Lists the other device's terminal sessions: `SESSION` and `STATE`, plus `TAB` (group › tab title) when the device sends them. It sends group names to a device it lets open or create sessions, and tab titles to one it lets open. A session marked `no sharing` can't be opened. Everything shown came from the other device and is cleaned before printing.

## attach

```text
flow-remote attach <device> <session>
flow-remote attach <device> --new [--group ID] [--request ID] [--resume] [--announce]
```

Opens a session of the other device live in this terminal: the remote screen as output, your keys as input, window resizes passed on. It needs a terminal on stdin and stdout and the device's **open** grant.

| Flag | Effect |
|---|---|
| `--new` | have the device's Flow create a session first (needs **create**), then attach to it. A reconnect attaches the session it made; it never creates a second one |
| `--group ID` | with `--new`: create the session in that app group |
| `--request ID` | with `--new`: the create's request id, 16–32 lowercase hex digits. A create repeated after a lost reply makes no second session on a device that supports it. Without it, `attach` picks one |
| `--resume` | for Flow's own use: with `--request`, only reattach the session that request made; never create |
| `--announce` | for Flow's own use: with `--new`, name the created session to the Flow pane before any remote output |

`attach` exits only when the remote shell exits (with its status), when stdin ends or the terminal goes away, or on a signal from outside. Anything else **reconnects by itself**:

| What happened | What `attach` does |
|---|---|
| the link dropped, or the device didn't answer (asleep, network change, its daemon restarting) | retries by itself with a backoff from 0.5 s up to 10 s; shows "`<device>` is offline — this view reconnects when it's back." while it can't reach it |
| the device refused the handshake | retries; after three in a row, waits 15 s to a minute, and from the sixth at least five minutes |
| the device withdrew access | says "`<device>` stopped sharing its sessions with this Mac." and which switch to ask for, then waits for Enter |
| the session is gone | says "`<device>` closed this session." and waits for Enter |
| a protocol error, an unpaired device or an old device that can't do it | prints why, then "Press Enter to try again, or close this tab." |

Enter always tries again at once. While waiting, a status of at most two dim lines sits on the bottom rows of the screen. The terminal stays in raw mode the whole time, so Ctrl-C reaches the remote program instead of ending the view. Keys typed while the remote screen is being replayed are dropped, never queued.

## status

```sh
flow-remote status [--json]
```

Asks the running daemon what it is doing. The text form prints the device name and id, then one line each:

| Line | Shows |
|---|---|
| `listening` | the address and port it listens on, and the bind mode |
| `advertises` | the addresses a pairing token would carry, or `nothing` |
| `devices` | `N paired, M connected` (or why the device list is unreadable) |
| `pairing` | `waiting for a device` while a `pair` waits, else `no` |
| `sync` | with a sync store: its sequence number, the peers by state and the streams it serves; or `off:` and why |
| `pid` | the daemon's process id |

A tailcat address is a secret and is always shown as `tailcat (tc…)`. `--json` adds fields such as the live terminal streams, and `"running": false` when no daemon answers (the command still exits 1).

## sync status

```sh
flow-remote sync status [--json]
```

Shows what the daemon's sync is doing: the store (path, device, sequence number), each collection's rows per owner, each paired device's subscriber state (`connecting`, `syncing`, `live`, `offline`, `refused`, or `too_old` for a device whose Flow is too old to sync) with its last error, the streams it serves, the intents still waiting per device, and the last cleanup pass. It says sync is off when the daemon was started without `--sink-db`. See [How Flow syncs data](https://flow.worldbreakstudios.com/docs/sync/sink.md).

## Files

| Path | What it holds |
|---|---|
| `~/.flow/remote/identity.json` | this device's name and keypair |
| `~/.flow/remote/devices.json` | the paired devices and their permissions |
| `~/.flow/remote/daemon.log` | the output of a daemon the app started |
| `~/.flow/remote/tailcat.json` | the tailcat tunnel's keys (`--bind tailcat` only); delete it and pair again to change the address |

All are `0600` in a `0700` folder. Edit them only through these commands or the Puddle page.
