imcp 0.1.4 → 0.1.6

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 (57) hide show
  1. package/.github/workflows/build.yml +28 -0
  2. package/README.md +21 -4
  3. package/dist/cli/commands/start.d.ts +2 -0
  4. package/dist/cli/commands/start.js +32 -0
  5. package/dist/cli/commands/sync.d.ts +2 -0
  6. package/dist/cli/commands/sync.js +17 -0
  7. package/dist/cli/index.js +0 -0
  8. package/dist/core/ConfigurationLoader.d.ts +32 -0
  9. package/dist/core/ConfigurationLoader.js +236 -0
  10. package/dist/core/ConfigurationProvider.d.ts +35 -0
  11. package/dist/core/ConfigurationProvider.js +375 -0
  12. package/dist/core/InstallationService.d.ts +50 -0
  13. package/dist/core/InstallationService.js +350 -0
  14. package/dist/core/MCPManager.d.ts +28 -0
  15. package/dist/core/MCPManager.js +188 -0
  16. package/dist/core/RequirementService.d.ts +40 -0
  17. package/dist/core/RequirementService.js +110 -0
  18. package/dist/core/ServerSchemaLoader.d.ts +11 -0
  19. package/dist/core/ServerSchemaLoader.js +43 -0
  20. package/dist/core/ServerSchemaProvider.d.ts +17 -0
  21. package/dist/core/ServerSchemaProvider.js +120 -0
  22. package/dist/core/constants.d.ts +47 -0
  23. package/dist/core/constants.js +94 -0
  24. package/dist/core/installers/BaseInstaller.d.ts +74 -0
  25. package/dist/core/installers/BaseInstaller.js +253 -0
  26. package/dist/core/installers/ClientInstaller.d.ts +23 -0
  27. package/dist/core/installers/ClientInstaller.js +564 -0
  28. package/dist/core/installers/CommandInstaller.d.ts +37 -0
  29. package/dist/core/installers/CommandInstaller.js +173 -0
  30. package/dist/core/installers/GeneralInstaller.d.ts +33 -0
  31. package/dist/core/installers/GeneralInstaller.js +85 -0
  32. package/dist/core/installers/InstallerFactory.d.ts +54 -0
  33. package/dist/core/installers/InstallerFactory.js +97 -0
  34. package/dist/core/installers/NpmInstaller.d.ts +26 -0
  35. package/dist/core/installers/NpmInstaller.js +127 -0
  36. package/dist/core/installers/PipInstaller.d.ts +28 -0
  37. package/dist/core/installers/PipInstaller.js +127 -0
  38. package/dist/core/installers/RequirementInstaller.d.ts +33 -0
  39. package/dist/core/installers/RequirementInstaller.js +3 -0
  40. package/dist/core/types.d.ts +166 -0
  41. package/dist/core/types.js +16 -0
  42. package/dist/services/InstallRequestValidator.d.ts +21 -0
  43. package/dist/services/InstallRequestValidator.js +99 -0
  44. package/dist/web/public/index.html +1 -1
  45. package/dist/web/public/js/modal/installHandler.js +227 -0
  46. package/dist/web/public/js/modal/loadingUI.js +74 -0
  47. package/dist/web/public/js/modal/messageQueue.js +101 -45
  48. package/dist/web/public/js/modal/modalUI.js +214 -0
  49. package/dist/web/public/js/modal/version.js +20 -0
  50. package/dist/web/public/onboard.html +4 -4
  51. package/package.json +1 -1
  52. package/src/web/public/index.html +1 -1
  53. package/src/web/public/onboard.html +4 -4
  54. package/wiki/Installation.md +3 -0
  55. package/wiki/Publish.md +3 -0
  56. package/dist/core/onboard/InstallOperationManager.d.ts +0 -23
  57. package/dist/core/onboard/InstallOperationManager.js +0 -144
