imcp 0.1.6 → 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,128 +1,2 @@
1
- import path from 'path';
2
- import { fileURLToPath } from 'url';
3
- import { Logger } from '../utils/logger.js';
4
- import { ServerSchemaProvider } from '../core/loaders/ServerSchemaProvider.js';
5
- import { mcpManager } from './MCPManager.js';
6
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
- /**
8
- * ServerService provides a unified interface for server management operations.
9
- * This layer handles business logic that's shared between the CLI and web interface.
10
- */
11
- export class ServerService {
12
- /**
13
- * Lists available MCP servers based on the provided options
14
- */
15
- async listServerCategories(options = {}) {
16
- return mcpManager.listServerCategories(options);
17
- }
18
- /**
19
- * Gets a server by name
20
- */
21
- async getServerCategory(categoryName) {
22
- const serverCategories = await this.listServerCategories();
23
- const serverCategory = serverCategories.find(s => s.name === categoryName);
24
- return serverCategory;
25
- }
26
- /**
27
- * Gets the schema for a specific server in a category
28
- */
29
- async getServerSchema(categoryName, serverName) {
30
- try {
31
- const provider = ServerSchemaProvider.getInstance();
32
- const serverMcpConfig = await mcpManager.getServerMcpConfig(categoryName, serverName);
33
- return await provider.getSchema(categoryName, serverMcpConfig?.schemas || `${serverName}.json`);
34
- }
35
- catch (error) {
36
- Logger.error(`Failed to get schema for server ${serverName} in category ${categoryName}:`, error);
37
- throw error;
38
- }
39
- }
40
- /**
41
- * Installs a specific mcp tool for a server.
42
- */
43
- async installMcpServer(category, serverName, options = {}) {
44
- Logger.debug(`Installing MCP server: ${JSON.stringify({ category, serverName, options })}`);
45
- try {
46
- const result = await mcpManager.installServer(category, serverName, options);
47
- Logger.debug(`Installation result: ${JSON.stringify(result)}`);
48
- return result;
49
- }
50
- catch (error) {
51
- Logger.error(`Failed to install MCP server: ${serverName}`, error);
52
- throw error;
53
- }
54
- }
55
- /**
56
- * Uninstall MCP server from specified client targets
57
- * @param category The server category
58
- * @param serverName The server name to uninstall
59
- * @param options Uninstall options including target clients and data removal flags
60
- */
61
- async uninstallMcpServer(category, serverName, options = {}) {
62
- Logger.debug(`Uninstalling MCP server: ${JSON.stringify({ category, serverName, options })}`);
63
- try {
64
- const result = await mcpManager.uninstallServer(category, serverName, options);
65
- Logger.debug(`Uninstallation result: ${JSON.stringify(result)}`);
66
- return result;
67
- }
68
- catch (error) {
69
- Logger.error(`Failed to uninstall MCP server: ${serverName}`, error);
70
- throw error;
71
- }
72
- }
73
- /**
74
- * Validates server names
75
- */
76
- async validateServerName(category, names) {
77
- const serverNames = Array.isArray(names) ? names : [names];
78
- Logger.debug(`Validating server names: ${JSON.stringify({ category, names: serverNames })}`);
79
- // Check if category exists in feeds
80
- const feedConfig = await mcpManager.getFeedConfiguration(category);
81
- if (!feedConfig) {
82
- Logger.debug(`Validation failed: Category "${category}" not found in feeds`);
83
- return false;
84
- }
85
- // Check if all servers exist in the category's mcpServers
86
- const invalidServers = serverNames.filter(name => !feedConfig.mcpServers.some(server => server.name === name));
87
- if (invalidServers.length > 0) {
88
- Logger.debug(`Validation failed: Servers "${invalidServers.join(', ')}" not found in category "${category}"`);
89
- return false;
90
- }
91
- return true;
92
- }
93
- /**
94
- * Formats success/error messages for operations
95
- */
96
- formatOperationResults(results) {
97
- return {
98
- success: results.every(r => r.success),
99
- messages: results.map(r => r.message).filter((m) => m !== undefined)
100
- };
101
- }
102
- /**
103
- * Syncs MCP server configurations from remote feed source
104
- */
105
- async syncFeeds() {
106
- return mcpManager.syncFeeds();
107
- }
108
- /**
109
- * Onboards a new feed configuration
110
- * @param config Feed configuration to onboard
111
- */
112
- async onboardFeed(config) {
113
- try {
114
- const result = await mcpManager.onboardFeed(config);
115
- // Log based on the operation status, e.g., if it's pending or succeeded.
116
- // The actual "success" of onboarding is a multi-step process (PR creation, merge).
117
- Logger.log(`Feed onboarding process for '${config.name}' initiated with status: ${result.status}, ID: ${result.onboardingId}`);
118
- return result;
119
- }
120
- catch (error) {
121
- Logger.error(`Failed to initiate feed onboarding for '${config.name}':`, error);
122
- throw error; // Or return a specific error status object
123
- }
124
- }
125
- }
126
- // Export a singleton instance
127
- export const serverService = new ServerService();
1
+ import path from"path";import{fileURLToPath}from"url";import{Logger}from"../utils/logger.js";import{ServerSchemaProvider}from"../core/loaders/ServerSchemaProvider.js";import{mcpManager}from"./MCPManager.js";const __dirname=path.dirname(fileURLToPath(import.meta.url));export class ServerService{async listServerCategories(e={}){return mcpManager.listServerCategories(e)}async getServerCategory(e){return(await this.listServerCategories()).find((r=>r.name===e))}async getServerSchema(e,r){try{const a=ServerSchemaProvider.getInstance(),t=await mcpManager.getServerMcpConfig(e,r);return await a.getSchema(e,t?.schemas||`${r}.json`)}catch(a){throw Logger.error(`Failed to get schema for server ${r} in category ${e}:`,a),a}}async installMcpServer(e,r,a={}){Logger.debug(`Installing MCP server: ${JSON.stringify({category:e,serverName:r,options:a})}`);try{const t=await mcpManager.installServer(e,r,a);return Logger.debug(`Installation result: ${JSON.stringify(t)}`),t}catch(e){throw Logger.error(`Failed to install MCP server: ${r}`,e),e}}async uninstallMcpServer(e,r,a={}){Logger.debug(`Uninstalling MCP server: ${JSON.stringify({category:e,serverName:r,options:a})}`);try{const t=await mcpManager.uninstallServer(e,r,a);return Logger.debug(`Uninstallation result: ${JSON.stringify(t)}`),t}catch(e){throw Logger.error(`Failed to uninstall MCP server: ${r}`,e),e}}async validateServerName(e,r){const a=Array.isArray(r)?r:[r];Logger.debug(`Validating server names: ${JSON.stringify({category:e,names:a})}`);const t=await mcpManager.getFeedConfiguration(e);if(!t)return Logger.debug(`Validation failed: Category "${e}" not found in feeds`),!1;const n=a.filter((e=>!t.mcpServers.some((r=>r.name===e))));return!(n.length>0&&(Logger.debug(`Validation failed: Servers "${n.join(", ")}" not found in category "${e}"`),1))}formatOperationResults(e){return{success:e.every((e=>e.success)),messages:e.map((e=>e.message)).filter((e=>void 0!==e))}}async syncFeeds(){return mcpManager.syncFeeds()}async onboardFeed(e){try{const r=await mcpManager.onboardFeed(e);return Logger.log(`Feed onboarding process for '${e.name}' initiated with status: ${r.status}, ID: ${r.onboardingId}`),r}catch(r){throw Logger.error(`Failed to initiate feed onboarding for '${e.name}':`,r),r}}}export const serverService=new ServerService;
128
2
  //# sourceMappingURL=ServerService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["path","fileURLToPath","Logger","ServerSchemaProvider","mcpManager","__dirname","dirname","url","ServerService","listServerCategories","options","getServerCategory","categoryName","this","find","s","name","getServerSchema","serverName","provider","getInstance","serverMcpConfig","getServerMcpConfig","getSchema","schemas","error","installMcpServer","category","debug","JSON","stringify","result","installServer","uninstallMcpServer","uninstallServer","validateServerName","names","serverNames","Array","isArray","feedConfig","getFeedConfiguration","invalidServers","filter","mcpServers","some","server","length","join","formatOperationResults","results","success","every","r","messages","map","message","m","undefined","syncFeeds","onboardFeed","config","log","status","onboardingId","serverService"],"sources":["../../src/services/ServerService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C,QAAQH,GAASA,EAAQ,CAACA,GACpDlC,OAAO0B,MAAM,4BAA4BC,KAAKC,UAAU,CAAEH,WAAUS,MAAOC,OAG3E,MAAMG,QAAmBpC,WAAWqC,qBAAqBd,GACzD,IAAKa,EAEH,OADAtC,OAAO0B,MAAM,gCAAgCD,0BACtC,EAIT,MAAMe,EAAiBL,EAAYM,QAAO3B,IACvCwB,EAAWI,WAAWC,MAAKC,GAAUA,EAAO9B,OAASA,MAGxD,QAAI0B,EAAeK,OAAS,IAC1B7C,OAAO0B,MAAM,+BAA+Bc,EAAeM,KAAK,iCAAiCrB,MAC1F,GAIX,CAKA,sBAAAsB,CAAuBC,GAIrB,MAAO,CACLC,QAASD,EAAQE,OAAMC,GAAKA,EAAEF,UAC9BG,SAAUJ,EAAQK,KAAIF,GAAKA,EAAEG,UAASb,QAAQc,QAAyBC,IAAND,IAErE,CAKA,eAAME,GACJ,OAAOvD,WAAWuD,WACpB,CAMA,iBAAMC,CAAYC,GAChB,IACE,MAAM9B,QAAe3B,WAAWwD,YAAYC,GAI5C,OADA3D,OAAO4D,IAAI,gCAAgCD,EAAO7C,gCAAgCe,EAAOgC,eAAehC,EAAOiC,gBACxGjC,CACT,CAAE,MAAON,GAEP,MADAvB,OAAOuB,MAAM,2CAA2CoC,EAAO7C,SAAUS,GACnEA,CACR,CACF,SAIK,MAAMwC,cAAgB,IAAIzD","ignoreList":[]}
