@@ -285,7 +285,7 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
285
285
private readonly _proxy : MainThreadChatAgentsShape2 ;
286
286
287
287
private static _participantDetectionProviderIdPool = 0 ;
288
- private readonly _participantDetectionProviders = new Map < number , vscode . ChatParticipantDetectionProvider > ( ) ;
288
+ private readonly _participantDetectionProviders = new Map < number , ExtHostParticipantDetector > ( ) ;
289
289
290
290
private readonly _sessionDisposables : DisposableMap < string , DisposableStore > = this . _register ( new DisposableMap ( ) ) ;
291
291
private readonly _completionDisposables : DisposableMap < number , DisposableStore > = this . _register ( new DisposableMap ( ) ) ;
@@ -323,9 +323,9 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
323
323
return agent . apiAgent ;
324
324
}
325
325
326
- registerChatParticipantDetectionProvider ( provider : vscode . ChatParticipantDetectionProvider ) : vscode . Disposable {
326
+ registerChatParticipantDetectionProvider ( extension : IExtensionDescription , provider : vscode . ChatParticipantDetectionProvider ) : vscode . Disposable {
327
327
const handle = ExtHostChatAgents2 . _participantDetectionProviderIdPool ++ ;
328
- this . _participantDetectionProviders . set ( handle , provider ) ;
328
+ this . _participantDetectionProviders . set ( handle , new ExtHostParticipantDetector ( extension , provider ) ) ;
329
329
this . _proxy . $registerChatParticipantDetectionProvider ( handle ) ;
330
330
return toDisposable ( ( ) => {
331
331
this . _participantDetectionProviders . delete ( handle ) ;
@@ -336,13 +336,18 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
336
336
async $detectChatParticipant ( handle : number , requestDto : Dto < IChatAgentRequest > , context : { history : IChatAgentHistoryEntryDto [ ] } , options : { location : ChatAgentLocation ; participants ?: vscode . ChatParticipantMetadata [ ] } , token : CancellationToken ) : Promise < vscode . ChatParticipantDetectionResult | null | undefined > {
337
337
const { request, location, history } = await this . _createRequest ( requestDto , context ) ;
338
338
339
- const provider = this . _participantDetectionProviders . get ( handle ) ;
340
- if ( ! provider ) {
339
+ const detector = this . _participantDetectionProviders . get ( handle ) ;
340
+ if ( ! detector ) {
341
341
return undefined ;
342
342
}
343
343
344
- return provider . provideParticipantDetection (
345
- typeConvert . ChatAgentRequest . to ( request , location ) ,
344
+ const extRequest = typeConvert . ChatAgentRequest . to ( request , location ) ;
345
+ if ( request . userSelectedModelId && isProposedApiEnabled ( detector . extension , 'chatParticipantAdditions' ) ) {
346
+ extRequest . userSelectedModel = await this . _languageModels . getLanguageModelByIdentifier ( detector . extension , request . userSelectedModelId ) ;
347
+ }
348
+
349
+ return detector . provider . provideParticipantDetection (
350
+ extRequest ,
346
351
{ history } ,
347
352
{ participants : options . participants , location : typeConvert . ChatLocation . to ( options . location ) } ,
348
353
token
@@ -588,6 +593,13 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
588
593
}
589
594
}
590
595
596
+ class ExtHostParticipantDetector {
597
+ constructor (
598
+ public readonly extension : IExtensionDescription ,
599
+ public readonly provider : vscode . ChatParticipantDetectionProvider ,
600
+ ) { }
601
+ }
602
+
591
603
class ExtHostChatAgent {
592
604
593
605
private _followupProvider : vscode . ChatFollowupProvider | undefined ;
0 commit comments