diff --git a/src/cliproxy/binary-manager.ts b/src/cliproxy/binary-manager.ts index 203693ef..bda4604a 100644 --- a/src/cliproxy/binary-manager.ts +++ b/src/cliproxy/binary-manager.ts @@ -198,9 +198,9 @@ export async function installCliproxyVersion( } /** Fetch the latest CLIProxyAPI version from GitHub API */ -export async function fetchLatestCliproxyVersion(): Promise { - const backend = getConfiguredBackend(); - const result = await new BinaryManager({}, backend).checkForUpdates(); +export async function fetchLatestCliproxyVersion(backend?: CLIProxyBackend): Promise { + const effectiveBackend = backend ?? getConfiguredBackend(); + const result = await new BinaryManager({}, effectiveBackend).checkForUpdates(); return result.latestVersion; } @@ -221,9 +221,11 @@ export interface CliproxyUpdateCheckResult { } /** Check for CLIProxyAPI binary updates */ -export async function checkCliproxyUpdate(): Promise { - const backend = getConfiguredBackend(); - const result = await new BinaryManager({}, backend).checkForUpdates(); +export async function checkCliproxyUpdate( + backend?: CLIProxyBackend +): Promise { + const effectiveBackend = backend ?? getConfiguredBackend(); + const result = await new BinaryManager({}, effectiveBackend).checkForUpdates(); // Import isNewerVersion for stability check const { isNewerVersion } = await import('./binary/version-checker'); @@ -232,11 +234,11 @@ export async function checkCliproxyUpdate(): Promise ? undefined : `v${result.currentVersion} has known stability issues. Max stable: v${CLIPROXY_MAX_STABLE_VERSION}`; - const backendLabel = backend === 'plus' ? 'CLIProxy Plus' : 'CLIProxy'; + const backendLabel = effectiveBackend === 'plus' ? 'CLIProxy Plus' : 'CLIProxy'; return { ...result, - backend, + backend: effectiveBackend, backendLabel, isStable, maxStableVersion: CLIPROXY_MAX_STABLE_VERSION, diff --git a/src/cliproxy/services/binary-service.ts b/src/cliproxy/services/binary-service.ts index 41f8e803..3826e581 100644 --- a/src/cliproxy/services/binary-service.ts +++ b/src/cliproxy/services/binary-service.ts @@ -77,7 +77,7 @@ export async function checkLatestVersion(backend?: CLIProxyBackend): Promise = */ router.get('/update-check', async (_req: Request, res: Response): Promise => { try { - const result = await checkCliproxyUpdate(); + const backend = getConfiguredBackend(); + const result = await checkCliproxyUpdate(backend); res.json(result); } catch (error) { res.status(500).json({ error: (error as Error).message }); @@ -625,7 +626,8 @@ router.post('/install', async (req: Request, res: Response): Promise => { await new Promise((r) => setTimeout(r, 500)); // Install the version - await installCliproxyVersion(version, true); + const backend = getConfiguredBackend(); + await installCliproxyVersion(version, true, backend); res.json({ success: true,