Documentation
¶
Index ¶
- func ToolAvailability() map[string]ToolInfo
- type Manager
- func (m *Manager) Create(tool, workDir string, args []string, yoloMode bool, parentID string) (*Session, error)
- func (m *Manager) FindChildSession(parentID, tool string) (*Session, bool)
- func (m *Manager) Get(id string) (*Session, bool)
- func (m *Manager) List() []*Session
- func (m *Manager) Remove(id string) error
- func (m *Manager) Restart(id string) (*Session, error)
- func (m *Manager) SaveAll()
- func (m *Manager) Stop(id string) error
- func (m *Manager) StopAll()
- func (m *Manager) TmuxAction(id, action string) error
- type RingBuffer
- type Session
- func (s *Session) BroadcastYoloDebug(tail string)
- func (s *Session) CaptureToolSessionID(data []byte)
- func (s *Session) CheckYolo(data []byte) (*YoloApproval, string)
- func (s *Session) Done() <-chan struct{}
- func (s *Session) Info() SessionInfo
- func (s *Session) IsYoloMode() bool
- func (s *Session) Resize(cols, rows uint16) error
- func (s *Session) SetYoloMode(enabled bool)
- func (s *Session) Subscribe() (chan []byte, []byte)
- func (s *Session) SubscribeYoloDebug() chan string
- func (s *Session) Unsubscribe(ch chan []byte)
- func (s *Session) UnsubscribeYoloDebug(ch chan string)
- func (s *Session) Write(data []byte) (int, error)
- type SessionInfo
- type Status
- type Store
- type ToolInfo
- type YoloApproval
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToolAvailability ¶
ToolAvailability checks which user-facing tools are available on this system.
Types ¶
type Manager ¶
type Manager struct {
// callback for session events
OnSessionExit func(s *Session)
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) FindChildSession ¶ added in v0.4.0
FindChildSession returns a child session of the given parent with the specified tool. Returns the first matching running session, or any matching session if none are running.
func (*Manager) Remove ¶ added in v0.4.4
Remove removes an exited session and its internal children from memory and persists the change.
func (*Manager) SaveAll ¶
func (m *Manager) SaveAll()
SaveAll persists all sessions to disk. Called on shutdown.
func (*Manager) TmuxAction ¶ added in v0.4.3
TmuxAction executes a whitelisted tmux action on a terminal session.
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
func NewRingBuffer ¶
func NewRingBuffer(size int) *RingBuffer
func (*RingBuffer) Bytes ¶
func (r *RingBuffer) Bytes() []byte
func (*RingBuffer) Write ¶
func (r *RingBuffer) Write(p []byte)
type Session ¶
type Session struct {
ID string
Tool string
WorkDir string
Args []string
PTY *os.File
Cmd *exec.Cmd
CreatedAt time.Time
Status Status
ExitCode *int
YoloMode bool
Internal bool // internal session (e.g. tmux), not user-facing
ToolSessionID string // tool-specific session ID for resume
ParentID string // parent session ID (e.g. tmux child of a CLI session)
TmuxSessionName string // tmux session name (kojo_<id>) for tmux-backed sessions
// contains filtered or unexported fields
}
func (*Session) BroadcastYoloDebug ¶
func (*Session) CaptureToolSessionID ¶ added in v0.2.0
CaptureToolSessionID tries to parse a tool-specific session ID from PTY output. Only captures once (when ToolSessionID is still empty). Accumulates data across chunk boundaries to handle split reads.
func (*Session) CheckYolo ¶
func (s *Session) CheckYolo(data []byte) (*YoloApproval, string)
CheckYolo appends data to a trailing buffer and checks for approval patterns. Returns non-nil YoloApproval if a match is found. Caller should write the response to PTY.
func (*Session) Info ¶
func (s *Session) Info() SessionInfo
func (*Session) IsYoloMode ¶
func (*Session) SetYoloMode ¶
func (*Session) SubscribeYoloDebug ¶
func (*Session) Unsubscribe ¶
func (*Session) UnsubscribeYoloDebug ¶
type SessionInfo ¶
type SessionInfo struct {
ID string `json:"id"`
Tool string `json:"tool"`
WorkDir string `json:"workDir"`
Args []string `json:"args,omitempty"`
Status Status `json:"status"`
ExitCode *int `json:"exitCode,omitempty"`
YoloMode bool `json:"yoloMode"`
Internal bool `json:"internal,omitempty"`
CreatedAt string `json:"createdAt"`
ToolSessionID string `json:"toolSessionId,omitempty"`
ParentID string `json:"parentId,omitempty"`
TmuxSessionName string `json:"tmuxSessionName,omitempty"`
LastOutput string `json:"lastOutput,omitempty"`
LastCols uint16 `json:"lastCols,omitempty"`
LastRows uint16 `json:"lastRows,omitempty"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists session metadata to disk.
func (*Store) Load ¶
func (st *Store) Load() ([]SessionInfo, error)
Load reads persisted sessions, filtering out entries older than maxAge. Returns (nil, nil) when the file does not exist (first run). Returns (nil, err) on read/parse errors so callers can distinguish "no sessions" from "failed to load" (important for orphan cleanup).
func (*Store) Save ¶
func (st *Store) Save(infos []SessionInfo)
Save writes session info to disk using atomic rename.
type YoloApproval ¶
YoloApproval is broadcast when yolo auto-approves a prompt.