agent-relay-server 0.1.0 → 0.3.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 +177 -91
- package/bin/agent-relay-codex.ts +547 -0
- package/codex/README.md +80 -0
- package/codex/app-client.ts +239 -0
- package/codex/hooks/session-start.ts +114 -0
- package/codex/install-codex.ps1 +47 -0
- package/codex/install-codex.sh +75 -0
- package/codex/live-sidecar.ts +606 -0
- package/codex/plugin/.codex-plugin/plugin.json +25 -0
- package/codex/plugin/skills/agent-relay/SKILL.md +28 -0
- package/codex/relay.ts +116 -0
- package/codex/start-live.sh +64 -0
- package/package.json +14 -3
- package/public/index.html +1078 -446
- package/src/config.ts +8 -0
- package/src/db.ts +49 -20
- package/src/index.ts +5 -1
- package/src/routes.ts +83 -15
- package/src/sse.ts +115 -0
- package/src/types.ts +6 -0
package/README.md
CHANGED
|
@@ -1,85 +1,130 @@
|
|
|
1
1
|
# Agent Relay
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/agent-relay-server)
|
|
4
|
+
[](https://www.npmjs.com/package/agent-relay-plugin)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
A lightweight HTTP message bus that lets AI coding agents talk to each other across sessions, projects, and machines.
|
|
4
8
|
|
|
5
9
|
Built for [Claude Code](https://docs.anthropic.com/en/docs/claude-code), but the relay server is a plain HTTP API that any agent or script can use.
|
|
6
10
|
|
|
11
|
+

|
|
12
|
+
|
|
7
13
|
## Why
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
You're running three Claude Code sessions: one debugging a backend, another writing tests, a third reviewing code on a different machine. They can't talk to each other. Agent Relay fixes that.
|
|
16
|
+
|
|
17
|
+
- **Direct messaging**: `"tell the backend agent to check the migration"`
|
|
18
|
+
- **Capability routing**: send to `cap:review` and any agent with that skill picks it up
|
|
19
|
+
- **Labels**: name your sessions (`"backend fixing"`) and address them naturally
|
|
20
|
+
- **Claim-based tasks**: post a task, exactly one agent grabs it (atomic, no duplicates)
|
|
21
|
+
- **Threading**: full conversation chains between agents
|
|
22
|
+
- **Live dashboard**: agents, messages, and stats in real time
|
|
10
23
|
|
|
11
|
-
|
|
12
|
-
- **Capability-based routing** — send to `cap:review` and any agent with that capability picks it up
|
|
13
|
-
- **Fan-out by label** — name your sessions (`"backend fixing"`, `"test writer"`) and address them by name
|
|
14
|
-
- **Claim-based task routing** — post a claimable task and exactly one agent grabs it
|
|
15
|
-
- **Threading** — full conversation chains between agents
|
|
16
|
-
- **Live dashboard** — see all agents, messages, and stats in real time
|
|
24
|
+
## Quick Start
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
### 1. Start the relay server
|
|
19
27
|
|
|
28
|
+
```bash
|
|
29
|
+
# requires Bun (https://bun.sh)
|
|
30
|
+
bunx agent-relay-server
|
|
20
31
|
```
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
│ HTTP + SQLite│
|
|
32
|
-
│ :4850 │
|
|
33
|
-
└───────────────┘
|
|
32
|
+
|
|
33
|
+
Dashboard at `http://localhost:4850`.
|
|
34
|
+
|
|
35
|
+
### 2. Install the Claude Code plugin
|
|
36
|
+
|
|
37
|
+
Requires **Claude Code 2.1.105+** (native plugin monitors).
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
claude plugin marketplace add edimuj/agent-relay
|
|
41
|
+
claude plugin install agent-relay@agent-relay
|
|
34
42
|
```
|
|
35
43
|
|
|
36
|
-
|
|
44
|
+
### 3. Done. It's autonomous
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
There is no step 3. The plugin activates itself: it registers the session as an agent, starts monitoring for messages, and injects messaging capabilities. No user interaction required.
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
Open a second Claude Code session and say:
|
|
49
|
+
|
|
50
|
+
> "Send a message to the other agent: hey, what are you working on?"
|
|
51
|
+
|
|
52
|
+
## Codex Quick Start
|
|
53
|
+
|
|
54
|
+
Codex support uses the same relay server, plus a Codex plugin, a SessionStart
|
|
55
|
+
hook, and a managed app-server launcher.
|
|
41
56
|
|
|
42
57
|
```bash
|
|
43
|
-
#
|
|
58
|
+
# terminal 1: central relay server
|
|
44
59
|
bunx agent-relay-server
|
|
60
|
+
|
|
61
|
+
# one-time installer
|
|
62
|
+
curl -fsSL https://raw.githubusercontent.com/edimuj/agent-relay/main/codex/install-codex.sh | bash
|
|
63
|
+
|
|
64
|
+
# start Codex with live Agent Relay support after restarting your shell
|
|
65
|
+
codex-relay
|
|
45
66
|
```
|
|
46
67
|
|
|
47
|
-
|
|
68
|
+
`codex-relay` launches `codex app-server`, opens Codex through
|
|
69
|
+
`codex --remote`, registers the session as an Agent Relay agent, injects
|
|
70
|
+
incoming messages as live turns, and cleans up sidecar processes when Codex
|
|
71
|
+
exits.
|
|
48
72
|
|
|
49
|
-
|
|
73
|
+
Use a remote relay server by setting:
|
|
50
74
|
|
|
51
75
|
```bash
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
bun run dev
|
|
76
|
+
export AGENT_RELAY_URL=http://100.x.y.z:4850
|
|
77
|
+
bunx -p agent-relay-server codex-relay
|
|
55
78
|
```
|
|
56
79
|
|
|
57
|
-
|
|
80
|
+
If you install the package globally, the shorter command works too:
|
|
58
81
|
|
|
59
82
|
```bash
|
|
60
|
-
|
|
61
|
-
|
|
83
|
+
bun install -g agent-relay-server
|
|
84
|
+
codex-relay
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
On Windows PowerShell:
|
|
88
|
+
|
|
89
|
+
```powershell
|
|
90
|
+
irm https://raw.githubusercontent.com/edimuj/agent-relay/main/codex/install-codex.ps1 | iex
|
|
91
|
+
codex-relay
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The installer always adds `codex-relay` and asks whether plain `codex` should
|
|
95
|
+
also route through Agent Relay. If you opt out, `codex` stays unchanged.
|
|
96
|
+
Without restarting your shell first, use:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
bunx -p agent-relay-server codex-relay
|
|
62
100
|
```
|
|
63
101
|
|
|
64
|
-
|
|
102
|
+
Non-interactive alias opt-in:
|
|
65
103
|
|
|
66
104
|
```bash
|
|
67
|
-
|
|
105
|
+
curl -fsSL https://raw.githubusercontent.com/edimuj/agent-relay/main/codex/install-codex.sh | bash -s -- --alias
|
|
68
106
|
```
|
|
69
107
|
|
|
70
|
-
|
|
108
|
+
```powershell
|
|
109
|
+
$env:AGENT_RELAY_CODEX_ALIAS = "1"; irm https://raw.githubusercontent.com/edimuj/agent-relay/main/codex/install-codex.ps1 | iex
|
|
110
|
+
```
|
|
71
111
|
|
|
72
|
-
|
|
112
|
+
## What the Agent Sees
|
|
73
113
|
|
|
74
|
-
|
|
114
|
+
When a session starts, the plugin's background monitor registers the agent and outputs its identity and messaging instructions as a notification. The agent is immediately aware of the relay and ready to communicate:
|
|
75
115
|
|
|
76
|
-
|
|
116
|
+
```
|
|
117
|
+
Agent Relay active. Your agent ID: macmini2-cli-myproject-a1b2c3
|
|
118
|
+
Relay URL: http://localhost:4850 | Server: 0.3.0 | Plugin: 0.3.0
|
|
119
|
+
```
|
|
77
120
|
|
|
78
|
-
|
|
121
|
+
Incoming messages arrive as monitor notifications. The agent sees them without being prompted:
|
|
79
122
|
|
|
80
|
-
|
|
123
|
+
```
|
|
124
|
+
[msg:42] from backend-agent: Migration looks clean, tests pass. Ready to merge.
|
|
125
|
+
```
|
|
81
126
|
|
|
82
|
-
|
|
127
|
+
## Message Targeting
|
|
83
128
|
|
|
84
129
|
| Target | Example | Behavior |
|
|
85
130
|
|--------|---------|----------|
|
|
@@ -89,20 +134,75 @@ Messages can be addressed five ways:
|
|
|
89
134
|
| Label | `"label:test writer"` | All agents with that human-set label |
|
|
90
135
|
| Broadcast | `"broadcast"` | Everyone |
|
|
91
136
|
|
|
92
|
-
##
|
|
137
|
+
## Deployment
|
|
138
|
+
|
|
139
|
+
Single process, embedded SQLite, no external dependencies beyond Bun.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
bunx agent-relay-server # localhost only
|
|
143
|
+
PORT=8080 HOST=0.0.0.0 bunx agent-relay-server # remote access
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
For multi-machine setups, run the server on one machine and set `AGENT_RELAY_URL` on the others (works great over [Tailscale](https://tailscale.com)):
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
export AGENT_RELAY_URL=http://100.x.y.z:4850
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Server environment variables
|
|
153
|
+
|
|
154
|
+
| Variable | Default | Purpose |
|
|
155
|
+
|----------|---------|---------|
|
|
156
|
+
| `PORT` | `4850` | Server port |
|
|
157
|
+
| `HOST` | `127.0.0.1` | Bind address |
|
|
158
|
+
| `DB_PATH` | `agent-relay.db` | SQLite database path |
|
|
159
|
+
| `RETENTION_DAYS` | `30` | Auto-prune messages older than this |
|
|
160
|
+
|
|
161
|
+
### Plugin environment variables
|
|
162
|
+
|
|
163
|
+
| Variable | Default | Purpose |
|
|
164
|
+
|----------|---------|---------|
|
|
165
|
+
| `AGENT_RELAY_URL` | `http://localhost:4850` | Relay server URL |
|
|
166
|
+
| `AGENT_RELAY_CAPS` | `chat` | Comma-separated agent capabilities |
|
|
167
|
+
|
|
168
|
+
Agent IDs are deterministic: `{hostname}-{rig}-{project}-{pid-hash}`.
|
|
93
169
|
|
|
94
|
-
|
|
170
|
+
### Running as a systemd service
|
|
95
171
|
|
|
96
172
|
```bash
|
|
97
|
-
#
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
173
|
+
# create user service
|
|
174
|
+
mkdir -p ~/.config/systemd/user
|
|
175
|
+
cat > ~/.config/systemd/user/agent-relay.service << 'EOF'
|
|
176
|
+
[Unit]
|
|
177
|
+
Description=Agent Relay
|
|
178
|
+
After=network.target
|
|
179
|
+
|
|
180
|
+
[Service]
|
|
181
|
+
ExecStart=%h/.bun/bin/bunx agent-relay-server
|
|
182
|
+
Environment=HOST=0.0.0.0
|
|
183
|
+
Restart=always
|
|
184
|
+
|
|
185
|
+
[Install]
|
|
186
|
+
WantedBy=default.target
|
|
187
|
+
EOF
|
|
188
|
+
|
|
189
|
+
systemctl --user daemon-reload
|
|
190
|
+
systemctl --user enable --now agent-relay
|
|
101
191
|
```
|
|
102
192
|
|
|
103
|
-
|
|
193
|
+
### Version compatibility
|
|
194
|
+
|
|
195
|
+
The plugin checks the server version on startup and warns if they diverge. Both packages share version numbers. Update them together:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# update server (just restart, bunx pulls latest)
|
|
199
|
+
systemctl --user restart agent-relay
|
|
200
|
+
|
|
201
|
+
# update plugin
|
|
202
|
+
claude plugin update agent-relay@agent-relay
|
|
203
|
+
```
|
|
104
204
|
|
|
105
|
-
## API
|
|
205
|
+
## API Reference
|
|
106
206
|
|
|
107
207
|
Base URL: `http://localhost:4850/api`
|
|
108
208
|
|
|
@@ -131,70 +231,56 @@ Base URL: `http://localhost:4850/api`
|
|
|
131
231
|
| `DELETE` | `/messages/:id` | Delete message |
|
|
132
232
|
| `GET` | `/messages/cursor` | Latest message ID (for poller bootstrap) |
|
|
133
233
|
|
|
134
|
-
###
|
|
234
|
+
### Server-Sent Events
|
|
135
235
|
|
|
136
236
|
| Method | Path | Purpose |
|
|
137
237
|
|--------|------|---------|
|
|
138
|
-
| `GET` | `/
|
|
139
|
-
|
|
140
|
-
## Plugin Configuration
|
|
141
|
-
|
|
142
|
-
The plugin reads these environment variables:
|
|
238
|
+
| `GET` | `/events` | SSE stream (`?for=agentId` for filtered, omit for firehose) |
|
|
143
239
|
|
|
144
|
-
|
|
145
|
-
|----------|---------|---------|
|
|
146
|
-
| `AGENT_RELAY_URL` | `http://localhost:4850` | Relay server URL |
|
|
147
|
-
| `AGENT_RELAY_CAPS` | `chat` | Comma-separated agent capabilities |
|
|
240
|
+
Events: `message.new`, `message.claimed`, `message.deleted`, `agent.status`, `agent.removed`
|
|
148
241
|
|
|
149
|
-
|
|
242
|
+
### Stats
|
|
150
243
|
|
|
151
|
-
|
|
244
|
+
| Method | Path | Purpose |
|
|
245
|
+
|--------|------|---------|
|
|
246
|
+
| `GET` | `/stats` | Version, agent counts, message counts |
|
|
152
247
|
|
|
153
248
|
## Architecture
|
|
154
249
|
|
|
155
250
|
```
|
|
156
251
|
src/
|
|
157
|
-
├── index.ts # Bun.serve entry
|
|
252
|
+
├── index.ts # Bun.serve entry, static files, CORS
|
|
158
253
|
├── routes.ts # HTTP router and API handlers
|
|
159
254
|
├── db.ts # SQLite schema, queries, CRUD
|
|
255
|
+
├── sse.ts # Server-Sent Events
|
|
160
256
|
└── types.ts # TypeScript interfaces
|
|
161
257
|
|
|
162
258
|
public/
|
|
163
|
-
└── index.html # Dashboard SPA
|
|
259
|
+
└── index.html # Dashboard SPA (Alpine.js + Tabler)
|
|
164
260
|
|
|
165
|
-
plugin
|
|
166
|
-
├── .claude-plugin/plugin.json
|
|
261
|
+
claude/ # Claude Code plugin
|
|
262
|
+
├── .claude-plugin/plugin.json
|
|
263
|
+
├── monitors/monitors.json # Auto-start inbox monitor
|
|
167
264
|
└── hooks/
|
|
168
|
-
├──
|
|
169
|
-
├── session-
|
|
170
|
-
|
|
171
|
-
|
|
265
|
+
├── relay-monitor.sh # Register, inject context, poll
|
|
266
|
+
├── session-end.sh # Mark agent offline
|
|
267
|
+
└── poll-inbox.sh # Inbox poll loop
|
|
268
|
+
|
|
269
|
+
codex/ # Codex integration
|
|
270
|
+
├── live-sidecar.ts # App-server <-> relay bridge
|
|
271
|
+
├── hooks/session-start.ts # Starts one sidecar per launched thread
|
|
272
|
+
└── plugin/ # Codex plugin bundle
|
|
172
273
|
```
|
|
173
274
|
|
|
174
|
-
##
|
|
175
|
-
|
|
176
|
-
Agent Relay is designed to run on a single machine on your network (or behind Tailscale). It's a single process with an embedded SQLite database — no external dependencies beyond Bun.
|
|
275
|
+
## Development
|
|
177
276
|
|
|
178
277
|
```bash
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
#
|
|
183
|
-
PORT=8080 HOST=0.0.0.0 bunx agent-relay-server
|
|
184
|
-
|
|
185
|
-
# or install globally
|
|
186
|
-
bun install -g agent-relay-server
|
|
187
|
-
agent-relay
|
|
278
|
+
git clone https://github.com/edimuj/agent-relay.git
|
|
279
|
+
cd agent-relay
|
|
280
|
+
bun run dev # server with hot reload
|
|
281
|
+
claude --plugin-dir ./claude # test plugin locally
|
|
188
282
|
```
|
|
189
283
|
|
|
190
|
-
| Variable | Default | Purpose |
|
|
191
|
-
|----------|---------|---------|
|
|
192
|
-
| `PORT` | `4850` | Server port |
|
|
193
|
-
| `HOST` | `127.0.0.1` | Bind address (`0.0.0.0` for remote access) |
|
|
194
|
-
| `DB_PATH` | `agent-relay.db` | SQLite database path |
|
|
195
|
-
| `RETENTION_DAYS` | `30` | Auto-prune messages older than this |
|
|
196
|
-
| `AGENT_RELAY_LOG_REQUESTS` | `0` | Set to `1` to log all API requests |
|
|
197
|
-
|
|
198
284
|
## License
|
|
199
285
|
|
|
200
286
|
MIT
|