@xdarkicex/openclaw-memory-libravdb 1.8.8 → 1.8.9

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.
@@ -11,7 +11,7 @@ const DEFAULT_COMPACTION_THRESHOLD_FRACTION = 0.8;
11
11
  const STRUCTURED_MARKER_RE = /\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+){2,}_\d{6,}\b/g;
12
12
  const DISTINCTIVE_IDENTIFIER_RE = /\b([A-Za-z][A-Za-z0-9]*(?:[_-][A-Za-z0-9]+){1,})\b/g;
13
13
  const QUOTED_PHRASE_RE = /"([^"]{4,})"|'([^']{4,})'/g;
14
- const EXACT_RECALL_SEARCH_K = 32;
14
+ const EXACT_RECALL_SEARCH_K = 10;
15
15
  const EXACT_RECALL_MAX_TOKENS = 4;
16
16
  const RESERVED_CURRENT_TURN_TOKENS = 150;
17
17
  const AFTER_TURN_INGEST_MAX_TOKENS = 2048;
@@ -1265,6 +1265,13 @@ const SUBAGENT_BUDGET_MAX = 200;
1265
1265
  function subagentKey(sessionKey) {
1266
1266
  return sessionKey.trim();
1267
1267
  }
1268
+ function normalizeSubagentTokenBudget(value) {
1269
+ if (typeof value !== "number")
1270
+ return 8000;
1271
+ if (!Number.isFinite(value) || value < 0)
1272
+ return 8000;
1273
+ return Math.floor(value);
1274
+ }
1268
1275
  // consumeSubagentBudget deducts tokens from the subagent's budget.
1269
1276
  // Returns the granted budget, or -1 if no budget exists (not a subagent).
1270
1277
  export function consumeSubagentBudget(sessionKey, tokens) {
@@ -1283,7 +1290,14 @@ export function consumeSubagentBudget(sessionKey, tokens) {
1283
1290
  const budget = subagentBudgets.get(subagentKey(sessionKey));
1284
1291
  if (!budget)
1285
1292
  return -1; // not a subagent — no budget cap
1286
- const granted = Math.min(tokens, budget.remaining);
1293
+ const requested = Math.floor(tokens);
1294
+ if (!Number.isFinite(requested) || requested <= 0)
1295
+ return 0;
1296
+ if (!Number.isFinite(budget.remaining) || budget.remaining <= 0) {
1297
+ budget.remaining = 0;
1298
+ return 0;
1299
+ }
1300
+ const granted = Math.min(requested, budget.remaining);
1287
1301
  budget.remaining = Math.max(0, budget.remaining - granted);
1288
1302
  return granted;
1289
1303
  }
@@ -1639,8 +1653,9 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
1639
1653
  excludeByCollection: {},
1640
1654
  });
1641
1655
  const continuityHit = continuityHits.results?.find((r) => r.id === "__session_continuity__");
1642
- if (!continuityHit)
1643
- return null;
1656
+ if (!continuityHit) {
1657
+ return '<continuity_context>\nNo prior session context available. Use memory_search to recall previous conversations.\n</continuity_context>';
1658
+ }
1644
1659
  let meta = {};
1645
1660
  if (continuityHit.metadataJson && continuityHit.metadataJson.length > 0) {
1646
1661
  try {
@@ -1649,15 +1664,17 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
1649
1664
  catch { /* metadata parse failed, use empty */ }
1650
1665
  }
1651
1666
  const summaryId = meta.summary_id;
1652
- if (!summaryId)
1653
- return null;
1667
+ if (!summaryId) {
1668
+ const sid = meta.session_id ?? params.sessionId;
1669
+ return '<continuity_context>\nThe previous session (' + sid + ') was not compacted. Use memory_search with queries about what was discussed to recall context.\n</continuity_context>';
1670
+ }
1654
1671
  const expanded = await params.client.expandSummary({
1655
1672
  sessionId: meta.session_id ?? params.sessionId,
1656
1673
  summaryId,
1657
1674
  maxDepth: 2,
1658
1675
  });
1659
1676
  if (!expanded.text)
1660
- return null;
1677
+ return '<continuity_context>\nFailed to expand prior session summary. Use memory_search to recall previous conversations.\n</continuity_context>';
1661
1678
  return '<continuity_context>\nThe following is a summary of the previous session. Use it for context about what was discussed before the reset.\n' + expanded.text + '\n</continuity_context>';
1662
1679
  }
1663
1680
  catch {
@@ -2108,9 +2125,7 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
2108
2125
  // Grant the subagent a token budget for memory expansion.
2109
2126
  // Default 8000 tokens — enough for a focused expansion,
2110
2127
  // small enough to prevent context window destruction.
2111
- const budget = typeof cfg.subagentTokenBudget === "number"
2112
- ? cfg.subagentTokenBudget
2113
- : 8000;
2128
+ const budget = normalizeSubagentTokenBudget(cfg.subagentTokenBudget);
2114
2129
  const seconds = typeof params.ttlMs === "number" && params.ttlMs > 0
2115
2130
  ? Math.ceil(params.ttlMs / 1000)
2116
2131
  : 120;
package/dist/index.js CHANGED
@@ -26761,7 +26761,7 @@ var DEFAULT_COMPACTION_THRESHOLD_FRACTION = 0.8;
26761
26761
  var STRUCTURED_MARKER_RE = /\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+){2,}_\d{6,}\b/g;
