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.
Files changed (157) hide show
  1. package/dist/core/ConfigurationProvider.d.ts +1 -0
  2. package/dist/core/ConfigurationProvider.js +15 -0
  3. package/dist/core/InstallationService.js +2 -7
  4. package/dist/core/MCPManager.d.ts +11 -2
  5. package/dist/core/MCPManager.js +24 -1
  6. package/dist/core/RequirementService.js +2 -8
  7. package/dist/core/installers/clients/BaseClientInstaller.d.ts +51 -0
  8. package/dist/core/installers/clients/BaseClientInstaller.js +160 -0
  9. package/dist/core/installers/clients/ClientInstaller.d.ts +16 -8
  10. package/dist/core/installers/clients/ClientInstaller.js +77 -504
  11. package/dist/core/installers/clients/ClientInstallerFactory.d.ts +19 -0
  12. package/dist/core/installers/clients/ClientInstallerFactory.js +41 -0
  13. package/dist/core/installers/clients/ClineInstaller.d.ts +18 -0
  14. package/dist/core/installers/clients/ClineInstaller.js +124 -0
  15. package/dist/core/installers/clients/GithubCopilotInstaller.d.ts +34 -0
  16. package/dist/core/installers/clients/GithubCopilotInstaller.js +162 -0
  17. package/dist/core/installers/clients/MSRooCodeInstaller.d.ts +15 -0
  18. package/dist/core/installers/clients/MSRooCodeInstaller.js +122 -0
  19. package/dist/core/installers/requirements/BaseInstaller.d.ts +11 -34
  20. package/dist/core/installers/requirements/BaseInstaller.js +5 -116
  21. package/dist/core/installers/requirements/CommandInstaller.d.ts +6 -1
  22. package/dist/core/installers/requirements/CommandInstaller.js +7 -0
  23. package/dist/core/installers/requirements/GeneralInstaller.d.ts +6 -1
  24. package/dist/core/installers/requirements/GeneralInstaller.js +9 -4
  25. package/dist/core/installers/requirements/NpmInstaller.d.ts +46 -7
  26. package/dist/core/installers/requirements/NpmInstaller.js +150 -58
  27. package/dist/core/installers/requirements/PipInstaller.d.ts +9 -0
  28. package/dist/core/installers/requirements/PipInstaller.js +66 -28
  29. package/dist/core/onboard/FeedOnboardService.d.ts +72 -0
  30. package/dist/core/onboard/FeedOnboardService.js +312 -0
  31. package/dist/core/onboard/OnboardProcessor.d.ts +79 -0
  32. package/dist/core/onboard/OnboardProcessor.js +290 -0
  33. package/dist/core/onboard/OnboardStatus.d.ts +49 -0
  34. package/dist/core/onboard/OnboardStatus.js +10 -0
  35. package/dist/core/onboard/OnboardStatusManager.d.ts +57 -0
  36. package/dist/core/onboard/OnboardStatusManager.js +176 -0
  37. package/dist/core/types.d.ts +6 -6
  38. package/dist/core/validators/FeedValidator.d.ts +20 -0
  39. package/dist/core/validators/FeedValidator.js +80 -0
  40. package/dist/core/validators/IServerValidator.d.ts +19 -0
  41. package/dist/core/validators/IServerValidator.js +2 -0
  42. package/dist/core/validators/SSEServerValidator.d.ts +15 -0
  43. package/dist/core/validators/SSEServerValidator.js +39 -0
  44. package/dist/core/validators/ServerValidatorFactory.d.ts +24 -0
  45. package/dist/core/validators/ServerValidatorFactory.js +45 -0
  46. package/dist/core/validators/StdioServerValidator.d.ts +46 -0
  47. package/dist/core/validators/StdioServerValidator.js +229 -0
  48. package/dist/services/InstallRequestValidator.d.ts +1 -1
  49. package/dist/services/ServerService.d.ts +9 -6
  50. package/dist/services/ServerService.js +18 -7
  51. package/dist/utils/adoUtils.d.ts +29 -0
  52. package/dist/utils/adoUtils.js +252 -0
  53. package/dist/utils/clientUtils.d.ts +0 -7
  54. package/dist/utils/clientUtils.js +0 -42
  55. package/dist/utils/githubUtils.d.ts +10 -0
  56. package/dist/utils/githubUtils.js +22 -0
  57. package/dist/utils/macroExpressionUtils.d.ts +38 -0
  58. package/dist/utils/macroExpressionUtils.js +116 -0
  59. package/dist/utils/osUtils.d.ts +4 -20
  60. package/dist/utils/osUtils.js +78 -23
  61. package/dist/web/contract/serverContract.d.ts +66 -0
  62. package/dist/web/contract/serverContract.js +2 -0
  63. package/dist/web/public/css/notifications.css +48 -17
  64. package/dist/web/public/css/onboard.css +107 -0
  65. package/dist/web/public/index.html +90 -18
  66. package/dist/web/public/js/api.js +3 -6
  67. package/dist/web/public/js/flights/flights.js +127 -0
  68. package/dist/web/public/js/modal/index.js +58 -0
  69. package/dist/web/public/js/modal/installHandler.js +227 -0
  70. package/dist/web/public/js/modal/installModal.js +163 -0
  71. package/dist/web/public/js/modal/installation.js +281 -0
  72. package/dist/web/public/js/modal/loadingModal.js +52 -0
  73. package/dist/web/public/js/modal/loadingUI.js +74 -0
  74. package/dist/web/public/js/modal/messageQueue.js +112 -0
  75. package/dist/web/public/js/modal/modalSetup.js +513 -0
  76. package/dist/web/public/js/modal/modalUI.js +214 -0
  77. package/dist/web/public/js/modal/modalUtils.js +49 -0
  78. package/dist/web/public/js/modal/version.js +20 -0
  79. package/dist/web/public/js/modal/versionUtils.js +20 -0
  80. package/dist/web/public/js/modal.js +25 -1041
  81. package/dist/web/public/js/notifications.js +66 -27
  82. package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +338 -0
  83. package/dist/web/public/js/onboard/formProcessor.js +864 -0
  84. package/dist/web/public/js/onboard/index.js +374 -0
  85. package/dist/web/public/js/onboard/publishHandler.js +132 -0
  86. package/dist/web/public/js/onboard/state.js +76 -0
  87. package/dist/web/public/js/onboard/templates.js +343 -0
  88. package/dist/web/public/js/onboard/uiHandlers.js +758 -0
  89. package/dist/web/public/js/onboard/validationHandlers.js +378 -0
  90. package/dist/web/public/js/serverCategoryDetails.js +43 -17
  91. package/dist/web/public/js/serverCategoryList.js +15 -2
  92. package/dist/web/public/onboard.html +296 -0
  93. package/dist/web/public/styles.css +91 -1
  94. package/dist/web/server.d.ts +0 -10
  95. package/dist/web/server.js +131 -22
  96. package/package.json +2 -2
  97. package/src/core/ConfigurationProvider.ts +15 -0
  98. package/src/core/InstallationService.ts +2 -7
  99. package/src/core/MCPManager.ts +26 -1
  100. package/src/core/RequirementService.ts +2 -9
  101. package/src/core/installers/clients/BaseClientInstaller.ts +196 -0
  102. package/src/core/installers/clients/ClientInstaller.ts +97 -589
  103. package/src/core/installers/clients/ClientInstallerFactory.ts +46 -0
  104. package/src/core/installers/clients/ClineInstaller.ts +135 -0
  105. package/src/core/installers/clients/GithubCopilotInstaller.ts +179 -0
  106. package/src/core/installers/clients/MSRooCodeInstaller.ts +133 -0
  107. package/src/core/installers/requirements/BaseInstaller.ts +13 -136
  108. package/src/core/installers/requirements/CommandInstaller.ts +9 -1
  109. package/src/core/installers/requirements/GeneralInstaller.ts +11 -4
  110. package/src/core/installers/requirements/NpmInstaller.ts +178 -61
  111. package/src/core/installers/requirements/PipInstaller.ts +68 -29
  112. package/src/core/onboard/FeedOnboardService.ts +346 -0
  113. package/src/core/onboard/OnboardProcessor.ts +305 -0
  114. package/src/core/onboard/OnboardStatus.ts +55 -0
  115. package/src/core/onboard/OnboardStatusManager.ts +188 -0
  116. package/src/core/types.ts +6 -6
  117. package/src/core/validators/FeedValidator.ts +79 -0
  118. package/src/core/validators/IServerValidator.ts +21 -0
  119. package/src/core/validators/SSEServerValidator.ts +43 -0
  120. package/src/core/validators/ServerValidatorFactory.ts +51 -0
  121. package/src/core/validators/StdioServerValidator.ts +259 -0
  122. package/src/services/InstallRequestValidator.ts +1 -1
  123. package/src/services/ServerService.ts +22 -7
  124. package/src/utils/adoUtils.ts +291 -0
  125. package/src/utils/clientUtils.ts +0 -44
  126. package/src/utils/githubUtils.ts +24 -0
  127. package/src/utils/macroExpressionUtils.ts +121 -0
  128. package/src/utils/osUtils.ts +89 -24
  129. package/src/web/contract/serverContract.ts +74 -0
  130. package/src/web/public/css/notifications.css +48 -17
  131. package/src/web/public/css/onboard.css +107 -0
  132. package/src/web/public/index.html +90 -18
  133. package/src/web/public/js/api.js +3 -6
  134. package/src/web/public/js/flights/flights.js +127 -0
  135. package/src/web/public/js/modal/index.js +58 -0
  136. package/src/web/public/js/modal/installModal.js +163 -0
  137. package/src/web/public/js/modal/installation.js +281 -0
  138. package/src/web/public/js/modal/loadingModal.js +52 -0
  139. package/src/web/public/js/modal/messageQueue.js +112 -0
  140. package/src/web/public/js/modal/modalSetup.js +513 -0
  141. package/src/web/public/js/modal/modalUtils.js +49 -0
  142. package/src/web/public/js/modal/versionUtils.js +20 -0
  143. package/src/web/public/js/modal.js +25 -1041
  144. package/src/web/public/js/notifications.js +66 -27
  145. package/src/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +338 -0
  146. package/src/web/public/js/onboard/formProcessor.js +864 -0
  147. package/src/web/public/js/onboard/index.js +374 -0
  148. package/src/web/public/js/onboard/publishHandler.js +132 -0
  149. package/src/web/public/js/onboard/state.js +76 -0
  150. package/src/web/public/js/onboard/templates.js +343 -0
  151. package/src/web/public/js/onboard/uiHandlers.js +758 -0
  152. package/src/web/public/js/onboard/validationHandlers.js +378 -0
  153. package/src/web/public/js/serverCategoryDetails.js +43 -17
  154. package/src/web/public/js/serverCategoryList.js +15 -2
  155. package/src/web/public/onboard.html +296 -0
  156. package/src/web/public/styles.css +91 -1
  157. package/src/web/server.ts +167 -58
