@xdarkicex/openclaw-memory-libravdb 1.8.0 → 1.8.1
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/README.md +49 -15
- package/dist/index.js +28 -0
- package/dist/memory-tools.js +35 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -144,19 +144,53 @@ If your service runs elsewhere, set `sidecarPath`:
|
|
|
144
144
|
|
|
145
145
|
## Highlights
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
- **
|
|
150
|
-
- **
|
|
151
|
-
- **
|
|
152
|
-
- **
|
|
153
|
-
- **
|
|
154
|
-
- **
|
|
155
|
-
- **
|
|
156
|
-
- **
|
|
157
|
-
- **
|
|
158
|
-
- **
|
|
159
|
-
- **
|
|
147
|
+
### Why LibraVDB over other memory plugins
|
|
148
|
+
|
|
149
|
+
- **Truly local.** All embedding, search, and compaction runs on your hardware through a dedicated vector service. No cloud API calls, no data leaving your machine, no subscription fees. Works offline.
|
|
150
|
+
- **Handles long conversations.** Sessions with hundreds of turns are automatically compacted into searchable summaries. The agent can recall what was discussed in turn 5 even when you're on turn 200 — without blowing the context window.
|
|
151
|
+
- **Never forgets a constraint.** Behavioral rules, preferences, and operating boundaries ("always use TLS", "prefers dark mode") are automatically detected and surfaced higher in recall than conversational noise. The agent can ask "what are my constraints?" and get a surgical answer.
|
|
152
|
+
- **Automatic contradiction detection.** When you say "my email changed to jeff@anthropic.com", the old email is automatically marked as outdated — no manual cleanup, no stale facts confusing the agent.
|
|
153
|
+
- **BM25 + vector hybrid search.** Lexical matching (exact identifiers, file paths, error codes) is fused with semantic similarity. A query for `docker-compose.yml` finds the file even if you described it as "the container config."
|
|
154
|
+
- **Summary recall with expansion tools.** Compacted conversation history can be explored without flooding context. `memory_describe` peeks at what a summary covers; `memory_expand` drills into specifics; `memory_grep` searches by pattern. The agent decides how deep to go.
|
|
155
|
+
- **Subagent-safe expansion.** When a summary is too large to expand directly, `memory_expand` enforces a token budget and delegates to a sub-agent — protecting the main agent's context window.
|
|
156
|
+
- **Predictive memory.** The vector service pre-computes what the agent is likely to ask next after each turn, injecting relevant context before the model even sees the prompt.
|
|
157
|
+
- **Three memory scopes.** Session memory (current conversation), user memory (everything you've ever told the agent), and global memory (shared across users) are kept separate. Searches can target specific scopes.
|
|
158
|
+
- **Cognitive kind and signal filters.** Memories are classified as identity, fact, preference, constraint, decision, or episode. `memory_search(kind="constraint")` returns only operating boundaries — no conversational noise.
|
|
159
|
+
- **True multi-tenancy.** Isolated per-agent vector databases within a single vector service process. Each agent sees only its own data.
|
|
160
|
+
- **Memory-mapped embedding cache.** Frequently embedded text is cached in a file-backed mmap region that survives daemon restarts. Cold starts are faster, repeat queries are instant.
|
|
161
|
+
- **Pluggable summarization backend.** The vector service's extractive summarization can replace LLM-based compaction — zero tokens burned on summarization.
|
|
162
|
+
- **Local-first inference.** GGUF, ONNX, or remote embedding backends. Hardware-native acceleration on Apple Silicon and NVIDIA. No cloud required.
|
|
163
|
+
- **Operational CLI.** `libravdbd status`, `health`, `search`, `tenant evict`, `migrate` — live observability and management without interrupting active sessions.
|
|
164
|
+
|
|
165
|
+
### Technical Architecture
|
|
166
|
+
|
|
167
|
+
- **Unified Cognitive Scoring** — mathematically blends cosine similarity with frequency, recency, authored salience, and cognitive authority composite weights (`ω(c)`).
|
|
168
|
+
- **Section 7 Two-Pass Retrieval** — coarse cascade search (coarse top-K) followed by precision reranking (second-pass top-K) with hop expansion and temporal comparison profiling.
|
|
169
|
+
- **BM25 + Vector RRF Fusion** — lexical BM25 scoring fused with vector similarity via Reciprocal Rank Fusion across all 11 recall paths.
|
|
170
|
+
- **Content-Addressed Summaries** — deterministic SHA256-based summary IDs: same inputs produce identical IDs across crashes and retries.
|
|
171
|
+
- **Structured Eviction Cues** — ~60-token deterministic metadata pointers on summary records (anchors, decisions, constraints, signal counts) — no LLM needed.
|
|
172
|
+
- **Topological Causal Graphs** — temporal memory chains via directed acyclic graphs (`WhyIDs`), injecting causal proximity into retrieval scoring.
|
|
173
|
+
- **Zero-GC Slab Allocation** — manages model tensor and inference data via a custom contiguous slab allocator (`slabby`), bypassing Go garbage collection pauses.
|
|
174
|
+
- **Deontic & Salience Retrieval** — structural authority weightings and deontic logic rules ensure critical behavioral constraints mathematically outrank conversational chatter.
|
|
175
|
+
- **Matryoshka Representation Learning** — dynamically tiered embedding dimensions (e.g., slicing 768d vectors down to 64d) for cascading coarse search followed by precision reranking.
|
|
176
|
+
- **Cognitive Routing Circuit Breakers** — stateful circuit breakers on remote endpoints, auto-disabling complex ML routing during outages while preserving foundational search.
|
|
177
|
+
- **Zero-ML Local Compaction** — purely localized session summarization and compaction cycles natively within the vector service. L1-L8 pipeline with deterministic state skeleton.
|
|
178
|
+
- **Anchor-Based Contradiction Detection** — regex anchor extraction with Jaccard dedup and automatic `MarkSuperseded` — zero LLM overhead.
|
|
179
|
+
- **Access Frequency in Omega** — `log2(accessCount+1)/10` term in the authority composite: frequently-retrieved memories surface higher without dominating relevance.
|
|
180
|
+
- **True multi-tenancy** — strictly isolated, per-agent vector databases within a single lightweight vector service process.
|
|
181
|
+
- **Zero-copy caching** — memory-mapped cross-tenant embedding cache across all active agents. Tenant-scoped keys prevent cross-tenant collision.
|
|
182
|
+
- **Three memory scopes** — active session, durable user, and global memory kept separate.
|
|
183
|
+
- **Local-first inference** — GGUF, ONNX, or remote embedding backends. Hardware-native acceleration on Apple Silicon and NVIDIA.
|
|
184
|
+
- **Pluggable compaction backend** — exposes the vector service's extractive summarization as an OpenClaw `CompactionProvider` — replaces LLM summarization.
|
|
185
|
+
- **Operational tooling** — dedicated CLI (`libravdbd status`, `health`, `search`, `migrate`, `tenant evict`) for live observability.
|
|
186
|
+
- **Half-Life Decay per Cognitive Kind** — each memory kind decays at its own rate: identity, constraint, and decision have infinite half-life (permanent); facts decay over 180 days; preferences over 365 days. Mathematical support accumulation prevents thrashing.
|
|
187
|
+
- **Deterministic State Skeleton (L8)** — extracts structured decisions, constraints, and next steps from raw turns using pure heuristics — no LLM call needed. Line-level scoring with commitment-verb and future-intent detection.
|
|
188
|
+
- **Deterministic Tool Output Compression** — 3-phase compression of tool outputs before summarization: JSON key sampling, log-line deduplication (FNV-64a), and fenced-block tagging. Reduces token pressure without losing deontic markers.
|
|
189
|
+
- **Seven Budget Channels** — waterfall token allocation across retrieval floor, mandatory continuity tail, hard-authored items, elevated guidance, soft-authored items, retrieval remainder, and recovery reserve. Each channel has its own budget fraction.
|
|
190
|
+
- **Temporal Comparison Profiling** — witness scoring with diachronicity detection for "how did this change?" queries. Slot decomposition, discriminative membership, and position-weighted specificity.
|
|
191
|
+
- **Merkle Chain Ingest** — content-hash-based session manifest with cursor reconciliation between plugin and vector service. Guarantees idempotent ingestion across crashes and retries.
|
|
192
|
+
- **Nonce-Chaining HMAC Auth** — per-request challenge-response authentication with single-use cryptographic nonces. Supports mTLS for secure multi-machine deployments.
|
|
193
|
+
- **Explicit service lifecycle** — the npm/OpenClaw package stays connect-only; `libravdbd` is installed and supervised separately over a secure gRPC transport.
|
|
160
194
|
|
|
161
195
|
## Embedding Backend Providers
|
|
162
196
|
|
|
@@ -193,11 +227,11 @@ openclaw memory journal --limit 50
|
|
|
193
227
|
openclaw memory dream-promote --user-id <userId> --dream-file ~/DREAMS.md
|
|
194
228
|
```
|
|
195
229
|
|
|
196
|
-
### Vector Service CLI (libravdbd v1.
|
|
230
|
+
### Vector Service CLI (libravdbd v1.6.0+)
|
|
197
231
|
|
|
198
232
|
```bash
|
|
199
233
|
# Service health and status
|
|
200
|
-
libravdbd status # tenants, cache, DB sizes
|
|
234
|
+
libravdbd status # tenants, cache, DB sizes, CPU load
|
|
201
235
|
libravdbd health # OK/UNHEALTHY
|
|
202
236
|
|
|
203
237
|
# Search tenant memory (same collections memory_search queries)
|
package/dist/index.js
CHANGED
|
@@ -36020,6 +36020,27 @@ var MEMORY_GET_SCHEMA = {
|
|
|
36020
36020
|
function createLibraVdbMemoryTools(getClient, cfg, logger = console) {
|
|
36021
36021
|
const bridge = buildMemoryRuntimeBridge(getClient, cfg);
|
|
36022
36022
|
const managers = /* @__PURE__ */ new Map();
|
|
36023
|
+
const turnSearchKeys = /* @__PURE__ */ new Map();
|
|
36024
|
+
const TURN_SEARCH_MAX_KEYS = 500;
|
|
36025
|
+
function dedupKey(sessionKey, query) {
|
|
36026
|
+
return `${sessionKey}:${query.toLowerCase().replace(/\s+/g, " ").trim().slice(0, 80)}`;
|
|
36027
|
+
}
|
|
36028
|
+
function isDuplicateSearch(sessionKey, query) {
|
|
36029
|
+
if (!sessionKey) return false;
|
|
36030
|
+
const key = dedupKey(sessionKey, query);
|
|
36031
|
+
const keys = turnSearchKeys.get(sessionKey);
|
|
36032
|
+
if (!keys) {
|
|
36033
|
+
turnSearchKeys.set(sessionKey, /* @__PURE__ */ new Set([key]));
|
|
36034
|
+
if (turnSearchKeys.size > TURN_SEARCH_MAX_KEYS) {
|
|
36035
|
+
const oldest = turnSearchKeys.keys().next().value;
|
|
36036
|
+
if (oldest !== void 0) turnSearchKeys.delete(oldest);
|
|
36037
|
+
}
|
|
36038
|
+
return false;
|
|
36039
|
+
}
|
|
36040
|
+
if (keys.has(key)) return true;
|
|
36041
|
+
keys.add(key);
|
|
36042
|
+
return false;
|
|
36043
|
+
}
|
|
36023
36044
|
async function getManager(ctx, purpose) {
|
|
36024
36045
|
const key = managerCacheKey(ctx);
|
|
36025
36046
|
let manager = managers.get(key);
|
|
@@ -36045,6 +36066,13 @@ function createLibraVdbMemoryTools(getClient, cfg, logger = console) {
|
|
|
36045
36066
|
execute: async (_toolCallId, rawParams) => {
|
|
36046
36067
|
const params = asToolParamsRecord(rawParams);
|
|
36047
36068
|
const query = readRequiredStringParam(params, "query");
|
|
36069
|
+
const sessionKey = ctx.sessionKey ?? "";
|
|
36070
|
+
if (isDuplicateSearch(sessionKey, query)) {
|
|
36071
|
+
return jsonToolResult({
|
|
36072
|
+
results: [],
|
|
36073
|
+
error: `Duplicate search blocked. You already searched this turn \u2014 use the previous results. Do not call memory_search again.`
|
|
36074
|
+
});
|
|
36075
|
+
}
|
|
36048
36076
|
const corpus = readMemoryCorpus(params.corpus);
|
|
36049
36077
|
const kind = typeof params.kind === "string" ? params.kind : void 0;
|
|
36050
36078
|
const signals = Array.isArray(params.signals) ? params.signals.filter((s) => typeof s === "string") : void 0;
|
package/dist/memory-tools.js
CHANGED
|
@@ -67,6 +67,34 @@ const MEMORY_GET_SCHEMA = {
|
|
|
67
67
|
export function createLibraVdbMemoryTools(getClient, cfg, logger = console) {
|
|
68
68
|
const bridge = buildMemoryRuntimeBridge(getClient, cfg);
|
|
69
69
|
const managers = new Map();
|
|
70
|
+
// Turn-scoped search dedup: blocks repeated searches within the same turn.
|
|
71
|
+
// The model sometimes loops memory_search with slight query variations;
|
|
72
|
+
// this enforces "once per turn" at the tool level, not just the prompt.
|
|
73
|
+
const turnSearchKeys = new Map();
|
|
74
|
+
const TURN_SEARCH_MAX_KEYS = 500;
|
|
75
|
+
function dedupKey(sessionKey, query) {
|
|
76
|
+
return `${sessionKey}:${query.toLowerCase().replace(/\s+/g, " ").trim().slice(0, 80)}`;
|
|
77
|
+
}
|
|
78
|
+
function isDuplicateSearch(sessionKey, query) {
|
|
79
|
+
if (!sessionKey)
|
|
80
|
+
return false;
|
|
81
|
+
const key = dedupKey(sessionKey, query);
|
|
82
|
+
const keys = turnSearchKeys.get(sessionKey);
|
|
83
|
+
if (!keys) {
|
|
84
|
+
turnSearchKeys.set(sessionKey, new Set([key]));
|
|
85
|
+
// Prune stale entries.
|
|
86
|
+
if (turnSearchKeys.size > TURN_SEARCH_MAX_KEYS) {
|
|
87
|
+
const oldest = turnSearchKeys.keys().next().value;
|
|
88
|
+
if (oldest !== undefined)
|
|
89
|
+
turnSearchKeys.delete(oldest);
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (keys.has(key))
|
|
94
|
+
return true;
|
|
95
|
+
keys.add(key);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
70
98
|
async function getManager(ctx, purpose) {
|
|
71
99
|
const key = managerCacheKey(ctx);
|
|
72
100
|
let manager = managers.get(key);
|
|
@@ -95,6 +123,13 @@ export function createLibraVdbMemoryTools(getClient, cfg, logger = console) {
|
|
|
95
123
|
execute: async (_toolCallId, rawParams) => {
|
|
96
124
|
const params = asToolParamsRecord(rawParams);
|
|
97
125
|
const query = readRequiredStringParam(params, "query");
|
|
126
|
+
const sessionKey = ctx.sessionKey ?? "";
|
|
127
|
+
if (isDuplicateSearch(sessionKey, query)) {
|
|
128
|
+
return jsonToolResult({
|
|
129
|
+
results: [],
|
|
130
|
+
error: `Duplicate search blocked. You already searched this turn — use the previous results. Do not call memory_search again.`,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
98
133
|
const corpus = readMemoryCorpus(params.corpus);
|
|
99
134
|
const kind = typeof params.kind === "string" ? params.kind : undefined;
|
|
100
135
|
const signals = Array.isArray(params.signals) ? params.signals.filter((s) => typeof s === "string") : undefined;
|
package/openclaw.plugin.json
CHANGED