Files
ccs/src/commands/cliproxy/pool-subcommand.ts
T
Tam Nhu Tran fdb043083f feat(cliproxy): pool routing defaults and safety rails
- pool opt-in writes disable-cooling: false, routing.strategy fill-first,
  session-affinity on (1h TTL), max-retry-credentials 3; all emissions
  pool-gated so non-pool generated config stays content-identical
- cooling re-enable is safe on current CLIProxy binaries: the v5
  disable-cooling workaround targeted upstream cooldown bugs fixed by
  Apr 2026 (see plan archaeology report)
- informed-consent prompt at the 1->2 account-add transition enumerates
  every provider with multiple accounts (instance-global effect) and is
  gated per provider on spike-verified limit signals
- disablePoolRouting restores the non-pool config including
  disable-cooling: true and prints single-account rollback guidance
- cross-lane guard warns when a pool account email is also active in a
  native Claude profile (concurrency is the documented ban vector)
- routing strategy and affinity subcommands warn when pool routing
  manages those keys

Part of #1464 account pools (phase 3).
2026-06-11 00:12:14 -04:00

67 lines
2.3 KiB
TypeScript

/**
* CLIProxy Pool Routing Subcommand
*
* Handles:
* ccs cliproxy pool --enable Enable pool routing (fill-first + affinity + cooling ON)
* ccs cliproxy pool --disable Disable pool routing and restore non-pool config
* ccs cliproxy pool Show current pool routing state
*/
import { initUI, header, ok, warn, info } from '../../utils/ui';
import { enablePoolRouting, disablePoolRouting } from '../../cliproxy/routing/routing-strategy';
import { loadOrCreateUnifiedConfig } from '../../config/config-loader-facade';
import { CLIPROXY_DEFAULT_PORT } from '../../cliproxy/config/port-manager';
import { getConfigPathForPort, getAuthDir } from '../../cliproxy/config/path-resolver';
import { hasAnyFlag } from '../arg-extractor';
export async function handlePoolSubcommand(args: string[]): Promise<void> {
await initUI();
console.log('');
console.log(header('CLIProxy Pool Routing'));
console.log('');
const port = CLIPROXY_DEFAULT_PORT;
const configPath = getConfigPathForPort(port);
const authDir = getAuthDir();
if (hasAnyFlag(args, ['--enable'])) {
const result = enablePoolRouting(port, { configPath, authDir });
if (result.changed) {
console.log(ok(result.message));
} else {
console.log(info(result.message));
}
console.log('');
return;
}
if (hasAnyFlag(args, ['--disable'])) {
const result = disablePoolRouting(port, { configPath, authDir });
if (result.changed) {
console.log(ok(result.message));
} else {
console.log(info(result.message));
}
console.log('');
return;
}
// Default: show status
const config = loadOrCreateUnifiedConfig();
const enabled = config.cliproxy?.pool_routing?.enabled === true;
const dismissed = config.cliproxy?.pool_routing?.prompt_dismissed === true;
const maxRetry = config.cliproxy?.pool_routing?.max_retry_credentials;
console.log(` Status: ${enabled ? ok('enabled') : warn('disabled')}`);
if (enabled && maxRetry !== undefined) {
console.log(` Max retry: ${maxRetry}`);
}
if (!enabled && dismissed) {
console.log(` Dismissed: ${info('yes (prompt will not re-show)')}`);
}
console.log('');
console.log(` Enable: ccs cliproxy pool --enable`);
console.log(` Disable: ccs cliproxy pool --disable`);
console.log('');
}