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
+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}).` };
}