refactor(cliproxy): plugin-based quota probes + GLM/xAI support#89
Conversation
63dd031 to
a593290
Compare
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThis PR refactors the monolithic quota-probing module into a modular architecture with shared utilities, a provider registry, and five provider-specific implementations (Claude, Codex, GLM, Kimi, xAI). It also adds GLM as a supported login provider. ChangesQuota Probing Refactor
GLM Login Provider Support
🎯 3 (Moderate) | ⏱️ ~25 minutes
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
Summary
Refactor the monolithic
src/cliproxy/quota.ts(477 lines) into a plugin registry pattern and add two new provider quota probes.Changes
Structural refactoring
AuthFile,ProbeResult,ProbeWindow,ProbeFn) intoquota/types.tsnormalizePercent,normalizeReset,fetchJson, etc.) intoquota/helpers.tsif/elsedispatch withMap<string, ProbeFn>registry +registerProbe()probeClaude,probeCodex,probeKimiinto individual files underquota/probes/New providers
probes/glm.ts): Probesapi.z.ai/api/monitor/usage/quota/limit— parsesTIME_LIMITandTOKENS_LIMITentries into standardized windowsprobes/xai.ts): Uses xAI Management API (management-api.x.ai) — combines prepaid balance + spending limits + invoice preview into monthly spend utilizationAdding a new provider (3 steps)
src/cliproxy/quota/probes/xxx.tsexporting aProbeFnregisterProbe("xxx", probeXxx)inquota/index.tslogin.ts(if OAuth-based)File structure
Verification
bun run typecheck✅bun test— 246 pass, 0 fail ✅bun run build✅Summary by cubic
Refactored quota probing into a plugin registry and added GLM and xAI provider probes. This simplifies adding providers and enables xAI monthly spend visibility.
Refactors
src/cliproxy/quota.tswithquota/registry (registerProbe()), plus sharedtypes.tsandhelpers.ts.quota/probes/*and dispatch viaMap<string, ProbeFn>.New Features
api.z.ai/api/monitor/usage/quota/limit) parsingTIME_LIMITandTOKENS_LIMITinto standardized windows.glmCLI login flag inlogin.ts(-glm-login).Written for commit a593290. Summary will update on new commits.
Review in cubic
Summary by CodeRabbit