Documentation
¶
Overview ¶
Package session manages lifecycle operations (start, delete, continue, promote, spawn).
Index ¶
- func TitleFromPrompt(prompt string) string
- 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) Promote(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 TitleFromPrompt ¶ added in v0.3.10
TitleFromPrompt derives a short, human-readable session title from a user's first message. It strips code and URLs, collapses whitespace, and keeps the leading clause. It returns "" when nothing usable remains, so callers can keep the title blank rather than persist a meaningless value.
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 unless a per-spawn override is provided.
Types ¶
type ContinueResult ¶
type ContinueResult struct {
SessionID string `json:"session_id"`
Reattach bool `json:"reattach"` // true if session was already running
Master bool `json:"master"`
RevivedWorkers []string `json:"revived_workers,omitempty"` // worker IDs auto-continued on master cascade
FailedWorkers []string `json:"failed_workers,omitempty"` // 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.
type SpawnOpts ¶
type SpawnOpts struct {
Title string
Cwd string
// DisplayColor is an explicit named color selected for this worker.
DisplayColor 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
FromApp bool
// Model overrides the worker's primary agent model.
Model string
// ReasoningEffort overrides the worker's primary agent reasoning effort.
ReasoningEffort string
}
SpawnOpts configures a worker session spawned from a master.
type StartOpts ¶
type StartOpts struct {
Title string
Cwd string
Shell bool
Master bool
MasterID string // parent master session ID (for worker spawn)
// DisplayColor is the named display color persisted with session metadata.
DisplayColor string
// ResumeIDs maps agent name → resume ID (e.g. {"claude": "abc", "codex": "xyz"}).
ResumeIDs map[string]string
Prompt string
SystemBrief string
Detached bool
FromApp bool
// Model overrides the primary agent's model (worker spawn only). Empty
// leaves the role default in place.
Model string
// ReasoningEffort overrides the primary agent's reasoning effort. Empty
// leaves the role default in place.
ReasoningEffort string
}
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.