maxpool 1.24.15 → 1.24.16

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.15",
3
+ "version": "1.24.16",
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",
package/src/index.js CHANGED
@@ -777,6 +777,15 @@ async function serverWorkerCommand() {
777
777
  }, 5 * 60_000);
778
778
  secretTimer.unref?.();
779
779
  }
780
+ // Key rotation: a new secret version reaches the live pool within 30 min.
781
+ const { refreshRotatedProviders } = await import('./secret-resolver.js');
782
+ const rotateTimer = setInterval(async () => {
783
+ try {
784
+ const n = await refreshRotatedProviders(accountManager.accounts);
785
+ if (n) console.log(`[Maxpool] Key rotation: ${n} provider key(s) updated from Secret Manager`);
786
+ } catch { /* next tick */ }
787
+ }, 30 * 60_000);
788
+ rotateTimer.unref?.();
780
789
  }
781
790
 
782
791
  // Seed the running version immediately so the TUI header always shows it, even
@@ -199,6 +199,28 @@ export function pendingProviders(accounts) {
199
199
  return accounts.filter(a => a.configSourced && a.type === 'provider' && a.secretName && !a.credential);
200
200
  }
201
201
 
202
+ /**
203
+ * Pick up ROTATED keys. A key resolves once at startup, so a new secret version (a
204
+ * key swap in Secret Manager) stayed invisible until the next restart — the pool kept
205
+ * calling with the old key (2026-10-09: all six z.ai keys moved to the account's
206
+ * "zcode-api-key", which is the only key z.ai issues reset cards for). Re-reads every
207
+ * loaded provider's secret, bypassing the local cache, and swaps `credential` when the
208
+ * value changed. A failed read keeps the current key. Returns the number swapped.
209
+ */
210
+ export async function refreshRotatedProviders(accounts, resolve = (names) => resolveSecrets(names, { useCache: false })) {
211
+ const loaded = accounts.filter(a => a.configSourced && a.type === 'provider' && a.secretName && a.credential);
212
+ if (!loaded.length) return 0;
213
+ const resolved = await resolve([...new Set(loaded.map(a => a.secretName))]);
214
+ let swapped = 0;
215
+ for (const a of loaded) {
216
+ const tok = resolved[a.secretName];
217
+ if (!tok || tok === a.credential) continue;
218
+ a.credential = tok;
219
+ swapped++;
220
+ }
221
+ return swapped;
222
+ }
223
+
202
224
  export async function reresolveProviders(accounts, resolve = resolveSecrets) {
203
225
  const pending = pendingProviders(accounts);
204
226
  if (!pending.length) return 0;
package/src/server.js CHANGED
@@ -1709,7 +1709,7 @@ function formatRetryDuration(seconds) {
1709
1709
  function computeQueueWindowMs({
1710
1710
  cause, stream, retryPlanCause,
1711
1711
  maxWaitMs, capacityMaxWaitMs, nonStreamMaxWaitMs, streamHoldMaxMs, streamClientToleranceMs,
1712
- isCountTokens, countTokensMaxWaitMs, networkMaxWaitMs,
1712
+ isCountTokens, countTokensMaxWaitMs,
1713
1713
  }) {
1714
1714
  let windowMs;
1715
1715
  if (!stream) {
@@ -2649,9 +2649,6 @@ async function queueAndRetry(
2649
2649
  const streamClientToleranceMs = Number.isFinite(requestInfo.clientToleranceMs)
2650
2650
  ? requestInfo.clientToleranceMs
2651
2651
  : Math.max(0, Number(queueConfig.streamClientToleranceMs) || 0);
2652
- const networkMaxWaitMs = queueConfig.networkMaxWaitMs == null
2653
- ? 2 * 60 * 1000
2654
- : Math.max(0, Number(queueConfig.networkMaxWaitMs) || 0);
2655
2652
  const queueWindowMs = computeQueueWindowMs({
2656
2653
  cause,
2657
2654
  stream: Boolean(requestInfo.stream),
@@ -2659,7 +2656,6 @@ async function queueAndRetry(
2659
2656
  maxWaitMs,
2660
2657
  capacityMaxWaitMs,
2661
2658
  nonStreamMaxWaitMs,
2662
- networkMaxWaitMs,
2663
2659
  streamHoldMaxMs,
2664
2660
  streamClientToleranceMs,
2665
2661
  isCountTokens: Boolean(requestInfo.isCountTokens),