@magpie-community/opencode-workbuddy-auth 0.2.21 → 0.2.22

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 +16 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -359,7 +359,10 @@ credit packs) and platform rewards (gifted and activity credits,
359
359
  against plan_bonus, addon and benefit); a summary without them is split
360
360
  by package code as WorkBuddy's client does. Only one of the two stops the
361
361
  account, since WorkBuddy serves it while any credits are left: the extra
362
- window is set aside until the plan's credits are spent. A summary with
362
+ window is set aside until the plan's credits are spent, then the plan's
363
+ is. Extra credits only the detail lists carry (a China-site free
364
+ account's summary can list the plan's base alone) are their own "Extra
365
+ credits" window by the same rule (ferock on Discord). A summary with
363
366
  only one kind keeps the one "Credits" window (akic404 on Discord; since
364
367
  0.2.16 the plan's bonus is extra too, Jiabubu on Discord).
365
368
 
package/index.mjs CHANGED
@@ -3903,24 +3903,30 @@ function makePlugin(site) {
3903
3903
  const aside = extra ? (stops === credits ? extra : credits) : null
3904
3904
  if (aside) Object.assign(aside, runsOutOf(sum, packages, Date.now(), (code) => ofPlan(code) === (aside === credits)) ?? {})
3905
3905
  // the summary of the plan's credits alone: the extra ones
3906
- // only the detail lists have (listedExtra) are their window,
3907
- // always set aside. Whether WorkBuddy spends them once the
3908
- // plan's are gone isn't seen, so the plan's window stops the
3909
- // account as it did before.
3906
+ // only the detail lists have (listedExtra) are their window.
3907
+ // As with the summary's split (usageOf), one of the two stops
3908
+ // the account: the plan's, until its credits are spent with
3909
+ // extra ones left. WorkBuddy goes on serving such an account on
3910
+ // its extra credits (ferock on Discord, a China-site account
3911
+ // at "500 / 500" moved off while its extra ones were left).
3910
3912
  const kinds = !extra && kindsOf(sum, site)
3911
3913
  const more = kinds && kinds.plan.total > 0 && kinds.extra.total === 0 ? listedExtra(sum, packages, site) : null
3912
3914
  if (more) {
3913
3915
  const { runsOutAt, runsOut, ...counts } = more
3914
- const w = { ...creditWindow("Extra credits", counts), aside: true, ...(runsOutAt ? { runsOutAt, runsOut } : {}) }
3916
+ const w = { ...creditWindow("Extra credits", counts), ...(runsOutAt ? { runsOutAt, runsOut } : {}) }
3917
+ const planSpent = credits.amount >= credits.limit && counts.used < counts.total
3918
+ if (planSpent) credits.aside = true
3919
+ else w.aside = true
3915
3920
  out.windows.splice(out.windows.indexOf(credits) + 1, 0, w)
3916
- // and, as with the split's, the soonest of them to lapse is
3921
+ // and, as with the split's, the soonest credits to lapse are
3917
3922
  // the account's too, on the window that stops it: routing
3918
3923
  // reads none set aside, so an account whose extra credits
3919
3924
  // expire first went unknown to it (Kayphoon on Discord)
3920
- const at = runsOutAt ? Date.parse(runsOutAt) : 0
3921
- const was = credits.runsOutAt ? Date.parse(credits.runsOutAt) : 0
3922
- if (at > 0 && (!was || at < was)) Object.assign(credits, { runsOutAt, runsOut })
3923
- else if (at > 0 && at === was) credits.runsOut = (credits.runsOut ?? 0) + runsOut
3925
+ const [stops, other] = planSpent ? [w, credits] : [credits, w]
3926
+ const at = other.runsOutAt ? Date.parse(other.runsOutAt) : 0
3927
+ const was = stops.runsOutAt ? Date.parse(stops.runsOutAt) : 0
3928
+ if (at > 0 && (!was || at < was)) Object.assign(stops, { runsOutAt: other.runsOutAt, runsOut: other.runsOut })
3929
+ else if (at > 0 && at === was) stops.runsOut = (stops.runsOut ?? 0) + other.runsOut
3924
3930
  }
3925
3931
  } catch {}
3926
3932
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-workbuddy-auth",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
5
5
  "type": "module",
6
6
  "main": "./opencode.mjs",