Skip to content

terminals.screen

The current plain-text terminal screen, optionally waiting for a revision change (TRM-106).

/** `terminals.screen` params (TRM-106). */
export type TerminalScreenParams = {
/** Return immediately when the screen has a different revision; otherwise wait for output, resize or exit. */
afterRevision?: number | null;
terminalId: string;
/** Long-poll duration in milliseconds; at most 30 seconds. */
waitMs?: number | null;
};
/** Current visible plain-text screen of a daemon-owned PTY session (TRM-106). */
export type TerminalScreen = {
alternateScreen: boolean;
cols: number;
/** Visible cells as plain text. Trailing blank cells and rows are omitted. */
contents: string;
cursor: TerminalCursor;
/** Increases after output, resize or exit; pass it as `afterRevision` to wait for a change. */
revision: number;
rows: number;
status: TerminalStatus;
};
/** Cursor position in an agent-readable terminal screen (TRM-106); row and column are zero-based. */
export type TerminalCursor = {
column: number;
row: number;
visible: boolean;
};
/** The process state of a daemon-owned PTY session (TRM-100). */
export type TerminalStatus =
| {
state: "running";
}
/** The shell exited; PTY output is still available in the topic snapshot. */
| {
code?: number | null;
endedAt: number;
state: "exited";
};