imcp 0.0.1
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/.github/ISSUE_TEMPLATE/JitAccess.yml +28 -0
- package/.github/acl/access.yml +20 -0
- package/.github/compliance/inventory.yml +5 -0
- package/.github/policies/jit.yml +19 -0
- package/README.md +137 -0
- package/dist/cli/commands/install.d.ts +2 -0
- package/dist/cli/commands/install.js +105 -0
- package/dist/cli/commands/list.d.ts +2 -0
- package/dist/cli/commands/list.js +90 -0
- package/dist/cli/commands/pull.d.ts +2 -0
- package/dist/cli/commands/pull.js +17 -0
- package/dist/cli/commands/serve.d.ts +2 -0
- package/dist/cli/commands/serve.js +32 -0
- package/dist/cli/commands/start.d.ts +2 -0
- package/dist/cli/commands/start.js +32 -0
- package/dist/cli/commands/sync.d.ts +2 -0
- package/dist/cli/commands/sync.js +17 -0
- package/dist/cli/commands/uninstall.d.ts +2 -0
- package/dist/cli/commands/uninstall.js +39 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +114 -0
- package/dist/core/ConfigurationProvider.d.ts +31 -0
- package/dist/core/ConfigurationProvider.js +416 -0
- package/dist/core/InstallationService.d.ts +17 -0
- package/dist/core/InstallationService.js +144 -0
- package/dist/core/MCPManager.d.ts +17 -0
- package/dist/core/MCPManager.js +98 -0
- package/dist/core/RequirementService.d.ts +45 -0
- package/dist/core/RequirementService.js +123 -0
- package/dist/core/constants.d.ts +29 -0
- package/dist/core/constants.js +55 -0
- package/dist/core/installers/BaseInstaller.d.ts +73 -0
- package/dist/core/installers/BaseInstaller.js +247 -0
- package/dist/core/installers/ClientInstaller.d.ts +17 -0
- package/dist/core/installers/ClientInstaller.js +307 -0
- package/dist/core/installers/CommandInstaller.d.ts +36 -0
- package/dist/core/installers/CommandInstaller.js +170 -0
- package/dist/core/installers/GeneralInstaller.d.ts +32 -0
- package/dist/core/installers/GeneralInstaller.js +87 -0
- package/dist/core/installers/InstallerFactory.d.ts +52 -0
- package/dist/core/installers/InstallerFactory.js +95 -0
- package/dist/core/installers/NpmInstaller.d.ts +25 -0
- package/dist/core/installers/NpmInstaller.js +123 -0
- package/dist/core/installers/PipInstaller.d.ts +25 -0
- package/dist/core/installers/PipInstaller.js +114 -0
- package/dist/core/installers/RequirementInstaller.d.ts +32 -0
- package/dist/core/installers/RequirementInstaller.js +3 -0
- package/dist/core/installers/index.d.ts +6 -0
- package/dist/core/installers/index.js +7 -0
- package/dist/core/types.d.ts +152 -0
- package/dist/core/types.js +16 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +19 -0
- package/dist/services/InstallRequestValidator.d.ts +21 -0
- package/dist/services/InstallRequestValidator.js +99 -0
- package/dist/services/ServerService.d.ts +47 -0
- package/dist/services/ServerService.js +145 -0
- package/dist/utils/UpdateCheckTracker.d.ts +39 -0
- package/dist/utils/UpdateCheckTracker.js +80 -0
- package/dist/utils/clientUtils.d.ts +29 -0
- package/dist/utils/clientUtils.js +105 -0
- package/dist/utils/feedUtils.d.ts +5 -0
- package/dist/utils/feedUtils.js +29 -0
- package/dist/utils/githubAuth.d.ts +1 -0
- package/dist/utils/githubAuth.js +123 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.js +90 -0
- package/dist/utils/osUtils.d.ts +16 -0
- package/dist/utils/osUtils.js +235 -0
- package/dist/web/public/css/modal.css +250 -0
- package/dist/web/public/css/notifications.css +70 -0
- package/dist/web/public/index.html +157 -0
- package/dist/web/public/js/api.js +213 -0
- package/dist/web/public/js/modal.js +572 -0
- package/dist/web/public/js/notifications.js +99 -0
- package/dist/web/public/js/serverCategoryDetails.js +210 -0
- package/dist/web/public/js/serverCategoryList.js +82 -0
- package/dist/web/public/modal.html +61 -0
- package/dist/web/public/styles.css +155 -0
- package/dist/web/server.d.ts +5 -0
- package/dist/web/server.js +150 -0
- package/package.json +53 -0
- package/src/cli/commands/install.ts +140 -0
- package/src/cli/commands/list.ts +112 -0
- package/src/cli/commands/pull.ts +16 -0
- package/src/cli/commands/serve.ts +37 -0
- package/src/cli/commands/uninstall.ts +54 -0
- package/src/cli/index.ts +127 -0
- package/src/core/ConfigurationProvider.ts +489 -0
- package/src/core/InstallationService.ts +173 -0
- package/src/core/MCPManager.ts +134 -0
- package/src/core/RequirementService.ts +147 -0
- package/src/core/constants.ts +61 -0
- package/src/core/installers/BaseInstaller.ts +292 -0
- package/src/core/installers/ClientInstaller.ts +423 -0
- package/src/core/installers/CommandInstaller.ts +185 -0
- package/src/core/installers/GeneralInstaller.ts +89 -0
- package/src/core/installers/InstallerFactory.ts +109 -0
- package/src/core/installers/NpmInstaller.ts +128 -0
- package/src/core/installers/PipInstaller.ts +121 -0
- package/src/core/installers/RequirementInstaller.ts +38 -0
- package/src/core/installers/index.ts +9 -0
- package/src/core/types.ts +163 -0
- package/src/index.ts +44 -0
- package/src/services/InstallRequestValidator.ts +112 -0
- package/src/services/ServerService.ts +181 -0
- package/src/utils/UpdateCheckTracker.ts +86 -0
- package/src/utils/clientUtils.ts +112 -0
- package/src/utils/feedUtils.ts +31 -0
- package/src/utils/githubAuth.ts +142 -0
- package/src/utils/logger.ts +101 -0
- package/src/utils/osUtils.ts +250 -0
- package/src/web/public/css/modal.css +250 -0
- package/src/web/public/css/notifications.css +70 -0
- package/src/web/public/index.html +157 -0
- package/src/web/public/js/api.js +213 -0
- package/src/web/public/js/modal.js +572 -0
- package/src/web/public/js/notifications.js +99 -0
- package/src/web/public/js/serverCategoryDetails.js +210 -0
- package/src/web/public/js/serverCategoryList.js +82 -0
- package/src/web/public/modal.html +61 -0
- package/src/web/public/styles.css +155 -0
- package/src/web/server.ts +195 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { RequirementConfig, RequirementStatus } from '../types.js';
|
|
2
|
+
import { RequirementInstaller } from './RequirementInstaller.js';
|
|
3
|
+
import { NpmInstaller } from './NpmInstaller.js';
|
|
4
|
+
import { PipInstaller } from './PipInstaller.js';
|
|
5
|
+
import { CommandInstaller } from './CommandInstaller.js';
|
|
6
|
+
import { GeneralInstaller } from './GeneralInstaller.js';
|
|
7
|
+
import { exec } from 'child_process';
|
|
8
|
+
import util from 'util';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Factory for creating the appropriate installer for a requirement
|
|
12
|
+
*/
|
|
13
|
+
export class InstallerFactory {
|
|
14
|
+
private installers: RequirementInstaller[] = [];
|
|
15
|
+
private readonly execPromise: (command: string) => Promise<{ stdout: string; stderr: string }>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Create a new InstallerFactory
|
|
19
|
+
* @param execPromise Function to execute commands
|
|
20
|
+
*/
|
|
21
|
+
constructor(execPromise: (command: string) => Promise<{ stdout: string; stderr: string }>) {
|
|
22
|
+
this.execPromise = execPromise;
|
|
23
|
+
this.registerDefaultInstallers();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Register default installers for npm, pip, and general requirements
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
private registerDefaultInstallers(): void {
|
|
31
|
+
this.registerInstaller(new NpmInstaller(this.execPromise));
|
|
32
|
+
this.registerInstaller(new PipInstaller(this.execPromise));
|
|
33
|
+
this.registerInstaller(new CommandInstaller(this.execPromise));
|
|
34
|
+
this.registerInstaller(new GeneralInstaller(this.execPromise));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Register a custom installer
|
|
39
|
+
* @param installer The installer to register
|
|
40
|
+
*/
|
|
41
|
+
public registerInstaller(installer: RequirementInstaller): void {
|
|
42
|
+
this.installers.push(installer);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get the appropriate installer for a requirement
|
|
47
|
+
* @param requirement The requirement to get an installer for
|
|
48
|
+
* @returns The appropriate installer, or undefined if none found
|
|
49
|
+
*/
|
|
50
|
+
public getInstaller(requirement: RequirementConfig): RequirementInstaller | undefined {
|
|
51
|
+
// Validate that if registry is empty, type must not be 'other'
|
|
52
|
+
if (!requirement.registry && requirement.type === 'other') {
|
|
53
|
+
throw new Error('Registry must be specified for requirement type "other"');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return this.installers.find(installer => installer.canHandle(requirement));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Install a requirement using the appropriate installer
|
|
61
|
+
* @param requirement The requirement to install
|
|
62
|
+
* @returns The installation status
|
|
63
|
+
*/
|
|
64
|
+
public async install(requirement: RequirementConfig): Promise<RequirementStatus> {
|
|
65
|
+
const installer = this.getInstaller(requirement);
|
|
66
|
+
if (!installer) {
|
|
67
|
+
return {
|
|
68
|
+
name: requirement.name,
|
|
69
|
+
type: requirement.type,
|
|
70
|
+
installed: false,
|
|
71
|
+
error: `No installer found for requirement type '${requirement.type}'`,
|
|
72
|
+
inProgress: false
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return await installer.install(requirement);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Check the installation status of a requirement
|
|
81
|
+
* @param requirement The requirement to check
|
|
82
|
+
* @returns The installation status
|
|
83
|
+
*/
|
|
84
|
+
public async checkInstallation(requirement: RequirementConfig): Promise<RequirementStatus> {
|
|
85
|
+
const installer = this.getInstaller(requirement);
|
|
86
|
+
if (!installer) {
|
|
87
|
+
return {
|
|
88
|
+
name: requirement.name,
|
|
89
|
+
type: requirement.type,
|
|
90
|
+
installed: false,
|
|
91
|
+
error: `No installer found for requirement type '${requirement.type}'`,
|
|
92
|
+
inProgress: false
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return await installer.checkInstallation(requirement);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Create a new InstallerFactory with default settings
|
|
102
|
+
* @param execPromise Optional function to execute commands
|
|
103
|
+
* @returns A new InstallerFactory
|
|
104
|
+
*/
|
|
105
|
+
export const createInstallerFactory = (
|
|
106
|
+
execPromise = util.promisify(exec)
|
|
107
|
+
): InstallerFactory => {
|
|
108
|
+
return new InstallerFactory(execPromise);
|
|
109
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { stat } from 'fs';
|
|
2
|
+
import { RequirementConfig, RequirementStatus } from '../types.js';
|
|
3
|
+
import { BaseInstaller } from './BaseInstaller.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Installer implementation for NPM packages
|
|
7
|
+
*/
|
|
8
|
+
export class NpmInstaller extends BaseInstaller {
|
|
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
|
+
return requirement.type === 'npm';
|
|
16
|
+
}
|
|
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: RequirementConfig): Promise<RequirementStatus> {
|
|
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
|
+
|
|
29
|
+
return {
|
|
30
|
+
name: requirement.name,
|
|
31
|
+
type: 'npm',
|
|
32
|
+
installed: !!installedVersion,
|
|
33
|
+
version: installedVersion,
|
|
34
|
+
inProgress: false
|
|
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
|
+
/**
|
|
48
|
+
* Install the NPM package
|
|
49
|
+
* @param requirement The requirement to install
|
|
50
|
+
* @returns The status of the installation
|
|
51
|
+
*/
|
|
52
|
+
async install(requirement: RequirementConfig): Promise<RequirementStatus> {
|
|
53
|
+
try {
|
|
54
|
+
const status = await this.checkInstallation(requirement);
|
|
55
|
+
if (status.installed) {
|
|
56
|
+
return status;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let resolvedVersion = requirement.version;
|
|
60
|
+
|
|
61
|
+
// If no registry is specified, use standard npm installation
|
|
62
|
+
if (!requirement.registry) {
|
|
63
|
+
const { stderr } = await this.execPromise(`npm install -g ${requirement.name}@${requirement.version}`);
|
|
64
|
+
if (stderr && !stderr.includes('added')) {
|
|
65
|
+
throw new Error(stderr);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
// Handle different registry types
|
|
69
|
+
let packageSource: string;
|
|
70
|
+
|
|
71
|
+
if (requirement.registry.githubRelease) {
|
|
72
|
+
const result = await this.handleGitHubRelease(requirement, requirement.registry.githubRelease);
|
|
73
|
+
packageSource = result.resolvedPath;
|
|
74
|
+
resolvedVersion = result.resolvedVersion;
|
|
75
|
+
} else if (requirement.registry.artifacts) {
|
|
76
|
+
// For npm with artifacts, configure npm to use the specified registry URL
|
|
77
|
+
const registryUrl = requirement.registry.artifacts.registryUrl;
|
|
78
|
+
await this.execPromise(`npm config set registry ${registryUrl}`);
|
|
79
|
+
|
|
80
|
+
// Now install the package with the configured registry
|
|
81
|
+
const { stderr } = await this.execPromise(`npm install -g ${requirement.name}@${requirement.version}`);
|
|
82
|
+
if (stderr && !stderr.includes('added')) {
|
|
83
|
+
// Reset the registry to the default npm registry
|
|
84
|
+
await this.execPromise('npm config set registry https://registry.npmjs.org/');
|
|
85
|
+
throw new Error(stderr);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Reset the registry to the default npm registry
|
|
89
|
+
await this.execPromise('npm config set registry https://registry.npmjs.org/');
|
|
90
|
+
return {
|
|
91
|
+
name: requirement.name,
|
|
92
|
+
type: 'npm',
|
|
93
|
+
installed: true,
|
|
94
|
+
version: requirement.version,
|
|
95
|
+
inProgress: false
|
|
96
|
+
};
|
|
97
|
+
} else if (requirement.registry.local) {
|
|
98
|
+
packageSource = await this.handleLocalRegistry(requirement, requirement.registry.local);
|
|
99
|
+
} else {
|
|
100
|
+
throw new Error('Invalid registry configuration');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Install from the package source
|
|
104
|
+
const { stderr } = await this.execPromise(`npm install -g "${packageSource}"`);
|
|
105
|
+
if (stderr && !stderr.includes('added')) {
|
|
106
|
+
const status = await this.checkInstallation(requirement);
|
|
107
|
+
if (!status.installed) throw new Error(stderr);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
name: requirement.name,
|
|
113
|
+
type: 'npm',
|
|
114
|
+
installed: true,
|
|
115
|
+
version: resolvedVersion,
|
|
116
|
+
inProgress: false
|
|
117
|
+
};
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
name: requirement.name,
|
|
121
|
+
type: 'npm',
|
|
122
|
+
installed: false,
|
|
123
|
+
error: error instanceof Error ? error.message : String(error),
|
|
124
|
+
inProgress: false
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { RequirementConfig, RequirementStatus } from '../types.js';
|
|
2
|
+
import { BaseInstaller } from './BaseInstaller.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Installer implementation for Python packages using pip
|
|
6
|
+
*/
|
|
7
|
+
export class PipInstaller 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
|
+
return requirement.type === 'pip';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Check if the Python package is already installed
|
|
19
|
+
* @param requirement The requirement to check
|
|
20
|
+
* @returns The status of the requirement
|
|
21
|
+
*/
|
|
22
|
+
async checkInstallation(requirement: RequirementConfig): Promise<RequirementStatus> {
|
|
23
|
+
try {
|
|
24
|
+
const { stdout, stderr } = await this.execPromise(`pip show ${requirement.name}`);
|
|
25
|
+
|
|
26
|
+
// If we get an output and no error, the package is installed
|
|
27
|
+
const installed = stdout.includes(requirement.name);
|
|
28
|
+
const versionMatch = stdout.match(/Version: (.+)/);
|
|
29
|
+
const installedVersion = versionMatch ? versionMatch[1] : undefined;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
name: requirement.name,
|
|
33
|
+
type: 'pip',
|
|
34
|
+
installed,
|
|
35
|
+
version: installedVersion,
|
|
36
|
+
inProgress: false
|
|
37
|
+
};
|
|
38
|
+
} catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
name: requirement.name,
|
|
41
|
+
type: 'pip',
|
|
42
|
+
installed: false,
|
|
43
|
+
error: error instanceof Error ? error.message : String(error),
|
|
44
|
+
inProgress: false
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Install the Python package
|
|
51
|
+
* @param requirement The requirement to install
|
|
52
|
+
* @returns The status of the installation
|
|
53
|
+
*/
|
|
54
|
+
async install(requirement: RequirementConfig): Promise<RequirementStatus> {
|
|
55
|
+
try {
|
|
56
|
+
const status = await this.checkInstallation(requirement);
|
|
57
|
+
if (status.installed) {
|
|
58
|
+
return status;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// If no registry is specified, use standard pip installation
|
|
62
|
+
if (!requirement.registry) {
|
|
63
|
+
// Standard pip installation
|
|
64
|
+
const { stderr } = await this.execPromise(`pip install ${requirement.name}==${requirement.version}`);
|
|
65
|
+
if (stderr && stderr.toLowerCase().includes('error')) {
|
|
66
|
+
throw new Error(stderr);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
// Handle different registry types
|
|
70
|
+
let packageSource: string;
|
|
71
|
+
|
|
72
|
+
if (requirement.registry.githubRelease) {
|
|
73
|
+
const result = await this.handleGitHubRelease(requirement, requirement.registry.githubRelease);
|
|
74
|
+
packageSource = result.resolvedPath;
|
|
75
|
+
|
|
76
|
+
// Install from the downloaded wheel or tar.gz file
|
|
77
|
+
const { stderr } = await this.execPromise(`pip install "${packageSource}"`);
|
|
78
|
+
if (stderr && stderr.toLowerCase().includes('error')) {
|
|
79
|
+
throw new Error(stderr);
|
|
80
|
+
}
|
|
81
|
+
} else if (requirement.registry.artifacts) {
|
|
82
|
+
const registryUrl = requirement.registry.artifacts.registryUrl;
|
|
83
|
+
|
|
84
|
+
// Install using the custom index URL
|
|
85
|
+
const { stderr } = await this.execPromise(
|
|
86
|
+
`pip install ${requirement.name}==${requirement.version} --index-url ${registryUrl}`
|
|
87
|
+
);
|
|
88
|
+
if (stderr && stderr.toLowerCase().includes('error')) {
|
|
89
|
+
throw new Error(stderr);
|
|
90
|
+
}
|
|
91
|
+
} else if (requirement.registry.local) {
|
|
92
|
+
packageSource = await this.handleLocalRegistry(requirement, requirement.registry.local);
|
|
93
|
+
|
|
94
|
+
// Install from the local path
|
|
95
|
+
const { stderr } = await this.execPromise(`pip install "${packageSource}"`);
|
|
96
|
+
if (stderr && stderr.toLowerCase().includes('error')) {
|
|
97
|
+
throw new Error(stderr);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
throw new Error('Invalid registry configuration');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
name: requirement.name,
|
|
106
|
+
type: 'pip',
|
|
107
|
+
installed: true,
|
|
108
|
+
version: requirement.version,
|
|
109
|
+
inProgress: false
|
|
110
|
+
};
|
|
111
|
+
} catch (error) {
|
|
112
|
+
return {
|
|
113
|
+
name: requirement.name,
|
|
114
|
+
type: 'pip',
|
|
115
|
+
installed: false,
|
|
116
|
+
error: error instanceof Error ? error.message : String(error),
|
|
117
|
+
inProgress: false
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RequirementConfig, RequirementStatus } from '../types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface for requirement installers.
|
|
5
|
+
* Implementations should handle specific requirement types.
|
|
6
|
+
*/
|
|
7
|
+
export interface RequirementInstaller {
|
|
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
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Install the requirement
|
|
17
|
+
* @param requirement The requirement to install
|
|
18
|
+
* @returns The status of the installation
|
|
19
|
+
*/
|
|
20
|
+
install(requirement: RequirementConfig): Promise<RequirementStatus>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Check if the requirement is already installed
|
|
24
|
+
* @param requirement The requirement to check
|
|
25
|
+
* @returns The status of the requirement
|
|
26
|
+
*/
|
|
27
|
+
checkInstallation(requirement: RequirementConfig): Promise<RequirementStatus>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Check if updates are available for the requirement
|
|
31
|
+
* @param requirement The requirement to check
|
|
32
|
+
* @param currentStatus The current status of the requirement
|
|
33
|
+
* @returns The status of the requirement with update information
|
|
34
|
+
*/
|
|
35
|
+
checkForUpdates(requirement: RequirementConfig, currentStatus: RequirementStatus): Promise<RequirementStatus>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Note: Do not re-export implementations from here to avoid circular dependencies
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Export the interface
|
|
2
|
+
export { RequirementInstaller } from './RequirementInstaller.js';
|
|
3
|
+
|
|
4
|
+
// Export all installer implementations
|
|
5
|
+
export { BaseInstaller } from './BaseInstaller.js';
|
|
6
|
+
export { NpmInstaller } from './NpmInstaller.js';
|
|
7
|
+
export { PipInstaller } from './PipInstaller.js';
|
|
8
|
+
export { GeneralInstaller } from './GeneralInstaller.js';
|
|
9
|
+
export { InstallerFactory, createInstallerFactory } from './InstallerFactory.js';
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export enum OSType {
|
|
2
|
+
Windows = 'windows',
|
|
3
|
+
MacOS = 'macos',
|
|
4
|
+
Linux = 'linux'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface RequirementStatus {
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
installed: boolean;
|
|
11
|
+
inProgress?: boolean;
|
|
12
|
+
version?: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
availableUpdate?: {
|
|
15
|
+
version: string;
|
|
16
|
+
message: string;
|
|
17
|
+
checkTime: string;
|
|
18
|
+
};
|
|
19
|
+
operationStatus?: OperationStatus;
|
|
20
|
+
updateInfo?: {
|
|
21
|
+
available: boolean;
|
|
22
|
+
latestVersion?: string;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
} | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface MCPServerStatus {
|
|
28
|
+
installedStatus: Record<string, OperationStatus>; // client: installed
|
|
29
|
+
name: string;
|
|
30
|
+
error?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface OperationStatus {
|
|
34
|
+
status: 'pending' | 'in-progress' | 'completed' | 'failed';
|
|
35
|
+
type: 'install' | 'uninstall' | 'update' | 'check';
|
|
36
|
+
target: 'requirement' | 'server';
|
|
37
|
+
message?: string;
|
|
38
|
+
error?: string;
|
|
39
|
+
operationId?: string; // Added to track async operations
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface InstallationStatus {
|
|
43
|
+
requirementsStatus: Record<string, RequirementStatus>;
|
|
44
|
+
serversStatus: Record<string, MCPServerStatus>;
|
|
45
|
+
lastUpdated: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface MCPServerCategory {
|
|
49
|
+
name: string;
|
|
50
|
+
displayName: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
type: 'local';
|
|
53
|
+
path?: string;
|
|
54
|
+
installationStatus?: InstallationStatus;
|
|
55
|
+
feedConfiguration?: FeedConfiguration;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ServerCategoryListOptions {
|
|
59
|
+
local?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ServerOperationResult {
|
|
63
|
+
success: boolean;
|
|
64
|
+
message?: string;
|
|
65
|
+
error?: Error;
|
|
66
|
+
output?: string; // Added to capture installation logs
|
|
67
|
+
status?: OperationStatus[]; // Added to capture operation status
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface MCPConfiguration {
|
|
71
|
+
localServerCategories: MCPServerCategory[];
|
|
72
|
+
feeds: Record<string, FeedConfiguration>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ServerInstallOptions {
|
|
76
|
+
force?: boolean;
|
|
77
|
+
env?: Record<string, string>; // Environment variables for installation
|
|
78
|
+
targetClients?: string[]; // Target clients for configuration
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ServerUninstallOptions {
|
|
82
|
+
removeData?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Types related to server feed configuration (e.g., ai-coder-tools.json)
|
|
86
|
+
export interface EnvVariableConfig {
|
|
87
|
+
Required: boolean;
|
|
88
|
+
Description: string;
|
|
89
|
+
Default?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface InstallationConfig {
|
|
93
|
+
command: string;
|
|
94
|
+
args: string[]; // Can use ${packageSource} as template variable for installation path
|
|
95
|
+
env?: Record<string, EnvVariableConfig>; // Note the colon in property name
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface DependencyConfig {
|
|
99
|
+
requirements?: Array<{
|
|
100
|
+
name: string;
|
|
101
|
+
version: string;
|
|
102
|
+
}>;
|
|
103
|
+
mcpServers?: Array<{
|
|
104
|
+
name: string;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface McpConfig {
|
|
109
|
+
name: string;
|
|
110
|
+
description: string;
|
|
111
|
+
mode: 'stdio' | 'http'; // Currently only stdio mode is supported in ai-coder-tools
|
|
112
|
+
dependencies?: DependencyConfig;
|
|
113
|
+
installation: InstallationConfig;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface RegistryConfig {
|
|
117
|
+
githubRelease?: {
|
|
118
|
+
repository: string;
|
|
119
|
+
assetsName?: string; // Template string like "ai-coder-tools-${latest}.zip"
|
|
120
|
+
assetName: string; // Template string like "ai-coder-tools-${latest}.tgz"
|
|
121
|
+
};
|
|
122
|
+
artifacts?: {
|
|
123
|
+
registryUrl: string;
|
|
124
|
+
assetName?: string; // Template string like "ai-coder-tools-${latest}.tgz"
|
|
125
|
+
};
|
|
126
|
+
local?: {
|
|
127
|
+
localPath: string; // Local path for local registry
|
|
128
|
+
assetName?: string; // Template string like "ai-coder-tools-${latest}.tgz"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface RequirementConfig {
|
|
133
|
+
name: string;
|
|
134
|
+
type: 'npm' | 'pip' | 'command' | 'other'; // Add other requirement types if needed
|
|
135
|
+
alias?: string; // Alias for the command type
|
|
136
|
+
version: string;
|
|
137
|
+
registry?: RegistryConfig;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface FeedConfiguration {
|
|
141
|
+
name: string;
|
|
142
|
+
displayName: string;
|
|
143
|
+
description: string;
|
|
144
|
+
requirements: RequirementConfig[];
|
|
145
|
+
mcpServers: McpConfig[];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Events that can be emitted by the SDK
|
|
149
|
+
export enum MCPEvent {
|
|
150
|
+
SERVER_INSTALLED = 'server:installed',
|
|
151
|
+
SERVER_UNINSTALLED = 'server:uninstalled',
|
|
152
|
+
SERVER_STARTED = 'server:started',
|
|
153
|
+
SERVER_STOPPED = 'server:stopped',
|
|
154
|
+
CONFIG_CHANGED = 'config:changed',
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface MCPEventData {
|
|
158
|
+
[MCPEvent.SERVER_INSTALLED]: { server: MCPServerCategory };
|
|
159
|
+
[MCPEvent.SERVER_UNINSTALLED]: { serverName: string };
|
|
160
|
+
[MCPEvent.SERVER_STARTED]: { server: MCPServerCategory };
|
|
161
|
+
[MCPEvent.SERVER_STOPPED]: { serverName: string };
|
|
162
|
+
[MCPEvent.CONFIG_CHANGED]: { configuration: MCPConfiguration };
|
|
163
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Public types
|
|
2
|
+
export {
|
|
3
|
+
MCPServerCategory,
|
|
4
|
+
ServerCategoryListOptions,
|
|
5
|
+
ServerInstallOptions,
|
|
6
|
+
ServerUninstallOptions,
|
|
7
|
+
ServerOperationResult,
|
|
8
|
+
MCPConfiguration,
|
|
9
|
+
MCPEvent,
|
|
10
|
+
MCPEventData,
|
|
11
|
+
RequirementConfig,
|
|
12
|
+
RequirementStatus,
|
|
13
|
+
RegistryConfig
|
|
14
|
+
} from './core/types.js';
|
|
15
|
+
|
|
16
|
+
// Core functionality
|
|
17
|
+
export { MCPManager, mcpManager } from './core/MCPManager.js';
|
|
18
|
+
|
|
19
|
+
// Services
|
|
20
|
+
export { ServerService, serverService } from './services/ServerService.js';
|
|
21
|
+
export { RequirementService, requirementService } from './core/RequirementService.js';
|
|
22
|
+
|
|
23
|
+
// Installer interfaces and implementations
|
|
24
|
+
export {
|
|
25
|
+
RequirementInstaller,
|
|
26
|
+
BaseInstaller,
|
|
27
|
+
NpmInstaller,
|
|
28
|
+
PipInstaller,
|
|
29
|
+
GeneralInstaller,
|
|
30
|
+
InstallerFactory,
|
|
31
|
+
createInstallerFactory
|
|
32
|
+
} from './core/installers/index.js';
|
|
33
|
+
|
|
34
|
+
// Web server
|
|
35
|
+
export { startWebServer } from './web/server.js';
|
|
36
|
+
|
|
37
|
+
// Version information
|
|
38
|
+
export const VERSION = '0.0.1';
|
|
39
|
+
|
|
40
|
+
// Default configuration
|
|
41
|
+
export const DEFAULT_CONFIG = {
|
|
42
|
+
configPath: './config/servers.json',
|
|
43
|
+
webPort: 3000
|
|
44
|
+
} as const;
|