maxpool 1.24.55 → 1.24.56
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/package.json +1 -1
- package/src/account-manager.js +14 -3
- package/src/server.js +14 -1
package/package.json
CHANGED
package/src/account-manager.js
CHANGED
|
@@ -3437,12 +3437,23 @@ export class AccountManager {
|
|
|
3437
3437
|
if (account.type === 'provider') {
|
|
3438
3438
|
const sesUsed = q.providerSes != null ? clamp01(q.providerSes) : null;
|
|
3439
3439
|
const wkUsed = q.providerWk != null ? clamp01(q.providerWk) : null;
|
|
3440
|
-
|
|
3440
|
+
// The WEEKLY ladder tiers on the weekly window ALONE when the plan HAS one
|
|
3441
|
+
// (owner 2026-10-30: GLM serves to 100% of the session window; the old
|
|
3442
|
+
// Math.max(ses, wk) demoted a 97%-session / 20%-weekly key to 'critical' —
|
|
3443
|
+
// last-resort behind every Claude account with four-fifths of its weekly
|
|
3444
|
+
// window empty — council review 2026-10-31). A weeklyAbsent plan (providerWk
|
|
3445
|
+
// null: z.ai unlimited-weekly) keeps its historical ses-driven tiering — the
|
|
3446
|
+
// session window is its ONLY quota signal. Session availability otherwise
|
|
3447
|
+
// belongs to _isSessionQuotaUnavailable + PROVIDER_SES_WALL.
|
|
3448
|
+
const used = wkUsed != null ? wkUsed : (sesUsed ?? 0);
|
|
3441
3449
|
// USAGE CAP — checked FIRST, before every tier: a reservation is owner intent
|
|
3442
3450
|
// and outranks both the tier ladder and the upstream verdict. There is no
|
|
3443
3451
|
// upstreamAllows carve-out for providers anyway, but the ordering documents
|
|
3444
|
-
// that a cap can never be talked out of by the vendor's "allowed".
|
|
3445
|
-
|
|
3452
|
+
// that a cap can never be talked out of by the vendor's "allowed". The cap
|
|
3453
|
+
// reads the WORST window (max of ses/wk): a z.ai cap bounds total spend, and
|
|
3454
|
+
// the 5h reading is real consumption against it.
|
|
3455
|
+
const capUsed = Math.max(sesUsed ?? 0, wkUsed ?? 0);
|
|
3456
|
+
if (this._capped(account, capUsed, 'wk', now)) return 'capped';
|
|
3446
3457
|
if (used >= this.scheduler.weeklyExhaustedThreshold) return 'exhausted';
|
|
3447
3458
|
if (used >= this.scheduler.weeklyCriticalThreshold) return 'critical';
|
|
3448
3459
|
if (used >= this.scheduler.weeklyReserveThreshold) return 'reserve';
|
package/src/server.js
CHANGED
|
@@ -358,10 +358,17 @@ export function createProxyServer(accountManager, config, hooks = {}) {
|
|
|
358
358
|
});
|
|
359
359
|
// Keep the in-memory config mirror in step so a later TUI saveConfig
|
|
360
360
|
// can't clobber the fresh tokens with stale ones.
|
|
361
|
-
const mem = config.accounts.find(a => a.accountUuid === acct.accountUuid);
|
|
361
|
+
const mem = (config.accounts || []).find(a => a.accountUuid === acct.accountUuid);
|
|
362
362
|
if (mem) Object.assign(mem, tokenFields);
|
|
363
363
|
} catch (err) {
|
|
364
|
+
// A single-use credential write is only "ok" when it is DURABLE: the browser
|
|
365
|
+
// login may have invalidated the previous refresh token, so memory-only means
|
|
366
|
+
// a restart bricks the account while both sides recorded success (council
|
|
367
|
+
// review 2026-10-31). Tell the caller to retry instead of claiming Done.
|
|
364
368
|
console.error(`[Maxpool] Remote inject persisted to memory but NOT disk for uuid ${acct.accountUuid.slice(0, 8)}: ${err?.message || err}`);
|
|
369
|
+
res.writeHead(507, { 'Content-Type': 'application/json' });
|
|
370
|
+
res.end(JSON.stringify({ ok: false, error: 'not_persisted', message: 'Saved in memory only — the pool could not write it to disk. Log in again.' }));
|
|
371
|
+
return;
|
|
365
372
|
}
|
|
366
373
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
367
374
|
res.end(JSON.stringify({ ok: true, result: amAcct ? 'reauthed' : 'added', name: amAcct ? amAcct.name : (acct.name || acct.accountUuid.slice(0, 8)) }));
|
|
@@ -477,6 +484,12 @@ export function createProxyServer(accountManager, config, hooks = {}) {
|
|
|
477
484
|
// caller can't steer routing. Applied by selection as an exclusive filter.
|
|
478
485
|
const pin = headerValue(req.headers, 'x-maxpool-pin-account');
|
|
479
486
|
if (pin && req.callerName && req.callerName !== 'legacy-key') requestInfo.pinAccount = String(pin);
|
|
487
|
+
else if (pin) {
|
|
488
|
+
// A pin from a legacy-key link is silently dropped — the local pool has
|
|
489
|
+
// already made mirror-specific decisions on it. Name the misconfiguration
|
|
490
|
+
// once instead (council review 2026-10-31: no warning fired anywhere).
|
|
491
|
+
console.error('[Maxpool] x-maxpool-pin-account dropped: the link authenticated with the remote\'s legacy apiKey — mint a named client key (proxy.clients) so pins and per-person attribution work');
|
|
492
|
+
}
|
|
480
493
|
requestInfo.sessionKey = headerValue(req.headers, 'x-maxpool-session');
|
|
481
494
|
requestInfo.caller = req._caller || null;
|
|
482
495
|
// The CLIENT tells us how long it will wait — the only source that is actually
|