@codingame/monaco-vscode-mcp-service-override 31.0.0 → 32.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +1 -1
  3. package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +2 -2
  4. package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +7 -11
  5. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +2 -2
  6. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +80 -80
  7. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +25 -25
  8. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +47 -25
  9. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpMigration.js +4 -4
  10. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.js +8 -8
  11. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.d.ts +72 -0
  12. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.js +1023 -0
  13. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.d.ts +17 -0
  14. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.js +49 -0
  15. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerIcons.d.ts +5 -0
  16. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerIcons.js +12 -0
  17. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.d.ts +88 -0
  18. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.js +372 -0
  19. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +11 -11
  20. package/vscode/src/vs/workbench/contrib/mcp/browser/media/mcpServerEditor.css +98 -0
  21. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +6 -5
  22. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/installedMcpServersDiscovery.js +2 -2
  23. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +3 -3
  24. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/pluginMcpDiscovery.js +2 -2
  25. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceDotMcpDiscovery.d.ts +21 -0
  26. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceDotMcpDiscovery.js +92 -0
  27. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.js +2 -2
  28. package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +4 -4
  29. package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +10 -8
  30. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +14 -14
  31. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +1 -1
  32. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +11 -11
  33. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.js +4 -4
  34. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +3 -3
  35. package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.d.ts +28 -3
  36. package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +88 -3
  37. package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +9 -9
  38. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.d.ts +0 -59
  39. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +0 -576
  40. package/vscode/src/vs/workbench/contrib/mcp/browser/media/mcpServersView.css +0 -53
