audrey 0.5.0 → 0.8.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/README.md +148 -128
- package/mcp-server/config.js +1 -1
- package/mcp-server/index.js +64 -4
- package/package.json +1 -1
- package/src/audrey.js +74 -4
- package/src/confidence.js +10 -2
- package/src/consolidate.js +4 -2
- package/src/context.js +15 -0
- package/src/db.js +24 -9
- package/src/decay.js +12 -5
- package/src/encode.js +4 -2
- package/src/forget.js +111 -0
- package/src/index.js +5 -1
- package/src/interference.js +51 -0
- package/src/migrate.js +32 -0
- package/src/recall.js +66 -32
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Biological memory architecture for AI agents. Gives agents cognitive memory that decays, consolidates, self-validates, and learns from experience — not just a database.
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
## Why Audrey Exists
|
|
7
6
|
|
|
8
7
|
Every AI memory tool today (Mem0, Zep, LangChain Memory) is a filing cabinet. Store stuff, retrieve stuff. None of them do what biological memory actually does:
|
|
@@ -46,7 +45,7 @@ npx audrey status
|
|
|
46
45
|
npx audrey uninstall
|
|
47
46
|
```
|
|
48
47
|
|
|
49
|
-
Every Claude Code session now has
|
|
48
|
+
Every Claude Code session now has 9 memory tools: `memory_encode`, `memory_recall`, `memory_consolidate`, `memory_introspect`, `memory_resolve_truth`, `memory_export`, `memory_import`, `memory_forget`, `memory_decay`.
|
|
50
49
|
|
|
51
50
|
### SDK in Your Code
|
|
52
51
|
|
|
@@ -79,14 +78,26 @@ await brain.encode({
|
|
|
79
78
|
const memories = await brain.recall('stripe rate limits', { limit: 5 });
|
|
80
79
|
// Returns: [{ content, type, confidence, score, ... }]
|
|
81
80
|
|
|
82
|
-
// 4.
|
|
81
|
+
// 4. Filtered recall — by tag, source, or date range
|
|
82
|
+
const recent = await brain.recall('stripe', {
|
|
83
|
+
tags: ['rate-limit'],
|
|
84
|
+
sources: ['direct-observation'],
|
|
85
|
+
after: '2026-02-01T00:00:00Z',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// 5. Consolidate episodes into principles (the "sleep" cycle)
|
|
83
89
|
await brain.consolidate();
|
|
84
90
|
|
|
85
|
-
//
|
|
91
|
+
// 6. Forget something
|
|
92
|
+
brain.forget(memoryId); // soft-delete
|
|
93
|
+
brain.forget(memoryId, { purge: true }); // hard-delete
|
|
94
|
+
await brain.forgetByQuery('old API endpoint', { minSimilarity: 0.9 });
|
|
95
|
+
|
|
96
|
+
// 7. Check brain health
|
|
86
97
|
const stats = brain.introspect();
|
|
87
98
|
// { episodic: 47, semantic: 12, procedural: 3, dormant: 8, ... }
|
|
88
99
|
|
|
89
|
-
//
|
|
100
|
+
// 8. Clean up
|
|
90
101
|
brain.close();
|
|
91
102
|
```
|
|
92
103
|
|
|
@@ -219,6 +230,16 @@ Context-dependent truths are modeled explicitly:
|
|
|
219
230
|
|
|
220
231
|
New high-confidence evidence can reopen resolved disputes.
|
|
221
232
|
|
|
233
|
+
### Forget and Purge
|
|
234
|
+
|
|
235
|
+
Memories can be explicitly forgotten — by ID or by semantic query:
|
|
236
|
+
|
|
237
|
+
**Soft-delete** (default) — Marks the memory as forgotten/superseded and removes its vector index. The record stays in the database but is excluded from recall. Reversible via direct database access.
|
|
238
|
+
|
|
239
|
+
**Hard-delete** (`purge: true`) — Permanently removes the memory from both the main table and the vector index. Irreversible.
|
|
240
|
+
|
|
241
|
+
**Bulk purge** — Removes all forgotten, dormant, superseded, and rolled-back memories in one operation. Useful for GDPR compliance or storage cleanup.
|
|
242
|
+
|
|
222
243
|
### Rollback
|
|
223
244
|
|
|
224
245
|
Bad consolidation? Undo it:
|
|
@@ -268,20 +289,38 @@ const id = await brain.encode({
|
|
|
268
289
|
|
|
269
290
|
Episodes are **immutable**. Corrections create new records with `supersedes` links. The original is preserved.
|
|
270
291
|
|
|
292
|
+
### `brain.encodeBatch(paramsList)` → `Promise<string[]>`
|
|
293
|
+
|
|
294
|
+
Encode multiple episodes in one call. Same params as `encode()`, but as an array.
|
|
295
|
+
|
|
296
|
+
```js
|
|
297
|
+
const ids = await brain.encodeBatch([
|
|
298
|
+
{ content: 'Stripe returned 429', source: 'direct-observation' },
|
|
299
|
+
{ content: 'Redis timed out', source: 'tool-result' },
|
|
300
|
+
{ content: 'User reports slow checkout', source: 'told-by-user' },
|
|
301
|
+
]);
|
|
302
|
+
```
|
|
303
|
+
|
|
271
304
|
### `brain.recall(query, options)` → `Promise<Memory[]>`
|
|
272
305
|
|
|
273
306
|
Retrieve memories ranked by `similarity * confidence`.
|
|
274
307
|
|
|
275
308
|
```js
|
|
276
309
|
const memories = await brain.recall('stripe rate limits', {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
includeProvenance: true,
|
|
281
|
-
includeDormant: false,
|
|
310
|
+
limit: 5, // Max results (default 10)
|
|
311
|
+
minConfidence: 0.5, // Filter below this confidence
|
|
312
|
+
types: ['semantic'], // Filter by memory type
|
|
313
|
+
includeProvenance: true, // Include evidence chains
|
|
314
|
+
includeDormant: false, // Include dormant memories
|
|
315
|
+
tags: ['rate-limit'], // Only episodic memories with these tags
|
|
316
|
+
sources: ['direct-observation'], // Only episodic memories from these sources
|
|
317
|
+
after: '2026-02-01T00:00:00Z', // Only memories created after this date
|
|
318
|
+
before: '2026-03-01T00:00:00Z', // Only memories created before this date
|
|
282
319
|
});
|
|
283
320
|
```
|
|
284
321
|
|
|
322
|
+
Tag and source filters only apply to episodic memories (semantic and procedural memories don't have tags or sources). Date filters apply to all memory types.
|
|
323
|
+
|
|
285
324
|
Each result:
|
|
286
325
|
|
|
287
326
|
```js
|
|
@@ -304,21 +343,9 @@ Each result:
|
|
|
304
343
|
|
|
305
344
|
Retrieval automatically reinforces matched memories (boosts confidence, resets decay clock).
|
|
306
345
|
|
|
307
|
-
### `brain.encodeBatch(paramsList)` → `Promise<string[]>`
|
|
308
|
-
|
|
309
|
-
Encode multiple episodes in one call. Same params as `encode()`, but as an array.
|
|
310
|
-
|
|
311
|
-
```js
|
|
312
|
-
const ids = await brain.encodeBatch([
|
|
313
|
-
{ content: 'Stripe returned 429', source: 'direct-observation' },
|
|
314
|
-
{ content: 'Redis timed out', source: 'tool-result' },
|
|
315
|
-
{ content: 'User reports slow checkout', source: 'told-by-user' },
|
|
316
|
-
]);
|
|
317
|
-
```
|
|
318
|
-
|
|
319
346
|
### `brain.recallStream(query, options)` → `AsyncGenerator<Memory>`
|
|
320
347
|
|
|
321
|
-
Streaming version of `recall()`. Yields results one at a time. Supports early `break`.
|
|
348
|
+
Streaming version of `recall()`. Yields results one at a time. Supports early `break`. Same options as `recall()`.
|
|
322
349
|
|
|
323
350
|
```js
|
|
324
351
|
for await (const memory of brain.recallStream('stripe issues', { limit: 10 })) {
|
|
@@ -327,6 +354,37 @@ for await (const memory of brain.recallStream('stripe issues', { limit: 10 })) {
|
|
|
327
354
|
}
|
|
328
355
|
```
|
|
329
356
|
|
|
357
|
+
### `brain.forget(id, options)` → `ForgetResult`
|
|
358
|
+
|
|
359
|
+
Forget a memory by ID. Works on any memory type (episodic, semantic, procedural).
|
|
360
|
+
|
|
361
|
+
```js
|
|
362
|
+
brain.forget(memoryId); // soft-delete
|
|
363
|
+
brain.forget(memoryId, { purge: true }); // hard-delete (permanent)
|
|
364
|
+
// { id, type: 'episodic', purged: false }
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### `brain.forgetByQuery(query, options)` → `Promise<ForgetResult | null>`
|
|
368
|
+
|
|
369
|
+
Find the closest matching memory by semantic search and forget it. Searches all three memory types, picks the best match.
|
|
370
|
+
|
|
371
|
+
```js
|
|
372
|
+
const result = await brain.forgetByQuery('old API endpoint', {
|
|
373
|
+
minSimilarity: 0.9, // Threshold for match (default 0.9)
|
|
374
|
+
purge: false, // Hard-delete? (default false)
|
|
375
|
+
});
|
|
376
|
+
// null if no match above threshold
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### `brain.purge()` → `PurgeCounts`
|
|
380
|
+
|
|
381
|
+
Bulk hard-delete all dead memories: forgotten episodes, dormant/superseded/rolled-back semantics and procedures.
|
|
382
|
+
|
|
383
|
+
```js
|
|
384
|
+
const counts = brain.purge();
|
|
385
|
+
// { episodes: 12, semantics: 3, procedures: 0 }
|
|
386
|
+
```
|
|
387
|
+
|
|
330
388
|
### `brain.consolidate(options)` → `Promise<ConsolidationResult>`
|
|
331
389
|
|
|
332
390
|
Run the consolidation engine manually.
|
|
@@ -389,6 +447,15 @@ brain.introspect();
|
|
|
389
447
|
|
|
390
448
|
Full audit trail of all consolidation runs.
|
|
391
449
|
|
|
450
|
+
### `brain.export()` / `brain.import(snapshot)`
|
|
451
|
+
|
|
452
|
+
Export all memories as a JSON snapshot, or import from one.
|
|
453
|
+
|
|
454
|
+
```js
|
|
455
|
+
const snapshot = brain.export(); // { version, episodes, semantics, procedures, ... }
|
|
456
|
+
await brain.import(snapshot); // Re-embeds everything with current provider
|
|
457
|
+
```
|
|
458
|
+
|
|
392
459
|
### Events
|
|
393
460
|
|
|
394
461
|
```js
|
|
@@ -398,6 +465,9 @@ brain.on('contradiction', ({ episodeId, contradictionId, semanticId, resolution
|
|
|
398
465
|
brain.on('consolidation', ({ runId, principlesExtracted }) => { ... });
|
|
399
466
|
brain.on('decay', ({ totalEvaluated, transitionedToDormant }) => { ... });
|
|
400
467
|
brain.on('rollback', ({ runId, rolledBackMemories }) => { ... });
|
|
468
|
+
brain.on('forget', ({ id, type, purged }) => { ... });
|
|
469
|
+
brain.on('purge', ({ episodes, semantics, procedures }) => { ... });
|
|
470
|
+
brain.on('migration', ({ episodes, semantics, procedures }) => { ... });
|
|
401
471
|
brain.on('error', (err) => { ... });
|
|
402
472
|
```
|
|
403
473
|
|
|
@@ -409,7 +479,7 @@ Close the database connection.
|
|
|
409
479
|
|
|
410
480
|
```
|
|
411
481
|
audrey-data/
|
|
412
|
-
audrey.db
|
|
482
|
+
audrey.db <- Single SQLite file. WAL mode. That's your brain.
|
|
413
483
|
```
|
|
414
484
|
|
|
415
485
|
```
|
|
@@ -417,22 +487,27 @@ src/
|
|
|
417
487
|
audrey.js Main class. EventEmitter. Public API surface.
|
|
418
488
|
causal.js Causal graph management. LLM-powered mechanism articulation.
|
|
419
489
|
confidence.js Compositional confidence formula. Pure math.
|
|
420
|
-
consolidate.js "Sleep" cycle. KNN clustering
|
|
490
|
+
consolidate.js "Sleep" cycle. KNN clustering -> LLM extraction -> promote.
|
|
421
491
|
db.js SQLite + sqlite-vec. Schema, vec0 tables, migrations.
|
|
422
492
|
decay.js Ebbinghaus forgetting curves.
|
|
423
493
|
embedding.js Pluggable providers (Mock, OpenAI). Batch embedding.
|
|
424
494
|
encode.js Immutable episodic memory creation + vec0 writes.
|
|
495
|
+
forget.js Soft-delete, hard-delete, query-based forget, bulk purge.
|
|
425
496
|
introspect.js Health dashboard queries.
|
|
426
497
|
llm.js Pluggable LLM providers (Mock, Anthropic, OpenAI).
|
|
427
498
|
prompts.js Structured prompt templates for LLM operations.
|
|
428
|
-
recall.js KNN retrieval + confidence scoring +
|
|
499
|
+
recall.js KNN retrieval + confidence scoring + filtered recall + streaming.
|
|
429
500
|
rollback.js Undo consolidation runs.
|
|
430
501
|
utils.js Date math, safe JSON parse.
|
|
431
502
|
validate.js KNN validation + LLM contradiction detection.
|
|
503
|
+
migrate.js Dimension migration re-embedding.
|
|
504
|
+
adaptive.js Adaptive consolidation parameter suggestions.
|
|
505
|
+
export.js Memory export (JSON snapshots).
|
|
506
|
+
import.js Memory import with re-embedding.
|
|
432
507
|
index.js Barrel export.
|
|
433
508
|
|
|
434
509
|
mcp-server/
|
|
435
|
-
index.js MCP tool server (
|
|
510
|
+
index.js MCP tool server (9 tools, stdio transport) + CLI subcommands.
|
|
436
511
|
config.js Shared config (env var parsing, install arg builder).
|
|
437
512
|
```
|
|
438
513
|
|
|
@@ -456,7 +531,7 @@ All mutations use SQLite transactions. CHECK constraints enforce valid states an
|
|
|
456
531
|
## Running Tests
|
|
457
532
|
|
|
458
533
|
```bash
|
|
459
|
-
npm test #
|
|
534
|
+
npm test # 278 tests across 23 files
|
|
460
535
|
npm run test:watch
|
|
461
536
|
```
|
|
462
537
|
|
|
@@ -466,115 +541,60 @@ npm run test:watch
|
|
|
466
541
|
node examples/stripe-demo.js
|
|
467
542
|
```
|
|
468
543
|
|
|
469
|
-
Demonstrates the full pipeline: encode 3 rate-limit observations
|
|
544
|
+
Demonstrates the full pipeline: encode 3 rate-limit observations, consolidate into principle, recall proactively.
|
|
470
545
|
|
|
471
546
|
---
|
|
472
547
|
|
|
473
|
-
##
|
|
548
|
+
## Changelog
|
|
474
549
|
|
|
475
|
-
### v0.
|
|
550
|
+
### v0.6.0 — Filtered Recall + Forget (current)
|
|
476
551
|
|
|
477
|
-
-
|
|
478
|
-
-
|
|
479
|
-
-
|
|
480
|
-
-
|
|
481
|
-
-
|
|
482
|
-
-
|
|
483
|
-
- [x] Retrieval reinforcement (frequently accessed memories resist decay)
|
|
484
|
-
- [x] Consolidation engine with clustering and principle extraction
|
|
485
|
-
- [x] Idempotent consolidation with checkpoint cursors
|
|
486
|
-
- [x] Full consolidation audit trail (input/output IDs per run)
|
|
487
|
-
- [x] Consolidation rollback (undo bad runs, restore episodes)
|
|
488
|
-
- [x] Contradiction lifecycle (open/resolved/context_dependent/reopened)
|
|
489
|
-
- [x] Circular self-confirmation defense (model-generated cap at 0.6)
|
|
490
|
-
- [x] Source type diversity tracking on semantic memories
|
|
491
|
-
- [x] Supersedes links for correcting episodic memories
|
|
492
|
-
- [x] Pluggable embedding providers (Mock for tests, OpenAI for production)
|
|
493
|
-
- [x] Causal context storage (trigger/consequence per episode)
|
|
494
|
-
- [x] Introspection API (memory counts, contradiction stats, consolidation history)
|
|
495
|
-
- [x] EventEmitter lifecycle hooks (encode, reinforcement, consolidation, decay, rollback, error)
|
|
496
|
-
- [x] SQLite with WAL mode, CHECK constraints, indexes, foreign keys
|
|
497
|
-
- [x] Transaction safety on all multi-step mutations
|
|
498
|
-
- [x] Input validation on public API (content, salience, tags, source)
|
|
499
|
-
- [x] Shared utility extraction (cosine similarity, date math, safe JSON parse)
|
|
500
|
-
- [x] 104 tests across 12 test files
|
|
501
|
-
- [x] Proof-of-concept demo (Stripe rate limit scenario)
|
|
552
|
+
- Filtered recall: tag, source, and date-range filters on `recall()` and `recallStream()`
|
|
553
|
+
- `forget()` — soft-delete any memory by ID
|
|
554
|
+
- `forgetByQuery()` — find closest match by semantic search and forget it
|
|
555
|
+
- `purge()` — bulk hard-delete all forgotten/dormant/superseded memories
|
|
556
|
+
- `memory_forget` and `memory_decay` MCP tools (9 tools total)
|
|
557
|
+
- 278 tests across 23 files
|
|
502
558
|
|
|
503
|
-
### v0.
|
|
559
|
+
### v0.5.0 — Feature Depth
|
|
504
560
|
|
|
505
|
-
-
|
|
506
|
-
-
|
|
507
|
-
-
|
|
508
|
-
-
|
|
509
|
-
-
|
|
510
|
-
-
|
|
511
|
-
|
|
512
|
-
|
|
561
|
+
- Configurable confidence weights and decay rates per instance
|
|
562
|
+
- Memory export/import (JSON snapshots with re-embedding)
|
|
563
|
+
- `memory_export` and `memory_import` MCP tools
|
|
564
|
+
- Auto-consolidation scheduling
|
|
565
|
+
- Adaptive consolidation parameter suggestions
|
|
566
|
+
- 243 tests across 22 files
|
|
567
|
+
|
|
568
|
+
### v0.3.1 — MCP Server
|
|
569
|
+
|
|
570
|
+
- MCP tool server via `@modelcontextprotocol/sdk` with stdio transport
|
|
571
|
+
- One-command install: `npx audrey install` (auto-detects API keys)
|
|
572
|
+
- CLI subcommands: `install`, `uninstall`, `status`
|
|
573
|
+
- JSDoc type annotations on all public exports
|
|
574
|
+
- Published to npm
|
|
575
|
+
- 194 tests across 17 files
|
|
513
576
|
|
|
514
577
|
### v0.3.0 — Vector Performance
|
|
515
578
|
|
|
516
|
-
-
|
|
517
|
-
-
|
|
518
|
-
-
|
|
519
|
-
-
|
|
520
|
-
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
-
|
|
532
|
-
-
|
|
533
|
-
-
|
|
534
|
-
-
|
|
535
|
-
|
|
536
|
-
### v0.5.0 — Feature Depth (current)
|
|
537
|
-
|
|
538
|
-
- [x] Configurable confidence weights per Audrey instance
|
|
539
|
-
- [x] Configurable decay rates (half-lives) per Audrey instance
|
|
540
|
-
- [x] Confidence config wired through constructor to recall and decay
|
|
541
|
-
- [x] Memory export (JSON snapshot of all tables, no raw embeddings)
|
|
542
|
-
- [x] Memory import with automatic re-embedding via current provider
|
|
543
|
-
- [x] `memory_export` and `memory_import` MCP tools (7 tools total)
|
|
544
|
-
- [x] Auto-consolidation scheduling (`startAutoConsolidate` / `stopAutoConsolidate`)
|
|
545
|
-
- [x] Consolidation metrics tracking (per-run params and results)
|
|
546
|
-
- [x] Adaptive consolidation parameter suggestions based on historical yield
|
|
547
|
-
- [x] 220+ tests across 20 test files
|
|
548
|
-
|
|
549
|
-
### v0.4.0 — Type Safety & Developer Experience
|
|
550
|
-
|
|
551
|
-
- [ ] Full TypeScript conversion with strict mode
|
|
552
|
-
- [ ] Published type declarations (.d.ts)
|
|
553
|
-
- [ ] Schema versioning and migration system
|
|
554
|
-
- [ ] Structured logging (optional, pluggable)
|
|
555
|
-
|
|
556
|
-
### v0.4.5 — Embedding Migration (deferred from v0.3.0)
|
|
557
|
-
|
|
558
|
-
- [ ] Embedding migration pipeline (re-embed when models change)
|
|
559
|
-
- [ ] Re-consolidation queue (re-run consolidation with new embedding model)
|
|
560
|
-
|
|
561
|
-
### v0.6.0 — Scale
|
|
562
|
-
|
|
563
|
-
- [ ] pgvector adapter for PostgreSQL backend
|
|
564
|
-
- [ ] Redis adapter for distributed caching
|
|
565
|
-
- [ ] Connection pooling for concurrent agent access
|
|
566
|
-
- [ ] Pagination on recall queries (cursor-based)
|
|
567
|
-
- [ ] Benchmarks: encode throughput, recall latency at 10k/100k/1M memories
|
|
568
|
-
|
|
569
|
-
### v1.0.0 — Production Ready
|
|
570
|
-
|
|
571
|
-
- [ ] Comprehensive error handling at all boundaries
|
|
572
|
-
- [ ] Rate limiting on embedding API calls
|
|
573
|
-
- [ ] Memory usage profiling and optimization
|
|
574
|
-
- [ ] Security audit (injection, data isolation)
|
|
575
|
-
- [ ] Cross-agent knowledge sharing protocol (Hivemind)
|
|
576
|
-
- [ ] Documentation site
|
|
577
|
-
- [ ] Integration guides (LangChain, CrewAI, Claude Code, custom agents)
|
|
579
|
+
- sqlite-vec native vector indexing (vec0 virtual tables with cosine distance)
|
|
580
|
+
- KNN queries for recall, validation, and consolidation clustering
|
|
581
|
+
- Batch encoding API and streaming recall with async generators
|
|
582
|
+
- Dimension configuration and automatic migration from v0.2.0
|
|
583
|
+
- 168 tests across 16 files
|
|
584
|
+
|
|
585
|
+
### v0.2.0 — LLM Integration
|
|
586
|
+
|
|
587
|
+
- LLM-powered principle extraction, contradiction detection, causal articulation
|
|
588
|
+
- Context-dependent truth resolution
|
|
589
|
+
- Configurable LLM providers (Mock, Anthropic, OpenAI)
|
|
590
|
+
- 142 tests across 15 files
|
|
591
|
+
|
|
592
|
+
### v0.1.0 — Foundation
|
|
593
|
+
|
|
594
|
+
- Immutable episodic memory, compositional confidence, Ebbinghaus forgetting curves
|
|
595
|
+
- Consolidation engine, contradiction lifecycle, rollback
|
|
596
|
+
- Circular self-confirmation defense, causal context, introspection
|
|
597
|
+
- 104 tests across 12 files
|
|
578
598
|
|
|
579
599
|
## Design Decisions
|
|
580
600
|
|
|
@@ -586,7 +606,7 @@ Demonstrates the full pipeline: encode 3 rate-limit observations → consolidate
|
|
|
586
606
|
|
|
587
607
|
**Why model-generated cap at 0.6?** Prevents the most dangerous exploit in AI memory: circular self-confirmation where an agent's own inferences bootstrap themselves into high-confidence "facts" through repeated retrieval.
|
|
588
608
|
|
|
589
|
-
**Why
|
|
609
|
+
**Why soft-delete by default?** Hard-deletes are irreversible. Soft-delete preserves data integrity and audit trails while excluding the memory from recall. Use `purge: true` or `brain.purge()` when you need permanent removal (GDPR, storage cleanup).
|
|
590
610
|
|
|
591
611
|
## License
|
|
592
612
|
|
package/mcp-server/config.js
CHANGED
package/mcp-server/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function install() {
|
|
|
65
65
|
console.log(`
|
|
66
66
|
Audrey registered as "${SERVER_NAME}" with Claude Code.
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
9 tools available in every session:
|
|
69
69
|
memory_encode — Store observations, facts, preferences
|
|
70
70
|
memory_recall — Search memories by semantic similarity
|
|
71
71
|
memory_consolidate — Extract principles from accumulated episodes
|
|
@@ -73,6 +73,8 @@ Audrey registered as "${SERVER_NAME}" with Claude Code.
|
|
|
73
73
|
memory_resolve_truth — Resolve contradictions between claims
|
|
74
74
|
memory_export — Export all memories as JSON snapshot
|
|
75
75
|
memory_import — Import a snapshot into a fresh database
|
|
76
|
+
memory_forget — Forget a specific memory by ID or query
|
|
77
|
+
memory_decay — Apply forgetting curves, transition low-confidence to dormant
|
|
76
78
|
|
|
77
79
|
Data stored in: ${DEFAULT_DATA_DIR}
|
|
78
80
|
Verify: claude mcp list
|
|
@@ -161,10 +163,11 @@ async function main() {
|
|
|
161
163
|
source: z.enum(VALID_SOURCES).describe('Source type of the memory'),
|
|
162
164
|
tags: z.array(z.string()).optional().describe('Optional tags for categorization'),
|
|
163
165
|
salience: z.number().min(0).max(1).optional().describe('Importance weight 0-1'),
|
|
166
|
+
context: z.record(z.string()).optional().describe('Situational context as key-value pairs (e.g., {task: "debugging", domain: "payments"})'),
|
|
164
167
|
},
|
|
165
|
-
async ({ content, source, tags, salience }) => {
|
|
168
|
+
async ({ content, source, tags, salience, context }) => {
|
|
166
169
|
try {
|
|
167
|
-
const id = await audrey.encode({ content, source, tags, salience });
|
|
170
|
+
const id = await audrey.encode({ content, source, tags, salience, context });
|
|
168
171
|
return toolResult({ id, content, source });
|
|
169
172
|
} catch (err) {
|
|
170
173
|
return toolError(err);
|
|
@@ -179,13 +182,23 @@ async function main() {
|
|
|
179
182
|
limit: z.number().min(1).max(50).optional().describe('Max results (default 10)'),
|
|
180
183
|
types: z.array(z.enum(VALID_TYPES)).optional().describe('Memory types to search'),
|
|
181
184
|
min_confidence: z.number().min(0).max(1).optional().describe('Minimum confidence threshold'),
|
|
185
|
+
tags: z.array(z.string()).optional().describe('Only return episodic memories with these tags'),
|
|
186
|
+
sources: z.array(z.enum(VALID_SOURCES)).optional().describe('Only return episodic memories from these sources'),
|
|
187
|
+
after: z.string().optional().describe('Only return memories created after this ISO date'),
|
|
188
|
+
before: z.string().optional().describe('Only return memories created before this ISO date'),
|
|
189
|
+
context: z.record(z.string()).optional().describe('Retrieval context — memories encoded in matching context get boosted'),
|
|
182
190
|
},
|
|
183
|
-
async ({ query, limit, types, min_confidence }) => {
|
|
191
|
+
async ({ query, limit, types, min_confidence, tags, sources, after, before, context }) => {
|
|
184
192
|
try {
|
|
185
193
|
const results = await audrey.recall(query, {
|
|
186
194
|
limit: limit ?? 10,
|
|
187
195
|
types,
|
|
188
196
|
minConfidence: min_confidence,
|
|
197
|
+
tags,
|
|
198
|
+
sources,
|
|
199
|
+
after,
|
|
200
|
+
before,
|
|
201
|
+
context,
|
|
189
202
|
});
|
|
190
203
|
return toolResult(results);
|
|
191
204
|
} catch (err) {
|
|
@@ -279,6 +292,53 @@ async function main() {
|
|
|
279
292
|
},
|
|
280
293
|
);
|
|
281
294
|
|
|
295
|
+
server.tool(
|
|
296
|
+
'memory_forget',
|
|
297
|
+
{
|
|
298
|
+
id: z.string().optional().describe('ID of the memory to forget'),
|
|
299
|
+
query: z.string().optional().describe('Semantic query to find and forget the closest matching memory'),
|
|
300
|
+
min_similarity: z.number().min(0).max(1).optional().describe('Minimum similarity for query-based forget (default 0.9)'),
|
|
301
|
+
purge: z.boolean().optional().describe('Hard-delete the memory permanently (default false, soft-delete)'),
|
|
302
|
+
},
|
|
303
|
+
async ({ id, query, min_similarity, purge }) => {
|
|
304
|
+
try {
|
|
305
|
+
if (!id && !query) {
|
|
306
|
+
return toolError(new Error('Provide either id or query'));
|
|
307
|
+
}
|
|
308
|
+
let result;
|
|
309
|
+
if (id) {
|
|
310
|
+
result = audrey.forget(id, { purge: purge ?? false });
|
|
311
|
+
} else {
|
|
312
|
+
result = await audrey.forgetByQuery(query, {
|
|
313
|
+
minSimilarity: min_similarity ?? 0.9,
|
|
314
|
+
purge: purge ?? false,
|
|
315
|
+
});
|
|
316
|
+
if (!result) {
|
|
317
|
+
return toolResult({ forgotten: false, reason: 'No memory found above similarity threshold' });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return toolResult({ forgotten: true, ...result });
|
|
321
|
+
} catch (err) {
|
|
322
|
+
return toolError(err);
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
server.tool(
|
|
328
|
+
'memory_decay',
|
|
329
|
+
{
|
|
330
|
+
dormant_threshold: z.number().min(0).max(1).optional().describe('Confidence below which memories go dormant (default 0.1)'),
|
|
331
|
+
},
|
|
332
|
+
async ({ dormant_threshold }) => {
|
|
333
|
+
try {
|
|
334
|
+
const result = audrey.decay({ dormantThreshold: dormant_threshold });
|
|
335
|
+
return toolResult(result);
|
|
336
|
+
} catch (err) {
|
|
337
|
+
return toolError(err);
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
);
|
|
341
|
+
|
|
282
342
|
const transport = new StdioServerTransport();
|
|
283
343
|
await server.connect(transport);
|
|
284
344
|
console.error('[audrey-mcp] connected via stdio');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "audrey",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Biological memory architecture for AI agents — encode, consolidate, and recall memories with confidence decay, contradiction detection, and causal graphs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|