@xdarkicex/openclaw-memory-libravdb 1.4.69 → 1.4.71

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.
@@ -398,6 +398,7 @@ export function normalizeAssembleResult(result) {
398
398
  };
399
399
  }
400
400
  export function buildContextEngineFactory(runtime, cfg, logger = console) {
401
+ const predictiveContextCache = new Map();
401
402
  let cachedIdentity = null;
402
403
  let cachedSessionKey;
403
404
  function resolveUserId(args) {
@@ -775,12 +776,19 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
775
776
  config: buildAssemblyConfig(args.tokenBudget),
776
777
  });
777
778
  const assembled = normalizeAssembleResult(resp);
778
- return enforceTokenBudgetInvariant(await augmentWithExactRecall(assembled, {
779
+ const enforced = enforceTokenBudgetInvariant(await augmentWithExactRecall(assembled, {
779
780
  queryText: args.prompt ?? messages[messages.length - 1]?.content ?? "",
780
781
  userId,
781
782
  sessionId,
782
783
  tokenBudget: args.tokenBudget,
783
784
  }), args.tokenBudget);
785
+ const predictions = predictiveContextCache.get(sessionId) || [];
786
+ predictiveContextCache.delete(sessionId);
787
+ if (predictions.length > 0) {
788
+ const injection = ["<predictive_context>", ...predictions.map((p) => p.text), "</predictive_context>"].join("\n");
789
+ enforced.systemPromptAddition = appendSystemPromptAddition(enforced.systemPromptAddition, injection);
790
+ }
791
+ return enforced;
784
792
  }
785
793
  catch (error) {
786
794
  logger.warn?.(`LibraVDB assemble sidecar failed, using budget-clamped fallback context: ${error instanceof Error ? error.message : String(error)}`);
@@ -822,6 +830,10 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
822
830
  tokenBudget: args.tokenBudget,
823
831
  currentTokenCount,
824
832
  });
833
+ const predictions = result.predictions;
834
+ if (Array.isArray(predictions) && predictions.length > 0) {
835
+ predictiveContextCache.set(sessionId, predictions);
836
+ }
825
837
  return result;
826
838
  }
827
839
  const rpc = await runtime.getRpc();
@@ -838,6 +850,10 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
838
850
  tokenBudget: args.tokenBudget,
839
851
  currentTokenCount,
840
852
  });
853
+ const predictions = result.predictions;
854
+ if (Array.isArray(predictions) && predictions.length > 0) {
855
+ predictiveContextCache.set(sessionId, predictions);
856
+ }
841
857
  return result;
842
858
  }
843
859
  catch (error) {
@@ -36,8 +36,12 @@ export class GrpcKernelClient {
36
36
  if (!this.nonceHex) {
37
37
  throw new Error("call initializeSession before authenticated RPCs");
38
38
  }
39
- const hmac = createHmac("sha256", Buffer.from(this.nonceHex, "hex"));
40
- hmac.update(this.secret);
39
+ // Challenge-response: HMAC(secret, nonce) — the secret is the HMAC key,
40
+ // the server-issued nonce is the message. The previous implementation
41
+ // swapped these, computing HMAC(nonce, secret), which is cryptographically
42
+ // incorrect: the nonce is sent in the clear and must not be used as the key.
43
+ const hmac = createHmac("sha256", this.secret);
44
+ hmac.update(this.nonceHex);
41
45
  const signature = hmac.digest("hex");
42
46
  md.add("x-libravdb-auth", signature);
43
47
  }
package/dist/index.js CHANGED
@@ -34034,6 +34034,7 @@ function normalizeAssembleResult(result) {
34034
34034
  };
34035
34035
  }
34036
34036
  function buildContextEngineFactory(runtime, cfg, logger = console) {
34037
+ const predictiveContextCache = /* @__PURE__ */ new Map();
34037
34038
  let cachedIdentity = null;
34038
34039
  let cachedSessionKey;
34039
34040
  function resolveUserId(args) {
@@ -34399,7 +34400,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
34399
34400
  config: buildAssemblyConfig(args.tokenBudget)
34400
34401
  });
