@icex-labs/openclaw-memory-engine 3.5.0 → 3.5.1

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.
Files changed (2) hide show
  1. package/index.js +31 -16
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -16,6 +16,7 @@
16
16
 
17
17
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
18
18
  import { existsSync } from "node:fs";
19
+ import { join } from "node:path";
19
20
 
20
21
  import { resolveWorkspace, getCoreSizeLimit, DEFAULT_TOP_K, MAX_TOP_K } from "./lib/paths.js";
21
22
  import { readCore, writeCore, dotGet, dotSet, autoParse } from "./lib/core.js";
@@ -95,25 +96,39 @@ export default definePluginEntry({
95
96
  // Factory ctx has: { sessionKey, workspaceDir, agentId, ... }
96
97
  // ═══════════════════════════════════════════════════════════════════
97
98
 
98
- // Background: auto-backfill missing embeddings on startup
99
- const defaultWs = resolveWorkspace(null);
100
- setTimeout(() => {
99
+ // Background: auto-backfill missing embeddings on startup (all workspaces)
100
+ setTimeout(async () => {
101
101
  try {
102
- const records = loadArchival(defaultWs);
103
- const cache = loadEmbeddingCache(defaultWs);
104
- const missing = records.filter((r) => r.id && !cache[r.id]).length;
105
- if (missing > 0) {
106
- console.error(`[memory-engine] Backfilling ${missing} missing embeddings...`);
107
- backfillEmbeddings(defaultWs, records, {
108
- onProgress: (done, total) => {
109
- if (done % 500 === 0) console.error(`[memory-engine] Embedding backfill: ${done}/${total}`);
110
- },
111
- }).then((result) => {
112
- console.error(`[memory-engine] Backfill complete: ${result.processed} embedded, ${result.errors} errors`);
113
- }).catch(() => {});
102
+ // Discover all unique workspaces from openclaw.json agent configs
103
+ const workspaces = new Set();
104
+ workspaces.add(resolveWorkspace(null)); // default
105
+ try {
106
+ const cfgPath = join(process.env.HOME || "/tmp", ".openclaw", "openclaw.json");
107
+ const cfg = JSON.parse(readFileSync(cfgPath, "utf-8"));
108
+ for (const agent of cfg?.agents?.list || []) {
109
+ if (agent.workspace) workspaces.add(agent.workspace);
110
+ }
111
+ } catch { /* ignore */ }
112
+
113
+ for (const wsDir of workspaces) {
114
+ try {
115
+ const records = loadArchival(wsDir);
116
+ if (records.length === 0) continue;
117
+ const cache = loadEmbeddingCache(wsDir);
118
+ const missing = records.filter((r) => r.id && !cache[r.id]).length;
119
+ if (missing > 0) {
120
+ console.error(`[memory-engine] Backfilling ${missing} embeddings in ${wsDir}...`);
121
+ const result = await backfillEmbeddings(wsDir, records, {
122
+ onProgress: (done, total) => {
123
+ if (done % 500 === 0) console.error(`[memory-engine] ${wsDir}: ${done}/${total}`);
124
+ },
125
+ });
126
+ console.error(`[memory-engine] ${wsDir}: done — ${result.processed} embedded, ${result.errors} errors`);
127
+ }
128
+ } catch { /* skip workspace errors */ }
114
129
  }
115
130
  } catch { /* ignore startup errors */ }
116
- }, 10000); // delay 10s after gateway start to avoid blocking
131
+ }, 10000); // delay 10s after gateway start
117
132
 
118
133
  // ─── core_memory_read ───
119
134
  api.registerTool(withAgent((agentId) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icex-labs/openclaw-memory-engine",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "MemGPT-style hierarchical memory plugin for OpenClaw — core memory block + archival storage with semantic search",
5
5
  "type": "module",
6
6
  "main": "index.js",