@magpie-community/opencode-zcode-auth 0.1.49 → 0.1.51
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 +18 -4
- package/index.mjs +26 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -294,7 +294,9 @@ and again, all day while the feed names no plan — one GET, nothing
|
|
|
294
294
|
posted: ZCode drops plans into the feed on its own schedule (a weekend
|
|
295
295
|
banner starting at 19:00 Beijing, say), and one that arrives
|
|
296
296
|
after the day's ask used to sit unclaimed past its short life. The
|
|
297
|
-
other answers stand for the day
|
|
297
|
+
other answers stand for the day — but an *ineligible* (code 1004, below)
|
|
298
|
+
is read again in half an hour, as an inactive is: a claimed plan leaves
|
|
299
|
+
the feed, so
|
|
298
300
|
asking again half an hour later would find nothing and flip the card
|
|
299
301
|
from "Checked in today" to "No check-in event now"; a captcha plan
|
|
300
302
|
re-asked makes ZCode demand its captcha again; a done plan re-asked
|
|
@@ -313,6 +315,14 @@ the body's code, not the HTTP status:
|
|
|
313
315
|
(11-03: seven accounts' ZCODE GLOBAL BUILD all answered 3007). Once
|
|
314
316
|
claimed there, the gift lands on the account and freeFirst spends it
|
|
315
317
|
like any other;
|
|
318
|
+
- code 1004 "…not eligible for this plan yet" (HTTP 400): *ineligible*,
|
|
319
|
+
ZCode is not offering this account the plan at that moment. It is read
|
|
320
|
+
again half an hour out, since a plan can be offered later in the day
|
|
321
|
+
(11-04: an account's GLOBAL BUILD banner appeared 28 minutes after it
|
|
322
|
+
signed in). When *every* account answers 1004, check `APP_VERSION`
|
|
323
|
+
first: six accounts all answered 1004 under 3.16.3's header, and four
|
|
324
|
+
of them claimed with code 0 under 3.17.2's, one night, with nothing
|
|
325
|
+
else changed;
|
|
316
326
|
- anything else, an HTTP error without a code, or a reply that isn't
|
|
317
327
|
JSON: *failed*, which magpie asks again later that day. It is never
|
|
318
328
|
taken as claimed, and a failed claim leaves the account's sign-in
|
|
@@ -349,9 +359,13 @@ plans add `-Trial` entries, which are told as read):
|
|
|
349
359
|
| GLM-5-Turbo | 200K | 64K | none, high |
|
|
350
360
|
|
|
351
361
|
The Start Plan's config has all of these except GLM-5.3. An account
|
|
352
|
-
with no GLM Coding Plan
|
|
353
|
-
|
|
354
|
-
GLM-5.3 a model), since all of its requests go to the gift
|
|
362
|
+
with no GLM Coding Plan lists the models its gift plans' balance names,
|
|
363
|
+
under each model's own name, as ZCode does (the Start Plan's GLM-5.3
|
|
364
|
+
bucket makes GLM-5.3 a model), since all of its requests go to the gift
|
|
365
|
+
anyway. A config model the balance doesn't name is left out: an account
|
|
366
|
+
whose Start Plan holds only GLM-5.3-Flash lists GLM-5.3-Flash (and its
|
|
367
|
+
-Trial entry), not GLM-5.2 or GLM-5-Turbo. Only a balance that names no
|
|
368
|
+
model leaves the config's list standing.
|
|
355
369
|
|
|
356
370
|
A gift plan's models appear again as `<model>-Trial` entries, so a
|
|
357
371
|
request can spend the gift's quota on purpose. A trial entry is listed
|
package/index.mjs
CHANGED
|
@@ -709,6 +709,12 @@ async function claimHint(s) {
|
|
|
709
709
|
// (seen 10-06, #30).
|
|
710
710
|
const CLAIMED_ALREADY = 1003
|
|
711
711
|
const CAPTCHA = 3007
|
|
712
|
+
// NOT_ELIGIBLE is /billing/claim's body code for a plan the account is not
|
|
713
|
+
// offered at that moment: HTTP 400 {"code":1004,…}. A stale APP_VERSION
|
|
714
|
+
// answers it for every account at once (11-04: six accounts all answered
|
|
715
|
+
// 1004 under 3.16.3's header, and four of them claimed with code 0 under
|
|
716
|
+
// 3.17.2's, one night, with nothing else changed).
|
|
717
|
+
const NOT_ELIGIBLE = 1004
|
|
712
718
|
const CAPTCHA_WORDS = /captcha/i
|
|
713
719
|
|
|
714
720
|
// The marketing feed and the claim are gated on the client's version:
|
|
@@ -743,6 +749,7 @@ async function claimOne(s, planID) {
|
|
|
743
749
|
const msg = typeof env?.msg === "string" ? env.msg : ""
|
|
744
750
|
if (code === CAPTCHA || CAPTCHA_WORDS.test(msg)) return { outcome: "captcha", why: msg || `code ${code}` }
|
|
745
751
|
if (code === CLAIMED_ALREADY) return { outcome: "done" }
|
|
752
|
+
if (code === NOT_ELIGIBLE) return { outcome: "ineligible", why: msg || `code ${code}` }
|
|
746
753
|
if (code === 0 && res.ok) return { outcome: "claimed" }
|
|
747
754
|
if (!Number.isFinite(code)) return { outcome: "failed", why: `HTTP ${res.status}, unreadable reply ${String(text ?? "").trim().slice(0, 120) || "(empty)"}` }
|
|
748
755
|
return { outcome: "failed", why: `${msg || "error"} (HTTP ${res.status}, code ${code})` }
|
|
@@ -761,6 +768,12 @@ async function claimOne(s, planID) {
|
|
|
761
768
|
// gifts are the rewards website's, claimed in the client.
|
|
762
769
|
const TOUCH = "/api/v1/marketing/touch"
|
|
763
770
|
const CLAIM_ACTION = "claim_zcode_plan"
|
|
771
|
+
// touchSeq is the feed's seq: ZCode's own count of its feed requests
|
|
772
|
+
// since the process started, from 0, one GET per refresh. It is not a
|
|
773
|
+
// page: "仅供服务端日志定位,不改变投放判断" (docs/marketing-touch-client.md,
|
|
774
|
+
// marketingTouchService.ts's bootRequestSeq, zai-org/ZCode@a9fe401), so a
|
|
775
|
+
// check-in asks once, never seq 0..8 in a row (plugins#676), and a banner
|
|
776
|
+
// seen at one seq and not another is a delivery arriving later.
|
|
764
777
|
let touchSeq = 0
|
|
765
778
|
// clientLanguage is the language ZCode names to marketing/touch: zh-CN or
|
|
766
779
|
// en-US, its two UI languages, never another (marketingTouchService's
|
|
@@ -847,7 +860,9 @@ const recheck = () => new Date(Date.now() + RECHECK_MS).toISOString()
|
|
|
847
860
|
// toClaim, the app's banners and its preview), as auth.checkin's answer:
|
|
848
861
|
// inactive when neither lists one, claimed when one was claimed now,
|
|
849
862
|
// done when each was claimed before, captcha when ZCode wants the app's
|
|
850
|
-
// captcha for one (it is claimed in the ZCode app),
|
|
863
|
+
// captcha for one (it is claimed in the ZCode app), ineligible when
|
|
864
|
+
// ZCode is not offering one at that moment (code 1004, read again later
|
|
865
|
+
// in the day), failed when a list
|
|
851
866
|
// or a claim can't be read. A failed one is asked again later in the
|
|
852
867
|
// day, when a plan claimed now answers 1003. An inactive stands only
|
|
853
868
|
// until RECHECK_MS from now, so a plan dropped into the feed later in
|
|
@@ -867,6 +882,7 @@ async function claimDaily(s) {
|
|
|
867
882
|
const said = [
|
|
868
883
|
claimed.length ? `claimed ${claimed.join(", ")}` : "",
|
|
869
884
|
...got.filter((g) => g.outcome === "captcha").map((g) => `${g.name}: claim it in the ZCode app (${g.why})`),
|
|
885
|
+
...got.filter((g) => g.outcome === "ineligible").map((g) => `${g.name}: ${g.why}`),
|
|
870
886
|
...got.filter((g) => g.outcome === "failed").map((g) => `${g.name}: ${g.why}`),
|
|
871
887
|
...unread,
|
|
872
888
|
].filter(Boolean).join("; ")
|
|
@@ -876,6 +892,10 @@ async function claimDaily(s) {
|
|
|
876
892
|
if (unread.length || got.some((g) => g.outcome === "failed")) return { outcome: "failed", message: said }
|
|
877
893
|
if (got.some((g) => g.outcome === "captcha")) return { outcome: "captcha", message: said }
|
|
878
894
|
if (claimed.length) return { outcome: "claimed", message: said }
|
|
895
|
+
// a plan not offered now can be offered later in the day (11-04: an
|
|
896
|
+
// account's GLOBAL BUILD banner showed 28 minutes after it signed in),
|
|
897
|
+
// so an ineligible is read again half an hour out, as an inactive is
|
|
898
|
+
if (got.some((g) => g.outcome === "ineligible")) return { outcome: "ineligible", message: said, until: recheck() }
|
|
879
899
|
return { outcome: "done", message: `already claimed: ${named("done").join(", ")}` }
|
|
880
900
|
}
|
|
881
901
|
|
|
@@ -2355,6 +2375,11 @@ export async function ZCodeAuthPlugin({ client, magpie } = {}, options = {}) {
|
|
|
2355
2375
|
// the list it was told last, as the built-in keeps the one it fetched last
|
|
2356
2376
|
const fell = !ms.length
|
|
2357
2377
|
if (fell) ms = start ? START_MODELS : MODELS
|
|
2378
|
+
// a gift-only account serves what its balance names, as ZCode
|
|
2379
|
+
// offers it (resolveStartPlanBalanceAvailability): the Start
|
|
2380
|
+
// Plan's config models the balance lacks would only be refused
|
|
2381
|
+
// (young02036). A balance naming none leaves the config's list.
|
|
2382
|
+
if (start && giftNames(gift).length) ms = ms.filter((m) => giftNames(gift).some((x) => x.toLowerCase() === m.id.toLowerCase()))
|
|
2358
2383
|
const url = s.base + "/v1"
|
|
2359
2384
|
const out = Object.fromEntries(ms.map((m) => [m.id, model(m, url)]))
|
|
2360
2385
|
const details = [...ms, ...modelsOf(cfg, planID(START_BASE)), ...modelsOf(cfg, planID(ZAI_BASE)), ...MODELS]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-zcode-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"description": "OpenCode provider plugin: signs in to Z.ai's or BigModel's (智谱) GLM Coding Plan as ZCode does, including team seats and ZCode's Start Plan, and claims its gift plans daily",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./opencode.mjs",
|