@magpie-community/opencode-qoder-auth 0.2.26 → 0.2.27

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 +10 -3
  2. package/index.mjs +18 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -277,9 +277,16 @@ the account's credentials.
277
277
  - For another installation location, set `QODER_RUNTIME_INFO` to the
278
278
  absolute path of Qoder's installed `runtime-info` executable
279
279
  (`runtime-info.exe` on Windows), with its accompanying SDK files.
280
- - A missing helper or invalid identity is an error, rather than a false
281
- "no activity" result. Qoder CN keeps its existing requests and does
282
- not need this local helper.
280
+ - With no helper anywhere (a machine that never had Qoder desktop or
281
+ Qoder CLI), the check-in is `ineligible` for the day, with a message
282
+ saying to install one (or set `QODER_RUNTIME_INFO`); magpie asks again
283
+ the next day rather than every 30 minutes (#304). The identity comes
284
+ only from Qoder's own helper: the plugin never makes one up, so such an
285
+ international account gets no daily claim until Qoder is installed.
286
+ - A helper that is there but can't be read, or gives an invalid identity,
287
+ is `failed` and asked again later, rather than a false "no activity"
288
+ result. Qoder CN keeps its existing requests and does not need this
289
+ local helper.
283
290
 
284
291
  - **List:** `GET <openapi>/sash/api/v1/me/campaigns`: `campaigns[]` with
285
292
  `campaignId`, `actionType`, `claimStatus` (`CLAIMABLE`, `CLAIMED`),
package/index.mjs CHANGED
@@ -1408,7 +1408,21 @@ async function campaignRuntime({ home = homedir(), platform = process.platform,
1408
1408
  if (path && (await isFile(path))) found.push({ path, time: (await stat(path)).mtimeMs })
1409
1409
  }
1410
1410
  if (found.length) return found.sort((a, b) => b.time - a.time)[0].path
1411
- throw new Error("Qoder check-in: device identity runtime not found; install Qoder desktop or sign in to Qoder CLI once, or set QODER_RUNTIME_INFO to its runtime-info executable")
1411
+ throw new RuntimeMissing()
1412
+ }
1413
+
1414
+ // RuntimeMissing: no Qoder desktop or CLI on this machine to read the
1415
+ // device identity from. Qoder offers the daily credits only on a request
1416
+ // carrying it (without it the list answers 200 with no CLAIM_BENEFIT), and
1417
+ // the identity is the output of Qoder's own signed helper, which the plugin
1418
+ // never makes up. Asking again won't change that until the user installs
1419
+ // Qoder, so the check-in says what to do once instead of "tries again later".
1420
+ class RuntimeMissing extends Error {
1421
+ constructor() {
1422
+ super(
1423
+ "Qoder check-in: device identity runtime not found. Qoder gives the daily credits only to a device its own app identifies, and this machine has neither Qoder desktop nor Qoder CLI to read that identity from. Install Qoder desktop (or install Qoder CLI and sign in to it once), or set QODER_RUNTIME_INFO to its runtime-info executable; magpie checks in again the next day",
1424
+ )
1425
+ }
1412
1426
  }
1413
1427
 
1414
1428
  // Read the SDK identity as Qoder does: environment 3 is international; on
@@ -1851,6 +1865,9 @@ const makePlugin = (site) => async ({ client }) => {
1851
1865
  }
1852
1866
  return { outcome: "failed", message: `claim: ${said || "unknown answer"}` }
1853
1867
  } catch (e) {
1868
+ // no Qoder on this machine: an answer for the day, not a failure
1869
+ // magpie would ask again every 30 minutes (plugins#304)
1870
+ if (e instanceof RuntimeMissing) return { outcome: "ineligible", message: e.message }
1854
1871
  return { outcome: "failed", message: e?.message ?? String(e), ...(e?.expired ? { signIn: "expired" } : {}) }
1855
1872
  }
1856
1873
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-qoder-auth",
3
- "version": "0.2.26",
3
+ "version": "0.2.27",
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",