observer

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyRunning = errors.New("observer is already running")
)

Functions

This section is empty.

Types

type CatalogEntry

type CatalogEntry struct {
	Harness       registry.Harness `json:"harness"`
	SessionID     string           `json:"session_id,omitempty"`
	SessionPath   string           `json:"session_path,omitempty"`
	ResumeCommand []string         `json:"resume_command,omitempty"`
	CWD           string           `json:"cwd,omitempty"`
	ProjectRoot   string           `json:"project_root,omitempty"`
	ProcessPID    int              `json:"process_pid,omitempty"`
	Current       bool             `json:"current"`
}

func DefaultCatalogList

func DefaultCatalogList(ctx context.Context) ([]CatalogEntry, error)

DefaultCatalogList reads the optional machine-readable catalog configured by AHT_CATALOG_JSON or AHT_CATALOG_FILE. The payload is either an array of catalog entries or an object with a sessions array.

type CatalogLister

type CatalogLister func(context.Context) ([]CatalogEntry, error)

type Health

type Health struct {
	PID                          int           `json:"pid"`
	StartIdentity                string        `json:"start_identity,omitempty"`
	Interval                     time.Duration `json:"interval"`
	GracePeriod                  time.Duration `json:"grace_period"`
	StartedAt                    time.Time     `json:"started_at"`
	LastAttemptAt                time.Time     `json:"last_attempt_at"`
	LastSuccessAt                time.Time     `json:"last_success_at"`
	LastEnumerationErrorCategory string        `json:"last_enumeration_error_category,omitempty"`
	LastEnumerationError         string        `json:"last_enumeration_error,omitempty"`
	Cycles                       int           `json:"cycles"`
	Observations                 int           `json:"observations"`
	Sessions                     int           `json:"sessions"`
	Degraded                     bool          `json:"degraded"`
}

type Observer

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

func New

func New(options Options) *Observer

func (*Observer) Health

func (o *Observer) Health() Health

func (*Observer) Run

func (o *Observer) Run(ctx context.Context) error

func (*Observer) RunOnce

func (o *Observer) RunOnce(ctx context.Context) (Result, error)

func (*Observer) RunWithResults

func (o *Observer) RunWithResults(ctx context.Context, handle func(Result) error) error

RunWithResults runs the observer and calls handle after every reconciliation cycle. It is used by foreground clients that stream cycle results.

type Options

type Options struct {
	Store         Store
	StorePath     string
	Interval      time.Duration
	GracePeriod   time.Duration
	HealthPath    string
	ProcessList   ProcessLister
	PaneList      mux.PaneLister
	CatalogList   CatalogLister
	ScreenCapture mux.ScreenCapturer
	// DisableScreenInspection disables terminal capture and screen-derived state.
	// Native multiplexer activity remains available without reading screen text.
	DisableScreenInspection bool
	DetectionConfigDir      string
	Now                     func() time.Time
	ErrorWriter             io.Writer
	Quiet                   bool
}

type ProcessLister

type ProcessLister func(context.Context) ([]processinfo.Process, error)

type Result

type Result struct {
	ObservedAt   time.Time `json:"observed_at"`
	Observations int       `json:"observations"`
	Sessions     int       `json:"sessions"`
	Processes    int       `json:"processes"`
	Panes        int       `json:"panes"`
	Catalog      int       `json:"catalog"`
	Present      int       `json:"present"`
	Gone         int       `json:"gone"`
	Changed      int       `json:"changed"`
	Degraded     bool      `json:"degraded"`
	Error        string    `json:"error,omitempty"`
}

func (Result) String

func (r Result) String() string

type Store added in v1.3.0

type Store interface {
	Observe(ctx context.Context, observation registry.Observation) (registry.Session, error)
	ObserveBatch(ctx context.Context, observations []registry.Observation) ([]registry.Session, error)
	List(ctx context.Context, filter registry.Filter) ([]registry.Session, error)
}

Store is the observation and inventory capability required by an Observer.

Jump to

Keyboard shortcuts

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