@@ -23,18 +23,42 @@
23
23
 
24
24
  <body class="bg-gray-50 min-h-screen">
25
25
  <div class="container mx-auto px-4 py-6">
26
- <header class="mb-8">
27
- <h1 class="text-3xl font-bold text-gray-900 flex items-center justify-center">
26
+ <div class="flex items-center justify-between mb-8">
27
+ <h1 class="text-3xl font-bold text-gray-900 flex items-center">
28
28
  <i class='bx bx-server mr-3 text-blue-600'></i>
29
29
  IMCP Server Manager
30
30
  </h1>
31
- </header>
32
-
33
- <div class="search-controls mb-6">
34
- <div class="relative max-w-2xl mx-auto">
35
- <input type="text" id="searchBox" placeholder="Search servers or tools..." class="search-input">
36
- <i class='bx bx-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400'></i>
31
+ <div class="lg:w-2/3 flex justify-end items-center gap-4">
32
+ <div class="relative w-48 focus-within:w-96 transition-all duration-300 ease-in-out">
33
+ <input type="text" id="searchBox"
34
+ placeholder="Search..."
35
+ data-expanded-placeholder="Search servers or tools..."
36
+ class="w-full px-10 py-2.5 bg-gray-50 border border-gray-200 rounded-lg
37
+ text-gray-700 placeholder-gray-400
38
+ focus:border-blue-400 focus:ring-2 focus:ring-blue-100
39
+ transition-all duration-300 ease-in-out">
40
+ <i class='bx bx-search absolute left-3.5 top-1/2 transform -translate-y-1/2 text-gray-400'></i>
41
+ </div>
42
+ <button id="onboardButton" style="display: none;"
43
+ class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center">
44
+ <i class='bx bx-plus-circle mr-2'></i>
45
+ Onboard
46
+ </button>
37
47
  </div>
