@codingame/monaco-vscode-chat-service-override 9.0.3 → 10.0.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 (41) hide show
  1. package/chat.js +8 -2
  2. package/package.json +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +24 -25
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +5 -7
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +100 -293
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +115 -26
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +6 -8
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +9 -7
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +448 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +58 -43
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +2 -4
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +7 -2
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatGettingStarted.js +131 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +88 -88
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +26 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +4 -2
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +6 -22
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +11 -17
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +21 -14
  23. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
  24. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +7 -1
  25. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +27 -0
  26. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +52 -0
  27. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +25 -29
  28. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +8 -1
  29. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +1 -2
  30. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +7 -8
  31. package/vscode/src/vs/workbench/contrib/chat/common/languageModelToolsService.js +70 -20
  32. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +172 -0
  33. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +30 -12
  34. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
  35. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +11 -15
  36. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -2
  37. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +5 -6
  38. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +5 -6
  39. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +5 -8
  40. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +0 -58
  41. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +0 -412
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { isAncestorOfActiveElement, $ } from 'vscode/vscode/vs/base/browser/dom';
3
- import { Sash, Orientation } from 'vscode/vscode/vs/base/browser/ui/sash/sash';
3
+ import { Sash } from 'vscode/vscode/vs/base/browser/ui/sash/sash';
4
4
  import { disposableTimeout } from 'vscode/vscode/vs/base/common/async';
5
5
  import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
6
6
  import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
@@ -27,6 +27,7 @@ import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat
27
27
  import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
28
28
  import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
29
29
  import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
30
+ import { EDITOR_DRAG_AND_DROP_BACKGROUND } from 'vscode/vscode/vs/workbench/common/theme';
30
31
 
31
32
  var QuickChat_1;
32
33
  let QuickChatService = class QuickChatService extends Disposable {
@@ -181,6 +182,7 @@ let QuickChat = class QuickChat extends Disposable {
181
182
  this.widget = this._register(scopedInstantiationService.createInstance(ChatWidget, ChatAgentLocation.Panel, { isQuickChat: true }, { renderInputOnTop: true, renderStyle: 'compact', menus: { inputSideToolbar: MenuId.ChatInputSide } }, {
182
183
  listForeground: quickInputForeground,
183
184
  listBackground: quickInputBackground,
185
+ overlayBackground: EDITOR_DRAG_AND_DROP_BACKGROUND,
184
186
  inputEditorBackground: inputBackground,
185
187
  resultEditorBackground: editorBackground
186
188
  }));
@@ -191,7 +193,7 @@ let QuickChat = class QuickChat extends Disposable {
191
193
  this.sash = this._register(( new Sash(
192
194
  parent,
193
195
  { getHorizontalSashTop: () => parent.offsetHeight },
194
- { orientation: Orientation.HORIZONTAL }
196
+ { orientation: 1 }
195
197
  )));
196
198
  this.registerListeners(parent);
197
199
  }
@@ -1,18 +1,15 @@
1
1
  import { renderMarkdownAsPlaintext } from 'vscode/vscode/vs/base/browser/markdownRenderer';
2
2
  import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
3
- import { AccessibleViewType, AccessibleViewProviderId } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleView';
4
- import { AccessibilityVerbositySettingId } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
5
- import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
3
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
6
4
  import { CONTEXT_IN_CHAT_SESSION } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
7
- import { ChatWelcomeMessageModel } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
8
5
  import { isResponseVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
9
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
6
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
10
7
 
11
8
  class ChatResponseAccessibleView {
12
9
  constructor() {
13
10
  this.priority = 100;
14
11
  this.name = 'panelChat';
15
- this.type = AccessibleViewType.View;
12
+ this.type = "view" ;
16
13
  this.when = CONTEXT_IN_CHAT_SESSION;
17
14
  }
18
15
  getProvider(accessor) {
@@ -38,29 +35,16 @@ class ChatResponseAccessibleProvider extends Disposable {
38
35
  super();
39
36
  this._widget = _widget;
40
37
  this._chatInputFocused = _chatInputFocused;
41
- this.id = AccessibleViewProviderId.Chat;
42
- this.verbositySettingKey = AccessibilityVerbositySettingId.Chat;
43
- this.options = { type: AccessibleViewType.View };
38
+ this.id = "panelChat" ;
39
+ this.verbositySettingKey = "accessibility.verbosity.panelChat" ;
40
+ this.options = { type: "view" };
44
41
  this._focusedItem = item;
45
42
  }
46
43
  provideContent() {
47
44
  return this._getContent(this._focusedItem);
48
45
  }
49
46
  _getContent(item) {
50
- const isWelcome = item instanceof ChatWelcomeMessageModel;
51
47
  let responseContent = isResponseVM(item) ? ( item.response.toString()) : '';
52
- if (isWelcome) {
53
- const welcomeReplyContents = [];
54
- for (const content of item.content) {
55
- if (Array.isArray(content)) {
56
- welcomeReplyContents.push(...( content.map(m => m.message)));
57
- }
58
- else {
59
- welcomeReplyContents.push(content.value);
60
- }
61
- }
62
- responseContent = welcomeReplyContents.join('\n');
63
- }
64
48
  if (!responseContent && 'errorDetails' in item && item.errorDetails) {
65
49
  responseContent = item.errorDetails.message;
66
50
  }
@@ -1,25 +1,23 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { basename } from 'vscode/vscode/vs/base/common/path';
3
2
  import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
4
3
  import { onUnexpectedExternalError } from 'vscode/vscode/vs/base/common/errors';
5
4
  import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
6
5
  import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
6
+ import { basename } from 'vscode/vscode/vs/base/common/path';
7
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
7
8
  import { URI } from 'vscode/vscode/vs/base/common/uri';
9
+ import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
10
+ import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
11
+ import { ChatRequestVariablePart, ChatRequestDynamicVariablePart, ChatRequestToolPart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
8
12
  import { showChatView } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
9
13
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
14
+ import { ChatContextAttachments } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments';
10
15
  import { ChatDynamicVariableModel } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
11
- import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
12
- import { ChatRequestVariablePart, ChatRequestDynamicVariablePart, ChatRequestToolPart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
13
- import { ChatContextAttachments } from './contrib/chatContextAttachments.js';
14
- import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
15
- import { ILanguageModelToolsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
16
- import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
17
16
 
18
17
  let ChatVariablesService = class ChatVariablesService {
19
- constructor(chatWidgetService, viewsService, toolsService) {
18
+ constructor(chatWidgetService, viewsService) {
20
19
  this.chatWidgetService = chatWidgetService;
21
20
  this.viewsService = viewsService;
22
- this.toolsService = toolsService;
23
21
  this._resolver = ( new Map());
24
22
  }
25
23
  async resolveVariables(prompt, attachedContextVariables, model, progress, token) {
@@ -46,13 +44,10 @@ let ChatVariablesService = class ChatVariablesService {
46
44
  }
47
45
  }
48
46
  else if (part instanceof ChatRequestDynamicVariablePart) {
49
- resolvedVariables[i] = { id: part.id, name: part.referenceText, range: part.range, value: part.data, };
47
+ resolvedVariables[i] = { id: part.id, name: part.referenceText, range: part.range, value: part.data, fullName: part.fullName, icon: part.icon };
50
48
  }
51
49
  else if (part instanceof ChatRequestToolPart) {
52
- const tool = this.toolsService.getTool(part.toolId);
53
- if (tool) {
54
- resolvedVariables[i] = { id: part.toolId, name: part.toolName, range: part.range, value: undefined, isTool: true, icon: ThemeIcon.isThemeIcon(tool.icon) ? tool.icon : undefined, fullName: tool.displayName };
55
- }
50
+ resolvedVariables[i] = { id: part.toolId, name: part.toolName, range: part.range, value: undefined, isTool: true, icon: ThemeIcon.isThemeIcon(part.icon) ? part.icon : undefined, fullName: part.displayName };
56
51
  }
57
52
  });
58
53
  const resolvedAttachedContext = [];
@@ -130,7 +125,7 @@ let ChatVariablesService = class ChatVariablesService {
130
125
  if (location !== ChatAgentLocation.Panel) {
131
126
  return;
132
127
  }
133
- const widget = await showChatView(this.viewsService);
128
+ const widget = this.chatWidgetService.lastFocusedWidget ?? (await showChatView(this.viewsService));
134
129
  if (!widget || !widget.viewModel) {
135
130
  return;
136
131
  }
@@ -150,8 +145,7 @@ let ChatVariablesService = class ChatVariablesService {
150
145
  };
151
146
  ChatVariablesService = ( __decorate([
152
147
  ( __param(0, IChatWidgetService)),
153
- ( __param(1, IViewsService)),
154
- ( __param(2, ILanguageModelToolsService))
148
+ ( __param(1, IViewsService))
155
149
  ], ChatVariablesService));
156
150
 
157
151
  export { ChatVariablesService };
@@ -10,7 +10,6 @@ import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/commo
10
10
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
11
11
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
12
12
  import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
13
- import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
14
13
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
15
14
  import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
16
15
  import 'vscode/vscode/vs/platform/theme/common/colorUtils';
@@ -29,12 +28,12 @@ import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPan
29
28
  import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
30
29
  import { SIDE_BAR_FOREGROUND } from 'vscode/vscode/vs/workbench/common/theme';
31
30
  import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views.service';
32
- import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
33
31
  import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
34
32
  import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
35
- import { CHAT_PROVIDER_ID } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParticipantContribTypes';
36
33
  import { ChatModelInitState } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
34
+ import { CHAT_PROVIDER_ID } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParticipantContribTypes';
37
35
  import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
36
+ import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
38
37
 
39
38
  const CHAT_SIDEBAR_PANEL_ID = 'workbench.panel.chatSidebar';
40
39
  let ChatViewPane = class ChatViewPane extends ViewPane {
@@ -48,13 +47,16 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
48
47
  this.modelDisposables = this._register(( new DisposableStore()));
49
48
  this.didProviderRegistrationFail = false;
50
49
  this.didUnregisterProvider = false;
50
+ this.isInitialized = false;
51
51
  this.memento = ( new Memento('interactive-session-view-' + CHAT_PROVIDER_ID, this.storageService));
52
- this.viewState = this.memento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
52
+ this.viewState = this.memento.getMemento(1 , 1 );
53
53
  this._register(this.chatAgentService.onDidChangeAgents(() => {
54
+ this.isInitialized = true;
54
55
  if (this.chatAgentService.getDefaultAgent(ChatAgentLocation.Panel)) {
55
56
  if (!this._widget?.viewModel) {
56
57
  const sessionId = this.getSessionId();
57
58
  const model = sessionId ? this.chatService.getOrRestoreSession(sessionId) : undefined;
59
+ const wasVisible = this._widget.visible;
58
60
  try {
59
61
  this._widget.setVisible(false);
60
62
  this.updateModel(model);
@@ -63,7 +65,7 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
63
65
  this._onDidChangeViewWelcomeState.fire();
64
66
  }
65
67
  finally {
66
- this.widget.setVisible(true);
68
+ this.widget.setVisible(wasVisible);
67
69
  }
68
70
  }
69
71
  }
@@ -78,7 +80,7 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
78
80
  chatView: this
79
81
  };
80
82
  }
81
- updateModel(model) {
83
+ updateModel(model, viewState) {
82
84
  this.modelDisposables.clear();
83
85
  model = model ?? (this.chatService.transferredSessionData?.sessionId
84
86
  ? this.chatService.getOrRestoreSession(this.chatService.transferredSessionData.sessionId)
@@ -86,15 +88,18 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
86
88
  if (!model) {
87
89
  throw ( new Error('Could not start chat session'));
88
90
  }
89
- this._widget.setModel(model, { ...this.viewState });
91
+ if (viewState) {
92
+ this.updateViewState(viewState);
93
+ }
90
94
  this.viewState.sessionId = model.sessionId;
95
+ this._widget.setModel(model, { ...this.viewState });
91
96
  }
92
97
  shouldShowWelcome() {
93
98
  if (!this.chatAgentService.getContributedDefaultAgent(ChatAgentLocation.Panel)) {
94
99
  return true;
95
100
  }
96
101
  const noPersistedSessions = !this.chatService.hasSessions();
97
- return this.didUnregisterProvider || !this._widget?.viewModel && (noPersistedSessions || this.didProviderRegistrationFail);
102
+ return this.didUnregisterProvider || !this._widget?.viewModel && (noPersistedSessions || this.didProviderRegistrationFail) || !this.isInitialized;
98
103
  }
99
104
  getSessionId() {
100
105
  let sessionId;
@@ -115,6 +120,7 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
115
120
  this._widget = this._register(scopedInstantiationService.createInstance(ChatWidget, ChatAgentLocation.Panel, { viewId: this.id }, { supportsFileReferences: true }, {
116
121
  listForeground: SIDE_BAR_FOREGROUND,
117
122
  listBackground: locationBasedColors.background,
123
+ overlayBackground: locationBasedColors.overlayBackground,
118
124
  inputEditorBackground: locationBasedColors.background,
119
125
  resultEditorBackground: editorBackground
120
126
  }));
@@ -149,12 +155,12 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
149
155
  this.updateViewState();
150
156
  this.updateModel(undefined);
151
157
  }
152
- loadSession(sessionId) {
158
+ loadSession(sessionId, viewState) {
153
159
  if (this.widget.viewModel) {
154
160
  this.chatService.clearSession(this.widget.viewModel.sessionId);
155
161
  }
156
162
  const newModel = this.chatService.getOrRestoreSession(sessionId);
157
- this.updateModel(newModel);
163
+ this.updateModel(newModel, viewState);
158
164
  }
159
165
  focusInput() {
160
166
  this._widget.focusInput();
@@ -175,10 +181,11 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
175
181
  }
176
182
  super.saveState();
177
183
  }
178
- updateViewState() {
179
- const widgetViewState = this._widget.getViewState();
180
- this.viewState.inputValue = widgetViewState.inputValue;
181
- this.viewState.inputState = widgetViewState.inputState;
184
+ updateViewState(viewState) {
185
+ const newViewState = viewState ?? this._widget.getViewState();
186
+ this.viewState.inputValue = newViewState.inputValue;
187
+ this.viewState.inputState = newViewState.inputState;
188
+ this.viewState.selectedLanguageModelId = newViewState.selectedLanguageModelId;
182
189
  }
183
190
  };
184
191
  ChatViewPane = ( __decorate([
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
3
3
  import { Range } from 'vscode/vscode/vs/editor/common/core/range';
4
- import { RenderedHoverParts, HoverAnchorType, HoverParticipantRegistry } from 'vscode/vscode/vs/editor/contrib/hover/browser/hoverTypes';
4
+ import { RenderedHoverParts, HoverParticipantRegistry } from 'vscode/vscode/vs/editor/contrib/hover/browser/hoverTypes';
5
5
  import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
6
6
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
7
7
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
@@ -61,7 +61,7 @@ let ChatAgentHoverParticipant = class ChatAgentHoverParticipant {
61
61
  );
62
62
  }
63
63
  getAccessibleContent(hoverPart) {
64
- return ( localize(7162, 'There is a chat agent hover part here.'));
64
+ return ( localize(7381, 'There is a chat agent hover part here.'));
65
65
  }
66
66
  };
67
67
  ChatAgentHoverParticipant = ( (__decorate([
@@ -76,7 +76,7 @@ class ChatAgentHoverPart {
76
76
  this.agent = agent;
77
77
  }
78
78
  isValidForHoverAnchor(anchor) {
79
- return (anchor.type === HoverAnchorType.Range
79
+ return (anchor.type === 1
80
80
  && this.range.startColumn <= anchor.range.startColumn
81
81
  && this.range.endColumn >= anchor.range.endColumn);
82
82
  }
@@ -1,7 +1,13 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import './media/editorHoverWrapper.css.js';
3
3
  import { $ as $$1, h as h$1 } from 'vscode/vscode/vs/base/browser/dom';
4
- import 'vscode/vscode/vs/base/browser/ui/hover/hoverWidget';
4
+ import 'vscode/vscode/vs/base/browser/browser';
5
+ import 'vscode/vscode/vs/base/common/keyCodes';
6
+ import 'vscode/vscode/vs/base/common/platform';
7
+ import 'vscode/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
8
+ import 'vscode/vscode/vs/base/common/lifecycle';
9
+ import 'vscode/vscode/vs/base/browser/ui/hover/hoverWidget.css';
10
+ import 'vscode/vscode/vs/nls';
5
11
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
6
12
 
7
13
  const $ = $$1;
@@ -0,0 +1,27 @@
1
+ class CodeMapperService {
2
+ constructor() {
3
+ this.providers = [];
4
+ }
5
+ registerCodeMapperProvider(handle, provider) {
6
+ this.providers.push(provider);
7
+ return {
8
+ dispose: () => {
9
+ const index = this.providers.indexOf(provider);
10
+ if (index >= 0) {
11
+ this.providers.splice(index, 1);
12
+ }
13
+ }
14
+ };
15
+ }
16
+ async mapCode(request, response, token) {
17
+ for (const provider of this.providers) {
18
+ const result = await provider.mapCode(request, response, token);
19
+ if (result) {
20
+ return result;
21
+ }
22
+ }
23
+ return undefined;
24
+ }
25
+ }
26
+
27
+ export { CodeMapperService };
@@ -0,0 +1,52 @@
1
+ import { DeferredPromise } from 'vscode/vscode/vs/base/common/async';
2
+
3
+ class ChatToolInvocation {
4
+ get isComplete() {
5
+ return this._isComplete;
6
+ }
7
+ get isCanceled() {
8
+ return this._isCanceled;
9
+ }
10
+ get confirmed() {
11
+ return this._confirmDeferred;
12
+ }
13
+ get isConfirmed() {
14
+ return this._isConfirmed;
15
+ }
16
+ constructor(invocationMessage, _confirmationMessages) {
17
+ this.invocationMessage = invocationMessage;
18
+ this._confirmationMessages = _confirmationMessages;
19
+ this.kind = 'toolInvocation';
20
+ this._isComplete = false;
21
+ this._confirmDeferred = ( new DeferredPromise());
22
+ if (!_confirmationMessages) {
23
+ this._isConfirmed = true;
24
+ this._confirmDeferred.complete(true);
25
+ }
26
+ this._confirmDeferred.p.then(confirmed => {
27
+ this._isConfirmed = confirmed;
28
+ this._confirmationMessages = undefined;
29
+ if (!confirmed) {
30
+ this.complete();
31
+ }
32
+ });
33
+ }
34
+ complete() {
35
+ if (this._isComplete) {
36
+ throw ( new Error('Invocation is already complete.'));
37
+ }
38
+ this._isComplete = true;
39
+ }
40
+ get confirmationMessages() {
41
+ return this._confirmationMessages;
42
+ }
43
+ toJSON() {
44
+ return {
45
+ kind: 'toolInvocationSerialized',
46
+ invocationMessage: this.invocationMessage,
47
+ isConfirmed: this._isConfirmed ?? false
48
+ };
49
+ }
50
+ }
51
+
52
+ export { ChatToolInvocation };
@@ -16,22 +16,19 @@ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/
16
16
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
17
17
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
18
18
  import { Progress } from 'vscode/vscode/vs/platform/progress/common/progress';
19
- import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
20
19
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
21
20
  import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
22
21
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
22
+ import { IWorkbenchAssignmentService } from 'vscode/vscode/vs/workbench/services/assignment/common/assignmentService.service';
23
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
23
24
  import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
24
25
  import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
25
- import { CONTEXT_VOTE_UP_ENABLED } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
26
- import { normalizeSerializableChatData, ChatModel, ChatWelcomeMessageModel, ChatRequestRemovalReason, updateRanges, ChatRequestModel } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
26
+ import { normalizeSerializableChatData, ChatModel, updateRanges, toChatHistoryContent, ChatRequestModel } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
27
27
  import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, chatSubcommandLeader, chatAgentLeader, ChatRequestSlashCommandPart, getPromptText } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
28
28
  import { ChatRequestParser } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
29
29
  import { ChatServiceTelemetry } from './chatServiceTelemetry.js';
30
30
  import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
31
31
  import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
32
- import { ChatMessageRole } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModels';
33
- import { IWorkbenchAssignmentService } from 'vscode/vscode/vs/workbench/services/assignment/common/assignmentService.service';
34
- import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
35
32
 
36
33
  const serializedChatKey = 'interactive.sessions';
37
34
  const globalChatKey = 'chat.workspaceTransfer';
@@ -75,7 +72,7 @@ let ChatService = class ChatService extends Disposable {
75
72
  this._sessionFollowupCancelTokens = this._register(( (new DisposableMap())));
76
73
  this._chatServiceTelemetry = this.instantiationService.createInstance(ChatServiceTelemetry);
77
74
  const isEmptyWindow = !workspaceContextService.getWorkspace().folders.length;
78
- const sessionData = storageService.get(serializedChatKey, isEmptyWindow ? StorageScope.APPLICATION : StorageScope.WORKSPACE, '');
75
+ const sessionData = storageService.get(serializedChatKey, isEmptyWindow ? -1 : 1 , '');
79
76
  if (sessionData) {
80
77
  this._persistedSessions = this.deserializeChats(sessionData);
81
78
  const countsForLog = ( (Object.keys(this._persistedSessions))).length;
@@ -94,9 +91,6 @@ let ChatService = class ChatService extends Disposable {
94
91
  this._transferredSessionData = { sessionId: transferredChat.sessionId, inputValue: transferredData.inputValue };
95
92
  }
96
93
  this._register(storageService.onWillSaveState(() => this.saveState()));
97
- const voteUpEnabled = CONTEXT_VOTE_UP_ENABLED.bindTo(contextKeyService);
98
- workbenchAssignmentService.getTreatment('chatVoteUpEnabled')
99
- .then(value => voteUpEnabled.set(!!value));
100
94
  }
101
95
  isEnabled(location) {
102
96
  return this.chatAgentService.getContributedDefaultAgent(location) !== undefined;
@@ -123,12 +117,12 @@ let ChatService = class ChatService extends Disposable {
123
117
  if (allSessions.length) {
124
118
  this.trace('onWillSaveState', `Persisting ${serialized.length} chars`);
125
119
  }
126
- this.storageService.store(serializedChatKey, serialized, StorageScope.WORKSPACE, StorageTarget.MACHINE);
120
+ this.storageService.store(serializedChatKey, serialized, 1 , 1 );
127
121
  }
128
122
  this._deletedChatIds.clear();
129
123
  }
130
124
  syncEmptyWindowChats(thisWindowChats) {
131
- const sessionData = this.storageService.get(serializedChatKey, StorageScope.APPLICATION, '');
125
+ const sessionData = this.storageService.get(serializedChatKey, -1 , '');
132
126
  const originalPersistedSessions = this._persistedSessions;
133
127
  let persistedSessions;
134
128
  if (sessionData) {
@@ -161,7 +155,7 @@ let ChatService = class ChatService extends Disposable {
161
155
  sessionsList.sort((a, b) => (b.creationDate ?? 0) - (a.creationDate ?? 0));
162
156
  sessionsList = sessionsList.slice(0, maxPersistedSessions);
163
157
  const data = JSON.stringify(sessionsList);
164
- this.storageService.store(serializedChatKey, data, StorageScope.APPLICATION, StorageTarget.MACHINE);
158
+ this.storageService.store(serializedChatKey, data, -1 , 1 );
165
159
  }
166
160
  notifyUserAction(action) {
167
161
  this._chatServiceTelemetry.notifyUserAction(action);
@@ -222,7 +216,7 @@ let ChatService = class ChatService extends Disposable {
222
216
  }
223
217
  }
224
218
  getTransferredSessionData() {
225
- const data = this.storageService.getObject(globalChatKey, StorageScope.PROFILE, []);
219
+ const data = this.storageService.getObject(globalChatKey, 0 , []);
226
220
  const workspaceUri = this.workspaceContextService.getWorkspace().folders[0]?.uri;
227
221
  if (!workspaceUri) {
228
222
  return;
@@ -231,7 +225,7 @@ let ChatService = class ChatService extends Disposable {
231
225
  const currentTime = Date.now();
232
226
  const transferred = data.find(item => ( (URI.revive(item.toWorkspace).toString())) === thisWorkspace && (currentTime - item.timestampInMilliseconds < SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS));
233
227
  const filtered = data.filter(item => ( (URI.revive(item.toWorkspace).toString())) !== thisWorkspace && (currentTime - item.timestampInMilliseconds < SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS));
234
- this.storageService.store(globalChatKey, JSON.stringify(filtered), StorageScope.PROFILE, StorageTarget.MACHINE);
228
+ this.storageService.store(globalChatKey, JSON.stringify(filtered), 0 , 1 );
235
229
  return transferred;
236
230
  }
237
231
  getHistory() {
@@ -252,7 +246,7 @@ let ChatService = class ChatService extends Disposable {
252
246
  const liveSessionItems = ( (Array.from(( (this._sessionModels.values())))
253
247
  .filter(session => !session.isImported)
254
248
  .map(session => {
255
- const title = session.title || ( localize(3050, "New Chat"));
249
+ const title = session.title || ( localize(3154, "New Chat"));
256
250
  return {
257
251
  sessionId: session.sessionId,
258
252
  title,
@@ -298,11 +292,9 @@ let ChatService = class ChatService extends Disposable {
298
292
  if (!defaultAgent) {
299
293
  throw ( (new ErrorNoTelemetry('No default agent registered')));
300
294
  }
301
- const welcomeMessage = model.welcomeMessage ? undefined : (await defaultAgent.provideWelcomeMessage?.(model.initialLocation, token)) ?? undefined;
302
- const welcomeModel = welcomeMessage && this.instantiationService.createInstance(ChatWelcomeMessageModel, ( (welcomeMessage.map(
303
- item => typeof item === 'string' ? ( (new MarkdownString(item))) : item
304
- ))), (await defaultAgent.provideSampleQuestions?.(model.initialLocation, token)) ?? []);
305
- model.initialize(welcomeModel);
295
+ const welcomeMessage = (await defaultAgent.provideWelcomeMessage?.(token)) ?? undefined;
296
+ const sampleQuestions = (await defaultAgent.provideSampleQuestions?.(model.initialLocation, token)) ?? undefined;
297
+ model.initialize(welcomeMessage, sampleQuestions);
306
298
  }
307
299
  catch (err) {
308
300
  this.trace('startSession', `initializeSession failed: ${err}`);
@@ -347,7 +339,7 @@ let ChatService = class ChatService extends Disposable {
347
339
  const attempt = options?.attempt ?? 0;
348
340
  const enableCommandDetection = !options?.noCommandDetection;
349
341
  const defaultAgent = this.chatAgentService.getDefaultAgent(location);
350
- model.removeRequest(request.id, ChatRequestRemovalReason.Resend);
342
+ model.removeRequest(request.id, 1 );
351
343
  const resendOptions = {
352
344
  ...options,
353
345
  locationData: request.locationData,
@@ -453,7 +445,8 @@ let ChatService = class ChatService extends Disposable {
453
445
  location,
454
446
  citations: request?.response?.codeCitations.length ?? 0,
455
447
  numCodeBlocks: getCodeBlocks(request.response?.response.toString() ?? '').length,
456
- isParticipantDetected: !!detectedAgent
448
+ isParticipantDetected: !!detectedAgent,
449
+ enableCommandDetection
457
450
  });
458
451
  model.cancelRequest(request);
459
452
  });
@@ -483,6 +476,7 @@ let ChatService = class ChatService extends Disposable {
483
476
  locationData: request.locationData,
484
477
  acceptedConfirmationData: options?.acceptedConfirmationData,
485
478
  rejectedConfirmationData: options?.rejectedConfirmationData,
479
+ userSelectedModelId: options?.userSelectedModelId
486
480
  };
487
481
  };
488
482
  if (this.configurationService.getValue('chat.experimental.detectParticipant.enabled') !== false && this.chatAgentService.hasChatParticipantDetectionProviders() && !agentPart && !commandPart && enableCommandDetection) {
@@ -518,8 +512,8 @@ let ChatService = class ChatService extends Disposable {
518
512
  if (!request.response) {
519
513
  continue;
520
514
  }
521
- history.push({ role: ChatMessageRole.User, content: [{ type: 'text', value: request.message.text }] });
522
- history.push({ role: ChatMessageRole.Assistant, content: [{ type: 'text', value: ( (request.response.response.toString())) }] });
515
+ history.push({ role: 1 , content: [{ type: 'text', value: request.message.text }] });
516
+ history.push({ role: 2 , content: [{ type: 'text', value: ( (request.response.response.toString())) }] });
523
517
  }
524
518
  const message = parsedRequest.text;
525
519
  const commandResult = await this.chatSlashCommandService.executeCommand(commandPart.slashCommand.command, message.substring(commandPart.slashCommand.command.length + 1).trimStart(), ( (new Progress(p => {
@@ -537,7 +531,7 @@ let ChatService = class ChatService extends Disposable {
537
531
  else {
538
532
  if (!rawResult) {
539
533
  this.trace('sendRequest', `Provider returned no response for session ${model.sessionId}`);
540
- rawResult = { errorDetails: { message: ( localize(3051, "Provider returned null response")) } };
534
+ rawResult = { errorDetails: { message: ( localize(3155, "Provider returned null response")) } };
541
535
  }
542
536
  const result = rawResult.errorDetails?.responseIsFiltered ? 'filtered' :
543
537
  rawResult.errorDetails && gotProgress ? 'errorWithOutput' :
@@ -553,6 +547,7 @@ let ChatService = class ChatService extends Disposable {
553
547
  agentExtensionId: agentPart?.agent.extensionId.value ?? '',
554
548
  slashCommand: commandForTelemetry,
555
549
  chatSessionId: model.sessionId,
550
+ enableCommandDetection,
556
551
  isParticipantDetected: !!detectedAgent,
557
552
  location,
558
553
  citations: request.response?.codeCitations.length ?? 0,
@@ -589,6 +584,7 @@ let ChatService = class ChatService extends Disposable {
589
584
  location,
590
585
  citations: 0,
591
586
  numCodeBlocks: 0,
587
+ enableCommandDetection,
592
588
  isParticipantDetected: !!detectedAgent
593
589
  });
594
590
  this.logService.error(`Error while handling chat request: ${toErrorMessage(err, true)}`);
@@ -633,7 +629,7 @@ let ChatService = class ChatService extends Disposable {
633
629
  variables: updateRanges(request.variableData, promptTextResult.diff),
634
630
  location: ChatAgentLocation.Panel
635
631
  };
636
- history.push({ request: historyRequest, response: request.response.response.value, result: request.response.result ?? {} });
632
+ history.push({ request: historyRequest, response: toChatHistoryContent(request.response.response.value), result: request.response.result ?? {} });
637
633
  }
638
634
  return history;
639
635
  }
@@ -725,14 +721,14 @@ let ChatService = class ChatService extends Disposable {
725
721
  `Failed to transfer session. Unknown session ID: ${transferredSessionData.sessionId}`
726
722
  )));
727
723
  }
728
- const existingRaw = this.storageService.getObject(globalChatKey, StorageScope.PROFILE, []);
724
+ const existingRaw = this.storageService.getObject(globalChatKey, 0 , []);
729
725
  existingRaw.push({
730
726
  chat: model.toJSON(),
731
727
  timestampInMilliseconds: Date.now(),
732
728
  toWorkspace: toWorkspace,
733
729
  inputValue: transferredSessionData.inputValue,
734
730
  });
735
- this.storageService.store(globalChatKey, JSON.stringify(existingRaw), StorageScope.PROFILE, StorageTarget.MACHINE);
731
+ this.storageService.store(globalChatKey, JSON.stringify(existingRaw), 0 , 1 );
736
732
  this.trace('transferChatSession', `Transferred session ${model.sessionId} to workspace ${( (toWorkspace.toString()))}`);
737
733
  }
738
734
  };
@@ -26,10 +26,17 @@ let ChatServiceTelemetry = class ChatServiceTelemetry {
26
26
  else if (action.action.kind === 'insert') {
27
27
  this.telemetryService.publicLog2('interactiveSessionInsert', {
28
28
  newFile: !!action.action.newFile,
29
- userAction: action.action.userAction,
29
+ agentId: action.agentId ?? '',
30
+ command: action.command,
31
+ });
32
+ }
33
+ else if (action.action.kind === 'apply') {
34
+ this.telemetryService.publicLog2('interactiveSessionApply', {
35
+ newFile: !!action.action.newFile,
30
36
  codeMapper: action.action.codeMapper,
31
37
  agentId: action.agentId ?? '',
32
38
  command: action.command,
39
+ editsProposed: !!action.action.editsProposed,
33
40
  });
34
41
  }
35
42
  else if (action.action.kind === 'command') {
@@ -1,6 +1,5 @@
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 { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
4
3
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
5
4
  import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
6
5
  import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
@@ -11,7 +10,7 @@ let ChatWidgetHistoryService = class ChatWidgetHistoryService {
11
10
  this._onDidClearHistory = ( new Emitter());
12
11
  this.onDidClearHistory = this._onDidClearHistory.event;
13
12
  this.memento = ( new Memento('interactive-session', storageService));
14
- const loadedState = this.memento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
13
+ const loadedState = this.memento.getMemento(1 , 1 );
15
14
  for (const provider in loadedState.history) {
16
15
  loadedState.history[provider] = ( loadedState.history[provider].map(entry => typeof entry === 'string' ? { text: entry } : entry));
17
16
  }