zcode 0.1.5: the month's MCP tool calls are set aside as 'MCP · Month', as the built-in's quota did, not counted as a window — an older plan reports that uncapped month as 100% used, which read the account as out of quota and skipped it; a limit whose whole is 0 is set aside too. The new test in usage.test.mjs fails against 0.1.4.
This commit is contained in:
@@ -78,7 +78,7 @@ test("windows, names and terms as Go reads them", () => {
|
||||
{ name: "Weekly", used: 25, display: "200 / 800", span: 604800 },
|
||||
{ name: "0 hours", used: 7.5, span: 1800 },
|
||||
{ name: "3 days", used: 0, span: 3 * 86400 },
|
||||
{ name: "Monthly", used: 0, span: 30 * 86400 },
|
||||
{ name: "Monthly", used: 0, aside: true, span: 30 * 86400 }, // a whole of 0: no cap
|
||||
{ name: "Credits", used: 0 },
|
||||
])
|
||||
// Beijing times: the next renewal, auto or not; else the valid span's end
|
||||
@@ -91,6 +91,32 @@ test("windows, names and terms as Go reads them", () => {
|
||||
expect(_internal.termOf([{ status: "VALID", valid: "2026-09-18 - 2026-10-18" }])).toEqual({ until: "2026-10-17T16:00:00.000Z", renew: "off" })
|
||||
})
|
||||
|
||||
// Go's TestZCodeNoMonthlyCap (#366): the month's MCP tool calls are named
|
||||
// and set aside as the built-in's are, so an older plan's uncapped month,
|
||||
// told as 100% used, never reads as the account run out
|
||||
test("the month's MCP calls: named and set aside, an uncapped month nothing used", () => {
|
||||
const reset = Date.now() + 3 * 3600_000
|
||||
const month = Date.now() + 20 * 86400_000
|
||||
expect(_internal.limitWindows({ level: "pro", limits: [
|
||||
{ type: "TOKENS_LIMIT", unit: 3, number: 5, percentage: 0, nextResetTime: reset },
|
||||
{ type: "TIME_LIMIT", unit: 5, number: 1, usage: 0, currentValue: 0, remaining: 0, percentage: 100, nextResetTime: month },
|
||||
] })).toEqual([
|
||||
{ name: "5 hours", used: 0, resetsAt: new Date(reset).toISOString(), span: 5 * 3600 },
|
||||
{ name: "MCP · Month", used: 0, aside: true, resetsAt: new Date(month).toISOString(), span: 30 * 86400 },
|
||||
])
|
||||
// capped and used up: still shown as used, still aside
|
||||
const ws = _internal.limitWindows({ limits: [
|
||||
{ type: "TOKENS_LIMIT", unit: 3, number: 5, percentage: 10, nextResetTime: reset },
|
||||
{ type: "TOKENS_LIMIT", unit: 6, number: 1, percentage: 30, nextResetTime: month },
|
||||
{ type: "TIME_LIMIT", unit: 5, number: 1, usage: 100, currentValue: 100, remaining: 0, percentage: 100, nextResetTime: month },
|
||||
] })
|
||||
expect(ws.map((w) => [w.name, w.used, !!w.aside, w.display])).toEqual([
|
||||
["5 hours", 10, false, undefined],
|
||||
["Weekly", 30, false, undefined],
|
||||
["MCP · Month", 100, true, "100 / 100"],
|
||||
])
|
||||
})
|
||||
|
||||
// a Start Plan with one bucket, GLM-5.1's tokens for the day, a quarter used
|
||||
function startBalance(now, status) {
|
||||
return { server_time: now, plans: [{ plan_id: "zai-start-plan", user_plan_id: "up1", name: "Start Plan", status, ends_at: now + 7 * 86400,
|
||||
|
||||
Reference in New Issue
Block a user