agent-relay 1.0.6 → 1.0.8

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 (72) hide show
  1. package/README.md +18 -6
  2. package/dist/cli/index.d.ts +2 -0
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +344 -3
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/daemon/agent-registry.d.ts +60 -0
  7. package/dist/daemon/agent-registry.d.ts.map +1 -0
  8. package/dist/daemon/agent-registry.js +158 -0
  9. package/dist/daemon/agent-registry.js.map +1 -0
  10. package/dist/daemon/connection.d.ts +11 -1
  11. package/dist/daemon/connection.d.ts.map +1 -1
  12. package/dist/daemon/connection.js +31 -2
  13. package/dist/daemon/connection.js.map +1 -1
  14. package/dist/daemon/index.d.ts +2 -0
  15. package/dist/daemon/index.d.ts.map +1 -1
  16. package/dist/daemon/index.js +2 -0
  17. package/dist/daemon/index.js.map +1 -1
  18. package/dist/daemon/registry.d.ts +9 -0
  19. package/dist/daemon/registry.d.ts.map +1 -0
  20. package/dist/daemon/registry.js +9 -0
  21. package/dist/daemon/registry.js.map +1 -0
  22. package/dist/daemon/router.d.ts +34 -2
  23. package/dist/daemon/router.d.ts.map +1 -1
  24. package/dist/daemon/router.js +111 -1
  25. package/dist/daemon/router.js.map +1 -1
  26. package/dist/daemon/server.d.ts +1 -0
  27. package/dist/daemon/server.d.ts.map +1 -1
  28. package/dist/daemon/server.js +60 -13
  29. package/dist/daemon/server.js.map +1 -1
  30. package/dist/dashboard/public/index.html +625 -16
  31. package/dist/dashboard/server.d.ts +1 -1
  32. package/dist/dashboard/server.d.ts.map +1 -1
  33. package/dist/dashboard/server.js +125 -7
  34. package/dist/dashboard/server.js.map +1 -1
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/protocol/types.d.ts +15 -1
  38. package/dist/protocol/types.d.ts.map +1 -1
  39. package/dist/storage/adapter.d.ts +53 -0
  40. package/dist/storage/adapter.d.ts.map +1 -1
  41. package/dist/storage/adapter.js +3 -0
  42. package/dist/storage/adapter.js.map +1 -1
  43. package/dist/storage/sqlite-adapter.d.ts +58 -1
  44. package/dist/storage/sqlite-adapter.d.ts.map +1 -1
  45. package/dist/storage/sqlite-adapter.js +374 -47
  46. package/dist/storage/sqlite-adapter.js.map +1 -1
  47. package/dist/utils/project-namespace.d.ts.map +1 -1
  48. package/dist/utils/project-namespace.js +22 -1
  49. package/dist/utils/project-namespace.js.map +1 -1
  50. package/dist/wrapper/client.d.ts +22 -3
  51. package/dist/wrapper/client.d.ts.map +1 -1
  52. package/dist/wrapper/client.js +59 -9
  53. package/dist/wrapper/client.js.map +1 -1
  54. package/dist/wrapper/parser.d.ts +110 -4
  55. package/dist/wrapper/parser.d.ts.map +1 -1
  56. package/dist/wrapper/parser.js +296 -84
  57. package/dist/wrapper/parser.js.map +1 -1
  58. package/dist/wrapper/tmux-wrapper.d.ts +100 -9
  59. package/dist/wrapper/tmux-wrapper.d.ts.map +1 -1
  60. package/dist/wrapper/tmux-wrapper.js +441 -83
  61. package/dist/wrapper/tmux-wrapper.js.map +1 -1
  62. package/docs/AGENTS.md +27 -27
  63. package/docs/CHANGELOG.md +1 -1
  64. package/docs/DESIGN_V2.md +1079 -0
  65. package/docs/INTEGRATION-GUIDE.md +926 -0
  66. package/docs/PROPOSAL-trajectories.md +1582 -0
  67. package/docs/PROTOCOL.md +3 -3
  68. package/docs/SCALING_ANALYSIS.md +280 -0
  69. package/docs/TMUX_IMPLEMENTATION_NOTES.md +9 -9
  70. package/docs/TMUX_IMPROVEMENTS.md +968 -0
  71. package/docs/competitive-analysis-mcp-agent-mail.md +389 -0
  72. package/package.json +6 -2
