@magpie-community/opencode-workbuddy-auth 0.1.35 → 0.1.36
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/index.mjs +23 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1728,14 +1728,33 @@ function runsOutOf(sum, packages, now = Date.now()) {
|
|
|
1728
1728
|
// is over.
|
|
1729
1729
|
function cycleOf(sum, packages, now = Date.now()) {
|
|
1730
1730
|
const code = sum?.SubscriptionPackageCode
|
|
1731
|
-
if (!code) return null
|
|
1732
1731
|
const at = (v) => (typeof v === "string" && /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(v.trim()) ? Date.parse(v.trim().replace(" ", "T") + "+08:00") : 0)
|
|
1733
|
-
|
|
1734
|
-
if (p?.PackageCode !== code) continue
|
|
1732
|
+
const of = (p) => {
|
|
1735
1733
|
const end = at(p?.CycleEndTime), start = at(p?.CycleStartTime)
|
|
1736
|
-
if (!(end > now))
|
|
1734
|
+
if (!(end > now)) return null
|
|
1737
1735
|
return { resetsAt: new Date(end).toISOString(), ...(start > 0 && start < end ? { span: (end - start) / 1000 } : {}) }
|
|
1738
1736
|
}
|
|
1737
|
+
// A summary that does name one goes by it alone: named and not listed, or
|
|
1738
|
+
// its cycle over, is unknown — a paid plan's cycle is its subscription's,
|
|
1739
|
+
// never the slice's (yetone, #415).
|
|
1740
|
+
if (code) {
|
|
1741
|
+
for (const p of packages ?? []) if (p?.PackageCode === code) return of(p)
|
|
1742
|
+
return null
|
|
1743
|
+
}
|
|
1744
|
+
// A free account's summary names no subscription at all: both sites answer
|
|
1745
|
+
// SubscriptionPackageCode "" (copilot.tencent.com and www.workbuddy.ai,
|
|
1746
|
+
// measured 2026-10-26 on eight CN accounts and one AI one), so this
|
|
1747
|
+
// returned null and the card of an account whose credits are being spent
|
|
1748
|
+
// said nothing of when they come back — the one thing cycleOf is for.
|
|
1749
|
+
//
|
|
1750
|
+
// Its plan's own credits are the slice (CapacityType 4): packagesOf's
|
|
1751
|
+
// free list returns a month's plan_base with it, 00:00:00 to 23:59:59
|
|
1752
|
+
// UTC+8, the same cycle on every account on both sites (500 credits on
|
|
1753
|
+
// the CN site, 100 on the international), and its CycleEndTime is when
|
|
1754
|
+
// the plan gives the next month's back. A slice tells no account apart,
|
|
1755
|
+
// which is why runsOutOf keeps it out: which account to spend first is a
|
|
1756
|
+
// different question from when the plan refills.
|
|
1757
|
+
for (const p of packages ?? []) if (String(p?.CapacityType) === SLICE) return of(p)
|
|
1739
1758
|
return null
|
|
1740
1759
|
}
|
|
1741
1760
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-workbuddy-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
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": "./index.mjs",
|