@joshuaswarren/openclaw-engram 9.2.6 → 9.3.0

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.
Files changed (52) hide show
  1. package/dist/access-cli.js +1 -222
  2. package/dist/index.js +3 -15127
  3. package/openclaw.plugin.json +2 -2
  4. package/package.json +33 -82
  5. package/LICENSE +0 -21
  6. package/README.md +0 -656
  7. package/dist/access-cli.js.map +0 -1
  8. package/dist/admin-console/public/app.js +0 -721
  9. package/dist/admin-console/public/index.html +0 -470
  10. package/dist/calibration-5ZKC4PGR.js +0 -236
  11. package/dist/calibration-5ZKC4PGR.js.map +0 -1
  12. package/dist/causal-chain-NTQJJLVN.js +0 -23
  13. package/dist/causal-chain-NTQJJLVN.js.map +0 -1
  14. package/dist/causal-consolidation-K2R5TEG7.js +0 -206
  15. package/dist/causal-consolidation-K2R5TEG7.js.map +0 -1
  16. package/dist/causal-retrieval-BMM45BSR.js +0 -183
  17. package/dist/causal-retrieval-BMM45BSR.js.map +0 -1
  18. package/dist/causal-trajectory-graph-RXHMHGG3.js +0 -60
  19. package/dist/causal-trajectory-graph-RXHMHGG3.js.map +0 -1
  20. package/dist/chunk-6KX4XLQJ.js +0 -343
  21. package/dist/chunk-6KX4XLQJ.js.map +0 -1
  22. package/dist/chunk-DEIBZP3O.js +0 -49
  23. package/dist/chunk-DEIBZP3O.js.map +0 -1
  24. package/dist/chunk-GKUNOUQI.js +0 -562
  25. package/dist/chunk-GKUNOUQI.js.map +0 -1
  26. package/dist/chunk-IMMYYNXG.js +0 -160
  27. package/dist/chunk-IMMYYNXG.js.map +0 -1
  28. package/dist/chunk-MKM2BCQH.js +0 -436
  29. package/dist/chunk-MKM2BCQH.js.map +0 -1
  30. package/dist/chunk-NEJTYWAH.js +0 -280
  31. package/dist/chunk-NEJTYWAH.js.map +0 -1
  32. package/dist/chunk-OVWP47NO.js +0 -1849
  33. package/dist/chunk-OVWP47NO.js.map +0 -1
  34. package/dist/chunk-PKKCGNF2.js +0 -15
  35. package/dist/chunk-PKKCGNF2.js.map +0 -1
  36. package/dist/chunk-SSIIJJKA.js +0 -44
  37. package/dist/chunk-SSIIJJKA.js.map +0 -1
  38. package/dist/chunk-TUH5NNZ2.js +0 -4244
  39. package/dist/chunk-TUH5NNZ2.js.map +0 -1
  40. package/dist/chunk-V2QDCXYP.js +0 -33700
  41. package/dist/chunk-V2QDCXYP.js.map +0 -1
  42. package/dist/engine-GUURUH4W.js +0 -12
  43. package/dist/engine-GUURUH4W.js.map +0 -1
  44. package/dist/fallback-llm-KSO34MOM.js +0 -9
  45. package/dist/fallback-llm-KSO34MOM.js.map +0 -1
  46. package/dist/index.js.map +0 -1
  47. package/dist/legacy-hook-compat-722BG5XG.js +0 -36
  48. package/dist/legacy-hook-compat-722BG5XG.js.map +0 -1
  49. package/dist/logger-KPTKTANX.js +0 -10
  50. package/dist/logger-KPTKTANX.js.map +0 -1
  51. package/dist/storage-LOT4RKCT.js +0 -17
  52. package/dist/storage-LOT4RKCT.js.map +0 -1
