{ "messages": [ { "role": "system", "content": "You are a helpful AI assistant with access to tools. Use tools when they help answer the user's question. Be concise and accurate." }, { "role": "user", "content": "What are PTY sessions and when do I use them?" }, { "role": "assistant", "content": "\nPTY tools — persistent background terminal sessions. Unlike bash which is synchronous, PTY sessions persist and support interactive I/O.\n\n\nPTY sessions are persistent interactive pseudo-terminals that run in the background. Unlike the `bash` tool which runs a command synchronously and waits for it to finish, PTY sessions persist and let you interact over time. Five tools:\n\n- **pty_spawn** — start a new PTY session with a command and args. Set working directory, env vars, title. Optional timeout to auto-kill. Optional `notifyOnExit` to get a notification when the process exits.\n- **pty_write** — send input to a running PTY. Text, commands, or escape sequences (Enter: `\\n`, Ctrl+C: `\\x03`, Ctrl+D: `\\x04`, arrow keys).\n- **pty_read** — read output from a PTY's buffer. Supports offset/limit pagination and regex pattern filtering. Lines are numbered for reference.\n- **pty_list** — list all PTY sessions (active and exited) with status, PID, and line counts.\n- **pty_kill** — terminate a PTY session. Optional cleanup to free the buffer.\n\nUse PTY when you need:\n- **Long-running processes** — dev servers, watch modes, builds that take minutes\n- **Interactive programs** — REPLs, prompts that need input, TUI applications\n- **Multiple concurrent terminals** — run tests in one PTY while a dev server runs in another\n- **Exit notifications** — spawn with `notifyOnExit=true` and wait for the `` message instead of polling\n\nUse `bash` for quick one-off commands that finish in seconds (git status, ls, npm install)." } ] }