api

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package api provides REST API handlers for the web dashboard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API provides REST endpoints for the web dashboard.

func New

func New(tracker forge.IssueTracker, s store.Store, costs digest.CostSource, logger *zap.Logger) *API

New creates an API handler with the given dependencies. Any dependency may be nil; endpoints that require a nil dependency return 503 Service Unavailable.

func (*API) ListWorkers added in v0.1.11

func (a *API) ListWorkers() []WorkerRecord

ListWorkers returns a snapshot of all registered workers for external consumers (e.g. the MCP digest). Stale workers are marked offline in the returned slice.

func (*API) Pressure added in v0.1.11

func (a *API) Pressure() string

Pressure returns the current pressure level string. It is used by the server's /healthz handler to surface resource pressure without importing the api package.

func (*API) RegisterRoutes

func (a *API) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers all API endpoints on the given mux. Routes use Go 1.22+ method+path patterns.

func (*API) SetMetrics added in v0.1.11

func (a *API) SetMetrics(pool poolMetricsSource, disp dispatcherMetricsSource, sys systemMetricsSource)

SetMetrics attaches metrics sources to the API handler. Call before serving.

func (*API) SetScalingConfig added in v0.1.11

func (a *API) SetScalingConfig(enabled bool, minW, maxW int)

SetScalingConfig records the active scaling policy limits so the metrics endpoint can expose them alongside events read from the store. Call before serving. If not called, scaling_events and scaling_config in /api/v1/metrics will be null.

type WorkerRecord added in v0.1.11

type WorkerRecord struct {
	AgentID         string       `json:"agent_id"`
	Hostname        string       `json:"hostname"`
	Capabilities    []string     `json:"capabilities"`
	MaxConcurrent   int          `json:"max_concurrent"`
	WorkspaceRoot   string       `json:"workspace_root"`
	Status          WorkerStatus `json:"status"`
	CurrentTask     *int         `json:"current_task,omitempty"`
	CPUPercent      float64      `json:"cpu_percent"`
	MemoryPercent   float64      `json:"memory_percent"`
	ActiveWorktrees int          `json:"active_worktrees"`
	RegisteredAt    time.Time    `json:"registered_at"`
	LastHeartbeat   time.Time    `json:"last_heartbeat"`
}

WorkerRecord holds registration and heartbeat state for a single PC agent.

type WorkerStatus added in v0.1.11

type WorkerStatus string

WorkerStatus represents the operational state of a PC agent worker.

const (
	WorkerStatusIdle    WorkerStatus = "idle"
	WorkerStatusBusy    WorkerStatus = "busy"
	WorkerStatusOffline WorkerStatus = "offline"
)

Jump to

Keyboard shortcuts

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