Skip to content

Agent browser: mpx bridge, mpx browser, and the multiplex skill - #2

Draft
jhen0409 wants to merge 6 commits into
mainfrom
agent-browser
Draft

jhen0409 wants to merge 6 commits into
mainfrom
agent-browser

Conversation

@jhen0409

@jhen0409 jhen0409 commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Lets an agent on this machine open and operate web pages in the Multiplex app on the user's device (Vision Pro / iPad / iPhone). Pairs with the app-side PR in multiplex-term/Multiplex (branch agent-browser).

  • mpx bridge (hidden) — the app starts it over its own SSH connection (a PTY-less login shell, so the host's PATH applies). It serves a unix socket ~/.mpx/run/browser-<device>-<install id>.sock; no TCP port, no sshd forwarding.
    • The directory is 0700. Every ancestor must be owned by you or root, and any other-writable ancestor must be root-owned and sticky. Both ends check the peer's uid.
    • Framing is bounded JSON lines, with at most 16 clients.
    • Requests carry t/ttl and a cancel is sent on timeout, so an app that was suspended never replays stale clicks.
    • The socket is removed on EOF or on SIGTERM/SIGINT/SIGHUP.
  • mpx browser … — open, snapshot (outline with [ref=eN]), click, fill, type, press, select, scroll, wait, eval, console, screenshot, show, close, tabs, status, forward <port> [--open].
    • Screenshots are written 0600 under ~/.mpx/shots.
    • --device / MPX_BROWSER_DEVICE picks among connected devices; an ambiguous match is an error. Without it, the newest device wins and stderr says so.
    • In tmux, the agent's session is sent along so the tab docks beside it.
  • Skill — mpx skill install writes the multiplex skill, embedded in the binary from skills/multiplex/SKILL.md, into both places agents look: ~/.agents/skills (Codex and the agents that share it) and ~/.claude/skills (Claude Code; under CLAUDE_CONFIG_DIR when set). mpx skill print shows it.
    • --dir <skills dir> names another place instead and repeats. An agent's own directory (.agents, .claude) stands for the skills inside it, so --dir .agents --dir .claude installs for the project you are in.
    • --json prints the outcome as one line. The app's Host Settings ▸ Agent browser ▸ INSTALL SKILL runs mpx skill install --json over SSH and reads it.
    • A skill directory that is a symlink to one written in the same run counts as installed (skill managers link ~/.claude/skills/<name> to ~/.agents/skills/<name>); a symlink to anywhere else is refused.
    • There is no Claude Code plugin or marketplace: it was a second copy of the same text with its own version, for one agent.

Release note: the app copy says "mpx 0.2 or later", but Cargo.toml is still 0.1.2. Bump it at release.

Testing

  • cargo test: 55 unit tests and 12 integration tests, on macOS and on Linux (rust:1-slim-bookworm).
    • tests/browser_bridge.rs: a request round-trip through a real bridge process, the actionable no-device error, same-named devices on separate sockets with SIGTERM socket cleanup, and a bridge whose app stopped reading.
    • tests/skill_install.rs: both default directories under a throwaway HOME, CLAUDE_CONFIG_DIR, repeated --dir, --dir .agents --dir .claude, the JSON line, a directory that cannot be written (exit 1, the other still installed), and no HOME.
  • cargo clippy --all-targets is clean.
  • End to end against the app on an iPhone Air and the visionOS/iPad simulators. Details are in the app PR.

Lets an agent on this machine drive web pages in the Multiplex app on the
user's device.

- `mpx bridge` (hidden): started by the app over its own SSH connection;
  serves `~/.mpx/run/browser-<device>-<install id>.sock` (0700 dir,
  owner/sticky ancestry checked, peer uid checked on both ends), JSON
  lines both ways, request `t`/`ttl` stamps and `cancel` for the app's
  stale-request guard, socket removed on EOF or signal.
- `mpx browser …`: open, snapshot (outline with [ref=eN]), click, fill,
  type, press, select, scroll, wait, eval, console, screenshot (0600 in
  ~/.mpx/shots), show, close, tabs, status, forward [--open]. `--device`
  picks among several connected devices; an ambiguous match is an error.
- `mpx skill install|print` and a Claude Code plugin
  (`.claude-plugin/marketplace.json` → `plugin/`), one SKILL.md for both;
  a test pins the plugin version to the crate's.
CI's newer clippy flags unnecessary_sort_by (live_bridges) and chunks_exact_to_as_chunks (hex_decode, pre-existing on main).
`main` restores SIGPIPE's default so `mpx browser status | head -1`
ends quietly. The bridge inherited that. Its stdout is the app's SSH
channel, so a pong or an answer written after the channel stopped
reading killed the process on the spot: the waiting client saw the
socket close without an answer, and the socket file stayed behind.

The bridge now ignores SIGPIPE. The write fails, the client is told
`disconnected`, and the socket is removed when stdin reaches EOF. A new
integration test closes the read end of the bridge's stdout and checks
all three; it fails without the change. Confirmed on Linux as well
(rust:1-slim-bookworm).

README: the example prints `http://localhost:5173/` (the app keeps
`localhost` as this machine's), and agent tabs are described as seeing
this machine's network rather than "the internet and this machine
only", which was the earlier device route.
- `fill e1 -42`, `type -foo`, `eval "-x * 2"`, `select e3 -1`, and
  `wait --text -5` were refused as unknown flags. Those arguments now
  allow a leading hyphen; flags around them still parse as flags (new
  parsing tests). `bridge --device` does too, for a device whose name
  starts with one.
- `--timeout` is clamped to the bridge's own ceiling (600 s). Unclamped,
  an absurd value overflowed the socket timeout built from it and
  panicked.
- With several devices connected, the stderr note names each with its
  slug. Two iPads are both "iPad", and the slug is what `--device` can
  tell apart.
`mpx skill install` is now the one way the skill reaches an agent, and
it writes both places agents look:

- `~/.agents/skills/multiplex` — the directory Codex and other agents
  share.
- `~/.claude/skills/multiplex` — Claude Code, which reads only its own
  (under `CLAUDE_CONFIG_DIR` when that is set).

`--agent claude|codex` is gone. `--dir <skills dir>` still names another
place and now repeats, so `--dir .agents/skills --dir .claude/skills`
installs for one project. `--json` prints the outcome as one line
(`skill`, `installed`, `failed`) for the Multiplex app, which runs the
command over SSH from Host Settings ▸ Agent browser ▸ INSTALL SKILL.

The Claude Code plugin and its marketplace manifest are removed. They
were a second copy of the same text with its own version to bump, for
one agent only. The skill moves from `plugin/skills/` to `skills/`.

A skill directory that is a symlink to one written in the same run
counts as installed: skill managers link `~/.claude/skills/<name>` to
`~/.agents/skills/<name>`, and refusing that would fail every default
install on such a machine. A symlink that leads anywhere else is still
refused, the other directories are still written, and the command exits
1 naming the one it could not fill.
`--dir` takes a skills directory, so `--dir ~/.claude` wrote
`~/.claude/multiplex/SKILL.md` — a file no agent reads, with a
success line. An agent's own directory (`.agents`, `.claude`) now
stands for the `skills` inside it, which makes a project install
`mpx skill install --dir .agents --dir .claude`. Any other path is
still used as given.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant