Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vscode-dts/vscode.proposed.chatParticipantPrivate.d.ts
3290 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: 10
7
8
declare module 'vscode' {
9
10
/**
11
* The location at which the chat is happening.
12
*/
13
export enum ChatLocation {
14
/**
15
* The chat panel
16
*/
17
Panel = 1,
18
/**
19
* Terminal inline chat
20
*/
21
Terminal = 2,
22
/**
23
* Notebook inline chat
24
*/
25
Notebook = 3,
26
/**
27
* Code editor inline chat
28
*/
29
Editor = 4,
30
}
31
32
export class ChatRequestEditorData {
33
//TODO@API should be the editor
34
document: TextDocument;
35
selection: Selection;
36
wholeRange: Range;
37
38
constructor(document: TextDocument, selection: Selection, wholeRange: Range);
39
}
40
41
export class ChatRequestNotebookData {
42
//TODO@API should be the editor
43
readonly cell: TextDocument;
44
45
constructor(cell: TextDocument);
46
}
47
48
export interface ChatRequest {
49
/**
50
* The id of the chat request. Used to identity an interaction with any of the chat surfaces.
51
*/
52
readonly id: string;
53
/**
54
* The attempt number of the request. The first request has attempt number 0.
55
*/
56
readonly attempt: number;
57
58
/**
59
* If automatic command detection is enabled.
60
*/
61
readonly enableCommandDetection: boolean;
62
63
/**
64
* If the chat participant or command was automatically assigned.
65
*/
66
readonly isParticipantDetected: boolean;
67
68
/**
69
* The location at which the chat is happening. This will always be one of the supported values
70
*
71
* @deprecated
72
*/
73
readonly location: ChatLocation;
74
75
/**
76
* Information that is specific to the location at which chat is happening, e.g within a document, notebook,
77
* or terminal. Will be `undefined` for the chat panel.
78
*/
79
readonly location2: ChatRequestEditorData | ChatRequestNotebookData | undefined;
80
81
/**
82
* Events for edited files in this session collected since the last request.
83
*/
84
readonly editedFileEvents?: ChatRequestEditedFileEvent[];
85
}
86
87
export enum ChatRequestEditedFileEventKind {
88
Keep = 1,
89
Undo = 2,
90
UserModification = 3,
91
}
92
93
export interface ChatRequestEditedFileEvent {
94
readonly uri: Uri;
95
readonly eventKind: ChatRequestEditedFileEventKind;
96
}
97
98
/**
99
* ChatRequestTurn + private additions. Note- at runtime this is the SAME as ChatRequestTurn and instanceof is safe.
100
*/
101
export class ChatRequestTurn2 {
102
/**
103
* The prompt as entered by the user.
104
*
105
* Information about references used in this request is stored in {@link ChatRequestTurn.references}.
106
*
107
* *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}
108
* are not part of the prompt.
109
*/
110
readonly prompt: string;
111
112
/**
113
* The id of the chat participant to which this request was directed.
114
*/
115
readonly participant: string;
116
117
/**
118
* The name of the {@link ChatCommand command} that was selected for this request.
119
*/
120
readonly command?: string;
121
122
/**
123
* The references that were used in this message.
124
*/
125
readonly references: ChatPromptReference[];
126
127
/**
128
* The list of tools were attached to this request.
129
*/
130
readonly toolReferences: readonly ChatLanguageModelToolReference[];
131
132
/**
133
* Events for edited files in this session collected between the previous request and this one.
134
*/
135
readonly editedFileEvents?: ChatRequestEditedFileEvent[];
136
137
/**
138
* @hidden
139
*/
140
constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string, toolReferences: ChatLanguageModelToolReference[], editedFileEvents: ChatRequestEditedFileEvent[] | undefined);
141
}
142
143
export class ChatResponseTurn2 {
144
/**
145
* The content that was received from the chat participant. Only the stream parts that represent actual content (not metadata) are represented.
146
*/
147
readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart | ExtendedChatResponsePart | ChatToolInvocationPart>;
148
149
/**
150
* The result that was received from the chat participant.
151
*/
152
readonly result: ChatResult;
153
154
/**
155
* The id of the chat participant that this response came from.
156
*/
157
readonly participant: string;
158
159
/**
160
* The name of the command that this response came from.
161
*/
162
readonly command?: string;
163
164
constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart | ExtendedChatResponsePart>, result: ChatResult, participant: string);
165
}
166
167
export interface ChatParticipant {
168
supportIssueReporting?: boolean;
169
}
170
171
export enum ChatErrorLevel {
172
Info = 0,
173
Warning = 1,
174
Error = 2,
175
}
176
177
export interface ChatErrorDetails {
178
/**
179
* If set to true, the message content is completely hidden. Only ChatErrorDetails#message will be shown.
180
*/
181
responseIsRedacted?: boolean;
182
183
isQuotaExceeded?: boolean;
184
185
level?: ChatErrorLevel;
186
187
code?: string;
188
}
189
190
export namespace chat {
191
export function createDynamicChatParticipant(id: string, dynamicProps: DynamicChatParticipantProps, handler: ChatExtendedRequestHandler): ChatParticipant;
192
}
193
194
/**
195
* These don't get set on the ChatParticipant after creation, like other props, because they are typically defined in package.json and we want them at the time of creation.
196
*/
197
export interface DynamicChatParticipantProps {
198
name: string;
199
publisherName: string;
200
description?: string;
201
fullName?: string;
202
}
203
204
export namespace lm {
205
export function registerIgnoredFileProvider(provider: LanguageModelIgnoredFileProvider): Disposable;
206
}
207
208
export interface LanguageModelIgnoredFileProvider {
209
provideFileIgnored(uri: Uri, token: CancellationToken): ProviderResult<boolean>;
210
}
211
212
export interface LanguageModelToolInvocationOptions<T> {
213
chatRequestId?: string;
214
chatSessionId?: string;
215
chatInteractionId?: string;
216
terminalCommand?: string;
217
}
218
219
export interface LanguageModelToolInvocationPrepareOptions<T> {
220
/**
221
* The input that the tool is being invoked with.
222
*/
223
input: T;
224
chatRequestId?: string;
225
chatSessionId?: string;
226
chatInteractionId?: string;
227
}
228
229
export interface PreparedToolInvocation {
230
pastTenseMessage?: string | MarkdownString;
231
presentation?: 'hidden' | undefined;
232
}
233
234
export class ExtendedLanguageModelToolResult extends LanguageModelToolResult {
235
toolResultMessage?: string | MarkdownString;
236
toolResultDetails?: Array<Uri | Location>;
237
}
238
239
// #region Chat participant detection
240
241
export interface ChatParticipantMetadata {
242
participant: string;
243
command?: string;
244
disambiguation: { category: string; description: string; examples: string[] }[];
245
}
246
247
export interface ChatParticipantDetectionResult {
248
participant: string;
249
command?: string;
250
}
251
252
export interface ChatParticipantDetectionProvider {
253
provideParticipantDetection(chatRequest: ChatRequest, context: ChatContext, options: { participants?: ChatParticipantMetadata[]; location: ChatLocation }, token: CancellationToken): ProviderResult<ChatParticipantDetectionResult>;
254
}
255
256
export namespace chat {
257
export function registerChatParticipantDetectionProvider(participantDetectionProvider: ChatParticipantDetectionProvider): Disposable;
258
259
export const onDidDisposeChatSession: Event<string>;
260
}
261
262
// #endregion
263
264
// #region ChatErrorDetailsWithConfirmation
265
266
export interface ChatErrorDetails {
267
confirmationButtons?: ChatErrorDetailsConfirmationButton[];
268
}
269
270
export interface ChatErrorDetailsConfirmationButton {
271
data: any;
272
label: string;
273
}
274
275
// #endregion
276
}
277
278