docs

Client–daemon mode

The TUI is a pure HTTP client; all agent work — LLM calls, tools, sessions — happens in a daemon. dex with no arguments starts a daemon in the background and attaches the TUI to it, so the same architecture serves both local and remote use.

Local default

dex                     # daemon on a random localhost port + TUI

Headless daemon + remote TUI

Run the daemon headless (e.g. on a remote machine, in the directory you want as the agent workspace) and connect the TUI from anywhere:

dex serve               # daemon on 127.0.0.1:8420
dex serve 0.0.0.0:8420  # reachable from other machines
dex connect http://127.0.0.1:8420
dex connect http://10.0.0.5:8420 "explain the Cargo.toml dependencies"  # one-shot

Bearer tokens

  • A non-loopback bind always requires a token: the daemon generates one and prints it; clients present DEX_DAEMON_TOKEN=<token> (or the token file at $XDG_DATA_HOME/dex/daemon.token).
  • Loopback-only daemons need no token unless DEX_DAEMON_TOKEN is set (explicit env wins everywhere).
  • One machine, one token file: two daemons share it (second overwrites), so multi-daemon clients must pass per-host DEX_DAEMON_TOKEN explicitly.

Reconnects & replay

A dropped TUI replays the journal from its cursor and re-POSTs with the same idempotency key. Completed turns replay their terminal event; still-running turns answer 409 (reattach with --reattach); turns that died with no terminal event re-execute (idempotency can't dedup what never finished). One reconnect per turn, then an honest error.

What the remote TUI does

It behaves exactly like the local one: assistant text streams live, tool calls and results appear as they happen, tool approvals pop up as an overlay (the daemon parks the turn until you decide), and Ctrl+C/Esc cancels the in-flight turn (a third Ctrl+C force-quits a stuck turn). API keys, the model, and the permission mode are resolved by the daemon's own environment; client flags like --model and --permission are forwarded as per-request overrides.

Reattach

dex --reattach <id> (this process owns the daemon) and dex connect <url> --reattach <id> (it does not) attach to an existing interactive session and replay its event journal — so a crashed or closed TUI never loses a session that the daemon still holds.

Tools execute on the machine where the daemon runs, confined to the daemon's working directory.