@magpie-community/opencode-qoder-auth 0.2.23 → 0.2.25

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 +7 -1
  2. package/index.mjs +13 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -22,6 +22,11 @@ hosts; [its section](#qoder-cn) says what differs.
22
22
  3. The device token is traded for a job token, and the account's email and
23
23
  name are read.
24
24
 
25
+ The page is asked for no `redirect_uri`, as Qoder's CLI asks for none, so
26
+ the sign-in ends in the browser tab even when Qoder.app is installed
27
+ (before 0.2.25 it sent the desktop app's `qoder-app://`, which handed the
28
+ page to Qoder.app).
29
+
25
30
  **Sign in with Qoder PAT** (and **Sign in with Qoder CN PAT**) skips the
26
31
  device flow: a Personal Access Token from `<site>/account/integrations` is
27
32
  posted to `/api/v1/jobToken/exchange` (`personal_token`), which answers a
@@ -125,6 +130,7 @@ itself.
125
130
  | A quota (codes 110, 112–119, 122) | 429 |
126
131
  | 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
132
  | A refusal of the request itself (codes 406, 416, 430, 80411, 80412, 100400–100403) | 400, with Qoder's words |
133
+ | "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
134
  | A failure before the answer starts | Qoder's status |
129
135
  | A failure after the answer has started | The stream ends with an error |
130
136
 
@@ -177,7 +183,7 @@ Qoder CN's own CLI builds in for its `cn` build (`@qodercn-ai/qoderclicn`
177
183
  | Accounts: poll, tokens, user info, usage | openapi.qoder.sh | openapi.qoder.com.cn |
178
184
  | Models and chat | api3.qoder.sh | gateway.qoder.com.cn |
179
185
  | Device-flow client id | Qoder's desktop client's | Qoder CN's CLI's (production) |
180
- | `redirect_uri` on the sign-in page | `qoder-app://` | none, as the CLI sends |
186
+ | `redirect_uri` on the sign-in page | none, as Qoder's CLI sends (since 0.2.25) | none, as the CLI sends |
181
187
 
182
188
  Qoder CN's CLI chats with the device token itself and never makes a job
183
189
  token. The plugin asks qoder.cn for a job token first, as it does on
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
@@ -1495,7 +1504,10 @@ const SITES = {
1495
1504
  web: "https://qoder.com",
1496
1505
  openapi: "https://openapi.qoder.sh",
1497
1506
  api: "https://api3.qoder.sh",
1498
- redirect: "qoder-app://",
1507
+ // none, as Qoder's CLI (@qoder-ai/qodercli 1.1.75) sends: the desktop
1508
+ // app's qoder-app:// hands the finished page to Qoder.app, when it is
1509
+ // installed, instead of leaving it in the tab while this polls (#276)
1510
+ redirect: "",
1499
1511
  models: MODELS,
1500
1512
  },
1501
1513
  "qoder-cn": {
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.25",
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",