mnemosyne-core 2.0.1 → 2.0.3
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/index.js +198 -28
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +197 -28
- package/dist/cli/index.mjs.map +1 -1
- package/dist/dashboard/index.html +9401 -0
- package/dist/index.js +105 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -25
- package/dist/index.mjs.map +1 -1
- package/dist/mcp/index.js +19 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/index.mjs +26 -2
- package/dist/mcp/index.mjs.map +1 -1
- package/dist/server/api.js +66 -13
- package/dist/server/api.js.map +1 -1
- package/dist/server/api.mjs +72 -13
- package/dist/server/api.mjs.map +1 -1
- package/dist/server/index.js +80 -23
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +79 -23
- package/dist/server/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/server/index.js
CHANGED
|
@@ -3730,9 +3730,26 @@ function loadConfig() {
|
|
|
3730
3730
|
return defaultConfig();
|
|
3731
3731
|
}
|
|
3732
3732
|
}
|
|
3733
|
+
function getVersion2() {
|
|
3734
|
+
try {
|
|
3735
|
+
const { readFileSync: readFileSync5 } = require("fs");
|
|
3736
|
+
const { resolve: resolve7 } = require("path");
|
|
3737
|
+
const pkg = JSON.parse(readFileSync5(resolve7(__dirname, "../package.json"), "utf-8"));
|
|
3738
|
+
return pkg.version;
|
|
3739
|
+
} catch {
|
|
3740
|
+
try {
|
|
3741
|
+
const { readFileSync: readFileSync5 } = require("fs");
|
|
3742
|
+
const { resolve: resolve7 } = require("path");
|
|
3743
|
+
const pkg = JSON.parse(readFileSync5(resolve7(process.cwd(), "package.json"), "utf-8"));
|
|
3744
|
+
return pkg.version;
|
|
3745
|
+
} catch {
|
|
3746
|
+
return "2.0.3";
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3733
3750
|
function defaultConfig() {
|
|
3734
3751
|
return {
|
|
3735
|
-
server: { port: 7321, host: "localhost", version:
|
|
3752
|
+
server: { port: 7321, host: "localhost", version: getVersion2() },
|
|
3736
3753
|
database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
|
|
3737
3754
|
storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
|
|
3738
3755
|
limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
|
|
@@ -3755,13 +3772,22 @@ function mergeDeep(target, source) {
|
|
|
3755
3772
|
}
|
|
3756
3773
|
return output;
|
|
3757
3774
|
}
|
|
3758
|
-
|
|
3775
|
+
function getConfig() {
|
|
3776
|
+
if (!_config) _config = loadConfig();
|
|
3777
|
+
return _config;
|
|
3778
|
+
}
|
|
3779
|
+
var import_fs, import_path, _config, CONFIG;
|
|
3759
3780
|
var init_config = __esm({
|
|
3760
3781
|
"src/config.ts"() {
|
|
3761
3782
|
"use strict";
|
|
3762
3783
|
import_fs = require("fs");
|
|
3763
3784
|
import_path = require("path");
|
|
3764
|
-
|
|
3785
|
+
_config = null;
|
|
3786
|
+
CONFIG = new Proxy({}, {
|
|
3787
|
+
get(_, prop) {
|
|
3788
|
+
return getConfig()[prop];
|
|
3789
|
+
}
|
|
3790
|
+
});
|
|
3765
3791
|
}
|
|
3766
3792
|
});
|
|
3767
3793
|
|
|
@@ -3843,11 +3869,14 @@ var init_embedder = __esm({
|
|
|
3843
3869
|
});
|
|
3844
3870
|
|
|
3845
3871
|
// src/server/files.ts
|
|
3872
|
+
function getFilesDir() {
|
|
3873
|
+
return (0, import_path2.resolve)(process.cwd(), CONFIG.storage.files_dir);
|
|
3874
|
+
}
|
|
3846
3875
|
function ensureDir(path) {
|
|
3847
3876
|
if (!(0, import_fs2.existsSync)(path)) (0, import_fs2.mkdirSync)(path, { recursive: true });
|
|
3848
3877
|
}
|
|
3849
3878
|
function hashPath(hash) {
|
|
3850
|
-
return (0, import_path2.resolve)(
|
|
3879
|
+
return (0, import_path2.resolve)(getFilesDir(), hash.slice(0, 2), hash.slice(2));
|
|
3851
3880
|
}
|
|
3852
3881
|
function computeHash(buffer) {
|
|
3853
3882
|
return (0, import_crypto.createHash)("sha256").update(buffer).digest("hex");
|
|
@@ -3868,7 +3897,7 @@ function getFile(hash) {
|
|
|
3868
3897
|
return null;
|
|
3869
3898
|
}
|
|
3870
3899
|
}
|
|
3871
|
-
var import_crypto, import_fs2, import_path2
|
|
3900
|
+
var import_crypto, import_fs2, import_path2;
|
|
3872
3901
|
var init_files = __esm({
|
|
3873
3902
|
"src/server/files.ts"() {
|
|
3874
3903
|
"use strict";
|
|
@@ -3876,7 +3905,6 @@ var init_files = __esm({
|
|
|
3876
3905
|
import_fs2 = require("fs");
|
|
3877
3906
|
import_path2 = require("path");
|
|
3878
3907
|
init_config();
|
|
3879
|
-
FILES_DIR = (0, import_path2.resolve)(process.cwd(), CONFIG.storage.files_dir);
|
|
3880
3908
|
}
|
|
3881
3909
|
});
|
|
3882
3910
|
|
|
@@ -9835,6 +9863,23 @@ var TOOLS = [
|
|
|
9835
9863
|
];
|
|
9836
9864
|
|
|
9837
9865
|
// src/mcp/server.ts
|
|
9866
|
+
function getVersion() {
|
|
9867
|
+
try {
|
|
9868
|
+
const { readFileSync: readFileSync5 } = require("fs");
|
|
9869
|
+
const { resolve: resolve7 } = require("path");
|
|
9870
|
+
const pkg = JSON.parse(readFileSync5(resolve7(__dirname, "../../package.json"), "utf-8"));
|
|
9871
|
+
return pkg.version;
|
|
9872
|
+
} catch {
|
|
9873
|
+
try {
|
|
9874
|
+
const { readFileSync: readFileSync5 } = require("fs");
|
|
9875
|
+
const { resolve: resolve7 } = require("path");
|
|
9876
|
+
const pkg = JSON.parse(readFileSync5(resolve7(process.cwd(), "package.json"), "utf-8"));
|
|
9877
|
+
return pkg.version;
|
|
9878
|
+
} catch {
|
|
9879
|
+
return "2.0.3";
|
|
9880
|
+
}
|
|
9881
|
+
}
|
|
9882
|
+
}
|
|
9838
9883
|
var McpServer = class {
|
|
9839
9884
|
store;
|
|
9840
9885
|
toolMap = /* @__PURE__ */ new Map();
|
|
@@ -9855,7 +9900,7 @@ var McpServer = class {
|
|
|
9855
9900
|
return this.ok(req.id, {
|
|
9856
9901
|
protocolVersion: "2024-11-05",
|
|
9857
9902
|
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
9858
|
-
serverInfo: { name: "mnemosyne-mcp", version:
|
|
9903
|
+
serverInfo: { name: "mnemosyne-mcp", version: getVersion() }
|
|
9859
9904
|
});
|
|
9860
9905
|
case "tools/list":
|
|
9861
9906
|
return this.ok(req.id, {
|
|
@@ -9882,7 +9927,7 @@ var McpServer = class {
|
|
|
9882
9927
|
getManifest() {
|
|
9883
9928
|
return {
|
|
9884
9929
|
name: "Mnemosyne",
|
|
9885
|
-
version:
|
|
9930
|
+
version: getVersion(),
|
|
9886
9931
|
description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
|
|
9887
9932
|
protocol: "mcp",
|
|
9888
9933
|
transport: ["stdio", "sse"],
|
|
@@ -10760,7 +10805,7 @@ var import_crypto2 = require("crypto");
|
|
|
10760
10805
|
var import_fs3 = require("fs");
|
|
10761
10806
|
var import_path3 = require("path");
|
|
10762
10807
|
var DB_PATH = (0, import_path3.resolve)(process.cwd(), "data", "nexus.db");
|
|
10763
|
-
var
|
|
10808
|
+
var FILES_DIR = (0, import_path3.resolve)(process.cwd(), "data", "files");
|
|
10764
10809
|
function sha256File(path) {
|
|
10765
10810
|
return (0, import_crypto2.createHash)("sha256").update((0, import_fs3.readFileSync)(path)).digest("hex");
|
|
10766
10811
|
}
|
|
@@ -10780,11 +10825,11 @@ function sha256Dir(dir) {
|
|
|
10780
10825
|
function buildMnemosyneExport(projectId, projectName) {
|
|
10781
10826
|
const zip = new import_adm_zip.default();
|
|
10782
10827
|
zip.addLocalFile(DB_PATH, "", "nexus.db");
|
|
10783
|
-
if ((0, import_fs3.existsSync)(
|
|
10784
|
-
zip.addLocalFolder(
|
|
10828
|
+
if ((0, import_fs3.existsSync)(FILES_DIR)) {
|
|
10829
|
+
zip.addLocalFolder(FILES_DIR, "files");
|
|
10785
10830
|
}
|
|
10786
10831
|
const dbChecksum = sha256File(DB_PATH);
|
|
10787
|
-
const filesChecksum = (0, import_fs3.existsSync)(
|
|
10832
|
+
const filesChecksum = (0, import_fs3.existsSync)(FILES_DIR) ? sha256Dir(FILES_DIR) : "";
|
|
10788
10833
|
const manifest = {
|
|
10789
10834
|
version: "1.1",
|
|
10790
10835
|
app: "Mnemosyne",
|
|
@@ -10910,12 +10955,20 @@ function handleEvents(store, pathname, method, res, searchParams) {
|
|
|
10910
10955
|
}
|
|
10911
10956
|
|
|
10912
10957
|
// src/api/routes/health.ts
|
|
10958
|
+
var PKG_VERSION = (() => {
|
|
10959
|
+
try {
|
|
10960
|
+
const pkg = JSON.parse(require("fs").readFileSync(require("path").resolve(__dirname, "../../../package.json"), "utf-8"));
|
|
10961
|
+
return pkg.version;
|
|
10962
|
+
} catch {
|
|
10963
|
+
return "2.0.3";
|
|
10964
|
+
}
|
|
10965
|
+
})();
|
|
10913
10966
|
function handleHealth(store, pathname, method, res) {
|
|
10914
|
-
if (pathname === "/health" && method === "GET") {
|
|
10967
|
+
if ((pathname === "/health" || pathname === "/api/v1/health") && method === "GET") {
|
|
10915
10968
|
const stats = store.getStats();
|
|
10916
10969
|
json(res, 200, {
|
|
10917
10970
|
status: "ok",
|
|
10918
|
-
version:
|
|
10971
|
+
version: PKG_VERSION,
|
|
10919
10972
|
storage: "sqlite",
|
|
10920
10973
|
database: store.config.database.path,
|
|
10921
10974
|
uptime: process.uptime(),
|
|
@@ -12513,18 +12566,20 @@ CREATE TABLE IF NOT EXISTS atom_permissions (
|
|
|
12513
12566
|
`;
|
|
12514
12567
|
|
|
12515
12568
|
// src/db/connection.ts
|
|
12516
|
-
|
|
12569
|
+
function getDbPath() {
|
|
12570
|
+
return process.env.MNEMOSYNE_DB_PATH || (0, import_path5.resolve)(process.cwd(), CONFIG.database.path);
|
|
12571
|
+
}
|
|
12517
12572
|
var db = null;
|
|
12518
12573
|
var vecEnabled = false;
|
|
12519
12574
|
function getDb() {
|
|
12520
12575
|
if (!db) {
|
|
12521
|
-
db = new import_better_sqlite32.default(
|
|
12576
|
+
db = new import_better_sqlite32.default(getDbPath());
|
|
12522
12577
|
db.pragma("journal_mode = WAL");
|
|
12523
12578
|
db.pragma("foreign_keys = ON");
|
|
12524
12579
|
db.pragma("synchronous = NORMAL");
|
|
12525
12580
|
try {
|
|
12526
|
-
const
|
|
12527
|
-
db.loadExtension(
|
|
12581
|
+
const { getLoadablePath } = require("sqlite-vec");
|
|
12582
|
+
db.loadExtension(getLoadablePath());
|
|
12528
12583
|
vecEnabled = true;
|
|
12529
12584
|
console.log("[DB] sqlite-vec extension loaded");
|
|
12530
12585
|
} catch (err) {
|
|
@@ -12563,7 +12618,6 @@ var Store2 = class extends Store {
|
|
|
12563
12618
|
};
|
|
12564
12619
|
|
|
12565
12620
|
// src/server/MnemosyneServer.ts
|
|
12566
|
-
init_config();
|
|
12567
12621
|
var MnemosyneServer = class {
|
|
12568
12622
|
store;
|
|
12569
12623
|
api;
|
|
@@ -12571,8 +12625,9 @@ var MnemosyneServer = class {
|
|
|
12571
12625
|
httpServer;
|
|
12572
12626
|
brain;
|
|
12573
12627
|
constructor(options = {}, brain) {
|
|
12574
|
-
const
|
|
12575
|
-
const
|
|
12628
|
+
const cfg = brain?.config?.config;
|
|
12629
|
+
const port = options.port ?? cfg?.server?.port ?? 7321;
|
|
12630
|
+
const host = options.host ?? cfg?.server?.host ?? "localhost";
|
|
12576
12631
|
const enableDashboard = options.dashboard !== false;
|
|
12577
12632
|
const enableWebsocket = options.websocket !== false;
|
|
12578
12633
|
process.on("uncaughtException", (err) => {
|
|
@@ -12600,8 +12655,9 @@ var MnemosyneServer = class {
|
|
|
12600
12655
|
const wss = new import_websocket_server.default({ server: this.httpServer });
|
|
12601
12656
|
this.wsHandler = new WebSocketHandler(wss, this.store);
|
|
12602
12657
|
}
|
|
12658
|
+
const version = cfg?.server?.version || "2.0.3";
|
|
12603
12659
|
this.httpServer.listen(port, () => {
|
|
12604
|
-
console.log(`Mnemosyne v${
|
|
12660
|
+
console.log(`Mnemosyne v${version} \u2014 port ${port}`);
|
|
12605
12661
|
console.log(`Dashboard: http://${host}:${port}/dashboard`);
|
|
12606
12662
|
console.log(`API: http://${host}:${port}/api/v1`);
|
|
12607
12663
|
console.log(`MCP: http://${host}:${port}/mcp/manifest`);
|
|
@@ -12626,7 +12682,8 @@ var MnemosyneServer = class {
|
|
|
12626
12682
|
};
|
|
12627
12683
|
const dirs = [
|
|
12628
12684
|
(0, import_path6.resolve)(process.cwd(), "src/dashboard"),
|
|
12629
|
-
(0, import_path6.resolve)(process.cwd(), "dashboard")
|
|
12685
|
+
(0, import_path6.resolve)(process.cwd(), "dashboard"),
|
|
12686
|
+
(0, import_path6.resolve)(__dirname, "../dashboard")
|
|
12630
12687
|
];
|
|
12631
12688
|
for (const dir of dirs) {
|
|
12632
12689
|
const filePath = (0, import_path6.resolve)(dir, urlPath);
|