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

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.
@@ -1392,9 +1392,9 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
1392
1392
  }
1393
1393
  function cleanPredictionText(text) {
1394
1394
  // 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);
1395
+ // Keep the timestamp/sender envelope — LLMs recognize it as conversation
1396
+ // history format and use it to understand message context.
1397
+ return text.replace(OPENCLAW_CONTEXT_PREFIX_RE, "").trimStart();
1398
1398
  }
1399
1399
  function formatRetrievedMemory(predictions) {
1400
1400
  if (!predictions?.length)
@@ -1602,8 +1602,19 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
1602
1602
  : {}),
1603
1603
  };
1604
1604
  }
1605
+ const continuityCache = new Map(); // sessionKey -> raw context block
1606
+ function updateContinuityCache(sessionKey, messages) {
1607
+ const lastTurns = messages.filter(m => m.role === 'user' || m.role === 'assistant').slice(-2);
1608
+ if (lastTurns.length > 0) {
1609
+ continuityCache.set(sessionKey, lastTurns.map(m => `${m.role}: ${m.content}`).join('\n'));
1610
+ }
1611
+ }
1605
1612
  async function injectContinuityContext(params) {
1606
1613
  try {
1614
+ const cached = continuityCache.get(params.sessionKey);
1615
+ if (cached) {
1616
+ return `<continuity_context>\nRecent conversation:\n${cached}\n</continuity_context>`;
1617
+ }
1607
1618
  // Use a natural-language query that semantically matches the
1608
1619
  // pointer record text ("Previous session continuity — ...").
1609
1620
  // Fetch enough results so the exact ID match isn't crowded out
@@ -1941,6 +1952,7 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
1941
1952
  client,
1942
1953
  userId,
1943
1954
  sessionId,
1955
+ sessionKey: args.sessionKey ?? sessionId,
1944
1956
  logger,
1945
1957
  tokenBudget: args.tokenBudget,
1946
1958
  systemPromptAddition: assembled.systemPromptAddition,
@@ -2102,6 +2114,7 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
2102
2114
  isHeartbeat: args.isHeartbeat,
2103
2115
  cursor,
2104
2116
  });
2117
+ updateContinuityCache(args.sessionKey ?? sessionId, ingestMessages);
2105
2118
  // Reconcile manifest with daemon-confirmed cursor.
2106
2119
  // The daemon returns a cursor even when it ingests zero messages
2107
2120
  // (e.g. gap detected, all messages deduped). Trust its
package/dist/index.js CHANGED
@@ -36635,8 +36635,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
36635
36635
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
36636
36636
  }
36637
36637
  function cleanPredictionText(text) {
36638
- const stripped = text.replace(OPENCLAW_CONTEXT_PREFIX_RE, "").trimStart();
36639
- return stripOpenClawUntrustedMetadataEnvelope(stripped);
36638
+ return text.replace(OPENCLAW_CONTEXT_PREFIX_RE, "").trimStart();
36640
36639
  }
36641
36640
  function formatRetrievedMemory(predictions) {
36642
36641
  if (!predictions?.length) return "";
@@ -36837,8 +36836,22 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
36837
36836
  ...typeof cfg.continuityPriorContextTokens === "number" ? { continuityPriorContextTokens: cfg.continuityPriorContextTokens } : {}
36838
36837
  };
36839
36838
  }
36839
+ const continuityCache = /* @__PURE__ */ new Map();
36840
+ function updateContinuityCache(sessionKey, messages) {
36841
+ const lastTurns = messages.filter((m) => m.role === "user" || m.role === "assistant").slice(-2);
36842
+ if (lastTurns.length > 0) {
36843
+ continuityCache.set(sessionKey, lastTurns.map((m) => `${m.role}: ${m.content}`).join("\n"));
36844
+ }
36845
+ }
36840
36846
  async function injectContinuityContext(params) {
36841
36847
  try {
36848
+ const cached = continuityCache.get(params.sessionKey);
36849
+ if (cached) {
36850
+ return `<continuity_context>
36851
+ Recent conversation:
36852
+ ${cached}
36853
+ </continuity_context>`;
36854
+ }
36842
36855
  const continuityHits = await params.client.searchTextCollections({
36843
36856
  collections: [resolveUserCollection(params.userId)],
36844
36857
  text: "previous session context continuity",
@@ -37162,6 +37175,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
37162
37175
  client,
37163
37176
  userId,
37164
37177
  sessionId,
37178
+ sessionKey: args.sessionKey ?? sessionId,
37165
37179
  logger,
37166
37180
  tokenBudget: args.tokenBudget,
37167
37181
  systemPromptAddition: assembled.systemPromptAddition
@@ -37321,6 +37335,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
37321
37335
  isHeartbeat: args.isHeartbeat,
37322
37336
  cursor
37323
37337
  });
37338
+ updateContinuityCache(args.sessionKey ?? sessionId, ingestMessages);
37324
37339
  const daemonCursor = extractCursorFromResult(result);
37325
37340
  if (daemonCursor) {
37326
37341
  if (!daemonCursor.manifestTailHash) {
@@ -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.12",
5
+ "version": "1.9.10-beta.14",
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.12",
3
+ "version": "1.9.10-beta.14",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",