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
5272 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: 13
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
34
readonly editor: TextEditor;
35
36
//TODO@API should be the editor
37
document: TextDocument;
38
selection: Selection;
39
40
/** @deprecated */
41
wholeRange: Range;
42
43
constructor(editor: TextEditor, document: TextDocument, selection: Selection, wholeRange: Range);
44
}
45
46
export class ChatRequestNotebookData {
47
//TODO@API should be the editor
48
readonly cell: TextDocument;
49
50
constructor(cell: TextDocument);
51
}
52
53
export interface ChatRequest {
54
/**
55
* The id of the chat request. Used to identity an interaction with any of the chat surfaces.
56
*/
57
readonly id: string;
58
/**
59
* The attempt number of the request. The first request has attempt number 0.
60
*/
61
readonly attempt: number;
62
63
/**
64
* The session identifier for this chat request.
65
*
66
* @deprecated Use {@link chatSessionResource} instead.
67
*/
68
readonly sessionId: string;
69
70
/**
71
* The resource URI for the chat session this request belongs to.
72
*/
73
readonly sessionResource: Uri;
74
75
/**
76
* If automatic command detection is enabled.
77
*/
78
readonly enableCommandDetection: boolean;
79
80
/**
81
* If the chat participant or command was automatically assigned.
82
*/
83
readonly isParticipantDetected: boolean;
84
85
/**
86
* The location at which the chat is happening. This will always be one of the supported values
87
*
88
* @deprecated
89
*/
90
readonly location: ChatLocation;
91
92
/**
93
* Information that is specific to the location at which chat is happening, e.g within a document, notebook,
94
* or terminal. Will be `undefined` for the chat panel.
95
*/
96
readonly location2: ChatRequestEditorData | ChatRequestNotebookData | undefined;
97
98
/**
99
* Events for edited files in this session collected since the last request.
100
*/
101
readonly editedFileEvents?: ChatRequestEditedFileEvent[];
102
103
/**
104
* Unique ID for the subagent invocation, used to group tool calls from the same subagent run together.
105
* Pass this to tool invocations when calling tools from within a subagent context.
106
*/
107
readonly subAgentInvocationId?: string;
108
109
/**
110
* Display name of the subagent that is invoking this request.
111
*/
112
readonly subAgentName?: string;
113
114
/**
115
* The request ID of the parent request that invoked this subagent.
116
*/
117
readonly parentRequestId?: string;
118
119
/**
120
* Whether any hooks are enabled for this request.
121
*/
122
readonly hasHooksEnabled: boolean;
123
}
124
125
export enum ChatRequestEditedFileEventKind {
126
Keep = 1,
127
Undo = 2,
128
UserModification = 3,
129
}
130
131
export interface ChatRequestEditedFileEvent {
132
readonly uri: Uri;
133
readonly eventKind: ChatRequestEditedFileEventKind;
134
}
135
136
/**
137
* ChatRequestTurn + private additions. Note- at runtime this is the SAME as ChatRequestTurn and instanceof is safe.
138
*/
139
export class ChatRequestTurn2 {
140
/**
141
* The id of the chat request. Used to identity an interaction with any of the chat surfaces.
142
*/
143
readonly id?: string;
144
/**
145
* The prompt as entered by the user.
146
*
147
* Information about references used in this request is stored in {@link ChatRequestTurn.references}.
148
*
149
* *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}
150
* are not part of the prompt.
151
*/
152
readonly prompt: string;
153
154
/**
155
* The id of the chat participant to which this request was directed.
156
*/
157
readonly participant: string;
158
159
/**
160
* The name of the {@link ChatCommand command} that was selected for this request.
161
*/
162
readonly command?: string;
163
164
/**
165
* The references that were used in this message.
166
*/
167
readonly references: ChatPromptReference[];
168
169
/**
170
* The list of tools were attached to this request.
171
*/
172
readonly toolReferences: readonly ChatLanguageModelToolReference[];
173
174
/**
175
* Events for edited files in this session collected between the previous request and this one.
176
*/
177
readonly editedFileEvents?: ChatRequestEditedFileEvent[];
178
179
/**
180
* @hidden
181
*/
182
constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string, toolReferences: ChatLanguageModelToolReference[], editedFileEvents: ChatRequestEditedFileEvent[] | undefined, id: string | undefined);
183
}
184
185
export class ChatResponseTurn2 {
186
/**
187
* The id of the chat response. Used to identity an interaction with any of the chat surfaces.
188
*/
189
readonly id?: string;
190
191
/**
192
* The content that was received from the chat participant. Only the stream parts that represent actual content (not metadata) are represented.
193
*/
194
readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart | ExtendedChatResponsePart | ChatToolInvocationPart>;
195
196
/**
197
* The result that was received from the chat participant.
198
*/
199
readonly result: ChatResult;
200
201
/**
202
* The id of the chat participant that this response came from.
203
*/
204
readonly participant: string;
205
206
/**
207
* The name of the command that this response came from.
208
*/
209
readonly command?: string;
210
211
constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart | ExtendedChatResponsePart>, result: ChatResult, participant: string);
212
}
213
214
export interface ChatParticipant {
215
supportIssueReporting?: boolean;
216
}
217
218
export enum ChatErrorLevel {
219
Info = 0,
220
Warning = 1,
221
Error = 2,
222
}
223
224
export interface ChatErrorDetails {
225
/**
226
* If set to true, the message content is completely hidden. Only ChatErrorDetails#message will be shown.
227
*/
228
responseIsRedacted?: boolean;
229
230
isQuotaExceeded?: boolean;
231
232
isRateLimited?: boolean;
233
234
level?: ChatErrorLevel;
235
236
code?: string;
237
}
238
239
export namespace chat {
240
export function createDynamicChatParticipant(id: string, dynamicProps: DynamicChatParticipantProps, handler: ChatExtendedRequestHandler): ChatParticipant;
241
}
242
243
/**
244
* 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.
245
*/
246
export interface DynamicChatParticipantProps {
247
name: string;
248
publisherName: string;
249
description?: string;
250
fullName?: string;
251
}
252
253
export namespace lm {
254
export function registerIgnoredFileProvider(provider: LanguageModelIgnoredFileProvider): Disposable;
255
}
256
257
export interface LanguageModelIgnoredFileProvider {
258
provideFileIgnored(uri: Uri, token: CancellationToken): ProviderResult<boolean>;
259
}
260
261
export type PreToolUsePermissionDecision = 'allow' | 'deny' | 'ask';
262
263
export interface LanguageModelToolInvocationOptions<T> {
264
chatRequestId?: string;
265
/** @deprecated Use {@link chatSessionResource} instead */
266
chatSessionId?: string;
267
chatSessionResource?: Uri;
268
chatInteractionId?: string;
269
terminalCommand?: string;
270
/**
271
* Unique ID for the subagent invocation, used to group tool calls from the same subagent run together.
272
*/
273
subAgentInvocationId?: string;
274
/**
275
* Pre-tool-use hook result, if the hook was already executed by the caller.
276
* When provided, the tools service will skip executing its own preToolUse hook
277
* and use this result for permission decisions and input modifications instead.
278
*/
279
preToolUseResult?: {
280
permissionDecision?: PreToolUsePermissionDecision;
281
permissionDecisionReason?: string;
282
updatedInput?: object;
283
};
284
}
285
286
export interface LanguageModelToolInvocationPrepareOptions<T> {
287
/**
288
* The input that the tool is being invoked with.
289
*/
290
input: T;
291
chatRequestId?: string;
292
/** @deprecated Use {@link chatSessionResource} instead */
293
chatSessionId?: string;
294
chatSessionResource?: Uri;
295
chatInteractionId?: string;
296
/**
297
* If set, tells the tool that it should include confirmation messages.
298
*/
299
forceConfirmationReason?: string;
300
}
301
302
export interface PreparedToolInvocation {
303
pastTenseMessage?: string | MarkdownString;
304
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;
305
}
306
307
export class ExtendedLanguageModelToolResult extends LanguageModelToolResult {
308
toolResultMessage?: string | MarkdownString;
309
toolResultDetails?: Array<Uri | Location>;
310
toolMetadata?: unknown;
311
/** Whether there was an error calling the tool. The tool may still have partially succeeded. */
312
hasError?: boolean;
313
}
314
315
// #region Chat participant detection
316
317
export interface ChatParticipantMetadata {
318
participant: string;
319
command?: string;
320
disambiguation: { category: string; description: string; examples: string[] }[];
321
}
322
323
export interface ChatParticipantDetectionResult {
324
participant: string;
325
command?: string;
326
}
327
328
export interface ChatParticipantDetectionProvider {
329
provideParticipantDetection(chatRequest: ChatRequest, context: ChatContext, options: { participants?: ChatParticipantMetadata[]; location: ChatLocation }, token: CancellationToken): ProviderResult<ChatParticipantDetectionResult>;
330
}
331
332
export namespace chat {
333
export function registerChatParticipantDetectionProvider(participantDetectionProvider: ChatParticipantDetectionProvider): Disposable;
334
335
export const onDidDisposeChatSession: Event<string>;
336
}
337
338
// #endregion
339
340
// #region ChatErrorDetailsWithConfirmation
341
342
export interface ChatErrorDetails {
343
confirmationButtons?: ChatErrorDetailsConfirmationButton[];
344
}
345
346
export interface ChatErrorDetailsConfirmationButton {
347
data: any;
348
label: string;
349
}
350
351
// #endregion
352
353
// #region LanguageModelProxyProvider
354
355
/**
356
* Duplicated so that this proposal and languageModelProxy can be independent.
357
*/
358
export interface LanguageModelProxy extends Disposable {
359
readonly uri: Uri;
360
readonly key: string;
361
}
362
363
export interface LanguageModelProxyProvider {
364
provideModelProxy(forExtensionId: string, token: CancellationToken): ProviderResult<LanguageModelProxy>;
365
}
366
367
export namespace lm {
368
export function registerLanguageModelProxyProvider(provider: LanguageModelProxyProvider): Disposable;
369
}
370
371
// #endregion
372
373
// #region Steering
374
375
export interface ChatContext {
376
/**
377
* Set to `true` by the editor to request the language model gracefully
378
* stop after its next opportunity. When set, it's likely that the editor
379
* will immediately follow up with a new request in the same conversation.
380
*/
381
readonly yieldRequested: boolean;
382
}
383
384
// #endregion
385
}
386
387