imcp 0.0.13 → 0.0.15
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/dist/core/ConfigurationProvider.d.ts +1 -0
- package/dist/core/ConfigurationProvider.js +15 -0
- package/dist/core/InstallationService.js +2 -7
- package/dist/core/MCPManager.d.ts +11 -2
- package/dist/core/MCPManager.js +24 -1
- package/dist/core/RequirementService.js +2 -8
- package/dist/core/installers/clients/BaseClientInstaller.d.ts +51 -0
- package/dist/core/installers/clients/BaseClientInstaller.js +160 -0
- package/dist/core/installers/clients/ClientInstaller.d.ts +16 -8
- package/dist/core/installers/clients/ClientInstaller.js +77 -504
- package/dist/core/installers/clients/ClientInstallerFactory.d.ts +19 -0
- package/dist/core/installers/clients/ClientInstallerFactory.js +41 -0
- package/dist/core/installers/clients/ClineInstaller.d.ts +18 -0
- package/dist/core/installers/clients/ClineInstaller.js +124 -0
- package/dist/core/installers/clients/GithubCopilotInstaller.d.ts +34 -0
- package/dist/core/installers/clients/GithubCopilotInstaller.js +162 -0
- package/dist/core/installers/clients/MSRooCodeInstaller.d.ts +15 -0
- package/dist/core/installers/clients/MSRooCodeInstaller.js +122 -0
- package/dist/core/installers/requirements/BaseInstaller.d.ts +11 -34
- package/dist/core/installers/requirements/BaseInstaller.js +5 -116
- package/dist/core/installers/requirements/CommandInstaller.d.ts +6 -1
- package/dist/core/installers/requirements/CommandInstaller.js +7 -0
- package/dist/core/installers/requirements/GeneralInstaller.d.ts +6 -1
- package/dist/core/installers/requirements/GeneralInstaller.js +9 -4
- package/dist/core/installers/requirements/NpmInstaller.d.ts +46 -7
- package/dist/core/installers/requirements/NpmInstaller.js +150 -58
- package/dist/core/installers/requirements/PipInstaller.d.ts +9 -0
- package/dist/core/installers/requirements/PipInstaller.js +66 -28
- package/dist/core/onboard/FeedOnboardService.d.ts +72 -0
- package/dist/core/onboard/FeedOnboardService.js +312 -0
- package/dist/core/onboard/OnboardProcessor.d.ts +79 -0
- package/dist/core/onboard/OnboardProcessor.js +290 -0
- package/dist/core/onboard/OnboardStatus.d.ts +49 -0
- package/dist/core/onboard/OnboardStatus.js +10 -0
- package/dist/core/onboard/OnboardStatusManager.d.ts +57 -0
- package/dist/core/onboard/OnboardStatusManager.js +176 -0
- package/dist/core/types.d.ts +6 -6
- package/dist/core/validators/FeedValidator.d.ts +20 -0
- package/dist/core/validators/FeedValidator.js +80 -0
- package/dist/core/validators/IServerValidator.d.ts +19 -0
- package/dist/core/validators/IServerValidator.js +2 -0
- package/dist/core/validators/SSEServerValidator.d.ts +15 -0
- package/dist/core/validators/SSEServerValidator.js +39 -0
- package/dist/core/validators/ServerValidatorFactory.d.ts +24 -0
- package/dist/core/validators/ServerValidatorFactory.js +45 -0
- package/dist/core/validators/StdioServerValidator.d.ts +46 -0
- package/dist/core/validators/StdioServerValidator.js +229 -0
- package/dist/services/InstallRequestValidator.d.ts +1 -1
- package/dist/services/ServerService.d.ts +9 -6
- package/dist/services/ServerService.js +18 -7
- package/dist/utils/adoUtils.d.ts +29 -0
- package/dist/utils/adoUtils.js +252 -0
- package/dist/utils/clientUtils.d.ts +0 -7
- package/dist/utils/clientUtils.js +0 -42
- package/dist/utils/githubUtils.d.ts +10 -0
- package/dist/utils/githubUtils.js +22 -0
- package/dist/utils/macroExpressionUtils.d.ts +38 -0
- package/dist/utils/macroExpressionUtils.js +116 -0
- package/dist/utils/osUtils.d.ts +4 -20
- package/dist/utils/osUtils.js +78 -23
- package/dist/web/contract/serverContract.d.ts +66 -0
- package/dist/web/contract/serverContract.js +2 -0
- package/dist/web/public/css/notifications.css +48 -17
- package/dist/web/public/css/onboard.css +107 -0
- package/dist/web/public/index.html +90 -18
- package/dist/web/public/js/api.js +3 -6
- package/dist/web/public/js/flights/flights.js +127 -0
- package/dist/web/public/js/modal/index.js +58 -0
- package/dist/web/public/js/modal/installHandler.js +227 -0
- package/dist/web/public/js/modal/installModal.js +163 -0
- package/dist/web/public/js/modal/installation.js +281 -0
- package/dist/web/public/js/modal/loadingModal.js +52 -0
- package/dist/web/public/js/modal/loadingUI.js +74 -0
- package/dist/web/public/js/modal/messageQueue.js +112 -0
- package/dist/web/public/js/modal/modalSetup.js +513 -0
- package/dist/web/public/js/modal/modalUI.js +214 -0
- package/dist/web/public/js/modal/modalUtils.js +49 -0
- package/dist/web/public/js/modal/version.js +20 -0
- package/dist/web/public/js/modal/versionUtils.js +20 -0
- package/dist/web/public/js/modal.js +25 -1041
- package/dist/web/public/js/notifications.js +66 -27
- package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +338 -0
- package/dist/web/public/js/onboard/formProcessor.js +864 -0
- package/dist/web/public/js/onboard/index.js +374 -0
- package/dist/web/public/js/onboard/publishHandler.js +132 -0
- package/dist/web/public/js/onboard/state.js +76 -0
- package/dist/web/public/js/onboard/templates.js +343 -0
- package/dist/web/public/js/onboard/uiHandlers.js +758 -0
- package/dist/web/public/js/onboard/validationHandlers.js +378 -0
- package/dist/web/public/js/serverCategoryDetails.js +43 -17
- package/dist/web/public/js/serverCategoryList.js +15 -2
- package/dist/web/public/onboard.html +296 -0
- package/dist/web/public/styles.css +91 -1
- package/dist/web/server.d.ts +0 -10
- package/dist/web/server.js +131 -22
- package/package.json +2 -2
- package/src/core/ConfigurationProvider.ts +15 -0
- package/src/core/InstallationService.ts +2 -7
- package/src/core/MCPManager.ts +26 -1
- package/src/core/RequirementService.ts +2 -9
- package/src/core/installers/clients/BaseClientInstaller.ts +196 -0
- package/src/core/installers/clients/ClientInstaller.ts +97 -589
- package/src/core/installers/clients/ClientInstallerFactory.ts +46 -0
- package/src/core/installers/clients/ClineInstaller.ts +135 -0
- package/src/core/installers/clients/GithubCopilotInstaller.ts +179 -0
- package/src/core/installers/clients/MSRooCodeInstaller.ts +133 -0
- package/src/core/installers/requirements/BaseInstaller.ts +13 -136
- package/src/core/installers/requirements/CommandInstaller.ts +9 -1
- package/src/core/installers/requirements/GeneralInstaller.ts +11 -4
- package/src/core/installers/requirements/NpmInstaller.ts +178 -61
- package/src/core/installers/requirements/PipInstaller.ts +68 -29
- package/src/core/onboard/FeedOnboardService.ts +346 -0
- package/src/core/onboard/OnboardProcessor.ts +305 -0
- package/src/core/onboard/OnboardStatus.ts +55 -0
- package/src/core/onboard/OnboardStatusManager.ts +188 -0
- package/src/core/types.ts +6 -6
- package/src/core/validators/FeedValidator.ts +79 -0
- package/src/core/validators/IServerValidator.ts +21 -0
- package/src/core/validators/SSEServerValidator.ts +43 -0
- package/src/core/validators/ServerValidatorFactory.ts +51 -0
- package/src/core/validators/StdioServerValidator.ts +259 -0
- package/src/services/InstallRequestValidator.ts +1 -1
- package/src/services/ServerService.ts +22 -7
- package/src/utils/adoUtils.ts +291 -0
- package/src/utils/clientUtils.ts +0 -44
- package/src/utils/githubUtils.ts +24 -0
- package/src/utils/macroExpressionUtils.ts +121 -0
- package/src/utils/osUtils.ts +89 -24
- package/src/web/contract/serverContract.ts +74 -0
- package/src/web/public/css/notifications.css +48 -17
- package/src/web/public/css/onboard.css +107 -0
- package/src/web/public/index.html +90 -18
- package/src/web/public/js/api.js +3 -6
- package/src/web/public/js/flights/flights.js +127 -0
- package/src/web/public/js/modal/index.js +58 -0
- package/src/web/public/js/modal/installModal.js +163 -0
- package/src/web/public/js/modal/installation.js +281 -0
- package/src/web/public/js/modal/loadingModal.js +52 -0
- package/src/web/public/js/modal/messageQueue.js +112 -0
- package/src/web/public/js/modal/modalSetup.js +513 -0
- package/src/web/public/js/modal/modalUtils.js +49 -0
- package/src/web/public/js/modal/versionUtils.js +20 -0
- package/src/web/public/js/modal.js +25 -1041
- package/src/web/public/js/notifications.js +66 -27
- package/src/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +338 -0
- package/src/web/public/js/onboard/formProcessor.js +864 -0
- package/src/web/public/js/onboard/index.js +374 -0
- package/src/web/public/js/onboard/publishHandler.js +132 -0
- package/src/web/public/js/onboard/state.js +76 -0
- package/src/web/public/js/onboard/templates.js +343 -0
- package/src/web/public/js/onboard/uiHandlers.js +758 -0
- package/src/web/public/js/onboard/validationHandlers.js +378 -0
- package/src/web/public/js/serverCategoryDetails.js +43 -17
- package/src/web/public/js/serverCategoryList.js +15 -2
- package/src/web/public/onboard.html +296 -0
- package/src/web/public/styles.css +91 -1
- package/src/web/server.ts +167 -58
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import { showToast, showConfirm } from '../notifications.js';
|
|
2
|
+
import { showInstallLoadingModal } from './loadingModal.js';
|
|
3
|
+
import { delayedAppendInstallLoadingMessage } from './messageQueue.js';
|
|
4
|
+
import { uninstallTools } from './installation.js';
|
|
5
|
+
import { handleBulkClientInstall } from './installation.js';
|
|
6
|
+
import { compareVersions } from './versionUtils.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Set up client items in the modal
|
|
10
|
+
*/
|
|
11
|
+
export function setupClientItems(targets, serverStatus, categoryName, serverName, targetDiv) {
|
|
12
|
+
targets.forEach(target => {
|
|
13
|
+
const operationStatus = serverStatus.installedStatus[target] || { status: 'not-installed', type: 'check', target: 'server' };
|
|
14
|
+
|
|
15
|
+
// Determine client status
|
|
16
|
+
let statusText = '';
|
|
17
|
+
let statusClass = '';
|
|
18
|
+
|
|
19
|
+
if (operationStatus.status === 'completed' && operationStatus.type === 'install') {
|
|
20
|
+
statusText = 'Installed';
|
|
21
|
+
statusClass = 'installed';
|
|
22
|
+
} else if (operationStatus.status === 'pending') {
|
|
23
|
+
statusText = 'Pending Requirements';
|
|
24
|
+
statusClass = 'pending';
|
|
25
|
+
} else if (operationStatus.status === 'in-progress') {
|
|
26
|
+
statusText = 'In Progress';
|
|
27
|
+
statusClass = 'pending';
|
|
28
|
+
} else if (operationStatus.status === 'failed') {
|
|
29
|
+
statusText = 'Failed';
|
|
30
|
+
statusClass = 'not-installed';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const isConfigured = operationStatus.status === 'completed' && operationStatus.type === 'install';
|
|
34
|
+
const isInProgress = operationStatus.status === 'in-progress';
|
|
35
|
+
const isSelectable = !isConfigured && !isInProgress;
|
|
36
|
+
|
|
37
|
+
const clientItem = createClientItem(target, statusText, statusClass, isSelectable, isConfigured, isInProgress);
|
|
38
|
+
setupClientItemListeners(clientItem, target, isSelectable);
|
|
39
|
+
setupUninstallButton(clientItem, statusText, operationStatus, target, categoryName, serverName, statusClass);
|
|
40
|
+
targetDiv.appendChild(clientItem);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
addSectionTitle(targetDiv);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Set up environment variables section in the modal
|
|
48
|
+
*/
|
|
49
|
+
export function setupEnvironmentVariables(mcpServer, envInputsDiv, targetData) {
|
|
50
|
+
// For SSE mode, don't show env section at all
|
|
51
|
+
if (mcpServer.mode === 'sse') {
|
|
52
|
+
envInputsDiv.style.display = 'none';
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const envRequirements = mcpServer.installation?.['env'] || mcpServer.installation?.env || {};
|
|
57
|
+
addEnvironmentTitle(envInputsDiv);
|
|
58
|
+
|
|
59
|
+
if (Object.keys(envRequirements).length === 0) {
|
|
60
|
+
addNoEnvMessage(envInputsDiv);
|
|
61
|
+
} else {
|
|
62
|
+
createEnvironmentInputs(envRequirements, envInputsDiv, targetData.clientMcpSettings, mcpServer.name);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Set up installation arguments section in the modal
|
|
68
|
+
*/
|
|
69
|
+
export function setupInstallationArguments(installation, modalArguments, mcpServer) {
|
|
70
|
+
// For SSE mode, don't show arguments section at all
|
|
71
|
+
if (mcpServer?.mode === 'sse') {
|
|
72
|
+
modalArguments.style.display = 'none';
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!installation) return;
|
|
77
|
+
|
|
78
|
+
addArgumentsTitle(modalArguments);
|
|
79
|
+
const container = createArgumentsContainer();
|
|
80
|
+
modalArguments.appendChild(container);
|
|
81
|
+
|
|
82
|
+
if (installation.args && Array.isArray(installation.args)) {
|
|
83
|
+
installation.args.forEach(arg => {
|
|
84
|
+
container.appendChild(createArgumentInput(arg));
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
container.appendChild(createArgumentInput());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (installation.command === 'python' || installation.command.includes('python')) {
|
|
91
|
+
addPythonEnvironmentInput(modalArguments);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Set up server requirements section in the modal
|
|
97
|
+
*/
|
|
98
|
+
export function setupServerRequirements(mcpServer, serverData, categoryName, serverName, modalRequirements) {
|
|
99
|
+
// For SSE mode, don't show requirements section at all
|
|
100
|
+
if (mcpServer.mode === 'sse') {
|
|
101
|
+
modalRequirements.style.display = 'none';
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const serverRequirements = mcpServer.dependencies?.requirements || [];
|
|
106
|
+
const requirements = serverData.data.installationStatus?.requirementsStatus || {};
|
|
107
|
+
|
|
108
|
+
if (serverRequirements.length > 0) {
|
|
109
|
+
const reqHtml = renderRequirements(serverRequirements, requirements, categoryName, serverName);
|
|
110
|
+
modalRequirements.innerHTML = `
|
|
111
|
+
<h3 class="text-lg font-semibold text-gray-700 mb-3">Dependencies</h3>
|
|
112
|
+
<p class="text-sm text-gray-600 mb-4">These dependencies will be automatically installed when installing the server</p>
|
|
113
|
+
${reqHtml}
|
|
114
|
+
`;
|
|
115
|
+
|
|
116
|
+
setupUpdateToggles(modalRequirements);
|
|
117
|
+
} else {
|
|
118
|
+
modalRequirements.innerHTML = '<p class="text-gray-600">No additional dependencies required.</p>';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Set up the form submit handler
|
|
124
|
+
*/
|
|
125
|
+
export function setupFormSubmitHandler(form, envInputsDiv, modalArguments, modalRequirements, categoryName, serverName, serverStatuses, serverData, mcpServer) {
|
|
126
|
+
form.onsubmit = (e) => {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
|
|
129
|
+
const envVars = {};
|
|
130
|
+
const args = [];
|
|
131
|
+
const requirementsToUpdate = [];
|
|
132
|
+
let pythonEnv = undefined;
|
|
133
|
+
|
|
134
|
+
// Only collect env, args and requirements if not in SSE mode
|
|
135
|
+
if (mcpServer?.mode !== 'sse') {
|
|
136
|
+
const inputs = envInputsDiv.querySelectorAll('input');
|
|
137
|
+
inputs.forEach(input => {
|
|
138
|
+
if (input.name && input.value) {
|
|
139
|
+
envVars[input.name] = input.value;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const argInputs = modalArguments.querySelectorAll('.arg-input');
|
|
144
|
+
args.push(...Array.from(argInputs)
|
|
145
|
+
.map(input => input.value.trim())
|
|
146
|
+
.filter(val => val !== ''));
|
|
147
|
+
|
|
148
|
+
const pythonEnvInput = document.getElementById('python_env');
|
|
149
|
+
pythonEnv = pythonEnvInput?.value?.trim();
|
|
150
|
+
|
|
151
|
+
const updateToggles = modalRequirements.querySelectorAll('.toggle-update:checked');
|
|
152
|
+
updateToggles.forEach(toggle => {
|
|
153
|
+
requirementsToUpdate.push({
|
|
154
|
+
name: toggle.dataset.name,
|
|
155
|
+
version: toggle.dataset.version
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const hasRequirementsToUpdate = requirementsToUpdate.length > 0;
|
|
161
|
+
|
|
162
|
+
const uninstallBtn = document.querySelector('.uninstall-btn');
|
|
163
|
+
if (!uninstallBtn || !uninstallBtn.matches(':active')) {
|
|
164
|
+
const selectedTargets = window.selectedClients;
|
|
165
|
+
if (selectedTargets.length === 0 && !hasRequirementsToUpdate) {
|
|
166
|
+
showToast('Please select at least one client to configure.', 'error');
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let installingMessage = "Starting installation...";
|
|
171
|
+
const serverStatus = serverStatuses[serverName] || { installedStatus: {} };
|
|
172
|
+
if (selectedTargets.length > 0) {
|
|
173
|
+
const target = selectedTargets[0];
|
|
174
|
+
const msg = serverStatus.installedStatus?.[target]?.message;
|
|
175
|
+
if (msg) installingMessage = msg;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const serverInstallOptions = {
|
|
179
|
+
targetClients: selectedTargets,
|
|
180
|
+
env: envVars,
|
|
181
|
+
args: args,
|
|
182
|
+
settings: pythonEnv ? { pythonEnv: pythonEnv } : {}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
if (requirementsToUpdate.length > 0) {
|
|
186
|
+
serverInstallOptions.requirements = requirementsToUpdate;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
handleBulkClientInstall(categoryName, serverName, selectedTargets, envVars, installingMessage, serverData, serverInstallOptions);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Helper functions
|
|
195
|
+
function createClientItem(target, statusText, statusClass, isSelectable, isConfigured, isInProgress) {
|
|
196
|
+
const clientItem = document.createElement('div');
|
|
197
|
+
clientItem.className = 'client-item';
|
|
198
|
+
clientItem.dataset.target = target;
|
|
199
|
+
clientItem.dataset.selected = 'false';
|
|
200
|
+
|
|
201
|
+
// Create client info (name)
|
|
202
|
+
const clientInfo = document.createElement('div');
|
|
203
|
+
clientInfo.className = 'client-info';
|
|
204
|
+
|
|
205
|
+
// Client name label
|
|
206
|
+
const clientName = document.createElement('span');
|
|
207
|
+
clientName.className = 'text-sm font-medium text-gray-900';
|
|
208
|
+
clientName.textContent = target;
|
|
209
|
+
|
|
210
|
+
// Add elements to client info
|
|
211
|
+
clientInfo.appendChild(clientName);
|
|
212
|
+
|
|
213
|
+
// Add client info to client item
|
|
214
|
+
clientItem.appendChild(clientInfo);
|
|
215
|
+
|
|
216
|
+
if (!isSelectable) {
|
|
217
|
+
clientItem.classList.add('non-selectable');
|
|
218
|
+
if (isConfigured) {
|
|
219
|
+
clientItem.classList.add('installed-item');
|
|
220
|
+
clientItem.title = 'Already installed';
|
|
221
|
+
} else if (isInProgress) {
|
|
222
|
+
clientItem.classList.add('in-progress-item');
|
|
223
|
+
clientItem.title = 'Installation in progress';
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return clientItem;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function setupClientItemListeners(clientItem, target, isSelectable) {
|
|
231
|
+
if (isSelectable) {
|
|
232
|
+
clientItem.addEventListener('click', () => {
|
|
233
|
+
const isSelected = clientItem.dataset.selected === 'true';
|
|
234
|
+
clientItem.dataset.selected = isSelected ? 'false' : 'true';
|
|
235
|
+
|
|
236
|
+
if (isSelected) {
|
|
237
|
+
clientItem.classList.remove('selected');
|
|
238
|
+
window.selectedClients = window.selectedClients.filter(c => c !== target);
|
|
239
|
+
} else {
|
|
240
|
+
clientItem.classList.add('selected');
|
|
241
|
+
if (!window.selectedClients.includes(target)) {
|
|
242
|
+
window.selectedClients.push(target);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function setupUninstallButton(clientItem, statusText, operationStatus, target, categoryName, serverName, statusClass) {
|
|
250
|
+
if (statusText) {
|
|
251
|
+
const statusContainer = document.createElement('div');
|
|
252
|
+
statusContainer.className = 'status-container';
|
|
253
|
+
|
|
254
|
+
const statusBadge = document.createElement('span');
|
|
255
|
+
statusBadge.className = `status-badge ${statusClass}`;
|
|
256
|
+
statusBadge.textContent = statusText;
|
|
257
|
+
statusContainer.appendChild(statusBadge);
|
|
258
|
+
|
|
259
|
+
if (operationStatus.status === 'completed' && operationStatus.type === 'install') {
|
|
260
|
+
const uninstallBtn = createUninstallButton(target, categoryName, serverName);
|
|
261
|
+
statusContainer.appendChild(uninstallBtn);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
clientItem.appendChild(statusContainer);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function createUninstallButton(target, categoryName, serverName) {
|
|
269
|
+
const uninstallBtn = document.createElement('button');
|
|
270
|
+
uninstallBtn.className = 'uninstall-btn text-red-600 hover:text-red-800 ml-2';
|
|
271
|
+
uninstallBtn.innerHTML = '<i class="bx bx-trash"></i>';
|
|
272
|
+
uninstallBtn.title = 'Uninstall from this client';
|
|
273
|
+
|
|
274
|
+
uninstallBtn.onclick = async (e) => {
|
|
275
|
+
e.stopPropagation();
|
|
276
|
+
e.preventDefault();
|
|
277
|
+
|
|
278
|
+
const confirmed = await showConfirm('Uninstall Confirmation',
|
|
279
|
+
`Are you sure you want to uninstall ${serverName} from ${target}?`);
|
|
280
|
+
|
|
281
|
+
if (confirmed) {
|
|
282
|
+
window.selectedClients = [target];
|
|
283
|
+
showInstallLoadingModal('Uninstalling');
|
|
284
|
+
const serverList = {
|
|
285
|
+
[serverName]: {
|
|
286
|
+
removeData: true
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
delayedAppendInstallLoadingMessage(`Uninstalling ${serverName} from ${target}...`);
|
|
292
|
+
await uninstallTools(categoryName, serverList, [target]);
|
|
293
|
+
} catch (error) {
|
|
294
|
+
delayedAppendInstallLoadingMessage(`Error: ${error.message}`);
|
|
295
|
+
throw error;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return false;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
return uninstallBtn;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function addSectionTitle(targetDiv) {
|
|
305
|
+
if (!targetDiv.querySelector('.section-title')) {
|
|
306
|
+
const titleElement = document.createElement('h3');
|
|
307
|
+
titleElement.className = 'section-title text-lg font-semibold text-gray-700 mb-3';
|
|
308
|
+
titleElement.textContent = 'Client Status';
|
|
309
|
+
targetDiv.insertBefore(titleElement, targetDiv.firstChild);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function addEnvironmentTitle(envInputsDiv) {
|
|
314
|
+
if (!envInputsDiv.querySelector('.section-title')) {
|
|
315
|
+
const envTitle = document.createElement('h3');
|
|
316
|
+
envTitle.className = 'section-title text-lg font-semibold text-gray-700 mb-3';
|
|
317
|
+
envTitle.textContent = 'Environment Variables';
|
|
318
|
+
envInputsDiv.insertBefore(envTitle, envInputsDiv.firstChild);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function addNoEnvMessage(envInputsDiv) {
|
|
323
|
+
const noEnvMessage = document.createElement('p');
|
|
324
|
+
noEnvMessage.className = 'text-gray-600';
|
|
325
|
+
noEnvMessage.textContent = 'No environment variables required for this MCP server.';
|
|
326
|
+
envInputsDiv.appendChild(noEnvMessage);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function createEnvironmentInputs(envRequirements, envInputsDiv, clientSettings, serverName) {
|
|
330
|
+
Object.keys(envRequirements).forEach(key => {
|
|
331
|
+
const req = envRequirements[key];
|
|
332
|
+
const inputId = `env_${key}`;
|
|
333
|
+
const inputWrapper = document.createElement('div');
|
|
334
|
+
inputWrapper.className = 'mb-3';
|
|
335
|
+
|
|
336
|
+
const label = document.createElement('label');
|
|
337
|
+
label.htmlFor = inputId;
|
|
338
|
+
label.className = 'block text-sm font-medium text-gray-700 mb-1';
|
|
339
|
+
label.innerHTML = `${key} ${req.Required ? '<span class="text-red-500">*</span>' : ''}`;
|
|
340
|
+
|
|
341
|
+
const input = document.createElement('input');
|
|
342
|
+
input.type = req.isSecret ? 'password' : 'text';
|
|
343
|
+
input.id = inputId;
|
|
344
|
+
input.name = key;
|
|
345
|
+
input.placeholder = req.Description || key;
|
|
346
|
+
input.required = req.Required;
|
|
347
|
+
input.className = 'input-field';
|
|
348
|
+
|
|
349
|
+
// For default value, first check settings for the target server, then use the provided default
|
|
350
|
+
let defaultValue = req.Default || '';
|
|
351
|
+
|
|
352
|
+
// Check if we have settings from client configuration
|
|
353
|
+
if (clientSettings && clientSettings.MSRooCode &&
|
|
354
|
+
clientSettings.MSRooCode.mcpServers &&
|
|
355
|
+
clientSettings.MSRooCode.mcpServers[serverName] &&
|
|
356
|
+
clientSettings.MSRooCode.mcpServers[serverName].env &&
|
|
357
|
+
clientSettings.MSRooCode.mcpServers[serverName].env[key]) {
|
|
358
|
+
defaultValue = clientSettings.MSRooCode.mcpServers[serverName].env[key];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
input.value = defaultValue;
|
|
362
|
+
|
|
363
|
+
inputWrapper.appendChild(label);
|
|
364
|
+
inputWrapper.appendChild(input);
|
|
365
|
+
|
|
366
|
+
if (req.Description) {
|
|
367
|
+
const description = document.createElement('p');
|
|
368
|
+
description.className = 'text-xs text-gray-500 mt-1';
|
|
369
|
+
description.textContent = req.Description;
|
|
370
|
+
inputWrapper.appendChild(description);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
envInputsDiv.appendChild(inputWrapper);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function addArgumentsTitle(modalArguments) {
|
|
378
|
+
const argsTitle = document.createElement('h3');
|
|
379
|
+
argsTitle.className = 'section-title text-lg font-semibold text-gray-700 mb-3';
|
|
380
|
+
argsTitle.textContent = 'Arguments';
|
|
381
|
+
modalArguments.appendChild(argsTitle);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function createArgumentsContainer() {
|
|
385
|
+
const container = document.createElement('div');
|
|
386
|
+
container.className = 'args-container mb-3';
|
|
387
|
+
|
|
388
|
+
const addButton = document.createElement('button');
|
|
389
|
+
addButton.type = 'button';
|
|
390
|
+
addButton.className = 'add-arg-button px-3 py-1 text-sm text-blue-600 hover:text-blue-800 border border-blue-600 hover:border-blue-800 rounded-md mb-2';
|
|
391
|
+
addButton.innerHTML = '<i class="bx bx-plus"></i> Add Argument';
|
|
392
|
+
addButton.onclick = () => container.appendChild(createArgumentInput());
|
|
393
|
+
|
|
394
|
+
container.appendChild(addButton);
|
|
395
|
+
return container;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function createArgumentInput(value = '') {
|
|
399
|
+
const argWrapper = document.createElement('div');
|
|
400
|
+
argWrapper.className = 'arg-wrapper flex items-center gap-2 mb-2';
|
|
401
|
+
|
|
402
|
+
const input = document.createElement('input');
|
|
403
|
+
input.type = 'text';
|
|
404
|
+
input.className = 'arg-input flex-grow';
|
|
405
|
+
input.value = value;
|
|
406
|
+
input.placeholder = 'Enter argument value';
|
|
407
|
+
|
|
408
|
+
const removeButton = document.createElement('button');
|
|
409
|
+
removeButton.type = 'button';
|
|
410
|
+
removeButton.className = 'remove-arg-button text-red-600 hover:text-red-800';
|
|
411
|
+
removeButton.innerHTML = '<i class="bx bx-trash"></i>';
|
|
412
|
+
removeButton.onclick = () => argWrapper.remove();
|
|
413
|
+
|
|
414
|
+
argWrapper.appendChild(input);
|
|
415
|
+
argWrapper.appendChild(removeButton);
|
|
416
|
+
return argWrapper;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function addPythonEnvironmentInput(modalArguments) {
|
|
420
|
+
const pythonEnvWrapper = document.createElement('div');
|
|
421
|
+
pythonEnvWrapper.className = 'mt-4';
|
|
422
|
+
|
|
423
|
+
const pythonEnvLabel = document.createElement('label');
|
|
424
|
+
pythonEnvLabel.htmlFor = 'python_env';
|
|
425
|
+
pythonEnvLabel.className = 'block text-sm font-medium text-gray-700 mb-1';
|
|
426
|
+
pythonEnvLabel.textContent = 'Python Environment';
|
|
427
|
+
|
|
428
|
+
const pythonEnvInput = document.createElement('input');
|
|
429
|
+
pythonEnvInput.type = 'text';
|
|
430
|
+
pythonEnvInput.id = 'python_env';
|
|
431
|
+
pythonEnvInput.className = 'input-field';
|
|
432
|
+
pythonEnvInput.placeholder = 'Enter Python environment path (optional)';
|
|
433
|
+
|
|
434
|
+
const envDescription = document.createElement('p');
|
|
435
|
+
envDescription.className = 'text-xs text-gray-500 mt-1';
|
|
436
|
+
envDescription.textContent = 'Specify the Python executable file(e.g. C:/python312/python) to use for installation. Leave empty to use system default.';
|
|
437
|
+
|
|
438
|
+
pythonEnvWrapper.appendChild(pythonEnvLabel);
|
|
439
|
+
pythonEnvWrapper.appendChild(pythonEnvInput);
|
|
440
|
+
pythonEnvWrapper.appendChild(envDescription);
|
|
441
|
+
modalArguments.appendChild(pythonEnvWrapper);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function renderRequirements(serverRequirements, requirements, categoryName, serverName) {
|
|
445
|
+
return serverRequirements.map(req => {
|
|
446
|
+
const status = requirements[req.name] || {};
|
|
447
|
+
let statusClass = status.installed
|
|
448
|
+
? 'text-green-600 bg-green-50'
|
|
449
|
+
: 'text-yellow-600 bg-yellow-50';
|
|
450
|
+
let statusText = status.installed ? 'Installed' : 'Required';
|
|
451
|
+
let versionDisplay = status.version ? ` • <span class="font-medium">${status.version}</span>` : '';
|
|
452
|
+
let updateToggle = '';
|
|
453
|
+
|
|
454
|
+
// Check if there's an available update
|
|
455
|
+
if (status.installed && status.availableUpdate && status.availableUpdate.version) {
|
|
456
|
+
if (status.version && compareVersions(status.availableUpdate.version, status.version) > 0) {
|
|
457
|
+
// Show version update information with yellow color and icon
|
|
458
|
+
statusClass = 'text-yellow-600 bg-yellow-50';
|
|
459
|
+
statusText = `<span style="color: #f59e0b; font-weight: bold; margin-right: 5px;">↑</span>${status.availableUpdate.version}`;
|
|
460
|
+
|
|
461
|
+
// Create a toggle switch for update
|
|
462
|
+
updateToggle = `
|
|
463
|
+
<label class="inline-flex items-center cursor-pointer ml-2">
|
|
464
|
+
<input type="checkbox" class="toggle-update sr-only"
|
|
465
|
+
data-name="${req.name}"
|
|
466
|
+
data-version="${status.availableUpdate.version}"
|
|
467
|
+
data-category="${categoryName}"
|
|
468
|
+
data-server="${serverName}">
|
|
469
|
+
<div class="relative w-10 h-5 bg-gray-200 rounded-full toggle-bg">
|
|
470
|
+
<div class="absolute inset-y-0 left-0 w-5 h-5 bg-white rounded-full transition-transform duration-300 transform"></div>
|
|
471
|
+
</div>
|
|
472
|
+
<span class="ml-2 text-sm text-gray-700">Update</span>
|
|
473
|
+
</label>
|
|
474
|
+
`;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return `
|
|
479
|
+
<div class="border border-gray-200 p-3 rounded-lg mb-2 hover:bg-gray-50">
|
|
480
|
+
<div class="flex justify-between items-center">
|
|
481
|
+
<div>
|
|
482
|
+
<div class="font-semibold text-gray-800">${req.name}</div>
|
|
483
|
+
<div class="text-sm text-gray-600 shadow-sm p-1 rounded bg-gray-50">
|
|
484
|
+
<span class="font-medium">${status.type || 'package'}</span>${versionDisplay}
|
|
485
|
+
</div>
|
|
486
|
+
</div>
|
|
487
|
+
<div class="flex items-center">
|
|
488
|
+
<span class="${statusClass} inline-flex items-center px-3 py-1 rounded-full text-sm">
|
|
489
|
+
${statusText}
|
|
490
|
+
</span>
|
|
491
|
+
${updateToggle}
|
|
492
|
+
</div>
|
|
493
|
+
</div>
|
|
494
|
+
</div>
|
|
495
|
+
`;
|
|
496
|
+
}).join('');
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function setupUpdateToggles(modalRequirements) {
|
|
500
|
+
const updateToggles = modalRequirements.querySelectorAll('.toggle-update');
|
|
501
|
+
updateToggles.forEach(toggle => {
|
|
502
|
+
toggle.addEventListener('change', function () {
|
|
503
|
+
const toggleBg = this.parentElement.querySelector('.toggle-bg');
|
|
504
|
+
if (this.checked) {
|
|
505
|
+
toggleBg.classList.add('bg-blue-500');
|
|
506
|
+
toggleBg.querySelector('div').classList.add('translate-x-5');
|
|
507
|
+
} else {
|
|
508
|
+
toggleBg.classList.remove('bg-blue-500');
|
|
509
|
+
toggleBg.querySelector('div').classList.remove('translate-x-5');
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
}
|