feat(usage): display CLI account quotas and rate limits in Settings -> Usage (#2389)

* feat(usage): display CLI account quotas and rate limits across Codex, Antigravity, and Claude

* fix(usage): persist live quota state across processes and normalize agy usage

* fix(cli): isolate Claude quota observations by account and bound probe deadlines

* fix(usage): bind Claude quota events to producing session account and surface quota fetch errors

* fix(usage): preserve OAuth token isolation without email and surface Codex read failures

* fix(usage): skip host claude path lookup when test probe override is active
This commit is contained in:
Kiyoshi
2026-11-12 10:16:07 +08:00
committed by GitHub
parent 0bea8967b4
commit 31cb262ee0
32 changed files with 2984 additions and 12 deletions
+51
View File
@@ -387,3 +387,54 @@ export interface ExperimentalFeatureEnablementSetResponse {
enablement: Record<string, boolean>;
[key: string]: unknown;
}
export interface CodexAccountInfo {
type?: string | null;
email?: string | null;
planType?: string | null;
[key: string]: unknown;
}
export interface AccountReadResponse {
account?: CodexAccountInfo | null;
requiresOpenaiAuth?: boolean;
[key: string]: unknown;
}
export interface CodexRateLimitWindow {
usedPercent?: number | null;
windowDurationMins?: number | null;
resetsAt?: number | null;
[key: string]: unknown;
}
export interface CodexRateLimitCredits {
hasCredits?: boolean | null;
unlimited?: boolean | null;
balance?: string | number | null;
[key: string]: unknown;
}
export interface CodexRateLimitEntry {
limitId?: string | null;
limitName?: string | null;
normalModelSlug?: string | null;
primary?: CodexRateLimitWindow | null;
secondary?: CodexRateLimitWindow | null;
credits?: CodexRateLimitCredits | null;
planType?: string | null;
spendControlReached?: boolean | null;
rateLimitReachedType?: string | null;
[key: string]: unknown;
}
export interface AccountRateLimitsReadResponse {
ordinaryUsageAllowed?: boolean;
rateLimits?: CodexRateLimitEntry | null;
rateLimitsByLimitId?: Record<string, CodexRateLimitEntry> | null;
rateLimitResetCredits?: {
availableCount?: number | null;
[key: string]: unknown;
} | null;
[key: string]: unknown;
}
+16
View File
@@ -8,6 +8,8 @@ import { CODEX_WEBSOCKET_MAX_PAYLOAD } from './websocketLimits';
import { resolveModelCatalogArgs } from './utils/modelCatalog';
import { resolveSelectedCodexCommand } from './utils/codexExecutable';
import type {
AccountRateLimitsReadResponse,
AccountReadResponse,
CollaborationModeListResponse,
InitializeParams,
InitializeResponse,
@@ -366,6 +368,20 @@ export class CodexAppServerClient extends JsonLineParser {
return response as ModelListResponse;
}
async readAccount(): Promise<AccountReadResponse> {
const response = await this.sendRequest('account/read', {}, {
timeoutMs: 15_000
});
return response as AccountReadResponse;
}
async readRateLimits(): Promise<AccountRateLimitsReadResponse> {
const response = await this.sendRequest('account/rateLimits/read', {}, {
timeoutMs: 15_000
});
return response as AccountRateLimitsReadResponse;
}
async listSkills(params: SkillsListParams): Promise<SkillsListResponse> {
const response = await this.sendRequest('skills/list', params, {
timeoutMs: 30_000
@@ -1,5 +1,6 @@
import { INCLUSIVE_INPUT_TOKEN_USAGE_MARKER } from '@hapi/protocol/usage';
import { fileURLToPath } from 'node:url';
import { recordCodexRateLimitsUpdate } from '@/agent/agentQuotas';
import { logger } from '@/ui/logger';
import { codexAssistantText } from './assistantText';
@@ -679,6 +680,7 @@ export class AppServerEventConverter {
}
if (method === 'account/rateLimits/updated') {
recordCodexRateLimitsUpdate(paramsRecord);
return events;
}