@magpie-community/opencode-qoder-auth 0.2.22 → 0.2.24
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 +4 -0
- package/index.mjs +17 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,6 +100,9 @@ itself.
|
|
|
100
100
|
- the account, AES-encrypted, with the key wrapped by Qoder's RSA key;
|
|
101
101
|
- an MD5 signature;
|
|
102
102
|
- the machine id and the client's headers.
|
|
103
|
+
- `Cosy-Version`: the worker runtime version that Qoder's desktop app
|
|
104
|
+
ships (1.1.69 in app 0.4.8, since 0.2.23, #281), because
|
|
105
|
+
`Cosy-ClientType` says the desktop app.
|
|
103
106
|
|
|
104
107
|
**Reading the reply**
|
|
105
108
|
|
|
@@ -122,6 +125,7 @@ itself.
|
|
|
122
125
|
| A quota (codes 110, 112–119, 122) | 429 |
|
|
123
126
|
| Busy or queued for the model (code 10605) | 503, with `Retry-After` from Qoder's `retryAfterSeconds` (30s when it gives none); the sign-in is untouched |
|
|
124
127
|
| A refusal of the request itself (codes 406, 416, 430, 80411, 80412, 100400–100403) | 400, with Qoder's words |
|
|
128
|
+
| "Error in upstream response", the model's own vendor behind Qoder failing, which Qoder sends as a 400 (since 0.2.24) | 502, so magpie asks again or another account; the sign-in is untouched |
|
|
125
129
|
| A failure before the answer starts | Qoder's status |
|
|
126
130
|
| A failure after the answer has started | The stream ends with an error |
|
|
127
131
|
|
package/index.mjs
CHANGED
|
@@ -43,7 +43,14 @@ import { join, resolve } from "node:path"
|
|
|
43
43
|
|
|
44
44
|
const CHAT_PATH = "/algo/api/v2/service/pro/sse/agent_chat_generation?FetchKeys=llm_model_result&AgentId=agent_common&Encode=1"
|
|
45
45
|
const MODELS_PATH = "/algo/api/v2/model/list?Encode=1"
|
|
46
|
-
|
|
46
|
+
// The build the envelope claims. It has to be the one Qoder's desktop app
|
|
47
|
+
// talks through — the worker runtime bundled in the app — because the
|
|
48
|
+
// envelope also says Cosy-ClientType: 10 (desktop) and carries that app's
|
|
49
|
+
// machine identity; the CLI's channel publishes a different, later number
|
|
50
|
+
// that no desktop build runs. Taken from app 0.4.8 (build 79743374,
|
|
51
|
+
// 2026-10-14), whose transport config names 1.1.69. Raise it when the app
|
|
52
|
+
// moves, not when the CLI does.
|
|
53
|
+
const COSY_VERSION = "1.1.69"
|
|
47
54
|
const SIGN_IN_TIMEOUT = 15 * 60 * 1000
|
|
48
55
|
const REFRESH_LEAD = 5 * 60 * 1000 // a chat token this close to its end is refreshed before a request
|
|
49
56
|
const RENEW_LEAD = 10 * 60 * 1000 // and this close, magpie renews it ahead of time (auth.refresh)
|
|
@@ -842,6 +849,14 @@ const QUOTA_CODES = new Set(["110", "112", "113", "114", "115", "116", "117", "1
|
|
|
842
849
|
// supported, input too long, too many media, a custom model's service
|
|
843
850
|
const REQUEST_CODES = new Set(["406", "416", "430", "80411", "80412", "100400", "100401", "100403"])
|
|
844
851
|
const BUSY_WAIT = 30
|
|
852
|
+
// UPSTREAM_FAILED is Qoder saying the model's own vendor behind it failed:
|
|
853
|
+
// "Error in upstream response", which Qoder sends as a 400 (SlouchyQuill507
|
|
854
|
+
// on Discord, qoder-cn). Nothing is wrong with the request or the account,
|
|
855
|
+
// so it is a 502, which magpie asks again or of another account, not a
|
|
856
|
+
// 400 that ends the turn as the client's fault. A request too long for the
|
|
857
|
+
// model fails the same way, and magpie tells that one apart by its size
|
|
858
|
+
// (tooLongUnsaid), at 502 as at 400.
|
|
859
|
+
const UPSTREAM_FAILED = /\berror in upstream response\b/i
|
|
845
860
|
|
|
846
861
|
function failure(status, text) {
|
|
847
862
|
if (status < 400 || status > 599) status = 502
|
|
@@ -887,6 +902,7 @@ function failure(status, text) {
|
|
|
887
902
|
}
|
|
888
903
|
if (QUOTA_CODES.has(code)) return { status: 429, message: "usage limit reached: " + msg, signIn: "" }
|
|
889
904
|
if (REQUEST_CODES.has(code)) return { status: 400, message: `Qoder refused the request (${code}): ${msg}`, signIn: "" }
|
|
905
|
+
if (UPSTREAM_FAILED.test(msg)) return { status: 502, message: msg, signIn: "" }
|
|
890
906
|
// a refused chat is the built-in's 401, which never marked the account
|
|
891
907
|
// lapsed: only a refused refresh did (errorResponse says kept). Qoder's
|
|
892
908
|
// own words go with it: a 401 right after signing in isn't a lapsed
|
package/package.json
CHANGED