adp-agent 0.2.1 → 0.2.3
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 +492 -67
- package/README.zh.md +565 -0
- package/dist/src/mcp-server.js +2 -2
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/start-mcp.js +5 -5
- package/dist/start-mcp.js.map +1 -1
- package/dist/start-relay.d.ts +1 -0
- package/dist/start-relay.js +1 -0
- package/dist/start-relay.js.map +1 -1
- package/package.json +4 -2
- package/skill/SKILL.md +195 -3
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
[中文](README.zh.md) | **English**
|
|
4
|
+
|
|
5
|
+
</div>
|
|
6
|
+
|
|
1
7
|
<div align="center">
|
|
2
8
|
<h1>
|
|
3
9
|
<br>
|
|
@@ -19,56 +25,283 @@
|
|
|
19
25
|
</div>
|
|
20
26
|
|
|
21
27
|
<div align="center">
|
|
22
|
-
<strong
|
|
28
|
+
<strong>Enable AI agents to discover and communicate with each other, without a centralized platform</strong>
|
|
23
29
|
</div>
|
|
24
30
|
|
|
25
31
|
<br>
|
|
26
32
|
|
|
27
33
|
<div align="center">
|
|
28
|
-
<a href="
|
|
29
|
-
<a href="
|
|
30
|
-
<a href="
|
|
31
|
-
<a href="
|
|
32
|
-
<a href="
|
|
33
|
-
<a href="
|
|
34
|
+
<a href="#-platform-definition">Definition</a> •
|
|
35
|
+
<a href="#-core-components">Components</a> •
|
|
36
|
+
<a href="#-technical-goals">Goals</a> •
|
|
37
|
+
<a href="#-quick-start">Quick Start</a> •
|
|
38
|
+
<a href="#-installation">Installation</a> •
|
|
39
|
+
<a href="#-usage-examples">Examples</a> •
|
|
40
|
+
<a href="#-architecture">Architecture</a> •
|
|
41
|
+
<a href="#-documentation">Docs</a>
|
|
34
42
|
</div>
|
|
35
43
|
|
|
36
44
|
<br>
|
|
37
45
|
|
|
38
46
|
---
|
|
39
47
|
|
|
40
|
-
##
|
|
48
|
+
## Platform Definition
|
|
49
|
+
|
|
50
|
+
ADP (Agent Discovery Protocol) is a decentralized agent discovery and communication protocol that enables AI agents to discover each other, establish connections, and communicate securely without any centralized platform. Through self-authenticating cryptographic identities, mDNS zero-config discovery, and mandatory Ed25519 signature verification, ADP provides a secure and reliable infrastructure for inter-agent collaboration.
|
|
51
|
+
|
|
52
|
+
## Core Components
|
|
53
|
+
|
|
54
|
+
### 1. Self-Authenticating Identity System
|
|
55
|
+
|
|
56
|
+
A self-authenticating identity system based on Ed25519 public-key cryptography. The Agent ID directly embeds the public key, and whoever holds the private key owns that identity.
|
|
57
|
+
|
|
58
|
+
- **Zero-trust architecture** — No centralized authentication service required
|
|
59
|
+
- **Key rotation** — Supports secure key update mechanisms
|
|
60
|
+
- **Persistent storage** — Keys are securely stored in the local filesystem
|
|
61
|
+
|
|
62
|
+
### 2. Discovery Mechanisms
|
|
63
|
+
|
|
64
|
+
Multiple discovery methods to suit different network environments.
|
|
65
|
+
|
|
66
|
+
- **mDNS zero-config discovery** — Automatic discovery on LAN, no manual configuration needed
|
|
67
|
+
- **Registry directory service** — Optional centralized directory for WAN discovery
|
|
68
|
+
- **Relay service** — Communication relay that traverses NAT and firewalls
|
|
69
|
+
|
|
70
|
+
### 3. Message Transport Layer
|
|
71
|
+
|
|
72
|
+
Real-time message transmission based on WebSocket, supporting multiple communication modes.
|
|
73
|
+
|
|
74
|
+
- **WebSocket direct connection** — Point-to-point direct communication
|
|
75
|
+
- **Webhook callbacks** — Ideal for delivering results of long-running async tasks
|
|
76
|
+
- **Hybrid mode** — WebSocket for sync responses, Webhook for async callbacks
|
|
77
|
+
|
|
78
|
+
### 4. Security & Trust
|
|
79
|
+
|
|
80
|
+
Mandatory signature verification with flexible trust management mechanisms.
|
|
81
|
+
|
|
82
|
+
- **Ed25519 signatures** — All messages are mandatorily signature-verified
|
|
83
|
+
- **TOFU (Trust On First Use)** — Automatic trust on first verified connection
|
|
84
|
+
- **Trust store** — Configurable trust policies and blacklists
|
|
85
|
+
|
|
86
|
+
### 5. MCP Integration
|
|
41
87
|
|
|
42
|
-
|
|
43
|
-
- **去中心化优先** — 局域网 mDNS 零配置发现,Registry/Relay 可选
|
|
44
|
-
- **强制签名验证** — 所有消息 Ed25519 签名
|
|
45
|
-
- **模块化架构** — Gateway、Registry、Relay 独立部署
|
|
46
|
-
- **MCP 兼容** — 直接作为 MCP(Model Context Protocol)服务运行
|
|
47
|
-
- **开箱即用** — TypeScript 完整实现,含示例和测试
|
|
88
|
+
Native support for Model Context Protocol, can run directly as an MCP server.
|
|
48
89
|
|
|
49
|
-
|
|
90
|
+
- **MCP Server** — Expose ADP capabilities as MCP tools
|
|
91
|
+
- **Claude Desktop compatible** — Seamless integration with Claude Desktop
|
|
92
|
+
- **Tool discovery** — Automatically discover and invoke other ADP agents
|
|
93
|
+
|
|
94
|
+
## Technical Goals
|
|
95
|
+
|
|
96
|
+
- **Decentralization first** — Works within a LAN without any centralized services
|
|
97
|
+
- **Security first** — All messages mandatorily signature-verified to prevent MITM attacks
|
|
98
|
+
- **Interoperability** — Compatible with OpenClaw, Hermes Agent, and other major agent frameworks
|
|
99
|
+
- **Observability** — Complete logging and tracing mechanisms
|
|
100
|
+
- **Extensibility** — Modular design supporting custom capability handlers
|
|
101
|
+
|
|
102
|
+
## Architecture
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
┌───────────────────────────────────────────────────────────────────┐
|
|
106
|
+
│ Application Layer (Agent Frameworks) │
|
|
107
|
+
│ OpenClaw • Hermes Agent • MCP Host • Custom Applications │
|
|
108
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
109
|
+
│
|
|
110
|
+
┌────────────────────────────▼────────────────────────────────────┐
|
|
111
|
+
│ ADP Gateway │
|
|
112
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
113
|
+
│ │ Capability │ │ Task │ │ Contact │ │
|
|
114
|
+
│ │ Handlers │ │ Manager │ │ Manager │ │
|
|
115
|
+
│ └──────────────┘ └──────────────┘ └──────────────┘ │
|
|
116
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
117
|
+
│
|
|
118
|
+
┌────────────────────────────▼────────────────────────────────────┐
|
|
119
|
+
│ Message Layer (Envelope) │
|
|
120
|
+
│ Protocol • ID • From • To • Action • Params • Signature │
|
|
121
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
122
|
+
│
|
|
123
|
+
┌────────────────────────────▼────────────────────────────────────┐
|
|
124
|
+
│ Transport Layer │
|
|
125
|
+
│ ┌──────────────┐ ┌──────────────┐ │
|
|
126
|
+
│ │ WebSocket │ │ Webhook │ │
|
|
127
|
+
│ │ Direct/Relay │ │ Callbacks │ │
|
|
128
|
+
│ └──────────────┘ └──────────────┘ │
|
|
129
|
+
└────────────────────────────┬────────────────────────────────────┘
|
|
130
|
+
│
|
|
131
|
+
┌────────────────────────────▼────────────────────────────────────┐
|
|
132
|
+
│ Discovery Layer │
|
|
133
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
134
|
+
│ │ mDNS │ │ Registry │ │ Relay │ │
|
|
135
|
+
│ │ LAN Discovery│ │ Directory │ │ NAT Relay │ │
|
|
136
|
+
│ └──────────────┘ └──────────────┘ └──────────────┘ │
|
|
137
|
+
└───────────────────────────────────────────────────────────────────┘
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Quick Start
|
|
141
|
+
|
|
142
|
+
### Prerequisites
|
|
143
|
+
|
|
144
|
+
- **Node.js** : 18+
|
|
145
|
+
- **npm** : 9+
|
|
146
|
+
- **TypeScript** : 5.4+ (for development)
|
|
147
|
+
|
|
148
|
+
### Local Development
|
|
149
|
+
|
|
150
|
+
1. **Clone the repository**
|
|
50
151
|
|
|
51
152
|
```bash
|
|
52
153
|
git clone https://github.com/mengzhuowei/AgentDiscoveryProtocol.git
|
|
53
154
|
cd AgentDiscoveryProtocol
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
2. **Install dependencies**
|
|
158
|
+
|
|
159
|
+
```bash
|
|
54
160
|
npm install
|
|
55
|
-
npm start agent1 # 终端 1
|
|
56
|
-
npm start agent2 # 终端 2,自动发现 agent1
|
|
57
161
|
```
|
|
58
162
|
|
|
59
|
-
|
|
163
|
+
3. **Start Agent**
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Terminal 1: Start first agent
|
|
167
|
+
npm start
|
|
168
|
+
|
|
169
|
+
# Terminal 2: Start second agent (automatically discovers the first)
|
|
170
|
+
npm start
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
4. **Start Registry and Relay (optional)**
|
|
60
174
|
|
|
61
175
|
```bash
|
|
62
|
-
|
|
63
|
-
npm
|
|
176
|
+
# Terminal 3: Start Registry service
|
|
177
|
+
npm run registry
|
|
178
|
+
|
|
179
|
+
# Terminal 4: Start Relay service
|
|
180
|
+
npm run relay
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Docker Deployment
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Start the complete ADP ecosystem (Gateway + Registry + Relay)
|
|
187
|
+
docker-compose up -d
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
See [Docker Deployment Guide](docs/docker.md) for details.
|
|
191
|
+
|
|
192
|
+
## Installation
|
|
193
|
+
|
|
194
|
+
### Use as a Library
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npm install adp-agent
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Global Installation
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
npm install -g adp-agent
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
After installation, the `skill/` directory is automatically copied to your project root, containing complete integration documentation.
|
|
207
|
+
|
|
208
|
+
### Available Commands
|
|
209
|
+
|
|
210
|
+
After global installation, you can use the following commands:
|
|
211
|
+
|
|
212
|
+
| Command | Description |
|
|
213
|
+
|---------|-------------|
|
|
214
|
+
| `adp-agent` | Start MCP Server |
|
|
215
|
+
| `adp-registry` | Start Registry service |
|
|
216
|
+
| `adp-relay` | Start Relay service |
|
|
217
|
+
|
|
218
|
+
#### adp-agent Command Options
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
adp-agent [tag] [options]
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
| Argument | Description | Default |
|
|
225
|
+
|----------|-------------|---------|
|
|
226
|
+
| `[tag]` | Agent identifier name | `agent1` |
|
|
227
|
+
| `--relay=<url>` | Set Relay server address | - |
|
|
228
|
+
| `--registry=<url>` | Set Registry server address | - |
|
|
229
|
+
| `--name=<name>` | Set Agent name | - |
|
|
230
|
+
| `--direct` | Disable mDNS discovery, force direct connection mode | - |
|
|
231
|
+
|
|
232
|
+
| Environment Variable | Description | Default |
|
|
233
|
+
|-----------------------|-------------|---------|
|
|
234
|
+
| `ADP_RELAY` | Relay server address | - |
|
|
235
|
+
| `ADP_REGISTRY` | Registry server address | - |
|
|
236
|
+
| `ADP_REGISTRY_TOKEN` | Registry access token | - |
|
|
237
|
+
| `ADP_NAMESPACE` | Agent namespace | `local` |
|
|
238
|
+
| `ADP_NAME` | Agent name | - |
|
|
239
|
+
|
|
240
|
+
Config file: `.adp/config.json` (project directory or user home directory)
|
|
241
|
+
|
|
242
|
+
#### adp-registry Command Options
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
adp-registry
|
|
64
246
|
```
|
|
65
247
|
|
|
66
|
-
|
|
248
|
+
No command-line arguments required. All configuration is through environment variables or config file.
|
|
249
|
+
|
|
250
|
+
| Environment Variable | Description | Default |
|
|
251
|
+
|-----------------------|-------------|---------|
|
|
252
|
+
| `ADP_CONFIG` | Config file path | `config.json` |
|
|
253
|
+
| `REGISTRY_PORT` | Service port | `3000` |
|
|
254
|
+
| `REGISTRY_HOST` | Service address | `0.0.0.0` |
|
|
255
|
+
| `MYSQL_HOST` | MySQL database address | `127.0.0.1` |
|
|
256
|
+
| `MYSQL_PORT` | MySQL database port | `3306` |
|
|
257
|
+
| `MYSQL_USER` | MySQL username | `root` |
|
|
258
|
+
| `MYSQL_PASSWORD` | MySQL password | - |
|
|
259
|
+
| `MYSQL_DATABASE` | MySQL database name | `adp_registry` |
|
|
260
|
+
| `REDIS_HOST` | Redis address | `127.0.0.1` |
|
|
261
|
+
| `REDIS_PORT` | Redis port | `6379` |
|
|
262
|
+
| `REDIS_PASSWORD` | Redis password | - |
|
|
263
|
+
| `TOKEN_ENABLED` | Enable token authentication | `false` |
|
|
264
|
+
| `CORS_ENABLED` | Enable CORS | `false` |
|
|
265
|
+
| `CORS_ORIGINS` | CORS allowed origins (comma-separated) | `*` |
|
|
266
|
+
|
|
267
|
+
#### adp-relay Command Options
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
adp-relay
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
No command-line arguments required. All configuration is through environment variables.
|
|
274
|
+
|
|
275
|
+
| Environment Variable | Description | Default |
|
|
276
|
+
|-----------------------|-------------|---------|
|
|
277
|
+
| `ADP_RELAY_PORT` | Service port | `9700` |
|
|
278
|
+
| `ADP_RELAY_HOST` | Service address | `0.0.0.0` |
|
|
279
|
+
| `ADP_RELAY_MAX_CONNECTIONS` | Max connections | `10000` |
|
|
280
|
+
| `ADP_RELAY_HEARTBEAT_INTERVAL_MS` | Heartbeat interval (ms) | `15000` |
|
|
281
|
+
| `ADP_RELAY_HEARTBEAT_TIMEOUT_MS` | Heartbeat timeout (ms) | `45000` |
|
|
282
|
+
| `ADP_RELAY_OFFLINE_MAX_AGE_MS` | Max offline message retention (ms) | `86400000` |
|
|
283
|
+
| `ADP_RELAY_OFFLINE_MAX_PER_AGENT` | Max offline messages per agent | `500` |
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Start MCP Server
|
|
287
|
+
adp-agent
|
|
288
|
+
|
|
289
|
+
# Start Registry service
|
|
290
|
+
adp-registry
|
|
291
|
+
|
|
292
|
+
# Start Relay service
|
|
293
|
+
adp-relay
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Usage Examples
|
|
297
|
+
|
|
298
|
+
### Basic Gateway
|
|
67
299
|
|
|
68
300
|
```typescript
|
|
69
301
|
import { Gateway, loadOrCreateIdentity } from 'adp-agent';
|
|
70
302
|
|
|
71
|
-
const { identity } = loadOrCreateIdentity('
|
|
303
|
+
const { identity } = loadOrCreateIdentity('myapp', 'my-agent', 'My Agent');
|
|
304
|
+
|
|
72
305
|
const gateway = new Gateway({
|
|
73
306
|
port: 9900,
|
|
74
307
|
host: '0.0.0.0',
|
|
@@ -77,65 +310,257 @@ const gateway = new Gateway({
|
|
|
77
310
|
displayName: 'My Agent',
|
|
78
311
|
capabilities: ['adp:ping', 'adp:capability.query'],
|
|
79
312
|
});
|
|
313
|
+
|
|
314
|
+
console.log(`Agent running at ws://localhost:9900/adp`);
|
|
315
|
+
console.log(`Agent ID: ${identity.agentId}`);
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Custom Capability Handler
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
import { Gateway, loadOrCreateIdentity, signEnvelope, generateMessageId, canonicalize } from 'adp-agent';
|
|
322
|
+
|
|
323
|
+
const { identity } = loadOrCreateIdentity('myapp', 'video-agent', 'VideoAgent');
|
|
324
|
+
|
|
325
|
+
const gateway = new Gateway({
|
|
326
|
+
port: 9900,
|
|
327
|
+
secretKey: identity.secretKey,
|
|
328
|
+
agentId: identity.agentId,
|
|
329
|
+
displayName: 'Video Generator',
|
|
330
|
+
capabilities: [
|
|
331
|
+
'adp:ping',
|
|
332
|
+
'adp:capability.query',
|
|
333
|
+
{
|
|
334
|
+
capability: 'custom:video.generate',
|
|
335
|
+
description: 'Generate video from prompt',
|
|
336
|
+
input_schema: {
|
|
337
|
+
type: 'object',
|
|
338
|
+
properties: {
|
|
339
|
+
prompt: { type: 'string' },
|
|
340
|
+
duration: { type: 'integer', default: 5 },
|
|
341
|
+
},
|
|
342
|
+
required: ['prompt'],
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
customHandlers: {
|
|
347
|
+
'custom:video.generate': async (ws, envelope) => {
|
|
348
|
+
const params = envelope.params as { prompt?: string; duration?: number };
|
|
349
|
+
|
|
350
|
+
console.log(`Generating video: ${params.prompt}`);
|
|
351
|
+
|
|
352
|
+
const reply = signEnvelope({
|
|
353
|
+
protocol: 'adp/0.2',
|
|
354
|
+
id: generateMessageId(),
|
|
355
|
+
from: identity.agentId,
|
|
356
|
+
to: envelope.from,
|
|
357
|
+
action: 'custom:video.generate',
|
|
358
|
+
params: {
|
|
359
|
+
video_url: 'https://cdn.example.com/video.mp4',
|
|
360
|
+
},
|
|
361
|
+
reply_to: envelope.id,
|
|
362
|
+
timestamp: new Date().toISOString(),
|
|
363
|
+
}, identity.secretKey, canonicalize);
|
|
364
|
+
|
|
365
|
+
ws.send(JSON.stringify(reply));
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
});
|
|
80
369
|
```
|
|
81
370
|
|
|
82
|
-
|
|
371
|
+
### Agent Discovery
|
|
83
372
|
|
|
84
|
-
|
|
373
|
+
```typescript
|
|
374
|
+
import { Discovery, loadOrCreateIdentity } from 'adp-agent';
|
|
375
|
+
|
|
376
|
+
const { identity } = loadOrCreateIdentity('myapp', 'discovery-demo', 'DiscoveryDemo');
|
|
85
377
|
|
|
378
|
+
const discovery = new Discovery(identity.agentId, 9900, {
|
|
379
|
+
onPeerDiscovered: (peer) => {
|
|
380
|
+
console.log(`Found agent: ${peer.agentId}`);
|
|
381
|
+
console.log(`Address: ${peer.host}:${peer.port}`);
|
|
382
|
+
console.log(`Capabilities:`, peer.manifest?.capabilities);
|
|
383
|
+
},
|
|
384
|
+
onPeerLost: (agentId) => {
|
|
385
|
+
console.log(`Agent lost: ${agentId}`);
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
discovery.start();
|
|
86
390
|
```
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
391
|
+
|
|
392
|
+
### Registry Client
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
import { RegistryClient, loadOrCreateIdentity } from 'adp-agent';
|
|
396
|
+
|
|
397
|
+
const { identity } = loadOrCreateIdentity('myapp', 'registry-client', 'RegistryClient');
|
|
398
|
+
|
|
399
|
+
const registry = new RegistryClient({
|
|
400
|
+
registryUrl: 'http://localhost:9800',
|
|
401
|
+
agentId: identity.agentId,
|
|
402
|
+
secretKey: identity.secretKey,
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// Register yourself
|
|
406
|
+
await registry.register({
|
|
407
|
+
displayName: 'My Agent',
|
|
408
|
+
capabilities: ['adp:ping', 'custom:my-action'],
|
|
409
|
+
routes: [{ type: 'direct', address: 'localhost:9900' }],
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// Query other agents
|
|
413
|
+
const agents = await registry.query({ capability: 'custom:video.generate' });
|
|
414
|
+
console.log('Found agents:', agents);
|
|
415
|
+
|
|
416
|
+
// Get Agent Manifest
|
|
417
|
+
const manifest = await registry.resolve(agents[0].agentId);
|
|
418
|
+
console.log('Manifest:', manifest);
|
|
106
419
|
```
|
|
107
420
|
|
|
108
|
-
|
|
421
|
+
### Relay Client
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
import { RelayClient, loadOrCreateIdentity, generateMessageId } from 'adp-agent';
|
|
425
|
+
|
|
426
|
+
const { identity } = loadOrCreateIdentity('myapp', 'relay-client', 'RelayClient');
|
|
427
|
+
|
|
428
|
+
const relay = new RelayClient({
|
|
429
|
+
relayUrl: 'ws://localhost:9700/adp/relay',
|
|
430
|
+
agentId: identity.agentId,
|
|
431
|
+
secretKey: identity.secretKey,
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// Connect to Relay
|
|
435
|
+
await relay.connect();
|
|
436
|
+
|
|
437
|
+
// Send message through Relay
|
|
438
|
+
await relay.sendMessage(targetAgentId, {
|
|
439
|
+
protocol: 'adp/0.2',
|
|
440
|
+
id: generateMessageId(),
|
|
441
|
+
from: identity.agentId,
|
|
442
|
+
to: targetAgentId,
|
|
443
|
+
action: 'adp:ping',
|
|
444
|
+
params: {},
|
|
445
|
+
timestamp: new Date().toISOString(),
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// Listen for messages from Relay
|
|
449
|
+
relay.on('message', (envelope) => {
|
|
450
|
+
console.log('Received message:', envelope);
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
relay.disconnect();
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### MCP Server Mode
|
|
457
|
+
|
|
458
|
+
```typescript
|
|
459
|
+
import { AdpMcpServer } from 'adp-agent';
|
|
460
|
+
|
|
461
|
+
const server = new AdpMcpServer({
|
|
462
|
+
tag: 'my-agent',
|
|
463
|
+
namespace: 'myapp',
|
|
464
|
+
agentName: 'adp-mcp',
|
|
465
|
+
displayName: 'ADP MCP Agent',
|
|
466
|
+
portBase: 9900,
|
|
467
|
+
capabilities: [
|
|
468
|
+
'adp:ping',
|
|
469
|
+
'adp:capability.query',
|
|
470
|
+
{
|
|
471
|
+
capability: 'custom:my-action',
|
|
472
|
+
description: 'My custom action',
|
|
473
|
+
input_schema: {
|
|
474
|
+
type: 'object',
|
|
475
|
+
properties: { query: { type: 'string' } },
|
|
476
|
+
required: ['query'],
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
await server.start();
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Or use the globally installed command:
|
|
109
486
|
|
|
110
487
|
```bash
|
|
111
|
-
|
|
112
|
-
npm run test:integration # 集成测试
|
|
113
|
-
npm run relay # 启动 Relay
|
|
114
|
-
npm run registry # 启动 Registry
|
|
115
|
-
npm run build # 编译到 dist/
|
|
488
|
+
adp-agent
|
|
116
489
|
```
|
|
117
490
|
|
|
118
|
-
|
|
491
|
+
More examples are available in the [examples/](examples/) directory.
|
|
119
492
|
|
|
120
|
-
|
|
121
|
-
|------|------|
|
|
122
|
-
| [Docker 部署指南](docs/docker.md) | 使用 Docker 部署 |
|
|
123
|
-
| [身份与 Manifest](docs/01-identity.md) | Agent ID、能力声明 |
|
|
124
|
-
| [消息格式](docs/02-message.md) | Envelope、签名、错误码 |
|
|
125
|
-
| [发现机制](docs/03-discovery.md) | mDNS、Registry |
|
|
126
|
-
| [传输层](docs/04-transport.md) | WebSocket、Relay |
|
|
127
|
-
| [安全与信任](docs/05-security.md) | TOFU、签名验证 |
|
|
128
|
-
| [实现检查清单](docs/implementation-checklist.md) | 协议合规性 |
|
|
493
|
+
## Development
|
|
129
494
|
|
|
130
|
-
|
|
495
|
+
```bash
|
|
496
|
+
npm test # Run tests
|
|
497
|
+
npm run test:integration # Integration tests
|
|
498
|
+
npm run test:coverage # Test coverage
|
|
499
|
+
npm run build # Build to dist/
|
|
500
|
+
npm run dev # Watch mode build
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### Start Services
|
|
504
|
+
|
|
505
|
+
#### Development Mode (run from source)
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
npm run relay # Start Relay service
|
|
509
|
+
npm run registry # Start Registry service
|
|
510
|
+
npm run adp # Start MCP Server
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
#### Production Mode (run after global installation)
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
adp-relay # Start Relay service
|
|
517
|
+
adp-registry # Start Registry service
|
|
518
|
+
adp-agent # Start MCP Server
|
|
519
|
+
```
|
|
131
520
|
|
|
132
|
-
|
|
133
|
-
- [x] **Registry** — 中心化目录服务
|
|
134
|
-
- [x] **MCP 集成** — 作为 MCP 服务运行
|
|
135
|
-
- [ ] **任务委派** — 跨 Agent 任务调度
|
|
136
|
-
- [ ] **端到端加密** — 可选 E2EE
|
|
137
|
-
- [ ] **更多语言实现** — Python、Rust
|
|
521
|
+
## Documentation
|
|
138
522
|
|
|
139
|
-
|
|
523
|
+
| Document | Description |
|
|
524
|
+
|----------|-------------|
|
|
525
|
+
| [Usage Guide](USAGE.md) | Complete usage and configuration options |
|
|
526
|
+
| [Docker Deployment](docs/docker.md) | Docker deployment guide |
|
|
527
|
+
| [Identity & Manifest](docs/01-identity.md) | Agent ID, capability declaration, key management |
|
|
528
|
+
| [Message Format](docs/02-message.md) | Envelope, signatures, error codes |
|
|
529
|
+
| [Discovery Mechanisms](docs/03-discovery.md) | mDNS, Registry, Relay |
|
|
530
|
+
| [Transport Layer](docs/04-transport.md) | WebSocket, Webhook, hybrid mode |
|
|
531
|
+
| [Security & Trust](docs/05-security.md) | TOFU, signature verification, trust store |
|
|
532
|
+
| [Implementation Checklist](docs/implementation-checklist.md) | Protocol compliance checklist |
|
|
533
|
+
| [Integration Guide](skill/SKILL.md) | OpenClaw, Hermes Agent integration guide |
|
|
534
|
+
|
|
535
|
+
## Roadmap
|
|
536
|
+
|
|
537
|
+
- [x] **v0.2** — Self-authenticating identity, signature verification, TOFU
|
|
538
|
+
- [x] **Registry** — Centralized directory service
|
|
539
|
+
- [x] **MCP Integration** — Run as MCP service
|
|
540
|
+
- [x] **Webhook Communication** — Async task callback support
|
|
541
|
+
- [x] **Key Rotation** — Secure key update mechanism
|
|
542
|
+
- [ ] **Task Delegation** — Cross-agent task scheduling
|
|
543
|
+
- [ ] **End-to-End Encryption** — Optional E2EE
|
|
544
|
+
- [ ] **Multi-language implementations** — Python, Rust, Go
|
|
545
|
+
|
|
546
|
+
## Contributing
|
|
547
|
+
|
|
548
|
+
We welcome contributions! Please follow these steps:
|
|
549
|
+
|
|
550
|
+
1. Fork this repository
|
|
551
|
+
2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
|
|
552
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
553
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
554
|
+
5. Open a Pull Request
|
|
555
|
+
|
|
556
|
+
See [Code Standards](docs/implementation-checklist.md) for details.
|
|
557
|
+
|
|
558
|
+
## License
|
|
140
559
|
|
|
141
560
|
MIT © [ADP Working Group](https://github.com/mengzhuowei/AgentDiscoveryProtocol)
|
|
561
|
+
|
|
562
|
+
## Support & Contact
|
|
563
|
+
|
|
564
|
+
- **Issues** : [GitHub Issues](https://github.com/mengzhuowei/AgentDiscoveryProtocol/issues)
|
|
565
|
+
- **Discussions** : [GitHub Discussions](https://github.com/mengzhuowei/AgentDiscoveryProtocol/discussions)
|
|
566
|
+
- **Email** : mengzhuowei@qq.com
|