superbrain-distributed-sdk 0.2.0 โ†’ 0.2.2

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 +55 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -90,22 +90,63 @@ const received = JSON.parse((await clientB.read(ctxPtr, 0, 0)).toString());
90
90
  ## ๐Ÿ“Š Architecture
91
91
 
92
92
  ```
93
- Your LLM App SuperBrain Cluster
94
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
95
- โ”‚ Node.js SDK โ”‚โ”€โ”€gRPCโ”€โ”€>โ”‚ Coordinator โ”‚
96
- โ”‚ โ”‚ โ”‚ (Control Plane) โ”‚
97
- โ”‚ allocate() โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
98
- โ”‚ write() โ”‚ โ”‚ pointer map
99
- โ”‚ read() โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
100
- โ”‚ free() โ”‚โ”€โ”€gRPCโ”€โ”€>โ”‚ Memory Nodes โ”‚
101
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ (Data Plane) โ”‚
102
- โ”‚ 1TB+ pooled RAM โ”‚
103
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
93
+ Your LLM App (SDK) SuperBrain Cluster
94
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
95
+ โ”‚ allocate(size) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€(1)โ”€โ”€โ–บ Coordinator (Control Plane)
96
+ โ”‚ free(ptr_id) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€(5)โ”€โ”€โ–บ Maps pointers โ†’ node locations
97
+ โ”‚ โ”‚ โ”‚
98
+ โ”‚ โ”‚ (2) pointer map returned
99
+ โ”‚ โ”‚ โ”‚
100
+ โ”‚ write(ptr_id, data) โ”€โ”€โ”€โ”ผโ”€โ”€(3)โ”€โ”€โ–บโ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
101
+ โ”‚ read(ptr_id) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€(4)โ”€โ”€โ–บโ”‚ Memory Nodes โ”‚
102
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ (Data Plane) โ”‚
103
+ โ”‚ 1TB+ pooled RAM โ”‚
104
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
105
+
106
+ CRITICAL: write() and read() bypass the Coordinator entirely.
107
+ They stream directly to the Memory Nodes over gRPC for maximum throughput (~100 MB/s).
108
+ The Coordinator is ONLY in the control path (allocate + free).
104
109
  ```
105
110
 
106
- **Control plane** (Coordinator): Routes allocation requests, maintains node registry.
107
- **Data plane** (Memory Nodes): Direct gRPC streams for maximum throughput.
108
- **Client**: Talks to nodes directly after allocation โ€” Coordinator is never in the hot path.
111
+ **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.
112
+
113
+ ---
114
+
115
+ ## ๐Ÿงน Memory Management
116
+
117
+ > **The Node.js SDK exposes the raw client layer โ€” `free()` is always required after `allocate()`.**
118
+
119
+ ```typescript
120
+ // โœ… Always do this after you are done with a pointer
121
+ const ptr = await client.allocate(100 * 1024 * 1024);
122
+ await client.write(ptr, 0, data);
123
+ const result = await client.read(ptr, 0, 0);
124
+ await client.free(ptr); // โ† required โ€” leaks memory if skipped
125
+ ```
126
+
127
+ ### ๐Ÿ Want Managed Memory? Use the Python SDK
128
+
129
+ The Python SDK (`pip install superbrain-sdk`) provides higher-level APIs where **free() is never needed**:
130
+
131
+ | Python API | Free needed? | What it does |
132
+ |------------|:------------:|--------------|
133
+ | `SharedContext.write("key", data)` | โŒ No | Key-based shared state across agents |
134
+ | `fabric.store_kv_cache(prefix)` | โŒ No | Deduped prompt cache, auto-evicted |
135
+ | `SuperBrainMemory` (LangChain) | โŒ No | Chat history in distributed RAM |
136
+
137
+ ```python
138
+ # Python โ€” no free() ever needed with high-level APIs
139
+ from superbrain import DistributedContextFabric
140
+
141
+ fabric = DistributedContextFabric(coordinator="localhost:50050")
142
+ ctx = fabric.create_context("session-42")
143
+
144
+ ctx.write("state", {"step": 10}) # written to distributed RAM
145
+ ctx.read("state") # read from any machine
146
+ # No free() โœ…
147
+ ```
148
+
149
+ โ†’ [Full Memory Management Guide](https://github.com/anispy211/superbrainSdk/blob/main/DOCUMENTATION.md#memory-management--when-to-free)
109
150
 
110
151
  ---
111
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superbrain-distributed-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Premium High-Performance Distributed Memory SDK for AI Agents",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",