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