@199-bio/engram 0.6.0 → 0.6.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 +114 -314
- package/dist/storage/database.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/storage/database.ts +12 -11
package/README.md
CHANGED
|
@@ -2,41 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
**Give your AI a perfect memory.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Every conversation you have with your AI disappears the moment it ends. Names you've mentioned, preferences you've shared, the context of your life—all gone. You find yourself repeating the same information, re-explaining who people are, reminding it of things you've already said.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Engram changes that.
|
|
8
|
+
|
|
9
|
+
It gives your AI the ability to remember. Not just store text, but truly remember—the way you do. Important things stick. Trivial things fade. And everything connects to everything else.
|
|
8
10
|
|
|
9
11
|
> *An engram is a unit of cognitive information imprinted in a physical substance—the biological basis of memory.*
|
|
10
12
|
|
|
11
13
|
---
|
|
12
14
|
|
|
13
|
-
##
|
|
15
|
+
## How It Works
|
|
14
16
|
|
|
15
|
-
Tell your AI
|
|
17
|
+
Tell your AI something once:
|
|
16
18
|
|
|
17
19
|
> "My colleague Sarah is allergic to shellfish and prefers window seats. She's leading the Q1 product launch."
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
Weeks later, ask:
|
|
20
22
|
|
|
21
23
|
> "I'm booking a team lunch and flights for the offsite—what should I know?"
|
|
22
24
|
|
|
23
|
-
Engram connects the dots
|
|
25
|
+
Engram connects the dots. It remembers Sarah, her allergy, her seating preference, and her current workload. Your AI can now actually help—suggesting restaurants without shellfish, booking her a window seat, and noting she might be busy with the launch.
|
|
26
|
+
|
|
27
|
+
This isn't keyword matching. It's understanding.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Memory That Feels Real
|
|
32
|
+
|
|
33
|
+
Engram models memory the way your brain does.
|
|
34
|
+
|
|
35
|
+
**Things fade.** A memory from six months ago that you've never thought about becomes harder to find. But something important—a name, a birthday, a preference—stays accessible even as time passes.
|
|
24
36
|
|
|
25
|
-
**
|
|
37
|
+
**Recall strengthens.** Every time a memory surfaces, it becomes more permanent. The things you think about often become the things you'll never forget.
|
|
38
|
+
|
|
39
|
+
**Everything connects.** People link to places. Places link to events. When you ask about one thing, related things come along for the ride. Ask about Sarah, and her company, her projects, and her preferences all surface together.
|
|
26
40
|
|
|
27
41
|
---
|
|
28
42
|
|
|
29
43
|
## Quick Start
|
|
30
44
|
|
|
31
|
-
|
|
45
|
+
Install globally:
|
|
32
46
|
|
|
33
47
|
```bash
|
|
34
48
|
npm install -g @199-bio/engram
|
|
35
49
|
```
|
|
36
50
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
**Claude Desktop** — add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
51
|
+
Add to **Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
40
52
|
|
|
41
53
|
```json
|
|
42
54
|
{
|
|
@@ -52,383 +64,173 @@ npm install -g @199-bio/engram
|
|
|
52
64
|
}
|
|
53
65
|
```
|
|
54
66
|
|
|
55
|
-
**Claude Code
|
|
67
|
+
Or with **Claude Code**:
|
|
56
68
|
|
|
57
69
|
```bash
|
|
58
70
|
claude mcp add engram -- npx -y @199-bio/engram
|
|
59
71
|
```
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
That's it. Your AI now has memory.
|
|
73
|
+
That's it. Your AI now remembers.
|
|
64
74
|
|
|
65
75
|
---
|
|
66
76
|
|
|
67
|
-
##
|
|
68
|
-
|
|
69
|
-
Engram models memory like your brain does—important things stick, unimportant things fade, and everything connects.
|
|
70
|
-
|
|
71
|
-
```mermaid
|
|
72
|
-
flowchart LR
|
|
73
|
-
subgraph Input
|
|
74
|
-
A[Your Message] --> B[Remember]
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
subgraph Storage
|
|
78
|
-
B --> C[Memory Store]
|
|
79
|
-
B --> D[Knowledge Graph]
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
subgraph Retrieval
|
|
83
|
-
E[Your Question] --> F[Recall]
|
|
84
|
-
F --> G[Keyword Search]
|
|
85
|
-
F --> H[Semantic Search]
|
|
86
|
-
F --> I[Graph Traversal]
|
|
87
|
-
G & H & I --> J[Combine Results]
|
|
88
|
-
end
|
|
77
|
+
## What You Can Do
|
|
89
78
|
|
|
90
|
-
|
|
91
|
-
D --> F
|
|
92
|
-
J --> K[Relevant Memories]
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Three Key Ideas
|
|
96
|
-
|
|
97
|
-
**1. Memories Fade Over Time**
|
|
98
|
-
|
|
99
|
-
Just like real memory, things you haven't thought about recently become harder to recall. But important or emotional memories resist fading.
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
Fresh memory (today) → Easy to recall
|
|
103
|
-
Old but important memory → Still accessible
|
|
104
|
-
Old, trivial memory → Fades away
|
|
105
|
-
```
|
|
79
|
+
Just talk naturally. Your AI handles the rest.
|
|
106
80
|
|
|
107
|
-
**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
**3. Everything Connects**
|
|
112
|
-
|
|
113
|
-
People, places, and things form a web of relationships. When you ask about Sarah, Engram also knows she works at Acme Corp and is leading the Q1 launch.
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## The Memory Lifecycle
|
|
118
|
-
|
|
119
|
-
```mermaid
|
|
120
|
-
flowchart TD
|
|
121
|
-
subgraph "1. Capture"
|
|
122
|
-
A[Conversation] --> B[Extract Key Info]
|
|
123
|
-
B --> C[Store Memory]
|
|
124
|
-
B --> D[Create Entities]
|
|
125
|
-
B --> E[Link Relationships]
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
subgraph "2. Search"
|
|
129
|
-
F[Query] --> G[Find by Keywords]
|
|
130
|
-
F --> H[Find by Meaning]
|
|
131
|
-
F --> I[Follow Connections]
|
|
132
|
-
G & H & I --> J[Rank by Relevance + Recency]
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
subgraph "3. Consolidate"
|
|
136
|
-
K[Raw Memories] --> L[Compress & Summarize]
|
|
137
|
-
L --> M[Detect Contradictions]
|
|
138
|
-
M --> N[Update Knowledge]
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
C --> F
|
|
142
|
-
J --> K
|
|
143
|
-
```
|
|
81
|
+
**Store memories** by mentioning things:
|
|
82
|
+
- "Remember that my anniversary is March 15th"
|
|
83
|
+
- "Sarah prefers async communication"
|
|
84
|
+
- "I'm allergic to penicillin"
|
|
144
85
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
With an API key, Engram can periodically compress old memories into summaries—like how sleep consolidates your memories. This keeps important information while reducing storage.
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
# Run consolidation manually
|
|
151
|
-
consolidate # Compresses old memories, finds contradictions
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## What Makes It Special
|
|
157
|
-
|
|
158
|
-
| Feature | Why It Matters |
|
|
159
|
-
|---------|----------------|
|
|
160
|
-
| **Hybrid Search** | Finds memories by keywords AND meaning |
|
|
161
|
-
| **Knowledge Graph** | Understands relationships between people, places, things |
|
|
162
|
-
| **Natural Forgetting** | Old, unimportant memories fade; important ones persist |
|
|
163
|
-
| **Strengthening** | Frequently recalled memories become permanent |
|
|
164
|
-
| **Consolidation** | Compresses old memories, detects contradictions |
|
|
165
|
-
| **Fast** | ~50ms to recall, feels instant |
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## How to Use
|
|
170
|
-
|
|
171
|
-
Just talk naturally. Your AI will remember what matters.
|
|
172
|
-
|
|
173
|
-
### Storing Memories
|
|
174
|
-
|
|
175
|
-
Say things like:
|
|
176
|
-
- "Remember that Sarah is allergic to shellfish"
|
|
177
|
-
- "My anniversary is March 15th"
|
|
178
|
-
- "I prefer morning meetings, never schedule anything before 9am"
|
|
179
|
-
|
|
180
|
-
The AI automatically extracts:
|
|
181
|
-
- **Importance**: Key facts get higher priority
|
|
182
|
-
- **Entities**: People, places, organizations mentioned
|
|
183
|
-
- **Relationships**: How entities connect to each other
|
|
184
|
-
|
|
185
|
-
### Recalling
|
|
186
|
-
|
|
187
|
-
Just ask:
|
|
86
|
+
**Recall memories** by asking:
|
|
188
87
|
- "What do you know about Sarah?"
|
|
88
|
+
- "What are my allergies?"
|
|
189
89
|
- "When is my anniversary?"
|
|
190
|
-
- "What are my meeting preferences?"
|
|
191
|
-
|
|
192
|
-
Results are ranked by:
|
|
193
|
-
- **Relevance**: How well it matches your question
|
|
194
|
-
- **Recency**: Recent memories surface first
|
|
195
|
-
- **Importance**: High-priority info stays accessible
|
|
196
|
-
|
|
197
|
-
### The Knowledge Graph
|
|
198
|
-
|
|
199
|
-
Engram doesn't just store text—it understands relationships:
|
|
200
|
-
|
|
201
|
-
- **People**: Sarah, John, Dr. Martinez
|
|
202
|
-
- **Places**: Office, Conference Room A, Seattle HQ
|
|
203
|
-
- **Organizations**: Acme Corp, Stanford, FDA
|
|
204
|
-
- **Connections**: Sarah → works at → Acme Corp
|
|
205
|
-
- **Observations**: Sarah is allergic to shellfish
|
|
206
|
-
|
|
207
|
-
This means when you ask about Sarah's work, Engram knows to also surface relevant information about Acme Corp.
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## The Tools
|
|
212
|
-
|
|
213
|
-
Your AI gets these capabilities:
|
|
214
90
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
| `forget` | Remove a memory |
|
|
220
|
-
| `create_entity` | Add a person, place, or concept |
|
|
221
|
-
| `observe` | Note something about an entity |
|
|
222
|
-
| `relate` | Connect two entities |
|
|
223
|
-
| `query_entity` | Get everything about someone/something |
|
|
224
|
-
| `list_entities` | See all people, places, etc. |
|
|
225
|
-
| `stats` | Check memory statistics |
|
|
226
|
-
| `consolidate` | Compress old memories, find contradictions |
|
|
227
|
-
| `engram_web` | Launch visual memory browser |
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## Examples
|
|
232
|
-
|
|
233
|
-
### Personal Assistant
|
|
234
|
-
|
|
235
|
-
```
|
|
236
|
-
You: "Remember that my anniversary is March 15th and my partner loves Italian food"
|
|
237
|
-
AI: ✓ Stored. I've noted this as an important date with preferences.
|
|
238
|
-
|
|
239
|
-
You: "I need to plan something special next month"
|
|
240
|
-
AI: Your anniversary is coming up on March 15th! Given your partner's love for
|
|
241
|
-
Italian food, perhaps a nice Italian restaurant reservation?
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### Relationship Context
|
|
245
|
-
|
|
246
|
-
```
|
|
247
|
-
You: "My friend David lives in Austin and always recommends great coffee shops."
|
|
248
|
-
AI: ✓ Stored. Created entity: David (person), with observation about Austin and coffee expertise.
|
|
249
|
-
|
|
250
|
-
You: "I'm visiting Austin next week"
|
|
251
|
-
AI: David is in Austin—he'd probably have great coffee shop recommendations!
|
|
252
|
-
Want me to remind you to ask him?
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Professional Memory
|
|
256
|
-
|
|
257
|
-
```
|
|
258
|
-
You: "John Chen is our VP of Engineering. He prefers async communication and hates meetings before 11am."
|
|
259
|
-
Claude: ✓ Stored. Created entity: John Chen (person, VP of Engineering).
|
|
260
|
-
|
|
261
|
-
You: "I need to schedule a sync with John"
|
|
262
|
-
Claude: Given John's preferences, I'd suggest a late morning slot, maybe 11:30am,
|
|
263
|
-
or an async Loom video if it doesn't require real-time discussion.
|
|
264
|
-
```
|
|
91
|
+
**Build a knowledge graph** of your world:
|
|
92
|
+
- People, places, organizations, and how they connect
|
|
93
|
+
- Observations about each entity
|
|
94
|
+
- Relationships that span your entire life
|
|
265
95
|
|
|
266
96
|
---
|
|
267
97
|
|
|
268
98
|
## Privacy
|
|
269
99
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
- All data stored locally in `~/.engram/`
|
|
273
|
-
- No external APIs required for core functionality
|
|
274
|
-
- Consolidation uses Anthropic API (optional, requires key)
|
|
275
|
-
- You own your data completely
|
|
100
|
+
Your memories stay on your machine. Everything is stored locally in `~/.engram/`. The only external call is optional—if you provide an API key, Engram can periodically compress old memories into summaries. But the core functionality works entirely offline.
|
|
276
101
|
|
|
277
102
|
---
|
|
278
103
|
|
|
279
|
-
##
|
|
104
|
+
## The Details
|
|
280
105
|
|
|
281
106
|
<details>
|
|
282
|
-
<summary>
|
|
107
|
+
<summary><strong>Available Tools</strong></summary>
|
|
283
108
|
|
|
284
|
-
|
|
109
|
+
Your AI gets these capabilities:
|
|
285
110
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
111
|
+
| Tool | Purpose |
|
|
112
|
+
|------|---------|
|
|
113
|
+
| `remember` | Store new information with importance, emotions, and timing |
|
|
114
|
+
| `recall` | Find relevant memories ranked by relevance and recency |
|
|
115
|
+
| `forget` | Remove a specific memory |
|
|
116
|
+
| `create_entity` | Add a person, place, or concept to the knowledge graph |
|
|
117
|
+
| `observe` | Record a fact about an entity |
|
|
118
|
+
| `relate` | Connect two entities (e.g., "works at", "married to") |
|
|
119
|
+
| `query_entity` | Get everything known about someone or something |
|
|
120
|
+
| `list_entities` | See all tracked people, places, and things |
|
|
121
|
+
| `stats` | View memory statistics |
|
|
122
|
+
| `consolidate` | Compress old memories and detect contradictions |
|
|
123
|
+
| `engram_web` | Launch a visual memory browser |
|
|
289
124
|
|
|
290
|
-
|
|
291
|
-
- **Retention**: How fresh is this memory?
|
|
292
|
-
- **Salience**: How important/emotional is it?
|
|
125
|
+
</details>
|
|
293
126
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
Q[Query] --> BM25
|
|
297
|
-
Q --> Semantic
|
|
298
|
-
Q --> Graph
|
|
127
|
+
<details>
|
|
128
|
+
<summary><strong>How Search Works</strong></summary>
|
|
299
129
|
|
|
300
|
-
|
|
301
|
-
Semantic --> RRF
|
|
302
|
-
Graph --> RRF
|
|
130
|
+
Engram uses three search methods simultaneously:
|
|
303
131
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
132
|
+
1. **Keywords** — SQLite FTS5 finds exact matches for names, dates, and phrases
|
|
133
|
+
2. **Meaning** — Neural embeddings find conceptually related content
|
|
134
|
+
3. **Connections** — The knowledge graph expands to related entities
|
|
135
|
+
|
|
136
|
+
Results are fused together, then adjusted for how recent and important each memory is. Fresh memories surface first. Important memories resist fading.
|
|
308
137
|
|
|
309
138
|
</details>
|
|
310
139
|
|
|
311
140
|
<details>
|
|
312
|
-
<summary>How Forgetting Works</summary>
|
|
141
|
+
<summary><strong>How Forgetting Works</strong></summary>
|
|
313
142
|
|
|
314
|
-
Memories follow an exponential decay curve
|
|
143
|
+
Memories follow an exponential decay curve:
|
|
315
144
|
|
|
316
145
|
```
|
|
317
146
|
Retention = e^(-time / stability)
|
|
318
147
|
```
|
|
319
148
|
|
|
320
|
-
|
|
321
|
-
- **time
|
|
322
|
-
- **stability**: Memory strength (increases each time you recall it)
|
|
149
|
+
- **Time** is days since the memory was last accessed
|
|
150
|
+
- **Stability** is memory strength, which increases each time you recall something
|
|
323
151
|
|
|
324
|
-
High-importance and
|
|
152
|
+
High-importance and emotionally significant memories decay slower. Frequently accessed memories become essentially permanent.
|
|
325
153
|
|
|
326
154
|
</details>
|
|
327
155
|
|
|
328
156
|
<details>
|
|
329
|
-
<summary>How Consolidation Works</summary>
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
flowchart TD
|
|
333
|
-
A[Old Memories] --> B{Important?}
|
|
334
|
-
B -->|Yes| C[Keep as-is]
|
|
335
|
-
B -->|No| D[Group Similar]
|
|
336
|
-
D --> E[Summarize with AI]
|
|
337
|
-
E --> F[Create Digest]
|
|
338
|
-
F --> G[Archive Originals]
|
|
339
|
-
|
|
340
|
-
H[All Memories] --> I[Find Contradictions]
|
|
341
|
-
I --> J[Flag for Review]
|
|
342
|
-
```
|
|
157
|
+
<summary><strong>How Consolidation Works</strong></summary>
|
|
158
|
+
|
|
159
|
+
With an API key, Engram can compress old memories—like how sleep consolidates your experiences into long-term storage.
|
|
343
160
|
|
|
344
|
-
|
|
345
|
-
1. Groups related low-importance memories
|
|
161
|
+
1. Groups related low-importance memories together
|
|
346
162
|
2. Creates AI-generated summaries (digests)
|
|
347
163
|
3. Detects contradictory information
|
|
348
|
-
4. Archives
|
|
164
|
+
4. Archives the originals
|
|
349
165
|
|
|
350
|
-
|
|
166
|
+
This keeps storage efficient while preserving everything important.
|
|
351
167
|
|
|
352
168
|
</details>
|
|
353
169
|
|
|
354
170
|
<details>
|
|
355
|
-
<summary>Architecture</summary>
|
|
171
|
+
<summary><strong>Architecture</strong></summary>
|
|
356
172
|
|
|
357
173
|
```
|
|
358
174
|
engram/
|
|
359
175
|
├── src/
|
|
360
|
-
│ ├── index.ts # MCP server
|
|
361
|
-
│ ├── storage/
|
|
362
|
-
│
|
|
363
|
-
│ ├── graph/
|
|
364
|
-
│ │ └── knowledge-graph.ts
|
|
176
|
+
│ ├── index.ts # MCP server
|
|
177
|
+
│ ├── storage/database.ts # SQLite with temporal fields
|
|
178
|
+
│ ├── graph/knowledge-graph.ts
|
|
365
179
|
│ ├── retrieval/
|
|
366
180
|
│ │ ├── colbert.ts # Semantic search
|
|
367
|
-
│ │ └── hybrid.ts #
|
|
368
|
-
│ ├── consolidation/
|
|
369
|
-
│
|
|
370
|
-
│ └── web/
|
|
371
|
-
│ └── server.ts # Visual browser
|
|
181
|
+
│ │ └── hybrid.ts # Fusion + decay + salience
|
|
182
|
+
│ ├── consolidation/consolidator.ts
|
|
183
|
+
│ └── web/server.ts # Visual browser
|
|
372
184
|
```
|
|
373
185
|
|
|
374
186
|
</details>
|
|
375
187
|
|
|
376
188
|
<details>
|
|
377
|
-
<summary>
|
|
189
|
+
<summary><strong>Configuration</strong></summary>
|
|
190
|
+
|
|
191
|
+
Environment variables:
|
|
192
|
+
|
|
193
|
+
| Variable | Purpose | Default |
|
|
194
|
+
|----------|---------|---------|
|
|
195
|
+
| `ENGRAM_DB_PATH` | Where to store data | `~/.engram/` |
|
|
196
|
+
| `ANTHROPIC_API_KEY` | Enable consolidation | None (optional) |
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary><strong>Building from Source</strong></summary>
|
|
378
202
|
|
|
379
203
|
```bash
|
|
380
204
|
git clone https://github.com/199-biotechnologies/engram.git
|
|
381
205
|
cd engram
|
|
382
206
|
npm install
|
|
383
207
|
npm run build
|
|
384
|
-
|
|
385
|
-
# Install globally from local build
|
|
386
208
|
npm install -g .
|
|
387
209
|
```
|
|
388
210
|
|
|
389
|
-
|
|
211
|
+
For semantic search, install Python dependencies:
|
|
212
|
+
|
|
390
213
|
```bash
|
|
391
214
|
pip install ragatouille torch
|
|
392
215
|
```
|
|
393
216
|
|
|
394
|
-
If
|
|
217
|
+
If unavailable, Engram falls back to keyword-only search automatically.
|
|
395
218
|
|
|
396
219
|
</details>
|
|
397
220
|
|
|
398
221
|
<details>
|
|
399
|
-
<summary>
|
|
400
|
-
|
|
401
|
-
Environment variables:
|
|
402
|
-
- `ENGRAM_DB_PATH`: Database location (default: `~/.engram/`)
|
|
403
|
-
- `ANTHROPIC_API_KEY`: Required for consolidation features
|
|
404
|
-
|
|
405
|
-
Claude Desktop full config:
|
|
406
|
-
```json
|
|
407
|
-
{
|
|
408
|
-
"mcpServers": {
|
|
409
|
-
"engram": {
|
|
410
|
-
"command": "engram",
|
|
411
|
-
"env": {
|
|
412
|
-
"ENGRAM_DB_PATH": "/custom/path/",
|
|
413
|
-
"ANTHROPIC_API_KEY": "sk-ant-..."
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
</details>
|
|
421
|
-
|
|
422
|
-
<details>
|
|
423
|
-
<summary>Performance</summary>
|
|
222
|
+
<summary><strong>Performance</strong></summary>
|
|
424
223
|
|
|
425
224
|
On M1 MacBook Air:
|
|
426
|
-
- **remember**: ~100ms
|
|
427
|
-
- **recall**: ~50ms (includes decay calculation)
|
|
428
|
-
- **graph queries**: ~5ms
|
|
429
|
-
- **consolidate**: ~2-5s per batch (API call)
|
|
430
225
|
|
|
431
|
-
|
|
226
|
+
| Operation | Time |
|
|
227
|
+
|-----------|------|
|
|
228
|
+
| Remember | ~100ms |
|
|
229
|
+
| Recall | ~50ms |
|
|
230
|
+
| Graph queries | ~5ms |
|
|
231
|
+
| Consolidate | ~2-5s per batch |
|
|
232
|
+
|
|
233
|
+
Storage: ~1KB per memory.
|
|
432
234
|
|
|
433
235
|
</details>
|
|
434
236
|
|
|
@@ -436,14 +238,12 @@ Database size: ~1KB per memory (text + embeddings + graph data)
|
|
|
436
238
|
|
|
437
239
|
## Roadmap
|
|
438
240
|
|
|
439
|
-
- [x]
|
|
440
|
-
- [x]
|
|
441
|
-
- [x]
|
|
442
|
-
- [x]
|
|
443
|
-
- [x]
|
|
444
|
-
- [
|
|
445
|
-
- [x] Web dashboard
|
|
446
|
-
- [ ] Export/import
|
|
241
|
+
- [x] Hybrid search (keywords + semantics)
|
|
242
|
+
- [x] Knowledge graph with relationships
|
|
243
|
+
- [x] Memory decay and strengthening
|
|
244
|
+
- [x] Consolidation with contradiction detection
|
|
245
|
+
- [x] Web interface
|
|
246
|
+
- [ ] Export and import
|
|
447
247
|
- [ ] Scheduled consolidation
|
|
448
248
|
|
|
449
249
|
---
|
|
@@ -455,10 +255,10 @@ Founder, [199 Biotechnologies](https://199bio.com)
|
|
|
455
255
|
|
|
456
256
|
## License
|
|
457
257
|
|
|
458
|
-
MIT
|
|
258
|
+
MIT
|
|
459
259
|
|
|
460
260
|
---
|
|
461
261
|
|
|
462
262
|
<p align="center">
|
|
463
|
-
<i>Built
|
|
263
|
+
<i>Built by <a href="https://github.com/199-biotechnologies">199 Biotechnologies</a></i>
|
|
464
264
|
</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/storage/database.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,cAAc,CAAC;IAChE,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,UAAU,EAAE,MAAM,CA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
|
|
112
112
|
|
|
113
113
|
private initialize(): void {
|
|
114
114
|
// Memories table (Semantic Memory - neocortex analog)
|
|
115
|
+
// Create table with base columns first (for new databases)
|
|
115
116
|
this.db.exec(`
|
|
116
117
|
CREATE TABLE IF NOT EXISTS memories (
|
|
117
118
|
id TEXT PRIMARY KEY,
|
|
118
119
|
content TEXT NOT NULL,
|
|
119
120
|
source TEXT DEFAULT 'conversation',
|
|
120
121
|
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
121
|
-
event_time DATETIME,
|
|
122
122
|
importance REAL DEFAULT 0.5,
|
|
123
123
|
access_count INTEGER DEFAULT 0,
|
|
124
|
-
last_accessed DATETIME
|
|
125
|
-
stability REAL DEFAULT 1.0,
|
|
126
|
-
emotional_weight REAL DEFAULT 0.5
|
|
124
|
+
last_accessed DATETIME
|
|
127
125
|
);
|
|
128
|
-
|
|
129
|
-
CREATE INDEX IF NOT EXISTS idx_memories_timestamp ON memories(timestamp);
|
|
130
|
-
CREATE INDEX IF NOT EXISTS idx_memories_importance ON memories(importance);
|
|
131
|
-
CREATE INDEX IF NOT EXISTS idx_memories_event_time ON memories(event_time);
|
|
132
126
|
`);
|
|
133
127
|
|
|
134
128
|
// Episodes table (Episodic Memory - hippocampal buffer)
|
|
@@ -142,15 +136,22 @@ export class EngramDatabase {
|
|
|
142
136
|
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
143
137
|
consolidated INTEGER DEFAULT 0
|
|
144
138
|
);
|
|
139
|
+
`);
|
|
140
|
+
|
|
141
|
+
// IMPORTANT: Migrate schema BEFORE creating indexes on new columns
|
|
142
|
+
// This adds event_time, stability, emotional_weight to existing databases
|
|
143
|
+
this.migrateSchema();
|
|
145
144
|
|
|
145
|
+
// Now create all indexes (after migration ensures columns exist)
|
|
146
|
+
this.db.exec(`
|
|
147
|
+
CREATE INDEX IF NOT EXISTS idx_memories_timestamp ON memories(timestamp);
|
|
148
|
+
CREATE INDEX IF NOT EXISTS idx_memories_importance ON memories(importance);
|
|
149
|
+
CREATE INDEX IF NOT EXISTS idx_memories_event_time ON memories(event_time);
|
|
146
150
|
CREATE INDEX IF NOT EXISTS idx_episodes_session ON episodes(session_id);
|
|
147
151
|
CREATE INDEX IF NOT EXISTS idx_episodes_consolidated ON episodes(consolidated);
|
|
148
152
|
CREATE INDEX IF NOT EXISTS idx_episodes_timestamp ON episodes(timestamp);
|
|
149
153
|
`);
|
|
150
154
|
|
|
151
|
-
// Migrate existing tables: add new columns if they don't exist
|
|
152
|
-
this.migrateSchema();
|
|
153
|
-
|
|
154
155
|
// FTS5 for BM25 search
|
|
155
156
|
this.db.exec(`
|
|
156
157
|
CREATE VIRTUAL TABLE IF NOT EXISTS memories_fts USING fts5(
|