@magpie-community/opencode-qoder-auth 0.2.48 → 0.2.49
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 +7 -0
- package/index.mjs +30 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,6 +76,13 @@ Refreshing:
|
|
|
76
76
|
or another process renewed it meanwhile, else after one refresh, under the
|
|
77
77
|
same lock. A token renewed less than 5 minutes ago and refused again isn't
|
|
78
78
|
renewed again; the refusal is the answer.
|
|
79
|
+
- A model Qoder serves that the account's listing has off or leaves out is
|
|
80
|
+
asked for the same way: the job token is renewed once (or the pair saved
|
|
81
|
+
since is used) and the list read again, before the request is answered
|
|
82
|
+
`unknown or disabled model`. On a job token Qoder no longer honours in
|
|
83
|
+
full, the listing can have only the free models on (#484). The same
|
|
84
|
+
5-minute rule holds, and an id Qoder has never served is said unknown at
|
|
85
|
+
once, with no renewal.
|
|
79
86
|
- The device token, which reads usage, has no end on record: it is rotated
|
|
80
87
|
when Qoder refuses it. On a [Qoder CN](#qoder-cn) device-token account it
|
|
81
88
|
is the chat token too, and is renewed as above.
|
package/index.mjs
CHANGED
|
@@ -2542,11 +2542,21 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2542
2542
|
return next
|
|
2543
2543
|
})
|
|
2544
2544
|
|
|
2545
|
+
// the ids Qoder serves: the site's shipped list and every key a listing
|
|
2546
|
+
// has named, on or off
|
|
2547
|
+
const served = new Set(site.models.map((m) => m.id))
|
|
2548
|
+
const knows = (id) => served.has(id)
|
|
2545
2549
|
const models = async (cred, again = false) => {
|
|
2546
2550
|
const key = listingKey(cred)
|
|
2547
2551
|
let l = listings.get(key)
|
|
2548
2552
|
if (!l || again) {
|
|
2549
|
-
|
|
2553
|
+
const s = siteOf(site, cred)
|
|
2554
|
+
const listing = await fetchListing(s, cred)
|
|
2555
|
+
for (const m of s.modelScene ? (Array.isArray(listing?.[s.modelScene]) ? listing[s.modelScene] : []) : sceneModels(listing)) {
|
|
2556
|
+
const k = String(m?.key ?? "").trim()
|
|
2557
|
+
if (k) served.add(k)
|
|
2558
|
+
}
|
|
2559
|
+
l = modelInfos(listing, s)
|
|
2550
2560
|
listings.set(key, l)
|
|
2551
2561
|
}
|
|
2552
2562
|
return l
|
|
@@ -2783,8 +2793,26 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2783
2793
|
const ask = async (chat, cred, init, named = "", fallback = false, getAuth, asked = {}) => {
|
|
2784
2794
|
asked.cred = cred
|
|
2785
2795
|
let m
|
|
2796
|
+
let relogged = false
|
|
2797
|
+
const listed = (ms) => ms.find((x) => x.key === chat.model)
|
|
2786
2798
|
try {
|
|
2787
|
-
m = (await models(cred))
|
|
2799
|
+
m = listed(await models(cred)) ?? listed(await models(cred, true))
|
|
2800
|
+
// A model Qoder serves that the account's listing leaves out, or has
|
|
2801
|
+
// off, on a job token Qoder no longer honours in full: the token is
|
|
2802
|
+
// renewed once (relogin, as for a refused chat) and the list asked
|
|
2803
|
+
// again. On an enterprise qoder.com account (plugins#484) the listing
|
|
2804
|
+
// had only the free dfmodel and qfmodel on while the job token was
|
|
2805
|
+
// stale, and every other model was answered 400 here, before a chat
|
|
2806
|
+
// could be refused and renew it. An id Qoder has never served is said
|
|
2807
|
+
// unknown at once, with no renewal spent on it.
|
|
2808
|
+
if (!m && getAuth && knows(chat.model)) {
|
|
2809
|
+
relogged = true
|
|
2810
|
+
const next = await relogin(getAuth, cred.access)
|
|
2811
|
+
if (next) {
|
|
2812
|
+
cred = asked.cred = next
|
|
2813
|
+
m = listed(await models(cred, true))
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2788
2816
|
} catch (e) {
|
|
2789
2817
|
if (e instanceof SignInGone || e?.expired) return signedInError(e)
|
|
2790
2818
|
return errorResponse({ status: 502, message: e?.message ?? String(e) })
|
|
@@ -2804,7 +2832,6 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2804
2832
|
// resend can be queued again before it is answered.
|
|
2805
2833
|
const deadline = QUEUE.now() + QUEUE.budget
|
|
2806
2834
|
const ask = { requestSetId: body.request_set_id, requestId: body.request_id, sessionId: body.session_id, modelKey: m.key }
|
|
2807
|
-
let relogged = false
|
|
2808
2835
|
for (let sent = 0, waited = 0; ; sent++) {
|
|
2809
2836
|
if (sent) {
|
|
2810
2837
|
body.request_id = body.chat_record_id = randomUUID()
|
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.49",
|
|
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",
|