@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.
- package/index.js +31 -16
- 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
|
-
|
|
100
|
-
setTimeout(() => {
|
|
99
|
+
// Background: auto-backfill missing embeddings on startup (all workspaces)
|
|
100
|
+
setTimeout(async () => {
|
|
101
101
|
try {
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
|
131
|
+
}, 10000); // delay 10s after gateway start
|
|
117
132
|
|
|
118
133
|
// ─── core_memory_read ───
|
|
119
134
|
api.registerTool(withAgent((agentId) => ({
|
package/package.json
CHANGED