@codingame/monaco-vscode-chat-service-override 11.1.2 → 12.0.0
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.
- package/index.d.ts +2 -1
- package/index.js +64 -1
- package/package.json +32 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +21 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +73 -60
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +73 -81
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +73 -112
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +253 -101
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +16 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +23 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +30 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +22 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +23 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +52 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +50 -47
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +124 -95
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +6 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.js +30 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.d.ts +69 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +203 -182
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +103 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +458 -165
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +42 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +14 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/{chatParticipantContributions.js → chatParticipant.contribution.js} +101 -92
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +42 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +164 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +6 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +30 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +10 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +941 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +9 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +54 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +32 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.js +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +8 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +16 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +108 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +3 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +31 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +70 -49
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/{chatViewsWelcomeContributions.js → chatViewsWelcomeHandler.js} +13 -13
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +44 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +3 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +22 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +1 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +80 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +152 -104
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +41 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.d.ts +31 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +6 -4
- package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.d.ts +13 -0
- package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.js +1 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +23 -21
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.js +1 -0
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +39 -0
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +20 -19
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.service.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +30 -33
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +6 -4
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +9 -7
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.d.ts +44 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +247 -83
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +5 -4
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.d.ts +29 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +35 -35
- package/chat.js +0 -59
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +0 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +0 -326
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +0 -76
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorActions.js +0 -110
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorController.js +0 -287
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +0 -130
- package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +0 -172
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { DeferredPromise } from 'vscode/vscode/vs/base/common/async';
|
|
3
4
|
import { CancellationToken, CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
|
|
4
5
|
import { toErrorMessage } from 'vscode/vscode/vs/base/common/errorMessage';
|
|
@@ -10,25 +11,26 @@ import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycl
|
|
|
10
11
|
import { revive } from 'vscode/vscode/vs/base/common/marshalling';
|
|
11
12
|
import { StopWatch } from 'vscode/vscode/vs/base/common/stopwatch';
|
|
12
13
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
14
|
+
import { isLocation } from 'vscode/vscode/vs/editor/common/languages';
|
|
13
15
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
14
16
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
15
|
-
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
16
17
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
17
18
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
18
19
|
import { Progress } from 'vscode/vscode/vs/platform/progress/common/progress';
|
|
20
|
+
import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
19
21
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
20
22
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
21
23
|
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
24
|
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
24
25
|
import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
25
26
|
import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
26
|
-
import { normalizeSerializableChatData, ChatModel, updateRanges, toChatHistoryContent, ChatRequestModel } from '@codingame/monaco-vscode-
|
|
27
|
-
import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, chatSubcommandLeader, chatAgentLeader, ChatRequestSlashCommandPart, getPromptText } from '@codingame/monaco-vscode-
|
|
28
|
-
import { ChatRequestParser } from '@codingame/monaco-vscode-
|
|
27
|
+
import { normalizeSerializableChatData, ChatModel, ChatRequestRemovalReason, updateRanges, toChatHistoryContent, ChatRequestModel } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
28
|
+
import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, chatSubcommandLeader, chatAgentLeader, ChatRequestSlashCommandPart, getPromptText } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
29
|
+
import { ChatRequestParser } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
|
|
29
30
|
import { ChatServiceTelemetry } from './chatServiceTelemetry.js';
|
|
30
31
|
import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
|
|
31
32
|
import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
|
|
33
|
+
import { ChatMessageRole } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModels';
|
|
32
34
|
|
|
33
35
|
const serializedChatKey = 'interactive.sessions';
|
|
34
36
|
const globalChatKey = 'chat.workspaceTransfer';
|
|
@@ -50,7 +52,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
50
52
|
get transferredSessionData() {
|
|
51
53
|
return this._transferredSessionData;
|
|
52
54
|
}
|
|
53
|
-
constructor(storageService, logService, extensionService, instantiationService, telemetryService, workspaceContextService, chatSlashCommandService, chatVariablesService, chatAgentService,
|
|
55
|
+
constructor(storageService, logService, extensionService, instantiationService, telemetryService, workspaceContextService, chatSlashCommandService, chatVariablesService, chatAgentService, configurationService) {
|
|
54
56
|
super();
|
|
55
57
|
this.storageService = storageService;
|
|
56
58
|
this.logService = logService;
|
|
@@ -62,20 +64,20 @@ let ChatService = class ChatService extends Disposable {
|
|
|
62
64
|
this.chatVariablesService = chatVariablesService;
|
|
63
65
|
this.chatAgentService = chatAgentService;
|
|
64
66
|
this.configurationService = configurationService;
|
|
65
|
-
this._sessionModels = this._register((
|
|
66
|
-
this._pendingRequests = this._register((
|
|
67
|
-
this._deletedChatIds = (
|
|
68
|
-
this._onDidPerformUserAction = this._register((
|
|
67
|
+
this._sessionModels = this._register(( new DisposableMap()));
|
|
68
|
+
this._pendingRequests = this._register(( new DisposableMap()));
|
|
69
|
+
this._deletedChatIds = ( new Set());
|
|
70
|
+
this._onDidPerformUserAction = this._register(( new Emitter()));
|
|
69
71
|
this.onDidPerformUserAction = this._onDidPerformUserAction.event;
|
|
70
|
-
this._onDidDisposeSession = this._register((
|
|
72
|
+
this._onDidDisposeSession = this._register(( new Emitter()));
|
|
71
73
|
this.onDidDisposeSession = this._onDidDisposeSession.event;
|
|
72
|
-
this._sessionFollowupCancelTokens = this._register((
|
|
74
|
+
this._sessionFollowupCancelTokens = this._register(( new DisposableMap()));
|
|
73
75
|
this._chatServiceTelemetry = this.instantiationService.createInstance(ChatServiceTelemetry);
|
|
74
76
|
const isEmptyWindow = !workspaceContextService.getWorkspace().folders.length;
|
|
75
|
-
const sessionData = storageService.get(serializedChatKey, isEmptyWindow ?
|
|
77
|
+
const sessionData = storageService.get(serializedChatKey, isEmptyWindow ? StorageScope.APPLICATION : StorageScope.WORKSPACE, '');
|
|
76
78
|
if (sessionData) {
|
|
77
79
|
this._persistedSessions = this.deserializeChats(sessionData);
|
|
78
|
-
const countsForLog = (
|
|
80
|
+
const countsForLog = ( Object.keys(this._persistedSessions)).length;
|
|
79
81
|
if (countsForLog > 0) {
|
|
80
82
|
this.trace('constructor', `Restored ${countsForLog} persisted sessions`);
|
|
81
83
|
}
|
|
@@ -96,8 +98,8 @@ let ChatService = class ChatService extends Disposable {
|
|
|
96
98
|
return this.chatAgentService.getContributedDefaultAgent(location) !== undefined;
|
|
97
99
|
}
|
|
98
100
|
saveState() {
|
|
99
|
-
const liveChats = Array.from((
|
|
100
|
-
.filter(session => session.initialLocation === ChatAgentLocation.Panel)
|
|
101
|
+
const liveChats = Array.from(( this._sessionModels.values()))
|
|
102
|
+
.filter(session => session.initialLocation === ChatAgentLocation.Panel || session.initialLocation === ChatAgentLocation.EditingSession)
|
|
101
103
|
.filter(session => session.getRequests().length > 0);
|
|
102
104
|
const isEmptyWindow = !this.workspaceContextService.getWorkspace().folders.length;
|
|
103
105
|
if (isEmptyWindow) {
|
|
@@ -105,8 +107,8 @@ let ChatService = class ChatService extends Disposable {
|
|
|
105
107
|
}
|
|
106
108
|
else {
|
|
107
109
|
let allSessions = liveChats;
|
|
108
|
-
allSessions = allSessions.concat((
|
|
109
|
-
.filter(session => !(
|
|
110
|
+
allSessions = allSessions.concat(( Object.values(this._persistedSessions))
|
|
111
|
+
.filter(session => !( this._sessionModels.has(session.sessionId)))
|
|
110
112
|
.filter(session => session.requests.length));
|
|
111
113
|
allSessions.sort((a, b) => (b.creationDate ?? 0) - (a.creationDate ?? 0));
|
|
112
114
|
allSessions = allSessions.slice(0, maxPersistedSessions);
|
|
@@ -117,17 +119,17 @@ let ChatService = class ChatService extends Disposable {
|
|
|
117
119
|
if (allSessions.length) {
|
|
118
120
|
this.trace('onWillSaveState', `Persisting ${serialized.length} chars`);
|
|
119
121
|
}
|
|
120
|
-
this.storageService.store(serializedChatKey, serialized,
|
|
122
|
+
this.storageService.store(serializedChatKey, serialized, StorageScope.WORKSPACE, StorageTarget.MACHINE);
|
|
121
123
|
}
|
|
122
124
|
this._deletedChatIds.clear();
|
|
123
125
|
}
|
|
124
126
|
syncEmptyWindowChats(thisWindowChats) {
|
|
125
|
-
const sessionData = this.storageService.get(serializedChatKey,
|
|
127
|
+
const sessionData = this.storageService.get(serializedChatKey, StorageScope.APPLICATION, '');
|
|
126
128
|
const originalPersistedSessions = this._persistedSessions;
|
|
127
129
|
let persistedSessions;
|
|
128
130
|
if (sessionData) {
|
|
129
131
|
persistedSessions = this.deserializeChats(sessionData);
|
|
130
|
-
const countsForLog = (
|
|
132
|
+
const countsForLog = ( Object.keys(persistedSessions)).length;
|
|
131
133
|
if (countsForLog > 0) {
|
|
132
134
|
this.trace('constructor', `Restored ${countsForLog} persisted sessions`);
|
|
133
135
|
}
|
|
@@ -136,7 +138,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
136
138
|
persistedSessions = {};
|
|
137
139
|
}
|
|
138
140
|
this._deletedChatIds.forEach(id => delete persistedSessions[id]);
|
|
139
|
-
(
|
|
141
|
+
( Object.values(originalPersistedSessions)).forEach(session => {
|
|
140
142
|
const persistedSession = persistedSessions[session.sessionId];
|
|
141
143
|
if (persistedSession && session.requests.length > persistedSession.requests.length) {
|
|
142
144
|
persistedSessions[session.sessionId] = session;
|
|
@@ -151,11 +153,11 @@ let ChatService = class ChatService extends Disposable {
|
|
|
151
153
|
for (const chat of thisWindowChats) {
|
|
152
154
|
allSessions[chat.sessionId] = chat;
|
|
153
155
|
}
|
|
154
|
-
let sessionsList = (
|
|
156
|
+
let sessionsList = ( Object.values(allSessions));
|
|
155
157
|
sessionsList.sort((a, b) => (b.creationDate ?? 0) - (a.creationDate ?? 0));
|
|
156
158
|
sessionsList = sessionsList.slice(0, maxPersistedSessions);
|
|
157
159
|
const data = JSON.stringify(sessionsList);
|
|
158
|
-
this.storageService.store(serializedChatKey, data,
|
|
160
|
+
this.storageService.store(serializedChatKey, data, StorageScope.APPLICATION, StorageTarget.MACHINE);
|
|
159
161
|
}
|
|
160
162
|
notifyUserAction(action) {
|
|
161
163
|
this._chatServiceTelemetry.notifyUserAction(action);
|
|
@@ -187,22 +189,20 @@ let ChatService = class ChatService extends Disposable {
|
|
|
187
189
|
try {
|
|
188
190
|
const arrayOfSessions = revive(JSON.parse(sessionData));
|
|
189
191
|
if (!Array.isArray(arrayOfSessions)) {
|
|
190
|
-
throw (
|
|
192
|
+
throw ( new Error('Expected array'));
|
|
191
193
|
}
|
|
192
194
|
const sessions = arrayOfSessions.reduce((acc, session) => {
|
|
193
195
|
for (const request of session.requests) {
|
|
194
196
|
if (Array.isArray(request.response)) {
|
|
195
|
-
request.response = (
|
|
197
|
+
request.response = ( request.response.map((response) => {
|
|
196
198
|
if (typeof response === 'string') {
|
|
197
|
-
return (
|
|
198
|
-
(new MarkdownString(response))
|
|
199
|
-
);
|
|
199
|
+
return ( new MarkdownString(response));
|
|
200
200
|
}
|
|
201
201
|
return response;
|
|
202
|
-
}))
|
|
202
|
+
}));
|
|
203
203
|
}
|
|
204
204
|
else if (typeof request.response === 'string') {
|
|
205
|
-
request.response = [(
|
|
205
|
+
request.response = [( new MarkdownString(request.response))];
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
acc[session.sessionId] = normalizeSerializableChatData(session);
|
|
@@ -216,23 +216,23 @@ let ChatService = class ChatService extends Disposable {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
getTransferredSessionData() {
|
|
219
|
-
const data = this.storageService.getObject(globalChatKey,
|
|
219
|
+
const data = this.storageService.getObject(globalChatKey, StorageScope.PROFILE, []);
|
|
220
220
|
const workspaceUri = this.workspaceContextService.getWorkspace().folders[0]?.uri;
|
|
221
221
|
if (!workspaceUri) {
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
|
-
const thisWorkspace = (
|
|
224
|
+
const thisWorkspace = ( workspaceUri.toString());
|
|
225
225
|
const currentTime = Date.now();
|
|
226
|
-
const transferred = data.find(item => (
|
|
227
|
-
const filtered = data.filter(item => (
|
|
228
|
-
this.storageService.store(globalChatKey, JSON.stringify(filtered),
|
|
226
|
+
const transferred = data.find(item => ( URI.revive(item.toWorkspace).toString()) === thisWorkspace && (currentTime - item.timestampInMilliseconds < SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS));
|
|
227
|
+
const filtered = data.filter(item => ( URI.revive(item.toWorkspace).toString()) !== thisWorkspace && (currentTime - item.timestampInMilliseconds < SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS));
|
|
228
|
+
this.storageService.store(globalChatKey, JSON.stringify(filtered), StorageScope.PROFILE, StorageTarget.MACHINE);
|
|
229
229
|
return transferred;
|
|
230
230
|
}
|
|
231
231
|
getHistory() {
|
|
232
|
-
const persistedSessions = (
|
|
232
|
+
const persistedSessions = ( Object.values(this._persistedSessions))
|
|
233
233
|
.filter(session => session.requests.length > 0)
|
|
234
|
-
.filter(session => !(
|
|
235
|
-
const persistedSessionItems = (
|
|
234
|
+
.filter(session => !( this._sessionModels.has(session.sessionId)));
|
|
235
|
+
const persistedSessionItems = ( persistedSessions
|
|
236
236
|
.filter(session => !session.isImported && session.initialLocation !== ChatAgentLocation.EditingSession)
|
|
237
237
|
.map(session => {
|
|
238
238
|
const title = session.customTitle ?? ChatModel.getDefaultTitle(session.requests);
|
|
@@ -242,18 +242,18 @@ let ChatService = class ChatService extends Disposable {
|
|
|
242
242
|
lastMessageDate: session.lastMessageDate,
|
|
243
243
|
isActive: false,
|
|
244
244
|
};
|
|
245
|
-
}))
|
|
246
|
-
const liveSessionItems = (
|
|
245
|
+
}));
|
|
246
|
+
const liveSessionItems = ( Array.from(( this._sessionModels.values()))
|
|
247
247
|
.filter(session => !session.isImported && session.initialLocation !== ChatAgentLocation.EditingSession)
|
|
248
248
|
.map(session => {
|
|
249
|
-
const title = session.title || ( localize(
|
|
249
|
+
const title = session.title || ( localize(4617, "New Chat"));
|
|
250
250
|
return {
|
|
251
251
|
sessionId: session.sessionId,
|
|
252
252
|
title,
|
|
253
253
|
lastMessageDate: session.lastMessageDate,
|
|
254
254
|
isActive: true,
|
|
255
255
|
};
|
|
256
|
-
}))
|
|
256
|
+
}));
|
|
257
257
|
return [...liveSessionItems, ...persistedSessionItems];
|
|
258
258
|
}
|
|
259
259
|
removeHistoryEntry(sessionId) {
|
|
@@ -264,7 +264,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
clearAllHistoryEntries() {
|
|
267
|
-
(
|
|
267
|
+
( Object.values(this._persistedSessions)).forEach(session => this._deletedChatIds.add(session.sessionId));
|
|
268
268
|
this._persistedSessions = {};
|
|
269
269
|
this.saveState();
|
|
270
270
|
}
|
|
@@ -285,12 +285,12 @@ let ChatService = class ChatService extends Disposable {
|
|
|
285
285
|
await this.extensionService.whenInstalledExtensionsRegistered();
|
|
286
286
|
const defaultAgentData = this.chatAgentService.getContributedDefaultAgent(model.initialLocation) ?? this.chatAgentService.getContributedDefaultAgent(ChatAgentLocation.Panel);
|
|
287
287
|
if (!defaultAgentData) {
|
|
288
|
-
throw (
|
|
288
|
+
throw ( new ErrorNoTelemetry('No default agent contributed'));
|
|
289
289
|
}
|
|
290
290
|
await this.extensionService.activateByEvent(`onChatParticipant:${defaultAgentData.id}`);
|
|
291
291
|
const defaultAgent = this.chatAgentService.getActivatedAgents().find(agent => agent.id === defaultAgentData.id);
|
|
292
292
|
if (!defaultAgent) {
|
|
293
|
-
throw (
|
|
293
|
+
throw ( new ErrorNoTelemetry('No default agent registered'));
|
|
294
294
|
}
|
|
295
295
|
const welcomeMessage = (await defaultAgent.provideWelcomeMessage?.(token)) ?? undefined;
|
|
296
296
|
const sampleQuestions = (await defaultAgent.provideSampleQuestions?.(model.initialLocation, token)) ?? undefined;
|
|
@@ -327,7 +327,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
327
327
|
async resendRequest(request, options) {
|
|
328
328
|
const model = this._sessionModels.get(request.session.sessionId);
|
|
329
329
|
if (!model && model !== request.session) {
|
|
330
|
-
throw (
|
|
330
|
+
throw ( new Error(`Unknown session: ${request.session.sessionId}`));
|
|
331
331
|
}
|
|
332
332
|
await model.waitForInitialization();
|
|
333
333
|
const cts = this._pendingRequests.get(request.session.sessionId);
|
|
@@ -339,7 +339,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
339
339
|
const attempt = options?.attempt ?? 0;
|
|
340
340
|
const enableCommandDetection = !options?.noCommandDetection;
|
|
341
341
|
const defaultAgent = this.chatAgentService.getDefaultAgent(location);
|
|
342
|
-
model.removeRequest(request.id,
|
|
342
|
+
model.removeRequest(request.id, ChatRequestRemovalReason.Resend);
|
|
343
343
|
const resendOptions = {
|
|
344
344
|
...options,
|
|
345
345
|
locationData: request.locationData,
|
|
@@ -356,10 +356,10 @@ let ChatService = class ChatService extends Disposable {
|
|
|
356
356
|
}
|
|
357
357
|
const model = this._sessionModels.get(sessionId);
|
|
358
358
|
if (!model) {
|
|
359
|
-
throw (
|
|
359
|
+
throw ( new Error(`Unknown session: ${sessionId}`));
|
|
360
360
|
}
|
|
361
361
|
await model.waitForInitialization();
|
|
362
|
-
if ((
|
|
362
|
+
if (( this._pendingRequests.has(sessionId))) {
|
|
363
363
|
this.trace('sendRequest', `Session ${sessionId} already has a pending request`);
|
|
364
364
|
return;
|
|
365
365
|
}
|
|
@@ -380,7 +380,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
380
380
|
if (options?.agentId) {
|
|
381
381
|
const agent = this.chatAgentService.getAgent(options.agentId);
|
|
382
382
|
if (!agent) {
|
|
383
|
-
throw (
|
|
383
|
+
throw ( new Error(`Unknown agent: ${options.agentId}`));
|
|
384
384
|
}
|
|
385
385
|
parserContext = { selectedAgent: agent };
|
|
386
386
|
const commandPart = options.slashCommand ? ` ${chatSubcommandLeader}${options.slashCommand}` : '';
|
|
@@ -391,7 +391,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
391
391
|
}
|
|
392
392
|
refreshFollowupsCancellationToken(sessionId) {
|
|
393
393
|
this._sessionFollowupCancelTokens.get(sessionId)?.cancel();
|
|
394
|
-
const newTokenSource = (
|
|
394
|
+
const newTokenSource = ( new CancellationTokenSource());
|
|
395
395
|
this._sessionFollowupCancelTokens.set(sessionId, newTokenSource);
|
|
396
396
|
return newTokenSource.token;
|
|
397
397
|
}
|
|
@@ -401,10 +401,10 @@ let ChatService = class ChatService extends Disposable {
|
|
|
401
401
|
const agentPart = 'kind' in parsedRequest ? undefined : parsedRequest.parts.find((r) => r instanceof ChatRequestAgentPart);
|
|
402
402
|
const agentSlashCommandPart = 'kind' in parsedRequest ? undefined : parsedRequest.parts.find((r) => r instanceof ChatRequestAgentSubcommandPart);
|
|
403
403
|
const commandPart = 'kind' in parsedRequest ? undefined : parsedRequest.parts.find((r) => r instanceof ChatRequestSlashCommandPart);
|
|
404
|
-
const requests = [...model.getRequests(
|
|
404
|
+
const requests = [...model.getRequests()];
|
|
405
405
|
let gotProgress = false;
|
|
406
406
|
const requestType = commandPart ? 'slashCommand' : 'string';
|
|
407
|
-
const responseCreated = (
|
|
407
|
+
const responseCreated = ( new DeferredPromise());
|
|
408
408
|
let responseCreatedComplete = false;
|
|
409
409
|
function completeResponseCreated() {
|
|
410
410
|
if (!responseCreatedComplete && request?.response) {
|
|
@@ -412,7 +412,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
412
412
|
responseCreatedComplete = true;
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
-
const source = (
|
|
415
|
+
const source = ( new CancellationTokenSource());
|
|
416
416
|
const token = source.token;
|
|
417
417
|
const sendRequestInternal = async () => {
|
|
418
418
|
const progressCallback = (progress) => {
|
|
@@ -431,7 +431,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
431
431
|
};
|
|
432
432
|
let detectedAgent;
|
|
433
433
|
let detectedCommand;
|
|
434
|
-
const stopWatch = (
|
|
434
|
+
const stopWatch = ( new StopWatch(false));
|
|
435
435
|
const listener = token.onCancellationRequested(() => {
|
|
436
436
|
this.trace('sendRequest', `Request for session ${model.sessionId} was cancelled`);
|
|
437
437
|
this.telemetryService.publicLog2('interactiveSessionProviderInvoked', {
|
|
@@ -439,15 +439,16 @@ let ChatService = class ChatService extends Disposable {
|
|
|
439
439
|
totalTime: stopWatch.elapsed(),
|
|
440
440
|
result: 'cancelled',
|
|
441
441
|
requestType,
|
|
442
|
-
agent: agentPart?.agent.id ?? '',
|
|
443
|
-
agentExtensionId: agentPart?.agent.extensionId.value ?? '',
|
|
442
|
+
agent: detectedAgent?.id ?? agentPart?.agent.id ?? '',
|
|
443
|
+
agentExtensionId: detectedAgent?.extensionId.value ?? agentPart?.agent.extensionId.value ?? '',
|
|
444
444
|
slashCommand: agentSlashCommandPart ? agentSlashCommandPart.command.name : commandPart?.slashCommand.command,
|
|
445
445
|
chatSessionId: model.sessionId,
|
|
446
446
|
location,
|
|
447
447
|
citations: request?.response?.codeCitations.length ?? 0,
|
|
448
448
|
numCodeBlocks: getCodeBlocks(request.response?.response.toString() ?? '').length,
|
|
449
449
|
isParticipantDetected: !!detectedAgent,
|
|
450
|
-
enableCommandDetection
|
|
450
|
+
enableCommandDetection,
|
|
451
|
+
attachmentKinds: this.attachmentKindsForTelemetry(request.variableData)
|
|
451
452
|
});
|
|
452
453
|
model.cancelRequest(request);
|
|
453
454
|
});
|
|
@@ -494,7 +495,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
494
495
|
userSelectedModelId: options?.userSelectedModelId
|
|
495
496
|
};
|
|
496
497
|
};
|
|
497
|
-
if (this.configurationService.getValue('chat.
|
|
498
|
+
if (this.configurationService.getValue('chat.detectParticipant.enabled') !== false && this.chatAgentService.hasChatParticipantDetectionProviders() && !agentPart && !commandPart && enableCommandDetection) {
|
|
498
499
|
const defaultAgentHistory = this.getHistoryEntriesFromModel(requests, model.sessionId, location, defaultAgent.id);
|
|
499
500
|
const chatAgentRequest = await prepareChatAgentRequest(defaultAgent, agentSlashCommandPart?.command, enableCommandDetection, undefined, false);
|
|
500
501
|
const result = await this.chatAgentService.detectAgentOrCommand(chatAgentRequest, defaultAgentHistory, { location }, token);
|
|
@@ -517,28 +518,28 @@ let ChatService = class ChatService extends Disposable {
|
|
|
517
518
|
const agentResult = await this.chatAgentService.invokeAgent(agent.id, requestProps, progressCallback, history, token);
|
|
518
519
|
rawResult = agentResult;
|
|
519
520
|
agentOrCommandFollowups = this.chatAgentService.getFollowups(agent.id, requestProps, agentResult, history, followupsCancelToken);
|
|
520
|
-
chatTitlePromise = model.getRequests(
|
|
521
|
+
chatTitlePromise = model.getRequests().length === 1 && !model.customTitle ? this.chatAgentService.getChatTitle(defaultAgent.id, this.getHistoryEntriesFromModel(model.getRequests(), model.sessionId, location, agent.id), CancellationToken.None) : undefined;
|
|
521
522
|
}
|
|
522
523
|
else if (commandPart && this.chatSlashCommandService.hasCommand(commandPart.slashCommand.command)) {
|
|
523
524
|
request = model.addRequest(parsedRequest, { variables: [] }, attempt);
|
|
524
525
|
completeResponseCreated();
|
|
525
526
|
const history = [];
|
|
526
|
-
for (const request of model.getRequests(
|
|
527
|
+
for (const request of model.getRequests()) {
|
|
527
528
|
if (!request.response) {
|
|
528
529
|
continue;
|
|
529
530
|
}
|
|
530
|
-
history.push({ role:
|
|
531
|
-
history.push({ role:
|
|
531
|
+
history.push({ role: ChatMessageRole.User, content: [{ type: 'text', value: request.message.text }] });
|
|
532
|
+
history.push({ role: ChatMessageRole.Assistant, content: [{ type: 'text', value: ( request.response.response.toString()) }] });
|
|
532
533
|
}
|
|
533
534
|
const message = parsedRequest.text;
|
|
534
|
-
const commandResult = await this.chatSlashCommandService.executeCommand(commandPart.slashCommand.command, message.substring(commandPart.slashCommand.command.length + 1).trimStart(), (
|
|
535
|
+
const commandResult = await this.chatSlashCommandService.executeCommand(commandPart.slashCommand.command, message.substring(commandPart.slashCommand.command.length + 1).trimStart(), ( new Progress(p => {
|
|
535
536
|
progressCallback(p);
|
|
536
|
-
}))
|
|
537
|
+
})), history, location, token);
|
|
537
538
|
agentOrCommandFollowups = Promise.resolve(commandResult?.followUp);
|
|
538
539
|
rawResult = {};
|
|
539
540
|
}
|
|
540
541
|
else {
|
|
541
|
-
throw (
|
|
542
|
+
throw ( new Error(`Cannot handle request`));
|
|
542
543
|
}
|
|
543
544
|
if (token.isCancellationRequested) {
|
|
544
545
|
return;
|
|
@@ -546,7 +547,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
546
547
|
else {
|
|
547
548
|
if (!rawResult) {
|
|
548
549
|
this.trace('sendRequest', `Provider returned no response for session ${model.sessionId}`);
|
|
549
|
-
rawResult = { errorDetails: { message: ( localize(
|
|
550
|
+
rawResult = { errorDetails: { message: ( localize(4618, "Provider returned null response")) } };
|
|
550
551
|
}
|
|
551
552
|
const result = rawResult.errorDetails?.responseIsFiltered ? 'filtered' :
|
|
552
553
|
rawResult.errorDetails && gotProgress ? 'errorWithOutput' :
|
|
@@ -558,15 +559,16 @@ let ChatService = class ChatService extends Disposable {
|
|
|
558
559
|
totalTime: rawResult.timings?.totalElapsed,
|
|
559
560
|
result,
|
|
560
561
|
requestType,
|
|
561
|
-
agent: agentPart?.agent.id ?? '',
|
|
562
|
-
agentExtensionId: agentPart?.agent.extensionId.value ?? '',
|
|
562
|
+
agent: detectedAgent?.id ?? agentPart?.agent.id ?? '',
|
|
563
|
+
agentExtensionId: detectedAgent?.extensionId.value ?? agentPart?.agent.extensionId.value ?? '',
|
|
563
564
|
slashCommand: commandForTelemetry,
|
|
564
565
|
chatSessionId: model.sessionId,
|
|
565
566
|
enableCommandDetection,
|
|
566
567
|
isParticipantDetected: !!detectedAgent,
|
|
567
568
|
location,
|
|
568
569
|
citations: request.response?.codeCitations.length ?? 0,
|
|
569
|
-
numCodeBlocks: getCodeBlocks(request.response?.response.toString() ?? '').length
|
|
570
|
+
numCodeBlocks: getCodeBlocks(request.response?.response.toString() ?? '').length,
|
|
571
|
+
attachmentKinds: this.attachmentKindsForTelemetry(request.variableData)
|
|
570
572
|
});
|
|
571
573
|
model.setResponse(request, rawResult);
|
|
572
574
|
completeResponseCreated();
|
|
@@ -592,15 +594,16 @@ let ChatService = class ChatService extends Disposable {
|
|
|
592
594
|
totalTime: undefined,
|
|
593
595
|
result,
|
|
594
596
|
requestType,
|
|
595
|
-
agent: agentPart?.agent.id ?? '',
|
|
596
|
-
agentExtensionId: agentPart?.agent.extensionId.value ?? '',
|
|
597
|
+
agent: detectedAgent?.id ?? agentPart?.agent.id ?? '',
|
|
598
|
+
agentExtensionId: detectedAgent?.extensionId.value ?? agentPart?.agent.extensionId.value ?? '',
|
|
597
599
|
slashCommand: agentSlashCommandPart ? agentSlashCommandPart.command.name : commandPart?.slashCommand.command,
|
|
598
600
|
chatSessionId: model.sessionId,
|
|
599
601
|
location,
|
|
600
602
|
citations: 0,
|
|
601
603
|
numCodeBlocks: 0,
|
|
602
604
|
enableCommandDetection,
|
|
603
|
-
isParticipantDetected: !!detectedAgent
|
|
605
|
+
isParticipantDetected: !!detectedAgent,
|
|
606
|
+
attachmentKinds: this.attachmentKindsForTelemetry(request.variableData)
|
|
604
607
|
});
|
|
605
608
|
this.logService.error(`Error while handling chat request: ${toErrorMessage(err, true)}`);
|
|
606
609
|
if (request) {
|
|
@@ -615,7 +618,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
615
618
|
}
|
|
616
619
|
};
|
|
617
620
|
const rawResponsePromise = sendRequestInternal();
|
|
618
|
-
this._pendingRequests.set(model.sessionId, (
|
|
621
|
+
this._pendingRequests.set(model.sessionId, ( new CancellableRequest(source)));
|
|
619
622
|
rawResponsePromise.finally(() => {
|
|
620
623
|
this._pendingRequests.deleteAndDispose(model.sessionId);
|
|
621
624
|
});
|
|
@@ -624,6 +627,53 @@ let ChatService = class ChatService extends Disposable {
|
|
|
624
627
|
responseCompletePromise: rawResponsePromise,
|
|
625
628
|
};
|
|
626
629
|
}
|
|
630
|
+
attachmentKindsForTelemetry(variableData) {
|
|
631
|
+
return ( variableData.variables.map(v => {
|
|
632
|
+
if (v.kind === 'implicit') {
|
|
633
|
+
return 'implicit';
|
|
634
|
+
}
|
|
635
|
+
else if (v.range) {
|
|
636
|
+
if (v.isTool) {
|
|
637
|
+
return 'toolInPrompt';
|
|
638
|
+
}
|
|
639
|
+
else if (v.isDynamic) {
|
|
640
|
+
return 'fileInPrompt';
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
return 'variableInPrompt';
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
else if (v.kind === 'command') {
|
|
647
|
+
return 'command';
|
|
648
|
+
}
|
|
649
|
+
else if (v.kind === 'symbol') {
|
|
650
|
+
return 'symbol';
|
|
651
|
+
}
|
|
652
|
+
else if (v.isImage) {
|
|
653
|
+
return 'image';
|
|
654
|
+
}
|
|
655
|
+
else if (v.isDirectory) {
|
|
656
|
+
return 'directory';
|
|
657
|
+
}
|
|
658
|
+
else if (v.isTool) {
|
|
659
|
+
return 'tool';
|
|
660
|
+
}
|
|
661
|
+
else if (v.isDynamic) {
|
|
662
|
+
if (URI.isUri(v.value)) {
|
|
663
|
+
return 'file';
|
|
664
|
+
}
|
|
665
|
+
else if (isLocation(v.value)) {
|
|
666
|
+
return 'location';
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
return 'otherAttachment';
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
return 'variableAttachment';
|
|
674
|
+
}
|
|
675
|
+
}));
|
|
676
|
+
}
|
|
627
677
|
getHistoryEntriesFromModel(requests, sessionId, location, forAgentId) {
|
|
628
678
|
const history = [];
|
|
629
679
|
for (const request of requests) {
|
|
@@ -651,7 +701,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
651
701
|
async removeRequest(sessionId, requestId) {
|
|
652
702
|
const model = this._sessionModels.get(sessionId);
|
|
653
703
|
if (!model) {
|
|
654
|
-
throw (
|
|
704
|
+
throw ( new Error(`Unknown session: ${sessionId}`));
|
|
655
705
|
}
|
|
656
706
|
await model.waitForInitialization();
|
|
657
707
|
const pendingRequest = this._pendingRequests.get(sessionId);
|
|
@@ -663,11 +713,11 @@ let ChatService = class ChatService extends Disposable {
|
|
|
663
713
|
}
|
|
664
714
|
async adoptRequest(sessionId, request) {
|
|
665
715
|
if (!(request instanceof ChatRequestModel)) {
|
|
666
|
-
throw (
|
|
716
|
+
throw ( new TypeError('Can only adopt requests of type ChatRequestModel'));
|
|
667
717
|
}
|
|
668
718
|
const target = this._sessionModels.get(sessionId);
|
|
669
719
|
if (!target) {
|
|
670
|
-
throw (
|
|
720
|
+
throw ( new Error(`Unknown session: ${sessionId}`));
|
|
671
721
|
}
|
|
672
722
|
await target.waitForInitialization();
|
|
673
723
|
const oldOwner = request.session;
|
|
@@ -684,7 +734,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
684
734
|
this.trace('addCompleteRequest', `message: ${message}`);
|
|
685
735
|
const model = this._sessionModels.get(sessionId);
|
|
686
736
|
if (!model) {
|
|
687
|
-
throw (
|
|
737
|
+
throw ( new Error(`Unknown session: ${sessionId}`));
|
|
688
738
|
}
|
|
689
739
|
await model.waitForInitialization();
|
|
690
740
|
const parsedRequest = typeof message === 'string' ?
|
|
@@ -692,7 +742,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
692
742
|
message;
|
|
693
743
|
const request = model.addRequest(parsedRequest, variableData || { variables: [] }, attempt ?? 0, undefined, undefined, undefined, undefined, undefined, undefined, true);
|
|
694
744
|
if (typeof response.message === 'string') {
|
|
695
|
-
model.acceptResponseProgress(request, { content: (
|
|
745
|
+
model.acceptResponseProgress(request, { content: ( new MarkdownString(response.message)), kind: 'markdownContent' });
|
|
696
746
|
}
|
|
697
747
|
else {
|
|
698
748
|
for (const part of response.message) {
|
|
@@ -714,7 +764,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
714
764
|
this.trace('clearSession', `sessionId: ${sessionId}`);
|
|
715
765
|
const model = this._sessionModels.get(sessionId);
|
|
716
766
|
if (!model) {
|
|
717
|
-
throw (
|
|
767
|
+
throw ( new Error(`Unknown session: ${sessionId}`));
|
|
718
768
|
}
|
|
719
769
|
if (model.initialLocation === ChatAgentLocation.Panel) {
|
|
720
770
|
const sessionData = JSON.parse(JSON.stringify(model));
|
|
@@ -727,40 +777,38 @@ let ChatService = class ChatService extends Disposable {
|
|
|
727
777
|
this._onDidDisposeSession.fire({ sessionId, reason: 'cleared' });
|
|
728
778
|
}
|
|
729
779
|
hasSessions() {
|
|
730
|
-
return
|
|
780
|
+
return ( Object.values(this._persistedSessions)).length > 0;
|
|
731
781
|
}
|
|
732
782
|
transferChatSession(transferredSessionData, toWorkspace) {
|
|
733
|
-
const model = Iterable.find((
|
|
783
|
+
const model = Iterable.find(( this._sessionModels.values()), model => model.sessionId === transferredSessionData.sessionId);
|
|
734
784
|
if (!model) {
|
|
735
|
-
throw (
|
|
785
|
+
throw ( new Error(
|
|
736
786
|
`Failed to transfer session. Unknown session ID: ${transferredSessionData.sessionId}`
|
|
737
|
-
))
|
|
787
|
+
));
|
|
738
788
|
}
|
|
739
|
-
const existingRaw = this.storageService.getObject(globalChatKey,
|
|
789
|
+
const existingRaw = this.storageService.getObject(globalChatKey, StorageScope.PROFILE, []);
|
|
740
790
|
existingRaw.push({
|
|
741
791
|
chat: model.toJSON(),
|
|
742
792
|
timestampInMilliseconds: Date.now(),
|
|
743
793
|
toWorkspace: toWorkspace,
|
|
744
794
|
inputValue: transferredSessionData.inputValue,
|
|
745
795
|
});
|
|
746
|
-
this.storageService.store(globalChatKey, JSON.stringify(existingRaw),
|
|
747
|
-
this.trace('transferChatSession', `Transferred session ${model.sessionId} to workspace ${(
|
|
796
|
+
this.storageService.store(globalChatKey, JSON.stringify(existingRaw), StorageScope.PROFILE, StorageTarget.MACHINE);
|
|
797
|
+
this.trace('transferChatSession', `Transferred session ${model.sessionId} to workspace ${( toWorkspace.toString())}`);
|
|
748
798
|
}
|
|
749
799
|
};
|
|
750
|
-
ChatService = (
|
|
751
|
-
(
|
|
752
|
-
(
|
|
753
|
-
(
|
|
754
|
-
(
|
|
755
|
-
(
|
|
756
|
-
(
|
|
757
|
-
(
|
|
758
|
-
(
|
|
759
|
-
(
|
|
760
|
-
(
|
|
761
|
-
|
|
762
|
-
( (__param(11, IConfigurationService)))
|
|
763
|
-
], ChatService)));
|
|
800
|
+
ChatService = ( __decorate([
|
|
801
|
+
( __param(0, IStorageService)),
|
|
802
|
+
( __param(1, ILogService)),
|
|
803
|
+
( __param(2, IExtensionService)),
|
|
804
|
+
( __param(3, IInstantiationService)),
|
|
805
|
+
( __param(4, ITelemetryService)),
|
|
806
|
+
( __param(5, IWorkspaceContextService)),
|
|
807
|
+
( __param(6, IChatSlashCommandService)),
|
|
808
|
+
( __param(7, IChatVariablesService)),
|
|
809
|
+
( __param(8, IChatAgentService)),
|
|
810
|
+
( __param(9, IConfigurationService))
|
|
811
|
+
], ChatService));
|
|
764
812
|
function getCodeBlocks(text) {
|
|
765
813
|
const lines = text.split('\n');
|
|
766
814
|
const codeBlockLanguages = [];
|
|
@@ -768,7 +816,7 @@ function getCodeBlocks(text) {
|
|
|
768
816
|
for (let i = 0; i < lines.length; i++) {
|
|
769
817
|
const line = lines[i];
|
|
770
818
|
if (codeBlockState) {
|
|
771
|
-
if ((
|
|
819
|
+
if (( new RegExp(`^\\s*${codeBlockState.delimiter}\\s*$`)).test(line)) {
|
|
772
820
|
codeBlockLanguages.push(codeBlockState.languageId);
|
|
773
821
|
codeBlockState = undefined;
|
|
774
822
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ITelemetryService } from "vscode/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
2
|
+
import { IChatUserActionEvent } from "vscode/vscode/vs/workbench/contrib/chat/common/chatService";
|
|
3
|
+
export declare class ChatServiceTelemetry {
|
|
4
|
+
private readonly telemetryService;
|
|
5
|
+
constructor(telemetryService: ITelemetryService);
|
|
6
|
+
notifyUserAction(action: IChatUserActionEvent): void;
|
|
7
|
+
retrievedFollowups(agentId: string, command: string | undefined, numFollowups: number): void;
|
|
8
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
3
4
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
4
5
|
import { ChatAgentVoteDirection, ChatCopyKind } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
|