Skip to content

Conversation

@cpfiffer
Copy link
Contributor

Summary

Adds support for the Kitty graphics protocol to enable image pasting in Ghostty and other terminals that use Kitty protocol instead of iTerm2's OSC 1337.

Problem

Image pasting doesn't work in Ghostty terminal because Ghostty uses the Kitty graphics protocol, not the iTerm2 OSC 1337 protocol that Letta Code currently supports.

Solution

Added detection and parsing for Kitty graphics protocol escape sequences:

  • Format: ESC _Ga=T,f=100;<base64-data>ESC\
  • Parameters:
    • a=T: direct transmission mode
    • f=format: image format (100=PNG, 32=RGBA, 24=RGB)

Supported Image Paste Formats (Updated)

  1. iTerm2 OSC 1337 protocol - iTerm2, Warp, some other terminals
  2. Kitty graphics protocol - Ghostty, Kitty, WezTerm ✨ NEW
  3. Data URLs - data:image/png;base64,...
  4. File paths - Local file paths or file:// URLs

Terminal Compatibility

Terminal Image Pasting Protocol
iTerm2 ✅ Before + After OSC 1337
Warp ✅ Before + After OSC 1337
Ghostty ❌ Before → ✅ After Kitty graphics
Kitty ✅ Before + After Kitty graphics
WezTerm ✅ Before + After Both protocols

Testing

  • ✅ Build passes
  • ✅ Lint passes
  • ✅ Tested with sample Kitty protocol escape sequences
  • ✅ Verified existing iTerm2 protocol still works
  • ✅ Handles invalid/incomplete sequences gracefully

Implementation Details

The Kitty protocol detector:

  1. Matches escape sequence pattern: ESC _G<params>;<base64>ESC\
  2. Parses key=value parameters (e.g., a=T,f=100)
  3. Only processes direct transmissions (a=T)
  4. Maps format codes to MIME types
  5. Allocates image in placeholder registry

👾 Generated with Letta Code

Adds detection for Kitty graphics protocol (ESC _G...ESC\) to support
image pasting in Ghostty and other terminals that use Kitty protocol.

Supported formats now:
1. iTerm2 OSC 1337 protocol (iTerm2, Warp)
2. Kitty graphics protocol (Ghostty, Kitty, WezTerm) - NEW
3. Data URLs (data:image/png;base64,...)
4. File paths (local files or file:// URLs)

Kitty protocol format: ESC _Ga=T,f=100;<base64-data>ESC\
- a=T: direct transmission
- f=format: 100=PNG, 32=RGBA, 24=RGB

Tested with sample Kitty protocol payloads.

Fixes image pasting in Ghostty terminal.

Co-Authored-By: Letta <noreply@letta.com>
@mruderman
Copy link

Opened follow-up PR #134 which rebases this change onto the latest main and keeps the diff minimal.\nLint and build pass with Bun (bun run lint, bun run build).

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.

3 participants