imcp 0.1.7 → 0.1.8

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,361 +1,2 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { SETTINGS_DIR } from '../metadatas/constants.js';
4
- import { OnboardingProcessStatus } from './OnboardStatus.js';
5
- import { Logger } from '../../utils/logger.js';
6
- import * as RecordingConstants from '../metadatas/recordingConstants.js';
7
- const ONBOARD_STATUS_DIR = path.join(SETTINGS_DIR, 'onboard');
8
- const CATEGORY_OPERATIONS_STATUS_FILE = path.join(ONBOARD_STATUS_DIR, 'OnboardStatus.json');
9
- const FEED_CONFIG_DIR = path.join(ONBOARD_STATUS_DIR, 'feed_configs'); // Staging for feed configs during operation
10
- const NON_COMPLETED_ONBOARDING_STATUSES = [
11
- OnboardingProcessStatus.PENDING,
12
- OnboardingProcessStatus.VALIDATING,
13
- OnboardingProcessStatus.VALIDATED,
14
- OnboardingProcessStatus.PR_CREATING,
15
- ];
16
- export class OnboardStatusManager {
17
- static instance;
18
- activeCategoryOperations = {};
19
- statusLock = Promise.resolve();
20
- constructor() {
21
- this.loadStatuses().catch(error => Logger.error('Failed to initialize OnboardStatusManager:', error));
22
- }
23
- static getInstance() {
24
- if (!OnboardStatusManager.instance) {
25
- OnboardStatusManager.instance = new OnboardStatusManager();
26
- }
27
- return OnboardStatusManager.instance;
28
- }
29
- async withLock(operation) {
30
- const current = this.statusLock;
31
- let resolve;
32
- this.statusLock = new Promise(r => resolve = r);
33
- try {
34
- await current;
35
- return await operation();
36
- }
37
- finally {
38
- resolve();
39
- }
40
- }
41
- async loadStatuses() {
42
- await this.withLock(async () => {
43
- try {
44
- await fs.mkdir(ONBOARD_STATUS_DIR, { recursive: true });
45
- await fs.mkdir(FEED_CONFIG_DIR, { recursive: true });
46
- const data = await fs.readFile(CATEGORY_OPERATIONS_STATUS_FILE, 'utf-8');
47
- this.activeCategoryOperations = JSON.parse(data);
48
- }
49
- catch (error) {
50
- if (error.code === 'ENOENT') {
51
- this.activeCategoryOperations = {};
52
- await this.saveStatuses(); // Create the file if it doesn't exist
53
- }
54
- else {
55
- Logger.error('Failed to load onboarding statuses:', error);
56
- this.activeCategoryOperations = {}; // Initialize with empty statuses in case of other errors
57
- }
58
- }
59
- });
60
- }
61
- async saveStatuses() {
62
- await fs.mkdir(ONBOARD_STATUS_DIR, { recursive: true });
63
- await fs.writeFile(CATEGORY_OPERATIONS_STATUS_FILE, JSON.stringify(this.activeCategoryOperations, null, 2));
64
- }
65
- /**
66
- * Saves the feed configuration associated with a category's active operation.
67
- * The operation is identified by the categoryName.
68
- * @param categoryName The name of the category (acting as operationId).
69
- * @param config The FeedConfiguration to save.
70
- */
71
- async saveFeedConfiguration(categoryName, operationType, config) {
72
- await this.withLock(async () => {
73
- try {
74
- await fs.mkdir(FEED_CONFIG_DIR, { recursive: true });
75
- // Suffix `_feed.json` to distinguish from potential status files if names overlap
76
- const operationId = this.createOperationId(categoryName, operationType);
77
- const configPath = path.join(FEED_CONFIG_DIR, `${operationId}_feed.json`);
78
- await fs.writeFile(configPath, JSON.stringify(config, null, 2));
79
- Logger.debug(`Saved feed configuration for category ${categoryName} to ${configPath}`);
80
- }
81
- catch (error) {
82
- Logger.error(`Failed to save feed configuration for category ${categoryName}:`, error);
83
- throw error; // Re-throw to allow caller to handle
84
- }
85
- });
86
- }
87
- /**
88
- * Retrieves the feed configuration associated with a category's active operation.
89
- * @param categoryName The name of the category (acting as operationId).
90
- * @returns A promise that resolves to the FeedConfiguration, or undefined if not found.
91
- */
92
- async getFeedConfiguration(categoryName, operationType) {
93
- return await this.withLock(async () => {
94
- try {
95
- const operationId = this.createOperationId(categoryName, operationType);
96
- const configPath = path.join(FEED_CONFIG_DIR, `${operationId}_feed.json`);
97
- const data = await fs.readFile(configPath, 'utf-8');
98
- return JSON.parse(data);
99
- }
100
- catch (error) {
101
- if (error.code === 'ENOENT') {
102
- return undefined; // File not found, not an error state for this getter
103
- }
104
- // Log other errors but still return undefined as the config couldn't be retrieved.
105
- Logger.error(`Failed to read feed configuration for category ${categoryName}:`, error);
106
- return undefined; // Ensure undefined is returned on other errors too
107
- }
108
- });
109
- }
110
- /**
111
- * Retrieves the status of a specific operation for a category.
112
- * @param categoryName The name of the category.
113
- * @param operationType The type of operation.
114
- * @returns A promise that resolves to the OnboardStatus, or undefined if no such operation or category.
115
- */
116
- async getStatus(categoryName, operationType) {
117
- await this.loadStatuses(); // Ensure latest statuses are loaded
118
- return this.activeCategoryOperations[categoryName]?.[operationType];
119
- }
120
- /**
121
- * Retrieves all active category operation statuses, structured by category and then by operation type.
122
- * @returns A promise that resolves to a record of all active OnboardStatus objects.
123
- */
124
- async getAllStatuses() {
125
- await this.loadStatuses();
126
- return this.activeCategoryOperations;
127
- }
128
- /**
129
- * Updates the status of a specific operation for a category.
130
- * If a `stepName` is provided in `updates`, it will also add a new step.
131
- * @param categoryName The name of the category.
132
- * @param operationType The type of operation.
133
- * @param updates Partial OnboardStatus object with fields to update. Can include `stepName` to record a new step.
134
- * @param stepName Optional. If provided, a new step with this name will be recorded.
135
- * @param stepStatus Optional. Status for the new step, if `stepName` is provided.
136
- * @param errorMessage Optional. Error message for the new step, if `stepName` is provided.
137
- * @returns A promise that resolves to the updated OnboardStatus.
138
- */
139
- async updateStatus(categoryName, operationType, updates, // Exclude steps from direct updates here
140
- stepName, stepStatus, errorMessage) {
141
- return await this.withLock(async () => {
142
- const operationId = this.createOperationId(categoryName, operationType);
143
- const categoryOps = this.activeCategoryOperations[categoryName] || {};
144
- let existingStatus = categoryOps[operationType];
145
- if (!existingStatus) {
146
- // If no status exists, create an initial one.
147
- // This might happen if updateStatus is called before createInitialStatus,
148
- // though ideally createInitialStatus should be the entry point.
149
- existingStatus = {
150
- onboardingId: operationId,
151
- feedName: categoryName,
152
- status: updates.status || OnboardingProcessStatus.PENDING,
153
- lastUpdated: new Date().toISOString(),
154
- operationType: operationType,
155
- steps: [],
156
- };
157
- }
158
- // Apply general updates
159
- let updatedStatus = {
160
- ...existingStatus,
161
- ...updates,
162
- onboardingId: operationId,
163
- feedName: categoryName,
164
- operationType: operationType,
165
- lastUpdated: new Date().toISOString(),
166
- };
167
- // If stepName is provided, add it as a new step
168
- if (stepName) {
169
- const newStep = {
170
- stepName,
171
- timestamp: new Date().toISOString(),
172
- status: stepStatus ?? updates.status ?? existingStatus.status,
173
- errorMessage: errorMessage ?? updates.errorMessage,
174
- };
175
- updatedStatus.steps = [...(existingStatus.steps || []), newStep];
176
- // If the step has a specific status, it might also update the overall status
177
- if (newStep.status && newStep.status !== updatedStatus.status) {
178
- updatedStatus.status = newStep.status;
179
- }
180
- if (newStep.errorMessage && !updatedStatus.errorMessage) {
181
- updatedStatus.errorMessage = newStep.errorMessage;
182
- }
183
- }
184
- categoryOps[operationType] = updatedStatus;
185
- this.activeCategoryOperations[categoryName] = categoryOps;
186
- await this.saveStatuses();
187
- return updatedStatus;
188
- });
189
- }
190
- /**
191
- * A more specific method to record a step, which can also update the overall status.
192
- * This is intended to replace the local `updateStatus` functions in validators/services.
193
- * @param categoryName The name of the category (e.g., feed name).
194
- * @param operationType The type of operation.
195
- * @param stepName The description of the current step.
196
- * @param serverName Optional server context for this step.
197
- * @param newStatus Optional overall status to set for the operation.
198
- * @param errorMessage Optional error message if this step resulted in a failure.
199
- * @returns A promise that resolves to the updated OnboardStatus.
200
- */
201
- async recordStep(categoryName, operationType, stepName, serverName, // Added serverName to be part of the step if relevant
202
- newStatus, errorMessage) {
203
- return await this.withLock(async () => {
204
- const operationId = this.createOperationId(categoryName, operationType);
205
- const categoryOps = this.activeCategoryOperations[categoryName] || {};
206
- let currentStatus = categoryOps[operationType];
207
- if (!currentStatus) {
208
- currentStatus = await this.createInitialStatus(categoryName, operationType, serverName);
209
- }
210
- const stepToAdd = {
211
- stepName,
212
- timestamp: new Date().toISOString(),
213
- status: newStatus ?? (errorMessage ? OnboardingProcessStatus.FAILED : currentStatus.status), // Step inherits current or becomes FAILED
214
- errorMessage: errorMessage,
215
- ...(serverName && { serverName }), // Include serverName in the step if provided
216
- };
217
- const updatedSteps = [...(currentStatus.steps || []), stepToAdd];
218
- const statusUpdatePayload = {
219
- steps: updatedSteps,
220
- lastUpdated: new Date().toISOString(),
221
- };
222
- if (newStatus) {
223
- statusUpdatePayload.status = newStatus;
224
- }
225
- else if (errorMessage && currentStatus.status !== OnboardingProcessStatus.FAILED) {
226
- // If an error occurs and we're not already FAILED, mark as FAILED.
227
- statusUpdatePayload.status = OnboardingProcessStatus.FAILED;
228
- }
229
- if (errorMessage && !currentStatus.errorMessage) { // Store the first error message
230
- statusUpdatePayload.errorMessage = errorMessage;
231
- }
232
- if (serverName && !currentStatus.serverName) { // Store serverName if not already set at top level
233
- statusUpdatePayload.serverName = serverName;
234
- }
235
- const updatedStatus = {
236
- ...currentStatus,
237
- ...statusUpdatePayload,
238
- };
239
- categoryOps[operationType] = updatedStatus;
240
- this.activeCategoryOperations[categoryName] = categoryOps;
241
- await this.saveStatuses();
242
- return updatedStatus;
243
- });
244
- }
245
- /**
246
- * Creates an operation ID that combines category name and operation type.
247
- * @param categoryName The name of the category.
248
- * @param operationType The type of operation.
249
- * @returns Combined operation ID string.
250
- */
251
- createOperationId(categoryName, operationType) {
252
- return `${categoryName}_${operationType}`;
253
- }
254
- /**
255
- * Creates an initial status for a new category-wide operation.
256
- * The operation is identified by the categoryName.
257
- * @param categoryName The name of the category (also used as feedName and operationId).
258
- * @param operationType The type of operation (e.g., FULL_ONBOARDING, VALIDATION_ONLY).
259
- * @param serverName Optional: if the operation has a specific server context (e.g. validating a single new server in an existing category).
260
- * However, the primary operation tracking is still by categoryName.
261
- * @returns A promise that resolves to the initial OnboardStatus.
262
- */
263
- async createInitialStatus(categoryName, operationType, serverName) {
264
- // Create operation ID that includes both category and operation type
265
- const operationId = this.createOperationId(categoryName, operationType);
266
- const initialStatus = {
267
- onboardingId: operationId,
268
- feedName: categoryName,
269
- serverName,
270
- status: OnboardingProcessStatus.PENDING,
271
- steps: [{ stepName: RecordingConstants.STEP_INITIATED, timestamp: new Date().toISOString() }],
272
- lastUpdated: new Date().toISOString(),
273
- operationType,
274
- errorMessage: undefined,
275
- prInfo: undefined
276
- };
277
- // Save directly without using updateStatus, into the new structure
278
- await this.withLock(async () => {
279
- const categoryOps = this.activeCategoryOperations[categoryName] || {};
280
- categoryOps[operationType] = initialStatus;
281
- this.activeCategoryOperations[categoryName] = categoryOps;
282
- await this.saveStatuses();
283
- });
284
- return initialStatus;
285
- }
286
- /**
287
- * Finds a succeeded operation for a given feed name and operation type that has a matching feed configuration.
288
- * @param feedName The name of the feed.
289
- * @param operationType The type of operation.
290
- * @param currentConfig The current feed configuration to compare against.
291
- * @returns A promise that resolves to the OnboardStatus of the succeeded operation, or undefined if not found.
292
- */
293
- async findSucceededOperation(feedName, operationType, currentConfig) {
294
- return await this.withLock(async () => {
295
- for (const categoryName in this.activeCategoryOperations) {
296
- const operations = this.activeCategoryOperations[categoryName];
297
- if (operations) {
298
- const specificOperationStatus = operations[operationType];
299
- if (specificOperationStatus &&
300
- specificOperationStatus.feedName === feedName &&
301
- specificOperationStatus.status === OnboardingProcessStatus.SUCCEEDED) {
302
- // The FeedConfiguration is stored in the result of the SUCCEEDED operation
303
- const savedConfig = specificOperationStatus.result?.feedConfiguration;
304
- if (savedConfig && this.isFeedConfigurationEqual(savedConfig, currentConfig)) {
305
- return specificOperationStatus;
306
- }
307
- }
308
- }
309
- }
310
- return undefined;
311
- });
312
- }
313
- /**
314
- * Compares two feed configurations for equality.
315
- * @param config1 First feed configuration.
316
- * @param config2 Second feed configuration.
317
- * @returns True if the configurations are identical, false otherwise.
318
- */
319
- isFeedConfigurationEqual(config1, config2) {
320
- // Compare basic properties
321
- if (config1.name !== config2.name)
322
- return false;
323
- // Compare arrays with specific order handling
324
- const compareArrays = (arr1, arr2, sortFn) => {
325
- if (arr1.length !== arr2.length)
326
- return false;
327
- const sorted1 = sortFn ? [...arr1].sort(sortFn) : arr1;
328
- const sorted2 = sortFn ? [...arr2].sort(sortFn) : arr2;
329
- return JSON.stringify(sorted1) === JSON.stringify(sorted2);
330
- };
331
- // Compare requirements array
332
- if (!compareArrays(config1.requirements || [], config2.requirements || []))
333
- return false;
334
- // Compare MCP servers with name-based sorting
335
- const sortByName = (a, b) => (a.name || '').localeCompare(b.name || '');
336
- if (!compareArrays(config1.mcpServers || [], config2.mcpServers || [], sortByName))
337
- return false;
338
- return true;
339
- }
340
- /**
341
- * Finds an existing non-completed operation for a given feed name, server name, and operation type.
342
- * @param feedName The name of the feed.
343
- * @param operationType The type of operation.
344
- * @returns A promise that resolves to the OnboardStatus of the existing operation, or undefined if not found.
345
- */
346
- async _findExistingNonCompletedOperation(feedName, operationType) {
347
- const allCategoryStatuses = await this.getAllStatuses();
348
- // feedName is the categoryName
349
- const categoryOperations = allCategoryStatuses[feedName];
350
- if (categoryOperations) {
351
- const specificOperationStatus = categoryOperations[operationType];
352
- if (specificOperationStatus && NON_COMPLETED_ONBOARDING_STATUSES.includes(specificOperationStatus.status)) {
353
- return specificOperationStatus;
354
- }
355
- }
356
- return undefined;
357
- }
358
- }
359
- // Export singleton instance
360
- export const onboardStatusManager = OnboardStatusManager.getInstance();
1
+ import fs from"fs/promises";import path from"path";import{SETTINGS_DIR}from"../metadatas/constants.js";import{OnboardingProcessStatus}from"./OnboardStatus.js";import{Logger}from"../../utils/logger.js";import*as RecordingConstants from"../metadatas/recordingConstants.js";const ONBOARD_STATUS_DIR=path.join(SETTINGS_DIR,"onboard"),CATEGORY_OPERATIONS_STATUS_FILE=path.join(ONBOARD_STATUS_DIR,"OnboardStatus.json"),FEED_CONFIG_DIR=path.join(ONBOARD_STATUS_DIR,"feed_configs"),NON_COMPLETED_ONBOARDING_STATUSES=[OnboardingProcessStatus.PENDING,OnboardingProcessStatus.VALIDATING,OnboardingProcessStatus.VALIDATED,OnboardingProcessStatus.PR_CREATING];export class OnboardStatusManager{static instance;activeCategoryOperations={};statusLock=Promise.resolve();constructor(){this.loadStatuses().catch((t=>Logger.error("Failed to initialize OnboardStatusManager:",t)))}static getInstance(){return OnboardStatusManager.instance||(OnboardStatusManager.instance=new OnboardStatusManager),OnboardStatusManager.instance}async withLock(t){const a=this.statusLock;let e;this.statusLock=new Promise((t=>e=t));try{return await a,await t()}finally{e()}}async loadStatuses(){await this.withLock((async()=>{try{await fs.mkdir(ONBOARD_STATUS_DIR,{recursive:!0}),await fs.mkdir(FEED_CONFIG_DIR,{recursive:!0});const t=await fs.readFile(CATEGORY_OPERATIONS_STATUS_FILE,"utf-8");this.activeCategoryOperations=JSON.parse(t)}catch(t){"ENOENT"===t.code?(this.activeCategoryOperations={},await this.saveStatuses()):(Logger.error("Failed to load onboarding statuses:",t),this.activeCategoryOperations={})}}))}async saveStatuses(){await fs.mkdir(ONBOARD_STATUS_DIR,{recursive:!0}),await fs.writeFile(CATEGORY_OPERATIONS_STATUS_FILE,JSON.stringify(this.activeCategoryOperations,null,2))}async saveFeedConfiguration(t,a,e){await this.withLock((async()=>{try{await fs.mkdir(FEED_CONFIG_DIR,{recursive:!0});const s=this.createOperationId(t,a),r=path.join(FEED_CONFIG_DIR,`${s}_feed.json`);await fs.writeFile(r,JSON.stringify(e,null,2)),Logger.debug(`Saved feed configuration for category ${t} to ${r}`)}catch(a){throw Logger.error(`Failed to save feed configuration for category ${t}:`,a),a}}))}async getFeedConfiguration(t,a){return await this.withLock((async()=>{try{const e=this.createOperationId(t,a),s=path.join(FEED_CONFIG_DIR,`${e}_feed.json`),r=await fs.readFile(s,"utf-8");return JSON.parse(r)}catch(a){if("ENOENT"===a.code)return;return void Logger.error(`Failed to read feed configuration for category ${t}:`,a)}}))}async getStatus(t,a){return await this.loadStatuses(),this.activeCategoryOperations[t]?.[a]}async getAllStatuses(){return await this.loadStatuses(),this.activeCategoryOperations}async updateStatus(t,a,e,s,r,i){return await this.withLock((async()=>{const o=this.createOperationId(t,a),n=this.activeCategoryOperations[t]||{};let c=n[a];c||(c={onboardingId:o,feedName:t,status:e.status||OnboardingProcessStatus.PENDING,lastUpdated:(new Date).toISOString(),operationType:a,steps:[]});let u={...c,...e,onboardingId:o,feedName:t,operationType:a,lastUpdated:(new Date).toISOString()};if(s){const t={stepName:s,timestamp:(new Date).toISOString(),status:r??e.status??c.status,errorMessage:i??e.errorMessage};u.steps=[...c.steps||[],t],t.status&&t.status!==u.status&&(u.status=t.status),t.errorMessage&&!u.errorMessage&&(u.errorMessage=t.errorMessage)}return n[a]=u,this.activeCategoryOperations[t]=n,await this.saveStatuses(),u}))}async recordStep(t,a,e,s,r,i){return await this.withLock((async()=>{this.createOperationId(t,a);const o=this.activeCategoryOperations[t]||{};let n=o[a];n||(n=await this.createInitialStatus(t,a,s));const c={stepName:e,timestamp:(new Date).toISOString(),status:r??(i?OnboardingProcessStatus.FAILED:n.status),errorMessage:i,...s&&{serverName:s}},u={steps:[...n.steps||[],c],lastUpdated:(new Date).toISOString()};r?u.status=r:i&&n.status!==OnboardingProcessStatus.FAILED&&(u.status=OnboardingProcessStatus.FAILED),i&&!n.errorMessage&&(u.errorMessage=i),s&&!n.serverName&&(u.serverName=s);const g={...n,...u};return o[a]=g,this.activeCategoryOperations[t]=o,await this.saveStatuses(),g}))}createOperationId(t,a){return`${t}_${a}`}async createInitialStatus(t,a,e){const s={onboardingId:this.createOperationId(t,a),feedName:t,serverName:e,status:OnboardingProcessStatus.PENDING,steps:[{stepName:RecordingConstants.STEP_INITIATED,timestamp:(new Date).toISOString()}],lastUpdated:(new Date).toISOString(),operationType:a,errorMessage:void 0,prInfo:void 0};return await this.withLock((async()=>{const e=this.activeCategoryOperations[t]||{};e[a]=s,this.activeCategoryOperations[t]=e,await this.saveStatuses()})),s}async findSucceededOperation(t,a,e){return await this.withLock((async()=>{for(const s in this.activeCategoryOperations){const r=this.activeCategoryOperations[s];if(r){const s=r[a];if(s&&s.feedName===t&&s.status===OnboardingProcessStatus.SUCCEEDED){const t=s.result?.feedConfiguration;if(t&&this.isFeedConfigurationEqual(t,e))return s}}}}))}isFeedConfigurationEqual(t,a){if(t.name!==a.name)return!1;const e=(t,a,e)=>{if(t.length!==a.length)return!1;const s=e?[...t].sort(e):t,r=e?[...a].sort(e):a;return JSON.stringify(s)===JSON.stringify(r)};return!!e(t.requirements||[],a.requirements||[])&&!!e(t.mcpServers||[],a.mcpServers||[],((t,a)=>(t.name||"").localeCompare(a.name||"")))}async _findExistingNonCompletedOperation(t,a){const e=(await this.getAllStatuses())[t];if(e){const t=e[a];if(t&&NON_COMPLETED_ONBOARDING_STATUSES.includes(t.status))return t}}}export const onboardStatusManager=OnboardStatusManager.getInstance();
361
2
  //# sourceMappingURL=OnboardStatusManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","path","SETTINGS_DIR","OnboardingProcessStatus","Logger","RecordingConstants","ONBOARD_STATUS_DIR","join","CATEGORY_OPERATIONS_STATUS_FILE","FEED_CONFIG_DIR","NON_COMPLETED_ONBOARDING_STATUSES","PENDING","VALIDATING","VALIDATED","PR_CREATING","OnboardStatusManager","static","activeCategoryOperations","statusLock","Promise","resolve","constructor","this","loadStatuses","catch","error","getInstance","instance","withLock","operation","current","r","async","mkdir","recursive","data","readFile","JSON","parse","code","saveStatuses","writeFile","stringify","saveFeedConfiguration","categoryName","operationType","config","operationId","createOperationId","configPath","debug","getFeedConfiguration","getStatus","getAllStatuses","updateStatus","updates","stepName","stepStatus","errorMessage","categoryOps","existingStatus","onboardingId","feedName","status","lastUpdated","Date","toISOString","steps","updatedStatus","newStep","timestamp","recordStep","serverName","newStatus","currentStatus","createInitialStatus","stepToAdd","FAILED","statusUpdatePayload","initialStatus","STEP_INITIATED","undefined","prInfo","findSucceededOperation","currentConfig","operations","specificOperationStatus","SUCCEEDED","savedConfig","result","feedConfiguration","isFeedConfigurationEqual","config1","config2","name","compareArrays","arr1","arr2","sortFn","length","sorted1","sort","sorted2","requirements","mcpServers","a","b","localeCompare","_findExistingNonCompletedOperation","categoryOperations","includes","onboardStatusManager"],"sources":["../../../src/core/onboard/OnboardStatusManager.ts"],"mappings":"OAAOA,OAAQ,qBACRC,SAAU,cACRC,iBAAoB,mCAELC,4BAA8C,4BAC7DC,WAAc,kCAEXC,uBAAwB,qCACpC,MAAMC,mBAAqBL,KAAKM,KAAKL,aAAc,WAC7CM,gCAAkCP,KAAKM,KAAKD,mBAAoB,sBAChEG,gBAAkBR,KAAKM,KAAKD,mBAAoB,gBAEhDI,kCAA+D,CACnEP,wBAAwBQ,QACxBR,wBAAwBS,WACxBT,wBAAwBU,UACxBV,wBAAwBW,oBAGpB,MAAOC,qBACHC,gBACAC,yBAA0F,GAC1FC,WAA4BC,QAAQC,UAE5C,WAAAC,GACEC,KAAKC,eAAeC,OAAMC,GAASrB,OAAOqB,MAAM,6CAA8CA,IAChG,CAEO,kBAAOC,GAIZ,OAHKX,qBAAqBY,WACxBZ,qBAAqBY,SAAW,IAAIZ,sBAE/BA,qBAAqBY,QA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SAASxB,EAAwBvB,QAChG,OAAOuB,CAEX,CAEF,SAIK,MAAMyB,qBAAuBhG,qBAAqBW","ignoreList":[]}
