feat: update the quota tracking for user role

This commit is contained in:
2026-07-11 21:38:22 +07:00
parent 8d731d84fb
commit 4e3e46c1af
6 changed files with 519 additions and 12 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ const USAGE_HANDLERS = {
"gemini-cli": (c) => getGeminiUsage(c.accessToken, c.providerDataWithProjectId, c.proxyOptions),
antigravity: (c) => getAntigravityUsage(c.accessToken, c.providerSpecificData, c.proxyOptions),
claude: (c) => getClaudeUsage(c.accessToken, c.proxyOptions),
codex: (c) => getCodexUsage(c.accessToken, c.proxyOptions),
codex: (c) => getCodexUsage(c.accessToken, c.proxyOptions, c.providerSpecificData),
kiro: (c) => getKiroUsage(c.accessToken, c.providerSpecificData, c.proxyOptions),
qoder: (c) => getQoderUsage(c.accessToken, c.proxyOptions),
qwen: (c) => getQwenUsage(c.accessToken, c.providerSpecificData),
+14 -5
View File
@@ -80,17 +80,26 @@ function getCodexReviewRateLimit(data) {
}) || null;
}
export async function getCodexUsage(accessToken, proxyOptions = null) {
export async function getCodexUsage(accessToken, proxyOptions = null, providerSpecificData = null) {
try {
const accountId = getCodexAccountId(providerSpecificData);
const headers = {
"Authorization": `Bearer ${accessToken}`,
"Accept": "application/json",
"OpenAI-Beta": "codex-1",
"originator": "codex_cli_rs",
};
if (accountId) headers["ChatGPT-Account-ID"] = accountId;
const response = await proxyAwareFetch(CODEX_CONFIG.usageUrl, {
method: "GET",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Accept": "application/json",
},
headers,
}, proxyOptions);
if (!response.ok) {
if (response.status === 401 || response.status === 403) {
return { message: `Codex authentication failed (${response.status}). Please re-authorize the connection.` };
}
return { message: `Codex connected. Usage API temporarily unavailable (${response.status}).` };
}