Documentation
¶
Index ¶
- Variables
- func NeedsTmuxCheck() bool
- func ShellToolName() string
- func ShutdownSignals() []os.Signal
- func ToolAvailability() map[string]ToolInfo
- type Attachment
- 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) GetCustomBaseURL() string
- 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) SetCustomBaseURL(baseURL string)
- 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) Attachments() []*Attachment
- func (s *Session) BroadcastAttachments(attachments []*Attachment)
- func (s *Session) BroadcastYoloDebug(tail string)
- func (s *Session) CaptureToolSessionID(data []byte)
- func (s *Session) CheckAttachments(data []byte) []*Attachment
- func (s *Session) CheckYolo(data []byte) (*YoloApproval, string)
- func (s *Session) Done() <-chan struct{}
- func (s *Session) HasAttachment(path string) bool
- func (s *Session) Info() SessionInfo
- func (s *Session) InfoForSave() SessionInfo
- func (s *Session) IsYoloMode() bool
- func (s *Session) RemoveAttachment(path string)
- func (s *Session) Resize(cols, rows uint16) error
- func (s *Session) SetYoloMode(enabled bool)
- func (s *Session) Subscribe() (chan []byte, []byte)
- func (s *Session) SubscribeAttachments() chan []*Attachment
- func (s *Session) SubscribeYoloDebug() chan string
- func (s *Session) Unsubscribe(ch chan []byte)
- func (s *Session) UnsubscribeAttachments(ch chan []*Attachment)
- 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 ¶
var ( ErrSessionNotFound = errors.New("session not found") ErrSessionRunning = errors.New("session is still running") ErrSessionNotRunning = errors.New("session not running") ErrToolNotFound = errors.New("tool not found") ErrUnsupportedTool = errors.New("unsupported tool") ErrHasRunningChildren = errors.New("cannot remove session with running children") ErrNotTerminal = errors.New("not a terminal session") ErrNoTmuxID = errors.New("session has no tmux ID") )
Sentinel errors for the session package.
Functions ¶
func NeedsTmuxCheck ¶ added in v0.5.0
func NeedsTmuxCheck() bool
NeedsTmuxCheck returns whether the platform requires a tmux check at startup.
func ShellToolName ¶ added in v0.5.0
func ShellToolName() string
ShellToolName returns the internal tool name for terminal sessions.
func ShutdownSignals ¶ added in v0.5.0
ShutdownSignals returns the OS signals for graceful shutdown.
func ToolAvailability ¶
ToolAvailability checks which user-facing tools are available on this system.
Types ¶
type Attachment ¶ added in v0.5.0
type Attachment struct {
Path string `json:"path"`
Name string `json:"name"`
Size int64 `json:"size"`
Mime string `json:"mime"`
ModTime string `json:"modTime"`
CreatedAt string `json:"createdAt"`
}
Attachment represents a media file detected in session output.
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.
func (*Manager) GetCustomBaseURL ¶ added in v0.10.1
GetCustomBaseURL returns the custom API base URL (empty if not configured).
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) SetCustomBaseURL ¶ added in v0.10.1
SetCustomBaseURL configures the base URL for custom Anthropic API sessions.
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 io.ReadWriteCloser
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) Attachments ¶ added in v0.5.0
func (s *Session) Attachments() []*Attachment
Attachments returns all tracked attachments, removing any whose files no longer exist.
func (*Session) BroadcastAttachments ¶ added in v0.5.0
func (s *Session) BroadcastAttachments(attachments []*Attachment)
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) CheckAttachments ¶ added in v0.5.0
func (s *Session) CheckAttachments(data []byte) []*Attachment
CheckAttachments appends data to the trailing buffer, scans for media file paths, and returns newly detected attachments. Caller should broadcast the result.
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) HasAttachment ¶ added in v0.5.0
HasAttachment checks if a path is tracked as an attachment.
func (*Session) Info ¶
func (s *Session) Info() SessionInfo
func (*Session) InfoForSave ¶ added in v0.5.0
func (s *Session) InfoForSave() SessionInfo
InfoForSave returns session info including attachment metadata for persistence.
func (*Session) IsYoloMode ¶
func (*Session) RemoveAttachment ¶ added in v0.5.0
RemoveAttachment removes an attachment from tracking (does not delete the file).
func (*Session) SetYoloMode ¶
func (*Session) SubscribeAttachments ¶ added in v0.5.0
func (s *Session) SubscribeAttachments() chan []*Attachment
func (*Session) SubscribeYoloDebug ¶
func (*Session) Unsubscribe ¶
func (*Session) UnsubscribeAttachments ¶ added in v0.5.0
func (s *Session) UnsubscribeAttachments(ch chan []*Attachment)
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"`
Attachments []*Attachment `json:"attachments,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.