package/README.md DELETED
@@ -1,656 +0,0 @@
1
- # Engram
2
-
3
- **Persistent, private memory for AI agents.** Your agents forget everything between sessions — Engram fixes that.
4
-
5
- Engram gives AI agents long-term memory that survives across conversations. Decisions, preferences, project context, personal details, past mistakes — everything your agent learns persists and resurfaces exactly when it's needed. All data stays on your machine as plain markdown files. No cloud services, no subscriptions, no sharing your data with third parties.
6
-
7
- [![npm version](https://img.shields.io/npm/v/@joshuaswarren/openclaw-engram)](https://www.npmjs.com/package/@joshuaswarren/openclaw-engram)
8
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
9
- [![Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-pink)](https://github.com/sponsors/joshuaswarren)
10
-
11
- ## The Problem
12
-
13
- Every AI agent session starts from zero. Your agent doesn't know your name, your projects, the decisions you've already made, or the bugs you already debugged. Whether it's a personal assistant, a coding agent, a research agent, or a multi-agent team — they all forget everything between conversations. You re-explain the same context over and over, and your agents still make the same mistakes.
14
-
15
- OpenClaw's built-in memory works for simple cases, but it doesn't scale. It lacks semantic search, lifecycle management, entity tracking, and governance. Third-party memory services exist, but they cost money and require sending your private data to someone else's servers.
16
-
17
- ## The Solution
18
-
19
- Engram is an open-source, local-first memory system that replaces OpenClaw's default memory with something much more capable — while keeping everything on your machine. It watches your agent conversations, extracts durable knowledge, and injects the right memories back at the start of every session. Use OpenAI or a **local LLM** (Ollama, LM Studio, etc.) for extraction — your choice.
20
-
21
- It works as a native **[OpenClaw](https://github.com/openclaw/openclaw)** plugin, with **[Codex CLI](https://github.com/openai/codex)** via MCP, and with any other MCP-compatible client — with more integrations coming.
22
-
23
- | Without Engram | With Engram |
24
- |---|---|
25
- | Re-explain who you are and what you're working on | Agent recalls your identity, projects, and preferences automatically |
26
- | Repeat context for every task | Entity knowledge surfaces people, projects, tools, and relationships on demand |
27
- | Lose debugging and research context between sessions | Past root causes, dead ends, and findings are recalled — no repeated work |
28
- | Manually restate preferences every session | Preferences persist across sessions, agents, and projects |
29
- | Context-switching tax when resuming work | Session-start recall brings you back to speed instantly |
30
- | Default OpenClaw memory doesn't scale | Hybrid search, lifecycle management, namespaces, and governance |
31
- | Third-party memory services cost money and share your data | Everything stays local — your filesystem, your rules |
32
-
33
- ## Installation
34
-
35
- ### Option 1: Install from the CLI
36
-
37
- ```bash
38
- openclaw plugins install @joshuaswarren/openclaw-engram --pin
39
- ```
40
-
41
- ### Option 2: Ask your OpenClaw agent to install it
42
-
43
- Tell any OpenClaw agent:
44
-
45
- > Install the openclaw-engram plugin and configure it as my memory system.
46
-
47
- Your agent will run the install command, update `openclaw.json`, and restart the gateway for you.
48
-
49
- ### Option 3: Developer install from source
50
-
51
- ```bash
52
- git clone https://github.com/joshuaswarren/openclaw-engram.git \
53
- ~/.openclaw/extensions/openclaw-engram
54
- cd ~/.openclaw/extensions/openclaw-engram
55
- npm ci && npm run build
56
- ```
57
-
58
- ### Option 4: Standalone (no OpenClaw)
59
-
60
- Build from source and use the standalone CLI. Requires [Node.js](https://nodejs.org/) 22.12+ and [tsx](https://github.com/privatenumber/tsx) (`npm install -g tsx`).
61
-
62
- ```bash
63
- npm install -g tsx # Required — CLI entry point is TypeScript
64
- git clone https://github.com/joshuaswarren/openclaw-engram.git
65
- cd openclaw-engram
66
- npm ci && npm run build
67
- cd packages/cli && npm link # Makes `engram` available on PATH
68
- cd ../..
69
- engram init # Create engram.config.json
70
- export OPENAI_API_KEY=sk-...
71
- export ENGRAM_AUTH_TOKEN=$(openssl rand -hex 32)
72
- engram daemon start # Start background server
73
- engram status # Verify it's running
74
- engram query "hello" --explain # Test query with tier breakdown
75
- ```
76
-
77
- > **Note:** The `engram` binary (`packages/cli/bin/engram.cjs`) is a CJS wrapper that auto-locates `tsx` from `node_modules` (falling back to a global `tsx`). Running `npm link` from `packages/cli/` (not the repo root) makes the CLI globally available — the root package only exposes `engram-access`. Alternatively, invoke directly: `npx tsx packages/cli/src/index.ts <command>`.
78
-
79
- The standalone CLI provides 15+ commands for memory management, project onboarding, curation, diff-aware sync, dedup, connectors, spaces, and benchmarks -- all without requiring OpenClaw. See the [Platform Migration Guide](docs/guides/platform-migration.md) for the full command reference.
80
-
81
- ### Configure
82
-
83
- After installation, add Engram to your `openclaw.json`:
84
-
85
- ```jsonc
86
- {
87
- "plugins": {
88
- "allow": ["openclaw-engram"],
89
- "slots": { "memory": "openclaw-engram" },
90
- "entries": {
91
- "openclaw-engram": {
92
- "enabled": true,
93
- "config": {
94
- // Option 1: Use OpenAI for extraction:
95
- "openaiApiKey": "${OPENAI_API_KEY}"
96
-
97
- // Option 2: Use Engram's local LLM path (plugin mode only; no API key needed):
98
- // "localLlmEnabled": true,
99
- // "localLlmUrl": "http://localhost:1234/v1",
100
- // "localLlmModel": "qwen2.5-32b-instruct"
101
-
102
- // Option 3: Use the gateway model chain (primary path in gateway mode):
103
- // "modelSource": "gateway",
104
- // "gatewayAgentId": "engram-llm",
105
- // "fastGatewayAgentId": "engram-llm-fast"
106
- }
107
- }
108
- }
109
- }
110
- }
111
- ```
112
-
113
- > **Gateway model source:** When `modelSource` is `"gateway"`, Engram routes all LLM calls (extraction, consolidation, reranking) through an OpenClaw agent persona's model chain instead of its own config. Extraction starts on the `gatewayAgentId` chain directly in this mode; `localLlm*` settings do not control primary extraction order. Define agent personas in `openclaw.json → agents.list[]` with a `primary` model and `fallbacks[]` array — Engram tries each in order until one succeeds. This lets you build multi-provider fallback chains like Fireworks → local LLM → cloud OpenAI. See the [Gateway Model Source](docs/config-reference.md#gateway-model-source) guide for full setup.
114
-
115
- Restart the gateway:
116
-
117
- ```bash
118
- launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway # macOS
119
- # or: systemctl restart openclaw-gateway # Linux
120
- ```
121
-
122
- Start a conversation — Engram begins learning immediately.
123
-
124
- > **Note:** This shows only the minimal config. Engram has 60+ configuration options for search backends, capture modes, memory OS features, and more. See the [full config reference](docs/config-reference.md) for every setting.
125
-
126
- ### Verify installation
127
-
128
- ```bash
129
- openclaw engram setup --json # Validates config, scaffolds directories
130
- openclaw engram doctor --json # Health diagnostics with remediation hints
131
- openclaw engram config-review --json # Opinionated config tuning recommendations
132
- ```
133
-
134
- ## Using Engram with Codex CLI
135
-
136
- Start the Engram HTTP server:
137
-
138
- ```bash
139
- # Generate a token
140
- export OPENCLAW_ENGRAM_ACCESS_TOKEN="$(openssl rand -base64 32)"
141
-
142
- # Start the server
143
- openclaw engram access http-serve \
144
- --host 127.0.0.1 \
145
- --port 4318 \
146
- --token "$OPENCLAW_ENGRAM_ACCESS_TOKEN"
147
- ```
148
-
149
- Add to `~/.codex/config.toml`:
150
-
151
- ```toml
152
- [mcp_servers.engram]
153
- url = "http://127.0.0.1:4318/mcp"
154
- bearer_token_env_var = "OPENCLAW_ENGRAM_ACCESS_TOKEN"
155
- ```
156
-
157
- That's it. Codex now has access to Engram's recall, store, and entity tools. See the [full Codex integration guide](docs/guides/codex-cli.md) for session-start hooks, cross-machine setup, and automatic recall at session start.
158
-
159
- ## Using Engram with Any MCP Client
160
-
161
- Run the stdio MCP server:
162
-
163
- ```bash
164
- openclaw engram access mcp-serve
165
- ```
166
-
167
- Point your MCP client's command at `openclaw engram access mcp-serve`. Works with Claude Code, and any other MCP-compatible client. The server exposes the same tools as the HTTP endpoint.
168
-
169
- **Claude Code (MCP over HTTP):** Start the Engram HTTP server, then add to `~/.claude.json`:
170
-
171
- ```json
172
- {
173
- "mcpServers": {
174
- "engram": {
175
- "url": "http://localhost:4318/mcp",
176
- "headers": {
177
- "Authorization": "Bearer ${ENGRAM_TOKEN}"
178
- }
179
- }
180
- }
181
- }
182
- ```
183
-
184
- See the [Standalone Server Guide](docs/guides/standalone-server.md) for multi-tenant setups and connecting multiple agent harnesses.
185
-
186
- ## Standalone Usage
187
-
188
- Engram also works as a standalone tool without OpenClaw. Install and run the CLI directly:
189
-
190
- ```bash
191
- npm install -g @joshuaswarren/openclaw-engram
192
- engram init # create engram.config.json
193
- export OPENAI_API_KEY=sk-...
194
- export ENGRAM_AUTH_TOKEN=$(openssl rand -hex 32)
195
- engram daemon start # start background server
196
- engram query "hello" # verify
197
- ```
198
-
199
- The CLI provides 15+ commands for querying, onboarding projects, curating files, managing spaces, running benchmarks, and more. See the [full CLI reference](docs/api.md#standalone-cli-commands) for all commands.
200
-
201
- ### Connect to any coding tool
202
-
203
- Engram works with 10+ coding tools via MCP or HTTP. See the [Connector Setup Guide](docs/integration/connector-setup.md) for config snippets for Claude Code, Codex CLI, Cursor, GitHub Copilot, Cline, Roo Code, Windsurf, Amp, Replit, and any generic MCP client.
204
-
205
- OpenClaw remains the recommended path for most users. The standalone CLI is useful for CI/CD pipelines, scripted memory operations, and environments without OpenClaw.
206
-
207
- ### Package Architecture
208
-
209
- ```
210
- @engram/core — Framework-agnostic engine (re-exports orchestrator, config, storage, search, extraction, graph, trust zones)
211
- @engram/cli — Standalone CLI binary (15+ commands)
212
- @engram/server — Standalone HTTP/MCP server
213
- @engram/bench — Benchmarks + CI regression gates
214
- @engram/hermes-provider — HTTP client for remote Engram instances
215
- ```
216
-
217
- ## How It Works
218
-
219
- Engram operates in three phases:
220
-
221
- ```
222
- Recall → Before each conversation, inject relevant memories into context
223
- Buffer → After each turn, accumulate content until a trigger fires
224
- Extract → Periodically, extract structured memories using an LLM
225
- ```
226
-
227
- Memories are stored as plain markdown files with YAML frontmatter — fully portable, git-friendly, no database required:
228
-
229
- ```yaml
230
- ---
231
- id: decision-1738789200000-a1b2
232
- category: decision
233
- confidence: 0.92
234
- tags: ["architecture", "search"]
235
- ---
236
- Decided to use the port/adapter pattern for search backends
237
- so alternative engines can replace QMD without changing core logic.
238
- ```
239
-
240
- Memory categories include: `fact`, `decision`, `preference`, `correction`, `relationship`, `principle`, `commitment`, `moment`, `skill`, `rule`, and more.
241
-
242
- ## Architecture
243
-
244
- Starting with v9.1.36, Engram is organized as a monorepo with five packages:
245
-
246
- ```
247
- ┌─────────────────┐
248
- │ @engram/core │
249
- │ (engine) │
250
- └────────┬────────┘
251
-
252
- ┌─────────────┼─────────────┐
253
- │ │ │
254
- ┌──────┴──────┐ ┌───┴────┐ ┌──────┴──────────┐
255
- │ @engram/cli │ │@engram/│ │ @engram/ │
256
- │ (CLI binary)│ │server │ │ hermes-provider │
257
- └─────────────┘ └────────┘ └─────────────────┘
258
-
259
- ┌──────┴──────┐
260
- │ @engram/ │
261
- │ bench │
262
- └─────────────┘
263
- ```
264
-
265
- | Package | Description |
266
- |---------|-------------|
267
- | `@engram/core` | Framework-agnostic engine with zero OpenClaw imports. Re-exports orchestrator, config, storage, search, extraction, graph, and trust zones. |
268
- | `@engram/cli` | Standalone CLI binary with 15+ commands for memory management, project onboarding, curation, sync, dedup, connectors, spaces, and benchmarks. |
269
- | `@engram/server` | Standalone HTTP/MCP server wrapping the existing access layer. Run independently or as a daemon. |
270
- | `@engram/bench` | Latency ladder benchmarks with tier breakdowns, saved baselines, and CI regression gates. |
271
- | `@engram/hermes-provider` | Lightweight HTTP client for connecting to remote Engram instances. Works with any TypeScript project. |
272
-
273
- The npm package `@joshuaswarren/openclaw-engram` continues to work as the primary distribution channel for OpenClaw users. The `@engram/*` packages are for standalone use or custom integrations.
274
-
275
- ## Why Engram?
276
-
277
- ### Your data stays yours
278
-
279
- All memory lives on your filesystem as plain markdown files. No cloud dependency, no subscriptions, no proprietary formats, no sending your private conversations to third-party servers. Back it up with git, rsync, or Time Machine. Move it between machines with a folder copy. You own your data completely.
280
-
281
- ### A real upgrade from default OpenClaw memory
282
-
283
- OpenClaw's built-in memory is basic — it works for getting started, but lacks semantic search, entity tracking, lifecycle management, governance, and multi-agent isolation. Engram is a drop-in replacement that brings all of those capabilities while keeping the same local-first philosophy.
284
-
285
- ### Smart recall, not keyword search
286
-
287
- Engram uses hybrid search (BM25 + vector + reranking via [QMD](https://github.com/tobilu/qmd)) to find semantically relevant memories. It doesn't just match keywords — it understands what you're working on and surfaces the right context.
288
-
289
- ### Flexible LLM routing — OpenAI, local, or gateway model chain
290
-
291
- Use OpenAI for extraction and reranking, run entirely offline with a local LLM (Ollama, LM Studio), or route through the **gateway model chain** to use any provider with automatic fallback. The `local-llm-heavy` preset is optimized for fully local operation. See the [Local LLM Guide](docs/guides/local-llm.md) and the [Gateway Model Source](docs/config-reference.md#gateway-model-source) section for multi-provider setups.
292
-
293
- ### Progressive complexity
294
-
295
- Start with zero config. Enable features as your needs grow:
296
-
297
- | Level | What You Get |
298
- |-------|-------------|
299
- | **Defaults** | Automatic extraction, recall injection, entity tracking, lifecycle management |
300
- | **+ Search tuning** | Choose from 6 search backends (QMD, Orama, LanceDB, Meilisearch, remote, noop) |
301
- | **+ Capture control** | `implicit`, `explicit`, or `hybrid` capture modes for memory write policy |
302
- | **+ Memory OS** | Memory boxes, graph reasoning, compounding, shared context, identity continuity |
303
- | **+ LCM** | Lossless Context Management — never lose conversation context to compaction |
304
- | **+ Parallel retrieval** | Three specialized agents (DirectFact, Contextual, Temporal) run in parallel — same latency, broader coverage |
305
- | **+ Advanced** | Trust zones, causal trajectories, harmonic retrieval, evaluation harness, poisoning defense |
306
-
307
- Use a preset to jump to a recommended level: `conservative`, `balanced`, `research-max`, or `local-llm-heavy`.
308
-
309
- ### Works with your tools
310
-
311
- - **[OpenClaw](https://github.com/openclaw/openclaw)** — Native plugin with automatic extraction and recall injection
312
- - **[Codex CLI](https://github.com/openai/codex)** — MCP-over-HTTP with session-start hooks for automatic recall
313
- - **Any MCP client** — stdio or HTTP transport, 8 tools available
314
- - **Scripts & automation** — Authenticated REST API for custom integrations
315
- - **Local LLMs** — Run extraction and reranking with local models (Ollama, LM Studio, etc.)
316
-
317
- ### Standalone Multi-Tenant Server
318
-
319
- Run Engram as a standalone HTTP server that multiple agent harnesses share. Isolate tenants with namespace policies, feed conversations from any client via the observe endpoint, and search archived history with LCM full-text search. Works with OpenClaw, Codex CLI, Claude Code, and custom HTTP agents. See the [Standalone Server Guide](docs/guides/standalone-server.md).
320
-
321
- ### Built for production
322
-
323
- - **672 tests** with CI enforcement
324
- - **Evaluation harness** with benchmark packs, shadow recall recording, and CI delta gates
325
- - **Governance system** with review queues, shadow/apply modes, and reversible transitions
326
- - **Namespace isolation** for multi-agent deployments
327
- - **Rate limiting** on write paths with idempotency support
328
-
329
- ## Features
330
-
331
- ### Core
332
-
333
- - **Automatic memory extraction** — Facts, decisions, preferences, corrections extracted from conversations
334
- - **Observe endpoint** — Feed conversation messages from any agent into the extraction pipeline via HTTP or MCP
335
- - **Recall injection** — Relevant memories injected before each agent turn
336
- - **Entity tracking** — People, projects, tools, companies tracked as structured entities
337
- - **Lifecycle management** — Memories age through active, validated, stale, archived states
338
- - **Episode/Note model** — Memories classified as time-specific events or stable beliefs
339
-
340
- ### Search Backends
341
-
342
- | Backend | Type | Best For |
343
- |---------|------|----------|
344
- | **QMD** (default) | Hybrid BM25+vector+reranking | Best recall quality |
345
- | **Orama** | Embedded, pure JS | Zero native deps |
346
- | **LanceDB** | Embedded, native Arrow | Large collections |
347
- | **Meilisearch** | Server-based | Shared search |
348
- | **Remote** | HTTP REST | Custom services |
349
- | **Noop** | No-op | Extraction only |
350
-
351
- See the [Search Backends Guide](docs/search-backends.md) or [write your own](docs/writing-a-search-backend.md).
352
-
353
- ### Memory OS (opt-in)
354
-
355
- These capabilities can be enabled progressively:
356
-
357
- - **Memory Boxes** — Groups related memories into topic-windowed episodes
358
- - **Graph Recall** — Entity-relationship graph for causal and timeline queries
359
- - **Compounding** — Weekly synthesis surfaces patterns and recurring mistakes
360
- - **Shared Context** — Cross-agent memory sharing for multi-agent setups
361
- - **Identity Continuity** — Consistent agent personality across sessions
362
- - **Hot/Cold Tiering** — Automatic migration of aging memories to cold storage
363
- - **Memory Cache** — Process-level singleton cache for `readAllMemories()` — turns 15s disk scans into <100ms cache hits, shared across all sessions
364
- - **Semantic Consolidation** — Finds clusters of semantically similar memories, synthesizes canonical versions via LLM, archives originals to reduce bloat
365
- - **Native Knowledge** — Search curated markdown (workspace docs, Obsidian vaults) without extracting into memory
366
- - **Behavior Loop Tuning** — Runtime self-tuning of extraction and recall parameters
367
-
368
- ### Lossless Context Management (LCM)
369
-
370
- When your AI agent hits its context window limit, the runtime silently compresses old messages — and that context is gone forever. LCM fixes this by proactively archiving every message into a local SQLite database and building a hierarchical summary DAG (directed acyclic graph) alongside it. When context gets compacted, LCM injects compressed session history back into recall, so your agent never loses track of what happened earlier in the conversation.
371
-
372
- - **Proactive archiving** — Every message is indexed with full-text search before compaction can discard it
373
- - **Hierarchical summaries** — Leaf summaries cover ~8 turns, depth-1 covers ~32, depth-2 ~128, etc.
374
- - **Fresh tail protection** — Recent turns always use the most detailed (leaf-level) summaries
375
- - **Three-level summarization** — Normal LLM summary, aggressive bullet compression, and deterministic truncation (guaranteed convergence, no LLM needed)
376
- - **MCP expansion tools** — Agents can search, describe, or expand any part of conversation history on demand
377
- - **Zero data loss** — Raw messages are retained for the configured retention period (default 90 days)
378
-
379
- Enable it in your `openclaw.json`:
380
-
381
- ```jsonc
382
- {
383
- "plugins": {
384
- "entries": {
385
- "openclaw-engram": {
386
- "config": {
387
- "lcmEnabled": true
388
- // All other LCM settings have sensible defaults
389
- }
390
- }
391
- }
392
- }
393
- }
394
- ```
395
-
396
- See the [LCM Guide](docs/guides/lossless-context-management.md) for architecture details, configuration options, and how it complements native compaction.
397
-
398
- ### Parallel Specialized Retrieval (opt-in)
399
-
400
- Engram's default retrieval runs a single hybrid search pass. Parallel Specialized Retrieval (inspired by [Supermemory's ASMR technique](https://blog.supermemory.ai/we-broke-the-frontier-in-agent-memory-introducing-99-sota-memory-system/)) runs three specialized agents in parallel so total latency equals `max(agents)` not `sum(agents)`.
401
-
402
- | Agent | What It Does | Cost |
403
- |-------|-------------|------|
404
- | **DirectFact** | Scans entity filenames for keyword overlap with the query | File I/O only, <5ms |
405
- | **Contextual** | Existing hybrid BM25+vector search (unchanged) | Same as current |
406
- | **Temporal** | Reads the temporal date index, returns recent memories with recency decay scoring | File I/O + math, <10ms |
407
-
408
- **Zero additional LLM cost.** The DirectFact and Temporal agents reuse existing indexes with no new embeddings or inference. The Contextual agent is the same hybrid search already running.
409
-
410
- Results from all three agents are merged by path, deduplicated, and weighted (`direct=1.0×, temporal=0.85×, contextual=0.7×`) before returning the top N results. Any agent error degrades gracefully without blocking the others.
411
-
412
- Enable it in your `openclaw.json`:
413
-
414
- ```jsonc
415
- {
416
- "plugins": {
417
- "entries": {
418
- "openclaw-engram": {
419
- "config": {
420
- "parallelRetrievalEnabled": true
421
- // Optional tuning:
422
- // "parallelMaxResultsPerAgent": 20,
423
- // "parallelAgentWeights": { "direct": 1.0, "contextual": 0.7, "temporal": 0.85 }
424
- }
425
- }
426
- }
427
- }
428
- }
429
- ```
430
-
431
- Set `parallelMaxResultsPerAgent: 0` to disable an individual agent's results without disabling the feature entirely.
432
-
433
- ### Semantic Consolidation (opt-in)
434
-
435
- Over time, memory stores accumulate redundant facts — the same information extracted multiple times across sessions, expressed slightly differently. Semantic consolidation finds clusters of similar memories using token overlap, synthesizes a single canonical version via LLM, and archives the originals. This reduces storage bloat, speeds up recall, and improves memory quality.
436
-
437
- - **Conservative by default** — Only merges when 80%+ token overlap is detected across 3+ memories
438
- - **LLM synthesis** — Uses your configured model to combine unique information from all cluster members
439
- - **Safe archival** — Originals are archived (not deleted) with full provenance tracking
440
- - **Configurable** — Adjust threshold, cluster size, excluded categories, model, and schedule
441
- - **Excluded categories** — Corrections and commitments are never consolidated (configurable)
442
-
443
- Enable it in your `openclaw.json`:
444
-
445
- ```jsonc
446
- {
447
- "plugins": {
448
- "entries": {
449
- "openclaw-engram": {
450
- "config": {
451
- "semanticConsolidationEnabled": true
452
- // Optional tuning:
453
- // "semanticConsolidationThreshold": 0.8, // 0.8=conservative, 0.6=aggressive
454
- // "semanticConsolidationModel": "fast", // "auto", "fast", or specific model
455
- // "semanticConsolidationIntervalHours": 168, // weekly (default)
456
- // "semanticConsolidationMaxPerRun": 100
457
- }
458
- }
459
- }
460
- }
461
- }
462
- ```
463
-
464
- Run manually from the CLI:
465
-
466
- ```bash
467
- openclaw engram semantic-consolidate --dry-run # Preview what would be merged
468
- openclaw engram semantic-consolidate --verbose # Run with detailed output
469
- openclaw engram semantic-consolidate --threshold 0.6 # Override threshold
470
- ```
471
-
472
- ### Advanced (opt-in)
473
-
474
- - **Objective-State Recall** — Surfaces file/process/tool state snapshots alongside semantic memory
475
- - **Causal Trajectories** — Typed `goal -> action -> observation -> outcome` chains
476
- - **Trust Zones** — Quarantine/working/trusted tiers with promotion rules and poisoning defense
477
- - **Harmonic Retrieval** — Blends abstraction nodes with cue-anchor matches
478
- - **Verified Recall** — Only surfaces memory boxes whose source memories still verify
479
- - **Semantic Rule Promotion** — Promotes `IF ... THEN` rules from verified episodes
480
- - **Creation Memory** — Work-product ledger tracking agent outputs
481
- - **Commitment Lifecycle** — Tracks promises, deadlines, and obligations
482
- - **Resume Bundles** — Crash-recovery context for interrupted sessions
483
- - **Utility Learning** — Learns promotion/ranking weights from downstream outcomes
484
-
485
- See [Enable All Features](docs/enable-all-v8.md) for a full-feature config profile.
486
-
487
- ## Access Layer
488
-
489
- Engram exposes one shared service layer through multiple transports:
490
-
491
- ### HTTP API
492
-
493
- ```bash
494
- openclaw engram access http-serve --token "$OPENCLAW_ENGRAM_ACCESS_TOKEN"
495
- ```
496
-
497
- Key endpoints: `GET /engram/v1/health`, `POST /engram/v1/recall`, `POST /engram/v1/memories`, `GET /engram/v1/entities/:name`, and more. Full reference in [API docs](docs/api.md).
498
-
499
- The HTTP server also hosts a lightweight operator UI at `http://127.0.0.1:4318/engram/ui/` for memory browsing, recall inspection, governance review, trust-zone promotion, and entity exploration.
500
-
501
- ### MCP Tools
502
-
503
- Available via both stdio and HTTP transports:
504
-
505
- | Tool | Purpose |
506
- |------|---------|
507
- | `engram.recall` | Retrieve relevant memories for a query |
508
- | `engram.recall_explain` | Debug the last recall |
509
- | `engram.day_summary` | Generate structured end-of-day summary from memory content |
510
- | `engram.memory_get` | Fetch a specific memory by ID |
511
- | `engram.memory_timeline` | View a memory's lifecycle history |
512
- | `engram.memory_store` | Store a new memory |
513
- | `engram.suggestion_submit` | Queue a memory for review |
514
- | `engram.entity_get` | Look up a known entity |
515
- | `engram.review_queue_list` | View the governance review queue |
516
- | `engram.observe` | Feed conversation messages into memory pipeline (LCM + extraction) |
517
- | `engram.lcm_search` | Full-text search over LCM-archived conversations |
518
- | `engram_context_search` | Full-text search across all archived conversation history (LCM) |
519
- | `engram_context_describe` | Get a compressed summary of a turn range (LCM) |
520
- | `engram_context_expand` | Retrieve raw lossless messages for a turn range (LCM) |
521
-
522
- ### MCP over HTTP
523
-
524
- The HTTP server exposes an MCP JSON-RPC endpoint at `POST /mcp`, allowing remote MCP clients to use Engram tools over HTTP:
525
-
526
- ```bash
527
- openclaw engram access http-serve --host 0.0.0.0 --port 4318 --token "$TOKEN"
528
- ```
529
-
530
- For namespace-enabled deployments, pass `--principal <name>` where `<name>` matches a `writePrincipals` entry for your target namespace. Deployments with `namespacesEnabled: false` (the default) do not need `--principal`.
531
-
532
- ## CLI Reference
533
-
534
- ```bash
535
- # Setup & diagnostics
536
- openclaw engram setup # Guided first-run setup
537
- openclaw engram doctor # Health diagnostics with remediation hints
538
- openclaw engram config-review # Config tuning recommendations
539
- openclaw engram stats # Memory counts, search status
540
- openclaw engram inventory # Full storage and namespace inventory
541
-
542
- # Search & recall
543
- openclaw engram search "query" # Search memories from CLI
544
- openclaw engram harmonic-search "query" # Preview harmonic retrieval matches
545
-
546
- # Governance
547
- openclaw engram governance-run --mode shadow # Preview governance transitions
548
- openclaw engram governance-run --mode apply # Apply reversible transitions
549
- openclaw engram review-disposition <id> --status rejected # Operator review
550
-
551
- # Benchmarking
552
- openclaw engram benchmark recall # Benchmark status and validation
553
- openclaw engram benchmark-ci-gate # CI gate for regressions
554
-
555
- # Memory maintenance
556
- openclaw engram consolidate # Run standard consolidation
557
- openclaw engram semantic-consolidate # Run semantic dedup consolidation
558
- openclaw engram semantic-consolidate --dry-run # Preview without changes
559
-
560
- # Access layer
561
- openclaw engram access http-serve --token "$TOKEN" # Start HTTP API
562
- openclaw engram access mcp-serve # Start stdio MCP server
563
-
564
- # Trust-zone demos
565
- openclaw engram trust-zone-demo-seed --dry-run # Preview the opt-in buyer demo dataset
566
- openclaw engram trust-zone-demo-seed # Explicitly seed the demo dataset
567
- openclaw engram trust-zone-promote --record-id <id> --target-zone working --reason "Operator review"
568
- ```
569
-
570
- ### Trust-zone demo workflow
571
-
572
- Trust zones now ship with a dedicated admin-console view plus an explicit demo seeding path for buyer-facing walkthroughs.
573
-
574
- - **Never automatic** — Engram does not seed sample trust-zone records on install, startup, or feature enablement.
575
- - **Explicit only** — demo records appear only after you run `openclaw engram trust-zone-demo-seed` or trigger the matching admin-console action.
576
- - **Buyer-friendly story** — the trust-zone view surfaces provenance strength, promotion readiness, corroboration requirements, and operator promotion actions in one place.
577
-
578
- The seeded scenario is `enterprise-buyer-v1`, which creates a small, opinionated dataset covering:
579
-
580
- - quarantine records that are ready for review
581
- - working records that are blocked on missing provenance
582
- - working records that still need corroboration
583
- - working records with independent corroboration support
584
- - a trusted operator policy record
585
-
586
- See the [full CLI reference](docs/api.md#cli-commands) for all commands.
587
-
588
- ## Configuration
589
-
590
- All settings live in `openclaw.json` under `plugins.entries.openclaw-engram.config`. The table below shows the most commonly changed settings — Engram has **60+ configuration options** covering search backends, capture modes, memory OS features, namespaces, governance, benchmarking, and more.
591
-
592
- | Setting | Default | Description |
593
- |---------|---------|-------------|
594
- | `openaiApiKey` | `(env)` | OpenAI API key (optional when using a local LLM) |
595
- | `localLlmEnabled` | `false` | Enable Engram's local LLM path when `modelSource` is `plugin` |
596
- | `localLlmUrl` | unset | Local LLM endpoint (e.g., `http://localhost:1234/v1`) |
597
- | `localLlmModel` | unset | Local model name (e.g., `qwen2.5-32b-instruct`) |
598
- | `model` | `gpt-5.2` | OpenAI model for extraction when `modelSource` is `plugin` and local LLM is disabled |
599
- | `searchBackend` | `"qmd"` | Search engine: `qmd`, `orama`, `lancedb`, `meilisearch`, `remote`, `noop` |
600
- | `captureMode` | `implicit` | Memory write policy: `implicit`, `explicit`, `hybrid` |
601
- | `recallBudgetChars` | `maxMemoryTokens * 4` | Recall budget (default ~8K chars; set 64K+ for large-context models) |
602
- | `memoryDir` | `~/.openclaw/workspace/memory/local` | Memory storage root |
603
- | `memoryOsPreset` | unset | Quick config: `conservative`, `balanced`, `research-max`, `local-llm-heavy` |
604
- | `lcmEnabled` | `false` | Enable Lossless Context Management (proactive session archive + summary DAG) |
605
- | `semanticConsolidationEnabled` | `false` | Enable periodic semantic dedup of similar memories |
606
- | `semanticConsolidationThreshold` | `0.8` | Token overlap threshold (0.8=conservative, 0.6=aggressive) |
607
- | `semanticConsolidationModel` | `"auto"` | LLM for synthesis: `"auto"`, `"fast"`, or specific model |
608
-
609
- **[See the full config reference for all 60+ settings](docs/config-reference.md)** including search backend configuration, namespace policies, Memory OS features, governance, evaluation harness, trust zones, causal trajectories, and more.
610
-
611
- ## Documentation
612
-
613
- - [Getting Started](docs/getting-started.md) — Installation, setup, first-run verification
614
- - [Config Reference](docs/config-reference.md) — Every setting with defaults
615
- - [Architecture Overview](docs/architecture/overview.md) — System design and storage layout
616
- - [Retrieval Pipeline](docs/architecture/retrieval-pipeline.md) — How recall works
617
- - [Memory Lifecycle](docs/architecture/memory-lifecycle.md) — Write, consolidation, expiry
618
- - [Search Backends](docs/search-backends.md) — Choosing and configuring search engines
619
- - [Writing a Search Backend](docs/writing-a-search-backend.md) — Build your own adapter
620
- - [API Reference](docs/api.md) — HTTP, MCP, and CLI documentation
621
- - [Codex CLI Integration](docs/guides/codex-cli.md) — Setup Engram with OpenAI's Codex
622
- - [Standalone Server Guide](docs/guides/standalone-server.md) — Multi-tenant HTTP server for multiple agent harnesses
623
- - [Local LLM Guide](docs/guides/local-llm.md) — Local-first extraction and reranking
624
- - [Cost Control Guide](docs/guides/cost-control.md) — Budget mappings and presets
625
- - [Namespaces](docs/namespaces.md) — Multi-agent memory isolation
626
- - [Shared Context](docs/shared-context.md) — Cross-agent intelligence
627
- - [Identity Continuity](docs/identity-continuity.md) — Consistent agent personality
628
- - [Graph Reasoning](docs/architecture/graph-reasoning.md) — Opt-in graph traversal
629
- - [Evaluation Harness](docs/evaluation-harness.md) — Benchmarks and CI delta gates
630
- - [Operations](docs/operations.md) — Backup, export, maintenance
631
- - [Lossless Context Management](docs/guides/lossless-context-management.md) — Never lose context to compaction
632
- - [Enable All Features](docs/enable-all-v8.md) — Full-feature config profile
633
- - [Migration Guide](docs/guides/migrations.md) — Upgrading from older versions
634
- - [Platform Migration Guide](docs/guides/platform-migration.md) — Migrating to the monorepo architecture (v9.1.36+)
635
- - [Hermes Setup](docs/integration/hermes-setup.md) — HTTP client for remote Engram instances
636
- - [Deployment Topologies](docs/integration/deployment-topologies.md) — Localhost, LAN, remote, containerized, standalone
637
-
638
- ## Contributing
639
-
640
- Contributions are welcome! Please:
641
-
642
- 1. Fork the repository
643
- 2. Create a feature branch (`git checkout -b feat/my-feature`)
644
- 3. Write tests for new functionality
645
- 4. Ensure `npm test` (672 tests) and `npm run check-types` pass
646
- 5. Submit a pull request
647
-
648
- ## Sponsorship
649
-
650
- If Engram is useful to you, consider [sponsoring the project](https://github.com/sponsors/joshuaswarren). Sponsorship helps fund continued development, new integrations, and keeping Engram free and open source.
651
-
652
- [![Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-pink?style=for-the-badge)](https://github.com/sponsors/joshuaswarren)
653
-
654
- ## License
655
-
656
- [MIT](LICENSE)