fix(vscode): support Codex business spend limits

This commit is contained in:
Bohdan Triapitsyn
2026-07-29 18:32:27 +03:00
parent 4a56527d1b
commit d5e63467cf
2 changed files with 47 additions and 0 deletions
+21
View File
@@ -40,6 +40,13 @@ type OpenAiUsagePayload = {
balance?: number | string;
unlimited?: boolean;
};
spend_control?: {
individual_limit?: {
limit?: number | string;
used?: number | string;
used_percent?: number | string;
};
};
};
type GoogleModelsPayload = {
@@ -558,6 +565,20 @@ const fetchCodexQuota = async (): Promise<ProviderResult> => {
valueLabel,
});
}
if (payload?.spend_control?.individual_limit) {
const spendLimit = payload.spend_control.individual_limit;
const used = toNumber(spendLimit.used);
const limit = toNumber(spendLimit.limit);
const valueLabel = used !== null && limit !== null
? `${used.toFixed(0)} / ${limit.toFixed(0)} used`
: null;
windows.credits = toUsageWindow({
usedPercent: toNumber(spendLimit.used_percent),
windowSeconds: null,
resetAt: null,
valueLabel,
});
}
return buildResult({
providerId: 'codex',