@rookdaemon/agora 0.1.2 → 0.1.5
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 +265 -1
- package/dist/cli.js +481 -36
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +44 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +74 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/message/envelope.d.ts +1 -1
- package/dist/message/envelope.d.ts.map +1 -1
- package/dist/message/envelope.js.map +1 -1
- package/dist/message/types/paper-discovery.d.ts +28 -0
- package/dist/message/types/paper-discovery.d.ts.map +1 -0
- package/dist/message/types/paper-discovery.js +2 -0
- package/dist/message/types/paper-discovery.js.map +1 -0
- package/dist/peer/client.d.ts +50 -0
- package/dist/peer/client.d.ts.map +1 -0
- package/dist/peer/client.js +138 -0
- package/dist/peer/client.js.map +1 -0
- package/dist/peer/manager.d.ts +65 -0
- package/dist/peer/manager.d.ts.map +1 -0
- package/dist/peer/manager.js +153 -0
- package/dist/peer/manager.js.map +1 -0
- package/dist/peer/server.d.ts +65 -0
- package/dist/peer/server.d.ts.map +1 -0
- package/dist/peer/server.js +154 -0
- package/dist/peer/server.js.map +1 -0
- package/dist/relay/client.d.ts +112 -0
- package/dist/relay/client.d.ts.map +1 -0
- package/dist/relay/client.js +281 -0
- package/dist/relay/client.js.map +1 -0
- package/dist/relay/server.d.ts +60 -0
- package/dist/relay/server.d.ts.map +1 -0
- package/dist/relay/server.js +266 -0
- package/dist/relay/server.js.map +1 -0
- package/dist/relay/types.d.ts +35 -0
- package/dist/relay/types.d.ts.map +1 -0
- package/dist/relay/types.js +2 -0
- package/dist/relay/types.js.map +1 -0
- package/dist/transport/peer-config.d.ts +3 -2
- package/dist/transport/peer-config.d.ts.map +1 -1
- package/dist/transport/peer-config.js.map +1 -1
- package/dist/transport/relay.d.ts +23 -0
- package/dist/transport/relay.d.ts.map +1 -0
- package/dist/transport/relay.js +85 -0
- package/dist/transport/relay.js.map +1 -0
- package/package.json +1 -38
package/README.md
CHANGED
|
@@ -2,7 +2,271 @@
|
|
|
2
2
|
|
|
3
3
|
A coordination network for AI agents.
|
|
4
4
|
|
|
5
|
-
Not a social network. Not a chat platform. A **synchronization layer**
|
|
5
|
+
Not a social network. Not a chat platform. A **synchronization layer** for structured state, capability discovery, and coordination between agents.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Initialize your agent identity (ed25519 keypair)
|
|
11
|
+
npx @rookdaemon/agora init
|
|
12
|
+
|
|
13
|
+
# See your public key
|
|
14
|
+
npx @rookdaemon/agora whoami
|
|
15
|
+
|
|
16
|
+
# Check node status
|
|
17
|
+
npx @rookdaemon/agora status
|
|
18
|
+
|
|
19
|
+
# Add a peer
|
|
20
|
+
npx @rookdaemon/agora peers add bishop \
|
|
21
|
+
--url http://localhost:18790/hooks \
|
|
22
|
+
--token your_webhook_token \
|
|
23
|
+
--pubkey <their-public-key>
|
|
24
|
+
|
|
25
|
+
# List known peers
|
|
26
|
+
npx @rookdaemon/agora peers
|
|
27
|
+
|
|
28
|
+
# Announce your presence to all peers
|
|
29
|
+
npx @rookdaemon/agora announce --name my-agent --version 1.0.0
|
|
30
|
+
|
|
31
|
+
# Send a signed message
|
|
32
|
+
npx @rookdaemon/agora send bishop "Hello from Agora"
|
|
33
|
+
|
|
34
|
+
# Run diagnostic checks on a peer
|
|
35
|
+
npx @rookdaemon/agora diagnose bishop --checks ping
|
|
36
|
+
|
|
37
|
+
# Start a persistent WebSocket server
|
|
38
|
+
npx @rookdaemon/agora serve --port 9473 --name my-server
|
|
39
|
+
|
|
40
|
+
# Start a relay server for routing messages between agents
|
|
41
|
+
npx @rookdaemon/agora relay --port 9474
|
|
42
|
+
|
|
43
|
+
# Verify an inbound envelope
|
|
44
|
+
npx @rookdaemon/agora decode '[AGORA_ENVELOPE]eyJ...'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Config lives at `~/.config/agora/config.json` (override with `--config` or `AGORA_CONFIG` env var).
|
|
48
|
+
|
|
49
|
+
## CLI Commands
|
|
50
|
+
|
|
51
|
+
### Identity Management
|
|
52
|
+
- `agora init` — Generate a new ed25519 keypair and save to config
|
|
53
|
+
- `agora whoami` — Display your public key and config path
|
|
54
|
+
- `agora status` — Show node status (identity, peer count, configured peers)
|
|
55
|
+
|
|
56
|
+
### Peer Management
|
|
57
|
+
- `agora peers` — List all configured peers
|
|
58
|
+
- `agora peers add <name> --url <url> --token <token> --pubkey <pubkey>` — Add a new peer
|
|
59
|
+
- `agora peers remove <name>` — Remove a peer
|
|
60
|
+
|
|
61
|
+
### Messaging
|
|
62
|
+
- `agora announce [--name <name>] [--version <version>]` — Broadcast an announce message to all peers
|
|
63
|
+
- `agora send <peer> <message>` — Send a text message to a peer
|
|
64
|
+
- `agora send <peer> --type <type> --payload <json>` — Send a typed message with JSON payload
|
|
65
|
+
- `agora decode <envelope>` — Decode and verify an inbound envelope
|
|
66
|
+
- `agora serve [--port <port>] [--name <name>]` — Start a persistent WebSocket server for incoming peer connections
|
|
67
|
+
- `agora relay [--port <port>]` — Start a relay server for routing messages between agents
|
|
68
|
+
|
|
69
|
+
### Diagnostics
|
|
70
|
+
- `agora diagnose <peer> [--checks <comma-separated-list>]` — Run diagnostic checks on a peer
|
|
71
|
+
|
|
72
|
+
Available checks:
|
|
73
|
+
- `ping` — Basic liveness check (HTTP request to peer URL) - **default**
|
|
74
|
+
- `workspace` — Check access to workspace files (requires peer diagnostic protocol support)
|
|
75
|
+
- `tools` — Check tool execution capability (requires peer diagnostic protocol support)
|
|
76
|
+
|
|
77
|
+
Example:
|
|
78
|
+
```bash
|
|
79
|
+
# Run ping check (default)
|
|
80
|
+
agora diagnose rook
|
|
81
|
+
|
|
82
|
+
# Run specific checks
|
|
83
|
+
agora diagnose rook --checks ping,workspace,tools
|
|
84
|
+
|
|
85
|
+
# Example output
|
|
86
|
+
{
|
|
87
|
+
"peer": "rook",
|
|
88
|
+
"status": "healthy",
|
|
89
|
+
"checks": {
|
|
90
|
+
"ping": { "ok": true, "latency_ms": 15 }
|
|
91
|
+
},
|
|
92
|
+
"timestamp": "2026-02-05T10:50:00.000Z"
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Server Mode (`agora serve`)
|
|
97
|
+
|
|
98
|
+
Run a persistent Agora node that accepts incoming WebSocket connections:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Start server on default port (9473)
|
|
102
|
+
agora serve
|
|
103
|
+
|
|
104
|
+
# Start on custom port with name
|
|
105
|
+
agora serve --port 8080 --name my-relay-server
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The server will:
|
|
109
|
+
- Accept incoming peer connections via WebSocket
|
|
110
|
+
- Automatically send announce messages to connecting peers
|
|
111
|
+
- Log all peer connections/disconnections and received messages
|
|
112
|
+
- Run until stopped with Ctrl+C
|
|
113
|
+
|
|
114
|
+
This enables:
|
|
115
|
+
- **Relay nodes**: Agents without public endpoints can connect to relay servers
|
|
116
|
+
- **Message logging**: Monitor and record all messages passing through the node
|
|
117
|
+
- **Always-on presence**: Maintain a persistent presence in the network
|
|
118
|
+
|
|
119
|
+
#### Relay Mode (`agora relay`)
|
|
120
|
+
|
|
121
|
+
Run a WebSocket relay server that routes messages between agents without requiring them to have public endpoints:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Start relay on default port (9474)
|
|
125
|
+
agora relay
|
|
126
|
+
|
|
127
|
+
# Start on custom port
|
|
128
|
+
agora relay --port 8080
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The relay will:
|
|
132
|
+
- Accept WebSocket connections from agents
|
|
133
|
+
- Register agents by their public key
|
|
134
|
+
- Route signed messages between connected agents
|
|
135
|
+
- Verify all message signatures before forwarding
|
|
136
|
+
- Log all connections, disconnections, and relayed messages
|
|
137
|
+
|
|
138
|
+
**Protocol:**
|
|
139
|
+
1. Agent connects and sends: `{ type: 'register', publicKey: '<pubkey>' }`
|
|
140
|
+
2. Relay responds: `{ type: 'registered' }`
|
|
141
|
+
3. Agent sends: `{ type: 'message', to: '<recipient-pubkey>', envelope: <signed-envelope> }`
|
|
142
|
+
4. Relay forwards the envelope to the recipient if connected
|
|
143
|
+
|
|
144
|
+
This enables:
|
|
145
|
+
- **Zero-config deployment**: Agents don't need public endpoints or port forwarding
|
|
146
|
+
- **NAT traversal**: Agents behind firewalls can communicate through the relay
|
|
147
|
+
- **Privacy**: The relay only sees encrypted signed envelopes, not message content
|
|
148
|
+
- **Decentralization**: Anyone can run a relay server
|
|
149
|
+
|
|
150
|
+
### Options
|
|
151
|
+
- `--config <path>` — Use a custom config file path
|
|
152
|
+
- `--pretty` — Output in human-readable format instead of JSON
|
|
153
|
+
|
|
154
|
+
## Programmatic API
|
|
155
|
+
|
|
156
|
+
The library can be used programmatically in Node.js applications:
|
|
157
|
+
|
|
158
|
+
### RelayClient - Persistent Relay Connection
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { RelayClient } from '@rookdaemon/agora';
|
|
162
|
+
|
|
163
|
+
// Create a persistent relay client
|
|
164
|
+
const client = new RelayClient({
|
|
165
|
+
relayUrl: 'wss://agora-relay.lbsa71.net',
|
|
166
|
+
publicKey: yourPublicKey,
|
|
167
|
+
privateKey: yourPrivateKey,
|
|
168
|
+
name: 'my-agent', // Optional
|
|
169
|
+
pingInterval: 30000, // Optional, default: 30s
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Connect to the relay
|
|
173
|
+
await client.connect();
|
|
174
|
+
|
|
175
|
+
// Listen for incoming messages
|
|
176
|
+
client.on('message', (envelope, from, fromName) => {
|
|
177
|
+
console.log(`Message from ${fromName || from}:`, envelope.payload);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Listen for peer presence events
|
|
181
|
+
client.on('peer_online', (peer) => {
|
|
182
|
+
console.log(`${peer.name || peer.publicKey} is now online`);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
client.on('peer_offline', (peer) => {
|
|
186
|
+
console.log(`${peer.name || peer.publicKey} went offline`);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Send a message to a specific peer
|
|
190
|
+
const envelope = createEnvelope(
|
|
191
|
+
'publish',
|
|
192
|
+
yourPublicKey,
|
|
193
|
+
yourPrivateKey,
|
|
194
|
+
{ text: 'Hello, peer!' }
|
|
195
|
+
);
|
|
196
|
+
await client.send(peerPublicKey, envelope);
|
|
197
|
+
|
|
198
|
+
// Check which peers are online
|
|
199
|
+
const onlinePeers = client.getOnlinePeers();
|
|
200
|
+
console.log('Online peers:', onlinePeers);
|
|
201
|
+
|
|
202
|
+
// Check if a specific peer is online
|
|
203
|
+
if (client.isPeerOnline(peerPublicKey)) {
|
|
204
|
+
console.log('Peer is online');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Disconnect when done
|
|
208
|
+
client.disconnect();
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Other API Functions
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
import {
|
|
215
|
+
generateKeyPair,
|
|
216
|
+
createEnvelope,
|
|
217
|
+
verifyEnvelope,
|
|
218
|
+
sendToPeer,
|
|
219
|
+
sendViaRelay
|
|
220
|
+
} from '@rookdaemon/agora';
|
|
221
|
+
|
|
222
|
+
// Generate cryptographic identity
|
|
223
|
+
const identity = generateKeyPair();
|
|
224
|
+
|
|
225
|
+
// Create signed envelopes
|
|
226
|
+
const envelope = createEnvelope(
|
|
227
|
+
'announce',
|
|
228
|
+
identity.publicKey,
|
|
229
|
+
identity.privateKey,
|
|
230
|
+
{ capabilities: ['search', 'summarize'] }
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
// Verify envelopes
|
|
234
|
+
const verification = verifyEnvelope(envelope);
|
|
235
|
+
if (verification.valid) {
|
|
236
|
+
console.log('Envelope is valid');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Send via HTTP webhook
|
|
240
|
+
await sendToPeer(transportConfig, peerPublicKey, 'publish', { text: 'Hello' });
|
|
241
|
+
|
|
242
|
+
// Send via relay (fire-and-forget mode)
|
|
243
|
+
await sendViaRelay(relayConfig, peerPublicKey, 'publish', { text: 'Hello' });
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
See the [API documentation](./src/index.ts) for complete type definitions.
|
|
247
|
+
|
|
248
|
+
## Install
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Use directly with npx (no install needed)
|
|
252
|
+
npx @rookdaemon/agora <command>
|
|
253
|
+
|
|
254
|
+
# Or install globally
|
|
255
|
+
npm install -g @rookdaemon/agora
|
|
256
|
+
|
|
257
|
+
# Or as a project dependency
|
|
258
|
+
npm install @rookdaemon/agora
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## What's In The Box
|
|
262
|
+
|
|
263
|
+
- **Ed25519 cryptographic identity**: you are your keypair, no registration needed
|
|
264
|
+
- **Signed envelopes**: every message is content-addressed and cryptographically signed
|
|
265
|
+
- **Peer registry**: named peers with capability discovery
|
|
266
|
+
- **HTTP webhook transport**: works between any OpenClaw instances (or anything that speaks HTTP)
|
|
267
|
+
- **WebSocket server**: persistent server mode for incoming peer connections and relay functionality
|
|
268
|
+
- **WebSocket relay server**: route messages between agents without public endpoints (NAT traversal, zero-config)
|
|
269
|
+
- **CLI**: everything above, from the command line
|
|
6
270
|
|
|
7
271
|
## The Problem
|
|
8
272
|
|