55
66declare module 'vscode' {
77
8- /**
9- * One request/response pair in chat history.
10- */
11- export interface ChatAgentHistoryEntry {
12- /**
13- * The request that was sent to the chat agent.
14- */
15- request : ChatAgentRequest ;
16-
17- /**
18- * The content that was received from the chat agent. Only the progress parts that represent actual content (not metadata) are represented.
19- */
20- response : ReadonlyArray < ChatResponseTextPart | ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart > ;
21-
22- /**
23- * The result that was received from the chat agent.
24- */
25- result : ChatAgentResult2 ;
26- }
27-
288 // TODO@API name: Turn?
299 export class ChatAgentRequestTurn {
3010
@@ -38,15 +18,10 @@ declare module 'vscode' {
3818 */
3919 readonly prompt : string ;
4020
41- // TODO@API NAME agent
42- // TODO@API TYPE {agent:string, extension:string}
43- /** @deprecated */
44- readonly agentId : string ;
45-
4621 /**
4722 * The ID of the chat agent to which this request was directed.
4823 */
49- readonly agent : { extensionId : string ; agentId : string } ;
24+ readonly agent : { readonly extensionId : string ; readonly agentId : string } ;
5025
5126 /**
5227 * The name of the {@link ChatAgentCommand command} that was selected for this request.
@@ -74,10 +49,7 @@ declare module 'vscode' {
7449 */
7550 readonly result : ChatAgentResult2 ;
7651
77- /** @deprecated */
78- readonly agentId : string ;
79-
80- readonly agent : { extensionId : string ; agentId : string } ;
52+ readonly agent : { readonly extensionId : string ; readonly agentId : string } ;
8153
8254 private constructor ( response : ReadonlyArray < ChatResponseTextPart | ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart > , result : ChatAgentResult2 , agentId : { extensionId : string ; agentId : string } ) ;
8355 }
@@ -189,14 +161,15 @@ declare module 'vscode' {
189161
190162 /**
191163 * Returns a list of commands that its agent is capable of handling. A command
192- * can be selected by the user and will then be passed to the {@link ChatAgentHandler handler}
164+ * can be selected by the user and will then be passed to the {@link ChatAgentRequestHandler handler}
193165 * via the {@link ChatAgentRequest.command command} property.
194166 *
195167 *
196168 * @param token A cancellation token.
197169 * @returns A list of commands. The lack of a result can be signaled by returning `undefined`, `null`, or
198170 * an empty array.
199171 */
172+ // TODO@API Q: should we provide the current history or last results for extra context?
200173 provideCommands ( token : CancellationToken ) : ProviderResult < ChatAgentCommand [ ] > ;
201174 }
202175
@@ -228,6 +201,7 @@ declare module 'vscode' {
228201 /**
229202 * A title to show the user, when it is different than the message.
230203 */
204+ // TODO@API title vs tooltip?
231205 title ?: string ;
232206 }
233207
@@ -243,6 +217,12 @@ declare module 'vscode' {
243217 provideFollowups ( result : ChatAgentResult2 , token : CancellationToken ) : ProviderResult < ChatAgentFollowup [ ] > ;
244218 }
245219
220+ /**
221+ * A chat request handler is a callback that will be invoked when a request is made to a chat agent.
222+ */
223+ export type ChatAgentRequestHandler = ( request : ChatAgentRequest , context : ChatAgentContext , response : ChatAgentResponseStream , token : CancellationToken ) => ProviderResult < ChatAgentResult2 > ;
224+
225+
246226 export interface ChatAgent2 {
247227
248228 /**
@@ -274,6 +254,11 @@ declare module 'vscode' {
274254 dark : Uri ;
275255 } | ThemeIcon ;
276256
257+ /**
258+ * The handler for requests to this agent.
259+ */
260+ requestHandler : ChatAgentRequestHandler ;
261+
277262 /**
278263 * This provider will be called to retrieve the agent's commands.
279264 */
@@ -284,16 +269,6 @@ declare module 'vscode' {
284269 */
285270 followupProvider ?: ChatAgentFollowupProvider ;
286271
287-
288- // TODO@API
289- // notify(request: ChatResponsePart, reference: string): boolean;
290- // BETTER
291- // requestResponseStream(result: ChatAgentResult, callback: (stream: ChatAgentResponseStream) => void, why?: string): void;
292-
293- // TODO@API
294- // clear NEVER happens
295- // onDidClearResult(value: TResult): void;
296-
297272 /**
298273 * When the user clicks this agent in `/help`, this text will be submitted to this command
299274 */
@@ -315,9 +290,9 @@ declare module 'vscode' {
315290 }
316291
317292 export interface ChatAgentResolvedVariable {
318- name : string ;
319- range : [ start : number , end : number ] ;
320- values : ChatVariableValue [ ] ;
293+ readonly name : string ;
294+ readonly range : [ start : number , end : number ] ;
295+ readonly values : ChatVariableValue [ ] ;
321296 }
322297
323298 export interface ChatAgentRequest {
@@ -330,17 +305,17 @@ declare module 'vscode' {
330305 * *Note* that the {@link ChatAgent2.name name} of the agent and the {@link ChatAgentCommand.name command}
331306 * are not part of the prompt.
332307 */
333- prompt : string ;
308+ readonly prompt : string ;
334309
335310 /**
336311 * The name of the {@link ChatAgentCommand command} that was selected for this request.
337312 */
338- command ? : string ;
313+ readonly command : string | undefined ;
339314
340315 /**
341316 * The list of variables that are referenced in the prompt.
342317 */
343- variables : ChatAgentResolvedVariable [ ] ;
318+ readonly variables : readonly ChatAgentResolvedVariable [ ] ;
344319 }
345320
346321 export interface ChatAgentResponseStream {
@@ -429,11 +404,6 @@ declare module 'vscode' {
429404 push ( part : ChatResponsePart ) : ChatAgentResponseStream ;
430405 }
431406
432- // TODO@API
433- // support ChatResponseCommandPart
434- // support ChatResponseTextEditPart
435- // support ChatResponseCodeReferencePart
436-
437407 // TODO@API should the name suffix differentiate between rendered items (XYZPart)
438408 // and metadata like XYZItem
439409 export class ChatResponseTextPart {
@@ -482,9 +452,6 @@ declare module 'vscode' {
482452 | ChatResponseProgressPart | ChatResponseReferencePart | ChatResponseCommandButtonPart ;
483453
484454
485- // TODO@API Remove a different type of `request` so that they can
486- // evolve at their own pace
487- export type ChatAgentHandler = ( request : ChatAgentRequest , context : ChatAgentContext , response : ChatAgentResponseStream , token : CancellationToken ) => ProviderResult < ChatAgentResult2 > ;
488455
489456 export namespace chat {
490457
@@ -495,7 +462,7 @@ declare module 'vscode' {
495462 * @param handler The reply-handler of the agent.
496463 * @returns A new chat agent
497464 */
498- export function createChatAgent ( name : string , handler : ChatAgentHandler ) : ChatAgent2 ;
465+ export function createChatAgent ( name : string , handler : ChatAgentRequestHandler ) : ChatAgent2 ;
499466
500467 /**
501468 * Register a variable which can be used in a chat request to any agent.
0 commit comments