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.
- package/README.md +45 -194
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,229 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Superbrain Fabric Node.js SDK (V5.1) π§ β¨
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://github.com/golightstep/superbrainSdk/blob/main/LICENSE)
|
|
5
|
-
[](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
|
-
##
|
|
7
|
+
## π The Soul Expansion (V5.1 Breakthroughs)
|
|
16
8
|
|
|
17
|
-
|
|
9
|
+
V5.1 transitions Superbrain Fabric from a fast storage layer into a **Cognitive Organism**.
|
|
18
10
|
|
|
19
|
-
###
|
|
20
|
-
|
|
21
|
-
- **
|
|
22
|
-
- **Semantic
|
|
23
|
-
- **
|
|
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
|
-
###
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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 {
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
import { SuperbrainClient } from 'superbrain-distributed-sdk';
|
|
39
|
+
// Connect to the Fabric
|
|
40
|
+
const client = new Client("coordinator:50050");
|
|
88
41
|
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
53
|
+
### 3. Relational Discovery (Knowledge Graph)
|
|
102
54
|
```typescript
|
|
103
|
-
//
|
|
104
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
##
|
|
184
|
-
|
|
185
|
-
|
|
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
|
|
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.
|
|
4
|
-
"description": "
|
|
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
|
-
"
|
|
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
|
],
|