34401
34402
  const assembled = normalizeAssembleResult(resp);
34402
- return enforceTokenBudgetInvariant(
34403
+ const enforced = enforceTokenBudgetInvariant(
34403
34404
  await augmentWithExactRecall(assembled, {
34404
34405
  queryText: args.prompt ?? messages[messages.length - 1]?.content ?? "",
34405
34406
  userId,
@@ -34408,6 +34409,13 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
34408
34409
  }),
34409
34410
  args.tokenBudget
34410
34411
  );
34412
+ const predictions = predictiveContextCache.get(sessionId) || [];
34413
+ predictiveContextCache.delete(sessionId);
34414
+ if (predictions.length > 0) {
34415
+ const injection = ["<predictive_context>", ...predictions.map((p) => p.text), "</predictive_context>"].join("\n");
34416
+ enforced.systemPromptAddition = appendSystemPromptAddition(enforced.systemPromptAddition, injection);
34417
+ }
34418
+ return enforced;
34411
34419
  } catch (error) {
34412
34420
  logger.warn?.(
34413
34421
  `LibraVDB assemble sidecar failed, using budget-clamped fallback context: ${error instanceof Error ? error.message : String(error)}`
@@ -34449,6 +34457,10 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
34449
34457
  tokenBudget: args.tokenBudget,
34450
34458
  currentTokenCount
34451
34459
  });
34460
+ const predictions2 = result2.predictions;
34461
+ if (Array.isArray(predictions2) && predictions2.length > 0) {
34462
+ predictiveContextCache.set(sessionId, predictions2);
34463
+ }
34452
34464
  return result2;
34453
34465
  }
34454
34466
  const rpc = await runtime.getRpc();
@@ -34465,6 +34477,10 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
34465
34477
  tokenBudget: args.tokenBudget,
34466
34478
  currentTokenCount
34467
34479
  });
34480
+ const predictions = result.predictions;
34481
+ if (Array.isArray(predictions) && predictions.length > 0) {
34482
+ predictiveContextCache.set(sessionId, predictions);
34483
+ }
34468
34484
  return result;
34469
34485
  } catch (error) {
34470
34486
  logger.warn?.(
@@ -39541,8 +39557,8 @@ var GrpcKernelClient = class {
39541
39557
  if (!this.nonceHex) {
39542
39558
  throw new Error("call initializeSession before authenticated RPCs");
39543
39559
  }
39544
- const hmac = createHmac("sha256", Buffer.from(this.nonceHex, "hex"));
39545
- hmac.update(this.secret);
39560
+ const hmac = createHmac("sha256", this.secret);
39561
+ hmac.update(this.nonceHex);
39546
39562
  const signature = hmac.digest("hex");
39547
39563
  md.add("x-libravdb-auth", signature);
39548
39564
  }
package/dist/types.d.ts CHANGED
@@ -155,3 +155,8 @@ export interface SidecarHandle {
155
155
  export interface RpcCallOptions {
156
156
  timeoutMs: number;
157
157
  }
158
+ export interface PredictedContext {
159
+ id: string;
160
+ text: string;
161
+ reason: string;
162
+ }
@@ -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.4.69",
5
+ "version": "1.4.71",
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.4.69",
3
+ "version": "1.4.71",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -64,9 +64,6 @@
64
64
  "prepack": "npm run build",
65
65
  "build:daemon": "bash scripts/build-daemon.sh"
66
66
  },
67
- "dependencies": {
68
- "openclaw": "*"
69
- },
70
67
  "devDependencies": {
71
68
  "@bufbuild/protobuf": "1.7.2",
72
69
  "@grpc/grpc-js": "^1.14.3",
@@ -75,6 +72,7 @@
75
72
  "@types/node": "^20.11.0",
76
73
  "@xdarkicex/libravdb-contracts": "^0.0.6",
77
74
  "esbuild": "^0.27.0",
75
+ "openclaw": "2026.4.11",
78
76
  "typescript": "^6.0.3"
79
77
  },
80
78
  "peerDependencies": {