@xdarkicex/openclaw-memory-libravdb 1.9.10-beta.13 → 1.9.10-beta.15

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.
@@ -1,4 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import { homedir } from "node:os";
3
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
+ import { join } from "node:path";
2
5
  import { resolveIdentity } from "./identity.js";
3
6
  import { resolveUserCollection } from "./memory-scopes.js";
4
7
  import { manifestStore } from "./manifest.js";
@@ -1392,9 +1395,9 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
1392
1395
  }
1393
1396
  function cleanPredictionText(text) {
1394
1397
  // Strip the [OpenClaw context: key=value; ...] routing prefix line.
1395
- const stripped = text.replace(OPENCLAW_CONTEXT_PREFIX_RE, "").trimStart();
1396
- // Then run the standard metadata envelope stripping.
1397
- return stripOpenClawUntrustedMetadataEnvelope(stripped);
1398
+ // Keep the timestamp/sender envelope — LLMs recognize it as conversation
1399
+ // history format and use it to understand message context.
1400
+ return text.replace(OPENCLAW_CONTEXT_PREFIX_RE, "").trimStart();
1398
1401
  }
1399
1402
  function formatRetrievedMemory(predictions) {
1400
1403
  if (!predictions?.length)
@@ -1603,10 +1606,34 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
1603
1606
  };
1604
1607
  }
1605
1608
  const continuityCache = new Map(); // sessionKey -> raw context block
1609
+ const continuityCachePath = (() => {
1610
+ const stateDir = process.env.OPENCLAW_STATE_DIR?.trim();
1611
+ const dir = stateDir || join(homedir(), '.openclaw');
1612
+ return join(dir, 'libravdb-continuity-cache.json');
1613
+ })();
1614
+ // Load persisted cache on startup.
1615
+ try {
1616
+ if (existsSync(continuityCachePath)) {
1617
+ const raw = JSON.parse(readFileSync(continuityCachePath, 'utf8'));
1618
+ for (const [k, v] of Object.entries(raw)) {
1619
+ if (typeof v === 'string')
1620
+ continuityCache.set(k, v);
1621
+ }
1622
+ }
1623
+ }
1624
+ catch { /* best-effort */ }
1625
+ function persistContinuityCache() {
1626
+ try {
1627
+ mkdirSync(join(continuityCachePath, '..'), { recursive: true });
1628
+ writeFileSync(continuityCachePath, JSON.stringify(Object.fromEntries(continuityCache)));
1629
+ }
1630
+ catch { /* best-effort */ }
1631
+ }
1606
1632
  function updateContinuityCache(sessionKey, messages) {
1607
1633
  const lastTurns = messages.filter(m => m.role === 'user' || m.role === 'assistant').slice(-2);
1608
1634
  if (lastTurns.length > 0) {
1609
1635
  continuityCache.set(sessionKey, lastTurns.map(m => `${m.role}: ${m.content}`).join('\n'));
1636
+ persistContinuityCache();
1610
1637
  }
1611
1638
  }
1612
1639
  async function injectContinuityContext(params) {
package/dist/index.js CHANGED
@@ -35278,6 +35278,9 @@ function resolveCliMemoryOperationScope(opts) {
35278
35278
 
35279
35279
  // src/context-engine.ts
35280
35280
  import { randomUUID } from "node:crypto";
35281
+ import { homedir as homedir2 } from "node:os";
35282
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
35283
+ import { join as join3 } from "node:path";
35281
35284
 
35282
35285
  // src/manifest.ts
35283
35286
  import * as fs2 from "fs";
@@ -36635,8 +36638,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
36635
36638
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
36636
36639
  }
36637
36640
  function cleanPredictionText(text) {
36638
- const stripped = text.replace(OPENCLAW_CONTEXT_PREFIX_RE, "").trimStart();
36639
- return stripOpenClawUntrustedMetadataEnvelope(stripped);
36641
+ return text.replace(OPENCLAW_CONTEXT_PREFIX_RE, "").trimStart();
36640
36642
  }
36641
36643
  function formatRetrievedMemory(predictions) {
36642
36644
  if (!predictions?.length) return "";
@@ -36838,10 +36840,32 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
36838
36840
  };
36839
36841
  }
