cvm-server 0.1.0 → 0.2.0
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/README.md +7 -0
- package/dist/LICENSE +202 -0
- package/dist/README.md +83 -0
- package/dist/bin/cvm-server.js +17 -0
- package/dist/main.js +725 -0
- package/dist/package-lock.json +1202 -0
- package/dist/package.json +91 -0
- package/package.json +27 -31
- package/apps/cvm-server/src/config.d.ts +0 -18
- package/apps/cvm-server/src/config.d.ts.map +0 -1
- package/apps/cvm-server/src/config.js +0 -73
- package/apps/cvm-server/src/logger.d.ts +0 -13
- package/apps/cvm-server/src/logger.d.ts.map +0 -1
- package/apps/cvm-server/src/logger.js +0 -77
- package/apps/cvm-server/src/main.d.ts +0 -2
- package/apps/cvm-server/src/main.d.ts.map +0 -1
- package/apps/cvm-server/src/main.js +0 -57
- package/main.js +0 -44
- package/packages/mcp-server/src/index.js +0 -28
- package/packages/mcp-server/src/lib/mcp-server.js +0 -233
- package/packages/mongodb/src/index.js +0 -28
- package/packages/mongodb/src/lib/mongodb.js +0 -94
- package/packages/mongodb/src/lib/types.js +0 -16
- package/packages/parser/src/index.js +0 -26
- package/packages/parser/src/lib/bytecode.js +0 -42
- package/packages/parser/src/lib/compiler.js +0 -104
- package/packages/parser/src/lib/parser.js +0 -91
- package/packages/storage/src/index.js +0 -28
- package/packages/storage/src/lib/file-adapter.js +0 -113
- package/packages/storage/src/lib/mongodb-adapter.js +0 -94
- package/packages/storage/src/lib/storage-factory.js +0 -58
- package/packages/storage/src/lib/storage.js +0 -16
- package/packages/types/src/index.js +0 -22
- package/packages/types/src/lib/types.js +0 -16
- package/packages/vm/src/index.js +0 -24
- package/packages/vm/src/lib/vm-manager.js +0 -231
- package/packages/vm/src/lib/vm.js +0 -97
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cvm-server",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Cognitive Virtual Machine (CVM) - A deterministic bytecode VM with AI cognitive operations",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"ai",
|
|
8
|
+
"vm",
|
|
9
|
+
"cognitive",
|
|
10
|
+
"bytecode",
|
|
11
|
+
"virtual-machine",
|
|
12
|
+
"claude"
|
|
13
|
+
],
|
|
14
|
+
"author": "Ladislav Sopko",
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"homepage": "https://github.com/LadislavSopko/cvm#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/LadislavSopko/cvm.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/LadislavSopko/cvm/issues"
|
|
23
|
+
},
|
|
24
|
+
"main": "main.js",
|
|
25
|
+
"bin": {
|
|
26
|
+
"cvm-server": "./bin/cvm-server.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"bin",
|
|
30
|
+
"main.js",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@modelcontextprotocol/sdk": "^1.12.2",
|
|
42
|
+
"dotenv": "^16.0.0",
|
|
43
|
+
"mongodb": "^6.17.0",
|
|
44
|
+
"zod": "^3.25.64"
|
|
45
|
+
},
|
|
46
|
+
"nx": {
|
|
47
|
+
"targets": {
|
|
48
|
+
"build": {
|
|
49
|
+
"executor": "@nx/vite:build",
|
|
50
|
+
"outputs": [
|
|
51
|
+
"{options.outputPath}"
|
|
52
|
+
],
|
|
53
|
+
"defaultConfiguration": "production",
|
|
54
|
+
"options": {
|
|
55
|
+
"outputPath": "apps/cvm-server/dist",
|
|
56
|
+
"generatePackageJson": true,
|
|
57
|
+
"main": "apps/cvm-server/src/main.ts",
|
|
58
|
+
"tsConfig": "apps/cvm-server/tsconfig.app.json"
|
|
59
|
+
},
|
|
60
|
+
"configurations": {
|
|
61
|
+
"development": {
|
|
62
|
+
"mode": "development"
|
|
63
|
+
},
|
|
64
|
+
"production": {
|
|
65
|
+
"mode": "production"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"serve": {
|
|
70
|
+
"continuous": true,
|
|
71
|
+
"executor": "@nx/js:node",
|
|
72
|
+
"defaultConfiguration": "development",
|
|
73
|
+
"dependsOn": [
|
|
74
|
+
"build"
|
|
75
|
+
],
|
|
76
|
+
"options": {
|
|
77
|
+
"buildTarget": "cvm-server:build",
|
|
78
|
+
"runBuildTargetDependencies": false
|
|
79
|
+
},
|
|
80
|
+
"configurations": {
|
|
81
|
+
"development": {
|
|
82
|
+
"buildTarget": "cvm-server:build:development"
|
|
83
|
+
},
|
|
84
|
+
"production": {
|
|
85
|
+
"buildTarget": "cvm-server:build:production"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cvm-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Cognitive Virtual Machine (CVM) - A deterministic bytecode VM with AI cognitive operations",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"ai",
|
|
8
|
+
"vm",
|
|
9
|
+
"cognitive",
|
|
10
|
+
"bytecode",
|
|
11
|
+
"virtual-machine",
|
|
12
|
+
"claude"
|
|
13
|
+
],
|
|
6
14
|
"author": "Ladislav Sopko",
|
|
7
15
|
"license": "Apache-2.0",
|
|
8
16
|
"homepage": "https://github.com/LadislavSopko/cvm#readme",
|
|
@@ -18,9 +26,7 @@
|
|
|
18
26
|
},
|
|
19
27
|
"files": [
|
|
20
28
|
"bin",
|
|
21
|
-
"
|
|
22
|
-
"apps",
|
|
23
|
-
"packages",
|
|
29
|
+
"dist",
|
|
24
30
|
"README.md",
|
|
25
31
|
"LICENSE"
|
|
26
32
|
],
|
|
@@ -30,42 +36,32 @@
|
|
|
30
36
|
"publishConfig": {
|
|
31
37
|
"access": "public"
|
|
32
38
|
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.12.2",
|
|
41
|
+
"zod": "^3.25.64",
|
|
42
|
+
"mongodb": "^6.17.0",
|
|
43
|
+
"dotenv": "^16.0.0"
|
|
44
|
+
},
|
|
33
45
|
"nx": {
|
|
34
46
|
"targets": {
|
|
35
47
|
"build": {
|
|
36
|
-
"executor": "@nx/
|
|
48
|
+
"executor": "@nx/vite:build",
|
|
37
49
|
"outputs": [
|
|
38
50
|
"{options.outputPath}"
|
|
39
51
|
],
|
|
40
52
|
"defaultConfiguration": "production",
|
|
41
53
|
"options": {
|
|
42
|
-
"platform": "node",
|
|
43
54
|
"outputPath": "apps/cvm-server/dist",
|
|
44
|
-
"
|
|
45
|
-
"cjs"
|
|
46
|
-
],
|
|
47
|
-
"bundle": false,
|
|
55
|
+
"generatePackageJson": true,
|
|
48
56
|
"main": "apps/cvm-server/src/main.ts",
|
|
49
|
-
"tsConfig": "apps/cvm-server/tsconfig.app.json"
|
|
50
|
-
"assets": [
|
|
51
|
-
"apps/cvm-server/src/assets"
|
|
52
|
-
],
|
|
53
|
-
"esbuildOptions": {
|
|
54
|
-
"sourcemap": true,
|
|
55
|
-
"outExtension": {
|
|
56
|
-
".js": ".js"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
57
|
+
"tsConfig": "apps/cvm-server/tsconfig.app.json"
|
|
59
58
|
},
|
|
60
59
|
"configurations": {
|
|
61
|
-
"development": {
|
|
60
|
+
"development": {
|
|
61
|
+
"mode": "development"
|
|
62
|
+
},
|
|
62
63
|
"production": {
|
|
63
|
-
"
|
|
64
|
-
"sourcemap": false,
|
|
65
|
-
"outExtension": {
|
|
66
|
-
".js": ".js"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
64
|
+
"mode": "production"
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
67
|
},
|
|
@@ -77,15 +73,15 @@
|
|
|
77
73
|
"build"
|
|
78
74
|
],
|
|
79
75
|
"options": {
|
|
80
|
-
"buildTarget": "
|
|
76
|
+
"buildTarget": "cvm-server:build",
|
|
81
77
|
"runBuildTargetDependencies": false
|
|
82
78
|
},
|
|
83
79
|
"configurations": {
|
|
84
80
|
"development": {
|
|
85
|
-
"buildTarget": "
|
|
81
|
+
"buildTarget": "cvm-server:build:development"
|
|
86
82
|
},
|
|
87
83
|
"production": {
|
|
88
|
-
"buildTarget": "
|
|
84
|
+
"buildTarget": "cvm-server:build:production"
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface Config {
|
|
2
|
-
storage: {
|
|
3
|
-
type: 'file' | 'mongodb';
|
|
4
|
-
mongoUri?: string;
|
|
5
|
-
dataDir?: string;
|
|
6
|
-
};
|
|
7
|
-
logging: {
|
|
8
|
-
level: 'debug' | 'info' | 'warn' | 'error';
|
|
9
|
-
};
|
|
10
|
-
execution: {
|
|
11
|
-
maxExecutionTime: number;
|
|
12
|
-
maxStackSize: number;
|
|
13
|
-
maxOutputSize: number;
|
|
14
|
-
};
|
|
15
|
-
env: 'development' | 'production';
|
|
16
|
-
}
|
|
17
|
-
export declare function loadConfig(): Config;
|
|
18
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/config.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,OAAO,EAAE;QACP,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;KAC5C,CAAC;IACF,SAAS,EAAE;QACT,gBAAgB,EAAE,MAAM,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,GAAG,EAAE,aAAa,GAAG,YAAY,CAAC;CACnC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAwCnC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var config_exports = {};
|
|
30
|
-
__export(config_exports, {
|
|
31
|
-
loadConfig: () => loadConfig
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(config_exports);
|
|
34
|
-
var dotenv = __toESM(require("dotenv"));
|
|
35
|
-
var import_path = require("path");
|
|
36
|
-
dotenv.config({ path: (0, import_path.resolve)(__dirname, "../../../.env") });
|
|
37
|
-
function loadConfig() {
|
|
38
|
-
const env = process.env.NODE_ENV || "development";
|
|
39
|
-
const storageType = process.env.CVM_STORAGE_TYPE || "file";
|
|
40
|
-
const mongoUri = process.env.MONGODB_URI;
|
|
41
|
-
const dataDir = process.env.CVM_DATA_DIR;
|
|
42
|
-
if (storageType === "mongodb" && !mongoUri) {
|
|
43
|
-
throw new Error("MONGODB_URI environment variable is required when CVM_STORAGE_TYPE is mongodb");
|
|
44
|
-
}
|
|
45
|
-
const logLevel = process.env.CVM_LOG_LEVEL || "info";
|
|
46
|
-
const validLogLevels = ["debug", "info", "warn", "error"];
|
|
47
|
-
if (!validLogLevels.includes(logLevel)) {
|
|
48
|
-
throw new Error(`Invalid CVM_LOG_LEVEL: ${logLevel}. Must be one of: ${validLogLevels.join(", ")}`);
|
|
49
|
-
}
|
|
50
|
-
const maxExecutionTime = parseInt(process.env.CVM_MAX_EXECUTION_TIME || "300000", 10);
|
|
51
|
-
const maxStackSize = parseInt(process.env.CVM_MAX_STACK_SIZE || "1000", 10);
|
|
52
|
-
const maxOutputSize = parseInt(process.env.CVM_MAX_OUTPUT_SIZE || "1048576", 10);
|
|
53
|
-
return {
|
|
54
|
-
storage: {
|
|
55
|
-
type: storageType,
|
|
56
|
-
mongoUri,
|
|
57
|
-
dataDir
|
|
58
|
-
},
|
|
59
|
-
logging: {
|
|
60
|
-
level: logLevel
|
|
61
|
-
},
|
|
62
|
-
execution: {
|
|
63
|
-
maxExecutionTime,
|
|
64
|
-
maxStackSize,
|
|
65
|
-
maxOutputSize
|
|
66
|
-
},
|
|
67
|
-
env
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
-
0 && (module.exports = {
|
|
72
|
-
loadConfig
|
|
73
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
-
export declare class Logger {
|
|
3
|
-
private levelValue;
|
|
4
|
-
constructor(level: LogLevel);
|
|
5
|
-
private log;
|
|
6
|
-
debug(message: string, ...args: unknown[]): void;
|
|
7
|
-
info(message: string, ...args: unknown[]): void;
|
|
8
|
-
warn(message: string, ...args: unknown[]): void;
|
|
9
|
-
error(message: string, ...args: unknown[]): void;
|
|
10
|
-
}
|
|
11
|
-
export declare function initLogger(level: LogLevel): Logger;
|
|
12
|
-
export declare function getLogger(): Logger;
|
|
13
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/logger.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAS3D,qBAAa,MAAM;IACjB,OAAO,CAAC,UAAU,CAAS;gBAEf,KAAK,EAAE,QAAQ;IAI3B,OAAO,CAAC,GAAG;IAcX,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAGjD;AAKD,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAGlD;AAED,wBAAgB,SAAS,IAAI,MAAM,CAKlC"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var logger_exports = {};
|
|
20
|
-
__export(logger_exports, {
|
|
21
|
-
Logger: () => Logger,
|
|
22
|
-
getLogger: () => getLogger,
|
|
23
|
-
initLogger: () => initLogger
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(logger_exports);
|
|
26
|
-
const LOG_LEVELS = {
|
|
27
|
-
debug: 0,
|
|
28
|
-
info: 1,
|
|
29
|
-
warn: 2,
|
|
30
|
-
error: 3
|
|
31
|
-
};
|
|
32
|
-
class Logger {
|
|
33
|
-
levelValue;
|
|
34
|
-
constructor(level) {
|
|
35
|
-
this.levelValue = LOG_LEVELS[level];
|
|
36
|
-
}
|
|
37
|
-
log(level, message, ...args) {
|
|
38
|
-
if (LOG_LEVELS[level] >= this.levelValue) {
|
|
39
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
40
|
-
const prefix = `[${timestamp}] [${level.toUpperCase()}]`;
|
|
41
|
-
if (args.length > 0) {
|
|
42
|
-
console.error(prefix, message, ...args);
|
|
43
|
-
} else {
|
|
44
|
-
console.error(prefix, message);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
debug(message, ...args) {
|
|
49
|
-
this.log("debug", message, ...args);
|
|
50
|
-
}
|
|
51
|
-
info(message, ...args) {
|
|
52
|
-
this.log("info", message, ...args);
|
|
53
|
-
}
|
|
54
|
-
warn(message, ...args) {
|
|
55
|
-
this.log("warn", message, ...args);
|
|
56
|
-
}
|
|
57
|
-
error(message, ...args) {
|
|
58
|
-
this.log("error", message, ...args);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
let logger;
|
|
62
|
-
function initLogger(level) {
|
|
63
|
-
logger = new Logger(level);
|
|
64
|
-
return logger;
|
|
65
|
-
}
|
|
66
|
-
function getLogger() {
|
|
67
|
-
if (!logger) {
|
|
68
|
-
throw new Error("Logger not initialized. Call initLogger() first.");
|
|
69
|
-
}
|
|
70
|
-
return logger;
|
|
71
|
-
}
|
|
72
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
-
0 && (module.exports = {
|
|
74
|
-
Logger,
|
|
75
|
-
getLogger,
|
|
76
|
-
initLogger
|
|
77
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/main.ts"],"names":[],"mappings":""}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var import_mcp_server = require("@cvm/mcp-server");
|
|
3
|
-
var import_config = require("./config.js");
|
|
4
|
-
var import_logger = require("./logger.js");
|
|
5
|
-
var import_path = require("path");
|
|
6
|
-
async function main() {
|
|
7
|
-
let cvmServer;
|
|
8
|
-
try {
|
|
9
|
-
const config = (0, import_config.loadConfig)();
|
|
10
|
-
(0, import_logger.initLogger)(config.logging.level);
|
|
11
|
-
const logger = (0, import_logger.getLogger)();
|
|
12
|
-
logger.info("Starting CVM Server...", {
|
|
13
|
-
env: config.env,
|
|
14
|
-
logLevel: config.logging.level
|
|
15
|
-
});
|
|
16
|
-
if (config.storage.type === "file") {
|
|
17
|
-
const dataDir = config.storage.dataDir || ".cvm";
|
|
18
|
-
const fullPath = (0, import_path.resolve)(process.cwd(), dataDir);
|
|
19
|
-
logger.info(`[CVM] Initializing file storage in: ${fullPath}`);
|
|
20
|
-
logger.warn(`[CVM] \u26A0\uFE0F Remember to add '${dataDir}/' to your .gitignore file!`);
|
|
21
|
-
} else {
|
|
22
|
-
logger.info("[CVM] Using MongoDB storage");
|
|
23
|
-
}
|
|
24
|
-
cvmServer = new import_mcp_server.CVMMcpServer();
|
|
25
|
-
await cvmServer.start();
|
|
26
|
-
logger.info("CVM Server is running and ready to accept MCP connections");
|
|
27
|
-
process.on("SIGINT", async () => {
|
|
28
|
-
logger.info("Received SIGINT, shutting down gracefully...");
|
|
29
|
-
await shutdown();
|
|
30
|
-
});
|
|
31
|
-
process.on("SIGTERM", async () => {
|
|
32
|
-
logger.info("Received SIGTERM, shutting down gracefully...");
|
|
33
|
-
await shutdown();
|
|
34
|
-
});
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error("Fatal error starting CVM Server:", error);
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
async function shutdown() {
|
|
40
|
-
const logger = (0, import_logger.getLogger)();
|
|
41
|
-
try {
|
|
42
|
-
logger.info("Closing connections...");
|
|
43
|
-
if (cvmServer) {
|
|
44
|
-
await cvmServer.stop();
|
|
45
|
-
}
|
|
46
|
-
logger.info("Shutdown complete");
|
|
47
|
-
process.exit(0);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
logger.error("Error during shutdown:", error);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
main().catch((error) => {
|
|
55
|
-
console.error("Unhandled error:", error);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
});
|
package/main.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const Module = require("module");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const originalResolveFilename = Module._resolveFilename;
|
|
6
|
-
const distPath = __dirname;
|
|
7
|
-
const manifest = [];
|
|
8
|
-
Module._resolveFilename = function(request, parent) {
|
|
9
|
-
let found;
|
|
10
|
-
for (const entry of manifest) {
|
|
11
|
-
if (request === entry.module && entry.exactMatch) {
|
|
12
|
-
const entry2 = manifest.find((x) => request === x.module || request.startsWith(x.module + "/"));
|
|
13
|
-
const candidate = path.join(distPath, entry2.exactMatch);
|
|
14
|
-
if (isFile(candidate)) {
|
|
15
|
-
found = candidate;
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
const re = new RegExp(entry.module.replace(/\*$/, "(?<rest>.*)"));
|
|
20
|
-
const match = request.match(re);
|
|
21
|
-
if (match?.groups) {
|
|
22
|
-
const candidate = path.join(distPath, entry.pattern.replace("*", ""), match.groups.rest);
|
|
23
|
-
if (isFile(candidate)) {
|
|
24
|
-
found = candidate;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (found) {
|
|
30
|
-
const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
|
|
31
|
-
return originalResolveFilename.apply(this, modifiedArguments);
|
|
32
|
-
} else {
|
|
33
|
-
return originalResolveFilename.apply(this, arguments);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
function isFile(s) {
|
|
37
|
-
try {
|
|
38
|
-
require.resolve(s);
|
|
39
|
-
return true;
|
|
40
|
-
} catch (_e) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
module.exports = require("./apps/cvm-server/src/main.js");
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var src_exports = {};
|
|
20
|
-
__export(src_exports, {
|
|
21
|
-
CVMMcpServer: () => import_mcp_server.CVMMcpServer
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(src_exports);
|
|
24
|
-
var import_mcp_server = require("./lib/mcp-server.js");
|
|
25
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
-
0 && (module.exports = {
|
|
27
|
-
CVMMcpServer
|
|
28
|
-
});
|