@@ -11,15 +11,28 @@ declare module 'vscode' {
1111 /**
1212 * Label of the extension that registers the provider.
1313 */
14- readonly label : string ;
14+ readonly label : string ; // TODO: move to contribution or registration
1515
1616 /**
1717 * Event that the provider can fire to signal that chat sessions have changed.
1818 */
1919 readonly onDidChangeChatSessionItems : Event < void > ;
2020
21+ // /**
22+ // * Create a new chat session item
23+ // */
24+ // provideNewChatSessionItem(context: {
25+ // // This interface should be extracted
26+ // readonly triggerChat?: {
27+ // readonly prompt: string;
28+ // readonly history: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;
29+ // };
30+ // }, token: CancellationToken): Thenable<ChatSessionItem> | ChatSessionItem;
31+
2132 /**
2233 * Provides a list of chat sessions.
34+ *
35+ * TODO: Do we need a flag to try auth if needed?
2336 */
2437 provideChatSessionItems ( token : CancellationToken ) : ProviderResult < ChatSessionItem [ ] > ;
2538 }
@@ -41,7 +54,67 @@ declare module 'vscode' {
4154 iconPath ?: IconPath ;
4255 }
4356
57+ export interface ChatSession {
58+
59+ /**
60+ * The full history of the session
61+ *
62+ * This should not include any currently active responses
63+ *
64+ * TODO: Are these the right types to use?
65+ * TODO: link request + response to encourage correct usage?
66+ */
67+ readonly history : ReadonlyArray < ChatRequestTurn | ChatResponseTurn2 > ;
68+
69+ /**
70+ * Callback invoked by the editor for a currently running response. This allows the session to push items for the
71+ * current response and stream these in as them come in. The current response will be considered complete once the
72+ * callback resolved.
73+ *
74+ * If not provided, the chat session is assumed to not currently be running.
75+ */
76+ readonly activeResponseCallback ?: ( stream : ChatResponseStream , token : CancellationToken ) => Thenable < void > ;
77+
78+ /**
79+ * Handles new request for the session.
80+ *
81+ * If not set, then the session will be considered read-only and no requests can be made.
82+ *
83+ * TODO: Should we introduce our own type for `ChatRequestHandler` since not all field apply to chat sessions?
84+ */
85+ readonly requestHandler : ChatRequestHandler | undefined ;
86+ }
87+
88+ export interface ChatSessionContentProvider {
89+ /**
90+ * Resolves a chat session into a full `ChatSession` object.
91+ *
92+ * @param uri The URI of the chat session to open. Uris as structured as `vscode-chat-session:<chatSessionType>/id`
93+ * @param token A cancellation token that can be used to cancel the operation.
94+ */
95+ provideChatSessionContent ( id : string , token : CancellationToken ) : Thenable < ChatSession > ;
96+ }
97+
4498 export namespace chat {
4599 export function registerChatSessionItemProvider ( chatSessionType : string , provider : ChatSessionItemProvider ) : Disposable ;
100+
101+ /**
102+ * @param chatSessionType A unique identifier for the chat session type. This is used to differentiate between different chat session providers.
103+ */
104+ export function registerChatSessionContentProvider ( chatSessionType : string , provider : ChatSessionContentProvider ) : Disposable ;
105+ }
106+
107+ export interface ChatSessionShowOptions {
108+ /**
109+ * The editor view column to show the chat session in.
110+ *
111+ * If not provided, the chat session will be shown in the chat panel instead.
112+ */
113+ readonly viewColumn ?: ViewColumn ;
114+ }
115+
116+ export namespace window {
117+
118+ export function showChatSession ( chatSessionType : string , id : string , options : ChatSessionShowOptions ) : Thenable < void > ;
46119 }
47120}
0 commit comments