fix(quota): harden dashboard integration

This commit is contained in:
Patrick Wozniak
2026-08-25 13:34:54 +02:00
parent 63dd92da09
commit 96356698fa
9 changed files with 556 additions and 514 deletions
+47
View File
@@ -0,0 +1,47 @@
export interface CommandCodeWindowLimit {
window: "fiveHour" | "weekly"
used: number
cap: number
resetAt: number | null
}
export interface CommandCodeCredits {
monthlyCredits: number
purchasedCredits: number
freeCredits: number
remainingCredits: number
windowLimits: CommandCodeWindowLimit[]
}
export interface CommandCodeSubscription {
planId: string | null
status: string | null
currentPeriodStart: string | null
currentPeriodEnd: string | null
}
export interface CommandCodeUsageSummary {
totalCost: number
totalCount: number
totalTokens?: number
}
export type CommandCodeQuotaSection = "credits" | "subscription" | "usage"
export interface CommandCodeQuota {
account: {
login: string
orgId: string | null
keyName?: string
}
credits: CommandCodeCredits | null
subscription: CommandCodeSubscription | null
summary: CommandCodeUsageSummary | null
unavailable?: readonly CommandCodeQuotaSection[]
}
export type CommandCodeQuotaErrorKind = "config" | "http" | "network" | "timeout"
export type CommandCodeQuotaResult =
| { ok: true; quota: CommandCodeQuota }
| { ok: false; error: { message: string; kind: CommandCodeQuotaErrorKind } }