Documentation
¶
Overview ¶
Package daemon is `stagent daemon`: the per-user session registry, event log, hook integration (state, notifications, pending approvals), push notifications, transcript access and scrollback retention. It never sees PTY bytes — holders keep the terminal and report state transitions only.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is one running daemon.
func (*Daemon) Done ¶
func (d *Daemon) Done() <-chan struct{}
Done is closed when Shutdown starts (daemon.shutdown, signals).
type Options ¶
type Options struct {
Layout *paths.Layout
// Roots of the harness transcripts (nil: transcript.DefaultRoots).
Roots transcript.Roots
// GoneGrace: a holder connection that drops without holder.ended counts
// as a lost session unless the holder re-registers within this time.
GoneGrace time.Duration
// EndedLinger: how long an ended session stays listed.
EndedLinger time.Duration
// TranscriptPoll: tail interval while a transcript is subscribed.
TranscriptPoll time.Duration
// AgentProbe reports whether the agents of promoted shell sessions
// still run (default: follow.AgentProbe; see probe.go), and
// ProbeInterval how often it is asked.
AgentProbe func([]follow.SessionAgent) ([]bool, error)
ProbeInterval time.Duration
// PushGrace: how long a passthrough session's push waits (default
// 15 s; tests shorten it).
PushGrace time.Duration
// UnwrappedTTL: how long an agent started without a stagent session
// stays listed after its last hook (default 12h; see unwrapped.go).
UnwrappedTTL time.Duration
// PrepareGrace: how long a preparing task waits for its prepared
// session to register before it counts as interrupted (default 30 s;
// see tasks.go).
PrepareGrace time.Duration
Logf func(format string, args ...any)
// Bootstrap is what `stagent daemon` found swapping its bootstrap port
// (macOS), reported by daemon.status.
Bootstrap bootstrap.Result
// Guard refuses some methods to coding agents' process trees (ADR
// 0004; default: harness.NewGuard(Layout)).
Guard *harness.Guard
// Now is the wall clock schedules run by and hooks are timed by
// (default time.Now), and ScheduleTick how often it is compared with
// the schedules' times (default 30 s). RunStartGrace: how long a run's
// holder has to register (default 30 s; see schedules.go). AfterFunc
// starts the timers that go with the hooks' times (default
// time.AfterFunc; replyIdleLocked): tests run them on a fake Now.
Now func() time.Time
AfterFunc func(d time.Duration, f func()) Timer
ScheduleTick time.Duration
RunStartGrace time.Duration
// HostLocation is the host's own clock, which schedule entries name
// where it differs from their zone (default time.Local). Tests set a
// zone here: assigning time.Local races with every timer that fires.
HostLocation *time.Location
// LoginEnv takes the login shell's environment before each schedule
// run (default: loginenv.Capture of this stagent, runLoginEnvWithin at
// most), and SpawnHolder starts the run's holder and tells whether it
// is outside the GUI login session (default: proc.StartHolder).
LoginEnv func() ([]string, error)
SpawnHolder func(exe string, args []string, dir string, env []string, logPath string) (pid int, outsideGUI bool, err error)
// UsageScanInterval: how often the transcripts are scanned for new
// usage (default 10 s; usage.get also asks for a scan), and
// UsageChangedEvery the least time between two usage.changed
// (default 30 s). UsageBeforeFile, when set, is called before each
// file the scan reads (tests hold the scan with it). See usage.go.
UsageScanInterval time.Duration
UsageChangedEvery time.Duration
UsageBeforeFile func(path string)
// PrivateAPI calls the harnesses' private usage APIs (default: the
// real endpoints; on macOS the Keychain too, unless STAGENT_HOME is
// set), and PrivateAPITick is how often the daemon looks whether one
// is due (default 15 s). See usage_private.go.
PrivateAPI usage.PrivateAPI
PrivateAPITick time.Duration
// OmpBin finds omp's executable ("" when not installed; default: PATH
// then the per-user tool directories, nil — omp never run — when
// STAGENT_HOME is set), Omp runs its usage command, and
// OmpHistoryEvery is how often its snapshots are read (default 2
// min). See usage_omp.go.
OmpBin func() string
Omp usage.OmpUsage
OmpHistoryEvery time.Duration
// BootID reads the id of the host's current boot ("" when unknown;
// default bootid.Get): agents.json recorded in another boot means the
// host restarted (stopped.go).
BootID func() string
}
Options configures a Daemon. Zero fields take defaults.
Source Files
¶
- antigravity.go
- claude.go
- codex.go
- copilot.go
- daemon.go
- grok.go
- hooks.go
- main.go
- omp.go
- opencode.go
- pi.go
- probe.go
- prompt.go
- push.go
- question.go
- qwen.go
- retention.go
- schedule_output.go
- schedules.go
- schedules_agent.go
- schedules_limits.go
- schedules_mac.go
- schedules_manage.go
- schedules_notify.go
- sessionend.go
- sessionend_unix.go
- sessions.go
- setup.go
- state.go
- stopped.go
- tasks.go
- transcripts.go
- unwrapped.go
- usage.go
- usage_alerts.go
- usage_omp.go
- usage_private.go