session

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolAvailability

func ToolAvailability() map[string]ToolInfo

ToolAvailability checks which 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 NewManager(logger *slog.Logger) *Manager

func (*Manager) Create

func (m *Manager) Create(tool, workDir string, args []string, yoloMode bool) (*Session, error)

func (*Manager) Get

func (m *Manager) Get(id string) (*Session, bool)

func (*Manager) List

func (m *Manager) List() []*Session

func (*Manager) Restart

func (m *Manager) Restart(id string) (*Session, error)

func (*Manager) SaveAll

func (m *Manager) SaveAll()

SaveAll persists all sessions to disk. Called on shutdown.

func (*Manager) Stop

func (m *Manager) Stop(id string) error

func (*Manager) StopAll

func (m *Manager) StopAll()

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
	ToolSessionID string // tool-specific session ID for resume
	// contains filtered or unexported fields
}

func (*Session) BroadcastYoloDebug

func (s *Session) BroadcastYoloDebug(tail string)

func (*Session) CaptureToolSessionID added in v0.2.0

func (s *Session) CaptureToolSessionID(data []byte)

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) Done

func (s *Session) Done() <-chan struct{}

func (*Session) Info

func (s *Session) Info() SessionInfo

func (*Session) IsYoloMode

func (s *Session) IsYoloMode() bool

func (*Session) Resize

func (s *Session) Resize(cols, rows uint16) error

func (*Session) SetYoloMode

func (s *Session) SetYoloMode(enabled bool)

func (*Session) Subscribe

func (s *Session) Subscribe() (chan []byte, []byte)

func (*Session) SubscribeYoloDebug

func (s *Session) SubscribeYoloDebug() chan string

func (*Session) Unsubscribe

func (s *Session) Unsubscribe(ch chan []byte)

func (*Session) UnsubscribeYoloDebug

func (s *Session) UnsubscribeYoloDebug(ch chan string)

func (*Session) Write

func (s *Session) Write(data []byte) (int, error)

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"`
	CreatedAt     string   `json:"createdAt"`
	ToolSessionID string   `json:"toolSessionId,omitempty"`
}

type Status

type Status string
const (
	StatusRunning Status = "running"
	StatusExited  Status = "exited"
)

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store persists session metadata to disk.

func (*Store) Load

func (st *Store) Load() []SessionInfo

Load reads persisted sessions, filtering out entries older than maxAge.

func (*Store) Save

func (st *Store) Save(infos []SessionInfo)

Save writes session info to disk using atomic rename.

type ToolInfo

type ToolInfo struct {
	Available bool   `json:"available"`
	Path      string `json:"path"`
}

type YoloApproval

type YoloApproval struct {
	Matched  string `json:"matched"`
	Response string `json:"response"`
}

YoloApproval is broadcast when yolo auto-approves a prompt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL