imcp 0.1.7 → 0.1.8-dev

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 (314) hide show
  1. package/dist/cli/commands/install.js +1 -106
  2. package/dist/cli/commands/install.js.map +1 -0
  3. package/dist/cli/commands/list.js +1 -90
  4. package/dist/cli/commands/list.js.map +1 -0
  5. package/dist/cli/commands/pull.js +1 -16
  6. package/dist/cli/commands/pull.js.map +1 -0
  7. package/dist/cli/commands/serve.js +1 -33
  8. package/dist/cli/commands/serve.js.map +1 -0
  9. package/dist/cli/commands/uninstall.js +1 -46
  10. package/dist/cli/commands/uninstall.js.map +1 -0
  11. package/dist/cli/index.js +1 -65
  12. package/dist/cli/index.js.map +1 -0
  13. package/dist/core/installers/clients/BaseClientInstaller.js +1 -282
  14. package/dist/core/installers/clients/BaseClientInstaller.js.map +1 -0
  15. package/dist/core/installers/clients/ClientInstaller.js +1 -163
  16. package/dist/core/installers/clients/ClientInstaller.js.map +1 -0
  17. package/dist/core/installers/clients/ClientInstallerFactory.js +1 -36
  18. package/dist/core/installers/clients/ClientInstallerFactory.js.map +1 -0
  19. package/dist/core/installers/clients/ClineInstaller.js +1 -30
  20. package/dist/core/installers/clients/ClineInstaller.js.map +1 -0
  21. package/dist/core/installers/clients/ExtensionInstaller.js +1 -151
  22. package/dist/core/installers/clients/ExtensionInstaller.js.map +1 -0
  23. package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -68
  24. package/dist/core/installers/clients/GithubCopilotInstaller.js.map +1 -0
  25. package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -28
  26. package/dist/core/installers/clients/MSRooCodeInstaller.js.map +1 -0
  27. package/dist/core/installers/index.js +1 -8
  28. package/dist/core/installers/index.js.map +1 -0
  29. package/dist/core/installers/requirements/BaseInstaller.js +1 -56
  30. package/dist/core/installers/requirements/BaseInstaller.js.map +1 -0
  31. package/dist/core/installers/requirements/CommandInstaller.js +1 -213
  32. package/dist/core/installers/requirements/CommandInstaller.js.map +1 -0
  33. package/dist/core/installers/requirements/GeneralInstaller.js +1 -126
  34. package/dist/core/installers/requirements/GeneralInstaller.js.map +1 -0
  35. package/dist/core/installers/requirements/InstallerFactory.js +1 -99
  36. package/dist/core/installers/requirements/InstallerFactory.js.map +1 -0
  37. package/dist/core/installers/requirements/NpmInstaller.js +1 -235
  38. package/dist/core/installers/requirements/NpmInstaller.js.map +1 -0
  39. package/dist/core/installers/requirements/NugetInstaller.js +1 -188
  40. package/dist/core/installers/requirements/NugetInstaller.js.map +1 -0
  41. package/dist/core/installers/requirements/PipInstaller.js +1 -192
  42. package/dist/core/installers/requirements/PipInstaller.js.map +1 -0
  43. package/dist/core/installers/requirements/RequirementInstaller.js +1 -2
  44. package/dist/core/installers/requirements/RequirementInstaller.js.map +1 -0
  45. package/dist/core/loaders/ConfigurationLoader.js +1 -256
  46. package/dist/core/loaders/ConfigurationLoader.js.map +1 -0
  47. package/dist/core/loaders/ConfigurationProvider.js +1 -383
  48. package/dist/core/loaders/ConfigurationProvider.js.map +1 -0
  49. package/dist/core/loaders/InstallOperationManager.js +1 -310
  50. package/dist/core/loaders/InstallOperationManager.js.map +1 -0
  51. package/dist/core/loaders/ServerSchemaLoader.js +1 -108
  52. package/dist/core/loaders/ServerSchemaLoader.js.map +1 -0
  53. package/dist/core/loaders/ServerSchemaProvider.js +1 -89
  54. package/dist/core/loaders/ServerSchemaProvider.js.map +1 -0
  55. package/dist/core/loaders/SystemSettingsManager.js +1 -256
  56. package/dist/core/loaders/SystemSettingsManager.js.map +1 -0
  57. package/dist/core/metadatas/constants.js +1 -100
  58. package/dist/core/metadatas/constants.js.map +1 -0
  59. package/dist/core/metadatas/recordingConstants.js +1 -46
  60. package/dist/core/metadatas/recordingConstants.js.map +1 -0
  61. package/dist/core/metadatas/types.js +1 -15
  62. package/dist/core/metadatas/types.js.map +1 -0
  63. package/dist/core/onboard/FeedOnboardService.js +1 -422
  64. package/dist/core/onboard/FeedOnboardService.js.map +1 -0
  65. package/dist/core/onboard/OnboardProcessor.js +1 -333
  66. package/dist/core/onboard/OnboardProcessor.js.map +1 -0
  67. package/dist/core/onboard/OnboardStatus.js +1 -9
  68. package/dist/core/onboard/OnboardStatus.js.map +1 -0
  69. package/dist/core/onboard/OnboardStatusManager.js +1 -360
  70. package/dist/core/onboard/OnboardStatusManager.js.map +1 -0
  71. package/dist/core/validators/FeedValidator.js +1 -133
  72. package/dist/core/validators/FeedValidator.js.map +1 -0
  73. package/dist/core/validators/IServerValidator.js +1 -1
  74. package/dist/core/validators/IServerValidator.js.map +1 -0
  75. package/dist/core/validators/SSEServerValidator.js +1 -38
  76. package/dist/core/validators/SSEServerValidator.js.map +1 -0
  77. package/dist/core/validators/ServerValidatorFactory.js +1 -44
  78. package/dist/core/validators/ServerValidatorFactory.js.map +1 -0
  79. package/dist/core/validators/StdioServerValidator.js +1 -281
  80. package/dist/core/validators/StdioServerValidator.js.map +1 -0
  81. package/dist/index.js +1 -18
  82. package/dist/index.js.map +1 -0
  83. package/dist/services/InstallationService.js +1 -81
  84. package/dist/services/InstallationService.js.map +1 -0
  85. package/dist/services/MCPManager.js +1 -197
  86. package/dist/services/MCPManager.js.map +1 -0
  87. package/dist/services/RequirementService.js +1 -548
  88. package/dist/services/RequirementService.js.map +1 -0
  89. package/dist/services/ServerService.js +1 -127
  90. package/dist/services/ServerService.js.map +1 -0
  91. package/dist/services/TelemetryService.js +1 -53
  92. package/dist/services/TelemetryService.js.map +1 -0
  93. package/dist/utils/UpdateCheckTracker.js +1 -79
  94. package/dist/utils/UpdateCheckTracker.js.map +1 -0
  95. package/dist/utils/adoUtils.js +1 -254
  96. package/dist/utils/adoUtils.js.map +1 -0
  97. package/dist/utils/clientUtils.js +1 -65
  98. package/dist/utils/clientUtils.js.map +1 -0
  99. package/dist/utils/feedUtils.js +1 -28
  100. package/dist/utils/feedUtils.js.map +1 -0
  101. package/dist/utils/githubAuth.js +1 -177
  102. package/dist/utils/githubAuth.js.map +1 -0
  103. package/dist/utils/githubUtils.js +1 -125
  104. package/dist/utils/githubUtils.js.map +1 -0
  105. package/dist/utils/logger.js +1 -176
  106. package/dist/utils/logger.js.map +1 -0
  107. package/dist/utils/macroExpressionUtils.js +1 -93
  108. package/dist/utils/macroExpressionUtils.js.map +1 -0
  109. package/dist/utils/osUtils.js +1 -664
  110. package/dist/utils/osUtils.js.map +1 -0
  111. package/dist/utils/versionUtils.js +1 -101
  112. package/dist/utils/versionUtils.js.map +1 -0
  113. package/dist/web/contract/serverContract.js +1 -1
  114. package/dist/web/contract/serverContract.js.map +1 -0
  115. package/dist/web/public/js/api.js +2 -132
  116. package/dist/web/public/js/api.js.map +1 -0
  117. package/dist/web/public/js/detailsWidget.js +2 -264
  118. package/dist/web/public/js/detailsWidget.js.map +1 -0
  119. package/dist/web/public/js/flights/flights.js +2 -127
  120. package/dist/web/public/js/flights/flights.js.map +1 -0
  121. package/dist/web/public/js/modal/index.js +2 -52
  122. package/dist/web/public/js/modal/index.js.map +1 -0
  123. package/dist/web/public/js/modal/installModal.js +2 -162
  124. package/dist/web/public/js/modal/installModal.js.map +1 -0
  125. package/dist/web/public/js/modal/installation.js +2 -266
  126. package/dist/web/public/js/modal/installation.js.map +1 -0
  127. package/dist/web/public/js/modal/loadingModal.js +2 -182
  128. package/dist/web/public/js/modal/loadingModal.js.map +1 -0
  129. package/dist/web/public/js/modal/modalSetup.js +2 -595
  130. package/dist/web/public/js/modal/modalSetup.js.map +1 -0
  131. package/dist/web/public/js/modal/modalUtils.js +2 -37
  132. package/dist/web/public/js/modal/modalUtils.js.map +1 -0
  133. package/dist/web/public/js/modal/versionUtils.js +2 -20
  134. package/dist/web/public/js/modal/versionUtils.js.map +1 -0
  135. package/dist/web/public/js/modal.js +2 -42
  136. package/dist/web/public/js/modal.js.map +1 -0
  137. package/dist/web/public/js/notifications.js +2 -137
  138. package/dist/web/public/js/notifications.js.map +1 -0
  139. package/dist/web/public/js/onboard/formProcessor.js +2 -1037
  140. package/dist/web/public/js/onboard/formProcessor.js.map +1 -0
  141. package/dist/web/public/js/onboard/index.js +2 -374
  142. package/dist/web/public/js/onboard/index.js.map +1 -0
  143. package/dist/web/public/js/onboard/publishHandler.js +2 -172
  144. package/dist/web/public/js/onboard/publishHandler.js.map +1 -0
  145. package/dist/web/public/js/onboard/state.js +2 -76
  146. package/dist/web/public/js/onboard/state.js.map +1 -0
  147. package/dist/web/public/js/onboard/templates.js +2 -342
  148. package/dist/web/public/js/onboard/templates.js.map +1 -0
  149. package/dist/web/public/js/onboard/uiHandlers.js +2 -1076
  150. package/dist/web/public/js/onboard/uiHandlers.js.map +1 -0
  151. package/dist/web/public/js/onboard/validationHandlers.js +2 -493
  152. package/dist/web/public/js/onboard/validationHandlers.js.map +1 -0
  153. package/dist/web/public/js/serverCategoryDetails.js +2 -364
  154. package/dist/web/public/js/serverCategoryDetails.js.map +1 -0
  155. package/dist/web/public/js/serverCategoryList.js +2 -241
  156. package/dist/web/public/js/serverCategoryList.js.map +1 -0
  157. package/dist/web/public/js/settings.js +2 -314
  158. package/dist/web/public/js/settings.js.map +1 -0
  159. package/dist/web/server.js +1 -404
  160. package/dist/web/server.js.map +1 -0
  161. package/package.json +8 -2
  162. package/.github/ISSUE_TEMPLATE/JitAccess.yml +0 -28
  163. package/.github/acl/access.yml +0 -20
  164. package/.github/compliance/inventory.yml +0 -5
  165. package/.github/policies/jit.yml +0 -19
  166. package/.github/workflows/build.yml +0 -28
  167. package/.roo/rules-code/rules.md +0 -88
  168. package/dist/cli/commands/start.d.ts +0 -2
  169. package/dist/cli/commands/start.js +0 -32
  170. package/dist/cli/commands/sync.d.ts +0 -2
  171. package/dist/cli/commands/sync.js +0 -17
  172. package/dist/core/ConfigurationLoader.d.ts +0 -32
  173. package/dist/core/ConfigurationLoader.js +0 -236
  174. package/dist/core/ConfigurationProvider.d.ts +0 -35
  175. package/dist/core/ConfigurationProvider.js +0 -375
  176. package/dist/core/InstallationService.d.ts +0 -50
  177. package/dist/core/InstallationService.js +0 -350
  178. package/dist/core/MCPManager.d.ts +0 -28
  179. package/dist/core/MCPManager.js +0 -188
  180. package/dist/core/RequirementService.d.ts +0 -40
  181. package/dist/core/RequirementService.js +0 -110
  182. package/dist/core/ServerSchemaLoader.d.ts +0 -11
  183. package/dist/core/ServerSchemaLoader.js +0 -43
  184. package/dist/core/ServerSchemaProvider.d.ts +0 -17
  185. package/dist/core/ServerSchemaProvider.js +0 -120
  186. package/dist/core/constants.d.ts +0 -47
  187. package/dist/core/constants.js +0 -94
  188. package/dist/core/installers/BaseInstaller.d.ts +0 -74
  189. package/dist/core/installers/BaseInstaller.js +0 -253
  190. package/dist/core/installers/ClientInstaller.d.ts +0 -23
  191. package/dist/core/installers/ClientInstaller.js +0 -564
  192. package/dist/core/installers/CommandInstaller.d.ts +0 -37
  193. package/dist/core/installers/CommandInstaller.js +0 -173
  194. package/dist/core/installers/GeneralInstaller.d.ts +0 -33
  195. package/dist/core/installers/GeneralInstaller.js +0 -85
  196. package/dist/core/installers/InstallerFactory.d.ts +0 -54
  197. package/dist/core/installers/InstallerFactory.js +0 -97
  198. package/dist/core/installers/NpmInstaller.d.ts +0 -26
  199. package/dist/core/installers/NpmInstaller.js +0 -127
  200. package/dist/core/installers/PipInstaller.d.ts +0 -28
  201. package/dist/core/installers/PipInstaller.js +0 -127
  202. package/dist/core/installers/RequirementInstaller.d.ts +0 -33
  203. package/dist/core/installers/RequirementInstaller.js +0 -3
  204. package/dist/core/types.d.ts +0 -166
  205. package/dist/core/types.js +0 -16
  206. package/dist/services/InstallRequestValidator.d.ts +0 -21
  207. package/dist/services/InstallRequestValidator.js +0 -99
  208. package/dist/web/public/js/modal/installHandler.js +0 -227
  209. package/dist/web/public/js/modal/loadingUI.js +0 -74
  210. package/dist/web/public/js/modal/messageQueue.js +0 -112
  211. package/dist/web/public/js/modal/modalUI.js +0 -214
  212. package/dist/web/public/js/modal/version.js +0 -20
  213. package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +0 -370
  214. package/docs/ONBOARDING_PAGE_DESIGN.md +0 -260
  215. package/docs/Telemetry.md +0 -136
  216. package/memory-bank/activeContext.md +0 -26
  217. package/memory-bank/decisionLog.md +0 -91
  218. package/memory-bank/productContext.md +0 -41
  219. package/memory-bank/progress.md +0 -35
  220. package/memory-bank/systemPatterns.md +0 -10
  221. package/src/cli/commands/install.ts +0 -139
  222. package/src/cli/commands/list.ts +0 -113
  223. package/src/cli/commands/pull.ts +0 -16
  224. package/src/cli/commands/serve.ts +0 -39
  225. package/src/cli/commands/uninstall.ts +0 -64
  226. package/src/cli/index.ts +0 -82
  227. package/src/core/installers/clients/BaseClientInstaller.ts +0 -341
  228. package/src/core/installers/clients/ClientInstaller.ts +0 -222
  229. package/src/core/installers/clients/ClientInstallerFactory.ts +0 -43
  230. package/src/core/installers/clients/ClineInstaller.ts +0 -35
  231. package/src/core/installers/clients/ExtensionInstaller.ts +0 -165
  232. package/src/core/installers/clients/GithubCopilotInstaller.ts +0 -79
  233. package/src/core/installers/clients/MSRooCodeInstaller.ts +0 -32
  234. package/src/core/installers/index.ts +0 -11
  235. package/src/core/installers/requirements/BaseInstaller.ts +0 -85
  236. package/src/core/installers/requirements/CommandInstaller.ts +0 -231
  237. package/src/core/installers/requirements/GeneralInstaller.ts +0 -133
  238. package/src/core/installers/requirements/InstallerFactory.ts +0 -114
  239. package/src/core/installers/requirements/NpmInstaller.ts +0 -271
  240. package/src/core/installers/requirements/NugetInstaller.ts +0 -203
  241. package/src/core/installers/requirements/PipInstaller.ts +0 -207
  242. package/src/core/installers/requirements/RequirementInstaller.ts +0 -42
  243. package/src/core/loaders/ConfigurationLoader.ts +0 -298
  244. package/src/core/loaders/ConfigurationProvider.ts +0 -462
  245. package/src/core/loaders/InstallOperationManager.ts +0 -367
  246. package/src/core/loaders/ServerSchemaLoader.ts +0 -117
  247. package/src/core/loaders/ServerSchemaProvider.ts +0 -99
  248. package/src/core/loaders/SystemSettingsManager.ts +0 -278
  249. package/src/core/metadatas/constants.ts +0 -122
  250. package/src/core/metadatas/recordingConstants.ts +0 -65
  251. package/src/core/metadatas/types.ts +0 -202
  252. package/src/core/onboard/FeedOnboardService.ts +0 -501
  253. package/src/core/onboard/OnboardProcessor.ts +0 -356
  254. package/src/core/onboard/OnboardStatus.ts +0 -60
  255. package/src/core/onboard/OnboardStatusManager.ts +0 -416
  256. package/src/core/validators/FeedValidator.ts +0 -135
  257. package/src/core/validators/IServerValidator.ts +0 -21
  258. package/src/core/validators/SSEServerValidator.ts +0 -43
  259. package/src/core/validators/ServerValidatorFactory.ts +0 -51
  260. package/src/core/validators/StdioServerValidator.ts +0 -313
  261. package/src/index.ts +0 -44
  262. package/src/services/InstallationService.ts +0 -102
  263. package/src/services/MCPManager.ts +0 -249
  264. package/src/services/RequirementService.ts +0 -627
  265. package/src/services/ServerService.ts +0 -161
  266. package/src/services/TelemetryService.ts +0 -59
  267. package/src/utils/UpdateCheckTracker.ts +0 -86
  268. package/src/utils/adoUtils.ts +0 -293
  269. package/src/utils/clientUtils.ts +0 -72
  270. package/src/utils/feedUtils.ts +0 -31
  271. package/src/utils/githubAuth.ts +0 -212
  272. package/src/utils/githubUtils.ts +0 -164
  273. package/src/utils/logger.ts +0 -195
  274. package/src/utils/macroExpressionUtils.ts +0 -104
  275. package/src/utils/osUtils.ts +0 -700
  276. package/src/utils/versionUtils.ts +0 -114
  277. package/src/web/contract/serverContract.ts +0 -74
  278. package/src/web/public/css/detailsWidget.css +0 -235
  279. package/src/web/public/css/modal.css +0 -757
  280. package/src/web/public/css/notifications.css +0 -101
  281. package/src/web/public/css/onboard.css +0 -107
  282. package/src/web/public/css/serverCategoryList.css +0 -120
  283. package/src/web/public/css/serverDetails.css +0 -139
  284. package/src/web/public/index.html +0 -359
  285. package/src/web/public/js/api.js +0 -132
  286. package/src/web/public/js/detailsWidget.js +0 -264
  287. package/src/web/public/js/flights/flights.js +0 -127
  288. package/src/web/public/js/modal/index.js +0 -52
  289. package/src/web/public/js/modal/installModal.js +0 -162
  290. package/src/web/public/js/modal/installation.js +0 -266
  291. package/src/web/public/js/modal/loadingModal.js +0 -182
  292. package/src/web/public/js/modal/modalSetup.js +0 -595
  293. package/src/web/public/js/modal/modalUtils.js +0 -37
  294. package/src/web/public/js/modal/versionUtils.js +0 -20
  295. package/src/web/public/js/modal.js +0 -42
  296. package/src/web/public/js/notifications.js +0 -137
  297. package/src/web/public/js/onboard/formProcessor.js +0 -1037
  298. package/src/web/public/js/onboard/index.js +0 -374
  299. package/src/web/public/js/onboard/publishHandler.js +0 -172
  300. package/src/web/public/js/onboard/state.js +0 -76
  301. package/src/web/public/js/onboard/templates.js +0 -342
  302. package/src/web/public/js/onboard/uiHandlers.js +0 -1076
  303. package/src/web/public/js/onboard/validationHandlers.js +0 -493
  304. package/src/web/public/js/serverCategoryDetails.js +0 -364
  305. package/src/web/public/js/serverCategoryList.js +0 -241
  306. package/src/web/public/js/settings.js +0 -314
  307. package/src/web/public/modal.html +0 -84
  308. package/src/web/public/onboard.html +0 -296
  309. package/src/web/public/settings.html +0 -135
  310. package/src/web/public/styles.css +0 -277
  311. package/src/web/server.ts +0 -478
  312. package/tsconfig.json +0 -18
  313. package/wiki/Installation.md +0 -3
  314. package/wiki/Publish.md +0 -3
