@sym-bot/sym 0.1.0 → 0.2.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/PRD.md +1 -1
- package/README.md +165 -64
- package/TECHNICAL-SPEC.md +250 -197
- package/bin/setup-claude.sh +31 -1
- package/docs/mesh-memory-protocol.md +563 -0
- package/docs/mmp-architecture-image-prompt.txt +12 -0
- package/docs/p2p-protocol-research.md +907 -0
- package/docs/protocol-wake.md +242 -0
- package/integrations/claude-code/mcp-server.js +240 -18
- package/integrations/telegram/bot.js +418 -0
- package/lib/node.js +488 -39
- package/lib/transport.js +88 -0
- package/package.json +3 -2
- package/sym-relay/Dockerfile +7 -0
- package/sym-relay/lib/logger.js +28 -0
- package/sym-relay/lib/relay.js +388 -0
- package/sym-relay/package-lock.json +40 -0
- package/sym-relay/package.json +18 -0
- package/sym-relay/render.yaml +14 -0
- package/sym-relay/server.js +67 -0
- package/.mcp.json +0 -12
package/PRD.md
CHANGED
|
@@ -166,7 +166,7 @@ SYM is the product layer. The SDK is the engine.
|
|
|
166
166
|
| **Audience** | App developers | AI tool users |
|
|
167
167
|
| **Decision** | Drift evaluation | Memory, mood, peer coupling |
|
|
168
168
|
| **Platform** | TypeScript, Python, Swift | Node.js, Swift |
|
|
169
|
-
| **Install** | `npm install mesh-cognition` | `npm install sym` / SPM |
|
|
169
|
+
| **Install** | `npm install mesh-cognition` | `npm install @sym-bot/sym` / SPM |
|
|
170
170
|
|
|
171
171
|
---
|
|
172
172
|
|
package/README.md
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
# SYM
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Reference implementation of the [Mesh Memory Protocol (MMP)](https://sym.bot/protocol) — every agent is a sovereign node.**
|
|
4
4
|
|
|
5
5
|
Your AI agents share everything or nothing. There's no intelligence in the decision. SYM adds the missing layer — each node encodes its context into a cognitive state, and the coupling engine evaluates drift before sharing. Aligned agents share knowledge. Divergent agents stay independent. The architecture decides, not policy.
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/sym)
|
|
7
|
+
[](https://www.npmjs.com/package/@sym-bot/sym)
|
|
8
8
|
[](LICENSE)
|
|
9
|
+
[](https://sym.bot/protocol)
|
|
9
10
|
|
|
10
11
|
---
|
|
11
12
|
|
|
12
13
|
## Quick Start
|
|
13
14
|
|
|
14
15
|
```bash
|
|
15
|
-
|
|
16
|
-
cd sym && npm install
|
|
16
|
+
npm install @sym-bot/sym
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
```javascript
|
|
20
|
-
const { SymNode } = require('
|
|
20
|
+
const { SymNode } = require('@sym-bot/sym');
|
|
21
21
|
|
|
22
|
-
const node = new SymNode({
|
|
22
|
+
const node = new SymNode({
|
|
23
|
+
name: 'my-agent',
|
|
24
|
+
cognitiveProfile: 'Coding assistant that understands bugs, APIs, and debugging',
|
|
25
|
+
});
|
|
23
26
|
await node.start();
|
|
24
27
|
|
|
25
28
|
node.remember('race condition in order processing', { tags: ['bug'] });
|
|
@@ -28,7 +31,7 @@ node.recall('order');
|
|
|
28
31
|
await node.stop();
|
|
29
32
|
```
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
Peers on the same network discover each other automatically via Bonjour. Peers across the internet connect through the WebSocket relay. The coupling engine decides what to share.
|
|
32
35
|
|
|
33
36
|
## Cognitive Coupling
|
|
34
37
|
|
|
@@ -41,12 +44,12 @@ SYM doesn't blindly broadcast. Each node encodes its memories into a hidden stat
|
|
|
41
44
|
```
|
|
42
45
|
Three agents. Two work on APIs. One writes a food blog.
|
|
43
46
|
|
|
44
|
-
API Dev ↔ API Fix: drift 0.
|
|
45
|
-
API Dev ↔ Blogger: drift 1.
|
|
46
|
-
API Fix ↔ Blogger: drift 1.
|
|
47
|
+
API Dev ↔ API Fix: drift 0.38 → guarded (related context, shared with reduced confidence)
|
|
48
|
+
API Dev ↔ Blogger: drift 1.19 → rejected (unrelated context)
|
|
49
|
+
API Fix ↔ Blogger: drift 1.18 → rejected (unrelated context)
|
|
47
50
|
|
|
48
51
|
API Dev remembers "race condition in order processing"
|
|
49
|
-
→ Shared with API Fix ✓
|
|
52
|
+
→ Shared with API Fix ✓ (guarded — related domain)
|
|
50
53
|
→ Not shared with Blogger ✗ (rejected by coupling engine)
|
|
51
54
|
```
|
|
52
55
|
|
|
@@ -58,37 +61,45 @@ There is no central service. Each agent embeds its own SymNode with its own iden
|
|
|
58
61
|
|
|
59
62
|
```
|
|
60
63
|
┌────────────────┐ ┌────────────────┐ ┌────────────────┐
|
|
61
|
-
│ Claude Code │ │ MeloTune │ │
|
|
62
|
-
│ (Mac/Windows) │ │ (iPhone) │ │ (any
|
|
64
|
+
│ Claude Code │ │ MeloTune │ │ Telegram Bot │
|
|
65
|
+
│ (Mac/Windows) │ │ (iPhone) │ │ (any device) │
|
|
63
66
|
│ │ │ │ │ │
|
|
64
67
|
│ ┌───────────┐ │ │ ┌───────────┐ │ │ ┌───────────┐ │
|
|
65
68
|
│ │ SYM Node │ │ │ │ SYM Node │ │ │ │ SYM Node │ │
|
|
66
|
-
│ │ Node.js │ │ │ │ Swift │ │ │ │
|
|
67
|
-
│ └─────┬─────┘ │
|
|
68
|
-
└────────┼────────┘
|
|
69
|
-
│
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
│ │ Node.js │ │ │ │ Swift │ │ │ │ Node.js │ │
|
|
70
|
+
│ └─────┬─────┘ │ └─────┬───────┘ │ │ └─────┬─────┘ │
|
|
71
|
+
└────────┼────────┘ └──────┼────────┘ └────────┼───────┘
|
|
72
|
+
│ │ │
|
|
73
|
+
├── Bonjour (LAN) ─┤ │
|
|
74
|
+
│ │ │
|
|
75
|
+
└──── WebSocket Relay (internet) ────────┘
|
|
73
76
|
```
|
|
74
77
|
|
|
75
78
|
Each node:
|
|
76
|
-
-
|
|
77
|
-
-
|
|
79
|
+
- Declares its cognitive identity via `cognitiveProfile`
|
|
80
|
+
- Encodes context into a hidden state vector (context encoder)
|
|
81
|
+
- Discovers local peers via Bonjour/mDNS (`_sym._tcp`)
|
|
82
|
+
- Connects to remote peers via WebSocket relay
|
|
78
83
|
- Exchanges cognitive state with peers
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
- Evaluates incoming mood against own cognitive state — the SDK's coupling engine decides whether to act
|
|
84
|
+
- Shares memories only with aligned peers (drift ≤ 0.5)
|
|
85
|
+
- Evaluates incoming mood with configurable `moodThreshold` (default 0.8)
|
|
82
86
|
- Re-encodes periodically as context evolves
|
|
83
87
|
|
|
84
|
-
One engine makes every decision. Memory sharing, peer coupling, and mood relevance all go through the [Mesh Cognition SDK](https://github.com/sym-bot/mesh-cognition-sdk)'s `SemanticCoupler`.
|
|
88
|
+
One engine makes every decision. Memory sharing, peer coupling, and mood relevance all go through the [Mesh Cognition SDK](https://github.com/sym-bot/mesh-cognition-sdk)'s `SemanticCoupler`.
|
|
85
89
|
|
|
86
90
|
## API
|
|
87
91
|
|
|
88
92
|
```javascript
|
|
89
|
-
const { SymNode } = require('sym');
|
|
90
|
-
|
|
91
|
-
const node = new SymNode({
|
|
93
|
+
const { SymNode } = require('@sym-bot/sym');
|
|
94
|
+
|
|
95
|
+
const node = new SymNode({
|
|
96
|
+
name: 'my-agent',
|
|
97
|
+
cognitiveProfile: 'What this agent understands and responds to',
|
|
98
|
+
moodThreshold: 0.8, // how permissive to mood signals (default 0.8)
|
|
99
|
+
relay: 'wss://your-relay.example.com', // optional relay for internet mesh
|
|
100
|
+
relayToken: 'shared-secret', // optional relay auth token
|
|
101
|
+
relayOnly: false, // skip Bonjour, relay only (default false)
|
|
102
|
+
});
|
|
92
103
|
await node.start();
|
|
93
104
|
|
|
94
105
|
// Memory (shared only with cognitively aligned peers)
|
|
@@ -108,8 +119,8 @@ node.on('mood-rejected', ({ from, mood, drift }) => {
|
|
|
108
119
|
node.send(message);
|
|
109
120
|
node.on('message', (from, content) => {});
|
|
110
121
|
|
|
111
|
-
// Monitoring
|
|
112
|
-
node.peers(); // [{ name, coupling: 'aligned', drift: 0.12 }, ...]
|
|
122
|
+
// Monitoring
|
|
123
|
+
node.peers(); // [{ name, coupling: 'aligned', drift: 0.12, source: 'relay' }, ...]
|
|
113
124
|
node.coherence(); // Overall mesh coherence
|
|
114
125
|
node.status(); // Full node status
|
|
115
126
|
|
|
@@ -122,15 +133,50 @@ node.on('memory-received', ({ from, entry, decision }) => {});
|
|
|
122
133
|
await node.stop();
|
|
123
134
|
```
|
|
124
135
|
|
|
136
|
+
## Transport
|
|
137
|
+
|
|
138
|
+
SYM supports two transport modes that can run simultaneously:
|
|
139
|
+
|
|
140
|
+
### Bonjour (LAN)
|
|
141
|
+
|
|
142
|
+
Zero-configuration discovery on the local network. Peers find each other automatically via `_sym._tcp` mDNS. Direct TCP connections with length-prefixed JSON framing. No setup required.
|
|
143
|
+
|
|
144
|
+
### WebSocket Relay (Internet)
|
|
145
|
+
|
|
146
|
+
For mesh cognition across the internet. A lightweight relay server forwards frames between authenticated nodes. The relay is dumb transport — all coupling decisions remain on-device.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Deploy your own relay
|
|
150
|
+
cd sym-relay
|
|
151
|
+
npm install
|
|
152
|
+
SYM_RELAY_TOKEN=your-secret node server.js
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
// Connect a node to the relay
|
|
157
|
+
const node = new SymNode({
|
|
158
|
+
name: 'my-agent',
|
|
159
|
+
relay: 'wss://your-relay.example.com',
|
|
160
|
+
relayToken: 'your-secret',
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Hybrid mode** (default): nodes discover local peers via Bonjour AND connect to the relay for remote peers. Same node, same coupling engine, two transport layers.
|
|
165
|
+
|
|
166
|
+
The relay server provides:
|
|
167
|
+
- Token-based authentication
|
|
168
|
+
- Health endpoint (`GET /health`)
|
|
169
|
+
- 30-second heartbeat (keeps connections alive on cloud platforms)
|
|
170
|
+
- Peer join/leave notifications
|
|
171
|
+
- Targeted or broadcast frame forwarding
|
|
172
|
+
|
|
125
173
|
## Integrations
|
|
126
174
|
|
|
127
175
|
### Claude Code
|
|
128
176
|
|
|
129
|
-
SYM bridges Claude Code's memory system to the mesh. No extra commands needed.
|
|
130
|
-
|
|
131
177
|
```bash
|
|
132
|
-
|
|
133
|
-
cd sym
|
|
178
|
+
npm install @sym-bot/sym
|
|
179
|
+
cd node_modules/@sym-bot/sym
|
|
134
180
|
./bin/setup-claude.sh /path/to/your/project
|
|
135
181
|
```
|
|
136
182
|
|
|
@@ -140,30 +186,50 @@ One command. Adds MCP server, auto-approves `sym_mood` (no permission prompts),
|
|
|
140
186
|
|
|
141
187
|
**Inbound:** Peer memory arrives → coupling engine accepts it → SYM writes it to your Claude Code memory directory → Claude Code reads it in the next conversation.
|
|
142
188
|
|
|
143
|
-
Explicit tools are also available for direct mesh interaction:
|
|
144
|
-
|
|
145
189
|
| Tool | What it does |
|
|
146
190
|
|------|-------------|
|
|
191
|
+
| `sym_mood` | Proactively broadcasts detected mood to the mesh |
|
|
147
192
|
| `sym_remember` | Store a memory directly to the mesh |
|
|
148
193
|
| `sym_recall` | Search memories across the mesh |
|
|
194
|
+
| `sym_send` | Send a message to all peers |
|
|
149
195
|
| `sym_peers` | Show connected peers with coupling state and drift |
|
|
150
196
|
| `sym_status` | Full node status — identity, peers, memory count, coherence |
|
|
151
197
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Start agents on different machines on the same network. Bonjour discovers peers automatically. No configuration.
|
|
198
|
+
To connect Claude Code to the relay, set environment variables:
|
|
155
199
|
|
|
200
|
+
```bash
|
|
201
|
+
export SYM_RELAY_URL=wss://your-relay.example.com
|
|
202
|
+
export SYM_RELAY_TOKEN=your-secret
|
|
156
203
|
```
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
204
|
+
|
|
205
|
+
### Telegram
|
|
206
|
+
|
|
207
|
+
A multi-tenant Telegram bot — each user gets their own isolated SYM mesh node with separate identity, memory, and coupling state.
|
|
208
|
+
|
|
209
|
+
**Public bot:** Message [@sym_mesh_bot](https://t.me/sym_mesh_bot) on Telegram and send `/start` to connect.
|
|
210
|
+
|
|
211
|
+
**Self-hosted:**
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
TELEGRAM_BOT_TOKEN=your-bot-token \
|
|
215
|
+
SYM_RELAY_TOKEN=your-secret \
|
|
216
|
+
node integrations/telegram/bot.js
|
|
160
217
|
```
|
|
161
218
|
|
|
162
|
-
|
|
219
|
+
Commands:
|
|
220
|
+
- `/start` — connect to the SYM mesh
|
|
221
|
+
- `/peers` — connected mesh peers
|
|
222
|
+
- `/mood <text>` — broadcast mood to mesh
|
|
223
|
+
- `/remember <text>` — store memory in mesh
|
|
224
|
+
- `/recall <query>` — search mesh memories
|
|
225
|
+
- `/stop` — disconnect from mesh
|
|
226
|
+
- Any plain text — broadcast as a mood signal
|
|
227
|
+
|
|
228
|
+
Mesh events (peer joins, messages, mood signals, coupling decisions) are forwarded to your chat. Sessions auto-disconnect after 30 minutes of inactivity.
|
|
163
229
|
|
|
164
230
|
## Demo: Autonomous Mood Detection
|
|
165
231
|
|
|
166
|
-
You're coding with Claude Code for hours. You say "I'm exhausted." You didn't ask for music. But Claude Code detected your fatigue, broadcast your mood to the mesh, and MeloTune on your iPhone started playing
|
|
232
|
+
You're coding with Claude Code for hours. You say "I'm exhausted." You didn't ask for music. But Claude Code detected your fatigue, broadcast your mood to the mesh, and MeloTune on your iPhone started playing spa music. Autonomously.
|
|
167
233
|
|
|
168
234
|
```
|
|
169
235
|
You (in Claude Code): "I'm exhausted"
|
|
@@ -171,14 +237,14 @@ You (in Claude Code): "I'm exhausted"
|
|
|
171
237
|
Claude Code: detects fatigue → calls sym_mood silently
|
|
172
238
|
→ broadcasts "exhausted, persistently fatigued, urgently needs rest"
|
|
173
239
|
│
|
|
174
|
-
SYM mesh (Bonjour
|
|
240
|
+
SYM mesh (Bonjour + Relay)
|
|
175
241
|
│
|
|
176
242
|
MeloTune (iPhone): SymNode receives mood frame
|
|
177
|
-
→ SDK coupling engine evaluates drift: 0.
|
|
243
|
+
→ SDK coupling engine evaluates drift: 0.62
|
|
178
244
|
→ cognitiveProfile includes "tired, exhausted, rest"
|
|
179
|
-
→ drift 0.
|
|
245
|
+
→ drift 0.62 ≤ moodThreshold 1.2 → ACCEPTED
|
|
180
246
|
→ rule-based parser: recovery, rest → Healing
|
|
181
|
-
→ Apple Music:
|
|
247
|
+
→ Apple Music: spa playlist
|
|
182
248
|
→ zero LLM tokens
|
|
183
249
|
→ you didn't ask — the agents decided
|
|
184
250
|
```
|
|
@@ -187,40 +253,75 @@ MeloTune (iPhone): SymNode receives mood frame
|
|
|
187
253
|
|
|
188
254
|
| Evaluation | Drift | Threshold | Decision |
|
|
189
255
|
|-----------|-------|-----------|----------|
|
|
190
|
-
| Memory coupling | 1.
|
|
191
|
-
| Mood coupling | 0.
|
|
256
|
+
| Memory coupling | 1.06 | 0.50 | Rejected — coding memories don't leak into music context |
|
|
257
|
+
| Mood coupling | 0.62 | 1.20 | Accepted — "exhausted" aligns with MeloTune's cognitiveProfile |
|
|
192
258
|
|
|
193
259
|
The SDK's `SemanticCoupler` makes every decision. The agent's `cognitiveProfile` declares what it understands. The `moodThreshold` controls how permissive the agent is to mood signals. No routing tables. No capability registration. The engine decides.
|
|
194
260
|
|
|
195
|
-
Also works
|
|
261
|
+
Also works via Telegram:
|
|
196
262
|
|
|
197
263
|
```
|
|
198
|
-
|
|
199
|
-
→
|
|
264
|
+
You (in Telegram): @sym_mesh_bot → "Play classic music"
|
|
265
|
+
→ MeloTune plays Modern Classical via Apple Music
|
|
200
266
|
```
|
|
201
267
|
|
|
202
|
-
|
|
203
|
-
- [sym](https://github.com/sym-bot/sym) — Node.js (npm)
|
|
204
|
-
- [sym-swift](https://github.com/sym-bot/sym-swift) — Swift (SPM) for iOS/macOS
|
|
205
|
-
|
|
206
|
-
## Verified
|
|
268
|
+
## Verified in Production
|
|
207
269
|
|
|
208
|
-
- Mac Claude Code ↔ Windows Claude Code — P2P memory sharing
|
|
209
270
|
- Mac Claude Code → iPhone MeloTune — autonomous mood-based playback via SYM mesh
|
|
210
|
-
-
|
|
271
|
+
- Telegram [@sym_mesh_bot](https://t.me/sym_mesh_bot) → Relay → MeloTune — internet-scale mood relay (multi-tenant)
|
|
272
|
+
- Mac Claude Code ↔ Windows Claude Code — P2P memory sharing via Bonjour
|
|
273
|
+
- Node.js ↔ Swift — cross-platform mesh via Bonjour and WebSocket relay
|
|
274
|
+
|
|
275
|
+
## Semantic vs Neural Coupling
|
|
276
|
+
|
|
277
|
+
The SDK supports two coupling modes through the same API. The mode is selected automatically based on whether per-neuron time constants (τ) are provided.
|
|
278
|
+
|
|
279
|
+
### Semantic Coupling
|
|
280
|
+
|
|
281
|
+
For AI agents sharing memory. Uniform coupling across all hidden state dimensions. No trained model needed. Used by Claude Code, Telegram, LangChain, and multi-agent coordination.
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
Claude Code ↔ Claude Code: drift 0.38 → guarded → share memories with reduced confidence
|
|
285
|
+
Claude Code ↔ Food Blogger: drift 1.19 → rejected → no sharing
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Neural Coupling
|
|
289
|
+
|
|
290
|
+
For trained CfC neural networks with per-neuron time constants. Fast-τ neurons (emotion, ~1s) sync quickly between devices. Slow-τ neurons (context/memory, ~5s) stay independent. Real Kuramoto phase coherence r(t).
|
|
291
|
+
|
|
292
|
+
**In practice — two MeloTune devices on the same mesh:**
|
|
293
|
+
|
|
294
|
+
| What | Behaviour |
|
|
295
|
+
|------|-----------|
|
|
296
|
+
| **Fast neurons** (low τ) | Sync quickly — both devices converge on emotional trajectory |
|
|
297
|
+
| **Slow neurons** (high τ) | Stay independent — each device retains its own listening context |
|
|
298
|
+
| **Genre selection** | Per-device — iPhone plays Ambient, Mac plays Lo-Fi |
|
|
299
|
+
| **Track selection** | Per-device — never the same tracks |
|
|
300
|
+
| **Mood trajectory** | Shared — iPhone at E:45 N:25, Mac drifts toward E:46 N:36 |
|
|
301
|
+
| **Coherence** | r(t) = 0.94 — high alignment, strong mutual influence |
|
|
302
|
+
|
|
303
|
+
The coupling engine blends peer state into the local trajectory at each inference step. Influence strength scales with coherence — highly aligned peers have more effect. If you shift one device to high energy, the other gradually follows (fast neurons). But each device's genre, history, and track selection remain sovereign.
|
|
211
304
|
|
|
212
305
|
## Privacy
|
|
213
306
|
|
|
214
|
-
- All
|
|
215
|
-
-
|
|
307
|
+
- All coupling decisions stay on-device
|
|
308
|
+
- The relay is dumb transport — it never inspects frame payloads
|
|
216
309
|
- Memories stored locally — delete the directory, everything is gone
|
|
217
310
|
- Bonjour discovery only on local network
|
|
311
|
+
- Relay connections authenticated via shared token
|
|
218
312
|
- Rejected peers never receive your memories
|
|
313
|
+
- No cloud AI. No account. No telemetry.
|
|
314
|
+
|
|
315
|
+
## Platforms
|
|
316
|
+
|
|
317
|
+
- [@sym-bot/sym](https://www.npmjs.com/package/@sym-bot/sym) — Node.js (npm)
|
|
318
|
+
- [sym-swift](https://github.com/sym-bot/sym-swift) — Swift (SPM) for iOS/macOS
|
|
219
319
|
|
|
220
320
|
## Built On
|
|
221
321
|
|
|
222
|
-
SYM is
|
|
322
|
+
SYM is the reference implementation of the [Mesh Memory Protocol (MMP)](https://sym.bot/protocol). MMP is the protocol for collective intelligence. SYM implements it.
|
|
223
323
|
|
|
324
|
+
- [MMP Protocol Spec](https://sym.bot/protocol) — the protocol specification (v0.1.0)
|
|
224
325
|
- [Whitepaper](https://sym.bot/research/mesh-cognition) — the science behind cognitive coupling
|
|
225
326
|
- [Mesh Cognition SDK](https://github.com/sym-bot/mesh-cognition-sdk) — the coupling engine (TypeScript, Python, Swift)
|
|
226
327
|
|