Path: blob/main/src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts
3290 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45declare module 'vscode' {6/**7* Represents the status of a chat session.8*/9export enum ChatSessionStatus {10/**11* The chat session failed to complete.12*/13Failed = 0,1415/**16* The chat session completed successfully.17*/18Completed = 1,1920/**21* The chat session is currently in progress.22*/23InProgress = 224}2526/**27* Provides a list of information about chat sessions.28*/29export interface ChatSessionItemProvider {30/**31* Event that the provider can fire to signal that chat sessions have changed.32*/33readonly onDidChangeChatSessionItems: Event<void>;3435/**36* Creates a new chat session.37*38* @param options Options for the new session including an optional initial prompt and history39* @param token A cancellation token40* @returns Metadata for the chat session41*/42provideNewChatSessionItem?(options: {43/**44* The chat request that initiated the session creation45*/46readonly request: ChatRequest;4748/**49* Initial prompt to initiate the session50*/51readonly prompt?: string;5253/**54* History to initialize the session with55*/56readonly history?: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;5758/**59* Additional metadata to use for session creation60*/61metadata?: any;62}, token: CancellationToken): ProviderResult<ChatSessionItem>;6364/**65* Provides a list of chat sessions.66*/67// TODO: Do we need a flag to try auth if needed?68provideChatSessionItems(token: CancellationToken): ProviderResult<ChatSessionItem[]>;69}7071export interface ChatSessionItem {72/**73* Unique identifier for the chat session.74*/75id: string;7677/**78* Human readable name of the session shown in the UI79*/80label: string;8182/**83* An icon for the participant shown in UI.84*/85iconPath?: IconPath;8687/**88* An optional description that provides additional context about the chat session.89*/90description?: string | MarkdownString;9192/**93* An optional status indicating the current state of the session.94*/95status?: ChatSessionStatus;9697/**98* The tooltip text when you hover over this item.99*/100tooltip?: string | MarkdownString;101102/**103* The times at which session started and ended104*/105timing?: {106/**107* Session start timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.108*/109startTime: number;110/**111* Session end timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.112*/113endTime?: number;114};115116/**117* Statistics about the chat session.118*/119statistics?: {120/**121* Number of insertions made during the session.122*/123insertions: number;124125/**126* Number of deletions made during the session.127*/128deletions: number;129};130}131132export interface ChatSession {133/**134* The full history of the session135*136* This should not include any currently active responses137*/138// TODO: Are these the right types to use?139// TODO: link request + response to encourage correct usage?140readonly history: ReadonlyArray<ChatRequestTurn | ChatResponseTurn2>;141142/**143* Callback invoked by the editor for a currently running response. This allows the session to push items for the144* current response and stream these in as them come in. The current response will be considered complete once the145* callback resolved.146*147* If not provided, the chat session is assumed to not currently be running.148*/149readonly activeResponseCallback?: (stream: ChatResponseStream, token: CancellationToken) => Thenable<void>;150151/**152* Handles new request for the session.153*154* If not set, then the session will be considered read-only and no requests can be made.155*/156// TODO: Should we introduce our own type for `ChatRequestHandler` since not all field apply to chat sessions?157// TODO: Revisit this to align with code.158readonly requestHandler: ChatRequestHandler | undefined;159}160161export interface ChatSessionContentProvider {162/**163* Resolves a chat session into a full `ChatSession` object.164*165* @param sessionId The id of the chat session to open.166* @param token A cancellation token that can be used to cancel the operation.167*/168provideChatSessionContent(sessionId: string, token: CancellationToken): Thenable<ChatSession> | ChatSession;169}170171export namespace chat {172/**173* Registers a new {@link ChatSessionItemProvider chat session item provider}.174*175* To use this, also make sure to also add `chatSessions` contribution in the `package.json`.176*177* @param chatSessionType The type of chat session the provider is for.178* @param provider The provider to register.179*180* @returns A disposable that unregisters the provider when disposed.181*/182export function registerChatSessionItemProvider(chatSessionType: string, provider: ChatSessionItemProvider): Disposable;183184/**185* Registers a new {@link ChatSessionContentProvider chat session content provider}.186*187* @param chatSessionType A unique identifier for the chat session type. This is used to differentiate between different chat session providers.188* @param provider The provider to register.189*190* @returns A disposable that unregisters the provider when disposed.191*/192export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider, capabilities?: ChatSessionCapabilities): Disposable;193}194195export interface ChatSessionCapabilities {196/**197* Whether sessions can be interrupted and resumed without side-effects.198*/199supportsInterruptions?: boolean;200}201202export interface ChatSessionShowOptions {203/**204* The editor view column to show the chat session in.205*206* If not provided, the chat session will be shown in the chat panel instead.207*/208readonly viewColumn?: ViewColumn;209}210211export namespace window {212/**213* Shows a chat session in the panel or editor.214*/215export function showChatSession(chatSessionType: string, sessionId: string, options: ChatSessionShowOptions): Thenable<void>;216}217}218219220