-
Notifications
You must be signed in to change notification settings - Fork 733
Expand file tree
/
Copy pathvscode.proposed.chatSessionsProvider.d.ts
More file actions
386 lines (332 loc) · 11 KB
/
vscode.proposed.chatSessionsProvider.d.ts
File metadata and controls
386 lines (332 loc) · 11 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
/*---------------------------------------------------------------------------------------------
* 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' {
/**
* Represents the status of a chat session.
*/
export enum ChatSessionStatus {
/**
* The chat session failed to complete.
*/
Failed = 0,
/**
* The chat session completed successfully.
*/
Completed = 1,
/**
* The chat session is currently in progress.
*/
InProgress = 2
}
/**
* Provides a list of information about chat sessions.
*/
export interface ChatSessionItemProvider {
/**
* Event that the provider can fire to signal that chat sessions have changed.
*/
readonly onDidChangeChatSessionItems: Event<void>;
/**
* Provides a list of chat sessions.
*/
// TODO: Do we need a flag to try auth if needed?
provideChatSessionItems(token: CancellationToken): ProviderResult<ChatSessionItem[]>;
// #region Unstable parts of API
/**
* Event that the provider can fire to signal that the current (original) chat session should be replaced with a new (modified) chat session.
* The UI can use this information to gracefully migrate the user to the new session.
*/
readonly onDidCommitChatSessionItem: Event<{ original: ChatSessionItem /** untitled */; modified: ChatSessionItem /** newly created */ }>;
/**
* DEPRECATED: Will be removed!
* Creates a new chat session.
*
* @param options Options for the new session including an optional initial prompt and history
* @param token A cancellation token
* @returns Metadata for the chat session
*/
provideNewChatSessionItem?(options: {
/**
* The chat request that initiated the session creation
*/
readonly request: ChatRequest;
/**
* Additional metadata to use for session creation
*/
metadata?: any;
}, token: CancellationToken): ProviderResult<ChatSessionItem>;
// #endregion
}
export interface ChatSessionItem {
/**
* The resource associated with the chat session.
*
* This is uniquely identifies the chat session and is used to open the chat session.
*/
resource: Uri;
/**
* Human readable name of the session shown in the UI
*/
label: string;
/**
* An icon for the participant shown in UI.
*/
iconPath?: IconPath;
/**
* An optional description that provides additional context about the chat session.
*/
description?: string | MarkdownString;
/**
* An optional badge that provides additional context about the chat session.
*/
badge?: string | MarkdownString;
/**
* An optional status indicating the current state of the session.
*/
status?: ChatSessionStatus;
/**
* The tooltip text when you hover over this item.
*/
tooltip?: string | MarkdownString;
/**
* The times at which session started and ended
*/
timing?: {
/**
* Session start timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
*/
startTime: number;
/**
* Session end timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
*/
endTime?: number;
};
/**
* Statistics about the chat session.
*/
changes?: readonly ChatSessionChangedFile[] | {
/**
* Number of files edited during the session.
*/
files: number;
/**
* Number of insertions made during the session.
*/
insertions: number;
/**
* Number of deletions made during the session.
*/
deletions: number;
};
}
export class ChatSessionChangedFile {
/**
* URI of the file.
*/
modifiedUri: Uri;
/**
* File opened when the user takes the 'compare' action.
*/
originalUri?: Uri;
/**
* Number of insertions made during the session.
*/
insertions: number;
/**
* Number of deletions made during the session.
*/
deletions: number;
constructor(modifiedUri: Uri, insertions: number, deletions: number, originalUri?: Uri);
}
export interface ChatSession {
/**
* The full history of the session
*
* This should not include any currently active responses
*/
// TODO: Are these the right types to use?
// TODO: link request + response to encourage correct usage?
readonly history: ReadonlyArray<ChatRequestTurn | ChatResponseTurn2>;
/**
* Options configured for this session as key-value pairs.
* Keys correspond to option group IDs (e.g., 'models', 'subagents').
* Values can be either:
* - A string (the option item ID) for backwards compatibility
* - A ChatSessionProviderOptionItem object to include metadata like locked state
* TODO: Strongly type the keys
*/
readonly options?: Record<string, string | ChatSessionProviderOptionItem>;
/**
* Callback invoked by the editor for a currently running response. This allows the session to push items for the
* current response and stream these in as them come in. The current response will be considered complete once the
* callback resolved.
*
* If not provided, the chat session is assumed to not currently be running.
*/
readonly activeResponseCallback?: (stream: ChatResponseStream, token: CancellationToken) => Thenable<void>;
/**
* Handles new request for the session.
*
* If not set, then the session will be considered read-only and no requests can be made.
*/
// TODO: Should we introduce our own type for `ChatRequestHandler` since not all field apply to chat sessions?
// TODO: Revisit this to align with code.
readonly requestHandler: ChatRequestHandler | undefined;
}
/**
* Event fired when chat session options change.
*/
export interface ChatSessionOptionChangeEvent {
/**
* Identifier of the chat session being updated.
*/
readonly resource: Uri;
/**
* Collection of option identifiers and their new values. Only the options that changed are included.
*/
readonly updates: ReadonlyArray<{
/**
* Identifier of the option that changed (for example `model`).
*/
readonly optionId: string;
/**
* The new value assigned to the option. When `undefined`, the option is cleared.
*/
readonly value: string | ChatSessionProviderOptionItem;
}>;
}
/**
* Provides the content for a chat session rendered using the native chat UI.
*/
export interface ChatSessionContentProvider {
/**
* Event that the provider can fire to signal that the options for a chat session have changed.
*/
readonly onDidChangeChatSessionOptions?: Event<ChatSessionOptionChangeEvent>;
/**
* Provides the chat session content for a given uri.
*
* The returned {@linkcode ChatSession} is used to populate the history of the chat UI.
*
* @param resource The URI of the chat session to resolve.
* @param token A cancellation token that can be used to cancel the operation.
*
* @return The {@link ChatSession chat session} associated with the given URI.
*/
provideChatSessionContent(resource: Uri, token: CancellationToken): Thenable<ChatSession> | ChatSession;
/**
* @param resource Identifier of the chat session being updated.
* @param updates Collection of option identifiers and their new values. Only the options that changed are included.
* @param token A cancellation token that can be used to cancel the notification if the session is disposed.
*/
provideHandleOptionsChange?(resource: Uri, updates: ReadonlyArray<ChatSessionOptionUpdate>, token: CancellationToken): void;
/**
* Called as soon as you register (call me once)
* @param token
*/
provideChatSessionProviderOptions?(token: CancellationToken): Thenable<ChatSessionProviderOptions> | ChatSessionProviderOptions;
}
export interface ChatSessionOptionUpdate {
/**
* Identifier of the option that changed (for example `model`).
*/
readonly optionId: string;
/**
* The new value assigned to the option. When `undefined`, the option is cleared.
*/
readonly value: string | undefined;
}
export namespace chat {
/**
* Registers a new {@link ChatSessionItemProvider chat session item provider}.
*
* To use this, also make sure to also add `chatSessions` contribution in the `package.json`.
*
* @param chatSessionType The type of chat session the provider is for.
* @param provider The provider to register.
*
* @returns A disposable that unregisters the provider when disposed.
*/
export function registerChatSessionItemProvider(chatSessionType: string, provider: ChatSessionItemProvider): Disposable;
/**
* Registers a new {@link ChatSessionContentProvider chat session content provider}.
*
* @param scheme The uri-scheme to register for. This must be unique.
* @param provider The provider to register.
*
* @returns A disposable that unregisters the provider when disposed.
*/
export function registerChatSessionContentProvider(scheme: string, provider: ChatSessionContentProvider, chatParticipant: ChatParticipant, capabilities?: ChatSessionCapabilities): Disposable;
}
export interface ChatContext {
readonly chatSessionContext?: ChatSessionContext;
}
export interface ChatSessionContext {
readonly chatSessionItem: ChatSessionItem; // Maps to URI of chat session editor (could be 'untitled-1', etc..)
readonly isUntitled: boolean;
}
export interface ChatSessionCapabilities {
/**
* Whether sessions can be interrupted and resumed without side-effects.
*/
supportsInterruptions?: boolean;
}
/**
* Represents a single selectable item within a provider option group.
*/
export interface ChatSessionProviderOptionItem {
/**
* Unique identifier for the option item.
*/
readonly id: string;
/**
* Human-readable name displayed in the UI.
*/
readonly name: string;
/**
* Optional description shown in tooltips.
*/
readonly description?: string;
/**
* When true, this option is locked and cannot be changed by the user.
* The option will still be visible in the UI but will be disabled.
* Use this when an option is set but cannot be hot-swapped (e.g., model already initialized).
*/
readonly locked?: boolean;
/**
* An icon for the option item shown in UI.
*/
readonly icon?: ThemeIcon;
}
/**
* Represents a group of related provider options (e.g., models, sub-agents).
*/
export interface ChatSessionProviderOptionGroup {
/**
* Unique identifier for the option group (e.g., "models", "subagents").
*/
readonly id: string;
/**
* Human-readable name for the option group.
*/
readonly name: string;
/**
* Optional description providing context about this option group.
*/
readonly description?: string;
/**
* The selectable items within this option group.
*/
readonly items: ChatSessionProviderOptionItem[];
}
export interface ChatSessionProviderOptions {
/**
* Provider-defined option groups (0-2 groups supported).
* Examples: models picker, sub-agents picker, etc.
*/
optionGroups?: ChatSessionProviderOptionGroup[];
}
}