@@ -7,6 +7,32 @@ import { useHeaderRefresh } from '@/shared/hooks';
77import { AuthFile , type ProviderId } from '@/types' ;
88import { openExternalUrl , isTauri } from '@/services/tauri' ;
99import { toast } from 'sonner' ;
10+ import { PLUS_ONLY_PROVIDERS } from '@/constants' ;
11+ import { useCliProxyStore } from '@/features/settings/cliProxy.store' ;
12+
13+ export function detectIsPlusVersion ( serverVersion : string | null | undefined ) : boolean | null {
14+ if ( ! serverVersion ) return null ;
15+ const cleaned = serverVersion . trim ( ) . replace ( / ^ v / i, '' ) ;
16+ if ( ! cleaned ) return null ;
17+ return / - / . test ( cleaned ) ;
18+ }
19+
20+ export function checkIsNonPlusServer ( ) : boolean {
21+ const { serverVersion } = useAuthStore . getState ( ) ;
22+ const fromServerVersion = detectIsPlusVersion ( serverVersion ) ;
23+ if ( fromServerVersion !== null ) return ! fromServerVersion ;
24+
25+ const { currentInstalledVersion, cliProxyVersion, exePath } = useCliProxyStore . getState ( ) ;
26+ const fromInstalledVersion = detectIsPlusVersion ( currentInstalledVersion ) ;
27+ if ( fromInstalledVersion !== null ) return ! fromInstalledVersion ;
28+
29+ if ( cliProxyVersion === 'plus' ) return false ;
30+ if ( cliProxyVersion === 'standard' ) return true ;
31+
32+ if ( exePath && exePath . toLowerCase ( ) . includes ( 'plus' ) ) return false ;
33+
34+ return false ;
35+ }
1036
1137export type ProviderStatus = 'idle' | 'waiting' | 'polling' | 'success' | 'error' ;
1238
@@ -276,6 +302,12 @@ export function useProvidersPresenter() {
276302 } , [ stopPolling , loadFiles , updateProviderState , t ] ) ;
277303
278304 const startAuth = useCallback ( async ( providerId : ProviderId , options ?: { projectId ?: string } ) => {
305+ // Block plus-only providers when using standard (non-plus) CLIProxyAPI
306+ if ( PLUS_ONLY_PROVIDERS . includes ( providerId ) && checkIsNonPlusServer ( ) ) {
307+ toast . error ( t ( 'providers.plusOnly' , 'This provider requires CLIProxyAPI Plus version' ) ) ;
308+ return ;
309+ }
310+
279311 stopPolling ( providerId ) ;
280312 updateProviderState ( providerId , { status : 'waiting' , error : undefined } ) ;
281313 setSelectedProvider ( providerId ) ;
@@ -319,7 +351,6 @@ export function useProvidersPresenter() {
319351 return ;
320352 }
321353
322- // Copilot uses device code flow via backend
323354 if ( providerId === 'copilot' ) {
324355 try {
325356 const response = await oauthApi . startAuth ( 'copilot' ) ;
@@ -561,8 +592,27 @@ export function useProvidersPresenter() {
561592 setIsPrivacyMode ( prev => ! prev ) ;
562593 } , [ ] ) ;
563594
595+ // Auto-detect Plus version from multiple sources
596+ const { serverVersion } = useAuthStore ( ) ;
597+ const { currentInstalledVersion, cliProxyVersion, exePath } = useCliProxyStore ( ) ;
598+ const isNonPlusServer = useMemo ( ( ) => {
599+ // Check serverVersion (from API response headers)
600+ const fromServer = detectIsPlusVersion ( serverVersion ) ;
601+ if ( fromServer !== null ) return ! fromServer ;
602+ // Check currentInstalledVersion (from update check)
603+ const fromInstalled = detectIsPlusVersion ( currentInstalledVersion ) ;
604+ if ( fromInstalled !== null ) return ! fromInstalled ;
605+ // Check explicit cliProxyVersion
606+ if ( cliProxyVersion === 'plus' ) return false ;
607+ if ( cliProxyVersion === 'standard' ) return true ;
608+ // Check exe path
609+ if ( exePath && exePath . toLowerCase ( ) . includes ( 'plus' ) ) return false ;
610+ return false ;
611+ } , [ serverVersion , currentInstalledVersion , cliProxyVersion , exePath ] ) ;
612+
564613 return {
565614 isAuthenticated,
615+ isNonPlusServer,
566616
567617 // Connected accounts
568618 files,
0 commit comments