@@ -0,0 +1,1023 @@
1
+
2
+ import { registerCss } from '@codingame/monaco-vscode-api/css';
3
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
4
+ import * as mcpServerEditor from './media/mcpServerEditor.css';
5
+ import { append, $, setParentFlowTo, clearNode } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
6
+ import { ActionBar } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionbar';
7
+ import { getDefaultHoverDelegate } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
8
+ import { DomScrollableElement } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
9
+ import { Action } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
10
+ import { insert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
11
+ import { Cache } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cache';
12
+ import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
13
+ import { isCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
14
+ import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
15
+ import { Disposable, dispose, MutableDisposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
16
+ import { matchesScheme, Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
17
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
18
+ import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
19
+ import { TokenizationRegistry } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
20
+ import { ILanguageService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service';
21
+ import { generateTokensCSSForColorMap } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/supports/tokenization';
22
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
23
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
24
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
25
+ import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
26
+ import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
27
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
28
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
29
+ import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
30
+ import { EditorPane } from '@codingame/monaco-vscode-api/vscode/vs/workbench/browser/parts/editor/editorPane';
31
+ import { renderMarkdownDocument, DEFAULT_MARKDOWN_STYLES } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer';
32
+ import { IWebviewService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/webview/browser/webview.service';
33
+ import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
34
+ import { IHoverService } from '@codingame/monaco-vscode-api/vscode/vs/platform/hover/browser/hover.service';
35
+ import { McpServerInstallState, McpServerContainers } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
36
+ import { IMcpWorkbenchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
37
+ import { McpServerIconWidget, McpServerScopeBadgeWidget, PublisherWidget, StarredWidget, LicenseWidget, McpServerStatusWidget, McpServerWidget, onClick } from './mcpServerWidgets.js';
38
+ import { InstallAction, InstallingLabelAction, ButtonWithDropDownExtensionAction, UninstallAction, InstallInWorkspaceAction, InstallInRemoteAction, EnableMcpDropDownAction, DisableMcpDropDownAction, ManageMcpServerAction, DropDownAction, ButtonWithDropdownExtensionActionViewItem, McpServerStatusAction } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/browser/mcpServerActions';
39
+ import { McpServerType } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpPlatformTypes';
40
+ import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
41
+ import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
42
+ import { getMcpGalleryManifestResourceUri, McpGalleryResourceType } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpGalleryManifest';
43
+ import { IMcpGalleryManifestService } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpGalleryManifest.service';
44
+ import { fromNow } from '@codingame/monaco-vscode-api/vscode/vs/base/common/date';
45
+ import { IContextMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service';
46
+
47
+ var McpServerEditor_1;
48
+ registerCss(mcpServerEditor);
49
+ var McpServerEditorTab;
50
+ (function(McpServerEditorTab) {
51
+ McpServerEditorTab["Readme"] = "readme";
52
+ McpServerEditorTab["Configuration"] = "configuration";
53
+ McpServerEditorTab["Manifest"] = "manifest";
54
+ })(McpServerEditorTab || (McpServerEditorTab = {}));
55
+ class NavBar extends Disposable {
56
+ get onChange() {
57
+ return this._onChange.event;
58
+ }
59
+ get currentId() {
60
+ return this._currentId;
61
+ }
62
+ constructor(container) {
63
+ super();
64
+ this._onChange = this._register(( new Emitter()));
65
+ this._currentId = null;
66
+ const element = append(container, $(".navbar"));
67
+ this.actions = [];
68
+ this.actionbar = this._register(( new ActionBar(element)));
69
+ }
70
+ push(id, label, tooltip, index) {
71
+ const action = ( new Action(id, label, undefined, true, () => this.update(id, true)));
72
+ action.tooltip = tooltip;
73
+ if (typeof index === "number") {
74
+ this.actions.splice(index, 0, action);
75
+ } else {
76
+ this.actions.push(action);
77
+ }
78
+ this.actionbar.push(action, {
79
+ index
80
+ });
81
+ if (this.actions.length === 1) {
82
+ this.update(id);
83
+ }
84
+ }
85
+ remove(id) {
86
+ const index = this.actions.findIndex(action => action.id === id);
87
+ if (index !== -1) {
88
+ this.actions.splice(index, 1);
89
+ this.actionbar.pull(index);
90
+ if (this._currentId === id) {
91
+ this.switch(this.actions[0]?.id);
92
+ }
93
+ }
94
+ }
95
+ clear() {
96
+ this.actions = dispose(this.actions);
97
+ this.actionbar.clear();
98
+ }
99
+ switch(id) {
100
+ const action = this.actions.find(action => action.id === id);
101
+ if (action) {
102
+ action.run();
103
+ return true;
104
+ }
105
+ return false;
106
+ }
107
+ has(id) {
108
+ return ( this.actions.some(action => action.id === id));
109
+ }
110
+ update(id, focus) {
111
+ this._currentId = id;
112
+ this._onChange.fire({
113
+ id,
114
+ focus: !!focus
115
+ });
116
+ this.actions.forEach(a => a.checked = a.id === id);
117
+ }
118
+ }
119
+ var WebviewIndex;
120
+ (function(WebviewIndex) {
121
+ WebviewIndex[WebviewIndex["Readme"] = 0] = "Readme";
122
+ WebviewIndex[WebviewIndex["Changelog"] = 1] = "Changelog";
123
+ })(WebviewIndex || (WebviewIndex = {}));
124
+ let McpServerEditor = class McpServerEditor extends EditorPane {
125
+ static {
126
+ McpServerEditor_1 = this;
127
+ }
128
+ static {
129
+ this.ID = "workbench.editor.mcpServer";
130
+ }
131
+ constructor(
132
+ group,
133
+ telemetryService,
134
+ instantiationService,
135
+ themeService,
136
+ notificationService,
137
+ openerService,
138
+ storageService,
139
+ extensionService,
140
+ webviewService,
141
+ languageService,
142
+ contextKeyService,
143
+ mcpWorkbenchService,
144
+ hoverService,
145
+ contextMenuService
146
+ ) {
147
+ super(
148
+ McpServerEditor_1.ID,
149
+ group,
150
+ telemetryService,
151
+ themeService,
152
+ storageService
153
+ );
154
+ this.instantiationService = instantiationService;
155
+ this.notificationService = notificationService;
156
+ this.openerService = openerService;
157
+ this.extensionService = extensionService;
158
+ this.webviewService = webviewService;
159
+ this.languageService = languageService;
160
+ this.contextKeyService = contextKeyService;
161
+ this.mcpWorkbenchService = mcpWorkbenchService;
162
+ this.hoverService = hoverService;
163
+ this.contextMenuService = contextMenuService;
164
+ this._scopedContextKeyService = this._register(( new MutableDisposable()));
165
+ this.initialScrollProgress = ( new Map());
166
+ this.currentIdentifier = "";
167
+ this.layoutParticipants = [];
168
+ this.contentDisposables = this._register(( new DisposableStore()));
169
+ this.transientDisposables = this._register(( new DisposableStore()));
170
+ this.activeElement = null;
171
+ this.mcpServerReadme = null;
172
+ this.mcpServerManifest = null;
173
+ }
174
+ get scopedContextKeyService() {
175
+ return this._scopedContextKeyService.value;
176
+ }
177
+ createEditor(parent) {
178
+ const root = append(parent, $(".extension-editor.mcp-server-editor"));
179
+ this._scopedContextKeyService.value = this.contextKeyService.createScoped(root);
180
+ this._scopedContextKeyService.value.createKey("inExtensionEditor", true);
181
+ root.tabIndex = 0;
182
+ root.style.outline = "none";
183
+ root.setAttribute("role", "document");
184
+ const header = append(root, $(".header"));
185
+ const iconContainer = append(header, $(".icon-container"));
186
+ const iconWidget = this.instantiationService.createInstance(McpServerIconWidget, iconContainer);
187
+ const scopeWidget = this.instantiationService.createInstance(McpServerScopeBadgeWidget, iconContainer);
188
+ const details = append(header, $(".details"));
189
+ const title = append(details, $(".title"));
190
+ const name = append(title, $("span.name.clickable", {
191
+ role: "heading",
192
+ tabIndex: 0
193
+ }));
194
+ this._register(
195
+ this.hoverService.setupManagedHover(getDefaultHoverDelegate("mouse"), name, ( localize(11067, "Extension name")))
196
+ );
197
+ const subtitle = append(details, $(".subtitle"));
198
+ const subTitleEntryContainers = [];
199
+ const publisherContainer = append(subtitle, $(".subtitle-entry"));
200
+ subTitleEntryContainers.push(publisherContainer);
201
+ const publisherWidget = this.instantiationService.createInstance(PublisherWidget, publisherContainer, false);
202
+ const starredContainer = append(subtitle, $(".subtitle-entry"));
203
+ subTitleEntryContainers.push(starredContainer);
204
+ const installCountWidget = this.instantiationService.createInstance(StarredWidget, starredContainer, false);
205
+ const licenseContainer = append(subtitle, $(".subtitle-entry"));
206
+ subTitleEntryContainers.push(licenseContainer);
207
+ const licenseWidget = this.instantiationService.createInstance(LicenseWidget, licenseContainer);
208
+ const widgets = [
209
+ iconWidget,
210
+ publisherWidget,
211
+ installCountWidget,
212
+ scopeWidget,
213
+ licenseWidget
214
+ ];
215
+ const description = append(details, $(".description"));
216
+ const actions = [
217
+ this.instantiationService.createInstance(InstallAction, false),
218
+ this.instantiationService.createInstance(InstallingLabelAction),
219
+ this.instantiationService.createInstance(
220
+ ButtonWithDropDownExtensionAction,
221
+ "extensions.uninstall",
222
+ UninstallAction.CLASS,
223
+ [[
224
+ this.instantiationService.createInstance(UninstallAction),
225
+ this.instantiationService.createInstance(InstallInWorkspaceAction, false),
226
+ this.instantiationService.createInstance(InstallInRemoteAction, false)
227
+ ]]
228
+ ),
229
+ this.instantiationService.createInstance(EnableMcpDropDownAction),
230
+ this.instantiationService.createInstance(DisableMcpDropDownAction),
231
+ this.instantiationService.createInstance(ManageMcpServerAction, true)
232
+ ];
233
+ const actionsAndStatusContainer = append(details, $(".actions-status-container.mcp-server-actions"));
234
+ const actionBar = this._register(( new ActionBar(actionsAndStatusContainer, {
235
+ actionViewItemProvider: (action, options) => {
236
+ if (action instanceof DropDownAction) {
237
+ return action.createActionViewItem(options);
238
+ }
239
+ if (action instanceof ButtonWithDropDownExtensionAction) {
240
+ return ( new ButtonWithDropdownExtensionActionViewItem(action, {
241
+ ...options,
242
+ icon: true,
243
+ label: true,
244
+ menuActionsOrProvider: {
245
+ getActions: () => action.menuActions
246
+ },
247
+ menuActionClassNames: action.menuActionClassNames
248
+ }, this.contextMenuService));
249
+ }
250
+ return undefined;
251
+ },
252
+ focusOnlyEnabledItems: true
253
+ })));
254
+ actionBar.push(actions, {
255
+ icon: true,
256
+ label: true
257
+ });
258
+ actionBar.setFocusable(true);
259
+ this._register(Event.any(...( actions.map(a => Event.filter(a.onDidChange, e => e.enabled !== undefined))))(() => {
260
+ actionBar.setFocusable(false);
261
+ actionBar.setFocusable(true);
262
+ }));
263
+ const otherContainers = [];
264
+ const mcpServerStatusAction = this.instantiationService.createInstance(McpServerStatusAction);
265
+ const mcpServerStatusWidget = this._register(this.instantiationService.createInstance(
266
+ McpServerStatusWidget,
267
+ append(actionsAndStatusContainer, $(".status")),
268
+ mcpServerStatusAction
269
+ ));
270
+ this._register(Event.any(mcpServerStatusWidget.onDidRender)(() => {
271
+ if (this.dimension) {
272
+ this.layout(this.dimension);
273
+ }
274
+ }));
275
+ otherContainers.push(mcpServerStatusAction, new (class extends McpServerWidget {
276
+ render() {
277
+ actionsAndStatusContainer.classList.toggle(
278
+ "list-layout",
279
+ this.mcpServer?.installState === McpServerInstallState.Installed
280
+ );
281
+ }
282
+ })());
283
+ const mcpServerContainers = this.instantiationService.createInstance(McpServerContainers, [...actions, ...widgets, ...otherContainers]);
284
+ for (const disposable of [...actions, ...widgets, ...otherContainers, mcpServerContainers]) {
285
+ this._register(disposable);
286
+ }
287
+ const onError = Event.chain(actionBar.onDidRun, $ => ( $.map((
288
+ {
289
+ error
290
+ }
291
+ ) => error)).filter(error => !!error));
292
+ this._register(onError(this.onError, this));
293
+ const body = append(root, $(".body"));
294
+ const navbar = ( new NavBar(body));
295
+ const content = append(body, $(".content"));
296
+ content.id = generateUuid();
297
+ this.template = {
298
+ content,
299
+ description,
300
+ header,
301
+ name,
302
+ navbar,
303
+ actionsAndStatusContainer,
304
+ actionBar: actionBar,
305
+ set mcpServer(mcpServer) {
306
+ mcpServerContainers.mcpServer = mcpServer;
307
+ let lastNonEmptySubtitleEntryContainer;
308
+ for (const subTitleEntryElement of subTitleEntryContainers) {
309
+ subTitleEntryElement.classList.remove("last-non-empty");
310
+ if (subTitleEntryElement.children.length > 0) {
311
+ lastNonEmptySubtitleEntryContainer = subTitleEntryElement;
312
+ }
313
+ }
314
+ if (lastNonEmptySubtitleEntryContainer) {
315
+ lastNonEmptySubtitleEntryContainer.classList.add("last-non-empty");
316
+ }
317
+ }
318
+ };
319
+ }
320
+ async setInput(input, options, context, token) {
321
+ await super.setInput(input, options, context, token);
322
+ if (this.template) {
323
+ await this.render(input.mcpServer, this.template, !!options?.preserveFocus);
324
+ }
325
+ }
326
+ async render(mcpServer, template, preserveFocus) {
327
+ this.activeElement = null;
328
+ this.transientDisposables.clear();
329
+ const token = this.transientDisposables.add(( new CancellationTokenSource())).token;
330
+ this.mcpServerReadme = ( new Cache(() => mcpServer.getReadme(token)));
331
+ this.mcpServerManifest = ( new Cache(() => mcpServer.getManifest(token)));
332
+ template.mcpServer = mcpServer;
333
+ template.name.textContent = mcpServer.label;
334
+ template.name.classList.toggle("clickable", !!mcpServer.gallery?.webUrl);
335
+ template.description.textContent = mcpServer.description;
336
+ if (mcpServer.gallery?.webUrl) {
337
+ this.transientDisposables.add(onClick(template.name, () => this.openerService.open(( URI.parse(mcpServer.gallery?.webUrl)))));
338
+ }
339
+ this.renderNavbar(mcpServer, template, preserveFocus);
340
+ }
341
+ setOptions(options) {
342
+ super.setOptions(options);
343
+ if (options?.tab) {
344
+ this.template?.navbar.switch(options.tab);
345
+ }
346
+ }
347
+ renderNavbar(extension, template, preserveFocus) {
348
+ template.content.innerText = "";
349
+ template.navbar.clear();
350
+ if (this.currentIdentifier !== extension.id) {
351
+ this.initialScrollProgress.clear();
352
+ this.currentIdentifier = extension.id;
353
+ }
354
+ if (extension.readmeUrl || extension.gallery?.readme) {
355
+ template.navbar.push(McpServerEditorTab.Readme, ( localize(11068, "Details")), ( localize(11069, "Extension details, rendered from the extension's 'README.md' file")));
356
+ }
357
+ if (extension.gallery || extension.local?.manifest) {
358
+ template.navbar.push(McpServerEditorTab.Manifest, ( localize(11070, "Manifest")), ( localize(11071, "Server manifest details")));
359
+ }
360
+ if (extension.config) {
361
+ template.navbar.push(McpServerEditorTab.Configuration, ( localize(11072, "Configuration")), ( localize(11073, "Server configuration details")));
362
+ }
363
+ this.transientDisposables.add(this.mcpWorkbenchService.onChange(e => {
364
+ if (e === extension) {
365
+ if (e.config && !( template.navbar.has(McpServerEditorTab.Configuration))) {
366
+ template.navbar.push(McpServerEditorTab.Configuration, ( localize(11072, "Configuration")), ( localize(11073, "Server configuration details")), extension.readmeUrl ? 1 : 0);
367
+ }
368
+ if (!e.config && ( template.navbar.has(McpServerEditorTab.Configuration))) {
369
+ template.navbar.remove(McpServerEditorTab.Configuration);
370
+ }
371
+ }
372
+ }));
373
+ if (this.options?.tab) {
374
+ template.navbar.switch(this.options.tab);
375
+ }
376
+ if (template.navbar.currentId) {
377
+ this.onNavbarChange(extension, {
378
+ id: template.navbar.currentId,
379
+ focus: !preserveFocus
380
+ }, template);
381
+ }
382
+ template.navbar.onChange(
383
+ e => this.onNavbarChange(extension, e, template),
384
+ this,
385
+ this.transientDisposables
386
+ );
387
+ }
388
+ clearInput() {
389
+ this.contentDisposables.clear();
390
+ this.transientDisposables.clear();
391
+ super.clearInput();
392
+ }
393
+ focus() {
394
+ super.focus();
395
+ this.activeElement?.focus();
396
+ }
397
+ showFind() {
398
+ this.activeWebview?.showFind();
399
+ }
400
+ runFindAction(previous) {
401
+ this.activeWebview?.runFindAction(previous);
402
+ }
403
+ get activeWebview() {
404
+ if (!this.activeElement || !this.activeElement.runFindAction) {
405
+ return undefined;
406
+ }
407
+ return this.activeElement;
408
+ }
409
+ onNavbarChange(
410
+ extension,
411
+ {
412
+ id,
413
+ focus
414
+ },
415
+ template
416
+ ) {
417
+ this.contentDisposables.clear();
418
+ template.content.innerText = "";
419
+ this.activeElement = null;
420
+ if (id) {
421
+ const cts = ( new CancellationTokenSource());
422
+ this.contentDisposables.add(toDisposable(() => cts.dispose(true)));
423
+ this.open(id, extension, template, cts.token).then(activeElement => {
424
+ if (cts.token.isCancellationRequested) {
425
+ return;
426
+ }
427
+ this.activeElement = activeElement;
428
+ if (focus) {
429
+ this.focus();
430
+ }
431
+ });
432
+ }
433
+ }
434
+ open(id, extension, template, token) {
435
+ switch (id) {
436
+ case McpServerEditorTab.Configuration:
437
+ return this.openConfiguration(extension, template, token);
438
+ case McpServerEditorTab.Readme:
439
+ return this.openDetails(extension, template, token);
440
+ case McpServerEditorTab.Manifest:
441
+ return extension.readmeUrl ? this.openManifest(extension, template.content, token) : this.openManifestWithAdditionalDetails(extension, template, token);
442
+ }
443
+ return Promise.resolve(null);
444
+ }
445
+ async openMarkdown(
446
+ extension,
447
+ cacheResult,
448
+ noContentCopy,
449
+ container,
450
+ webviewIndex,
451
+ title,
452
+ token
453
+ ) {
454
+ try {
455
+ const body = await this.renderMarkdown(extension, cacheResult, container, token);
456
+ if (token.isCancellationRequested) {
457
+ return Promise.resolve(null);
458
+ }
459
+ const webview = this.contentDisposables.add(this.webviewService.createWebviewOverlay({
460
+ title,
461
+ options: {
462
+ enableFindWidget: true,
463
+ tryRestoreScrollPosition: true,
464
+ disableServiceWorker: true
465
+ },
466
+ contentOptions: {},
467
+ extension: undefined
468
+ }));
469
+ webview.initialScrollProgress = this.initialScrollProgress.get(webviewIndex) || 0;
470
+ webview.claim(this, this.window, this.scopedContextKeyService);
471
+ setParentFlowTo(webview.container, container);
472
+ webview.setAnchorElement(container);
473
+ webview.setHtml(body);
474
+ webview.claim(this, this.window, undefined);
475
+ this.contentDisposables.add(webview.onDidFocus(() => this._onDidFocus?.fire()));
476
+ this.contentDisposables.add(webview.onDidScroll(
477
+ () => this.initialScrollProgress.set(webviewIndex, webview.initialScrollProgress)
478
+ ));
479
+ const removeLayoutParticipant = insert(this.layoutParticipants, {
480
+ layout: () => {
481
+ webview.setAnchorElement(container);
482
+ }
483
+ });
484
+ this.contentDisposables.add(toDisposable(removeLayoutParticipant));
485
+ let isDisposed = false;
486
+ this.contentDisposables.add(toDisposable(() => {
487
+ isDisposed = true;
488
+ }));
489
+ this.contentDisposables.add(this.themeService.onDidColorThemeChange(async () => {
490
+ const body = await this.renderMarkdown(extension, cacheResult, container);
491
+ if (!isDisposed) {
492
+ webview.setHtml(body);
493
+ }
494
+ }));
495
+ this.contentDisposables.add(webview.onDidClickLink(link => {
496
+ if (!link) {
497
+ return;
498
+ }
499
+ if (matchesScheme(link, Schemas.http) || matchesScheme(link, Schemas.https) || matchesScheme(link, Schemas.mailto)) {
500
+ this.openerService.open(link);
501
+ }
502
+ }));
503
+ return webview;
504
+ } catch (e) {
505
+ const p = append(container, $("p.nocontent"));
506
+ p.textContent = noContentCopy;
507
+ return p;
508
+ }
509
+ }
510
+ async renderMarkdown(extension, cacheResult, container, token) {
511
+ const contents = await this.loadContents(() => cacheResult, container);
512
+ if (token?.isCancellationRequested) {
513
+ return "";
514
+ }
515
+ const content = await renderMarkdownDocument(contents, this.extensionService, this.languageService, {}, token);
516
+ if (token?.isCancellationRequested) {
517
+ return "";
518
+ }
519
+ return this.renderBody(content);
520
+ }
521
+ renderBody(body) {
522
+ const nonce = generateUuid();
523
+ const colorMap = TokenizationRegistry.getColorMap();
524
+ const css = colorMap ? generateTokensCSSForColorMap(colorMap) : "";
525
+ return `<!DOCTYPE html>
526
+ <html>
527
+ <head>
528
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
529
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src https: data:; media-src https:; script-src 'none'; style-src 'nonce-${nonce}';">
530
+ <style nonce="${nonce}">
531
+ ${DEFAULT_MARKDOWN_STYLES}
532
+
533
+ /* prevent scroll-to-top button from blocking the body text */
534
+ body {
535
+ padding-bottom: 75px;
536
+ }
537
+
538
+ #scroll-to-top {
539
+ position: fixed;
540
+ width: 32px;
541
+ height: 32px;
542
+ right: 25px;
543
+ bottom: 25px;
544
+ background-color: var(--vscode-button-secondaryBackground);
545
+ border-color: var(--vscode-button-border);
546
+ border-radius: 50%;
547
+ cursor: pointer;
548
+ box-shadow: 1px 1px 1px rgba(0,0,0,.25);
549
+ outline: none;
550
+ display: flex;
551
+ justify-content: center;
552
+ align-items: center;
553
+ }
554
+
555
+ #scroll-to-top:hover {
556
+ background-color: var(--vscode-button-secondaryHoverBackground);
557
+ box-shadow: 2px 2px 2px rgba(0,0,0,.25);
558
+ }
559
+
560
+ body.vscode-high-contrast #scroll-to-top {
561
+ border-width: 2px;
562
+ border-style: solid;
563
+ box-shadow: none;
564
+ }
565
+
566
+ #scroll-to-top span.icon::before {
567
+ content: "";
568
+ display: block;
569
+ background: var(--vscode-button-secondaryForeground);
570
+ /* Chevron up icon */
571
+ webkit-mask-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAxNiAxNiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTYgMTY7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5zdDB7ZmlsbDojRkZGRkZGO30KCS5zdDF7ZmlsbDpub25lO30KPC9zdHlsZT4KPHRpdGxlPnVwY2hldnJvbjwvdGl0bGU+CjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik04LDUuMWwtNy4zLDcuM0wwLDExLjZsOC04bDgsOGwtMC43LDAuN0w4LDUuMXoiLz4KPHJlY3QgY2xhc3M9InN0MSIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2Ii8+Cjwvc3ZnPgo=');
572
+ -webkit-mask-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAxNiAxNiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTYgMTY7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5zdDB7ZmlsbDojRkZGRkZGO30KCS5zdDF7ZmlsbDpub25lO30KPC9zdHlsZT4KPHRpdGxlPnVwY2hldnJvbjwvdGl0bGU+CjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik04LDUuMWwtNy4zLDcuM0wwLDExLjZsOC04bDgsOGwtMC43LDAuN0w4LDUuMXoiLz4KPHJlY3QgY2xhc3M9InN0MSIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2Ii8+Cjwvc3ZnPgo=');
573
+ width: 16px;
574
+ height: 16px;
575
+ }
576
+ ${css}
577
+ </style>
578
+ </head>
579
+ <body>
580
+ <a id="scroll-to-top" role="button" aria-label="scroll to top" href="#"><span class="icon"></span></a>
581
+ ${body}
582
+ </body>
583
+ </html>`;
584
+ }
585
+ async openDetails(extension, template, token) {
586
+ const details = append(template.content, $(".details"));
587
+ const readmeContainer = append(details, $(".content-container"));
588
+ const additionalDetailsContainer = append(details, $(".additional-details-container"));
589
+ const layout = () => details.classList.toggle("narrow", this.dimension && this.dimension.width < 500);
590
+ layout();
591
+ this.contentDisposables.add(toDisposable(insert(this.layoutParticipants, {
592
+ layout
593
+ })));
594
+ const activeElement = await this.openMarkdown(extension, this.mcpServerReadme.get(), ( localize(11074, "No README available.")), readmeContainer, WebviewIndex.Readme, ( localize(11075, "Readme")), token);
595
+ this.renderAdditionalDetails(additionalDetailsContainer, extension);
596
+ return activeElement;
597
+ }
598
+ async openConfiguration(mcpServer, template, token) {
599
+ const configContainer = append(template.content, $(".configuration"));
600
+ const content = $("div", {
601
+ class: "configuration-content"
602
+ });
603
+ this.renderConfigurationDetails(content, mcpServer);
604
+ const scrollableContent = ( new DomScrollableElement(content, {}));
605
+ const layout = () => scrollableContent.scanDomNode();
606
+ this.contentDisposables.add(toDisposable(insert(this.layoutParticipants, {
607
+ layout
608
+ })));
609
+ append(configContainer, scrollableContent.getDomNode());
610
+ return {
611
+ focus: () => content.focus()
612
+ };
613
+ }
614
+ async openManifestWithAdditionalDetails(mcpServer, template, token) {
615
+ const details = append(template.content, $(".details"));
616
+ const readmeContainer = append(details, $(".content-container"));
617
+ const additionalDetailsContainer = append(details, $(".additional-details-container"));
618
+ const layout = () => details.classList.toggle("narrow", this.dimension && this.dimension.width < 500);
619
+ layout();
620
+ this.contentDisposables.add(toDisposable(insert(this.layoutParticipants, {
621
+ layout
622
+ })));
623
+ const activeElement = await this.openManifest(mcpServer, readmeContainer, token);
624
+ this.renderAdditionalDetails(additionalDetailsContainer, mcpServer);
625
+ return activeElement;
626
+ }
627
+ async openManifest(mcpServer, parent, token) {
628
+ const manifestContainer = append(parent, $(".manifest"));
629
+ const content = $("div", {
630
+ class: "manifest-content"
631
+ });
632
+ try {
633
+ const manifest = await this.loadContents(() => this.mcpServerManifest.get(), content);
634
+ if (token.isCancellationRequested) {
635
+ return null;
636
+ }
637
+ this.renderManifestDetails(content, manifest);
638
+ } catch (error) {
639
+ while (content.firstChild) {
640
+ content.removeChild(content.firstChild);
641
+ }
642
+ const noManifestMessage = append(content, $(".no-manifest"));
643
+ noManifestMessage.textContent = ( localize(11076, "No manifest available for this MCP server."));
644
+ }
645
+ const scrollableContent = ( new DomScrollableElement(content, {}));
646
+ const layout = () => scrollableContent.scanDomNode();
647
+ this.contentDisposables.add(toDisposable(insert(this.layoutParticipants, {
648
+ layout
649
+ })));
650
+ append(manifestContainer, scrollableContent.getDomNode());
651
+ return {
652
+ focus: () => content.focus()
653
+ };
654
+ }
655
+ renderConfigurationDetails(container, mcpServer) {
656
+ clearNode(container);
657
+ const config = mcpServer.config;
658
+ if (!config) {
659
+ const noConfigMessage = append(container, $(".no-config"));
660
+ noConfigMessage.textContent = ( localize(11077, "No configuration available for this MCP server."));
661
+ return;
662
+ }
663
+ const nameSection = append(container, $(".config-section"));
664
+ const nameLabel = append(nameSection, $(".config-label"));
665
+ nameLabel.textContent = ( localize(11078, "Name:"));
666
+ const nameValue = append(nameSection, $(".config-value"));
667
+ nameValue.textContent = mcpServer.name;
668
+ const typeSection = append(container, $(".config-section"));
669
+ const typeLabel = append(typeSection, $(".config-label"));
670
+ typeLabel.textContent = ( localize(11079, "Type:"));
671
+ const typeValue = append(typeSection, $(".config-value"));
672
+ typeValue.textContent = config.type;
673
+ if (config.type === McpServerType.LOCAL) {
674
+ const commandSection = append(container, $(".config-section"));
675
+ const commandLabel = append(commandSection, $(".config-label"));
676
+ commandLabel.textContent = ( localize(11080, "Command:"));
677
+ const commandValue = append(commandSection, $("code.config-value"));
678
+ commandValue.textContent = config.command;
679
+ if (config.args && config.args.length > 0) {
680
+ const argsSection = append(container, $(".config-section"));
681
+ const argsLabel = append(argsSection, $(".config-label"));
682
+ argsLabel.textContent = ( localize(11081, "Arguments:"));
683
+ const argsValue = append(argsSection, $("code.config-value"));
684
+ argsValue.textContent = config.args.join(" ");
685
+ }
686
+ if (config.env && ( Object.keys(config.env)).length > 0) {
687
+ const envSection = append(container, $(".config-section"));
688
+ const envLabel = append(envSection, $(".config-label"));
689
+ envLabel.textContent = ( localize(11082, "Environment:"));
690
+ const envValue = append(envSection, $(".config-value"));
691
+ for (const [key, value] of Object.entries(config.env)) {
692
+ append(envValue, $("code.env-entry", undefined, `${key}=${value ?? ""}`));
693
+ }
694
+ }
695
+ if (config.envFile) {
696
+ const envFileSection = append(container, $(".config-section"));
697
+ const envFileLabel = append(envFileSection, $(".config-label"));
698
+ envFileLabel.textContent = ( localize(11083, "Environment File:"));
699
+ const envFileValue = append(envFileSection, $("code.config-value"));
700
+ envFileValue.textContent = config.envFile;
701
+ }
702
+ } else if (config.type === McpServerType.REMOTE) {
703
+ const urlSection = append(container, $(".config-section"));
704
+ const urlLabel = append(urlSection, $(".config-label"));
705
+ urlLabel.textContent = ( localize(11084, "URL:"));
706
+ const urlValue = append(urlSection, $("code.config-value"));
707
+ urlValue.textContent = config.url;
708
+ if (config.headers && ( Object.keys(config.headers)).length > 0) {
709
+ const headersSection = append(container, $(".config-section"));
710
+ const headersLabel = append(headersSection, $(".config-label"));
711
+ headersLabel.textContent = ( localize(11085, "Headers:"));
712
+ const headersValue = append(headersSection, $(".config-value"));
713
+ for (const [key, value] of Object.entries(config.headers)) {
714
+ append(headersValue, $("code.env-entry", undefined, `${key}: ${value ?? ""}`));
715
+ }
716
+ }
717
+ }
718
+ }
719
+ renderManifestDetails(container, manifest) {
720
+ clearNode(container);
721
+ if (manifest.packages && manifest.packages.length > 0) {
722
+ const packagesByType = ( new Map());
723
+ for (const pkg of manifest.packages) {
724
+ const type = pkg.registryType;
725
+ let packages = packagesByType.get(type);
726
+ if (!packages) {
727
+ packagesByType.set(type, packages = []);
728
+ }
729
+ packages.push(pkg);
730
+ }
731
+ append(container, $(
732
+ ".manifest-section",
733
+ undefined,
734
+ $(".manifest-section-title", undefined, ( localize(11086, "Packages")))
735
+ ));
736
+ for (const [packageType, packages] of packagesByType) {
737
+ const packageSection = append(container, $(
738
+ ".package-section",
739
+ undefined,
740
+ $(".package-section-title", undefined, packageType.toUpperCase())
741
+ ));
742
+ const packagesGrid = append(packageSection, $(".package-details"));
743
+ for (let i = 0; i < packages.length; i++) {
744
+ const pkg = packages[i];
745
+ append(
746
+ packagesGrid,
747
+ $(".package-detail", undefined, $(".detail-label", undefined, ( localize(11087, "Package:"))), $(".detail-value", undefined, pkg.identifier))
748
+ );
749
+ if (pkg.packageArguments && pkg.packageArguments.length > 0) {
750
+ const argStrings = [];
751
+ for (const arg of pkg.packageArguments) {
752
+ if (arg.type === "named") {
753
+ argStrings.push(arg.name);
754
+ if (arg.value) {
755
+ argStrings.push(arg.value);
756
+ }
757
+ }
758
+ if (arg.type === "positional") {
759
+ const val = arg.value ?? arg.valueHint;
760
+ if (val) {
761
+ argStrings.push(val);
762
+ }
763
+ }
764
+ }
765
+ append(
766
+ packagesGrid,
767
+ $(".package-detail", undefined, $(".detail-label", undefined, ( localize(11088, "Package Arguments:"))), $("code.detail-value", undefined, argStrings.join(" ")))
768
+ );
769
+ }
770
+ if (pkg.runtimeArguments && pkg.runtimeArguments.length > 0) {
771
+ const argStrings = [];
772
+ for (const arg of pkg.runtimeArguments) {
773
+ if (arg.type === "named") {
774
+ argStrings.push(arg.name);
775
+ if (arg.value) {
776
+ argStrings.push(arg.value);
777
+ }
778
+ }
779
+ if (arg.type === "positional") {
780
+ const val = arg.value ?? arg.valueHint;
781
+ if (val) {
782
+ argStrings.push(val);
783
+ }
784
+ }
785
+ }
786
+ append(
787
+ packagesGrid,
788
+ $(".package-detail", undefined, $(".detail-label", undefined, ( localize(11089, "Runtime Arguments:"))), $("code.detail-value", undefined, argStrings.join(" ")))
789
+ );
790
+ }
791
+ if (pkg.environmentVariables && pkg.environmentVariables.length > 0) {
792
+ const envStrings = ( pkg.environmentVariables.map(envVar => `${envVar.name}=${envVar.value ?? ""}`));
793
+ append(
794
+ packagesGrid,
795
+ $(".package-detail", undefined, $(".detail-label", undefined, ( localize(11090, "Environment Variables:"))), $("code.detail-value", undefined, envStrings.join(" ")))
796
+ );
797
+ }
798
+ if (i < packages.length - 1) {
799
+ append(packagesGrid, $(".package-separator"));
800
+ }
801
+ }
802
+ }
803
+ }
804
+ if (manifest.remotes && manifest.remotes.length > 0) {
805
+ const packageSection = append(container, $(
806
+ ".package-section",
807
+ undefined,
808
+ $(".package-section-title", undefined, ( localize(11091, "Remote")).toLocaleUpperCase())
809
+ ));
810
+ for (const remote of manifest.remotes) {
811
+ const packagesGrid = append(packageSection, $(".package-details"));
812
+ append(
813
+ packagesGrid,
814
+ $(".package-detail", undefined, $(".detail-label", undefined, ( localize(11084, "URL:"))), $(".detail-value", undefined, remote.url))
815
+ );
816
+ if (remote.type) {
817
+ append(
818
+ packagesGrid,
819
+ $(".package-detail", undefined, $(".detail-label", undefined, ( localize(11092, "Transport:"))), $(".detail-value", undefined, remote.type))
820
+ );
821
+ }
822
+ if (remote.headers && remote.headers.length > 0) {
823
+ const headerStrings = ( remote.headers.map(header => `${header.name}: ${header.value ?? ""}`));
824
+ append(
825
+ packagesGrid,
826
+ $(".package-detail", undefined, $(".detail-label", undefined, ( localize(11085, "Headers:"))), $(".detail-value", undefined, headerStrings.join(", ")))
827
+ );
828
+ }
829
+ }
830
+ }
831
+ }
832
+ renderAdditionalDetails(container, extension) {
833
+ const content = $("div", {
834
+ class: "additional-details-content",
835
+ tabindex: "0"
836
+ });
837
+ const scrollableContent = ( new DomScrollableElement(content, {}));
838
+ const layout = () => scrollableContent.scanDomNode();
839
+ const removeLayoutParticipant = insert(this.layoutParticipants, {
840
+ layout
841
+ });
842
+ this.contentDisposables.add(toDisposable(removeLayoutParticipant));
843
+ this.contentDisposables.add(scrollableContent);
844
+ this.contentDisposables.add(
845
+ this.instantiationService.createInstance(AdditionalDetailsWidget, content, extension)
846
+ );
847
+ append(container, scrollableContent.getDomNode());
848
+ scrollableContent.scanDomNode();
849
+ }
850
+ loadContents(loadingTask, container) {
851
+ container.classList.add("loading");
852
+ const result = this.contentDisposables.add(loadingTask());
853
+ const onDone = () => container.classList.remove("loading");
854
+ result.promise.then(onDone, onDone);
855
+ return result.promise;
856
+ }
857
+ layout(dimension) {
858
+ this.dimension = dimension;
859
+ this.layoutParticipants.forEach(p => p.layout());
860
+ }
861
+ onError(err) {
862
+ if (isCancellationError(err)) {
863
+ return;
864
+ }
865
+ this.notificationService.error(err);
866
+ }
867
+ };
868
+ McpServerEditor = McpServerEditor_1 = ( __decorate([( __param(1, ITelemetryService)), ( __param(2, IInstantiationService)), ( __param(3, IThemeService)), ( __param(4, INotificationService)), ( __param(5, IOpenerService)), ( __param(6, IStorageService)), ( __param(7, IExtensionService)), ( __param(8, IWebviewService)), ( __param(9, ILanguageService)), ( __param(10, IContextKeyService)), ( __param(11, IMcpWorkbenchService)), ( __param(12, IHoverService)), ( __param(13, IContextMenuService))], McpServerEditor));
869
+ let AdditionalDetailsWidget = class AdditionalDetailsWidget extends Disposable {
870
+ constructor(
871
+ container,
872
+ extension,
873
+ mcpGalleryManifestService,
874
+ hoverService,
875
+ openerService
876
+ ) {
877
+ super();
878
+ this.container = container;
879
+ this.mcpGalleryManifestService = mcpGalleryManifestService;
880
+ this.hoverService = hoverService;
881
+ this.openerService = openerService;
882
+ this.disposables = this._register(( new DisposableStore()));
883
+ this.render(extension);
884
+ this._register(
885
+ this.mcpGalleryManifestService.onDidChangeMcpGalleryManifest(() => this.render(extension))
886
+ );
887
+ }
888
+ render(extension) {
889
+ this.container.innerText = "";
890
+ this.disposables.clear();
891
+ if (extension.local) {
892
+ this.renderInstallInfo(this.container, extension.local);
893
+ }
894
+ if (extension.gallery) {
895
+ this.renderMarketplaceInfo(this.container, extension);
896
+ }
897
+ this.renderTags(this.container, extension);
898
+ this.renderExtensionResources(this.container, extension);
899
+ }
900
+ renderTags(container, extension) {
901
+ if (extension.gallery?.topics?.length) {
902
+ const categoriesContainer = append(container, $(".categories-container.additional-details-element"));
903
+ append(
904
+ categoriesContainer,
905
+ $(".additional-details-title", undefined, ( localize(11093, "Tags")))
906
+ );
907
+ const categoriesElement = append(categoriesContainer, $(".categories"));
908
+ for (const category of extension.gallery.topics) {
909
+ append(categoriesElement, $("span.category", {
910
+ tabindex: "0"
911
+ }, category));
912
+ }
913
+ }
914
+ }
915
+ async renderExtensionResources(container, extension) {
916
+ const resources = [];
917
+ const manifest = await this.mcpGalleryManifestService.getMcpGalleryManifest();
918
+ if (extension.repository) {
919
+ try {
920
+ resources.push([( localize(11094, "Repository")), ThemeIcon.fromId(Codicon.repo.id), ( URI.parse(extension.repository))]);
921
+ } catch (error) {}
922
+ }
923
+ if (manifest) {
924
+ const supportUri = getMcpGalleryManifestResourceUri(manifest, McpGalleryResourceType.ContactSupportUri);
925
+ if (supportUri) {
926
+ try {
927
+ resources.push([( localize(11095, "Contact Support")), ThemeIcon.fromId(Codicon.commentDiscussion.id), ( URI.parse(supportUri))]);
928
+ } catch (error) {}
929
+ }
930
+ }
931
+ if (resources.length) {
932
+ const extensionResourcesContainer = append(container, $(".resources-container.additional-details-element"));
933
+ append(
934
+ extensionResourcesContainer,
935
+ $(".additional-details-title", undefined, ( localize(11096, "Resources")))
936
+ );
937
+ const resourcesElement = append(extensionResourcesContainer, $(".resources"));
938
+ for (const [label, icon, uri] of resources) {
939
+ const resourceElement = append(resourcesElement, $(".resource"));
940
+ append(resourceElement, $(ThemeIcon.asCSSSelector(icon)));
941
+ append(resourceElement, $("a", {
942
+ tabindex: "0"
943
+ }, label));
944
+ this.disposables.add(onClick(resourceElement, () => this.openerService.open(uri)));
945
+ this.disposables.add(
946
+ this.hoverService.setupManagedHover(getDefaultHoverDelegate("mouse"), resourceElement, ( uri.toString()))
947
+ );
948
+ }
949
+ }
950
+ }
951
+ renderInstallInfo(container, extension) {
952
+ const installInfoContainer = append(container, $(".more-info-container.additional-details-element"));
953
+ append(
954
+ installInfoContainer,
955
+ $(".additional-details-title", undefined, ( localize(11097, "Installation")))
956
+ );
957
+ const installInfo = append(installInfoContainer, $(".more-info"));
958
+ append(installInfo, $(
959
+ ".more-info-entry",
960
+ undefined,
961
+ $("div.more-info-entry-name", undefined, ( localize(11098, "Identifier"))),
962
+ $("code", undefined, extension.name)
963
+ ));
964
+ if (extension.version) {
965
+ append(installInfo, $(
966
+ ".more-info-entry",
967
+ undefined,
968
+ $("div.more-info-entry-name", undefined, ( localize(11099, "Version"))),
969
+ $("code", undefined, extension.version)
970
+ ));
971
+ }
972
+ }
973
+ renderMarketplaceInfo(container, extension) {
974
+ const gallery = extension.gallery;
975
+ const moreInfoContainer = append(container, $(".more-info-container.additional-details-element"));
976
+ append(
977
+ moreInfoContainer,
978
+ $(".additional-details-title", undefined, ( localize(11100, "Marketplace")))
979
+ );
980
+ const moreInfo = append(moreInfoContainer, $(".more-info"));
981
+ if (gallery) {
982
+ if (!extension.local) {
983
+ append(moreInfo, $(
984
+ ".more-info-entry",
985
+ undefined,
986
+ $("div.more-info-entry-name", undefined, ( localize(11098, "Identifier"))),
987
+ $("code", undefined, extension.name)
988
+ ));
989
+ if (gallery.version) {
990
+ append(moreInfo, $(
991
+ ".more-info-entry",
992
+ undefined,
993
+ $("div.more-info-entry-name", undefined, ( localize(11099, "Version"))),
994
+ $("code", undefined, gallery.version)
995
+ ));
996
+ }
997
+ }
998
+ if (gallery.lastUpdated) {
999
+ append(moreInfo, $(
1000
+ ".more-info-entry",
1001
+ undefined,
1002
+ $("div.more-info-entry-name", undefined, ( localize(11101, "Last Released"))),
1003
+ $("div", {
1004
+ "title": ( ( new Date(gallery.lastUpdated)).toString())
1005
+ }, fromNow(gallery.lastUpdated, true, true, true))
1006
+ ));
1007
+ }
1008
+ if (gallery.publishDate) {
1009
+ append(moreInfo, $(
1010
+ ".more-info-entry",
1011
+ undefined,
1012
+ $("div.more-info-entry-name", undefined, ( localize(11102, "Published"))),
1013
+ $("div", {
1014
+ "title": ( ( new Date(gallery.publishDate)).toString())
1015
+ }, fromNow(gallery.publishDate, true, true, true))
1016
+ ));
1017
+ }
1018
+ }
1019
+ }
1020
+ };
1021
+ AdditionalDetailsWidget = ( __decorate([( __param(2, IMcpGalleryManifestService)), ( __param(3, IHoverService)), ( __param(4, IOpenerService))], AdditionalDetailsWidget));
1022
+
1023
+ export { McpServerEditor };