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.mjs
CHANGED
|
@@ -120,9 +120,26 @@ function loadConfig() {
|
|
|
120
120
|
return defaultConfig();
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
+
function getVersion() {
|
|
124
|
+
try {
|
|
125
|
+
const { readFileSync: readFileSync6 } = __require("fs");
|
|
126
|
+
const { resolve: resolve9 } = __require("path");
|
|
127
|
+
const pkg = JSON.parse(readFileSync6(resolve9(__dirname, "../package.json"), "utf-8"));
|
|
128
|
+
return pkg.version;
|
|
129
|
+
} catch {
|
|
130
|
+
try {
|
|
131
|
+
const { readFileSync: readFileSync6 } = __require("fs");
|
|
132
|
+
const { resolve: resolve9 } = __require("path");
|
|
133
|
+
const pkg = JSON.parse(readFileSync6(resolve9(process.cwd(), "package.json"), "utf-8"));
|
|
134
|
+
return pkg.version;
|
|
135
|
+
} catch {
|
|
136
|
+
return "2.0.3";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
123
140
|
function defaultConfig() {
|
|
124
141
|
return {
|
|
125
|
-
server: { port: 7321, host: "localhost", version:
|
|
142
|
+
server: { port: 7321, host: "localhost", version: getVersion() },
|
|
126
143
|
database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
|
|
127
144
|
storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
|
|
128
145
|
limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
|
|
@@ -145,11 +162,20 @@ function mergeDeep(target, source) {
|
|
|
145
162
|
}
|
|
146
163
|
return output;
|
|
147
164
|
}
|
|
148
|
-
|
|
165
|
+
function getConfig() {
|
|
166
|
+
if (!_config) _config = loadConfig();
|
|
167
|
+
return _config;
|
|
168
|
+
}
|
|
169
|
+
var _config, CONFIG;
|
|
149
170
|
var init_config = __esm({
|
|
150
171
|
"src/config.ts"() {
|
|
151
172
|
"use strict";
|
|
152
|
-
|
|
173
|
+
_config = null;
|
|
174
|
+
CONFIG = new Proxy({}, {
|
|
175
|
+
get(_, prop) {
|
|
176
|
+
return getConfig()[prop];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
153
179
|
}
|
|
154
180
|
});
|
|
155
181
|
|
|
@@ -234,11 +260,14 @@ var init_embedder = __esm({
|
|
|
234
260
|
import { createHash } from "crypto";
|
|
235
261
|
import { mkdirSync, existsSync as existsSync2, writeFileSync, readFileSync as readFileSync2 } from "fs";
|
|
236
262
|
import { resolve as resolve2, dirname } from "path";
|
|
263
|
+
function getFilesDir() {
|
|
264
|
+
return resolve2(process.cwd(), CONFIG.storage.files_dir);
|
|
265
|
+
}
|
|
237
266
|
function ensureDir(path) {
|
|
238
267
|
if (!existsSync2(path)) mkdirSync(path, { recursive: true });
|
|
239
268
|
}
|
|
240
269
|
function hashPath(hash) {
|
|
241
|
-
return resolve2(
|
|
270
|
+
return resolve2(getFilesDir(), hash.slice(0, 2), hash.slice(2));
|
|
242
271
|
}
|
|
243
272
|
function computeHash(buffer) {
|
|
244
273
|
return createHash("sha256").update(buffer).digest("hex");
|
|
@@ -262,12 +291,10 @@ function getFile(hash) {
|
|
|
262
291
|
function fileExists(hash) {
|
|
263
292
|
return existsSync2(hashPath(hash));
|
|
264
293
|
}
|
|
265
|
-
var FILES_DIR;
|
|
266
294
|
var init_files = __esm({
|
|
267
295
|
"src/server/files.ts"() {
|
|
268
296
|
"use strict";
|
|
269
297
|
init_config();
|
|
270
|
-
FILES_DIR = resolve2(process.cwd(), CONFIG.storage.files_dir);
|
|
271
298
|
}
|
|
272
299
|
});
|
|
273
300
|
|
|
@@ -10828,9 +10855,26 @@ function parseYaml2(text) {
|
|
|
10828
10855
|
}
|
|
10829
10856
|
return root;
|
|
10830
10857
|
}
|
|
10858
|
+
function getVersion2() {
|
|
10859
|
+
try {
|
|
10860
|
+
const { readFileSync: readFileSync6 } = __require("fs");
|
|
10861
|
+
const { resolve: resolve9 } = __require("path");
|
|
10862
|
+
const pkg = JSON.parse(readFileSync6(resolve9(__dirname, "../../package.json"), "utf-8"));
|
|
10863
|
+
return pkg.version;
|
|
10864
|
+
} catch {
|
|
10865
|
+
try {
|
|
10866
|
+
const { readFileSync: readFileSync6 } = __require("fs");
|
|
10867
|
+
const { resolve: resolve9 } = __require("path");
|
|
10868
|
+
const pkg = JSON.parse(readFileSync6(resolve9(process.cwd(), "package.json"), "utf-8"));
|
|
10869
|
+
return pkg.version;
|
|
10870
|
+
} catch {
|
|
10871
|
+
return "2.0.3";
|
|
10872
|
+
}
|
|
10873
|
+
}
|
|
10874
|
+
}
|
|
10831
10875
|
function defaultConfig2() {
|
|
10832
10876
|
return {
|
|
10833
|
-
server: { port: 7321, host: "localhost", version:
|
|
10877
|
+
server: { port: 7321, host: "localhost", version: getVersion2() },
|
|
10834
10878
|
database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
|
|
10835
10879
|
storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
|
|
10836
10880
|
limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
|
|
@@ -11117,7 +11161,13 @@ var Mnemosyne = class {
|
|
|
11117
11161
|
this.db.pragma("synchronous = NORMAL");
|
|
11118
11162
|
this.vecEnabled = false;
|
|
11119
11163
|
try {
|
|
11120
|
-
|
|
11164
|
+
let vecPath;
|
|
11165
|
+
try {
|
|
11166
|
+
const sqliteVec = __require("sqlite-vec");
|
|
11167
|
+
vecPath = sqliteVec.getLoadablePath();
|
|
11168
|
+
} catch {
|
|
11169
|
+
vecPath = resolve5(this.config.baseDirPath || process.cwd(), cfg.database.vec_extension_path);
|
|
11170
|
+
}
|
|
11121
11171
|
this.db.loadExtension(vecPath);
|
|
11122
11172
|
this.vecEnabled = true;
|
|
11123
11173
|
console.log("[DB] sqlite-vec extension loaded");
|
|
@@ -11384,6 +11434,23 @@ var TOOLS = [
|
|
|
11384
11434
|
];
|
|
11385
11435
|
|
|
11386
11436
|
// src/mcp/server.ts
|
|
11437
|
+
function getVersion3() {
|
|
11438
|
+
try {
|
|
11439
|
+
const { readFileSync: readFileSync6 } = __require("fs");
|
|
11440
|
+
const { resolve: resolve9 } = __require("path");
|
|
11441
|
+
const pkg = JSON.parse(readFileSync6(resolve9(__dirname, "../../package.json"), "utf-8"));
|
|
11442
|
+
return pkg.version;
|
|
11443
|
+
} catch {
|
|
11444
|
+
try {
|
|
11445
|
+
const { readFileSync: readFileSync6 } = __require("fs");
|
|
11446
|
+
const { resolve: resolve9 } = __require("path");
|
|
11447
|
+
const pkg = JSON.parse(readFileSync6(resolve9(process.cwd(), "package.json"), "utf-8"));
|
|
11448
|
+
return pkg.version;
|
|
11449
|
+
} catch {
|
|
11450
|
+
return "2.0.3";
|
|
11451
|
+
}
|
|
11452
|
+
}
|
|
11453
|
+
}
|
|
11387
11454
|
var McpServer = class {
|
|
11388
11455
|
store;
|
|
11389
11456
|
toolMap = /* @__PURE__ */ new Map();
|
|
@@ -11404,7 +11471,7 @@ var McpServer = class {
|
|
|
11404
11471
|
return this.ok(req.id, {
|
|
11405
11472
|
protocolVersion: "2024-11-05",
|
|
11406
11473
|
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
11407
|
-
serverInfo: { name: "mnemosyne-mcp", version:
|
|
11474
|
+
serverInfo: { name: "mnemosyne-mcp", version: getVersion3() }
|
|
11408
11475
|
});
|
|
11409
11476
|
case "tools/list":
|
|
11410
11477
|
return this.ok(req.id, {
|
|
@@ -11431,7 +11498,7 @@ var McpServer = class {
|
|
|
11431
11498
|
getManifest() {
|
|
11432
11499
|
return {
|
|
11433
11500
|
name: "Mnemosyne",
|
|
11434
|
-
version:
|
|
11501
|
+
version: getVersion3(),
|
|
11435
11502
|
description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
|
|
11436
11503
|
protocol: "mcp",
|
|
11437
11504
|
transport: ["stdio", "sse"],
|
|
@@ -12343,7 +12410,7 @@ import { createHash as createHash2 } from "crypto";
|
|
|
12343
12410
|
import { readFileSync as readFileSync4, existsSync as existsSync5, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
12344
12411
|
import { resolve as resolve6 } from "path";
|
|
12345
12412
|
var DB_PATH = resolve6(process.cwd(), "data", "nexus.db");
|
|
12346
|
-
var
|
|
12413
|
+
var FILES_DIR = resolve6(process.cwd(), "data", "files");
|
|
12347
12414
|
function sha256File(path) {
|
|
12348
12415
|
return createHash2("sha256").update(readFileSync4(path)).digest("hex");
|
|
12349
12416
|
}
|
|
@@ -12363,11 +12430,11 @@ function sha256Dir(dir) {
|
|
|
12363
12430
|
function buildMnemosyneExport(projectId, projectName) {
|
|
12364
12431
|
const zip = new AdmZip2();
|
|
12365
12432
|
zip.addLocalFile(DB_PATH, "", "nexus.db");
|
|
12366
|
-
if (existsSync5(
|
|
12367
|
-
zip.addLocalFolder(
|
|
12433
|
+
if (existsSync5(FILES_DIR)) {
|
|
12434
|
+
zip.addLocalFolder(FILES_DIR, "files");
|
|
12368
12435
|
}
|
|
12369
12436
|
const dbChecksum = sha256File(DB_PATH);
|
|
12370
|
-
const filesChecksum = existsSync5(
|
|
12437
|
+
const filesChecksum = existsSync5(FILES_DIR) ? sha256Dir(FILES_DIR) : "";
|
|
12371
12438
|
const manifest = {
|
|
12372
12439
|
version: "1.1",
|
|
12373
12440
|
app: "Mnemosyne",
|
|
@@ -12493,12 +12560,20 @@ function handleEvents(store, pathname, method, res, searchParams) {
|
|
|
12493
12560
|
}
|
|
12494
12561
|
|
|
12495
12562
|
// src/api/routes/health.ts
|
|
12563
|
+
var PKG_VERSION = (() => {
|
|
12564
|
+
try {
|
|
12565
|
+
const pkg = JSON.parse(__require("fs").readFileSync(__require("path").resolve(__dirname, "../../../package.json"), "utf-8"));
|
|
12566
|
+
return pkg.version;
|
|
12567
|
+
} catch {
|
|
12568
|
+
return "2.0.3";
|
|
12569
|
+
}
|
|
12570
|
+
})();
|
|
12496
12571
|
function handleHealth(store, pathname, method, res) {
|
|
12497
|
-
if (pathname === "/health" && method === "GET") {
|
|
12572
|
+
if ((pathname === "/health" || pathname === "/api/v1/health") && method === "GET") {
|
|
12498
12573
|
const stats = store.getStats();
|
|
12499
12574
|
json(res, 200, {
|
|
12500
12575
|
status: "ok",
|
|
12501
|
-
version:
|
|
12576
|
+
version: PKG_VERSION,
|
|
12502
12577
|
storage: "sqlite",
|
|
12503
12578
|
database: store.config.database.path,
|
|
12504
12579
|
uptime: process.uptime(),
|
|
@@ -12762,18 +12837,20 @@ import { resolve as resolve8 } from "path";
|
|
|
12762
12837
|
init_config();
|
|
12763
12838
|
import Database2 from "better-sqlite3";
|
|
12764
12839
|
import { resolve as resolve7 } from "path";
|
|
12765
|
-
|
|
12840
|
+
function getDbPath() {
|
|
12841
|
+
return process.env.MNEMOSYNE_DB_PATH || resolve7(process.cwd(), CONFIG.database.path);
|
|
12842
|
+
}
|
|
12766
12843
|
var db = null;
|
|
12767
12844
|
var vecEnabled = false;
|
|
12768
12845
|
function getDb() {
|
|
12769
12846
|
if (!db) {
|
|
12770
|
-
db = new Database2(
|
|
12847
|
+
db = new Database2(getDbPath());
|
|
12771
12848
|
db.pragma("journal_mode = WAL");
|
|
12772
12849
|
db.pragma("foreign_keys = ON");
|
|
12773
12850
|
db.pragma("synchronous = NORMAL");
|
|
12774
12851
|
try {
|
|
12775
|
-
const
|
|
12776
|
-
db.loadExtension(
|
|
12852
|
+
const { getLoadablePath } = __require("sqlite-vec");
|
|
12853
|
+
db.loadExtension(getLoadablePath());
|
|
12777
12854
|
vecEnabled = true;
|
|
12778
12855
|
console.log("[DB] sqlite-vec extension loaded");
|
|
12779
12856
|
} catch (err) {
|
|
@@ -12812,7 +12889,6 @@ var Store2 = class extends Store {
|
|
|
12812
12889
|
};
|
|
12813
12890
|
|
|
12814
12891
|
// src/server/MnemosyneServer.ts
|
|
12815
|
-
init_config();
|
|
12816
12892
|
var MnemosyneServer = class {
|
|
12817
12893
|
store;
|
|
12818
12894
|
api;
|
|
@@ -12820,8 +12896,9 @@ var MnemosyneServer = class {
|
|
|
12820
12896
|
httpServer;
|
|
12821
12897
|
brain;
|
|
12822
12898
|
constructor(options = {}, brain) {
|
|
12823
|
-
const
|
|
12824
|
-
const
|
|
12899
|
+
const cfg = brain?.config?.config;
|
|
12900
|
+
const port = options.port ?? cfg?.server?.port ?? 7321;
|
|
12901
|
+
const host = options.host ?? cfg?.server?.host ?? "localhost";
|
|
12825
12902
|
const enableDashboard = options.dashboard !== false;
|
|
12826
12903
|
const enableWebsocket = options.websocket !== false;
|
|
12827
12904
|
process.on("uncaughtException", (err) => {
|
|
@@ -12849,8 +12926,9 @@ var MnemosyneServer = class {
|
|
|
12849
12926
|
const wss = new import_websocket_server.default({ server: this.httpServer });
|
|
12850
12927
|
this.wsHandler = new WebSocketHandler(wss, this.store);
|
|
12851
12928
|
}
|
|
12929
|
+
const version = cfg?.server?.version || "2.0.3";
|
|
12852
12930
|
this.httpServer.listen(port, () => {
|
|
12853
|
-
console.log(`Mnemosyne v${
|
|
12931
|
+
console.log(`Mnemosyne v${version} \u2014 port ${port}`);
|
|
12854
12932
|
console.log(`Dashboard: http://${host}:${port}/dashboard`);
|
|
12855
12933
|
console.log(`API: http://${host}:${port}/api/v1`);
|
|
12856
12934
|
console.log(`MCP: http://${host}:${port}/mcp/manifest`);
|
|
@@ -12875,7 +12953,8 @@ var MnemosyneServer = class {
|
|
|
12875
12953
|
};
|
|
12876
12954
|
const dirs = [
|
|
12877
12955
|
resolve8(process.cwd(), "src/dashboard"),
|
|
12878
|
-
resolve8(process.cwd(), "dashboard")
|
|
12956
|
+
resolve8(process.cwd(), "dashboard"),
|
|
12957
|
+
resolve8(__dirname, "../dashboard")
|
|
12879
12958
|
];
|
|
12880
12959
|
for (const dir of dirs) {
|
|
12881
12960
|
const filePath = resolve8(dir, urlPath);
|