-
Notifications
You must be signed in to change notification settings - Fork 735
Expand file tree
/
Copy pathvscode.proposed.chatSessionsProvider.d.ts
More file actions
188 lines (163 loc) · 5.53 KB
/
vscode.proposed.chatSessionsProvider.d.ts
File metadata and controls
188 lines (163 loc) · 5.53 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
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>;
/**
* 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: {
/**
* Initial prompt to initiate the session
*/
readonly prompt?: string;
/**
* History to initialize the session with
*/
readonly history?: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;
/**
* Additional metadata to use for session creation
*/
metadata?: any;
}, token: CancellationToken): ProviderResult<ChatSessionItem>;
/**
* Provides a list of chat sessions.
*/
// TODO: Do we need a flag to try auth if needed?
provideChatSessionItems(token: CancellationToken): ProviderResult<ChatSessionItem[]>;
}
export interface ChatSessionItem {
/**
* Unique identifier for the chat session.
*/
id: string;
/**
* 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 status indicating the current state of the session.
*/
status?: ChatSessionStatus;
/**
* The tooltip text when you hover over this item.
*/
tooltip?: string | MarkdownString;
/**
* A badge to show additional information about the session.
*/
badge?: string;
/**
* The tooltip text when you hover over the badge.
*/
badgeTooltip?: string;
}
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>;
/**
* 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;
}
export interface ChatSessionContentProvider {
/**
* Resolves a chat session into a full `ChatSession` object.
*
* @param sessionId The id of the chat session to open.
* @param token A cancellation token that can be used to cancel the operation.
*/
provideChatSessionContent(sessionId: string, token: CancellationToken): Thenable<ChatSession> | ChatSession;
}
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 chatSessionType A unique identifier for the chat session type. This is used to differentiate between different chat session providers.
* @param provider The provider to register.
*
* @returns A disposable that unregisters the provider when disposed.
*/
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider): Disposable;
}
export interface ChatSessionShowOptions {
/**
* The editor view column to show the chat session in.
*
* If not provided, the chat session will be shown in the chat panel instead.
*/
readonly viewColumn?: ViewColumn;
}
export namespace window {
/**
* Shows a chat session in the panel or editor.
*/
export function showChatSession(chatSessionType: string, sessionId: string, options: ChatSessionShowOptions): Thenable<void>;
}
}