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) 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) SetPendingEvent(sessionID string, event tea.Msg)
- 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
// PendingEvents queues attention events (tool confirmation, max
// iterations, elicitation) that arrived while this tab was inactive, in
// arrival order, for replay when the user switches to it. A single slot
// used to overwrite an earlier event with a later one, silently dropping
// it (#3584) — e.g. two concurrent background-job elicitations on the
// same unfocused tab would leave only the second visible.
PendingEvents []tea.Msg
// 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) string
CloseSession closes a session and removes it from the supervisor.
func (*Supervisor) ConsumePendingEvent ¶
func (s *Supervisor) ConsumePendingEvent(sessionID string) tea.Msg
ConsumePendingEvent pops and returns the oldest pending event for the given session (FIFO). Returns nil if none 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) SetPendingEvent ¶ added in v1.55.0
func (s *Supervisor) SetPendingEvent(sessionID string, event tea.Msg)
SetPendingEvent re-queues an attention event at the FRONT of the given session's pending queue, ahead of anything queued behind it, so it can be replayed when the user later switches to that tab. Used to re-stash a background dialog's originating event when the user navigates away from the tab that opened it.
NeedsAttention is intentionally NOT set here: the user is already aware of the prompt (they just chose to step away from it) and we don't want to flag the tab as if a brand-new event had arrived.
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.