superbrain-fabric-sdk 5.0.0 β†’ 5.1.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.
Files changed (2) hide show
  1. package/README.md +45 -194
  2. package/package.json +7 -6
package/README.md CHANGED
@@ -1,229 +1,80 @@
1
- # 🧠 superbrain-fabric-sdk v5.0.0 β€” TypeScript/Node.js
1
+ # Superbrain Fabric Node.js SDK (V5.1) 🧠✨
2
2
 
3
- [![npm version](https://badge.fury.io/js/superbrain-fabric-sdk.svg)](https://badge.fury.io/js/superbrain-fabric-sdk)
4
- [![License: BSL 1.1](https://img.shields.io/badge/License-BSL%201.1-blue.svg)](https://github.com/golightstep/superbrainSdk/blob/main/LICENSE)
5
- [![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)](https://nodejs.org)
6
-
7
- > **The Distributed RAM Fabric for AI Agents** β€” Share terabytes of context across your LLM cluster at microsecond speeds using 36-byte UUID pointers.
8
-
9
- ---
10
-
11
- πŸ”₯ **v5.0.0-cognitive: The Cognitive Fabric Update** is now live!
3
+ **Superbrain Fabric** is a high-performance, distributed cognitive RAM fabric. This SDK allows your AI agents to treat memory as an active, self-reflecting participant in their reasoning loops.
12
4
 
13
5
  ---
14
6
 
15
- ## ⚑ v3.0.0-cognitive Highlights
7
+ ## πŸ’Ž The Soul Expansion (V5.1 Breakthroughs)
16
8
 
17
- This major release transforms the Node.js SDK into a microsecond-latency **Active Memory Tier**.
9
+ V5.1 transitions Superbrain Fabric from a fast storage layer into a **Cognitive Organism**.
18
10
 
19
- ### Key Highlights:
20
- - **Durable Persistence**: Full support for WAL-backed storage nodes (FileStore/Redis/Postgres).
21
- - **Coordinator Bypass**: 100x faster pointer resolution via local metadata caching.
22
- - **Semantic Triggers**: Subscribe to memory offsets and get notified when agents write with specific intents.
23
- - **Zero-Copy SHM**: Optimized FFI for direct `/dev/shm` access on Linux.
11
+ ### πŸ“‰ Layered Cognitive Compression (LCC)
12
+ Achieve **11-38x token reduction** before data ever hits the wire.
13
+ - **Level 1 (Deterministic)**: Prunes structural noise (HTML/JSON boilerplate).
14
+ - **Level 2 (Semantic)**: Prevents redundant writes via Jaccard-deduplication.
15
+ - **Level 3 (Extractive)**: Consolidates long contexts into extractive summaries.
24
16
 
25
- ### 🧠 Example: Semantic Memory Trigger
26
- ```typescript
27
- import { SuperbrainFabricClient } from 'superbrain-fabric-sdk';
17
+ ### πŸ•°οΈ Memory History (The Hippocampus)
18
+ 100% auditable lineage. Retrieve the full versioned history of any memory block to understand why an agent modified a belief.
28
19
 
29
- const client = new SuperbrainFabricClient('localhost:50050');
20
+ ### πŸ•ΈοΈ Knowledge Graph (The Cortical Mesh)
21
+ Distributed relational memory. Link memories via explicit edges (`supports`, `contradicts`, `part-of`) and traverse them via recursive discovery.
30
22
 
31
- // Subscribe to "User Intent" updates across the whole cluster
32
- client.semanticSubscribe('User Intent', (notify) => {
33
- console.log(`🧠 Neural Trigger: ${notify.snippet}`);
34
- console.log(`Intent detected: ${notify.intent}`);
35
- });
23
+ ### πŸͺž MIRROR Tier (Stability)
24
+ Use Lyapunov-inspired stability loops to protect critical reasoning blocks from the automatic decay cycles.
36
25
 
37
- // Write with cognitive enrichment
38
- await client.writeCognitive(ptr, 0, data, {
39
- liveliness: 0.8,
40
- intent: 'User Intent',
41
- summary: 'Updating user preference profile',
42
- tag: 'Preference'
43
- });
44
- ```
26
+ ---
45
27
 
46
- ## πŸ“¦ Installation
28
+ ## πŸš€ Quickstart
47
29
 
30
+ ### 1. Installation
48
31
  ```bash
49
32
  npm install superbrain-fabric-sdk
50
33
  ```
51
34
 
52
- ---
53
-
54
- ## πŸš€ New in v3.0.0-cognitive β€” Active Memory & Coordinator Bypass
55
- Version 3.0.0 introduces the ability to operate as a microsecond-latency **Active Memory Tier** for agent architectures.
56
-
57
- - **Coordinator Bypass**: Metadata is cached locally, eliminating the gRPC hop to the Coordinator for established pointers.
58
- - **Zero-Copy SHM**: When the SDK detects a co-located Memory Node (`127.0.0.1`), it seamlessly switches from gRPC streaming to direct `/dev/shm` memory-mapped file access.
59
- - **13.5Β΅s Native Latency**: The Native Go core bypass achieves microsecond speed, bypassing the network entirely for local agents.
60
-
61
- ---
62
-
63
- ## πŸ”§ Usage
64
-
65
- ### Basic β€” Shared Memory Between Agents
35
+ ### 2. High-Level Memory Write
66
36
  ```typescript
67
- import { SuperbrainFabricClient } from 'superbrain-fabric-sdk';
68
-
69
- const client = new SuperbrainFabricClient('localhost:50050');
70
- await client.register('my-agent-id');
71
-
72
- // Allocate distributed RAM
73
- const ptrId = await client.allocate(100 * 1024 * 1024); // 100 MB
74
-
75
- // Write from Agent A on Machine A
76
- await client.write(ptrId, 0, Buffer.from('Shared AI context'));
77
-
78
- // Read from Agent B on Machine B (just needs the 36-byte pointer!)
79
- const data = await client.read(ptrId, 0, 17);
80
-
81
- await client.free(ptrId);
82
- client.close();
83
- ```
37
+ import { Client } from 'superbrain-fabric-sdk';
84
38
 
85
- ### Advanced β€” Secure Fabric (E2EE)
86
- ```typescript
87
- import { SuperbrainClient } from 'superbrain-distributed-sdk';
39
+ // Connect to the Fabric
40
+ const client = new Client("coordinator:50050");
88
41
 
89
- // All data encrypted with AES-256-GCM at client level
90
- // Memory nodes NEVER see plaintext
91
- const client = new SuperbrainClient('localhost:50050', {
92
- encryptionKey: crypto.randomBytes(32)
42
+ // Write a memory with automated LCC Level 3 and Mirror protection
43
+ const ptrId = await client.writeMemory("Long research context...", {
44
+ liveliness: 0.9,
45
+ tag: "strategy",
46
+ lccLevel: 3,
47
+ mirrorReinforcement: true
93
48
  });
94
- await client.register('secure-agent');
95
49
 
96
- const ptr = await client.allocate(4 * 1024 * 1024);
97
- await client.write(ptr, 0, Buffer.from(JSON.stringify(sensitiveData)));
98
- const response = await client.read(ptr, 0, 0);
50
+ console.log(`Memory anchored at: ${ptrId}`);
99
51
  ```
100
52
 
101
- ### Multi-Agent Context Passing
53
+ ### 3. Relational Discovery (Knowledge Graph)
102
54
  ```typescript
103
- // Agent A writes β€” gets pointer
104
- const ctxPtr = await client.allocate(1024 * 1024);
105
- await client.write(ctxPtr, 0, Buffer.from(JSON.stringify({
106
- topic: "distributed AI inference",
107
- findings: researchResults,
108
- timestamp: Date.now()
109
- })));
110
-
111
- // Share the 36-byte pointer ID via any channel (HTTP, gRPC, etc.)
112
- broadcast({ contextPtr: ctxPtr }); // other agents connect immediately
113
-
114
- // Agent B reads β€” microseconds, no data copying
115
- const received = JSON.parse((await clientB.read(ctxPtr, 0, 0)).toString());
116
- ```
117
-
118
- ---
55
+ // Link two cognitive blocks
56
+ await client.addEdge(sourcePtr, targetPtr, "supports", 1.0);
119
57
 
120
- ## πŸ“Š Architecture
121
-
122
- ```
123
- Your LLM App (SDK) SuperBrain Cluster
124
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
125
- β”‚ allocate(size) ────────┼──(1)──► Coordinator (Control Plane)
126
- β”‚ free(ptr_id) ────────┼──(5)──► Maps pointers β†’ node locations
127
- β”‚ β”‚ β”‚
128
- β”‚ β”‚ (2) pointer map returned
129
- β”‚ β”‚ β”‚
130
- β”‚ write(ptr_id, data) ───┼──(3)β”€β”€β–Ίβ”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
131
- β”‚ read(ptr_id) ────────┼──(4)──►│ Memory Nodes β”‚
132
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ (Data Plane) β”‚
133
- β”‚ 1TB+ pooled RAM β”‚
134
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
135
-
136
- CRITICAL: write() and read() bypass the Coordinator entirely.
137
- They stream directly to the Memory Nodes over gRPC for maximum throughput (~100 MB/s).
138
- The Coordinator is ONLY in the control path (allocate + free).
58
+ // Query the mesh
59
+ const { edges, nodes } = await client.queryGraph(sourcePtr, 2);
139
60
  ```
140
61
 
141
- **Why this matters**: The Coordinator never becomes a bottleneck for your data. 1000 agents can read/write simultaneously to different nodes without fighting for the same control plane.
142
-
143
- ---
144
-
145
- ## 🧹 Memory Management
146
-
147
- > **The Node.js SDK exposes the raw client layer β€” `free()` is always required after `allocate()`.**
148
-
62
+ ### 4. Audit Trail (History)
149
63
  ```typescript
150
- // βœ… Always do this after you are done with a pointer
151
- const ptr = await client.allocate(100 * 1024 * 1024);
152
- await client.write(ptr, 0, data);
153
- const result = await client.read(ptr, 0, 0);
154
- await client.free(ptr); // ← required β€” leaks memory if skipped
155
- ```
156
-
157
- ### 🐍 Want Managed Memory? Use the Python SDK
158
-
159
- The Python SDK (`pip install superbrain-sdk`) provides higher-level APIs where **free() is never needed**:
160
-
161
- | Python API | Free needed? | What it does |
162
- |------------|:------------:|--------------|
163
- | `SharedContext.write("key", data)` | ❌ No | Key-based shared state across agents |
164
- | `fabric.store_kv_cache(prefix)` | ❌ No | Deduped prompt cache, auto-evicted |
165
- | `SuperBrainMemory` (LangChain) | ❌ No | Chat history in distributed RAM |
166
-
167
- ```python
168
- # Python β€” no free() ever needed with high-level APIs
169
- from superbrain import DistributedContextFabric
170
-
171
- fabric = DistributedContextFabric(coordinator="localhost:50050")
172
- ctx = fabric.create_context("session-42")
173
-
174
- ctx.write("state", {"step": 10}) # written to distributed RAM
175
- ctx.read("state") # read from any machine
176
- # No free() βœ…
64
+ // See how a memory evolved over time
65
+ const history = await client.getMemoryHistory(ptrId);
66
+ history.forEach(snap => {
67
+ console.log(`Version ${snap.version} tag: ${snap.tag}`);
68
+ });
177
69
  ```
178
70
 
179
- β†’ [Full Memory Management Guide](https://github.com/anispy211/superbrainSdk/blob/main/DOCUMENTATION.md#memory-management--when-to-free)
180
-
181
71
  ---
182
72
 
183
- ## πŸ” Security Features
184
-
185
- | Feature | Status |
186
- |---------|--------|
187
- | mTLS (mutual TLS between all nodes) | βœ… |
188
- | E2EE (AES-256-GCM at SDK level) | βœ… |
189
- | Pub/Sub (real-time memory notifications) | βœ… |
190
- | Per-context key rotation | βœ… (v0.2.0) |
191
- | Anomaly detection | βœ… (v0.2.0) |
192
- | GDPR/SOC2 audit logging | βœ… (v0.2.0) |
193
-
194
- ---
195
-
196
- ## πŸ—ΊοΈ Roadmap
197
-
198
- | Phase | Milestone | Features | Status |
199
- |-------|-----------|----------|--------|
200
- | **1** | **Distributed Fabric** | Multi-node RAM, Block I/O, P2P Gossip | βœ… Shipped |
201
- | **2** | **Secure Fabric** | mTLS, E2EE (AES-GCM), CA Authority | βœ… Shipped |
202
- | **3** | **Active Intelligence** | Cognitive Smart Layers, Durable WAL, Decay, FAISS | πŸš€ **Current** |
203
- | **4** | **Hardware Acceleration** | GPUDirect RDMA, NVMe Spilling (Cold Storage) | πŸ—οΈ Planned |
204
- | **5** | **Agent Harmony** | Raft-based Consensus Mirroring, Auto-Discovery | πŸ—οΈ Planned |
205
-
206
- ---
207
-
208
- ## πŸ“š Documentation
209
-
210
- - [Full Documentation & API Reference](https://github.com/anispy211/superbrainSdk/blob/main/DOCUMENTATION.md)
211
- - [GitHub Repository](https://github.com/anispy211/superbrainSdk)
212
- - [Main Server Repo](https://github.com/anispy211/memorypool)
213
-
214
- ---
215
-
216
- ## πŸ–₯️ Server Setup (Required)
217
-
218
- This SDK connects to a **SuperBrain coordinator**. To run one locally in 30 seconds:
219
-
220
- ```bash
221
- git clone https://github.com/anispy211/memorypool
222
- cd memorypool
223
- docker compose up -d
224
- # Dashboard: http://localhost:8080
225
- ```
73
+ ## πŸ›‘οΈ Security & Performance
74
+ - **E2EE**: Enable via `new Client(addr, Buffer.from(KEY))` for AES-256-GCM SDK-level protection.
75
+ - **Low Latency**: Automated **SHM Bypass** (<15ΞΌs) for co-located agents.
76
+ - **Durable Mode**: WAL-backed recovery support.
226
77
 
227
78
  ---
228
79
 
229
- MIT License Β· Built by [Anispy](https://github.com/anispy211)
80
+ MIT License Β· Built by **Anispy**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "superbrain-fabric-sdk",
3
- "version": "5.0.0",
4
- "description": "Premium High-Performance Distributed Memory Fabric SDK for AI Agents",
3
+ "version": "5.1.0",
4
+ "description": "Superbrain Fabric v5.1 β€” The Soul Expansion: LCC, Memory History, Knowledge Graph & MIRROR stability.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "repository": {
@@ -15,13 +15,14 @@
15
15
  "keywords": [
16
16
  "distributed-memory",
17
17
  "ai-agents",
18
- "kv-cache",
18
+ "cognitive-fabric",
19
+ "layered-compression",
20
+ "memory-history",
21
+ "knowledge-graph",
22
+ "mirror-tier",
19
23
  "langchain",
20
- "pytorch",
21
24
  "mcp",
22
25
  "grpc",
23
- "performance",
24
- "context-sharing",
25
26
  "llm",
26
27
  "rag"
27
28
  ],