Add usage commands, a vendor-neutral usage format and a knowledge base

This commit is contained in:
Ian Gulliver
2026-10-19 15:08:57 -07:00
parent 912225cbd1
commit 8a395d4d6e
17 changed files with 1010 additions and 403 deletions
+5 -19
View File
@@ -153,7 +153,6 @@ func (m *Manager) agyTurnEnded(ctx context.Context, l *live, p antigravityProces
m.mu.Lock()
final := l.lastText
m.mu.Unlock()
go m.readAgyRateLimit()
success := res.Status == "SUCCESS"
bounce := false
@@ -207,30 +206,17 @@ func (m *Manager) readAgyRateLimit() {
slog.Error("read antigravity rate limits", "err", err)
return
}
m.mu.Lock()
m.rateLimits[api.Antigravity] = agyRateLimit(groups)
m.mu.Unlock()
m.store.Broadcast(api.Event{Kind: "admin.health", Actor: "byre", Payload: map[string]any{}})
m.setVendorUsage(api.Antigravity, agyUsage(groups))
}
func agyRateLimit(groups []antigravity.UsageGroup) map[string]any {
info := map[string]any{"status": "allowed"}
windows := map[string]any{}
func agyUsage(groups []antigravity.UsageGroup) api.Usage {
u := api.Usage{UpdatedAt: time.Now(), Windows: []api.UsageWindow{}}
for _, g := range groups {
for _, b := range g.Buckets {
window := map[string]any{"utilization": 1 - b.RemainingFraction, "resetsAt": b.ResetTime.Unix()}
if mins := agyWindowMins[b.Window]; mins != 0 {
window["windowMins"] = mins
}
windows[b.ID] = window
if b.RemainingFraction <= 0 {
info["status"] = "rejected"
info["rateLimitType"] = b.ID
}
u.Windows = append(u.Windows, percentWindow(b.ID, 1-b.RemainingFraction, b.ResetTime.Unix(), int64(agyWindowMins[b.Window])*60))
}
}
info["unifiedWindows"] = windows
return info
return u
}
func (m *Manager) agyBeforeModel(l *live) antigravity.HookFunc {