@magpie-community/opencode-cursor-auth 0.2.9 → 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.
- package/README.md +4 -1
- package/index.mjs +14 -6
- 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
|
|
401
|
-
|
|
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
|
-
|
|
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
|
|
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)}
|
|
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
|
: []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-cursor-auth",
|
|
3
|
-
"version": "0.2.
|
|
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",
|