@magpie-community/opencode-cursor-auth 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -1
  2. package/index.mjs +21 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -140,7 +140,10 @@ team or personal spend limit, as `cursor-agent`'s usage view shows it) also
140
140
  shows On-demand: its spend, and its limit when it has one. Cursor keeps
141
141
  serving such an account past the included usage, so magpie doesn't count
142
142
  it used up when Cursor Models or Other Models reach 100%; it does when the
143
- on-demand spend reaches its limit.
143
+ on-demand spend reaches its limit. A team member with no limit of their
144
+ own spends the team's pool: On-demand shows the pool's spend and limit,
145
+ with the member's own spend beside it, and the account is used up when
146
+ the pool is.
144
147
 
145
148
  Sign in to the Cursor account linked in Grok Bot. A linked SuperGrok
146
149
  subscription grants Bot access without a paid Cursor plan; see
package/index.mjs CHANGED
@@ -385,7 +385,10 @@ function firstParty(model) {
385
385
  // period's spendLimitUsage (cents) and, where that sets no limit of the
386
386
  // user's, GetHardLimit's reply (dollars; undefined when it couldn't be
387
387
  // read). kind is "fixed" (up to limitDollars), "unlimited", "disabled" or
388
- // "unavailable" (not known).
388
+ // "unavailable" (not known). A team member with no limit of their own
389
+ // spends the team's pool, which cursor-agent's view calls unlimited but
390
+ // which runs out at pooledLimit for the whole team (magpie #1868): that is
391
+ // a fixed limit on the pool's spend, with the member's own in mineDollars.
389
392
  function onDemandOf(data, hard) {
390
393
  const s = data?.spendLimitUsage
391
394
  const usedDollars = Number(s?.individualUsed ?? 0) / 100
@@ -397,8 +400,11 @@ function onDemandOf(data, hard) {
397
400
  : { kind: "disabled", usedDollars }
398
401
  if (s?.limitType === "team") {
399
402
  if (own) return own
400
- if (hard) return hard.noUsageBasedAllowed || !(Number(hard.hardLimit) > 0) ? { kind: "disabled", usedDollars } : { kind: "unlimited", usedDollars }
401
- return Number(s.pooledLimit ?? 0) > 0 ? { kind: "unlimited", usedDollars } : { kind: "unavailable", usedDollars }
403
+ if (hard && (hard.noUsageBasedAllowed || !(Number(hard.hardLimit) > 0))) return { kind: "disabled", usedDollars }
404
+ // pooledLimit and pooledRemaining come as int64 strings, pooledUsed as a number
405
+ const pool = Number(s.pooledLimit ?? 0)
406
+ if (pool > 0) return { kind: "fixed", usedDollars: Number(s.pooledUsed ?? 0) / 100, limitDollars: pool / 100, mineDollars: usedDollars }
407
+ return hard ? { kind: "unlimited", usedDollars } : { kind: "unavailable", usedDollars }
402
408
  }
403
409
  if (!hard) return own ?? { kind: "unavailable", usedDollars }
404
410
  if (hard.noUsageBasedAllowed) return { kind: "disabled", usedDollars }
@@ -422,7 +428,8 @@ async function hardLimit(tok) {
422
428
  }
423
429
  }
424
430
 
425
- const dollars = (n) => "$" + n.toFixed(2)
431
+ // dollars, thousands grouped: a team's pool runs to six figures ($451,200.00)
432
+ const dollars = (n) => "$" + n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
426
433
 
427
434
  // usage is the account's windows this billing period; an enterprise plan
428
435
  // reports spend instead, and gets none. ids are the models it can be
@@ -430,7 +437,8 @@ const dollars = (n) => "$" + n.toFixed(2)
430
437
  // may spend on-demand once its included usage is gone (fottencity on
431
438
  // Discord: a team that pays for more) is still served when the pools are
432
439
  // spent, so they are shown aside, and its On-demand spend is what can run
433
- // out: at its limit, or never when it has none.
440
+ // out: at its limit (a team member with none of their own: the team's
441
+ // pool), or never when it has none.
434
442
  async function usage(tok, ids) {
435
443
  const [res, hard] = await Promise.all([
436
444
  fetch(API + "/aiserver.v1.DashboardService/GetCurrentPeriodUsage", {
@@ -467,7 +475,7 @@ async function usage(tok, ids) {
467
475
  const pooled = od.kind === "fixed" || od.kind === "unlimited" ? { aside: true } : {}
468
476
  const onDemand =
469
477
  od.kind === "fixed"
470
- ? [{ name: "On-demand", used: Math.max(0, Math.min(100, (100 * od.usedDollars) / od.limitDollars)), display: `${dollars(od.usedDollars)} / ${dollars(od.limitDollars)}`, ...resets }]
478
+ ? [{ name: "On-demand", used: Math.max(0, Math.min(100, (100 * od.usedDollars) / od.limitDollars)), display: `${dollars(od.usedDollars)} / ${dollars(od.limitDollars)}` + (od.mineDollars === undefined ? "" : ` (you: ${dollars(od.mineDollars)})`), ...resets }]
471
479
  : od.kind === "unlimited"
472
480
  ? [{ name: "On-demand", used: 0, display: dollars(od.usedDollars), ...resets, aside: true }]
473
481
  : []
@@ -723,17 +731,20 @@ function pick(entry, effort, fast, seed) {
723
731
  // without thinking stops at high), the variant with those parameters at the
724
732
  // nearest effort it has, not the default's id with parameters that
725
733
  // contradict it (claude-opus-5-thinking-high with thinking=false). Where
726
- // the default differs from what is asked in the effort alone, the effort
727
- // goes as asked, as for a listed model.
734
+ // the default differs from what is asked in the effort alone, and no
735
+ // variant at all is named for that effort, the effort goes as asked, as for
736
+ // a listed model (claude-opus-5-5-xhigh). When another branch has it, the
737
+ // default's own branch stops short there, and its nearest goes (#55).
728
738
  function branch(entry, want) {
729
739
  if (!entry.pid || entry.pid === "thinking") return undefined
740
+ const level = (x) => (x === "extra-high" ? "xhigh" : x)
730
741
  const def = valuesOf(entry.def)
731
- if (Object.keys(want).every((k) => k === entry.pid || k === "context" || def[k] === undefined || def[k] === want[k])) return undefined
742
+ const named = entry.variants.some((v) => level(valuesOf(v)[entry.pid]) === level(want[entry.pid]))
743
+ if (!named && Object.keys(want).every((k) => k === entry.pid || k === "context" || def[k] === undefined || def[k] === want[k])) return undefined
732
744
  const vs = entry.variants.filter((v) => {
733
745
  const have = valuesOf(v)
734
746
  return entry.pid in have && Object.keys(want).every((k) => k === entry.pid || have[k] === undefined || have[k] === want[k])
735
747
  })
736
- const level = (x) => (x === "extra-high" ? "xhigh" : x)
737
748
  const at = fitEffort(level(want[entry.pid]), vs.map((v) => level(valuesOf(v)[entry.pid])))
738
749
  return at ? vs.find((v) => level(valuesOf(v)[entry.pid]) === at) : undefined
739
750
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-cursor-auth",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Cursor subscriptions (Pro, Pro+, Ultra, Teams) in OpenCode and magpie, through the API cursor-agent talks to",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",