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/index.js
CHANGED
|
@@ -114,9 +114,26 @@ function loadConfig() {
|
|
|
114
114
|
return defaultConfig();
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
function getVersion() {
|
|
118
|
+
try {
|
|
119
|
+
const { readFileSync: readFileSync6 } = require("fs");
|
|
120
|
+
const { resolve: resolve9 } = require("path");
|
|
121
|
+
const pkg = JSON.parse(readFileSync6(resolve9(__dirname, "../package.json"), "utf-8"));
|
|
122
|
+
return pkg.version;
|
|
123
|
+
} catch {
|
|
124
|
+
try {
|
|
125
|
+
const { readFileSync: readFileSync6 } = require("fs");
|
|
126
|
+
const { resolve: resolve9 } = require("path");
|
|
127
|
+
const pkg = JSON.parse(readFileSync6(resolve9(process.cwd(), "package.json"), "utf-8"));
|
|
128
|
+
return pkg.version;
|
|
129
|
+
} catch {
|
|
130
|
+
return "2.0.3";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
117
134
|
function defaultConfig() {
|
|
118
135
|
return {
|
|
119
|
-
server: { port: 7321, host: "localhost", version:
|
|
136
|
+
server: { port: 7321, host: "localhost", version: getVersion() },
|
|
120
137
|
database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
|
|
121
138
|
storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
|
|
122
139
|
limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
|
|
@@ -139,13 +156,22 @@ function mergeDeep(target, source) {
|
|
|
139
156
|
}
|
|
140
157
|
return output;
|
|
141
158
|
}
|
|
142
|
-
|
|
159
|
+
function getConfig() {
|
|
160
|
+
if (!_config) _config = loadConfig();
|
|
161
|
+
return _config;
|
|
162
|
+
}
|
|
163
|
+
var import_fs, import_path, _config, CONFIG;
|
|
143
164
|
var init_config = __esm({
|
|
144
165
|
"src/config.ts"() {
|
|
145
166
|
"use strict";
|
|
146
167
|
import_fs = require("fs");
|
|
147
168
|
import_path = require("path");
|
|
148
|
-
|
|
169
|
+
_config = null;
|
|
170
|
+
CONFIG = new Proxy({}, {
|
|
171
|
+
get(_, prop) {
|
|
172
|
+
return getConfig()[prop];
|
|
173
|
+
}
|
|
174
|
+
});
|
|
149
175
|
}
|
|
150
176
|
});
|
|
151
177
|
|
|
@@ -227,11 +253,14 @@ var init_embedder = __esm({
|
|
|
227
253
|
});
|
|
228
254
|
|
|
229
255
|
// src/server/files.ts
|
|
256
|
+
function getFilesDir() {
|
|
257
|
+
return (0, import_path2.resolve)(process.cwd(), CONFIG.storage.files_dir);
|
|
258
|
+
}
|
|
230
259
|
function ensureDir(path) {
|
|
231
260
|
if (!(0, import_fs2.existsSync)(path)) (0, import_fs2.mkdirSync)(path, { recursive: true });
|
|
232
261
|
}
|
|
233
262
|
function hashPath(hash) {
|
|
234
|
-
return (0, import_path2.resolve)(
|
|
263
|
+
return (0, import_path2.resolve)(getFilesDir(), hash.slice(0, 2), hash.slice(2));
|
|
235
264
|
}
|
|
236
265
|
function computeHash(buffer) {
|
|
237
266
|
return (0, import_crypto.createHash)("sha256").update(buffer).digest("hex");
|
|
@@ -255,7 +284,7 @@ function getFile(hash) {
|
|
|
255
284
|
function fileExists(hash) {
|
|
256
285
|
return (0, import_fs2.existsSync)(hashPath(hash));
|
|
257
286
|
}
|
|
258
|
-
var import_crypto, import_fs2, import_path2
|
|
287
|
+
var import_crypto, import_fs2, import_path2;
|
|
259
288
|
var init_files = __esm({
|
|
260
289
|
"src/server/files.ts"() {
|
|
261
290
|
"use strict";
|
|
@@ -263,7 +292,6 @@ var init_files = __esm({
|
|
|
263
292
|
import_fs2 = require("fs");
|
|
264
293
|
import_path2 = require("path");
|
|
265
294
|
init_config();
|
|
266
|
-
FILES_DIR = (0, import_path2.resolve)(process.cwd(), CONFIG.storage.files_dir);
|
|
267
295
|
}
|
|
268
296
|
});
|
|
269
297
|
|
|
@@ -10857,9 +10885,26 @@ function parseYaml2(text) {
|
|
|
10857
10885
|
}
|
|
10858
10886
|
return root;
|
|
10859
10887
|
}
|
|
10888
|
+
function getVersion2() {
|
|
10889
|
+
try {
|
|
10890
|
+
const { readFileSync: readFileSync6 } = require("fs");
|
|
10891
|
+
const { resolve: resolve9 } = require("path");
|
|
10892
|
+
const pkg = JSON.parse(readFileSync6(resolve9(__dirname, "../../package.json"), "utf-8"));
|
|
10893
|
+
return pkg.version;
|
|
10894
|
+
} catch {
|
|
10895
|
+
try {
|
|
10896
|
+
const { readFileSync: readFileSync6 } = require("fs");
|
|
10897
|
+
const { resolve: resolve9 } = require("path");
|
|
10898
|
+
const pkg = JSON.parse(readFileSync6(resolve9(process.cwd(), "package.json"), "utf-8"));
|
|
10899
|
+
return pkg.version;
|
|
10900
|
+
} catch {
|
|
10901
|
+
return "2.0.3";
|
|
10902
|
+
}
|
|
10903
|
+
}
|
|
10904
|
+
}
|
|
10860
10905
|
function defaultConfig2() {
|
|
10861
10906
|
return {
|
|
10862
|
-
server: { port: 7321, host: "localhost", version:
|
|
10907
|
+
server: { port: 7321, host: "localhost", version: getVersion2() },
|
|
10863
10908
|
database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
|
|
10864
10909
|
storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
|
|
10865
10910
|
limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
|
|
@@ -11146,7 +11191,13 @@ var Mnemosyne = class {
|
|
|
11146
11191
|
this.db.pragma("synchronous = NORMAL");
|
|
11147
11192
|
this.vecEnabled = false;
|
|
11148
11193
|
try {
|
|
11149
|
-
|
|
11194
|
+
let vecPath;
|
|
11195
|
+
try {
|
|
11196
|
+
const sqliteVec = require("sqlite-vec");
|
|
11197
|
+
vecPath = sqliteVec.getLoadablePath();
|
|
11198
|
+
} catch {
|
|
11199
|
+
vecPath = (0, import_path5.resolve)(this.config.baseDirPath || process.cwd(), cfg.database.vec_extension_path);
|
|
11200
|
+
}
|
|
11150
11201
|
this.db.loadExtension(vecPath);
|
|
11151
11202
|
this.vecEnabled = true;
|
|
11152
11203
|
console.log("[DB] sqlite-vec extension loaded");
|
|
@@ -11413,6 +11464,23 @@ var TOOLS = [
|
|
|
11413
11464
|
];
|
|
11414
11465
|
|
|
11415
11466
|
// src/mcp/server.ts
|
|
11467
|
+
function getVersion3() {
|
|
11468
|
+
try {
|
|
11469
|
+
const { readFileSync: readFileSync6 } = require("fs");
|
|
11470
|
+
const { resolve: resolve9 } = require("path");
|
|
11471
|
+
const pkg = JSON.parse(readFileSync6(resolve9(__dirname, "../../package.json"), "utf-8"));
|
|
11472
|
+
return pkg.version;
|
|
11473
|
+
} catch {
|
|
11474
|
+
try {
|
|
11475
|
+
const { readFileSync: readFileSync6 } = require("fs");
|
|
11476
|
+
const { resolve: resolve9 } = require("path");
|
|
11477
|
+
const pkg = JSON.parse(readFileSync6(resolve9(process.cwd(), "package.json"), "utf-8"));
|
|
11478
|
+
return pkg.version;
|
|
11479
|
+
} catch {
|
|
11480
|
+
return "2.0.3";
|
|
11481
|
+
}
|
|
11482
|
+
}
|
|
11483
|
+
}
|
|
11416
11484
|
var McpServer = class {
|
|
11417
11485
|
store;
|
|
11418
11486
|
toolMap = /* @__PURE__ */ new Map();
|
|
@@ -11433,7 +11501,7 @@ var McpServer = class {
|
|
|
11433
11501
|
return this.ok(req.id, {
|
|
11434
11502
|
protocolVersion: "2024-11-05",
|
|
11435
11503
|
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
11436
|
-
serverInfo: { name: "mnemosyne-mcp", version:
|
|
11504
|
+
serverInfo: { name: "mnemosyne-mcp", version: getVersion3() }
|
|
11437
11505
|
});
|
|
11438
11506
|
case "tools/list":
|
|
11439
11507
|
return this.ok(req.id, {
|
|
@@ -11460,7 +11528,7 @@ var McpServer = class {
|
|
|
11460
11528
|
getManifest() {
|
|
11461
11529
|
return {
|
|
11462
11530
|
name: "Mnemosyne",
|
|
11463
|
-
version:
|
|
11531
|
+
version: getVersion3(),
|
|
11464
11532
|
description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
|
|
11465
11533
|
protocol: "mcp",
|
|
11466
11534
|
transport: ["stdio", "sse"],
|
|
@@ -12372,7 +12440,7 @@ var import_crypto2 = require("crypto");
|
|
|
12372
12440
|
var import_fs5 = require("fs");
|
|
12373
12441
|
var import_path6 = require("path");
|
|
12374
12442
|
var DB_PATH = (0, import_path6.resolve)(process.cwd(), "data", "nexus.db");
|
|
12375
|
-
var
|
|
12443
|
+
var FILES_DIR = (0, import_path6.resolve)(process.cwd(), "data", "files");
|
|
12376
12444
|
function sha256File(path) {
|
|
12377
12445
|
return (0, import_crypto2.createHash)("sha256").update((0, import_fs5.readFileSync)(path)).digest("hex");
|
|
12378
12446
|
}
|
|
@@ -12392,11 +12460,11 @@ function sha256Dir(dir) {
|
|
|
12392
12460
|
function buildMnemosyneExport(projectId, projectName) {
|
|
12393
12461
|
const zip = new import_adm_zip2.default();
|
|
12394
12462
|
zip.addLocalFile(DB_PATH, "", "nexus.db");
|
|
12395
|
-
if ((0, import_fs5.existsSync)(
|
|
12396
|
-
zip.addLocalFolder(
|
|
12463
|
+
if ((0, import_fs5.existsSync)(FILES_DIR)) {
|
|
12464
|
+
zip.addLocalFolder(FILES_DIR, "files");
|
|
12397
12465
|
}
|
|
12398
12466
|
const dbChecksum = sha256File(DB_PATH);
|
|
12399
|
-
const filesChecksum = (0, import_fs5.existsSync)(
|
|
12467
|
+
const filesChecksum = (0, import_fs5.existsSync)(FILES_DIR) ? sha256Dir(FILES_DIR) : "";
|
|
12400
12468
|
const manifest = {
|
|
12401
12469
|
version: "1.1",
|
|
12402
12470
|
app: "Mnemosyne",
|
|
@@ -12522,12 +12590,20 @@ function handleEvents(store, pathname, method, res, searchParams) {
|
|
|
12522
12590
|
}
|
|
12523
12591
|
|
|
12524
12592
|
// src/api/routes/health.ts
|
|
12593
|
+
var PKG_VERSION = (() => {
|
|
12594
|
+
try {
|
|
12595
|
+
const pkg = JSON.parse(require("fs").readFileSync(require("path").resolve(__dirname, "../../../package.json"), "utf-8"));
|
|
12596
|
+
return pkg.version;
|
|
12597
|
+
} catch {
|
|
12598
|
+
return "2.0.3";
|
|
12599
|
+
}
|
|
12600
|
+
})();
|
|
12525
12601
|
function handleHealth(store, pathname, method, res) {
|
|
12526
|
-
if (pathname === "/health" && method === "GET") {
|
|
12602
|
+
if ((pathname === "/health" || pathname === "/api/v1/health") && method === "GET") {
|
|
12527
12603
|
const stats = store.getStats();
|
|
12528
12604
|
json(res, 200, {
|
|
12529
12605
|
status: "ok",
|
|
12530
|
-
version:
|
|
12606
|
+
version: PKG_VERSION,
|
|
12531
12607
|
storage: "sqlite",
|
|
12532
12608
|
database: store.config.database.path,
|
|
12533
12609
|
uptime: process.uptime(),
|
|
@@ -12791,18 +12867,20 @@ var import_path8 = require("path");
|
|
|
12791
12867
|
var import_better_sqlite33 = __toESM(require("better-sqlite3"));
|
|
12792
12868
|
var import_path7 = require("path");
|
|
12793
12869
|
init_config();
|
|
12794
|
-
|
|
12870
|
+
function getDbPath() {
|
|
12871
|
+
return process.env.MNEMOSYNE_DB_PATH || (0, import_path7.resolve)(process.cwd(), CONFIG.database.path);
|
|
12872
|
+
}
|
|
12795
12873
|
var db = null;
|
|
12796
12874
|
var vecEnabled = false;
|
|
12797
12875
|
function getDb() {
|
|
12798
12876
|
if (!db) {
|
|
12799
|
-
db = new import_better_sqlite33.default(
|
|
12877
|
+
db = new import_better_sqlite33.default(getDbPath());
|
|
12800
12878
|
db.pragma("journal_mode = WAL");
|
|
12801
12879
|
db.pragma("foreign_keys = ON");
|
|
12802
12880
|
db.pragma("synchronous = NORMAL");
|
|
12803
12881
|
try {
|
|
12804
|
-
const
|
|
12805
|
-
db.loadExtension(
|
|
12882
|
+
const { getLoadablePath } = require("sqlite-vec");
|
|
12883
|
+
db.loadExtension(getLoadablePath());
|
|
12806
12884
|
vecEnabled = true;
|
|
12807
12885
|
console.log("[DB] sqlite-vec extension loaded");
|
|
12808
12886
|
} catch (err) {
|
|
@@ -12841,7 +12919,6 @@ var Store2 = class extends Store {
|
|
|
12841
12919
|
};
|
|
12842
12920
|
|
|
12843
12921
|
// src/server/MnemosyneServer.ts
|
|
12844
|
-
init_config();
|
|
12845
12922
|
var MnemosyneServer = class {
|
|
12846
12923
|
store;
|
|
12847
12924
|
api;
|
|
@@ -12849,8 +12926,9 @@ var MnemosyneServer = class {
|
|
|
12849
12926
|
httpServer;
|
|
12850
12927
|
brain;
|
|
12851
12928
|
constructor(options = {}, brain) {
|
|
12852
|
-
const
|
|
12853
|
-
const
|
|
12929
|
+
const cfg = brain?.config?.config;
|
|
12930
|
+
const port = options.port ?? cfg?.server?.port ?? 7321;
|
|
12931
|
+
const host = options.host ?? cfg?.server?.host ?? "localhost";
|
|
12854
12932
|
const enableDashboard = options.dashboard !== false;
|
|
12855
12933
|
const enableWebsocket = options.websocket !== false;
|
|
12856
12934
|
process.on("uncaughtException", (err) => {
|
|
@@ -12878,8 +12956,9 @@ var MnemosyneServer = class {
|
|
|
12878
12956
|
const wss = new import_websocket_server.default({ server: this.httpServer });
|
|
12879
12957
|
this.wsHandler = new WebSocketHandler(wss, this.store);
|
|
12880
12958
|
}
|
|
12959
|
+
const version = cfg?.server?.version || "2.0.3";
|
|
12881
12960
|
this.httpServer.listen(port, () => {
|
|
12882
|
-
console.log(`Mnemosyne v${
|
|
12961
|
+
console.log(`Mnemosyne v${version} \u2014 port ${port}`);
|
|
12883
12962
|
console.log(`Dashboard: http://${host}:${port}/dashboard`);
|
|
12884
12963
|
console.log(`API: http://${host}:${port}/api/v1`);
|
|
12885
12964
|
console.log(`MCP: http://${host}:${port}/mcp/manifest`);
|
|
@@ -12904,7 +12983,8 @@ var MnemosyneServer = class {
|
|
|
12904
12983
|
};
|
|
12905
12984
|
const dirs = [
|
|
12906
12985
|
(0, import_path8.resolve)(process.cwd(), "src/dashboard"),
|
|
12907
|
-
(0, import_path8.resolve)(process.cwd(), "dashboard")
|
|
12986
|
+
(0, import_path8.resolve)(process.cwd(), "dashboard"),
|
|
12987
|
+
(0, import_path8.resolve)(__dirname, "../dashboard")
|
|
12908
12988
|
];
|
|
12909
12989
|
for (const dir of dirs) {
|
|
12910
12990
|
const filePath = (0, import_path8.resolve)(dir, urlPath);
|