maxpool 1.24.40 → 1.24.42
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 +18 -0
- package/src/prober.js +5 -2
- package/src/server.js +5 -0
- package/src/tui.js +37 -2
package/package.json
CHANGED
package/src/account-manager.js
CHANGED
|
@@ -4656,6 +4656,19 @@ export class AccountManager {
|
|
|
4656
4656
|
return a;
|
|
4657
4657
|
}
|
|
4658
4658
|
|
|
4659
|
+
/** The linked pool's LIVE row for a benched local account (by identity), or null.
|
|
4660
|
+
* The local copy's own quota/counters go stale the moment it's benched — the
|
|
4661
|
+
* display must read the cloud's numbers (owner 2026-10-29: "I don't know if I can
|
|
4662
|
+
* trust the session and weekly limits I'm seeing"). */
|
|
4663
|
+
remoteRowFor(account) {
|
|
4664
|
+
if (!account?.poolBenchedBy) return null;
|
|
4665
|
+
for (const l of this.poolLinks) {
|
|
4666
|
+
const row = (l.status?.accounts || []).find(ra => ra.name === account.poolBenchedBy);
|
|
4667
|
+
if (row) return { row, linkOk: l.lastOkAt != null && !l.lastError, linkName: l.name };
|
|
4668
|
+
}
|
|
4669
|
+
return null;
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4659
4672
|
/** True when account is benched by the duplicate guard. */
|
|
4660
4673
|
isPoolBenched(account) {
|
|
4661
4674
|
return Boolean(account && account.poolBenchedBy);
|
|
@@ -4795,6 +4808,11 @@ export class AccountManager {
|
|
|
4795
4808
|
refreshDead: Boolean(ra.refreshDead),
|
|
4796
4809
|
quota: ra.quota || null,
|
|
4797
4810
|
status: ra.status || null,
|
|
4811
|
+
inFlight: ra.inFlight || 0,
|
|
4812
|
+
completedRequests: ra.completedRequests || 0,
|
|
4813
|
+
failedRequests: ra.failedRequests || 0,
|
|
4814
|
+
lastError: ra.lastError || null,
|
|
4815
|
+
load: ra.load || null,
|
|
4798
4816
|
})),
|
|
4799
4817
|
})),
|
|
4800
4818
|
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);
|
|
@@ -751,6 +752,25 @@ export class TUI {
|
|
|
751
752
|
return parts.join(' ');
|
|
752
753
|
}
|
|
753
754
|
|
|
755
|
+
/** ` People max 120 · ahmed 40 · andrey 7` — requests per person since start.
|
|
756
|
+
* Merges this pool's named callers with every linked team pool's callers (the
|
|
757
|
+
* cloud's view of who used it). '' when nobody named has used the pool. */
|
|
758
|
+
_peopleLine(W = 80) {
|
|
759
|
+
const totals = new Map();
|
|
760
|
+
for (const [n, c] of this.am.callerCounts || []) totals.set(n, (totals.get(n) || 0) + c);
|
|
761
|
+
for (const l of this.am.poolLinks || []) {
|
|
762
|
+
for (const [n, v] of Object.entries(l.status?.callers || {})) {
|
|
763
|
+
totals.set(n, Math.max(totals.get(n) || 0, v?.requests || 0));
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
totals.delete('legacy-key');
|
|
767
|
+
if (!totals.size) return '';
|
|
768
|
+
const parts = [...totals.entries()].sort((x, y) => y[1] - x[1])
|
|
769
|
+
.map(([n, c]) => `${n} ${cyan(String(c))}`);
|
|
770
|
+
const line = ` People ${parts.join(dim(' · '))}`;
|
|
771
|
+
return vw(line) > W ? line.slice(0, W) : line;
|
|
772
|
+
}
|
|
773
|
+
|
|
754
774
|
_routingLine(routing, xpText) {
|
|
755
775
|
return ` Routing ${cyan(routing)}${xpText}`;
|
|
756
776
|
}
|
|
@@ -1848,6 +1868,10 @@ export class TUI {
|
|
|
1848
1868
|
const right = `Port ${port} ${green('▲')} `;
|
|
1849
1869
|
lines.push(left + ' '.repeat(Math.max(1, W - vw(left) - vw(right))) + right);
|
|
1850
1870
|
lines.push(' ' + dim('─'.repeat(W - 2)));
|
|
1871
|
+
// Usage by person (owner 2026-10-29: "the only thing missing is usage by person").
|
|
1872
|
+
// Local named callers + each linked team pool's callers, one compact line.
|
|
1873
|
+
const people = this._peopleLine(W);
|
|
1874
|
+
if (people) lines.push(people);
|
|
1851
1875
|
// Restart/reload in progress: admission is paused while active requests drain, then
|
|
1852
1876
|
// the process swaps. Without live feedback the screen looks FROZEN (identical
|
|
1853
1877
|
// dashboard, nothing moving) from R→Yes until the swap — the reported bug. Show an
|
|
@@ -2086,7 +2110,15 @@ export class TUI {
|
|
|
2086
2110
|
}
|
|
2087
2111
|
|
|
2088
2112
|
_renderAcct(idx, bw, showBoth) {
|
|
2089
|
-
|
|
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
|
+
}
|
|
2090
2122
|
// Highlight the ACTIVE account(s) — drives BOTH the ► marker and the green
|
|
2091
2123
|
// "active" status color. In manual mode that's the single pinned account (all
|
|
2092
2124
|
// traffic goes there). In automatic load-balancing there is no single "current"
|
|
@@ -2123,7 +2155,9 @@ export class TUI {
|
|
|
2123
2155
|
// the one running the recovery probe as "probing" and the rest "waiting"
|
|
2124
2156
|
// (the pool-wide throttle banner above conveys the cause).
|
|
2125
2157
|
const upstreamBlocking = a.type !== 'provider' && this.am._isUpstreamThrottleBlocking?.();
|
|
2126
|
-
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));
|
|
2127
2161
|
if (a.enabled !== false && upstreamBlocking && a.status === 'active') {
|
|
2128
2162
|
effectiveStatus = a.inFlight > 0 ? 'probing' : 'waiting';
|
|
2129
2163
|
}
|
|
@@ -2175,6 +2209,7 @@ export class TUI {
|
|
|
2175
2209
|
case 'paused': status = yellow('paused'); break;
|
|
2176
2210
|
case 'disabled': status = red('✕ disabled'); break;
|
|
2177
2211
|
case 'pool-benched': status = gray('⟐ team pool'); break;
|
|
2212
|
+
case 'cloud-down': status = red('⟐ cloud ✕'); break;
|
|
2178
2213
|
// Disabled AND needs re-login — both facts matter, and DISABLED LEADS.
|
|
2179
2214
|
// The owner's question that drove this (2026-09-30): "when I disable the account
|
|
2180
2215
|
// and then the token expires, does it show disabled or reauth? It needs to
|