feat(xai): track SuperGrok weekly limit + API usage quota

Fetch OAuth quota from cli-chat-proxy billing, GetGrokCreditsConfig weekly
window, and settings plan label so the dashboard matches grok.com usage.
This commit is contained in:
2026-07-13 23:44:36 +07:00
parent b1d368d960
commit ab9a3c1d43
6 changed files with 643 additions and 1 deletions

View File

@@ -451,6 +451,48 @@ export function parseQuotaData(provider, data) {
}
break;
case "xai":
// xAI mixes:
// - weekly: percentage window (used/total 0-100) from GetGrokCreditsConfig
// - api_usage: absolute monthly credits from /v1/billing
// For absolute rows, do not forward remainingCredits as `remaining`
// (QuotaTable treats remaining as a 0-100 percentage; same pitfall as Qoder).
if (data.quotas) {
Object.entries(data.quotas).forEach(([quotaType, quota]) => {
const name =
quotaType === "weekly"
? "Weekly limit"
: quotaType === "api_usage"
? "Api usage"
: quotaType === "monthly"
? "Api usage"
: quotaType === "on_demand"
? "On-demand"
: quotaType;
if (quotaType === "weekly") {
normalizedQuotas.push({
name,
used: quota.used || 0,
total: quota.total || 100,
remaining: quota.remaining,
remainingPercentage: quota.remainingPercentage ?? quota.remaining,
resetAt: quota.resetAt || null,
});
return;
}
normalizedQuotas.push({
name,
used: quota.used || 0,
total: quota.total || 0,
unit: quota.unit,
resetAt: quota.resetAt || null,
});
});
}
break;
default:
// Generic fallback for unknown providers
if (data.quotas) {