Reference

CLI reference

Every dpty subcommand and flag, taken from the command definitions in src/main.rs. id accepts a session's id, name or label.

In this guide

Guide

On this page

Daemon

Clients start the daemon automatically; these commands manage it directly.

dpty serve [--http ADDR] [--no-http]

Runs the daemon in the foreground. Clients start it automatically; use install to run it at login instead.

  • --http ADDR HTTP/WebSocket listen address (default 127.0.0.1:7878)
  • --no-http disable the HTTP listener entirely
dpty stop [--sessions]

Stops the daemon. By default sessions keep running in their shims and the next daemon start picks them back up with nothing lost.

  • --sessions also stop every session, instead of leaving them running
dpty status

Prints daemon status as JSON. Exits with code 3 if the daemon is not running.

dpty token

Prints the bearer token used by the HTTP, WebSocket and MCP-over-HTTP listeners.

dpty install [--http ADDR] [--no-http]

Installs a login service — launchd on macOS, systemd --user on Linux — that runs the daemon and restarts it if it exits.

  • --http ADDR HTTP/WebSocket listen address (default 127.0.0.1:7878)
  • --no-http disable the HTTP listener for the installed service
dpty uninstall

Removes the login service. Sessions and history in ~/.durable-pty are kept.

Sessions

Create, list and manage sessions.

dpty ls [--json] [-l/--label LABEL]... [--status STATUS]

Lists sessions.

  • --json print the full session list as JSON
  • -l, --label LABEL filter by label, repeatable
  • --status STATUS filter by status (e.g. running, lost)
dpty new [-n NAME] [-C CWD] [-l LABEL]... [-e KEY=VALUE]... [--env-all] [-d/--detach] [--restart POLICY] [--kind KIND] [--resume-cmd CMD] -- CMD...

Starts a session. Example: dpty new -n work -C ~/proj -- claude "fix the bug".

  • -n, --name NAME a short name to attach by later
  • -C, --cwd CWD working directory (default: current directory)
  • -l, --label LABEL arbitrary key=value label, repeatable
  • -e, --env KEY=VALUE extra environment variable, repeatable
  • --env-all pass the whole environment (default passes PATH, HOME, locale and agent API variables only)
  • -d, --detach create the session without attaching to it
  • --restart POLICY never, on-failure or always
  • --kind KIND force the agent adapter instead of detecting it from the command
  • --resume-cmd CMD how to resume an agent with no built-in adapter, e.g. "grok --resume {id}"
dpty attach ID

Attaches this terminal to a running session. Detach with Ctrl-\ without stopping it.

dpty kill ID [-s/--signal SIGNAL]

Sends a signal to the session's process.

  • -s, --signal SIGNAL e.g. TERM, KILL (default: the process's normal termination signal)
dpty rm ID

Deletes a session and its stored history.

dpty restart ID

Relaunches a session, resuming the agent conversation when its id is known.

dpty set ID [--name NAME] [-l LABEL]... [--restart POLICY]

Updates a session's name, labels or restart policy without restarting it.

  • --name NAME rename the session
  • -l, --label LABEL set a key=value label, repeatable
  • --restart POLICY never, on-failure or always
dpty tag-agent ID AGENT_SESSION_ID

Records an agent's own session id, for use from a hook: dpty tag-agent "$DPTY_SESSION" <id>.

Interacting with a session

dpty send ID TEXT... [--no-enter] [-k/--key KEY]...

Types into a session.

  • --no-enter do not send a trailing Enter after the text
  • -k, --key KEY send a named key instead, e.g. ctrl-c, repeatable
dpty screen ID

Prints the session's current screen as plain text.

dpty wait ID PATTERN [--timeout SECONDS]

Blocks until a pattern appears in the session's output. Exits with code 2 on timeout.

  • --timeout SECONDS default 30

Reading history and events

dpty logs ID [-n/--bytes N] [--raw]

Reads output from a session.

  • -n, --bytes N how many bytes to read (default 65536)
  • --raw write the raw bytes instead of decoded text
dpty history ID [-n/--limit N]

Lists commands typed into a session.

  • -n, --limit N default 100
dpty events [ID] [-n/--limit N]

Lists daemon events, optionally filtered to one session.

  • -n, --limit N default 50

MCP

dpty mcp [--http ADDR] [--no-auth]

Runs the MCP server. With no flags, serves over stdio. With --http, serves streamable HTTP (POST /mcp) and legacy SSE (GET /sse).

  • --http ADDR listen address for streamable HTTP + SSE instead of stdio
  • --no-auth do not require the bearer token on the HTTP listener