48
+ <script>
49
+ document.addEventListener('DOMContentLoaded', () => {
50
+ const searchBox = document.getElementById('searchBox');
51
+ const expandedPlaceholder = searchBox.dataset.expandedPlaceholder;
52
+ searchBox.addEventListener('focus', () => {
53
+ setTimeout(() => searchBox.placeholder = expandedPlaceholder, 150);
54
+ });
55
+ searchBox.addEventListener('blur', () => {
56
+ if (!searchBox.value) {
57
+ searchBox.placeholder = 'Search...';
58
+ }
59
+ });
60
+ });
61
+ </script>
38
62
  </div>
39
63
 
40
64
  <div class="flex flex-col lg:flex-row gap-6">
@@ -147,10 +171,15 @@
147
171
  import { setupSearch } from './js/serverCategoryList.js';
148
172
  import { showServerDetails } from './js/serverCategoryDetails.js';
149
173
  import { showInstallModal, closeModal, setupModalOutsideClick } from './js/modal.js';
174
+ // import { showOnboardModal as navigateToOnboard } from './js/onboard/index.js'; // We are directly navigating
175
+ import flights, { getFlightQueryParameters, buildUrlWithFlights } from './js/flights/flights.js';
150
176
 
151
177
  // Make necessary functions available globally