@@ -0,0 +1,389 @@
1
+ # Competitive Analysis: mcp_agent_mail vs agent-relay
2
+
3
+ ## Executive Summary
4
+
5
+ | Aspect | mcp_agent_mail | agent-relay |
6
+ |--------|----------------|-------------|
7
+ | **Architecture** | MCP HTTP Server (FastAPI) | PTY Wrapper + Unix Socket |
8
+ | **Protocol** | MCP JSON-RPC over HTTP | Custom binary framing over Unix socket |
9
+ | **Storage** | SQLite + Git archive | SQLite + file-based inbox |
10
+ | **Latency** | ~50-200ms (HTTP overhead) | <5ms (local IPC) |
11
+ | **Complexity** | ~15,000+ lines Python | ~7,000 lines TypeScript |
12
+ | **Agent Integration** | Requires MCP client SDK | Zero-config (pattern detection) |
13
+ | **Persistence** | Git-backed audit trail | SQLite messages table |
14
+ | **Scale Target** | 5-50+ agents, multi-project | 5-10 agents, single project |
15
+
16
+ ---
17
+
18
+ ## Architecture Comparison
19
+
20
+ ### mcp_agent_mail: MCP-First Design
21
+
22
+ ```
23
+ ┌─────────────────────────────────────────────────────────────┐
24
+ │ Agent Clients (FastMCP) │
25
+ │ Claude Code, Codex, Gemini CLI, etc. │
26
+ └────────────────────────────┬────────────────────────────────┘
27
+ │ HTTP JSON-RPC (MCP Protocol)
28
+ ┌────────────────────────────▼────────────────────────────────┐
29
+ │ FastAPI Transport Layer │
30
+ │ ├─ Bearer Token / JWT / RBAC │
31
+ │ ├─ Rate Limiting (token bucket) │
32
+ │ └─ Middleware Stack │
33
+ └────────────────────────────┬────────────────────────────────┘
34
+
35
+ ┌────────────────────────────▼────────────────────────────────┐
36
+ │ FastMCP Application Layer │
37
+ │ ├─ 40+ Tools (messaging, identity, reservations) │
38
+ │ ├─ 20+ Resources (agents, messages, threads) │
39
+ │ └─ Macros (workflow shortcuts) │
40
+ └────────────────────────────┬────────────────────────────────┘
41
+
42
+ ┌────────────────────┼────────────────────┐
43
+ │ │ │
44
+ ┌────▼────────┐ ┌────▼────────┐ ┌────▼────────┐
45
+ │ SQLite │ │ Git Archive │ │ Locks │
46
+ │ (async) │ │ (global) │ │ (LRU) │
47
+ └─────────────┘ └─────────────┘ └─────────────┘
48
+ ```
49
+
50
+ **Pros:**
51
+ - Standards-based (MCP protocol)
52
+ - Rich feature set (40+ tools)
53
+ - Git-backed audit trail
54
+ - Cross-project messaging
55
+ - Product grouping for large fleets
56
+ - File reservation system with enforcement
57
+ - Contact/permission system
58
+
59
+ **Cons:**
60
+ - HTTP overhead (~50-200ms per call)
61
+ - Requires MCP client integration
62
+ - Complex setup (Python venv, dependencies)
63
+ - Heavy resource footprint
64
+ - Overkill for simple use cases
65
+
66
+ ### agent-relay: PTY-First Design
67
+
68
+ ```
69
+ ┌─────────────────────────────────────────────────────────────┐
70
+ │ User Terminal │
71
+ │ (attached to tmux session) │
72
+ └────────────────────────────┬────────────────────────────────┘
73
+ │ tmux attach
74
+ ┌────────────────────────────▼────────────────────────────────┐
75
+ │ Tmux Session │
76
+ │ ├─ Agent Process (claude, codex, gemini) │
77
+ │ ├─ Silent Polling (capture-pane @ 200ms) │
78
+ │ ├─ Pattern Detection (->relay:) │
79
+ │ └─ Message Injection (send-keys) │
80
+ └────────────────────────────┬────────────────────────────────┘
81
+ │ Unix Socket IPC
82
+ ┌────────────────────────────▼────────────────────────────────┐
83
+ │ Daemon (Router) │
84
+ │ ├─ Connection State Machine │
85
+ │ ├─ Message Routing (direct + broadcast) │
86
+ │ ├─ SQLite Persistence │
87
+ │ └─ Dashboard (WebSocket) │
88
+ └─────────────────────────────────────────────────────────────┘
89
+ ```
90
+
91
+ **Pros:**
92
+ - Ultra-low latency (<5ms)
93
+ - Zero-config (no SDK needed)
94
+ - Works with ANY agent (pattern-based)
95
+ - Lightweight (~7k lines)
96
+ - Transparent to user (real terminal)
97
+ - Simple mental model
98
+
99
+ **Cons:**
100
+ - Single project scope
101
+ - No persistent audit trail (Git)
102
+ - No file reservation system
103
+ - No cross-project messaging
104
+ - Polling overhead (CPU)
105
+ - Limited security model
106
+
107
+ ---
108
+
109
+ ## Feature-by-Feature Comparison
110
+
111
+ ### 1. Message Sending
112
+
113
+ | Feature | mcp_agent_mail | agent-relay |
114
+ |---------|----------------|-------------|
115
+ | **API** | `send_message()` tool call | `->relay:Name message` pattern |
116
+ | **Broadcast** | `to=["*"]` | `->relay:*` |
117
+ | **Attachments** | Yes (images, files) | No |
118
+ | **Threading** | Yes (`thread_id`) | No |
119
+ | **Markdown** | Full GFM support | Plain text |
120
+ | **Images** | Auto-convert to WebP, inline | Not supported |
121
+
122
+ **Winner: mcp_agent_mail** - Rich message format with attachments and threading.
123
+
124
+ ### 2. Agent Discovery
125
+
126
+ | Feature | mcp_agent_mail | agent-relay |
127
+ |---------|----------------|-------------|
128
+ | **Registration** | Explicit `register_agent()` | Auto on HELLO handshake |
129
+ | **Directory** | `resource://agents/{project}` | `agents.json` file |
130
+ | **Metadata** | Program, model, task, capabilities | Name only |
131
+ | **Cross-project** | Contact request system | Not supported |
132
+
133
+ **Winner: mcp_agent_mail** - Richer agent metadata and cross-project discovery.
134
+
135
+ ### 3. Message Persistence
136
+
137
+ | Feature | mcp_agent_mail | agent-relay |
138
+ |---------|----------------|-------------|
139
+ | **Primary** | SQLite (async, WAL mode) | SQLite |
140
+ | **Backup** | Git archive (audit trail) | None |
141
+ | **Search** | FTS (full-text search) | Basic queries |
142
+ | **History** | Permanent | Session-based |
143
+
144
+ **Winner: mcp_agent_mail** - Git-backed audit trail is powerful for compliance.
145
+
146
+ ### 4. Security
147
+
148
+ | Feature | mcp_agent_mail | agent-relay |
149
+ |---------|----------------|-------------|
150
+ | **Auth** | Bearer token, JWT, RBAC | Unix socket permissions |
151
+ | **Rate Limiting** | Token bucket (memory/Redis) | None |
152
+ | **Contact Policy** | open/auto/contacts_only/block_all | None |
153
+ | **Encryption** | TLS (transport) | None (local only) |
154
+
155
+ **Winner: mcp_agent_mail** - Production-grade security model.
156
+
157
+ ### 5. File Coordination
158
+
159
+ | Feature | mcp_agent_mail | agent-relay |
160
+ |---------|----------------|-------------|
161
+ | **Reservations** | Yes (exclusive/shared, TTL) | No |
162
+ | **Enforcement** | Pre-commit hooks | None |
163
+ | **Build Slots** | Yes (long-running tasks) | No |
164
+ | **Conflict Detection** | Advisory + block mode | None |
165
+
166
+ **Winner: mcp_agent_mail** - Critical for multi-agent file editing.
167
+
168
+ ### 6. Latency & Performance
169
+
170
+ | Feature | mcp_agent_mail | agent-relay |
171
+ |---------|----------------|-------------|
172
+ | **Message Latency** | ~50-200ms | <5ms |
173
+ | **Connection** | HTTP (stateless) | Unix socket (persistent) |
174
+ | **Overhead** | JSON-RPC parsing | Binary framing |
175
+ | **Memory** | Higher (Python, FastAPI) | Lower (Node.js) |
176
+
177
+ **Winner: agent-relay** - 10-40x faster message delivery.
178
+
179
+ ### 7. Developer Experience
180
+
181
+ | Feature | mcp_agent_mail | agent-relay |
182
+ |---------|----------------|-------------|
183
+ | **Setup** | Python venv, pip install, .env | npm install, single binary |
184
+ | **Integration** | MCP client required | Pattern in stdout |
185
+ | **Learning Curve** | Steep (40+ tools) | Minimal (->relay:) |
186
+ | **Debugging** | Structured logging, metrics | Dashboard + logs |
187
+
188
+ **Winner: agent-relay** - Much simpler to get started.
189
+
190
+ ### 8. Observability
191
+
192
+ | Feature | mcp_agent_mail | agent-relay |
193
+ |---------|----------------|-------------|
194
+ | **Metrics** | Tool call counts, latency, errors | Basic connection status |
195
+ | **Resources** | 20+ queryable resources | agents.json |
196
+ | **Logging** | Structured (structlog + rich) | Console output |
197
+ | **Dashboard** | None (resources only) | Web UI with live updates |
198
+
199
+ **Mixed** - mcp_agent_mail has richer metrics, agent-relay has visual dashboard.
200
+
201
+ ---
202
+
203
+ ## Key Insights & Learnings
204
+
205
+ ### What mcp_agent_mail Does Better
206
+
207
+ 1. **Git-Backed Audit Trail**
208
+ - Every message committed to Git
209
+ - Full history, diff-able, recoverable
210
+ - Compliance-friendly
211
+
212
+ 2. **File Reservation System**
213
+ - Advisory locks with TTL
214
+ - Pre-commit hook enforcement
215
+ - Build slots for long tasks
216
+ - Critical for preventing conflicts
217
+
218
+ 3. **Cross-Project Messaging**
219
+ - Contact request system
220
+ - Product grouping
221
+ - Multi-repo coordination
222
+
223
+ 4. **Rich Message Format**
224
+ - Attachments (images, files)
225
+ - Threading (thread_id)
226
+ - Full GFM markdown
227
+ - Auto image processing
228
+
229
+ 5. **Security Model**
230
+ - JWT + RBAC
231
+ - Rate limiting
232
+ - Contact policies
233
+ - Per-agent capabilities
234
+
235
+ 6. **Agent Metadata**
236
+ - Program, model, task description
237
+ - Capabilities tracking
238
+ - Last active timestamps
239
+
240
+ ### What agent-relay Does Better
241
+
242
+ 1. **Zero Configuration**
243
+ - No SDK needed
244
+ - Works with any agent
245
+ - Pattern-based detection
246
+
247
+ 2. **Ultra-Low Latency**
248
+ - <5ms vs 50-200ms
249
+ - Unix socket IPC
250
+ - Binary framing
251
+
252
+ 3. **Transparent UX**
253
+ - User stays in real terminal
254
+ - No proxy/wrapper visible
255
+ - Native tmux experience
256
+
257
+ 4. **Simplicity**
258
+ - ~7k lines vs ~15k+ lines
259
+ - Single mental model
260
+ - Easy to understand
261
+
262
+ 5. **Visual Dashboard**
263
+ - Real-time agent status
264
+ - Message history
265
+ - WebSocket updates
266
+
267
+ ---
268
+
269
+ ## Recommended Improvements for agent-relay
270
+
271
+ ### High Priority
272
+
273
+ 1. **Add File Reservation System** (from mcp_agent_mail)
274
+ - Advisory locks with TTL
275
+ - `->relay:lock src/**/*.ts` pattern
276
+ - Pre-commit hook integration
277
+ - Critical for multi-agent file editing
278
+
279
+ 2. **Add Message Threading**
280
+ - `->relay:Bob [thread:feature-123] message`
281
+ - Group related messages
282
+ - Better context tracking
283
+
284
+ 3. **Add Git Audit Trail**
285
+ - Optional commit of messages to repo
286
+ - `.agent-relay/messages/` directory
287
+ - Recoverable history
288
+
289
+ 4. **Add Agent Metadata**
290
+ - Track program, model, task
291
+ - Store in agents.json
292
+ - Better agent discovery
293
+
294
+ ### Medium Priority
295
+
296
+ 5. **Add Message Attachments**
297
+ - `->relay:Bob [attach:path/to/file]`
298
+ - Inline small files
299
+ - Reference large files
300
+
301
+ 6. **Add Cross-Project Messaging**
302
+ - `->relay:Bob@other-project message`
303
+ - Contact request system
304
+ - Product grouping
305
+
306
+ 7. **Add Rate Limiting**
307
+ - Prevent message flooding
308
+ - Per-agent limits
309
+ - Backpressure handling
310
+
311
+ 8. **Add Message Search**
312
+ - FTS on stored messages
313
+ - `agent-relay search "query"`
314
+ - Filter by agent, time, topic
315
+
316
+ ### Lower Priority
317
+
318
+ 9. **Add Security Model**
319
+ - Optional authentication
320
+ - Agent capabilities
321
+ - Contact policies
322
+
323
+ 10. **Add Workflow Macros**
324
+ - `->relay:macro:start-session`
325
+ - Bundle common patterns
326
+ - Reduce boilerplate
327
+
328
+ ---
329
+
330
+ ## Architecture Recommendations
331
+
332
+ ### Hybrid Approach
333
+
334
+ Consider a **hybrid architecture** that combines the best of both:
335
+
336
+ ```
337
+ ┌─────────────────────────────────────────────────────────────┐
338
+ │ User Terminal │
339
+ │ (attached to tmux session) │
340
+ └────────────────────────────┬────────────────────────────────┘
341
+
342
+ ┌────────────────────────────▼────────────────────────────────┐
343
+ │ PTY Wrapper (fast path) │
344
+ │ ├─ Pattern Detection (->relay:) │
345
+ │ ├─ Message Injection │
346
+ │ └─ Direct daemon IPC (<5ms) │
347
+ └────────────────────────────┬────────────────────────────────┘
348
+
349
+ ┌────────────────────────────▼────────────────────────────────┐
350
+ │ Enhanced Daemon │
351
+ │ ├─ Message Router (existing) │
352
+ │ ├─ File Reservation Manager (NEW) │
353
+ │ ├─ Git Archive Writer (NEW, optional) │
354
+ │ ├─ Agent Metadata Store (NEW) │
355
+ │ └─ SQLite + FTS (enhanced) │
356
+ └─────────────────────────────────────────────────────────────┘
357
+ ```
358
+
359
+ ### Key Design Principles
360
+
361
+ 1. **Keep Zero-Config Core** - Pattern-based detection is the killer feature
362
+ 2. **Add Opt-In Features** - File locks, Git archive as flags
363
+ 3. **Maintain Low Latency** - Don't add HTTP layer
364
+ 4. **Progressive Enhancement** - Simple default, powerful when needed
365
+
366
+ ---
367
+
368
+ ## Conclusion
369
+
370
+ **mcp_agent_mail** is a feature-rich, production-grade system designed for enterprise-scale multi-agent coordination. It excels at security, compliance, and cross-project workflows.
371
+
372
+ **agent-relay** is an elegantly simple, ultra-fast system designed for rapid prototyping and real-time collaboration. It excels at developer experience and low latency.
373
+
374
+ The ideal path forward for agent-relay is to **selectively adopt** the most valuable features from mcp_agent_mail (file reservations, threading, Git audit) while **preserving** its core strengths (zero-config, low latency, simplicity).
375
+
376
+ ---
377
+
378
+ ## Action Items
379
+
380
+ | Priority | Item | Effort | Impact |
381
+ |----------|------|--------|--------|
382
+ | P0 | Add file reservation system | Medium | High |
383
+ | P0 | Add message threading | Low | Medium |
384
+ | P1 | Add Git audit trail (optional) | Medium | High |
385
+ | P1 | Add agent metadata | Low | Medium |
386
+ | P2 | Add message attachments | Medium | Medium |
387
+ | P2 | Add cross-project messaging | High | Medium |
388
+ | P3 | Add rate limiting | Low | Low |
389
+ | P3 | Add message search (FTS) | Medium | Medium |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-relay",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Real-time agent-to-agent communication system",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,9 +19,13 @@
19
19
  "access": "public"
20
20
  },
21
21
  "scripts": {
22
+ "postinstall": "npm rebuild better-sqlite3",
22
23
  "build": "npm run clean && tsc",
23
- "postbuild": "cp -r src/dashboard/public dist/dashboard/",
24
+ "postbuild": "cp -r src/dashboard/public dist/dashboard/ && chmod +x dist/cli/index.js",
24
25
  "dev": "tsc -w",
26
+ "dev:local": "npm run build && npm link && echo '✓ agent-relay linked globally'",
27
+ "dev:unlink": "npm unlink -g agent-relay && echo '✓ agent-relay unlinked'",
28
+ "dev:rebuild": "npm run build && echo '✓ Rebuilt (linked version updated)'",
25
29
  "start": "node dist/cli/index.js",
26
30
  "daemon": "node dist/daemon/server.js",
27
31
  "dashboard": "node dist/dashboard/start.js",