@magpie-community/opencode-zcode-auth 0.1.39 → 0.1.40

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 +13 -0
  2. package/index.mjs +11 -1
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -196,6 +196,19 @@ number written into the plugin would hold a Max account to a Lite one's
196
196
  with no way to raise it. A user who knows their plan's cap sets it on the
197
197
  account or the provider in magpie, and magpie's queue follows that.
198
198
 
199
+ ## Two accounts at once
200
+
201
+ Three ZCode accounts used at once from one address can get the address
202
+ refused with a 405, where two are served (01huadalang on Discord). So the
203
+ plugin declares `maxAccounts` two, on the auth hook and as
204
+ `magpie.maxAccounts` in its `package.json`: magpie sends requests to the
205
+ first two accounts of the user's list only, and holds the others in
206
+ reserve. One that runs out or fails rests, and the first in reserve takes
207
+ its place until it is back. A user changes the number on the provider in
208
+ magpie (Advanced → Accounts at once, or `magpie provider at-once zcode
209
+ <n>`), 0 for every account at once. A magpie older than the one that
210
+ reads it uses every account, as before.
211
+
199
212
  ## The usage card
200
213
 
201
214
  An account with both plans shows both allowances: the coding plan's
package/index.mjs CHANGED
@@ -1746,6 +1746,13 @@ function kept(res, text) {
1746
1746
  // (https://docs.z.ai/devpack/usage-policy), so a number written here would
1747
1747
  // hold a Max account to a Lite one's, with no way for the user to raise it.
1748
1748
  const DEFAULT_CONCURRENCY = 3
1749
+ // DEFAULT_ACCOUNTS is how many of a user's ZCode accounts magpie sends
1750
+ // requests to at the same time (maxAccounts, on the auth hook and in
1751
+ // package.json): the first in the user's list, the next taking over once
1752
+ // one runs out or fails. 01huadalang on Discord: three accounts used at
1753
+ // once from one address got the address refused with a 405, two didn't. A
1754
+ // user sets their own on the provider (Accounts at once), 0 for no limit.
1755
+ const DEFAULT_ACCOUNTS = 2
1749
1756
  const BUSY_CODES = new Set(["3008", "3009"])
1750
1757
  // BUSY_WAITS are the waits between asks, longest last: about ten seconds of
1751
1758
  // them. Past that the account is saturated rather than busy, and magpie's
@@ -2294,6 +2301,9 @@ export async function ZCodeAuthPlugin({ client }, options = {}) {
2294
2301
  // own cap follows its tier (Max > Pro > Lite) and the time of day, and
2295
2302
  // a user who knows theirs can raise this on the account
2296
2303
  maxConcurrency: DEFAULT_CONCURRENCY,
2304
+ // how many accounts take requests at once, the others in reserve
2305
+ // (DEFAULT_ACCOUNTS); a magpie that doesn't read it uses them all
2306
+ maxAccounts: DEFAULT_ACCOUNTS,
2297
2307
  async loader(getAuth, provider) {
2298
2308
  const s0 = stateOf(await getAuth())
2299
2309
  if (!s0) return {}
@@ -2650,4 +2660,4 @@ export async function ZCodeAuthPlugin({ client }, options = {}) {
2650
2660
  // config sets what zcodeConfig has read, for tests: null is ZCode's config
2651
2661
  // out of reach, undefined forgets it
2652
2662
  const config = (cfg) => (cfgCache = cfg === undefined ? null : { cfg, at: Date.now() })
2653
- export const _internal = { config, entry, limitWindows, termOf, startUsage, routes, blocked, plansOf, giftOf, dualUsage, claimHint, claimDaily, spentUp, giftServes, modelOf, teamKeys, ownSignIn, stateOf, located, dress, PROMPT, marked, keyDevice, sessionOf, busy, BUSY_WAITS, DEFAULT_CONCURRENCY }
2663
+ export const _internal = { config, entry, limitWindows, termOf, startUsage, routes, blocked, plansOf, giftOf, dualUsage, claimHint, claimDaily, spentUp, giftServes, modelOf, teamKeys, ownSignIn, stateOf, located, dress, PROMPT, marked, keyDevice, sessionOf, busy, BUSY_WAITS, DEFAULT_CONCURRENCY, DEFAULT_ACCOUNTS }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-zcode-auth",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
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": "./index.mjs",
@@ -14,6 +14,7 @@
14
14
  "directory": "packages/zcode"
15
15
  },
16
16
  "magpie": {
17
- "maxConcurrency": 3
17
+ "maxConcurrency": 3,
18
+ "maxAccounts": 2
18
19
  }
19
20
  }