agent-relay-server 0.2.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 +176 -94
- 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 +12 -3
package/README.md
CHANGED
|
@@ -1,87 +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.
|
|
10
16
|
|
|
11
|
-
- **Direct messaging
|
|
12
|
-
- **Capability
|
|
13
|
-
- **
|
|
14
|
-
- **Claim-based
|
|
15
|
-
- **Threading
|
|
16
|
-
- **Live dashboard
|
|
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
|
|
17
23
|
|
|
18
|
-
##
|
|
24
|
+
## Quick Start
|
|
19
25
|
|
|
26
|
+
### 1. Start the relay server
|
|
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
|
|
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:
|
|
60
97
|
|
|
61
98
|
```bash
|
|
62
|
-
|
|
63
|
-
claude plugin install agent-relay@agent-relay
|
|
99
|
+
bunx -p agent-relay-server codex-relay
|
|
64
100
|
```
|
|
65
101
|
|
|
66
|
-
|
|
102
|
+
Non-interactive alias opt-in:
|
|
67
103
|
|
|
68
104
|
```bash
|
|
69
|
-
|
|
105
|
+
curl -fsSL https://raw.githubusercontent.com/edimuj/agent-relay/main/codex/install-codex.sh | bash -s -- --alias
|
|
70
106
|
```
|
|
71
107
|
|
|
72
|
-
|
|
108
|
+
```powershell
|
|
109
|
+
$env:AGENT_RELAY_CODEX_ALIAS = "1"; irm https://raw.githubusercontent.com/edimuj/agent-relay/main/codex/install-codex.ps1 | iex
|
|
110
|
+
```
|
|
73
111
|
|
|
74
|
-
|
|
112
|
+
## What the Agent Sees
|
|
75
113
|
|
|
76
|
-
|
|
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:
|
|
77
115
|
|
|
78
|
-
|
|
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
|
+
```
|
|
79
120
|
|
|
80
|
-
|
|
121
|
+
Incoming messages arrive as monitor notifications. The agent sees them without being prompted:
|
|
81
122
|
|
|
82
|
-
|
|
123
|
+
```
|
|
124
|
+
[msg:42] from backend-agent: Migration looks clean, tests pass. Ready to merge.
|
|
125
|
+
```
|
|
83
126
|
|
|
84
|
-
|
|
127
|
+
## Message Targeting
|
|
85
128
|
|
|
86
129
|
| Target | Example | Behavior |
|
|
87
130
|
|--------|---------|----------|
|
|
@@ -91,20 +134,75 @@ Messages can be addressed five ways:
|
|
|
91
134
|
| Label | `"label:test writer"` | All agents with that human-set label |
|
|
92
135
|
| Broadcast | `"broadcast"` | Everyone |
|
|
93
136
|
|
|
94
|
-
##
|
|
137
|
+
## Deployment
|
|
95
138
|
|
|
96
|
-
|
|
139
|
+
Single process, embedded SQLite, no external dependencies beyond Bun.
|
|
97
140
|
|
|
98
141
|
```bash
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
-H 'Content-Type: application/json' \
|
|
102
|
-
-d '{"from":"user","to":"cap:review","body":"Review PR #42","claimable":true}'
|
|
142
|
+
bunx agent-relay-server # localhost only
|
|
143
|
+
PORT=8080 HOST=0.0.0.0 bunx agent-relay-server # remote access
|
|
103
144
|
```
|
|
104
145
|
|
|
105
|
-
|
|
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
|
+
```
|
|
106
151
|
|
|
107
|
-
|
|
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}`.
|
|
169
|
+
|
|
170
|
+
### Running as a systemd service
|
|
171
|
+
|
|
172
|
+
```bash
|
|
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
|
|
191
|
+
```
|
|
192
|
+
|
|
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
|
+
```
|
|
204
|
+
|
|
205
|
+
## API Reference
|
|
108
206
|
|
|
109
207
|
Base URL: `http://localhost:4850/api`
|
|
110
208
|
|
|
@@ -133,72 +231,56 @@ Base URL: `http://localhost:4850/api`
|
|
|
133
231
|
| `DELETE` | `/messages/:id` | Delete message |
|
|
134
232
|
| `GET` | `/messages/cursor` | Latest message ID (for poller bootstrap) |
|
|
135
233
|
|
|
136
|
-
###
|
|
234
|
+
### Server-Sent Events
|
|
137
235
|
|
|
138
236
|
| Method | Path | Purpose |
|
|
139
237
|
|--------|------|---------|
|
|
140
|
-
| `GET` | `/
|
|
238
|
+
| `GET` | `/events` | SSE stream (`?for=agentId` for filtered, omit for firehose) |
|
|
141
239
|
|
|
142
|
-
|
|
240
|
+
Events: `message.new`, `message.claimed`, `message.deleted`, `agent.status`, `agent.removed`
|
|
143
241
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
| Variable | Default | Purpose |
|
|
147
|
-
|----------|---------|---------|
|
|
148
|
-
| `AGENT_RELAY_URL` | `http://localhost:4850` | Relay server URL |
|
|
149
|
-
| `AGENT_RELAY_CAPS` | `chat` | Comma-separated agent capabilities |
|
|
150
|
-
|
|
151
|
-
If the relay runs on a different machine, set `AGENT_RELAY_URL` to its address — e.g. a Tailscale IP like `http://100.x.y.z:4850`.
|
|
242
|
+
### Stats
|
|
152
243
|
|
|
153
|
-
|
|
244
|
+
| Method | Path | Purpose |
|
|
245
|
+
|--------|------|---------|
|
|
246
|
+
| `GET` | `/stats` | Version, agent counts, message counts |
|
|
154
247
|
|
|
155
248
|
## Architecture
|
|
156
249
|
|
|
157
250
|
```
|
|
158
251
|
src/
|
|
159
|
-
├── index.ts # Bun.serve entry
|
|
252
|
+
├── index.ts # Bun.serve entry, static files, CORS
|
|
160
253
|
├── routes.ts # HTTP router and API handlers
|
|
161
254
|
├── db.ts # SQLite schema, queries, CRUD
|
|
255
|
+
├── sse.ts # Server-Sent Events
|
|
162
256
|
└── types.ts # TypeScript interfaces
|
|
163
257
|
|
|
164
258
|
public/
|
|
165
|
-
└── index.html # Dashboard SPA
|
|
259
|
+
└── index.html # Dashboard SPA (Alpine.js + Tabler)
|
|
166
260
|
|
|
167
|
-
claude/
|
|
168
|
-
├── .claude-plugin/plugin.json
|
|
169
|
-
├── monitors/
|
|
170
|
-
│ └── monitors.json # Auto-start inbox monitor
|
|
261
|
+
claude/ # Claude Code plugin
|
|
262
|
+
├── .claude-plugin/plugin.json
|
|
263
|
+
├── monitors/monitors.json # Auto-start inbox monitor
|
|
171
264
|
└── hooks/
|
|
172
|
-
├──
|
|
173
|
-
├──
|
|
174
|
-
|
|
175
|
-
|
|
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
|
|
176
273
|
```
|
|
177
274
|
|
|
178
|
-
##
|
|
179
|
-
|
|
180
|
-
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
|
|
181
276
|
|
|
182
277
|
```bash
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
#
|
|
187
|
-
PORT=8080 HOST=0.0.0.0 bunx agent-relay-server
|
|
188
|
-
|
|
189
|
-
# or install globally
|
|
190
|
-
bun install -g agent-relay-server
|
|
191
|
-
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
|
|
192
282
|
```
|
|
193
283
|
|
|
194
|
-
| Variable | Default | Purpose |
|
|
195
|
-
|----------|---------|---------|
|
|
196
|
-
| `PORT` | `4850` | Server port |
|
|
197
|
-
| `HOST` | `127.0.0.1` | Bind address (`0.0.0.0` for remote access) |
|
|
198
|
-
| `DB_PATH` | `agent-relay.db` | SQLite database path |
|
|
199
|
-
| `RETENTION_DAYS` | `30` | Auto-prune messages older than this |
|
|
200
|
-
| `AGENT_RELAY_LOG_REQUESTS` | `0` | Set to `1` to log all API requests |
|
|
201
|
-
|
|
202
284
|
## License
|
|
203
285
|
|
|
204
286
|
MIT
|