maxpool 1.24.41 → 1.24.43
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 +37 -0
- package/src/prober.js +5 -2
- package/src/server.js +5 -0
- package/src/tui.js +14 -2
package/package.json
CHANGED
package/src/account-manager.js
CHANGED
|
@@ -2861,8 +2861,27 @@ export class AccountManager {
|
|
|
2861
2861
|
_scoreAccount(account, requestInfo = {}, ctx = null, criticalUnlock = null) {
|
|
2862
2862
|
const now = ctx?.now ?? Date.now();
|
|
2863
2863
|
const reqWeight = Math.max(1, requestInfo.weight || 1);
|
|
2864
|
+
// POOL LINK scores as the cloud's WORST-case load (owner 2026-10-29: "the team
|
|
2865
|
+
// pool will respect the accounts within it... included in the balancing act").
|
|
2866
|
+
// The link row's inFlight is mirrored from the remote status poll, so the
|
|
2867
|
+
// concurrency term already treats one link request as N remote requests.
|
|
2864
2868
|
const inflight = account.activeWeight + reqWeight;
|
|
2865
2869
|
const refillMult = this._fastRefillMultiplier(account);
|
|
2870
|
+
if (account.type === 'pool' && account._link) {
|
|
2871
|
+
// Utilization = the cloud's own reported fraction of usable accounts spent
|
|
2872
|
+
// (weekly windows), so a near-exhausted cloud pool de-preferences like a
|
|
2873
|
+
// near-exhausted local account rather than pretending to be empty-fresh.
|
|
2874
|
+
const link = account._link;
|
|
2875
|
+
const remoteUtil = link.summary && link.summary.total
|
|
2876
|
+
? (link.summary.total - link.summary.usable) / link.summary.total : 0;
|
|
2877
|
+
// Same shape as a provider's weekly utilization cost, keyed to remote load.
|
|
2878
|
+
const remoteLoad = Math.max(account.activeWeight, link.status?.scheduler?.globalInFlight || 0);
|
|
2879
|
+
return (
|
|
2880
|
+
remoteLoad * this.scheduler.concurrencyWeight
|
|
2881
|
+
+ Math.max(0, remoteLoad - this.scheduler.perAccountConcurrencyTarget) * this.scheduler.capPenaltyWeight
|
|
2882
|
+
+ remoteUtil * this.scheduler.capPenaltyWeight
|
|
2883
|
+
);
|
|
2884
|
+
}
|
|
2866
2885
|
|
|
2867
2886
|
// DOMINANT term: in-flight concurrency. Short-term throttling is driven by
|
|
2868
2887
|
// how many requests pile on one account, so least-loaded-first spread is
|
|
@@ -4656,6 +4675,19 @@ export class AccountManager {
|
|
|
4656
4675
|
return a;
|
|
4657
4676
|
}
|
|
4658
4677
|
|
|
4678
|
+
/** The linked pool's LIVE row for a benched local account (by identity), or null.
|
|
4679
|
+
* The local copy's own quota/counters go stale the moment it's benched — the
|
|
4680
|
+
* display must read the cloud's numbers (owner 2026-10-29: "I don't know if I can
|
|
4681
|
+
* trust the session and weekly limits I'm seeing"). */
|
|
4682
|
+
remoteRowFor(account) {
|
|
4683
|
+
if (!account?.poolBenchedBy) return null;
|
|
4684
|
+
for (const l of this.poolLinks) {
|
|
4685
|
+
const row = (l.status?.accounts || []).find(ra => ra.name === account.poolBenchedBy);
|
|
4686
|
+
if (row) return { row, linkOk: l.lastOkAt != null && !l.lastError, linkName: l.name };
|
|
4687
|
+
}
|
|
4688
|
+
return null;
|
|
4689
|
+
}
|
|
4690
|
+
|
|
4659
4691
|
/** True when account is benched by the duplicate guard. */
|
|
4660
4692
|
isPoolBenched(account) {
|
|
4661
4693
|
return Boolean(account && account.poolBenchedBy);
|
|
@@ -4795,6 +4827,11 @@ export class AccountManager {
|
|
|
4795
4827
|
refreshDead: Boolean(ra.refreshDead),
|
|
4796
4828
|
quota: ra.quota || null,
|
|
4797
4829
|
status: ra.status || null,
|
|
4830
|
+
inFlight: ra.inFlight || 0,
|
|
4831
|
+
completedRequests: ra.completedRequests || 0,
|
|
4832
|
+
failedRequests: ra.failedRequests || 0,
|
|
4833
|
+
lastError: ra.lastError || null,
|
|
4834
|
+
load: ra.load || null,
|
|
4798
4835
|
})),
|
|
4799
4836
|
})),
|
|
4800
4837
|
sessions: {
|
package/src/prober.js
CHANGED
|
@@ -202,7 +202,9 @@ export class Prober {
|
|
|
202
202
|
// OWNER GATE (2026-09-30): disabled accounts are excluded from listing AND
|
|
203
203
|
// redemption entirely — a readable key on a disabled account (someone else
|
|
204
204
|
// uses it) is not authority to act.
|
|
205
|
-
|
|
205
|
+
// A duplicate-guard-benched copy never redeems: the team pool owns that key now,
|
|
206
|
+
// and two pools redeeming one key would burn two cards for one reset.
|
|
207
|
+
if (account.enabled !== false && account.credential && !account.poolBenchedBy) {
|
|
206
208
|
if (account.provider === 'zai' && this.am.applyResetCards) {
|
|
207
209
|
try {
|
|
208
210
|
const cards = await this._withTimeout(this.cardsFn(account.credential));
|
|
@@ -226,7 +228,8 @@ export class Prober {
|
|
|
226
228
|
* else legitimately using the key is WHY the account is benched. */
|
|
227
229
|
async _checkOutsideUsage(account, now = this._now()) {
|
|
228
230
|
try {
|
|
229
|
-
|
|
231
|
+
// Benched duplicate: the team pool's traffic on this key is NOT outside usage.
|
|
232
|
+
if (account.provider !== 'zai' || !account.credential || account.enabled === false || account.poolBenchedBy) return;
|
|
230
233
|
const last = account._outsideCheckedAt || 0;
|
|
231
234
|
if (now - last < OUTSIDE_CHECK_MS) return;
|
|
232
235
|
const data = await this._withTimeout(this.zaiUsageFn(account.credential, { now }));
|
package/src/server.js
CHANGED
|
@@ -741,6 +741,11 @@ async function forwardRequest(
|
|
|
741
741
|
for (const [k, v] of Object.entries(req.headers)) {
|
|
742
742
|
const lk = k.toLowerCase();
|
|
743
743
|
if (HOP_BY_HOP_HEADERS.has(lk) || lk === 'content-length' || lk === 'host' || lk === 'connection') continue;
|
|
744
|
+
// NEVER forward the client's provider credentials to a linked pool (live finding
|
|
745
|
+
// 2026-10-29: `cc all` sends x-maxpool-zai-token / x-maxpool-kimi-token and the
|
|
746
|
+
// cloud pool turned them into runtime accounts — a key the owner had disabled
|
|
747
|
+
// locally went live remotely). The remote pool owns its own accounts.
|
|
748
|
+
if (/^x-maxpool-(zai|kimi)-/.test(lk)) continue;
|
|
744
749
|
linkHeaders[k] = v;
|
|
745
750
|
}
|
|
746
751
|
linkHeaders[HOP_HEADER] = String(hop);
|
package/src/tui.js
CHANGED
|
@@ -45,6 +45,7 @@ const ROW_PREFIX = ' '; // ' ' + sel(1) + cur(1) + ' ' — 4 cols before the
|
|
|
45
45
|
const PROVIDER_LABELS = { anthropic: 'Anthropic', zai: 'z.ai', kimi: 'Moonshot', openai: 'OpenAI', codex: 'Codex', grok: 'Grok', xai: 'Grok' };
|
|
46
46
|
function providerLabel(a) {
|
|
47
47
|
if (a.type === 'pool') return 'Team pool';
|
|
48
|
+
if (a._cloud) return (PROVIDER_LABELS[a.provider] || a.provider || 'Cloud').slice(0, PROVIDER_W - 1) + '☁';
|
|
48
49
|
const key = a.provider || (a.type === 'provider' ? 'provider' : 'anthropic');
|
|
49
50
|
const label = PROVIDER_LABELS[key] || (key.charAt(0).toUpperCase() + key.slice(1));
|
|
50
51
|
return label.slice(0, PROVIDER_W);
|
|
@@ -2109,7 +2110,15 @@ export class TUI {
|
|
|
2109
2110
|
}
|
|
2110
2111
|
|
|
2111
2112
|
_renderAcct(idx, bw, showBoth) {
|
|
2112
|
-
|
|
2113
|
+
let a = this.am.accounts[idx];
|
|
2114
|
+
// A row benched by the duplicate guard renders the CLOUD's live copy (status,
|
|
2115
|
+
// bars, in-flight, request counts) — never the stale local snapshot. Identity
|
|
2116
|
+
// and name stay local so the row doesn't move.
|
|
2117
|
+
const remote = this.am.remoteRowFor?.(a);
|
|
2118
|
+
if (remote) {
|
|
2119
|
+
a = { ...a, ...remote.row, name: a.name, index: a.index, poolBenchedBy: a.poolBenchedBy,
|
|
2120
|
+
_cloud: true, _cloudOk: remote.linkOk, enabled: true };
|
|
2121
|
+
}
|
|
2113
2122
|
// Highlight the ACTIVE account(s) — drives BOTH the ► marker and the green
|
|
2114
2123
|
// "active" status color. In manual mode that's the single pinned account (all
|
|
2115
2124
|
// traffic goes there). In automatic load-balancing there is no single "current"
|
|
@@ -2146,7 +2155,9 @@ export class TUI {
|
|
|
2146
2155
|
// the one running the recovery probe as "probing" and the rest "waiting"
|
|
2147
2156
|
// (the pool-wide throttle banner above conveys the cause).
|
|
2148
2157
|
const upstreamBlocking = a.type !== 'provider' && this.am._isUpstreamThrottleBlocking?.();
|
|
2149
|
-
let effectiveStatus = a.
|
|
2158
|
+
let effectiveStatus = a._cloud
|
|
2159
|
+
? (a._cloudOk ? a.status : 'cloud-down')
|
|
2160
|
+
: (a.poolBenchedBy ? 'pool-benched' : (a.enabled === false ? 'disabled' : a.status));
|
|
2150
2161
|
if (a.enabled !== false && upstreamBlocking && a.status === 'active') {
|
|
2151
2162
|
effectiveStatus = a.inFlight > 0 ? 'probing' : 'waiting';
|
|
2152
2163
|
}
|
|
@@ -2198,6 +2209,7 @@ export class TUI {
|
|
|
2198
2209
|
case 'paused': status = yellow('paused'); break;
|
|
2199
2210
|
case 'disabled': status = red('✕ disabled'); break;
|
|
2200
2211
|
case 'pool-benched': status = gray('⟐ team pool'); break;
|
|
2212
|
+
case 'cloud-down': status = red('⟐ cloud ✕'); break;
|
|
2201
2213
|
// Disabled AND needs re-login — both facts matter, and DISABLED LEADS.
|
|
2202
2214
|
// The owner's question that drove this (2026-09-30): "when I disable the account
|
|
2203
2215
|
// and then the token expires, does it show disabled or reauth? It needs to
|