@magpie-community/opencode-qoder-auth 0.2.45 → 0.2.46
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 +13 -0
- package/index.mjs +22 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -472,6 +472,19 @@ the plugin factory and its pieces, for another service on this same
|
|
|
472
472
|
protocol (QwenWork ships here; a future one can too). Its shape is not a
|
|
473
473
|
stable API — it changes as the packages on it need.
|
|
474
474
|
|
|
475
|
+
## Free models when the credits run out
|
|
476
|
+
|
|
477
|
+
Qoder serves its free models after the credits are used up: "When Credits
|
|
478
|
+
run out, you can continue using free basic models, subject to daily and
|
|
479
|
+
monthly limits" ([docs.qoder.com/Credits](https://docs.qoder.com/Credits);
|
|
480
|
+
the zh page says the same). So the credit windows the usage hook gives
|
|
481
|
+
(Qoder and Qoder CN, since 0.2.46) name the account's free models in
|
|
482
|
+
`notModels`: a model listed at 0× (not a discount's 0 for a while), from the
|
|
483
|
+
account's own model list. magpie then doesn't count those models as spent
|
|
484
|
+
on a used-up account, or on a free account's "0 credits left". A list that
|
|
485
|
+
can't be read leaves every model counted. QwenWork reads its usage
|
|
486
|
+
elsewhere and is not changed.
|
|
487
|
+
|
|
475
488
|
## Not here
|
|
476
489
|
|
|
477
490
|
- Qoder's usage and quota display.
|
package/index.mjs
CHANGED
|
@@ -2515,6 +2515,26 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2515
2515
|
return dt.token
|
|
2516
2516
|
})
|
|
2517
2517
|
|
|
2518
|
+
// spareFree has the credit windows not count the models that cost none
|
|
2519
|
+
// (notModels): Qoder's own docs say "When Credits run out, you can
|
|
2520
|
+
// continue using free basic models, subject to daily and monthly limits"
|
|
2521
|
+
// (docs.qoder.com/Credits; the zh page the same: "Credits 用尽后,仍可使用
|
|
2522
|
+
// 免费基础模型"). Counted, a plan used up (or a free account's "0 credits
|
|
2523
|
+
// left") put the account last for Qwen3.8-Flash and DeepSeek-Flash too,
|
|
2524
|
+
// which it still serves (coeo91 on Discord). Free is the listing's own
|
|
2525
|
+
// price (freeOf: 0×, not a discount's 0 for a while). A listing that can't
|
|
2526
|
+
// be read leaves every model counted, as before. Qoder and Qoder CN only:
|
|
2527
|
+
// QwenWork reads its usage elsewhere and says nothing of free models.
|
|
2528
|
+
const spareFree = async (cred, out) => {
|
|
2529
|
+
if (!out?.windows?.length) return out
|
|
2530
|
+
let free = []
|
|
2531
|
+
try {
|
|
2532
|
+
free = (await models(cred)).filter((m) => m.free).map((m) => m.key)
|
|
2533
|
+
} catch {}
|
|
2534
|
+
if (free.length) for (const w of out.windows) w.notModels = free
|
|
2535
|
+
return out
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2518
2538
|
// usage is the account's allowance, magpie's own hook. signIn is what the read means for the sign-in, as the built-in's did:
|
|
2519
2539
|
// a refused job refresh marks it, a renewed one clears it, and nothing
|
|
2520
2540
|
// else does — not a clean read, nor a refused device token, which serves
|
|
@@ -2562,7 +2582,7 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2562
2582
|
// no second token here to rotate and retry with.
|
|
2563
2583
|
if (cred.patAuth && !cred.deviceToken) {
|
|
2564
2584
|
const env = await fetchUsage(siteOf(site, cred), cred.access)
|
|
2565
|
-
return { ...parseUsage(env), signIn }
|
|
2585
|
+
return { ...(await spareFree(cred, parseUsage(env))), signIn }
|
|
2566
2586
|
}
|
|
2567
2587
|
let env
|
|
2568
2588
|
try {
|
|
@@ -2571,7 +2591,7 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2571
2591
|
if (!(e instanceof UsageStatus) || (e.status !== 401 && e.status !== 403)) throw e
|
|
2572
2592
|
env = await fetchUsage(siteOf(site, cred), await deviceToken(getAuth, cred.deviceToken))
|
|
2573
2593
|
}
|
|
2574
|
-
return { ...parseUsage(env), signIn }
|
|
2594
|
+
return { ...(await spareFree(cred, parseUsage(env))), signIn }
|
|
2575
2595
|
} catch (e) {
|
|
2576
2596
|
return { error: e?.message ?? String(e), signIn: e?.expired ? "expired" : signIn }
|
|
2577
2597
|
}
|
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.46",
|
|
4
4
|
"description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship (VPC)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|