Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/agents-usage/src/collectors/kimi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ describe("parseKimiUsage", () => {
expect(session.resetsAt).toBe(Date.parse(SESSION_RESET));
});

it("maps the membership level to the subscription plan name with its credit multiplier", () => {
const snap = parseKimiUsage(JSON.parse(USAGES_BODY), FAKE_NOW_MS);
expect(snap.plan).toBe("Allegretto 5x");
it("maps paid membership levels to the current subscription credit multipliers", () => {
const body = JSON.parse(USAGES_BODY);
expect(parseKimiUsage(body, FAKE_NOW_MS).plan).toBe("Allegretto 2x");
body.user.membership.level = "LEVEL_ADVANCED";
expect(parseKimiUsage(body, FAKE_NOW_MS).plan).toBe("Allegro 5x");
body.user.membership.level = "LEVEL_STANDARD";
expect(parseKimiUsage(body, FAKE_NOW_MS).plan).toBe("Vivace 10x");
});

it("humanizes unknown membership levels and omits plan when absent", () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/agents-usage/src/collectors/kimi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface KimiUsagesResponse {
* Subscription tier names shown on kimi.com/membership, keyed by the
* `user.membership.level` enum the usages endpoint returns. Paid tiers above
* the base carry the Kimi Code credit multiplier from the pricing page
* (Allegretto 5x / Allegro 15x / Vivace 30x), mirroring the Codex plan labels
* (Allegretto 2x / Allegro 5x / Vivace 10x), mirroring the Codex plan labels
* ("ChatGPT Pro 20x"). Unknown levels fall back to a humanized form of the
* enum ("LEVEL_SOMETHING" → "Something") so a new tier still shows a readable
* name instead of nothing.
Expand All @@ -65,9 +65,9 @@ const KIMI_PLAN_BY_LEVEL: Record<string, string> = {
LEVEL_FREE: "Adagio",
LEVEL_TRIAL: "Andante",
LEVEL_BASIC: "Moderato",
LEVEL_INTERMEDIATE: "Allegretto 5x",
LEVEL_ADVANCED: "Allegro 15x",
LEVEL_STANDARD: "Vivace 30x",
LEVEL_INTERMEDIATE: "Allegretto 2x",
LEVEL_ADVANCED: "Allegro 5x",
LEVEL_STANDARD: "Vivace 10x",
};

function formatKimiPlan(level: unknown): string | undefined {
Expand Down