@@ -8,6 +8,7 @@ import { DeferredPromise, raceCancellation } from 'vs/base/common/async';
88import { CancellationToken } from 'vs/base/common/cancellation' ;
99import { toErrorMessage } from 'vs/base/common/errorMessage' ;
1010import { Emitter } from 'vs/base/common/event' ;
11+ import { IMarkdownString } from 'vs/base/common/htmlContent' ;
1112import { StopWatch } from 'vs/base/common/stopwatch' ;
1213import { URI } from 'vs/base/common/uri' ;
1314import { localize } from 'vs/nls' ;
@@ -19,7 +20,7 @@ import { ExtHostChatProvider } from 'vs/workbench/api/common/extHostChatProvider
1920import * as typeConvert from 'vs/workbench/api/common/extHostTypeConverters' ;
2021import * as extHostTypes from 'vs/workbench/api/common/extHostTypes' ;
2122import { IChatAgentCommand , IChatAgentRequest , IChatAgentResult } from 'vs/workbench/contrib/chat/common/chatAgents' ;
22- import { IChatFollowup , IChatUserActionEvent , InteractiveSessionVoteDirection } from 'vs/workbench/contrib/chat/common/chatService' ;
23+ import { IChatFollowup , IChatReplyFollowup , IChatUserActionEvent , InteractiveSessionVoteDirection } from 'vs/workbench/contrib/chat/common/chatService' ;
2324import { checkProposedApiEnabled , isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions' ;
2425import type * as vscode from 'vscode' ;
2526
@@ -218,12 +219,30 @@ export class ExtHostChatAgents2 implements ExtHostChatAgentsShape2 {
218219 const items = await agent . invokeCompletionProvider ( query , token ) ;
219220 return items . map ( typeConvert . ChatAgentCompletionItem . from ) ;
220221 }
222+
223+ async $provideWelcomeMessage ( handle : number , token : CancellationToken ) : Promise < ( string | IMarkdownString ) [ ] | undefined > {
224+ const agent = this . _agents . get ( handle ) ;
225+ if ( ! agent ) {
226+ return ;
227+ }
228+
229+ return await agent . provideWelcomeMessage ( token ) ;
230+ }
231+
232+ async $provideSampleQuestions ( handle : number , token : CancellationToken ) : Promise < IChatReplyFollowup [ ] | undefined > {
233+ const agent = this . _agents . get ( handle ) ;
234+ if ( ! agent ) {
235+ return ;
236+ }
237+
238+ return await agent . provideSampleQuestions ( token ) ;
239+ }
221240}
222241
223242class ExtHostChatAgent < TResult extends vscode . ChatAgentResult2 > {
224243
225244 private _subCommandProvider : vscode . ChatAgentSubCommandProvider | undefined ;
226- private _followupProvider : vscode . FollowupProvider < TResult > | undefined ;
245+ private _followupProvider : vscode . ChatAgentFollowupProvider < TResult > | undefined ;
227246 private _description : string | undefined ;
228247 private _fullName : string | undefined ;
229248 private _iconPath : vscode . Uri | { light : vscode . Uri ; dark : vscode . Uri } | vscode . ThemeIcon | undefined ;
@@ -236,6 +255,7 @@ class ExtHostChatAgent<TResult extends vscode.ChatAgentResult2> {
236255 private _onDidPerformAction = new Emitter < vscode . ChatAgentUserActionEvent > ( ) ;
237256 private _supportIssueReporting : boolean | undefined ;
238257 private _agentVariableProvider ?: { provider : vscode . ChatAgentCompletionItemProvider ; triggerCharacters : string [ ] } ;
258+ private _welcomeMessageProvider ?: vscode . ChatAgentWelcomeMessageProvider | undefined ;
239259
240260 constructor (
241261 public readonly extension : IExtensionDescription ,
@@ -290,6 +310,35 @@ class ExtHostChatAgent<TResult extends vscode.ChatAgentResult2> {
290310 return followups . map ( f => typeConvert . ChatFollowup . from ( f ) ) ;
291311 }
292312
313+ async provideWelcomeMessage ( token : CancellationToken ) : Promise < ( string | IMarkdownString ) [ ] | undefined > {
314+ if ( ! this . _welcomeMessageProvider ) {
315+ return [ ] ;
316+ }
317+ const content = await this . _welcomeMessageProvider . provideWelcomeMessage ( token ) ;
318+ if ( ! content ) {
319+ return [ ] ;
320+ }
321+ return content . map ( item => {
322+ if ( typeof item === 'string' ) {
323+ return item ;
324+ } else {
325+ return typeConvert . MarkdownString . from ( item ) ;
326+ }
327+ } ) ;
328+ }
329+
330+ async provideSampleQuestions ( token : CancellationToken ) : Promise < IChatReplyFollowup [ ] > {
331+ if ( ! this . _welcomeMessageProvider || ! this . _welcomeMessageProvider . provideSampleQuestions ) {
332+ return [ ] ;
333+ }
334+ const content = await this . _welcomeMessageProvider . provideSampleQuestions ( token ) ;
335+ if ( ! content ) {
336+ return [ ] ;
337+ }
338+
339+ return content ?. map ( f => typeConvert . ChatReplyFollowup . from ( f ) ) ;
340+ }
341+
293342 get apiAgent ( ) : vscode . ChatAgent2 < TResult > {
294343 let disposed = false ;
295344 let updateScheduled = false ;
@@ -444,6 +493,13 @@ class ExtHostChatAgent<TResult extends vscode.ChatAgentResult2> {
444493 get agentVariableProvider ( ) {
445494 return that . _agentVariableProvider ;
446495 } ,
496+ set welcomeMessageProvider ( v ) {
497+ that . _welcomeMessageProvider = v ;
498+ updateMetadataSoon ( ) ;
499+ } ,
500+ get welcomeMessageProvider ( ) {
501+ return that . _welcomeMessageProvider ;
502+ } ,
447503 onDidPerformAction : ! isProposedApiEnabled ( this . extension , 'chatAgents2Additions' )
448504 ? undefined !
449505 : this . _onDidPerformAction . event
0 commit comments