@@ -1,134 +1,2 @@
1
- import fs from 'fs/promises';
2
- import { serverValidatorFactory } from "./ServerValidatorFactory.js";
3
- import { Logger } from "../../utils/logger.js";
4
- import { onboardStatusManager } from "../onboard/OnboardStatusManager.js";
5
- import { OnboardingProcessStatus } from "../onboard/OnboardStatus.js";
6
- /**
7
- * Validates feed configurations to ensure they meet required criteria
8
- */
9
- export class FeedValidator {
10
- /**
11
- * Validates a feed configuration
12
- * @param config The feed configuration to validate
13
- * @param categoryName The name of the category (feed name) for status updates
14
- * @param operationType The type of operation for status updates
15
- * @returns true if valid, throws error if invalid
16
- */
17
- async validate(config, categoryName, operationType) {
18
- try {
19
- await onboardStatusManager.recordStep(categoryName, operationType, `Starting feed validation for '${config.name}'`);
20
- Logger.debug(`Validating feed configuration: ${config.name}`);
21
- // Validate required fields
22
- await onboardStatusManager.recordStep(categoryName, operationType, `Validating required fields for '${config.name}'`);
23
- if (!config.name)
24
- throw new Error('Feed name is required');
25
- if (!config.displayName)
26
- throw new Error('Feed display name is required');
27
- if (!config.description)
28
- throw new Error('Feed description is required');
29
- // Validate MCP servers array
30
- await onboardStatusManager.recordStep(categoryName, operationType, `Validating MCP servers array for '${config.name}'`);
31
- if (!Array.isArray(config.mcpServers) || config.mcpServers.length === 0) {
32
- throw new Error('Feed must contain at least one MCP server');
33
- }
34
- // Validate requirements if present
35
- if (config.requirements) {
36
- await onboardStatusManager.recordStep(categoryName, operationType, `Validating requirements for '${config.name}'`);
37
- for (const req of config.requirements) {
38
- if (!req.name)
39
- throw new Error('Requirement name is required');
40
- if (!req.type)
41
- throw new Error('Requirement type is required');
42
- if (!req.version)
43
- throw new Error('Requirement version is required');
44
- }
45
- }
46
- await onboardStatusManager.recordStep(categoryName, operationType, `Feed validation successful for '${config.name}'`, undefined, OnboardingProcessStatus.VALIDATING); // Still in progress until all servers validated
47
- Logger.debug(`Feed configuration validation successful: ${config.name}`);
48
- return true;
49
- }
50
- catch (error) {
51
- const errorMsg = `Feed validation failed for '${config.name}': ${error instanceof Error ? error.message : String(error)}`;
52
- Logger.error(errorMsg);
53
- await onboardStatusManager.recordStep(categoryName, operationType, `Feed validation failed for '${config.name}'`, undefined, OnboardingProcessStatus.FAILED, errorMsg);
54
- throw new Error(errorMsg);
55
- }
56
- }
57
- /**
58
- * Validates a single MCP server configuration using the appropriate validator
59
- * @param server The MCP server configuration to validate
60
- * @param config The feed configuration containing shared requirements
61
- * @param categoryName The name of the category (feed name) for status updates
62
- * @param operationType The type of operation for status updates
63
- * @returns true if valid, throws error if invalid
64
- */
65
- async validateServer(server, config, categoryName, operationType) {
66
- const feedName = config.name; // categoryName is the feedName in this context
67
- const serverDisplayName = server.name;
68
- try {
69
- await onboardStatusManager.recordStep(categoryName, operationType, `Starting server validation for '${serverDisplayName}' in feed '${feedName}'`, server.name);
70
- Logger.debug(`Validating server configuration: ${serverDisplayName} in feed ${feedName}`);
71
- // Validate basic required fields
72
- await onboardStatusManager.recordStep(categoryName, operationType, `Validating basic fields for server '${serverDisplayName}'`, server.name);
73
- if (!server.name)
74
- throw new Error('Server name is required');
75
- if (!server.description)
76
- throw new Error('Server description is required');
77
- if (!server.mode)
78
- throw new Error('Server mode is required');
79
- if (!server.installation)
80
- throw new Error('Server installation configuration is required');
81
- // Validate schema file existence if schemas is defined
82
- if (server.schemas) {
83
- await onboardStatusManager.recordStep(categoryName, operationType, `Validating schema file for server '${serverDisplayName}'`, server.name);
84
- try {
85
- // Assuming server.schemas is a relative path from the project root or a path that needs to be resolved.
86
- // For now, let's assume it's relative to the feed file's location or an absolute path.
87
- // If it's relative to the feed file, we might need the feed file's path.
88
- // For simplicity, let's assume it's a path that can be directly accessed.
89
- // If the schema path is relative to the feed config file, this logic will need adjustment.
90
- // For now, we'll treat it as a path that `fs.access` can check.
91
- // It's more likely that schema paths are relative to the feed definition file itself.
92
- // However, the task description implies `server.schemas` is a path to be checked.
93
- // Let's assume for now it's a path that should exist.
94
- // If the schemas are stored within the repo, their paths would be relative to the repo root.
95
- // During validation, we might not have the repo context directly here.
96
- // This needs clarification on how schema paths are resolved during validation.
97
- // For now, we'll proceed with a direct check.
98
- // If the schema is part of the feed package, its path might be relative to the package root.
99
- // Let's assume the path is resolvable from the current working directory or is absolute.
100
- // This part might need refinement based on where schema files are expected to be.
101
- // The task implies `server.schemas` is a string path.
102
- const schemaPath = server.schemas; // This path needs to be correctly resolved.
103
- // If it's relative to the feed file, we need that context.
104
- // For now, we'll assume it's a path that can be checked.
105
- // This might be an issue if it's relative to a file not yet in the repo.
106
- // Let's assume it's a path that should be resolvable.
107
- await fs.access(schemaPath);
108
- Logger.debug(`Schema file ${schemaPath} exists for server ${serverDisplayName}`);
109
- }
110
- catch (fileAccessError) {
111
- throw new Error(`Schema file '${server.schemas}' not found for server '${serverDisplayName}'.`);
112
- }
113
- }
114
- // Get the appropriate validator for this server type
115
- await onboardStatusManager.recordStep(categoryName, operationType, `Obtaining specific validator for server '${serverDisplayName}'`, server.name);
116
- const validator = serverValidatorFactory.getValidatorForServer(server);
117
- // Perform mode-specific validation with feed config
118
- await onboardStatusManager.recordStep(categoryName, operationType, `Performing mode-specific validation for server '${serverDisplayName}'`, server.name);
119
- await validator.validateServer(server, config); // This internal call won't have status updates unless modified too
120
- await onboardStatusManager.recordStep(categoryName, operationType, `Server validation successful for '${serverDisplayName}'`, server.name, OnboardingProcessStatus.VALIDATING); // Still in progress until all servers validated
121
- Logger.debug(`Server configuration validation successful: ${serverDisplayName}`);
122
- return true;
123
- }
124
- catch (error) {
125
- const errorMsg = `Server validation failed for '${serverDisplayName}' in feed '${feedName}': ${error instanceof Error ? error.message : String(error)}`;
126
- Logger.error(errorMsg);
127
- await onboardStatusManager.recordStep(categoryName, operationType, `Server validation failed for '${serverDisplayName}'`, server.name, OnboardingProcessStatus.FAILED, errorMsg);
128
- throw new Error(errorMsg);
129
- }
130
- }
131
- }
132
- // Export singleton instance
133
- export const feedValidator = new FeedValidator();
1
+ import fs from"fs/promises";import{serverValidatorFactory}from"./ServerValidatorFactory.js";import{Logger}from"../../utils/logger.js";import{onboardStatusManager}from"../onboard/OnboardStatusManager.js";import{OnboardingProcessStatus}from"../onboard/OnboardStatus.js";export class FeedValidator{async validate(r,e,a){try{if(await onboardStatusManager.recordStep(e,a,`Starting feed validation for '${r.name}'`),Logger.debug(`Validating feed configuration: ${r.name}`),await onboardStatusManager.recordStep(e,a,`Validating required fields for '${r.name}'`),!r.name)throw new Error("Feed name is required");if(!r.displayName)throw new Error("Feed display name is required");if(!r.description)throw new Error("Feed description is required");if(await onboardStatusManager.recordStep(e,a,`Validating MCP servers array for '${r.name}'`),!Array.isArray(r.mcpServers)||0===r.mcpServers.length)throw new Error("Feed must contain at least one MCP server");if(r.requirements){await onboardStatusManager.recordStep(e,a,`Validating requirements for '${r.name}'`);for(const e of r.requirements){if(!e.name)throw new Error("Requirement name is required");if(!e.type)throw new Error("Requirement type is required");if(!e.version)throw new Error("Requirement version is required")}}return await onboardStatusManager.recordStep(e,a,`Feed validation successful for '${r.name}'`,void 0,OnboardingProcessStatus.VALIDATING),Logger.debug(`Feed configuration validation successful: ${r.name}`),!0}catch(o){const t=`Feed validation failed for '${r.name}': ${o instanceof Error?o.message:String(o)}`;throw Logger.error(t),await onboardStatusManager.recordStep(e,a,`Feed validation failed for '${r.name}'`,void 0,OnboardingProcessStatus.FAILED,t),new Error(t)}}async validateServer(r,e,a,o){const t=e.name,i=r.name;try{if(await onboardStatusManager.recordStep(a,o,`Starting server validation for '${i}' in feed '${t}'`,r.name),Logger.debug(`Validating server configuration: ${i} in feed ${t}`),await onboardStatusManager.recordStep(a,o,`Validating basic fields for server '${i}'`,r.name),!r.name)throw new Error("Server name is required");if(!r.description)throw new Error("Server description is required");if(!r.mode)throw new Error("Server mode is required");if(!r.installation)throw new Error("Server installation configuration is required");if(r.schemas){await onboardStatusManager.recordStep(a,o,`Validating schema file for server '${i}'`,r.name);try{const e=r.schemas;await fs.access(e),Logger.debug(`Schema file ${e} exists for server ${i}`)}catch(e){throw new Error(`Schema file '${r.schemas}' not found for server '${i}'.`)}}await onboardStatusManager.recordStep(a,o,`Obtaining specific validator for server '${i}'`,r.name);const n=serverValidatorFactory.getValidatorForServer(r);return await onboardStatusManager.recordStep(a,o,`Performing mode-specific validation for server '${i}'`,r.name),await n.validateServer(r,e),await onboardStatusManager.recordStep(a,o,`Server validation successful for '${i}'`,r.name,OnboardingProcessStatus.VALIDATING),Logger.debug(`Server configuration validation successful: ${i}`),!0}catch(e){const n=`Server validation failed for '${i}' in feed '${t}': ${e instanceof Error?e.message:String(e)}`;throw Logger.error(n),await onboardStatusManager.recordStep(a,o,`Server validation failed for '${i}'`,r.name,OnboardingProcessStatus.FAILED,n),new Error(n)}}}export const feedValidator=new FeedValidator;
134
2
  //# sourceMappingURL=FeedValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","serverValidatorFactory","Logger","onboardStatusManager","OnboardingProcessStatus","FeedValidator","validate","config","categoryName","operationType","recordStep","name","debug","Error","displayName","description","Array","isArray","mcpServers","length","requirements","req","type","version","undefined","VALIDATING","error","errorMsg","message","String","FAILED","validateServer","server","feedName","serverDisplayName","mode","installation","schemas","schemaPath","access","fileAccessError","validator","getValidatorForServer","feedValidator"],"sources":["../../../src/core/validators/FeedValidator.ts"],"mappings":"OAAOA,OAAQ,qBAGNC,2BAA8B,qCAC9BC,WAAc,+BACdC,yBAA4B,4CAC5BC,4BAA8C,qCAKjD,MAAOC,cAQJ,cAAMC,CAASC,EAA2BC,EAAsBC,GACrE,IAME,SALMN,qBAAqBO,WAAWF,EAAcC,EAAe,iCAAiCF,EAAOI,SAC3GT,OAAOU,MAAM,kCAAkCL,EAAOI,cAGhDR,qBAAqBO,WAAWF,EAAcC,EAAe,mCAAmCF,EAAOI,UACxGJ,EAAOI,KAAM,MAAM,IAAIE,MAAM,yBAClC,IAAKN,EAAOO,YAAa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B,YAAa,MAAM,IAAIF,MAAM,kCACzC,IAAKmB,EAAOG,KAAM,MAAM,IAAItB,MAAM,2BAClC,IAAKmB,EAAOI,aAAc,MAAM,IAAIvB,MAAM,iDAG1C,GAAImB,EAAOK,QAAS,OACZlC,qBAAqBO,WAAWF,EAAcC,EAAe,sCAAsCyB,KAAsBF,EAAOrB,MACtI,IAkBE,MAAM2B,EAAaN,EAAOK,cAKpBrC,GAAGuC,OAAOD,GAChBpC,OAAOU,MAAM,eAAe0B,uBAAgCJ,IAC9D,CAAE,MAAOM,GACP,MAAM,IAAI3B,MAAM,gBAAgBmB,EAAOK,kCAAkCH,MAC3E,CACF,OAGM/B,qBAAqBO,WAAWF,EAAcC,EAAe,4CAA4CyB,KAAsBF,EAAOrB,MAC5I,MAAM8B,EAAYxC,uBAAuByC,sBAAsBV,GAQ/D,aALM7B,qBAAqBO,WAAWF,EAAcC,EAAe,mDAAmDyB,KAAsBF,EAAOrB,YAC7I8B,EAAUV,eAAeC,EAAQzB,SAEjCJ,qBAAqBO,WAAWF,EAAcC,EAAe,qCAAqCyB,KAAsBF,EAAOrB,KAAMP,wBAAwBqB,YACnKvB,OAAOU,MAAM,+CAA+CsB,MACrD,CACT,CAAE,MAAOR,GACP,MAAMC,EAAW,iCAAiCO,eAA+BD,OAAcP,aAAiBb,MAAQa,EAAME,QAAUC,OAAOH,KAG/I,MAFAxB,OAAOwB,MAAMC,SACPxB,qBAAqBO,WAAWF,EAAcC,EAAe,iCAAiCyB,KAAsBF,EAAOrB,KAAMP,wBAAwB0B,OAAQH,GACjK,IAAId,MAAMc,EAClB,CACF,SAIK,MAAMgB,cAAgB,IAAItC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- export {};
