maxpool 1.24.61 → 1.24.63
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 +44 -47
- package/src/screen.html +1 -1
- package/src/server.js +1 -1
- package/src/tui.js +0 -3
package/package.json
CHANGED
package/src/account-manager.js
CHANGED
|
@@ -488,12 +488,12 @@ export class AccountManager {
|
|
|
488
488
|
index,
|
|
489
489
|
name: acct.name,
|
|
490
490
|
type: acct.type,
|
|
491
|
-
provider: acct.provider || (acct.type === 'provider' ? 'provider' :
|
|
491
|
+
provider: acct.provider || (acct.type === 'provider' ? 'provider' : 'anthropic'),
|
|
492
492
|
accountUuid: acct.accountUuid || null,
|
|
493
493
|
credential: acct.accessToken || acct.authToken || acct.apiKey,
|
|
494
494
|
upstream: acct.upstream || null,
|
|
495
495
|
authHeader: acct.authHeader || null,
|
|
496
|
-
profiles: acct.profiles || (acct.type === 'provider'
|
|
496
|
+
profiles: acct.profiles || (acct.type === 'provider' ? ['all'] : ['claude', 'all']),
|
|
497
497
|
priority: Number.isFinite(acct.priority) ? acct.priority : 0,
|
|
498
498
|
// USAGE CAP (owner-directed 2026-08-26): reserve capacity on this account —
|
|
499
499
|
// the proxy benches it at capUtilization of BOTH the 5h and 7d windows, keeping
|
|
@@ -1077,14 +1077,6 @@ export class AccountManager {
|
|
|
1077
1077
|
if (!l || l.lastError || l.lastOkAt == null) return false;
|
|
1078
1078
|
if (account.refreshDead || account.status === 'error') return false;
|
|
1079
1079
|
}
|
|
1080
|
-
// Pool link: available only while its last poll succeeded AND the remote has a
|
|
1081
|
-
// usable account — a down/empty team pool must not swallow requests that local
|
|
1082
|
-
// accounts could serve.
|
|
1083
|
-
if (account.type === 'pool') {
|
|
1084
|
-
const link = account._link;
|
|
1085
|
-
if (!link || link.lastError || link.lastOkAt == null) return false;
|
|
1086
|
-
if (!link.summary || link.summary.usable < 1) return false;
|
|
1087
|
-
}
|
|
1088
1080
|
const now = options.now ?? Date.now();
|
|
1089
1081
|
|
|
1090
1082
|
// Check rate limit expiry
|
|
@@ -2509,7 +2501,7 @@ export class AccountManager {
|
|
|
2509
2501
|
if (!this._isRequestCompatible(account, profile, requestInfo)) return false;
|
|
2510
2502
|
// Cloud mirrors egress from the cloud's own IP — this machine's upstream throttle
|
|
2511
2503
|
// and local queue fairness don't describe them.
|
|
2512
|
-
const providerLike = account.type === 'provider' ||
|
|
2504
|
+
const providerLike = account.type === 'provider' || Boolean(account.remote);
|
|
2513
2505
|
if (
|
|
2514
2506
|
!providerLike
|
|
2515
2507
|
&& this.queueState.waiting.length
|
|
@@ -2551,7 +2543,7 @@ export class AccountManager {
|
|
|
2551
2543
|
const incompatible = this._effectiveIncompatible(requestInfo).incompatible;
|
|
2552
2544
|
// An incompatible session is pinned to its provider family — no mode overrides that.
|
|
2553
2545
|
if (incompatible) {
|
|
2554
|
-
const isHome = (account.type === 'provider'
|
|
2546
|
+
const isHome = (account.type === 'provider')
|
|
2555
2547
|
&& (mode === 'prefer-zai' ? account.provider === 'zai'
|
|
2556
2548
|
: mode === 'prefer-kimi' ? account.provider === 'kimi' : true);
|
|
2557
2549
|
return isHome ? 0 : base;
|
|
@@ -2769,11 +2761,18 @@ export class AccountManager {
|
|
|
2769
2761
|
|
|
2770
2762
|
_isRequestCompatible(account, profile, requestInfo = {}) {
|
|
2771
2763
|
if (!this._matchesProfile(account, profile)) return false;
|
|
2772
|
-
// A
|
|
2764
|
+
// A cloud mirror carries Anthropic-API traffic only (/v1/…). Browser noise
|
|
2773
2765
|
// (favicon, stray GETs) must never be forwarded — on the remote it finds no
|
|
2774
2766
|
// route, queues up to the hold window, and pins a link lease the whole time
|
|
2775
2767
|
// (live-rehearsal 2026-10-29: 4 favicon GETs showed as "4 running").
|
|
2776
|
-
if (account.
|
|
2768
|
+
if (account.remote && !String(requestInfo.path || '').startsWith('/v1/')) return false;
|
|
2769
|
+
// A cloud mirror carries Anthropic-API traffic only (/v1/…). Browser noise
|
|
2770
|
+
// (favicon, stray GETs) must never be forwarded — on the remote it finds no
|
|
2771
|
+
// route, queues up to the hold window, and pins a link lease the whole time
|
|
2772
|
+
// (live-rehearsal 2026-10-29: 4 favicon GETs showed as "4 running"). This guard
|
|
2773
|
+
// used to key on the aggregate type:'pool' row; mirrors (account.remote) are the
|
|
2774
|
+
// only link rows now, so it moves to them.
|
|
2775
|
+
|
|
2777
2776
|
|
|
2778
2777
|
// Kimi (Moonshot) 400s on images Anthropic/GLM accept ("failed to decode
|
|
2779
2778
|
// image") — and a provider 400 is TERMINAL (not retried to another account), so
|
|
@@ -3012,21 +3011,6 @@ export class AccountManager {
|
|
|
3012
3011
|
// unchanged balancing logic — sees it as busy as it really is.
|
|
3013
3012
|
const inflight = account.activeWeight + reqWeight + (account._remoteOtherLoad || 0);
|
|
3014
3013
|
const refillMult = this._fastRefillMultiplier(account);
|
|
3015
|
-
if (account.type === 'pool' && account._link) {
|
|
3016
|
-
// Utilization = the cloud's own reported fraction of usable accounts spent
|
|
3017
|
-
// (weekly windows), so a near-exhausted cloud pool de-preferences like a
|
|
3018
|
-
// near-exhausted local account rather than pretending to be empty-fresh.
|
|
3019
|
-
const link = account._link;
|
|
3020
|
-
const remoteUtil = link.summary && link.summary.total
|
|
3021
|
-
? (link.summary.total - link.summary.usable) / link.summary.total : 0;
|
|
3022
|
-
// Same shape as a provider's weekly utilization cost, keyed to remote load.
|
|
3023
|
-
const remoteLoad = Math.max(account.activeWeight, link.status?.scheduler?.globalInFlight || 0);
|
|
3024
|
-
return (
|
|
3025
|
-
remoteLoad * this.scheduler.concurrencyWeight
|
|
3026
|
-
+ Math.max(0, remoteLoad - this.scheduler.perAccountConcurrencyTarget) * this.scheduler.capPenaltyWeight
|
|
3027
|
-
+ remoteUtil * this.scheduler.capPenaltyWeight
|
|
3028
|
-
);
|
|
3029
|
-
}
|
|
3030
3014
|
|
|
3031
3015
|
// DOMINANT term: in-flight concurrency. Short-term throttling is driven by
|
|
3032
3016
|
// how many requests pile on one account, so least-loaded-first spread is
|
|
@@ -3733,12 +3717,19 @@ export class AccountManager {
|
|
|
3733
3717
|
}
|
|
3734
3718
|
|
|
3735
3719
|
monthlyPriceFor(account) {
|
|
3720
|
+
// A cloud mirror carries no credential, so this pool cannot read its subscription;
|
|
3721
|
+
// the cloud pool reads it and exports it per row (remoteMonthlyPriceUSD).
|
|
3722
|
+
if (account?.remote && account.remoteMonthlyPriceUSD != null) return account.remoteMonthlyPriceUSD;
|
|
3736
3723
|
if (account?.type === 'provider') return account.monthlyPriceUSD ?? null;
|
|
3737
3724
|
const tbl = this.scheduler?.monthlyPriceUSD;
|
|
3738
3725
|
if (tbl && typeof tbl === 'object') {
|
|
3739
3726
|
const hit = tbl[account?.name] ?? tbl['*'];
|
|
3740
3727
|
if (Number.isFinite(hit)) return hit;
|
|
3741
3728
|
}
|
|
3729
|
+
// Owner 2026-10-31: "Claude monthly price is fixed, it's 200 dollars per month."
|
|
3730
|
+
// Anthropic has no per-account price API, so this is the default for every Claude
|
|
3731
|
+
// login; scheduler.monthlyPriceUSD (name or '*') overrides it.
|
|
3732
|
+
if (account?.type === 'oauth') return 200;
|
|
3742
3733
|
return null;
|
|
3743
3734
|
}
|
|
3744
3735
|
|
|
@@ -4004,6 +3995,19 @@ export class AccountManager {
|
|
|
4004
3995
|
capacityTank(accountIndex, window) {
|
|
4005
3996
|
const a = this.accounts[accountIndex];
|
|
4006
3997
|
if (!a) return null;
|
|
3998
|
+
// A cloud mirror's history lives in TWO ledgers: this pool's, under the account's
|
|
3999
|
+
// pre-migration name (months of cycles measured locally before it moved), and the
|
|
4000
|
+
// cloud pool's own, exported per row as remoteTank. Mirror rows are named
|
|
4001
|
+
// "<name> ☁", which matched neither — so every cloud row read "--" (2026-10-31).
|
|
4002
|
+
if (a.remote) {
|
|
4003
|
+
// Prefer whichever ledger holds MORE cycles: the cloud pool only started
|
|
4004
|
+
// measuring at migration (2026-10-29), so for weeks its 0-2 cycles would
|
|
4005
|
+
// otherwise override months of history measured here.
|
|
4006
|
+
const cloud = a.remoteTank?.[window] || null;
|
|
4007
|
+
const local = this.capacity.tankStats(a.remote.remoteName || a.name, window);
|
|
4008
|
+
const best = (cloud && local) ? ((cloud.n || 0) >= (local.n || 0) ? cloud : local) : (cloud || local);
|
|
4009
|
+
return best ? { ...best, source: 'cycles' } : null;
|
|
4010
|
+
}
|
|
4007
4011
|
const measured = this.capacity.tankStats(a.name, window);
|
|
4008
4012
|
if (measured) return { ...measured, source: 'cycles' };
|
|
4009
4013
|
const est = this.capacityEstimate(accountIndex, window);
|
|
@@ -4882,24 +4886,6 @@ export class AccountManager {
|
|
|
4882
4886
|
this._remoteIdentities = ids;
|
|
4883
4887
|
}
|
|
4884
4888
|
|
|
4885
|
-
/** Add (or update) the routable account row for a pool link. */
|
|
4886
|
-
upsertPoolAccount(link) {
|
|
4887
|
-
let a = this.accounts.find(x => x.type === 'pool' && x.name === link.name);
|
|
4888
|
-
if (!a) {
|
|
4889
|
-
this.upsertRuntimeAccount({
|
|
4890
|
-
name: link.name, type: 'pool', provider: 'pool',
|
|
4891
|
-
authToken: link.key, upstream: String(link.url).replace(/\/+$/, ''),
|
|
4892
|
-
profiles: ['claude', 'all'], priority: 0, configSourced: true,
|
|
4893
|
-
});
|
|
4894
|
-
a = this.accounts.find(x => x.type === 'pool' && x.name === link.name);
|
|
4895
|
-
}
|
|
4896
|
-
a.credential = link.key;
|
|
4897
|
-
a.upstream = String(link.url).replace(/\/+$/, '');
|
|
4898
|
-
a._link = link;
|
|
4899
|
-
a.configSourced = true;
|
|
4900
|
-
return a;
|
|
4901
|
-
}
|
|
4902
|
-
|
|
4903
4889
|
/** The linked pool's LIVE row for a benched local account (by identity), or null.
|
|
4904
4890
|
* The local copy's own quota/counters go stale the moment it's benched — the
|
|
4905
4891
|
* display must read the cloud's numbers (owner 2026-10-29: "I don't know if I can
|
|
@@ -4956,6 +4942,8 @@ export class AccountManager {
|
|
|
4956
4942
|
a.addedAt = null; // H3: mirrors never count as "warming"
|
|
4957
4943
|
a.resetCards = ra.resetCards || null;
|
|
4958
4944
|
a.resetGrants = ra.resetGrants || null;
|
|
4945
|
+
a.remoteMonthlyPriceUSD = Number.isFinite(ra.monthlyPriceUSD) ? ra.monthlyPriceUSD : null;
|
|
4946
|
+
a.remoteTank = ra.tank || null;
|
|
4959
4947
|
// Other teammates' live load on this cloud account (remote inFlight minus our
|
|
4960
4948
|
// own leases) — so the balancer sees the account as busy as it really is.
|
|
4961
4949
|
a._remoteOtherLoad = Math.max(0, (ra.inFlight || 0) - (a.inFlight || 0));
|
|
@@ -5009,6 +4997,15 @@ export class AccountManager {
|
|
|
5009
4997
|
// counts and expiry only — no credentials; the redeem stays with the holder.
|
|
5010
4998
|
resetCards: a.resetCards ? { fiveHour: a.resetCards.fiveHour, weekly: a.resetCards.weekly, checkedAt: a.resetCards.checkedAt } : null,
|
|
5011
4999
|
resetGrants: a.resetGrants ? { grants: a.resetGrants.grants, cooldownUntil: a.resetGrants.cooldownUntil, checkedAt: a.resetGrants.checkedAt } : null,
|
|
5000
|
+
// Capacity-page inputs for linked pools (a mirror has no credential and no
|
|
5001
|
+
// local cycles): this pool's plan price and measured tanks, per window.
|
|
5002
|
+
monthlyPriceUSD: a.remote ? null : this.monthlyPriceFor(a),
|
|
5003
|
+
tank: a.remote ? null : (() => {
|
|
5004
|
+
const pick = w => { const t = this.capacity?.tankStats(a.name, w);
|
|
5005
|
+
return t ? { avg: t.avg, n: t.n, prev: t.prev, last: t.last, lowerBound: t.lowerBound } : null; };
|
|
5006
|
+
const ses = pick('ses'), wk = pick('wk');
|
|
5007
|
+
return ses || wk ? { ses, wk } : null;
|
|
5008
|
+
})(),
|
|
5012
5009
|
// Identity for duplicate matching by linked pools (D12). The Claude account
|
|
5013
5010
|
// UUID is an identifier, not a credential; provider keys export only a
|
|
5014
5011
|
// fingerprint. Without these a linked pool can't see a duplicate Claude login
|
package/src/screen.html
CHANGED
|
@@ -129,7 +129,7 @@ h1{font-size:22px;margin:0;letter-spacing:-.3px}
|
|
|
129
129
|
var five = q.unified5h != null ? q.unified5h : q.providerSes;
|
|
130
130
|
var week = q.unified7d != null ? q.unified7d : q.providerWk;
|
|
131
131
|
return '<div class="acct' + (a.refreshDead ? ' dead' : '') + '">' +
|
|
132
|
-
'<div><div class="name">' + esc(a.name) + '</div><div class="sub">' + esc(a.
|
|
132
|
+
'<div><div class="name">' + esc(a.name) + '</div><div class="sub">' + esc(a.provider || (a.type === 'oauth' ? 'Claude' : a.type)) +
|
|
133
133
|
(a.inFlight ? ' · ' + a.inFlight + ' running' : '') + '</div></div>' +
|
|
134
134
|
'<div class="bars">' + bar('5h', five) + bar('7d', week) + '</div>' +
|
|
135
135
|
'<span class="state ' + st[0] + '">' + st[1] + '</span></div>';
|
package/src/server.js
CHANGED
|
@@ -849,7 +849,7 @@ async function forwardRequest(
|
|
|
849
849
|
// request to it with the person's key, a stepped hop header, and the client's
|
|
850
850
|
// session header preserved — the remote pool does its own account selection,
|
|
851
851
|
// so no body rewriting, no credential substitution.
|
|
852
|
-
if (account.
|
|
852
|
+
if (account.remote) {
|
|
853
853
|
const hop = nextHopCount(headerValue(req.headers, HOP_HEADER));
|
|
854
854
|
if (hop == null) {
|
|
855
855
|
accountManager.releaseAccount(lease, { neutral: true });
|
package/src/tui.js
CHANGED
|
@@ -50,7 +50,6 @@ function whereCell(a) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function providerLabel(a) {
|
|
53
|
-
if (a.type === 'pool') return 'Team pool';
|
|
54
53
|
|
|
55
54
|
const key = a.provider || (a.type === 'provider' ? 'provider' : 'anthropic');
|
|
56
55
|
const label = PROVIDER_LABELS[key] || (key.charAt(0).toUpperCase() + key.slice(1));
|
|
@@ -2101,8 +2100,6 @@ export class TUI {
|
|
|
2101
2100
|
// effectively off (owner 2026-10-29: "should it hide the local ones that are
|
|
2102
2101
|
// in the cloud... they're effectively disabled as well"). No separate key.
|
|
2103
2102
|
if (this.hideDisabled && this.am.accounts[i]?.poolBenchedBy) { hidden++; continue; }
|
|
2104
|
-
// The legacy single team-pool row is superseded by per-account cloud rows.
|
|
2105
|
-
if (this.am.accounts[i]?.type === 'pool') continue;
|
|
2106
2103
|
lines.push(this._renderAcct(i, bw, showBoth));
|
|
2107
2104
|
}
|
|
2108
2105
|
if (hidden > 0) {
|