Skip to content

Commit b273d1c

Browse files
feat(usage): pool subscription limits per provider across accounts and environments (pingdotgg#10300)
1 parent d924fe2 commit b273d1c

9 files changed

Lines changed: 1823 additions & 246 deletions

File tree

‎apps/server/src/usage/cliproxyUsageLimits.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ describe("cliproxyStatusToAccounts", () => {
102102
},
103103
]);
104104
});
105+
106+
it("names a Codex five-hour window `primary`, as the Codex driver does", () => {
107+
const accounts = cliproxyStatusToAccounts(
108+
{
109+
accounts: {
110+
111+
provider: "codex",
112+
plan: "pro",
113+
five_hour: { hard_limited: false, known: true, used_percent: 40 },
114+
},
115+
},
116+
},
117+
checkedAt,
118+
);
119+
expect(accounts[0]?.usageLimits.windows.map((window) => window.id)).toEqual(["primary"]);
120+
});
105121
});
106122

107123
describe("accountEmailFromAuthFile", () => {

‎apps/server/src/usage/cliproxyUsageLimits.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export function cliproxyAccountToUsageLimits(
124124
if (!window || window.known === false) continue;
125125
const resetsAt = isoFromHub(window.reset_at);
126126
windows.push({
127-
id: spec.id,
127+
// Codex names its five-hour window by position, so a hub row and a
128+
// native row for the same account pool together.
129+
id: spec.key === "five_hour" && account.provider === "codex" ? "primary" : spec.id,
128130
kind: spec.kind,
129131
label: spec.label,
130132
windowDurationMins: spec.windowDurationMins,

0 commit comments

Comments
 (0)