@hbarefoot/engram 1.0.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.
- package/LICENSE +21 -0
- package/README.md +535 -0
- package/bin/engram.js +421 -0
- package/dashboard/dist/assets/index-BHkLa5w_.css +1 -0
- package/dashboard/dist/assets/index-D9QR_Cnu.js +45 -0
- package/dashboard/dist/index.html +14 -0
- package/dashboard/package.json +21 -0
- package/package.json +76 -0
- package/src/config/index.js +150 -0
- package/src/embed/index.js +249 -0
- package/src/export/static.js +396 -0
- package/src/extract/rules.js +233 -0
- package/src/extract/secrets.js +114 -0
- package/src/index.js +54 -0
- package/src/memory/consolidate.js +420 -0
- package/src/memory/context.js +346 -0
- package/src/memory/feedback.js +197 -0
- package/src/memory/recall.js +350 -0
- package/src/memory/store.js +626 -0
- package/src/server/mcp.js +668 -0
- package/src/server/rest.js +499 -0
- package/src/utils/id.js +9 -0
- package/src/utils/logger.js +79 -0
- package/src/utils/time.js +296 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Engram Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
# Engram
|
|
2
|
+
|
|
3
|
+
> **Persistent memory for AI agents - SQLite for agent state**
|
|
4
|
+
|
|
5
|
+
Engram is a production-ready memory system that gives AI agents persistent, searchable memory across conversations. Think of it as SQLite for agent state - simple, fast, and reliable.
|
|
6
|
+
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- ๐ง **Hybrid Memory Retrieval** - Combines semantic similarity, recency, confidence, and access patterns
|
|
13
|
+
- ๐ **Full-Text Search** - SQLite FTS5 for fast keyword search
|
|
14
|
+
- ๐ฏ **Vector Embeddings** - Local embeddings with Xenova/all-MiniLM-L6-v2 (~23MB)
|
|
15
|
+
- ๐ **Secret Detection** - Automatic detection and redaction of API keys and credentials
|
|
16
|
+
- ๐งน **Auto-Consolidation** - Duplicate detection, contradiction flagging, confidence decay
|
|
17
|
+
- ๐ **Web Dashboard** - Modern React UI for visualizing and managing memories
|
|
18
|
+
- ๐ **MCP Server** - Model Context Protocol integration for Claude Desktop/Code
|
|
19
|
+
- ๐ **REST API** - Full-featured HTTP API with CORS support
|
|
20
|
+
- ๐ฆ **Zero Config** - Works out of the box with sensible defaults
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Clone the repository
|
|
28
|
+
git clone https://github.com/your-username/engram.git
|
|
29
|
+
cd engram
|
|
30
|
+
|
|
31
|
+
# Install dependencies
|
|
32
|
+
npm install
|
|
33
|
+
|
|
34
|
+
# Start the server
|
|
35
|
+
npm start
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The REST API will be available at `http://localhost:3838` and the dashboard at `http://localhost:5173`.
|
|
39
|
+
|
|
40
|
+
### Basic Usage
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Store a memory
|
|
44
|
+
engram remember "User prefers Fastify over Express for APIs" --category preference
|
|
45
|
+
|
|
46
|
+
# Search for memories
|
|
47
|
+
engram recall "What framework does the user prefer?"
|
|
48
|
+
|
|
49
|
+
# List all memories
|
|
50
|
+
engram list
|
|
51
|
+
|
|
52
|
+
# Check system status
|
|
53
|
+
engram status
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage Modes
|
|
57
|
+
|
|
58
|
+
### 1. CLI (Command Line Interface)
|
|
59
|
+
|
|
60
|
+
Perfect for quick interactions and scripting:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Remember something
|
|
64
|
+
node bin/engram.js remember "Project uses PostgreSQL 15" --category fact --entity postgresql
|
|
65
|
+
|
|
66
|
+
# Search with options
|
|
67
|
+
node bin/engram.js recall "database" --limit 3 --threshold 0.5
|
|
68
|
+
|
|
69
|
+
# Filter by namespace
|
|
70
|
+
node bin/engram.js list --namespace project-alpha
|
|
71
|
+
|
|
72
|
+
# Delete a memory
|
|
73
|
+
node bin/engram.js forget <memory-id>
|
|
74
|
+
|
|
75
|
+
# Run consolidation
|
|
76
|
+
node bin/engram.js consolidate
|
|
77
|
+
|
|
78
|
+
# View conflicts
|
|
79
|
+
node bin/engram.js conflicts
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2. MCP Server (Claude Desktop/Code)
|
|
83
|
+
|
|
84
|
+
Integrate with Claude Desktop or Claude Code.
|
|
85
|
+
|
|
86
|
+
**โจ Easiest Method: Use the Integration Wizard**
|
|
87
|
+
|
|
88
|
+
1. Run `npm run dev` to start the dashboard
|
|
89
|
+
2. Open http://localhost:5173 and go to the **Agents** tab
|
|
90
|
+
3. Click **Quick Setup** โ **Launch Setup Wizard**
|
|
91
|
+
4. Select your platform and copy the auto-generated configuration
|
|
92
|
+
|
|
93
|
+
**Alternative: Manual Setup**
|
|
94
|
+
|
|
95
|
+
**macOS**: Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"mcpServers": {
|
|
100
|
+
"engram": {
|
|
101
|
+
"command": "node",
|
|
102
|
+
"args": [
|
|
103
|
+
"/path/to/engram/bin/engram.js",
|
|
104
|
+
"start",
|
|
105
|
+
"--mcp-only"
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Available MCP Tools:**
|
|
113
|
+
- `engram_remember` - Store a memory
|
|
114
|
+
- `engram_recall` - Search for relevant memories
|
|
115
|
+
- `engram_forget` - Delete a memory
|
|
116
|
+
- `engram_status` - Get system status
|
|
117
|
+
|
|
118
|
+
See [docs/mcp-setup.md](docs/mcp-setup.md) for detailed configuration.
|
|
119
|
+
|
|
120
|
+
### 3. REST API
|
|
121
|
+
|
|
122
|
+
Full HTTP API for programmatic access:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Create a memory
|
|
126
|
+
curl -X POST http://localhost:3838/api/memories \
|
|
127
|
+
-H "Content-Type: application/json" \
|
|
128
|
+
-d '{
|
|
129
|
+
"content": "User prefers Svelte for frontend",
|
|
130
|
+
"category": "preference",
|
|
131
|
+
"entity": "svelte",
|
|
132
|
+
"confidence": 0.9
|
|
133
|
+
}'
|
|
134
|
+
|
|
135
|
+
# Search memories
|
|
136
|
+
curl -X POST http://localhost:3838/api/memories/search \
|
|
137
|
+
-H "Content-Type: application/json" \
|
|
138
|
+
-d '{
|
|
139
|
+
"query": "frontend preferences",
|
|
140
|
+
"limit": 5
|
|
141
|
+
}'
|
|
142
|
+
|
|
143
|
+
# Get system status
|
|
144
|
+
curl http://localhost:3838/api/status
|
|
145
|
+
|
|
146
|
+
# List memories with filters
|
|
147
|
+
curl "http://localhost:3838/api/memories?namespace=default&limit=10"
|
|
148
|
+
|
|
149
|
+
# Delete a memory
|
|
150
|
+
curl -X DELETE http://localhost:3838/api/memories/<memory-id>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
See [docs/api.md](docs/api.md) for complete API documentation.
|
|
154
|
+
|
|
155
|
+
### 4. Web Dashboard
|
|
156
|
+
|
|
157
|
+
Visual interface for managing memories:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
npm start
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Then open http://localhost:5173 in your browser.
|
|
164
|
+
|
|
165
|
+
**Dashboard Features:**
|
|
166
|
+
- ๐ System overview with statistics
|
|
167
|
+
- ๐ Browse and filter memories
|
|
168
|
+
- ๐ Semantic search with score visualization
|
|
169
|
+
- โ Create new memories
|
|
170
|
+
- ๐๏ธ Delete memories
|
|
171
|
+
- ๐ View category and namespace distributions
|
|
172
|
+
- โ ๏ธ Detect and resolve conflicts
|
|
173
|
+
- ๐ Run consolidation
|
|
174
|
+
|
|
175
|
+
### 5. PM2 Process Manager (Production Service)
|
|
176
|
+
|
|
177
|
+
Run Engram as a persistent background service using PM2:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Install PM2 globally (if not already installed)
|
|
181
|
+
npm install -g pm2
|
|
182
|
+
|
|
183
|
+
# Start Engram as a PM2 service
|
|
184
|
+
npm run pm2:start
|
|
185
|
+
|
|
186
|
+
# Check status
|
|
187
|
+
npm run pm2:status
|
|
188
|
+
|
|
189
|
+
# View logs
|
|
190
|
+
npm run pm2:logs
|
|
191
|
+
|
|
192
|
+
# Restart service
|
|
193
|
+
npm run pm2:restart
|
|
194
|
+
|
|
195
|
+
# Stop service
|
|
196
|
+
npm run pm2:stop
|
|
197
|
+
|
|
198
|
+
# Remove from PM2
|
|
199
|
+
npm run pm2:delete
|
|
200
|
+
|
|
201
|
+
# Monitor in real-time
|
|
202
|
+
npm run pm2:monit
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Auto-start on boot:**
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Generate startup script
|
|
209
|
+
pm2 startup
|
|
210
|
+
|
|
211
|
+
# Save current PM2 process list
|
|
212
|
+
pm2 save
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
PM2 configuration is in [ecosystem.config.cjs](ecosystem.config.cjs). Logs are stored in `~/.engram/logs/`.
|
|
216
|
+
|
|
217
|
+
## Architecture
|
|
218
|
+
|
|
219
|
+
### Memory Categories
|
|
220
|
+
|
|
221
|
+
Engram organizes memories into five categories:
|
|
222
|
+
|
|
223
|
+
- **preference** - User likes/dislikes ("prefers Fastify over Express")
|
|
224
|
+
- **fact** - Objective truth about their setup ("uses PostgreSQL 15")
|
|
225
|
+
- **pattern** - Recurring workflow ("always runs tests before commit")
|
|
226
|
+
- **decision** - Choice they made and why ("chose React for its ecosystem")
|
|
227
|
+
- **outcome** - Result of an action ("deployment succeeded after fixing port")
|
|
228
|
+
|
|
229
|
+
### Hybrid Recall Algorithm
|
|
230
|
+
|
|
231
|
+
Memories are ranked using a weighted formula:
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
score = (similarity ร 0.5) + (recency ร 0.15) + (confidence ร 0.2) + (access ร 0.05) + fts_boost
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- **Similarity**: Cosine similarity of embeddings (0-1)
|
|
238
|
+
- **Recency**: Time-based decay using last access time
|
|
239
|
+
- **Confidence**: User-specified or auto-calculated confidence (0-1)
|
|
240
|
+
- **Access**: Normalized access count (0-1, capped at 10 accesses)
|
|
241
|
+
- **FTS Boost**: +0.1 if found via full-text search
|
|
242
|
+
|
|
243
|
+
### Database Schema
|
|
244
|
+
|
|
245
|
+
```sql
|
|
246
|
+
CREATE TABLE memories (
|
|
247
|
+
id TEXT PRIMARY KEY,
|
|
248
|
+
content TEXT NOT NULL,
|
|
249
|
+
entity TEXT,
|
|
250
|
+
category TEXT DEFAULT 'fact',
|
|
251
|
+
confidence REAL DEFAULT 0.8,
|
|
252
|
+
embedding BLOB,
|
|
253
|
+
source TEXT,
|
|
254
|
+
namespace TEXT DEFAULT 'default',
|
|
255
|
+
tags TEXT, -- JSON array
|
|
256
|
+
access_count INTEGER DEFAULT 0,
|
|
257
|
+
decay_rate REAL DEFAULT 0.01,
|
|
258
|
+
created_at INTEGER NOT NULL,
|
|
259
|
+
updated_at INTEGER NOT NULL,
|
|
260
|
+
last_accessed INTEGER
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
-- FTS5 virtual table for full-text search
|
|
264
|
+
CREATE VIRTUAL TABLE memories_fts USING fts5(
|
|
265
|
+
content, entity, category, namespace,
|
|
266
|
+
content='memories', content_rowid='rowid'
|
|
267
|
+
);
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Configuration
|
|
271
|
+
|
|
272
|
+
Engram uses a YAML configuration file at `~/.engram/config.yml`:
|
|
273
|
+
|
|
274
|
+
```yaml
|
|
275
|
+
dataDir: ~/.engram
|
|
276
|
+
port: 3838
|
|
277
|
+
|
|
278
|
+
defaults:
|
|
279
|
+
namespace: default
|
|
280
|
+
recallLimit: 5
|
|
281
|
+
confidenceThreshold: 0.3
|
|
282
|
+
|
|
283
|
+
security:
|
|
284
|
+
secretDetection: true
|
|
285
|
+
|
|
286
|
+
consolidation:
|
|
287
|
+
duplicateThreshold: 0.92
|
|
288
|
+
decayEnabled: true
|
|
289
|
+
staleCleanupDays: 90
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Advanced Features
|
|
293
|
+
|
|
294
|
+
### Secret Detection
|
|
295
|
+
|
|
296
|
+
Engram automatically detects and redacts common secrets:
|
|
297
|
+
|
|
298
|
+
- OpenAI API keys (`sk-...`)
|
|
299
|
+
- Stripe keys (`pk_...`, `sk_live_...`)
|
|
300
|
+
- AWS keys (`AKIA...`)
|
|
301
|
+
- GitHub tokens (`ghp_...`, `gho_...`)
|
|
302
|
+
- Slack tokens (`xoxb-...`, `xoxp-...`)
|
|
303
|
+
- Google API keys (`AIza...`)
|
|
304
|
+
- Private keys (`BEGIN PRIVATE KEY`)
|
|
305
|
+
- Database connection strings
|
|
306
|
+
- JWT tokens
|
|
307
|
+
|
|
308
|
+
### Consolidation
|
|
309
|
+
|
|
310
|
+
Run periodic consolidation to maintain memory quality:
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
node bin/engram.js consolidate
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**What it does:**
|
|
317
|
+
- Removes duplicate memories (>0.92 similarity)
|
|
318
|
+
- Detects contradictions between memories
|
|
319
|
+
- Applies confidence decay to old, unused memories
|
|
320
|
+
- Marks stale memories for review
|
|
321
|
+
|
|
322
|
+
### Namespaces
|
|
323
|
+
|
|
324
|
+
Organize memories by project or context:
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
# Create memories in different namespaces
|
|
328
|
+
engram remember "Uses Docker" --namespace project-alpha
|
|
329
|
+
engram remember "Prefers Kubernetes" --namespace project-beta
|
|
330
|
+
|
|
331
|
+
# Filter by namespace
|
|
332
|
+
engram list --namespace project-alpha
|
|
333
|
+
engram recall "container tech" --namespace project-alpha
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Development
|
|
337
|
+
|
|
338
|
+
### Project Structure
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
engram/
|
|
342
|
+
โโโ bin/
|
|
343
|
+
โ โโโ engram.js # CLI entry point
|
|
344
|
+
โโโ src/
|
|
345
|
+
โ โโโ config/
|
|
346
|
+
โ โ โโโ index.js # Configuration management
|
|
347
|
+
โ โโโ memory/
|
|
348
|
+
โ โ โโโ store.js # SQLite operations
|
|
349
|
+
โ โ โโโ recall.js # Hybrid search
|
|
350
|
+
โ โ โโโ consolidate.js # Memory consolidation
|
|
351
|
+
โ โโโ embed/
|
|
352
|
+
โ โ โโโ index.js # Embedding generation
|
|
353
|
+
โ โโโ extract/
|
|
354
|
+
โ โ โโโ rules.js # Category/entity extraction
|
|
355
|
+
โ โ โโโ secrets.js # Secret detection
|
|
356
|
+
โ โโโ server/
|
|
357
|
+
โ โ โโโ mcp.js # MCP server
|
|
358
|
+
โ โ โโโ rest.js # REST API server
|
|
359
|
+
โ โโโ utils/
|
|
360
|
+
โ โโโ id.js # UUID generation
|
|
361
|
+
โ โโโ logger.js # Structured logging
|
|
362
|
+
โโโ dashboard/ # React web UI
|
|
363
|
+
โโโ test/ # Test suites
|
|
364
|
+
โโโ docs/ # Documentation
|
|
365
|
+
โโโ examples/ # Usage examples
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Running Tests
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
# Run all tests
|
|
372
|
+
npm test
|
|
373
|
+
|
|
374
|
+
# Run tests once (no watch)
|
|
375
|
+
npm run test:run
|
|
376
|
+
|
|
377
|
+
# Run specific test file
|
|
378
|
+
npx vitest test/memory/store.test.js
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Building
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
# No build step required - uses ESM modules directly
|
|
385
|
+
node bin/engram.js start
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
## API Reference
|
|
389
|
+
|
|
390
|
+
See [docs/api.md](docs/api.md) for complete REST API documentation.
|
|
391
|
+
|
|
392
|
+
### Key Endpoints
|
|
393
|
+
|
|
394
|
+
- `POST /api/memories` - Create memory
|
|
395
|
+
- `GET /api/memories` - List memories
|
|
396
|
+
- `POST /api/memories/search` - Search memories
|
|
397
|
+
- `GET /api/memories/:id` - Get single memory
|
|
398
|
+
- `DELETE /api/memories/:id` - Delete memory
|
|
399
|
+
- `POST /api/consolidate` - Run consolidation
|
|
400
|
+
- `GET /api/conflicts` - Get detected conflicts
|
|
401
|
+
- `GET /api/status` - System status
|
|
402
|
+
- `GET /health` - Health check
|
|
403
|
+
|
|
404
|
+
## Examples
|
|
405
|
+
|
|
406
|
+
### Example 1: Project Context Memory
|
|
407
|
+
|
|
408
|
+
```javascript
|
|
409
|
+
// Store project decisions
|
|
410
|
+
await api.createMemory({
|
|
411
|
+
content: "Chose Fastify over Express because of better TypeScript support and performance",
|
|
412
|
+
category: "decision",
|
|
413
|
+
entity: "fastify",
|
|
414
|
+
confidence: 1.0,
|
|
415
|
+
namespace: "project-api",
|
|
416
|
+
tags: ["backend", "framework"]
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// Later, recall why you chose it
|
|
420
|
+
const results = await api.searchMemories("why did we choose Fastify?", {
|
|
421
|
+
namespace: "project-api",
|
|
422
|
+
limit: 3
|
|
423
|
+
});
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Example 2: User Preferences
|
|
427
|
+
|
|
428
|
+
```javascript
|
|
429
|
+
// Store user preferences
|
|
430
|
+
await api.createMemory({
|
|
431
|
+
content: "User prefers compact code without unnecessary comments",
|
|
432
|
+
category: "preference",
|
|
433
|
+
entity: "coding-style",
|
|
434
|
+
confidence: 0.9
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// Recall preferences before generating code
|
|
438
|
+
const prefs = await api.searchMemories("coding style preferences", {
|
|
439
|
+
category: "preference",
|
|
440
|
+
limit: 5
|
|
441
|
+
});
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### Example 3: Infrastructure Facts
|
|
445
|
+
|
|
446
|
+
```javascript
|
|
447
|
+
// Document infrastructure
|
|
448
|
+
await api.createMemory({
|
|
449
|
+
content: "Production database is PostgreSQL 15 on AWS RDS (db.t3.medium)",
|
|
450
|
+
category: "fact",
|
|
451
|
+
entity: "postgresql",
|
|
452
|
+
namespace: "production"
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// Quick lookup
|
|
456
|
+
const infra = await api.searchMemories("production database", {
|
|
457
|
+
namespace: "production"
|
|
458
|
+
});
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
See [examples/](examples/) directory for more detailed examples.
|
|
462
|
+
|
|
463
|
+
## Performance
|
|
464
|
+
|
|
465
|
+
- **Memory Storage**: ~1ms per memory (with embedding)
|
|
466
|
+
- **Recall Search**: ~10-50ms for 5 results (depends on database size)
|
|
467
|
+
- **Database Size**: ~2KB per memory (including embedding)
|
|
468
|
+
- **Embedding Model**: 23MB (downloaded on first use)
|
|
469
|
+
- **Memory Usage**: ~50MB base + loaded model
|
|
470
|
+
|
|
471
|
+
## Troubleshooting
|
|
472
|
+
|
|
473
|
+
### Embedding model not downloading
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# Check internet connection and disk space
|
|
477
|
+
# Model downloads to ~/.engram/models/
|
|
478
|
+
ls -lh ~/.engram/models/
|
|
479
|
+
|
|
480
|
+
# Manual download if needed
|
|
481
|
+
mkdir -p ~/.engram/models
|
|
482
|
+
# The model will auto-download on first use
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Port already in use
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
# Change the port
|
|
489
|
+
node bin/engram.js start --port 8080
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### Database locked
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
# SQLite WAL mode should prevent this, but if it happens:
|
|
496
|
+
# Close all connections and restart
|
|
497
|
+
pkill -f "node bin/engram.js"
|
|
498
|
+
node bin/engram.js start
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
### Tests failing
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
# Clean test databases
|
|
505
|
+
rm -rf /tmp/engram-*
|
|
506
|
+
|
|
507
|
+
# Run tests
|
|
508
|
+
npm test
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
## Contributing
|
|
512
|
+
|
|
513
|
+
Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
514
|
+
|
|
515
|
+
## License
|
|
516
|
+
|
|
517
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
518
|
+
|
|
519
|
+
## Acknowledgments
|
|
520
|
+
|
|
521
|
+
- Built with [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) for fast SQLite access
|
|
522
|
+
- Embeddings powered by [@xenova/transformers](https://github.com/xenova/transformers.js)
|
|
523
|
+
- REST API built with [Fastify](https://www.fastify.io/)
|
|
524
|
+
- Dashboard built with [React](https://react.dev/) and [Tailwind CSS](https://tailwindcss.com/)
|
|
525
|
+
- MCP integration via [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/sdk)
|
|
526
|
+
|
|
527
|
+
## Support
|
|
528
|
+
|
|
529
|
+
- ๐ [Documentation](docs/)
|
|
530
|
+
- ๐ [Issue Tracker](https://github.com/your-username/engram/issues)
|
|
531
|
+
- ๐ฌ [Discussions](https://github.com/your-username/engram/discussions)
|
|
532
|
+
|
|
533
|
+
---
|
|
534
|
+
|
|
535
|
+
**Made with โค๏ธ for the AI agent community**
|