From 1897d34ce344a44c200d7de41af2923290071ca3 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 10 Oct 2026 20:38:54 +0800 Subject: [PATCH] =?UTF-8?q?devin=200.1.14:=20a=20week=20used=20up=20shows?= =?UTF-8?q?=20at=20100%=20beside=20the=20day,=20and=20holds=20the=20accoun?= =?UTF-8?q?t=20until=20the=20week's=20reset=20(=E9=9D=A2=E6=9D=A1=20on=20m?= =?UTF-8?q?agpie's=20Discord)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Devin plans billed by quota have a daily and a weekly quota. GetUserStatus answers in proto JSON, which leaves a 0 out, so a week with nothing left came as no weeklyQuotaRemainingPercent at all beside the day's 100. usage skipped a window whose share was left out, so the card showed "1 day 0%" alone and magpie's routing, seeing no full window, kept sending to an account Devin refuses until the week resets. On a BILLING_STRATEGY_QUOTA plan a window with a reset time and no share is now used up (100%, its reset kept), so routing holds the account until then. A hidden quota and one with no reset are still not shown, and a plan billed otherwise still has no quota windows from a share left out. usage.test.mjs: the new test (the week left out beside the day's 100, and both left out) fails on 0.1.13 and passes now; the old test that took a left-out share for "no quota" on a quota plan is replaced. HOME=$(mktemp -d) bun test packages/devin: 50 pass, 0 fail. bun scripts/check.mjs devin passes. Against the owner's real Devin Teams account (read-only GetUserStatus): both windows are read as before (1 day 0%, 7 days 1%), so present shares are unchanged. A real account with the week used up wasn't available; the left-out field is how the reporter's card lost its week. --- packages/devin/index.mjs | 13 +++++++++---- packages/devin/package.json | 2 +- packages/devin/usage.test.mjs | 20 ++++++++++++++++++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/devin/index.mjs b/packages/devin/index.mjs index 4eb6d1d..a28ba4c 100644 --- a/packages/devin/index.mjs +++ b/packages/devin/index.mjs @@ -1457,7 +1457,8 @@ function userStatus(key, server) { // and end, the daily and weekly quotas a quota-billed plan has (the share // left of each, and when it comes back), the ACUs a plan with a limit has // used this cycle, and the extra usage balance. JSON leaves out what is -// zero, so a quota with a reset and no share left is used up. magpie's +// zero, so a quota-billed plan's quota with a reset and no share is used +// up. magpie's // built-in Devin account showed none of this. async function usage(key, server) { const res = await userStatus(key, server) @@ -1472,14 +1473,18 @@ async function usage(key, server) { // ("Devin Pro"), as magpie's built-in row said it, not planName's "Pro" const out = { windows: [] } if (st.planEnd) out.until = st.planEnd - // a quota's window is shown when Devin says what is left of it; one it - // leaves out is not taken for used up + // a quota's window is shown when Devin says what is left of it. JSON + // leaves a 0 out, so on a quota-billed plan a window with a reset and no + // share left is used up: a week at 0% left came as no weeklyQuota- + // RemainingPercent beside the day's 100, and the day alone was shown + // (面条 on magpie's Discord). Billed otherwise, a missing share is no quota. + const quota = info.billingStrategy === "BILLING_STRATEGY_QUOTA" for (const [name, span, left, reset, hide] of [ ["1 day", 24 * 3600, st.dailyQuotaRemainingPercent, st.dailyQuotaResetAtUnix, info.hideDailyQuota], ["7 days", 7 * 24 * 3600, st.weeklyQuotaRemainingPercent, st.weeklyQuotaResetAtUnix, info.hideWeeklyQuota], ]) { - if (hide || left === undefined || left === null) continue const at = num(reset) + if (hide || ((left === undefined || left === null) && !(quota && at > 0))) continue out.windows.push({ name, used: Math.min(100, Math.max(0, 100 - num(left))), span, ...(at > 0 ? { resetsAt: at } : {}) }) } const limit = num(st.acuLimit) diff --git a/packages/devin/package.json b/packages/devin/package.json index d95b9ec..f38ded3 100644 --- a/packages/devin/package.json +++ b/packages/devin/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-devin-auth", - "version": "0.1.13", + "version": "0.1.14", "description": "Devin subscriptions (the devin CLI's account) in OpenCode and magpie", "type": "module", "main": "./index.mjs", diff --git a/packages/devin/usage.test.mjs b/packages/devin/usage.test.mjs index beed05f..4c25c58 100644 --- a/packages/devin/usage.test.mjs +++ b/packages/devin/usage.test.mjs @@ -56,8 +56,24 @@ test("a Teams plan: its end, its day and week, the extra usage balance", async ( expect(seen[0].body.metadata).toMatchObject({ ideName: "devin-cli", extensionName: "devin-cli", apiKey: "devin-key", locale: "en" }) }) -test("a quota Devin says nothing left of isn't taken for used up; a hidden one isn't shown; ACUs with a limit are", async () => { - const s = status({ dailyQuotaRemainingPercent: undefined, overageBalanceMicros: undefined, acuConsumed: 12.5, acuLimit: 50 }) +// 面条 on magpie's Discord: Devin has a daily and a weekly quota; with the +// week used up only the day showed, at 0%, and routing kept sending to the +// account. JSON leaves a 0 out, so the week came as no +// weeklyQuotaRemainingPercent beside the day's 100. +test("a week used up, its share left out, shows at 100% and holds until its reset", async () => { + const s = status({ weeklyQuotaRemainingPercent: undefined }) + const { u } = await run(auth, () => new Response(JSON.stringify(s))) + expect(u.windows).toEqual([ + { name: "1 day", used: 0, span: 86400, resetsAt: 1790841600 }, + { name: "7 days", used: 100, span: 604800, resetsAt: 1791100800 }, + ]) + // both used up: both are left out + const both = status({ dailyQuotaRemainingPercent: undefined, weeklyQuotaRemainingPercent: undefined }) + expect((await run(auth, () => Response.json(both))).u.windows.map((w) => w.used)).toEqual([100, 100]) +}) + +test("a hidden quota isn't shown, nor one with no reset; ACUs with a limit are", async () => { + const s = status({ dailyQuotaResetAtUnix: undefined, dailyQuotaRemainingPercent: undefined, weeklyQuotaRemainingPercent: undefined, overageBalanceMicros: undefined, acuConsumed: 12.5, acuLimit: 50 }) s.userStatus.planStatus.planInfo.hideWeeklyQuota = true const { u } = await run({ ...auth, metadata: { ...auth.metadata, server: "https://eu.example" } }, () => Response.json(s)) expect(u).toEqual({