fix(cliproxy): pass variant port to executor for isolation

Variants configured with dedicated ports (8318-8417) were not using
their assigned port. The executor always defaulted to 8317.

Changes:
- Add port field to ProfileDetectionResult interface
- Pass variant.port from profile-detector to ccs.ts
- Forward port to execClaudeWithCLIProxy options
- Update executor priority: CLI flags > variant port > config.yaml > default

Closes #228
This commit is contained in:
kaitranntt
2025-12-30 12:42:54 -05:00
parent 98a1d0898d
commit e58afd7790
3 changed files with 19 additions and 2 deletions
+3
View File
@@ -39,6 +39,8 @@ export interface ProfileDetectionResult {
message?: string;
/** For cliproxy variants: the underlying provider (gemini, codex, agy, qwen) */
provider?: CLIProxyProfileName;
/** For cliproxy variants: dedicated port for isolation (8318-8417) */
port?: number;
/** For unified config profiles: merged env vars (config + secrets) */
env?: Record<string, string>;
/** For copilot profile: the copilot config */
@@ -250,6 +252,7 @@ class ProfileDetector {
name: profileName,
provider: variant.provider as CLIProxyProfileName,
settingsPath: variant.settings,
port: variant.port,
};
}
+5 -1
View File
@@ -511,7 +511,11 @@ async function main(): Promise<void> {
// CLIPROXY FLOW: OAuth-based profiles (gemini, codex, agy, qwen) or user-defined variants
const provider = profileInfo.provider || (profileInfo.name as CLIProxyProvider);
const customSettingsPath = profileInfo.settingsPath; // undefined for hardcoded profiles
await execClaudeWithCLIProxy(claudeCli, provider, remainingArgs, { customSettingsPath });
const variantPort = profileInfo.port; // variant-specific port for isolation
await execClaudeWithCLIProxy(claudeCli, provider, remainingArgs, {
customSettingsPath,
port: variantPort,
});
} else if (profileInfo.type === 'copilot') {
// COPILOT FLOW: GitHub Copilot subscription via copilot-api proxy
const { executeCopilotProfile } = await import('./copilot');
+11 -1
View File
@@ -154,7 +154,17 @@ export async function execClaudeWithCLIProxy(
});
// Use resolved port from proxy config (overrides ExecutorConfig)
if (proxyConfig.port !== CLIPROXY_DEFAULT_PORT) {
// Priority: CLI flags > Variant port (cfg.port) > config.yaml > default
// cfg.port is set if variant has dedicated port; proxyConfig.port comes from CLI/ENV/config.yaml
if (cfg.port && cfg.port !== CLIPROXY_DEFAULT_PORT) {
// Variant port already set via config param - keep it (highest priority after CLI flags)
// CLI flags would have been parsed in resolveProxyConfig and set proxyConfig.port
// So if proxyConfig.port differs from default AND cfg.port differs, CLI wins
if (proxyConfig.port !== CLIPROXY_DEFAULT_PORT) {
cfg.port = proxyConfig.port; // CLI/ENV override variant port
}
// else: keep cfg.port (variant port)
} else if (proxyConfig.port !== CLIPROXY_DEFAULT_PORT) {
cfg.port = proxyConfig.port;
}