@xdarkicex/openclaw-memory-libravdb 1.6.18 → 1.6.19

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/README.md CHANGED
@@ -49,6 +49,9 @@ brew services start libravdbd
49
49
  **Linux (APT)**
50
50
 
51
51
  ```bash
52
+ curl -fsSL https://xDarkicex.github.io/apt-libravdbd/gpg.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/libravdbd.gpg
53
+ echo "deb https://xDarkicex.github.io/apt-libravdbd stable main" | sudo tee /etc/apt/sources.list.d/libravdbd.list
54
+ sudo apt update
52
55
  sudo apt install libravdbd
53
56
  systemctl --user enable --now libravdbd
54
57
  ```
@@ -90,6 +90,9 @@ export declare function buildContextEngineFactory(runtime: PluginRuntime, cfg: P
90
90
  targetSize?: number;
91
91
  tokenBudget?: number;
92
92
  currentTokenCount?: number;
93
+ compactionTarget?: "budget" | "threshold";
94
+ runtimeContext?: Record<string, unknown>;
95
+ abortSignal?: AbortSignal;
93
96
  }): Promise<OpenClawCompatibleCompactResult>;
94
97
  afterTurn(args: {
95
98
  sessionId: string;
@@ -173,6 +173,13 @@ function resolvePredictiveCompactionTarget(params) {
173
173
  ? belowThresholdTarget
174
174
  : Math.max(1, currentTokenCount - 1);
175
175
  }
176
+ function readRuntimeNumber(runtimeContext, key) {
177
+ const value = runtimeContext?.[key];
178
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
179
+ }
180
+ function isManualCompactionRequested(runtimeContext) {
181
+ return runtimeContext?.manualCompaction === true;
182
+ }
176
183
  function logPredictiveCompactionAttempt(params) {
177
184
  params.logger.info?.(`LibraVDB predictive compaction trigger phase=${params.phase} sessionId=${params.sessionId} ` +
178
185
  `currentTokenCount=${params.currentTokenCount} threshold=${params.threshold} ` +
@@ -915,7 +922,39 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
915
922
  }
916
923
  },
917
924
  async compact(args) {
918
- return await runCompaction(args);
925
+ const tokenBudget = normalizeTokenBudget(args.tokenBudget) ??
926
+ normalizeTokenBudget(readRuntimeNumber(args.runtimeContext, "tokenBudget"));
927
+ const currentTokenCount = normalizeCurrentTokenCount(args.currentTokenCount) ??
928
+ normalizeCurrentTokenCount(readRuntimeNumber(args.runtimeContext, "currentTokenCount"));
929
+ const forceCompaction = args.force === true || isManualCompactionRequested(args.runtimeContext);
930
+ const threshold = getDynamicCompactThreshold(tokenBudget);
931
+ if (!forceCompaction &&
932
+ currentTokenCount != null &&
933
+ threshold != null &&
934
+ currentTokenCount < threshold) {
935
+ return {
936
+ ok: true,
937
+ compacted: false,
938
+ reason: "below threshold",
939
+ result: {
940
+ tokensBefore: currentTokenCount,
941
+ details: {
942
+ threshold,
943
+ targetTokens: args.compactionTarget === "threshold" ? threshold : tokenBudget,
944
+ },
945
+ },
946
+ };
947
+ }
948
+ const runArgs = {
949
+ ...args,
950
+ force: forceCompaction || args.force,
951
+ ...(tokenBudget != null ? { tokenBudget } : {}),
952
+ ...(currentTokenCount != null ? { currentTokenCount } : {}),
953
+ ...(args.compactionTarget === "threshold" && threshold != null
954
+ ? { targetSize: threshold }
955
+ : {}),
956
+ };
957
+ return await runCompaction(runArgs);
919
958
  },
920
959
  async afterTurn(args) {
921
960
  const sessionId = requireSessionId(args.sessionId, "afterTurn");
package/dist/index.js CHANGED
@@ -26702,6 +26702,13 @@ function resolvePredictiveCompactionTarget(params) {
26702
26702
  const belowThresholdTarget = Math.max(1, threshold - 1);
26703
26703
  return belowThresholdTarget < currentTokenCount ? belowThresholdTarget : Math.max(1, currentTokenCount - 1);
26704
26704
  }
26705
+ function readRuntimeNumber(runtimeContext, key) {
26706
+ const value = runtimeContext?.[key];
26707
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
26708
+ }
26709
+ function isManualCompactionRequested(runtimeContext) {
26710
+ return runtimeContext?.manualCompaction === true;
26711
+ }
26705
26712
  function logPredictiveCompactionAttempt(params) {
26706
26713
  params.logger.info?.(
26707
26714
  `LibraVDB predictive compaction trigger phase=${params.phase} sessionId=${params.sessionId} currentTokenCount=${params.currentTokenCount} threshold=${params.threshold} targetSize=${params.targetSize} tokenBudget=${params.tokenBudget ?? "unknown"}`
@@ -27431,7 +27438,32 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
27431
27438
  }
27432
27439
  },
27433
27440
  async compact(args) {
27434
- return await runCompaction(args);
27441
+ const tokenBudget = normalizeTokenBudget(args.tokenBudget) ?? normalizeTokenBudget(readRuntimeNumber(args.runtimeContext, "tokenBudget"));
27442
+ const currentTokenCount = normalizeCurrentTokenCount(args.currentTokenCount) ?? normalizeCurrentTokenCount(readRuntimeNumber(args.runtimeContext, "currentTokenCount"));
27443
+ const forceCompaction = args.force === true || isManualCompactionRequested(args.runtimeContext);
27444
+ const threshold = getDynamicCompactThreshold(tokenBudget);
27445
+ if (!forceCompaction && currentTokenCount != null && threshold != null && currentTokenCount < threshold) {
27446
+ return {
27447
+ ok: true,
27448
+ compacted: false,
27449
+ reason: "below threshold",
27450
+ result: {
27451
+ tokensBefore: currentTokenCount,
27452
+ details: {
27453
+ threshold,
27454
+ targetTokens: args.compactionTarget === "threshold" ? threshold : tokenBudget
27455
+ }
27456
+ }
27457
+ };
27458
+ }
27459
+ const runArgs = {
27460
+ ...args,
27461
+ force: forceCompaction || args.force,
27462
+ ...tokenBudget != null ? { tokenBudget } : {},
27463
+ ...currentTokenCount != null ? { currentTokenCount } : {},
27464
+ ...args.compactionTarget === "threshold" && threshold != null ? { targetSize: threshold } : {}
27465
+ };
27466
+ return await runCompaction(runArgs);
27435
27467
  },
27436
27468
  async afterTurn(args) {
27437
27469
  const sessionId = requireSessionId(args.sessionId, "afterTurn");
@@ -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.6.18",
5
+ "version": "1.6.19",
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.6.18",
3
+ "version": "1.6.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",