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.
@@ -3736,9 +3736,26 @@ function loadConfig() {
3736
3736
  return defaultConfig();
3737
3737
  }
3738
3738
  }
3739
+ function getVersion2() {
3740
+ try {
3741
+ const { readFileSync: readFileSync5 } = __require("fs");
3742
+ const { resolve: resolve7 } = __require("path");
3743
+ const pkg = JSON.parse(readFileSync5(resolve7(__dirname, "../package.json"), "utf-8"));
3744
+ return pkg.version;
3745
+ } catch {
3746
+ try {
3747
+ const { readFileSync: readFileSync5 } = __require("fs");
3748
+ const { resolve: resolve7 } = __require("path");
3749
+ const pkg = JSON.parse(readFileSync5(resolve7(process.cwd(), "package.json"), "utf-8"));
3750
+ return pkg.version;
3751
+ } catch {
3752
+ return "2.0.3";
3753
+ }
3754
+ }
3755
+ }
3739
3756
  function defaultConfig() {
3740
3757
  return {
3741
- server: { port: 7321, host: "localhost", version: "2.0.0" },
3758
+ server: { port: 7321, host: "localhost", version: getVersion2() },
3742
3759
  database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
3743
3760
  storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
3744
3761
  limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
@@ -3761,11 +3778,20 @@ function mergeDeep(target, source) {
3761
3778
  }
3762
3779
  return output;
3763
3780
  }
3764
- var CONFIG;
3781
+ function getConfig() {
3782
+ if (!_config) _config = loadConfig();
3783
+ return _config;
3784
+ }
3785
+ var _config, CONFIG;
3765
3786
  var init_config = __esm({
3766
3787
  "src/config.ts"() {
3767
3788
  "use strict";
3768
- CONFIG = loadConfig();
3789
+ _config = null;
3790
+ CONFIG = new Proxy({}, {
3791
+ get(_, prop) {
3792
+ return getConfig()[prop];
3793
+ }
3794
+ });
3769
3795
  }
3770
3796
  });
3771
3797
 
@@ -3850,11 +3876,14 @@ var init_embedder = __esm({
3850
3876
  import { createHash } from "crypto";
3851
3877
  import { mkdirSync, existsSync as existsSync2, writeFileSync, readFileSync as readFileSync2 } from "fs";
3852
3878
  import { resolve as resolve2, dirname } from "path";
3879
+ function getFilesDir() {
3880
+ return resolve2(process.cwd(), CONFIG.storage.files_dir);
3881
+ }
3853
3882
  function ensureDir(path) {
3854
3883
  if (!existsSync2(path)) mkdirSync(path, { recursive: true });
3855
3884
  }
3856
3885
  function hashPath(hash) {
3857
- return resolve2(FILES_DIR, hash.slice(0, 2), hash.slice(2));
3886
+ return resolve2(getFilesDir(), hash.slice(0, 2), hash.slice(2));
3858
3887
  }
3859
3888
  function computeHash(buffer) {
3860
3889
  return createHash("sha256").update(buffer).digest("hex");
@@ -3875,12 +3904,10 @@ function getFile(hash) {
3875
3904
  return null;
3876
3905
  }
3877
3906
  }
3878
- var FILES_DIR;
3879
3907
  var init_files = __esm({
3880
3908
  "src/server/files.ts"() {
3881
3909
  "use strict";
3882
3910
  init_config();
3883
- FILES_DIR = resolve2(process.cwd(), CONFIG.storage.files_dir);
3884
3911
  }
3885
3912
  });
3886
3913
 
@@ -9832,6 +9859,23 @@ var TOOLS = [
9832
9859
  ];
9833
9860
 
9834
9861
  // src/mcp/server.ts
9862
+ function getVersion() {
9863
+ try {
9864
+ const { readFileSync: readFileSync5 } = __require("fs");
9865
+ const { resolve: resolve7 } = __require("path");
9866
+ const pkg = JSON.parse(readFileSync5(resolve7(__dirname, "../../package.json"), "utf-8"));
9867
+ return pkg.version;
9868
+ } catch {
9869
+ try {
9870
+ const { readFileSync: readFileSync5 } = __require("fs");
9871
+ const { resolve: resolve7 } = __require("path");
9872
+ const pkg = JSON.parse(readFileSync5(resolve7(process.cwd(), "package.json"), "utf-8"));
9873
+ return pkg.version;
9874
+ } catch {
9875
+ return "2.0.3";
9876
+ }
9877
+ }
9878
+ }
9835
9879
  var McpServer = class {
9836
9880
  store;
9837
9881
  toolMap = /* @__PURE__ */ new Map();
@@ -9852,7 +9896,7 @@ var McpServer = class {
9852
9896
  return this.ok(req.id, {
9853
9897
  protocolVersion: "2024-11-05",
9854
9898
  capabilities: { tools: {}, resources: {}, prompts: {} },
9855
- serverInfo: { name: "mnemosyne-mcp", version: "2.0.0" }
9899
+ serverInfo: { name: "mnemosyne-mcp", version: getVersion() }
9856
9900
  });
9857
9901
  case "tools/list":
9858
9902
  return this.ok(req.id, {
@@ -9879,7 +9923,7 @@ var McpServer = class {
9879
9923
  getManifest() {
9880
9924
  return {
9881
9925
  name: "Mnemosyne",
9882
- version: "2.0.0",
9926
+ version: getVersion(),
9883
9927
  description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
9884
9928
  protocol: "mcp",
9885
9929
  transport: ["stdio", "sse"],
@@ -10757,7 +10801,7 @@ import { createHash as createHash2 } from "crypto";
10757
10801
  import { readFileSync as readFileSync3, existsSync as existsSync3, readdirSync, statSync } from "fs";
10758
10802
  import { resolve as resolve3 } from "path";
10759
10803
  var DB_PATH = resolve3(process.cwd(), "data", "nexus.db");
10760
- var FILES_DIR2 = resolve3(process.cwd(), "data", "files");
10804
+ var FILES_DIR = resolve3(process.cwd(), "data", "files");
10761
10805
  function sha256File(path) {
10762
10806
  return createHash2("sha256").update(readFileSync3(path)).digest("hex");
10763
10807
  }
@@ -10777,11 +10821,11 @@ function sha256Dir(dir) {
10777
10821
  function buildMnemosyneExport(projectId, projectName) {
10778
10822
  const zip = new AdmZip();
10779
10823
  zip.addLocalFile(DB_PATH, "", "nexus.db");
10780
- if (existsSync3(FILES_DIR2)) {
10781
- zip.addLocalFolder(FILES_DIR2, "files");
10824
+ if (existsSync3(FILES_DIR)) {
10825
+ zip.addLocalFolder(FILES_DIR, "files");
10782
10826
  }
10783
10827
  const dbChecksum = sha256File(DB_PATH);
10784
- const filesChecksum = existsSync3(FILES_DIR2) ? sha256Dir(FILES_DIR2) : "";
10828
+ const filesChecksum = existsSync3(FILES_DIR) ? sha256Dir(FILES_DIR) : "";
10785
10829
  const manifest = {
10786
10830
  version: "1.1",
10787
10831
  app: "Mnemosyne",
@@ -10907,12 +10951,20 @@ function handleEvents(store, pathname, method, res, searchParams) {
10907
10951
  }
10908
10952
 
10909
10953
  // src/api/routes/health.ts
10954
+ var PKG_VERSION = (() => {
10955
+ try {
10956
+ const pkg = JSON.parse(__require("fs").readFileSync(__require("path").resolve(__dirname, "../../../package.json"), "utf-8"));
10957
+ return pkg.version;
10958
+ } catch {
10959
+ return "2.0.3";
10960
+ }
10961
+ })();
10910
10962
  function handleHealth(store, pathname, method, res) {
10911
- if (pathname === "/health" && method === "GET") {
10963
+ if ((pathname === "/health" || pathname === "/api/v1/health") && method === "GET") {
10912
10964
  const stats = store.getStats();
10913
10965
  json(res, 200, {
10914
10966
  status: "ok",
10915
- version: "2.0.0",
10967
+ version: PKG_VERSION,
10916
10968
  storage: "sqlite",
10917
10969
  database: store.config.database.path,
10918
10970
  uptime: process.uptime(),
@@ -12510,18 +12562,20 @@ CREATE TABLE IF NOT EXISTS atom_permissions (
12510
12562
  `;
12511
12563
 
12512
12564
  // src/db/connection.ts
12513
- var DB_PATH2 = process.env.MNEMOSYNE_DB_PATH || resolve5(process.cwd(), CONFIG.database.path);
12565
+ function getDbPath() {
12566
+ return process.env.MNEMOSYNE_DB_PATH || resolve5(process.cwd(), CONFIG.database.path);
12567
+ }
12514
12568
  var db = null;
12515
12569
  var vecEnabled = false;
12516
12570
  function getDb() {
12517
12571
  if (!db) {
12518
- db = new Database(DB_PATH2);
12572
+ db = new Database(getDbPath());
12519
12573
  db.pragma("journal_mode = WAL");
12520
12574
  db.pragma("foreign_keys = ON");
12521
12575
  db.pragma("synchronous = NORMAL");
12522
12576
  try {
12523
- const vecPath = resolve5(process.cwd(), CONFIG.database.vec_extension_path);
12524
- db.loadExtension(vecPath);
12577
+ const { getLoadablePath } = __require("sqlite-vec");
12578
+ db.loadExtension(getLoadablePath());
12525
12579
  vecEnabled = true;
12526
12580
  console.log("[DB] sqlite-vec extension loaded");
12527
12581
  } catch (err) {
@@ -12560,7 +12614,6 @@ var Store2 = class extends Store {
12560
12614
  };
12561
12615
 
12562
12616
  // src/server/MnemosyneServer.ts
12563
- init_config();
12564
12617
  var MnemosyneServer = class {
12565
12618
  store;
12566
12619
  api;
@@ -12568,8 +12621,9 @@ var MnemosyneServer = class {
12568
12621
  httpServer;
12569
12622
  brain;
12570
12623
  constructor(options = {}, brain) {
12571
- const port = options.port ?? CONFIG.server.port;
12572
- const host = options.host ?? CONFIG.server.host;
12624
+ const cfg = brain?.config?.config;
12625
+ const port = options.port ?? cfg?.server?.port ?? 7321;
12626
+ const host = options.host ?? cfg?.server?.host ?? "localhost";
12573
12627
  const enableDashboard = options.dashboard !== false;
12574
12628
  const enableWebsocket = options.websocket !== false;
12575
12629
  process.on("uncaughtException", (err) => {
@@ -12597,8 +12651,9 @@ var MnemosyneServer = class {
12597
12651
  const wss = new import_websocket_server.default({ server: this.httpServer });
12598
12652
  this.wsHandler = new WebSocketHandler(wss, this.store);
12599
12653
  }
12654
+ const version = cfg?.server?.version || "2.0.3";
12600
12655
  this.httpServer.listen(port, () => {
12601
- console.log(`Mnemosyne v${CONFIG.server.version} \u2014 port ${port}`);
12656
+ console.log(`Mnemosyne v${version} \u2014 port ${port}`);
12602
12657
  console.log(`Dashboard: http://${host}:${port}/dashboard`);
12603
12658
  console.log(`API: http://${host}:${port}/api/v1`);
12604
12659
  console.log(`MCP: http://${host}:${port}/mcp/manifest`);
@@ -12623,7 +12678,8 @@ var MnemosyneServer = class {
12623
12678
  };
12624
12679
  const dirs = [
12625
12680
  resolve6(process.cwd(), "src/dashboard"),
12626
- resolve6(process.cwd(), "dashboard")
12681
+ resolve6(process.cwd(), "dashboard"),
12682
+ resolve6(__dirname, "../dashboard")
12627
12683
  ];
12628
12684
  for (const dir of dirs) {
12629
12685
  const filePath = resolve6(dir, urlPath);