Documentation
¶
Overview ¶
Package session manages lifecycle operations (start, delete, continue, promote, spawn).
Index ¶
- func WorkerSpawnRegistry(master state.Manifest, overrides *agent.ConfigOverrides) (*agent.Registry, error)
- func WorkerSpawnRegistryWithBase(master state.Manifest, base *agent.Registry, overrides *agent.ConfigOverrides) (*agent.Registry, error)
- type ContinueResult
- type Service
- func (s *Service) Continue(ctx context.Context, sessionID string) (ContinueResult, error)
- func (s *Service) Delete(ctx context.Context, sessionID string) error
- func (s *Service) DeleteWorkers(ctx context.Context, masterID string) error
- func (s *Service) Deregister(sessionID string) error
- func (s *Service) Promote(ctx context.Context, sessionID string) error
- func (s *Service) Resize(ctx context.Context, sessionID string) error
- func (s *Service) Spawn(ctx context.Context, masterID string, opts SpawnOpts) (StartResult, error)
- func (s *Service) Start(ctx context.Context, opts StartOpts) (StartResult, error)
- type SpawnOpts
- type StartOpts
- type StartResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WorkerSpawnRegistry ¶
func WorkerSpawnRegistry(master state.Manifest, overrides *agent.ConfigOverrides) (*agent.Registry, error)
WorkerSpawnRegistry resolves the worker agent layout for a master. Workers inherit the master's primary agent. The companion is strictly opt-in via overrides.Companion — when no companion override is given, the worker has no companion regardless of the user's [roles.companion] config. When the resolved primary and companion are the same agent, this fails before any tmux work, naming both roles in the error.
Types ¶
type ContinueResult ¶
type ContinueResult struct {
SessionID string
Reattach bool // true if session was already running
Master bool
RevivedWorkers []string // worker IDs auto-continued on master cascade
FailedWorkers []string // worker IDs that failed to auto-continue
}
ContinueResult holds the outcome of a Continue operation.
type Service ¶
type Service struct {
Store *state.Store
Client *tmux.Client
RepoRoot string
Registry *agent.Registry
// CLIResolver resolves the questmaster launch command. Defaults to config.ResolveQuestmasterCmd.
CLIResolver func(repoRoot string) (string, error)
// Now returns the current unix timestamp. Defaults to time.Now().Unix().
Now func() int64
// RandSuffix returns a random int for session ID dedup.
RandSuffix func() int64
}
Service provides session lifecycle operations backed by state and tmux.
func NewService ¶
func NewService(store *state.Store, client *tmux.Client, repoRoot string, registry ...*agent.Registry) *Service
NewService creates a session service with production defaults.
func (*Service) Delete ¶
Delete removes a session completely: kills tmux, cleans runtime, removes manifest.
func (*Service) DeleteWorkers ¶
DeleteWorkers removes every worker recorded on a master manifest. Missing or non-master manifests are no-ops so Delete keeps its historical behavior for stale and corrupt manifest state.
func (*Service) Deregister ¶
Deregister removes a session from its parent master's worker list and cleans up. Returns an error if manifest deletion fails (stale manifest would linger). "Manifest not found" is tolerated — the desired state is already achieved.
func (*Service) Promote ¶
Promote converts a worker or standalone session to a master session. Handles both the legacy classic layout (in-place companion-pane respawn, single window) and the current sidebar layout (replace the tracker pane in the workspace window, kill the hidden companion window).
func (*Service) Resize ¶
Resize resets the pane layout to canonical widths for the given session. Finds the left pane (tracker or companion) and the shell pane by role, then resizes left to leftPaneWidth and shell to shellPaneWidth.
type SpawnOpts ¶
type SpawnOpts struct {
Title string
Cwd string
// ResumeIDs maps agent name → resume ID.
ResumeIDs map[string]string
// Prompt is the worker's first user turn.
Prompt string
// SystemBrief is a rare worker-only system override appended after
// the built-in worker system prompt.
SystemBrief string
Detached bool
Registry *agent.Registry
}
SpawnOpts configures a worker session spawned from a master.
type StartOpts ¶
type StartOpts struct {
Title string
Cwd string
Master bool
IncludeCompanion bool
MasterID string // parent master session ID (for worker spawn)
// ResumeIDs maps agent name → resume ID (e.g. {"claude": "abc", "codex": "xyz"}).
ResumeIDs map[string]string
Prompt string
SystemBrief string
Detached bool
}
StartOpts configures a new session launch.
Prompt is the initial user-turn message (Claude `-- <prompt>`, Codex positional). SystemBrief is a rare standalone/worker system override that is appended after the built-in standalone or worker system prompt.
type StartResult ¶
StartResult holds the outcome of a Start operation.