imcp 0.1.3 → 0.1.5

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 (239) hide show
  1. package/README.md +21 -4
  2. package/dist/cli/commands/install.js.map +1 -0
  3. package/dist/cli/commands/list.js.map +1 -0
  4. package/dist/cli/commands/pull.js.map +1 -0
  5. package/dist/cli/commands/serve.js.map +1 -0
  6. package/dist/cli/commands/start.d.ts +2 -0
  7. package/dist/cli/commands/start.js +32 -0
  8. package/dist/cli/commands/start.js.map +1 -0
  9. package/dist/cli/commands/sync.d.ts +2 -0
  10. package/dist/cli/commands/sync.js +17 -0
  11. package/dist/cli/commands/sync.js.map +1 -0
  12. package/dist/cli/commands/uninstall.js.map +1 -0
  13. package/dist/cli/index.js +0 -0
  14. package/dist/cli/index.js.map +1 -0
  15. package/dist/core/ConfigurationLoader.d.ts +32 -0
  16. package/{src/core/loaders/ConfigurationLoader.ts → dist/core/ConfigurationLoader.js} +236 -298
  17. package/dist/core/ConfigurationLoader.js.map +1 -0
  18. package/dist/core/ConfigurationProvider.d.ts +35 -0
  19. package/{src/core/loaders/ConfigurationProvider.ts → dist/core/ConfigurationProvider.js} +375 -462
  20. package/dist/core/ConfigurationProvider.js.map +1 -0
  21. package/dist/core/InstallationService.d.ts +50 -0
  22. package/dist/core/InstallationService.js +350 -0
  23. package/dist/core/InstallationService.js.map +1 -0
  24. package/dist/core/MCPManager.d.ts +28 -0
  25. package/dist/core/MCPManager.js +188 -0
  26. package/dist/core/MCPManager.js.map +1 -0
  27. package/dist/core/RequirementService.d.ts +40 -0
  28. package/dist/core/RequirementService.js +110 -0
  29. package/dist/core/RequirementService.js.map +1 -0
  30. package/dist/core/ServerSchemaLoader.d.ts +11 -0
  31. package/dist/core/ServerSchemaLoader.js +43 -0
  32. package/dist/core/ServerSchemaLoader.js.map +1 -0
  33. package/dist/core/ServerSchemaProvider.d.ts +17 -0
  34. package/dist/core/ServerSchemaProvider.js +120 -0
  35. package/dist/core/ServerSchemaProvider.js.map +1 -0
  36. package/dist/core/constants.d.ts +47 -0
  37. package/dist/core/constants.js +94 -0
  38. package/dist/core/constants.js.map +1 -0
  39. package/dist/core/installers/BaseInstaller.d.ts +74 -0
  40. package/dist/core/installers/BaseInstaller.js +253 -0
  41. package/dist/core/installers/BaseInstaller.js.map +1 -0
  42. package/dist/core/installers/ClientInstaller.d.ts +23 -0
  43. package/dist/core/installers/ClientInstaller.js +564 -0
  44. package/dist/core/installers/ClientInstaller.js.map +1 -0
  45. package/dist/core/installers/CommandInstaller.d.ts +37 -0
  46. package/{src/core/installers/requirements/CommandInstaller.ts → dist/core/installers/CommandInstaller.js} +173 -231
  47. package/dist/core/installers/CommandInstaller.js.map +1 -0
  48. package/dist/core/installers/GeneralInstaller.d.ts +33 -0
  49. package/dist/core/installers/GeneralInstaller.js +85 -0
  50. package/dist/core/installers/GeneralInstaller.js.map +1 -0
  51. package/dist/core/installers/InstallerFactory.d.ts +54 -0
  52. package/{src/core/installers/requirements/InstallerFactory.ts → dist/core/installers/InstallerFactory.js} +97 -112
  53. package/dist/core/installers/InstallerFactory.js.map +1 -0
  54. package/dist/core/installers/NpmInstaller.d.ts +26 -0
  55. package/dist/core/installers/NpmInstaller.js +127 -0
  56. package/dist/core/installers/NpmInstaller.js.map +1 -0
  57. package/dist/core/installers/PipInstaller.d.ts +28 -0
  58. package/dist/core/installers/PipInstaller.js +127 -0
  59. package/dist/core/installers/PipInstaller.js.map +1 -0
  60. package/{src/core/installers/requirements/RequirementInstaller.ts → dist/core/installers/RequirementInstaller.d.ts} +33 -42
  61. package/dist/core/installers/RequirementInstaller.js +3 -0
  62. package/dist/core/installers/RequirementInstaller.js.map +1 -0
  63. package/dist/core/installers/clients/BaseClientInstaller.js.map +1 -0
  64. package/dist/core/installers/clients/ClientInstaller.js.map +1 -0
  65. package/dist/core/installers/clients/ClientInstallerFactory.js.map +1 -0
  66. package/dist/core/installers/clients/ClineInstaller.js.map +1 -0
  67. package/dist/core/installers/clients/ExtensionInstaller.js.map +1 -0
  68. package/dist/core/installers/clients/GithubCopilotInstaller.js.map +1 -0
  69. package/dist/core/installers/clients/MSRooCodeInstaller.js.map +1 -0
  70. package/dist/core/installers/index.js.map +1 -0
  71. package/dist/core/installers/requirements/BaseInstaller.js.map +1 -0
  72. package/dist/core/installers/requirements/CommandInstaller.js.map +1 -0
  73. package/dist/core/installers/requirements/GeneralInstaller.js.map +1 -0
  74. package/dist/core/installers/requirements/InstallerFactory.js +2 -0
  75. package/dist/core/installers/requirements/InstallerFactory.js.map +1 -0
  76. package/dist/core/installers/requirements/NpmInstaller.js.map +1 -0
  77. package/dist/core/installers/requirements/NugetInstaller.d.ts +37 -0
  78. package/dist/core/installers/requirements/NugetInstaller.js +189 -0
  79. package/dist/core/installers/requirements/NugetInstaller.js.map +1 -0
  80. package/dist/core/installers/requirements/PipInstaller.js.map +1 -0
  81. package/dist/core/installers/requirements/RequirementInstaller.js.map +1 -0
  82. package/dist/core/loaders/ConfigurationLoader.js.map +1 -0
  83. package/dist/core/loaders/ConfigurationProvider.js.map +1 -0
  84. package/dist/core/loaders/InstallOperationManager.js.map +1 -0
  85. package/dist/core/loaders/ServerSchemaLoader.js.map +1 -0
  86. package/dist/core/loaders/ServerSchemaProvider.js.map +1 -0
  87. package/dist/core/loaders/SystemSettingsManager.js.map +1 -0
  88. package/dist/core/metadatas/constants.js.map +1 -0
  89. package/dist/core/metadatas/recordingConstants.d.ts +2 -0
  90. package/dist/core/metadatas/recordingConstants.js +2 -0
  91. package/dist/core/metadatas/recordingConstants.js.map +1 -0
  92. package/dist/core/metadatas/types.d.ts +1 -1
  93. package/dist/core/metadatas/types.js.map +1 -0
  94. package/dist/core/onboard/FeedOnboardService.js +1 -22
  95. package/dist/core/onboard/FeedOnboardService.js.map +1 -0
  96. package/dist/core/onboard/OnboardProcessor.js.map +1 -0
  97. package/dist/core/onboard/OnboardStatus.js.map +1 -0
  98. package/dist/core/onboard/OnboardStatusManager.js.map +1 -0
  99. package/dist/core/types.d.ts +166 -0
  100. package/dist/core/types.js +16 -0
  101. package/dist/core/types.js.map +1 -0
  102. package/dist/core/validators/FeedValidator.js.map +1 -0
  103. package/dist/core/validators/IServerValidator.js.map +1 -0
  104. package/dist/core/validators/SSEServerValidator.js.map +1 -0
  105. package/dist/core/validators/ServerValidatorFactory.js.map +1 -0
  106. package/dist/core/validators/StdioServerValidator.js +5 -5
  107. package/dist/core/validators/StdioServerValidator.js.map +1 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/services/InstallRequestValidator.d.ts +21 -0
  110. package/dist/services/InstallRequestValidator.js +99 -0
  111. package/dist/services/InstallRequestValidator.js.map +1 -0
  112. package/dist/services/InstallationService.js.map +1 -0
  113. package/dist/services/MCPManager.js.map +1 -0
  114. package/dist/services/RequirementService.js.map +1 -0
  115. package/dist/services/ServerService.js.map +1 -0
  116. package/dist/services/TelemetryService.js.map +1 -0
  117. package/dist/utils/UpdateCheckTracker.js.map +1 -0
  118. package/dist/utils/adoUtils.js.map +1 -0
  119. package/dist/utils/clientUtils.js.map +1 -0
  120. package/dist/utils/feedUtils.js.map +1 -0
  121. package/dist/utils/githubAuth.js.map +1 -0
  122. package/dist/utils/githubUtils.js.map +1 -0
  123. package/dist/utils/logger.js.map +1 -0
  124. package/dist/utils/macroExpressionUtils.js.map +1 -0
  125. package/dist/utils/osUtils.d.ts +11 -0
  126. package/dist/utils/osUtils.js +100 -0
  127. package/dist/utils/osUtils.js.map +1 -0
  128. package/dist/utils/versionUtils.js.map +1 -0
  129. package/dist/web/contract/serverContract.js.map +1 -0
  130. package/dist/web/public/index.html +1 -1
  131. package/dist/web/public/js/modal/installHandler.js +227 -0
  132. package/dist/web/public/js/modal/loadingUI.js +74 -0
  133. package/dist/web/public/js/modal/messageQueue.js +101 -45
  134. package/dist/web/public/js/modal/modalUI.js +214 -0
  135. package/{src/web/public/js/modal/versionUtils.js → dist/web/public/js/modal/version.js} +1 -1
  136. package/dist/web/public/js/onboard/templates.js +1 -0
  137. package/dist/web/public/js/serverCategoryList.js +3 -3
  138. package/dist/web/public/onboard.html +4 -4
  139. package/dist/web/server.js.map +1 -0
  140. package/package.json +5 -1
  141. package/.github/ISSUE_TEMPLATE/JitAccess.yml +0 -28
  142. package/.github/acl/access.yml +0 -20
  143. package/.github/compliance/inventory.yml +0 -5
  144. package/.github/policies/jit.yml +0 -19
  145. package/.roo/rules-code/rules.md +0 -88
  146. package/dist/core/onboard/InstallOperationManager.d.ts +0 -23
  147. package/dist/core/onboard/InstallOperationManager.js +0 -144
  148. package/docs/ONBOARDING_PAGE_DESIGN.md +0 -260
  149. package/docs/Telemetry.md +0 -136
  150. package/memory-bank/activeContext.md +0 -26
  151. package/memory-bank/decisionLog.md +0 -91
  152. package/memory-bank/productContext.md +0 -41
  153. package/memory-bank/progress.md +0 -35
  154. package/memory-bank/systemPatterns.md +0 -10
  155. package/src/cli/commands/install.ts +0 -139
  156. package/src/cli/commands/list.ts +0 -113
  157. package/src/cli/commands/pull.ts +0 -16
  158. package/src/cli/commands/serve.ts +0 -39
  159. package/src/cli/commands/uninstall.ts +0 -64
  160. package/src/cli/index.ts +0 -82
  161. package/src/core/installers/clients/BaseClientInstaller.ts +0 -341
  162. package/src/core/installers/clients/ClientInstaller.ts +0 -222
  163. package/src/core/installers/clients/ClientInstallerFactory.ts +0 -43
  164. package/src/core/installers/clients/ClineInstaller.ts +0 -35
  165. package/src/core/installers/clients/ExtensionInstaller.ts +0 -165
  166. package/src/core/installers/clients/GithubCopilotInstaller.ts +0 -79
  167. package/src/core/installers/clients/MSRooCodeInstaller.ts +0 -32
  168. package/src/core/installers/index.ts +0 -11
  169. package/src/core/installers/requirements/BaseInstaller.ts +0 -85
  170. package/src/core/installers/requirements/GeneralInstaller.ts +0 -133
  171. package/src/core/installers/requirements/NpmInstaller.ts +0 -271
  172. package/src/core/installers/requirements/PipInstaller.ts +0 -207
  173. package/src/core/loaders/InstallOperationManager.ts +0 -367
  174. package/src/core/loaders/ServerSchemaLoader.ts +0 -117
  175. package/src/core/loaders/ServerSchemaProvider.ts +0 -99
  176. package/src/core/loaders/SystemSettingsManager.ts +0 -278
  177. package/src/core/metadatas/constants.ts +0 -122
  178. package/src/core/metadatas/recordingConstants.ts +0 -62
  179. package/src/core/metadatas/types.ts +0 -202
  180. package/src/core/onboard/FeedOnboardService.ts +0 -524
  181. package/src/core/onboard/OnboardProcessor.ts +0 -356
  182. package/src/core/onboard/OnboardStatus.ts +0 -60
  183. package/src/core/onboard/OnboardStatusManager.ts +0 -416
  184. package/src/core/validators/FeedValidator.ts +0 -135
  185. package/src/core/validators/IServerValidator.ts +0 -21
  186. package/src/core/validators/SSEServerValidator.ts +0 -43
  187. package/src/core/validators/ServerValidatorFactory.ts +0 -51
  188. package/src/core/validators/StdioServerValidator.ts +0 -312
  189. package/src/index.ts +0 -44
  190. package/src/services/InstallationService.ts +0 -102
  191. package/src/services/MCPManager.ts +0 -249
  192. package/src/services/RequirementService.ts +0 -627
  193. package/src/services/ServerService.ts +0 -161
  194. package/src/services/TelemetryService.ts +0 -59
  195. package/src/utils/UpdateCheckTracker.ts +0 -86
  196. package/src/utils/adoUtils.ts +0 -293
  197. package/src/utils/clientUtils.ts +0 -72
  198. package/src/utils/feedUtils.ts +0 -31
  199. package/src/utils/githubAuth.ts +0 -212
  200. package/src/utils/githubUtils.ts +0 -164
  201. package/src/utils/logger.ts +0 -195
  202. package/src/utils/macroExpressionUtils.ts +0 -104
  203. package/src/utils/osUtils.ts +0 -597
  204. package/src/utils/versionUtils.ts +0 -114
  205. package/src/web/contract/serverContract.ts +0 -74
  206. package/src/web/public/css/detailsWidget.css +0 -235
  207. package/src/web/public/css/modal.css +0 -757
  208. package/src/web/public/css/notifications.css +0 -101
  209. package/src/web/public/css/onboard.css +0 -107
  210. package/src/web/public/css/serverCategoryList.css +0 -120
  211. package/src/web/public/css/serverDetails.css +0 -139
  212. package/src/web/public/index.html +0 -359
  213. package/src/web/public/js/api.js +0 -132
  214. package/src/web/public/js/detailsWidget.js +0 -264
  215. package/src/web/public/js/flights/flights.js +0 -127
  216. package/src/web/public/js/modal/index.js +0 -52
  217. package/src/web/public/js/modal/installModal.js +0 -162
  218. package/src/web/public/js/modal/installation.js +0 -266
  219. package/src/web/public/js/modal/loadingModal.js +0 -182
  220. package/src/web/public/js/modal/modalSetup.js +0 -595
  221. package/src/web/public/js/modal/modalUtils.js +0 -37
  222. package/src/web/public/js/modal.js +0 -42
  223. package/src/web/public/js/notifications.js +0 -137
  224. package/src/web/public/js/onboard/formProcessor.js +0 -1037
  225. package/src/web/public/js/onboard/index.js +0 -374
  226. package/src/web/public/js/onboard/publishHandler.js +0 -172
  227. package/src/web/public/js/onboard/state.js +0 -76
  228. package/src/web/public/js/onboard/templates.js +0 -341
  229. package/src/web/public/js/onboard/uiHandlers.js +0 -1076
  230. package/src/web/public/js/onboard/validationHandlers.js +0 -493
  231. package/src/web/public/js/serverCategoryDetails.js +0 -364
  232. package/src/web/public/js/serverCategoryList.js +0 -241
  233. package/src/web/public/js/settings.js +0 -314
  234. package/src/web/public/modal.html +0 -84
  235. package/src/web/public/onboard.html +0 -296
  236. package/src/web/public/settings.html +0 -135
  237. package/src/web/public/styles.css +0 -277
  238. package/src/web/server.ts +0 -478
  239. package/tsconfig.json +0 -18