@@ -1,54 +1,2 @@
1
- import * as appInsights from 'applicationinsights';
2
- export class TelemetryService {
3
- static client = null;
4
- static instrumentationKey = 'InstrumentationKey=c5fc06c7-a96c-4d80-9aff-bc9c933db0d1';
5
- static {
6
- // Initialize Application Insights
7
- try {
8
- const client = new appInsights.TelemetryClient(TelemetryService.instrumentationKey);
9
- client.config.disableAppInsights = false;
10
- client.config.maxBatchSize = 250;
11
- client.context.tags[client.context.keys.cloudRole] = 'imcp';
12
- TelemetryService.client = client;
13
- console.log('Application Insights initialized');
14
- }
15
- catch (error) {
16
- console.error('Failed to initialize Application Insights:', error);
17
- }
18
- }
19
- static trackEvent(name, properties) {
20
- if (!this.client) {
21
- return;
22
- }
23
- this.client.trackEvent({ name, properties });
24
- }
25
- static trackException(error, properties) {
26
- if (!this.client) {
27
- return;
28
- }
29
- this.client.trackException({ exception: error, properties });
30
- }
31
- static trackTrace(message, properties) {
32
- if (!this.client) {
33
- return;
34
- }
35
- this.client.trackTrace({ message, properties });
36
- }
37
- static trackMetric(name, value) {
38
- if (!this.client) {
39
- return;
40
- }
41
- this.client.trackMetric({ name, value });
42
- }
43
- static flush() {
44
- return new Promise((resolve) => {
45
- if (!this.client) {
46
- resolve();
47
- return;
48
- }
49
- this.client.flush();
50
- resolve();
51
- });
52
- }
53
- }
1
+ import*as appInsights from"applicationinsights";export class TelemetryService{static client=null;static instrumentationKey="InstrumentationKey=c5fc06c7-a96c-4d80-9aff-bc9c933db0d1";static{try{const t=new appInsights.TelemetryClient(TelemetryService.instrumentationKey);t.config.disableAppInsights=!1,t.config.maxBatchSize=250,t.context.tags[t.context.keys.cloudRole]="imcp",TelemetryService.client=t}catch(t){}}static trackEvent(t,e){this.client&&this.client.trackEvent({name:t,properties:e})}static trackException(t,e){this.client&&this.client.trackException({exception:t,properties:e})}static trackTrace(t,e){this.client&&this.client.trackTrace({message:t,properties:e})}static trackMetric(t,e){this.client&&this.client.trackMetric({name:t,value:e})}static flush(){return new Promise((t=>{this.client?(this.client.flush(),t()):t()}))}}
54
2
  //# sourceMappingURL=TelemetryService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["appInsights","TelemetryService","static","client","TelemetryClient","instrumentationKey","config","disableAppInsights","maxBatchSize","context","tags","keys","cloudRole","error","trackEvent","name","properties","this","trackException","exception","trackTrace","message","trackMetric","value","flush","Promise","resolve"],"sources":["../../src/services/TelemetryService.ts"],"mappings":"UAAYA,gBAAiB,6BAEvB,MAAOC,iBACHC,cAAoD,KACpDA,0BAAqC,iEAI3C,IACE,MAAMC,EAAS,IAAIH,YAAYI,gBAAgBH,iBAAiBI,oBAChEF,EAAOG,OAAOC,oBAAqB,EACnCJ,EAAOG,OAAOE,aAAe,IAC7BL,EAAOM,QAAQC,KAAKP,EAAOM,QAAQE,KAAKC,WAAa,OACrDX,iBAAiBE,OAASA,CAE5B,CAAE,MAAOU,GAET,CACF,CAEA,iBAAOC,CAAWC,EAAcC,GACzBC,KAAKd,QAGVc,KAAKd,OAAOW,WAAW,CAAEC,OAAMC,cACjC,CAEA,qBAAOE,CAAeL,EAAcG,GAC7BC,KAAKd,QAGVc,KAAKd,OAAOe,eAAe,CAAEC,UAAWN,EAAOG,cACjD,CAEA,iBAAOI,CAAWC,EAAiBL,GAC5BC,KAAKd,QAGVc,KAAKd,OAAOiB,WAAW,CAAEC,UAASL,cACpC,CAEA,kBAAOM,CAAYP,EAAcQ,GAC1BN,KAAKd,QAGVc,KAAKd,OAAOmB,YAAY,CAAEP,OAAMQ,SAClC,CAEA,YAAOC,GACL,OAAO,IAAIC,SAASC,IACbT,KAAKd,QAIVc,KAAKd,OAAOqB,QACZE,KAJEA,GAIO,GAEb","ignoreList":[]}
