Documentation
¶
Overview ¶
Package api provides REST API handlers for the web dashboard.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStoreBackedMetrics ¶ added in v0.1.13
func NewStoreBackedMetrics(s store.Store) (pool *StorePoolMetrics, disp *StoreDispatcherMetrics)
NewStoreBackedMetrics creates pool and dispatcher metric sources that read from SQLite. This bridges the cross-process gap: the dispatch process writes snapshots, and the serve process reads them via these types. Returns nil, nil if the store has no recent metric data.
func StoreMetricsHaveData ¶ added in v0.1.13
StoreMetricsHaveData returns true if the store contains a recent metric snapshot.
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
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 ¶
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
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 StoreDispatcherMetrics ¶ added in v0.1.13
type StoreDispatcherMetrics struct {
// contains filtered or unexported fields
}
StoreDispatcherMetrics implements dispatcherMetricsSource by reading from SQLite.
func (*StoreDispatcherMetrics) Snapshot ¶ added in v0.1.13
func (m *StoreDispatcherMetrics) Snapshot() metrics.DispatcherSnapshot
Snapshot returns a DispatcherSnapshot read from the latest persisted metric snapshot.
type StorePoolMetrics ¶ added in v0.1.13
type StorePoolMetrics struct {
// contains filtered or unexported fields
}
StorePoolMetrics implements poolMetricsSource by reading from SQLite.
func (*StorePoolMetrics) Snapshot ¶ added in v0.1.13
func (m *StorePoolMetrics) Snapshot() metrics.PoolSnapshot
Snapshot returns a PoolSnapshot read from the latest persisted metric snapshot.
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" )