@codingame/monaco-vscode-chat-service-override 4.5.1 → 4.5.2
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/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +6 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +26 -39
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +5 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +3 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +9 -28
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +19 -34
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +35 -58
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +57 -100
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +66 -69
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +96 -93
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +4 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +35 -34
|
@@ -33,6 +33,7 @@ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/c
|
|
|
33
33
|
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
34
34
|
import Severity$1 from 'vscode/vscode/vs/base/common/severity';
|
|
35
35
|
|
|
36
|
+
const _moduleId = "vs/workbench/contrib/chat/common/chatServiceImpl";
|
|
36
37
|
const serializedChatKey = 'interactive.sessions';
|
|
37
38
|
const globalChatKey = 'chat.workspaceTransfer';
|
|
38
39
|
const SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS = 1000 * 60;
|
|
@@ -55,23 +56,23 @@ let ChatService = class ChatService extends Disposable {
|
|
|
55
56
|
this.chatAgentService = chatAgentService;
|
|
56
57
|
this.notificationService = notificationService;
|
|
57
58
|
this.commandService = commandService;
|
|
58
|
-
this._providers = ( new Map());
|
|
59
|
-
this._sessionModels = this._register(( new DisposableMap()));
|
|
60
|
-
this._pendingRequests = this._register(( new DisposableMap()));
|
|
61
|
-
this._onDidPerformUserAction = this._register(( new Emitter()));
|
|
59
|
+
this._providers = ( (new Map()));
|
|
60
|
+
this._sessionModels = this._register(( (new DisposableMap())));
|
|
61
|
+
this._pendingRequests = this._register(( (new DisposableMap())));
|
|
62
|
+
this._onDidPerformUserAction = this._register(( (new Emitter())));
|
|
62
63
|
this.onDidPerformUserAction = this._onDidPerformUserAction.event;
|
|
63
|
-
this._onDidDisposeSession = this._register(( new Emitter()));
|
|
64
|
+
this._onDidDisposeSession = this._register(( (new Emitter())));
|
|
64
65
|
this.onDidDisposeSession = this._onDidDisposeSession.event;
|
|
65
|
-
this._onDidRegisterProvider = this._register(( new Emitter()));
|
|
66
|
+
this._onDidRegisterProvider = this._register(( (new Emitter())));
|
|
66
67
|
this.onDidRegisterProvider = this._onDidRegisterProvider.event;
|
|
67
|
-
this._onDidUnregisterProvider = this._register(( new Emitter()));
|
|
68
|
+
this._onDidUnregisterProvider = this._register(( (new Emitter())));
|
|
68
69
|
this.onDidUnregisterProvider = this._onDidUnregisterProvider.event;
|
|
69
|
-
this._sessionFollowupCancelTokens = this._register(( new DisposableMap()));
|
|
70
|
+
this._sessionFollowupCancelTokens = this._register(( (new DisposableMap())));
|
|
70
71
|
this._hasProvider = CONTEXT_PROVIDER_EXISTS.bindTo(this.contextKeyService);
|
|
71
72
|
const sessionData = storageService.get(serializedChatKey, 1 , '');
|
|
72
73
|
if (sessionData) {
|
|
73
74
|
this._persistedSessions = this.deserializeChats(sessionData);
|
|
74
|
-
const countsForLog = ( Object.keys(this._persistedSessions)).length;
|
|
75
|
+
const countsForLog = ( (Object.keys(this._persistedSessions))).length;
|
|
75
76
|
if (countsForLog > 0) {
|
|
76
77
|
this.trace('constructor', `Restored ${countsForLog} persisted sessions`);
|
|
77
78
|
}
|
|
@@ -89,11 +90,11 @@ let ChatService = class ChatService extends Disposable {
|
|
|
89
90
|
this._register(storageService.onWillSaveState(() => this.saveState()));
|
|
90
91
|
}
|
|
91
92
|
saveState() {
|
|
92
|
-
let allSessions = Array.from(( this._sessionModels.values()))
|
|
93
|
+
let allSessions = Array.from(( (this._sessionModels.values())))
|
|
93
94
|
.filter(session => !session.providerId.startsWith('inlinechat:'))
|
|
94
95
|
.filter(session => session.getRequests().length > 0);
|
|
95
|
-
allSessions = allSessions.concat(( Object.values(this._persistedSessions))
|
|
96
|
-
.filter(session => !( this._sessionModels.has(session.sessionId)))
|
|
96
|
+
allSessions = allSessions.concat(( (Object.values(this._persistedSessions)))
|
|
97
|
+
.filter(session => !( (this._sessionModels.has(session.sessionId))))
|
|
97
98
|
.filter(session => session.requests.length));
|
|
98
99
|
allSessions.sort((a, b) => (b.creationDate ?? 0) - (a.creationDate ?? 0));
|
|
99
100
|
allSessions = allSessions.slice(0, maxPersistedSessions);
|
|
@@ -151,20 +152,22 @@ let ChatService = class ChatService extends Disposable {
|
|
|
151
152
|
try {
|
|
152
153
|
const arrayOfSessions = revive(JSON.parse(sessionData));
|
|
153
154
|
if (!Array.isArray(arrayOfSessions)) {
|
|
154
|
-
throw new Error('Expected array');
|
|
155
|
+
throw ( (new Error('Expected array')));
|
|
155
156
|
}
|
|
156
157
|
const sessions = arrayOfSessions.reduce((acc, session) => {
|
|
157
158
|
for (const request of session.requests) {
|
|
158
159
|
if (Array.isArray(request.response)) {
|
|
159
|
-
request.response = ( request.response.map((response) => {
|
|
160
|
+
request.response = ( (request.response.map((response) => {
|
|
160
161
|
if (typeof response === 'string') {
|
|
161
|
-
return (
|
|
162
|
+
return (
|
|
163
|
+
(new MarkdownString(response))
|
|
164
|
+
);
|
|
162
165
|
}
|
|
163
166
|
return response;
|
|
164
|
-
}));
|
|
167
|
+
})));
|
|
165
168
|
}
|
|
166
169
|
else if (typeof request.response === 'string') {
|
|
167
|
-
request.response = [( new MarkdownString(request.response))];
|
|
170
|
+
request.response = [( (new MarkdownString(request.response)))];
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
173
|
acc[session.sessionId] = session;
|
|
@@ -183,27 +186,29 @@ let ChatService = class ChatService extends Disposable {
|
|
|
183
186
|
if (!workspaceUri) {
|
|
184
187
|
return;
|
|
185
188
|
}
|
|
186
|
-
const thisWorkspace = ( workspaceUri.toString());
|
|
189
|
+
const thisWorkspace = ( (workspaceUri.toString()));
|
|
187
190
|
const currentTime = Date.now();
|
|
188
|
-
const transferred = data.find(item => ( URI.revive(item.toWorkspace).toString()) === thisWorkspace && (currentTime - item.timestampInMilliseconds < SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS));
|
|
189
|
-
const filtered = data.filter(item => ( URI.revive(item.toWorkspace).toString()) !== thisWorkspace && (currentTime - item.timestampInMilliseconds < SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS));
|
|
191
|
+
const transferred = data.find(item => ( (URI.revive(item.toWorkspace).toString())) === thisWorkspace && (currentTime - item.timestampInMilliseconds < SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS));
|
|
192
|
+
const filtered = data.filter(item => ( (URI.revive(item.toWorkspace).toString())) !== thisWorkspace && (currentTime - item.timestampInMilliseconds < SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS));
|
|
190
193
|
this.storageService.store(globalChatKey, JSON.stringify(filtered), 0 , 1 );
|
|
191
194
|
return transferred;
|
|
192
195
|
}
|
|
193
196
|
getHistory() {
|
|
194
|
-
const sessions = ( Object.values(this._persistedSessions))
|
|
197
|
+
const sessions = ( (Object.values(this._persistedSessions)))
|
|
195
198
|
.filter(session => session.requests.length > 0);
|
|
196
199
|
sessions.sort((a, b) => (b.creationDate ?? 0) - (a.creationDate ?? 0));
|
|
197
|
-
return (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
return (
|
|
201
|
+
(sessions
|
|
202
|
+
.filter(session => !( (this._sessionModels.has(session.sessionId))))
|
|
203
|
+
.filter(session => !session.isImported)
|
|
204
|
+
.map(item => {
|
|
205
|
+
const title = ChatModel.getDefaultTitle(item.requests);
|
|
206
|
+
return {
|
|
207
|
+
sessionId: item.sessionId,
|
|
208
|
+
title
|
|
209
|
+
};
|
|
210
|
+
}))
|
|
211
|
+
);
|
|
207
212
|
}
|
|
208
213
|
removeHistoryEntry(sessionId) {
|
|
209
214
|
delete this._persistedSessions[sessionId];
|
|
@@ -235,7 +240,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
235
240
|
await this.extensionService.activateByEvent(`onInteractiveSession:${model.providerId}`);
|
|
236
241
|
const provider = this._providers.get(model.providerId);
|
|
237
242
|
if (!provider) {
|
|
238
|
-
throw new ErrorNoTelemetry(`Unknown provider: ${model.providerId}`);
|
|
243
|
+
throw ( (new ErrorNoTelemetry(`Unknown provider: ${model.providerId}`)));
|
|
239
244
|
}
|
|
240
245
|
let session;
|
|
241
246
|
try {
|
|
@@ -245,7 +250,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
245
250
|
this.trace('initializeSession', `Provider initializeSession threw: ${err}`);
|
|
246
251
|
}
|
|
247
252
|
if (!session) {
|
|
248
|
-
throw new Error('Provider returned no session');
|
|
253
|
+
throw ( (new Error('Provider returned no session')));
|
|
249
254
|
}
|
|
250
255
|
this.trace('startSession', `Provider returned session`);
|
|
251
256
|
const defaultAgent = this.chatAgentService.getDefaultAgent(ChatAgentLocation.Panel);
|
|
@@ -253,26 +258,24 @@ let ChatService = class ChatService extends Disposable {
|
|
|
253
258
|
this.notificationService.notify({
|
|
254
259
|
severity: Severity$1.Error,
|
|
255
260
|
message: ( localizeWithPath(
|
|
256
|
-
|
|
257
|
-
|
|
261
|
+
_moduleId,
|
|
262
|
+
0,
|
|
258
263
|
"Chat failed to load. Please ensure that the GitHub Copilot Chat extension is up to date."
|
|
259
264
|
)),
|
|
260
265
|
actions: {
|
|
261
266
|
primary: [
|
|
262
|
-
( new Action('showExtension', ( localizeWithPath(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"Show Extension"
|
|
266
|
-
)), undefined, true, () => {
|
|
267
|
-
return this.commandService.executeCommand('workbench.extensions.action.showExtensionsWithIds', ['GitHub.copilot-chat']);
|
|
268
|
-
}))
|
|
267
|
+
( (new Action('showExtension', ( localizeWithPath(_moduleId, 1, "Show Extension")), undefined, true, () => {
|
|
268
|
+
return this.commandService.executeCommand('workbench.extensions.action.showExtensionsWithIds', ['GitHub.copilot-chat']);
|
|
269
|
+
})))
|
|
269
270
|
]
|
|
270
271
|
}
|
|
271
272
|
});
|
|
272
|
-
throw new ErrorNoTelemetry('No default agent');
|
|
273
|
+
throw ( (new ErrorNoTelemetry('No default agent')));
|
|
273
274
|
}
|
|
274
275
|
const welcomeMessage = model.welcomeMessage ? undefined : (await defaultAgent.provideWelcomeMessage?.(token)) ?? undefined;
|
|
275
|
-
const welcomeModel = welcomeMessage && this.instantiationService.createInstance(ChatWelcomeMessageModel, ( welcomeMessage.map(
|
|
276
|
+
const welcomeModel = welcomeMessage && this.instantiationService.createInstance(ChatWelcomeMessageModel, ( (welcomeMessage.map(
|
|
277
|
+
item => typeof item === 'string' ? ( (new MarkdownString(item))) : item
|
|
278
|
+
))), (await defaultAgent.provideSampleQuestions?.(token)) ?? []);
|
|
276
279
|
model.initialize(session, welcomeModel);
|
|
277
280
|
}
|
|
278
281
|
catch (err) {
|
|
@@ -286,7 +289,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
286
289
|
return this._sessionModels.get(sessionId);
|
|
287
290
|
}
|
|
288
291
|
getSessionId(sessionProviderId) {
|
|
289
|
-
return Iterable.find(( this._sessionModels.values()), model => model.session?.id === sessionProviderId)?.sessionId;
|
|
292
|
+
return Iterable.find(( (this._sessionModels.values())), model => model.session?.id === sessionProviderId)?.sessionId;
|
|
290
293
|
}
|
|
291
294
|
getOrRestoreSession(sessionId) {
|
|
292
295
|
this.trace('getOrRestoreSession', `sessionId: ${sessionId}`);
|
|
@@ -314,14 +317,14 @@ let ChatService = class ChatService extends Disposable {
|
|
|
314
317
|
}
|
|
315
318
|
const model = this._sessionModels.get(sessionId);
|
|
316
319
|
if (!model) {
|
|
317
|
-
throw new Error(`Unknown session: ${sessionId}`);
|
|
320
|
+
throw ( (new Error(`Unknown session: ${sessionId}`)));
|
|
318
321
|
}
|
|
319
322
|
await model.waitForInitialization();
|
|
320
323
|
const provider = this._providers.get(model.providerId);
|
|
321
324
|
if (!provider) {
|
|
322
|
-
throw new Error(`Unknown provider: ${model.providerId}`);
|
|
325
|
+
throw ( (new Error(`Unknown provider: ${model.providerId}`)));
|
|
323
326
|
}
|
|
324
|
-
if (( this._pendingRequests.has(sessionId))) {
|
|
327
|
+
if (( (this._pendingRequests.has(sessionId)))) {
|
|
325
328
|
this.trace('sendRequest', `Session ${sessionId} already has a pending request`);
|
|
326
329
|
return;
|
|
327
330
|
}
|
|
@@ -337,7 +340,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
337
340
|
}
|
|
338
341
|
refreshFollowupsCancellationToken(sessionId) {
|
|
339
342
|
this._sessionFollowupCancelTokens.get(sessionId)?.cancel();
|
|
340
|
-
const newTokenSource = ( new CancellationTokenSource());
|
|
343
|
+
const newTokenSource = ( (new CancellationTokenSource()));
|
|
341
344
|
this._sessionFollowupCancelTokens.set(sessionId, newTokenSource);
|
|
342
345
|
return newTokenSource.token;
|
|
343
346
|
}
|
|
@@ -349,7 +352,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
349
352
|
const commandPart = 'kind' in parsedRequest ? undefined : parsedRequest.parts.find((r) => r instanceof ChatRequestSlashCommandPart);
|
|
350
353
|
let gotProgress = false;
|
|
351
354
|
const requestType = commandPart ? 'slashCommand' : 'string';
|
|
352
|
-
const source = ( new CancellationTokenSource());
|
|
355
|
+
const source = ( (new CancellationTokenSource()));
|
|
353
356
|
const token = source.token;
|
|
354
357
|
const sendRequestInternal = async () => {
|
|
355
358
|
const progressCallback = (progress) => {
|
|
@@ -365,7 +368,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
365
368
|
}
|
|
366
369
|
model.acceptResponseProgress(request, progress);
|
|
367
370
|
};
|
|
368
|
-
const stopWatch = ( new StopWatch(false));
|
|
371
|
+
const stopWatch = ( (new StopWatch(false)));
|
|
369
372
|
const listener = token.onCancellationRequested(() => {
|
|
370
373
|
this.trace('sendRequest', `Request for session ${model.sessionId} was cancelled`);
|
|
371
374
|
this.telemetryService.publicLog2('interactiveSessionProviderInvoked', {
|
|
@@ -396,9 +399,9 @@ let ChatService = class ChatService extends Disposable {
|
|
|
396
399
|
if (implicitVariablesEnabled) {
|
|
397
400
|
const implicitVariables = agent.defaultImplicitVariables;
|
|
398
401
|
if (implicitVariables) {
|
|
399
|
-
const resolvedImplicitVariables = await Promise.all(( implicitVariables.map(
|
|
402
|
+
const resolvedImplicitVariables = await Promise.all(( (implicitVariables.map(
|
|
400
403
|
async (v) => ({ name: v, values: await this.chatVariablesService.resolveVariable(v, parsedRequest.text, model, progressCallback, token) })
|
|
401
|
-
)));
|
|
404
|
+
))));
|
|
402
405
|
updatedVariableData.variables.push(...resolvedImplicitVariables);
|
|
403
406
|
}
|
|
404
407
|
}
|
|
@@ -426,14 +429,14 @@ let ChatService = class ChatService extends Disposable {
|
|
|
426
429
|
history.push({ role: 2 , content: request.response.response.asString() });
|
|
427
430
|
}
|
|
428
431
|
const message = parsedRequest.text;
|
|
429
|
-
const commandResult = await this.chatSlashCommandService.executeCommand(commandPart.slashCommand.command, message.substring(commandPart.slashCommand.command.length + 1).trimStart(), ( new Progress(p => {
|
|
432
|
+
const commandResult = await this.chatSlashCommandService.executeCommand(commandPart.slashCommand.command, message.substring(commandPart.slashCommand.command.length + 1).trimStart(), ( (new Progress(p => {
|
|
430
433
|
progressCallback(p);
|
|
431
|
-
})), history, token);
|
|
434
|
+
}))), history, token);
|
|
432
435
|
agentOrCommandFollowups = Promise.resolve(commandResult?.followUp);
|
|
433
436
|
rawResult = {};
|
|
434
437
|
}
|
|
435
438
|
else {
|
|
436
|
-
throw new Error(`Cannot handle request`);
|
|
439
|
+
throw ( (new Error(`Cannot handle request`)));
|
|
437
440
|
}
|
|
438
441
|
if (token.isCancellationRequested) {
|
|
439
442
|
return;
|
|
@@ -441,11 +444,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
441
444
|
else {
|
|
442
445
|
if (!rawResult) {
|
|
443
446
|
this.trace('sendRequest', `Provider returned no response for session ${model.sessionId}`);
|
|
444
|
-
rawResult = { errorDetails: { message: ( localizeWithPath(
|
|
445
|
-
'vs/workbench/contrib/chat/common/chatServiceImpl',
|
|
446
|
-
'emptyResponse',
|
|
447
|
-
"Provider returned null response"
|
|
448
|
-
)) } };
|
|
447
|
+
rawResult = { errorDetails: { message: ( localizeWithPath(_moduleId, 2, "Provider returned null response")) } };
|
|
449
448
|
}
|
|
450
449
|
const result = rawResult.errorDetails?.responseIsFiltered ? 'filtered' :
|
|
451
450
|
rawResult.errorDetails && gotProgress ? 'errorWithOutput' :
|
|
@@ -485,23 +484,23 @@ let ChatService = class ChatService extends Disposable {
|
|
|
485
484
|
async removeRequest(sessionId, requestId) {
|
|
486
485
|
const model = this._sessionModels.get(sessionId);
|
|
487
486
|
if (!model) {
|
|
488
|
-
throw new Error(`Unknown session: ${sessionId}`);
|
|
487
|
+
throw ( (new Error(`Unknown session: ${sessionId}`)));
|
|
489
488
|
}
|
|
490
489
|
await model.waitForInitialization();
|
|
491
490
|
const provider = this._providers.get(model.providerId);
|
|
492
491
|
if (!provider) {
|
|
493
|
-
throw new Error(`Unknown provider: ${model.providerId}`);
|
|
492
|
+
throw ( (new Error(`Unknown provider: ${model.providerId}`)));
|
|
494
493
|
}
|
|
495
494
|
model.removeRequest(requestId);
|
|
496
495
|
}
|
|
497
496
|
getProviders() {
|
|
498
|
-
return Array.from(( this._providers.keys()));
|
|
497
|
+
return Array.from(( (this._providers.keys())));
|
|
499
498
|
}
|
|
500
499
|
async addCompleteRequest(sessionId, message, variableData, response) {
|
|
501
500
|
this.trace('addCompleteRequest', `message: ${message}`);
|
|
502
501
|
const model = this._sessionModels.get(sessionId);
|
|
503
502
|
if (!model) {
|
|
504
|
-
throw new Error(`Unknown session: ${sessionId}`);
|
|
503
|
+
throw ( (new Error(`Unknown session: ${sessionId}`)));
|
|
505
504
|
}
|
|
506
505
|
await model.waitForInitialization();
|
|
507
506
|
const parsedRequest = typeof message === 'string' ?
|
|
@@ -531,7 +530,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
531
530
|
this.trace('clearSession', `sessionId: ${sessionId}`);
|
|
532
531
|
const model = this._sessionModels.get(sessionId);
|
|
533
532
|
if (!model) {
|
|
534
|
-
throw new Error(`Unknown session: ${sessionId}`);
|
|
533
|
+
throw ( (new Error(`Unknown session: ${sessionId}`)));
|
|
535
534
|
}
|
|
536
535
|
if (!model.providerId.startsWith('inlinechat')) {
|
|
537
536
|
this._persistedSessions[sessionId] = model.toJSON();
|
|
@@ -543,13 +542,13 @@ let ChatService = class ChatService extends Disposable {
|
|
|
543
542
|
}
|
|
544
543
|
registerProvider(provider) {
|
|
545
544
|
this.trace('registerProvider', `Adding new chat provider`);
|
|
546
|
-
if (( this._providers.has(provider.id))) {
|
|
547
|
-
throw new Error(`Provider ${provider.id} already registered`);
|
|
545
|
+
if (( (this._providers.has(provider.id)))) {
|
|
546
|
+
throw ( (new Error(`Provider ${provider.id} already registered`)));
|
|
548
547
|
}
|
|
549
548
|
this._providers.set(provider.id, provider);
|
|
550
549
|
this._hasProvider.set(true);
|
|
551
550
|
this._onDidRegisterProvider.fire({ providerId: provider.id });
|
|
552
|
-
Array.from(( this._sessionModels.values()))
|
|
551
|
+
Array.from(( (this._sessionModels.values())))
|
|
553
552
|
.filter(model => model.providerId === provider.id)
|
|
554
553
|
.filter(model => model.initState === ChatModelInitState.Created)
|
|
555
554
|
.forEach(model => this.reinitializeModel(model));
|
|
@@ -557,26 +556,30 @@ let ChatService = class ChatService extends Disposable {
|
|
|
557
556
|
this.trace('registerProvider', `Disposing chat provider`);
|
|
558
557
|
this._providers.delete(provider.id);
|
|
559
558
|
this._hasProvider.set(this._providers.size > 0);
|
|
560
|
-
Array.from(( this._sessionModels.values()))
|
|
559
|
+
Array.from(( (this._sessionModels.values())))
|
|
561
560
|
.filter(model => model.providerId === provider.id)
|
|
562
561
|
.forEach(model => model.deinitialize());
|
|
563
562
|
this._onDidUnregisterProvider.fire({ providerId: provider.id });
|
|
564
563
|
});
|
|
565
564
|
}
|
|
566
565
|
hasSessions(providerId) {
|
|
567
|
-
return !!( Object.values(this._persistedSessions)).find((session) => session.providerId === providerId);
|
|
566
|
+
return !!( (Object.values(this._persistedSessions))).find((session) => session.providerId === providerId);
|
|
568
567
|
}
|
|
569
568
|
getProviderInfos() {
|
|
570
|
-
return (
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
569
|
+
return (
|
|
570
|
+
(Array.from(( (this._providers.values()))).map(provider => {
|
|
571
|
+
return {
|
|
572
|
+
id: provider.id,
|
|
573
|
+
};
|
|
574
|
+
}))
|
|
575
|
+
);
|
|
575
576
|
}
|
|
576
577
|
transferChatSession(transferredSessionData, toWorkspace) {
|
|
577
|
-
const model = Iterable.find(( this._sessionModels.values()), model => model.sessionId === transferredSessionData.sessionId);
|
|
578
|
+
const model = Iterable.find(( (this._sessionModels.values())), model => model.sessionId === transferredSessionData.sessionId);
|
|
578
579
|
if (!model) {
|
|
579
|
-
throw new Error(
|
|
580
|
+
throw ( (new Error(
|
|
581
|
+
`Failed to transfer session. Unknown session ID: ${transferredSessionData.sessionId}`
|
|
582
|
+
)));
|
|
580
583
|
}
|
|
581
584
|
const existingRaw = this.storageService.getObject(globalChatKey, 0 , []);
|
|
582
585
|
existingRaw.push({
|
|
@@ -586,22 +589,22 @@ let ChatService = class ChatService extends Disposable {
|
|
|
586
589
|
inputValue: transferredSessionData.inputValue,
|
|
587
590
|
});
|
|
588
591
|
this.storageService.store(globalChatKey, JSON.stringify(existingRaw), 0 , 1 );
|
|
589
|
-
this.trace('transferChatSession', `Transferred session ${model.sessionId} to workspace ${( toWorkspace.toString())}`);
|
|
592
|
+
this.trace('transferChatSession', `Transferred session ${model.sessionId} to workspace ${( (toWorkspace.toString()))}`);
|
|
590
593
|
}
|
|
591
594
|
};
|
|
592
|
-
ChatService = ( __decorate([
|
|
593
|
-
( __param(0, IStorageService)),
|
|
594
|
-
( __param(1, ILogService)),
|
|
595
|
-
( __param(2, IExtensionService)),
|
|
596
|
-
( __param(3, IInstantiationService)),
|
|
597
|
-
( __param(4, ITelemetryService)),
|
|
598
|
-
( __param(5, IContextKeyService)),
|
|
599
|
-
( __param(6, IWorkspaceContextService)),
|
|
600
|
-
( __param(7, IChatSlashCommandService)),
|
|
601
|
-
( __param(8, IChatVariablesService)),
|
|
602
|
-
( __param(9, IChatAgentService)),
|
|
603
|
-
( __param(10, INotificationService)),
|
|
604
|
-
( __param(11, ICommandService))
|
|
605
|
-
], ChatService));
|
|
595
|
+
ChatService = ( (__decorate([
|
|
596
|
+
( (__param(0, IStorageService))),
|
|
597
|
+
( (__param(1, ILogService))),
|
|
598
|
+
( (__param(2, IExtensionService))),
|
|
599
|
+
( (__param(3, IInstantiationService))),
|
|
600
|
+
( (__param(4, ITelemetryService))),
|
|
601
|
+
( (__param(5, IContextKeyService))),
|
|
602
|
+
( (__param(6, IWorkspaceContextService))),
|
|
603
|
+
( (__param(7, IChatSlashCommandService))),
|
|
604
|
+
( (__param(8, IChatVariablesService))),
|
|
605
|
+
( (__param(9, IChatAgentService))),
|
|
606
|
+
( (__param(10, INotificationService))),
|
|
607
|
+
( (__param(11, ICommandService)))
|
|
608
|
+
], ChatService)));
|
|
606
609
|
|
|
607
610
|
export { ChatService };
|
|
@@ -17,7 +17,7 @@ let ChatSlashCommandService = class ChatSlashCommandService extends Disposable {
|
|
|
17
17
|
}
|
|
18
18
|
registerSlashCommand(data, command) {
|
|
19
19
|
if (( this._commands.has(data.command))) {
|
|
20
|
-
throw new Error(`Already registered a command with id ${data.command}}`);
|
|
20
|
+
throw ( new Error(`Already registered a command with id ${data.command}}`));
|
|
21
21
|
}
|
|
22
22
|
this._commands.set(data.command, { data, command });
|
|
23
23
|
this._onDidChangeCommands.fire();
|
|
@@ -36,13 +36,13 @@ let ChatSlashCommandService = class ChatSlashCommandService extends Disposable {
|
|
|
36
36
|
async executeCommand(id, prompt, progress, history, token) {
|
|
37
37
|
const data = this._commands.get(id);
|
|
38
38
|
if (!data) {
|
|
39
|
-
throw new Error('No command with id ${id} NOT registered');
|
|
39
|
+
throw ( new Error('No command with id ${id} NOT registered'));
|
|
40
40
|
}
|
|
41
41
|
if (!data.command) {
|
|
42
42
|
await this._extensionService.activateByEvent(`onSlash:${id}`);
|
|
43
43
|
}
|
|
44
44
|
if (!data.command) {
|
|
45
|
-
throw new Error(`No command with id ${id} NOT resolved`);
|
|
45
|
+
throw ( new Error(`No command with id ${id} NOT resolved`));
|
|
46
46
|
}
|
|
47
47
|
return await data.command(prompt, progress, history, token);
|
|
48
48
|
}
|
|
@@ -19,7 +19,9 @@ class LanguageModelsService {
|
|
|
19
19
|
}
|
|
20
20
|
registerLanguageModelChat(identifier, provider) {
|
|
21
21
|
if (( this._providers.has(identifier))) {
|
|
22
|
-
throw new Error(
|
|
22
|
+
throw ( new Error(
|
|
23
|
+
`Chat response provider with identifier ${identifier} is already registered.`
|
|
24
|
+
));
|
|
23
25
|
}
|
|
24
26
|
this._providers.set(identifier, provider);
|
|
25
27
|
this._onDidChangeProviders.fire({ added: [provider.metadata] });
|
|
@@ -32,7 +34,7 @@ class LanguageModelsService {
|
|
|
32
34
|
makeLanguageModelChatRequest(identifier, from, messages, options, progress, token) {
|
|
33
35
|
const provider = this._providers.get(identifier);
|
|
34
36
|
if (!provider) {
|
|
35
|
-
throw new Error(`Chat response provider with identifier ${identifier} is not registered.`);
|
|
37
|
+
throw ( new Error(`Chat response provider with identifier ${identifier} is not registered.`));
|
|
36
38
|
}
|
|
37
39
|
return provider.provideChatResponse(messages, from, options, progress, token);
|
|
38
40
|
}
|
|
@@ -19,6 +19,7 @@ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
|
19
19
|
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
20
20
|
import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
21
21
|
|
|
22
|
+
const _moduleId = "vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl";
|
|
22
23
|
let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
23
24
|
constructor(_fileConfigService, _editorGroupService, _textFileService, _editorService, _inlineChatSessionService, _configService, _workingCopyFileService, _logService) {
|
|
24
25
|
this._fileConfigService = _fileConfigService;
|
|
@@ -29,19 +30,19 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
29
30
|
this._configService = _configService;
|
|
30
31
|
this._workingCopyFileService = _workingCopyFileService;
|
|
31
32
|
this._logService = _logService;
|
|
32
|
-
this._store = ( new DisposableStore());
|
|
33
|
-
this._saveParticipant = this._store.add(( new MutableDisposable()));
|
|
34
|
-
this._sessionData = ( new Map());
|
|
33
|
+
this._store = ( (new DisposableStore()));
|
|
34
|
+
this._saveParticipant = this._store.add(( (new MutableDisposable())));
|
|
35
|
+
this._sessionData = ( (new Map()));
|
|
35
36
|
this._store.add(Event.any(_inlineChatSessionService.onDidEndSession, _inlineChatSessionService.onDidStashSession)(e => {
|
|
36
37
|
this._sessionData.get(e.session)?.dispose();
|
|
37
38
|
}));
|
|
38
39
|
}
|
|
39
40
|
dispose() {
|
|
40
41
|
this._store.dispose();
|
|
41
|
-
dispose(( this._sessionData.values()));
|
|
42
|
+
dispose(( (this._sessionData.values())));
|
|
42
43
|
}
|
|
43
44
|
markChanged(session) {
|
|
44
|
-
if (!( this._sessionData.has(session))) {
|
|
45
|
+
if (!( (this._sessionData.has(session)))) {
|
|
45
46
|
let uri = session.targetUri;
|
|
46
47
|
if (uri.scheme === Schemas.vscodeNotebookCell) {
|
|
47
48
|
const data = CellUri.parse(uri);
|
|
@@ -69,7 +70,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
_installSaveParticpant() {
|
|
72
|
-
const queue = ( new Queue());
|
|
73
|
+
const queue = ( (new Queue()));
|
|
73
74
|
const d1 = this._textFileService.files.addSaveParticipant({
|
|
74
75
|
participate: (model, ctx, progress, token) => {
|
|
75
76
|
return queue.queue(() => this._participate(ctx.savedFrom ?? model.textEditorModel?.uri, ctx.reason, progress, token));
|
|
@@ -89,9 +90,9 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
89
90
|
if (!this._configService.getValue("inlineChat.acceptedOrDiscardBeforeSave" )) {
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
|
-
const sessions = ( new Map());
|
|
93
|
+
const sessions = ( (new Map()));
|
|
93
94
|
for (const [session, data] of this._sessionData) {
|
|
94
|
-
if (uri?.toString() === ( data.resourceUri.toString())) {
|
|
95
|
+
if (uri?.toString() === ( (data.resourceUri.toString()))) {
|
|
95
96
|
sessions.set(session, data);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
@@ -101,29 +102,29 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
101
102
|
progress.report({
|
|
102
103
|
message: sessions.size === 1
|
|
103
104
|
? ( localizeWithPath(
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
_moduleId,
|
|
106
|
+
0,
|
|
106
107
|
"Waiting for Inline Chat changes to be Accepted or Discarded..."
|
|
107
108
|
))
|
|
108
109
|
: ( localizeWithPath(
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
_moduleId,
|
|
111
|
+
1,
|
|
111
112
|
"Waiting for Inline Chat changes in {0} editors to be Accepted or Discarded...",
|
|
112
113
|
sessions.size
|
|
113
114
|
))
|
|
114
115
|
});
|
|
115
|
-
const { groups, orphans } = this._getGroupsAndOrphans(( sessions.values()));
|
|
116
|
+
const { groups, orphans } = this._getGroupsAndOrphans(( (sessions.values())));
|
|
116
117
|
const editorsOpenedAndSessionsEnded = this._openAndWait(groups, token).then(() => {
|
|
117
118
|
if (token.isCancellationRequested) {
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
|
-
return this._openAndWait(( Iterable.map(orphans, s => [this._editorGroupService.activeGroup, s])), token);
|
|
121
|
+
return this._openAndWait(( (Iterable.map(orphans, s => [this._editorGroupService.activeGroup, s]))), token);
|
|
121
122
|
});
|
|
122
|
-
const allSessionsEnded = this._whenSessionsEnded(Iterable.concat(( groups.map(tuple => tuple[1])), orphans), token);
|
|
123
|
+
const allSessionsEnded = this._whenSessionsEnded(Iterable.concat(( (groups.map(tuple => tuple[1]))), orphans), token);
|
|
123
124
|
await Promise.race([allSessionsEnded, editorsOpenedAndSessionsEnded]);
|
|
124
125
|
}
|
|
125
126
|
_getGroupsAndOrphans(sessions) {
|
|
126
|
-
const groupByEditor = ( new Map());
|
|
127
|
+
const groupByEditor = ( (new Map()));
|
|
127
128
|
for (const group of this._editorGroupService.getGroups(1 )) {
|
|
128
129
|
const candidate = group.activeEditorPane?.getControl();
|
|
129
130
|
if (isCodeEditor(candidate)) {
|
|
@@ -131,7 +132,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
const groups = [];
|
|
134
|
-
const orphans = ( new Set());
|
|
135
|
+
const orphans = ( (new Set()));
|
|
135
136
|
for (const data of sessions) {
|
|
136
137
|
const editor = this._inlineChatSessionService.getCodeEditor(data.session);
|
|
137
138
|
const group = groupByEditor.get(editor);
|
|
@@ -148,7 +149,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
148
149
|
return { groups, orphans };
|
|
149
150
|
}
|
|
150
151
|
async _openAndWait(groups, token) {
|
|
151
|
-
const dataByGroup = ( new Map());
|
|
152
|
+
const dataByGroup = ( (new Map()));
|
|
152
153
|
for (const [group, data] of groups) {
|
|
153
154
|
let array = dataByGroup.get(group);
|
|
154
155
|
if (!array) {
|
|
@@ -161,7 +162,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
161
162
|
if (token.isCancellationRequested) {
|
|
162
163
|
break;
|
|
163
164
|
}
|
|
164
|
-
array.sort((a, b) => compare(( a.session.targetUri.toString()), ( b.session.targetUri.toString())));
|
|
165
|
+
array.sort((a, b) => compare(( (a.session.targetUri.toString())), ( (b.session.targetUri.toString()))));
|
|
165
166
|
for (const data of array) {
|
|
166
167
|
const input = { resource: data.resourceUri };
|
|
167
168
|
const pane = await this._editorService.openEditor(input, group);
|
|
@@ -174,7 +175,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
174
175
|
if (cell) {
|
|
175
176
|
await notebookEditor.revealRangeInCenterIfOutsideViewportAsync(cell, data.session.wholeRange.value);
|
|
176
177
|
}
|
|
177
|
-
const tuple = notebookEditor.codeEditors.find(tuple => tuple[1].getModel()?.uri.toString() === ( data.session.targetUri.toString()));
|
|
178
|
+
const tuple = notebookEditor.codeEditors.find(tuple => tuple[1].getModel()?.uri.toString() === ( (data.session.targetUri.toString())));
|
|
178
179
|
editor = tuple?.[1];
|
|
179
180
|
}
|
|
180
181
|
}
|
|
@@ -188,13 +189,13 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
188
189
|
}
|
|
189
190
|
this._inlineChatSessionService.moveSession(data.session, editor);
|
|
190
191
|
InlineChatController.get(editor)?.showSaveHint();
|
|
191
|
-
this._logService.info('WAIT for session to end', editor.getId(), ( data.session.targetUri.toString()));
|
|
192
|
+
this._logService.info('WAIT for session to end', editor.getId(), ( (data.session.targetUri.toString())));
|
|
192
193
|
await this._whenSessionsEnded(Iterable.single(data), token);
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
async _whenSessionsEnded(iterable, token) {
|
|
197
|
-
const sessions = ( new Map());
|
|
198
|
+
const sessions = ( (new Map()));
|
|
198
199
|
for (const item of iterable) {
|
|
199
200
|
sessions.set(item.session, item);
|
|
200
201
|
}
|
|
@@ -202,7 +203,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
202
203
|
return;
|
|
203
204
|
}
|
|
204
205
|
let listener;
|
|
205
|
-
const whenEnded = ( new Promise(resolve => {
|
|
206
|
+
const whenEnded = ( (new Promise(resolve => {
|
|
206
207
|
listener = Event.any(this._inlineChatSessionService.onDidEndSession, this._inlineChatSessionService.onDidStashSession)(e => {
|
|
207
208
|
const data = sessions.get(e.session);
|
|
208
209
|
if (data) {
|
|
@@ -213,7 +214,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
216
|
});
|
|
216
|
-
}));
|
|
217
|
+
})));
|
|
217
218
|
try {
|
|
218
219
|
await raceCancellation(whenEnded, token);
|
|
219
220
|
}
|
|
@@ -222,15 +223,15 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
222
223
|
}
|
|
223
224
|
}
|
|
224
225
|
};
|
|
225
|
-
InlineChatSavingServiceImpl = ( __decorate([
|
|
226
|
-
( __param(0, IFilesConfigurationService)),
|
|
227
|
-
( __param(1, IEditorGroupsService)),
|
|
228
|
-
( __param(2, ITextFileService)),
|
|
229
|
-
( __param(3, IEditorService)),
|
|
230
|
-
( __param(4, IInlineChatSessionService)),
|
|
231
|
-
( __param(5, IConfigurationService)),
|
|
232
|
-
( __param(6, IWorkingCopyFileService)),
|
|
233
|
-
( __param(7, ILogService))
|
|
234
|
-
], InlineChatSavingServiceImpl));
|
|
226
|
+
InlineChatSavingServiceImpl = ( (__decorate([
|
|
227
|
+
( (__param(0, IFilesConfigurationService))),
|
|
228
|
+
( (__param(1, IEditorGroupsService))),
|
|
229
|
+
( (__param(2, ITextFileService))),
|
|
230
|
+
( (__param(3, IEditorService))),
|
|
231
|
+
( (__param(4, IInlineChatSessionService))),
|
|
232
|
+
( (__param(5, IConfigurationService))),
|
|
233
|
+
( (__param(6, IWorkingCopyFileService))),
|
|
234
|
+
( (__param(7, ILogService)))
|
|
235
|
+
], InlineChatSavingServiceImpl)));
|
|
235
236
|
|
|
236
237
|
export { InlineChatSavingServiceImpl };
|