@the-brain/core 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +101 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @the-brain/core
2
+
3
+ LLM-agnostic cognitive memory framework with biologically-inspired decay, synapses, and Graph RAG.
4
+
5
+ ## What it does
6
+
7
+ - **Memory that forgets** — entries decay over time, strong ones get consolidated to long-term memory
8
+ - **Synaptic connections** — weighted links between related entries, traversed like a graph
9
+ - **Hybrid intent routing** — AI classification with rule-based fallback (works with local or cloud LLMs)
10
+ - **User profile adaptation** — Brain learns your communication style and adapts responses
11
+ - **PDF ingest** — feed documents as permanent memory (`isPermanent=true`, never decays)
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @the-brain/core
17
+ # plus a storage adapter:
18
+ npm install @the-brain/adapter-mongo # MongoDB (recommended)
19
+ npm install @the-brain/adapter-sqlite # SQLite (zero-config)
20
+ ```
21
+
22
+ ## Quick start
23
+
24
+ ```typescript
25
+ import { Brain, OpenAICompatibleAdapter } from "@the-brain/core";
26
+ import { SQLiteStorageAdapter } from "@the-brain/adapter-sqlite";
27
+
28
+ const brain = new Brain(
29
+ new OpenAICompatibleAdapter(
30
+ "http://localhost:11434/v1/chat/completions", // any OpenAI-compatible endpoint
31
+ "llama3.2"
32
+ ),
33
+ new SQLiteStorageAdapter("./.brain")
34
+ );
35
+
36
+ await brain.loadActions();
37
+
38
+ // Save a fact
39
+ await brain.save("user-1", "I prefer TypeScript over JavaScript");
40
+
41
+ // Ask a question — Brain routes intent and searches memory
42
+ const result = await brain.process("user-1", "What do I prefer for coding?");
43
+ console.log(result.answer);
44
+
45
+ // Direct memory recall
46
+ const context = await brain.recall("user-1", "TypeScript preferences");
47
+ console.log(context.synapticTree);
48
+ ```
49
+
50
+ ## Works with any LLM
51
+
52
+ ```typescript
53
+ // Local (Ollama, LM Studio)
54
+ new OpenAICompatibleAdapter("http://localhost:11434/v1/chat/completions", "llama3.2")
55
+
56
+ // Groq (free, fast)
57
+ new OpenAICompatibleAdapter(
58
+ "https://api.groq.com/openai/v1/chat/completions",
59
+ "llama-3.3-70b-versatile",
60
+ process.env.GROQ_API_KEY
61
+ )
62
+
63
+ // OpenAI
64
+ new OpenAICompatibleAdapter(
65
+ "https://api.openai.com/v1/chat/completions",
66
+ "gpt-4o",
67
+ process.env.OPENAI_API_KEY
68
+ )
69
+ ```
70
+
71
+ ## Custom actions
72
+
73
+ ```typescript
74
+ await brain.registerAction(
75
+ "TRADING_SIGNAL",
76
+ "user asks about trading signals or market analysis",
77
+ async (userId, text, { synapticTree }, llm) => {
78
+ // your handler logic
79
+ return "Signal: BUY BTC — confidence 72%";
80
+ }
81
+ );
82
+ ```
83
+
84
+ ## Memory lifecycle
85
+
86
+ ```
87
+ Save entry (strength=5)
88
+ → Conscious processor: analyze, build synapses, consolidate strong entries to LTM
89
+ → Subconscious routine: decay inactive entries, prune dead ones
90
+ → Long-term memory: strength ≥ 10 → permanent summary created
91
+ ```
92
+
93
+ Run maintenance manually or let Brain trigger it automatically every N saves:
94
+
95
+ ```typescript
96
+ const { subStats, consciousStats } = await brain.runMaintenance();
97
+ ```
98
+
99
+ ## License
100
+
101
+ AGPL-3.0 — [github.com/greg00ry/the-brain](https://github.com/greg00ry/the-brain)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-brain/core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "LLM-agnostic cognitive memory framework — biologically-inspired decay, synapses, Graph RAG",
5
5
  "license": "AGPL-3.0",
6
6
  "publishConfig": {