@@ -1,524 +0,0 @@
1
- import { FeedConfiguration, McpConfig } from '../metadatas/types.js';
2
- import { configProvider } from '../loaders/ConfigurationProvider.js';
3
- import { ServerSchemaProvider } from '../loaders/ServerSchemaProvider.js';
4
- import { feedValidator } from '../validators/FeedValidator.js';
5
- import { Logger, EventType, EventStatus } from '../../utils/logger.js';
6
- import { OnboardingProcessStatus, OperationStatus, OperationType, ValidationOperationResult } from './OnboardStatus.js';
7
- import { onboardStatusManager } from './OnboardStatusManager.js';
8
- import { onboardProcessor } from './OnboardProcessor.js';
9
-
10
- /**
11
- * Service for handling feed onboarding operations
12
- */
13
- export class FeedOnboardService {
14
- // tempDir and repoDir will be generated per onboarding process
15
-
16
- constructor() {
17
- // No shared tempDir or repoDir at instance level
18
- }
19
-
20
- /**
21
- * Creates an operation ID that combines feed name and operation type.
22
- * @param feedName The name of the feed.
23
- * @param operationType The type of operation.
24
- * @returns Combined operation ID string.
25
- */
26
- private createOperationId(feedName: string, operationType: OperationType): string {
27
- return `${feedName}_${operationType}`;
28
- }
29
-
30
- /**
31
- * Onboard a new feed configuration. This method performs validation and initiates the onboarding process.
32
- * @param config Feed configuration to onboard
33
- * @param forExistingCategory Whether this onboarding is for an existing category
34
- * @returns Promise resolving to operation status with optional feed configuration
35
- */
36
- public async onboardFeed(config: FeedConfiguration, forExistingCategory?: boolean): Promise<OperationStatus & { feedConfiguration?: FeedConfiguration }> {
37
- // Perform static validation first
38
- const serverList = await this.validateStaticConfig(config, forExistingCategory);
39
-
40
- // Check for an existing, succeeded VALIDATION_ONLY operation with an identical configuration.
41
- const existingSucceededValidation = await onboardStatusManager.findSucceededOperation(config.name, 'VALIDATION_ONLY', config);
42
-
43
- if (!existingSucceededValidation) {
44
- // If no matching successful validation is found, instruct user to validate first.
45
- Logger.log(`Feed ${config.name} has not been successfully validated with the current configuration. Publishing requires prior successful validation.`);
46
- // Return a specific status/message indicating validation is required.
47
- // This is not a FAILED state for an operation, but a prerequisite not met.
48
- // We'll use a custom message and potentially a specific status if we define one for "PREREQUISITE_FAILED" or similar.
49
- // For now, let's return a FAILED status for the attempted FULL_ONBOARDING initiation.
50
- // A more robust solution might involve a different return type or error code.
51
- const onboardingId = this.createOperationId(config.name, 'FULL_ONBOARDING'); // Hypothetical ID
52
- const errorMessage = `No prior successful validation found for feed: ${config.name}. Please validate the configuration before publishing.`;
53
-
54
- // Track failed event
55
- Logger.trackEvent(EventType.FEED_ONBOARD, {
56
- status: EventStatus.FAILED,
57
- feedName: config.name,
58
- errorMessage,
59
- onboardingId: onboardingId,
60
- feedConfiguration: config
61
- });
62
-
63
- return {
64
- onboardingId: onboardingId,
65
- status: OnboardingProcessStatus.FAILED, // Or a new status like 'VALIDATION_REQUIRED'
66
- message: errorMessage,
67
- lastQueried: new Date().toISOString(),
68
- feedConfiguration: config
69
- };
70
- }
71
-
72
- Logger.log(`Found existing successful validation for feed: ${config.name}. Proceeding with full onboarding.`);
73
- // If validation exists and matches, proceed to initiate FULL_ONBOARDING.
74
- // _initiateOperation will handle checks for existing non-completed or successfully completed FULL_ONBOARDING operations.
75
- const operationStatus = await this._initiateOperation(config, 'FULL_ONBOARDING', serverList, forExistingCategory);
76
-
77
- return {
78
- ...operationStatus,
79
- feedConfiguration: config
80
- };
81
- }
82
-
83
- /**
84
- * Validate a feed configuration without performing full onboarding.
85
- * This method performs static validation and initiates the validation process.
86
- * @param config Feed configuration to validate
87
- * @param forExistingCategory Whether this validation is for an existing category
88
- * @returns Promise resolving to operation status with optional feed configuration
89
- */
90
- public async validateFeed(config: FeedConfiguration, forExistingCategory?: boolean): Promise<OperationStatus & { feedConfiguration?: FeedConfiguration }> {
91
- // Perform static validation first
92
- const serverList = await this.validateStaticConfig(config, forExistingCategory);
93
-
94
- const operationStatus = await this._initiateOperation(config, 'VALIDATION_ONLY', serverList, forExistingCategory);
95
-
96
- return { ...operationStatus, feedConfiguration: config };
97
- }
98
-
99
- /**
100
- * Initiates either a full onboarding or a validation-only operation.
101
- * It checks for existing non-completed operations for the same feed and operation type.
102
- * If an existing operation is found, its status is returned. Otherwise, a new operation is created and started.
103
- * @param config The feed configuration.
104
- * @param operationType The type of operation to initiate (FULL_ONBOARDING or VALIDATION_ONLY).
105
- * @param serverList The list of server names to process.
106
- * @returns A promise that resolves to the operation status.
107
- */
108
- private async _initiateOperation(config: FeedConfiguration, operationType: OperationType, serverList: string[], forExistingCategory?: boolean): Promise<OperationStatus & { feedConfiguration?: FeedConfiguration }> {
109
- // First, check for existing non-completed operations
110
- let existingOperation = await onboardStatusManager._findExistingNonCompletedOperation(config.name, operationType);
111
-
112
- if (existingOperation) {
113
- const fiveMinutesInMs = 5 * 60 * 1000;
114
- const lastUpdateTimestamp = existingOperation.lastUpdated ? new Date(existingOperation.lastUpdated).getTime() : 0;
115
- const currentTime = new Date().getTime();
116
-
117
- if (lastUpdateTimestamp > 0 && (currentTime - lastUpdateTimestamp) > fiveMinutesInMs) {
118
- Logger.log(`WARNING: [${existingOperation.onboardingId}] Found stale ${operationType} operation for feed: ${config.name} (last updated at: ${existingOperation.lastUpdated}). Proceeding to create a new operation.`);
119
- existingOperation = undefined; // Treat as no existing operation for starting a new one
120
- } else {
121
- Logger.log(`[${existingOperation.onboardingId}] Found existing non-completed ${operationType} operation for feed: ${config.name}. Returning its status.`);
122
- const lastStep = existingOperation.steps && existingOperation.steps.length > 0 ? existingOperation.steps[existingOperation.steps.length - 1].stepName : 'N/A';
123
- return {
124
- onboardingId: existingOperation.onboardingId,
125
- status: existingOperation.status,
126
- message: `An ${operationType} process for this feed (${existingOperation.onboardingId}) is already in status: ${existingOperation.status}. Last step: ${lastStep}`,
127
- lastQueried: new Date().toISOString(),
128
- };
129
- }
130
- }
131
-
132
- // Then, check for successful operations with matching configuration
133
- const succeededOperation = await onboardStatusManager.findSucceededOperation(config.name, operationType, config);
134
- if (succeededOperation) {
135
- Logger.log(`[${succeededOperation.onboardingId}] Found existing successful ${operationType} operation for feed: ${config.name} with matching configuration.`);
136
- const operationStatus: OperationStatus & { feedConfiguration?: FeedConfiguration } = {
137
- onboardingId: succeededOperation.onboardingId,
138
- status: succeededOperation.status,
139
- message: `A successful ${operationType} already exists for this feed with identical configuration.`,
140
- lastQueried: new Date().toISOString(),
141
- };
142
-
143
- if (config) {
144
- operationStatus.feedConfiguration = config;
145
- }
146
-
147
- return operationStatus;
148
- }
149
-
150
- // If no existing or matching operations found, create a new one
151
- const onboardingId = this.createOperationId(config.name, operationType);
152
- const initialStatus = await onboardStatusManager.createInitialStatus(config.name, operationType);
153
-
154
- // Use config.name as categoryName for saveFeedConfiguration
155
- await onboardStatusManager.saveFeedConfiguration(config.name, operationType, config);
156
-
157
- if (operationType === 'FULL_ONBOARDING') {
158
- // For FULL_ONBOARDING, we assume all servers defined in the config are to be processed for PR creation.
159
- // The serverList from validateStaticConfig primarily influences validation.
160
- // If specific servers need to be excluded from the PR, this logic might need adjustment.
161
- this.processFullOnboarding(onboardingId, config, operationType, serverList).catch(async (error) => {
162
- Logger.error(`[${onboardingId}] Full feed onboarding process failed:`, error);
163
- await onboardStatusManager.recordStep(
164
- config.name,
165
- operationType,
166
- 'Failed during full onboarding process',
167
- undefined, // serverName
168
- OnboardingProcessStatus.FAILED,
169
- error instanceof Error ? error.message : String(error)
170
- );
171
- });
172
- } else if (operationType === 'VALIDATION_ONLY') {
173
- this.processValidationOnly(onboardingId, config, operationType, serverList).catch(async (error) => {
174
- Logger.error(`[${onboardingId}] Feed validation process failed:`, error);
175
- await onboardStatusManager.recordStep(
176
- config.name,
177
- operationType,
178
- 'Failed during validation process',
179
- undefined, // serverName
180
- OnboardingProcessStatus.FAILED,
181
- error instanceof Error ? error.message : String(error)
182
- // TODO: Consider how to best store/pass 'validationStatus' if it's still needed at this specific failure point
183
- );
184
- });
185
- }
186
-
187
- return {
188
- onboardingId,
189
- status: OnboardingProcessStatus.PENDING,
190
- message: `New ${operationType} process started with ID: ${onboardingId}.`,
191
- lastQueried: new Date().toISOString(),
192
- };
193
- }
194
-
195
- /**
196
- * Performs static validation of the feed configuration.
197
- * @param config The feed configuration to validate.
198
- * @param forExistingCategory Whether this is for an existing category.
199
- * @returns A promise that resolves to a list of server names to be processed.
200
- * @throws Error if validation fails.
201
- */
202
- private async validateStaticConfig(config: FeedConfiguration, forExistingCategory?: boolean): Promise<string[]> {
203
- // --- Start of moved and enhanced static validation ---
204
- if (!config || typeof config !== 'object') { // Check if config itself is a valid object
205
- throw new Error('Invalid configuration: Input must be a valid object.');
206
- }
207
- if (typeof config.name !== 'string' || !config.name.trim()) {
208
- throw new Error('Invalid configuration: "name" must be a non-empty string.');
209
- }
210
- if (!Array.isArray(config.requirements)) {
211
- throw new Error('Invalid configuration: "requirements" must be an array.');
212
- }
213
- if (!Array.isArray(config.mcpServers)) {
214
- throw new Error('Invalid configuration: "mcpServers" must be an array.');
215
- }
216
- // --- End of moved static validation ---
217
-
218
- const existingConfig = await configProvider.getFeedConfiguration(config.name);
219
- // Note: operationType validation is handled at the MCP server level
220
-
221
- let serverListToProcess: string[];
222
-
223
- if (forExistingCategory) {
224
- if (!existingConfig) {
225
- throw new Error(`Cannot update non-existent category: ${config.name}. Please ensure the category name is correct or create it as a new category.`);
226
- }
227
- // For existing categories, mcpServers list must be present in the payload.
228
- if (!config.mcpServers || config.mcpServers.length === 0) {
229
- throw new Error('For an existing category, "mcpServers" must be provided and non-empty in the payload.');
230
- }
231
-
232
- const existingServerNames = new Set(existingConfig.mcpServers.map((s: McpConfig) => s.name));
233
- // Servers to process are those that are new OR existing ones marked as adhoc in the payload.
234
- const serversToProcessInPayload = config.mcpServers.filter(payloadServer => {
235
- const isNew = !existingServerNames.has(payloadServer.name);
236
- const isAdhocInPayload = payloadServer.systemTags?.adhoc === 'true';
237
- return isNew || (existingServerNames.has(payloadServer.name) && isAdhocInPayload);
238
- });
239
-
240
- if (serversToProcessInPayload.length === 0) {
241
- // If no new or editable (adhoc) servers are found in the payload for an existing category, it's an error.
242
- throw new Error(`No new or adhoc (editable) servers provided for the existing category "${config.name}". Ensure the "mcpServers" list in your payload contains at least one server not already in this category or an existing server marked with adhoc:true.`);
243
- }
244
- serverListToProcess = serversToProcessInPayload.map(s => s.name);
245
- } else { // For new categories
246
- if (existingConfig) {
247
- // If it's not for an existing category, but the category name already exists, this is an error.
248
- // Adhoc tags on servers are not relevant here as we are creating a new category.
249
- throw new Error(`Category "${config.name}" already exists. To modify an existing category, please set 'forExistingCategory' to true.`);
250
- }
251
- // For new categories, mcpServers list must be present and non-empty.
252
- if (!config.mcpServers || config.mcpServers.length === 0) {
253
- throw new Error('Server configuration ("mcpServers") must be provided and non-empty for new categories.');
254
- }
255
- // For new categories, all servers in the payload are considered.
256
- serverListToProcess = config.mcpServers.map(s => s.name);
257
- }
258
- // Remove systemTags from individual servers
259
- if (config.mcpServers && Array.isArray(config.mcpServers)) {
260
- config.mcpServers.forEach(server => {
261
- if (server.systemTags) {
262
- delete server.systemTags;
263
- }
264
- });
265
- }
266
-
267
- // Remove systemTags and PullRequest from the main config object
268
- if (config.systemTags) {
269
- delete config.systemTags;
270
- }
271
- if (config.PullRequest) {
272
- delete config.PullRequest;
273
- }
274
-
275
- return serverListToProcess;
276
- }
277
-
278
- /**
279
- * Validates the feed configuration.
280
- * Updates the onboarding status to VALIDATING, then to VALIDATED or FAILED based on the validation result.
281
- * @param onboardingId The ID of the onboarding process.
282
- * @param config The feed configuration to validate.
283
- * @param operationType The type of operation this validation is for.
284
- * @param serverList The list of server names to validate.
285
- * @throws Error if validation fails, to be caught by the calling process.
286
- */
287
- private async _validateFeedConfiguration(onboardingId: string, config: FeedConfiguration, operationType: OperationType, serverList: string[]): Promise<void> {
288
- await onboardStatusManager.recordStep(config.name, operationType, 'Validating feed configuration', undefined, OnboardingProcessStatus.VALIDATING);
289
- let overallValidationStatus: ValidationOperationResult['validationStatus'] = { isValid: true, serverResults: [] };
290
- try {
291
- await feedValidator.validate(config, config.name, operationType);
292
-
293
- // Then, validate each MCP server specified in the serverList
294
- for (const serverConfig of config.mcpServers) {
295
- if (!serverList.includes(serverConfig.name)) {
296
- Logger.log(`[${onboardingId}] Skipping validation for server ${serverConfig.name} as it's not in the specified list for this operation.`);
297
- // Optionally, record a skipped status or add to serverResults as skipped
298
- overallValidationStatus.serverResults?.push({ serverName: serverConfig.name, isValid: true, message: "Skipped (existed)" });
299
- continue;
300
- }
301
- try {
302
- await feedValidator.validateServer(serverConfig, config, config.name, operationType);
303
- overallValidationStatus.serverResults?.push({ serverName: serverConfig.name, isValid: true });
304
- await onboardStatusManager.recordStep(config.name, operationType, `Validated server: ${serverConfig.name}`, serverConfig.name, OnboardingProcessStatus.VALIDATING);
305
- await onboardStatusManager.updateStatus(config.name, operationType, { validationStatus: overallValidationStatus });
306
- } catch (serverValidationError: any) {
307
- overallValidationStatus.isValid = false;
308
- overallValidationStatus.serverResults?.push({
309
- serverName: serverConfig.name,
310
- isValid: false,
311
- message: serverValidationError.message || String(serverValidationError)
312
- });
313
- await onboardStatusManager.recordStep(
314
- config.name,
315
- operationType,
316
- `Validation failed for server: ${serverConfig.name}`,
317
- serverConfig.name,
318
- OnboardingProcessStatus.FAILED,
319
- `Server ${serverConfig.name}: ${serverValidationError.message || String(serverValidationError)}`
320
- );
321
- await onboardStatusManager.updateStatus(config.name, operationType, { validationStatus: overallValidationStatus });
322
- throw serverValidationError; // Propagate the error to fail the whole validation
323
- }
324
- }
325
-
326
- // If all *processed* servers validated successfully
327
- await onboardStatusManager.recordStep(config.name, operationType, 'All servers in feed configuration validated successfully', undefined, OnboardingProcessStatus.VALIDATED);
328
- await onboardStatusManager.updateStatus(config.name, operationType, { validationStatus: overallValidationStatus });
329
- } catch (error) {
330
- const validationError = error as any; // Assuming error might have validation details
331
- await onboardStatusManager.recordStep(
332
- config.name,
333
- operationType,
334
- 'Feed configuration validation failed',
335
- undefined,
336
- OnboardingProcessStatus.FAILED,
337
- validationError.message || String(error)
338
- );
339
- await onboardStatusManager.updateStatus(config.name, operationType, {
340
- validationStatus: {
341
- isValid: false,
342
- message: validationError.message || String(error),
343
- serverResults: overallValidationStatus.serverResults // Ensure this is up-to-date
344
- }
345
- });
346
- throw error; // Re-throw to be caught by the calling process
347
- }
348
- }
349
-
350
- /**
351
- * Processes a validation-only operation for a feed configuration.
352
- * It validates the configuration and updates the status to SUCCEEDED if validation is successful.
353
- * If validation fails, the error is handled by _validateFeedConfiguration and the calling _initiateOperation method.
354
- * @param onboardingId The ID of the onboarding process.
355
- * @param config The feed configuration.
356
- * @param operationType The type of operation (should be 'VALIDATION_ONLY').
357
- * @param serverList The list of server names to validate.
358
- */
359
- private async processValidationOnly(onboardingId: string, config: FeedConfiguration, operationType: OperationType, serverList: string[]): Promise<void> {
360
- try {
361
- // Pass operationType and serverList to _validateFeedConfiguration
362
- await this._validateFeedConfiguration(onboardingId, config, operationType, serverList);
363
- // Use config.name and operationType for getStatus
364
- const finalStatus = await onboardStatusManager.getStatus(config.name, operationType);
365
- const result: ValidationOperationResult = {
366
- validationStatus: finalStatus?.validationStatus || { isValid: true, serverResults: [] },
367
- feedConfiguration: config
368
- };
369
- // Use config.name and operationType for recordStep and updateStatus
370
- await onboardStatusManager.recordStep(
371
- config.name,
372
- operationType,
373
- 'Feed configuration validated successfully',
374
- undefined, // serverName
375
- OnboardingProcessStatus.SUCCEEDED
376
- );
377
- await onboardStatusManager.updateStatus(config.name, operationType, {
378
- errorMessage: undefined, // Clear any previous error
379
- prInfo: undefined, // Clear PR info for validation-only
380
- result: result, // Set the result
381
- validationStatus: result.validationStatus // Ensure validationStatus is also updated on success
382
- });
383
- Logger.log(`[${onboardingId}] Successfully validated feed: ${config.name}`);
384
-
385
- // Track successful validation
386
- Logger.trackEvent(EventType.FEED_VALIDATE, {
387
- status: EventStatus.SUCCESS,
388
- feedName: config.name,
389
- operationType: 'VALIDATION_ONLY',
390
- onboardingId: onboardingId,
391
- feedConfiguration: config
392
- });
393
- } catch (error) {
394
- const errorMessage = error instanceof Error ? error.message : String(error);
395
- // Error is already logged and status updated by _validateFeedConfiguration or its callers
396
- Logger.error(`[${onboardingId}] Feed validation process failed for ${config.name} (already handled):`, error);
397
-
398
- // Track validation failure
399
- Logger.trackEvent(EventType.FEED_VALIDATE, {
400
- status: EventStatus.FAILED,
401
- feedName: config.name,
402
- operationType: 'VALIDATION_ONLY',
403
- errorMessage: errorMessage,
404
- onboardingId: onboardingId,
405
- feedConfiguration: config
406
- });
407
- }
408
- }
409
-
410
-
411
- /**
412
- * Processes the full onboarding for a feed configuration.
413
- * This includes validation, forking/cloning the repository, saving the config, and creating a pull request.
414
- * Manages status updates throughout the process and handles cleanup of temporary directories.
415
- * @param onboardingId The ID of the onboarding process.
416
- * @param config The feed configuration.
417
- * @param operationType The type of operation (should be 'FULL_ONBOARDING').
418
- * @throws Error if any step of the full onboarding process fails.
419
- */
420
- private async processFullOnboarding(onboardingId: string, config: FeedConfiguration, operationType: OperationType, serverList: string[]): Promise<void> {
421
- const { tempDir, repoDir } = onboardProcessor.createDirectories(onboardingId);
422
- try {
423
- // Validation is now a prerequisite and assumed to be done if this process is initiated.
424
- // The status should be PENDING or a similar initial state from _initiateOperation.
425
- // We directly proceed to PR creation steps.
426
- // The first step recorded here will likely move status from PENDING to PR_CREATING.
427
-
428
- await onboardStatusManager.recordStep(config.name, operationType, 'Starting PR creation process (validation confirmed)', undefined, OnboardingProcessStatus.PR_CREATING);
429
-
430
- await onboardStatusManager.recordStep(config.name, operationType, 'Forking repository', undefined, OnboardingProcessStatus.PR_CREATING);
431
- await onboardProcessor.forkRepo(onboardingId, repoDir);
432
-
433
- await onboardStatusManager.recordStep(config.name, operationType, 'Cloning repository', undefined, OnboardingProcessStatus.PR_CREATING);
434
- await onboardProcessor.cloneRepo(onboardingId, tempDir, repoDir);
435
-
436
- await onboardStatusManager.recordStep(config.name, operationType, 'Setting up branch', undefined, OnboardingProcessStatus.PR_CREATING);
437
- const branchName = await onboardProcessor.setupBranch(onboardingId, config, repoDir);
438
-
439
- await onboardStatusManager.recordStep(config.name, operationType, 'Saving feed configuration to repository', undefined, OnboardingProcessStatus.PR_CREATING);
440
- const { feedFilePath, categorySchemasPath } = await onboardProcessor.saveFeedConfigToRepo(onboardingId, config, repoDir, serverList);
441
-
442
- await onboardStatusManager.recordStep(config.name, operationType, 'Creating pull request', undefined, OnboardingProcessStatus.PR_CREATING);
443
- const prInfo = await onboardProcessor.createPullRequest(onboardingId, config, repoDir, branchName);
444
-
445
- // Step 3: Finalize with SUCCEEDED status for PR creation
446
- await onboardStatusManager.recordStep(config.name, operationType, prInfo.prExists ? 'Successfully updated to existing pull request' : 'Successfully created pull request', undefined, OnboardingProcessStatus.SUCCEEDED);
447
- await onboardStatusManager.updateStatus(config.name, operationType, {
448
- errorMessage: undefined, // Clear any previous errors
449
- prInfo: prInfo,
450
- result: prInfo.url // Store PR URL as the result
451
- });
452
- Logger.log(`[${onboardingId}] Successfully created/updated PR for feed: ${config.name}. PR URL: ${prInfo.url}`);
453
-
454
- // After successful PR, re-initialize providers
455
- try {
456
- await onboardStatusManager.recordStep(config.name, operationType, 'Reloading server schemas', undefined, OnboardingProcessStatus.SUCCEEDED);
457
- Logger.log(`[${onboardingId}] Initializing ServerSchemaProvider with new schemas at ${categorySchemasPath}`);
458
- await ServerSchemaProvider.getInstance().initialize(categorySchemasPath);
459
- Logger.log(`[${onboardingId}] ServerSchemaProvider re-initialized.`);
460
-
461
- await onboardStatusManager.recordStep(config.name, operationType, 'Reloading configurations', undefined, OnboardingProcessStatus.SUCCEEDED);
462
- Logger.log(`[${onboardingId}] Initializing ConfigurationProvider with new feed file at ${feedFilePath}`);
463
- await configProvider.initialize(feedFilePath, { prLink: prInfo.url, adhocServers: serverList }); // configProvider is already an instance
464
- Logger.log(`[${onboardingId}] ConfigurationProvider re-initialized.`);
465
-
466
- Logger.log(`[${onboardingId}] Successfully completed full onboarding for feed: ${config.name}`);
467
-
468
- // Track successful onboarding
469
- Logger.trackEvent(EventType.FEED_ONBOARD, {
470
- status: EventStatus.SUCCESS,
471
- feedName: config.name,
472
- onboardingId: onboardingId,
473
- prUrl: prInfo.url,
474
- feedConfiguration: config
475
- });
476
- } catch (reinitError) {
477
- Logger.warn(`[${onboardingId}] Failed to re-initialize providers after PR creation for feed ${config.name}:`);
478
- Logger.warn(`Skipping re-initialization of providers due to error: ${reinitError}`,);
479
- }
480
-
481
- } catch (error) {
482
- Logger.error(`[${onboardingId}] Full feed onboarding process failed:`, error);
483
- const errorMessage = error instanceof Error ? error.message : String(error);
484
-
485
- // Track onboarding failure
486
- Logger.trackEvent(EventType.FEED_ONBOARD, {
487
- status: EventStatus.FAILED,
488
- feedName: config.name,
489
- onboardingId: onboardingId,
490
- errorMessage,
491
- feedConfiguration: config
492
- });
493
-
494
- // Check if status is already FAILED (e.g., by _validateFeedConfiguration)
495
- // to avoid overwriting a more specific error message or step from validation.
496
- const currentStatus = await onboardStatusManager.getStatus(config.name, operationType);
497
- if (currentStatus?.status !== OnboardingProcessStatus.FAILED) {
498
- let stepName = 'Failed during full onboarding process';
499
- if (error instanceof Error && 'step' in error && typeof error.step === 'string') {
500
- stepName = `Failed at step: ${error.step}`;
501
- } else if (currentStatus?.steps && currentStatus.steps.length > 0) {
502
- // If not already failed by validation, use the last known good step before this error
503
- stepName = `Failed after step: ${currentStatus.steps[currentStatus.steps.length - 1].stepName}`;
504
- }
505
- await onboardStatusManager.recordStep(
506
- config.name,
507
- operationType,
508
- stepName,
509
- undefined, // serverName
510
- OnboardingProcessStatus.FAILED,
511
- errorMessage
512
- );
513
- } else {
514
- // If already FAILED, the error and step were likely recorded by _validateFeedConfiguration.
515
- // Log the current error context if it's different or provides more info.
516
- Logger.log(`[${onboardingId}] Process was already marked as FAILED. Additional context - Current error: ${errorMessage}. Initial error from status: ${currentStatus.errorMessage}`);
517
- }
518
- throw error; // Re-throw to ensure the promise from processFullOnboarding is rejected.
519
- }
520
- }
521
- }
522
-
523
- // Export singleton instance
524
- export const feedOnboardService = new FeedOnboardService();