@psiclawops/hypermem-memory 0.9.0 → 0.9.2

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/index.js CHANGED
@@ -21,8 +21,12 @@ import fs from 'fs/promises';
21
21
  import os from 'os';
22
22
  import { fileURLToPath } from 'url';
23
23
  // ─── HyperMem singleton ────────────────────────────────────────
24
- // Reuses the same singleton pattern as the context engine plugin.
25
- // Both plugins load from the same installed runtime payload and share the instance.
24
+ // HyperMem.create() in the core package now dedupes per absolute dataDir, so
25
+ // whichever of the two plugins (context-engine, memory) calls create() first
26
+ // owns the instance. To avoid a race where this plugin would otherwise win
27
+ // boot with no embedding config and force defaults onto the shared instance,
28
+ // we load the same user config file the context-engine plugin loads and pass
29
+ // the full embedding/reranker config through to create().
26
30
  const __pluginDir = path.dirname(fileURLToPath(import.meta.url));
27
31
  async function resolveHyperMemPath() {
28
32
  try {
@@ -33,6 +37,19 @@ async function resolveHyperMemPath() {
33
37
  return path.resolve(__pluginDir, '../../dist/index.js');
34
38
  }
35
39
  }
40
+ async function loadFileConfig(dataDir) {
41
+ const configPath = path.join(dataDir, 'config.json');
42
+ try {
43
+ const raw = await fs.readFile(configPath, 'utf-8');
44
+ return JSON.parse(raw);
45
+ }
46
+ catch (err) {
47
+ if (err.code !== 'ENOENT') {
48
+ console.warn(`[hypermem-memory] Failed to parse config.json (using defaults):`, err.message);
49
+ }
50
+ return {};
51
+ }
52
+ }
36
53
  let _hm = null;
37
54
  let _hmInitPromise = null;
38
55
  async function getHyperMem() {
@@ -44,14 +61,25 @@ async function getHyperMem() {
44
61
  const hypermemPath = await resolveHyperMemPath();
45
62
  const mod = await import(hypermemPath);
46
63
  const HyperMem = mod.HyperMem;
47
- const instance = await HyperMem.create({
48
- dataDir: path.join(os.homedir(), '.openclaw/hypermem'),
64
+ const dataDir = path.join(os.homedir(), '.openclaw/hypermem');
65
+ const fileConfig = await loadFileConfig(dataDir);
66
+ const createConfig = {
67
+ dataDir,
49
68
  cache: {
50
69
  keyPrefix: 'hm:',
51
70
  sessionTTL: 14400,
52
71
  historyTTL: 86400,
53
72
  },
54
- });
73
+ };
74
+ // Forward embedding + reranker so this plugin's create() call produces
75
+ // an equivalent instance to the context-engine plugin's. Other config
76
+ // sections (compositor, indexer, dreaming, etc.) are owned by the
77
+ // context-engine plugin and only matter when it wins the singleton race.
78
+ if (fileConfig.embedding)
79
+ createConfig.embedding = fileConfig.embedding;
80
+ if (fileConfig.reranker)
81
+ createConfig.reranker = fileConfig.reranker;
82
+ const instance = await HyperMem.create(createConfig);
55
83
  _hm = instance;
56
84
  return instance;
57
85
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psiclawops/hypermem-memory",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "HyperMem memory plugin for OpenClaw — bridges HyperMem retrieval into the memory slot",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,10 +35,12 @@
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc",
38
+ "prepublishOnly": "npm run build",
39
+ "prepack": "npm run build",
38
40
  "typecheck": "tsc --noEmit"
39
41
  },
40
42
  "dependencies": {
41
- "@psiclawops/hypermem": "0.9.0"
43
+ "@psiclawops/hypermem": "0.9.2"
42
44
  },
43
45
  "devDependencies": {
44
46
  "openclaw": "*",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;;;;;;;;AA0VH,wBAmBG"}