55import { LanguageModelChatInformation , LanguageModelChatProvider , lm } from 'vscode' ;
66import { IAuthenticationService } from '../../../platform/authentication/common/authentication' ;
77import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient' ;
8+ import { isScenarioAutomation } from '../../../platform/env/common/envService' ;
89import { IVSCodeExtensionContext } from '../../../platform/extContext/common/extensionContext' ;
910import { ILogService } from '../../../platform/log/common/logService' ;
1011import { IFetcherService } from '../../../platform/networking/common/fetcherService' ;
@@ -76,9 +77,14 @@ export class BYOKContrib extends Disposable implements IExtensionContribution {
7677 for ( const [ providerName , provider ] of this . _providers ) {
7778 this . _byokRegistrations . add ( lm . registerLanguageModelChatProvider ( providerName , provider ) ) ;
7879 }
80+ this . _logService . info ( `BYOK: registered ${ this . _providers . size } provider(s): ${ Array . from ( this . _providers . keys ( ) ) . join ( ', ' ) } ` ) ;
81+ } else if ( ! this . _byokProvidersRegistered ) {
82+ const copilotToken = authService . copilotToken ;
83+ this . _logService . debug ( `BYOK: not enabling — copilotToken=${ copilotToken ? 'present' : 'absent' } , isScenarioAutomation=${ isScenarioAutomation } , isInternal=${ copilotToken ?. isInternal ?? 'n/a' } , isIndividual=${ copilotToken ?. isIndividual ?? 'n/a' } ` ) ;
7984 }
8085 }
8186 private async fetchKnownModelList ( fetcherService : IFetcherService ) : Promise < Record < string , BYOKKnownModels > > {
87+ this . _logService . info ( 'BYOK: fetching known models list' ) ;
8288 const data = await ( await fetcherService . fetch ( 'https://main.vscode-cdn.net/extensions/copilotChat.json' , { method : 'GET' , callSite : 'byok-known-models' } ) ) . json ( ) ;
8389 // Use this for testing with changes from a local file. Don't check in
8490 // const data = JSON.parse((await this._fileSystemService.readFile(URI.file('/Users/roblou/code/vscode-engineering/chat/copilotChat.json'))).toString());
@@ -92,4 +98,4 @@ export class BYOKContrib extends Disposable implements IExtensionContribution {
9298 this . _logService . info ( 'BYOK: Copilot Chat known models list fetched successfully.' ) ;
9399 return knownModels ;
94100 }
95- }
101+ }
0 commit comments