summaryrefslogtreecommitdiff
path: root/internal/api/server.go
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-05-26 20:34:09 +0000
committerClaude <noreply@anthropic.com>2026-05-26 20:34:09 +0000
commitab4b364954af08fa602388495ca425eaef0abf74 (patch)
treec0806a57295270b4d86f097c3d0b6a0e1d631201 /internal/api/server.go
parent32715355fe2eed321df4f7083dfe580d35f8a62a (diff)
feat(api,web): budget headroom endpoint + UI chips (Phase 6)
Adds GET /api/budget returning per-provider rolling-window headroom (empty when budget gating is unconfigured), wired from serve.go via SetBudget. The web UI polls it and renders a chip per limited provider in the header, flagging any under 20% remaining. New pure JS helpers formatBudgetHeadroom/ renderBudgetHeadroom are unit-tested; the endpoint is covered by Go handler tests (empty/reports/500). UI render not browser-verified in this environment. Completes Phase 6: spend accounting + dispatcher gating + observability surface. https://claude.ai/code/session_01SESwn7kQ7oP62trWw6pc39
Diffstat (limited to 'internal/api/server.go')
-rw-r--r--internal/api/server.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/internal/api/server.go b/internal/api/server.go
index a4b7ea1..ffa8cd4 100644
--- a/internal/api/server.go
+++ b/internal/api/server.go
@@ -61,6 +61,7 @@ type Server struct {
pushStore pushSubscriptionStore
dropsDir string
llm *llm.Client
+ budget budgetReporter // optional; per-provider spend headroom for GET /api/budget
}
// SetAPIToken configures a bearer token that must be supplied to access the API.
@@ -147,6 +148,7 @@ func (s *Server) routes() {
s.mux.HandleFunc("GET /api/tasks/{id}/events", s.handleListTaskEvents)
s.mux.HandleFunc("GET /api/executions", s.handleListRecentExecutions)
s.mux.HandleFunc("GET /api/stats", s.handleGetDashboardStats)
+ s.mux.HandleFunc("GET /api/budget", s.handleGetBudget)
s.mux.HandleFunc("GET /api/agents/status", s.handleGetAgentStatus)
s.mux.HandleFunc("GET /api/executions/{id}", s.handleGetExecution)
s.mux.HandleFunc("GET /api/executions/{id}/log", s.handleGetExecutionLog)