@magpie-community/opencode-qoder-auth 0.2.58 → 0.2.60
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 +16 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1600,7 +1600,16 @@ function failure(status, text) {
|
|
|
1600
1600
|
const said = msg && msg !== STATUS_CODES[status] ? ` (Qoder said ${status}: ${msg.slice(0, 300)})` : ""
|
|
1601
1601
|
return { status: 401, message: "the sign-in lapsed — sign in again" + said, lapsed: true }
|
|
1602
1602
|
}
|
|
1603
|
-
|
|
1603
|
+
// Qoder's words go with the status and code they came in, and the reply
|
|
1604
|
+
// itself when it says more than the message: a 429 that names no quota
|
|
1605
|
+
// ("All models failed", QwenWork) is not shown as an account's limit
|
|
1606
|
+
// with nothing to tell it apart (dsh, QwenWork flash)
|
|
1607
|
+
if (status === 429 || msg.toLowerCase().includes("quota")) {
|
|
1608
|
+
const raw = String(text ?? "").trim()
|
|
1609
|
+
const seen = `Qoder replied HTTP ${status}${code ? `, code ${code}` : ""}`
|
|
1610
|
+
const body = raw && raw !== msg ? `: ${raw.slice(0, 400)}` : ""
|
|
1611
|
+
return { status: 429, message: `usage limit reached: ${msg} (${seen}${body})` }
|
|
1612
|
+
}
|
|
1604
1613
|
return { status, message: msg }
|
|
1605
1614
|
}
|
|
1606
1615
|
|
|
@@ -2692,7 +2701,11 @@ function parseUsage(env) {
|
|
|
2692
2701
|
const used = b.used != null ? b.used : total - b.remaining
|
|
2693
2702
|
if (used < 0) return
|
|
2694
2703
|
const unit = b.unit || "credits"
|
|
2695
|
-
|
|
2704
|
+
// the count too, so magpie says "183 / 2,000 credits left" as Qoder's
|
|
2705
|
+
// own panel does, not a bare share (jzing.draw on Discord); the plan's
|
|
2706
|
+
// credits refresh when the plan says, as the panel's "refreshes on" does
|
|
2707
|
+
const w = { name: b.name || name, used: Math.min(100, (100 * used) / total), display: `${gfmt(used)} / ${gfmt(total)} ${unit}`, amount: used, limit: total, unit }
|
|
2708
|
+
if (name === "Credits" && until) w.resetsAt = until
|
|
2696
2709
|
out.windows.push(w)
|
|
2697
2710
|
if (SPENT_IN_TURN.has(name)) turn.push({ w, used: Math.min(used, total), total, unit })
|
|
2698
2711
|
}
|
|
@@ -2705,7 +2718,7 @@ function parseUsage(env) {
|
|
|
2705
2718
|
const used = turn.reduce((a, p) => a + p.used, 0)
|
|
2706
2719
|
const total = turn.reduce((a, p) => a + p.total, 0)
|
|
2707
2720
|
for (const p of turn) p.w.aside = true
|
|
2708
|
-
out.windows.unshift({ name: "Total credits", used: Math.min(100, (100 * used) / total), display: `${gfmt(used)} / ${gfmt(total)} ${turn[0].unit}
|
|
2721
|
+
out.windows.unshift({ name: "Total credits", used: Math.min(100, (100 * used) / total), display: `${gfmt(used)} / ${gfmt(total)} ${turn[0].unit}`, amount: used, limit: total, unit: turn[0].unit })
|
|
2709
2722
|
}
|
|
2710
2723
|
const dedicated = field("dedicatedResourcePackages", "dedicated_resource_packages")
|
|
2711
2724
|
for (const b of Array.isArray(dedicated) ? dedicated : []) add(b, "Dedicated credits")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-qoder-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.60",
|
|
4
4
|
"description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship, VPC and dedicated domains",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./opencode.mjs",
|