| name | manage-pty |
| description | Manage interactive or persistent terminal sessions. Must use before running these sessions, like start a dev server, SSH, REPL, ... |
Commands
pty-bridge [--timeout <ms>] <command> [options]
pty-bridge start <command> [args...]
pty-bridge read <id> [--full] [--buffer <type>]
pty-bridge write <id> <input>
pty-bridge exec <id> <command> [--wait <ms>] [--wait-for-idle <ms>]
pty-bridge sendkey <id> <key>
pty-bridge wait-for <id> <pattern> [--timeout <s>]
pty-bridge snapshot <id>
pty-bridge list
pty-bridge kill <id>
pty-bridge resize <id> <cols> <rows>
pty-bridge status
Global Options
pty-bridge --timeout 60000 exec <id> "slow-command"
Start Options
pty-bridge start ssh user@host --keepalive 30
pty-bridge start pnpm dev --wait 1000
pty-bridge start cmd --cols 200 --rows 50
Read Options
pty-bridge read <id> --buffer normal
pty-bridge read <id> --buffer alternate
pty-bridge read <id> --buffer active
Exec Options
pty-bridge exec <id> "make build" --wait-for-idle 500
pty-bridge exec <id> "make build" --wait-for-idle 500 --wait 10000
Special Keys
enter, tab, escape, space, backspace, delete, up, down, left, right, home, end, pageup, pagedown, ctrl-a through ctrl-z, ctrl-\, ctrl-]
Output Format Convention
- stdout: command output (the actual PTY content)
- stderr: metadata line in
[key=value ...] format, e.g. [lines=42 alive=true buffer=normal exitCode=0]
read returns output on stdout, session metadata on stderr — parse stderr for session state
exec returns command output on stdout — check isAlive and exitCode in the stderr line or JSON response
snapshot prints a header line [buffer=... cursor=... size=...] then the screen content
status output is human-readable text (parse with regex if needed)
Important Notes
- Prefer
exec over write + sendkey enter — exec combines write, enter, wait, and read into one call, returning only the new output.
read is incremental by default — it returns only output since the last read. Use read <id> --full to get the entire buffer.
exec does NOT advance the read cursor — if you call exec then read, the read will include the same output that exec already returned. This is by design: exec is a self-contained operation that doesn't interfere with incremental read state.
- Use
wait-for for long operations — instead of sleep N && read, use wait-for <id> "pattern" --timeout N to block until specific output appears.
write sends text as-is — use sendkey enter afterward to submit (or just use exec).
- For secrets, pipe via stdin:
echo -n "password" | pty-bridge write <id> --stdin
- Always
kill sessions when done to free resources.
- The daemon auto-exits after 5 minutes when no alive sessions remain.
- Use
ctrl-c via sendkey to interrupt stuck commands.
- Terminal defaults to 120x40. Use
--cols/--rows on start or resize for TUI apps that need specific dimensions.
- Use
--timeout <ms> (global flag, before the command) to override the default 30s client socket timeout for slow operations.