@@ -0,0 +1,173 @@
1
+ import { OSType } from '../types.js';
2
+ import { BaseInstaller } from './BaseInstaller.js';
3
+ import { getOSType, refreshPathEnv } from '../../utils/osUtils.js';
4
+ import { Logger } from '../../utils/logger.js';
5
+ /**
6
+ * Installer implementation for command-line tools
7
+ */
8
+ export class CommandInstaller extends BaseInstaller {
9
+ /**
10
+ * Mapping of command names to their package IDs
11
+ * This handles special cases where the command name differs from the package ID
12
+ */
13
+ commandMappings = {
14
+ 'uv': { windows: 'astral-sh.uv', macos: 'uv' }
15
+ // Add more mappings as needed
16
+ };
17
+ /**
18
+ * Check if this installer can handle the given requirement type
19
+ * @param requirement The requirement to check
20
+ * @returns True if this installer can handle the requirement
21
+ */
22
+ canHandle(requirement) {
23
+ return requirement.type === 'command';
24
+ }
25
+ supportCheckUpdates() {
26
+ return false;
27
+ }
28
+ /**
29
+ * Get the mapped package ID for a command
30
+ * @param commandName The command name to map
31
+ * @returns The mapped package ID
32
+ */
33
+ getMappedPackageId(commandName) {
34
+ const osType = getOSType();
35
+ const mapping = this.commandMappings[commandName];
36
+ if (mapping) {
37
+ return osType === OSType.Windows ? mapping.windows : mapping.macos;
38
+ }
39
+ // If no mapping exists, use the command name itself
40
+ return commandName;
41
+ }
42
+ /**
43
+ * Check if the command is already installed
44
+ * @param requirement The requirement to check
45
+ * @returns The status of the requirement
46
+ */
47
+ async checkInstallation(requirement) {
48
+ try {
49
+ await refreshPathEnv();
50
+ const commandName = requirement.alias || requirement.name;
51
+ const osType = getOSType();
52
+ let commandResult;
53
+ if (osType === OSType.Windows) {
54
+ // Check if command exists on Windows
55
+ try {
56
+ commandResult = await this.execPromise(`where ${commandName} 2>nul`);
57
+ }
58
+ catch (error) {
59
+ Logger.debug(`Error checking command existence: ${error}`);
60
+ // On Windows, 'where' command returns non-zero exit code if the command is not found
61
+ // We'll handle this as "command not found" rather than an error
62
+ commandResult = { stdout: '', stderr: '' };
63
+ }
64
+ }
65
+ else {
66
+ // Check if command exists on macOS/Linux
67
+ try {
68
+ commandResult = await this.execPromise(`which ${commandName} 2>/dev/null`);
69
+ }
70
+ catch (error) {
71
+ Logger.debug(`Error checking command existence: ${error}`);
72
+ // Similarly handle command not found on Unix systems
73
+ commandResult = { stdout: '', stderr: '' };
74
+ }
75
+ }
76
+ // If the command exists, it will return a path or multiple paths
77
+ const installed = commandResult.stdout.trim().length > 0;
78
+ // Try to get version information if available
79
+ let version;
80
+ if (installed) {
81
+ try {
82
+ const versionResult = await this.execPromise(`${commandName} --version`);
83
+ if (versionResult.stdout) {
84
+ // Extract version information - this is a simple approach that might need refinement
85
+ const versionMatch = versionResult.stdout.match(/\d+\.\d+(\.\d+)?/);
86
+ version = versionMatch ? versionMatch[0] : undefined;
87
+ }
88
+ }
89
+ catch (error) {
90
+ Logger.debug(`Error checking command version: ${error}`);
91
+ // Ignore errors from version check, consider it installed anyway
92
+ }
93
+ }
94
+ return {
95
+ name: requirement.name,
96
+ type: 'command',
97
+ installed,
98
+ version,
99
+ inProgress: false
100
+ };
101
+ }
102
+ catch (error) {
103
+ Logger.error(`Error checking installation: ${error}`);
104
+ return {
105
+ name: requirement.name,
106
+ type: 'command',
107
+ installed: false,
108
+ error: error instanceof Error ? error.message : String(error),
109
+ inProgress: false
110
+ };
111
+ }
112
+ }
113
+ /**
114
+ * Install the command
115
+ * @param requirement The requirement to install
116
+ * @returns The status of the installation
117
+ */
118
+ async install(requirement) {
119
+ try {
120
+ const status = await this.checkInstallation(requirement);
121
+ if (status.installed) {
122
+ return status;
123
+ }
124
+ const packageId = this.getMappedPackageId(requirement.name);
125
+ const osType = getOSType();
126
+ let installCommand;
127
+ if (osType === OSType.Windows) {
128
+ // Windows installation using winget
129
+ installCommand = `winget install --id ${packageId}`;
130
+ if (requirement.version && requirement.version !== 'latest') {
131
+ installCommand += ` --version ${requirement.version}`;
132
+ }
133
+ }
134
+ else if (osType === OSType.MacOS) {
135
+ // macOS installation using Homebrew
136
+ installCommand = `brew install ${packageId}`;
137
+ if (requirement.version && requirement.version !== 'latest') {
138
+ installCommand += `@${requirement.version}`;
139
+ }
140
+ }
141
+ else {
142
+ throw new Error(`Unsupported operating system for installing ${requirement.name}`);
143
+ }
144
+ // Execute the installation command
145
+ const { stderr } = await this.execPromise(installCommand);
146
+ if (stderr && stderr.toLowerCase().includes('error')) {
147
+ throw new Error(stderr);
148
+ }
149
+ // Check if installation was successful
150
+ const updatedStatus = await this.checkInstallation(requirement);
151
+ if (!updatedStatus.installed) {
152
+ throw new Error(`Failed to install ${requirement.name}`);
153
+ }
154
+ return {
155
+ name: requirement.name,
156
+ type: 'command',
157
+ installed: true,
158
+ version: updatedStatus.version || requirement.version,
159
+ inProgress: false
160
+ };
161
+ }
162
+ catch (error) {
163
+ return {
164
+ name: requirement.name,
165
+ type: 'command',
166
+ installed: false,
167
+ error: error instanceof Error ? error.message : String(error),
168
+ inProgress: false
169
+ };
170
+ }
171
+ }
172
+ }
173
+ //# sourceMappingURL=CommandInstaller.js.map
@@ -0,0 +1,33 @@
1
+ import { RequirementConfig, RequirementStatus } from '../types.js';
2
+ import { BaseInstaller } from './BaseInstaller.js';
3
+ /**
4
+ * Installer implementation for general requirements (type 'other')
5
+ * This installer handles requirements that don't fit into specific package manager categories
6
+ */
7
+ export declare class GeneralInstaller extends BaseInstaller {
8
+ /**
9
+ * Check if this installer can handle the given requirement type
10
+ * @param requirement The requirement to check
11
+ * @returns True if this installer can handle the requirement
12
+ */
13
+ canHandle(requirement: RequirementConfig): boolean;
14
+ supportCheckUpdates(): boolean;
15
+ /**
16
+ * Check if the requirement is already installed
17
+ * For general installers, we can't easily check if something is installed
18
+ * without specific knowledge of the requirement, so we always return false
19
+ *
20
+ * @param requirement The requirement to check
21
+ * @returns The status of the requirement
22
+ */
23
+ checkInstallation(requirement: RequirementConfig): Promise<RequirementStatus>;
24
+ /**
25
+ * Install the general requirement
26
+ * For type 'other', this doesn't actually install anything, but downloads
27
+ * or locates the asset and returns the path for the caller to use
28
+ *
29
+ * @param requirement The requirement to install
30
+ * @returns The status of the installation, including the install path in updateInfo
31
+ */
32
+ install(requirement: RequirementConfig): Promise<RequirementStatus>;
33
+ }
@@ -0,0 +1,85 @@
1
+ import { BaseInstaller } from './BaseInstaller.js';
2
+ /**
3
+ * Installer implementation for general requirements (type 'other')
4
+ * This installer handles requirements that don't fit into specific package manager categories
5
+ */
6
+ export class GeneralInstaller extends BaseInstaller {
7
+ /**
8
+ * Check if this installer can handle the given requirement type
9
+ * @param requirement The requirement to check
10
+ * @returns True if this installer can handle the requirement
11
+ */
12
+ canHandle(requirement) {
13
+ return requirement.type === 'other';
14
+ }
15
+ supportCheckUpdates() {
16
+ return false;
17
+ }
18
+ /**
19
+ * Check if the requirement is already installed
20
+ * For general installers, we can't easily check if something is installed
21
+ * without specific knowledge of the requirement, so we always return false
22
+ *
23
+ * @param requirement The requirement to check
24
+ * @returns The status of the requirement
25
+ */
26
+ async checkInstallation(requirement) {
27
+ // For general installers, we can't easily check if something is installed
28
+ // So we'll always return not installed, and the actual installation will check
29
+ return {
30
+ name: requirement.name,
31
+ type: 'other',
32
+ installed: false,
33
+ inProgress: false
34
+ };
35
+ }
36
+ /**
37
+ * Install the general requirement
38
+ * For type 'other', this doesn't actually install anything, but downloads
39
+ * or locates the asset and returns the path for the caller to use
40
+ *
41
+ * @param requirement The requirement to install
42
+ * @returns The status of the installation, including the install path in updateInfo
43
+ */
44
+ async install(requirement) {
45
+ try {
46
+ // For type 'other', a registry must be specified
47
+ if (!requirement.registry) {
48
+ throw new Error('Registry must be specified for requirement type "other"');
49
+ }
50
+ let installPath;
51
+ if (requirement.registry.githubRelease) {
52
+ const result = await this.handleGitHubRelease(requirement, requirement.registry.githubRelease);
53
+ installPath = result.resolvedPath;
54
+ }
55
+ else if (requirement.registry.artifacts) {
56
+ installPath = await this.handleArtifactsRegistry(requirement, requirement.registry.artifacts);
57
+ }
58
+ else if (requirement.registry.local) {
59
+ installPath = await this.handleLocalRegistry(requirement, requirement.registry.local);
60
+ }
61
+ else {
62
+ throw new Error('Invalid registry configuration');
63
+ }
64
+ // For general installer, we just return the path to the downloaded/located file
65
+ // The actual installation mechanism would depend on the specific requirement
66
+ return {
67
+ name: requirement.name,
68
+ type: 'other',
69
+ installed: true,
70
+ version: requirement.version,
71
+ inProgress: false,
72
+ };
73
+ }
74
+ catch (error) {
75
+ return {
76
+ name: requirement.name,
77
+ type: 'other',
78
+ installed: false,
79
+ error: error instanceof Error ? error.message : String(error),
80
+ inProgress: false
81
+ };
82
+ }
83
+ }
84
+ }
85
+ //# sourceMappingURL=GeneralInstaller.js.map
@@ -0,0 +1,54 @@
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../types.js';
2
+ import { RequirementInstaller } from './RequirementInstaller.js';
3
+ import { exec } from 'child_process';
4
+ /**
5
+ * Factory for creating the appropriate installer for a requirement
6
+ */
7
+ export declare class InstallerFactory {
8
+ private installers;
9
+ private readonly execPromise;
10
+ /**
11
+ * Create a new InstallerFactory
12
+ * @param execPromise Function to execute commands
13
+ */
14
+ constructor(execPromise: (command: string) => Promise<{
15
+ stdout: string;
16
+ stderr: string;
17
+ }>);
18
+ /**
19
+ * Register default installers for npm, pip, and general requirements
20
+ * @private
21
+ */
22
+ private registerDefaultInstallers;
23
+ /**
24
+ * Register a custom installer
25
+ * @param installer The installer to register
26
+ */
27
+ registerInstaller(installer: RequirementInstaller): void;
28
+ /**
29
+ * Get the appropriate installer for a requirement
30
+ * @param requirement The requirement to get an installer for
31
+ * @returns The appropriate installer, or undefined if none found
32
+ */
33
+ getInstaller(requirement: RequirementConfig): RequirementInstaller | undefined;
34
+ /**
35
+ * Install a requirement using the appropriate installer
36
+ * @param requirement The requirement to install
37
+ * @param options Installation options including python environment
38
+ * @returns The installation status
39
+ */
40
+ install(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
41
+ /**
42
+ * Check the installation status of a requirement
43
+ * @param requirement The requirement to check
44
+ * @param options Installation options including python environment
45
+ * @returns The installation status
46
+ */
47
+ checkInstallation(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
48
+ }
49
+ /**
50
+ * Create a new InstallerFactory with default settings
51
+ * @param execPromise Optional function to execute commands
52
+ * @returns A new InstallerFactory
53
+ */
54
+ export declare const createInstallerFactory: (execPromise?: typeof exec.__promisify__) => InstallerFactory;
@@ -0,0 +1,97 @@
1
+ import { NpmInstaller } from './NpmInstaller.js';
2
+ import { PipInstaller } from './PipInstaller.js';
3
+ import { CommandInstaller } from './CommandInstaller.js';
4
+ import { GeneralInstaller } from './GeneralInstaller.js';
5
+ import { exec } from 'child_process';
6
+ import util from 'util';
7
+ /**
8
+ * Factory for creating the appropriate installer for a requirement
9
+ */
10
+ export class InstallerFactory {
11
+ installers = [];
12
+ execPromise;
13
+ /**
14
+ * Create a new InstallerFactory
15
+ * @param execPromise Function to execute commands
16
+ */
17
+ constructor(execPromise) {
18
+ this.execPromise = execPromise;
19
+ this.registerDefaultInstallers();
20
+ }
21
+ /**
22
+ * Register default installers for npm, pip, and general requirements
23
+ * @private
24
+ */
25
+ registerDefaultInstallers() {
26
+ this.registerInstaller(new NpmInstaller(this.execPromise));
27
+ this.registerInstaller(new PipInstaller(this.execPromise));
28
+ this.registerInstaller(new CommandInstaller(this.execPromise));
29
+ this.registerInstaller(new GeneralInstaller(this.execPromise));
30
+ }
31
+ /**
32
+ * Register a custom installer
33
+ * @param installer The installer to register
34
+ */
35
+ registerInstaller(installer) {
36
+ this.installers.push(installer);
37
+ }
38
+ /**
39
+ * Get the appropriate installer for a requirement
40
+ * @param requirement The requirement to get an installer for
41
+ * @returns The appropriate installer, or undefined if none found
42
+ */
43
+ getInstaller(requirement) {
44
+ // Validate that if registry is empty, type must not be 'other'
45
+ if (!requirement.registry && requirement.type === 'other') {
46
+ throw new Error('Registry must be specified for requirement type "other"');
47
+ }
48
+ return this.installers.find(installer => installer.canHandle(requirement));
49
+ }
50
+ /**
51
+ * Install a requirement using the appropriate installer
52
+ * @param requirement The requirement to install
53
+ * @param options Installation options including python environment
54
+ * @returns The installation status
55
+ */
56
+ async install(requirement, options) {
57
+ const installer = this.getInstaller(requirement);
58
+ if (!installer) {
59
+ return {
60
+ name: requirement.name,
61
+ type: requirement.type,
62
+ installed: false,
63
+ error: `No installer found for requirement type '${requirement.type}'`,
64
+ inProgress: false
65
+ };
66
+ }
67
+ return await installer.install(requirement, options);
68
+ }
69
+ /**
70
+ * Check the installation status of a requirement
71
+ * @param requirement The requirement to check
72
+ * @param options Installation options including python environment
73
+ * @returns The installation status
74
+ */
75
+ async checkInstallation(requirement, options) {
76
+ const installer = this.getInstaller(requirement);
77
+ if (!installer) {
78
+ return {
79
+ name: requirement.name,
80
+ type: requirement.type,
81
+ installed: false,
82
+ error: `No installer found for requirement type '${requirement.type}'`,
83
+ inProgress: false
84
+ };
85
+ }
86
+ return await installer.checkInstallation(requirement, options);
87
+ }
88
+ }
89
+ /**
90
+ * Create a new InstallerFactory with default settings
91
+ * @param execPromise Optional function to execute commands
92
+ * @returns A new InstallerFactory
93
+ */
94
+ export const createInstallerFactory = (execPromise = util.promisify(exec)) => {
95
+ return new InstallerFactory(execPromise);
96
+ };
97
+ //# sourceMappingURL=InstallerFactory.js.map
@@ -0,0 +1,26 @@
1
+ import { RequirementConfig, RequirementStatus } from '../types.js';
2
+ import { BaseInstaller } from './BaseInstaller.js';
3
+ /**
4
+ * Installer implementation for NPM packages
5
+ */
6
+ export declare class NpmInstaller extends BaseInstaller {
7
+ /**
8
+ * Check if this installer can handle the given requirement type
9
+ * @param requirement The requirement to check
10
+ * @returns True if this installer can handle the requirement
11
+ */
12
+ canHandle(requirement: RequirementConfig): boolean;
13
+ supportCheckUpdates(): boolean;
14
+ /**
15
+ * Check if the NPM package is already installed
16
+ * @param requirement The requirement to check
17
+ * @returns The status of the requirement
18
+ */
19
+ checkInstallation(requirement: RequirementConfig): Promise<RequirementStatus>;
20
+ /**
21
+ * Install the NPM package
22
+ * @param requirement The requirement to install
23
+ * @returns The status of the installation
24
+ */
25
+ install(requirement: RequirementConfig): Promise<RequirementStatus>;
26
+ }
@@ -0,0 +1,127 @@
1
+ import { BaseInstaller } from './BaseInstaller.js';
2
+ import { compareVersions } from '../../utils/versionUtils.js';
3
+ /**
4
+ * Installer implementation for NPM packages
5
+ */
6
+ export class NpmInstaller extends BaseInstaller {
7
+ /**
8
+ * Check if this installer can handle the given requirement type
9
+ * @param requirement The requirement to check
10
+ * @returns True if this installer can handle the requirement
11
+ */
12
+ canHandle(requirement) {
13
+ return requirement.type === 'npm';
14
+ }
15
+ supportCheckUpdates() {
16
+ return true;
17
+ }
18
+ /**
19
+ * Check if the NPM package is already installed
20
+ * @param requirement The requirement to check
21
+ * @returns The status of the requirement
22
+ */
23
+ async checkInstallation(requirement) {
24
+ try {
25
+ const { stdout } = await this.execPromise(`npm list -g ${requirement.name} --json`);
26
+ const pkgInfo = JSON.parse(stdout);
27
+ const installedVersion = pkgInfo?.dependencies?.[requirement.name]?.version;
28
+ return {
29
+ name: requirement.name,
30
+ type: 'npm',
31
+ installed: !!installedVersion,
32
+ version: installedVersion,
33
+ inProgress: false
34
+ };
35
+ }
36
+ catch (error) {
37
+ return {
38
+ name: requirement.name,
39
+ type: 'npm',
40
+ installed: false,
41
+ error: error instanceof Error ? error.message : String(error),
42
+ inProgress: false
43
+ };
44
+ }
45
+ }
46
+ /**
47
+ * Install the NPM package
48
+ * @param requirement The requirement to install
49
+ * @returns The status of the installation
50
+ */
51
+ async install(requirement) {
52
+ try {
53
+ const status = await this.checkInstallation(requirement);
54
+ if (status.installed && status.version && compareVersions(status.version, requirement.version) === 0) {
55
+ return status;
56
+ }
57
+ let resolvedVersion = requirement.version;
58
+ // If no registry is specified, use standard npm installation
59
+ if (!requirement.registry) {
60
+ const { stderr } = await this.execPromise(`npm install -g ${requirement.name}@${requirement.version}`);
61
+ if (stderr && !stderr.includes('added')) {
62
+ throw new Error(stderr);
63
+ }
64
+ }
65
+ else {
66
+ // Handle different registry types
67
+ let packageSource;
68
+ if (requirement.registry.githubRelease) {
69
+ const result = await this.handleGitHubRelease(requirement, requirement.registry.githubRelease);
70
+ packageSource = result.resolvedPath;
71
+ resolvedVersion = result.resolvedVersion;
72
+ }
73
+ else if (requirement.registry.artifacts) {
74
+ // For npm with artifacts, configure npm to use the specified registry URL
75
+ const registryUrl = requirement.registry.artifacts.registryUrl;
76
+ await this.execPromise(`npm config set registry ${registryUrl}`);
77
+ // Now install the package with the configured registry
78
+ const { stderr } = await this.execPromise(`npm install -g ${requirement.name}@${requirement.version}`);
79
+ if (stderr && !stderr.includes('added')) {
80
+ // Reset the registry to the default npm registry
81
+ await this.execPromise('npm config set registry https://registry.npmjs.org/');
82
+ throw new Error(stderr);
83
+ }
84
+ // Reset the registry to the default npm registry
85
+ await this.execPromise('npm config set registry https://registry.npmjs.org/');
86
+ return {
87
+ name: requirement.name,
88
+ type: 'npm',
89
+ installed: true,
90
+ version: requirement.version,
91
+ inProgress: false
92
+ };
93
+ }
94
+ else if (requirement.registry.local) {
95
+ packageSource = await this.handleLocalRegistry(requirement, requirement.registry.local);
96
+ }
97
+ else {
98
+ throw new Error('Invalid registry configuration');
99
+ }
100
+ // Install from the package source
101
+ const { stderr } = await this.execPromise(`npm install -g "${packageSource}"`);
102
+ if (stderr && !stderr.includes('added')) {
103
+ const status = await this.checkInstallation(requirement);
104
+ if (!status.installed)
105
+ throw new Error(stderr);
106
+ }
107
+ }
108
+ return {
109
+ name: requirement.name,
110
+ type: 'npm',
111
+ installed: true,
112
+ version: resolvedVersion,
113
+ inProgress: false
114
+ };
115
+ }
116
+ catch (error) {
117
+ return {
118
+ name: requirement.name,
119
+ type: 'npm',
120
+ installed: false,
121
+ error: error instanceof Error ? error.message : String(error),
122
+ inProgress: false
123
+ };
124
+ }
125
+ }
126
+ }
127
+ //# sourceMappingURL=NpmInstaller.js.map
@@ -0,0 +1,28 @@
1
+ import { RequirementConfig, RequirementStatus, ServerInstallOptions } from '../types.js';
2
+ import { BaseInstaller } from './BaseInstaller.js';
3
+ /**
4
+ * Installer implementation for Python packages using pip
5
+ */
6
+ export declare class PipInstaller extends BaseInstaller {
7
+ private getPythonCommand;
8
+ private getPipCommand;
9
+ /**
10
+ * Check if this installer can handle the given requirement type
11
+ * @param requirement The requirement to check
12
+ * @returns True if this installer can handle the requirement
13
+ */
14
+ canHandle(requirement: RequirementConfig): boolean;
15
+ supportCheckUpdates(): boolean;
16
+ /**
17
+ * Check if the Python package is already installed
18
+ * @param requirement The requirement to check
19
+ * @returns The status of the requirement
20
+ */
21
+ checkInstallation(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
22
+ /**
23
+ * Install the Python package
24
+ * @param requirement The requirement to install
25
+ * @returns The status of the installation
26
+ */
27
+ install(requirement: RequirementConfig, options?: ServerInstallOptions): Promise<RequirementStatus>;
28
+ }