@xdarkicex/openclaw-memory-libravdb 1.4.40 → 1.4.42
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 +19 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +29 -6
- package/docs/development.md +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +4 -3
package/dist/context-engine.js
CHANGED
|
@@ -100,6 +100,20 @@ function approximateMessageTokens(message) {
|
|
|
100
100
|
function approximateMessagesTokens(messages) {
|
|
101
101
|
return messages.reduce((sum, message) => sum + approximateMessageTokens(message), 0);
|
|
102
102
|
}
|
|
103
|
+
function selectAfterTurnMessages(messages, prePromptMessageCount, logger) {
|
|
104
|
+
if (typeof prePromptMessageCount !== "number" ||
|
|
105
|
+
!Number.isFinite(prePromptMessageCount) ||
|
|
106
|
+
prePromptMessageCount <= 0) {
|
|
107
|
+
return messages;
|
|
108
|
+
}
|
|
109
|
+
const start = Math.floor(prePromptMessageCount);
|
|
110
|
+
if (start >= messages.length) {
|
|
111
|
+
logger?.warn?.(`LibraVDB afterTurn prePromptMessageCount produced zero forwarded messages ` +
|
|
112
|
+
`prePromptMessageCount=${prePromptMessageCount} start=${start} totalMessages=${messages.length}`);
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
return messages.slice(start);
|
|
116
|
+
}
|
|
103
117
|
function normalizeCurrentTokenCount(currentTokenCount) {
|
|
104
118
|
if (typeof currentTokenCount !== "number" ||
|
|
105
119
|
!Number.isFinite(currentTokenCount) ||
|
|
@@ -723,10 +737,13 @@ export function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
723
737
|
userIdOverride: args.userId,
|
|
724
738
|
sessionKey: args.sessionKey,
|
|
725
739
|
});
|
|
726
|
-
const
|
|
740
|
+
const afterTurnMessages = selectAfterTurnMessages(args.messages, args.prePromptMessageCount, logger);
|
|
741
|
+
const messages = normalizeKernelMessages(afterTurnMessages);
|
|
727
742
|
const msgCount = messages.length;
|
|
728
743
|
logger.info?.(`LibraVDB afterTurn sessionId=${args.sessionId} userId=${userId} ` +
|
|
729
|
-
`messageCount=${msgCount}
|
|
744
|
+
`messageCount=${msgCount} totalMessages=${args.messages.length} ` +
|
|
745
|
+
`prePromptMessageCount=${args.prePromptMessageCount ?? "unknown"} ` +
|
|
746
|
+
`heartbeat=${args.isHeartbeat ?? false}`);
|
|
730
747
|
try {
|
|
731
748
|
const kernel = await getKernelOrNull("afterTurn");
|
|
732
749
|
const currentTokenCount = normalizeCurrentTokenCount(typeof args.runtimeContext?.currentTokenCount === "number"
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
|
|
2
2
|
export declare const MEMORY_ID = "libravdb-memory";
|
|
3
|
+
export declare function shouldShutdownRuntimeForLifecycleCleanup(reason: string): boolean;
|
|
3
4
|
export declare function register(api: OpenClawPluginApi): void;
|
|
4
5
|
declare const _default: {
|
|
5
6
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -33678,6 +33678,19 @@ function approximateMessageTokens(message) {
|
|
|
33678
33678
|
function approximateMessagesTokens(messages) {
|
|
33679
33679
|
return messages.reduce((sum, message) => sum + approximateMessageTokens(message), 0);
|
|
33680
33680
|
}
|
|
33681
|
+
function selectAfterTurnMessages(messages, prePromptMessageCount, logger) {
|
|
33682
|
+
if (typeof prePromptMessageCount !== "number" || !Number.isFinite(prePromptMessageCount) || prePromptMessageCount <= 0) {
|
|
33683
|
+
return messages;
|
|
33684
|
+
}
|
|
33685
|
+
const start = Math.floor(prePromptMessageCount);
|
|
33686
|
+
if (start >= messages.length) {
|
|
33687
|
+
logger?.warn?.(
|
|
33688
|
+
`LibraVDB afterTurn prePromptMessageCount produced zero forwarded messages prePromptMessageCount=${prePromptMessageCount} start=${start} totalMessages=${messages.length}`
|
|
33689
|
+
);
|
|
33690
|
+
return [];
|
|
33691
|
+
}
|
|
33692
|
+
return messages.slice(start);
|
|
33693
|
+
}
|
|
33681
33694
|
function normalizeCurrentTokenCount(currentTokenCount) {
|
|
33682
33695
|
if (typeof currentTokenCount !== "number" || !Number.isFinite(currentTokenCount) || currentTokenCount <= 0) {
|
|
33683
33696
|
return void 0;
|
|
@@ -34269,10 +34282,11 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
34269
34282
|
userIdOverride: args.userId,
|
|
34270
34283
|
sessionKey: args.sessionKey
|
|
34271
34284
|
});
|
|
34272
|
-
const
|
|
34285
|
+
const afterTurnMessages = selectAfterTurnMessages(args.messages, args.prePromptMessageCount, logger);
|
|
34286
|
+
const messages = normalizeKernelMessages(afterTurnMessages);
|
|
34273
34287
|
const msgCount = messages.length;
|
|
34274
34288
|
logger.info?.(
|
|
34275
|
-
`LibraVDB afterTurn sessionId=${args.sessionId} userId=${userId} messageCount=${msgCount} heartbeat=${args.isHeartbeat ?? false}`
|
|
34289
|
+
`LibraVDB afterTurn sessionId=${args.sessionId} userId=${userId} messageCount=${msgCount} totalMessages=${args.messages.length} prePromptMessageCount=${args.prePromptMessageCount ?? "unknown"} heartbeat=${args.isHeartbeat ?? false}`
|
|
34276
34290
|
);
|
|
34277
34291
|
try {
|
|
34278
34292
|
const kernel = await getKernelOrNull("afterTurn");
|
|
@@ -39608,6 +39622,10 @@ function enrichStartupError(error, healthMessage) {
|
|
|
39608
39622
|
// src/index.ts
|
|
39609
39623
|
var MEMORY_ID = "libravdb-memory";
|
|
39610
39624
|
var LIGHTWEIGHT_MODES = /* @__PURE__ */ new Set(["cli-metadata", "setup-only"]);
|
|
39625
|
+
var RUNTIME_CLEANUP_SHUTDOWN_REASONS = /* @__PURE__ */ new Set(["delete", "restart"]);
|
|
39626
|
+
function shouldShutdownRuntimeForLifecycleCleanup(reason) {
|
|
39627
|
+
return RUNTIME_CLEANUP_SHUTDOWN_REASONS.has(reason);
|
|
39628
|
+
}
|
|
39611
39629
|
function register(api) {
|
|
39612
39630
|
const registrationMode = api.registrationMode;
|
|
39613
39631
|
const logger = api.logger ?? console;
|
|
@@ -39698,11 +39716,15 @@ function register(api) {
|
|
|
39698
39716
|
});
|
|
39699
39717
|
api.registerRuntimeLifecycle?.({
|
|
39700
39718
|
id: "libravdb-shutdown",
|
|
39701
|
-
description: "Shut down the vector service runtime on plugin
|
|
39719
|
+
description: "Shut down the vector service runtime on terminal plugin cleanup",
|
|
39702
39720
|
async cleanup(ctx) {
|
|
39703
|
-
if (ctx.reason
|
|
39704
|
-
logger.info?.(
|
|
39721
|
+
if (shouldShutdownRuntimeForLifecycleCleanup(ctx.reason)) {
|
|
39722
|
+
logger.info?.(`LibraVDB ${ctx.reason} \u2014 shutting down runtime`);
|
|
39705
39723
|
await runtime.shutdown();
|
|
39724
|
+
} else if (ctx.reason === "disable") {
|
|
39725
|
+
logger.info?.(
|
|
39726
|
+
"LibraVDB disable cleanup observed; preserving runtime for active context engine"
|
|
39727
|
+
);
|
|
39706
39728
|
}
|
|
39707
39729
|
}
|
|
39708
39730
|
});
|
|
@@ -39731,5 +39753,6 @@ var index_default = definePluginEntry({
|
|
|
39731
39753
|
export {
|
|
39732
39754
|
MEMORY_ID,
|
|
39733
39755
|
index_default as default,
|
|
39734
|
-
register
|
|
39756
|
+
register,
|
|
39757
|
+
shouldShutdownRuntimeForLifecycleCleanup
|
|
39735
39758
|
};
|
package/docs/development.md
CHANGED
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xdarkicex/openclaw-memory-libravdb",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc -p tsconfig.build.json && node scripts/bundle-entrypoint.mjs && mkdir -p dist/proto && cp -rf api/proto/. dist/proto/",
|
|
51
51
|
"check": "tsc --noEmit && pnpm run test:ts",
|
|
52
|
-
"test:
|
|
53
|
-
"test:
|
|
52
|
+
"test:inspect": "pnpm run plugin:ci",
|
|
53
|
+
"test:ts": "pnpm run test:inspect && tsc -p tsconfig.tests.json && node --test .ts-build/test/unit/*.test.js",
|
|
54
|
+
"test:integration": "pnpm run test:inspect && tsc -p tsconfig.tests.json && node --test .ts-build/test/integration/checklist-validation.test.js .ts-build/test/integration/dream-promotion.test.js .ts-build/test/integration/host-flow.test.js .ts-build/test/integration/markdown-ingest.test.js .ts-build/test/integration/sidecar-lifecycle.test.js",
|
|
54
55
|
"benchmark:session_search_mid": "tsc -p tsconfig.tests.json && OPENCLAW_PROFILE_ASSEMBLE=1 node --test --test-name-pattern=\"real sidecar mid-sized session search benchmark\" .ts-build/test/integration/host-flow.test.js",
|
|
55
56
|
"gate:assemble_optimization": "tsc -p tsconfig.tests.json && OPENCLAW_PROFILE_ASSEMBLE=1 OPENCLAW_ENFORCE_ASSEMBLE_EVIDENCE_GATE=1 node --test --test-name-pattern=\"real sidecar mid-sized session search benchmark\" .ts-build/test/integration/host-flow.test.js",
|
|
56
57
|
"probe:session_recall": "tsc -p tsconfig.tests.json && OPENCLAW_PROFILE_ASSEMBLE=1 node --test --test-name-pattern=\"real sidecar mid-sized session search benchmark\" .ts-build/test/integration/host-flow.test.js",
|