@@ -1,80 +1,2 @@
1
- /**
2
- * Utility class to track update check operations in progress
3
- * Provides thread-safe access to check status with proper locking
4
- */
5
- export class UpdateCheckTracker {
6
- static instance;
7
- // Map to track operations in progress (key -> inProgress)
8
- operationsInProgress = new Map();
9
- // Lock for thread safety when checking/updating the in-progress map
10
- operationsLock = Promise.resolve();
11
- constructor() { }
12
- /**
13
- * Get the singleton instance of the tracker
14
- */
15
- static getInstance() {
16
- if (!UpdateCheckTracker.instance) {
17
- UpdateCheckTracker.instance = new UpdateCheckTracker();
18
- }
19
- return UpdateCheckTracker.instance;
20
- }
21
- /**
22
- * Execute an operation with a lock to ensure thread safety
23
- * @param operation The operation to execute
24
- * @returns The result of the operation
25
- * @private
26
- */
27
- async withLock(operation) {
28
- const current = this.operationsLock;
29
- let resolve;
30
- this.operationsLock = new Promise(r => resolve = r);
31
- try {
32
- await current;
33
- return await operation();
34
- }
35
- finally {
36
- resolve();
37
- }
38
- }
39
- /**
40
- * Check if an operation can be started and mark it as in progress if so
41
- * @param key The key to identify the operation
42
- * @returns True if the operation can be started, false if already in progress
43
- */
44
- async startOperation(key) {
45
- return await this.withLock(async () => {
46
- if (!this.operationsInProgress.get(key)) {
47
- this.operationsInProgress.set(key, true);
48
- return true;
49
- }
50
- return false;
51
- });
52
- }
53
- /**
54
- * Mark an operation as complete
55
- * @param key The key to identify the operation
56
- */
57
- async endOperation(key) {
58
- try {
59
- await this.withLock(async () => {
60
- this.operationsInProgress.set(key, false);
61
- });
62
- }
63
- catch (error) {
64
- console.error(`Failed to end operation for key: ${key}`, error);
65
- }
66
- }
67
- /**
68
- * Check if an operation is in progress
69
- * @param key The key to identify the operation
70
- * @returns True if the operation is in progress
71
- */
72
- async isOperationInProgress(key) {
73
- return await this.withLock(async () => {
74
- return !!this.operationsInProgress.get(key);
75
- });
76
- }
77
- }
78
- // Export a singleton instance
79
- export const updateCheckTracker = UpdateCheckTracker.getInstance();
1
+ export class UpdateCheckTracker{static instance;operationsInProgress=new Map;operationsLock=Promise.resolve();constructor(){}static getInstance(){return UpdateCheckTracker.instance||(UpdateCheckTracker.instance=new UpdateCheckTracker),UpdateCheckTracker.instance}async withLock(t){const e=this.operationsLock;let s;this.operationsLock=new Promise((t=>s=t));try{return await e,await t()}finally{s()}}async startOperation(t){return await this.withLock((async()=>!this.operationsInProgress.get(t)&&(this.operationsInProgress.set(t,!0),!0)))}async endOperation(t){try{await this.withLock((async()=>{this.operationsInProgress.set(t,!1)}))}catch(t){}}async isOperationInProgress(t){return await this.withLock((async()=>!!this.operationsInProgress.get(t)))}}export const updateCheckTracker=UpdateCheckTracker.getInstance();
80
2
  //# sourceMappingURL=UpdateCheckTracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UpdateCheckTracker","static","operationsInProgress","Map","operationsLock","Promise","resolve","constructor","getInstance","instance","withLock","operation","current","this","r","startOperation","key","async","get","set","endOperation","error","isOperationInProgress","updateCheckTracker"],"sources":["../../src/utils/UpdateCheckTracker.ts"],"mappings":"OAIM,MAAOA,mBACDC,gBAGAC,qBAA6C,IAAIC,IAGjDC,eAAgCC,QAAQC,UAEhD,WAAAC,GAAwB,CAKjB,kBAAOC,GAIV,OAHKR,mBAAmBS,WACpBT,mBAAmBS,SAAW,IAAIT,oBAE/BA,mBAAmBS,QAC9B,CAQQ,cAAMC,CAAYC,GACtB,MAAMC,EAAUC,KAAKT,eACrB,IAAIE,EACJO,KAAKT,eAAiB,IAAIC,SAAcS,GAAKR,EAAUQ,IACvD,IAEI,aADMF,QACOD,GACjB,C,QACIL,GACJ,CACJ,CAOA,oBAAMS,CAAeC,GACjB,aAAaH,KAAKH,UAASO,UAClBJ,KAAKX,qBAAqBgB,IAAIF,KAC/BH,KAAKX,qBAAqBiB,IAAIH,GAAK,IAC5B,IAInB,CAMA,kBAAMI,CAAaJ,GACf,UACUH,KAAKH,UAASO,UAChBJ,KAAKX,qBAAqBiB,IAAIH,GAAK,EAAM,GAEjD,CAAE,MAAOK,GAET,CACJ,CAOA,2BAAMC,CAAsBN,GACxB,aAAaH,KAAKH,UAASO,WACdJ,KAAKX,qBAAqBgB,IAAIF,IAE/C,SAIG,MAAMO,mBAAqBvB,mBAAmBQ","ignoreList":[]}
