@xdarkicex/openclaw-memory-libravdb 1.9.10-beta.14 → 1.9.10-beta.16

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";
@@ -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) {
@@ -1957,7 +1984,10 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
1957
1984
  tokenBudget: args.tokenBudget,
1958
1985
  systemPromptAddition: assembled.systemPromptAddition,
1959
1986
  });
1960
- const withContinuity = continuityContext
1987
+ // Only inject continuity on session bootstrap (fresh /new).
1988
+ // After the first turn, predictive context handles it.
1989
+ const isSessionBootstrap = messages.length <= 1;
1990
+ const withContinuity = (isSessionBootstrap && continuityContext)
1961
1991
  ? { ...assembled, systemPromptAddition: appendSystemPromptAddition(assembled.systemPromptAddition, continuityContext) }
1962
1992
  : assembled;
1963
1993
  enforced = enforceTokenBudgetInvariant(await augmentWithExactRecall(withContinuity, {
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";
@@ -36837,10 +36840,32 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
36837
36840
  };
36838
36841
  }
36839
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
+ }
36840
36864
  function updateContinuityCache(sessionKey, messages) {
36841
36865
  const lastTurns = messages.filter((m) => m.role === "user" || m.role === "assistant").slice(-2);
36842
36866
  if (lastTurns.length > 0) {
36843
36867
  continuityCache.set(sessionKey, lastTurns.map((m) => `${m.role}: ${m.content}`).join("\n"));
36868
+ persistContinuityCache();
36844
36869
  }
36845
36870
  }
36846
36871
  async function injectContinuityContext(params) {
@@ -37180,7 +37205,8 @@ ${cached}
37180
37205
  tokenBudget: args.tokenBudget,
37181
37206
  systemPromptAddition: assembled.systemPromptAddition
37182
37207
  });
37183
- const withContinuity = continuityContext ? { ...assembled, systemPromptAddition: appendSystemPromptAddition(assembled.systemPromptAddition, continuityContext) } : assembled;
37208
+ const isSessionBootstrap = messages.length <= 1;
37209
+ const withContinuity = isSessionBootstrap && continuityContext ? { ...assembled, systemPromptAddition: appendSystemPromptAddition(assembled.systemPromptAddition, continuityContext) } : assembled;
37184
37210
  enforced = enforceTokenBudgetInvariant(
37185
37211
  await augmentWithExactRecall(withContinuity, {
37186
37212
  queryText: retrievalQuery,
@@ -48561,7 +48587,7 @@ function loadSecretFromEnv(logger) {
48561
48587
  }
48562
48588
 
48563
48589
  // src/plugin-runtime.ts
48564
- import { existsSync as existsSync3, statSync } from "node:fs";
48590
+ import { existsSync as existsSync4, statSync } from "node:fs";
48565
48591
  import path5 from "node:path";
48566
48592
  var DEFAULT_RPC_TIMEOUT_MS = 12e4;
48567
48593
  var ENV_RPC_TIMEOUT_MS = (() => {
@@ -48695,14 +48721,14 @@ function shouldValidateLocalEmbeddingPaths(cfg) {
48695
48721
  }
48696
48722
  function pathExistsAsFile(filePath) {
48697
48723
  try {
48698
- return existsSync3(filePath) && statSync(filePath).isFile();
48724
+ return existsSync4(filePath) && statSync(filePath).isFile();
48699
48725
  } catch {
48700
48726
  return false;
48701
48727
  }
48702
48728
  }
48703
48729
  function pathExistsAsDirectory(dirPath) {
48704
48730
  try {
48705
- return existsSync3(dirPath) && statSync(dirPath).isDirectory();
48731
+ return existsSync4(dirPath) && statSync(dirPath).isDirectory();
48706
48732
  } catch {
48707
48733
  return false;
48708
48734
  }
@@ -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.14",
5
+ "version": "1.9.10-beta.16",
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.14",
3
+ "version": "1.9.10-beta.16",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",