mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-17 12:22:34 +03:00
* feat(usage): devin-cli agentic quota + openrouter credits in Provider Limits Two provider families with live quota APIs were missing from the Provider Limits dashboard because their list entries were absent: - devin-cli: new usage leaf querying the Codeium seat-management Connect API (exa.seat_management_pb.SeatManagementService/GetUserStatus, protobuf over POST with the raw `Basic <token>-<token>` auth header the CLI itself uses). Surfaces the plan name plus daily/weekly agentic quota percentages with reset timestamps from the GetUserStatus plan_status payload, via a minimal hand-rolled protobuf encoder/reader (no proto dependency warranted for two fixed messages). - openrouter: the /key + /credits quota fetcher (#6842) was already wired into the dispatcher but gated out of the bulk sync — add it to USAGE_SUPPORTED_PROVIDERS and PROVIDER_LIMITS_APIKEY_PROVIDERS so key limits and account credits actually surface. * fix(build): externalize tiktoken so tiktoken_bg.wasm resolves at runtime The vendored ChatGPT Web connector v4.0.7 (#12181) imports tiktoken (get_encoding) at module level. tiktoken's node build reads tiktoken_bg.wasm via a __dirname-relative fs.readFileSync during import; when Next bundles the package the wasm asset is not traced into the server chunk, and page-data collection for every route reaching the tokenizer (e.g. /api/providers/[id]/chatgpt-web-codex-doctor) aborts with "Missing tiktoken_bg.wasm" — breaking the whole standalone build. Externalize it like the other runtime-resolved native/wasm packages (sql.js, sqlite-vec, better-sqlite3): the require stays at runtime, where node_modules/tiktoken/tiktoken_bg.wasm resolves normally. * fix(openrouter): /credits balance survives a /key failure OpenRouter is credit-based, not subscription-based: the authoritative remaining-credits signal is GET /api/v1/credits (total_credits - total_usage, the documented "get remaining credits" endpoint), while the /key limit fields are optional per-key caps that most accounts never set. fetchOpenrouterQuota previously treated /key as mandatory — any /key failure (429 rate limit, transient error, unexpected shape) discarded the whole payload and the Usage dashboard showed "OpenRouter (usage endpoint unreachable)" even though /credits was reachable. Now: - /key unavailable + /credits OK → credits-only quota (creditBalance = total_credits - total_usage) instead of null - /key 401/403 alone no longer means an invalid token; only a double auth-rejection (both endpoints) does - null is returned only when both endpoints fail, and the dashboard label reflects that ("credits endpoint unreachable") * fix(openrouter): render AI Credits as a USD credit count in Provider Limits The Provider Limits card's dollar renderer only activates on isCredits/creditCount rows (QuotaCardExpanded), but openrouter went through parseGeneric — which drops `currency` and never sets those flags — so the credits balance rendered as a meaningless "100% left" (the unlimited-credits row is always 100%) instead of the actual credit count. Route openrouter's `credits` quota through buildCreditsQuota() like the DeepSeek/AgentRouter credits rows: label "AI Credits", dollar-formatted balance. Free-tier request windows keep the generic percentage treatment. * fix(usage): document DEVIN_SEAT_API_URL and split quota parsers Keep fetchOpenrouterQuota and decodeProtoFields under the complexity ratchets, and add the seat-management URL to the env/docs contract. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> * test(usage): drop duplicated GLM quota-ordering test in provider-limits-ui * test(usage): drop stale openrouter ACCEPTED_DIVERGENCE OpenRouter is now in both USAGE_FETCHER_PROVIDERS and USAGE_SUPPORTED_PROVIDERS, so the recorded aggregator divergence is no longer real. Add the changelog fragment. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>
84 lines
2.8 KiB
TypeScript
84 lines
2.8 KiB
TypeScript
/**
|
|
* usage/supportedProviders.ts — registration list of providers whose usage/quota
|
|
* API is accepted by the dashboard and server routes.
|
|
*
|
|
* Extracted from `src/shared/constants/providers.ts` so that light consumers —
|
|
* the provider-plugin manifest (`config/providerPluginManifest.ts`) above all —
|
|
* can read the list without pulling the ~12-module provider registry, and
|
|
* without an open-sse module reaching across the workspace boundary into
|
|
* `src/` (the open-sse typecheck gate forbids open-sse → src imports). Same
|
|
* pattern as `fetcherProviders.ts` (#11903): pure data — no imports, no module
|
|
* state — so it cannot introduce a cycle. `src/shared/constants/providers.ts`
|
|
* re-exports the value, so every existing `@/shared/constants/providers`
|
|
* import path keeps working unchanged.
|
|
*
|
|
* Typed `readonly string[]` (not `as const`): the dashboard/server gates call
|
|
* `USAGE_SUPPORTED_PROVIDERS.includes(providerId)` with a plain `string`, which
|
|
* a literal-tuple type would reject (TS2345).
|
|
*/
|
|
|
|
// Providers that support usage/quota API
|
|
export const USAGE_SUPPORTED_PROVIDERS: readonly string[] = [
|
|
"antigravity",
|
|
"agy",
|
|
"kiro",
|
|
"amazon-q",
|
|
"github",
|
|
"codex",
|
|
"claude",
|
|
"cursor",
|
|
"qoder",
|
|
"kimi-coding",
|
|
"kimi-coding-apikey",
|
|
"glm",
|
|
"glm-cn",
|
|
"zai",
|
|
"glmt",
|
|
"opencode-go",
|
|
"ollama-cloud",
|
|
"minimax",
|
|
"minimax-cn",
|
|
"crof",
|
|
"nanogpt",
|
|
"deepseek",
|
|
"xiaomi-mimo",
|
|
"xiaomi-mimo-token-plan",
|
|
"vertex",
|
|
"vertex-partner",
|
|
"codebuddy-cn",
|
|
// PromptQL playground credits (getCreditSummary → USD micros)
|
|
"promptql",
|
|
"pql",
|
|
// Adobe Firefly web (cookie/JWT as apikey) — GET firefly.adobe.io/v1/credits/balance
|
|
"adobe-firefly",
|
|
"firefly",
|
|
"hyperagent",
|
|
"ha",
|
|
// xAI OAuth (Grok) weekly quota (id + public alias, same pattern as ha/agy)
|
|
"xai-oauth",
|
|
"xao",
|
|
// Grok Build subscription, billing credits, and auto top-up status
|
|
"grok-cli",
|
|
// Firecrawl team credits (GET /v2/team/credit-usage)
|
|
"firecrawl",
|
|
// Volcano Ark Plan subscriptions (agent-plan / coding-plan)
|
|
"volcengine-agent-plan",
|
|
"volcengine-coding-plan",
|
|
// Command Code credits + 5h/weekly rolling windows
|
|
"command-code",
|
|
"conol-web",
|
|
"cnl",
|
|
// Alibaba Coding Plan triple-window quota (#9603 UI gap — fetcher existed, list entry missing)
|
|
"bailian-coding-plan",
|
|
// Qwen Cloud / Model Studio personal Token Plan (cookie-authenticated console gateway)
|
|
"qwen-cloud-token-plan",
|
|
// AgentRouter (New-API) console balance quota (consoleApiKey + newApiUserId)
|
|
"agentrouter",
|
|
// Kilo Code personal USD balance (GET /api/profile/balance, existing OAuth token)
|
|
"kilocode",
|
|
// OpenRouter key limits + account credits (GET /api/v1/key + /api/v1/credits)
|
|
"openrouter",
|
|
// Devin CLI agentic quota (Codeium seat-management GetUserStatus, protobuf)
|
|
"devin-cli",
|
|
];
|