36840
36842
  const continuityCache = /* @__PURE__ */ new Map();
36843
+ const continuityCachePath = (() => {
36844
+ const stateDir = process.env.OPENCLAW_STATE_DIR?.trim();
36845
+ const dir = stateDir || join3(homedir2(), ".openclaw");
36846
+ return join3(dir, "libravdb-continuity-cache.json");
36847
+ })();
36848
+ try {
36849
+ if (existsSync3(continuityCachePath)) {
36850
+ const raw = JSON.parse(readFileSync3(continuityCachePath, "utf8"));
36851
+ for (const [k, v] of Object.entries(raw)) {
36852
+ if (typeof v === "string") continuityCache.set(k, v);
36853
+ }
36854
+ }
36855
+ } catch {
36856
+ }
36857
+ function persistContinuityCache() {
36858
+ try {
36859
+ mkdirSync3(join3(continuityCachePath, ".."), { recursive: true });
36860
+ writeFileSync3(continuityCachePath, JSON.stringify(Object.fromEntries(continuityCache)));
36861
+ } catch {
36862
+ }
36863
+ }
36841
36864
  function updateContinuityCache(sessionKey, messages) {
36842
36865
  const lastTurns = messages.filter((m) => m.role === "user" || m.role === "assistant").slice(-2);
36843
36866
  if (lastTurns.length > 0) {
36844
36867
  continuityCache.set(sessionKey, lastTurns.map((m) => `${m.role}: ${m.content}`).join("\n"));
36868
+ persistContinuityCache();
36845
36869
  }
36846
36870
  }
36847
36871
  async function injectContinuityContext(params) {
@@ -48562,7 +48586,7 @@ function loadSecretFromEnv(logger) {
48562
48586
  }
48563
48587
 
48564
48588
  // src/plugin-runtime.ts
48565
- import { existsSync as existsSync3, statSync } from "node:fs";
48589
+ import { existsSync as existsSync4, statSync } from "node:fs";
48566
48590
  import path5 from "node:path";
48567
48591
  var DEFAULT_RPC_TIMEOUT_MS = 12e4;
48568
48592
  var ENV_RPC_TIMEOUT_MS = (() => {
@@ -48696,14 +48720,14 @@ function shouldValidateLocalEmbeddingPaths(cfg) {
48696
48720
  }
48697
48721
  function pathExistsAsFile(filePath) {
48698
48722
  try {
48699
- return existsSync3(filePath) && statSync(filePath).isFile();
48723
+ return existsSync4(filePath) && statSync(filePath).isFile();
48700
48724
  } catch {
48701
48725
  return false;
48702
48726
  }
48703
48727
  }
48704
48728
  function pathExistsAsDirectory(dirPath) {
48705
48729
  try {
48706
- return existsSync3(dirPath) && statSync(dirPath).isDirectory();
48730
+ return existsSync4(dirPath) && statSync(dirPath).isDirectory();
48707
48731
  } catch {
48708
48732
  return false;
48709
48733
  }
@@ -2,7 +2,7 @@
2
2
  "id": "libravdb-memory",
3
3
  "name": "LibraVDB Memory",
4
4
  "description": "Persistent vector memory with three-tier hybrid scoring",
5
- "version": "1.9.10-beta.13",
5
+ "version": "1.9.10-beta.15",
6
6
  "kind": [
7
7
  "memory",
8
8
  "context-engine"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xdarkicex/openclaw-memory-libravdb",
3
- "version": "1.9.10-beta.13",
3
+ "version": "1.9.10-beta.15",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",