supervisor

package
v1.23.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package supervisor manages agent sessions.

Index

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 New

func New(spawner SessionSpawner) *Supervisor

New creates a new supervisor.

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

func (s *Supervisor) Count() int

Count returns the number of sessions.

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

func (s *Supervisor) Shutdown()

Shutdown closes all sessions.

func (*Supervisor) SpawnSession

func (s *Supervisor) SpawnSession(ctx context.Context, workingDir string) (string, error)

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.

Jump to

Keyboard shortcuts

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