@@ -1,364 +1,2 @@
1
- import { allServerCategoriesData, fetchServerCategories } from './api.js';
2
- import { showInstallModal } from './modal.js';
3
- import { showToast, showConfirm } from './notifications.js';
4
- import { DetailsWidget } from './detailsWidget.js';
5
-
6
- const REFRESH_INTERVAL = 2000; // 2 seconds
7
- let refreshTimer = null;
8
- let activeDetailsWidget = null;
9
- const MAX_RETRIES = 3;
10
- const RETRY_DELAY = 1000;
11
-
12
- // Start refresh timer for installation status
13
- function startRefreshTimer(serverName) {
14
- if (refreshTimer) {
15
- clearInterval(refreshTimer);
16
- }
17
-
18
- refreshTimer = setInterval(async () => {
19
- try {
20
- const server = allServerCategoriesData.find(s => s.name === serverName);
21
- if (!server?.installationStatus?.serversStatus) return;
22
-
23
- const hasPendingInstallation = Object.values(server.installationStatus.serversStatus).some(serverStatus =>
24
- Object.values(serverStatus.installedStatus || {}).some(status =>
25
- status.status === 'pending' || status.status === 'in-progress'
26
- )
27
- );
28
-
29
- if (hasPendingInstallation) {
30
- await fetchServerCategories();
31
- await showServerDetails(serverName);
32
- } else {
33
- clearInterval(refreshTimer);
34
- }
35
- } catch (error) {
36
- console.error('Error in refresh timer:', error);
37
- clearInterval(refreshTimer);
38
- }
39
- }, REFRESH_INTERVAL);
40
- }
41
-
42
- // Show server details with retry mechanism
43
- async function showServerDetails(serverName, retryCount = 0) {
44
- console.log("Showing details for:", serverName);
45
- try {
46
- localStorage.setItem('lastSelectedCategory', serverName);
47
-
48
- // If server data is not available, attempt to fetch it
49
- if (allServerCategoriesData.length === 0) {
50
- await fetchServerCategories();
51
- }
52
-
53
- const server = allServerCategoriesData.find(s => s.name === serverName);
54
- const detailsDiv = document.getElementById('serverCategoryDetails');
55
-
56
- if (!server) {
57
- if (retryCount < MAX_RETRIES) {
58
- console.log(`Server data not found, retrying (${retryCount + 1}/${MAX_RETRIES})...`);
59
- await new Promise(resolve => setTimeout(resolve, RETRY_DELAY));
60
- await fetchServerCategories(); // Refresh the data
61
- return showServerDetails(serverName, retryCount + 1);
62
- }
63
- throw new Error('Server data not found after retries');
64
- }
65
-
66
- let pullRequestHtml = '';
67
- if (server.feedConfiguration?.PullRequest) {
68
- pullRequestHtml = `
69
- <p class="mb-1 text-sm">
70
- <span class="font-semibold">Pull Request:</span>
71
- <a href="${server.feedConfiguration.PullRequest}" target="_blank" class="text-blue-600 hover:underline">${server.feedConfiguration.PullRequest}</a>
72
- </p>`;
73
- }
74
-
75
- detailsDiv.innerHTML = `
76
- <h3 class="text-xl font-semibold mb-2 text-gray-800">${server.displayName || server.name}</h3>
77
- <p class="mb-1"><span class="font-semibold">Description:</span> ${server.description || 'N/A'}</p>
78
- ${pullRequestHtml}
79
- <div id="toolMcpsList" class="mt-4">
80
- <div class="animate-pulse flex space-x-4">
81
- <div class="flex-1 space-y-4 py-1">
82
- <div class="h-4 bg-gray-200 rounded w-3/4"></div>
83
- <div class="space-y-2">
84
- <div class="h-4 bg-gray-200 rounded"></div>
85
- <div class="h-4 bg-gray-200 rounded w-5/6"></div>
86
- </div>
87
- </div>
88
- </div>
89
- </div>
90
- `;
91
-
92
- const serversListHtml = await renderServersList(server);
93
- const toolMcpsList = document.getElementById('toolMcpsList');
94
- if (!toolMcpsList) {
95
- throw new Error('toolMcpsList element not found');
96
- }
97
-
98
- toolMcpsList.innerHTML = serversListHtml;
99
-
100
- // Setup server items click handlers
101
- const serverItems = document.querySelectorAll('.server-item-content');
102
- console.log(`Found ${serverItems.length} server items`);
103
-
104
- serverItems.forEach(item => {
105
- const mcpServerName = item.dataset.serverName;
106
- console.log(`Setting up click handler for server: ${mcpServerName}`);
107
-
108
- const mcpServer = server.feedConfiguration?.mcpServers?.find(
109
- s => s.name === mcpServerName
110
- );
111
-
112
- if (mcpServer) {
113
- const detailsWidget = new DetailsWidget(item);
114
-
115
- // Initially set description
116
- detailsWidget.setContent(mcpServer.description);
117
-
118
- // Fetch and display schema when expanded
119
- const fetchSchema = async () => {
120
- try {
121
- const response = await fetch(`/api/categories/${server.name}/servers/${mcpServerName}/schema`);
122
- if (!response.ok) return;
123
-
124
- const result = await response.json();
125
- if (result.success && result.data) {
126
- detailsWidget.setContent(result.data);
127
- }
128
- } catch (error) {
129
- console.error('Error fetching schema:', error);
130
- // Silently fail - don't show error in UI
131
- }
132
- };
133
-
134
- item.addEventListener('click', async (event) => {
135
- if (!event.target.closest('button')) {
136
- if (detailsWidget === activeDetailsWidget) {
137
- // Only toggle if clicking the currently active item
138
- detailsWidget.toggle();
139
- if (!detailsWidget.isVisible()) {
140
- activeDetailsWidget = null;
141
- }
142
- } else {
143
- // Expand the clicked item without collapsing others
144
- detailsWidget.expand();
145
- activeDetailsWidget = detailsWidget;
146
- await fetchSchema();
147
- }
148
- }
149
- });
150
- }
151
- });
152
-
153
- startRefreshTimer(serverName);
154
- } catch (error) {
155
- console.error('Error in showServerDetails:', error);
156
- const detailsDiv = document.getElementById('serverCategoryDetails');
157
- if (detailsDiv) {
158
- detailsDiv.innerHTML = `<p class="text-red-500">Error loading server details: ${error.message}</p>`;
159
- }
160
- showToast(`Error loading server details: ${error.message}`, 'error');
161
- }
162
- }
163
-
164
- /**
165
- * Checks if any defined requirement for an MCP server has a pending update.
166
- * An update is pending if a requirement has an `availableUpdate` or if its installed version
167
- * differs from the version defined in the feed.
168
- * @param {object} mcpServer - The MCP server configuration object from the feed.
169
- * @param {object} requirementsStatus - The status of requirements for this server, typically from `installationStatus.requirementsStatus`.
170
- * @returns {{ needsUpdate: boolean, updateMessage: string|null }} - True and message if update is available, else false/null.
171
- */
172
- function checkNeedsRequirementUpdate(mcpServer, requirementsStatus) {
173
- const definedReqs = mcpServer?.dependencies?.requirements || [];
174
- if (definedReqs.length === 0) {
175
- return false; // No requirements defined in the feed for this server.
176
- }
177
-
178
- const currentReqsStatus = requirementsStatus || {};
179
-
180
- for (const defReq of definedReqs) {
181
- const alias = defReq.alias || defReq.name;
182
- if (!alias) continue;
183
-
184
- const statusEntry = currentReqsStatus[alias];
185
-
186
- if (statusEntry) {
187
- // Check 1: Explicit 'availableUpdate' information
188
- if (statusEntry.availableUpdate && statusEntry.availableUpdate.version) {
189
- return {needsUpdate: true, updateMessage: `${statusEntry.name}: ${statusEntry.availableUpdate.message}` || null};
190
- }
191
- }
192
- }
193
- return { needsUpdate: false, updateMessage: null };
194
- }
195
-
196
- async function renderServersList(serverCategory) {
197
- try {
198
- const targetResponse = await fetch('/api/targets');
199
- const targetData = await targetResponse.json();
200
- const availableTargets = targetData.success ? targetData.data : [];
201
-
202
- if (!serverCategory.feedConfiguration?.mcpServers) {
203
- return '<p class="text-gray-500">No MCP Servers found for this server.</p>';
204
- }
205
-
206
- const mcpServers = serverCategory.feedConfiguration.mcpServers;
207
- if (mcpServers.length === 0) {
208
- return '<p class="text-gray-500">No MCP Servers found for this server.</p>';
209
- }
210
-
211
- let toolsHtml = `
212
- <div class="flex justify-between items-center mb-4">
213
- <h2 class="text-lg font-semibold text-gray-600">MCP Servers</h2>
214
- </div>`;
215
-
216
- mcpServers.forEach(mcpServer => {
217
- const isInstalled = mcpServer.installed;
218
- const envRequirements = mcpServer.installation?.['env:'] || mcpServer.installation?.env || {};
219
- const hasEnvRequirements = Object.keys(envRequirements).length > 0;
220
-
221
- toolsHtml += `
222
- <div class="server-item-content" data-server-name="${mcpServer.name}">
223
- <div class="server-item-info" style="width: 100%; box-sizing: border-box;">
224
- <div class="server-item-header">
225
- <div class="flex items-center flex-wrap">
226
- <h5 class="font-semibold text-gray-800 mr-2">${mcpServer.displayName || mcpServer.name}</h5>
227
- ${mcpServer.systemTags && Object.keys(mcpServer.systemTags).length > 0 ? `
228
- <div class="flex flex-wrap gap-1 items-center">
229
- ${Object.entries(mcpServer.systemTags).map(([key, value]) => `<span class="text-xs bg-purple-100 text-purple-700 px-2 py-0.5 rounded-full">${key}: ${value}</span>`).join('')}
230
- </div>
231
- ` : ''}
232
- ${mcpServer.repository || serverCategory.feedConfiguration?.repository ? (() => {
233
- const repoUrl = mcpServer.repository || serverCategory.feedConfiguration?.repository;
234
- const isGithub = repoUrl.toLowerCase().includes('github.com');
235
- return `
236
- <a href="${repoUrl}" target="_blank" class="ml-2 flex items-center">
237
- <span class="text-xs px-2 py-1 bg-gray-100 rounded-md flex items-center text-gray-700 hover:bg-gray-200 transition-colors duration-200">
238
- ${isGithub ? `
239
- <svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
240
- <path fill-rule="evenodd" d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" clip-rule="evenodd"/>
241
- </svg>
242
- GitHub` : `
243
- <svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
244
- <path d="M21.721 12.752a9.711 9.711 0 00-.945-5.003 1.743 1.743 0 01-1.339-1.647c0-.522.236-1.01.62-1.341a9.707 9.707 0 00-3.62-2.087 1.744 1.744 0 01-2.113-1.334A9.721 9.721 0 0012 1.016 9.721 9.721 0 009.676 1.3 1.744 1.744 0 017.562 2.634a9.707 9.707 0 00-3.62 2.087 1.744 1.744 0 00-.048 2.32 9.711 9.711 0 00-.945 5.003 9.712 9.712 0 00.945 5.003 1.744 1.744 0 01.048 2.32 9.707 9.707 0 003.62 2.087 1.744 1.744 0 012.114 1.334A9.721 9.721 0 0012 22.982a9.721 9.721 0 002.324-.284 1.744 1.744 0 012.114-1.334 9.707 9.707 0 003.62-2.087 1.744 1.744 0 01.048-2.32 9.711 9.711 0 00.945-5.003z"/>
245
- </svg>
246
- Website`}
247
- </span>
248
- </a>`
249
- })() : ''}
250
- </div>
251
- <p class="text-sm text-gray-600 mb-1 mt-1">${mcpServer.description || 'No description'}</p>
252
- </div>
253
- <div class="flex flex-col mt-3">
254
- <span class="text-xs font-semibold mb-2">Client Status:</span>
255
- <div class="flex flex-wrap gap-2">
256
- ${availableTargets.map(client => {
257
- const status = (serverCategory.installationStatus?.serversStatus[mcpServer.name]?.installedStatus || {})[client];
258
- const isInstalled = status?.status === 'completed';
259
- return `
260
- <span class="text-xs flex items-center ${isInstalled ? 'text-green-600 bg-green-50' : 'text-gray-600 bg-gray-50'} px-3 py-1 rounded-full shadow">
261
- <svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
262
- ${isInstalled
263
- ? '<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"></path>'
264
- : '<path d="M7 3.5A1.5 1.5 0 018.5 2h3.879a1.5 1.5 0 011.06.44l3.122 3.12A1.5 1.5 0 0117 6.622V12.5a1.5 1.5 0 01-1.5 1.5h-1v-3.379a1.5 1.5 0 00-.44-1.06L10.94 6.44A1.5 1.5 0 009.879 6H7V3.5z M6 6h2.879A1.5 1.5 0 0110 7.5v1.379a1.5 1.5 0 01-.44 1.06L6.44 13.06A1.5 1.5 0 015.379 13H4.5A1.5 1.5 0 013 11.5V7.5A1.5 1.5 0 014.5 6H6z"></path>'
265
- }
266
- </svg>
267
- ${client}
268
- </span>
269
- `;
270
- }).join('')}
271
- </div>
272
- </div>
273
- <div class="action-buttons">
274
- ${(() => {
275
- const serverInstallationStatus = serverCategory.installationStatus;
276
- const requirementsStatus = serverInstallationStatus?.requirementsStatus;
277
- // dependencies is a simple array of names
278
- const { needsUpdate, updateMessage } = checkNeedsRequirementUpdate(mcpServer, requirementsStatus);
279
-
280
- if (isInstalled) {
281
- return `
282
- <button onclick="event.stopPropagation(); window.uninstallTools('${serverCategory.name}', ['${mcpServer.name}'])"
283
- class="bg-red-500 hover:bg-red-700 text-white text-sm font-bold py-2 px-4 rounded-full shadow-sm ease-in-out">
284
- Uninstall
285
- </button>`;
286
- } else {
287
- let buttonText = 'Setup';
288
- let titleAttr = '';
289
- if (needsUpdate) {
290
- buttonText = 'Update';
291
- if (updateMessage) {
292
- titleAttr = ` title="${updateMessage.replace(/"/g, '"')}"`;
293
- }
294
- }
295
- return `
296
- <button onclick="event.stopPropagation(); window.showInstallModal('${serverCategory.name}', '${mcpServer.name}')"
297
- class="${needsUpdate ? 'btn-update' : 'bg-blue-500 hover:bg-blue-700'} text-white text-xs font-bold py-2 px-4 rounded-full shadow-sm ease-in-out"${titleAttr}>
298
- ${buttonText}
299
- </button>`;
300
- }
301
- })()}
302
- </div>
303
- ${hasEnvRequirements ? `<div class="mt-3 text-xs text-blue-600">
304
- <svg class="w-3 h-3 inline mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
305
- <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path>
306
- </svg>
307
- Requires environment configuration
308
- </div>` : ''}
309
- </div>
310
- </div>
311
- `;
312
- });
313
-
314
- return toolsHtml;
315
- } catch (error) {
316
- console.error('Error in renderServersList:', error);
317
- throw error;
318
- }
319
- }
320
-
321
- window.uninstallTools = async function (serverName, toolList) {
322
- try {
323
- const confirmed = await showConfirm(`Are you sure you want to uninstall ${toolList.length} tool(s)?`);
324
- if (!confirmed) return;
325
-
326
- const response = await fetch(`/api/categories/${serverName}/uninstall`, {
327
- method: 'POST',
328
- headers: { 'Content-Type': 'application/json' },
329
- body: JSON.stringify({ toolList })
330
- });
331
-
332
- if (!response.ok) {
333
- const errorData = await response.text();
334
- throw new Error(`Uninstallation failed: ${errorData || response.statusText}`);
335
- }
336
-
337
- const result = await response.json();
338
- if (!result.success) {
339
- throw new Error(result.error || 'Uninstallation failed');
340
- }
341
-
342
- showToast('Tools uninstalled successfully!', 'success');
343
- await fetchServerCategories();
344
- await showServerDetails(serverName);
345
- } catch (error) {
346
- console.error('Error uninstalling tools:', error);
347
- showToast(`Error uninstalling tools: ${error.message}`, 'error');
348
- }
349
- }
350
-
351
- window.showServerDetails = async function (serverName) {
352
- try {
353
- await showServerDetails(serverName);
354
- } catch (error) {
355
- console.error('Error in window.showServerDetails:', error);
356
- const detailsDiv = document.getElementById('serverCategoryDetails');
357
- if (detailsDiv) {
358
- detailsDiv.innerHTML = `<p class="text-red-500">Error loading server details: ${error.message}</p>`;
359
- }
360
- showToast(`Error loading server details: ${error.message}`, 'error');
361
- }
362
- };
363
-
364
- export { showServerDetails };
1
+ import{allServerCategoriesData,fetchServerCategories}from"./api.js";import{showInstallModal}from"./modal.js";import{showToast,showConfirm}from"./notifications.js";import{DetailsWidget}from"./detailsWidget.js";const REFRESH_INTERVAL=2e3;let refreshTimer=null,activeDetailsWidget=null;const MAX_RETRIES=3,RETRY_DELAY=1e3;function startRefreshTimer(e){refreshTimer&&clearInterval(refreshTimer),refreshTimer=setInterval((async()=>{try{const t=allServerCategoriesData.find((t=>t.name===e));if(!t?.installationStatus?.serversStatus)return;Object.values(t.installationStatus.serversStatus).some((e=>Object.values(e.installedStatus||{}).some((e=>"pending"===e.status||"in-progress"===e.status))))?(await fetchServerCategories(),await showServerDetails(e)):clearInterval(refreshTimer)}catch(e){clearInterval(refreshTimer)}}),2e3)}async function showServerDetails(e,t=0){try{localStorage.setItem("lastSelectedCategory",e),0===allServerCategoriesData.length&&await fetchServerCategories();const s=allServerCategoriesData.find((t=>t.name===e)),n=document.getElementById("serverCategoryDetails");if(!s){if(t<3)return await new Promise((e=>setTimeout(e,1e3))),await fetchServerCategories(),showServerDetails(e,t+1);throw new Error("Server data not found after retries")}let a="";s.feedConfiguration?.PullRequest&&(a=`\n <p class="mb-1 text-sm">\n <span class="font-semibold">Pull Request:</span>\n <a href="${s.feedConfiguration.PullRequest}" target="_blank" class="text-blue-600 hover:underline">${s.feedConfiguration.PullRequest}</a>\n </p>`),n.innerHTML=`\n <h3 class="text-xl font-semibold mb-2 text-gray-800">${s.displayName||s.name}</h3>\n <p class="mb-1"><span class="font-semibold">Description:</span> ${s.description||"N/A"}</p>\n ${a}\n <div id="toolMcpsList" class="mt-4">\n <div class="animate-pulse flex space-x-4">\n <div class="flex-1 space-y-4 py-1">\n <div class="h-4 bg-gray-200 rounded w-3/4"></div>\n <div class="space-y-2">\n <div class="h-4 bg-gray-200 rounded"></div>\n <div class="h-4 bg-gray-200 rounded w-5/6"></div>\n </div>\n </div>\n </div>\n </div>\n `;const r=await renderServersList(s),i=document.getElementById("toolMcpsList");if(!i)throw new Error("toolMcpsList element not found");i.innerHTML=r,document.querySelectorAll(".server-item-content").forEach((e=>{const t=e.dataset.serverName,n=s.feedConfiguration?.mcpServers?.find((e=>e.name===t));if(n){const a=new DetailsWidget(e);a.setContent(n.description);const r=async()=>{try{const e=await fetch(`/api/categories/${s.name}/servers/${t}/schema`);if(!e.ok)return;const n=await e.json();n.success&&n.data&&a.setContent(n.data)}catch(e){}};e.addEventListener("click",(async e=>{e.target.closest("button")||(a===activeDetailsWidget?(a.toggle(),a.isVisible()||(activeDetailsWidget=null)):(a.expand(),activeDetailsWidget=a,await r()))}))}})),startRefreshTimer(e)}catch(e){const t=document.getElementById("serverCategoryDetails");t&&(t.innerHTML=`<p class="text-red-500">Error loading server details: ${e.message}</p>`),showToast(`Error loading server details: ${e.message}`,"error")}}function checkNeedsRequirementUpdate(e,t){const s=e?.dependencies?.requirements||[];if(0===s.length)return!1;const n=t||{};for(const e of s){const t=e.alias||e.name;if(!t)continue;const s=n[t];if(s&&s.availableUpdate&&s.availableUpdate.version)return{needsUpdate:!0,updateMessage:`${s.name}: ${s.availableUpdate.message}`||null}}return{needsUpdate:!1,updateMessage:null}}async function renderServersList(e){try{const t=await fetch("/api/targets"),s=await t.json(),n=s.success?s.data:[];if(!e.feedConfiguration?.mcpServers)return'<p class="text-gray-500">No MCP Servers found for this server.</p>';const a=e.feedConfiguration.mcpServers;if(0===a.length)return'<p class="text-gray-500">No MCP Servers found for this server.</p>';let r='\n <div class="flex justify-between items-center mb-4">\n <h2 class="text-lg font-semibold text-gray-600">MCP Servers</h2>\n </div>';return a.forEach((t=>{const s=t.installed,a=t.installation?.["env:"]||t.installation?.env||{},i=Object.keys(a).length>0;r+=`\n <div class="server-item-content" data-server-name="${t.name}">\n <div class="server-item-info" style="width: 100%; box-sizing: border-box;">\n <div class="server-item-header">\n <div class="flex items-center flex-wrap">\n <h5 class="font-semibold text-gray-800 mr-2">${t.displayName||t.name}</h5>\n ${t.systemTags&&Object.keys(t.systemTags).length>0?`\n <div class="flex flex-wrap gap-1 items-center">\n ${Object.entries(t.systemTags).map((([e,t])=>`<span class="text-xs bg-purple-100 text-purple-700 px-2 py-0.5 rounded-full">${e}: ${t}</span>`)).join("")}\n </div>\n `:""}\n ${t.repository||e.feedConfiguration?.repository?(()=>{const s=t.repository||e.feedConfiguration?.repository,n=s.toLowerCase().includes("github.com");return`\n <a href="${s}" target="_blank" class="ml-2 flex items-center">\n <span class="text-xs px-2 py-1 bg-gray-100 rounded-md flex items-center text-gray-700 hover:bg-gray-200 transition-colors duration-200">\n ${n?'\n <svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" clip-rule="evenodd"/>\n </svg>\n GitHub':'\n <svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">\n <path d="M21.721 12.752a9.711 9.711 0 00-.945-5.003 1.743 1.743 0 01-1.339-1.647c0-.522.236-1.01.62-1.341a9.707 9.707 0 00-3.62-2.087 1.744 1.744 0 01-2.113-1.334A9.721 9.721 0 0012 1.016 9.721 9.721 0 009.676 1.3 1.744 1.744 0 017.562 2.634a9.707 9.707 0 00-3.62 2.087 1.744 1.744 0 00-.048 2.32 9.711 9.711 0 00-.945 5.003 9.712 9.712 0 00.945 5.003 1.744 1.744 0 01.048 2.32 9.707 9.707 0 003.62 2.087 1.744 1.744 0 012.114 1.334A9.721 9.721 0 0012 22.982a9.721 9.721 0 002.324-.284 1.744 1.744 0 012.114-1.334 9.707 9.707 0 003.62-2.087 1.744 1.744 0 01.048-2.32 9.711 9.711 0 00.945-5.003z"/>\n </svg>\n Website'}\n </span>\n </a>`})():""}\n </div>\n <p class="text-sm text-gray-600 mb-1 mt-1">${t.description||"No description"}</p>\n </div>\n <div class="flex flex-col mt-3">\n <span class="text-xs font-semibold mb-2">Client Status:</span>\n <div class="flex flex-wrap gap-2">\n ${n.map((s=>{const n=(e.installationStatus?.serversStatus[t.name]?.installedStatus||{})[s],a="completed"===n?.status;return`\n <span class="text-xs flex items-center ${a?"text-green-600 bg-green-50":"text-gray-600 bg-gray-50"} px-3 py-1 rounded-full shadow">\n <svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\n ${a?'<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"></path>':'<path d="M7 3.5A1.5 1.5 0 018.5 2h3.879a1.5 1.5 0 011.06.44l3.122 3.12A1.5 1.5 0 0117 6.622V12.5a1.5 1.5 0 01-1.5 1.5h-1v-3.379a1.5 1.5 0 00-.44-1.06L10.94 6.44A1.5 1.5 0 009.879 6H7V3.5z M6 6h2.879A1.5 1.5 0 0110 7.5v1.379a1.5 1.5 0 01-.44 1.06L6.44 13.06A1.5 1.5 0 015.379 13H4.5A1.5 1.5 0 013 11.5V7.5A1.5 1.5 0 014.5 6H6z"></path>'}\n </svg>\n ${s}\n </span>\n `})).join("")}\n </div>\n </div>\n <div class="action-buttons">\n ${(()=>{const n=e.installationStatus,a=n?.requirementsStatus,{needsUpdate:r,updateMessage:i}=checkNeedsRequirementUpdate(t,a);if(s)return`\n <button onclick="event.stopPropagation(); window.uninstallTools('${e.name}', ['${t.name}'])"\n class="bg-red-500 hover:bg-red-700 text-white text-sm font-bold py-2 px-4 rounded-full shadow-sm ease-in-out">\n Uninstall\n </button>`;{let s="Setup",n="";return r&&(s="Update",i&&(n=` title="${i.replace(/"/g,'"')}"`)),`\n <button onclick="event.stopPropagation(); window.showInstallModal('${e.name}', '${t.name}')"\n class="${r?"btn-update":"bg-blue-500 hover:bg-blue-700"} text-white text-xs font-bold py-2 px-4 rounded-full shadow-sm ease-in-out"${n}>\n ${s}\n </button>`}})()}\n </div>\n ${i?'<div class="mt-3 text-xs text-blue-600">\n <svg class="w-3 h-3 inline mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path>\n </svg>\n Requires environment configuration\n </div>':""}\n </div>\n </div>\n `})),r}catch(e){throw e}}window.uninstallTools=async function(e,t){try{if(!await showConfirm(`Are you sure you want to uninstall ${t.length} tool(s)?`))return;const s=await fetch(`/api/categories/${e}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolList:t})});if(!s.ok){const e=await s.text();throw new Error(`Uninstallation failed: ${e||s.statusText}`)}const n=await s.json();if(!n.success)throw new Error(n.error||"Uninstallation failed");showToast("Tools uninstalled successfully!","success"),await fetchServerCategories(),await showServerDetails(e)}catch(e){showToast(`Error uninstalling tools: ${e.message}`,"error")}},window.showServerDetails=async function(e){try{await showServerDetails(e)}catch(e){const t=document.getElementById("serverCategoryDetails");t&&(t.innerHTML=`<p class="text-red-500">Error loading server details: ${e.message}</p>`),showToast(`Error loading server details: ${e.message}`,"error")}};export{showServerDetails};
2
+ //# sourceMappingURL=serverCategoryDetails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["allServerCategoriesData","fetchServerCategories"],"sources":["0"],"sourcesContent":["import { allServerCategoriesData, fetchServerCategories } from './api.js';\r\nimport { showInstallModal } from './modal.js';\r\nimport { showToast, showConfirm } from './notifications.js';\r\nimport { DetailsWidget } from './detailsWidget.js';\r\n\r\nconst REFRESH_INTERVAL = 2000; // 2 seconds\r\nlet refreshTimer = null;\r\nlet activeDetailsWidget = null;\r\nconst MAX_RETRIES = 3;\r\nconst RETRY_DELAY = 1000;\r\n\r\n// Start refresh timer for installation status\r\nfunction startRefreshTimer(serverName) {\r\n if (refreshTimer) {\r\n clearInterval(refreshTimer);\r\n }\r\n\r\n refreshTimer = setInterval(async () => {\r\n try {\r\n const server = allServerCategoriesData.find(s => s.name === serverName);\r\n if (!server?.installationStatus?.serversStatus) return;\r\n\r\n const hasPendingInstallation = Object.values(server.installationStatus.serversStatus).some(serverStatus =>\r\n Object.values(serverStatus.installedStatus || {}).some(status =>\r\n status.status === 'pending' || status.status === 'in-progress'\r\n )\r\n );\r\n\r\n if (hasPendingInstallation) {\r\n await fetchServerCategories();\r\n await showServerDetails(serverName);\r\n } else {\r\n clearInterval(refreshTimer);\r\n }\r\n } catch (error) {\r\n console.error('Error in refresh timer:', error);\r\n clearInterval(refreshTimer);\r\n }\r\n }, REFRESH_INTERVAL);\r\n}\r\n\r\n// Show server details with retry mechanism\r\nasync function showServerDetails(serverName, retryCount = 0) {\r\n console.log(\"Showing details for:\", serverName);\r\n try {\r\n localStorage.setItem('lastSelectedCategory', serverName);\r\n\r\n // If server data is not available, attempt to fetch it\r\n if (allServerCategoriesData.length === 0) {\r\n await fetchServerCategories();\r\n }\r\n\r\n const server = allServerCategoriesData.find(s => s.name === serverName);\r\n const detailsDiv = document.getElementById('serverCategoryDetails');\r\n\r\n if (!server) {\r\n if (retryCount < MAX_RETRIES) {\r\n console.log(`Server data not found, retrying (${retryCount + 1}/${MAX_RETRIES})...`);\r\n await new Promise(resolve => setTimeout(resolve, RETRY_DELAY));\r\n await fetchServerCategories(); // Refresh the data\r\n return showServerDetails(serverName, retryCount + 1);\r\n }\r\n throw new Error('Server data not found after retries');\r\n }\r\n\r\n let pullRequestHtml = '';\r\n if (server.feedConfiguration?.PullRequest) {\r\n pullRequestHtml = `\r\n <p class=\"mb-1 text-sm\">\r\n <span class=\"font-semibold\">Pull Request:</span>\r\n <a href=\"${server.feedConfiguration.PullRequest}\" target=\"_blank\" class=\"text-blue-600 hover:underline\">${server.feedConfiguration.PullRequest}</a>\r\n </p>`;\r\n }\r\n\r\n detailsDiv.innerHTML = `\r\n <h3 class=\"text-xl font-semibold mb-2 text-gray-800\">${server.displayName || server.name}</h3>\r\n <p class=\"mb-1\"><span class=\"font-semibold\">Description:</span> ${server.description || 'N/A'}</p>\r\n ${pullRequestHtml}\r\n <div id=\"toolMcpsList\" class=\"mt-4\">\r\n <div class=\"animate-pulse flex space-x-4\">\r\n <div class=\"flex-1 space-y-4 py-1\">\r\n <div class=\"h-4 bg-gray-200 rounded w-3/4\"></div>\r\n <div class=\"space-y-2\">\r\n <div class=\"h-4 bg-gray-200 rounded\"></div>\r\n <div class=\"h-4 bg-gray-200 rounded w-5/6\"></div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n `;\r\n\r\n const serversListHtml = await renderServersList(server);\r\n const toolMcpsList = document.getElementById('toolMcpsList');\r\n if (!toolMcpsList) {\r\n throw new Error('toolMcpsList element not found');\r\n }\r\n\r\n toolMcpsList.innerHTML = serversListHtml;\r\n\r\n // Setup server items click handlers\r\n const serverItems = document.querySelectorAll('.server-item-content');\r\n console.log(`Found ${serverItems.length} server items`);\r\n\r\n serverItems.forEach(item => {\r\n const mcpServerName = item.dataset.serverName;\r\n console.log(`Setting up click handler for server: ${mcpServerName}`);\r\n\r\n const mcpServer = server.feedConfiguration?.mcpServers?.find(\r\n s => s.name === mcpServerName\r\n );\r\n\r\n if (mcpServer) {\r\n const detailsWidget = new DetailsWidget(item);\r\n\r\n // Initially set description\r\n detailsWidget.setContent(mcpServer.description);\r\n\r\n // Fetch and display schema when expanded\r\n const fetchSchema = async () => {\r\n try {\r\n const response = await fetch(`/api/categories/${server.name}/servers/${mcpServerName}/schema`);\r\n if (!response.ok) return;\r\n\r\n const result = await response.json();\r\n if (result.success && result.data) {\r\n detailsWidget.setContent(result.data);\r\n }\r\n } catch (error) {\r\n console.error('Error fetching schema:', error);\r\n // Silently fail - don't show error in UI\r\n }\r\n };\r\n\r\n item.addEventListener('click', async (event) => {\r\n if (!event.target.closest('button')) {\r\n if (detailsWidget === activeDetailsWidget) {\r\n // Only toggle if clicking the currently active item\r\n detailsWidget.toggle();\r\n if (!detailsWidget.isVisible()) {\r\n activeDetailsWidget = null;\r\n }\r\n } else {\r\n // Expand the clicked item without collapsing others\r\n detailsWidget.expand();\r\n activeDetailsWidget = detailsWidget;\r\n await fetchSchema();\r\n }\r\n }\r\n });\r\n }\r\n });\r\n\r\n startRefreshTimer(serverName);\r\n } catch (error) {\r\n console.error('Error in showServerDetails:', error);\r\n const detailsDiv = document.getElementById('serverCategoryDetails');\r\n if (detailsDiv) {\r\n detailsDiv.innerHTML = `<p class=\"text-red-500\">Error loading server details: ${error.message}</p>`;\r\n }\r\n showToast(`Error loading server details: ${error.message}`, 'error');\r\n }\r\n}\r\n\r\n/**\r\n * Checks if any defined requirement for an MCP server has a pending update.\r\n * An update is pending if a requirement has an `availableUpdate` or if its installed version\r\n * differs from the version defined in the feed.\r\n * @param {object} mcpServer - The MCP server configuration object from the feed.\r\n * @param {object} requirementsStatus - The status of requirements for this server, typically from `installationStatus.requirementsStatus`.\r\n * @returns {{ needsUpdate: boolean, updateMessage: string|null }} - True and message if update is available, else false/null.\r\n */\r\nfunction checkNeedsRequirementUpdate(mcpServer, requirementsStatus) {\r\n const definedReqs = mcpServer?.dependencies?.requirements || [];\r\n if (definedReqs.length === 0) {\r\n return false; // No requirements defined in the feed for this server.\r\n }\r\n\r\n const currentReqsStatus = requirementsStatus || {};\r\n\r\n for (const defReq of definedReqs) {\r\n const alias = defReq.alias || defReq.name;\r\n if (!alias) continue;\r\n\r\n const statusEntry = currentReqsStatus[alias];\r\n\r\n if (statusEntry) {\r\n // Check 1: Explicit 'availableUpdate' information\r\n if (statusEntry.availableUpdate && statusEntry.availableUpdate.version) {\r\n return {needsUpdate: true, updateMessage: `${statusEntry.name}: ${statusEntry.availableUpdate.message}` || null};\r\n }\r\n }\r\n }\r\n return { needsUpdate: false, updateMessage: null };\r\n}\r\n\r\nasync function renderServersList(serverCategory) {\r\n try {\r\n const targetResponse = await fetch('/api/targets');\r\n const targetData = await targetResponse.json();\r\n const availableTargets = targetData.success ? targetData.data : [];\r\n\r\n if (!serverCategory.feedConfiguration?.mcpServers) {\r\n return '<p class=\"text-gray-500\">No MCP Servers found for this server.</p>';\r\n }\r\n\r\n const mcpServers = serverCategory.feedConfiguration.mcpServers;\r\n if (mcpServers.length === 0) {\r\n return '<p class=\"text-gray-500\">No MCP Servers found for this server.</p>';\r\n }\r\n\r\n let toolsHtml = `\r\n <div class=\"flex justify-between items-center mb-4\">\r\n <h2 class=\"text-lg font-semibold text-gray-600\">MCP Servers</h2>\r\n </div>`;\r\n\r\n mcpServers.forEach(mcpServer => {\r\n const isInstalled = mcpServer.installed;\r\n const envRequirements = mcpServer.installation?.['env:'] || mcpServer.installation?.env || {};\r\n const hasEnvRequirements = Object.keys(envRequirements).length > 0;\r\n\r\n toolsHtml += `\r\n <div class=\"server-item-content\" data-server-name=\"${mcpServer.name}\">\r\n <div class=\"server-item-info\" style=\"width: 100%; box-sizing: border-box;\">\r\n <div class=\"server-item-header\">\r\n <div class=\"flex items-center flex-wrap\">\r\n <h5 class=\"font-semibold text-gray-800 mr-2\">${mcpServer.displayName || mcpServer.name}</h5>\r\n ${mcpServer.systemTags && Object.keys(mcpServer.systemTags).length > 0 ? `\r\n <div class=\"flex flex-wrap gap-1 items-center\">\r\n ${Object.entries(mcpServer.systemTags).map(([key, value]) => `<span class=\"text-xs bg-purple-100 text-purple-700 px-2 py-0.5 rounded-full\">${key}: ${value}</span>`).join('')}\r\n </div>\r\n ` : ''}\r\n ${mcpServer.repository || serverCategory.feedConfiguration?.repository ? (() => {\r\n const repoUrl = mcpServer.repository || serverCategory.feedConfiguration?.repository;\r\n const isGithub = repoUrl.toLowerCase().includes('github.com');\r\n return `\r\n <a href=\"${repoUrl}\" target=\"_blank\" class=\"ml-2 flex items-center\">\r\n <span class=\"text-xs px-2 py-1 bg-gray-100 rounded-md flex items-center text-gray-700 hover:bg-gray-200 transition-colors duration-200\">\r\n ${isGithub ? `\r\n <svg class=\"w-4 h-4 mr-1\" fill=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path fill-rule=\"evenodd\" d=\"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z\" clip-rule=\"evenodd\"/>\r\n </svg>\r\n GitHub` : `\r\n <svg class=\"w-4 h-4 mr-1\" fill=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M21.721 12.752a9.711 9.711 0 00-.945-5.003 1.743 1.743 0 01-1.339-1.647c0-.522.236-1.01.62-1.341a9.707 9.707 0 00-3.62-2.087 1.744 1.744 0 01-2.113-1.334A9.721 9.721 0 0012 1.016 9.721 9.721 0 009.676 1.3 1.744 1.744 0 017.562 2.634a9.707 9.707 0 00-3.62 2.087 1.744 1.744 0 00-.048 2.32 9.711 9.711 0 00-.945 5.003 9.712 9.712 0 00.945 5.003 1.744 1.744 0 01.048 2.32 9.707 9.707 0 003.62 2.087 1.744 1.744 0 012.114 1.334A9.721 9.721 0 0012 22.982a9.721 9.721 0 002.324-.284 1.744 1.744 0 012.114-1.334 9.707 9.707 0 003.62-2.087 1.744 1.744 0 01.048-2.32 9.711 9.711 0 00.945-5.003z\"/>\r\n </svg>\r\n Website`}\r\n </span>\r\n </a>`\r\n })() : ''}\r\n </div>\r\n <p class=\"text-sm text-gray-600 mb-1 mt-1\">${mcpServer.description || 'No description'}</p>\r\n </div>\r\n <div class=\"flex flex-col mt-3\">\r\n <span class=\"text-xs font-semibold mb-2\">Client Status:</span>\r\n <div class=\"flex flex-wrap gap-2\">\r\n ${availableTargets.map(client => {\r\n const status = (serverCategory.installationStatus?.serversStatus[mcpServer.name]?.installedStatus || {})[client];\r\n const isInstalled = status?.status === 'completed';\r\n return `\r\n <span class=\"text-xs flex items-center ${isInstalled ? 'text-green-600 bg-green-50' : 'text-gray-600 bg-gray-50'} px-3 py-1 rounded-full shadow\">\r\n <svg class=\"w-3 h-3 mr-1\" fill=\"currentColor\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\">\r\n ${isInstalled\r\n ? '<path fill-rule=\"evenodd\" d=\"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z\" clip-rule=\"evenodd\"></path>'\r\n : '<path d=\"M7 3.5A1.5 1.5 0 018.5 2h3.879a1.5 1.5 0 011.06.44l3.122 3.12A1.5 1.5 0 0117 6.622V12.5a1.5 1.5 0 01-1.5 1.5h-1v-3.379a1.5 1.5 0 00-.44-1.06L10.94 6.44A1.5 1.5 0 009.879 6H7V3.5z M6 6h2.879A1.5 1.5 0 0110 7.5v1.379a1.5 1.5 0 01-.44 1.06L6.44 13.06A1.5 1.5 0 015.379 13H4.5A1.5 1.5 0 013 11.5V7.5A1.5 1.5 0 014.5 6H6z\"></path>'\r\n }\r\n </svg>\r\n ${client}\r\n </span>\r\n `;\r\n }).join('')}\r\n </div>\r\n </div>\r\n <div class=\"action-buttons\">\r\n ${(() => {\r\n const serverInstallationStatus = serverCategory.installationStatus;\r\n const requirementsStatus = serverInstallationStatus?.requirementsStatus;\r\n // dependencies is a simple array of names\r\n const { needsUpdate, updateMessage } = checkNeedsRequirementUpdate(mcpServer, requirementsStatus);\r\n\r\n if (isInstalled) {\r\n return `\r\n <button onclick=\"event.stopPropagation(); window.uninstallTools('${serverCategory.name}', ['${mcpServer.name}'])\"\r\n class=\"bg-red-500 hover:bg-red-700 text-white text-sm font-bold py-2 px-4 rounded-full shadow-sm ease-in-out\">\r\n Uninstall\r\n </button>`;\r\n } else {\r\n let buttonText = 'Setup';\r\n let titleAttr = '';\r\n if (needsUpdate) {\r\n buttonText = 'Update';\r\n if (updateMessage) {\r\n titleAttr = ` title=\"${updateMessage.replace(/\"/g, '\"')}\"`;\r\n }\r\n }\r\n return `\r\n <button onclick=\"event.stopPropagation(); window.showInstallModal('${serverCategory.name}', '${mcpServer.name}')\"\r\n class=\"${needsUpdate ? 'btn-update' : 'bg-blue-500 hover:bg-blue-700'} text-white text-xs font-bold py-2 px-4 rounded-full shadow-sm ease-in-out\"${titleAttr}>\r\n ${buttonText}\r\n </button>`;\r\n }\r\n })()}\r\n </div>\r\n ${hasEnvRequirements ? `<div class=\"mt-3 text-xs text-blue-600\">\r\n <svg class=\"w-3 h-3 inline mr-1\" fill=\"currentColor\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z\" clip-rule=\"evenodd\"></path>\r\n </svg>\r\n Requires environment configuration\r\n </div>` : ''}\r\n </div>\r\n </div>\r\n `;\r\n });\r\n\r\n return toolsHtml;\r\n } catch (error) {\r\n console.error('Error in renderServersList:', error);\r\n throw error;\r\n }\r\n}\r\n\r\nwindow.uninstallTools = async function (serverName, toolList) {\r\n try {\r\n const confirmed = await showConfirm(`Are you sure you want to uninstall ${toolList.length} tool(s)?`);\r\n if (!confirmed) return;\r\n\r\n const response = await fetch(`/api/categories/${serverName}/uninstall`, {\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify({ toolList })\r\n });\r\n\r\n if (!response.ok) {\r\n const errorData = await response.text();\r\n throw new Error(`Uninstallation failed: ${errorData || response.statusText}`);\r\n }\r\n\r\n const result = await response.json();\r\n if (!result.success) {\r\n throw new Error(result.error || 'Uninstallation failed');\r\n }\r\n\r\n showToast('Tools uninstalled successfully!', 'success');\r\n await fetchServerCategories();\r\n await showServerDetails(serverName);\r\n } catch (error) {\r\n console.error('Error uninstalling tools:', error);\r\n showToast(`Error uninstalling tools: ${error.message}`, 'error');\r\n }\r\n}\r\n\r\nwindow.showServerDetails = async function (serverName) {\r\n try {\r\n await showServerDetails(serverName);\r\n } catch (error) {\r\n console.error('Error in window.showServerDetails:', error);\r\n const detailsDiv = document.getElementById('serverCategoryDetails');\r\n if (detailsDiv) {\r\n detailsDiv.innerHTML = `<p class=\"text-red-500\">Error loading server details: ${error.message}</p>`;\r\n }\r\n showToast(`Error loading server details: ${error.message}`, 'error');\r\n }\r\n};\r\n\r\nexport { showServerDetails };\r\n"],"mappings":"OAASA,wBAAyBC,0BAA6B,kB","ignoreList":[]}