Bug
The extension throws UsageError: Required TOKENS_LIMIT entries (5h + weekly) not found in API response when using a Z.ai lite plan.
Cause
Lite plans (level: "lite") only return two quota buckets:
TOKENS_LIMIT unit 3 (5-hour)
TIME_LIMIT unit 5 (monthly)
There is no weekly TOKENS_LIMIT (unit 6). The code in dist/api.js requires both:
if (!fiveHourLimit || !weeklyLimit) {
throw new UsageError("Required TOKENS_LIMIT entries (5h + weekly) not found in API response", "nolimit");
}
API response (lite plan)
{
"data": {
"limits": [
{ "type": "TIME_LIMIT", "unit": 5, "percentage": 0 },
{ "type": "TOKENS_LIMIT", "unit": 3, "percentage": 11 }
],
"level": "lite"
}
}
Fix
Make weeklyLimit optional — same as monthlyLimit already is:
if (!fiveHourLimit) {
throw new UsageError("Required TOKENS_LIMIT entry (5h) not found in API response", "nolimit");
}
And guard the weekly render block in dist/index.js:
Environment
- Extension version: 0.3.6 / 0.3.7
- Plan: ZAI Coding Plan (Global), level: lite
- Models: glm-4.5-air, glm-5v-turbo (all via zai provider)
Fork with fix: https://github.com/recurut001/pi-zai-usage
Bug
The extension throws
UsageError: Required TOKENS_LIMIT entries (5h + weekly) not found in API responsewhen using a Z.ai lite plan.Cause
Lite plans (level:
"lite") only return two quota buckets:TOKENS_LIMITunit 3 (5-hour)TIME_LIMITunit 5 (monthly)There is no weekly
TOKENS_LIMIT(unit 6). The code indist/api.jsrequires both:API response (lite plan)
{ "data": { "limits": [ { "type": "TIME_LIMIT", "unit": 5, "percentage": 0 }, { "type": "TOKENS_LIMIT", "unit": 3, "percentage": 11 } ], "level": "lite" } }Fix
Make
weeklyLimitoptional — same asmonthlyLimitalready is:And guard the weekly render block in
dist/index.js:Environment
Fork with fix: https://github.com/recurut001/pi-zai-usage