Path: blob/main/src/vscode-dts/vscode.proposed.chatContextProvider.d.ts
4770 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*--------------------------------------------------------------------------------------------*/456declare module 'vscode' {78// https://github.com/microsoft/vscode/issues/271104 @alexr00910export namespace chat {1112/**13* Register a chat context provider. Chat context can be provided:14* - For a resource. Make sure to pass a selector that matches the resource you want to provide context for.15* Providers registered without a selector will not be called for resource-based context.16* - Explicitly. These context items are shown as options when the user explicitly attaches context.17*18* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.19*20* @param selector Optional document selector to filter which resources the provider is called for. If omitted, the provider will only be called for explicit context requests.21* @param id Unique identifier for the provider.22* @param provider The chat context provider.23*/24export function registerChatContextProvider(selector: DocumentSelector | undefined, id: string, provider: ChatContextProvider): Disposable;2526}2728export interface ChatContextItem {29/**30* Icon for the context item.31*/32icon: ThemeIcon;33/**34* Human readable label for the context item.35*/36label: string;37/**38* An optional description of the context item, e.g. to describe the item to the language model.39*/40modelDescription?: string;41/**42* The value of the context item. Can be omitted when returned from one of the `provide` methods if the provider supports `resolveChatContext`.43*/44value?: string;45}4647export interface ChatContextProvider<T extends ChatContextItem = ChatContextItem> {4849/**50* An optional event that should be fired when the workspace chat context has changed.51*/52onDidChangeWorkspaceChatContext?: Event<void>;5354/**55* Provide a list of chat context items to be included as workspace context for all chat sessions.56*57* @param token A cancellation token.58*/59provideWorkspaceChatContext?(token: CancellationToken): ProviderResult<T[]>;6061/**62* Provide a list of chat context items that a user can choose from. These context items are shown as options when the user explicitly attaches context.63* Chat context items can be provided without a `value`, as the `value` can be resolved later using `resolveChatContext`.64* `resolveChatContext` is only called for items that do not have a `value`.65*66* @param token A cancellation token.67*/68provideChatContextExplicit?(token: CancellationToken): ProviderResult<T[]>;6970/**71* Given a particular resource, provide a chat context item for it. This is used for implicit context (see the settings `chat.implicitContext.enabled` and `chat.implicitContext.suggestedContext`).72* Chat context items can be provided without a `value`, as the `value` can be resolved later using `resolveChatContext`.73* `resolveChatContext` is only called for items that do not have a `value`.74*75* Currently only called when the resource is a webview.76*77* @param options Options include the resource for which to provide context.78* @param token A cancellation token.79*/80provideChatContextForResource?(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;8182/**83* If a chat context item is provided without a `value`, from either of the `provide` methods, this method is called to resolve the `value` for the item.84*85* @param context The context item to resolve.86* @param token A cancellation token.87*/88resolveChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;89}9091}929394