Skip to content

Commit cba4d93

Browse files
committed
Merge branch 'main' into copilot/add-copilot-suggestion-menu
2 parents 5ffdf7b + b99fbe9 commit cba4d93

File tree

4 files changed

+162
-10
lines changed

4 files changed

+162
-10
lines changed

src/@types/vscode.proposed.chatContextProvider.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ declare module 'vscode' {
8989
* Chat context items can be provided without a `value`, as the `value` can be resolved later using `resolveChatContext`.
9090
* `resolveChatContext` is only called for items that do not have a `value`.
9191
*
92-
* Currently only called when the resource is a webview.
92+
* Called when the resource is a webview or a text editor.
9393
*
9494
* @param options Options include the resource for which to provide context.
9595
* @param token A cancellation token.

src/@types/vscode.proposed.chatParticipantAdditions.d.ts

Lines changed: 121 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ declare module 'vscode' {
6565
constructor(uri: Uri, edits: NotebookEdit | NotebookEdit[]);
6666
}
6767

68+
/**
69+
* Represents a file-level edit (creation, deletion, or rename).
70+
*/
71+
export interface ChatWorkspaceFileEdit {
72+
/**
73+
* The original file URI (undefined for new files).
74+
*/
75+
oldResource?: Uri;
76+
77+
/**
78+
* The new file URI (undefined for deleted files).
79+
*/
80+
newResource?: Uri;
81+
}
82+
83+
/**
84+
* Represents a workspace edit containing file-level operations.
85+
*/
86+
export class ChatResponseWorkspaceEditPart {
87+
edits: ChatWorkspaceFileEdit[];
88+
constructor(edits: ChatWorkspaceFileEdit[]);
89+
}
90+
6891
export class ChatResponseConfirmationPart {
6992
title: string;
7093
message: string | MarkdownString;
@@ -95,6 +118,48 @@ declare module 'vscode' {
95118
toolEdited?: string;
96119
};
97120
language: string;
121+
122+
/**
123+
* Terminal command output. Displayed when the terminal is no longer available.
124+
*/
125+
output?: {
126+
/** The raw output text, may include ANSI escape codes. */
127+
text: string;
128+
};
129+
130+
/**
131+
* Command execution state.
132+
*/
133+
state?: {
134+
/** Exit code of the command. */
135+
exitCode?: number;
136+
/** Duration of execution in milliseconds. */
137+
duration?: number;
138+
};
139+
}
140+
141+
export class McpToolInvocationContentData {
142+
/**
143+
* The mime type which determines how the data property is interpreted.
144+
*/
145+
mimeType: string;
146+
147+
/**
148+
* The byte data for this part.
149+
*/
150+
data: Uint8Array;
151+
152+
/**
153+
* Construct a generic data part with the given content.
154+
* @param data The byte data for this part.
155+
* @param mimeType The mime type of the data.
156+
*/
157+
constructor(data: Uint8Array, mimeType: string);
158+
}
159+
160+
export interface ChatMcpToolInvocationData {
161+
input: string;
162+
output: McpToolInvocationContentData[];
98163
}
99164

100165
export class ChatToolInvocationPart {
@@ -107,7 +172,7 @@ declare module 'vscode' {
107172
isConfirmed?: boolean;
108173
isComplete?: boolean;
109174
toolSpecificData?: ChatTerminalToolInvocationData;
110-
subAgentInvocationId?: string;
175+
fromSubAgent?: boolean;
111176
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;
112177

113178
constructor(toolName: string, toolCallId: string, isError?: boolean);
@@ -179,7 +244,7 @@ declare module 'vscode' {
179244
constructor(uris: Uri[], callback: () => Thenable<unknown>);
180245
}
181246

182-
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
247+
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatPrepareToolInvocationPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
183248
export class ChatResponseWarningPart {
184249
value: MarkdownString;
185250
constructor(value: string | MarkdownString);
@@ -313,6 +378,12 @@ declare module 'vscode' {
313378

314379
notebookEdit(target: Uri, isDone: true): void;
315380

381+
/**
382+
* Push a workspace edit containing file-level operations (create, delete, rename).
383+
* @param edits Array of file-level edits to apply
384+
*/
385+
workspaceEdit(edits: ChatWorkspaceFileEdit[]): void;
386+
316387
/**
317388
* Makes an external edit to one or more resources. Changes to the
318389
* resources made within the `callback` and before it resolves will be
@@ -421,7 +492,7 @@ declare module 'vscode' {
421492
/**
422493
* A map of all tools that should (`true`) and should not (`false`) be used in this request.
423494
*/
424-
readonly tools: Map<string, boolean>;
495+
readonly tools: Map<LanguageModelToolInformation, boolean>;
425496
}
426497

427498
export namespace lm {
@@ -511,6 +582,47 @@ declare module 'vscode' {
511582

512583
export type ChatExtendedRequestHandler = (request: ChatRequest, context: ChatContext, response: ChatResponseStream, token: CancellationToken) => ProviderResult<ChatResult | void>;
513584

585+
/**
586+
* Details about the prompt token usage by category and label.
587+
*/
588+
export interface ChatResultPromptTokenDetail {
589+
/**
590+
* The category this token usage belongs to (e.g., "System", "Context", "Conversation").
591+
*/
592+
readonly category: string;
593+
594+
/**
595+
* The label for this specific token usage (e.g., "System prompt", "Attached files").
596+
*/
597+
readonly label: string;
598+
599+
/**
600+
* The percentage of the total prompt tokens this represents (0-100).
601+
*/
602+
readonly percentageOfPrompt: number;
603+
}
604+
605+
/**
606+
* Token usage information for a chat request.
607+
*/
608+
export interface ChatResultUsage {
609+
/**
610+
* The number of prompt tokens used in this request.
611+
*/
612+
readonly promptTokens: number;
613+
614+
/**
615+
* The number of completion tokens generated in this response.
616+
*/
617+
readonly completionTokens: number;
618+
619+
/**
620+
* Optional breakdown of prompt token usage by category and label.
621+
* If the percentages do not sum to 100%, the remaining will be shown as "Uncategorized".
622+
*/
623+
readonly promptTokenDetails?: readonly ChatResultPromptTokenDetail[];
624+
}
625+
514626
export interface ChatResult {
515627
nextQuestion?: {
516628
prompt: string;
@@ -521,6 +633,12 @@ declare module 'vscode' {
521633
* An optional detail string that will be rendered at the end of the response in certain UI contexts.
522634
*/
523635
details?: string;
636+
637+
/**
638+
* Token usage information for this request, if available.
639+
* This is typically provided by the underlying language model.
640+
*/
641+
readonly usage?: ChatResultUsage;
524642
}
525643

526644
export namespace chat {

src/@types/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ declare module 'vscode' {
100100
refreshHandler: () => Thenable<void>;
101101

102102
/**
103-
* Fired when an item is archived by the editor
104-
*
105-
* TODO: expose archive state on the item too?
103+
* Fired when an item's archived state changes.
106104
*/
107-
readonly onDidArchiveChatSessionItem: Event<ChatSessionItem>;
105+
readonly onDidChangeChatSessionItemState: Event<ChatSessionItem>;
108106
}
109107

110108
/**
@@ -233,7 +231,7 @@ declare module 'vscode' {
233231
/**
234232
* Statistics about the chat session.
235233
*/
236-
changes?: readonly ChatSessionChangedFile[] | {
234+
changes?: readonly ChatSessionChangedFile[] | readonly ChatSessionChangedFile2[] | {
237235
/**
238236
* Number of files edited during the session.
239237
*/
@@ -275,6 +273,35 @@ declare module 'vscode' {
275273
constructor(modifiedUri: Uri, insertions: number, deletions: number, originalUri?: Uri);
276274
}
277275

276+
export class ChatSessionChangedFile2 {
277+
/**
278+
* URI of the file.
279+
*/
280+
readonly uri: Uri;
281+
282+
/**
283+
* URI of the original file. Undefined if the file was created.
284+
*/
285+
readonly originalUri: Uri | undefined;
286+
287+
/**
288+
* URI of the modified file. Undefined if the file was deleted.
289+
*/
290+
readonly modifiedUri: Uri | undefined;
291+
292+
/**
293+
* Number of insertions made during the session.
294+
*/
295+
insertions: number;
296+
297+
/**
298+
* Number of deletions made during the session.
299+
*/
300+
deletions: number;
301+
302+
constructor(uri: Uri, originalUri: Uri | undefined, modifiedUri: Uri | undefined, insertions: number, deletions: number);
303+
}
304+
278305
export interface ChatSession {
279306
/**
280307
* The full history of the session
@@ -513,6 +540,13 @@ declare module 'vscode' {
513540
* @returns Additional items to display in the searchable QuickPick.
514541
*/
515542
readonly onSearch?: (query: string, token: CancellationToken) => Thenable<ChatSessionProviderOptionItem[]>;
543+
544+
/**
545+
* Optional commands.
546+
*
547+
* These commands will be displayed at the bottom of the group.
548+
*/
549+
readonly commands?: Command[];
516550
}
517551

518552
export interface ChatSessionProviderOptions {

src/lm/participants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class ChatParticipant extends Disposable {
8686

8787
const allTools: vscode.LanguageModelChatTool[] = [];
8888
for (const tool of vscode.lm.tools) {
89-
if (request.tools.has(tool.name) && request.tools.get(tool.name)) {
89+
if (request.tools.has(tool) && request.tools.get(tool)) {
9090
allTools.push(tool);
9191
} else if (tool.name.startsWith('github-pull-request')) {
9292
allTools.push(tool);

0 commit comments

Comments
 (0)