152
178
  window.showServerDetails = showServerDetails;
153
179
  window.showInstallModal = showInstallModal;
180
+ // window.showOnboardModal = showOnboardModal; // This might conflict if showOnboardModal is also in onboard/index.js
181
+ // We'll rely on the event listener above for the main page's onboard button.
182
+ // If other parts of the app call window.showOnboardModal, they'll need updating too.
154
183
  window.closeModal = closeModal;
155
184
  window.handleInstallServer = handleInstallServer;
156
185
  window.installRequirement = installRequirement;
@@ -162,19 +191,62 @@
162
191
  setupSearch();
163
192
  setupModalOutsideClick();
164
193
 
165
- // Check URL parameters for category
166
- const urlParams = new URLSearchParams(window.location.search);
167
- const categoryParam = urlParams.get('category');
194
+ const onboardButton = document.getElementById('onboardButton');
195
+ if (flights.enableOnboard) {
196
+ onboardButton.style.display = 'flex'; // Make it visible
197
+ onboardButton.addEventListener('click', () => {
198
+ // The original showOnboardModal in onboard/index.js likely does window.location.href = 'onboard.html';
199
+ // We need to preserve existing flight parameters.
200
+ const flightQueryString = getFlightQueryParameters();
201
+ // Assuming navigateToOnboard from onboard/index.js handles the actual navigation
202
+ // If it directly sets window.location.href, we might need to adjust how it's called or modify it.
203
+ // For now, let's assume we can adapt its usage or it's a simple navigation.
204
+ // The simplest way if showOnboardModal in onboard/index.js is just `window.location.href = 'onboard.html'`
205
+ // would be to directly navigate here.
206
+ window.location.href = buildUrlWithFlights('onboard.html');
207
+ });
208
+ }
209
+ // No 'else' block needed as it's hidden by default via inline style
210
+
211
+ try {
212
+ // First fetch categories and wait for completion
213
+ // fetchServerCategories will call renderServerCategoryList, which might call loadLastSelectedCategory.
214
+ // loadLastSelectedCategory calls showServerDetails.
215
+ // The logic for setting initial category URL is now more centralized.
216
+
217
+ await fetchServerCategories(); // This populates allServerCategoriesData
168
218
 
169
- // If we have a category parameter or last selected category
170
- const lastSelected = categoryParam || localStorage.getItem('lastSelectedCategory');
219
+ const urlParams = new URLSearchParams(window.location.search);
220
+ const categoryParam = urlParams.get('category');
221
+ const lastSelectedCategoryFromStorage = localStorage.getItem('lastSelectedCategory');
171
222
 
172
- // First fetch categories
173
- await fetchServerCategories();
223
+ if (categoryParam) {
224
+ // Category is in URL, load it
225
+ await window.showServerDetails(categoryParam);
226
+ } else if (lastSelectedCategoryFromStorage) {
227
+ // Category not in URL, but in localStorage. Redirect to URL with this category and flights.
228
+ window.location.href = buildUrlWithFlights('index.html', { category: lastSelectedCategoryFromStorage });
229
+ return; // Stop further execution, page will reload
230
+ } else if (allServerCategoriesData && allServerCategoriesData.length > 0) {
231
+ // No category in URL or localStorage, pick first from list and redirect.
232
+ window.location.href = buildUrlWithFlights('index.html', { category: allServerCategoriesData[0].name });
233
+ return; // Stop further execution, page will reload
234
+ } else {
235
+ // No categories at all, or data still loading. Default placeholder will be shown.
236
+ // Or, if allServerCategoriesData is empty after fetch, the placeholder from HTML remains.
237
+ }
174
238
 
175
- // Then show the selected category if it exists
176
- if (lastSelected) {
177
- showServerDetails(lastSelected);
239
+ } catch (error) {
240
+ console.error('Error during initialization:', error);
241
+ // Potentially show a user-friendly error message in the UI
242
+ const serverCategoryDetailsDiv = document.getElementById('serverCategoryDetails');
243
+ if (serverCategoryDetailsDiv) {
244
+ serverCategoryDetailsDiv.innerHTML = `<p class="text-red-500">Error initializing page: ${error.message}</p>`;
245
+ }
246
+ const serverCategoryListDiv = document.getElementById('serverCategoryList');
247
+ if (serverCategoryListDiv) {
248
+ serverCategoryListDiv.innerHTML = `<p class="text-red-500">Could not load categories.</p>`;
249
+ }
178
250
  }
179
251
  });
