@xdarkicex/openclaw-memory-libravdb 1.4.69 → 1.4.70
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/dist/context-engine.js +17 -1
- package/dist/grpc-client.js +6 -2
- package/dist/index.js +19 -3
- package/dist/types.d.ts +5 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/context-engine.js
CHANGED
|
@@ -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
|
-
|
|
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) {
|
package/dist/grpc-client.js
CHANGED
|
@@ -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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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",
|
|
39545
|
-
hmac.update(this.
|
|
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
package/openclaw.plugin.json
CHANGED