cursor 0.2.32: a merged (newer) plan's included usage is one Weekly window for every model, no Other Models
majiang_ai on X: Cursor's newer plans have no third-party-model pool, while magpie's card still showed Cursor Models, Other Models and Total. What Cursor says: GetPlanInfo answers isMerged true and planInfo.includedUsagePeriod INCLUDED_USAGE_PERIOD_WEEKLY for such a plan (enum 1 MONTHLY, 2 WEEKLY, from cursor-agent 2026.10.22's proto), and GetCurrentPeriodUsage's billing cycle is then the week, with autoPercentUsed == totalPercentUsed and apiPercentUsed 0. The dashboard's usage page (cursor.com/v2/usage, chunk read on 10-29) draws one meter, "Weekly usage limit", from the period's totalPercentUsed. Now planOf reads isMerged and the period with the plan name (same hourly cache, last good answer kept). A merged plan's usage is one window, Weekly (span 7d; Monthly on a monthly merged plan, Included when not said), with no models list, so it counts every model; On-demand and Grok Bot as before; no Other Models or Total. A plan GetPlanInfo can't read, or isMerged false, keeps the two pools. Run: - HOME=$(mktemp -d) bun test (whole repo, on mote): 3229 pass, 8 skip, 0 fail - bun scripts/check.mjs: ok - Broken by hand: the merged branch turned off, 5 of the 6 new tests red (the 6th checks the unmerged case still has the pools). - Real account (owner's Cursor, a merged Premium plan, keychain token, read-only calls): the published 0.2.31 shows Cursor Models 7%, Other Models 0%, Total 7%; this change shows Weekly 7% (resets 11-03), Grok Bot, On-demand. Not tried: an old (unmerged) plan's real account; none is at hand, the unmerged path is unchanged and covered by the existing tests. A merged monthly plan was not seen for real.
This commit is contained in:
@@ -240,6 +240,11 @@ go without the list for 5 minutes instead of each waiting for it again.
|
||||
## Usage
|
||||
|
||||
magpie shows Cursor Models, Other Models and Total for the billing period.
|
||||
A plan of Cursor's merged billing (`GetPlanInfo`'s `isMerged`, the newer
|
||||
plans) has no Other Models pool: its included usage is one allowance every
|
||||
model draws on, as the dashboard's "Weekly usage limit" shows it. magpie
|
||||
shows that as one window, Weekly (Monthly on a monthly plan), for every
|
||||
model.
|
||||
Accounts with a Grok Bot allowance also show its usage and reset time;
|
||||
active trials are labelled separately. A spent Bot allowance doesn't stop
|
||||
Cursor requests.
|
||||
@@ -273,8 +278,8 @@ In magpie, open the Cursor provider, turn on **Included usage only** under
|
||||
applies to every Cursor account, and takes effect at each account's next
|
||||
usage reading.
|
||||
|
||||
When on, Cursor Models and Other Models (an Enterprise account's allowance)
|
||||
are what keep an account in routing: once one is used up, magpie moves its
|
||||
When on, Cursor Models and Other Models (a merged plan's Weekly, an
|
||||
Enterprise account's allowance) are what keep an account in routing: once one is used up, magpie moves its
|
||||
models to the next account until the period resets, even when on-demand
|
||||
could still pay for them. On-demand and Total are still shown but never
|
||||
keep an account in routing. Use it when on-demand is a shared or paid pool
|
||||
|
||||
@@ -316,18 +316,27 @@ async function whoIs(tok) {
|
||||
|
||||
// plans are the plan each token's account is on, as `cursor-agent about`
|
||||
// names it (GetPlanInfo's planName, magpie's card title), asked again after
|
||||
// an hour.
|
||||
// an hour. merged is GetPlanInfo's isMerged: a plan of Cursor's merged
|
||||
// (xAI) billing, whose included usage is one allowance for every model,
|
||||
// most of them a week long (includedUsagePeriod), and has no Other Models
|
||||
// pool (majiang_ai on X). The dashboard's usage page shows such a plan one
|
||||
// meter, the period's totalPercentUsed. period is "weekly", "monthly" or
|
||||
// "" (not said). A reply that couldn't be read keeps the last one, else
|
||||
// says nothing: undefined merged, which the pools are kept for.
|
||||
const plans = new Map()
|
||||
const PLAN_TTL = 3600_000
|
||||
const PERIODS = { INCLUDED_USAGE_PERIOD_WEEKLY: "weekly", INCLUDED_USAGE_PERIOD_MONTHLY: "monthly", 1: "monthly", 2: "weekly" }
|
||||
async function planOf(tok) {
|
||||
const had = plans.get(tok)
|
||||
if (had && Date.now() - had.at < PLAN_TTL) return had.plan
|
||||
if (had && Date.now() - had.at < PLAN_TTL) return had
|
||||
try {
|
||||
const plan = String((await unary(API, "aiserver.v1.DashboardService/GetPlanInfo", tok))?.planInfo?.planName ?? "").trim()
|
||||
if (plan) plans.set(tok, { plan, at: Date.now() })
|
||||
return plan || had?.plan || ""
|
||||
const info = await unary(API, "aiserver.v1.DashboardService/GetPlanInfo", tok)
|
||||
const plan = String(info?.planInfo?.planName ?? "").trim()
|
||||
const got = { plan: plan || had?.plan || "", merged: info?.isMerged === true, period: PERIODS[info?.planInfo?.includedUsagePeriod] ?? "", at: Date.now() }
|
||||
if (plan || got.merged) plans.set(tok, got)
|
||||
return got
|
||||
} catch {
|
||||
return had?.plan ?? ""
|
||||
return had ?? { plan: "" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,7 +626,9 @@ async function enterpriseUsage(tok, includedOnly = false) {
|
||||
// the pools are the allowance whatever on-demand allows, and On-demand is
|
||||
// shown only. An Enterprise account's period has no planUsage; its
|
||||
// allowance comes from usage-summary instead.
|
||||
async function usage(tok, ids, includedOnly = false) {
|
||||
// plan is planOf's answer, asked alongside (a promise): a merged plan's
|
||||
// included usage is one window, Weekly on a weekly plan, for every model.
|
||||
async function usage(tok, ids, includedOnly = false, plan = undefined) {
|
||||
const [res, hard] = await Promise.all([
|
||||
fetch(API + "/aiserver.v1.DashboardService/GetCurrentPeriodUsage", {
|
||||
method: "POST",
|
||||
@@ -661,6 +672,19 @@ async function usage(tok, ids, includedOnly = false) {
|
||||
: od.kind === "unlimited"
|
||||
? [{ name: "On-demand", used: 0, display: dollars(od.usedDollars), ...resets, aside: true }]
|
||||
: []
|
||||
// A merged plan has no pools: its included usage is one allowance every
|
||||
// model draws on, which the dashboard shows as the period's
|
||||
// totalPercentUsed, autoPercentUsed the same and apiPercentUsed 0 always.
|
||||
const info = await plan
|
||||
if (info?.merged === true) {
|
||||
const weekly = info.period === "weekly"
|
||||
return {
|
||||
windows: [
|
||||
{ name: weekly ? "Weekly" : info.period === "monthly" ? "Monthly" : "Included", used: num(u.totalPercentUsed), ...resets, ...(weekly ? { span: 604800 } : {}), ...pooled },
|
||||
...onDemand,
|
||||
],
|
||||
}
|
||||
}
|
||||
// the two pools fit the line; the total goes in its tooltip
|
||||
return {
|
||||
windows: [
|
||||
@@ -3233,7 +3257,7 @@ export async function CursorAuthPlugin(input) {
|
||||
key: INCLUDED_ONLY,
|
||||
label: "Included usage only",
|
||||
description:
|
||||
"Keeps an account in routing only while its included usage lasts: once Cursor Models or Other Models is used up, magpie moves those models to the next account until the period resets, even if on-demand could pay. On-demand and Total are still shown but never keep an account in routing.",
|
||||
"Keeps an account in routing only while its included usage lasts: once an included pool (Cursor Models, Other Models, a newer plan's Weekly) is used up, magpie moves its models to the next account until it resets, even if on-demand could pay. On-demand and Total never keep an account in routing.",
|
||||
},
|
||||
],
|
||||
// magpie's: how much of the plan's included usage is gone (the plan
|
||||
@@ -3246,7 +3270,8 @@ export async function CursorAuthPlugin(input) {
|
||||
} catch (e) {
|
||||
return { error: e.message, windows: [], signIn: "kept" }
|
||||
}
|
||||
const [u, plan, bot] = await Promise.all([usage(tok, Object.keys(provider?.models ?? {}), includedOnly()), planOf(tok), botUsage(tok)])
|
||||
const info = planOf(tok)
|
||||
const [u, { plan }, bot] = await Promise.all([usage(tok, Object.keys(provider?.models ?? {}), includedOnly(), info), info, botUsage(tok)])
|
||||
// Bot goes among magpie's three menu-bar rings: before Total, and
|
||||
// before an On-demand with no limit, which is only a dollar figure on
|
||||
// a ring that never fills (magpie #2213, Morganwan90). An On-demand
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-cursor-auth",
|
||||
"version": "0.2.31",
|
||||
"version": "0.2.32",
|
||||
"description": "Cursor subscriptions (Pro, Pro+, Ultra, Teams) in OpenCode and magpie, through the API cursor-agent talks to",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
@@ -471,3 +471,62 @@ test("Bot is among the first three windows ahead of an On-demand with no limit,
|
||||
const capped = (await botOnDemand({ ...spent, spendLimitUsage: { individualUsed: 500, limitType: "user" } }, { hardLimit: 20 })).u
|
||||
expect(capped.windows.map((w) => w.name)).toEqual(["Cursor Models", "Other Models", "On-demand", "Grok Bot", "Total"])
|
||||
})
|
||||
|
||||
// majiang_ai on X: a plan of Cursor's merged (xAI) billing has no Other
|
||||
// Models pool. Its included usage is one allowance for every model, which
|
||||
// the dashboard's usage page shows as one meter, "Weekly usage limit", the
|
||||
// period's totalPercentUsed. The replies are a real Premium account's
|
||||
// (2026-10-29), its autoBucketModels cut short.
|
||||
const mergedPlan = { planInfo: { planName: "Premium", price: "", billingCycleEnd: "1794547141340", includedUsagePeriod: "INCLUDED_USAGE_PERIOD_WEEKLY", includedUsageResetsAt: "1793683212396" }, isMerged: true }
|
||||
const mergedPeriod = {
|
||||
billingCycleStart: "1793078412396",
|
||||
billingCycleEnd: "1793683212396",
|
||||
planUsage: { remainingBonus: false, autoPercentUsed: 21.9, apiPercentUsed: 0, totalPercentUsed: 21.9 },
|
||||
spendLimitUsage: { limitType: "user" },
|
||||
enabled: true,
|
||||
autoBucketModels: ["default", "composer-2.5", "grok-4.7"],
|
||||
}
|
||||
const weekEnd = new Date(1793683212396).toISOString()
|
||||
|
||||
test("a merged plan's included usage is one Weekly window for every model, with no Other Models", async () => {
|
||||
const { u } = await run(fresh(), (url) => (url === PLAN ? Response.json(mergedPlan) : url === HARD ? Response.json({ noUsageBasedAllowed: true }) : Response.json(mergedPeriod)))
|
||||
expect(u.plan).toBe("Premium")
|
||||
expect(u.windows).toEqual([{ name: "Weekly", used: 21.9, resetsAt: weekEnd, span: 604800 }])
|
||||
for (const m of [...firstParty, ...others]) expect([m, counts(u.windows[0], m)]).toEqual([m, true])
|
||||
})
|
||||
|
||||
test("a merged plan whose period is a month says Monthly, and a numeric enum is read too", async () => {
|
||||
const { u } = await run(fresh(), (url) =>
|
||||
url === PLAN ? Response.json({ ...mergedPlan, planInfo: { ...mergedPlan.planInfo, includedUsagePeriod: 1 } }) : url === HARD ? Response.json({ noUsageBasedAllowed: true }) : Response.json(mergedPeriod),
|
||||
)
|
||||
expect(u.windows).toEqual([{ name: "Monthly", used: 21.9, resetsAt: weekEnd }])
|
||||
})
|
||||
|
||||
test("a merged plan that may spend on-demand keeps its Weekly aside and shows the On-demand", async () => {
|
||||
const { u } = await run(fresh(), (url) => (url === PLAN ? Response.json(mergedPlan) : url === HARD ? Response.json({ hardLimit: 50 }) : Response.json({ ...mergedPeriod, spendLimitUsage: { limitType: "user", individualUsed: 1000 } })))
|
||||
expect(u.windows).toEqual([
|
||||
{ name: "Weekly", used: 21.9, resetsAt: weekEnd, span: 604800, aside: true },
|
||||
{ name: "On-demand", used: 20, display: "$10.00 / $50.00", resetsAt: weekEnd },
|
||||
])
|
||||
})
|
||||
|
||||
test("a merged plan's Grok Bot goes after its Weekly", async () => {
|
||||
const a = botAuth()
|
||||
const { u } = await run(a, (url) => (url === PLAN ? Response.json(mergedPlan) : url === BOT ? Response.json(paidBot) : url === HARD ? Response.json({ noUsageBasedAllowed: true }) : Response.json(mergedPeriod)))
|
||||
expect(u.windows.map((w) => w.name)).toEqual(["Weekly", "Grok Bot"])
|
||||
})
|
||||
|
||||
test("an unmerged plan, or one GetPlanInfo can't say, keeps the two pools", async () => {
|
||||
for (const plan of [{ planInfo: { planName: "Ultra", includedUsagePeriod: "INCLUDED_USAGE_PERIOD_MONTHLY" }, isMerged: false }, new Response("no", { status: 500 })]) {
|
||||
const { u } = await run(fresh(), (url) => (url === PLAN ? (plan instanceof Response ? plan : Response.json(plan)) : Response.json(mergedPeriod)))
|
||||
expect(u.windows.map((w) => w.name)).toEqual(["Cursor Models", "Other Models", "Total"])
|
||||
}
|
||||
})
|
||||
|
||||
test("a merged plan read once is kept for the hour, not asked again", async () => {
|
||||
const a = fresh()
|
||||
await run(a, (url) => (url === PLAN ? Response.json(mergedPlan) : Response.json(mergedPeriod)))
|
||||
const { u, seen } = await run(a, (url) => (url === PLAN ? new Response("no", { status: 500 }) : Response.json(mergedPeriod)))
|
||||
expect(seen.map((r) => r.url)).not.toContain(PLAN)
|
||||
expect(u.windows.map((w) => w.name)).toEqual(["Weekly"])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user