maxpool 1.24.64 → 1.24.66
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/index.js +58 -1
- package/src/tui.js +11 -0
package/package.json
CHANGED
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();
|
|
@@ -1784,6 +1821,26 @@ async function poolCommand() {
|
|
|
1784
1821
|
console.log(` export ANTHROPIC_BASE_URL=http://${host}`);
|
|
1785
1822
|
console.log(` export ANTHROPIC_API_KEY=${key}`);
|
|
1786
1823
|
console.log('rc-gate users: also set RC_GATE_MAXPOOL_HOST/PORT/KEY in the LaunchAgent and restart it.');
|
|
1824
|
+
} else if (sub === 'team') {
|
|
1825
|
+
// The onboarding command the team DMs should name (2026-11-02: `pool shared`
|
|
1826
|
+
// was mistakenly sent to teammates — it redirects the WHOLE machine at an
|
|
1827
|
+
// address that is only reachable through the tunnel, and adds no cloud rows).
|
|
1828
|
+
// This adds a pools[] link: the remote pool's accounts appear as extra rows
|
|
1829
|
+
// beside the local ones; duplicates auto-bench. With no args it operates on
|
|
1830
|
+
// the standard wireproxy tunnel (127.0.0.1:13456 → 10.7.0.1:3456).
|
|
1831
|
+
const url = args[2] || 'http://127.0.0.1:13456';
|
|
1832
|
+
const key = args[3];
|
|
1833
|
+
if (key && key.startsWith('-')) {
|
|
1834
|
+
console.error('Usage: maxpool pool team [url] <your-pool-key>');
|
|
1835
|
+
process.exit(1);
|
|
1836
|
+
}
|
|
1837
|
+
await atomicConfigUpdate(c => {
|
|
1838
|
+
c.pools = (c.pools || []).filter(p => p.name !== 'team');
|
|
1839
|
+
c.pools.push(key ? { name: 'team', url, key } : { name: 'team', url });
|
|
1840
|
+
});
|
|
1841
|
+
console.log(`Team pool linked: cloud accounts will appear as extra rows marked Cloud.`);
|
|
1842
|
+
console.log('Restart your local pool (maxpool restart, or quit and start again) to load them.');
|
|
1843
|
+
console.log('If a local account also exists in the cloud, the local copy pauses itself automatically.');
|
|
1787
1844
|
} else if (sub === 'local') {
|
|
1788
1845
|
await atomicConfigUpdate(c => {
|
|
1789
1846
|
c.client = { ...(c.client || {}), mode: 'local' };
|
|
@@ -1800,7 +1857,7 @@ async function poolCommand() {
|
|
|
1800
1857
|
console.log(`mode: local → http://${config.proxy.host || '127.0.0.1'}:${config.proxy.port}`);
|
|
1801
1858
|
}
|
|
1802
1859
|
} else {
|
|
1803
|
-
console.error('Usage: maxpool pool <shared <host:port> <key> | local | status>');
|
|
1860
|
+
console.error('Usage: maxpool pool <team [url] <key> | shared <host:port> <key> | local | status>');
|
|
1804
1861
|
process.exit(1);
|
|
1805
1862
|
}
|
|
1806
1863
|
}
|
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
|
|
|
@@ -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).
|