@magpie-community/opencode-qoder-auth 0.2.51 → 0.2.52

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 +6 -0
  2. package/index.mjs +44 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -83,6 +83,12 @@ Refreshing:
83
83
  full, the listing can have only the free models on (#484). The same
84
84
  5-minute rule holds, and an id Qoder has never served is said unknown at
85
85
  once, with no renewal.
86
+ - The account's model list (what magpie and its agents see) is read the
87
+ same way (since 0.2.52): a listing with every model that costs credits
88
+ off and the free ones on, which is what Qoder CN answers a caller it
89
+ doesn't take for the account, renews the job token once and is read
90
+ again. A renewed token that still lists only the free models isn't
91
+ renewed again for the list.
86
92
  - The device token, which reads usage, has no end on record: it is rotated
87
93
  when Qoder refuses it. On a [Qoder CN](#qoder-cn) device-token account it
88
94
  is the chat token too, and is renewed as above.
package/index.mjs CHANGED
@@ -681,6 +681,23 @@ function sceneModels(listing) {
681
681
  // and "default" route inside Qoder and aren't one model. A site with its
682
682
  // own scene reads that scene's list; one that lists all models keeps the
683
683
  // disabled ones too (QwenWork's qwork scene carries its whole catalog).
684
+ // freeView is whether a listing is the one Qoder gives a caller it doesn't
685
+ // take for the account: every model that costs credits off, the free ones
686
+ // on. Qoder CN's gateway answers a caller it doesn't know with that list
687
+ // (2026-11-01: Qwen3.8-Flash on, Auto, Fast, Qwen3.8-Max, DeepSeek, GLM,
688
+ // Kimi and MiniMax off, in every scene), and an enterprise qoder.com
689
+ // account's stale job token was answered the same (plugins#484). A listing
690
+ // with no model that costs credits, or with one of them on, isn't it.
691
+ function freeView(entries) {
692
+ let off = false
693
+ for (const m of entries) {
694
+ if (!m || ["", "auto", "default"].includes(String(m.key ?? "").trim()) || freeOf(m)) continue
695
+ if (m.enable) return false
696
+ off = true
697
+ }
698
+ return off
699
+ }
700
+
684
701
  function modelInfos(listing, site) {
685
702
  if (site?.modelScene) {
686
703
  return (Array.isArray(listing?.[site.modelScene]) ? listing[site.modelScene] : [])
@@ -2653,6 +2670,8 @@ const makePlugin = (site) => async ({ client }) => {
2653
2670
  // the ids Qoder serves: the site's shipped list and every key a listing
2654
2671
  // has named, on or off
2655
2672
  const served = new Set(site.models.map((m) => m.id))
2673
+ // the job tokens a renewal gave that Qoder still listed the free view for
2674
+ const stillFree = new Set()
2656
2675
  const knows = (id) => served.has(id)
2657
2676
  const models = async (cred, again = false) => {
2658
2677
  const key = listingKey(cred)
@@ -2665,6 +2684,7 @@ const makePlugin = (site) => async ({ client }) => {
2665
2684
  if (k) served.add(k)
2666
2685
  }
2667
2686
  l = modelInfos(listing, s)
2687
+ if (!s.modelScene) l.freeView = freeView(sceneModels(listing))
2668
2688
  listings.set(key, l)
2669
2689
  }
2670
2690
  return l
@@ -3183,7 +3203,29 @@ const makePlugin = (site) => async ({ client }) => {
3183
3203
  }
3184
3204
  if (renewals.has(cred)) unsaid.add(listingKey(cred))
3185
3205
  try {
3186
- const ms = await models(cred, true)
3206
+ let ms = await models(cred, true)
3207
+ // The free view (freeView) on a job token is what Qoder lists for
3208
+ // a token it no longer takes in full: the token is renewed once,
3209
+ // as a chat for a model the list has off renews it (plugins#484),
3210
+ // and the list read again. Without it the account's list is the
3211
+ // free model alone, and magpie's agents see only that one (Qoder
3212
+ // CN, star21321321124_93024 on Discord, 2026-11-01). A token the
3213
+ // free view came back on after a renewal is not renewed again for
3214
+ // it: that account lists only the free models.
3215
+ if (ms.freeView && !stillFree.has(cred.access)) {
3216
+ let next
3217
+ try {
3218
+ next = await relogin(async () => auth, cred.access)
3219
+ } catch (e) {
3220
+ if (e?.expired) throw Object.assign(new Error(e.message), { signIn: "expired" })
3221
+ }
3222
+ if (next && next.access !== cred.access) {
3223
+ if (renewals.has(next)) unsaid.add(listingKey(next))
3224
+ cred = next
3225
+ ms = await models(cred, true)
3226
+ if (ms.freeView) stillFree.add(cred.access)
3227
+ }
3228
+ }
3187
3229
  if (!ms.length) return provider.models
3188
3230
  const s = siteOf(site, cred)
3189
3231
  return Object.fromEntries(
@@ -3260,4 +3302,4 @@ export async function QwenWorkEnterpriseAuthPlugin({ client }) {
3260
3302
  export const protocol = { makePlugin, deviceSignIn, openapi, siteOf }
3261
3303
 
3262
3304
  // for tests
3263
- export const _internal = { maskPhone, phoneLabelOf, realEmailOf, chatHeaders, machineOS, machineHostname, cosyHeaders, typedUnions, Splitter, campaignRuntime, RUNTIMES, campaignPage, campaignTarget, vpcInstance, vpcSite, parseUsage, gfmt, when, failure, modelInfo, qoderBody, qoderMessages, cacheMarked, sessionOf, namedSession, taskOf, TASKS, TASK_MAX, TASK_IDLE, SESSION, SITES, decodeBody, events, QUEUE, queueState }
3305
+ export const _internal = { freeView, maskPhone, phoneLabelOf, realEmailOf, chatHeaders, machineOS, machineHostname, cosyHeaders, typedUnions, Splitter, campaignRuntime, RUNTIMES, campaignPage, campaignTarget, vpcInstance, vpcSite, parseUsage, gfmt, when, failure, modelInfo, qoderBody, qoderMessages, cacheMarked, sessionOf, namedSession, taskOf, TASKS, TASK_MAX, TASK_IDLE, SESSION, SITES, decodeBody, events, QUEUE, queueState }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-qoder-auth",
3
- "version": "0.2.51",
3
+ "version": "0.2.52",
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",