Documentation
¶
Overview ¶
Package api provides REST API handlers for the web dashboard.
Index ¶
- func NewStoreBackedMetrics(s store.Store) (pool *StorePoolMetrics, disp *StoreDispatcherMetrics)
- func StoreMetricsHaveData(s store.Store) bool
- type API
- func (a *API) ListWorkers() []WorkerRecord
- func (a *API) Pressure() string
- func (a *API) RegisterRoutes(mux *http.ServeMux)
- func (a *API) RegisterSynapsetRoutes(mux *http.ServeMux)
- func (a *API) SetCapacity(providers []ProviderDTO, routing map[string][]string)
- func (a *API) SetHealthMonitor(hm *provider.HealthMonitor)
- func (a *API) SetHostMetrics(hm *hostmetrics.Collector)
- func (a *API) SetLogAnalyst(la *loganalyst.Analyst)
- func (a *API) SetLogStore(ls *logstore.LogStore)
- func (a *API) SetMetrics(pool poolMetricsSource, disp dispatcherMetricsSource, sys systemMetricsSource)
- func (a *API) SetScalingConfig(enabled bool, minW, maxW int)
- func (a *API) SetSynapsetProxy(baseURL string)
- type ProviderDTO
- type StoreDispatcherMetrics
- type StorePoolMetrics
- type SynapsetProxy
- type WorkerRecord
- type WorkerStatus
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) RegisterSynapsetRoutes ¶ added in v0.1.17
RegisterSynapsetRoutes registers all Synapset proxy routes on the given mux.
func (*API) SetCapacity ¶ added in v0.1.16
func (a *API) SetCapacity(providers []ProviderDTO, routing map[string][]string)
SetCapacity configures the static provider capacity info displayed on the metrics page. Call from the serve command after parsing providers.yaml.
func (*API) SetHealthMonitor ¶ added in v0.1.16
func (a *API) SetHealthMonitor(hm *provider.HealthMonitor)
SetHealthMonitor attaches the provider health monitor for the GET /api/v1/providers/health endpoint. Call from the serve or dispatch command after creating the HealthMonitor.
func (*API) SetHostMetrics ¶ added in v0.1.16
func (a *API) SetHostMetrics(hm *hostmetrics.Collector)
SetHostMetrics attaches the host metrics collector to the API handler.
func (*API) SetLogAnalyst ¶ added in v0.1.16
func (a *API) SetLogAnalyst(la *loganalyst.Analyst)
SetLogAnalyst attaches the log analyst for AI-powered log summaries. Call from the serve command after creating the logstore and Ollama client.
func (*API) SetLogStore ¶ added in v0.1.16
SetLogStore attaches the log store for the log query API endpoint.
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.
func (*API) SetSynapsetProxy ¶ added in v0.1.17
SetSynapsetProxy configures the Synapset proxy for dashboard API requests.
type ProviderDTO ¶ added in v0.1.16
type ProviderDTO struct {
Name string `json:"name"`
Type string `json:"type"`
Model string `json:"model"`
Healthy bool `json:"healthy"`
AccountURL string `json:"account_url,omitempty"`
}
ProviderDTO describes a single registered AI provider.
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 SynapsetProxy ¶ added in v0.1.17
type SynapsetProxy struct {
// contains filtered or unexported fields
}
SynapsetProxy forwards dashboard API requests to the Synapset service.
func NewSynapsetProxy ¶ added in v0.1.17
func NewSynapsetProxy(baseURL string, logger *zap.Logger) *SynapsetProxy
NewSynapsetProxy creates a proxy that forwards requests to the given Synapset base URL.
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" )