feat(api): limits read unifiedWindows, unknown seven-day windows labelled by model

This commit is contained in:
hh
2026-09-02 04:46:43 +02:00
parent 81d6560bf7
commit c46ba026ba
4 changed files with 112 additions and 15 deletions
+2
View File
@@ -215,6 +215,8 @@ export interface LimitWindow extends LimitRecord {
gateway: UsageTotals & { since: string };
// The last figure reported inside this window, if any: a lower bound.
last_known: LimitRecord | null;
// When the figure came from another event's unified report.
reported_at?: string | null;
}
export interface LimitsResponse {
+11 -1
View File
@@ -6,8 +6,18 @@ export const LIMIT_LABELS: Record<string, string> = {
seven_day_sonnet: "7-day · Sonnet",
};
const SEVEN_DAY = "seven_day_";
export function limitLabel(window: string): string {
return LIMIT_LABELS[window] ?? window;
const known = LIMIT_LABELS[window];
if (known) {
return known;
}
if (window.startsWith(SEVEN_DAY)) {
const model = window.slice(SEVEN_DAY.length);
return `7-day · ${model.charAt(0).toUpperCase()}${model.slice(1)}`;
}
return window.replaceAll("_", " ");
}
// The status as a word, for the windows the API never puts a figure on.