@magpie-community/opencode-qoder-auth 0.2.23 → 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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/index.mjs +9 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -125,6 +125,7 @@ itself.
125
125
  | A quota (codes 110, 112–119, 122) | 429 |
126
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 |
127
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 |
128
129
  | A failure before the answer starts | Qoder's status |
129
130
  | A failure after the answer has started | The stream ends with an error |
130
131
 
package/index.mjs CHANGED
@@ -849,6 +849,14 @@ const QUOTA_CODES = new Set(["110", "112", "113", "114", "115", "116", "117", "1
849
849
  // supported, input too long, too many media, a custom model's service
850
850
  const REQUEST_CODES = new Set(["406", "416", "430", "80411", "80412", "100400", "100401", "100403"])
851
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
852
860
 
853
861
  function failure(status, text) {
854
862
  if (status < 400 || status > 599) status = 502
@@ -894,6 +902,7 @@ function failure(status, text) {
894
902
  }
895
903
  if (QUOTA_CODES.has(code)) return { status: 429, message: "usage limit reached: " + msg, signIn: "" }
896
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: "" }
897
906
  // a refused chat is the built-in's 401, which never marked the account
898
907
  // lapsed: only a refused refresh did (errorResponse says kept). Qoder's
899
908
  // own words go with it: a 401 right after signing in isn't a lapsed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-qoder-auth",
3
- "version": "0.2.23",
3
+ "version": "0.2.24",
4
4
  "description": "Qoder subscriptions in OpenCode and magpie: Qoder (qoder.com) and Qoder CN (qoder.cn)",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",