Skip to content

Commit a658465

Browse files
khaliqgantAgent Relayclaude
authored
Integration tests and clean up of zed and parsing (#366)
* copy over integration tests * integration tests and clean up * demos * videos in docs * fix: address PR review comments - Fix memory leak: clear seenMessageIds Set in stop() method - Fix channel message ID collisions: use randomUUID() instead of Date.now() - Fix default export in utils/index.js: use direct imports instead of await import - Fix template literal issues in mcp/06-mcp-connect.js - Disable task-queue.test.js which imports non-existent modules Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use bounded CircularDedupeCache for message deduplication Replace unbounded Set with CircularDedupeCache (capacity 2000) to prevent memory leak in long-running ACP bridge sessions. The cache automatically evicts oldest entries when capacity is reached, matching the SDK behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: prevent message misrouting and bound pending queue - Drop threaded messages when target session is closed instead of misrouting them to all sessions - Bound the __pending__ queue to 500 messages to prevent unbounded memory growth before first ACP session is created Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use template literals for CLI variable interpolation in 08-mcp-receive.js Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: prevent pending message loss and race conditions - Stream existing buffered messages to user before clearing in bridgeToRelay() to prevent pending messages from being discarded - Remove duplicate __pending__ drain from prompt() to avoid race conditions in multi-session scenarios (e.g., multiple Zed windows) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: only drop threaded messages for known closed sessions Track closed session IDs separately so we can distinguish between: - Threads that match closed ACP sessions (should be dropped) - Arbitrary thread names like "code-review" (should be broadcast) This prevents silently dropping legitimate threaded messages that use relay's general thread feature rather than ACP session IDs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Agent Relay <agent@agent-relay.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent cf6244d commit a658465

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+8809
-114
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Navigate to **http://localhost:3888** to:
4545
| `agent-relay up` | Start daemon + dashboard |
4646
| `agent-relay down` | Stop daemon |
4747
| `agent-relay status` | Check daemon status |
48-
| `agent-relay create-agent -n Name <cmd>` | Create a named agent |
48+
| `agent-relay spawn <name> <cli> "task"` | Spawn a worker agent |
4949
| `agent-relay bridge <projects...>` | Bridge multiple projects |
5050
| `agent-relay doctor` | Diagnose issues |
5151

@@ -63,11 +63,19 @@ Define roles by adding markdown files to your project:
6363
└── designer.md # UI/UX
6464
```
6565

66-
Names automatically match roles (case-insensitive):
66+
Names automatically match roles (case-insensitive). Create agents using either method:
67+
68+
**Option A: Dashboard (recommended for interactive use)**
69+
1. Open http://localhost:3888
70+
2. Click "Spawn Agent"
71+
3. Enter name "Lead" and select CLI "claude"
72+
73+
**Option B: CLI (for scripting/automation)**
6774
```bash
68-
agent-relay create-agent -n Lead claude # Uses lead.md
75+
agent-relay spawn Lead claude "Your task instructions"
6976
```
70-
Agents spawned by that name in the dashboard automatically assume that role.
77+
78+
Agents with matching names automatically assume the corresponding role from your `.claude/agents/` directory.
7179

7280
## MCP Server
7381

docs/architecture/storage.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This describes the adapter stack, fallback behavior, and data policies.
44

55
## Components
66
- **createStorageAdapter**: Factory that selects an adapter based on config/env and handles fallbacks.
7-
- **SQLite adapter**: Primary durable store (WAL-enabled, 7d retention default); tries `better-sqlite3` first, then `node:sqlite` (Node 22+).
7+
- **JSONL adapter**: Default durable store; file-based append-only log (`.agent-relay/messages/YYYY-MM-DD.jsonl`, sessions in `.agent-relay/sessions.jsonl`). Zero native dependencies.
8+
- **SQLite adapter**: Optional durable store (WAL-enabled, 7d retention default); tries `better-sqlite3` first, then `node:sqlite` (Node 22+).
89
- **Batched SQLite adapter**: Wraps SQLite for higher write throughput via buffered flushes.
9-
- **JSONL adapter**: File-based append-only log (`.agent-relay/messages/YYYY-MM-DD.jsonl`, sessions in `.agent-relay/sessions.jsonl`) used when SQLite native modules fail or are blocked.
1010
- **Memory adapter**: Volatile fallback to keep the daemon running when persistence fails.
1111

1212
## Fallback Chain
@@ -16,32 +16,28 @@ Config/env ──┐
1616
createStorageAdapter
1717
|
1818
v
19-
SQLite (default)
20-
├─ better-sqlite3
21-
└─ node:sqlite (Node 22+)
19+
JSONL (default)
20+
└─ .agent-relay/messages/*.jsonl
2221
|
2322
(failure to init)
2423
v
25-
SQLite (batched) [opt-in]
24+
SQLite [opt-in via AGENT_RELAY_STORAGE_TYPE=sqlite]
2625
├─ better-sqlite3
27-
└─ node:sqlite
28-
|
29-
(failure to init)
30-
v
31-
JSONL (append-only)
26+
└─ node:sqlite (Node 22+)
3227
|
3328
(failure to init)
3429
v
3530
Memory (volatile)
3631
```
3732
Notes:
38-
- Current behavior: SQLite (better-sqlite3 → node:sqlite) → JSONL → Memory if native modules or permissions break persistence.
39-
- Each fallback logs the failure reason and a fix hint (upgrade Node or rebuild native deps).
33+
- Current behavior: JSONL (default) → Memory if filesystem write fails.
34+
- SQLite available via `AGENT_RELAY_STORAGE_TYPE=sqlite` for low-latency query needs.
35+
- Each fallback logs the failure reason and a fix hint.
4036

4137
## When to Use Each Adapter
42-
- **SQLite**: Default for durability and low latency; use whenever native modules are available.
38+
- **JSONL**: Default for durability with zero native dependencies; append-only per-day files.
39+
- **SQLite**: Low-latency queries; use when you need faster reads or complex queries.
4340
- **SQLite (batched)**: High-volume message bursts; tolerates small window of risk during batch flush.
44-
- **JSONL**: Environments where native builds are blocked but disk is available; append-only per-day files.
4541
- **Memory**: Tests, ephemeral runs, or emergency operation when persistence is broken.
4642

4743
## Performance Characteristics

docs/concepts.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ Agent names are case-insensitive identifiers used for routing messages:
4646

4747
```bash
4848
# These all refer to the same agent
49-
agent-relay create-agent -n Alice claude
49+
# Via dashboard: Spawn Agent → Name: "Alice", CLI: "claude"
50+
# Or via CLI: agent-relay spawn Alice claude "Task description"
51+
52+
# All these message targets are equivalent:
5053
->relay:alice Hello!
5154
->relay:ALICE Hello!
5255
```
@@ -152,7 +155,7 @@ The daemon is the central message broker that routes all communication between a
152155

153156
- **Agent Registry** - Tracks connected agents and their connections
154157
- **Message Routing** - Delivers messages to the correct recipients
155-
- **Storage** - Persists message history to SQLite
158+
- **Storage** - Persists message history (JSONL by default, SQLite available)
156159
- **Dashboard API** - Provides real-time data to the web dashboard
157160

158161
### Architecture
@@ -166,7 +169,7 @@ The daemon is the central message broker that routes all communication between a
166169
| | |
167170
+--------v--------+ +--------v--------+ +--------v--------+
168171
| Router | | Storage | | Dashboard |
169-
| (Message | | (SQLite | | (WebSocket + |
172+
| (Message | | (JSONL/SQLite | | (WebSocket + |
170173
| routing) | | persistence) | | REST API) |
171174
+-----------------+ +-----------------+ +-----------------+
172175
```
@@ -219,7 +222,7 @@ Projects are identified by looking for markers in the directory tree:
219222
Each project gets its own:
220223

221224
- Unix socket
222-
- SQLite database
225+
- Storage (JSONL files or SQLite database)
223226
- Message history
224227
- Agent registry
225228

docs/features/cloud.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ description: "Connect to Agent Relay Cloud for persistent workspaces, cross-mach
77

88
Agent Relay Cloud extends your local relay with persistent workspaces, cross-machine messaging, and team collaboration features. Link your local daemon to access cloud capabilities.
99

10+
<video
11+
controls
12+
className="w-full aspect-video rounded-xl"
13+
src="/videos/agent-relay-cloud.mp4"
14+
>
15+
Your browser does not support the video tag.
16+
</video>
17+
1018
## Overview
1119

1220
<CardGroup cols={2}>

docs/features/dashboard.mdx

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,17 @@ description: "Monitor and manage your agent network through the browser-based da
55

66
# Web Dashboard
77

8-
<Note>
9-
**The dashboard is now an external component.** Install it from
10-
[relay-dashboard on GitHub](https://github.com/AgentWorkforce/relay-dashboard).
11-
For a lightweight alternative, the TUI client provides relay communication directly in your terminal.
12-
</Note>
13-
14-
The relay-dashboard provides a web interface for real-time monitoring of your agent network. View agent presence, message history, and coordinate your team from a central interface.
15-
16-
## Installation
17-
18-
Install the dashboard from the external package:
19-
20-
```bash
21-
npm install -g relay-dashboard
22-
```
23-
24-
For full setup and configuration details, see the [relay-dashboard repository](https://github.com/AgentWorkforce/relay-dashboard).
8+
The web dashboard provides a real-time interface for monitoring your agent network. View agent presence, message history, spawn agents, and coordinate your team from a central interface.
259

2610
## Starting the Dashboard
2711

28-
After installing the external package, start the dashboard alongside the daemon:
12+
Start the daemon with the `--dashboard` flag:
2913

3014
```bash
31-
# Start the daemon
32-
agent-relay up
33-
34-
# In another terminal, start the dashboard
35-
relay-dashboard --port 3888
15+
agent-relay up --dashboard
3616
```
3717

38-
By default, the dashboard runs on port **3888**:
18+
This starts both the relay daemon and the dashboard. By default, the dashboard runs on port **3888**:
3919

4020
```
4121
Dashboard: http://localhost:3888
@@ -46,14 +26,14 @@ Dashboard: http://localhost:3888
4626
Specify a different port:
4727

4828
```bash
49-
relay-dashboard --port 3889
29+
agent-relay up --dashboard --port 3889
5030
```
5131

5232
Or set the environment variable:
5333

5434
```bash
5535
export AGENT_RELAY_DASHBOARD_PORT=3889
56-
relay-dashboard
36+
agent-relay up --dashboard
5737
```
5838

5939
## Dashboard Features

docs/guide/agent-setup.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,16 @@ Define roles by adding markdown files to your project:
447447
└── designer.md # UI/UX
448448
```
449449

450-
Names automatically match roles (case-insensitive):
450+
Names automatically match roles (case-insensitive). Create agents using either method:
451+
452+
**Option A: Dashboard (recommended for interactive use)**
453+
1. Open http://localhost:3888
454+
2. Click "Spawn Agent"
455+
3. Enter name "Lead" and select CLI "claude"
456+
457+
**Option B: CLI (for scripting/automation)**
451458
```bash
452-
agent-relay create-agent -n Lead claude # Uses lead.md
459+
agent-relay spawn Lead claude "Your task instructions"
453460
```
454461

455462
---

docs/guides/editor-integration.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ When you send a prompt from your editor:
4949

5050
## Quick Start (Zed)
5151

52+
<video
53+
controls
54+
className="w-full aspect-video rounded-xl"
55+
src="/videos/zed-acp-agent-relay.mp4"
56+
>
57+
Your browser does not support the video tag.
58+
</video>
59+
5260
### 1. Start the Daemon and Configure Zed
5361

5462
```bash

docs/introduction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Agent Relay consists of three main components:
9595
| +----------------+----------------+ |
9696
| | | |
9797
| +--------+--------+ +--------+--------+ |
98-
| | SQLite Storage | | Dashboard | |
98+
| | JSONL Storage | | Dashboard | |
9999
| | (Message | | localhost: | |
100100
| | History) | | 3888 | |
101101
| +-----------------+ +-----------------+ |

0 commit comments

Comments
 (0)