maxpool 1.24.16 → 1.24.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxpool",
3
- "version": "1.24.16",
3
+ "version": "1.24.17",
4
4
  "description": "Multi-account Claude Code proxy with adaptive, rate-aware load balancing across Claude accounts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -4375,8 +4375,12 @@ export class AccountManager {
4375
4375
  const configTokens = new Set(
4376
4376
  entries.map(e => e.token).filter(Boolean),
4377
4377
  );
4378
+ // Same rule for a provider KIND config already covers: a header-derived fallback
4379
+ // of that kind is a duplicate login even when its token differs (a pre-rotation key).
4380
+ const configKinds = new Set(entries.filter(e => e.token).map(e => e.provider).filter(Boolean));
4378
4381
  for (const a of [...this.accounts]) {
4379
- if (!a.configSourced && a.type === 'provider' && a.credential && configTokens.has(a.credential)) {
4382
+ if (!a.configSourced && a.type === 'provider' && a.credential
4383
+ && (configTokens.has(a.credential) || (a.runtime && configKinds.has(a.provider)))) {
4380
4384
  const idx = this.accounts.indexOf(a);
4381
4385
  if (idx >= 0 && this.accounts[idx].inFlight === 0) this.removeAccount(idx);
4382
4386
  }
package/src/server.js CHANGED
@@ -3015,9 +3015,29 @@ function prepareRuntimeProviders(accountManager, headers) {
3015
3015
  .filter(a => a.configSourced && a.credential)
3016
3016
  .map(a => a.credential),
3017
3017
  );
3018
+ // THE PROXY OWNS THE KEYS (2026-10-10). When config already manages accounts of a
3019
+ // provider kind, a session-supplied key for that kind is ignored outright. Dedup by
3020
+ // token alone was not enough: a session launched before a key rotation keeps sending
3021
+ // the OLD key for its whole life, and it surfaced as a duplicate "glm-fallback"
3022
+ // account for the same z.ai login (1,578 requests on the old key in 2 days).
3023
+ // A kind counts as proxy-managed only while at least one of its config accounts
3024
+ // HOLDS a key: if every one is unresolved (the secret-unresolved outages of
3025
+ // 2026-10-05/08) the session key still stands in as the safety net.
3026
+ const configKinds = new Set(
3027
+ (accountManager.accounts || []).filter(a => a.configSourced && a.credential).map(a => a.provider),
3028
+ );
3029
+ // Self-clean: a fallback created before the config keys loaded (or restored from
3030
+ // state) is dropped as soon as it is idle — no restart, no waiting for old sessions.
3031
+ // (removeAccount itself refuses an account with a request in flight.)
3032
+ for (const a of [...(accountManager.accounts || [])]) {
3033
+ if (a.runtime && !a.configSourced && a.type === 'provider' && configKinds.has(a.provider)
3034
+ && accountManager.removeAccount(accountManager.accounts.indexOf(a))) {
3035
+ console.log(`[Maxpool] Dropped session-supplied "${a.name}" — ${a.provider} keys are managed by the pool config`);
3036
+ }
3037
+ }
3018
3038
 
3019
3039
  const zaiToken = headerValue(headers, 'x-maxpool-zai-token');
3020
- if (zaiToken && !configTokens.has(zaiToken)) {
3040
+ if (zaiToken && !configKinds.has('zai') && !configTokens.has(zaiToken)) {
3021
3041
  const opus = headerValue(headers, 'x-maxpool-zai-opus-model') || headerValue(headers, 'x-maxpool-zai-model') || 'glm-5.3';
3022
3042
  const sonnet = headerValue(headers, 'x-maxpool-zai-sonnet-model') || headerValue(headers, 'x-maxpool-zai-model') || opus;
3023
3043
  const haiku = headerValue(headers, 'x-maxpool-zai-haiku-model') || 'glm-5.3';
@@ -3036,7 +3056,7 @@ function prepareRuntimeProviders(accountManager, headers) {
3036
3056
  }
3037
3057
 
3038
3058
  const kimiToken = headerValue(headers, 'x-maxpool-kimi-token');
3039
- if (kimiToken && !configTokens.has(kimiToken)) {
3059
+ if (kimiToken && !configKinds.has('kimi') && !configTokens.has(kimiToken)) {
3040
3060
  // Fallback only — `cc all` always sends x-maxpool-kimi-model from the llm_config SSOT,
3041
3061
  // so this is what a bare/older client gets. Kept current deliberately: it read
3042
3062
  // 'kimi-k2.7' while the fleet had moved to k3.
@@ -3652,3 +3672,6 @@ function computeRetryAfter(accountManager, requestInfo = {}) {
3652
3672
  const ms = accountManager.nextRetryForRequest?.(requestInfo, new Set())?.retryAfterMs ?? Infinity;
3653
3673
  return ms === Infinity ? 60 : Math.max(1, Math.ceil(ms / 1000));
3654
3674
  }
3675
+
3676
+ // Test seam: prepareRuntimeProviders with a plain headers object.
3677
+ export const __test = { prepareRuntimeProviders };