daemon

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 44 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Main

func Main(args []string) int

Main runs `stagent daemon`. A second daemon for the same user exits 0 right away (the IPC address is already served).

Types

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon is one running daemon.

func New

func New(opts Options) (*Daemon, error)

New opens the event log and loads the configuration.

func (*Daemon) Done

func (d *Daemon) Done() <-chan struct{}

Done is closed when Shutdown starts (daemon.shutdown, signals).

func (*Daemon) Serve

func (d *Daemon) Serve(ln net.Listener) error

Serve accepts connections on ln until Shutdown. It closes ln.

func (*Daemon) Shutdown

func (d *Daemon) Shutdown()

Shutdown stops accepting, closes every connection and releases resources. Pending approvals close and release their hooks. Safe to call more than once.

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 (default time.Now), and
	// ScheduleTick how often it is compared with their times (default
	// 30 s). RunStartGrace: how long a run's holder has to register
	// (default 30 s; see schedules.go).
	Now           func() time.Time
	ScheduleTick  time.Duration
	RunStartGrace time.Duration
	// 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)
}

Options configures a Daemon. Zero fields take defaults.

Jump to

Keyboard shortcuts

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