Skip to content

Add iTerm2 bridge (Python API / WebSocket) #3

Description

@moejay

Summary

Add a wrightty bridge for iTerm2 using its Python API over WebSocket (protobuf). macOS only.

Why iTerm2

iTerm2 has the richest terminal automation API of any emulator — full screen content access, input sending, session management, and continuous screen monitoring. It's the dominant terminal on macOS.

IPC capabilities

iTerm2 exposes a protobuf-based WebSocket API. The official iterm2 Python package wraps this.

Wrightty method iTerm2 equivalent
Screen.getText / Screen.getContents session.async_get_screen_contents() — full screen with line-level access
Input.sendText session.async_send_text("text")
Session.list app.windows > window.tabs > tab.sessions hierarchy
Session.create window.async_create_tab(), tab.async_split_pane()
Session.destroy session.async_close()
Terminal.getSize session.grid_size (rows, cols)
Terminal.resize session.async_set_grid_size()

Additional: get_screen_streamer() for continuous monitoring, profile management, color presets, keystroke monitoring, focus notifications, selection control.

Implementation approach

Two options:

  1. Python bridge — Use the iterm2 Python package. The bridge would be a Python process (similar to how the MCP server works). Simplest path.
  2. Rust bridge with protobuf — Reimplement the WebSocket + protobuf protocol in Rust. Better performance, consistent with other bridges.

Option 1 is recommended for initial implementation given iTerm2's well-maintained Python SDK.

Screen monitoring

iTerm2's ScreenStreamer provides push-based screen updates, enabling efficient Screen.updated events without polling.

Platform

macOS only. iTerm2 does not run on Linux/Windows.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions