@cognee/cognee-openclaw 2026.2.4 → 2026.3.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 CHANGED
@@ -1,13 +1,32 @@
1
1
  # @cognee/cognee-openclaw
2
2
 
3
- OpenClaw plugin that adds Cognee-backed memory with automatic recall and indexing.
3
+ OpenClaw plugin that adds Cognee-backed memory with **multi-scope support** (company/user/agent), session tracking, and automatic recall.
4
4
 
5
5
  ## Features
6
6
 
7
- - **Auto-recall**: Before each agent run, searches Cognee for relevant memories and injects them as context
8
- - **Auto-index**: On startup and after each agent run, syncs memory markdown files to Cognee (add new, update changed, skip unchanged)
9
- - **CLI commands**: `openclaw cognee index` to manually sync, `openclaw cognee status` to check state
10
- - **Configurable**: Search type, max results, score filtering, token limits, and more
7
+ - **Multi-scope memory**: Separate datasets for company-wide knowledge, per-user preferences, and per-agent context
8
+ - **Scope-aware routing**: Memory files are automatically routed to the correct dataset based on directory structure
9
+ - **Multi-scope recall**: Before each agent run, searches across all configured scopes and injects labeled context
10
+ - **Session tracking**: Multi-turn conversation context via Cognee's session system
11
+ - **14 search types**: From simple semantic search (CHUNKS) to chain-of-thought graph reasoning (GRAPH_COMPLETION_COT) to auto-selection (FEELING_LUCKY)
12
+ - **Health check**: Verifies Cognee API connectivity before operations
13
+ - **Auto-index**: Syncs memory markdown files to Cognee (add new, update changed, delete removed, skip unchanged)
14
+ - **Memify support**: Optional graph enrichment after cognify for better entity consolidation
15
+ - **One-command setup**: `openclaw cognee setup` configures Cognee as the sole memory provider
16
+ - **CLI commands**: `openclaw cognee setup`, `openclaw cognee index`, `openclaw cognee status`, `openclaw cognee health`, `openclaw cognee scopes`
17
+
18
+ ## Security: Recommended Plugin Allowlist
19
+
20
+ OpenClaw will auto-load any plugin it discovers if `plugins.allow` is not set. To restrict which plugins can load, add an explicit allowlist to your `~/.openclaw/openclaw.json`:
21
+
22
+ ```yaml
23
+ plugins:
24
+ allow:
25
+ - cognee-openclaw
26
+ - cognee-openclaw-skills
27
+ ```
28
+
29
+ Without this, any plugin found in your environment could be loaded automatically.
11
30
 
12
31
  ## Installation
13
32
 
@@ -23,76 +42,226 @@ openclaw plugins install -l .
23
42
  Or once published:
24
43
 
25
44
  ```bash
26
- openclaw plugins install @cognee/cognee-openclaw
45
+ # Pin to an exact version to avoid unintended updates (supply-chain best practice)
46
+ openclaw plugins install @cognee/cognee-openclaw@2026.3.0
27
47
  ```
28
48
 
29
- ## Configuration
49
+ ## Quick Start
50
+
51
+ After installing, run the setup command to configure Cognee as the memory provider:
30
52
 
31
- Enable the plugin in your OpenClaw config (`~/.openclaw/config.yaml` or project config):
53
+ ```bash
54
+ # Cognee only (replaces built-in memory)
55
+ openclaw cognee setup
56
+
57
+ # Or keep built-in memory alongside Cognee
58
+ openclaw cognee setup --hybrid
59
+ ```
60
+
61
+ **Default mode** disables built-in memory providers — all recall comes from Cognee.
62
+
63
+ **Hybrid mode** keeps `memory-core` enabled — the agent uses both Cognee recall and built-in memory search.
64
+
65
+ Then optionally configure the Cognee connection in `~/.openclaw/openclaw.json`:
32
66
 
33
67
  ```yaml
34
68
  plugins:
35
69
  entries:
36
- memory-cognee:
70
+ cognee-openclaw:
37
71
  enabled: true
38
72
  config:
39
73
  baseUrl: "http://localhost:8000"
40
74
  apiKey: "${COGNEE_API_KEY}"
41
75
  datasetName: "my-project"
42
- searchType: "GRAPH_COMPLETION"
43
- maxResults: 6
44
- autoRecall: true
45
- autoIndex: true
46
76
  ```
