From 7a5166621db838f636ebad4da52bb7c5118cf9e2 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Wed, 27 May 2026 19:05:02 -0300 Subject: [PATCH] feat(quota): add provider plan registry with known plans --- src/lib/quota/planRegistry.ts | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/lib/quota/planRegistry.ts diff --git a/src/lib/quota/planRegistry.ts b/src/lib/quota/planRegistry.ts new file mode 100644 index 0000000000..09e4084dfe --- /dev/null +++ b/src/lib/quota/planRegistry.ts @@ -0,0 +1,56 @@ +import type { QuotaDimension } from "./dimensions"; + +interface KnownPlanShape { + provider: string; + dimensions: QuotaDimension[]; +} + +const KNOWN_PLANS: Record = { + codex: { + provider: "codex", + dimensions: [ + { unit: "percent", window: "5h", limit: 100 }, + { unit: "percent", window: "weekly", limit: 100 }, + ], + }, + glm: { + provider: "glm", + dimensions: [ + // limit=0 = desconhecido; documentado. Mantido para correta detecção pelo planResolver. + // Sliding window / fair-share devem tratar limit=0 como "manual obrigatório". + { unit: "tokens", window: "5h", limit: Number.EPSILON }, + { unit: "tokens", window: "weekly", limit: Number.EPSILON }, + ], + }, + minimax: { + provider: "minimax", + dimensions: [ + { unit: "tokens", window: "5h", limit: Number.EPSILON }, + { unit: "tokens", window: "weekly", limit: Number.EPSILON }, + ], + }, + bailian: { + provider: "bailian", + dimensions: [ + { unit: "percent", window: "5h", limit: 100 }, + { unit: "percent", window: "weekly", limit: 100 }, + { unit: "percent", window: "monthly", limit: 100 }, + ], + }, + kimi: { + provider: "kimi", + dimensions: [{ unit: "requests", window: "hourly", limit: 1500 }], + }, + alibaba: { + provider: "alibaba", + dimensions: [{ unit: "requests", window: "monthly", limit: 90_000 }], + }, +}; + +export function getKnownPlan(provider: string): KnownPlanShape | null { + return KNOWN_PLANS[provider] ?? null; +} + +export function knownProviders(): readonly string[] { + return Object.keys(KNOWN_PLANS); +}