@xdarkicex/openclaw-memory-libravdb 1.9.10-beta.15 → 1.9.10-beta.17
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 +36 -6
- package/dist/index.js +22445 -36205
- package/dist/libravdb-client.d.ts +3 -1
- package/dist/libravdb-client.js +9 -0
- package/dist/tools/memory-recall.d.ts +48 -0
- package/dist/tools/memory-recall.js +89 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -8
package/dist/context-engine.js
CHANGED
|
@@ -1681,6 +1681,26 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
1681
1681
|
return null;
|
|
1682
1682
|
}
|
|
1683
1683
|
}
|
|
1684
|
+
async function injectUserCardContext(params) {
|
|
1685
|
+
try {
|
|
1686
|
+
const resp = await params.client.getUserCard({ userId: params.userId });
|
|
1687
|
+
if (!resp.cardJson)
|
|
1688
|
+
return null;
|
|
1689
|
+
let card;
|
|
1690
|
+
try {
|
|
1691
|
+
card = JSON.parse(resp.cardJson).card ?? resp.cardJson;
|
|
1692
|
+
}
|
|
1693
|
+
catch {
|
|
1694
|
+
card = resp.cardJson;
|
|
1695
|
+
}
|
|
1696
|
+
if (!card || card.trim().length === 0)
|
|
1697
|
+
return null;
|
|
1698
|
+
return '<user_context>\nThe person you are talking to is:\n' + card + '\n</user_context>';
|
|
1699
|
+
}
|
|
1700
|
+
catch {
|
|
1701
|
+
return null;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1684
1704
|
async function runCompaction(args) {
|
|
1685
1705
|
const request = buildCompactSessionRequest(args);
|
|
1686
1706
|
try {
|
|
@@ -1780,7 +1800,7 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
1780
1800
|
sessionId,
|
|
1781
1801
|
sessionKey: args.sessionKey,
|
|
1782
1802
|
userId,
|
|
1783
|
-
message,
|
|
1803
|
+
message: message,
|
|
1784
1804
|
isHeartbeat: args.isHeartbeat,
|
|
1785
1805
|
});
|
|
1786
1806
|
}
|
|
@@ -1967,7 +1987,7 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
1967
1987
|
sessionKey: args.sessionKey,
|
|
1968
1988
|
userId,
|
|
1969
1989
|
prompt: retrievalQuery,
|
|
1970
|
-
messages,
|
|
1990
|
+
messages: messages,
|
|
1971
1991
|
tokenBudget: args.tokenBudget,
|
|
1972
1992
|
config: buildAssemblyConfig(args.tokenBudget),
|
|
1973
1993
|
emitDebug: true,
|
|
@@ -1984,10 +2004,20 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
1984
2004
|
tokenBudget: args.tokenBudget,
|
|
1985
2005
|
systemPromptAddition: assembled.systemPromptAddition,
|
|
1986
2006
|
});
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
2007
|
+
const userCardContext = await injectUserCardContext({ client, userId });
|
|
2008
|
+
// Only inject continuity and user card on session bootstrap (fresh /new).
|
|
2009
|
+
// After the first turn, predictive context handles it.
|
|
2010
|
+
const isSessionBootstrap = messages.length <= 1;
|
|
2011
|
+
let withContext = assembled;
|
|
2012
|
+
if (isSessionBootstrap) {
|
|
2013
|
+
if (continuityContext) {
|
|
2014
|
+
withContext = { ...withContext, systemPromptAddition: appendSystemPromptAddition(withContext.systemPromptAddition, continuityContext) };
|
|
2015
|
+
}
|
|
2016
|
+
if (userCardContext) {
|
|
2017
|
+
withContext = { ...withContext, systemPromptAddition: appendSystemPromptAddition(withContext.systemPromptAddition, userCardContext) };
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
enforced = enforceTokenBudgetInvariant(await augmentWithExactRecall(withContext, {
|
|
1991
2021
|
queryText: retrievalQuery,
|
|
1992
2022
|
userId,
|
|
1993
2023
|
sessionId,
|