@magpie-community/opencode-trae-auth 0.2.20 → 0.2.21
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 +6 -3
- package/index.mjs +11 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -407,9 +407,12 @@ answered it 9074 even with the client's headers.
|
|
|
407
407
|
in today, and that holds for the day. No device id is ever changed or
|
|
408
408
|
rotated to get round a 9095 or a 9074, and no account is given another
|
|
409
409
|
account's device or its own client's device unless the client is signed
|
|
410
|
-
in as that account. The credit a claim granted is its `credits
|
|
411
|
-
its `extra_credits
|
|
412
|
-
|
|
410
|
+
in as that account. The credit a claim granted is its `credits`, or
|
|
411
|
+
its `extra_credits` when it names only that; Trae CN's claim usually
|
|
412
|
+
names neither (`{"code":0,"message":"success"}`), and then the status
|
|
413
|
+
answer's `credits` is the credit. The two are never added: the status
|
|
414
|
+
carries `extra_credits` beside `credits` (100 and 100 on a real
|
|
415
|
+
account) while the day gives 100.
|
|
413
416
|
|
|
414
417
|
Only `api.trae.cn`'s `/trae/api/` pages are sent this way; any other URL
|
|
415
418
|
that isn't a chat request is still refused (400). Needs 0.1.4 or later.
|
package/index.mjs
CHANGED
|
@@ -2902,13 +2902,18 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2902
2902
|
if (String(ce.code) === "9074") return { outcome: "ineligible", message: `${ce.message} — check in in the Trae CN app` }
|
|
2903
2903
|
if (claim.status !== 200 || (ce.code && String(ce.code) !== "0")) return { outcome: "failed", message: ce.message || statusLine(claim.status) }
|
|
2904
2904
|
if (!answer || typeof answer !== "object" || Array.isArray(answer)) return { outcome: "failed", message: `check-in claim: unreadable reply ${claimText.trim().slice(0, 120) || "(empty)"}` }
|
|
2905
|
-
//
|
|
2906
|
-
//
|
|
2907
|
-
//
|
|
2905
|
+
// The credit is the day's credits, never credits plus extra_credits.
|
|
2906
|
+
// Trae CN's real claim answers {"code":0,"message":"success"}, with no
|
|
2907
|
+
// credit at all (plugins#194), so the status's credits stand in. Its
|
|
2908
|
+
// status carries extra_credits beside credits, at the same 100 on a
|
|
2909
|
+
// real account (yetone/magpie#808: credits 100, extra_credits 100),
|
|
2910
|
+
// while the account gets 100: adding the two showed 200 (zhujiu on
|
|
2911
|
+
// magpie's Discord, 10-25). A claim that names its own credit is
|
|
2912
|
+
// taken first; one naming extra_credits alone is that (#260). Either
|
|
2913
|
+
// may be absent, and Number(undefined) is NaN, which reads as none.
|
|
2908
2914
|
const n = (v) => (Number.isFinite(Number(v)) ? Number(v) : 0)
|
|
2909
|
-
const credit = n(answer.credits)
|
|
2910
|
-
|
|
2911
|
-
return { outcome: "claimed", ...(credit > 0 ? { credit } : fallback > 0 ? { credit: fallback } : {}) }
|
|
2915
|
+
const credit = n(answer.credits) || n(answer.extra_credits) || n(body.credits)
|
|
2916
|
+
return { outcome: "claimed", ...(credit > 0 ? { credit } : {}) }
|
|
2912
2917
|
}
|
|
2913
2918
|
|
|
2914
2919
|
const usage = async (getAuth) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-trae-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "OpenCode provider plugins for Trae: Trae CN (trae.cn) and Trae Global (trae.ai), free tier included, with Trae's own browser sign-in",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|