@xdarkicex/openclaw-memory-libravdb 1.10.14-beta.2 → 1.10.14-beta.3
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 +48 -6
- package/dist/index.js +34 -9
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/context-engine.js
CHANGED
|
@@ -120,7 +120,7 @@ function normalizeCompactResult(response, options = {}) {
|
|
|
120
120
|
: undefined;
|
|
121
121
|
return {
|
|
122
122
|
ok: !engineRefused,
|
|
123
|
-
compacted:
|
|
123
|
+
compacted: effectiveCompacted,
|
|
124
124
|
...(effectiveCompacted ? {} : { reason: engineRefused ? "overbudget_not_compacted" : "not_compacted" }),
|
|
125
125
|
result: {
|
|
126
126
|
tokensBefore,
|
|
@@ -820,12 +820,54 @@ function enforceCompactedProjectionBudgetInvariant(result, tokenBudget) {
|
|
|
820
820
|
}
|
|
821
821
|
function buildBudgetFallbackContext(messages, tokenBudget) {
|
|
822
822
|
const effectiveBudget = resolveEffectiveAssembleBudget(tokenBudget);
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
823
|
+
const sourceTokens = approximateMessagesTokens(messages);
|
|
824
|
+
if (sourceTokens <= effectiveBudget) {
|
|
825
|
+
return {
|
|
826
|
+
messages,
|
|
827
|
+
estimatedTokens: sourceTokens,
|
|
828
|
+
systemPromptAddition: "",
|
|
829
|
+
promptAuthority: PROMPT_AUTHORITY_PREASSEMBLY_MAY_OVERFLOW,
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
// This is a pressure-relief projection, not an attempt to replay the
|
|
833
|
+
// daemon's normalized messages. It retains exact OpenClaw source objects
|
|
834
|
+
// and keeps the newest user/tool bundle intact. Because it is strictly
|
|
835
|
+
// smaller than the preassembly transcript, OpenClaw must precheck this
|
|
836
|
+
// projection itself; otherwise it discards the trim and retries the full
|
|
837
|
+
// overflowing session forever when daemon compaction is temporarily unable
|
|
838
|
+
// to make semantic progress (for example a singleton source turn).
|
|
839
|
+
const projection = enforceCompactedProjectionBudgetInvariant({
|
|
840
|
+
messages,
|
|
841
|
+
estimatedTokens: sourceTokens,
|
|
827
842
|
systemPromptAddition: "",
|
|
828
|
-
promptAuthority:
|
|
843
|
+
promptAuthority: "assembled",
|
|
844
|
+
}, tokenBudget);
|
|
845
|
+
if (projection.estimatedTokens <= effectiveBudget) {
|
|
846
|
+
return projection;
|
|
847
|
+
}
|
|
848
|
+
// A single newest user message can itself exceed the entire safe prompt
|
|
849
|
+
// budget. There is no tool-protocol-safe suffix to select in that case, so
|
|
850
|
+
// preserve the latest replay-safe user request and truncate only its text.
|
|
851
|
+
// This is the terminal local safety valve; it is preferable to repeatedly
|
|
852
|
+
// re-sending the unbounded transcript and permanently wedging the session.
|
|
853
|
+
const latestUser = findLastReplaySafeUserMessage(messages);
|
|
854
|
+
if (latestUser) {
|
|
855
|
+
const content = truncateContentToTokenBudget(latestUser.content, Math.max(1, effectiveBudget - 8));
|
|
856
|
+
if (content) {
|
|
857
|
+
const truncatedUser = { ...latestUser, content };
|
|
858
|
+
return {
|
|
859
|
+
...projection,
|
|
860
|
+
messages: [truncatedUser],
|
|
861
|
+
estimatedTokens: Math.min(effectiveBudget, approximateMessageTokens(truncatedUser)),
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
// Non-conversational/system-only transcripts have no user turn to protect.
|
|
866
|
+
// Drop them rather than claiming an under-budget projection that is not one.
|
|
867
|
+
return {
|
|
868
|
+
...projection,
|
|
869
|
+
messages: [],
|
|
870
|
+
estimatedTokens: 0,
|
|
829
871
|
};
|
|
830
872
|
}
|
|
831
873
|
const DAEMON_AUTHORED_CONTEXT_RE = /<authored_context\b[^>]*>([\s\S]*?)<\/authored_context>/gi;
|
package/dist/index.js
CHANGED
|
@@ -18928,7 +18928,7 @@ function normalizeCompactResult(response, options = {}) {
|
|
|
18928
18928
|
const tokensAfter = didCompact && typeof response?.tokensAfter === "number" && response.tokensAfter >= 0 ? response.tokensAfter : void 0;
|
|
18929
18929
|
return {
|
|
18930
18930
|
ok: !engineRefused,
|
|
18931
|
-
compacted:
|
|
18931
|
+
compacted: effectiveCompacted,
|
|
18932
18932
|
...effectiveCompacted ? {} : { reason: engineRefused ? "overbudget_not_compacted" : "not_compacted" },
|
|
18933
18933
|
result: {
|
|
18934
18934
|
tokensBefore,
|
|
@@ -19483,15 +19483,40 @@ function enforceCompactedProjectionBudgetInvariant(result, tokenBudget) {
|
|
|
19483
19483
|
}
|
|
19484
19484
|
function buildBudgetFallbackContext(messages, tokenBudget) {
|
|
19485
19485
|
const effectiveBudget = resolveEffectiveAssembleBudget(tokenBudget);
|
|
19486
|
-
const
|
|
19487
|
-
|
|
19488
|
-
|
|
19489
|
-
|
|
19490
|
-
|
|
19491
|
-
|
|
19492
|
-
|
|
19486
|
+
const sourceTokens = approximateMessagesTokens(messages);
|
|
19487
|
+
if (sourceTokens <= effectiveBudget) {
|
|
19488
|
+
return {
|
|
19489
|
+
messages,
|
|
19490
|
+
estimatedTokens: sourceTokens,
|
|
19491
|
+
systemPromptAddition: "",
|
|
19492
|
+
promptAuthority: PROMPT_AUTHORITY_PREASSEMBLY_MAY_OVERFLOW
|
|
19493
|
+
};
|
|
19494
|
+
}
|
|
19495
|
+
const projection = enforceCompactedProjectionBudgetInvariant({
|
|
19496
|
+
messages,
|
|
19497
|
+
estimatedTokens: sourceTokens,
|
|
19493
19498
|
systemPromptAddition: "",
|
|
19494
|
-
promptAuthority:
|
|
19499
|
+
promptAuthority: "assembled"
|
|
19500
|
+
}, tokenBudget);
|
|
19501
|
+
if (projection.estimatedTokens <= effectiveBudget) {
|
|
19502
|
+
return projection;
|
|
19503
|
+
}
|
|
19504
|
+
const latestUser = findLastReplaySafeUserMessage(messages);
|
|
19505
|
+
if (latestUser) {
|
|
19506
|
+
const content = truncateContentToTokenBudget(latestUser.content, Math.max(1, effectiveBudget - 8));
|
|
19507
|
+
if (content) {
|
|
19508
|
+
const truncatedUser = { ...latestUser, content };
|
|
19509
|
+
return {
|
|
19510
|
+
...projection,
|
|
19511
|
+
messages: [truncatedUser],
|
|
19512
|
+
estimatedTokens: Math.min(effectiveBudget, approximateMessageTokens(truncatedUser))
|
|
19513
|
+
};
|
|
19514
|
+
}
|
|
19515
|
+
}
|
|
19516
|
+
return {
|
|
19517
|
+
...projection,
|
|
19518
|
+
messages: [],
|
|
19519
|
+
estimatedTokens: 0
|
|
19495
19520
|
};
|
|
19496
19521
|
}
|
|
19497
19522
|
var DAEMON_AUTHORED_CONTEXT_RE = /<authored_context\b[^>]*>([\s\S]*?)<\/authored_context>/gi;
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "libravdb-memory",
|
|
3
3
|
"name": "LibraVDB Memory",
|
|
4
4
|
"description": "Cognitive memory engine — causal graph reasoning, predictive context, identity tracking, and hybrid vector recall with back-door adjustment scoring",
|
|
5
|
-
"version": "1.10.14-beta.
|
|
5
|
+
"version": "1.10.14-beta.3",
|
|
6
6
|
"kind": [
|
|
7
7
|
"memory",
|
|
8
8
|
"context-engine"
|