@magpie-community/opencode-zcode-auth 0.1.67 → 0.1.69
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 +33 -26
- package/index.mjs +131 -48
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -295,18 +295,23 @@ which it is answered here with the queue's 429. A request refused alone,
|
|
|
295
295
|
or free first's gift (which goes to the coding plan), is answered as
|
|
296
296
|
before.
|
|
297
297
|
|
|
298
|
-
##
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
298
|
+
## Every account, one address
|
|
299
|
+
|
|
300
|
+
The plugin declares no `maxAccounts`, so magpie sends requests to every
|
|
301
|
+
ZCode account of the user's: the routing chosen spreads them, and one
|
|
302
|
+
that runs out or fails rests while the others go on. A user who wants
|
|
303
|
+
fewer sets the number on the provider in magpie (Advanced → Accounts at
|
|
304
|
+
once, or `magpie provider at-once zcode <n>`).
|
|
305
|
+
|
|
306
|
+
What zcode.z.ai's firewall refuses an address for (405, for an hour or
|
|
307
|
+
two) is too many Start Plan requests in flight from it at once, whichever
|
|
308
|
+
accounts they are for. So besides each account's three, the Start Plan
|
|
309
|
+
is sent at most six requests at a time from this computer over all its
|
|
310
|
+
accounts; the rest wait their turn in the plugin, as an account's own do.
|
|
311
|
+
Six is what two accounts sent when 0.1.40 to 0.1.67 declared
|
|
312
|
+
`maxAccounts` two after a 405 with three (01huadalang on Discord), which
|
|
313
|
+
held a user's other accounts in reserve. The coding plan, on another
|
|
314
|
+
host, is held to none of it.
|
|
310
315
|
|
|
311
316
|
## The usage card
|
|
312
317
|
|
|
@@ -374,20 +379,22 @@ polling with the feed alone, and the feed is gated on the client's
|
|
|
374
379
|
version, so the plugin asks as the current client (3.17.2) sends — and
|
|
375
380
|
posts each plan the feed offers to
|
|
376
381
|
`POST /api/v1/zcode-plan/billing/claim` (`{"plan_id": …}`) with the
|
|
377
|
-
account's ZCode session, as the app does.
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
the
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
382
|
+
account's ZCode session, as the app does. ZCode drops plans into the
|
|
383
|
+
feed on its own schedule through the day (a weekend banner starting at
|
|
384
|
+
19:00 Beijing, and another at 19:30, say), and one that arrives after the
|
|
385
|
+
day's ask used to sit unclaimed past its short life. So an answer of
|
|
386
|
+
nothing to claim, a claim, a done and an ineligible each carry an
|
|
387
|
+
`until` half an hour out, and magpie's loop asks again then, all day —
|
|
388
|
+
one GET of the feed each time. A recheck posts only plans the account
|
|
389
|
+
has no answer for yet that day: a plan claimed, answered 1003 or held
|
|
390
|
+
for the captcha is never posted again, so its captcha is not asked for
|
|
391
|
+
again and no claim ZCode already answered is repeated. With nothing new
|
|
392
|
+
after the day's claim, the answer is *done*: the card keeps "Checked in
|
|
393
|
+
today" rather than "No check-in event now" (a claimed plan leaves the
|
|
394
|
+
feed). An ineligible (code 1004, below) is posted again on the next
|
|
395
|
+
recheck, as it may be offered later. The day's answers live in memory
|
|
396
|
+
and end with the Beijing day: after a magpie restart, a plan still in
|
|
397
|
+
the feed is posted once more and answers 1003, *done*. The answer is judged by
|
|
391
398
|
the body's code, not the HTTP status:
|
|
392
399
|
|
|
393
400
|
- nothing listed: *inactive* (ZCode answers an account with nothing to
|
package/index.mjs
CHANGED
|
@@ -980,25 +980,49 @@ async function toClaim(s) {
|
|
|
980
980
|
return { plans, unread, rate: null }
|
|
981
981
|
}
|
|
982
982
|
|
|
983
|
-
// RECHECK is how long an
|
|
984
|
-
// asks again: ZCode drops gift plans into the feed during
|
|
985
|
-
//
|
|
986
|
-
//
|
|
987
|
-
//
|
|
988
|
-
//
|
|
989
|
-
//
|
|
990
|
-
//
|
|
991
|
-
//
|
|
992
|
-
//
|
|
993
|
-
//
|
|
994
|
-
//
|
|
995
|
-
//
|
|
996
|
-
//
|
|
997
|
-
//
|
|
998
|
-
//
|
|
983
|
+
// RECHECK is how long an answer that leaves the day open stands before
|
|
984
|
+
// magpie's loop asks again: ZCode drops gift plans into the feed during
|
|
985
|
+
// the day on its own schedule (the weekend plan of
|
|
986
|
+
// testdata/touch-1030-wk.json starts 19:00 Beijing; @aaron0x10 on X,
|
|
987
|
+
// 11-22: a second one follows at 19:30), and the day's ask may have run
|
|
988
|
+
// hours before, so an answer settled for the day lets a plan sit
|
|
989
|
+
// unclaimed past its short life. `until` wakes the loop again in half an
|
|
990
|
+
// hour, and it asks again all day — one GET each time. That holds after a
|
|
991
|
+
// claim too (claimed, done): the recheck posts only plans this account
|
|
992
|
+
// has no answer for today (dayAnswers), so a plan claimed, answered 1003
|
|
993
|
+
// or held for the captcha is never posted again, and one that has left
|
|
994
|
+
// the feed is still the day's claim — answered done, so the card keeps
|
|
995
|
+
// "Checked in today" instead of flipping to "No check-in event now". A
|
|
996
|
+
// captcha needs no until: magpie leaves it for the day, as it waits on
|
|
997
|
+
// the user. A failed needs none either: magpie asks a failed again after
|
|
998
|
+
// 30 minutes of its own. The same shape as Qoder's campaign that opens
|
|
999
|
+
// mid-day, asked again on magpie's side there (yetone/magpie#2696).
|
|
999
1000
|
const RECHECK_MS = 30 * 60_000
|
|
1000
1001
|
const recheck = () => new Date(Date.now() + RECHECK_MS).toISOString()
|
|
1001
1002
|
|
|
1003
|
+
// dayAnswers is what each account's plans answered today (Beijing):
|
|
1004
|
+
// holdKey -> { day, plans: Map(plan_id -> { name, outcome }) }, for the
|
|
1005
|
+
// answers that settle a plan for the day — claimed, done (1003) and
|
|
1006
|
+
// captcha (3007). A recheck posts only plans not in it, so none of those
|
|
1007
|
+
// is asked again; an ineligible or failed one is not kept, and is asked
|
|
1008
|
+
// again. It lives in this process's memory: a magpie restart forgets it,
|
|
1009
|
+
// and the next check-in posts a plan still in the feed once more (1003,
|
|
1010
|
+
// done, as before).
|
|
1011
|
+
const dayAnswers = new Map()
|
|
1012
|
+
const SETTLES = new Set(["claimed", "done", "captcha"])
|
|
1013
|
+
const uniq = (xs) => [...new Set(xs)]
|
|
1014
|
+
const beijingDay = () => new Date(Date.now() + 8 * 3600_000).toISOString().slice(0, 10)
|
|
1015
|
+
function answersToday(s) {
|
|
1016
|
+
const k = holdKey(s), day = beijingDay()
|
|
1017
|
+
let a = dayAnswers.get(k)
|
|
1018
|
+
if (!a || a.day !== day) dayAnswers.set(k, (a = { day, plans: new Map() }))
|
|
1019
|
+
return a.plans
|
|
1020
|
+
}
|
|
1021
|
+
// resetDayAnswers is for tests: it forgets every account's answers today.
|
|
1022
|
+
export function resetDayAnswers() {
|
|
1023
|
+
dayAnswers.clear()
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1002
1026
|
// claimDaily claims every gift plan ZCode offers the account (#503:
|
|
1003
1027
|
// toClaim, the app's banners and its preview), as auth.checkin's answer:
|
|
1004
1028
|
// inactive when neither lists one, claimed when one was claimed now,
|
|
@@ -1016,9 +1040,10 @@ const recheck = () => new Date(Date.now() + RECHECK_MS).toISOString()
|
|
|
1016
1040
|
// v0.1.3165 honors a failed's `until` itself; older versions wait for
|
|
1017
1041
|
// this hold, which is why it stays.
|
|
1018
1042
|
// A failed one is asked again later in the
|
|
1019
|
-
// day
|
|
1020
|
-
//
|
|
1021
|
-
//
|
|
1043
|
+
// day. An inactive, ineligible, claimed or done stands only until
|
|
1044
|
+
// RECHECK_MS from now, so a plan dropped into the feed later in the day
|
|
1045
|
+
// is still claimed; a plan answered today (dayAnswers) is not posted
|
|
1046
|
+
// again, and after the day's claim an ask that finds nothing new is done
|
|
1022
1047
|
// (see RECHECK).
|
|
1023
1048
|
// Nothing here marks the account: a failed claim keeps its sign-in.
|
|
1024
1049
|
async function claimDaily(s) {
|
|
@@ -1035,14 +1060,23 @@ async function claimDaily(s) {
|
|
|
1035
1060
|
const message = unread.join("; ") || "ZCode rate limited this account"
|
|
1036
1061
|
return { outcome: "failed", message, until: noteRateLimit(holdKey(s), rate, message) }
|
|
1037
1062
|
}
|
|
1063
|
+
// the plans this account answered for already today: never posted again
|
|
1064
|
+
const today = answersToday(s)
|
|
1065
|
+
const checkedToday = () => [...today.values()].filter((a) => a.outcome === "claimed" || a.outcome === "done").map((a) => a.name)
|
|
1066
|
+
const fresh = plans.filter((p) => !today.has(p.plan_id))
|
|
1038
1067
|
// the feed answered and no claim is read: the wait is over. It is not
|
|
1039
1068
|
// forgotten before the claims below, so a claim ZCode keeps limiting
|
|
1040
1069
|
// waits longer each time (see noteRateLimit)
|
|
1041
|
-
if (!
|
|
1070
|
+
if (!fresh.length) {
|
|
1042
1071
|
rateWait.delete(holdKey(s))
|
|
1043
|
-
return unread.
|
|
1044
|
-
|
|
1045
|
-
|
|
1072
|
+
if (unread.length) return { outcome: "failed", message: unread.join("; ") }
|
|
1073
|
+
// nothing new since the day's claim: still checked in today, and
|
|
1074
|
+
// looked at again half an hour out (see RECHECK)
|
|
1075
|
+
const had = checkedToday()
|
|
1076
|
+
if (had.length) return { outcome: "done", message: `already claimed: ${uniq(had).join(", ")}`, until: recheck() }
|
|
1077
|
+
// only plans held for the captcha, still listed: named again, not posted
|
|
1078
|
+
if (plans.length) return { outcome: "captcha", message: plans.map((p) => `${p.name}: claim it in the ZCode app (${today.get(p.plan_id).why})`).join("; ") }
|
|
1079
|
+
return { outcome: "inactive", message: "no ZCode gift plan to claim", until: recheck() }
|
|
1046
1080
|
}
|
|
1047
1081
|
// a claim ZCode guards with its security check is not posted: the app
|
|
1048
1082
|
// passes it before each claim and sends the proof in a header, which
|
|
@@ -1059,11 +1093,15 @@ async function claimDaily(s) {
|
|
|
1059
1093
|
}
|
|
1060
1094
|
if (guarded !== false) {
|
|
1061
1095
|
rateWait.delete(holdKey(s))
|
|
1062
|
-
if (guarded === null) return { outcome: "failed", message: [...
|
|
1063
|
-
return { outcome: "captcha", message:
|
|
1096
|
+
if (guarded === null) return { outcome: "failed", message: [...fresh.map((p) => `${p.name}: not claimed, ZCode's security check for claims can't be read`), ...unread].join("; ") }
|
|
1097
|
+
return { outcome: "captcha", message: fresh.map((p) => `${p.name}: ${CAPTCHA_CLAIM}`).join("; ") }
|
|
1064
1098
|
}
|
|
1065
1099
|
const got = []
|
|
1066
|
-
for (const p of
|
|
1100
|
+
for (const p of fresh) {
|
|
1101
|
+
const g = { name: p.name, ...(await claimOne(s, p.plan_id)) }
|
|
1102
|
+
if (SETTLES.has(g.outcome)) today.set(p.plan_id, { name: p.name, outcome: g.outcome, why: g.why })
|
|
1103
|
+
got.push(g)
|
|
1104
|
+
}
|
|
1067
1105
|
const named = (o) => got.filter((g) => g.outcome === o).map((g) => g.name)
|
|
1068
1106
|
const claimed = named("claimed")
|
|
1069
1107
|
const said = [
|
|
@@ -1082,12 +1120,16 @@ async function claimDaily(s) {
|
|
|
1082
1120
|
// a list that didn't read may hold a plan not claimed: asked again
|
|
1083
1121
|
if (unread.length || got.some((g) => g.outcome === "failed")) return { outcome: "failed", message: said }
|
|
1084
1122
|
if (got.some((g) => g.outcome === "captcha")) return { outcome: "captcha", message: said }
|
|
1085
|
-
|
|
1123
|
+
// claimed and done keep looking for the day's later plans (see RECHECK)
|
|
1124
|
+
if (claimed.length) return { outcome: "claimed", message: said, until: recheck() }
|
|
1125
|
+
const had = checkedToday()
|
|
1126
|
+
const notOffered = got.filter((g) => g.outcome === "ineligible").map((g) => `${g.name}: ${g.why}`)
|
|
1086
1127
|
// a plan not offered now can be offered later in the day (11-04: an
|
|
1087
1128
|
// account's GLOBAL BUILD banner showed 28 minutes after it signed in),
|
|
1088
|
-
// so an ineligible is read again half an hour out, as an inactive is
|
|
1089
|
-
|
|
1090
|
-
return { outcome: "
|
|
1129
|
+
// so an ineligible is read again half an hour out, as an inactive is;
|
|
1130
|
+
// after the day's claim the card stays checked in
|
|
1131
|
+
if (!had.length) return { outcome: "ineligible", message: said, until: recheck() }
|
|
1132
|
+
return { outcome: "done", message: [`already claimed: ${uniq(had).join(", ")}`, ...notOffered].join("; "), until: recheck() }
|
|
1091
1133
|
}
|
|
1092
1134
|
|
|
1093
1135
|
// GIFT_SIGN_IN is the card's line for an account whose gift plans can't
|
|
@@ -2124,13 +2166,16 @@ function kept(res, text) {
|
|
|
2124
2166
|
// the number declared below (DEFAULT_CONCURRENCY, on the auth hook and in
|
|
2125
2167
|
// package.json), which a user raises on the account.
|
|
2126
2168
|
const DEFAULT_CONCURRENCY = 3
|
|
2127
|
-
//
|
|
2128
|
-
//
|
|
2129
|
-
//
|
|
2130
|
-
//
|
|
2131
|
-
//
|
|
2132
|
-
//
|
|
2133
|
-
|
|
2169
|
+
// No maxAccounts is declared: magpie sends requests to every ZCode account
|
|
2170
|
+
// of the user's, and a user still sets their own on the provider (Accounts
|
|
2171
|
+
// at once). 0.1.40 to 0.1.67 declared two, after 01huadalang's address was
|
|
2172
|
+
// refused with a 405 while three accounts took requests at once (Discord),
|
|
2173
|
+
// and the others sat in reserve until one ran out: a user with five gift
|
|
2174
|
+
// accounts saw two used (mathfournity on X). What the edge firewall counts
|
|
2175
|
+
// is this address's Start Plan requests in flight, not its accounts (see
|
|
2176
|
+
// busyHold), so that is what is held now, over every account (startGate's
|
|
2177
|
+
// address): as many as two accounts had in flight before, while a coding
|
|
2178
|
+
// plan account, on another host, is held to none of it.
|
|
2134
2179
|
const BUSY_CODES = new Set(["3008", "3009", "3010"])
|
|
2135
2180
|
// BUSY_WAITS are the waits before each ask again: ZCode's own client's,
|
|
2136
2181
|
// 1s and 2s (kqo in its bundle). Past them the cap goes back to magpie,
|
|
@@ -2172,11 +2217,18 @@ const BUSY_HINT =
|
|
|
2172
2217
|
// narrow is kept apart from lanes, which go when idle; now is its clock,
|
|
2173
2218
|
// injectable for tests.
|
|
2174
2219
|
const NARROW_FOR = 5 * 60_000
|
|
2175
|
-
const startGate = { inflight: 3, wait: 120_000, lanes: new Map(), narrow: new Map(), now: () => Date.now() }
|
|
2220
|
+
const startGate = { inflight: 3, address: 6, wait: 120_000, lanes: new Map(), narrow: new Map(), now: () => Date.now() }
|
|
2221
|
+
// ADDRESS is the lane every account's Start Plan requests share as well as
|
|
2222
|
+
// their own: zcode.z.ai sees one address, and its firewall refused the whole
|
|
2223
|
+
// of it with 405 once ~10 were in flight (busyHold). startGate.address is
|
|
2224
|
+
// six, what two accounts of three each sent when the plugin declared
|
|
2225
|
+
// maxAccounts two, which no 405 followed. It is never narrowed.
|
|
2226
|
+
const ADDRESS = "\0address"
|
|
2176
2227
|
|
|
2177
2228
|
// limitOf is how many of the account's Start Plan requests go at once: the
|
|
2178
2229
|
// gate's number, or less while the account is narrowed.
|
|
2179
2230
|
function limitOf(key) {
|
|
2231
|
+
if (key === ADDRESS) return startGate.address
|
|
2180
2232
|
const n = startGate.narrow.get(key)
|
|
2181
2233
|
if (!n) return startGate.inflight
|
|
2182
2234
|
if (startGate.now() >= n.until) {
|
|
@@ -2256,6 +2308,34 @@ function startSlot(key, signal, { wait = startGate.wait, front = false } = {}) {
|
|
|
2256
2308
|
})
|
|
2257
2309
|
}
|
|
2258
2310
|
|
|
2311
|
+
// startSlots waits for a slot of the account's, then one of the address's
|
|
2312
|
+
// (ADDRESS), both within the one wait: { release } letting both go, or
|
|
2313
|
+
// { key } naming the lane whose wait ran out, nothing held. Every request
|
|
2314
|
+
// takes the account's first, so one holding the address's never waits for
|
|
2315
|
+
// an account's.
|
|
2316
|
+
async function startSlots(key, signal, { wait = startGate.wait, front = false } = {}) {
|
|
2317
|
+
const until = Date.now() + wait
|
|
2318
|
+
const mine = await startSlot(key, signal, { wait, front })
|
|
2319
|
+
if (!mine) return { key }
|
|
2320
|
+
let all
|
|
2321
|
+
try {
|
|
2322
|
+
all = await startSlot(ADDRESS, signal, { wait: until - Date.now(), front })
|
|
2323
|
+
} catch (e) {
|
|
2324
|
+
mine.release()
|
|
2325
|
+
throw e
|
|
2326
|
+
}
|
|
2327
|
+
if (!all) {
|
|
2328
|
+
mine.release()
|
|
2329
|
+
return { key: ADDRESS }
|
|
2330
|
+
}
|
|
2331
|
+
return {
|
|
2332
|
+
release() {
|
|
2333
|
+
all.release()
|
|
2334
|
+
mine.release()
|
|
2335
|
+
},
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2259
2339
|
// released hands res on and lets its slot go once ZCode's answer has come
|
|
2260
2340
|
// to its end, failed, or been given up on (the agent's abort, the reader's
|
|
2261
2341
|
// cancel) — the request is in flight at ZCode until then. The answer is read
|
|
@@ -2299,9 +2379,12 @@ function released(res, slot, signal) {
|
|
|
2299
2379
|
// so it tries the next account, and a short Retry-After.
|
|
2300
2380
|
function startQueueAnswer(key) {
|
|
2301
2381
|
const n = limitOf(key)
|
|
2382
|
+
const s = n === 1 ? "" : "s"
|
|
2302
2383
|
const error = {
|
|
2303
2384
|
type: "rate_limit_error",
|
|
2304
|
-
message:
|
|
2385
|
+
message: key === ADDRESS
|
|
2386
|
+
? `ZCode's free Start Plan is sent ${n} request${s} at a time from this computer, over all its accounts, as more get the address refused; this one waited ${Math.round(startGate.wait / 1000)}s behind the others and was not sent. Run fewer agents or subagents on ZCode at once, or try again`
|
|
2387
|
+
: `ZCode's free Start Plan serves this account ${n} request${s} at a time; this one waited ${Math.round(startGate.wait / 1000)}s behind the others and was not sent. Run fewer agents or subagents on ZCode at once, or try again`,
|
|
2305
2388
|
}
|
|
2306
2389
|
return new Response(JSON.stringify({ type: "error", error }), {
|
|
2307
2390
|
status: 429, statusText: STATUS_TEXT[429], headers: { "content-type": "application/json", "retry-after": "5" },
|
|
@@ -3090,9 +3173,6 @@ export async function ZCodeAuthPlugin({ client, magpie } = {}, options = {}) {
|
|
|
3090
3173
|
// of day, and a user who knows theirs can raise this on the account.
|
|
3091
3174
|
// The Start Plan has the plugin's own gate below it (startGate)
|
|
3092
3175
|
maxConcurrency: DEFAULT_CONCURRENCY,
|
|
3093
|
-
// how many accounts take requests at once, the others in reserve
|
|
3094
|
-
// (DEFAULT_ACCOUNTS); a magpie that doesn't read it uses them all
|
|
3095
|
-
maxAccounts: DEFAULT_ACCOUNTS,
|
|
3096
3176
|
// magpie's own switches (OpenCode never reads auth.options), read at
|
|
3097
3177
|
// each request through input.magpie
|
|
3098
3178
|
options: [
|
|
@@ -3194,7 +3274,7 @@ export async function ZCodeAuthPlugin({ client, magpie } = {}, options = {}) {
|
|
|
3194
3274
|
m = raw
|
|
3195
3275
|
forcedGift = true
|
|
3196
3276
|
giftName = giftID(raw)
|
|
3197
|
-
} else if (!alone && !edgeHeld() && !busyHeld() && !startFull(gateKey) && freeFirst(provider?.options) && s.jwt && known && giftUsable(s, known, m) && !giftSidelined(s, m)) {
|
|
3277
|
+
} else if (!alone && !edgeHeld() && !busyHeld() && !startFull(gateKey) && !startFull(ADDRESS) && freeFirst(provider?.options) && s.jwt && known && giftUsable(s, known, m) && !giftSidelined(s, m)) {
|
|
3198
3278
|
// free first: the plain model spends the account's own live
|
|
3199
3279
|
// gift before it spends the coding plan, under the name the
|
|
3200
3280
|
// gift lists. The gift is the route's cache alone (a failed
|
|
@@ -3308,9 +3388,10 @@ export async function ZCodeAuthPlugin({ client, magpie } = {}, options = {}) {
|
|
|
3308
3388
|
// the account's Start Plan slots (startGate): a request past them
|
|
3309
3389
|
// waits here for one rather than being sent to be refused
|
|
3310
3390
|
if (start) {
|
|
3311
|
-
|
|
3391
|
+
const got = await startSlots(gateKey, opts.signal)
|
|
3312
3392
|
own.signal = opts.signal
|
|
3313
|
-
if (!
|
|
3393
|
+
if (!got.release) return kept(startQueueAnswer(got.key))
|
|
3394
|
+
own.slot = got
|
|
3314
3395
|
// a hold may have armed while it waited
|
|
3315
3396
|
if (edgeHeld()) return kept(edgeHeldAnswer())
|
|
3316
3397
|
if (busyHeld()) return kept(busyHeldAnswer())
|
|
@@ -3373,8 +3454,10 @@ export async function ZCodeAuthPlugin({ client, magpie } = {}, options = {}) {
|
|
|
3373
3454
|
const until = Date.now() + startGate.wait
|
|
3374
3455
|
for (let turn = 0; res.requeue && !freeGift && turn < REQUEUE_MAX; turn++) {
|
|
3375
3456
|
own.slot?.release()
|
|
3376
|
-
own.slot =
|
|
3377
|
-
|
|
3457
|
+
own.slot = null
|
|
3458
|
+
const got = await startSlots(gateKey, opts.signal, { wait: until - Date.now(), front: true })
|
|
3459
|
+
if (!got.release) return kept(startQueueAnswer(got.key))
|
|
3460
|
+
own.slot = got
|
|
3378
3461
|
if (edgeHeld()) return kept(edgeHeldAnswer())
|
|
3379
3462
|
if (busyHeld()) return kept(busyHeldAnswer())
|
|
3380
3463
|
res = await askBusy(url, opts, h, () => busyCap(gateKey))
|
|
@@ -3588,4 +3671,4 @@ export async function ZCodeAuthPlugin({ client, magpie } = {}, options = {}) {
|
|
|
3588
3671
|
// config sets what zcodeConfig has read, for tests: null is ZCode's config
|
|
3589
3672
|
// out of reach, undefined forgets it
|
|
3590
3673
|
const config = (cfg) => (cfgCache = cfg === undefined ? null : { cfg, at: Date.now() })
|
|
3591
|
-
export const _internal = { wallAnswer, unreached, planFull, notePlan, planFullUntil, locatedKeys, lastKeys, edge, EDGE_HOLD, busyHold, startGate, NARROW_FOR, limitOf, BUSY_N, BUSY_WINDOW, BUSY_HOLD, busyCap, busyHeld, config, entry, limitWindows, termOf, startUsage, routes, blocked, sidelined, plansOf, giftOf, dualUsage, claimHint, unclaimed, unclaimedSeen, aloneGift, aloneSeen, aloneNames, claimDaily, spentUp, giftServes, modelOf, teamKeys, ownSignIn, stateOf, giftSignIn, located, dress, queryOf, PROMPT, marked, keyDevice, sessionOf, busy, BUSY_WAITS, DEFAULT_CONCURRENCY,
|
|
3674
|
+
export const _internal = { wallAnswer, unreached, planFull, notePlan, planFullUntil, locatedKeys, lastKeys, edge, EDGE_HOLD, busyHold, startGate, NARROW_FOR, limitOf, BUSY_N, BUSY_WINDOW, BUSY_HOLD, busyCap, busyHeld, config, entry, limitWindows, termOf, startUsage, routes, blocked, sidelined, plansOf, giftOf, dualUsage, claimHint, unclaimed, unclaimedSeen, aloneGift, aloneSeen, aloneNames, claimDaily, spentUp, giftServes, modelOf, teamKeys, ownSignIn, stateOf, giftSignIn, located, dress, queryOf, PROMPT, marked, keyDevice, sessionOf, busy, BUSY_WAITS, DEFAULT_CONCURRENCY, ADDRESS, startSlots }
|
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.69",
|
|
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",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"directory": "packages/zcode"
|
|
15
15
|
},
|
|
16
16
|
"magpie": {
|
|
17
|
-
"maxConcurrency": 3
|
|
18
|
-
"maxAccounts": 2
|
|
17
|
+
"maxConcurrency": 3
|
|
19
18
|
}
|
|
20
19
|
}
|