maxpool 1.24.63 → 1.24.65

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +37 -0
  3. package/src/tui.js +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxpool",
3
- "version": "1.24.63",
3
+ "version": "1.24.65",
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
@@ -137,6 +137,10 @@ switch (command) {
137
137
  await poolCommand();
138
138
  process.exit(0);
139
139
  break;
140
+ case 'route':
141
+ await routeCommand();
142
+ process.exit(0);
143
+ break;
140
144
  case 'status':
141
145
  await statusCommand();
142
146
  process.exit(0);
@@ -1761,6 +1765,39 @@ async function envCommand() {
1761
1765
 
1762
1766
  // ── pool (client-side switch between local and shared pool) ─
1763
1767
 
1768
+ /** `maxpool route [pool|direct|status]` — flip rc-gate routing LIVE (owner
1769
+ * 2026-11-01: "if there is a way to make the routing switch without having to
1770
+ * restart the app, that would be amazing"). The gate re-reads the switch file
1771
+ * per request (1s cache), so already-running Claude Code sessions change route
1772
+ * instantly — no restart of anything. status shows what Claude Code routes
1773
+ * through RIGHT NOW. */
1774
+ async function routeCommand() {
1775
+ const { homedir } = await import('node:os');
1776
+ const { writeFile, readFile } = await import('node:fs/promises');
1777
+ const { join } = await import('node:path');
1778
+ const file = join(homedir(), '.config', 'rc-gate-route');
1779
+ const arg = process.argv[3] || 'status';
1780
+ const readIt = async () => { try { return (await readFile(file, 'utf8')).trim() || 'pool'; } catch { return 'pool'; } };
1781
+ if (arg === 'pool' || arg === 'direct') {
1782
+ await writeFile(file, arg + '\n', { mode: 0o600 }).catch(async () => {
1783
+ const { mkdir } = await import('node:fs/promises');
1784
+ await mkdir(join(homedir(), '.config'), { recursive: true });
1785
+ await writeFile(file, arg + '\n', { mode: 0o600 });
1786
+ });
1787
+ console.log(`Routing: ${arg === 'pool' ? 'through maxpool (all accounts, cloud + local)' : 'direct to Anthropic (pool bypassed)'} — takes effect on the next request, no restart needed`);
1788
+ return;
1789
+ }
1790
+ // status
1791
+ const mode = await readIt();
1792
+ const gateUp = await (async () => { try { await fetch('http://127.0.0.1:3457/', { signal: AbortSignal.timeout(1000) }).catch(() => {}); return true; } catch { return false; } })();
1793
+ console.log('Claude Code routes through: ' + (gateUp
1794
+ ? (mode === 'direct'
1795
+ ? 'rc-gate → DIRECT to Anthropic (pool bypassed)'
1796
+ : 'rc-gate → maxpool (local :3456, cloud accounts via the team tunnel)')
1797
+ : 'no rc-gate on :3457 — sessions use whatever ANTHROPIC_BASE_URL they started with'));
1798
+ console.log(`Switch file: ${file} = ${mode}`);
1799
+ }
1800
+
1764
1801
  async function poolCommand() {
1765
1802
  const sub = args[1];
1766
1803
  const config = await loadOrCreateConfig();
package/src/tui.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { createInterface } from 'node:readline';
2
+ import { readFileSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
2
4
  import { fetchProfile, loginOAuth, tokenFingerprint, isLoginCancelled } from './oauth.js';
3
5
  import { appendEventLog, setConsoleStdoutSuppressed } from './event-log.js';
4
6
 
@@ -468,7 +470,7 @@ export class TUI {
468
470
  this.log = []; // completed activity entries
469
471
  this.active = new Map(); // in-flight requests
470
472
  this.mode = 'normal'; // normal | accounts | routing | capacity | select | input | confirm | providers | addtype
471
- this.capacityWindow = 'ses'; // capacity page window: 'ses' (5h) | 'wk' (weekly)
473
+ this.capacityWindow = 'wk'; // default weekly — the true tank (owner 2026-10-31); 'w' toggles to 5h
472
474
  // Hide disabled accounts from the table. With 8 dead/disabled accounts the live
473
475
  // ones scroll off the top; `h` collapses them to a one-line summary.
474
476
  // Restored from config so an auto-update/reload does not un-hide what the user hid.
@@ -1986,6 +1988,15 @@ export class TUI {
1986
1988
  // and cross-provider fragments off the right edge at 120 columns.
1987
1989
  routing = this._routingModeDef(this.am.scheduler?.routingMode || 'sticky').label;
1988
1990
  }
1991
+ // WHERE CLAUDE CODE ROUTES (owner 2026-11-01: "can the app show where the Claude
1992
+ // Code app is routing to now?"). Reads the same switch file rc-gate re-reads per
1993
+ // request, so the header always agrees with the live path. Direct mode is RED —
1994
+ // it means the pool is bypassed and accounts are idle.
1995
+ try {
1996
+ let mode = 'pool';
1997
+ try { mode = readFileSync(homedir() + '/.config/rc-gate-route', 'utf8').trim() || 'pool'; } catch { /* absent = pool */ }
1998
+ routing += mode === 'direct' ? ` · Claude Code: ${red('DIRECT (pool bypassed)')}` : ` · Claude Code: ${green('pool')}`;
1999
+ } catch { /* display-only */ }
1989
2000
  // Cross-provider fallback policy — only meaningful when GLM/Kimi providers are in
1990
2001
  // the pool (profile=all). never=strict pin (yellow), when-exhausted=default (cyan),
1991
2002
  // always=peer (green).