Commands

Every command of twin, grouped by what it works on: twins, images, the screen, commands in the twin, style.

Every command

Every command takes --json: then standard output holds exactly one JSON value, and a failure is {"error":{"code":"…","message":"…"}} with a non-zero exit. Without it the output is for people.

Exit codes

CodeMeans
0It worked.
1The operation failed.
2A usage error: an unknown command or flag, a bad value.
3The twin does not exist.
4A timeout.

The error's code says more: usage, not_found, exists, invalid_name, unreachable, auth, timeout, engine, guest, unsupported.

Twins

  • twin create <name> --from <image> [--cpus n] [--memory MiB]: a new twin, a clone of the image, with a new network address.
  • twin up <name> [--wait] [--timeout ms] [--share name=path[:ro],…] [--fresh]: starts it. With --wait, returns once the guest's agent is up (default limit 120 s). --share gives the guest a folder of the host.
  • twin down <name> [--force]: asks the guest to shut down; after 90 s without an answer, stops it. --force stops it at once, and the next boot is slower for it.
  • twin list, twin show <name>: the twins and their state: running, stopped, unknown.
  • twin rm <name>: stops a running twin and deletes it.
  • twin attach <name> --screen <vnc-url> [--agent <url>] [--os macos|linux]: records a machine twin did not start: any VNC screen, and an agent if it runs twin guest serve.

Images

  • twin image install <name> [--ipsw file] [--disk GiB] [--cpus n] [--memory MiB] [--keep-ipsw]: installs macOS from Apple's restore image: the newest for this Mac, or the file given. The download is removed afterwards unless --keep-ipsw.
  • twin image make <name> --from <twin|image|tart-vm-folder> [--cpus n] [--memory MiB]: saves a stopped twin as an image.
  • twin image list, twin image rm <name>: the images, and removing one.

Screen

Coordinates are in the screenshot's pixels by default (--space shot), so an agent clicks where it saw a thing; --space screen takes the screen's own pixels.

  • twin screenshot <name> [-o file] [--max n] [--scale f] [--region x,y,w,h]: one frame as PNG, scaled down to --max pixels on its long side (1568 by default).
  • twin click <name> <x> <y> [--button left|right|middle] [--double]: moves the pointer and clicks.
  • twin type <name> <text>: types text, Unicode included; a character that needs Shift is sent with Shift held.
  • twin key <name> <combo>: a key or a chord, such as return, escape, cmd+t, cmd+shift+4, ctrl+c.
  • twin scroll <name> <x> <y> <dy> [--dx n]: scrolls at the point.
  • twin drag <name> <x1> <y1> <x2> <y2>: presses, moves, releases.
  • twin wait <name> [--idle ms] [--timeout ms]: returns once the screen has been still for --idle ms. A blinking caret does not count as change.

Commands in the twin

These go to the agent in the guest, over a virtual socket of the machine: no network, no terminal window.

  • twin sh <name> [--cwd dir] [--env K=V,…] [--sudo] [--timeout ms] -- <command>: runs the command in the guest's login shell, as your shell would: output as it comes, the command's exit code, your standard input passed in. Ctrl+C stops it and everything it started.
  • twin exec <name> [--cwd dir] [--timeout ms] -- <program> <args…>: runs one program with its arguments, no shell.
  • twin put <name> <local> <remote>, twin get <name> <remote> <local>: copies a file in or out, byte for byte.

Measured on a twin of tahoe-dev: twin sh work -- true takes 6.6 ms, twin exec 4.2 ms, twin sh --sudo 12.9 ms, and 5 MB through standard input and back 40 ms.

Style

A profile is JSON: appearance (dark or light), accent, wallpaper (a colour or an image), dock (autohide, size), desktopIcons, menuBarClock, resolution, packages, files to copy in, and run, programs to run last.

  • twin style plan <profile.json> [--os macos|linux]: the steps the profile becomes, changing nothing. Each step is a program with its arguments, never a shell string.
  • twin style apply <name> <profile.json>: runs those steps in the twin, in order, and stops at the first that fails, naming it.

The rest

  • twin mcp: the MCP server on standard input and output. See Agents.
  • twin guest serve --listen <url>: the agent inside a twin: vsock:7000, tcp://host:port or unix:path.
  • twin bench [--json]: the release build's own figures.
  • twin version: the name and version.