@codingame/monaco-vscode-chat-service-override 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +86 -91
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +5 -6
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +205 -115
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +61 -21
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +3 -4
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +2 -3
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +3 -4
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +4 -5
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +10 -11
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +10 -8
  12. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +24 -25
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +1 -1
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +5 -3
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +29 -108
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +76 -67
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +9 -8
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +1 -1
  19. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +9 -5
  20. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +17 -12
  21. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +28 -7
  22. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +2 -3
  23. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +17 -55
  24. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +54 -0
  25. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +4 -4
  26. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +3 -4
  27. package/vscode/src/vs/workbench/contrib/chat/common/languageModelToolsService.js +1 -1
  28. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +60 -25
  29. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +6 -7
  30. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +6 -5
  31. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +24 -0
  32. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +9 -12
  33. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +4 -10
  34. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +0 -17
@@ -4,7 +4,7 @@ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
4
4
  import { getWordAtText } from 'vscode/vscode/vs/editor/common/core/wordHelper';
5
5
  import { CompletionItemKind } from 'vscode/vscode/vs/editor/common/languages';
6
6
  import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
7
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
7
+ import { localize } from 'vscode/vscode/vs/nls';
8
8
  import { Action2, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
9
9
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
10
10
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
@@ -13,7 +13,7 @@ import { SubmitAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/ac
13
13
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
14
14
  import { ChatInputPart } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatInputPart';
15
15
  import { SelectAndInsertFileAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
16
- import { ChatAgentLocation, getFullyQualifiedId } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
16
+ import { getFullyQualifiedId, ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
17
17
  import { IChatAgentService, IChatAgentNameService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
18
18
  import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestTextPart, chatSubcommandLeader, chatAgentLeader, chatVariableLeader, ChatRequestVariablePart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
19
19
  import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
@@ -21,7 +21,6 @@ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/c
21
21
  import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
22
22
 
23
23
  var BuiltinDynamicCompletions_1, VariableCompletions_1;
24
- const _moduleId = "vs/workbench/contrib/chat/browser/contrib/chatInputCompletions";
25
24
  let SlashCommandCompletions = class SlashCommandCompletions extends Disposable {
26
25
  constructor(languageFeaturesService, chatWidgetService, chatSlashCommandService) {
27
26
  super();
@@ -33,7 +32,7 @@ let SlashCommandCompletions = class SlashCommandCompletions extends Disposable {
33
32
  triggerCharacters: ['/'],
34
33
  provideCompletionItems: async (model, position, _context, _token) => {
35
34
  const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
36
- if (!widget || !widget.viewModel || (widget.location !== ChatAgentLocation.Panel && widget.location !== ChatAgentLocation.Notebook) ) {
35
+ if (!widget || !widget.viewModel) {
37
36
  return null;
38
37
  }
39
38
  const range = computeCompletionRanges(model, position, /\/\w*/g);
@@ -45,7 +44,7 @@ let SlashCommandCompletions = class SlashCommandCompletions extends Disposable {
45
44
  if (usedAgent) {
46
45
  return;
47
46
  }
48
- const slashCommands = this.chatSlashCommandService.getCommands();
47
+ const slashCommands = this.chatSlashCommandService.getCommands(widget.location);
49
48
  if (!slashCommands) {
50
49
  return null;
51
50
  }
@@ -85,7 +84,7 @@ let AgentCompletions = class AgentCompletions extends Disposable {
85
84
  triggerCharacters: ['@'],
86
85
  provideCompletionItems: async (model, position, _context, _token) => {
87
86
  const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
88
- if (!widget || !widget.viewModel || (widget.location !== ChatAgentLocation.Panel && widget.location !== ChatAgentLocation.Notebook) ) {
87
+ if (!widget || !widget.viewModel) {
89
88
  return null;
90
89
  }
91
90
  const parsedRequest = widget.parsedInput.parts;
@@ -122,7 +121,7 @@ let AgentCompletions = class AgentCompletions extends Disposable {
122
121
  triggerCharacters: ['/'],
123
122
  provideCompletionItems: async (model, position, _context, token) => {
124
123
  const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
125
- if (!widget || !widget.viewModel || widget.location !== ChatAgentLocation.Panel ) {
124
+ if (!widget || !widget.viewModel) {
126
125
  return;
127
126
  }
128
127
  const range = computeCompletionRanges(model, position, /\/\w*/g);
@@ -164,7 +163,7 @@ let AgentCompletions = class AgentCompletions extends Disposable {
164
163
  provideCompletionItems: async (model, position, _context, token) => {
165
164
  const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
166
165
  const viewModel = widget?.viewModel;
167
- if (!widget || !viewModel || widget.location !== ChatAgentLocation.Panel ) {
166
+ if (!widget || !viewModel) {
168
167
  return;
169
168
  }
170
169
  const range = computeCompletionRanges(model, position, /\/\w*/g);
@@ -199,7 +198,7 @@ let AgentCompletions = class AgentCompletions extends Disposable {
199
198
  suggestions: justAgents.concat(agents.flatMap(agent => ( (agent.slashCommands.map((c, i) => {
200
199
  const { label: agentLabel, isDupe } = this.getAgentCompletionDetails(agent);
201
200
  const withSlash = `${chatSubcommandLeader}${c.name}`;
202
- return {
201
+ const item = {
203
202
  label: { label: withSlash, description: agentLabel, detail: isDupe ? ` (${agent.publisherDisplayName})` : undefined },
204
203
  filterText: getFilterText(agent, c.name),
205
204
  commitCharacters: [' '],
@@ -210,6 +209,12 @@ let AgentCompletions = class AgentCompletions extends Disposable {
210
209
  sortText: `${chatSubcommandLeader}${agent.name}${c.name}`,
211
210
  command: { id: AssignSelectedAgentAction.ID, title: AssignSelectedAgentAction.ID, arguments: [{ agent, widget }] },
212
211
  };
212
+ if (agent.isDefault) {
213
+ item.label = withSlash;
214
+ item.insertText = `${withSlash} `;
215
+ item.detail = c.description;
216
+ }
217
+ return item;
213
218
  })))))
214
219
  };
215
220
  }
@@ -258,7 +263,7 @@ let BuiltinDynamicCompletions = class BuiltinDynamicCompletions extends Disposab
258
263
  triggerCharacters: [chatVariableLeader],
259
264
  provideCompletionItems: async (model, position, _context, _token) => {
260
265
  const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
261
- if (!widget || !widget.supportsFileReferences || widget.location !== ChatAgentLocation.Panel ) {
266
+ if (!widget || !widget.supportsFileReferences) {
262
267
  return null;
263
268
  }
264
269
  const range = computeCompletionRanges(model, position, BuiltinDynamicCompletions_1.VariableNameDef);
@@ -276,7 +281,7 @@ let BuiltinDynamicCompletions = class BuiltinDynamicCompletions extends Disposab
276
281
  {
277
282
  label: `${chatVariableLeader}file`,
278
283
  insertText: `${chatVariableLeader}file:`,
279
- detail: ( localizeWithPath(_moduleId, 0, "Pick a file")),
284
+ detail: ( localize(7287, "Pick a file")),
280
285
  range,
281
286
  kind: CompletionItemKind.Text,
282
287
  command: { id: SelectAndInsertFileAction.ID, title: SelectAndInsertFileAction.ID, arguments: [{ widget, range: afterRange }] },
@@ -349,7 +354,7 @@ let VariableCompletions = class VariableCompletions extends Disposable {
349
354
  const usedAgent = widget.parsedInput.parts.find(p => p instanceof ChatRequestAgentPart);
350
355
  const slowSupported = usedAgent ? usedAgent.agent.metadata.supportsSlowVariables : true;
351
356
  const usedVariables = widget.parsedInput.parts.filter((p) => p instanceof ChatRequestVariablePart);
352
- const variableItems = ( (Array.from(this.chatVariablesService.getVariables())
357
+ const variableItems = ( (Array.from(this.chatVariablesService.getVariables(widget.location))
353
358
  .filter(v => !( (usedVariables.some(usedVar => usedVar.variableName === v.name))))
354
359
  .filter(v => !v.isSlow || slowSupported)
355
360
  .map((v) => {
@@ -18,7 +18,6 @@ import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
18
18
  import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
19
19
  import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
20
20
  import { dynamicVariableDecorationType } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
21
- import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
22
21
  import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
23
22
  import { chatSlashCommandForeground, chatSlashCommandBackground } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatColors';
24
23
  import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashCommandPart, ChatRequestTextPart, ChatRequestVariablePart, chatAgentLeader, chatSubcommandLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
@@ -154,8 +153,8 @@ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
154
153
  }];
155
154
  }
156
155
  }
157
- const onlyAgentCommandAndWhitespace = agentPart && agentSubcommandPart && parsedRequest.every(p => p instanceof ChatRequestTextPart && !p.text.trim().length || p instanceof ChatRequestAgentPart || p instanceof ChatRequestAgentSubcommandPart);
158
- if (onlyAgentCommandAndWhitespace) {
156
+ const onlyAgentAndAgentCommandAndWhitespace = agentPart && agentSubcommandPart && parsedRequest.every(p => p instanceof ChatRequestTextPart && !p.text.trim().length || p instanceof ChatRequestAgentPart || p instanceof ChatRequestAgentSubcommandPart);
157
+ if (onlyAgentAndAgentCommandAndWhitespace) {
159
158
  const isFollowupSlashCommand = ( this.previouslyUsedAgents.has(agentAndCommandToKey(agentPart.agent, agentSubcommandPart.command.name)));
160
159
  const shouldRenderFollowupPlaceholder = isFollowupSlashCommand && agentSubcommandPart.command.followupPlaceholder;
161
160
  if (agentSubcommandPart?.command.description && exactlyOneSpaceAfterPart(agentSubcommandPart)) {
@@ -170,13 +169,27 @@ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
170
169
  }];
171
170
  }
172
171
  }
172
+ const onlyAgentCommandAndWhitespace = agentSubcommandPart && parsedRequest.every(p => p instanceof ChatRequestTextPart && !p.text.trim().length || p instanceof ChatRequestAgentSubcommandPart);
173
+ if (onlyAgentCommandAndWhitespace) {
174
+ if (agentSubcommandPart?.command.description && exactlyOneSpaceAfterPart(agentSubcommandPart)) {
175
+ placeholderDecoration = [{
176
+ range: getRangeForPlaceholder(agentSubcommandPart),
177
+ renderOptions: {
178
+ after: {
179
+ contentText: agentSubcommandPart.command.description,
180
+ color: this.getPlaceholderColor(),
181
+ }
182
+ }
183
+ }];
184
+ }
185
+ }
173
186
  this.widget.inputEditor.setDecorationsByType(decorationDescription, placeholderDecorationType, placeholderDecoration ?? []);
174
187
  const textDecorations = [];
175
188
  if (agentPart) {
176
189
  textDecorations.push({ range: agentPart.editorRange });
177
- if (agentSubcommandPart) {
178
- textDecorations.push({ range: agentSubcommandPart.editorRange, hoverMessage: ( new MarkdownString(agentSubcommandPart.command.description)) });
179
- }
190
+ }
191
+ if (agentSubcommandPart) {
192
+ textDecorations.push({ range: agentSubcommandPart.editorRange, hoverMessage: ( new MarkdownString(agentSubcommandPart.command.description)) });
180
193
  }
181
194
  if (slashCommandPart) {
182
195
  textDecorations.push({ range: slashCommandPart.editorRange });
@@ -200,11 +213,19 @@ class InputEditorSlashCommandMode extends Disposable {
200
213
  super();
201
214
  this.widget = widget;
202
215
  this.id = 'InputEditorSlashCommandMode';
216
+ this._register(this.widget.onDidChangeAgent(e => {
217
+ if (e.slashCommand && e.slashCommand.isSticky || !e.slashCommand && e.agent.metadata.isSticky) {
218
+ this.repopulateAgentCommand(e.agent, e.slashCommand);
219
+ }
220
+ }));
203
221
  this._register(this.widget.onDidSubmitAgent(e => {
204
222
  this.repopulateAgentCommand(e.agent, e.slashCommand);
205
223
  }));
206
224
  }
207
225
  async repopulateAgentCommand(agent, slashCommand) {
226
+ if (this.widget.inputEditor.getValue().trim()) {
227
+ return;
228
+ }
208
229
  let value;
209
230
  if (slashCommand && slashCommand.isSticky) {
210
231
  value = `${chatAgentLeader}${agent.name} ${chatSubcommandLeader}${slashCommand.name} `;
@@ -236,7 +257,7 @@ let ChatTokenDeleter = class ChatTokenDeleter extends Disposable {
236
257
  }
237
258
  const change = e.changes[0];
238
259
  if (!change.text && this.widget.viewModel) {
239
- const previousParsedValue = parser.parseChatRequest(this.widget.viewModel.sessionId, previousInputValue, ChatAgentLocation.Panel, { selectedAgent: previousSelectedAgent });
260
+ const previousParsedValue = parser.parseChatRequest(this.widget.viewModel.sessionId, previousInputValue, widget.location, { selectedAgent: previousSelectedAgent });
240
261
  const deletableTokens = previousParsedValue.parts.filter(p => p instanceof ChatRequestAgentPart || p instanceof ChatRequestAgentSubcommandPart || p instanceof ChatRequestSlashCommandPart || p instanceof ChatRequestVariablePart);
241
262
  deletableTokens.forEach(token => {
242
263
  const deletedRangeOfToken = Range.intersectRanges(token.editorRange, change.range);
@@ -8,9 +8,8 @@ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/brow
8
8
  import { ChatAgentHover, getChatAgentHoverOptions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatAgentHover';
9
9
  import { ChatEditorHoverWrapper } from './editorHoverWrapper.js';
10
10
  import { extractAgentAndCommand } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
11
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
11
+ import { localize } from 'vscode/vscode/vs/nls';
12
12
 
13
- const _moduleId = "vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover";
14
13
  let ChatAgentHoverParticipant = class ChatAgentHoverParticipant {
15
14
  constructor(editor, instantiationService, chatWidgetService, commandService) {
16
15
  this.editor = editor;
@@ -62,7 +61,7 @@ let ChatAgentHoverParticipant = class ChatAgentHoverParticipant {
62
61
  );
63
62
  }
64
63
  getAccessibleContent(hoverPart) {
65
- return ( localizeWithPath(_moduleId, 0, 'There is a chat agent hover part here.'));
64
+ return ( localize(7288, 'There is a chat agent hover part here.'));
66
65
  }
67
66
  };
68
67
  ChatAgentHoverParticipant = ( (__decorate([
@@ -1,5 +1,4 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
3
2
  import { DeferredPromise } from 'vscode/vscode/vs/base/common/async';
4
3
  import { CancellationToken, CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
5
4
  import { toErrorMessage } from 'vscode/vscode/vs/base/common/errorMessage';
@@ -11,8 +10,7 @@ import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycl
11
10
  import { revive } from 'vscode/vscode/vs/base/common/marshalling';
12
11
  import { StopWatch } from 'vscode/vscode/vs/base/common/stopwatch';
13
12
  import { URI } from 'vscode/vscode/vs/base/common/uri';
14
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
15
- import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
13
+ import { localize } from 'vscode/vscode/vs/nls';
16
14
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
17
15
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
18
16
  import { Progress } from 'vscode/vscode/vs/platform/progress/common/progress';
@@ -25,13 +23,12 @@ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/commo
25
23
  import { ChatModel, ChatWelcomeMessageModel, ChatRequestRemovalReason, getHistoryEntriesFromModel, updateRanges, ChatRequestModel } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
26
24
  import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, chatSubcommandLeader, chatAgentLeader, ChatRequestSlashCommandPart, getPromptText } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
27
25
  import { ChatRequestParser } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
28
- import { ChatAgentVoteDirection, ChatCopyKind } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
26
+ import { ChatServiceTelemetry } from './chatServiceTelemetry.js';
29
27
  import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
30
28
  import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
31
29
  import { ChatMessageRole } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModels';
32
30
  import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
33
31
 
34
- const _moduleId = "vs/workbench/contrib/chat/common/chatServiceImpl";
35
32
  const serializedChatKey = 'interactive.sessions';
36
33
  const globalChatKey = 'chat.workspaceTransfer';
37
34
  const SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS = 1000 * 60;
@@ -58,6 +55,7 @@ let ChatService = class ChatService extends Disposable {
58
55
  this._onDidDisposeSession = this._register(( (new Emitter())));
59
56
  this.onDidDisposeSession = this._onDidDisposeSession.event;
60
57
  this._sessionFollowupCancelTokens = this._register(( (new DisposableMap())));
58
+ this._chatServiceTelemetry = this.instantiationService.createInstance(ChatServiceTelemetry);
61
59
  const sessionData = storageService.get(serializedChatKey, StorageScope.WORKSPACE, '');
62
60
  if (sessionData) {
63
61
  this._persistedSessions = this.deserializeChats(sessionData);
@@ -100,37 +98,7 @@ let ChatService = class ChatService extends Disposable {
100
98
  this.storageService.store(serializedChatKey, serialized, StorageScope.WORKSPACE, StorageTarget.MACHINE);
101
99
  }
102
100
  notifyUserAction(action) {
103
- if (action.action.kind === 'vote') {
104
- this.telemetryService.publicLog2('interactiveSessionVote', {
105
- direction: action.action.direction === ChatAgentVoteDirection.Up ? 'up' : 'down',
106
- agentId: action.agentId ?? ''
107
- });
108
- }
109
- else if (action.action.kind === 'copy') {
110
- this.telemetryService.publicLog2('interactiveSessionCopy', {
111
- copyKind: action.action.copyKind === ChatCopyKind.Action ? 'action' : 'toolbar',
112
- agentId: action.agentId ?? ''
113
- });
114
- }
115
- else if (action.action.kind === 'insert') {
116
- this.telemetryService.publicLog2('interactiveSessionInsert', {
117
- newFile: !!action.action.newFile,
118
- agentId: action.agentId ?? ''
119
- });
120
- }
121
- else if (action.action.kind === 'command') {
122
- const command = CommandsRegistry.getCommand(action.action.commandButton.command.id);
123
- const commandId = command ? action.action.commandButton.command.id : 'INVALID';
124
- this.telemetryService.publicLog2('interactiveSessionCommand', {
125
- commandId,
126
- agentId: action.agentId ?? ''
127
- });
128
- }
129
- else if (action.action.kind === 'runInTerminal') {
130
- this.telemetryService.publicLog2('interactiveSessionRunInTerminal', {
131
- languageId: action.action.languageId ?? ''
132
- });
133
- }
101
+ this._chatServiceTelemetry.notifyUserAction(action);
134
102
  this._onDidPerformUserAction.fire(action);
135
103
  }
136
104
  trace(method, message) {
@@ -379,9 +347,11 @@ let ChatService = class ChatService extends Disposable {
379
347
  result: 'cancelled',
380
348
  requestType,
381
349
  agent: agentPart?.agent.id ?? '',
350
+ agentExtensionId: agentPart?.agent.extensionId.value ?? '',
382
351
  slashCommand: agentSlashCommandPart ? agentSlashCommandPart.command.name : commandPart?.slashCommand.command,
383
352
  chatSessionId: model.sessionId,
384
353
  location,
354
+ citations: request?.response?.codeCitations.length ?? 0
385
355
  });
386
356
  model.cancelRequest(request);
387
357
  });
@@ -396,22 +366,9 @@ let ChatService = class ChatService extends Disposable {
396
366
  request = model.addRequest(parsedRequest, initVariableData, attempt, agent, agentSlashCommandPart?.command);
397
367
  completeResponseCreated();
398
368
  const variableData = await this.chatVariablesService.resolveVariables(parsedRequest, options?.attachedContext, model, progressCallback, token);
399
- request.variableData = variableData;
369
+ model.updateRequest(request, variableData);
400
370
  const promptTextResult = getPromptText(request.message);
401
371
  const updatedVariableData = updateRanges(variableData, promptTextResult.diff);
402
- const implicitVariablesEnabled = (location === ChatAgentLocation.Editor || location === ChatAgentLocation.Notebook);
403
- if (implicitVariablesEnabled) {
404
- const implicitVariables = agent.defaultImplicitVariables;
405
- if (implicitVariables) {
406
- const resolvedImplicitVariables = await Promise.all(( (implicitVariables.map(async (v) => {
407
- const id = this.chatVariablesService.getVariable(v)?.id ?? '';
408
- const value = await this.chatVariablesService.resolveVariable(v, parsedRequest.text, model, progressCallback, token);
409
- return value ? { id, name: v, value } :
410
- undefined;
411
- }))));
412
- updatedVariableData.variables.push(...coalesce(resolvedImplicitVariables));
413
- }
414
- }
415
372
  const requestProps = {
416
373
  sessionId,
417
374
  requestId: request.id,
@@ -422,6 +379,7 @@ let ChatService = class ChatService extends Disposable {
422
379
  enableCommandDetection,
423
380
  attempt,
424
381
  location,
382
+ locationData: options?.locationData,
425
383
  acceptedConfirmationData: options?.acceptedConfirmationData,
426
384
  rejectedConfirmationData: options?.rejectedConfirmationData,
427
385
  };
@@ -438,12 +396,12 @@ let ChatService = class ChatService extends Disposable {
438
396
  continue;
439
397
  }
440
398
  history.push({ role: ChatMessageRole.User, content: { type: 'text', value: request.message.text } });
441
- history.push({ role: ChatMessageRole.Assistant, content: { type: 'text', value: request.response.response.asString() } });
399
+ history.push({ role: ChatMessageRole.Assistant, content: { type: 'text', value: ( (request.response.response.toString())) } });
442
400
  }
443
401
  const message = parsedRequest.text;
444
402
  const commandResult = await this.chatSlashCommandService.executeCommand(commandPart.slashCommand.command, message.substring(commandPart.slashCommand.command.length + 1).trimStart(), ( (new Progress(p => {
445
403
  progressCallback(p);
446
- }))), history, token);
404
+ }))), history, location, token);
447
405
  agentOrCommandFollowups = Promise.resolve(commandResult?.followUp);
448
406
  rawResult = {};
449
407
  }
@@ -456,7 +414,7 @@ let ChatService = class ChatService extends Disposable {
456
414
  else {
457
415
  if (!rawResult) {
458
416
  this.trace('sendRequest', `Provider returned no response for session ${model.sessionId}`);
459
- rawResult = { errorDetails: { message: ( localizeWithPath(_moduleId, 0, "Provider returned null response")) } };
417
+ rawResult = { errorDetails: { message: ( localize(3097, "Provider returned null response")) } };
460
418
  }
461
419
  const result = rawResult.errorDetails?.responseIsFiltered ? 'filtered' :
462
420
  rawResult.errorDetails && gotProgress ? 'errorWithOutput' :
@@ -468,9 +426,11 @@ let ChatService = class ChatService extends Disposable {
468
426
  result,
469
427
  requestType,
470
428
  agent: agentPart?.agent.id ?? '',
429
+ agentExtensionId: agentPart?.agent.extensionId.value ?? '',
471
430
  slashCommand: agentSlashCommandPart ? agentSlashCommandPart.command.name : commandPart?.slashCommand.command,
472
431
  chatSessionId: model.sessionId,
473
- location
432
+ location,
433
+ citations: request.response?.codeCitations.length ?? 0
474
434
  });
475
435
  model.setResponse(request, rawResult);
476
436
  completeResponseCreated();
@@ -491,9 +451,11 @@ let ChatService = class ChatService extends Disposable {
491
451
  result,
492
452
  requestType,
493
453
  agent: agentPart?.agent.id ?? '',
454
+ agentExtensionId: agentPart?.agent.extensionId.value ?? '',
494
455
  slashCommand: agentSlashCommandPart ? agentSlashCommandPart.command.name : commandPart?.slashCommand.command,
495
456
  chatSessionId: model.sessionId,
496
- location
457
+ location,
458
+ citations: 0
497
459
  });
498
460
  this.logService.error(`Error while handling chat request: ${toErrorMessage(err, true)}`);
499
461
  if (request) {
@@ -0,0 +1,54 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
3
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
4
+ import { ChatAgentVoteDirection, ChatCopyKind } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
5
+
6
+ let ChatServiceTelemetry = class ChatServiceTelemetry {
7
+ constructor(telemetryService) {
8
+ this.telemetryService = telemetryService;
9
+ }
10
+ notifyUserAction(action) {
11
+ if (action.action.kind === 'vote') {
12
+ this.telemetryService.publicLog2('interactiveSessionVote', {
13
+ direction: action.action.direction === ChatAgentVoteDirection.Up ? 'up' : 'down',
14
+ agentId: action.agentId ?? '',
15
+ command: action.command,
16
+ });
17
+ }
18
+ else if (action.action.kind === 'copy') {
19
+ this.telemetryService.publicLog2('interactiveSessionCopy', {
20
+ copyKind: action.action.copyKind === ChatCopyKind.Action ? 'action' : 'toolbar',
21
+ agentId: action.agentId ?? '',
22
+ command: action.command,
23
+ });
24
+ }
25
+ else if (action.action.kind === 'insert') {
26
+ this.telemetryService.publicLog2('interactiveSessionInsert', {
27
+ newFile: !!action.action.newFile,
28
+ agentId: action.agentId ?? '',
29
+ command: action.command,
30
+ });
31
+ }
32
+ else if (action.action.kind === 'command') {
33
+ const command = CommandsRegistry.getCommand(action.action.commandButton.command.id);
34
+ const commandId = command ? action.action.commandButton.command.id : 'INVALID';
35
+ this.telemetryService.publicLog2('interactiveSessionCommand', {
36
+ commandId,
37
+ agentId: action.agentId ?? '',
38
+ command: action.command,
39
+ });
40
+ }
41
+ else if (action.action.kind === 'runInTerminal') {
42
+ this.telemetryService.publicLog2('interactiveSessionRunInTerminal', {
43
+ languageId: action.action.languageId ?? '',
44
+ agentId: action.agentId ?? '',
45
+ command: action.command,
46
+ });
47
+ }
48
+ }
49
+ };
50
+ ChatServiceTelemetry = ( __decorate([
51
+ ( __param(0, ITelemetryService))
52
+ ], ChatServiceTelemetry));
53
+
54
+ export { ChatServiceTelemetry };
@@ -27,13 +27,13 @@ let ChatSlashCommandService = class ChatSlashCommandService extends Disposable {
27
27
  }
28
28
  });
29
29
  }
30
- getCommands() {
31
- return Array.from(( this._commands.values()), v => v.data);
30
+ getCommands(location) {
31
+ return Array.from(( this._commands.values()), v => v.data).filter(c => c.locations.includes(location));
32
32
  }
33
33
  hasCommand(id) {
34
34
  return ( this._commands.has(id));
35
35
  }
36
- async executeCommand(id, prompt, progress, history, token) {
36
+ async executeCommand(id, prompt, progress, history, location, token) {
37
37
  const data = this._commands.get(id);
38
38
  if (!data) {
39
39
  throw ( new Error('No command with id ${id} NOT registered'));
@@ -44,7 +44,7 @@ let ChatSlashCommandService = class ChatSlashCommandService extends Disposable {
44
44
  if (!data.command) {
45
45
  throw ( new Error(`No command with id ${id} NOT resolved`));
46
46
  }
47
- return await data.command(prompt, progress, history, token);
47
+ return await data.command(prompt, progress, history, location, token);
48
48
  }
49
49
  };
50
50
  ChatSlashCommandService = ( __decorate([
@@ -7,10 +7,9 @@ import { ExtensionIdentifier } from 'vscode/vscode/vs/platform/extensions/common
7
7
  import { Extensions } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
8
8
  import { IExtensionFeaturesManagementService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures.service';
9
9
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
10
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
10
+ import { localize } from 'vscode/vscode/vs/nls';
11
11
 
12
12
  var LanguageModelStatsService_1;
13
- const _moduleId = "vs/workbench/contrib/chat/common/languageModelStats";
14
13
  let LanguageModelStatsService = class LanguageModelStatsService extends Disposable {
15
14
  static { LanguageModelStatsService_1 = this; }
16
15
  static { this.MODEL_STATS_STORAGE_KEY_PREFIX = 'languageModelStats.'; }
@@ -122,8 +121,8 @@ LanguageModelStatsService = LanguageModelStatsService_1 = ( (__decorate([
122
121
  ], LanguageModelStatsService)));
123
122
  ( (Registry.as(Extensions.ExtensionFeaturesRegistry))).registerExtensionFeature({
124
123
  id: 'languageModels',
125
- label: ( localizeWithPath(_moduleId, 0, "Language Models")),
126
- description: ( localizeWithPath(_moduleId, 1, "Language models usage statistics of this extension.")),
124
+ label: ( localize(3106, "Language Models")),
125
+ description: ( localize(3107, "Language models usage statistics of this extension.")),
127
126
  access: {
128
127
  canToggle: false
129
128
  },
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
- import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
3
  import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
4
+ import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
5
  import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
6
6
 
7
7
  let LanguageModelToolsService = class LanguageModelToolsService {
@@ -1,11 +1,12 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
3
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { joinPath } from 'vscode/vscode/vs/base/common/resources';
4
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
5
+ import { localize } from 'vscode/vscode/vs/nls';
4
6
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
5
7
  import { ILanguageModelToolsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
6
8
  import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
7
9
 
8
- const _moduleId = "vs/workbench/contrib/chat/common/tools/languageModelToolsContribution";
9
10
  const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoint({
10
11
  extensionPoint: 'languageModelTools',
11
12
  activationEventsGenerator: (contributions, result) => {
@@ -14,11 +15,7 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
14
15
  }
15
16
  },
16
17
  jsonSchema: {
17
- description: ( localizeWithPath(
18
- _moduleId,
19
- 0,
20
- 'Contributes a tool that can be invoked by a language model.'
21
- )),
18
+ description: ( localize(7302, 'Contributes a tool that can be invoked by a language model.')),
22
19
  type: 'array',
23
20
  items: {
24
21
  additionalProperties: false,
@@ -27,33 +24,53 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
27
24
  required: ['name', 'description'],
28
25
  properties: {
29
26
  name: {
30
- description: ( localizeWithPath(
31
- _moduleId,
32
- 1,
33
- "A name for this tool which must be unique across all tools."
34
- )),
27
+ description: ( localize(7303, "A name for this tool which must be unique across all tools.")),
35
28
  type: 'string'
36
29
  },
37
30
  description: {
38
- description: ( localizeWithPath(
39
- _moduleId,
40
- 2,
41
- "A description of this tool that may be passed to a language model."
42
- )),
31
+ description: ( localize(7304, "A description of this tool that may be passed to a language model.")),
43
32
  type: 'string'
44
33
  },
45
34
  displayName: {
46
- description: ( localizeWithPath(
47
- _moduleId,
48
- 3,
35
+ description: ( localize(
36
+ 7305,
49
37
  "A human-readable name for this tool that may be used to describe it in the UI."
50
38
  )),
51
39
  type: 'string'
52
40
  },
53
41
  parametersSchema: {
54
- description: ( localizeWithPath(_moduleId, 4, "A JSON schema for the parameters this tool accepts.")),
42
+ description: ( localize(7306, "A JSON schema for the parameters this tool accepts.")),
55
43
  type: 'object',
56
44
  $ref: 'http://json-schema.org/draft-07/schema#'
45
+ },
46
+ canBeInvokedManually: {
47
+ description: ( localize(
48
+ 7307,
49
+ "Whether this tool can be invoked manually by the user through the chat UX."
50
+ )),
51
+ type: 'boolean'
52
+ },
53
+ icon: {
54
+ description: ( localize(
55
+ 7308,
56
+ "An icon that represents this tool. Either a file path, an object with file paths for dark and light themes, or a theme icon reference, like `\\$(zap)`"
57
+ )),
58
+ anyOf: [{
59
+ type: 'string'
60
+ },
61
+ {
62
+ type: 'object',
63
+ properties: {
64
+ light: {
65
+ description: ( localize(7309, 'Icon path when a light theme is used')),
66
+ type: 'string'
67
+ },
68
+ dark: {
69
+ description: ( localize(7310, 'Icon path when a dark theme is used')),
70
+ type: 'string'
71
+ }
72
+ }
73
+ }]
57
74
  }
58
75
  }
59
76
  }
@@ -68,13 +85,31 @@ let LanguageModelToolsExtensionPointHandler = class LanguageModelToolsExtensionP
68
85
  this._registrationDisposables = ( (new DisposableMap()));
69
86
  languageModelToolsExtensionPoint.setHandler((extensions, delta) => {
70
87
  for (const extension of delta.added) {
71
- for (const tool of extension.value) {
72
- if (!tool.name || !tool.description) {
73
- logService.warn(`Invalid tool contribution from ${extension.description.identifier.value}: ${JSON.stringify(tool)}`);
88
+ for (const rawTool of extension.value) {
89
+ if (!rawTool.name || !rawTool.description) {
90
+ logService.warn(`Invalid tool contribution from ${extension.description.identifier.value}: ${JSON.stringify(rawTool)}`);
74
91
  continue;
75
92
  }
93
+ const rawIcon = rawTool.icon;
94
+ let icon;
95
+ if (typeof rawIcon === 'string') {
96
+ icon = ThemeIcon.fromString(rawIcon) ?? {
97
+ dark: joinPath(extension.description.extensionLocation, rawIcon),
98
+ light: joinPath(extension.description.extensionLocation, rawIcon)
99
+ };
100
+ }
101
+ else if (rawIcon) {
102
+ icon = {
103
+ dark: joinPath(extension.description.extensionLocation, rawIcon.dark),
104
+ light: joinPath(extension.description.extensionLocation, rawIcon.light)
105
+ };
106
+ }
107
+ const tool = {
108
+ ...rawTool,
109
+ icon
110
+ };
76
111
  const disposable = languageModelToolsService.registerToolData(tool);
77
- this._registrationDisposables.set(toToolKey(extension.description.identifier, tool.name), disposable);
112
+ this._registrationDisposables.set(toToolKey(extension.description.identifier, rawTool.name), disposable);
78
113
  }
79
114
  }
80
115
  for (const extension of delta.removed) {