@codingame/monaco-vscode-extensions-service-override 1.83.7 → 1.83.9
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/assets/webWorkerExtensionHostIframe.html +123 -0
- package/extensions.d.ts +12 -13
- package/extensions.js +456 -0
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
- package/external/tslib/tslib.es6.js +11 -0
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/override/vs/platform/dialogs/common/dialogs.js +8 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +8 -0
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +3 -0
- package/package.json +5 -3
- package/tools/url.js +10 -0
- package/tools.js +5 -0
- package/vscode/src/vs/base/common/console.js +59 -0
- package/vscode/src/vs/base/common/prefixTree.js +131 -0
- package/vscode/src/vs/platform/files/common/watcher.js +71 -0
- package/vscode/src/vs/platform/lifecycle/common/lifecycle.js +27 -0
- package/vscode/src/vs/platform/log/browser/log.js +26 -0
- package/vscode/src/vs/platform/remote/common/managedSocket.js +98 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadAiEmbeddingVector.js +31 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadAiRelatedInformation.js +35 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +330 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadBulkEdits.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +174 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents.js +52 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatProvider.js +61 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatSlashCommands.js +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatVariables.js +31 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadClipboard.js +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCodeInsets.js +107 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +94 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +541 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadConfiguration.js +80 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadConsole.js +35 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +578 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +387 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDecorations.js +102 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDiagnostics.js +69 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDialogs.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentContentProviders.js +75 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDocuments.js +249 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +370 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDownloadService.js +22 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditSessionIdentityParticipant.js +41 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditor.js +411 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +475 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditors.js +227 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadErrors.js +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadExtensionService.js +317 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +280 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +283 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadInlineChat.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadInteractive.js +28 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +33 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLabelService.js +27 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +947 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguages.js +78 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLocalization.js +35 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLogService.js +78 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadManagedSockets.js +93 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadMessageService.js +118 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +158 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +123 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +188 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDto.js +129 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +131 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +341 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +25 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +48 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadOutputService.js +76 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadProfilContentHandlers.js +38 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadProgress.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickDiff.js +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickOpen.js +185 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadRemoteConnectionData.js +30 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSCM.js +463 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSaveParticipant.js +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSearch.js +148 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSecretState.js +70 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadShare.js +50 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadStatusBar.js +53 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadStorage.js +72 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTask.js +731 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTelemetry.js +53 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTerminalService.js +412 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +182 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTheming.js +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTimeline.js +55 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTreeViews.js +313 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTunnelService.js +223 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadUriOpeners.js +110 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadUrls.js +61 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewManager.js +29 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewPanels.js +283 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewViews.js +100 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviews.js +135 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWindow.js +57 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWorkspace.js +273 -0
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHost.api.impl.d.ts +2 -2
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostConfiguration.d.ts +3 -3
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostExtensionService.d.ts +3 -4
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostManagedSockets.d.ts +2 -2
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostTerminalService.d.ts +19 -20
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostTunnelService.d.ts +7 -8
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostWorkspace.d.ts +25 -26
- package/vscode/src/vs/workbench/api/common/shared/dataTransferCache.js +35 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +217 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +57 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +51 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +92 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +648 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +297 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +62 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +249 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +109 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadRangeDecorator.js +109 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +331 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +380 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/comments.js +5 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +1196 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsFilterOptions.js +19 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +334 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +543 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +178 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/panel.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +101 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +57 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +145 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +3 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customTextEditorModel.js +73 -0
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/contributedOpeners.js +83 -0
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +179 -0
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveHistoryService.js +5 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +144 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +482 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +6 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +85 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +56 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +110 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +260 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +616 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +309 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +38 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +167 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +80 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +70 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +108 -0
- package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +506 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.js +132 -0
- package/vscode/src/vs/workbench/contrib/testing/common/getComputedState.js +103 -0
- package/vscode/src/vs/workbench/contrib/testing/common/observableValue.js +28 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testCoverage.js +25 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +336 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingStates.js +46 -0
- package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +283 -0
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +273 -0
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerFileSystemProvider.js +52 -0
- package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +1093 -0
- package/vscode/src/vs/workbench/services/extensions/common/extHostCustomers.js +41 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionDevOptions.js +25 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +643 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.js +274 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionStorageMigration.js +58 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionsProposedApi.js +80 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionsUtil.js +64 -0
- package/vscode/src/vs/workbench/services/extensions/common/remoteConsoleUtil.js +49 -0
- package/vscode/src/vs/workbench/services/extensions/common/remoteExtensionHost.js +220 -0
- package/vscode/src/vs/workbench/services/themes/common/iconExtensionPoint.js +5 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +79 -0
- package/vscode-proposed.d.ts +0 -3872
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHost.protocol.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostExtensionActivator.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostFileSystemInfo.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostInitDataService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostLocalizationService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostRpcService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostStoragePaths.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostTypes.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostUriTransformerService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/worker/extHostExtensionService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/services/search/common/queryBuilder.d.ts +0 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
3
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
4
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
5
|
+
import { getAuthenticationProviderActivationEvent, addAccountUsage, readAllowedExtensions, readAccountUsages, removeAccountUsage } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationService';
|
|
6
|
+
import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication';
|
|
7
|
+
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
8
|
+
import '../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
9
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
10
|
+
import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
|
|
11
|
+
import { IQuickInputService } from 'monaco-editor/esm/vs/platform/quickinput/common/quickInput.js';
|
|
12
|
+
import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
13
|
+
import { fromNow } from 'vscode/vscode/vs/base/common/date';
|
|
14
|
+
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
15
|
+
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
16
|
+
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
17
|
+
|
|
18
|
+
class MainThreadAuthenticationProvider extends Disposable {
|
|
19
|
+
constructor(_proxy, id, label, supportsMultipleAccounts, notificationService, storageService, quickInputService, dialogService) {
|
|
20
|
+
super();
|
|
21
|
+
this._proxy = _proxy;
|
|
22
|
+
this.id = id;
|
|
23
|
+
this.label = label;
|
|
24
|
+
this.supportsMultipleAccounts = supportsMultipleAccounts;
|
|
25
|
+
this.notificationService = notificationService;
|
|
26
|
+
this.storageService = storageService;
|
|
27
|
+
this.quickInputService = quickInputService;
|
|
28
|
+
this.dialogService = dialogService;
|
|
29
|
+
}
|
|
30
|
+
manageTrustedExtensions(accountName) {
|
|
31
|
+
const allowedExtensions = readAllowedExtensions(this.storageService, this.id, accountName);
|
|
32
|
+
if (!allowedExtensions.length) {
|
|
33
|
+
this.dialogService.info(( nls.localizeWithPath(
|
|
34
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
35
|
+
'noTrustedExtensions',
|
|
36
|
+
"This account has not been used by any extensions."
|
|
37
|
+
)));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const quickPick = this.quickInputService.createQuickPick();
|
|
41
|
+
quickPick.canSelectMany = true;
|
|
42
|
+
quickPick.customButton = true;
|
|
43
|
+
quickPick.customLabel = ( nls.localizeWithPath(
|
|
44
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
45
|
+
'manageTrustedExtensions.cancel',
|
|
46
|
+
'Cancel'
|
|
47
|
+
));
|
|
48
|
+
const usages = readAccountUsages(this.storageService, this.id, accountName);
|
|
49
|
+
const items = ( allowedExtensions.map(extension => {
|
|
50
|
+
const usage = usages.find(usage => extension.id === usage.extensionId);
|
|
51
|
+
return {
|
|
52
|
+
label: extension.name,
|
|
53
|
+
description: usage
|
|
54
|
+
? ( nls.localizeWithPath(
|
|
55
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
56
|
+
{ key: 'accountLastUsedDate', comment: ['The placeholder {0} is a string with time information, such as "3 days ago"'] },
|
|
57
|
+
"Last used this account {0}",
|
|
58
|
+
fromNow(usage.lastUsed, true)
|
|
59
|
+
))
|
|
60
|
+
: ( nls.localizeWithPath(
|
|
61
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
62
|
+
'notUsed',
|
|
63
|
+
"Has not used this account"
|
|
64
|
+
)),
|
|
65
|
+
extension
|
|
66
|
+
};
|
|
67
|
+
}));
|
|
68
|
+
quickPick.items = items;
|
|
69
|
+
quickPick.selectedItems = items.filter(item => item.extension.allowed === undefined || item.extension.allowed);
|
|
70
|
+
quickPick.title = ( nls.localizeWithPath(
|
|
71
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
72
|
+
'manageTrustedExtensions',
|
|
73
|
+
"Manage Trusted Extensions"
|
|
74
|
+
));
|
|
75
|
+
quickPick.placeholder = ( nls.localizeWithPath(
|
|
76
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
77
|
+
'manageExtensions',
|
|
78
|
+
"Choose which extensions can access this account"
|
|
79
|
+
));
|
|
80
|
+
quickPick.onDidAccept(() => {
|
|
81
|
+
const updatedAllowedList = ( quickPick.items
|
|
82
|
+
.map(i => i.extension));
|
|
83
|
+
this.storageService.store(`${this.id}-${accountName}`, JSON.stringify(updatedAllowedList), -1 , 0 );
|
|
84
|
+
quickPick.dispose();
|
|
85
|
+
});
|
|
86
|
+
quickPick.onDidChangeSelection((changed) => {
|
|
87
|
+
quickPick.items.forEach(item => {
|
|
88
|
+
if (item.extension) {
|
|
89
|
+
item.extension.allowed = false;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
changed.forEach((item) => item.extension.allowed = true);
|
|
93
|
+
});
|
|
94
|
+
quickPick.onDidHide(() => {
|
|
95
|
+
quickPick.dispose();
|
|
96
|
+
});
|
|
97
|
+
quickPick.onDidCustom(() => {
|
|
98
|
+
quickPick.hide();
|
|
99
|
+
});
|
|
100
|
+
quickPick.show();
|
|
101
|
+
}
|
|
102
|
+
async removeAccountSessions(accountName, sessions) {
|
|
103
|
+
const accountUsages = readAccountUsages(this.storageService, this.id, accountName);
|
|
104
|
+
const { confirmed } = await this.dialogService.confirm({
|
|
105
|
+
type: Severity.Info,
|
|
106
|
+
message: accountUsages.length
|
|
107
|
+
? ( nls.localizeWithPath(
|
|
108
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
109
|
+
'signOutMessage',
|
|
110
|
+
"The account '{0}' has been used by: \n\n{1}\n\n Sign out from these extensions?",
|
|
111
|
+
accountName,
|
|
112
|
+
( accountUsages.map(usage => usage.extensionName)).join('\n')
|
|
113
|
+
))
|
|
114
|
+
: ( nls.localizeWithPath(
|
|
115
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
116
|
+
'signOutMessageSimple',
|
|
117
|
+
"Sign out of '{0}'?",
|
|
118
|
+
accountName
|
|
119
|
+
)),
|
|
120
|
+
primaryButton: ( nls.localizeWithPath(
|
|
121
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
122
|
+
{ key: 'signOut', comment: ['&& denotes a mnemonic'] },
|
|
123
|
+
"&&Sign Out"
|
|
124
|
+
))
|
|
125
|
+
});
|
|
126
|
+
if (confirmed) {
|
|
127
|
+
const removeSessionPromises = ( sessions.map(session => this.removeSession(session.id)));
|
|
128
|
+
await Promise.all(removeSessionPromises);
|
|
129
|
+
removeAccountUsage(this.storageService, this.id, accountName);
|
|
130
|
+
this.storageService.remove(`${this.id}-${accountName}`, -1 );
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async getSessions(scopes) {
|
|
134
|
+
return this._proxy.$getSessions(this.id, scopes);
|
|
135
|
+
}
|
|
136
|
+
createSession(scopes, options) {
|
|
137
|
+
return this._proxy.$createSession(this.id, scopes, options);
|
|
138
|
+
}
|
|
139
|
+
async removeSession(sessionId) {
|
|
140
|
+
await this._proxy.$removeSession(this.id, sessionId);
|
|
141
|
+
this.notificationService.info(( nls.localizeWithPath(
|
|
142
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
143
|
+
'signedOut',
|
|
144
|
+
"Successfully signed out."
|
|
145
|
+
)));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let MainThreadAuthentication = class MainThreadAuthentication extends Disposable {
|
|
149
|
+
constructor(extHostContext, authenticationService, dialogService, storageService, notificationService, quickInputService, extensionService, telemetryService) {
|
|
150
|
+
super();
|
|
151
|
+
this.authenticationService = authenticationService;
|
|
152
|
+
this.dialogService = dialogService;
|
|
153
|
+
this.storageService = storageService;
|
|
154
|
+
this.notificationService = notificationService;
|
|
155
|
+
this.quickInputService = quickInputService;
|
|
156
|
+
this.extensionService = extensionService;
|
|
157
|
+
this.telemetryService = telemetryService;
|
|
158
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostAuthentication));
|
|
159
|
+
this._register(this.authenticationService.onDidChangeSessions(e => {
|
|
160
|
+
this._proxy.$onDidChangeAuthenticationSessions(e.providerId, e.label);
|
|
161
|
+
}));
|
|
162
|
+
this._proxy.$setProviders(this.authenticationService.declaredProviders);
|
|
163
|
+
this._register(this.authenticationService.onDidChangeDeclaredProviders(e => {
|
|
164
|
+
this._proxy.$setProviders(e);
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
async $registerAuthenticationProvider(id, label, supportsMultipleAccounts) {
|
|
168
|
+
const provider = ( new MainThreadAuthenticationProvider(
|
|
169
|
+
this._proxy,
|
|
170
|
+
id,
|
|
171
|
+
label,
|
|
172
|
+
supportsMultipleAccounts,
|
|
173
|
+
this.notificationService,
|
|
174
|
+
this.storageService,
|
|
175
|
+
this.quickInputService,
|
|
176
|
+
this.dialogService
|
|
177
|
+
));
|
|
178
|
+
this.authenticationService.registerAuthenticationProvider(id, provider);
|
|
179
|
+
}
|
|
180
|
+
$unregisterAuthenticationProvider(id) {
|
|
181
|
+
this.authenticationService.unregisterAuthenticationProvider(id);
|
|
182
|
+
}
|
|
183
|
+
$ensureProvider(id) {
|
|
184
|
+
return this.extensionService.activateByEvent(getAuthenticationProviderActivationEvent(id), 1 );
|
|
185
|
+
}
|
|
186
|
+
$sendDidChangeSessions(id, event) {
|
|
187
|
+
this.authenticationService.sessionsUpdate(id, event);
|
|
188
|
+
}
|
|
189
|
+
$removeSession(providerId, sessionId) {
|
|
190
|
+
return this.authenticationService.removeSession(providerId, sessionId);
|
|
191
|
+
}
|
|
192
|
+
async loginPrompt(providerName, extensionName, recreatingSession, detail) {
|
|
193
|
+
const message = recreatingSession
|
|
194
|
+
? ( nls.localizeWithPath(
|
|
195
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
196
|
+
'confirmRelogin',
|
|
197
|
+
"The extension '{0}' wants you to sign in again using {1}.",
|
|
198
|
+
extensionName,
|
|
199
|
+
providerName
|
|
200
|
+
))
|
|
201
|
+
: ( nls.localizeWithPath(
|
|
202
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
203
|
+
'confirmLogin',
|
|
204
|
+
"The extension '{0}' wants to sign in using {1}.",
|
|
205
|
+
extensionName,
|
|
206
|
+
providerName
|
|
207
|
+
));
|
|
208
|
+
const { confirmed } = await this.dialogService.confirm({
|
|
209
|
+
type: Severity.Info,
|
|
210
|
+
message,
|
|
211
|
+
detail,
|
|
212
|
+
primaryButton: ( nls.localizeWithPath(
|
|
213
|
+
'vs/workbench/api/browser/mainThreadAuthentication',
|
|
214
|
+
{ key: 'allow', comment: ['&& denotes a mnemonic'] },
|
|
215
|
+
"&&Allow"
|
|
216
|
+
))
|
|
217
|
+
});
|
|
218
|
+
return confirmed;
|
|
219
|
+
}
|
|
220
|
+
async doGetSession(providerId, scopes, extensionId, extensionName, options) {
|
|
221
|
+
const sessions = await this.authenticationService.getSessions(providerId, scopes, true);
|
|
222
|
+
const supportsMultipleAccounts = this.authenticationService.supportsMultipleAccounts(providerId);
|
|
223
|
+
if (options.forceNewSession && options.createIfNone) {
|
|
224
|
+
throw new Error('Invalid combination of options. Please remove one of the following: forceNewSession, createIfNone');
|
|
225
|
+
}
|
|
226
|
+
if (options.forceNewSession && options.silent) {
|
|
227
|
+
throw new Error('Invalid combination of options. Please remove one of the following: forceNewSession, silent');
|
|
228
|
+
}
|
|
229
|
+
if (options.createIfNone && options.silent) {
|
|
230
|
+
throw new Error('Invalid combination of options. Please remove one of the following: createIfNone, silent');
|
|
231
|
+
}
|
|
232
|
+
if (!options.forceNewSession && sessions.length) {
|
|
233
|
+
if (supportsMultipleAccounts) {
|
|
234
|
+
if (options.clearSessionPreference) {
|
|
235
|
+
this.authenticationService.removeSessionPreference(providerId, extensionId, scopes);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
const existingSessionPreference = this.authenticationService.getSessionPreference(providerId, extensionId, scopes);
|
|
239
|
+
if (existingSessionPreference) {
|
|
240
|
+
const matchingSession = sessions.find(session => session.id === existingSessionPreference);
|
|
241
|
+
if (matchingSession && this.authenticationService.isAccessAllowed(providerId, matchingSession.account.label, extensionId)) {
|
|
242
|
+
return matchingSession;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else if (this.authenticationService.isAccessAllowed(providerId, sessions[0].account.label, extensionId)) {
|
|
248
|
+
return sessions[0];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (options.createIfNone || options.forceNewSession) {
|
|
252
|
+
const providerName = this.authenticationService.getLabel(providerId);
|
|
253
|
+
const detail = (typeof options.forceNewSession === 'object') ? options.forceNewSession.detail : undefined;
|
|
254
|
+
const recreatingSession = !!(options.forceNewSession && sessions.length);
|
|
255
|
+
const isAllowed = await this.loginPrompt(providerName, extensionName, recreatingSession, detail);
|
|
256
|
+
if (!isAllowed) {
|
|
257
|
+
throw new Error('User did not consent to login.');
|
|
258
|
+
}
|
|
259
|
+
let session;
|
|
260
|
+
if (sessions?.length && !options.forceNewSession && supportsMultipleAccounts) {
|
|
261
|
+
session = await this.authenticationService.selectSession(providerId, extensionId, extensionName, scopes, sessions);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
let sessionToRecreate;
|
|
265
|
+
if (typeof options.forceNewSession === 'object' && options.forceNewSession.sessionToRecreate) {
|
|
266
|
+
sessionToRecreate = options.forceNewSession.sessionToRecreate;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
const sessionIdToRecreate = this.authenticationService.getSessionPreference(providerId, extensionId, scopes);
|
|
270
|
+
sessionToRecreate = sessionIdToRecreate ? sessions.find(session => session.id === sessionIdToRecreate) : undefined;
|
|
271
|
+
}
|
|
272
|
+
session = await this.authenticationService.createSession(providerId, scopes, { activateImmediate: true, sessionToRecreate });
|
|
273
|
+
}
|
|
274
|
+
this.authenticationService.updateAllowedExtension(providerId, session.account.label, extensionId, extensionName, true);
|
|
275
|
+
this.authenticationService.updateSessionPreference(providerId, extensionId, session);
|
|
276
|
+
return session;
|
|
277
|
+
}
|
|
278
|
+
const validSession = sessions.find(session => this.authenticationService.isAccessAllowed(providerId, session.account.label, extensionId));
|
|
279
|
+
if (validSession) {
|
|
280
|
+
if (!this.authenticationService.getSessionPreference(providerId, extensionId, scopes)) {
|
|
281
|
+
if (this.storageService.get(`${extensionName}-${providerId}`, -1 )) {
|
|
282
|
+
this.storageService.remove(`${extensionName}-${providerId}`, -1 );
|
|
283
|
+
}
|
|
284
|
+
this.authenticationService.updateAllowedExtension(providerId, validSession.account.label, extensionId, extensionName, true);
|
|
285
|
+
this.authenticationService.updateSessionPreference(providerId, extensionId, validSession);
|
|
286
|
+
}
|
|
287
|
+
return validSession;
|
|
288
|
+
}
|
|
289
|
+
if (!options.silent) {
|
|
290
|
+
sessions.length
|
|
291
|
+
? this.authenticationService.requestSessionAccess(providerId, extensionId, extensionName, scopes, sessions)
|
|
292
|
+
: await this.authenticationService.requestNewSession(providerId, scopes, extensionId, extensionName);
|
|
293
|
+
}
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
async $getSession(providerId, scopes, extensionId, extensionName, options) {
|
|
297
|
+
const session = await this.doGetSession(providerId, scopes, extensionId, extensionName, options);
|
|
298
|
+
if (session) {
|
|
299
|
+
this.sendProviderUsageTelemetry(extensionId, providerId);
|
|
300
|
+
addAccountUsage(this.storageService, providerId, session.account.label, extensionId, extensionName);
|
|
301
|
+
}
|
|
302
|
+
return session;
|
|
303
|
+
}
|
|
304
|
+
async $getSessions(providerId, scopes, extensionId, extensionName) {
|
|
305
|
+
const sessions = await this.authenticationService.getSessions(providerId, [...scopes], true);
|
|
306
|
+
const accessibleSessions = sessions.filter(s => this.authenticationService.isAccessAllowed(providerId, s.account.label, extensionId));
|
|
307
|
+
if (accessibleSessions.length) {
|
|
308
|
+
this.sendProviderUsageTelemetry(extensionId, providerId);
|
|
309
|
+
for (const session of accessibleSessions) {
|
|
310
|
+
addAccountUsage(this.storageService, providerId, session.account.label, extensionId, extensionName);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return accessibleSessions;
|
|
314
|
+
}
|
|
315
|
+
sendProviderUsageTelemetry(extensionId, providerId) {
|
|
316
|
+
this.telemetryService.publicLog2('authentication.providerUsage', { providerId, extensionId });
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
MainThreadAuthentication = __decorate([
|
|
320
|
+
extHostNamedCustomer(MainContext.MainThreadAuthentication),
|
|
321
|
+
( __param(1, IAuthenticationService)),
|
|
322
|
+
( __param(2, IDialogService)),
|
|
323
|
+
( __param(3, IStorageService)),
|
|
324
|
+
( __param(4, INotificationService)),
|
|
325
|
+
( __param(5, IQuickInputService)),
|
|
326
|
+
( __param(6, IExtensionService)),
|
|
327
|
+
( __param(7, ITelemetryService))
|
|
328
|
+
], MainThreadAuthentication);
|
|
329
|
+
|
|
330
|
+
export { MainThreadAuthentication, MainThreadAuthenticationProvider };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { decodeBase64 } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
3
|
+
import { revive } from 'monaco-editor/esm/vs/base/common/marshalling.js';
|
|
4
|
+
import { IBulkEditService, ResourceTextEdit, ResourceFileEdit } from 'monaco-editor/esm/vs/editor/browser/services/bulkEditService.js';
|
|
5
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
6
|
+
import { IUriIdentityService } from 'monaco-editor/esm/vs/platform/uriIdentity/common/uriIdentity.js';
|
|
7
|
+
import { MainContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
8
|
+
import { ResourceNotebookCellEdit } from 'vscode/vscode/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits';
|
|
9
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
10
|
+
|
|
11
|
+
let MainThreadBulkEdits = class MainThreadBulkEdits {
|
|
12
|
+
constructor(_extHostContext, _bulkEditService, _logService, _uriIdentService) {
|
|
13
|
+
this._bulkEditService = _bulkEditService;
|
|
14
|
+
this._logService = _logService;
|
|
15
|
+
this._uriIdentService = _uriIdentService;
|
|
16
|
+
}
|
|
17
|
+
dispose() { }
|
|
18
|
+
$tryApplyWorkspaceEdit(dto, undoRedoGroupId, isRefactoring) {
|
|
19
|
+
const edits = reviveWorkspaceEditDto(dto, this._uriIdentService);
|
|
20
|
+
return this._bulkEditService.apply(edits, { undoRedoGroupId, respectAutoSaveConfig: isRefactoring }).then((res) => res.isApplied, err => {
|
|
21
|
+
this._logService.warn(`IGNORING workspace edit: ${err}`);
|
|
22
|
+
return false;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
MainThreadBulkEdits = __decorate([
|
|
27
|
+
extHostNamedCustomer(MainContext.MainThreadBulkEdits),
|
|
28
|
+
( __param(1, IBulkEditService)),
|
|
29
|
+
( __param(2, ILogService)),
|
|
30
|
+
( __param(3, IUriIdentityService))
|
|
31
|
+
], MainThreadBulkEdits);
|
|
32
|
+
function reviveWorkspaceEditDto(data, uriIdentityService, resolveDataTransferFile) {
|
|
33
|
+
if (!data || !data.edits) {
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
const result = revive(data);
|
|
37
|
+
for (const edit of result.edits) {
|
|
38
|
+
if (ResourceTextEdit.is(edit)) {
|
|
39
|
+
edit.resource = uriIdentityService.asCanonicalUri(edit.resource);
|
|
40
|
+
}
|
|
41
|
+
if (ResourceFileEdit.is(edit)) {
|
|
42
|
+
if (edit.options) {
|
|
43
|
+
const inContents = edit.options?.contents;
|
|
44
|
+
if (inContents) {
|
|
45
|
+
if (inContents.type === 'base64') {
|
|
46
|
+
edit.options.contents = Promise.resolve(decodeBase64(inContents.value));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (resolveDataTransferFile) {
|
|
50
|
+
edit.options.contents = resolveDataTransferFile(inContents.id);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
throw new Error('Could not revive data transfer file');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
edit.newResource = edit.newResource && uriIdentityService.asCanonicalUri(edit.newResource);
|
|
59
|
+
edit.oldResource = edit.oldResource && uriIdentityService.asCanonicalUri(edit.oldResource);
|
|
60
|
+
}
|
|
61
|
+
if (ResourceNotebookCellEdit.is(edit)) {
|
|
62
|
+
edit.resource = uriIdentityService.asCanonicalUri(edit.resource);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { MainThreadBulkEdits, reviveWorkspaceEditDto };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
3
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
4
|
+
import { Disposable, DisposableMap } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
5
|
+
import { revive } from 'monaco-editor/esm/vs/base/common/marshalling.js';
|
|
6
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
7
|
+
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
8
|
+
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
9
|
+
import { IChatContributionService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContributionService';
|
|
10
|
+
import { isCompleteInteractiveProgressTreeData } from '../../contrib/chat/common/chatModel.js';
|
|
11
|
+
import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
|
|
12
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
13
|
+
|
|
14
|
+
let MainThreadChat = class MainThreadChat extends Disposable {
|
|
15
|
+
constructor(extHostContext, _chatService, _chatWidgetService, chatContribService) {
|
|
16
|
+
super();
|
|
17
|
+
this._chatService = _chatService;
|
|
18
|
+
this._chatWidgetService = _chatWidgetService;
|
|
19
|
+
this.chatContribService = chatContribService;
|
|
20
|
+
this._providerRegistrations = this._register(( new DisposableMap()));
|
|
21
|
+
this._activeRequestProgressCallbacks = ( new Map());
|
|
22
|
+
this._stateEmitters = ( new Map());
|
|
23
|
+
this._responsePartHandlePool = 0;
|
|
24
|
+
this._activeResponsePartPromises = ( new Map());
|
|
25
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostChat));
|
|
26
|
+
this._register(this._chatService.onDidPerformUserAction(e => {
|
|
27
|
+
this._proxy.$onDidPerformUserAction(e);
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
$transferChatSession(sessionId, toWorkspace) {
|
|
31
|
+
const sessionIdStr = this._chatService.getSessionId(sessionId);
|
|
32
|
+
if (!sessionIdStr) {
|
|
33
|
+
throw new Error(`Failed to transfer session. Unknown session provider ID: ${sessionId}`);
|
|
34
|
+
}
|
|
35
|
+
const widget = this._chatWidgetService.getWidgetBySessionId(sessionIdStr);
|
|
36
|
+
const inputValue = widget?.inputEditor.getValue() ?? '';
|
|
37
|
+
this._chatService.transferChatSession({ sessionId: sessionIdStr, inputValue: inputValue }, URI.revive(toWorkspace));
|
|
38
|
+
}
|
|
39
|
+
async $registerChatProvider(handle, id) {
|
|
40
|
+
const registration = this.chatContribService.registeredProviders.find(staticProvider => staticProvider.id === id);
|
|
41
|
+
if (!registration) {
|
|
42
|
+
throw new Error(`Provider ${id} must be declared in the package.json.`);
|
|
43
|
+
}
|
|
44
|
+
const unreg = this._chatService.registerProvider({
|
|
45
|
+
id,
|
|
46
|
+
displayName: registration.label,
|
|
47
|
+
prepareSession: async (initialState, token) => {
|
|
48
|
+
const session = await this._proxy.$prepareChat(handle, initialState, token);
|
|
49
|
+
if (!session) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const responderAvatarIconUri = session.responderAvatarIconUri ?
|
|
53
|
+
URI.revive(session.responderAvatarIconUri) :
|
|
54
|
+
registration.extensionIcon;
|
|
55
|
+
const emitter = ( new Emitter());
|
|
56
|
+
this._stateEmitters.set(session.id, emitter);
|
|
57
|
+
return {
|
|
58
|
+
id: session.id,
|
|
59
|
+
requesterUsername: session.requesterUsername,
|
|
60
|
+
requesterAvatarIconUri: URI.revive(session.requesterAvatarIconUri),
|
|
61
|
+
responderUsername: session.responderUsername,
|
|
62
|
+
responderAvatarIconUri,
|
|
63
|
+
inputPlaceholder: session.inputPlaceholder,
|
|
64
|
+
onDidChangeState: emitter.event,
|
|
65
|
+
dispose: () => {
|
|
66
|
+
emitter.dispose();
|
|
67
|
+
this._stateEmitters.delete(session.id);
|
|
68
|
+
this._proxy.$releaseSession(session.id);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
resolveRequest: async (session, context, token) => {
|
|
73
|
+
const dto = await this._proxy.$resolveRequest(handle, session.id, context, token);
|
|
74
|
+
return {
|
|
75
|
+
session,
|
|
76
|
+
...dto
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
provideReply: async (request, progress, token) => {
|
|
80
|
+
const id = `${handle}_${request.session.id}`;
|
|
81
|
+
this._activeRequestProgressCallbacks.set(id, progress);
|
|
82
|
+
try {
|
|
83
|
+
const requestDto = {
|
|
84
|
+
message: request.message,
|
|
85
|
+
variables: request.variables
|
|
86
|
+
};
|
|
87
|
+
const dto = await this._proxy.$provideReply(handle, request.session.id, requestDto, token);
|
|
88
|
+
return {
|
|
89
|
+
session: request.session,
|
|
90
|
+
...dto
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
this._activeRequestProgressCallbacks.delete(id);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
provideWelcomeMessage: (token) => {
|
|
98
|
+
return this._proxy.$provideWelcomeMessage(handle, token);
|
|
99
|
+
},
|
|
100
|
+
provideSlashCommands: (session, token) => {
|
|
101
|
+
return this._proxy.$provideSlashCommands(handle, session.id, token);
|
|
102
|
+
},
|
|
103
|
+
provideFollowups: (session, token) => {
|
|
104
|
+
return this._proxy.$provideFollowups(handle, session.id, token);
|
|
105
|
+
},
|
|
106
|
+
removeRequest: (session, requestId) => {
|
|
107
|
+
return this._proxy.$removeRequest(handle, session.id, requestId);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
this._providerRegistrations.set(handle, unreg);
|
|
111
|
+
}
|
|
112
|
+
async $acceptResponseProgress(handle, sessionId, progress, responsePartHandle) {
|
|
113
|
+
const id = `${handle}_${sessionId}`;
|
|
114
|
+
if ('placeholder' in progress) {
|
|
115
|
+
const responsePartId = `${id}_${++this._responsePartHandlePool}`;
|
|
116
|
+
const deferredContentPromise = ( new DeferredPromise());
|
|
117
|
+
this._activeResponsePartPromises.set(responsePartId, deferredContentPromise);
|
|
118
|
+
this._activeRequestProgressCallbacks.get(id)?.({ ...progress, resolvedContent: deferredContentPromise.p });
|
|
119
|
+
return this._responsePartHandlePool;
|
|
120
|
+
}
|
|
121
|
+
else if (responsePartHandle) {
|
|
122
|
+
const responsePartId = `${id}_${responsePartHandle}`;
|
|
123
|
+
const deferredContentPromise = this._activeResponsePartPromises.get(responsePartId);
|
|
124
|
+
if (deferredContentPromise && isCompleteInteractiveProgressTreeData(progress)) {
|
|
125
|
+
const withRevivedUris = revive(progress);
|
|
126
|
+
deferredContentPromise.complete(withRevivedUris);
|
|
127
|
+
this._activeResponsePartPromises.delete(responsePartId);
|
|
128
|
+
}
|
|
129
|
+
else if (deferredContentPromise && 'content' in progress) {
|
|
130
|
+
deferredContentPromise.complete(progress.content);
|
|
131
|
+
this._activeResponsePartPromises.delete(responsePartId);
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (isCompleteInteractiveProgressTreeData(progress)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if ('documents' in progress) {
|
|
139
|
+
const usedContext = {
|
|
140
|
+
documents: ( progress.documents.map(({ uri, version, ranges }) => ({
|
|
141
|
+
uri: URI.revive(uri),
|
|
142
|
+
version,
|
|
143
|
+
ranges,
|
|
144
|
+
}))),
|
|
145
|
+
};
|
|
146
|
+
this._activeRequestProgressCallbacks.get(id)?.(usedContext);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
this._activeRequestProgressCallbacks.get(id)?.(progress);
|
|
150
|
+
}
|
|
151
|
+
async $acceptChatState(sessionId, state) {
|
|
152
|
+
this._stateEmitters.get(sessionId)?.fire(state);
|
|
153
|
+
}
|
|
154
|
+
$addRequest(context) {
|
|
155
|
+
this._chatService.addRequest(context);
|
|
156
|
+
}
|
|
157
|
+
async $sendRequestToProvider(providerId, message) {
|
|
158
|
+
const widget = await this._chatWidgetService.revealViewForProvider(providerId);
|
|
159
|
+
if (widget && widget.viewModel) {
|
|
160
|
+
this._chatService.sendRequestToProvider(widget.viewModel.sessionId, message);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async $unregisterChatProvider(handle) {
|
|
164
|
+
this._providerRegistrations.deleteAndDispose(handle);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
MainThreadChat = __decorate([
|
|
168
|
+
extHostNamedCustomer(MainContext.MainThreadChat),
|
|
169
|
+
( __param(1, IChatService)),
|
|
170
|
+
( __param(2, IChatWidgetService)),
|
|
171
|
+
( __param(3, IChatContributionService))
|
|
172
|
+
], MainThreadChat);
|
|
173
|
+
|
|
174
|
+
export { MainThreadChat };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { DisposableMap } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
3
|
+
import { revive } from 'monaco-editor/esm/vs/base/common/marshalling.js';
|
|
4
|
+
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
5
|
+
import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
6
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
7
|
+
|
|
8
|
+
let MainThreadChatAgents = class MainThreadChatAgents {
|
|
9
|
+
constructor(extHostContext, _chatAgentService) {
|
|
10
|
+
this._chatAgentService = _chatAgentService;
|
|
11
|
+
this._agents = ( new DisposableMap());
|
|
12
|
+
this._pendingProgress = ( new Map());
|
|
13
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostChatAgents));
|
|
14
|
+
}
|
|
15
|
+
$unregisterAgent(handle) {
|
|
16
|
+
this._agents.deleteAndDispose(handle);
|
|
17
|
+
}
|
|
18
|
+
dispose() {
|
|
19
|
+
this._agents.clearAndDisposeAll();
|
|
20
|
+
}
|
|
21
|
+
$registerAgent(handle, name, metadata) {
|
|
22
|
+
if (!this._chatAgentService.hasAgent(name)) {
|
|
23
|
+
this._chatAgentService.registerAgentData({
|
|
24
|
+
id: name,
|
|
25
|
+
metadata: revive(metadata)
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const d = this._chatAgentService.registerAgentCallback(name, async (prompt, progress, history, token) => {
|
|
29
|
+
const requestId = Math.random();
|
|
30
|
+
this._pendingProgress.set(requestId, progress);
|
|
31
|
+
try {
|
|
32
|
+
return await this._proxy.$invokeAgent(handle, requestId, prompt, { history }, token);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
this._pendingProgress.delete(requestId);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
this._agents.set(handle, d);
|
|
39
|
+
}
|
|
40
|
+
async $handleProgressChunk(requestId, chunk) {
|
|
41
|
+
this._pendingProgress.get(requestId)?.report(revive(chunk));
|
|
42
|
+
}
|
|
43
|
+
$unregisterCommand(handle) {
|
|
44
|
+
this._agents.deleteAndDispose(handle);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
MainThreadChatAgents = __decorate([
|
|
48
|
+
extHostNamedCustomer(MainContext.MainThreadChatAgents),
|
|
49
|
+
( __param(1, IChatAgentService))
|
|
50
|
+
], MainThreadChatAgents);
|
|
51
|
+
|
|
52
|
+
export { MainThreadChatAgents };
|