1
+ export{};
2
2
  //# sourceMappingURL=IServerValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":[],"mappings":"","ignoreList":[]}
@@ -1,39 +1,2 @@
1
- import { Logger } from "../../utils/logger.js";
2
- /**
3
- * Validates MCP server configurations for SSE mode
4
- */
5
- export class SSEServerValidator {
6
- /**
7
- * Validates SSE-specific MCP server configuration
8
- * Checks installation URL, requirements, and environment variables
9
- * @param server The MCP server configuration to validate
10
- * @param config The feed configuration containing shared requirements
11
- * @returns true if valid, throws error if invalid
12
- */
13
- async validateServer(server, config) {
14
- try {
15
- Logger.debug(`Validating SSE server configuration: ${server.name}`);
16
- if (!server.installation?.url) {
17
- throw new Error('SSE server URL is required in installation configuration');
18
- }
19
- try {
20
- new URL(server.installation.url);
21
- }
22
- catch (e) {
23
- throw new Error(`Invalid SSE server URL: ${server.installation.url}`);
24
- }
25
- // Validate server mode
26
- if (server.mode !== 'sse') {
27
- throw new Error(`Invalid server mode for SSE validator: ${server.mode}`);
28
- }
29
- // Additional SSE-specific validation will be implemented later
30
- return true;
31
- }
32
- catch (error) {
33
- const errorMsg = `Server validation failed: ${error instanceof Error ? error.message : String(error)}`;
34
- Logger.error(errorMsg);
35
- throw new Error(errorMsg);
36
- }
37
- }
38
- }
1
+ import{Logger}from"../../utils/logger.js";export class SSEServerValidator{async validateServer(r,e){try{if(Logger.debug(`Validating SSE server configuration: ${r.name}`),!r.installation?.url)throw new Error("SSE server URL is required in installation configuration");try{new URL(r.installation.url)}catch(e){throw new Error(`Invalid SSE server URL: ${r.installation.url}`)}if("sse"!==r.mode)throw new Error(`Invalid server mode for SSE validator: ${r.mode}`);return!0}catch(r){const e=`Server validation failed: ${r instanceof Error?r.message:String(r)}`;throw Logger.error(e),new Error(e)}}}
39
2
  //# sourceMappingURL=SSEServerValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Logger","SSEServerValidator","validateServer","server","config","debug","name","installation","url","Error","URL","e","mode","error","errorMsg","message","String"],"sources":["../../../src/core/validators/SSEServerValidator.ts"],"mappings":"OAESA,WAAc,+BAKjB,MAAOC,mBAQJ,oBAAMC,CAAeC,EAAmBC,GAC7C,IAGE,GAFAJ,OAAOK,MAAM,wCAAwCF,EAAOG,SAEvDH,EAAOI,cAAcC,IACxB,MAAM,IAAIC,MAAM,4DAGlB,IACE,IAAIC,IAAIP,EAAOI,aAAaC,IAC9B,CAAE,MAAOG,GACP,MAAM,IAAIF,MAAM,2BAA2BN,EAAOI,aAAaC,MACjE,CAGA,GAAoB,QAAhBL,EAAOS,KACT,MAAM,IAAIH,MAAM,0CAA0CN,EAAOS,QAInE,OAAO,CACT,CAAE,MAAOC,GACP,MAAMC,EAAW,6BAA6BD,aAAiBJ,MAAQI,EAAME,QAAUC,OAAOH,KAE9F,MADAb,OAAOa,MAAMC,GACP,IAAIL,MAAMK,EAClB,CACF","ignoreList":[]}
