@codingame/monaco-vscode-extensions-service-override 4.1.0 → 4.1.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/_virtual/semver.js +3 -0
- package/extensions.js +6 -6
- package/external/vscode-semver/semver.js +985 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +8 -0
- package/package.json +9 -9
- package/vscode/src/vs/base/common/console.js +62 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagementCLI.js +497 -0
- package/vscode/src/vs/platform/extensionResourceLoader/browser/extensionResourceLoaderService.js +44 -0
- package/vscode/src/vs/platform/lifecycle/common/lifecycle.js +27 -0
- package/vscode/src/vs/platform/remote/common/managedSocket.js +98 -0
- package/vscode/src/vs/workbench/api/browser/extensionHost.contribution.js +104 -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 +254 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadBulkEdits.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCLICommands.js +103 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +70 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +207 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatVariables.js +41 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadClipboard.js +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCodeInsets.js +108 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +98 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +560 -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 +579 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +435 -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 +79 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDocuments.js +253 -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 +414 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +501 -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 +208 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +369 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadInlineChat.js +72 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadInteractive.js +28 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +50 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLabelService.js +27 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +1016 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguageModels.js +185 -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 +137 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +194 -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 +374 -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/mainThreadProfileContentHandlers.js +38 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadProgress.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickDiff.js +42 -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 +493 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSaveParticipant.js +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSearch.js +168 -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/mainThreadSpeech.js +99 -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 +409 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTerminalShellIntegration.js +51 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +219 -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 +312 -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 +268 -0
- package/vscode/src/vs/workbench/api/common/shared/dataTransferCache.js +35 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customTextEditorModel.js +76 -0
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/contributedOpeners.js +83 -0
- package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +285 -0
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +276 -0
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerFileSystemProvider.js +52 -0
- package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +1149 -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 +512 -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/lazyCreateExtensionHostManager.js +161 -0
- package/vscode/src/vs/workbench/services/extensions/common/remoteConsoleUtil.js +49 -0
- package/vscode/src/vs/workbench/services/extensions/common/remoteExtensionHost.js +222 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
3
|
+
import { isWeb } from 'vscode/vscode/vs/base/common/platform';
|
|
4
|
+
import { isString } from 'vscode/vscode/vs/base/common/types';
|
|
5
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
6
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
7
|
+
import { CommandsRegistry, ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
8
|
+
import { IExtensionManagementService, IExtensionGalleryService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement';
|
|
9
|
+
import { ExtensionManagementCLI } from '../../../platform/extensionManagement/common/extensionManagementCLI.js';
|
|
10
|
+
import { getExtensionId } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
|
|
11
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
|
+
import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
|
|
13
|
+
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
|
|
14
|
+
import { AbstractMessageLogger } from 'vscode/vscode/vs/platform/log/common/log';
|
|
15
|
+
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
16
|
+
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
|
|
17
|
+
import { IExtensionManagementServerService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionManagement';
|
|
18
|
+
import { IExtensionManifestPropertiesService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService';
|
|
19
|
+
|
|
20
|
+
CommandsRegistry.registerCommand('_remoteCLI.openExternal', function (accessor, uri) {
|
|
21
|
+
const openerService = accessor.get(IOpenerService);
|
|
22
|
+
return openerService.open(isString(uri) ? uri : URI.revive(uri), { openExternal: true, allowTunneling: true });
|
|
23
|
+
});
|
|
24
|
+
CommandsRegistry.registerCommand('_remoteCLI.windowOpen', function (accessor, toOpen, options) {
|
|
25
|
+
const commandService = accessor.get(ICommandService);
|
|
26
|
+
if (!toOpen.length) {
|
|
27
|
+
return commandService.executeCommand('_files.newWindow', options);
|
|
28
|
+
}
|
|
29
|
+
return commandService.executeCommand('_files.windowOpen', toOpen, options);
|
|
30
|
+
});
|
|
31
|
+
CommandsRegistry.registerCommand('_remoteCLI.getSystemStatus', function (accessor) {
|
|
32
|
+
const commandService = accessor.get(ICommandService);
|
|
33
|
+
return commandService.executeCommand('_issues.getSystemStatus');
|
|
34
|
+
});
|
|
35
|
+
CommandsRegistry.registerCommand('_remoteCLI.manageExtensions', async function (accessor, args) {
|
|
36
|
+
const instantiationService = accessor.get(IInstantiationService);
|
|
37
|
+
const extensionManagementServerService = accessor.get(IExtensionManagementServerService);
|
|
38
|
+
const remoteExtensionManagementService = extensionManagementServerService.remoteExtensionManagementServer?.extensionManagementService;
|
|
39
|
+
if (!remoteExtensionManagementService) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const lines = [];
|
|
43
|
+
const logger = new (class extends AbstractMessageLogger {
|
|
44
|
+
log(level, message) {
|
|
45
|
+
lines.push(message);
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
48
|
+
const cliService = instantiationService.createChild(( new ServiceCollection([IExtensionManagementService, remoteExtensionManagementService]))).createInstance(RemoteExtensionManagementCLI, logger);
|
|
49
|
+
if (args.list) {
|
|
50
|
+
await cliService.listExtensions(!!args.list.showVersions, args.list.category, undefined);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const revive = (inputs) => ( inputs.map(input => isString(input) ? input : URI.revive(input)));
|
|
54
|
+
if (Array.isArray(args.install) && args.install.length) {
|
|
55
|
+
try {
|
|
56
|
+
await cliService.installExtensions(revive(args.install), [], { isMachineScoped: true }, !!args.force);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
lines.push(e.message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(args.uninstall) && args.uninstall.length) {
|
|
63
|
+
try {
|
|
64
|
+
await cliService.uninstallExtensions(revive(args.uninstall), !!args.force, undefined);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
lines.push(e.message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return lines.join('\n');
|
|
72
|
+
});
|
|
73
|
+
let RemoteExtensionManagementCLI = class RemoteExtensionManagementCLI extends ExtensionManagementCLI {
|
|
74
|
+
constructor(logger, extensionManagementService, extensionGalleryService, labelService, envService, _extensionManifestPropertiesService) {
|
|
75
|
+
super(logger, extensionManagementService, extensionGalleryService);
|
|
76
|
+
this._extensionManifestPropertiesService = _extensionManifestPropertiesService;
|
|
77
|
+
const remoteAuthority = envService.remoteAuthority;
|
|
78
|
+
this._location = remoteAuthority ? labelService.getHostLabel(Schemas.vscodeRemote, remoteAuthority) : undefined;
|
|
79
|
+
}
|
|
80
|
+
get location() {
|
|
81
|
+
return this._location;
|
|
82
|
+
}
|
|
83
|
+
validateExtensionKind(manifest) {
|
|
84
|
+
if (!this._extensionManifestPropertiesService.canExecuteOnWorkspace(manifest)
|
|
85
|
+
&& !(isWeb && this._extensionManifestPropertiesService.canExecuteOnWeb(manifest))) {
|
|
86
|
+
this.logger.info(( localizeWithPath(
|
|
87
|
+
'vs/workbench/api/browser/mainThreadCLICommands',
|
|
88
|
+
'cannot be installed',
|
|
89
|
+
"Cannot install the '{0}' extension because it is declared to not run in this setup.",
|
|
90
|
+
getExtensionId(manifest.publisher, manifest.name)
|
|
91
|
+
)));
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
RemoteExtensionManagementCLI = ( __decorate([
|
|
98
|
+
( __param(1, IExtensionManagementService)),
|
|
99
|
+
( __param(2, IExtensionGalleryService)),
|
|
100
|
+
( __param(3, ILabelService)),
|
|
101
|
+
( __param(4, IWorkbenchEnvironmentService)),
|
|
102
|
+
( __param(5, IExtensionManifestPropertiesService))
|
|
103
|
+
], RemoteExtensionManagementCLI));
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
3
|
+
import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
5
|
+
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
6
|
+
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
7
|
+
import { IChatContributionService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContributionService';
|
|
8
|
+
import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
|
|
9
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
10
|
+
|
|
11
|
+
let MainThreadChat = class MainThreadChat extends Disposable {
|
|
12
|
+
constructor(extHostContext, _chatService, _chatWidgetService, chatContribService) {
|
|
13
|
+
super();
|
|
14
|
+
this._chatService = _chatService;
|
|
15
|
+
this._chatWidgetService = _chatWidgetService;
|
|
16
|
+
this.chatContribService = chatContribService;
|
|
17
|
+
this._providerRegistrations = this._register(( new DisposableMap()));
|
|
18
|
+
this._stateEmitters = ( new Map());
|
|
19
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostChat));
|
|
20
|
+
}
|
|
21
|
+
$transferChatSession(sessionId, toWorkspace) {
|
|
22
|
+
const sessionIdStr = this._chatService.getSessionId(sessionId);
|
|
23
|
+
if (!sessionIdStr) {
|
|
24
|
+
throw new Error(`Failed to transfer session. Unknown session provider ID: ${sessionId}`);
|
|
25
|
+
}
|
|
26
|
+
const widget = this._chatWidgetService.getWidgetBySessionId(sessionIdStr);
|
|
27
|
+
const inputValue = widget?.inputEditor.getValue() ?? '';
|
|
28
|
+
this._chatService.transferChatSession({ sessionId: sessionIdStr, inputValue: inputValue }, URI.revive(toWorkspace));
|
|
29
|
+
}
|
|
30
|
+
async $registerChatProvider(handle, id) {
|
|
31
|
+
const registration = this.chatContribService.registeredProviders.find(staticProvider => staticProvider.id === id);
|
|
32
|
+
if (!registration) {
|
|
33
|
+
throw new Error(`Provider ${id} must be declared in the package.json.`);
|
|
34
|
+
}
|
|
35
|
+
const unreg = this._chatService.registerProvider({
|
|
36
|
+
id,
|
|
37
|
+
prepareSession: async (token) => {
|
|
38
|
+
const session = await this._proxy.$prepareChat(handle, token);
|
|
39
|
+
if (!session) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const emitter = ( new Emitter());
|
|
43
|
+
this._stateEmitters.set(session.id, emitter);
|
|
44
|
+
return {
|
|
45
|
+
id: session.id,
|
|
46
|
+
dispose: () => {
|
|
47
|
+
emitter.dispose();
|
|
48
|
+
this._stateEmitters.delete(session.id);
|
|
49
|
+
this._proxy.$releaseSession(session.id);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
this._providerRegistrations.set(handle, unreg);
|
|
55
|
+
}
|
|
56
|
+
async $acceptChatState(sessionId, state) {
|
|
57
|
+
this._stateEmitters.get(sessionId)?.fire(state);
|
|
58
|
+
}
|
|
59
|
+
async $unregisterChatProvider(handle) {
|
|
60
|
+
this._providerRegistrations.deleteAndDispose(handle);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
MainThreadChat = __decorate([
|
|
64
|
+
extHostNamedCustomer(MainContext.MainThreadChat),
|
|
65
|
+
( __param(1, IChatService)),
|
|
66
|
+
( __param(2, IChatWidgetService)),
|
|
67
|
+
( __param(3, IChatContributionService))
|
|
68
|
+
], MainThreadChat);
|
|
69
|
+
|
|
70
|
+
export { MainThreadChat };
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import { revive } from 'vscode/vscode/vs/base/common/marshalling';
|
|
4
|
+
import { escapeRegExpCharacters } from 'vscode/vscode/vs/base/common/strings';
|
|
5
|
+
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
6
|
+
import { getWordAtText } from 'vscode/vscode/vs/editor/common/core/wordHelper';
|
|
7
|
+
import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
|
|
8
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
|
+
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
10
|
+
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
11
|
+
import { ChatInputPart } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatInputPart';
|
|
12
|
+
import { AddDynamicVariableAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
|
|
13
|
+
import { IChatAgentService, ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
14
|
+
import { ChatRequestAgentPart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
15
|
+
import { ChatRequestParser } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
|
|
16
|
+
import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
|
|
17
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
18
|
+
|
|
19
|
+
let MainThreadChatAgents2 = class MainThreadChatAgents2 extends Disposable {
|
|
20
|
+
constructor(extHostContext, _chatAgentService, _chatService, _languageFeaturesService, _chatWidgetService, _instantiationService) {
|
|
21
|
+
super();
|
|
22
|
+
this._chatAgentService = _chatAgentService;
|
|
23
|
+
this._chatService = _chatService;
|
|
24
|
+
this._languageFeaturesService = _languageFeaturesService;
|
|
25
|
+
this._chatWidgetService = _chatWidgetService;
|
|
26
|
+
this._instantiationService = _instantiationService;
|
|
27
|
+
this._agents = this._register(( new DisposableMap()));
|
|
28
|
+
this._agentCompletionProviders = this._register(( new DisposableMap()));
|
|
29
|
+
this._pendingProgress = ( new Map());
|
|
30
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostChatAgents2));
|
|
31
|
+
this._register(this._chatService.onDidDisposeSession(e => {
|
|
32
|
+
this._proxy.$releaseSession(e.sessionId);
|
|
33
|
+
}));
|
|
34
|
+
this._register(this._chatService.onDidPerformUserAction(e => {
|
|
35
|
+
if (typeof e.agentId === 'string') {
|
|
36
|
+
for (const [handle, agent] of this._agents) {
|
|
37
|
+
if (agent.id === e.agentId) {
|
|
38
|
+
if (e.action.kind === 'vote') {
|
|
39
|
+
this._proxy.$acceptFeedback(handle, e.result ?? {}, e.action.direction);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this._proxy.$acceptAction(handle, e.result || {}, e);
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
$unregisterAgent(handle) {
|
|
51
|
+
this._agents.deleteAndDispose(handle);
|
|
52
|
+
}
|
|
53
|
+
$registerAgent(handle, extension, id, metadata, dynamicProps) {
|
|
54
|
+
const staticAgentRegistration = this._chatAgentService.getAgent(id);
|
|
55
|
+
if (!staticAgentRegistration && !dynamicProps) {
|
|
56
|
+
if (this._chatAgentService.getAgentsByName(id).length) {
|
|
57
|
+
throw new Error(`chatParticipant must be declared with an ID in package.json. The "id" property may be missing! "${id}"`);
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`chatParticipant must be declared in package.json: ${id}`);
|
|
60
|
+
}
|
|
61
|
+
const impl = {
|
|
62
|
+
invoke: async (request, progress, history, token) => {
|
|
63
|
+
this._pendingProgress.set(request.requestId, progress);
|
|
64
|
+
try {
|
|
65
|
+
return (await this._proxy.$invokeAgent(handle, request, { history }, token)) ?? {};
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
this._pendingProgress.delete(request.requestId);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
provideFollowups: async (request, result, history, token) => {
|
|
72
|
+
if (!this._agents.get(handle)?.hasFollowups) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
return this._proxy.$provideFollowups(request, handle, result, { history }, token);
|
|
76
|
+
},
|
|
77
|
+
provideWelcomeMessage: (token) => {
|
|
78
|
+
return this._proxy.$provideWelcomeMessage(handle, token);
|
|
79
|
+
},
|
|
80
|
+
provideSampleQuestions: (token) => {
|
|
81
|
+
return this._proxy.$provideSampleQuestions(handle, token);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
let disposable;
|
|
85
|
+
if (!staticAgentRegistration && dynamicProps) {
|
|
86
|
+
disposable = this._chatAgentService.registerDynamicAgent({
|
|
87
|
+
id,
|
|
88
|
+
name: dynamicProps.name,
|
|
89
|
+
description: dynamicProps.description,
|
|
90
|
+
extensionId: extension,
|
|
91
|
+
metadata: revive(metadata),
|
|
92
|
+
slashCommands: [],
|
|
93
|
+
locations: [ChatAgentLocation.Panel]
|
|
94
|
+
}, impl);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
disposable = this._chatAgentService.registerAgentImplementation(id, impl);
|
|
98
|
+
}
|
|
99
|
+
this._agents.set(handle, {
|
|
100
|
+
id: id,
|
|
101
|
+
extensionId: extension,
|
|
102
|
+
dispose: disposable.dispose,
|
|
103
|
+
hasFollowups: metadata.hasFollowups
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
$updateAgent(handle, metadataUpdate) {
|
|
107
|
+
const data = this._agents.get(handle);
|
|
108
|
+
if (!data) {
|
|
109
|
+
throw new Error(`No agent with handle ${handle} registered`);
|
|
110
|
+
}
|
|
111
|
+
data.hasFollowups = metadataUpdate.hasFollowups;
|
|
112
|
+
this._chatAgentService.updateAgent(data.id, revive(metadataUpdate));
|
|
113
|
+
}
|
|
114
|
+
async $handleProgressChunk(requestId, progress) {
|
|
115
|
+
const revivedProgress = revive(progress);
|
|
116
|
+
this._pendingProgress.get(requestId)?.(revivedProgress);
|
|
117
|
+
}
|
|
118
|
+
$registerAgentCompletionsProvider(handle, triggerCharacters) {
|
|
119
|
+
this._agentCompletionProviders.set(handle, this._languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
120
|
+
_debugDisplayName: 'chatAgentCompletions:' + handle,
|
|
121
|
+
triggerCharacters,
|
|
122
|
+
provideCompletionItems: async (model, position, _context, token) => {
|
|
123
|
+
const widget = this._chatWidgetService.getWidgetByInputUri(model.uri);
|
|
124
|
+
if (!widget || !widget.viewModel) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const triggerCharsPart = ( triggerCharacters.map(c => escapeRegExpCharacters(c))).join('');
|
|
128
|
+
const wordRegex = ( new RegExp(`[${triggerCharsPart}]\\S*`, 'g'));
|
|
129
|
+
const query = getWordAtText(position.column, wordRegex, model.getLineContent(position.lineNumber), 0)?.word ?? '';
|
|
130
|
+
if (query && !( triggerCharacters.some(c => query.startsWith(c)))) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const parsedRequest = this._instantiationService.createInstance(ChatRequestParser).parseChatRequest(widget.viewModel.sessionId, model.getValue()).parts;
|
|
134
|
+
const agentPart = parsedRequest.find((part) => part instanceof ChatRequestAgentPart);
|
|
135
|
+
const thisAgentId = this._agents.get(handle)?.id;
|
|
136
|
+
if (agentPart?.agent.id !== thisAgentId) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const range = computeCompletionRanges(model, position, wordRegex);
|
|
140
|
+
if (!range) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const result = await this._proxy.$invokeCompletionProvider(handle, query, token);
|
|
144
|
+
const variableItems = ( result.map(v => {
|
|
145
|
+
const insertText = v.insertText ?? (typeof v.label === 'string' ? v.label : v.label.label);
|
|
146
|
+
const rangeAfterInsert = ( new Range(
|
|
147
|
+
range.insert.startLineNumber,
|
|
148
|
+
range.insert.startColumn,
|
|
149
|
+
range.insert.endLineNumber,
|
|
150
|
+
range.insert.startColumn + insertText.length
|
|
151
|
+
));
|
|
152
|
+
return {
|
|
153
|
+
label: v.label,
|
|
154
|
+
range,
|
|
155
|
+
insertText: insertText + ' ',
|
|
156
|
+
kind: 18 ,
|
|
157
|
+
detail: v.detail,
|
|
158
|
+
documentation: v.documentation,
|
|
159
|
+
command: { id: AddDynamicVariableAction.ID, title: '', arguments: [{ widget, range: rangeAfterInsert, variableData: revive(v.values) }] }
|
|
160
|
+
};
|
|
161
|
+
}));
|
|
162
|
+
return {
|
|
163
|
+
suggestions: variableItems
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
$unregisterAgentCompletionsProvider(handle) {
|
|
169
|
+
this._agentCompletionProviders.deleteAndDispose(handle);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
MainThreadChatAgents2 = __decorate([
|
|
173
|
+
extHostNamedCustomer(MainContext.MainThreadChatAgents2),
|
|
174
|
+
( __param(1, IChatAgentService)),
|
|
175
|
+
( __param(2, IChatService)),
|
|
176
|
+
( __param(3, ILanguageFeaturesService)),
|
|
177
|
+
( __param(4, IChatWidgetService)),
|
|
178
|
+
( __param(5, IInstantiationService))
|
|
179
|
+
], MainThreadChatAgents2);
|
|
180
|
+
function computeCompletionRanges(model, position, reg) {
|
|
181
|
+
const varWord = getWordAtText(position.column, reg, model.getLineContent(position.lineNumber), 0);
|
|
182
|
+
if (!varWord && model.getWordUntilPosition(position).word) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
let insert;
|
|
186
|
+
let replace;
|
|
187
|
+
if (!varWord) {
|
|
188
|
+
insert = replace = Range.fromPositions(position);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
insert = ( new Range(
|
|
192
|
+
position.lineNumber,
|
|
193
|
+
varWord.startColumn,
|
|
194
|
+
position.lineNumber,
|
|
195
|
+
position.column
|
|
196
|
+
));
|
|
197
|
+
replace = ( new Range(
|
|
198
|
+
position.lineNumber,
|
|
199
|
+
varWord.startColumn,
|
|
200
|
+
position.lineNumber,
|
|
201
|
+
varWord.endColumn
|
|
202
|
+
));
|
|
203
|
+
}
|
|
204
|
+
return { insert, replace };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export { MainThreadChatAgents2 };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import { revive } from 'vscode/vscode/vs/base/common/marshalling';
|
|
4
|
+
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
5
|
+
import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables';
|
|
6
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
7
|
+
|
|
8
|
+
let MainThreadChatVariables = class MainThreadChatVariables {
|
|
9
|
+
constructor(extHostContext, _chatVariablesService) {
|
|
10
|
+
this._chatVariablesService = _chatVariablesService;
|
|
11
|
+
this._variables = ( new DisposableMap());
|
|
12
|
+
this._pendingProgress = ( new Map());
|
|
13
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostChatVariables));
|
|
14
|
+
}
|
|
15
|
+
dispose() {
|
|
16
|
+
this._variables.clearAndDisposeAll();
|
|
17
|
+
}
|
|
18
|
+
$registerVariable(handle, data) {
|
|
19
|
+
const registration = this._chatVariablesService.registerVariable(data, async (messageText, _arg, model, progress, token) => {
|
|
20
|
+
const varRequestId = `${model.sessionId}-${handle}`;
|
|
21
|
+
this._pendingProgress.set(varRequestId, progress);
|
|
22
|
+
const result = revive(await this._proxy.$resolveVariable(handle, varRequestId, messageText, token));
|
|
23
|
+
this._pendingProgress.delete(varRequestId);
|
|
24
|
+
return result;
|
|
25
|
+
});
|
|
26
|
+
this._variables.set(handle, registration);
|
|
27
|
+
}
|
|
28
|
+
async $handleProgressChunk(requestId, progress) {
|
|
29
|
+
const revivedProgress = revive(progress);
|
|
30
|
+
this._pendingProgress.get(requestId)?.(revivedProgress);
|
|
31
|
+
}
|
|
32
|
+
$unregisterVariable(handle) {
|
|
33
|
+
this._variables.deleteAndDispose(handle);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
MainThreadChatVariables = __decorate([
|
|
37
|
+
extHostNamedCustomer(MainContext.MainThreadChatVariables),
|
|
38
|
+
( __param(1, IChatVariablesService))
|
|
39
|
+
], MainThreadChatVariables);
|
|
40
|
+
|
|
41
|
+
export { MainThreadChatVariables };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
3
|
+
import { MainContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
4
|
+
import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
|
|
5
|
+
|
|
6
|
+
let MainThreadClipboard = class MainThreadClipboard {
|
|
7
|
+
constructor(_context, _clipboardService) {
|
|
8
|
+
this._clipboardService = _clipboardService;
|
|
9
|
+
}
|
|
10
|
+
dispose() {
|
|
11
|
+
}
|
|
12
|
+
$readText() {
|
|
13
|
+
return this._clipboardService.readText();
|
|
14
|
+
}
|
|
15
|
+
$writeText(value) {
|
|
16
|
+
return this._clipboardService.writeText(value);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
MainThreadClipboard = __decorate([
|
|
20
|
+
extHostNamedCustomer(MainContext.MainThreadClipboard),
|
|
21
|
+
( __param(1, IClipboardService))
|
|
22
|
+
], MainThreadClipboard);
|
|
23
|
+
|
|
24
|
+
export { MainThreadClipboard };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { getWindow } from 'vscode/vscode/vs/base/browser/dom';
|
|
3
|
+
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
5
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
6
|
+
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
7
|
+
import { reviveWebviewContentOptions } from './mainThreadWebviews.js';
|
|
8
|
+
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
9
|
+
import { IWebviewService } from 'vscode/vscode/vs/workbench/contrib/webview/browser/webview';
|
|
10
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
11
|
+
|
|
12
|
+
class EditorWebviewZone {
|
|
13
|
+
constructor(editor, line, height, webview) {
|
|
14
|
+
this.editor = editor;
|
|
15
|
+
this.line = line;
|
|
16
|
+
this.height = height;
|
|
17
|
+
this.webview = webview;
|
|
18
|
+
this.domNode = document.createElement('div');
|
|
19
|
+
this.domNode.style.zIndex = '10';
|
|
20
|
+
this.afterLineNumber = line;
|
|
21
|
+
this.afterColumn = 1;
|
|
22
|
+
this.heightInLines = height;
|
|
23
|
+
editor.changeViewZones(accessor => this._id = accessor.addZone(this));
|
|
24
|
+
webview.mountTo(this.domNode, getWindow(editor.getDomNode()));
|
|
25
|
+
}
|
|
26
|
+
dispose() {
|
|
27
|
+
this.editor.changeViewZones(accessor => this._id && accessor.removeZone(this._id));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
let MainThreadEditorInsets = class MainThreadEditorInsets {
|
|
31
|
+
constructor(context, _editorService, _webviewService) {
|
|
32
|
+
this._editorService = _editorService;
|
|
33
|
+
this._webviewService = _webviewService;
|
|
34
|
+
this._disposables = ( new DisposableStore());
|
|
35
|
+
this._insets = ( new Map());
|
|
36
|
+
this._proxy = ( context.getProxy(ExtHostContext.ExtHostEditorInsets));
|
|
37
|
+
}
|
|
38
|
+
dispose() {
|
|
39
|
+
this._disposables.dispose();
|
|
40
|
+
}
|
|
41
|
+
async $createEditorInset(handle, id, uri, line, height, options, extensionId, extensionLocation) {
|
|
42
|
+
let editor;
|
|
43
|
+
id = id.substr(0, id.indexOf(','));
|
|
44
|
+
for (const candidate of this._editorService.listCodeEditors()) {
|
|
45
|
+
if (candidate.getId() === id && candidate.hasModel() && isEqual(candidate.getModel().uri, URI.revive(uri))) {
|
|
46
|
+
editor = candidate;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!editor) {
|
|
51
|
+
setTimeout(() => this._proxy.$onDidDispose(handle));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const disposables = ( new DisposableStore());
|
|
55
|
+
const webview = this._webviewService.createWebviewElement({
|
|
56
|
+
title: undefined,
|
|
57
|
+
options: {
|
|
58
|
+
enableFindWidget: false,
|
|
59
|
+
},
|
|
60
|
+
contentOptions: reviveWebviewContentOptions(options),
|
|
61
|
+
extension: { id: extensionId, location: URI.revive(extensionLocation) }
|
|
62
|
+
});
|
|
63
|
+
const webviewZone = ( new EditorWebviewZone(editor, line, height, webview));
|
|
64
|
+
const remove = () => {
|
|
65
|
+
disposables.dispose();
|
|
66
|
+
this._proxy.$onDidDispose(handle);
|
|
67
|
+
this._insets.delete(handle);
|
|
68
|
+
};
|
|
69
|
+
disposables.add(editor.onDidChangeModel(remove));
|
|
70
|
+
disposables.add(editor.onDidDispose(remove));
|
|
71
|
+
disposables.add(webviewZone);
|
|
72
|
+
disposables.add(webview);
|
|
73
|
+
disposables.add(webview.onMessage(msg => this._proxy.$onDidReceiveMessage(handle, msg.message)));
|
|
74
|
+
this._insets.set(handle, webviewZone);
|
|
75
|
+
}
|
|
76
|
+
$disposeEditorInset(handle) {
|
|
77
|
+
const inset = this.getInset(handle);
|
|
78
|
+
this._insets.delete(handle);
|
|
79
|
+
inset.dispose();
|
|
80
|
+
}
|
|
81
|
+
$setHtml(handle, value) {
|
|
82
|
+
const inset = this.getInset(handle);
|
|
83
|
+
inset.webview.setHtml(value);
|
|
84
|
+
}
|
|
85
|
+
$setOptions(handle, options) {
|
|
86
|
+
const inset = this.getInset(handle);
|
|
87
|
+
inset.webview.contentOptions = reviveWebviewContentOptions(options);
|
|
88
|
+
}
|
|
89
|
+
async $postMessage(handle, value) {
|
|
90
|
+
const inset = this.getInset(handle);
|
|
91
|
+
inset.webview.postMessage(value);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
getInset(handle) {
|
|
95
|
+
const inset = this._insets.get(handle);
|
|
96
|
+
if (!inset) {
|
|
97
|
+
throw new Error('Unknown inset');
|
|
98
|
+
}
|
|
99
|
+
return inset;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
MainThreadEditorInsets = __decorate([
|
|
103
|
+
extHostNamedCustomer(MainContext.MainThreadEditorInsets),
|
|
104
|
+
( __param(1, ICodeEditorService)),
|
|
105
|
+
( __param(2, IWebviewService))
|
|
106
|
+
], MainThreadEditorInsets);
|
|
107
|
+
|
|
108
|
+
export { MainThreadEditorInsets };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import { revive } from 'vscode/vscode/vs/base/common/marshalling';
|
|
4
|
+
import { ICommandService, CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
5
|
+
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
6
|
+
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
7
|
+
import { SerializableObjectWithBuffers } from 'vscode/vscode/vs/workbench/services/extensions/common/proxyIdentifier';
|
|
8
|
+
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
9
|
+
import { isString } from 'vscode/vscode/vs/base/common/types';
|
|
10
|
+
|
|
11
|
+
let MainThreadCommands = class MainThreadCommands {
|
|
12
|
+
constructor(extHostContext, _commandService, _extensionService) {
|
|
13
|
+
this._commandService = _commandService;
|
|
14
|
+
this._extensionService = _extensionService;
|
|
15
|
+
this._commandRegistrations = ( new DisposableMap());
|
|
16
|
+
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostCommands));
|
|
17
|
+
this._generateCommandsDocumentationRegistration = CommandsRegistry.registerCommand('_generateCommandsDocumentation', () => this._generateCommandsDocumentation());
|
|
18
|
+
}
|
|
19
|
+
dispose() {
|
|
20
|
+
this._commandRegistrations.dispose();
|
|
21
|
+
this._generateCommandsDocumentationRegistration.dispose();
|
|
22
|
+
}
|
|
23
|
+
async _generateCommandsDocumentation() {
|
|
24
|
+
const result = await this._proxy.$getContributedCommandMetadata();
|
|
25
|
+
const commands = CommandsRegistry.getCommands();
|
|
26
|
+
for (const [id, command] of commands) {
|
|
27
|
+
if (command.metadata) {
|
|
28
|
+
result[id] = command.metadata;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const all = [];
|
|
32
|
+
for (const id in result) {
|
|
33
|
+
all.push('`' + id + '` - ' + _generateMarkdown(result[id]));
|
|
34
|
+
}
|
|
35
|
+
console.log(all.join('\n'));
|
|
36
|
+
}
|
|
37
|
+
$registerCommand(id) {
|
|
38
|
+
this._commandRegistrations.set(id, CommandsRegistry.registerCommand(id, (accessor, ...args) => {
|
|
39
|
+
return this._proxy.$executeContributedCommand(id, ...args).then(result => {
|
|
40
|
+
return revive(result);
|
|
41
|
+
});
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
$unregisterCommand(id) {
|
|
45
|
+
this._commandRegistrations.deleteAndDispose(id);
|
|
46
|
+
}
|
|
47
|
+
$fireCommandActivationEvent(id) {
|
|
48
|
+
const activationEvent = `onCommand:${id}`;
|
|
49
|
+
if (!this._extensionService.activationEventIsDone(activationEvent)) {
|
|
50
|
+
this._extensionService.activateByEvent(activationEvent);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async $executeCommand(id, args, retry) {
|
|
54
|
+
if (args instanceof SerializableObjectWithBuffers) {
|
|
55
|
+
args = args.value;
|
|
56
|
+
}
|
|
57
|
+
for (let i = 0; i < args.length; i++) {
|
|
58
|
+
args[i] = revive(args[i]);
|
|
59
|
+
}
|
|
60
|
+
if (retry && args.length > 0 && !CommandsRegistry.getCommand(id)) {
|
|
61
|
+
await this._extensionService.activateByEvent(`onCommand:${id}`);
|
|
62
|
+
throw new Error('$executeCommand:retry');
|
|
63
|
+
}
|
|
64
|
+
return this._commandService.executeCommand(id, ...args);
|
|
65
|
+
}
|
|
66
|
+
$getCommands() {
|
|
67
|
+
return Promise.resolve([...( CommandsRegistry.getCommands().keys())]);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
MainThreadCommands = __decorate([
|
|
71
|
+
extHostNamedCustomer(MainContext.MainThreadCommands),
|
|
72
|
+
( __param(1, ICommandService)),
|
|
73
|
+
( __param(2, IExtensionService))
|
|
74
|
+
], MainThreadCommands);
|
|
75
|
+
function _generateMarkdown(description) {
|
|
76
|
+
if (typeof description === 'string') {
|
|
77
|
+
return description;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const descriptionString = isString(description.description)
|
|
81
|
+
? description.description
|
|
82
|
+
: description.description.original;
|
|
83
|
+
const parts = [descriptionString];
|
|
84
|
+
parts.push('\n\n');
|
|
85
|
+
if (description.args) {
|
|
86
|
+
for (const arg of description.args) {
|
|
87
|
+
parts.push(`* _${arg.name}_ - ${arg.description || ''}\n`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (description.returns) {
|
|
91
|
+
parts.push(`* _(returns)_ - ${description.returns}`);
|
|
92
|
+
}
|
|
93
|
+
parts.push('\n\n');
|
|
94
|
+
return parts.join('');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { MainThreadCommands };
|