47
77
 
48
- Set your API key in the environment:
78
+ ## Multi-Scope Memory
49
79
 
50
- ```bash
51
- export COGNEE_API_KEY="your-key-here"
80
+ For production use, enable multi-scope mode by setting any scope-specific dataset name:
81
+
82
+ ```yaml
83
+ plugins:
84
+ entries:
85
+ cognee-openclaw:
86
+ enabled: true
87
+ config:
88
+ baseUrl: "http://localhost:8000"
89
+ apiKey: "${COGNEE_API_KEY}"
90
+
91
+ # Multi-scope datasets
92
+ companyDataset: "acme-shared"
93
+ userDatasetPrefix: "acme-user"
94
+ agentDatasetPrefix: "acme-agent"
95
+ userId: "${OPENCLAW_USER_ID}"
96
+ agentId: "code-assistant"
97
+
98
+ # Search all scopes during recall (in priority order)
99
+ recallScopes:
100
+ - agent
101
+ - user
102
+ - company
103
+
104
+ # Default scope for files not matching any route
105
+ defaultWriteScope: "agent"
106
+ ```
107
+
108
+ ### Memory Scope Hierarchy
109
+
110
+ | Scope | Dataset | Purpose | Example Files |
111
+ |-------|---------|---------|---------------|
112
+ | **Company** | `acme-shared` | Shared knowledge across all users/agents | `memory/company/policies.md`, `memory/company/domain-glossary.md` |
113
+ | **User** | `acme-user-alice` | Per-user preferences, feedback, corrections | `memory/user/preferences.md`, `memory/user/feedback.md` |
114
+ | **Agent** | `acme-agent-code-assistant` | Per-agent learned behaviors, tool outputs | `memory/tools.md`, `MEMORY.md` |
115
+
116
+ ### Scope Routing
117
+
118
+ Files are routed to scopes based on their path. Default routing rules:
119
+
120
+ ```
121
+ memory/company/** -> company scope
122
+ memory/user/** -> user scope
123
+ memory/** -> agent scope (catch-all)
124
+ MEMORY.md -> agent scope
125
+ ```
126
+
127
+ Custom routing via config:
128
+
129
+ ```yaml
130
+ scopeRouting:
131
+ - pattern: "memory/shared/**"
132
+ scope: company
133
+ - pattern: "memory/personal/**"
134
+ scope: user
135
+ - pattern: "memory/**"
136
+ scope: agent
137
+ ```
138
+
139
+ ### Multi-Scope Recall
140
+
141
+ During recall, the plugin searches each scope independently and injects labeled results:
142
+
143
+ ```xml
144
+ <cognee_memories>
145
+ <agent_memory>[agent-specific results]</agent_memory>
146
+ <user_memory>[user preference results]</user_memory>
147
+ <company_memory>[shared knowledge results]</company_memory>
148
+ </cognee_memories>
52
149
  ```
53
150
 
151
+ This lets the agent distinguish between personal context, shared knowledge, and its own learned patterns.
152
+
54
153
  ## Configuration Options
55
154
 
155
+ ### Connection
156
+
56
157
  | Option | Type | Default | Description |
57
158
  |--------|------|---------|-------------|
58
159
  | `baseUrl` | string | `http://localhost:8000` | Cognee API base URL |
59
160
  | `apiKey` | string | `$COGNEE_API_KEY` | API key for authentication |
60
- | `datasetName` | string | `openclaw` | Dataset name for storing memories |
61
- | `searchType` | string | `GRAPH_COMPLETION` | Search mode: `GRAPH_COMPLETION`, `CHUNKS`, `SUMMARIES` |
62
- | `maxResults` | number | `6` | Max memories to inject per recall |
63
- | `minScore` | number | `0` | Minimum relevance score filter |
64
- | `maxTokens` | number | `512` | Token cap for recall context |
161
+
162
+ ### Memory Scopes
163
+
164
+ | Option | Type | Default | Description |
165
+ |--------|------|---------|-------------|
166
+ | `companyDataset` | string | — | Dataset for company-wide memory. Setting this enables multi-scope mode |
167
+ | `userDatasetPrefix` | string | — | Prefix for user datasets (becomes `{prefix}-{userId}`) |
168
+ | `agentDatasetPrefix` | string | — | Prefix for agent datasets (becomes `{prefix}-{agentId}`) |
169
+ | `userId` | string | `$OPENCLAW_USER_ID` | User identifier for user-scoped memory |
170
+ | `agentId` | string | `default` | Agent identifier for agent-scoped memory |
171
+ | `recallScopes` | string[] | `["agent","user","company"]` | Scopes to search during recall, in priority order |
172
+ | `defaultWriteScope` | string | `agent` | Default scope for files not matching any route |
173
+ | `scopeRouting` | object[] | (see above) | Path-to-scope routing rules |
174
+
175
+ ### Sessions
176
+
177
+ | Option | Type | Default | Description |
178
+ |--------|------|---------|-------------|
179
+ | `enableSessions` | boolean | `true` | Enable session-based conversation tracking |
180
+ | `persistSessionsAfterEnd` | boolean | `true` | Persist session Q&A into the knowledge graph |
181
+
182
+ ### Search
183
+
184
+ | Option | Type | Default | Description |
185
+ |--------|------|---------|-------------|
186
+ | `searchType` | string | `GRAPH_COMPLETION` | Search strategy (see below) |
187
+ | `maxResults` | number | `3` | Max memories to inject per scope |
188
+ | `minScore` | number | `0.3` | Minimum relevance score filter |
189
+ | `maxTokens` | number | `512` | Token cap for recall context per scope |
190
+ | `searchPrompt` | string | `""` | System prompt to guide search |
191
+
192
+ ### Search Types
193
+
194
+ | Type | Description |
195
+ |------|-------------|
196
+ | `GRAPH_COMPLETION` | **Default** — graph traversal + LLM reasoning |
197
+ | `CHUNKS` | Semantic vector search, returns raw stored text (no generation) |
198
+ | `FEELING_LUCKY` | Auto-selects a strategy per query (may pick generative modes) |
199
+ | `GRAPH_COMPLETION_COT` | Chain-of-thought reasoning over graph (iterative) |
200
+ | `GRAPH_COMPLETION_CONTEXT_EXTENSION` | Extended context retrieval (multiple rounds) |
201
+ | `GRAPH_SUMMARY_COMPLETION` | Graph with pre-computed summaries |
202
+ | `RAG_COMPLETION` | Traditional RAG with document chunks |
203
+ | `TRIPLET_COMPLETION` | Subject-predicate-object search |
204
+ | `CHUNKS` | Pure semantic vector search |
205
+ | `CHUNKS_LEXICAL` | Keyword/lexical search |
206
+ | `SUMMARIES` | Pre-computed hierarchical summaries |
207
+ | `TEMPORAL` | Time-aware graph search |
208
+ | `NATURAL_LANGUAGE` | Natural language to graph query |
209
+ | `CYPHER` | Direct graph database queries |
210
+ | `CODING_RULES` | Code-specific rule search |
211
+
212
+ ### Automation
213
+
214
+ | Option | Type | Default | Description |
215
+ |--------|------|---------|-------------|
65
216
  | `autoRecall` | boolean | `true` | Inject memories before agent runs |
66
217
  | `autoIndex` | boolean | `true` | Sync memory files on startup and after agent runs |
67
218
  | `autoCognify` | boolean | `true` | Run cognify after new memories are added |
68
- | `requestTimeoutMs` | number | `60000` | HTTP timeout for Cognee requests |
219
+ | `autoMemify` | boolean | `false` | Run memify (graph enrichment) after cognify |
220
+ | `deleteMode` | string | `soft` | `soft` removes raw data, `hard` also removes graph nodes |
69
221
 
70
- ## How It Works
222
+ ### Timeouts
71
223
 
72
- 1. **On startup**: Scans `memory/` directory for markdown files and syncs to Cognee (add new, update changed, skip unchanged)
73
- 2. **Before agent start**: Searches Cognee for memories relevant to the prompt and prepends as `<cognee_memories>` context
74
- 3. **After agent end**: Re-scans memory files and syncs any changes the agent made
75
- 4. **State tracking**:
76
- - `~/.openclaw/memory/cognee/datasets.json` — dataset ID mapping
77
- - `~/.openclaw/memory/cognee/sync-index.json` — per-file hash and Cognee data IDs
78
-
79
- Memory files detected at: `MEMORY.md`, `memory.md`, or `memory/*.md`
224
+ | Option | Type | Default | Description |
225
+ |--------|------|---------|-------------|
226
+ | `requestTimeoutMs` | number | `60000` | HTTP timeout for Cognee requests |
227
+ | `ingestionTimeoutMs` | number | `300000` | HTTP timeout for add/update requests |
80
228
 
81
229
  ## CLI Commands
82
230
 
83
231
  ```bash
232
+ # Configure Cognee as the memory provider (run once after install)
233
+ openclaw cognee setup # Cognee only
234
+ openclaw cognee setup --hybrid # Cognee + built-in memory
235
+
84
236
  # Manually sync memory files to Cognee
85
237
  openclaw cognee index
86
238
 
87
- # Check sync status (indexed files, pending changes)
239
+ # Check sync status (files indexed, dataset info, per-scope breakdown)
88
240
  openclaw cognee status
241
+
242
+ # Verify Cognee API connectivity
243
+ openclaw cognee health
244
+
245
+ # Show memory scope routing for current workspace files
246
+ openclaw cognee scopes
89
247
  ```
90
248
 
249
+ ## How It Works
250
+
251
+ 1. **On startup**: Health check, then scan `memory/` directory and sync files to scope-specific Cognee datasets
252
+ 2. **Before agent start**: Search each configured scope in parallel, merge results with scope labels, inject as `<cognee_memories>` context
253
+ 3. **After agent end**: Re-scan memory files and sync any changes (including deletions) to the correct scope datasets
254
+ 4. **State tracking**:
255
+ - `~/.openclaw/memory/cognee/datasets.json` — dataset ID mapping
256
+ - `~/.openclaw/memory/cognee/scoped-sync-indexes.json` — per-scope file hashes and data IDs
257
+ - `~/.openclaw/memory/cognee/sync-index.json` — legacy single-scope index
258
+
259
+ Memory files detected at: `MEMORY.md` and `memory/**/*.md` (recursive)
260
+
91
261
  ## Development
92
262
 
93
263
  ```bash
