Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vscode-dts/vscode.proposed.chatParticipantAdditions.d.ts
5266 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
// version: 3
7
8
declare module 'vscode' {
9
10
export interface ChatParticipant {
11
readonly onDidPerformAction: Event<ChatUserActionEvent>;
12
}
13
14
/**
15
* Now only used for the "intent detection" API below
16
*/
17
export interface ChatCommand {
18
readonly name: string;
19
readonly description: string;
20
}
21
22
export interface ChatVulnerability {
23
title: string;
24
description: string;
25
// id: string; // Later we will need to be able to link these across multiple content chunks.
26
}
27
28
export class ChatResponseMarkdownWithVulnerabilitiesPart {
29
value: MarkdownString;
30
vulnerabilities: ChatVulnerability[];
31
constructor(value: string | MarkdownString, vulnerabilities: ChatVulnerability[]);
32
}
33
34
export class ChatResponseCodeblockUriPart {
35
isEdit?: boolean;
36
value: Uri;
37
undoStopId?: string;
38
constructor(value: Uri, isEdit?: boolean, undoStopId?: string);
39
}
40
41
/**
42
* Displays a {@link Command command} as a button in the chat response.
43
*/
44
export interface ChatCommandButton {
45
command: Command;
46
}
47
48
export interface ChatDocumentContext {
49
uri: Uri;
50
version: number;
51
ranges: Range[];
52
}
53
54
export class ChatResponseTextEditPart {
55
uri: Uri;
56
edits: TextEdit[];
57
isDone?: boolean;
58
constructor(uri: Uri, done: true);
59
constructor(uri: Uri, edits: TextEdit | TextEdit[]);
60
}
61
62
export class ChatResponseNotebookEditPart {
63
uri: Uri;
64
edits: NotebookEdit[];
65
isDone?: boolean;
66
constructor(uri: Uri, done: true);
67
constructor(uri: Uri, edits: NotebookEdit | NotebookEdit[]);
68
}
69
70
/**
71
* Represents a file-level edit (creation, deletion, or rename).
72
*/
73
export interface ChatWorkspaceFileEdit {
74
/**
75
* The original file URI (undefined for new files).
76
*/
77
oldResource?: Uri;
78
79
/**
80
* The new file URI (undefined for deleted files).
81
*/
82
newResource?: Uri;
83
}
84
85
/**
86
* Represents a workspace edit containing file-level operations.
87
*/
88
export class ChatResponseWorkspaceEditPart {
89
edits: ChatWorkspaceFileEdit[];
90
constructor(edits: ChatWorkspaceFileEdit[]);
91
}
92
93
export class ChatResponseConfirmationPart {
94
title: string;
95
message: string | MarkdownString;
96
data: any;
97
buttons?: string[];
98
constructor(title: string, message: string | MarkdownString, data: any, buttons?: string[]);
99
}
100
101
/**
102
* An option for a question in a carousel.
103
*/
104
export interface ChatQuestionOption {
105
/**
106
* Unique identifier for the option.
107
*/
108
id: string;
109
/**
110
* The display label for the option.
111
*/
112
label: string;
113
/**
114
* The value returned when this option is selected.
115
*/
116
value: unknown;
117
}
118
119
/**
120
* The type of question for a chat question carousel.
121
*/
122
export enum ChatQuestionType {
123
/**
124
* A free-form text input question.
125
*/
126
Text = 1,
127
/**
128
* A single-select question with radio buttons.
129
*/
130
SingleSelect = 2,
131
/**
132
* A multi-select question with checkboxes.
133
*/
134
MultiSelect = 3
135
}
136
137
/**
138
* A question to be displayed in a question carousel.
139
*/
140
export class ChatQuestion {
141
/**
142
* Unique identifier for the question.
143
*/
144
id: string;
145
/**
146
* The type of question: Text for free-form input, SingleSelect for radio buttons, MultiSelect for checkboxes.
147
*/
148
type: ChatQuestionType;
149
/**
150
* The title/header of the question.
151
*/
152
title: string;
153
/**
154
* Optional detailed message or description for the question.
155
*/
156
message?: string | MarkdownString;
157
/**
158
* Options for singleSelect or multiSelect questions.
159
*/
160
options?: ChatQuestionOption[];
161
/**
162
* The id(s) of the default selected option(s).
163
* For SingleSelect, this should be a single option id.
164
* For MultiSelect, this can be an array of option ids.
165
*/
166
defaultValue?: string | string[];
167
/**
168
* Whether to allow free-form text input in addition to predefined options.
169
* When true, users can provide their own text answer even for SingleSelect or MultiSelect questions.
170
*/
171
allowFreeformInput?: boolean;
172
173
constructor(
174
id: string,
175
type: ChatQuestionType,
176
title: string,
177
options?: {
178
message?: string | MarkdownString;
179
options?: ChatQuestionOption[];
180
defaultValue?: string | string[];
181
allowFreeformInput?: boolean;
182
}
183
);
184
}
185
186
/**
187
* A carousel view for presenting multiple questions inline in the chat.
188
* The UI is displayed but does not block the chat input.
189
*/
190
export class ChatResponseQuestionCarouselPart {
191
/**
192
* The questions to display in the carousel.
193
*/
194
questions: ChatQuestion[];
195
/**
196
* Whether users can skip answering the questions.
197
*/
198
allowSkip: boolean;
199
200
constructor(questions: ChatQuestion[], allowSkip?: boolean);
201
}
202
203
export class ChatResponseCodeCitationPart {
204
value: Uri;
205
license: string;
206
snippet: string;
207
constructor(value: Uri, license: string, snippet: string);
208
}
209
210
export interface ChatToolInvocationStreamData {
211
/**
212
* Partial or not-yet-validated arguments that have streamed from the language model.
213
* Tools may use this to render interim UI while the full invocation input is collected.
214
*/
215
readonly partialInput?: unknown;
216
}
217
218
export interface ChatTerminalToolInvocationData {
219
commandLine: {
220
original: string;
221
userEdited?: string;
222
toolEdited?: string;
223
};
224
language: string;
225
226
/**
227
* Terminal command output. Displayed when the terminal is no longer available.
228
*/
229
output?: {
230
/** The raw output text, may include ANSI escape codes. */
231
text: string;
232
};
233
234
/**
235
* Command execution state.
236
*/
237
state?: {
238
/** Exit code of the command. */
239
exitCode?: number;
240
/** Duration of execution in milliseconds. */
241
duration?: number;
242
};
243
}
244
245
export class McpToolInvocationContentData {
246
/**
247
* The mime type which determines how the data property is interpreted.
248
*/
249
mimeType: string;
250
251
/**
252
* The byte data for this part.
253
*/
254
data: Uint8Array;
255
256
/**
257
* Construct a generic data part with the given content.
258
* @param data The byte data for this part.
259
* @param mimeType The mime type of the data.
260
*/
261
constructor(data: Uint8Array, mimeType: string);
262
}
263
264
export interface ChatMcpToolInvocationData {
265
input: string;
266
output: McpToolInvocationContentData[];
267
}
268
269
export enum ChatTodoStatus {
270
NotStarted = 1,
271
InProgress = 2,
272
Completed = 3
273
}
274
275
export interface ChatTodoToolInvocationData {
276
todoList: Array<{
277
id: number;
278
title: string;
279
status: ChatTodoStatus;
280
}>;
281
}
282
283
/**
284
* Generic tool result data that displays input and output in collapsible sections.
285
*/
286
export interface ChatSimpleToolResultData {
287
/**
288
* The input to display.
289
*/
290
input: string;
291
/**
292
* The output to display.
293
*/
294
output: string;
295
}
296
297
298
export interface ChatToolResourcesInvocationData {
299
/**
300
* Array of file URIs or locations to display as a collapsible list
301
*/
302
values: Array<Uri | Location>;
303
}
304
305
export class ChatSubagentToolInvocationData {
306
/**
307
* A description of the subagent's purpose or task.
308
*/
309
description?: string;
310
311
/**
312
* The name of the subagent being invoked.
313
*/
314
agentName?: string;
315
316
/**
317
* The prompt given to the subagent.
318
*/
319
prompt?: string;
320
321
/**
322
* The result text from the subagent after completion.
323
*/
324
result?: string;
325
326
constructor(description?: string, agentName?: string, prompt?: string, result?: string);
327
}
328
329
export class ChatToolInvocationPart {
330
toolName: string;
331
toolCallId: string;
332
isError?: boolean;
333
invocationMessage?: string | MarkdownString;
334
originMessage?: string | MarkdownString;
335
pastTenseMessage?: string | MarkdownString;
336
isConfirmed?: boolean;
337
isComplete?: boolean;
338
toolSpecificData?: ChatTerminalToolInvocationData | ChatMcpToolInvocationData | ChatTodoToolInvocationData | ChatSimpleToolResultData | ChatToolResourcesInvocationData | ChatSubagentToolInvocationData;
339
subAgentInvocationId?: string;
340
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;
341
342
/**
343
* If this flag is set, this will be treated as an update to any previous tool call with the same id.
344
*/
345
enablePartialUpdate?: boolean;
346
347
constructor(toolName: string, toolCallId: string, errorMessage?: string);
348
}
349
350
/**
351
* Represents a single file diff entry in a multi diff view.
352
*/
353
export interface ChatResponseDiffEntry {
354
/**
355
* The original file URI (undefined for new files).
356
*/
357
originalUri?: Uri;
358
359
/**
360
* The modified file URI (undefined for deleted files).
361
*/
362
modifiedUri?: Uri;
363
364
/**
365
* Optional URI to navigate to when clicking on the file.
366
*/
367
goToFileUri?: Uri;
368
369
/**
370
* Added data (e.g. line numbers) to show in the UI
371
*/
372
added?: number;
373
374
/**
375
* Removed data (e.g. line numbers) to show in the UI
376
*/
377
removed?: number;
378
}
379
380
/**
381
* Represents a part of a chat response that shows multiple file diffs.
382
*/
383
export class ChatResponseMultiDiffPart {
384
/**
385
* Array of file diff entries to display.
386
*/
387
value: ChatResponseDiffEntry[];
388
389
/**
390
* The title for the multi diff editor.
391
*/
392
title: string;
393
394
/**
395
* Whether the multi diff editor should be read-only.
396
* When true, users cannot open individual files or interact with file navigation.
397
*/
398
readOnly?: boolean;
399
400
/**
401
* Create a new ChatResponseMultiDiffPart.
402
* @param value Array of file diff entries.
403
* @param title The title for the multi diff editor.
404
* @param readOnly Optional flag to make the multi diff editor read-only.
405
*/
406
constructor(value: ChatResponseDiffEntry[], title: string, readOnly?: boolean);
407
}
408
409
export class ChatResponseExternalEditPart {
410
uris: Uri[];
411
callback: () => Thenable<unknown>;
412
applied: Thenable<string>;
413
constructor(uris: Uri[], callback: () => Thenable<unknown>);
414
}
415
416
/**
417
* Internal type that lists all the proposed chat response parts. This is used to generate `ExtendedChatResponsePart`
418
* which is the actual type used in this API. This is done so that other proposals can easily add their own response parts
419
* without having to modify this file.
420
*/
421
export interface ExtendedChatResponseParts {
422
ChatResponsePart: ChatResponsePart;
423
ChatResponseTextEditPart: ChatResponseTextEditPart;
424
ChatResponseNotebookEditPart: ChatResponseNotebookEditPart;
425
ChatResponseWorkspaceEditPart: ChatResponseWorkspaceEditPart;
426
ChatResponseConfirmationPart: ChatResponseConfirmationPart;
427
ChatResponseCodeCitationPart: ChatResponseCodeCitationPart;
428
ChatResponseReferencePart2: ChatResponseReferencePart2;
429
ChatResponseMovePart: ChatResponseMovePart;
430
ChatResponseExtensionsPart: ChatResponseExtensionsPart;
431
ChatResponsePullRequestPart: ChatResponsePullRequestPart;
432
ChatToolInvocationPart: ChatToolInvocationPart;
433
ChatResponseMultiDiffPart: ChatResponseMultiDiffPart;
434
ChatResponseThinkingProgressPart: ChatResponseThinkingProgressPart;
435
ChatResponseExternalEditPart: ChatResponseExternalEditPart;
436
ChatResponseQuestionCarouselPart: ChatResponseQuestionCarouselPart;
437
}
438
439
export type ExtendedChatResponsePart = ExtendedChatResponseParts[keyof ExtendedChatResponseParts];
440
441
export class ChatResponseWarningPart {
442
value: MarkdownString;
443
constructor(value: string | MarkdownString);
444
}
445
446
export class ChatResponseProgressPart2 extends ChatResponseProgressPart {
447
value: string;
448
task?: (progress: Progress<ChatResponseWarningPart | ChatResponseReferencePart>) => Thenable<string | void>;
449
constructor(value: string, task?: (progress: Progress<ChatResponseWarningPart | ChatResponseReferencePart>) => Thenable<string | void>);
450
}
451
452
/**
453
* A specialized progress part for displaying thinking/reasoning steps.
454
*/
455
export class ChatResponseThinkingProgressPart {
456
value: string | string[];
457
id?: string;
458
metadata?: { readonly [key: string]: any };
459
task?: (progress: Progress<LanguageModelThinkingPart>) => Thenable<string | void>;
460
461
/**
462
* Creates a new thinking progress part.
463
* @param value An initial progress message
464
* @param task A task that will emit thinking parts during its execution
465
*/
466
constructor(value: string | string[], id?: string, metadata?: { readonly [key: string]: any }, task?: (progress: Progress<LanguageModelThinkingPart>) => Thenable<string | void>);
467
}
468
469
export class ChatResponseReferencePart2 {
470
/**
471
* The reference target.
472
*/
473
value: Uri | Location | { variableName: string; value?: Uri | Location } | string;
474
475
/**
476
* The icon for the reference.
477
*/
478
iconPath?: Uri | ThemeIcon | {
479
/**
480
* The icon path for the light theme.
481
*/
482
light: Uri;
483
/**
484
* The icon path for the dark theme.
485
*/
486
dark: Uri;
487
};
488
options?: { status?: { description: string; kind: ChatResponseReferencePartStatusKind } };
489
490
/**
491
* Create a new ChatResponseReferencePart.
492
* @param value A uri or location
493
* @param iconPath Icon for the reference shown in UI
494
*/
495
constructor(value: Uri | Location | { variableName: string; value?: Uri | Location } | string, iconPath?: Uri | ThemeIcon | {
496
/**
497
* The icon path for the light theme.
498
*/
499
light: Uri;
500
/**
501
* The icon path for the dark theme.
502
*/
503
dark: Uri;
504
}, options?: { status?: { description: string; kind: ChatResponseReferencePartStatusKind } });
505
}
506
507
export class ChatResponseMovePart {
508
509
readonly uri: Uri;
510
readonly range: Range;
511
512
constructor(uri: Uri, range: Range);
513
}
514
515
export interface ChatResponseAnchorPart {
516
/**
517
* The target of this anchor.
518
*
519
* If this is a {@linkcode Uri} or {@linkcode Location}, this is rendered as a normal link.
520
*
521
* If this is a {@linkcode SymbolInformation}, this is rendered as a symbol link.
522
*
523
* TODO mjbvz: Should this be a full `SymbolInformation`? Or just the parts we need?
524
* TODO mjbvz: Should we allow a `SymbolInformation` without a location? For example, until `resolve` completes?
525
*/
526
value2: Uri | Location | SymbolInformation;
527
528
/**
529
* Optional method which fills in the details of the anchor.
530
*
531
* THis is currently only implemented for symbol links.
532
*/
533
resolve?(token: CancellationToken): Thenable<void>;
534
}
535
536
export class ChatResponseExtensionsPart {
537
538
readonly extensions: string[];
539
540
constructor(extensions: string[]);
541
}
542
543
export class ChatResponsePullRequestPart {
544
/**
545
* @deprecated use `command` instead
546
*/
547
readonly uri?: Uri;
548
readonly command: Command;
549
readonly linkTag: string;
550
readonly title: string;
551
readonly description: string;
552
readonly author: string;
553
constructor(uriOrCommand: Uri | Command, title: string, description: string, author: string, linkTag: string);
554
}
555
556
export interface ChatResponseStream {
557
558
/**
559
* Push a progress part to this stream. Short-hand for
560
* `push(new ChatResponseProgressPart(value))`.
561
*
562
* @param value A progress message
563
* @param task If provided, a task to run while the progress is displayed. When the Thenable resolves, the progress will be marked complete in the UI, and the progress message will be updated to the resolved string if one is specified.
564
* @returns This stream.
565
*/
566
progress(value: string, task?: (progress: Progress<ChatResponseWarningPart | ChatResponseReferencePart>) => Thenable<string | void>): void;
567
568
thinkingProgress(thinkingDelta: ThinkingDelta): void;
569
570
textEdit(target: Uri, edits: TextEdit | TextEdit[]): void;
571
572
textEdit(target: Uri, isDone: true): void;
573
574
notebookEdit(target: Uri, edits: NotebookEdit | NotebookEdit[]): void;
575
576
notebookEdit(target: Uri, isDone: true): void;
577
578
/**
579
* Push a workspace edit containing file-level operations (create, delete, rename).
580
* @param edits Array of file-level edits to apply
581
*/
582
workspaceEdit(edits: ChatWorkspaceFileEdit[]): void;
583
584
/**
585
* Makes an external edit to one or more resources. Changes to the
586
* resources made within the `callback` and before it resolves will be
587
* tracked as agent edits. This can be used to track edits made from
588
* external tools that don't generate simple {@link textEdit textEdits}.
589
*/
590
externalEdit(target: Uri | Uri[], callback: () => Thenable<unknown>): Thenable<string>;
591
592
markdownWithVulnerabilities(value: string | MarkdownString, vulnerabilities: ChatVulnerability[]): void;
593
codeblockUri(uri: Uri, isEdit?: boolean): void;
594
push(part: ChatResponsePart | ChatResponseTextEditPart | ChatResponseWarningPart | ChatResponseProgressPart2): void;
595
596
/**
597
* Show an inline message in the chat view asking the user to confirm an action.
598
* Multiple confirmations may be shown per response. The UI might show "Accept All" / "Reject All" actions.
599
* @param title The title of the confirmation entry
600
* @param message An extra message to display to the user
601
* @param data An arbitrary JSON-stringifiable object that will be included in the ChatRequest when
602
* the confirmation is accepted or rejected
603
* TODO@API should this be MarkdownString?
604
* TODO@API should actually be a more generic function that takes an array of buttons
605
*/
606
confirmation(title: string, message: string | MarkdownString, data: any, buttons?: string[]): void;
607
608
/**
609
* Show an inline carousel of questions to gather information from the user.
610
* This is a blocking call that waits for the user to submit or skip the questions.
611
* @param questions Array of questions to display to the user
612
* @param allowSkip Whether the user can skip questions without answering
613
* @returns A promise that resolves with the user's answers, or undefined if skipped
614
*/
615
questionCarousel(questions: ChatQuestion[], allowSkip?: boolean): Thenable<Record<string, unknown> | undefined>;
616
617
/**
618
* Push a warning to this stream. Short-hand for
619
* `push(new ChatResponseWarningPart(message))`.
620
*
621
* @param message A warning message
622
* @returns This stream.
623
*/
624
warning(message: string | MarkdownString): void;
625
626
reference(value: Uri | Location | { variableName: string; value?: Uri | Location }, iconPath?: Uri | ThemeIcon | { light: Uri; dark: Uri }): void;
627
628
reference2(value: Uri | Location | string | { variableName: string; value?: Uri | Location }, iconPath?: Uri | ThemeIcon | { light: Uri; dark: Uri }, options?: { status?: { description: string; kind: ChatResponseReferencePartStatusKind } }): void;
629
630
codeCitation(value: Uri, license: string, snippet: string): void;
631
632
/**
633
* Begin a tool invocation in streaming mode. This creates a tool invocation that will
634
* display streaming progress UI until the tool is actually invoked.
635
* @param toolCallId Unique identifier for this tool call, used to correlate streaming updates and final invocation.
636
* @param toolName The name of the tool being invoked.
637
* @param streamData Optional initial streaming data with partial arguments.
638
*/
639
beginToolInvocation(toolCallId: string, toolName: string, streamData?: ChatToolInvocationStreamData & { subagentInvocationId?: string }): void;
640
641
/**
642
* Update the streaming data for a tool invocation that was started with `beginToolInvocation`.
643
* @param toolCallId The tool call ID that was passed to `beginToolInvocation`.
644
* @param streamData New streaming data with updated partial arguments.
645
*/
646
updateToolInvocation(toolCallId: string, streamData: ChatToolInvocationStreamData): void;
647
648
push(part: ExtendedChatResponsePart): void;
649
650
clearToPreviousToolInvocation(reason: ChatResponseClearToPreviousToolInvocationReason): void;
651
652
/**
653
* Report token usage information for this request.
654
* This is typically called when the underlying language model provides usage statistics.
655
* @param usage Token usage information including prompt and completion tokens
656
*/
657
usage(usage: ChatResultUsage): void;
658
}
659
660
export enum ChatResponseReferencePartStatusKind {
661
Complete = 1,
662
Partial = 2,
663
Omitted = 3
664
}
665
666
export type ThinkingDelta = {
667
text?: string | string[];
668
id: string;
669
metadata?: { readonly [key: string]: any };
670
} | {
671
text?: string | string[];
672
id?: string;
673
metadata: { readonly [key: string]: any };
674
} |
675
{
676
text: string | string[];
677
id?: string;
678
metadata?: { readonly [key: string]: any };
679
};
680
681
export enum ChatResponseClearToPreviousToolInvocationReason {
682
NoReason = 0,
683
FilteredContentRetry = 1,
684
CopyrightContentRetry = 2,
685
}
686
687
/**
688
* Does this piggy-back on the existing ChatRequest, or is it a different type of request entirely?
689
* Does it show up in history?
690
*/
691
export interface ChatRequest {
692
/**
693
* The `data` for any confirmations that were accepted
694
*/
695
acceptedConfirmationData?: any[];
696
697
/**
698
* The `data` for any confirmations that were rejected
699
*/
700
rejectedConfirmationData?: any[];
701
}
702
703
export interface ChatRequest {
704
705
/**
706
* A map of all tools that should (`true`) and should not (`false`) be used in this request.
707
*/
708
readonly tools: Map<LanguageModelToolInformation, boolean>;
709
}
710
711
export namespace lm {
712
/**
713
* Fired when the set of tools on a chat request changes.
714
*/
715
export const onDidChangeChatRequestTools: Event<ChatRequest>;
716
}
717
718
export class LanguageModelToolExtensionSource {
719
/**
720
* ID of the extension that published the tool.
721
*/
722
readonly id: string;
723
724
/**
725
* Label of the extension that published the tool.
726
*/
727
readonly label: string;
728
729
private constructor(id: string, label: string);
730
}
731
732
export class LanguageModelToolMCPSource {
733
/**
734
* Editor-configured label of the MCP server that published the tool.
735
*/
736
readonly label: string;
737
738
/**
739
* Server-defined name of the MCP server.
740
*/
741
readonly name: string;
742
743
/**
744
* Server-defined instructions for MCP tool use.
745
*/
746
readonly instructions?: string;
747
748
private constructor(label: string, name: string, instructions?: string);
749
}
750
751
export interface LanguageModelToolInformation {
752
source: LanguageModelToolExtensionSource | LanguageModelToolMCPSource | undefined;
753
}
754
755
// TODO@API fit this into the stream
756
export interface ChatUsedContext {
757
documents: ChatDocumentContext[];
758
}
759
760
export interface ChatParticipant {
761
/**
762
* Provide a set of variables that can only be used with this participant.
763
*/
764
participantVariableProvider?: { provider: ChatParticipantCompletionItemProvider; triggerCharacters: string[] };
765
766
/**
767
* Event that fires when a request is paused or unpaused.
768
* Chat requests are initially unpaused in the {@link requestHandler}.
769
*/
770
readonly onDidChangePauseState: Event<ChatParticipantPauseStateEvent>;
771
}
772
773
export interface ChatParticipantPauseStateEvent {
774
request: ChatRequest;
775
isPaused: boolean;
776
}
777
778
export interface ChatParticipantCompletionItemProvider {
779
provideCompletionItems(query: string, token: CancellationToken): ProviderResult<ChatCompletionItem[]>;
780
}
781
782
export class ChatCompletionItem {
783
id: string;
784
label: string | CompletionItemLabel;
785
values: ChatVariableValue[];
786
fullName?: string;
787
icon?: ThemeIcon;
788
insertText?: string;
789
detail?: string;
790
documentation?: string | MarkdownString;
791
command?: Command;
792
793
constructor(id: string, label: string | CompletionItemLabel, values: ChatVariableValue[]);
794
}
795
796
export type ChatExtendedRequestHandler = (request: ChatRequest, context: ChatContext, response: ChatResponseStream, token: CancellationToken) => ProviderResult<ChatResult | void>;
797
798
/**
799
* Details about the prompt token usage by category and label.
800
*/
801
export interface ChatResultPromptTokenDetail {
802
/**
803
* The category this token usage belongs to (e.g., "System", "Context", "Conversation").
804
*/
805
readonly category: string;
806
807
/**
808
* The label for this specific token usage (e.g., "System prompt", "Attached files").
809
*/
810
readonly label: string;
811
812
/**
813
* The percentage of the total prompt tokens this represents (0-100).
814
*/
815
readonly percentageOfPrompt: number;
816
}
817
818
/**
819
* Token usage information for a chat request.
820
*/
821
export interface ChatResultUsage {
822
/**
823
* The number of prompt tokens used in this request.
824
*/
825
readonly promptTokens: number;
826
827
/**
828
* The number of completion tokens generated in this response.
829
*/
830
readonly completionTokens: number;
831
832
/**
833
* Optional breakdown of prompt token usage by category and label.
834
* If the percentages do not sum to 100%, the remaining will be shown as "Uncategorized".
835
*/
836
readonly promptTokenDetails?: readonly ChatResultPromptTokenDetail[];
837
}
838
839
export interface ChatResult {
840
nextQuestion?: {
841
prompt: string;
842
participant?: string;
843
command?: string;
844
};
845
/**
846
* An optional detail string that will be rendered at the end of the response in certain UI contexts.
847
*/
848
details?: string;
849
}
850
851
export namespace chat {
852
/**
853
* Create a chat participant with the extended progress type
854
*/
855
export function createChatParticipant(id: string, handler: ChatExtendedRequestHandler): ChatParticipant;
856
}
857
858
/*
859
* User action events
860
*/
861
862
export enum ChatCopyKind {
863
// Keyboard shortcut or context menu
864
Action = 1,
865
Toolbar = 2
866
}
867
868
export interface ChatCopyAction {
869
// eslint-disable-next-line local/vscode-dts-string-type-literals
870
kind: 'copy';
871
codeBlockIndex: number;
872
copyKind: ChatCopyKind;
873
copiedCharacters: number;
874
totalCharacters: number;
875
copiedText: string;
876
totalLines: number;
877
copiedLines: number;
878
modelId: string;
879
languageId?: string;
880
}
881
882
export interface ChatInsertAction {
883
// eslint-disable-next-line local/vscode-dts-string-type-literals
884
kind: 'insert';
885
codeBlockIndex: number;
886
totalCharacters: number;
887
totalLines: number;
888
languageId?: string;
889
modelId: string;
890
newFile?: boolean;
891
}
892
893
export interface ChatApplyAction {
894
// eslint-disable-next-line local/vscode-dts-string-type-literals
895
kind: 'apply';
896
codeBlockIndex: number;
897
totalCharacters: number;
898
totalLines: number;
899
languageId?: string;
900
modelId: string;
901
newFile?: boolean;
902
codeMapper?: string;
903
}
904
905
export interface ChatTerminalAction {
906
// eslint-disable-next-line local/vscode-dts-string-type-literals
907
kind: 'runInTerminal';
908
codeBlockIndex: number;
909
languageId?: string;
910
}
911
912
export interface ChatCommandAction {
913
// eslint-disable-next-line local/vscode-dts-string-type-literals
914
kind: 'command';
915
commandButton: ChatCommandButton;
916
}
917
918
export interface ChatFollowupAction {
919
// eslint-disable-next-line local/vscode-dts-string-type-literals
920
kind: 'followUp';
921
followup: ChatFollowup;
922
}
923
924
export interface ChatBugReportAction {
925
// eslint-disable-next-line local/vscode-dts-string-type-literals
926
kind: 'bug';
927
}
928
929
export interface ChatEditorAction {
930
// eslint-disable-next-line local/vscode-dts-string-type-literals
931
kind: 'editor';
932
accepted: boolean;
933
}
934
935
export interface ChatEditingSessionAction {
936
// eslint-disable-next-line local/vscode-dts-string-type-literals
937
kind: 'chatEditingSessionAction';
938
uri: Uri;
939
hasRemainingEdits: boolean;
940
outcome: ChatEditingSessionActionOutcome;
941
}
942
943
export interface ChatEditingHunkAction {
944
// eslint-disable-next-line local/vscode-dts-string-type-literals
945
kind: 'chatEditingHunkAction';
946
uri: Uri;
947
lineCount: number;
948
linesAdded: number;
949
linesRemoved: number;
950
outcome: ChatEditingSessionActionOutcome;
951
hasRemainingEdits: boolean;
952
}
953
954
export enum ChatEditingSessionActionOutcome {
955
Accepted = 1,
956
Rejected = 2,
957
Saved = 3
958
}
959
960
export interface ChatUserActionEvent {
961
readonly result: ChatResult;
962
readonly action: ChatCopyAction | ChatInsertAction | ChatApplyAction | ChatTerminalAction | ChatCommandAction | ChatFollowupAction | ChatBugReportAction | ChatEditorAction | ChatEditingSessionAction | ChatEditingHunkAction;
963
}
964
965
export interface ChatPromptReference {
966
/**
967
* TODO Needed for now to drive the variableName-type reference, but probably both of these should go away in the future.
968
*/
969
readonly name: string;
970
971
/**
972
* The list of tools were referenced in the value of the reference
973
*/
974
readonly toolReferences?: readonly ChatLanguageModelToolReference[];
975
}
976
977
export interface ChatResultFeedback {
978
readonly unhelpfulReason?: string;
979
}
980
981
export namespace lm {
982
export function fileIsIgnored(uri: Uri, token?: CancellationToken): Thenable<boolean>;
983
}
984
985
export interface ChatVariableValue {
986
/**
987
* The detail level of this chat variable value. If possible, variable resolvers should try to offer shorter values that will consume fewer tokens in an LLM prompt.
988
*/
989
level: ChatVariableLevel;
990
991
/**
992
* The variable's value, which can be included in an LLM prompt as-is, or the chat participant may decide to read the value and do something else with it.
993
*/
994
value: string | Uri;
995
996
/**
997
* A description of this value, which could be provided to the LLM as a hint.
998
*/
999
description?: string;
1000
}
1001
1002
/**
1003
* The detail level of this chat variable value.
1004
*/
1005
export enum ChatVariableLevel {
1006
Short = 1,
1007
Medium = 2,
1008
Full = 3
1009
}
1010
1011
export interface LanguageModelToolInvocationOptions<T> {
1012
model?: LanguageModelChat;
1013
chatStreamToolCallId?: string;
1014
}
1015
1016
export interface LanguageModelToolInvocationStreamOptions<T> {
1017
/**
1018
* Raw argument payload, such as the streamed JSON fragment from the language model.
1019
*/
1020
readonly rawInput?: unknown;
1021
1022
readonly chatRequestId?: string;
1023
/** @deprecated Use {@link chatSessionResource} instead */
1024
readonly chatSessionId?: string;
1025
readonly chatSessionResource?: Uri;
1026
readonly chatInteractionId?: string;
1027
}
1028
1029
export interface LanguageModelToolStreamResult {
1030
/**
1031
* A customized progress message to show while the tool runs.
1032
*/
1033
invocationMessage?: string | MarkdownString;
1034
}
1035
1036
export interface LanguageModelTool<T> {
1037
/**
1038
* Called zero or more times before {@link LanguageModelTool.prepareInvocation} while the
1039
* language model streams argument data for the invocation. Use this to update progress
1040
* or UI with the partial arguments that have been generated so far.
1041
*
1042
* Implementations must be free of side-effects and should be resilient to receiving
1043
* malformed or incomplete input.
1044
*/
1045
handleToolStream?(options: LanguageModelToolInvocationStreamOptions<T>, token: CancellationToken): ProviderResult<LanguageModelToolStreamResult>;
1046
}
1047
1048
export interface ChatRequest {
1049
readonly modeInstructions?: string;
1050
readonly modeInstructions2?: ChatRequestModeInstructions;
1051
}
1052
1053
export interface ChatRequestModeInstructions {
1054
readonly name: string;
1055
readonly content: string;
1056
readonly toolReferences?: readonly ChatLanguageModelToolReference[];
1057
readonly metadata?: Record<string, boolean | string | number>;
1058
}
1059
}
1060
1061