@@ -1,255 +1,2 @@
1
- import { SETTINGS_DIR } from '../core/metadatas/constants.js';
2
- import { Logger } from './logger.js';
3
- import { exec } from 'child_process';
4
- import util from 'util';
5
- import fs from 'fs/promises';
6
- import path from 'path';
7
- const execAsync = util.promisify(exec);
8
- /**
9
- * Sets up the NPM credential provider.
10
- * Installs @microsoft/artifacts-npm-credprovider if not already installed.
11
- * @private
12
- */
13
- async function _setupNpmCredentialProvider() {
14
- Logger.debug('Setting up NPM credential provider...');
15
- const credProviderCommand = 'artifacts-npm-credprovider';
16
- // Check if artifacts-npm-credprovider is installed by trying to get its version or a known command.
17
- // A more robust check might involve checking a specific version or path.
18
- let installed = false;
19
- try {
20
- // Attempt to get help output as a basic check for presence
21
- const { stdout, stderr } = await execAsync(`${credProviderCommand} --help`);
22
- Logger.debug(`${credProviderCommand} --help stdout: ${stdout}`);
23
- if (stderr)
24
- Logger.debug(`${credProviderCommand} --help stderr: ${stderr}`);
25
- installed = true;
26
- Logger.debug(`${credProviderCommand} appears to be installed.`);
27
- }
28
- catch (e) {
29
- Logger.debug(`${credProviderCommand} not found or --help failed, attempting installation. Error: ${e}`);
30
- }
31
- if (!installed) {
32
- Logger.log(`Installing @microsoft/artifacts-npm-credprovider...`);
33
- try {
34
- const installCommand = `npm install -g @microsoft/artifacts-npm-credprovider --registry https://pkgs.dev.azure.com/mseng/226da8e7-b1c0-4167-9678-53f461e07706/_packaging/AzureArtifacts/npm/registry/`;
35
- const { stdout: installStdout, stderr: installStderr } = await execAsync(installCommand);
36
- Logger.debug(`@microsoft/artifacts-npm-credprovider install stdout: ${installStdout}`);
37
- if (installStderr)
38
- Logger.debug(`@microsoft/artifacts-npm-credprovider install stderr: ${installStderr}`);
39
- Logger.log('@microsoft/artifacts-npm-credprovider installed successfully.');
40
- }
41
- catch (error) {
42
- Logger.error('Failed to install @microsoft/artifacts-npm-credprovider', error);
43
- throw new Error(`Failed to install @microsoft/artifacts-npm-credprovider: ${error instanceof Error ? error.message : String(error)}`);
44
- }
45
- }
46
- }
47
- /**
48
- * Installs pip requirements: keyring and artifacts-keyring.
49
- * @param pythonCommand The python command to use (e.g., 'python' or 'python3').
50
- * @private
51
- */
52
- async function _installPipRequirements(pythonCommand) {
53
- Logger.debug(`Installing pip requirements: keyring, artifacts-keyring using ${pythonCommand}`);
54
- try {
55
- const command = `${pythonCommand} -m pip install keyring artifacts-keyring`;
56
- const { stdout, stderr } = await execAsync(command);
57
- Logger.debug(`pip install keyring artifacts-keyring stdout: ${stdout}`);
58
- if (stderr)
59
- Logger.debug(`pip install keyring artifacts-keyring stderr: ${stderr}`);
60
- Logger.log('Successfully installed keyring and artifacts-keyring.');
61
- }
62
- catch (error) {
63
- Logger.error('Failed to install pip requirements (keyring, artifacts-keyring)', error);
64
- throw new Error(`Failed to install pip requirements: ${error instanceof Error ? error.message : String(error)}`);
65
- }
66
- }
67
- /**
68
- * Configures NPM authentication for Azure DevOps Artifacts in a specified directory.
69
- * This includes setting up the credential provider, creating an .npmrc file,
70
- * and running the credential provider.
71
- * @param execPromise The promise-based exec function.
72
- * @param registry The Azure DevOps artifacts registry configuration.
73
- * @param directoryPath The directory where .npmrc will be created and commands will be executed.
74
- * @private
75
- */
76
- async function _configureNpmAdoAuthInDirectory(execPromise, registry, directoryPath) {
77
- if (!registry || !registry.registryUrl || !registry.registryName) {
78
- throw new Error('Registry name and URL are required for NPM ADO auth configuration.');
79
- }
80
- await _setupNpmCredentialProvider();
81
- const npmrcContent = `@${registry.registryName}:registry=${registry.registryUrl}\nalways-auth=true`;
82
- const npmrcPath = path.join(directoryPath, '.npmrc');
83
- await fs.writeFile(npmrcPath, npmrcContent.trim());
84
- Logger.debug(`Created/Updated .npmrc file at: ${npmrcPath}`);
85
- const env = { ...process.env, NUGET_CREDENTIALPROVIDER_VSTS_TOKENTYPE: 'SelfDescribing' };
86
- Logger.debug(`Running artifacts-npm-credprovider in ${directoryPath}`);
87
- const { stdout: credProviderStdout, stderr: credProviderStderr } = await execPromise('artifacts-npm-credprovider', { cwd: directoryPath, env });
88
- Logger.debug(`artifacts-npm-credprovider stdout: ${credProviderStdout}`);
89
- if (credProviderStderr)
90
- Logger.debug(`artifacts-npm-credprovider stderr: ${credProviderStderr}`);
91
- Logger.log(`Successfully ran artifacts-npm-credprovider in ${directoryPath}`);
92
- }
93
- /**
94
- * Handles fetching and setting up an Azure DevOps artifact.
95
- * @param requirement The requirement configuration.
96
- * @param registry The Azure DevOps artifacts registry configuration.
97
- * @param pythonCommand Optional Python command (e.g., 'python', 'python3') for pip operations.
98
- * @param targetDir Optional target directory for npm artifact setup. If not provided, a default will be used.
99
- * @returns A promise that resolves with the artifact details.
100
- */
101
- export async function handleArtifact(requirement, registry, pythonCommand = 'python', // Default to 'python' if not provided
102
- targetDir // Optional target directory for npm
103
- ) {
104
- if (!registry) {
105
- throw new Error('Azure DevOps artifacts registry configuration is required.');
106
- }
107
- Logger.debug(`Handling ADO artifact for requirement: ${requirement.name}, type: ${requirement.type}`);
108
- if (requirement.type === 'npm') {
109
- if (!registry.registryName || !registry.registryUrl) {
110
- throw new Error('Registry name and URL are required for NPM source in Azure DevOps artifacts.');
111
- }
112
- const requirementDir = targetDir || path.join(SETTINGS_DIR, 'requirements', requirement.name, requirement.version);
113
- await fs.mkdir(requirementDir, { recursive: true });
114
- Logger.debug(`Ensured directory for npm requirement: ${requirementDir}`);
115
- try {
116
- await _configureNpmAdoAuthInDirectory(execAsync, registry, requirementDir);
117
- Logger.log(`Successfully configured ADO NPM auth for ${requirement.name} in ${requirementDir}`);
118
- const version = requirement.version.includes('latest') ? 'latest' : requirement.version;
119
- return {
120
- folderPath: requirementDir,
121
- type: 'npm',
122
- package: `@${registry.registryName}/${requirement.name}`,
123
- registryUrl: registry.registryUrl,
124
- version: version
125
- };
126
- }
127
- catch (error) {
128
- Logger.error(`Failed to configure ADO NPM auth for ${requirement.name} in ${requirementDir}`, error);
129
- throw new Error(`ADO NPM auth configuration failed: ${error instanceof Error ? error.message : String(error)}`);
130
- }
131
- }
132
- else if (requirement.type === 'pip') {
133
- if (!registry.registryUrl) {
134
- throw new Error('Registry URL are required for PIP source in Azure DevOps artifacts.');
135
- }
136
- await _installPipRequirements(pythonCommand);
137
- const packageName = requirement.version.toLowerCase().includes('latest')
138
- ? `${requirement.name} --upgrade`
139
- : `${requirement.name}==${requirement.version}`;
140
- Logger.log(`Pip requirement ${packageName} configured with registry ${registry.registryUrl}`);
141
- return {
142
- type: 'pip',
143
- package: packageName,
144
- registryUrl: registry.registryUrl,
145
- version: requirement.version
146
- };
147
- }
148
- else {
149
- throw new Error(`Unsupported requirement type for ADO artifact: ${requirement.type}`);
150
- }
151
- }
152
- /**
153
- * Get the latest version of an artifact from Azure DevOps.
154
- * This is a simplified implementation and might require further enhancements for robust authentication and error handling.
155
- * @param execPromise The promise-based exec function.
156
- * @param requirement The requirement configuration.
157
- * @param registry The Azure DevOps artifacts registry configuration.
158
- * @param options Optional server install options (e.g., for pythonCommand).
159
- * @returns The latest version string, or undefined if not found or an error occurs.
160
- */
161
- export async function getArtifactLatestVersion(requirement, registry, options, // Added import for ServerInstallOptions
162
- targetDir // Optional target directory for npm
163
- ) {
164
- if (!registry || !registry.registryUrl) {
165
- Logger.error('ADO Artifact registry URL is missing for fetching latest version.');
166
- return undefined;
167
- }
168
- Logger.debug(`Attempting to fetch latest version for ADO artifact: ${requirement.name} of type ${requirement.type}`);
169
- if (requirement.type === 'npm') {
170
- if (!registry.registryName) { // Ensure registryName is present
171
- Logger.error('NPM ADO Artifact registry name is missing for fetching latest version.');
172
- return undefined;
173
- }
174
- const requirementDir = targetDir || path.join(SETTINGS_DIR, 'requirements', requirement.name, requirement.version);
175
- try {
176
- await fs.mkdir(requirementDir, { recursive: true });
177
- Logger.debug(`Ensured directory for NPM ADO version check: ${requirementDir}`);
178
- // Configure auth within the requirementDir
179
- await _configureNpmAdoAuthInDirectory(execAsync, registry, requirementDir);
180
- Logger.log(`Successfully configured ADO NPM auth for version check of ${requirement.name} in ${requirementDir}`);
181
- const fullPackageName = `@${registry.registryName}/${requirement.name}`;
182
- const command = `npm view ${fullPackageName} version --registry ${registry.registryUrl}`;
183
- Logger.debug(`Executing for NPM ADO latest version: ${command} in ${requirementDir}`);
184
- const { stdout, stderr } = await execAsync(command, { cwd: requirementDir });
185
- if (stderr && !stdout.trim()) {
186
- Logger.error(`Error fetching NPM ADO version for ${fullPackageName} via npm view: ${stderr}`);
187
- return undefined;
188
- }
189
- const version = stdout.trim();
190
- if (version) {
191
- Logger.debug(`Found latest NPM ADO version for ${fullPackageName}: ${version}`);
192
- return version;
193
- }
194
- else {
195
- Logger.log(`Could not parse latest NPM version from ADO for ${fullPackageName} from output: '${stdout}'`);
196
- return undefined;
197
- }
198
- }
199
- catch (error) {
200
- Logger.error(`Exception fetching latest NPM version from ADO for ${requirement.name} in ${requirementDir}: ${error instanceof Error ? error.message : String(error)}`);
201
- return undefined;
202
- }
203
- }
204
- else if (requirement.type === 'pip') {
205
- try {
206
- const pythonCmd = options?.settings?.pythonEnv || 'python';
207
- const pipCmd = `${pythonCmd} -m pip`;
208
- // Ensure keyring and artifacts-keyring are installed.
209
- // This is usually handled by `handleArtifact` during install.
210
- // For a standalone version check, we might need to ensure they exist.
211
- // Consider calling _installPipRequirements(pythonCmd) if necessary, but it has side effects.
212
- // For now, assume they are present if ADO pip artifacts are being used.
213
- const command = `${pipCmd} index versions ${requirement.name} --extra-index-url ${registry.registryUrl}`;
214
- Logger.debug(`Executing for Pip ADO latest version: ${command}`);
215
- const { stdout, stderr } = await execAsync(command);
216
- if (stderr && !stdout.trim()) { // If there's stderr and no significant stdout, it's likely an error
217
- Logger.error(`Error fetching Pip ADO version for ${requirement.name}: ${stderr}`);
218
- return undefined;
219
- }
220
- // Parse output like:
221
- // mypackage (1.0.0)
222
- // Available versions: 1.0.0, 0.9.0
223
- // LATEST: 1.0.0
224
- // Or:
225
- // mypackage
226
- // VERSIONS: 1.0.0, 0.9.0
227
- // Latest: 1.0.0
228
- const latestMatch = stdout.match(/(?:LATEST|Latest):\s*([^\s]+)/);
229
- if (latestMatch && latestMatch[1]) {
230
- Logger.debug(`Found latest Pip ADO version via LATEST line: ${latestMatch[1]}`);
231
- return latestMatch[1];
232
- }
233
- // Fallback: try to parse from "Available versions" or "VERSIONS"
234
- const versionsMatch = stdout.match(/(?:Available versions|VERSIONS):\s*([^\n]+)/);
235
- if (versionsMatch && versionsMatch[1]) {
236
- const versions = versionsMatch[1].split(',').map(v => v.trim()).filter(v => v);
237
- if (versions.length > 0) {
238
- // This is a naive approach, assumes the first listed is relevant or latest.
239
- // Proper sorting (e.g. semver) would be better.
240
- Logger.debug(`Found Pip ADO versions: ${versions.join(', ')}. Taking the first one: ${versions[0]}`);
241
- return versions[0];
242
- }
243
- }
244
- Logger.log(`Could not parse latest Pip version from ADO for ${requirement.name} from output: ${stdout}`); // Changed Logger.warn to Logger.log
245
- return undefined;
246
- }
247
- catch (error) {
248
- Logger.error(`Exception fetching latest Pip version from ADO for ${requirement.name}: ${error instanceof Error ? error.message : String(error)}`);
249
- return undefined;
250
- }
251
- }
252
- Logger.log(`getArtifactLatestVersion not implemented for type '${requirement.type}' or encountered an issue.`); // Changed Logger.warn to Logger.log
253
- return undefined;
254
- }
1
+ import{SETTINGS_DIR}from"../core/metadatas/constants.js";import{Logger}from"./logger.js";import{exec}from"child_process";import util from"util";import fs from"fs/promises";import path from"path";const execAsync=util.promisify(exec);async function _setupNpmCredentialProvider(){Logger.debug("Setting up NPM credential provider...");const r="artifacts-npm-credprovider";let e=!1;try{const{stdout:t,stderr:i}=await execAsync(`${r} --help`);Logger.debug(`${r} --help stdout: ${t}`),i&&Logger.debug(`${r} --help stderr: ${i}`),e=!0,Logger.debug(`${r} appears to be installed.`)}catch(e){Logger.debug(`${r} not found or --help failed, attempting installation. Error: ${e}`)}if(!e){Logger.log("Installing @microsoft/artifacts-npm-credprovider...");try{const r="npm install -g @microsoft/artifacts-npm-credprovider --registry https://pkgs.dev.azure.com/mseng/226da8e7-b1c0-4167-9678-53f461e07706/_packaging/AzureArtifacts/npm/registry/",{stdout:e,stderr:t}=await execAsync(r);Logger.debug(`@microsoft/artifacts-npm-credprovider install stdout: ${e}`),t&&Logger.debug(`@microsoft/artifacts-npm-credprovider install stderr: ${t}`),Logger.log("@microsoft/artifacts-npm-credprovider installed successfully.")}catch(r){throw Logger.error("Failed to install @microsoft/artifacts-npm-credprovider",r),new Error(`Failed to install @microsoft/artifacts-npm-credprovider: ${r instanceof Error?r.message:String(r)}`)}}}async function _installPipRequirements(r){Logger.debug(`Installing pip requirements: keyring, artifacts-keyring using ${r}`);try{const e=`${r} -m pip install keyring artifacts-keyring`,{stdout:t,stderr:i}=await execAsync(e);Logger.debug(`pip install keyring artifacts-keyring stdout: ${t}`),i&&Logger.debug(`pip install keyring artifacts-keyring stderr: ${i}`),Logger.log("Successfully installed keyring and artifacts-keyring.")}catch(r){throw Logger.error("Failed to install pip requirements (keyring, artifacts-keyring)",r),new Error(`Failed to install pip requirements: ${r instanceof Error?r.message:String(r)}`)}}async function _configureNpmAdoAuthInDirectory(r,e,t){if(!e||!e.registryUrl||!e.registryName)throw new Error("Registry name and URL are required for NPM ADO auth configuration.");await _setupNpmCredentialProvider();const i=`@${e.registryName}:registry=${e.registryUrl}\nalways-auth=true`,o=path.join(t,".npmrc");await fs.writeFile(o,i.trim()),Logger.debug(`Created/Updated .npmrc file at: ${o}`);const n={...process.env,NUGET_CREDENTIALPROVIDER_VSTS_TOKENTYPE:"SelfDescribing"};Logger.debug(`Running artifacts-npm-credprovider in ${t}`);const{stdout:s,stderr:a}=await r("artifacts-npm-credprovider",{cwd:t,env:n});Logger.debug(`artifacts-npm-credprovider stdout: ${s}`),a&&Logger.debug(`artifacts-npm-credprovider stderr: ${a}`),Logger.log(`Successfully ran artifacts-npm-credprovider in ${t}`)}export async function handleArtifact(r,e,t="python",i){if(!e)throw new Error("Azure DevOps artifacts registry configuration is required.");if(Logger.debug(`Handling ADO artifact for requirement: ${r.name}, type: ${r.type}`),"npm"!==r.type){if("pip"===r.type){if(!e.registryUrl)throw new Error("Registry URL are required for PIP source in Azure DevOps artifacts.");await _installPipRequirements(t);const i=r.version.toLowerCase().includes("latest")?`${r.name} --upgrade`:`${r.name}==${r.version}`;return Logger.log(`Pip requirement ${i} configured with registry ${e.registryUrl}`),{type:"pip",package:i,registryUrl:e.registryUrl,version:r.version}}throw new Error(`Unsupported requirement type for ADO artifact: ${r.type}`)}{if(!e.registryName||!e.registryUrl)throw new Error("Registry name and URL are required for NPM source in Azure DevOps artifacts.");const t=i||path.join(SETTINGS_DIR,"requirements",r.name,r.version);await fs.mkdir(t,{recursive:!0}),Logger.debug(`Ensured directory for npm requirement: ${t}`);try{await _configureNpmAdoAuthInDirectory(execAsync,e,t),Logger.log(`Successfully configured ADO NPM auth for ${r.name} in ${t}`);const i=r.version.includes("latest")?"latest":r.version;return{folderPath:t,type:"npm",package:`@${e.registryName}/${r.name}`,registryUrl:e.registryUrl,version:i}}catch(e){throw Logger.error(`Failed to configure ADO NPM auth for ${r.name} in ${t}`,e),new Error(`ADO NPM auth configuration failed: ${e instanceof Error?e.message:String(e)}`)}}}export async function getArtifactLatestVersion(r,e,t,i){if(e&&e.registryUrl){if(Logger.debug(`Attempting to fetch latest version for ADO artifact: ${r.name} of type ${r.type}`),"npm"===r.type){if(!e.registryName)return void Logger.error("NPM ADO Artifact registry name is missing for fetching latest version.");const t=i||path.join(SETTINGS_DIR,"requirements",r.name,r.version);try{await fs.mkdir(t,{recursive:!0}),Logger.debug(`Ensured directory for NPM ADO version check: ${t}`),await _configureNpmAdoAuthInDirectory(execAsync,e,t),Logger.log(`Successfully configured ADO NPM auth for version check of ${r.name} in ${t}`);const i=`@${e.registryName}/${r.name}`,o=`npm view ${i} version --registry ${e.registryUrl}`;Logger.debug(`Executing for NPM ADO latest version: ${o} in ${t}`);const{stdout:n,stderr:s}=await execAsync(o,{cwd:t});if(s&&!n.trim())return void Logger.error(`Error fetching NPM ADO version for ${i} via npm view: ${s}`);const a=n.trim();return a?(Logger.debug(`Found latest NPM ADO version for ${i}: ${a}`),a):void Logger.log(`Could not parse latest NPM version from ADO for ${i} from output: '${n}'`)}catch(e){return void Logger.error(`Exception fetching latest NPM version from ADO for ${r.name} in ${t}: ${e instanceof Error?e.message:String(e)}`)}}else if("pip"===r.type)try{const i=`${t?.settings?.pythonEnv||"python"} -m pip index versions ${r.name} --extra-index-url ${e.registryUrl}`;Logger.debug(`Executing for Pip ADO latest version: ${i}`);const{stdout:o,stderr:n}=await execAsync(i);if(n&&!o.trim())return void Logger.error(`Error fetching Pip ADO version for ${r.name}: ${n}`);const s=o.match(/(?:LATEST|Latest):\s*([^\s]+)/);if(s&&s[1])return Logger.debug(`Found latest Pip ADO version via LATEST line: ${s[1]}`),s[1];const a=o.match(/(?:Available versions|VERSIONS):\s*([^\n]+)/);if(a&&a[1]){const r=a[1].split(",").map((r=>r.trim())).filter((r=>r));if(r.length>0)return Logger.debug(`Found Pip ADO versions: ${r.join(", ")}. Taking the first one: ${r[0]}`),r[0]}return void Logger.log(`Could not parse latest Pip version from ADO for ${r.name} from output: ${o}`)}catch(e){return void Logger.error(`Exception fetching latest Pip version from ADO for ${r.name}: ${e instanceof Error?e.message:String(e)}`)}Logger.log(`getArtifactLatestVersion not implemented for type '${r.type}' or encountered an issue.`)}else Logger.error("ADO Artifact registry URL is missing for fetching latest version.")}
255
2
  //# sourceMappingURL=adoUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SETTINGS_DIR","Logger","exec","util","fs","path","execAsync","promisify","async","_setupNpmCredentialProvider","debug","credProviderCommand","installed","stdout","stderr","e","log","installCommand","installStdout","installStderr","error","Error","message","String","_installPipRequirements","pythonCommand","command","_configureNpmAdoAuthInDirectory","execPromise","registry","directoryPath","registryUrl","registryName","npmrcContent","npmrcPath","join","writeFile","trim","env","process","NUGET_CREDENTIALPROVIDER_VSTS_TOKENTYPE","credProviderStdout","credProviderStderr","cwd","handleArtifact","requirement","targetDir","name","type","packageName","version","toLowerCase","includes","package","requirementDir","mkdir","recursive","folderPath","getArtifactLatestVersion","options","fullPackageName","settings","pythonEnv","latestMatch","match","versionsMatch","versions","split","map","v","filter","length"],"sources":["../../src/utils/adoUtils.ts"],"mappings":"OACSA,iBAAoB,wCACpBC,WAAc,qBACdC,SAAsB,uBACxBC,SAAU,cACVC,OAAQ,qBACRC,SAAU,OAGjB,MAAMC,UAAYH,KAAKI,UAAUL,MAejCM,eAAeC,8BACXR,OAAOS,MAAM,yCACb,MAAMC,EAAsB,6BAI5B,IAAIC,GAAY,EAChB,IAEI,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBR,UAAU,GAAGK,YAC9CV,OAAOS,MAAM,GAAGC,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EjK,CACJ,MAAO,GAAyB,QAArByB,EAAYG,KACnB,IACI,MASMtB,EAAU,GATEiC,GAASE,UAAUC,WAAuB,kCAShBjB,EAAYE,0BAA0BlB,EAASE,cAC3F9B,OAAOS,MAAM,yCAAyCgB,KACtD,MAAMb,OAAEA,EAAMC,OAAEA,SAAiBR,UAAUoB,GAE3C,GAAIZ,IAAWD,EAAOwB,OAElB,YADApC,OAAOmB,MAAM,sCAAsCyB,EAAYE,SAASjC,KAY5E,MAAMiD,EAAclD,EAAOmD,MAAM,iCACjC,GAAID,GAAeA,EAAY,GAE3B,OADA9D,OAAOS,MAAM,iDAAiDqD,EAAY,MACnEA,EAAY,GAIvB,MAAME,EAAgBpD,EAAOmD,MAAM,+CACnC,GAAIC,GAAiBA,EAAc,GAAI,CACnC,MAAMC,EAAWD,EAAc,GAAGE,MAAM,KAAKC,KAAIC,GAAKA,EAAEhC,SAAQiC,QAAOD,GAAKA,IAC5E,GAAIH,EAASK,OAAS,EAIlB,OADAtE,OAAOS,MAAM,2BAA2BwD,EAAS/B,KAAK,gCAAgC+B,EAAS,MACxFA,EAAS,EAExB,CAGA,YADAjE,OAAOe,IAAI,mDAAmD6B,EAAYE,qBAAqBlC,IAEnG,CAAE,MAAOO,GAEL,YADAnB,OAAOmB,MAAM,sDAAsDyB,EAAYE,SAAS3B,aAAiBC,MAAQD,EAAME,QAAUC,OAAOH,KAE5I,CAGJnB,OAAOe,IAAI,sDAAsD6B,EAAYG,iCAjG7E,MAFI/C,OAAOmB,MAAM,oEAqGrB","ignoreList":[]}