94
264
  cd integrations/openclaw
95
- # Build once, then link for local development with an OpenClaw project
96
265
  npm install
97
266
  npm run build
98
267
  openclaw plugins install -l .
@@ -103,3 +272,9 @@ For live rebuilds during development:
103
272
  ```bash
104
273
  npm run dev
105
274
  ```
275
+
276
+ ## Testing
277
+
278
+ ```bash
279
+ npm test
280
+ ```
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
2
- declare const memoryCogneePlugin: {
3
- id: string;
4
- name: string;
5
- description: string;
6
- kind: "memory";
7
- register(api: OpenClawPluginApi): void;
8
- };
9
- export default memoryCogneePlugin;
1
+ export { default } from "./src/plugin.js";
2
+ export { CogneeHttpClient } from "./src/client.js";
3
+ export { syncFiles, syncFilesScoped } from "./src/sync.js";
4
+ export { matchGlob, routeFileToScope, datasetNameForScope, isMultiScopeEnabled } from "./src/scope.js";
5
+ export { resolveConfig } from "./src/config.js";
6
+ export { collectMemoryFiles, hashText } from "./src/files.js";
7
+ export { loadDatasetState, saveDatasetState, loadSyncIndex, saveSyncIndex, loadScopedSyncIndexes, saveScopedSyncIndexes, migrateLegacyIndex, } from "./src/persistence.js";
8
+ export type { CogneeDeleteMode, CogneePluginConfig, CogneeSearchType, CogneeSearchResult, MemoryFile, MemoryScope, ScopeRoute, ScopedSyncIndexes, SyncIndex, SyncResult, } from "./src/types.js";