Skip to content

Add kitty terminal emulator backend#52

Open
DmitryAkDev wants to merge 2 commits into
HazAT:mainfrom
DmitryAkDev:main
Open

Add kitty terminal emulator backend#52
DmitryAkDev wants to merge 2 commits into
HazAT:mainfrom
DmitryAkDev:main

Conversation

@DmitryAkDev
Copy link
Copy Markdown

Add kitty terminal emulator backend

Add support for kitty as a subagent surface backend, enabling spawning and management of sub-agents in separate kitty windows or tabs via the kitten @ remote control API.

What's Included

kitty Backend (cmux.ts)

  • Runtime detectionisKittyRuntimeAvailable() checks KITTY_PID + KITTY_WINDOW_ID + remote control via KITTY_LISTEN_ON socket (works from TUI context where /dev/tty is unavailable)
  • Two surface modes:
    • window (default) — split window inside current tab, auto-balanced side-by-side via horizontal layout
    • tab — new dedicated tab with full terminal space
  • Full lifecycle — create, send commands, send escape, read screen, close surface, rename tab
  • Auto-rebalance — after create/close, switches to horizontal layout for equal-width side-by-side windows

Configuration (index.ts)

  • Agent frontmatterkitty-mode: tab or kitty-mode: window in agent .md YAML frontmatter
  • Resolution — agent frontmatter → default ("window")
  • Tool parameter not added (avoids breaking general API schema)

Documentation (README.md)

  • kitty added to supported multiplexers list
  • Setup instructions (kitty.conf requirements)
  • Surface mode documentation with frontmatter and tool parameter examples

Requirements

Add to ~/.config/kitty/kitty.conf:

allow_remote_control socket-only
listen_on unix:/tmp/kitty-rc

Then start pi inside kitty: kitty pi

Or force via environment: PI_SUBAGENT_MUX=kitty

API Mapping

Operation kitty Command
Create (window) kitten @ launch --type=window --location vsplit --keep-focus
Create (tab) kitten @ launch --type=tab --keep-focus
Send command kitten @ send-text --match id:N
Send Escape kitten @ action --match id:N send_key Escape
Read screen kitten @ get-text --match id:N
Close kitten @ close-window --match id:N
Rename kitten @ set-window-title --match id:N
Rebalance kitten @ goto-layout horizontal

Testing

Tested on kitty 0.46.2:

  • Single subagent launch → completion → window close
  • Multiple concurrent subagents (4+) with auto-rebalance
  • Tab mode (separate tab, auto-close on completion)
  • Window mode (split, horizontal layout, equal widths)
  • Real tasks (file operations, code analysis) with correct summary extraction

Notes

  • horizontal layout chosen over grid for side-by-side arrangement (grid creates 2×2 layout)
  • splits layout remembers old sizes — not suitable for rebalance (switching to grid then back to splits restores original proportions)
  • Socket-based remote control (KITTY_LISTEN_ON) used instead of /dev/tty DCS sequences for TUI compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant