Documentation
¶
Overview ¶
Package live provides adapters for detecting and interacting with LIVE Claude sessions running in the user's terminal (not started by cdev).
Index ¶
- func SupportedTerminals() []string
- type Detector
- type Injector
- func (i *Injector) Send(tty string, text string) error
- func (i *Injector) SendKey(tty string, key string) error
- func (i *Injector) SendKeyToApp(key string, terminalApp string) error
- func (i *Injector) SendToApp(text string, terminalApp string) error
- func (i *Injector) SendWithEnter(tty string, text string) error
- func (i *Injector) SendWithEnterToApp(text string, terminalApp string) error
- type LiveSession
- type MacOSPlatform
- func (p *MacOSPlatform) DetectTerminalApp(tty string) string
- func (p *MacOSPlatform) Name() string
- func (p *MacOSPlatform) SendKey(key string) error
- func (p *MacOSPlatform) SendKeyCode(keyCode int) error
- func (p *MacOSPlatform) SendKeyCodeToApp(keyCode int, tty string) error
- func (p *MacOSPlatform) SendKeyToApp(key string, tty string) error
- func (p *MacOSPlatform) SendText(text string) error
- func (p *MacOSPlatform) SendTextToApp(text string, tty string) error
- func (p *MacOSPlatform) SetTargetApp(app string)
- type Platform
- type TerminalReader
- func (r *TerminalReader) GetContent() (string, error)
- func (r *TerminalReader) GetLastNLines(n int) (string, error)
- func (r *TerminalReader) GetVisibleContent() (string, error)
- func (r *TerminalReader) IsRunning() bool
- func (r *TerminalReader) Output() <-chan string
- func (r *TerminalReader) SetPollInterval(interval time.Duration)
- func (r *TerminalReader) Start() error
- func (r *TerminalReader) Stop()
- type UnsupportedPlatform
- type WindowsPlatform
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportedTerminals ¶
func SupportedTerminals() []string
SupportedTerminals returns the list of supported terminals for the current platform.
Types ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector finds and tracks running Claude processes not managed by cdev.
func NewDetector ¶
NewDetector creates a new live session detector for a specific workspace.
func (*Detector) DetectAll ¶
func (d *Detector) DetectAll() ([]*LiveSession, error)
DetectAll finds all LIVE Claude processes.
func (*Detector) GetLiveSession ¶
func (d *Detector) GetLiveSession(sessionID string) *LiveSession
GetLiveSession returns a LIVE session for the workspace.
If sessionID resolves to an on-disk Claude session file, we keep that ID. If it does not resolve (e.g. stale/foreign session id from remote client), we still return a detected LIVE Claude process in the workspace as best effort. This preserves inbound prompt delivery to an already-running terminal session.
func (*Detector) RegisterManagedPID ¶
RegisterManagedPID marks a PID as managed by cdev (will be excluded from detection).
func (*Detector) UnregisterManagedPID ¶
UnregisterManagedPID removes a PID from the managed list.
type Injector ¶
type Injector struct {
// contains filtered or unexported fields
}
Injector sends input to a terminal for LIVE sessions. Supports multiple platforms with different injection methods.
func NewInjector ¶
func NewInjector() *Injector
NewInjector creates a new injector for the current platform.
func (*Injector) SendKeyToApp ¶
SendKeyToApp sends a special key to a specific terminal application.
func (*Injector) SendWithEnter ¶
SendWithEnter sends text followed by Enter key.
type LiveSession ¶
type LiveSession struct {
PID int `json:"pid"`
TTY string `json:"tty"` // e.g., "/dev/ttys002"
WorkDir string `json:"work_dir"` // Working directory of the process
SessionID string `json:"session_id"` // Claude session ID from JSONL file
TerminalApp string `json:"terminal_app"` // The terminal app (Terminal, iTerm2, Code, Cursor, etc.)
StartTime time.Time `json:"start_time"`
}
LiveSession represents a detected Claude process running in user's terminal.
type MacOSPlatform ¶
type MacOSPlatform struct {
// contains filtered or unexported fields
}
MacOSPlatform implements injection for macOS using AppleScript.
func (*MacOSPlatform) DetectTerminalApp ¶
func (p *MacOSPlatform) DetectTerminalApp(tty string) string
DetectTerminalApp tries to detect which terminal app is running Claude.
func (*MacOSPlatform) Name ¶
func (p *MacOSPlatform) Name() string
func (*MacOSPlatform) SendKey ¶
func (p *MacOSPlatform) SendKey(key string) error
func (*MacOSPlatform) SendKeyCode ¶
func (p *MacOSPlatform) SendKeyCode(keyCode int) error
func (*MacOSPlatform) SendKeyCodeToApp ¶
func (p *MacOSPlatform) SendKeyCodeToApp(keyCode int, tty string) error
func (*MacOSPlatform) SendKeyToApp ¶
func (p *MacOSPlatform) SendKeyToApp(key string, tty string) error
func (*MacOSPlatform) SendText ¶
func (p *MacOSPlatform) SendText(text string) error
func (*MacOSPlatform) SendTextToApp ¶
func (p *MacOSPlatform) SendTextToApp(text string, tty string) error
func (*MacOSPlatform) SetTargetApp ¶
func (p *MacOSPlatform) SetTargetApp(app string)
SetTargetApp sets which application to send keystrokes to.
type Platform ¶
type Platform interface {
SendText(text string) error
SendKey(key string) error
SendKeyCode(keyCode int) error
Name() string
}
Platform defines the interface for platform-specific injection.
type TerminalReader ¶
type TerminalReader struct {
// contains filtered or unexported fields
}
TerminalReader reads terminal content from native terminal applications. Platform-specific implementations: - macOS: AppleScript (Terminal.app, iTerm2) - Windows: UI Automation / PowerShell (Windows Terminal, cmd, PowerShell)
func NewTerminalReader ¶
func NewTerminalReader(terminalApp string) *TerminalReader
NewTerminalReader creates a reader for a specific terminal application.
func (*TerminalReader) GetContent ¶
func (r *TerminalReader) GetContent() (string, error)
GetContent reads the current content from the terminal window. This is implemented per-platform in terminal_reader_darwin.go and terminal_reader_windows.go
func (*TerminalReader) GetLastNLines ¶
func (r *TerminalReader) GetLastNLines(n int) (string, error)
GetLastNLines returns the last N lines from the terminal.
func (*TerminalReader) GetVisibleContent ¶
func (r *TerminalReader) GetVisibleContent() (string, error)
GetVisibleContent returns approximately the visible portion of the terminal. Default implementation returns last 50 lines.
func (*TerminalReader) IsRunning ¶
func (r *TerminalReader) IsRunning() bool
IsRunning returns whether the reader is currently polling.
func (*TerminalReader) Output ¶
func (r *TerminalReader) Output() <-chan string
Output returns the channel that receives new terminal content.
func (*TerminalReader) SetPollInterval ¶
func (r *TerminalReader) SetPollInterval(interval time.Duration)
SetPollInterval sets how often to poll for terminal content changes.
func (*TerminalReader) Start ¶
func (r *TerminalReader) Start() error
Start begins polling the terminal for content changes.
type UnsupportedPlatform ¶
type UnsupportedPlatform struct {
// contains filtered or unexported fields
}
UnsupportedPlatform is used for platforms without injection support.
func (*UnsupportedPlatform) Name ¶
func (p *UnsupportedPlatform) Name() string
func (*UnsupportedPlatform) SendKey ¶
func (p *UnsupportedPlatform) SendKey(key string) error
func (*UnsupportedPlatform) SendKeyCode ¶
func (p *UnsupportedPlatform) SendKeyCode(keyCode int) error
func (*UnsupportedPlatform) SendText ¶
func (p *UnsupportedPlatform) SendText(text string) error
type WindowsPlatform ¶
type WindowsPlatform struct{}
WindowsPlatform implements injection for Windows using PowerShell SendKeys.
func (*WindowsPlatform) Name ¶
func (p *WindowsPlatform) Name() string
func (*WindowsPlatform) SendKey ¶
func (p *WindowsPlatform) SendKey(key string) error
func (*WindowsPlatform) SendKeyCode ¶
func (p *WindowsPlatform) SendKeyCode(keyCode int) error
func (*WindowsPlatform) SendText ¶
func (p *WindowsPlatform) SendText(text string) error