@@ -1,45 +1,2 @@
1
- import { StdioServerValidator } from "./StdioServerValidator.js";
2
- import { SSEServerValidator } from "./SSEServerValidator.js";
3
- import { Logger } from "../../utils/logger.js";
4
- /**
5
- * Factory class for managing server validator instances
6
- * Maintains a singleton map of validators by type
7
- */
8
- export class ServerValidatorFactory {
9
- static validators = new Map();
10
- constructor() {
11
- // Initialize validators if not already done
12
- if (ServerValidatorFactory.validators.size === 0) {
13
- Logger.debug('Initializing server validators');
14
- ServerValidatorFactory.validators.set('stdio', new StdioServerValidator());
15
- ServerValidatorFactory.validators.set('sse', new SSEServerValidator());
16
- }
17
- }
18
- /**
19
- * Gets the appropriate validator for the given server mode
20
- * @param mode The server mode to get validator for
21
- * @returns IServerValidator instance for the specified mode
22
- * @throws Error if server mode is not supported
23
- */
24
- getValidator(mode) {
25
- const validator = ServerValidatorFactory.validators.get(mode);
26
- if (!validator) {
27
- const error = `Unsupported MCP server mode: ${mode}`;
28
- Logger.error(error);
29
- throw new Error(error);
30
- }
31
- Logger.debug(`Retrieved ${mode} validator`);
32
- return validator;
33
- }
34
- /**
35
- * Gets the appropriate validator for the given server config
36
- * @param serverConfig MCP server configuration
37
- * @returns IServerValidator instance appropriate for the server mode
38
- */
39
- getValidatorForServer(serverConfig) {
40
- return this.getValidator(serverConfig.mode);
41
- }
42
- }
43
- // Export singleton instance
44
- export const serverValidatorFactory = new ServerValidatorFactory();
1
+ import{StdioServerValidator}from"./StdioServerValidator.js";import{SSEServerValidator}from"./SSEServerValidator.js";import{Logger}from"../../utils/logger.js";export class ServerValidatorFactory{static validators=new Map;constructor(){0===ServerValidatorFactory.validators.size&&(Logger.debug("Initializing server validators"),ServerValidatorFactory.validators.set("stdio",new StdioServerValidator),ServerValidatorFactory.validators.set("sse",new SSEServerValidator))}getValidator(r){const e=ServerValidatorFactory.validators.get(r);if(!e){const e=`Unsupported MCP server mode: ${r}`;throw Logger.error(e),new Error(e)}return Logger.debug(`Retrieved ${r} validator`),e}getValidatorForServer(r){return this.getValidator(r.mode)}}export const serverValidatorFactory=new ServerValidatorFactory;
45
2
  //# sourceMappingURL=ServerValidatorFactory.js.map