The terminal methods manage pseudo-terminal (PTY) sessions on the server. Each session is identified by aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Emanuele-web04/dpcode/llms.txt
Use this file to discover all available pages before exploring further.
threadId and a terminalId. When you open a terminal it is associated with a thread, so the thread’s working directory and environment provide the execution context. All methods are in the terminal.* namespace.
Terminal output arrives through the terminal.event push channel on the WebSocket connection — you do not need an explicit subscription call to receive output events.
terminal.open
Open a new terminal session. If a session already exists for the giventhreadId/terminalId pair, it is returned as-is. Returns a snapshot of the session state including any buffered history.
Parameters
ID of the thread this terminal belongs to.
Identifier for the terminal session within the thread. Max 128 characters. Defaults to
"default".Working directory in which to start the shell.
Terminal width in columns. Integer between 20 and 400.
Terminal height in rows. Integer between 5 and 200.
Additional environment variables to set for the shell process. Keys must match
[A-Za-z_][A-Za-z0-9_]*. Values max 8,192 characters. Max 128 entries.Response (TerminalSessionSnapshot)
Working directory the terminal was opened in.
OS process ID of the shell, once started.
Buffered terminal output since the session started or was last cleared.
Exit code if the session has exited.
Exit signal number if the process was killed by a signal.
ISO 8601 timestamp of the last status update.
terminal.write
Write data to a running terminal session. Use this to send keystrokes, commands, or control sequences.Parameters
Data to write. Must be non-empty. Max 65,536 characters. To send a command followed by Enter, include
"\r" or "\n" at the end.Response
Returns void on success.terminal.resize
Resize a terminal session to new dimensions. Send this whenever the terminal UI is resized so that line-wrapping and cursor positioning remain accurate.Parameters
New width in columns. Integer between 20 and 400.
New height in rows. Integer between 5 and 200.
Response
Returns void on success.terminal.clear
Clear the terminal history buffer. Acleared event is emitted on the terminal.event channel after this call.
Parameters
Response
Returns void on success.terminal.restart
Restart an existing terminal session with a fresh shell process. Returns a new session snapshot. The previous process is killed.Parameters
Working directory for the new shell process.
Terminal width in columns. Integer between 20 and 400.
Terminal height in rows. Integer between 5 and 200.
Additional environment variables for the new shell process.
Response
SameTerminalSessionSnapshot structure as terminal.open.
terminal.close
Close a terminal session and optionally delete its history.Parameters
Specific terminal to close. If omitted, all terminals for the thread are closed.
If
true, the history buffer is deleted from the server.Response
Returns void on success.terminal.subscribeEvents
Streaming. Subscribe to all terminal events across all sessions. Once subscribed, the server streamsTerminalEvent items for every session change that occurs on this connection.
You can also receive terminal events without this subscription by listening to the
terminal.event push channel. Use terminal.subscribeEvents only if you need a structured stream that replays in-order through the RPC layer.Parameters
No parameters required.Stream items (TerminalEvent)
Every event carries these base fields:
ISO 8601 timestamp.
Event type (see below).
type | Additional fields |
|---|---|
started | snapshot: TerminalSessionSnapshot — full session state |
output | data: string — raw terminal output bytes |
exited | exitCode: number | null, exitSignal: number | null |
error | message: string |
cleared | (no additional fields) |
restarted | snapshot: TerminalSessionSnapshot — new session state |
activity | hasRunningSubprocess: boolean, cliKind: "codex" | "claude" | null, agentState: "running" | "attention" | "review" | null |
Complete example: open and use a terminal
- 1. Open terminal
- Open response
- 2. Write a command
- Output push event
- 3. Resize