From f0c845c32e7f389d8427941dd685898a3f894faa Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Fri, 23 Jan 2026 15:37:40 -0500 Subject: [PATCH] fix(cliproxy): use backend-aware labels in error messages and API - Use checkCliproxyUpdate() in checkLatestVersion() for correct repo - Dynamic error messages based on backend in service-manager - Dynamic error messages based on backend in cliproxy-executor - Generic "CLIProxy" message in oauth-process (no backend context) --- src/cliproxy/auth/oauth-process.ts | 2 +- src/cliproxy/cliproxy-executor.ts | 5 +++-- src/cliproxy/service-manager.ts | 9 ++++++++- src/cliproxy/services/binary-service.ts | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/cliproxy/auth/oauth-process.ts b/src/cliproxy/auth/oauth-process.ts index 6b5cb997..64d8ee44 100644 --- a/src/cliproxy/auth/oauth-process.ts +++ b/src/cliproxy/auth/oauth-process.ts @@ -271,7 +271,7 @@ async function handleTokenNotFound( /** Handle process exit with error */ function handleProcessError(code: number | null, state: ProcessState, headless: boolean): void { console.log(''); - console.log(fail(`CLIProxy Plus auth exited with code ${code}`)); + console.log(fail(`CLIProxy auth exited with code ${code}`)); if (state.stderrData && !state.urlDisplayed) { console.log(` ${state.stderrData.trim().split('\n')[0]}`); } diff --git a/src/cliproxy/cliproxy-executor.ts b/src/cliproxy/cliproxy-executor.ts index f019c6f4..bea75a25 100644 --- a/src/cliproxy/cliproxy-executor.ts +++ b/src/cliproxy/cliproxy-executor.ts @@ -724,12 +724,13 @@ export async function execClaudeWithCLIProxy( await waitForProxyReady(cfg.port, cfg.timeout, cfg.pollInterval); readySpinner.succeed(`CLIProxy ready on port ${cfg.port}`); } catch (error) { - readySpinner.fail('CLIProxy Plus startup failed'); + const backendLabel = backend === 'plus' ? 'CLIProxy Plus' : 'CLIProxy'; + readySpinner.fail(`${backendLabel} startup failed`); proxy.kill('SIGTERM'); const err = error as Error; console.error(''); - console.error(fail('CLIProxy Plus failed to start')); + console.error(fail(`${backendLabel} failed to start`)); console.error(''); console.error('Possible causes:'); console.error(` 1. Port ${cfg.port} already in use`); diff --git a/src/cliproxy/service-manager.ts b/src/cliproxy/service-manager.ts index 6788c66c..ea9dff59 100644 --- a/src/cliproxy/service-manager.ts +++ b/src/cliproxy/service-manager.ts @@ -281,11 +281,18 @@ export async function ensureCliproxyService( proxyProcess = null; } + // Get backend label for error message + const { loadOrCreateUnifiedConfig } = await import('../config/unified-config-loader'); + const { DEFAULT_BACKEND } = await import('./platform-detector'); + const config = loadOrCreateUnifiedConfig(); + const backendLabel = + (config.cliproxy?.backend ?? DEFAULT_BACKEND) === 'plus' ? 'CLIProxy Plus' : 'CLIProxy'; + return { started: false, alreadyRunning: false, port, - error: `CLIProxy Plus failed to start within 5s on port ${port}`, + error: `${backendLabel} failed to start within 5s on port ${port}`, }; } diff --git a/src/cliproxy/services/binary-service.ts b/src/cliproxy/services/binary-service.ts index 6ad3f392..41f8e803 100644 --- a/src/cliproxy/services/binary-service.ts +++ b/src/cliproxy/services/binary-service.ts @@ -75,7 +75,10 @@ export async function checkLatestVersion(backend?: CLIProxyBackend): Promise