Path: blob/main/src/vscode-dts/vscode.proposed.chatParticipantPrivate.d.ts
5272 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*--------------------------------------------------------------------------------------------*/45// version: 1367declare module 'vscode' {89/**10* The location at which the chat is happening.11*/12export enum ChatLocation {13/**14* The chat panel15*/16Panel = 1,17/**18* Terminal inline chat19*/20Terminal = 2,21/**22* Notebook inline chat23*/24Notebook = 3,25/**26* Code editor inline chat27*/28Editor = 4,29}3031export class ChatRequestEditorData {3233readonly editor: TextEditor;3435//TODO@API should be the editor36document: TextDocument;37selection: Selection;3839/** @deprecated */40wholeRange: Range;4142constructor(editor: TextEditor, document: TextDocument, selection: Selection, wholeRange: Range);43}4445export class ChatRequestNotebookData {46//TODO@API should be the editor47readonly cell: TextDocument;4849constructor(cell: TextDocument);50}5152export interface ChatRequest {53/**54* The id of the chat request. Used to identity an interaction with any of the chat surfaces.55*/56readonly id: string;57/**58* The attempt number of the request. The first request has attempt number 0.59*/60readonly attempt: number;6162/**63* The session identifier for this chat request.64*65* @deprecated Use {@link chatSessionResource} instead.66*/67readonly sessionId: string;6869/**70* The resource URI for the chat session this request belongs to.71*/72readonly sessionResource: Uri;7374/**75* If automatic command detection is enabled.76*/77readonly enableCommandDetection: boolean;7879/**80* If the chat participant or command was automatically assigned.81*/82readonly isParticipantDetected: boolean;8384/**85* The location at which the chat is happening. This will always be one of the supported values86*87* @deprecated88*/89readonly location: ChatLocation;9091/**92* Information that is specific to the location at which chat is happening, e.g within a document, notebook,93* or terminal. Will be `undefined` for the chat panel.94*/95readonly location2: ChatRequestEditorData | ChatRequestNotebookData | undefined;9697/**98* Events for edited files in this session collected since the last request.99*/100readonly editedFileEvents?: ChatRequestEditedFileEvent[];101102/**103* Unique ID for the subagent invocation, used to group tool calls from the same subagent run together.104* Pass this to tool invocations when calling tools from within a subagent context.105*/106readonly subAgentInvocationId?: string;107108/**109* Display name of the subagent that is invoking this request.110*/111readonly subAgentName?: string;112113/**114* The request ID of the parent request that invoked this subagent.115*/116readonly parentRequestId?: string;117118/**119* Whether any hooks are enabled for this request.120*/121readonly hasHooksEnabled: boolean;122}123124export enum ChatRequestEditedFileEventKind {125Keep = 1,126Undo = 2,127UserModification = 3,128}129130export interface ChatRequestEditedFileEvent {131readonly uri: Uri;132readonly eventKind: ChatRequestEditedFileEventKind;133}134135/**136* ChatRequestTurn + private additions. Note- at runtime this is the SAME as ChatRequestTurn and instanceof is safe.137*/138export class ChatRequestTurn2 {139/**140* The id of the chat request. Used to identity an interaction with any of the chat surfaces.141*/142readonly id?: string;143/**144* The prompt as entered by the user.145*146* Information about references used in this request is stored in {@link ChatRequestTurn.references}.147*148* *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}149* are not part of the prompt.150*/151readonly prompt: string;152153/**154* The id of the chat participant to which this request was directed.155*/156readonly participant: string;157158/**159* The name of the {@link ChatCommand command} that was selected for this request.160*/161readonly command?: string;162163/**164* The references that were used in this message.165*/166readonly references: ChatPromptReference[];167168/**169* The list of tools were attached to this request.170*/171readonly toolReferences: readonly ChatLanguageModelToolReference[];172173/**174* Events for edited files in this session collected between the previous request and this one.175*/176readonly editedFileEvents?: ChatRequestEditedFileEvent[];177178/**179* @hidden180*/181constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string, toolReferences: ChatLanguageModelToolReference[], editedFileEvents: ChatRequestEditedFileEvent[] | undefined, id: string | undefined);182}183184export class ChatResponseTurn2 {185/**186* The id of the chat response. Used to identity an interaction with any of the chat surfaces.187*/188readonly id?: string;189190/**191* The content that was received from the chat participant. Only the stream parts that represent actual content (not metadata) are represented.192*/193readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart | ExtendedChatResponsePart | ChatToolInvocationPart>;194195/**196* The result that was received from the chat participant.197*/198readonly result: ChatResult;199200/**201* The id of the chat participant that this response came from.202*/203readonly participant: string;204205/**206* The name of the command that this response came from.207*/208readonly command?: string;209210constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart | ExtendedChatResponsePart>, result: ChatResult, participant: string);211}212213export interface ChatParticipant {214supportIssueReporting?: boolean;215}216217export enum ChatErrorLevel {218Info = 0,219Warning = 1,220Error = 2,221}222223export interface ChatErrorDetails {224/**225* If set to true, the message content is completely hidden. Only ChatErrorDetails#message will be shown.226*/227responseIsRedacted?: boolean;228229isQuotaExceeded?: boolean;230231isRateLimited?: boolean;232233level?: ChatErrorLevel;234235code?: string;236}237238export namespace chat {239export function createDynamicChatParticipant(id: string, dynamicProps: DynamicChatParticipantProps, handler: ChatExtendedRequestHandler): ChatParticipant;240}241242/**243* These don't get set on the ChatParticipant after creation, like other props, because they are typically defined in package.json and we want them at the time of creation.244*/245export interface DynamicChatParticipantProps {246name: string;247publisherName: string;248description?: string;249fullName?: string;250}251252export namespace lm {253export function registerIgnoredFileProvider(provider: LanguageModelIgnoredFileProvider): Disposable;254}255256export interface LanguageModelIgnoredFileProvider {257provideFileIgnored(uri: Uri, token: CancellationToken): ProviderResult<boolean>;258}259260export type PreToolUsePermissionDecision = 'allow' | 'deny' | 'ask';261262export interface LanguageModelToolInvocationOptions<T> {263chatRequestId?: string;264/** @deprecated Use {@link chatSessionResource} instead */265chatSessionId?: string;266chatSessionResource?: Uri;267chatInteractionId?: string;268terminalCommand?: string;269/**270* Unique ID for the subagent invocation, used to group tool calls from the same subagent run together.271*/272subAgentInvocationId?: string;273/**274* Pre-tool-use hook result, if the hook was already executed by the caller.275* When provided, the tools service will skip executing its own preToolUse hook276* and use this result for permission decisions and input modifications instead.277*/278preToolUseResult?: {279permissionDecision?: PreToolUsePermissionDecision;280permissionDecisionReason?: string;281updatedInput?: object;282};283}284285export interface LanguageModelToolInvocationPrepareOptions<T> {286/**287* The input that the tool is being invoked with.288*/289input: T;290chatRequestId?: string;291/** @deprecated Use {@link chatSessionResource} instead */292chatSessionId?: string;293chatSessionResource?: Uri;294chatInteractionId?: string;295/**296* If set, tells the tool that it should include confirmation messages.297*/298forceConfirmationReason?: string;299}300301export interface PreparedToolInvocation {302pastTenseMessage?: string | MarkdownString;303presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;304}305306export class ExtendedLanguageModelToolResult extends LanguageModelToolResult {307toolResultMessage?: string | MarkdownString;308toolResultDetails?: Array<Uri | Location>;309toolMetadata?: unknown;310/** Whether there was an error calling the tool. The tool may still have partially succeeded. */311hasError?: boolean;312}313314// #region Chat participant detection315316export interface ChatParticipantMetadata {317participant: string;318command?: string;319disambiguation: { category: string; description: string; examples: string[] }[];320}321322export interface ChatParticipantDetectionResult {323participant: string;324command?: string;325}326327export interface ChatParticipantDetectionProvider {328provideParticipantDetection(chatRequest: ChatRequest, context: ChatContext, options: { participants?: ChatParticipantMetadata[]; location: ChatLocation }, token: CancellationToken): ProviderResult<ChatParticipantDetectionResult>;329}330331export namespace chat {332export function registerChatParticipantDetectionProvider(participantDetectionProvider: ChatParticipantDetectionProvider): Disposable;333334export const onDidDisposeChatSession: Event<string>;335}336337// #endregion338339// #region ChatErrorDetailsWithConfirmation340341export interface ChatErrorDetails {342confirmationButtons?: ChatErrorDetailsConfirmationButton[];343}344345export interface ChatErrorDetailsConfirmationButton {346data: any;347label: string;348}349350// #endregion351352// #region LanguageModelProxyProvider353354/**355* Duplicated so that this proposal and languageModelProxy can be independent.356*/357export interface LanguageModelProxy extends Disposable {358readonly uri: Uri;359readonly key: string;360}361362export interface LanguageModelProxyProvider {363provideModelProxy(forExtensionId: string, token: CancellationToken): ProviderResult<LanguageModelProxy>;364}365366export namespace lm {367export function registerLanguageModelProxyProvider(provider: LanguageModelProxyProvider): Disposable;368}369370// #endregion371372// #region Steering373374export interface ChatContext {375/**376* Set to `true` by the editor to request the language model gracefully377* stop after its next opportunity. When set, it's likely that the editor378* will immediately follow up with a new request in the same conversation.379*/380readonly yieldRequested: boolean;381}382383// #endregion384}385386387