monitor

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 18 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForceKillSessionByPID

func ForceKillSessionByPID(runtimeDir, sessionID string)

ForceKillSessionByPID reads the PID from a session's process.json and forcefully kills the process.

func SessionPIDAlive

func SessionPIDAlive(runtimeDir, sessionID string) bool

SessionPIDAlive returns true if the session's process.json PID is alive. Returns false if process.json is missing or the PID is dead.

func TerminateSessionByPID

func TerminateSessionByPID(runtimeDir, sessionID string)

TerminateSessionByPID reads the PID from a session's process.json and requests graceful termination.

Types

type CanonicalClaimsReader

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

func NewCanonicalClaimsReader

func NewCanonicalClaimsReader(runtimeDir string) *CanonicalClaimsReader

func (*CanonicalClaimsReader) ReadSession

func (r *CanonicalClaimsReader) ReadSession(sessionID string) (SessionClaims, error)

type ClaimsReader

type ClaimsReader interface {
	ReadSession(sessionID string) (SessionClaims, error)
}

type CompositeObserver

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

func NewCompositeObserver

func NewCompositeObserver(runtimeDir string, local Observer, remote Observer) *CompositeObserver

func (*CompositeObserver) Observe

func (o *CompositeObserver) Observe(sessionID string) (Observation, error)

type EventTicketMaterializer

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

func NewEventTicketMaterializer

func NewEventTicketMaterializer(runtimeDir string) *EventTicketMaterializer

func (*EventTicketMaterializer) Materialize

func (m *EventTicketMaterializer) Materialize(ctx context.Context, sessionIDs []string) error

type HealthStatus

type HealthStatus string
const (
	HealthGreen  HealthStatus = "green"
	HealthYellow HealthStatus = "yellow"
	HealthRed    HealthStatus = "red"
)

type HeartbeatObserver

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

func NewHeartbeatObserver

func NewHeartbeatObserver(runtimeDir string) *HeartbeatObserver

func (*HeartbeatObserver) Observe

func (o *HeartbeatObserver) Observe(sessionID string) (Observation, error)

type Monitor

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

func NewMonitor

func NewMonitor(runtimeDir string) *Monitor

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context) error

func (*Monitor) RunOnce

func (m *Monitor) RunOnce(ctx context.Context) ([]SessionMeta, error)

type Observation

type Observation struct {
	SessionID string
	Alive     bool
	LogMTime  time.Time
	LogSize   int64
}

type Observer

type Observer interface {
	Observe(sessionID string) (Observation, error)
}

type PidObserver

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

PidObserver checks session liveness by reading the PID from process.json and probing it with kill(pid, 0). EPERM is treated as alive per brain/codebase/unix-process-liveness-eperm.

func NewPidObserver

func NewPidObserver(runtimeDir string) *PidObserver

func (*PidObserver) Observe

func (o *PidObserver) Observe(sessionID string) (Observation, error)

type SessionClaims

type SessionClaims struct {
	SessionID    string    `json:"session_id"`
	HasEvents    bool      `json:"has_events"`
	Completed    bool      `json:"completed"`
	Skill        string    `json:"skill,omitempty"`
	Runtime      string    `json:"runtime,omitempty"`
	Provider     string    `json:"provider,omitempty"`
	Model        string    `json:"model,omitempty"`
	TotalCostUSD float64   `json:"total_cost_usd"`
	FirstEventAt time.Time `json:"first_event_at"`
	LastEventAt  time.Time `json:"last_event_at"`
	LastAction   string    `json:"last_action,omitempty"`
	TokensIn     int       `json:"tokens_in"`
	TokensOut    int       `json:"tokens_out"`
	Failed       bool      `json:"failed"`
}

type SessionMeta

type SessionMeta struct {
	SessionID               string        `json:"session_id"`
	Status                  SessionStatus `json:"status"`
	Runtime                 string        `json:"runtime,omitempty"`
	Provider                string        `json:"provider,omitempty"`
	Model                   string        `json:"model,omitempty"`
	TotalCostUSD            float64       `json:"total_cost_usd"`
	DurationSeconds         int64         `json:"duration_seconds"`
	LastActivity            time.Time     `json:"last_activity"`
	CurrentAction           string        `json:"current_action,omitempty"`
	Health                  HealthStatus  `json:"health"`
	ContextWindowUsagePct   float64       `json:"context_window_usage_pct"`
	RetryCount              int           `json:"retry_count"`
	Alive                   bool          `json:"alive"`
	Stuck                   bool          `json:"stuck"`
	LogSize                 int64         `json:"log_size"`
	UpdatedAt               time.Time     `json:"updated_at"`
	IdleSeconds             int64         `json:"idle_seconds"`
	LastObservedProviderRaw string        `json:"last_observed_provider_raw,omitempty"`
}

func DeriveSessionMeta

func DeriveSessionMeta(
	sessionID string,
	observation Observation,
	claims SessionClaims,
	previous SessionMeta,
	now time.Time,
) SessionMeta

type SessionStatus

type SessionStatus string
const (
	SessionStatusRunning SessionStatus = "running"
	SessionStatusExited  SessionStatus = "exited"
	SessionStatusFailed  SessionStatus = "failed"
)

type TicketMaterializer

type TicketMaterializer interface {
	Materialize(ctx context.Context, sessionIDs []string) error
}

Jump to

Keyboard shortcuts

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