imcp 0.1.7 → 0.1.8-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/install.js +1 -106
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/list.js +1 -90
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/pull.js +1 -16
- package/dist/cli/commands/pull.js.map +1 -0
- package/dist/cli/commands/serve.js +1 -33
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/uninstall.js +1 -46
- package/dist/cli/commands/uninstall.js.map +1 -0
- package/dist/cli/index.js +1 -65
- package/dist/cli/index.js.map +1 -0
- package/dist/core/installers/clients/BaseClientInstaller.js +1 -282
- package/dist/core/installers/clients/BaseClientInstaller.js.map +1 -0
- package/dist/core/installers/clients/ClientInstaller.js +1 -163
- package/dist/core/installers/clients/ClientInstaller.js.map +1 -0
- package/dist/core/installers/clients/ClientInstallerFactory.js +1 -36
- package/dist/core/installers/clients/ClientInstallerFactory.js.map +1 -0
- package/dist/core/installers/clients/ClineInstaller.js +1 -30
- package/dist/core/installers/clients/ClineInstaller.js.map +1 -0
- package/dist/core/installers/clients/ExtensionInstaller.js +1 -151
- package/dist/core/installers/clients/ExtensionInstaller.js.map +1 -0
- package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -68
- package/dist/core/installers/clients/GithubCopilotInstaller.js.map +1 -0
- package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -28
- package/dist/core/installers/clients/MSRooCodeInstaller.js.map +1 -0
- package/dist/core/installers/index.js +1 -8
- package/dist/core/installers/index.js.map +1 -0
- package/dist/core/installers/requirements/BaseInstaller.js +1 -56
- package/dist/core/installers/requirements/BaseInstaller.js.map +1 -0
- package/dist/core/installers/requirements/CommandInstaller.js +1 -213
- package/dist/core/installers/requirements/CommandInstaller.js.map +1 -0
- package/dist/core/installers/requirements/GeneralInstaller.js +1 -126
- package/dist/core/installers/requirements/GeneralInstaller.js.map +1 -0
- package/dist/core/installers/requirements/InstallerFactory.js +1 -99
- package/dist/core/installers/requirements/InstallerFactory.js.map +1 -0
- package/dist/core/installers/requirements/NpmInstaller.js +1 -235
- package/dist/core/installers/requirements/NpmInstaller.js.map +1 -0
- package/dist/core/installers/requirements/NugetInstaller.js +1 -188
- package/dist/core/installers/requirements/NugetInstaller.js.map +1 -0
- package/dist/core/installers/requirements/PipInstaller.js +1 -192
- package/dist/core/installers/requirements/PipInstaller.js.map +1 -0
- package/dist/core/installers/requirements/RequirementInstaller.js +1 -2
- package/dist/core/installers/requirements/RequirementInstaller.js.map +1 -0
- package/dist/core/loaders/ConfigurationLoader.js +1 -256
- package/dist/core/loaders/ConfigurationLoader.js.map +1 -0
- package/dist/core/loaders/ConfigurationProvider.js +1 -383
- package/dist/core/loaders/ConfigurationProvider.js.map +1 -0
- package/dist/core/loaders/InstallOperationManager.js +1 -310
- package/dist/core/loaders/InstallOperationManager.js.map +1 -0
- package/dist/core/loaders/ServerSchemaLoader.js +1 -108
- package/dist/core/loaders/ServerSchemaLoader.js.map +1 -0
- package/dist/core/loaders/ServerSchemaProvider.js +1 -89
- package/dist/core/loaders/ServerSchemaProvider.js.map +1 -0
- package/dist/core/loaders/SystemSettingsManager.js +1 -256
- package/dist/core/loaders/SystemSettingsManager.js.map +1 -0
- package/dist/core/metadatas/constants.js +1 -100
- package/dist/core/metadatas/constants.js.map +1 -0
- package/dist/core/metadatas/recordingConstants.js +1 -46
- package/dist/core/metadatas/recordingConstants.js.map +1 -0
- package/dist/core/metadatas/types.js +1 -15
- package/dist/core/metadatas/types.js.map +1 -0
- package/dist/core/onboard/FeedOnboardService.js +1 -422
- package/dist/core/onboard/FeedOnboardService.js.map +1 -0
- package/dist/core/onboard/OnboardProcessor.js +1 -333
- package/dist/core/onboard/OnboardProcessor.js.map +1 -0
- package/dist/core/onboard/OnboardStatus.js +1 -9
- package/dist/core/onboard/OnboardStatus.js.map +1 -0
- package/dist/core/onboard/OnboardStatusManager.js +1 -360
- package/dist/core/onboard/OnboardStatusManager.js.map +1 -0
- package/dist/core/validators/FeedValidator.js +1 -133
- package/dist/core/validators/FeedValidator.js.map +1 -0
- package/dist/core/validators/IServerValidator.js +1 -1
- package/dist/core/validators/IServerValidator.js.map +1 -0
- package/dist/core/validators/SSEServerValidator.js +1 -38
- package/dist/core/validators/SSEServerValidator.js.map +1 -0
- package/dist/core/validators/ServerValidatorFactory.js +1 -44
- package/dist/core/validators/ServerValidatorFactory.js.map +1 -0
- package/dist/core/validators/StdioServerValidator.js +1 -281
- package/dist/core/validators/StdioServerValidator.js.map +1 -0
- package/dist/index.js +1 -18
- package/dist/index.js.map +1 -0
- package/dist/services/InstallationService.js +1 -81
- package/dist/services/InstallationService.js.map +1 -0
- package/dist/services/MCPManager.js +1 -197
- package/dist/services/MCPManager.js.map +1 -0
- package/dist/services/RequirementService.js +1 -548
- package/dist/services/RequirementService.js.map +1 -0
- package/dist/services/ServerService.js +1 -127
- package/dist/services/ServerService.js.map +1 -0
- package/dist/services/TelemetryService.js +1 -53
- package/dist/services/TelemetryService.js.map +1 -0
- package/dist/utils/UpdateCheckTracker.js +1 -79
- package/dist/utils/UpdateCheckTracker.js.map +1 -0
- package/dist/utils/adoUtils.js +1 -254
- package/dist/utils/adoUtils.js.map +1 -0
- package/dist/utils/clientUtils.js +1 -65
- package/dist/utils/clientUtils.js.map +1 -0
- package/dist/utils/feedUtils.js +1 -28
- package/dist/utils/feedUtils.js.map +1 -0
- package/dist/utils/githubAuth.js +1 -177
- package/dist/utils/githubAuth.js.map +1 -0
- package/dist/utils/githubUtils.js +1 -125
- package/dist/utils/githubUtils.js.map +1 -0
- package/dist/utils/logger.js +1 -176
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/macroExpressionUtils.js +1 -93
- package/dist/utils/macroExpressionUtils.js.map +1 -0
- package/dist/utils/osUtils.js +1 -664
- package/dist/utils/osUtils.js.map +1 -0
- package/dist/utils/versionUtils.js +1 -101
- package/dist/utils/versionUtils.js.map +1 -0
- package/dist/web/contract/serverContract.js +1 -1
- package/dist/web/contract/serverContract.js.map +1 -0
- package/dist/web/public/js/api.js +2 -132
- package/dist/web/public/js/api.js.map +1 -0
- package/dist/web/public/js/detailsWidget.js +2 -264
- package/dist/web/public/js/detailsWidget.js.map +1 -0
- package/dist/web/public/js/flights/flights.js +2 -127
- package/dist/web/public/js/flights/flights.js.map +1 -0
- package/dist/web/public/js/modal/index.js +2 -52
- package/dist/web/public/js/modal/index.js.map +1 -0
- package/dist/web/public/js/modal/installModal.js +2 -162
- package/dist/web/public/js/modal/installModal.js.map +1 -0
- package/dist/web/public/js/modal/installation.js +2 -266
- package/dist/web/public/js/modal/installation.js.map +1 -0
- package/dist/web/public/js/modal/loadingModal.js +2 -182
- package/dist/web/public/js/modal/loadingModal.js.map +1 -0
- package/dist/web/public/js/modal/modalSetup.js +2 -595
- package/dist/web/public/js/modal/modalSetup.js.map +1 -0
- package/dist/web/public/js/modal/modalUtils.js +2 -37
- package/dist/web/public/js/modal/modalUtils.js.map +1 -0
- package/dist/web/public/js/modal/versionUtils.js +2 -20
- package/dist/web/public/js/modal/versionUtils.js.map +1 -0
- package/dist/web/public/js/modal.js +2 -42
- package/dist/web/public/js/modal.js.map +1 -0
- package/dist/web/public/js/notifications.js +2 -137
- package/dist/web/public/js/notifications.js.map +1 -0
- package/dist/web/public/js/onboard/formProcessor.js +2 -1037
- package/dist/web/public/js/onboard/formProcessor.js.map +1 -0
- package/dist/web/public/js/onboard/index.js +2 -374
- package/dist/web/public/js/onboard/index.js.map +1 -0
- package/dist/web/public/js/onboard/publishHandler.js +2 -172
- package/dist/web/public/js/onboard/publishHandler.js.map +1 -0
- package/dist/web/public/js/onboard/state.js +2 -76
- package/dist/web/public/js/onboard/state.js.map +1 -0
- package/dist/web/public/js/onboard/templates.js +2 -342
- package/dist/web/public/js/onboard/templates.js.map +1 -0
- package/dist/web/public/js/onboard/uiHandlers.js +2 -1076
- package/dist/web/public/js/onboard/uiHandlers.js.map +1 -0
- package/dist/web/public/js/onboard/validationHandlers.js +2 -493
- package/dist/web/public/js/onboard/validationHandlers.js.map +1 -0
- package/dist/web/public/js/serverCategoryDetails.js +2 -364
- package/dist/web/public/js/serverCategoryDetails.js.map +1 -0
- package/dist/web/public/js/serverCategoryList.js +2 -241
- package/dist/web/public/js/serverCategoryList.js.map +1 -0
- package/dist/web/public/js/settings.js +2 -314
- package/dist/web/public/js/settings.js.map +1 -0
- package/dist/web/server.js +1 -404
- package/dist/web/server.js.map +1 -0
- package/package.json +8 -2
- package/.github/ISSUE_TEMPLATE/JitAccess.yml +0 -28
- package/.github/acl/access.yml +0 -20
- package/.github/compliance/inventory.yml +0 -5
- package/.github/policies/jit.yml +0 -19
- package/.github/workflows/build.yml +0 -28
- package/.roo/rules-code/rules.md +0 -88
- package/dist/cli/commands/start.d.ts +0 -2
- package/dist/cli/commands/start.js +0 -32
- package/dist/cli/commands/sync.d.ts +0 -2
- package/dist/cli/commands/sync.js +0 -17
- package/dist/core/ConfigurationLoader.d.ts +0 -32
- package/dist/core/ConfigurationLoader.js +0 -236
- package/dist/core/ConfigurationProvider.d.ts +0 -35
- package/dist/core/ConfigurationProvider.js +0 -375
- package/dist/core/InstallationService.d.ts +0 -50
- package/dist/core/InstallationService.js +0 -350
- package/dist/core/MCPManager.d.ts +0 -28
- package/dist/core/MCPManager.js +0 -188
- package/dist/core/RequirementService.d.ts +0 -40
- package/dist/core/RequirementService.js +0 -110
- package/dist/core/ServerSchemaLoader.d.ts +0 -11
- package/dist/core/ServerSchemaLoader.js +0 -43
- package/dist/core/ServerSchemaProvider.d.ts +0 -17
- package/dist/core/ServerSchemaProvider.js +0 -120
- package/dist/core/constants.d.ts +0 -47
- package/dist/core/constants.js +0 -94
- package/dist/core/installers/BaseInstaller.d.ts +0 -74
- package/dist/core/installers/BaseInstaller.js +0 -253
- package/dist/core/installers/ClientInstaller.d.ts +0 -23
- package/dist/core/installers/ClientInstaller.js +0 -564
- package/dist/core/installers/CommandInstaller.d.ts +0 -37
- package/dist/core/installers/CommandInstaller.js +0 -173
- package/dist/core/installers/GeneralInstaller.d.ts +0 -33
- package/dist/core/installers/GeneralInstaller.js +0 -85
- package/dist/core/installers/InstallerFactory.d.ts +0 -54
- package/dist/core/installers/InstallerFactory.js +0 -97
- package/dist/core/installers/NpmInstaller.d.ts +0 -26
- package/dist/core/installers/NpmInstaller.js +0 -127
- package/dist/core/installers/PipInstaller.d.ts +0 -28
- package/dist/core/installers/PipInstaller.js +0 -127
- package/dist/core/installers/RequirementInstaller.d.ts +0 -33
- package/dist/core/installers/RequirementInstaller.js +0 -3
- package/dist/core/types.d.ts +0 -166
- package/dist/core/types.js +0 -16
- package/dist/services/InstallRequestValidator.d.ts +0 -21
- package/dist/services/InstallRequestValidator.js +0 -99
- package/dist/web/public/js/modal/installHandler.js +0 -227
- package/dist/web/public/js/modal/loadingUI.js +0 -74
- package/dist/web/public/js/modal/messageQueue.js +0 -112
- package/dist/web/public/js/modal/modalUI.js +0 -214
- package/dist/web/public/js/modal/version.js +0 -20
- package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +0 -370
- package/docs/ONBOARDING_PAGE_DESIGN.md +0 -260
- package/docs/Telemetry.md +0 -136
- package/memory-bank/activeContext.md +0 -26
- package/memory-bank/decisionLog.md +0 -91
- package/memory-bank/productContext.md +0 -41
- package/memory-bank/progress.md +0 -35
- package/memory-bank/systemPatterns.md +0 -10
- package/src/cli/commands/install.ts +0 -139
- package/src/cli/commands/list.ts +0 -113
- package/src/cli/commands/pull.ts +0 -16
- package/src/cli/commands/serve.ts +0 -39
- package/src/cli/commands/uninstall.ts +0 -64
- package/src/cli/index.ts +0 -82
- package/src/core/installers/clients/BaseClientInstaller.ts +0 -341
- package/src/core/installers/clients/ClientInstaller.ts +0 -222
- package/src/core/installers/clients/ClientInstallerFactory.ts +0 -43
- package/src/core/installers/clients/ClineInstaller.ts +0 -35
- package/src/core/installers/clients/ExtensionInstaller.ts +0 -165
- package/src/core/installers/clients/GithubCopilotInstaller.ts +0 -79
- package/src/core/installers/clients/MSRooCodeInstaller.ts +0 -32
- package/src/core/installers/index.ts +0 -11
- package/src/core/installers/requirements/BaseInstaller.ts +0 -85
- package/src/core/installers/requirements/CommandInstaller.ts +0 -231
- package/src/core/installers/requirements/GeneralInstaller.ts +0 -133
- package/src/core/installers/requirements/InstallerFactory.ts +0 -114
- package/src/core/installers/requirements/NpmInstaller.ts +0 -271
- package/src/core/installers/requirements/NugetInstaller.ts +0 -203
- package/src/core/installers/requirements/PipInstaller.ts +0 -207
- package/src/core/installers/requirements/RequirementInstaller.ts +0 -42
- package/src/core/loaders/ConfigurationLoader.ts +0 -298
- package/src/core/loaders/ConfigurationProvider.ts +0 -462
- package/src/core/loaders/InstallOperationManager.ts +0 -367
- package/src/core/loaders/ServerSchemaLoader.ts +0 -117
- package/src/core/loaders/ServerSchemaProvider.ts +0 -99
- package/src/core/loaders/SystemSettingsManager.ts +0 -278
- package/src/core/metadatas/constants.ts +0 -122
- package/src/core/metadatas/recordingConstants.ts +0 -65
- package/src/core/metadatas/types.ts +0 -202
- package/src/core/onboard/FeedOnboardService.ts +0 -501
- package/src/core/onboard/OnboardProcessor.ts +0 -356
- package/src/core/onboard/OnboardStatus.ts +0 -60
- package/src/core/onboard/OnboardStatusManager.ts +0 -416
- package/src/core/validators/FeedValidator.ts +0 -135
- package/src/core/validators/IServerValidator.ts +0 -21
- package/src/core/validators/SSEServerValidator.ts +0 -43
- package/src/core/validators/ServerValidatorFactory.ts +0 -51
- package/src/core/validators/StdioServerValidator.ts +0 -313
- package/src/index.ts +0 -44
- package/src/services/InstallationService.ts +0 -102
- package/src/services/MCPManager.ts +0 -249
- package/src/services/RequirementService.ts +0 -627
- package/src/services/ServerService.ts +0 -161
- package/src/services/TelemetryService.ts +0 -59
- package/src/utils/UpdateCheckTracker.ts +0 -86
- package/src/utils/adoUtils.ts +0 -293
- package/src/utils/clientUtils.ts +0 -72
- package/src/utils/feedUtils.ts +0 -31
- package/src/utils/githubAuth.ts +0 -212
- package/src/utils/githubUtils.ts +0 -164
- package/src/utils/logger.ts +0 -195
- package/src/utils/macroExpressionUtils.ts +0 -104
- package/src/utils/osUtils.ts +0 -700
- package/src/utils/versionUtils.ts +0 -114
- package/src/web/contract/serverContract.ts +0 -74
- package/src/web/public/css/detailsWidget.css +0 -235
- package/src/web/public/css/modal.css +0 -757
- package/src/web/public/css/notifications.css +0 -101
- package/src/web/public/css/onboard.css +0 -107
- package/src/web/public/css/serverCategoryList.css +0 -120
- package/src/web/public/css/serverDetails.css +0 -139
- package/src/web/public/index.html +0 -359
- package/src/web/public/js/api.js +0 -132
- package/src/web/public/js/detailsWidget.js +0 -264
- package/src/web/public/js/flights/flights.js +0 -127
- package/src/web/public/js/modal/index.js +0 -52
- package/src/web/public/js/modal/installModal.js +0 -162
- package/src/web/public/js/modal/installation.js +0 -266
- package/src/web/public/js/modal/loadingModal.js +0 -182
- package/src/web/public/js/modal/modalSetup.js +0 -595
- package/src/web/public/js/modal/modalUtils.js +0 -37
- package/src/web/public/js/modal/versionUtils.js +0 -20
- package/src/web/public/js/modal.js +0 -42
- package/src/web/public/js/notifications.js +0 -137
- package/src/web/public/js/onboard/formProcessor.js +0 -1037
- package/src/web/public/js/onboard/index.js +0 -374
- package/src/web/public/js/onboard/publishHandler.js +0 -172
- package/src/web/public/js/onboard/state.js +0 -76
- package/src/web/public/js/onboard/templates.js +0 -342
- package/src/web/public/js/onboard/uiHandlers.js +0 -1076
- package/src/web/public/js/onboard/validationHandlers.js +0 -493
- package/src/web/public/js/serverCategoryDetails.js +0 -364
- package/src/web/public/js/serverCategoryList.js +0 -241
- package/src/web/public/js/settings.js +0 -314
- package/src/web/public/modal.html +0 -84
- package/src/web/public/onboard.html +0 -296
- package/src/web/public/settings.html +0 -135
- package/src/web/public/styles.css +0 -277
- package/src/web/server.ts +0 -478
- package/tsconfig.json +0 -18
- package/wiki/Installation.md +0 -3
- package/wiki/Publish.md +0 -3
|
@@ -1,627 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RequirementConfig,
|
|
3
|
-
RequirementStatus,
|
|
4
|
-
ServerInstallOptions,
|
|
5
|
-
OperationStatus,
|
|
6
|
-
FeedConfiguration,
|
|
7
|
-
McpConfig,
|
|
8
|
-
ServerOperationResult,
|
|
9
|
-
MCPServerCategory
|
|
10
|
-
} from '../core/metadatas/types.js';
|
|
11
|
-
import { createInstallerFactory, InstallerFactory } from '../core/installers/index.js';
|
|
12
|
-
import { exec } from 'child_process';
|
|
13
|
-
import util from 'util';
|
|
14
|
-
import { configProvider, ConfigurationProvider } from '../core/loaders/ConfigurationProvider.js';
|
|
15
|
-
import { Logger } from '../utils/logger.js';
|
|
16
|
-
import { updateCheckTracker } from '../utils/UpdateCheckTracker.js';
|
|
17
|
-
import { InstallOperationManager } from '../core/loaders/InstallOperationManager.js';
|
|
18
|
-
import { UPDATE_CHECK_INTERVAL_MS } from '../core/metadatas/constants.js';
|
|
19
|
-
import * as RecordingConstants from '../core/metadatas/recordingConstants.js';
|
|
20
|
-
import { systemSettingsManager } from '../core/loaders/SystemSettingsManager.js';
|
|
21
|
-
/**
|
|
22
|
-
* Service responsible for managing requirements installation and status
|
|
23
|
-
*/
|
|
24
|
-
export class RequirementService {
|
|
25
|
-
private static instance: RequirementService;
|
|
26
|
-
private installerFactory: InstallerFactory;
|
|
27
|
-
|
|
28
|
-
private constructor() {
|
|
29
|
-
this.installerFactory = createInstallerFactory(util.promisify(exec));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get the singleton instance of RequirementService
|
|
34
|
-
* @returns The RequirementService instance
|
|
35
|
-
*/
|
|
36
|
-
public static getInstance(): RequirementService {
|
|
37
|
-
if (!RequirementService.instance) {
|
|
38
|
-
RequirementService.instance = new RequirementService();
|
|
39
|
-
}
|
|
40
|
-
return RequirementService.instance;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private generateOperationId(): string {
|
|
44
|
-
return `install-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Checks and installs requirements for a server if needed.
|
|
49
|
-
* @param categoryName The category name.
|
|
50
|
-
* @param serverName The server name.
|
|
51
|
-
* @param options The installation options.
|
|
52
|
-
* @returns A failure result if requirements check fails, null if requirements are satisfied or installation started in background.
|
|
53
|
-
*/
|
|
54
|
-
public async checkAndInstallRequirements(categoryName: string, serverName: string, options: ServerInstallOptions): Promise<ServerOperationResult | null> {
|
|
55
|
-
const recoder = InstallOperationManager.getInstance(categoryName, serverName);
|
|
56
|
-
|
|
57
|
-
return recoder.recording(async () => {
|
|
58
|
-
const configProvider = ConfigurationProvider.getInstance();
|
|
59
|
-
const feedConfig = await configProvider.getFeedConfiguration(categoryName);
|
|
60
|
-
|
|
61
|
-
if (!feedConfig) {
|
|
62
|
-
const errorMsg = 'Feed configuration not found';
|
|
63
|
-
// No need to record step here, recoder.recording will handle failure
|
|
64
|
-
return {
|
|
65
|
-
success: false, message: errorMsg,
|
|
66
|
-
status: [{ status: 'failed', type: 'install', target: 'server', message: errorMsg }]
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const serverConfig = feedConfig.mcpServers.find((s: McpConfig) => s.name === serverName);
|
|
72
|
-
if (!serverConfig?.dependencies?.requirements || serverConfig.dependencies.requirements.length === 0) {
|
|
73
|
-
const msg = `No requirements for ${serverName} in category ${categoryName}`;
|
|
74
|
-
Logger.debug(msg);
|
|
75
|
-
await recoder.recordStep(RecordingConstants.STEP_CHECKING_REQUIREMENT_STATUS, 'completed', msg);
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const ready = await recoder.recording(
|
|
80
|
-
async () => {
|
|
81
|
-
await recoder.recordStep(RecordingConstants.STEP_CHECKING_REQUIREMENT_STATUS, 'in-progress', 'Checking status of all requirements.');
|
|
82
|
-
const requirementStatuses = await Promise.all(
|
|
83
|
-
serverConfig.dependencies!.requirements!.map(async (req) => {
|
|
84
|
-
const reqConfig = feedConfig.requirements?.find((r: RequirementConfig) => r.name === req.name) || {
|
|
85
|
-
name: req.name, version: req.version, type: 'npm' // Default to npm if not fully defined
|
|
86
|
-
};
|
|
87
|
-
return await this.installerFactory.checkInstallation(reqConfig, options);
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const requirementsReady = await configProvider.isRequirementsReady(categoryName, serverName);
|
|
92
|
-
for (const status of requirementStatuses) {
|
|
93
|
-
if (status.installed && !requirementsReady) {
|
|
94
|
-
await configProvider.updateRequirementStatus(categoryName, status.name, { ...status, installed: true });
|
|
95
|
-
} else if (!status.installed && requirementsReady) {
|
|
96
|
-
await configProvider.updateRequirementStatus(categoryName, status.name, { ...status, installed: false });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return requirementStatuses.every(status => status.installed);
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
stepName: RecordingConstants.STEP_CHECKING_REQUIREMENT_STATUS,
|
|
104
|
-
inProgressMessage: `Checking status of all requirements for ${serverName}`,
|
|
105
|
-
endMessage: (ready) => ready ? `Requirements for ${serverName} in ${categoryName} are already installed.` : 'Requirements check completed. Some requirements need installation.',
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
// If requirements are already installed, return null
|
|
110
|
-
if (ready) return null;
|
|
111
|
-
|
|
112
|
-
const sortedRequirements = [...serverConfig.dependencies.requirements].sort((a, b) => {
|
|
113
|
-
const orderA = a.order ?? Infinity;
|
|
114
|
-
const orderB = b.order ?? Infinity;
|
|
115
|
-
return orderA - orderB;
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// Use recordingAsync for the background task
|
|
119
|
-
recoder.recordingAsync(
|
|
120
|
-
() => this.installRequirementsInBackground(categoryName, serverName, feedConfig, sortedRequirements, options, recoder),
|
|
121
|
-
{
|
|
122
|
-
stepName: RecordingConstants.STEP_INSTALLING_REQUIREMENTS_IN_BACKGROUND,
|
|
123
|
-
inProgressMessage: 'Starting background installation of requirements.',
|
|
124
|
-
endMessage: () => 'Background installation of requirements completed.',
|
|
125
|
-
onError: (err) => {
|
|
126
|
-
const errorMsg = `Error in background requirement installations for ${serverName} in ${categoryName}: ${err instanceof Error ? err.message : String(err)}`;
|
|
127
|
-
Logger.error(errorMsg);
|
|
128
|
-
return errorMsg; // This message will be recorded for the 'failed' step
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
// The main operation returns null as installation is happening in background
|
|
133
|
-
return null;
|
|
134
|
-
}, {
|
|
135
|
-
stepName: RecordingConstants.STEP_CHECK_AND_INSTALL_REQUIREMENTS,
|
|
136
|
-
inProgressMessage: `Checking and installing requirements for ${serverName}`,
|
|
137
|
-
endMessage: (result) => result?.success === false ? `Requirement check/install failed: ${result.message}` : `Requirement check and install process for ${serverName} completed.`,
|
|
138
|
-
onResult: (result) => result === null || result.success !== false // Success if null (bg install) or result.success is not false
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Installs requirements in background without blocking the main thread.
|
|
144
|
-
* Requirements with the same order are installed in parallel.
|
|
145
|
-
* @param categoryName The category name.
|
|
146
|
-
* @param feedConfig The feed configuration.
|
|
147
|
-
* @param sortedRequirements Array of requirements sorted by order.
|
|
148
|
-
* @param options The installation options.
|
|
149
|
-
*/
|
|
150
|
-
private async installRequirementsInBackground(
|
|
151
|
-
categoryName: string,
|
|
152
|
-
serverName: string,
|
|
153
|
-
feedConfig: FeedConfiguration,
|
|
154
|
-
sortedRequirements: Array<{ name: string; version: string; order?: number }>,
|
|
155
|
-
options: ServerInstallOptions,
|
|
156
|
-
recoder: InstallOperationManager // Added recoder parameter
|
|
157
|
-
): Promise<void> {
|
|
158
|
-
const configProvider = ConfigurationProvider.getInstance();
|
|
159
|
-
type RequirementType = { name: string; version: string; order?: number };
|
|
160
|
-
const requirementGroups = sortedRequirements.reduce<Record<number, RequirementType[]>>((groups, req) => {
|
|
161
|
-
const order = req.order ?? Infinity;
|
|
162
|
-
if (!groups[order]) {
|
|
163
|
-
groups[order] = [];
|
|
164
|
-
}
|
|
165
|
-
groups[order].push(req);
|
|
166
|
-
return groups;
|
|
167
|
-
}, {});
|
|
168
|
-
|
|
169
|
-
const orderKeys = Object.keys(requirementGroups).map(Number).sort((a, b) => a - b);
|
|
170
|
-
for (const order of orderKeys) {
|
|
171
|
-
const group = requirementGroups[order];
|
|
172
|
-
await Promise.all(group.map(async requirement => {
|
|
173
|
-
const stepName = `InstallRequirement_${requirement.name}`;
|
|
174
|
-
return recoder.recording(async () => {
|
|
175
|
-
let requirementConfig = feedConfig.requirements?.find((r: RequirementConfig) => r.name === requirement.name);
|
|
176
|
-
if (!requirementConfig) {
|
|
177
|
-
requirementConfig = { name: requirement.name, version: requirement.version, type: 'npm' }; // Default
|
|
178
|
-
const warnMsg = `Requirement ${requirement.name} not found in feed's requirements definitions for category ${categoryName}. Using default config.`;
|
|
179
|
-
Logger.warn(warnMsg);
|
|
180
|
-
// This case is a "completion" of this specific step with a warning, not a failure.
|
|
181
|
-
// The recording will mark it completed, and the message will be this warning.
|
|
182
|
-
return { installed: true, message: warnMsg, type: requirementConfig.type, name: requirement.name, version: requirement.version };
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
let currentOptions = { ...options };
|
|
186
|
-
const currentStatus = await configProvider.getRequirementStatus(categoryName, requirement.name);
|
|
187
|
-
if (requirementConfig.type === 'pip' && currentStatus?.pythonEnv && !currentOptions?.settings?.pythonEnv) {
|
|
188
|
-
currentOptions = {
|
|
189
|
-
...currentOptions,
|
|
190
|
-
settings: { ...currentOptions?.settings, pythonEnv: currentStatus.pythonEnv }
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const installer = this.installerFactory.getInstaller(requirementConfig);
|
|
195
|
-
if (!installer) {
|
|
196
|
-
const errorMsg = `No installer found for requirement type: ${requirementConfig.type}`;
|
|
197
|
-
await this.updateRequirementFailureStatus(categoryName, requirement.name, requirementConfig.type, errorMsg);
|
|
198
|
-
throw new Error(errorMsg); // Caught by recoder.recording
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const operationId = this.generateOperationId();
|
|
202
|
-
await this.updateRequirementProgressStatus(categoryName, requirement.name, requirementConfig.type, operationId);
|
|
203
|
-
|
|
204
|
-
const installStatus = await installer.install(requirementConfig, recoder, currentOptions);
|
|
205
|
-
const success = installStatus.installed;
|
|
206
|
-
const message = success ? `Requirement ${requirement.name} installed successfully` : `Failed to install ${requirement.name}: ${installStatus.error || 'Unknown error'}`;
|
|
207
|
-
|
|
208
|
-
await this.updateRequirementCompletionStatus(categoryName, requirement.name, installStatus, operationId);
|
|
209
|
-
if (!success) {
|
|
210
|
-
throw new Error(message); // Caught by recoder.recording
|
|
211
|
-
}
|
|
212
|
-
return { ...installStatus, message };
|
|
213
|
-
}, {
|
|
214
|
-
stepName: stepName,
|
|
215
|
-
inProgressMessage: `Starting installation of ${requirement.name}`,
|
|
216
|
-
onResult: (status) => status.installed,
|
|
217
|
-
endMessage: (status) => status.message // Use the message from the installStatus
|
|
218
|
-
});
|
|
219
|
-
}));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Helper to update requirement status for failure case.
|
|
225
|
-
* @param categoryName The category name.
|
|
226
|
-
* @param requirementName The name of the requirement.
|
|
227
|
-
* @param requirementType The type of the requirement.
|
|
228
|
-
* @param errorMessage The error message.
|
|
229
|
-
*/
|
|
230
|
-
private async updateRequirementFailureStatus(
|
|
231
|
-
categoryName: string, requirementName: string, requirementType: string, errorMessage: string
|
|
232
|
-
): Promise<void> {
|
|
233
|
-
const configProvider = ConfigurationProvider.getInstance();
|
|
234
|
-
await configProvider.updateRequirementStatus(categoryName, requirementName, {
|
|
235
|
-
name: requirementName, type: requirementType, installed: false, error: errorMessage,
|
|
236
|
-
operationStatus: {
|
|
237
|
-
status: 'failed', type: 'install', target: 'requirement',
|
|
238
|
-
message: `Error installing requirement: ${errorMessage}`,
|
|
239
|
-
operationId: this.generateOperationId()
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Helper to update requirement status for in-progress case.
|
|
246
|
-
* @param categoryName The category name.
|
|
247
|
-
* @param requirementName The name of the requirement.
|
|
248
|
-
* @param requirementType The type of the requirement.
|
|
249
|
-
* @param operationId The operation ID.
|
|
250
|
-
*/
|
|
251
|
-
private async updateRequirementProgressStatus(
|
|
252
|
-
categoryName: string, requirementName: string, requirementType: string, operationId: string
|
|
253
|
-
): Promise<void> {
|
|
254
|
-
const configProvider = ConfigurationProvider.getInstance();
|
|
255
|
-
await configProvider.updateRequirementStatus(categoryName, requirementName, {
|
|
256
|
-
name: requirementName, type: requirementType, installed: false, inProgress: true,
|
|
257
|
-
operationStatus: {
|
|
258
|
-
status: 'in-progress', type: 'install', target: 'requirement',
|
|
259
|
-
message: `Installing requirement: ${requirementName}`, operationId
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Helper to update requirement status for completion case.
|
|
266
|
-
* @param categoryName The category name.
|
|
267
|
-
* @param requirementName The name of the requirement.
|
|
268
|
-
* @param installStatus The installation status.
|
|
269
|
-
* @param operationId The operation ID.
|
|
270
|
-
*/
|
|
271
|
-
private async updateRequirementCompletionStatus(
|
|
272
|
-
categoryName: string, requirementName: string, installStatus: RequirementStatus, operationId: string
|
|
273
|
-
): Promise<void> {
|
|
274
|
-
const configProvider = ConfigurationProvider.getInstance();
|
|
275
|
-
await configProvider.updateRequirementStatus(categoryName, requirementName, {
|
|
276
|
-
...installStatus,
|
|
277
|
-
operationStatus: {
|
|
278
|
-
status: installStatus.installed ? 'completed' : 'failed',
|
|
279
|
-
type: 'install', target: 'requirement',
|
|
280
|
-
message: installStatus.installed
|
|
281
|
-
? `Requirement ${requirementName} installed successfully`
|
|
282
|
-
: `Failed to install ${requirementName}`,
|
|
283
|
-
operationId
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Validate a requirement configuration.
|
|
290
|
-
* @param requirement The requirement to validate.
|
|
291
|
-
* @throws Error if the requirement is invalid.
|
|
292
|
-
*/
|
|
293
|
-
private validateRequirement(requirement: RequirementConfig): void {
|
|
294
|
-
if (!requirement.name) { throw new Error('Requirement name is required'); }
|
|
295
|
-
if (!requirement.type) { throw new Error('Requirement type is required'); }
|
|
296
|
-
if (requirement.type === 'other' && !requirement.registry) {
|
|
297
|
-
throw new Error('Registry must be specified for requirement type "other"');
|
|
298
|
-
}
|
|
299
|
-
if (requirement.registry) {
|
|
300
|
-
const { githubRelease, artifacts } = requirement.registry;
|
|
301
|
-
if (githubRelease) {
|
|
302
|
-
if (!githubRelease.repository) { throw new Error('Repository is required for GitHub release registry'); }
|
|
303
|
-
if (!githubRelease.assetName) { throw new Error('Asset name is required for GitHub release registry'); }
|
|
304
|
-
}
|
|
305
|
-
if (artifacts) {
|
|
306
|
-
if (!artifacts.registryUrl) { throw new Error('Registry URL is required for artifacts registry'); }
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Check for updates to requirements for all server categories
|
|
313
|
-
* This method is called periodically to check for updates
|
|
314
|
-
*/
|
|
315
|
-
public async checkRequirementForUpdateAsync(): Promise<void> {
|
|
316
|
-
const allCategories = await configProvider.getServerCategories();
|
|
317
|
-
allCategories.forEach(
|
|
318
|
-
async (serverCategory) => {
|
|
319
|
-
// Start async check for requirement updates if one isn't already in progress
|
|
320
|
-
if (serverCategory && serverCategory.feedConfiguration && serverCategory.name) {
|
|
321
|
-
// Check if update is already in progress using the tracker
|
|
322
|
-
const shouldCheckForUpdates = await updateCheckTracker.startOperation(serverCategory.name);
|
|
323
|
-
|
|
324
|
-
if (shouldCheckForUpdates) {
|
|
325
|
-
Logger.info(`Checking the status of requirements in ${serverCategory.name}`);
|
|
326
|
-
this.checkRequirementsForUpdateInternal(serverCategory).catch(error => {
|
|
327
|
-
// Ensure we mark the operation as complete on error
|
|
328
|
-
if (serverCategory.name) {
|
|
329
|
-
updateCheckTracker.endOperation(serverCategory.name)
|
|
330
|
-
.catch(lockError => console.error(`Failed to mark update check as complete: ${lockError.message}`));
|
|
331
|
-
}
|
|
332
|
-
Logger.error(`Error checking requirements for updates: ${error.message}`);
|
|
333
|
-
});
|
|
334
|
-
} else {
|
|
335
|
-
Logger.debug(`Update check already in progress for ${serverCategory.name}, skipping`);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
)
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Check for updates to requirements for a specific server category
|
|
344
|
-
* @param categoryName The name of the server category
|
|
345
|
-
* @param serverName The name of the server (optional)
|
|
346
|
-
*/
|
|
347
|
-
public async checkServerRequirementForUpdateAsync(categoryName: string, serverName: string): Promise<void> {
|
|
348
|
-
const serverCategory = await configProvider.getServerCategory(categoryName);
|
|
349
|
-
if (!serverCategory) {
|
|
350
|
-
Logger.error(`Server category ${categoryName} not found`);
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
const shouldCheckForUpdates = await updateCheckTracker.startOperation(`${serverCategory.name}:${serverName}`);
|
|
354
|
-
if (shouldCheckForUpdates) {
|
|
355
|
-
this.checkRequirementsForUpdateInternal(serverCategory, serverName)
|
|
356
|
-
.then(() => {
|
|
357
|
-
// Mark the operation as complete
|
|
358
|
-
updateCheckTracker.endOperation(`${serverCategory.name}:${serverName}`)
|
|
359
|
-
.catch(lockError => console.error(`Failed to mark update check as complete: ${lockError.message}`));
|
|
360
|
-
|
|
361
|
-
})
|
|
362
|
-
.catch(error => {
|
|
363
|
-
// Ensure we mark the operation as complete on error
|
|
364
|
-
updateCheckTracker.endOperation(`${serverCategory.name}:${serverName}`)
|
|
365
|
-
.catch(lockError => console.error(`Failed to mark update check as complete: ${lockError.message}`));
|
|
366
|
-
|
|
367
|
-
Logger.error(`Error checking requirements for updates: ${error.message}`);
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Check for updates to requirements for a server category
|
|
374
|
-
* @param serverCategory The server category to check
|
|
375
|
-
* @param serverName The name of the server (optional). When serverName is provided, check the requirement always
|
|
376
|
-
* @private
|
|
377
|
-
*/
|
|
378
|
-
private async checkRequirementsForUpdateInternal(serverCategory: MCPServerCategory, serverName?: string): Promise<void> {
|
|
379
|
-
if (!serverCategory.name || !serverCategory.feedConfiguration?.requirements?.length) {
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
try {
|
|
383
|
-
|
|
384
|
-
for (const requirement of serverCategory.feedConfiguration.requirements) {
|
|
385
|
-
if (requirement.version.includes('latest')) {
|
|
386
|
-
// Get current status if available
|
|
387
|
-
const currentStatus = serverCategory.installationStatus?.requirementsStatus[requirement.name];
|
|
388
|
-
if (!currentStatus) continue;
|
|
389
|
-
|
|
390
|
-
let providedServerName: string | undefined = serverName;
|
|
391
|
-
if (providedServerName) {
|
|
392
|
-
// If serverName is provided, check if the requirement is associated with that server
|
|
393
|
-
Logger.debug(`Checking whether requirement ${requirement.name} has update for server ${serverName}`);
|
|
394
|
-
const serverConfig = serverCategory.feedConfiguration.mcpServers.find((s: McpConfig) => s.name === serverName);
|
|
395
|
-
if (!serverConfig?.dependencies?.requirements?.some((r) => r.name == requirement.name)) {
|
|
396
|
-
Logger.debug(`Requirement ${requirement.name} is not associated with server ${serverName}. Skipping update check.`);
|
|
397
|
-
continue;
|
|
398
|
-
}
|
|
399
|
-
} else {
|
|
400
|
-
providedServerName = serverCategory.feedConfiguration.mcpServers.find((s: McpConfig) => s.dependencies?.requirements?.some((r) => r.name == requirement.name))?.name;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (!providedServerName) {
|
|
404
|
-
// We need to find the server name for the requirement, if not able to find, skip as the requirement is not associated with any server
|
|
405
|
-
Logger.debug(`No server using requirement ${requirement.name}. Skipping update check.`);
|
|
406
|
-
continue;
|
|
407
|
-
}
|
|
408
|
-
// Check for updates
|
|
409
|
-
const updatedStatus = await this.checkRequirementForUpdates(requirement, currentStatus, serverCategory.name, providedServerName);
|
|
410
|
-
|
|
411
|
-
// If update information is found, update the configuration
|
|
412
|
-
if (updatedStatus.availableUpdate && serverCategory.name) {
|
|
413
|
-
await configProvider.updateRequirementStatus(
|
|
414
|
-
serverCategory.name,
|
|
415
|
-
requirement.name,
|
|
416
|
-
updatedStatus
|
|
417
|
-
);
|
|
418
|
-
|
|
419
|
-
// Also update the in-memory status for immediate use
|
|
420
|
-
if (serverCategory.installationStatus?.requirementsStatus) {
|
|
421
|
-
serverCategory.installationStatus.requirementsStatus[requirement.name] = updatedStatus;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
currentStatus.lastCheckTime = new Date().toISOString();
|
|
425
|
-
await configProvider.updateRequirementStatus(
|
|
426
|
-
serverCategory.name,
|
|
427
|
-
requirement.name,
|
|
428
|
-
currentStatus
|
|
429
|
-
);
|
|
430
|
-
if (serverCategory.installationStatus?.requirementsStatus) {
|
|
431
|
-
serverCategory.installationStatus.requirementsStatus[requirement.name] = updatedStatus;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
} catch (error) {
|
|
436
|
-
Logger.error(`Error checking requirements for updates: ${error instanceof Error ? error.message : String(error)}`);
|
|
437
|
-
throw error; // Re-throw the error to be handled by the caller
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Check the installation status of a requirement
|
|
442
|
-
* @param requirement The requirement to check
|
|
443
|
-
* @param options Optional installation options
|
|
444
|
-
* @returns The installation status
|
|
445
|
-
*/
|
|
446
|
-
public async checkRequirementStatus(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus> {
|
|
447
|
-
this.validateRequirement(requirement);
|
|
448
|
-
return await this.installerFactory.checkInstallation(requirement, options);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Check if updates are available for a requirement
|
|
453
|
-
* @param requirement The requirement to check for updates
|
|
454
|
-
* @param currentStatus The current status of the requirement
|
|
455
|
-
* @param categoryName The category name
|
|
456
|
-
* @param serverName The server name (optional)
|
|
457
|
-
* @returns Updated status with available updates information
|
|
458
|
-
*/
|
|
459
|
-
public async checkRequirementForUpdates(requirement: RequirementConfig, currentStatus: RequirementStatus, categoryName: string, serverName?: string): Promise<RequirementStatus> {
|
|
460
|
-
this.validateRequirement(requirement);
|
|
461
|
-
const installer = this.installerFactory.getInstaller(requirement);
|
|
462
|
-
if (!installer || !installer.supportCheckUpdates()) {
|
|
463
|
-
return currentStatus;
|
|
464
|
-
}
|
|
465
|
-
var systemSettings = await systemSettingsManager.getSystemSettings();
|
|
466
|
-
const options = requirement.type === 'pip'
|
|
467
|
-
? { settings: { pythonEnv: systemSettings.pythonEnvs?.[`${categoryName}:${serverName}`] || systemSettings.pythonEnvs?.system || currentStatus.pythonEnv } }
|
|
468
|
-
: undefined;
|
|
469
|
-
const status = await this.checkRequirementStatus(requirement, options);
|
|
470
|
-
return await (installer as any).checkForUpdates(requirement, status);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Process requirement updates specified in serverInstallOptions.
|
|
475
|
-
* All updates are processed in parallel for maximum efficiency.
|
|
476
|
-
* @param categoryName The category name.
|
|
477
|
-
* @param serverName The server name.
|
|
478
|
-
* @param options The installation options.
|
|
479
|
-
*/
|
|
480
|
-
public async processRequirementUpdates(categoryName: string, serverName: string, options: ServerInstallOptions): Promise<void> {
|
|
481
|
-
const operationKey = `requirement-updates-${categoryName}-${serverName}`;
|
|
482
|
-
const canProceed = await updateCheckTracker.startOperation(operationKey);
|
|
483
|
-
if (!canProceed) {
|
|
484
|
-
Logger.info(`Requirement updates for ${categoryName}/${serverName} already in progress, skipping`);
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
const recoder = InstallOperationManager.getInstance(categoryName, serverName);
|
|
489
|
-
|
|
490
|
-
try {
|
|
491
|
-
await recoder.recording(async () => {
|
|
492
|
-
const configProvider = ConfigurationProvider.getInstance();
|
|
493
|
-
const feedConfig = await configProvider.getFeedConfiguration(categoryName);
|
|
494
|
-
|
|
495
|
-
if (!feedConfig) {
|
|
496
|
-
const errorMsg = `Feed configuration not found for category: ${categoryName}`;
|
|
497
|
-
Logger.error(errorMsg);
|
|
498
|
-
throw new Error(errorMsg); // This will be caught by recoder.recording
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
const updatePromises = options.requirements?.map(async (reqToUpdate) => {
|
|
502
|
-
const stepName = `${RecordingConstants.STEP_INSTALL_REQUIREMENT_PREFIX}: ${reqToUpdate.name}`;
|
|
503
|
-
return recoder.recording(
|
|
504
|
-
async () => {
|
|
505
|
-
let reqConfig: RequirementConfig | undefined;
|
|
506
|
-
let currentStatus: RequirementStatus | undefined | null;
|
|
507
|
-
try {
|
|
508
|
-
reqConfig = feedConfig.requirements?.find((r: RequirementConfig) => r.name === reqToUpdate.name);
|
|
509
|
-
if (!reqConfig) {
|
|
510
|
-
const errorMsg = `Requirement configuration not found for: ${reqToUpdate.name}`;
|
|
511
|
-
Logger.error(errorMsg);
|
|
512
|
-
await configProvider.updateRequirementStatus(categoryName, reqToUpdate.name, {
|
|
513
|
-
name: reqToUpdate.name, type: 'unknown', installed: false, inProgress: false,
|
|
514
|
-
error: errorMsg,
|
|
515
|
-
operationStatus: { status: 'failed', type: 'update', target: 'requirement', message: errorMsg }
|
|
516
|
-
});
|
|
517
|
-
throw new Error(errorMsg);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
currentStatus = await configProvider.getRequirementStatus(categoryName, reqToUpdate.name);
|
|
521
|
-
if (!currentStatus) {
|
|
522
|
-
const errorMsg = `No current status found for requirement: ${reqToUpdate.name}`;
|
|
523
|
-
Logger.error(errorMsg);
|
|
524
|
-
await configProvider.updateRequirementStatus(categoryName, reqToUpdate.name, {
|
|
525
|
-
name: reqToUpdate.name, type: reqConfig.type, installed: false, inProgress: false,
|
|
526
|
-
error: errorMsg,
|
|
527
|
-
operationStatus: { status: 'failed', type: 'update', target: 'requirement', message: errorMsg }
|
|
528
|
-
});
|
|
529
|
-
throw new Error(errorMsg);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
Logger.info(`Updating ${reqToUpdate.name} from ${currentStatus.version || 'unknown'} to ${reqToUpdate.version}`);
|
|
533
|
-
await configProvider.updateRequirementStatus(categoryName, reqToUpdate.name, {
|
|
534
|
-
...currentStatus, name: reqToUpdate.name,
|
|
535
|
-
type: currentStatus.type || reqConfig.type || 'unknown',
|
|
536
|
-
installed: currentStatus.installed || false, inProgress: true,
|
|
537
|
-
operationStatus: {
|
|
538
|
-
status: 'in-progress', type: 'update', target: 'requirement',
|
|
539
|
-
message: `Updating ${reqToUpdate.name} from ${currentStatus.version || 'unknown'} to ${reqToUpdate.version}`
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
let currentOptions = { ...options };
|
|
544
|
-
if (reqConfig.type === 'pip' && currentStatus.pythonEnv && !currentOptions?.settings?.pythonEnv) {
|
|
545
|
-
currentOptions = {
|
|
546
|
-
...currentOptions,
|
|
547
|
-
settings: { ...currentOptions?.settings, pythonEnv: currentStatus.pythonEnv }
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
const updatedStatus = await this.updateRequirement(reqConfig, reqToUpdate.version, recoder, currentOptions);
|
|
552
|
-
|
|
553
|
-
const successMessage = `Successfully updated ${reqToUpdate.name} to version ${reqToUpdate.version}`;
|
|
554
|
-
const failureMessage = `Failed to update ${reqToUpdate.name} to version ${reqToUpdate.version}. Error: ${updatedStatus.error || 'Unknown'}`;
|
|
555
|
-
|
|
556
|
-
await configProvider.updateRequirementStatus(categoryName, reqToUpdate.name, {
|
|
557
|
-
...updatedStatus, name: reqToUpdate.name,
|
|
558
|
-
type: updatedStatus.type || currentStatus.type || reqConfig.type || 'unknown',
|
|
559
|
-
installed: updatedStatus.installed, inProgress: false,
|
|
560
|
-
operationStatus: {
|
|
561
|
-
status: updatedStatus.installed ? 'completed' : 'failed',
|
|
562
|
-
type: 'update', target: 'requirement',
|
|
563
|
-
message: updatedStatus.installed ? successMessage : failureMessage
|
|
564
|
-
},
|
|
565
|
-
availableUpdate: updatedStatus.installed ? undefined : currentStatus.availableUpdate
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
if (!updatedStatus.installed) {
|
|
569
|
-
Logger.error(failureMessage);
|
|
570
|
-
throw new Error(failureMessage);
|
|
571
|
-
}
|
|
572
|
-
Logger.info(successMessage);
|
|
573
|
-
return updatedStatus;
|
|
574
|
-
} catch (error) {
|
|
575
|
-
const errorMsg = `Error updating requirement ${reqToUpdate.name}: ${error instanceof Error ? error.message : String(error)}`;
|
|
576
|
-
Logger.error(errorMsg);
|
|
577
|
-
await configProvider.updateRequirementStatus(categoryName, reqToUpdate.name, {
|
|
578
|
-
name: reqToUpdate.name,
|
|
579
|
-
type: reqConfig?.type || currentStatus?.type || 'unknown',
|
|
580
|
-
installed: false, inProgress: false,
|
|
581
|
-
error: error instanceof Error ? error.message : String(error),
|
|
582
|
-
operationStatus: { status: 'failed', type: 'update', target: 'requirement', message: errorMsg }
|
|
583
|
-
});
|
|
584
|
-
throw error; // Re-throw to be handled by recoder.recording
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
stepName: stepName,
|
|
589
|
-
inProgressMessage: `Processing update for requirement ${reqToUpdate.name}`,
|
|
590
|
-
onResult: (status) => status.installed, // status is the returned updatedStatus
|
|
591
|
-
}
|
|
592
|
-
);
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
if (updatePromises) {
|
|
596
|
-
await Promise.all(updatePromises);
|
|
597
|
-
}
|
|
598
|
-
}, {
|
|
599
|
-
stepName: RecordingConstants.STEP_PROCESS_REQUIREMENT_UPDATES,
|
|
600
|
-
inProgressMessage: `Starting to process requirement updates for ${serverName}`,
|
|
601
|
-
// If fn() succeeds, data is void. If fn() throws, recording() uses the error message.
|
|
602
|
-
endMessage: () => `Finished processing requirement updates for ${serverName}`
|
|
603
|
-
});
|
|
604
|
-
} finally {
|
|
605
|
-
await updateCheckTracker.endOperation(operationKey);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* Update a requirement to a new version
|
|
611
|
-
* @param requirement The requirement configuration
|
|
612
|
-
* @param updateVersion The version to update to
|
|
613
|
-
* @param options Optional installation options
|
|
614
|
-
* @returns The updated requirement status
|
|
615
|
-
*/
|
|
616
|
-
private async updateRequirement(requirement: RequirementConfig, updateVersion: string, recorder: InstallOperationManager, options?: ServerInstallOptions): Promise<RequirementStatus> {
|
|
617
|
-
this.validateRequirement(requirement);
|
|
618
|
-
const updatedRequirement: RequirementConfig = {
|
|
619
|
-
...requirement,
|
|
620
|
-
version: requirement.version.includes('latest') ? requirement.version : updateVersion,
|
|
621
|
-
};
|
|
622
|
-
return await this.installerFactory.install(updatedRequirement, recorder, options);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// Export a singleton instance
|
|
627
|
-
export const requirementService = RequirementService.getInstance();
|