@codingame/monaco-vscode-extensions-service-override 3.2.3 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions.js +6 -87
- package/override/vs/platform/dialogs/common/dialogs.js +2 -0
- package/package.json +9 -9
- package/_virtual/semver.js +0 -3
- package/external/vscode-semver/semver.js +0 -985
- package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +0 -8
- package/vscode/src/vs/base/common/console.js +0 -59
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagementCLI.js +0 -497
- package/vscode/src/vs/platform/extensionResourceLoader/browser/extensionResourceLoaderService.js +0 -44
- package/vscode/src/vs/platform/lifecycle/common/lifecycle.js +0 -27
- package/vscode/src/vs/platform/remote/common/managedSocket.js +0 -98
- package/vscode/src/vs/workbench/api/browser/mainThreadAiEmbeddingVector.js +0 -31
- package/vscode/src/vs/workbench/api/browser/mainThreadAiRelatedInformation.js +0 -35
- package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +0 -227
- package/vscode/src/vs/workbench/api/browser/mainThreadBulkEdits.js +0 -68
- package/vscode/src/vs/workbench/api/browser/mainThreadCLICommands.js +0 -103
- package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +0 -83
- package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +0 -203
- package/vscode/src/vs/workbench/api/browser/mainThreadChatProvider.js +0 -201
- package/vscode/src/vs/workbench/api/browser/mainThreadChatVariables.js +0 -41
- package/vscode/src/vs/workbench/api/browser/mainThreadClipboard.js +0 -24
- package/vscode/src/vs/workbench/api/browser/mainThreadCodeInsets.js +0 -107
- package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +0 -98
- package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +0 -545
- package/vscode/src/vs/workbench/api/browser/mainThreadConfiguration.js +0 -80
- package/vscode/src/vs/workbench/api/browser/mainThreadConsole.js +0 -35
- package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +0 -578
- package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +0 -424
- package/vscode/src/vs/workbench/api/browser/mainThreadDecorations.js +0 -102
- package/vscode/src/vs/workbench/api/browser/mainThreadDiagnostics.js +0 -69
- package/vscode/src/vs/workbench/api/browser/mainThreadDialogs.js +0 -68
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentContentProviders.js +0 -79
- package/vscode/src/vs/workbench/api/browser/mainThreadDocuments.js +0 -253
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +0 -370
- package/vscode/src/vs/workbench/api/browser/mainThreadDownloadService.js +0 -22
- package/vscode/src/vs/workbench/api/browser/mainThreadEditSessionIdentityParticipant.js +0 -41
- package/vscode/src/vs/workbench/api/browser/mainThreadEditor.js +0 -414
- package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +0 -482
- package/vscode/src/vs/workbench/api/browser/mainThreadEditors.js +0 -227
- package/vscode/src/vs/workbench/api/browser/mainThreadErrors.js +0 -24
- package/vscode/src/vs/workbench/api/browser/mainThreadExtensionService.js +0 -317
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +0 -208
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +0 -374
- package/vscode/src/vs/workbench/api/browser/mainThreadInlineChat.js +0 -72
- package/vscode/src/vs/workbench/api/browser/mainThreadInteractive.js +0 -28
- package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +0 -50
- package/vscode/src/vs/workbench/api/browser/mainThreadLabelService.js +0 -27
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +0 -991
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguages.js +0 -78
- package/vscode/src/vs/workbench/api/browser/mainThreadLocalization.js +0 -35
- package/vscode/src/vs/workbench/api/browser/mainThreadLogService.js +0 -78
- package/vscode/src/vs/workbench/api/browser/mainThreadManagedSockets.js +0 -93
- package/vscode/src/vs/workbench/api/browser/mainThreadMessageService.js +0 -137
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +0 -194
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +0 -123
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +0 -188
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDto.js +0 -129
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +0 -131
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +0 -374
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +0 -25
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +0 -48
- package/vscode/src/vs/workbench/api/browser/mainThreadOutputService.js +0 -76
- package/vscode/src/vs/workbench/api/browser/mainThreadProfilContentHandlers.js +0 -38
- package/vscode/src/vs/workbench/api/browser/mainThreadProgress.js +0 -68
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickDiff.js +0 -42
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickOpen.js +0 -185
- package/vscode/src/vs/workbench/api/browser/mainThreadRemoteConnectionData.js +0 -30
- package/vscode/src/vs/workbench/api/browser/mainThreadSCM.js +0 -493
- package/vscode/src/vs/workbench/api/browser/mainThreadSaveParticipant.js +0 -49
- package/vscode/src/vs/workbench/api/browser/mainThreadSearch.js +0 -146
- package/vscode/src/vs/workbench/api/browser/mainThreadSecretState.js +0 -70
- package/vscode/src/vs/workbench/api/browser/mainThreadShare.js +0 -50
- package/vscode/src/vs/workbench/api/browser/mainThreadSpeech.js +0 -99
- package/vscode/src/vs/workbench/api/browser/mainThreadStatusBar.js +0 -53
- package/vscode/src/vs/workbench/api/browser/mainThreadStorage.js +0 -72
- package/vscode/src/vs/workbench/api/browser/mainThreadTask.js +0 -731
- package/vscode/src/vs/workbench/api/browser/mainThreadTelemetry.js +0 -53
- package/vscode/src/vs/workbench/api/browser/mainThreadTerminalService.js +0 -408
- package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +0 -195
- package/vscode/src/vs/workbench/api/browser/mainThreadTheming.js +0 -24
- package/vscode/src/vs/workbench/api/browser/mainThreadTimeline.js +0 -55
- package/vscode/src/vs/workbench/api/browser/mainThreadTreeViews.js +0 -312
- package/vscode/src/vs/workbench/api/browser/mainThreadTunnelService.js +0 -223
- package/vscode/src/vs/workbench/api/browser/mainThreadUriOpeners.js +0 -110
- package/vscode/src/vs/workbench/api/browser/mainThreadUrls.js +0 -61
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewManager.js +0 -29
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewPanels.js +0 -283
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewViews.js +0 -100
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviews.js +0 -135
- package/vscode/src/vs/workbench/api/browser/mainThreadWindow.js +0 -57
- package/vscode/src/vs/workbench/api/browser/mainThreadWorkspace.js +0 -268
- package/vscode/src/vs/workbench/api/common/shared/dataTransferCache.js +0 -35
- package/vscode/src/vs/workbench/contrib/customEditor/common/customTextEditorModel.js +0 -73
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/contributedOpeners.js +0 -83
- package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +0 -284
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +0 -276
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerFileSystemProvider.js +0 -52
- package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +0 -1138
- package/vscode/src/vs/workbench/services/extensions/common/extHostCustomers.js +0 -41
- package/vscode/src/vs/workbench/services/extensions/common/extensionDevOptions.js +0 -25
- package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +0 -512
- package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.js +0 -274
- package/vscode/src/vs/workbench/services/extensions/common/extensionStorageMigration.js +0 -58
- package/vscode/src/vs/workbench/services/extensions/common/extensionsProposedApi.js +0 -80
- package/vscode/src/vs/workbench/services/extensions/common/extensionsUtil.js +0 -64
- package/vscode/src/vs/workbench/services/extensions/common/lazyCreateExtensionHostManager.js +0 -161
- package/vscode/src/vs/workbench/services/extensions/common/remoteConsoleUtil.js +0 -49
- package/vscode/src/vs/workbench/services/extensions/common/remoteExtensionHost.js +0 -222
|
@@ -1,203 +0,0 @@
|
|
|
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 } 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.name === 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, name, metadata) {
|
|
54
|
-
const lastSlashCommands = ( new WeakMap());
|
|
55
|
-
const d = this._chatAgentService.registerAgent({
|
|
56
|
-
id: name,
|
|
57
|
-
extensionId: extension,
|
|
58
|
-
metadata: revive(metadata),
|
|
59
|
-
invoke: async (request, progress, history, token) => {
|
|
60
|
-
this._pendingProgress.set(request.requestId, progress);
|
|
61
|
-
try {
|
|
62
|
-
return (await this._proxy.$invokeAgent(handle, request, { history }, token)) ?? {};
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
this._pendingProgress.delete(request.requestId);
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
provideFollowups: async (request, result, token) => {
|
|
69
|
-
if (!this._agents.get(handle)?.hasFollowups) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
return this._proxy.$provideFollowups(request, handle, result, token);
|
|
73
|
-
},
|
|
74
|
-
getLastSlashCommands: (model) => {
|
|
75
|
-
return lastSlashCommands.get(model);
|
|
76
|
-
},
|
|
77
|
-
provideSlashCommands: async (model, history, token) => {
|
|
78
|
-
if (!this._agents.get(handle)?.hasSlashCommands) {
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
const commands = await this._proxy.$provideSlashCommands(handle, { history }, token);
|
|
82
|
-
if (model) {
|
|
83
|
-
lastSlashCommands.set(model, commands);
|
|
84
|
-
}
|
|
85
|
-
return commands;
|
|
86
|
-
},
|
|
87
|
-
provideWelcomeMessage: (token) => {
|
|
88
|
-
return this._proxy.$provideWelcomeMessage(handle, token);
|
|
89
|
-
},
|
|
90
|
-
provideSampleQuestions: (token) => {
|
|
91
|
-
return this._proxy.$provideSampleQuestions(handle, token);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
this._agents.set(handle, {
|
|
95
|
-
name,
|
|
96
|
-
dispose: d.dispose,
|
|
97
|
-
hasSlashCommands: metadata.hasSlashCommands,
|
|
98
|
-
hasFollowups: metadata.hasFollowups
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
$updateAgent(handle, metadataUpdate) {
|
|
102
|
-
const data = this._agents.get(handle);
|
|
103
|
-
if (!data) {
|
|
104
|
-
throw new Error(`No agent with handle ${handle} registered`);
|
|
105
|
-
}
|
|
106
|
-
data.hasSlashCommands = metadataUpdate.hasSlashCommands;
|
|
107
|
-
data.hasFollowups = metadataUpdate.hasFollowups;
|
|
108
|
-
this._chatAgentService.updateAgent(data.name, revive(metadataUpdate));
|
|
109
|
-
}
|
|
110
|
-
async $handleProgressChunk(requestId, progress) {
|
|
111
|
-
const revivedProgress = revive(progress);
|
|
112
|
-
this._pendingProgress.get(requestId)?.(revivedProgress);
|
|
113
|
-
}
|
|
114
|
-
$registerAgentCompletionsProvider(handle, triggerCharacters) {
|
|
115
|
-
this._agentCompletionProviders.set(handle, this._languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
116
|
-
_debugDisplayName: 'chatAgentCompletions:' + handle,
|
|
117
|
-
triggerCharacters,
|
|
118
|
-
provideCompletionItems: async (model, position, _context, token) => {
|
|
119
|
-
const widget = this._chatWidgetService.getWidgetByInputUri(model.uri);
|
|
120
|
-
if (!widget || !widget.viewModel) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const triggerCharsPart = ( triggerCharacters.map(c => escapeRegExpCharacters(c))).join('');
|
|
124
|
-
const wordRegex = ( new RegExp(`[${triggerCharsPart}]\\S*`, 'g'));
|
|
125
|
-
const query = getWordAtText(position.column, wordRegex, model.getLineContent(position.lineNumber), 0)?.word ?? '';
|
|
126
|
-
if (query && !( triggerCharacters.some(c => query.startsWith(c)))) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const parsedRequest = this._instantiationService.createInstance(ChatRequestParser).parseChatRequest(widget.viewModel.sessionId, model.getValue()).parts;
|
|
130
|
-
const agentPart = parsedRequest.find((part) => part instanceof ChatRequestAgentPart);
|
|
131
|
-
const thisAgentName = this._agents.get(handle)?.name;
|
|
132
|
-
if (agentPart?.agent.id !== thisAgentName) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const range = computeCompletionRanges(model, position, wordRegex);
|
|
136
|
-
if (!range) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
const result = await this._proxy.$invokeCompletionProvider(handle, query, token);
|
|
140
|
-
const variableItems = ( result.map(v => {
|
|
141
|
-
const insertText = v.insertText ?? (typeof v.label === 'string' ? v.label : v.label.label);
|
|
142
|
-
const rangeAfterInsert = ( new Range(
|
|
143
|
-
range.insert.startLineNumber,
|
|
144
|
-
range.insert.startColumn,
|
|
145
|
-
range.insert.endLineNumber,
|
|
146
|
-
range.insert.startColumn + insertText.length
|
|
147
|
-
));
|
|
148
|
-
return {
|
|
149
|
-
label: v.label,
|
|
150
|
-
range,
|
|
151
|
-
insertText: insertText + ' ',
|
|
152
|
-
kind: 18 ,
|
|
153
|
-
detail: v.detail,
|
|
154
|
-
documentation: v.documentation,
|
|
155
|
-
command: { id: AddDynamicVariableAction.ID, title: '', arguments: [{ widget, range: rangeAfterInsert, variableData: revive(v.values) }] }
|
|
156
|
-
};
|
|
157
|
-
}));
|
|
158
|
-
return {
|
|
159
|
-
suggestions: variableItems
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
$unregisterAgentCompletionsProvider(handle) {
|
|
165
|
-
this._agentCompletionProviders.deleteAndDispose(handle);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
MainThreadChatAgents2 = __decorate([
|
|
169
|
-
extHostNamedCustomer(MainContext.MainThreadChatAgents2),
|
|
170
|
-
( __param(1, IChatAgentService)),
|
|
171
|
-
( __param(2, IChatService)),
|
|
172
|
-
( __param(3, ILanguageFeaturesService)),
|
|
173
|
-
( __param(4, IChatWidgetService)),
|
|
174
|
-
( __param(5, IInstantiationService))
|
|
175
|
-
], MainThreadChatAgents2);
|
|
176
|
-
function computeCompletionRanges(model, position, reg) {
|
|
177
|
-
const varWord = getWordAtText(position.column, reg, model.getLineContent(position.lineNumber), 0);
|
|
178
|
-
if (!varWord && model.getWordUntilPosition(position).word) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
let insert;
|
|
182
|
-
let replace;
|
|
183
|
-
if (!varWord) {
|
|
184
|
-
insert = replace = Range.fromPositions(position);
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
insert = ( new Range(
|
|
188
|
-
position.lineNumber,
|
|
189
|
-
varWord.startColumn,
|
|
190
|
-
position.lineNumber,
|
|
191
|
-
position.column
|
|
192
|
-
));
|
|
193
|
-
replace = ( new Range(
|
|
194
|
-
position.lineNumber,
|
|
195
|
-
varWord.startColumn,
|
|
196
|
-
position.lineNumber,
|
|
197
|
-
varWord.endColumn
|
|
198
|
-
));
|
|
199
|
-
}
|
|
200
|
-
return { insert, replace };
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export { MainThreadChatAgents2 };
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { Event, Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
3
|
-
import { DisposableStore, DisposableMap, Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
5
|
-
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
6
|
-
import { Progress } from 'vscode/vscode/vs/platform/progress/common/progress';
|
|
7
|
-
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
8
|
-
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
9
|
-
import { IChatProviderService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatProvider';
|
|
10
|
-
import { IAuthenticationService, INTERNAL_AUTH_PROVIDER_PREFIX } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication';
|
|
11
|
-
import { IExtensionFeaturesManagementService, Extensions } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
|
|
12
|
-
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
13
|
-
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
14
|
-
|
|
15
|
-
let MainThreadChatProvider = class MainThreadChatProvider {
|
|
16
|
-
constructor(extHostContext, _chatProviderService, _extensionFeaturesManagementService, _logService, _authenticationService, _extensionService) {
|
|
17
|
-
this._chatProviderService = _chatProviderService;
|
|
18
|
-
this._extensionFeaturesManagementService = _extensionFeaturesManagementService;
|
|
19
|
-
this._logService = _logService;
|
|
20
|
-
this._authenticationService = _authenticationService;
|
|
21
|
-
this._extensionService = _extensionService;
|
|
22
|
-
this._store = ( new DisposableStore());
|
|
23
|
-
this._providerRegistrations = ( new DisposableMap());
|
|
24
|
-
this._pendingProgress = ( new Map());
|
|
25
|
-
this._proxy = ( extHostContext.getProxy(ExtHostContext.ExtHostChatProvider));
|
|
26
|
-
this._proxy.$updateLanguageModels({ added: _chatProviderService.getProviders() });
|
|
27
|
-
this._store.add(_chatProviderService.onDidChangeProviders(this._proxy.$updateLanguageModels, this._proxy));
|
|
28
|
-
}
|
|
29
|
-
dispose() {
|
|
30
|
-
this._providerRegistrations.dispose();
|
|
31
|
-
this._store.dispose();
|
|
32
|
-
}
|
|
33
|
-
$registerProvider(handle, identifier, metadata) {
|
|
34
|
-
const dipsosables = ( new DisposableStore());
|
|
35
|
-
dipsosables.add(this._chatProviderService.registerChatResponseProvider(identifier, {
|
|
36
|
-
metadata,
|
|
37
|
-
provideChatResponse: async (messages, from, options, progress, token) => {
|
|
38
|
-
const requestId = (Math.random() * 1e6) | 0;
|
|
39
|
-
this._pendingProgress.set(requestId, progress);
|
|
40
|
-
try {
|
|
41
|
-
await this._proxy.$provideLanguageModelResponse(handle, requestId, from, messages, options, token);
|
|
42
|
-
}
|
|
43
|
-
finally {
|
|
44
|
-
this._pendingProgress.delete(requestId);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
if (metadata.auth) {
|
|
49
|
-
dipsosables.add(this._registerAuthenticationProvider(metadata.extension, metadata.auth));
|
|
50
|
-
}
|
|
51
|
-
dipsosables.add(( Registry.as(Extensions.ExtensionFeaturesRegistry)).registerExtensionFeature({
|
|
52
|
-
id: `lm-${identifier}`,
|
|
53
|
-
label: ( localizeWithPath(
|
|
54
|
-
'vs/workbench/api/browser/mainThreadChatProvider',
|
|
55
|
-
'languageModels',
|
|
56
|
-
"Language Model ({0})",
|
|
57
|
-
`${identifier}`
|
|
58
|
-
)),
|
|
59
|
-
access: {
|
|
60
|
-
canToggle: false,
|
|
61
|
-
},
|
|
62
|
-
}));
|
|
63
|
-
this._providerRegistrations.set(handle, dipsosables);
|
|
64
|
-
}
|
|
65
|
-
async $handleProgressChunk(requestId, chunk) {
|
|
66
|
-
this._pendingProgress.get(requestId)?.report(chunk);
|
|
67
|
-
}
|
|
68
|
-
$unregisterProvider(handle) {
|
|
69
|
-
this._providerRegistrations.deleteAndDispose(handle);
|
|
70
|
-
}
|
|
71
|
-
async $prepareChatAccess(extension, providerId, justification) {
|
|
72
|
-
const activate = this._extensionService.activateByEvent(`onLanguageModelAccess:${providerId}`);
|
|
73
|
-
const metadata = this._chatProviderService.lookupChatResponseProvider(providerId);
|
|
74
|
-
if (metadata) {
|
|
75
|
-
return metadata;
|
|
76
|
-
}
|
|
77
|
-
await Promise.race([
|
|
78
|
-
activate,
|
|
79
|
-
Event.toPromise(Event.filter(this._chatProviderService.onDidChangeProviders, e => Boolean(e.added?.includes(providerId))))
|
|
80
|
-
]);
|
|
81
|
-
return this._chatProviderService.lookupChatResponseProvider(providerId);
|
|
82
|
-
}
|
|
83
|
-
async $fetchResponse(extension, providerId, requestId, messages, options, token) {
|
|
84
|
-
await this._extensionFeaturesManagementService.getAccess(extension, `lm-${providerId}`);
|
|
85
|
-
this._logService.debug('[CHAT] extension request STARTED', extension.value, requestId);
|
|
86
|
-
const task = this._chatProviderService.fetchChatResponse(providerId, extension, messages, options, ( new Progress(value => {
|
|
87
|
-
this._proxy.$handleResponseFragment(requestId, value);
|
|
88
|
-
})), token);
|
|
89
|
-
task.catch(err => {
|
|
90
|
-
this._logService.error('[CHAT] extension request ERRORED', err, extension.value, requestId);
|
|
91
|
-
throw err;
|
|
92
|
-
}).finally(() => {
|
|
93
|
-
this._logService.debug('[CHAT] extension request DONE', extension.value, requestId);
|
|
94
|
-
});
|
|
95
|
-
return task;
|
|
96
|
-
}
|
|
97
|
-
_registerAuthenticationProvider(extension, auth) {
|
|
98
|
-
const authProviderId = INTERNAL_AUTH_PROVIDER_PREFIX + extension.value;
|
|
99
|
-
if (this._authenticationService.getProviderIds().includes(authProviderId)) {
|
|
100
|
-
return Disposable.None;
|
|
101
|
-
}
|
|
102
|
-
const accountLabel = auth.accountLabel ?? ( localizeWithPath(
|
|
103
|
-
'vs/workbench/api/browser/mainThreadChatProvider',
|
|
104
|
-
'languageModelsAccountId',
|
|
105
|
-
'Language Models'
|
|
106
|
-
));
|
|
107
|
-
const disposables = ( new DisposableStore());
|
|
108
|
-
this._authenticationService.registerAuthenticationProvider(authProviderId, ( new LanguageModelAccessAuthProvider(authProviderId, auth.providerLabel, accountLabel)));
|
|
109
|
-
disposables.add(toDisposable(() => {
|
|
110
|
-
this._authenticationService.unregisterAuthenticationProvider(authProviderId);
|
|
111
|
-
}));
|
|
112
|
-
disposables.add(this._authenticationService.onDidChangeSessions(async (e) => {
|
|
113
|
-
if (e.providerId === authProviderId) {
|
|
114
|
-
if (e.event.removed?.length) {
|
|
115
|
-
const allowedExtensions = this._authenticationService.readAllowedExtensions(authProviderId, accountLabel);
|
|
116
|
-
const extensionsToUpdateAccess = [];
|
|
117
|
-
for (const allowed of allowedExtensions) {
|
|
118
|
-
const from = await this._extensionService.getExtension(allowed.id);
|
|
119
|
-
this._authenticationService.updateAllowedExtension(authProviderId, authProviderId, allowed.id, allowed.name, false);
|
|
120
|
-
if (from) {
|
|
121
|
-
extensionsToUpdateAccess.push({
|
|
122
|
-
from: from.identifier,
|
|
123
|
-
to: extension,
|
|
124
|
-
enabled: false
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
this._proxy.$updateModelAccesslist(extensionsToUpdateAccess);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}));
|
|
132
|
-
disposables.add(this._authenticationService.onDidChangeExtensionSessionAccess(async (e) => {
|
|
133
|
-
const allowedExtensions = this._authenticationService.readAllowedExtensions(authProviderId, accountLabel);
|
|
134
|
-
const accessList = [];
|
|
135
|
-
for (const allowedExtension of allowedExtensions) {
|
|
136
|
-
const from = await this._extensionService.getExtension(allowedExtension.id);
|
|
137
|
-
if (from) {
|
|
138
|
-
accessList.push({
|
|
139
|
-
from: from.identifier,
|
|
140
|
-
to: extension,
|
|
141
|
-
enabled: allowedExtension.allowed ?? true
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
this._proxy.$updateModelAccesslist(accessList);
|
|
146
|
-
}));
|
|
147
|
-
return disposables;
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
MainThreadChatProvider = __decorate([
|
|
151
|
-
extHostNamedCustomer(MainContext.MainThreadChatProvider),
|
|
152
|
-
( __param(1, IChatProviderService)),
|
|
153
|
-
( __param(2, IExtensionFeaturesManagementService)),
|
|
154
|
-
( __param(3, ILogService)),
|
|
155
|
-
( __param(4, IAuthenticationService)),
|
|
156
|
-
( __param(5, IExtensionService))
|
|
157
|
-
], MainThreadChatProvider);
|
|
158
|
-
class LanguageModelAccessAuthProvider {
|
|
159
|
-
constructor(id, label, _accountLabel) {
|
|
160
|
-
this.id = id;
|
|
161
|
-
this.label = label;
|
|
162
|
-
this._accountLabel = _accountLabel;
|
|
163
|
-
this.supportsMultipleAccounts = false;
|
|
164
|
-
this._onDidChangeSessions = ( new Emitter());
|
|
165
|
-
this.onDidChangeSessions = this._onDidChangeSessions.event;
|
|
166
|
-
}
|
|
167
|
-
async getSessions(scopes) {
|
|
168
|
-
if (scopes === undefined && !this._session) {
|
|
169
|
-
return [];
|
|
170
|
-
}
|
|
171
|
-
if (this._session) {
|
|
172
|
-
return [this._session];
|
|
173
|
-
}
|
|
174
|
-
return [await this.createSession(scopes || [], {})];
|
|
175
|
-
}
|
|
176
|
-
async createSession(scopes, options) {
|
|
177
|
-
this._session = this._createFakeSession(scopes);
|
|
178
|
-
this._onDidChangeSessions.fire({ added: [this._session], changed: [], removed: [] });
|
|
179
|
-
return this._session;
|
|
180
|
-
}
|
|
181
|
-
removeSession(sessionId) {
|
|
182
|
-
if (this._session) {
|
|
183
|
-
this._onDidChangeSessions.fire({ added: [], changed: [], removed: [this._session] });
|
|
184
|
-
this._session = undefined;
|
|
185
|
-
}
|
|
186
|
-
return Promise.resolve();
|
|
187
|
-
}
|
|
188
|
-
_createFakeSession(scopes) {
|
|
189
|
-
return {
|
|
190
|
-
id: 'fake-session',
|
|
191
|
-
account: {
|
|
192
|
-
id: this.id,
|
|
193
|
-
label: this._accountLabel,
|
|
194
|
-
},
|
|
195
|
-
accessToken: 'fake-access-token',
|
|
196
|
-
scopes,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export { MainThreadChatProvider };
|
|
@@ -1,41 +0,0 @@
|
|
|
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 };
|
|
@@ -1,24 +0,0 @@
|
|
|
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 };
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
4
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
5
|
-
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
6
|
-
import { reviveWebviewContentOptions } from './mainThreadWebviews.js';
|
|
7
|
-
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
8
|
-
import { IWebviewService } from 'vscode/vscode/vs/workbench/contrib/webview/browser/webview';
|
|
9
|
-
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
10
|
-
|
|
11
|
-
class EditorWebviewZone {
|
|
12
|
-
constructor(editor, line, height, webview) {
|
|
13
|
-
this.editor = editor;
|
|
14
|
-
this.line = line;
|
|
15
|
-
this.height = height;
|
|
16
|
-
this.webview = webview;
|
|
17
|
-
this.domNode = document.createElement('div');
|
|
18
|
-
this.domNode.style.zIndex = '10';
|
|
19
|
-
this.afterLineNumber = line;
|
|
20
|
-
this.afterColumn = 1;
|
|
21
|
-
this.heightInLines = height;
|
|
22
|
-
editor.changeViewZones(accessor => this._id = accessor.addZone(this));
|
|
23
|
-
webview.mountTo(this.domNode);
|
|
24
|
-
}
|
|
25
|
-
dispose() {
|
|
26
|
-
this.editor.changeViewZones(accessor => this._id && accessor.removeZone(this._id));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
let MainThreadEditorInsets = class MainThreadEditorInsets {
|
|
30
|
-
constructor(context, _editorService, _webviewService) {
|
|
31
|
-
this._editorService = _editorService;
|
|
32
|
-
this._webviewService = _webviewService;
|
|
33
|
-
this._disposables = ( new DisposableStore());
|
|
34
|
-
this._insets = ( new Map());
|
|
35
|
-
this._proxy = ( context.getProxy(ExtHostContext.ExtHostEditorInsets));
|
|
36
|
-
}
|
|
37
|
-
dispose() {
|
|
38
|
-
this._disposables.dispose();
|
|
39
|
-
}
|
|
40
|
-
async $createEditorInset(handle, id, uri, line, height, options, extensionId, extensionLocation) {
|
|
41
|
-
let editor;
|
|
42
|
-
id = id.substr(0, id.indexOf(','));
|
|
43
|
-
for (const candidate of this._editorService.listCodeEditors()) {
|
|
44
|
-
if (candidate.getId() === id && candidate.hasModel() && isEqual(candidate.getModel().uri, URI.revive(uri))) {
|
|
45
|
-
editor = candidate;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (!editor) {
|
|
50
|
-
setTimeout(() => this._proxy.$onDidDispose(handle));
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const disposables = ( new DisposableStore());
|
|
54
|
-
const webview = this._webviewService.createWebviewElement({
|
|
55
|
-
title: undefined,
|
|
56
|
-
options: {
|
|
57
|
-
enableFindWidget: false,
|
|
58
|
-
},
|
|
59
|
-
contentOptions: reviveWebviewContentOptions(options),
|
|
60
|
-
extension: { id: extensionId, location: URI.revive(extensionLocation) }
|
|
61
|
-
});
|
|
62
|
-
const webviewZone = ( new EditorWebviewZone(editor, line, height, webview));
|
|
63
|
-
const remove = () => {
|
|
64
|
-
disposables.dispose();
|
|
65
|
-
this._proxy.$onDidDispose(handle);
|
|
66
|
-
this._insets.delete(handle);
|
|
67
|
-
};
|
|
68
|
-
disposables.add(editor.onDidChangeModel(remove));
|
|
69
|
-
disposables.add(editor.onDidDispose(remove));
|
|
70
|
-
disposables.add(webviewZone);
|
|
71
|
-
disposables.add(webview);
|
|
72
|
-
disposables.add(webview.onMessage(msg => this._proxy.$onDidReceiveMessage(handle, msg.message)));
|
|
73
|
-
this._insets.set(handle, webviewZone);
|
|
74
|
-
}
|
|
75
|
-
$disposeEditorInset(handle) {
|
|
76
|
-
const inset = this.getInset(handle);
|
|
77
|
-
this._insets.delete(handle);
|
|
78
|
-
inset.dispose();
|
|
79
|
-
}
|
|
80
|
-
$setHtml(handle, value) {
|
|
81
|
-
const inset = this.getInset(handle);
|
|
82
|
-
inset.webview.setHtml(value);
|
|
83
|
-
}
|
|
84
|
-
$setOptions(handle, options) {
|
|
85
|
-
const inset = this.getInset(handle);
|
|
86
|
-
inset.webview.contentOptions = reviveWebviewContentOptions(options);
|
|
87
|
-
}
|
|
88
|
-
async $postMessage(handle, value) {
|
|
89
|
-
const inset = this.getInset(handle);
|
|
90
|
-
inset.webview.postMessage(value);
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
getInset(handle) {
|
|
94
|
-
const inset = this._insets.get(handle);
|
|
95
|
-
if (!inset) {
|
|
96
|
-
throw new Error('Unknown inset');
|
|
97
|
-
}
|
|
98
|
-
return inset;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
MainThreadEditorInsets = __decorate([
|
|
102
|
-
extHostNamedCustomer(MainContext.MainThreadEditorInsets),
|
|
103
|
-
( __param(1, ICodeEditorService)),
|
|
104
|
-
( __param(2, IWebviewService))
|
|
105
|
-
], MainThreadEditorInsets);
|
|
106
|
-
|
|
107
|
-
export { MainThreadEditorInsets };
|
|
@@ -1,98 +0,0 @@
|
|
|
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 };
|