Documentation
¶
Overview ¶
Package supervisor manages agent sessions.
Index ¶
- type SessionRunner
- type SessionSpawner
- type Supervisor
- func (s *Supervisor) ActiveID() string
- func (s *Supervisor) ActiveRunner() *SessionRunner
- func (s *Supervisor) AddSession(ctx context.Context, a *app.App, sess *session.Session, workingDir string, ...) string
- func (s *Supervisor) CloseSession(sessionID string) (nextActiveID string)
- func (s *Supervisor) ConsumePendingEvent(sessionID string) tea.Msg
- func (s *Supervisor) Count() int
- func (s *Supervisor) GetRunner(sessionID string) *SessionRunner
- func (s *Supervisor) GetTabs() ([]messages.TabInfo, int)
- func (s *Supervisor) ReorderTab(fromIdx, toIdx int)
- func (s *Supervisor) ReplaceRunnerApp(ctx context.Context, sessionID string, newApp *app.App, workingDir string, ...)
- func (s *Supervisor) SetProgram(p *tea.Program)
- func (s *Supervisor) SetRunnerTitle(sessionID, title string)
- func (s *Supervisor) Shutdown()
- func (s *Supervisor) SpawnSession(ctx context.Context, workingDir string) (string, error)
- func (s *Supervisor) Spawner() SessionSpawner
- func (s *Supervisor) SwitchTo(sessionID string) *SessionRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SessionRunner ¶
type SessionRunner struct {
ID string
App *app.App
WorkingDir string
Title string
IsRunning bool // True when stream is active
NeedsAttn bool // True when user attention is needed
PendingEvent tea.Msg // Event that triggered attention (for replay on tab switch)
// contains filtered or unexported fields
}
SessionRunner represents a running session.
type SessionSpawner ¶
type SessionSpawner func(ctx context.Context, workingDir string) (*app.App, *session.Session, func(), error)
SessionSpawner is a function that creates new sessions. It takes a working directory and returns the app, session, and cleanup function.
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor manages agent sessions.
func (*Supervisor) ActiveID ¶
func (s *Supervisor) ActiveID() string
ActiveID returns the ID of the currently active session.
func (*Supervisor) ActiveRunner ¶
func (s *Supervisor) ActiveRunner() *SessionRunner
ActiveRunner returns the currently active session runner.
func (*Supervisor) AddSession ¶
func (s *Supervisor) AddSession(ctx context.Context, a *app.App, sess *session.Session, workingDir string, cleanup func()) string
AddSession adds an existing session to the supervisor.
func (*Supervisor) CloseSession ¶
func (s *Supervisor) CloseSession(sessionID string) (nextActiveID string)
CloseSession closes a session and removes it from the supervisor.
func (*Supervisor) ConsumePendingEvent ¶
func (s *Supervisor) ConsumePendingEvent(sessionID string) tea.Msg
ConsumePendingEvent returns and clears the pending event for the given session. Returns nil if no event is pending.
func (*Supervisor) GetRunner ¶
func (s *Supervisor) GetRunner(sessionID string) *SessionRunner
GetRunner returns the runner for the given session ID, or nil if not found.
func (*Supervisor) GetTabs ¶
func (s *Supervisor) GetTabs() ([]messages.TabInfo, int)
GetTabs returns the current tab info.
func (*Supervisor) ReorderTab ¶
func (s *Supervisor) ReorderTab(fromIdx, toIdx int)
ReorderTab moves the tab at fromIdx to toIdx, shifting others accordingly.
func (*Supervisor) ReplaceRunnerApp ¶
func (s *Supervisor) ReplaceRunnerApp(ctx context.Context, sessionID string, newApp *app.App, workingDir string, cleanup func())
ReplaceRunnerApp replaces the app, working directory, and cleanup function for an existing runner. The old app's context is cancelled and its cleanup is run asynchronously. A new subscription goroutine is started for the new app. This is used when restoring a session whose working directory differs from the runner's current one, requiring a fresh runtime.
func (*Supervisor) SetProgram ¶
func (s *Supervisor) SetProgram(p *tea.Program)
SetProgram sets the Bubble Tea program for sending messages.
func (*Supervisor) SetRunnerTitle ¶
func (s *Supervisor) SetRunnerTitle(sessionID, title string)
SetRunnerTitle updates the title of the runner for the given session ID. It also triggers a tab update notification.
func (*Supervisor) SpawnSession ¶
SpawnSession creates and adds a new session.
func (*Supervisor) Spawner ¶
func (s *Supervisor) Spawner() SessionSpawner
Spawner returns the session spawner function, or nil if none is configured.
func (*Supervisor) SwitchTo ¶
func (s *Supervisor) SwitchTo(sessionID string) *SessionRunner
SwitchTo switches to a different session.