Documentation
¶
Index ¶
- Constants
- func DefaultLauncher() terminal.Launcher
- func MustJSON(v any) json.RawMessage
- func ShellQuote(s string) string
- func TranscriptPath(home, dir, sessionID string) string
- func ValidTmuxKey(key string) bool
- func WaitForPaneReady(ctx context.Context, term terminal.Session) bool
- type PaneState
- type PermissionOption
- type Session
- type SessionOptions
- type TerminalPermission
- type TranscriptReader
- type TranscriptRecord
Constants ¶
const ( PromptInjectCheckInterval = 500 * time.Millisecond PromptInjectTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func DefaultLauncher ¶
func MustJSON ¶
func MustJSON(v any) json.RawMessage
func ShellQuote ¶
ShellQuote single-quotes a string for safe interpolation into a shell command.
func TranscriptPath ¶
func ValidTmuxKey ¶
ValidTmuxKey returns true if key is a safe single-character string for tmux send-keys.
func WaitForPaneReady ¶
WaitForPaneReady blocks until Claude's input box is taking input. It auto-dismisses the trust-safety dialog if present. Returns false on context cancel, capture error, send error, or the PromptInjectTimeout deadline — callers must treat any false return as "do not paste, the pane is not in a known-ready state".
Types ¶
type PaneState ¶
type PaneState string
func ClassifyPane ¶
ClassifyPane returns the most-specific pane state. After a turn is submitted the pane shows both an echo line that starts with `❯` (the prior user prompt) AND a spinner line below it; the input box `❯` reappears at the bottom. An activity line therefore must beat any `❯` line, otherwise we'd report idle while a turn is still running.
type PermissionOption ¶
type Session ¶
type Session struct {
SessionID string
RunID string
Dir string
TmuxName string
Term terminal.Session
Transcript *TranscriptReader
Events chan events.Event
Done chan struct{}
Ctx context.Context
CancelFn context.CancelFunc
StartedAt time.Time
Mu sync.Mutex
Prompted bool
Active bool
Finished bool
PendingTerminalPerm *TerminalPermission
}
func NewSession ¶
func NewSession(ctx context.Context, opts SessionOptions) *Session
func (*Session) MarkActive ¶
func (s *Session) MarkActive()
func (*Session) MarkFinished ¶
func (*Session) ScanTerminalTick ¶
func (s *Session) ScanTerminalTick()
func (*Session) ScanTranscriptTick ¶
func (s *Session) ScanTranscriptTick()
type SessionOptions ¶
type TerminalPermission ¶
type TerminalPermission struct {
RequestID string
Prompt string
Options []PermissionOption
CreatedAt time.Time
}
func ParseTerminalPermission ¶
func ParseTerminalPermission(text string) *TerminalPermission
ParseTerminalPermission extracts a TerminalPermission from pane text, or nil if the text doesn't represent a Claude permission dialog.
type TranscriptReader ¶
type TranscriptReader struct {
// contains filtered or unexported fields
}
TranscriptReader incrementally reads new records from a JSONL transcript. Successive Tick calls return only records appended since the last call.
func NewTranscriptReader ¶
func NewTranscriptReader(path string) *TranscriptReader
func (*TranscriptReader) Tick ¶
func (r *TranscriptReader) Tick() ([]TranscriptRecord, time.Time, error)
Tick reads records appended since the previous call. It returns the records, the file's mtime (zero if missing), and any read error. A missing file is not an error — callers tick early and often, and the transcript only appears once Claude writes its first record.
Offset only advances past newline-terminated lines so a half-written final record is left for the next tick to consume in full.
type TranscriptRecord ¶
type TranscriptRecord struct {
Type string `json:"type"`
AITitle string `json:"aiTitle,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
Text string `json:"text,omitempty"`
ContentEvents []events.Event `json:"-"`
}
TranscriptRecord is the minimal subset of JSONL fields used for status and best-effort content extraction.