180
252
  </script>
@@ -3,6 +3,8 @@ import { showToast } from './notifications.js';
3
3
 
4
4
  // Global store for server data
5
5
  let allServerCategoriesData = [];
6
+ // Make it available globally for legacy code
7
+ window.allServerCategoriesData = allServerCategoriesData;
6
8
 
7
9
  // Fetch and display servers
8
10
  async function fetchServerCategories() {
@@ -14,16 +16,11 @@ async function fetchServerCategories() {
14
16
  if (!responseData.success || !responseData.data) {
15
17
  throw new Error(`API Error fetching servers: ${responseData.error || 'Invalid data format'}`);
16
18
  }
17
- allServerCategoriesData = responseData.data; // Store globally
19
+ allServerCategoriesData = window.allServerCategoriesData = responseData.data; // Update both local and global references
18
20
 
19
21
  // Use the renderServerCategoryList function to display servers
20
22
  renderServerCategoryList(allServerCategoriesData);
21
23
 
22
- // Show the first category by default if there are categories
23
- if (allServerCategoriesData.length > 0) {
24
- window.showServerDetails(allServerCategoriesData[0].name);
25
- }
26
-
27
24
  // Check if search is active
28
25
  const searchTerm = document.getElementById('searchBox').value.toLowerCase();
29
26
  if (searchTerm) {
@@ -0,0 +1,127 @@
1
+ // Centralized flight control configuration
2
+
3
+ const FLIGHT_STORAGE_KEY = 'activeFlightSettings';
4
+
5
+ // Default flight settings
6
+ const defaultFlights = {
7
+ enableOnboard: true, // Default: Onboarding is enabled. Set to false to disable.
8
+ // Add other default flights here, e.g., newFeatureX: false,
9
+ };
10
+
11
+ let effectiveFlightSettings = {};
12
+
13
+ // Initialize flight settings
14
+ function initializeFlightSettings() {
15
+ const urlParams = new URLSearchParams(window.location.search);
16
+ let settingsToStore = {};
17
+ let sourcedFromUrl = false;
18
+
19
+ // Check URL parameters first
20
+ for (const key in defaultFlights) {
21
+ if (urlParams.has(key)) {
22
+ const paramValue = urlParams.get(key);
23
+ settingsToStore[key] = (paramValue === 'true') ? true : (paramValue === 'false' ? false : paramValue);
24
+ sourcedFromUrl = true;
25
+ }
26
+ }
27
+
28
+ if (sourcedFromUrl) {
29
+ // If any flight was set via URL, these override sessionStorage for this load
30
+ // and then update sessionStorage.
31
+ // Fill any missing flights with defaults before storing.
32
+ for (const key in defaultFlights) {
33
+ if (!Object.hasOwnProperty.call(settingsToStore, key)) {
34
+ settingsToStore[key] = defaultFlights[key];
35
+ }
36
+ }
37
+ try {
38
+ sessionStorage.setItem(FLIGHT_STORAGE_KEY, JSON.stringify(settingsToStore));
39
+ effectiveFlightSettings = settingsToStore;
40
+ } catch (e) {
41
+ console.error("Failed to write to sessionStorage:", e);
42
+ effectiveFlightSettings = settingsToStore; // Use them anyway for this page load
43
+ }
44
+ } else {
45
+ // No flight params in URL, try sessionStorage
46
+ try {
47
+ const storedSettings = sessionStorage.getItem(FLIGHT_STORAGE_KEY);
48
+ if (storedSettings) {
49
+ effectiveFlightSettings = JSON.parse(storedSettings);
50
+ // Ensure all default keys are present, add if missing (e.g., new flight added)
51
+ for (const key in defaultFlights) {
52
+ if (!Object.hasOwnProperty.call(effectiveFlightSettings, key)) {
53
+ effectiveFlightSettings[key] = defaultFlights[key];
54
+ }
55
+ }
56
+ } else {
57
+ // Not in sessionStorage, use defaults and store them
58
+ effectiveFlightSettings = { ...defaultFlights };
59
+ sessionStorage.setItem(FLIGHT_STORAGE_KEY, JSON.stringify(effectiveFlightSettings));
60
+ }
61
+ } catch (e) {
62
+ console.error("Failed to read/write sessionStorage:", e);
63
+ effectiveFlightSettings = { ...defaultFlights }; // Fallback to defaults
64
+ }
65
+ }
66
+ }
67
+
68
+ initializeFlightSettings();
69
+
70
+ // The `flights` object provides these effective values.
71
+ const flights = {};
72
+ for (const key in defaultFlights) { // Iterate defaultFlights to define getters for all known flights
73
+ if (Object.hasOwnProperty.call(defaultFlights, key)) {
74
+ Object.defineProperty(flights, key, {
75
+ get: () => effectiveFlightSettings[key] !== undefined ? effectiveFlightSettings[key] : defaultFlights[key],
76
+ enumerable: true,
77
+ configurable: false
78
+ });
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Helper to build a URLSearchParams object with the effective flight values.
84
+ * @returns {URLSearchParams}
85
+ */
86
+ function _buildFlightParams() {
87
+ const flightParams = new URLSearchParams();
88
+ for (const flightName in effectiveFlightSettings) {
89
+ if (Object.hasOwnProperty.call(effectiveFlightSettings, flightName)) {
90
+ // Only add if it's a recognized flight from defaultFlights to avoid polluting URL
91
+ // with unrelated sessionStorage items if FLIGHT_STORAGE_KEY was somehow corrupted.
92
+ if (Object.hasOwnProperty.call(defaultFlights, flightName)) {
93
+ flightParams.set(flightName, String(effectiveFlightSettings[flightName]));
94
+ }
95
+ }
96
+ }
97
+ return flightParams;
98
+ }
99
+
100
+ /**
101
+ * Constructs a URL with the effective flight parameters and any additional parameters.
102
+ * @param {string} baseUrl The base URL (e.g., "index.html").
103
+ * @param {object} [additionalParams={}] - An object of additional key-value pairs to include.
104
+ * @returns {string} A full URL with query string.
105
+ */
106
+ export function buildUrlWithFlights(baseUrl, additionalParams = {}) {
107
+ const params = _buildFlightParams(); // Start with all effective flight values
108
+
109
+ for (const key in additionalParams) {
110
+ if (Object.hasOwnProperty.call(additionalParams, key) && additionalParams[key] !== undefined) {
111
+ params.set(key, additionalParams[key]);
112
+ }
113
+ }
114
+ const queryString = params.toString();
115
+ return `${baseUrl}${queryString ? `?${queryString}` : ''}`;
116
+ }
117
+
118
+ /**
119
+ * Gets a query string containing only the effective flight parameters.
120
+ * @returns {string} A query string like "?enableOnboard=true" or empty.
121
+ */
122
+ export function getFlightQueryParameters() {
123
+ const queryString = _buildFlightParams().toString();
124
+ return queryString ? `?${queryString}` : '';
125
+ }
126
+
127
+ export default flights;
@@ -0,0 +1,58 @@
1
+ // Import all modal-related functionality
2
+ import { compareVersions } from './versionUtils.js';
3
+ import { delayedAppendInstallLoadingMessage } from './messageQueue.js';
4
+ import { showInstallLoadingModal, appendInstallLoadingMessage, hideInstallLoadingModal } from './loadingModal.js';
5
+ import { closeModal, setupModalOutsideClick } from './modalUtils.js';
6
+ import { handleBulkClientInstall, uninstallTools } from './installation.js';
7
+ import { showInstallModal } from './installModal.js';
8
+ import {
9
+ setupClientItems,
10
+ setupEnvironmentVariables,
11
+ setupInstallationArguments,
12
+ setupServerRequirements,
13
+ setupFormSubmitHandler
14
+ } from './modalSetup.js';
15
+
16
+ // Export all modal functionality
17
+ export {
18
+ // Version utilities
19
+ compareVersions,
20
+
21
+ // Message queue
22
+ delayedAppendInstallLoadingMessage,
23
+
24
+ // Loading modal
25
+ showInstallLoadingModal,
26
+ appendInstallLoadingMessage,
27
+ hideInstallLoadingModal,
28
+
29
+ // Modal utilities
30
+ closeModal,
31
+ setupModalOutsideClick,
32
+
33
+ // Installation
34
+ handleBulkClientInstall,
35
+ uninstallTools,
36
+
37
+ // Install modal
38
+ showInstallModal,
39
+
40
+ // Modal setup
41
+ setupClientItems,
42
+ setupEnvironmentVariables,
43
+ setupInstallationArguments,
44
+ setupServerRequirements,
45
+ setupFormSubmitHandler
46
+ };
47
+
48
+ // Initialize modal functionality
49
+ document.addEventListener('DOMContentLoaded', () => {
50
+ setupModalOutsideClick();
51
+ });
52
+
53
+ // Make certain functions available globally
54
+ window.showInstallModal = showInstallModal;
55
+ window.showInstallLoadingModal = showInstallLoadingModal;
56
+ window.appendInstallLoadingMessage = appendInstallLoadingMessage;
57
+ window.hideInstallLoadingModal = hideInstallLoadingModal;
58
+ window.uninstallTools = uninstallTools;
@@ -0,0 +1,163 @@
1
+ import { showToast, showConfirm } from '../notifications.js';
2
+ import { compareVersions } from './versionUtils.js';
3
+ import { delayedAppendInstallLoadingMessage } from './messageQueue.js';
4
+ import { showInstallLoadingModal } from './loadingModal.js';
5
+ import { setupModalOutsideClick, closeModal, setupToggleStyles } from './modalUtils.js';
6
+ import { handleBulkClientInstall, uninstallTools } from './installation.js';
7
+ import {
8
+ setupClientItems,
9
+ setupEnvironmentVariables,
10
+ setupInstallationArguments,
11
+ setupServerRequirements,
12
+ setupFormSubmitHandler
13
+ } from './modalSetup.js';
14
+
15
+ // Initialize modal functionality when DOM is loaded
16
+ document.addEventListener('DOMContentLoaded', () => {
17
+ setupModalOutsideClick();
18
+ setupToggleStyles();
19
+ });
20
+
21
+ /**
22
+ * Show install modal for MCP tools
23
+ * @param {string} categoryName - The category name
24
+ * @param {string} serverName - The server name
25
+ * @param {Function} callback - Optional callback function
26
+ */
27
+ export async function showInstallModal(categoryName, serverName, callback) {
28
+ console.log("Showing install modal for:", serverName);
29
+
30
+ // Wait for a short delay to ensure modal is loaded
31
+ await new Promise(resolve => setTimeout(resolve, 100));
32
+
33
+ const modal = document.getElementById('installModal');
34
+ if (!modal) {
35
+ console.error('Modal container not found');
36
+ return;
37
+ }
38
+
39
+ const title = modal.querySelector('#modalTitle');
40
+ const envInputsDiv = modal.querySelector('#modalEnvInputs');
41
+ const targetDiv = modal.querySelector('#modalTargets');
42
+ const modalRequirements = modal.querySelector('#modalRequirements');
43
+ const modalArguments = modal.querySelector('#modalArguments');
44
+
45
+ // Global array to track selected clients
46
+ window.selectedClients = [];
47
+
48
+ // Verify all required modal elements exist
49
+ if (!title || !envInputsDiv || !targetDiv || !modalRequirements || !modalArguments) {
50
+ console.error('Required modal elements not found');
51
+ return;
52
+ }
53
+
54
+ title.textContent = `Install ${serverName}`;
55
+ envInputsDiv.innerHTML = ''; // Clear previous inputs
56
+ targetDiv.innerHTML = ''; // Clear previous targets
57
+ modalRequirements.innerHTML = ''; // Clear previous requirements
58
+ modalArguments.innerHTML = ''; // Clear previous arguments
59
+
60
+ try {
61
+ // Fetch both targets and server data simultaneously
62
+ const [targetResponse, serverResponse] = await Promise.all([
63
+ fetch('/api/targets'),
64
+ fetch(`/api/categories/${categoryName}`)
65
+ ]);
66
+
67
+ if (!targetResponse.ok || !serverResponse.ok) {
68
+ throw new Error('Failed to fetch required data');
69
+ }
70
+
71
+ const [targetData, serverData] = await Promise.all([
72
+ targetResponse.json(),
73
+ serverResponse.json()
74
+ ]);
75
+
76
+ if (!targetData.success || !serverData.success) {
77
+ throw new Error('Invalid data received');
78
+ }
79
+
80
+ const mcpServer = serverData.data.feedConfiguration.mcpServers.find(server => server.name === serverName);
81
+ if (!mcpServer) {
82
+ throw new Error('Server configuration not found');
83
+ }
84
+
85
+ // Add mode indicator
86
+ const modeSpan = document.createElement('span');
87
+ modeSpan.textContent = mcpServer.mode || 'stdio';
88
+ modeSpan.className = 'ml-2 px-2 py-0.5 text-xs bg-gray-200 text-gray-600 rounded';
89
+ title.appendChild(modeSpan);
90
+ const installationStatus = serverData.data.installationStatus || {};
91
+ const serverStatuses = installationStatus.serversStatus || {};
92
+ const serverStatus = serverStatuses[serverName] || { installedStatus: {} };
93
+
94
+ await setupModalContent(
95
+ targetData,
96
+ mcpServer,
97
+ serverStatus,
98
+ categoryName,
99
+ serverName,
100
+ serverStatuses,
101
+ serverData,
102
+ targetDiv,
103
+ envInputsDiv,
104
+ modalArguments,
105
+ modalRequirements
106
+ );
107
+
108
+ } catch (error) {
109
+ console.error("Error loading data:", error);
110
+ targetDiv.innerHTML = `<p class="text-red-500">Error: ${error.message}</p>`;
111
+ }
112
+
113
+ modal.style.display = "block";
114
+ }
115
+
116
+ /**
117
+ * Set up the modal content including client list, environment variables, and requirements
118
+ * @private
119
+ */
120
+ async function setupModalContent(
121
+ targetData,
122
+ mcpServer,
123
+ serverStatus,
124
+ categoryName,
125
+ serverName,
126
+ serverStatuses,
127
+ serverData,
128
+ targetDiv,
129
+ envInputsDiv,
130
+ modalArguments,
131
+ modalRequirements
132
+ ) {
133
+ // Create client items
134
+ setupClientItems(targetData.data, serverStatus, categoryName, serverName, targetDiv);
135
+
136
+ // Handle environment variables section
137
+ setupEnvironmentVariables(mcpServer, envInputsDiv, targetData);
138
+
139
+ // Handle installation arguments section
140
+ setupInstallationArguments(mcpServer.installation, modalArguments, mcpServer);
141
+
142
+ // Handle server requirements section
143
+ setupServerRequirements(mcpServer, serverData, categoryName, serverName, modalRequirements);
144
+
145
+ // Set up the install form submit handler
146
+ const installForm = document.getElementById('installForm');
147
+ setupFormSubmitHandler(
148
+ installForm,
149
+ envInputsDiv,
150
+ modalArguments,
151
+ modalRequirements,
152
+ categoryName,
153
+ serverName,
154
+ serverStatuses,
155
+ serverData,
156
+ mcpServer
157
+ );
158
+ }
159
+
160
+ // Make functions available globally
161
+ window.showInstallModal = showInstallModal;
162
+ window.closeModal = closeModal;
163
+ window.uninstallTools = uninstallTools;