@@ -1,66 +1,2 @@
1
- import fs from 'fs/promises';
2
- import * as path from 'path';
3
- import extractZipModule from 'extract-zip';
4
- /**
5
- * Extract a zip file to a directory
6
- * @param zipPath The path to the zip file
7
- * @param options Extraction options
8
- * @returns A promise that resolves when extraction is complete
9
- */
10
- export async function extractZipFile(zipPath, options) {
11
- try {
12
- // Try to use extract-zip if available
13
- if (typeof extractZipModule === 'function') {
14
- return await extractZipModule(zipPath, options);
15
- }
16
- // Fallback to Node.js built-in unzipper
17
- const fs = require('fs');
18
- const unzipper = require('unzipper');
19
- await fs.promises.mkdir(options.dir, { recursive: true });
20
- return new Promise((resolve, reject) => {
21
- fs.createReadStream(zipPath)
22
- .pipe(unzipper.Extract({ path: options.dir }))
23
- .on('close', resolve)
24
- .on('error', reject);
25
- });
26
- }
27
- catch (error) {
28
- console.error(`Error extracting zip: ${error instanceof Error ? error.message : String(error)}`);
29
- throw new Error(`Failed to extract zip file ${zipPath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
30
- }
31
- }
32
- /**
33
- * Reads a JSON file and parses its content
34
- * @param filePath Path to the JSON file
35
- * @param createIfNotExist Whether to create the file if it doesn't exist
36
- * @returns The parsed JSON content
37
- */
38
- import stripJsonComments from 'strip-json-comments';
39
- export async function readJsonFile(filePath, createIfNotExist = false) {
40
- try {
41
- // Ensure directory exists
42
- if (createIfNotExist) {
43
- await fs.mkdir(path.dirname(filePath), { recursive: true });
44
- }
45
- const content = await fs.readFile(filePath, 'utf8');
46
- // Remove comments and trailing commas from JSON content
47
- const sanitizedContent = stripJsonComments(content).replace(/,(\s*[}\]])/g, '$1');
48
- return JSON.parse(sanitizedContent);
49
- }
50
- catch (error) {
51
- if (error.code === 'ENOENT' && createIfNotExist) {
52
- return {};
53
- }
54
- throw error;
55
- }
56
- }
57
- /**
58
- * Writes content to a JSON file
59
- * @param filePath Path to the JSON file
60
- * @param content Content to write to the file
61
- */
62
- export async function writeJsonFile(filePath, content) {
63
- await fs.mkdir(path.dirname(filePath), { recursive: true });
64
- await fs.writeFile(filePath, JSON.stringify(content, null, 2), 'utf8');
65
- }
1
+ import fs from"fs/promises";import*as path from"path";import extractZipModule from"extract-zip";export async function extractZipFile(r,e){try{if("function"==typeof extractZipModule)return await extractZipModule(r,e);const t=require("fs"),i=require("unzipper");return await t.promises.mkdir(e.dir,{recursive:!0}),new Promise(((o,a)=>{t.createReadStream(r).pipe(i.Extract({path:e.dir})).on("close",o).on("error",a)}))}catch(e){throw new Error(`Failed to extract zip file ${r}: ${e instanceof Error?e.message:"Unknown error"}`)}}import stripJsonComments from"strip-json-comments";export async function readJsonFile(r,e=!1){try{e&&await fs.mkdir(path.dirname(r),{recursive:!0});const t=await fs.readFile(r,"utf8"),i=stripJsonComments(t).replace(/,(\s*[}\]])/g,"$1");return JSON.parse(i)}catch(r){if("ENOENT"===r.code&&e)return{};throw r}}export async function writeJsonFile(r,e){await fs.mkdir(path.dirname(r),{recursive:!0}),await fs.writeFile(r,JSON.stringify(e,null,2),"utf8")}
66
2
  //# sourceMappingURL=clientUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","path","extractZipModule","async","extractZipFile","zipPath","options","require","unzipper","promises","mkdir","dir","recursive","Promise","resolve","reject","createReadStream","pipe","Extract","on","error","Error","message","stripJsonComments","readJsonFile","filePath","createIfNotExist","dirname","content","readFile","sanitizedContent","replace","JSON","parse","code","writeJsonFile","writeFile","stringify"],"sources":["../../src/utils/clientUtils.ts"],"mappings":"OAAOA,OAAQ,wBACHC,SAAU,cACfC,qBAAsB,qBAQtBC,eAAeC,eAAeC,EAAiBC,GAClD,IAEI,GAAgC,mBAArBJ,iBACP,aAAaA,iBAAiBG,EAASC,GAI3C,MAAMN,EAAKO,QAAQ,MACbC,EAAWD,QAAQ,YAIzB,aAFMP,EAAGS,SAASC,MAAMJ,EAAQK,IAAK,CAAEC,WAAW,IAE3C,IAAIC,SAAc,CAACC,EAASC,KAC/Bf,EAAGgB,iBAAiBX,GACfY,KAAKT,EAASU,QAAQ,CAAEjB,KAAMK,EAAQK,OACtCQ,GAAG,QAASL,GACZK,GAAG,QAASJ,EAAO,GAEhC,CAAE,MAAOK,GAEL,MAAM,IAAIC,MAAM,8BAA8BhB,MAAYe,aAAiBC,MAAQD,EAAME,QAAU,kBACvG,CACJ,QASOC,sBAAuB,6BAEvBpB,eAAeqB,aAAaC,EAAkBC,GAAmB,GACpE,IAEQA,SACM1B,GAAGU,MAAMT,KAAK0B,QAAQF,GAAW,CAAEb,WAAW,IAGxD,MAAMgB,QAAgB5B,GAAG6B,SAASJ,EAAU,QAEtCK,EAAmBP,kBAAkBK,GAASG,QAAQ,eAAgB,MAC5E,OAAOC,KAAKC,MAAMH,EACtB,CAAE,MAAOV,GACL,GAA8C,WAAzCA,EAAgCc,MAAqBR,EACtD,MAAO,GAEX,MAAMN,CACV,CACJ,QAOOjB,eAAegC,cAAcV,EAAkBG,SAC5C5B,GAAGU,MAAMT,KAAK0B,QAAQF,GAAW,CAAEb,WAAW,UAC9CZ,GAAGoC,UAAUX,EAAUO,KAAKK,UAAUT,EAAS,KAAM,GAAI,OACnE","ignoreList":[]}