26762
26762
  var DISTINCTIVE_IDENTIFIER_RE = /\b([A-Za-z][A-Za-z0-9]*(?:[_-][A-Za-z0-9]+){1,})\b/g;
26763
26763
  var QUOTED_PHRASE_RE = /"([^"]{4,})"|'([^']{4,})'/g;
26764
- var EXACT_RECALL_SEARCH_K = 32;
26764
+ var EXACT_RECALL_SEARCH_K = 10;
26765
26765
  var EXACT_RECALL_MAX_TOKENS = 4;
26766
26766
  var RESERVED_CURRENT_TURN_TOKENS = 150;
26767
26767
  var AFTER_TURN_INGEST_MAX_TOKENS = 2048;
@@ -27807,6 +27807,11 @@ var SUBAGENT_BUDGET_MAX = 200;
27807
27807
  function subagentKey(sessionKey) {
27808
27808
  return sessionKey.trim();
27809
27809
  }
27810
+ function normalizeSubagentTokenBudget(value) {
27811
+ if (typeof value !== "number") return 8e3;
27812
+ if (!Number.isFinite(value) || value < 0) return 8e3;
27813
+ return Math.floor(value);
27814
+ }
27810
27815
  function consumeSubagentBudget(sessionKey, tokens) {
27811
27816
  const now = Date.now();
27812
27817
  for (const [key, b] of subagentBudgets) {
@@ -27818,7 +27823,13 @@ function consumeSubagentBudget(sessionKey, tokens) {
27818
27823
  }
27819
27824
  const budget = subagentBudgets.get(subagentKey(sessionKey));
27820
27825
  if (!budget) return -1;
27821
- const granted = Math.min(tokens, budget.remaining);
27826
+ const requested = Math.floor(tokens);
27827
+ if (!Number.isFinite(requested) || requested <= 0) return 0;
27828
+ if (!Number.isFinite(budget.remaining) || budget.remaining <= 0) {
27829
+ budget.remaining = 0;
27830
+ return 0;
27831
+ }
27832
+ const granted = Math.min(requested, budget.remaining);
27822
27833
  budget.remaining = Math.max(0, budget.remaining - granted);
27823
27834
  return granted;
27824
27835
  }
@@ -28155,7 +28166,9 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
28155
28166
  const continuityHit = continuityHits.results?.find(
28156
28167
  (r) => r.id === "__session_continuity__"
28157
28168
  );
28158
- if (!continuityHit) return null;
28169
+ if (!continuityHit) {
28170
+ return "<continuity_context>\nNo prior session context available. Use memory_search to recall previous conversations.\n</continuity_context>";
28171
+ }
28159
28172
  let meta = {};
28160
28173
  if (continuityHit.metadataJson && continuityHit.metadataJson.length > 0) {
28161
28174
  try {
@@ -28164,13 +28177,16 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
28164
28177
  }
28165
28178
  }
28166
28179
  const summaryId = meta.summary_id;
28167
- if (!summaryId) return null;
28180
+ if (!summaryId) {
28181
+ const sid = meta.session_id ?? params.sessionId;
28182
+ return "<continuity_context>\nThe previous session (" + sid + ") was not compacted. Use memory_search with queries about what was discussed to recall context.\n</continuity_context>";
28183
+ }
28168
28184
  const expanded = await params.client.expandSummary({
28169
28185
  sessionId: meta.session_id ?? params.sessionId,
28170
28186
  summaryId,
28171
28187
  maxDepth: 2
28172
28188
  });
28173
- if (!expanded.text) return null;
28189
+ if (!expanded.text) return "<continuity_context>\nFailed to expand prior session summary. Use memory_search to recall previous conversations.\n</continuity_context>";
28174
28190
  return "<continuity_context>\nThe following is a summary of the previous session. Use it for context about what was discussed before the reset.\n" + expanded.text + "\n</continuity_context>";
28175
28191
  } catch {
28176
28192
  return null;
@@ -28621,7 +28637,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
28621
28637
  }
28622
28638
  },
28623
28639
  async prepareSubagentSpawn(params) {
28624
- const budget = typeof cfg.subagentTokenBudget === "number" ? cfg.subagentTokenBudget : 8e3;
28640
+ const budget = normalizeSubagentTokenBudget(cfg.subagentTokenBudget);
28625
28641
  const seconds = typeof params.ttlMs === "number" && params.ttlMs > 0 ? Math.ceil(params.ttlMs / 1e3) : 120;
28626
28642
  const key = subagentKey(params.childSessionKey);
28627
28643
  subagentBudgets.set(key, {
@@ -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.8.8",
5
+ "version": "1.8.9",
6
6
  "kind": [
7
7
  "memory",
8
8
  "context-engine"
@@ -12,7 +12,10 @@
12
12
  "contextEngine": true,
13
13
  "tools": [
14
14
  "memory_search",
15
- "memory_get"
15
+ "memory_get",
16
+ "memory_describe",
17
+ "memory_expand",
18
+ "memory_grep"
16
19
  ]
17
20
  },
18
21
  "activation": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xdarkicex/openclaw-memory-libravdb",
3
- "version": "1.8.8",
3
+ "version": "1.8.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",