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 CHANGED
@@ -3548,9 +3548,26 @@ function loadConfig() {
3548
3548
  return defaultConfig();
3549
3549
  }
3550
3550
  }
3551
+ function getVersion() {
3552
+ try {
3553
+ const { readFileSync: readFileSync7 } = require("fs");
3554
+ const { resolve: resolve13 } = require("path");
3555
+ const pkg = JSON.parse(readFileSync7(resolve13(__dirname, "../package.json"), "utf-8"));
3556
+ return pkg.version;
3557
+ } catch {
3558
+ try {
3559
+ const { readFileSync: readFileSync7 } = require("fs");
3560
+ const { resolve: resolve13 } = require("path");
3561
+ const pkg = JSON.parse(readFileSync7(resolve13(process.cwd(), "package.json"), "utf-8"));
3562
+ return pkg.version;
3563
+ } catch {
3564
+ return "2.0.3";
3565
+ }
3566
+ }
3567
+ }
3551
3568
  function defaultConfig() {
3552
3569
  return {
3553
- server: { port: 7321, host: "localhost", version: "2.0.0" },
3570
+ server: { port: 7321, host: "localhost", version: getVersion() },
3554
3571
  database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
3555
3572
  storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
3556
3573
  limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
@@ -3573,13 +3590,22 @@ function mergeDeep(target, source) {
3573
3590
  }
3574
3591
  return output;
3575
3592
  }
3576
- var import_fs, import_path, CONFIG;
3593
+ function getConfig() {
3594
+ if (!_config) _config = loadConfig();
3595
+ return _config;
3596
+ }
3597
+ var import_fs, import_path, _config, CONFIG;
3577
3598
  var init_config = __esm({
3578
3599
  "src/config.ts"() {
3579
3600
  "use strict";
3580
3601
  import_fs = require("fs");
3581
3602
  import_path = require("path");
3582
- CONFIG = loadConfig();
3603
+ _config = null;
3604
+ CONFIG = new Proxy({}, {
3605
+ get(_, prop) {
3606
+ return getConfig()[prop];
3607
+ }
3608
+ });
3583
3609
  }
3584
3610
  });
3585
3611
 
@@ -3661,11 +3687,14 @@ var init_embedder = __esm({
3661
3687
  });
3662
3688
 
3663
3689
  // src/server/files.ts
3690
+ function getFilesDir() {
3691
+ return (0, import_path2.resolve)(process.cwd(), CONFIG.storage.files_dir);
3692
+ }
3664
3693
  function ensureDir(path) {
3665
3694
  if (!(0, import_fs2.existsSync)(path)) (0, import_fs2.mkdirSync)(path, { recursive: true });
3666
3695
  }
3667
3696
  function hashPath(hash) {
3668
- return (0, import_path2.resolve)(FILES_DIR, hash.slice(0, 2), hash.slice(2));
3697
+ return (0, import_path2.resolve)(getFilesDir(), hash.slice(0, 2), hash.slice(2));
3669
3698
  }
3670
3699
  function computeHash(buffer) {
3671
3700
  return (0, import_crypto.createHash)("sha256").update(buffer).digest("hex");
@@ -3686,7 +3715,7 @@ function getFile(hash) {
3686
3715
  return null;
3687
3716
  }
3688
3717
  }
3689
- var import_crypto, import_fs2, import_path2, FILES_DIR;
3718
+ var import_crypto, import_fs2, import_path2;
3690
3719
  var init_files = __esm({
3691
3720
  "src/server/files.ts"() {
3692
3721
  "use strict";
@@ -3694,7 +3723,6 @@ var init_files = __esm({
3694
3723
  import_fs2 = require("fs");
3695
3724
  import_path2 = require("path");
3696
3725
  init_config();
3697
- FILES_DIR = (0, import_path2.resolve)(process.cwd(), CONFIG.storage.files_dir);
3698
3726
  }
3699
3727
  });
3700
3728
 
@@ -13074,6 +13102,81 @@ var init_stdio = __esm({
13074
13102
  }
13075
13103
  });
13076
13104
 
13105
+ // package.json
13106
+ var require_package2 = __commonJS({
13107
+ "package.json"(exports2, module2) {
13108
+ module2.exports = {
13109
+ name: "mnemosyne-core",
13110
+ version: "2.0.3",
13111
+ description: "Unified memory engine for AI agents \u2014 graph atoms, semantic search, and collaborative memory",
13112
+ logo: "logo.png",
13113
+ author: "Arman Aslanyan <aslanyanarman88@gmail.com> (https://www.linkedin.com/in/arman-aslanyan/)",
13114
+ main: "dist/index.js",
13115
+ module: "dist/index.js",
13116
+ types: "dist/index.d.ts",
13117
+ bin: {
13118
+ "mnemosyne-core": "./dist/cli/index.js"
13119
+ },
13120
+ exports: {
13121
+ ".": {
13122
+ types: "./dist/index.d.ts",
13123
+ import: "./dist/index.js",
13124
+ require: "./dist/index.js"
13125
+ },
13126
+ "./sdk": {
13127
+ types: "./dist/sdk/index.d.ts",
13128
+ import: "./dist/sdk/index.js",
13129
+ require: "./dist/sdk/index.js"
13130
+ },
13131
+ "./ws": {
13132
+ types: "./dist/ws/index.d.ts",
13133
+ import: "./dist/ws/index.js",
13134
+ require: "./dist/ws/index.js"
13135
+ },
13136
+ "./mcp": {
13137
+ types: "./dist/mcp/index.d.ts",
13138
+ import: "./dist/mcp/index.js",
13139
+ require: "./dist/mcp/index.js"
13140
+ },
13141
+ "./cli": {
13142
+ types: "./dist/cli/index.d.ts",
13143
+ import: "./dist/cli/index.js",
13144
+ require: "./dist/cli/index.js"
13145
+ }
13146
+ },
13147
+ files: [
13148
+ "dist"
13149
+ ],
13150
+ scripts: {
13151
+ start: "node dist/cli/index.js",
13152
+ dev: "tsx watch src/cli/index.ts",
13153
+ build: `tsup --config tsup.config.ts && node -e "require('fs').mkdirSync('dist/dashboard',{recursive:true});require('fs').copyFileSync('src/dashboard/index.html','dist/dashboard/index.html')"`,
13154
+ typecheck: "tsc --noEmit"
13155
+ },
13156
+ devDependencies: {
13157
+ "@types/adm-zip": "^0.5.8",
13158
+ "@types/better-sqlite3": "^7.6.13",
13159
+ "@types/node": "^25.6.2",
13160
+ "@types/ws": "^8.18.1",
13161
+ commander: "^14.0.3",
13162
+ tsup: "^8.5.1",
13163
+ tsx: "^4.19.0",
13164
+ typescript: "^5.8.3",
13165
+ ws: "^8.18.0"
13166
+ },
13167
+ engines: {
13168
+ node: ">=20"
13169
+ },
13170
+ dependencies: {
13171
+ "@xenova/transformers": "^2.17.2",
13172
+ "adm-zip": "^0.5.17",
13173
+ "better-sqlite3": "^12.10.0",
13174
+ "sqlite-vec": "^0.1.9"
13175
+ }
13176
+ };
13177
+ }
13178
+ });
13179
+
13077
13180
  // src/cli/index.ts
13078
13181
  var cli_exports = {};
13079
13182
  __export(cli_exports, {
@@ -14326,9 +14429,26 @@ function parseYaml2(text) {
14326
14429
  }
14327
14430
  return root;
14328
14431
  }
14432
+ function getVersion2() {
14433
+ try {
14434
+ const { readFileSync: readFileSync7 } = require("fs");
14435
+ const { resolve: resolve13 } = require("path");
14436
+ const pkg = JSON.parse(readFileSync7(resolve13(__dirname, "../../package.json"), "utf-8"));
14437
+ return pkg.version;
14438
+ } catch {
14439
+ try {
14440
+ const { readFileSync: readFileSync7 } = require("fs");
14441
+ const { resolve: resolve13 } = require("path");
14442
+ const pkg = JSON.parse(readFileSync7(resolve13(process.cwd(), "package.json"), "utf-8"));
14443
+ return pkg.version;
14444
+ } catch {
14445
+ return "2.0.3";
14446
+ }
14447
+ }
14448
+ }
14329
14449
  function defaultConfig2() {
14330
14450
  return {
14331
- server: { port: 7321, host: "localhost", version: "2.0.0" },
14451
+ server: { port: 7321, host: "localhost", version: getVersion2() },
14332
14452
  database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
14333
14453
  storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
14334
14454
  limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
@@ -14615,7 +14735,13 @@ var Mnemosyne = class {
14615
14735
  this.db.pragma("synchronous = NORMAL");
14616
14736
  this.vecEnabled = false;
14617
14737
  try {
14618
- const vecPath = (0, import_path5.resolve)(this.config.baseDirPath || process.cwd(), cfg.database.vec_extension_path);
14738
+ let vecPath;
14739
+ try {
14740
+ const sqliteVec = require("sqlite-vec");
14741
+ vecPath = sqliteVec.getLoadablePath();
14742
+ } catch {
14743
+ vecPath = (0, import_path5.resolve)(this.config.baseDirPath || process.cwd(), cfg.database.vec_extension_path);
14744
+ }
14619
14745
  this.db.loadExtension(vecPath);
14620
14746
  this.vecEnabled = true;
14621
14747
  console.log("[DB] sqlite-vec extension loaded");
@@ -14897,6 +15023,23 @@ var TOOLS = [
14897
15023
  ];
14898
15024
 
14899
15025
  // src/mcp/server.ts
15026
+ function getVersion3() {
15027
+ try {
15028
+ const { readFileSync: readFileSync7 } = require("fs");
15029
+ const { resolve: resolve13 } = require("path");
15030
+ const pkg = JSON.parse(readFileSync7(resolve13(__dirname, "../../package.json"), "utf-8"));
15031
+ return pkg.version;
15032
+ } catch {
15033
+ try {
15034
+ const { readFileSync: readFileSync7 } = require("fs");
15035
+ const { resolve: resolve13 } = require("path");
15036
+ const pkg = JSON.parse(readFileSync7(resolve13(process.cwd(), "package.json"), "utf-8"));
15037
+ return pkg.version;
15038
+ } catch {
15039
+ return "2.0.3";
15040
+ }
15041
+ }
15042
+ }
14900
15043
  var McpServer = class {
14901
15044
  store;
14902
15045
  toolMap = /* @__PURE__ */ new Map();
@@ -14917,7 +15060,7 @@ var McpServer = class {
14917
15060
  return this.ok(req.id, {
14918
15061
  protocolVersion: "2024-11-05",
14919
15062
  capabilities: { tools: {}, resources: {}, prompts: {} },
14920
- serverInfo: { name: "mnemosyne-mcp", version: "2.0.0" }
15063
+ serverInfo: { name: "mnemosyne-mcp", version: getVersion3() }
14921
15064
  });
14922
15065
  case "tools/list":
14923
15066
  return this.ok(req.id, {
@@ -14944,7 +15087,7 @@ var McpServer = class {
14944
15087
  getManifest() {
14945
15088
  return {
14946
15089
  name: "Mnemosyne",
14947
- version: "2.0.0",
15090
+ version: getVersion3(),
14948
15091
  description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
14949
15092
  protocol: "mcp",
14950
15093
  transport: ["stdio", "sse"],
@@ -15825,7 +15968,7 @@ var import_crypto2 = require("crypto");
15825
15968
  var import_fs5 = require("fs");
15826
15969
  var import_path6 = require("path");
15827
15970
  var DB_PATH = (0, import_path6.resolve)(process.cwd(), "data", "nexus.db");
15828
- var FILES_DIR2 = (0, import_path6.resolve)(process.cwd(), "data", "files");
15971
+ var FILES_DIR = (0, import_path6.resolve)(process.cwd(), "data", "files");
15829
15972
  function sha256File(path) {
15830
15973
  return (0, import_crypto2.createHash)("sha256").update((0, import_fs5.readFileSync)(path)).digest("hex");
15831
15974
  }
@@ -15845,11 +15988,11 @@ function sha256Dir(dir) {
15845
15988
  function buildMnemosyneExport(projectId, projectName) {
15846
15989
  const zip = new import_adm_zip2.default();
15847
15990
  zip.addLocalFile(DB_PATH, "", "nexus.db");
15848
- if ((0, import_fs5.existsSync)(FILES_DIR2)) {
15849
- zip.addLocalFolder(FILES_DIR2, "files");
15991
+ if ((0, import_fs5.existsSync)(FILES_DIR)) {
15992
+ zip.addLocalFolder(FILES_DIR, "files");
15850
15993
  }
15851
15994
  const dbChecksum = sha256File(DB_PATH);
15852
- const filesChecksum = (0, import_fs5.existsSync)(FILES_DIR2) ? sha256Dir(FILES_DIR2) : "";
15995
+ const filesChecksum = (0, import_fs5.existsSync)(FILES_DIR) ? sha256Dir(FILES_DIR) : "";
15853
15996
  const manifest = {
15854
15997
  version: "1.1",
15855
15998
  app: "Mnemosyne",
@@ -15975,12 +16118,20 @@ function handleEvents(store, pathname, method, res, searchParams) {
15975
16118
  }
15976
16119
 
15977
16120
  // src/api/routes/health.ts
16121
+ var PKG_VERSION = (() => {
16122
+ try {
16123
+ const pkg = JSON.parse(require("fs").readFileSync(require("path").resolve(__dirname, "../../../package.json"), "utf-8"));
16124
+ return pkg.version;
16125
+ } catch {
16126
+ return "2.0.3";
16127
+ }
16128
+ })();
15978
16129
  function handleHealth(store, pathname, method, res) {
15979
- if (pathname === "/health" && method === "GET") {
16130
+ if ((pathname === "/health" || pathname === "/api/v1/health") && method === "GET") {
15980
16131
  const stats = store.getStats();
15981
16132
  json(res, 200, {
15982
16133
  status: "ok",
15983
- version: "2.0.0",
16134
+ version: PKG_VERSION,
15984
16135
  storage: "sqlite",
15985
16136
  database: store.config.database.path,
15986
16137
  uptime: process.uptime(),
@@ -16207,18 +16358,20 @@ var WebSocketHandler = class {
16207
16358
  var import_better_sqlite33 = __toESM(require("better-sqlite3"));
16208
16359
  var import_path7 = require("path");
16209
16360
  init_config();
16210
- var DB_PATH2 = process.env.MNEMOSYNE_DB_PATH || (0, import_path7.resolve)(process.cwd(), CONFIG.database.path);
16361
+ function getDbPath() {
16362
+ return process.env.MNEMOSYNE_DB_PATH || (0, import_path7.resolve)(process.cwd(), CONFIG.database.path);
16363
+ }
16211
16364
  var db = null;
16212
16365
  var vecEnabled = false;
16213
16366
  function getDb() {
16214
16367
  if (!db) {
16215
- db = new import_better_sqlite33.default(DB_PATH2);
16368
+ db = new import_better_sqlite33.default(getDbPath());
16216
16369
  db.pragma("journal_mode = WAL");
16217
16370
  db.pragma("foreign_keys = ON");
16218
16371
  db.pragma("synchronous = NORMAL");
16219
16372
  try {
16220
- const vecPath = (0, import_path7.resolve)(process.cwd(), CONFIG.database.vec_extension_path);
16221
- db.loadExtension(vecPath);
16373
+ const { getLoadablePath } = require("sqlite-vec");
16374
+ db.loadExtension(getLoadablePath());
16222
16375
  vecEnabled = true;
16223
16376
  console.log("[DB] sqlite-vec extension loaded");
16224
16377
  } catch (err) {
@@ -16257,7 +16410,6 @@ var Store2 = class extends Store {
16257
16410
  };
16258
16411
 
16259
16412
  // src/server/MnemosyneServer.ts
16260
- init_config();
16261
16413
  var MnemosyneServer = class {
16262
16414
  store;
16263
16415
  api;
@@ -16265,8 +16417,9 @@ var MnemosyneServer = class {
16265
16417
  httpServer;
16266
16418
  brain;
16267
16419
  constructor(options = {}, brain) {
16268
- const port = options.port ?? CONFIG.server.port;
16269
- const host = options.host ?? CONFIG.server.host;
16420
+ const cfg = brain?.config?.config;
16421
+ const port = options.port ?? cfg?.server?.port ?? 7321;
16422
+ const host = options.host ?? cfg?.server?.host ?? "localhost";
16270
16423
  const enableDashboard = options.dashboard !== false;
16271
16424
  const enableWebsocket = options.websocket !== false;
16272
16425
  process.on("uncaughtException", (err) => {
@@ -16294,8 +16447,9 @@ var MnemosyneServer = class {
16294
16447
  const wss = new import_websocket_server.default({ server: this.httpServer });
16295
16448
  this.wsHandler = new WebSocketHandler(wss, this.store);
16296
16449
  }
16450
+ const version = cfg?.server?.version || "2.0.3";
16297
16451
  this.httpServer.listen(port, () => {
16298
- console.log(`Mnemosyne v${CONFIG.server.version} \u2014 port ${port}`);
16452
+ console.log(`Mnemosyne v${version} \u2014 port ${port}`);
16299
16453
  console.log(`Dashboard: http://${host}:${port}/dashboard`);
16300
16454
  console.log(`API: http://${host}:${port}/api/v1`);
16301
16455
  console.log(`MCP: http://${host}:${port}/mcp/manifest`);
@@ -16320,7 +16474,8 @@ var MnemosyneServer = class {
16320
16474
  };
16321
16475
  const dirs = [
16322
16476
  (0, import_path8.resolve)(process.cwd(), "src/dashboard"),
16323
- (0, import_path8.resolve)(process.cwd(), "dashboard")
16477
+ (0, import_path8.resolve)(process.cwd(), "dashboard"),
16478
+ (0, import_path8.resolve)(__dirname, "../dashboard")
16324
16479
  ];
16325
16480
  for (const dir of dirs) {
16326
16481
  const filePath = (0, import_path8.resolve)(dir, urlPath);
@@ -16344,6 +16499,15 @@ var MnemosyneServer = class {
16344
16499
  };
16345
16500
 
16346
16501
  // src/cli/commands/start.ts
16502
+ function getVersion4() {
16503
+ try {
16504
+ const { readFileSync: readFileSync7 } = require("fs");
16505
+ const { resolve: resolve13 } = require("path");
16506
+ return JSON.parse(readFileSync7(resolve13(__dirname, "../../../package.json"), "utf-8")).version;
16507
+ } catch {
16508
+ return "2.0.3";
16509
+ }
16510
+ }
16347
16511
  async function startCommand(options) {
16348
16512
  const dataDir = (0, import_path9.resolve)(options.dataDir);
16349
16513
  const dbPath = (0, import_path9.resolve)(dataDir, "nexus.db");
@@ -16351,7 +16515,7 @@ async function startCommand(options) {
16351
16515
  await brain.init();
16352
16516
  if (options.mcpTransport === "stdio" && options.mcp) {
16353
16517
  if (options.verbose) {
16354
- console.error(`\u{1F9E0} Mnemosyne v2.0.0 (stdio mode)`);
16518
+ console.error(`\u{1F9E0} Mnemosyne v${getVersion4()} (stdio mode)`);
16355
16519
  console.error(` dbPath: ${dbPath}`);
16356
16520
  }
16357
16521
  const mcpServer = new McpServer(brain.store);
@@ -16361,7 +16525,7 @@ async function startCommand(options) {
16361
16525
  return;
16362
16526
  }
16363
16527
  const port = parseInt(options.port, 10);
16364
- console.log(`\u{1F9E0} Mnemosyne v2.0.0`);
16528
+ console.log(`\u{1F9E0} Mnemosyne v${getVersion4()}`);
16365
16529
  if (options.verbose) {
16366
16530
  console.log(` dataDir: ${dataDir}`);
16367
16531
  console.log(` dbPath: ${dbPath}`);
@@ -16542,7 +16706,13 @@ async function exportCommand(options) {
16542
16706
 
16543
16707
  // src/cli/index.ts
16544
16708
  var program2 = new Command();
16545
- program2.name("mnemosyne").description("Mnemosyne \u2014 Your exocortex").version("2.0.0");
16709
+ program2.name("mnemosyne").description("Mnemosyne \u2014 Your exocortex").version((() => {
16710
+ try {
16711
+ return require_package2().version;
16712
+ } catch {
16713
+ return "2.0.3";
16714
+ }
16715
+ })());
16546
16716
  program2.command("init").description("Initialize a new Mnemosyne workspace").option("-d, --data-dir <path>", "Data directory", "./data").option("-c, --config <path>", "Config file path").action(initCommand);
16547
16717
  program2.command("start").description("Start the Mnemosyne server").option("-p, --port <number>", "Port to listen on", "7321").option("-h, --host <string>", "Host to bind to", "localhost").option("-d, --data-dir <path>", "Data directory", "./data").option("--mcp", "Enable MCP server", true).option("--mcp-transport <type>", "MCP transport: sse or stdio", "sse").option("--no-dashboard", "Disable dashboard serving").option("-c, --config <path>", "Config file path").option("-v, --verbose", "Enable verbose logging").action(startCommand);
16548
16718
  program2.command("migrate").description("Migrate from v1.0 JSON to v2.0 SQLite").requiredOption("--from <path>", "Path to v1.0 mnemosyne.db.json").requiredOption("--to <path>", "Path to v2.0 nexus.db").action(migrateCommand);