sockapi

package
v0.0.0-...-1d32ed5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDaemonRunning

func IsDaemonRunning(sockPath string) bool

IsDaemonRunning checks whether the daemon is reachable on the socket.

Types

type HealthData

type HealthData struct {
	Status string `json:"status"` // "ok" or "disconnected"
}

HealthData is the health check response.

func QueryHealth

func QueryHealth(sockPath string) (*HealthData, error)

QueryHealth checks daemon health via the Unix socket.

type Server

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

Server serves the status API over a Unix domain socket.

func NewServer

func NewServer(sockPath string, provider StatusProvider, authSecret ...string) *Server

NewServer creates a Server that will listen on sockPath.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe starts the Unix socket listener and serves HTTP until ctx is cancelled. Removes stale socket files on startup and cleans up on shutdown.

type SessionInfo

type SessionInfo struct {
	SessionID string     `json:"sessionID"`
	State     string     `json:"state"`     // "executing" or "idle"
	TaskID    string     `json:"taskID"`    // empty when idle
	StartedAt *time.Time `json:"startedAt"` // when current task started; nil when idle
	IdleSince *time.Time `json:"idleSince"` // when actor became idle; nil when executing
}

SessionInfo is a snapshot of one active session.

func QuerySessions

func QuerySessions(sockPath string) ([]SessionInfo, error)

QuerySessions fetches the active session list via the Unix socket.

type StatusData

type StatusData struct {
	Version            string `json:"version"`
	Uptime             string `json:"uptime"`
	RelayConnected     bool   `json:"relayConnected"`
	RelayURL           string `json:"relayURL"`
	MachineID          string `json:"machineID"`
	ActiveSessions     int    `json:"activeSessions"`
	InFlightTasks      int    `json:"inFlightTasks"`
	MaxConcurrentTasks int    `json:"maxConcurrentTasks"`
	WarmWorkersEnabled bool   `json:"warmWorkersEnabled"`
	WarmWorkerIdleTTL  string `json:"warmWorkerIdleTTL"`
	WarmWorkerIdleCap  int    `json:"warmWorkerIdleCap"`
	ActiveWarmWorkers  int    `json:"activeWarmWorkers"`
	IdleWarmWorkers    int    `json:"idleWarmWorkers"`
	LogLevel           string `json:"logLevel"`
}

StatusData is the full daemon status snapshot.

func QueryStatus

func QueryStatus(sockPath string) (*StatusData, error)

QueryStatus fetches the full daemon status via the Unix socket.

type StatusProvider

type StatusProvider interface {
	Health() HealthData
	Status() StatusData
	Sessions() []SessionInfo
	Workers() []WorkerInfo
}

StatusProvider is implemented by the daemon loop to expose live state.

type WorkerInfo

type WorkerInfo struct {
	SessionID  string     `json:"sessionID"`
	Provider   string     `json:"provider"`
	Model      string     `json:"model"`
	PID        int        `json:"pid"`
	KeyHash    string     `json:"keyHash"`
	State      string     `json:"state"`
	StartedAt  time.Time  `json:"startedAt"`
	LastUsedAt time.Time  `json:"lastUsedAt"`
	IdleSince  *time.Time `json:"idleSince"`
}

func QueryWorkers

func QueryWorkers(sockPath string) ([]WorkerInfo, error)

QueryWorkers fetches warm provider worker snapshots via the Unix socket.

Jump to

Keyboard shortcuts

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