@magpie-community/opencode-qoder-auth 0.2.69 → 0.2.70
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 +17 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1729,6 +1729,12 @@ const QUEUE = {
|
|
|
1729
1729
|
recoveries: 10, // the queue waited out this many times, at most, for one request
|
|
1730
1730
|
failures: 3, // status asks failing in a row that end the wait
|
|
1731
1731
|
ask: 30_000, // the longest one status ask may take
|
|
1732
|
+
// the longest a call waits for Qoder's first event (headers included).
|
|
1733
|
+
// Qoder CN once held a call 15 minutes with nothing sent and nothing to
|
|
1734
|
+
// log (#1204); after this it is a 504 that says so, which magpie can
|
|
1735
|
+
// fail over from. A queued call answers its 10605 at once, and a
|
|
1736
|
+
// thinking model streams its reasoning, so a real answer starts sooner.
|
|
1737
|
+
silent: 120_000,
|
|
1732
1738
|
now: () => Date.now(),
|
|
1733
1739
|
// every calls fn each ms until the returned stop is called
|
|
1734
1740
|
every: (fn, ms) => {
|
|
@@ -3792,11 +3798,22 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
3792
3798
|
const call = new AbortController()
|
|
3793
3799
|
const callSignal = signal ? AbortSignal.any([signal, call.signal]) : call.signal
|
|
3794
3800
|
let res, open
|
|
3801
|
+
let silent = false
|
|
3802
|
+
const hush = setTimeout(() => {
|
|
3803
|
+
silent = true
|
|
3804
|
+
call.abort()
|
|
3805
|
+
}, QUEUE.silent)
|
|
3795
3806
|
try {
|
|
3796
3807
|
res = await fetch(CHAT_URL, { method: "POST", headers, body: wire, signal: callSignal })
|
|
3797
3808
|
if (res.ok) open = await opened(res, chat.tool_choice !== "none" ? (chat.tools ?? []).filter((t) => t?.type === "function") : [])
|
|
3798
3809
|
} catch (e) {
|
|
3810
|
+
if (silent) {
|
|
3811
|
+
const who = siteOf(site, cred).name ?? "Qoder"
|
|
3812
|
+
return errorResponse({ status: 504, message: `${who} sent nothing for ${Math.round(QUEUE.silent / 1000)}s after the request (${res ? "no first event" : "no reply headers"}); the call was dropped`, signIn: "" })
|
|
3813
|
+
}
|
|
3799
3814
|
return errorResponse({ status: 502, message: e.message })
|
|
3815
|
+
} finally {
|
|
3816
|
+
clearTimeout(hush)
|
|
3800
3817
|
}
|
|
3801
3818
|
const f = !res.ok ? failure(res.status, (await res.text()).slice(0, 1 << 20)) : open.first.value?.error
|
|
3802
3819
|
if (f) call.abort()
|
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.70",
|
|
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",
|