@starlink-awaken/agentmesh 1.0.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/CHANGELOG.md +47 -0
- package/LICENSE +21 -0
- package/README.md +243 -0
- package/README.zh-CN.md +243 -0
- package/config/gateway.yaml +190 -0
- package/docs/api.md +566 -0
- package/package.json +74 -0
- package/src/adapters/base.ts +34 -0
- package/src/adapters/claude-code.ts +122 -0
- package/src/adapters/openclaw.ts +120 -0
- package/src/adapters/process.ts +136 -0
- package/src/cli.ts +284 -0
- package/src/core/agent-registry.ts +334 -0
- package/src/core/config.ts +148 -0
- package/src/core/context-manager.ts +210 -0
- package/src/core/event-bus.ts +76 -0
- package/src/core/metrics.ts +216 -0
- package/src/core/router.ts +105 -0
- package/src/core/task-manager.ts +248 -0
- package/src/core/vector-store.ts +203 -0
- package/src/index.ts +84 -0
- package/src/routes/api.ts +158 -0
- package/src/routes/websocket.ts +91 -0
- package/src/types/index.ts +90 -0
package/docs/api.md
ADDED
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
# Agent Gateway API 文档
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
Agent Gateway 是一个多 Agent 调度网关,提供 REST API 用于任务提交、Agent 管理和共享空间操作。
|
|
6
|
+
|
|
7
|
+
**基础 URL**: `http://localhost:3000`
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 认证
|
|
12
|
+
|
|
13
|
+
当前版本无需认证。生产环境建议添加 API Key 或 JWT 认证。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 端点概览
|
|
18
|
+
|
|
19
|
+
| 方法 | 路径 | 描述 |
|
|
20
|
+
|------|------|------|
|
|
21
|
+
| GET | `/health` | 健康检查 |
|
|
22
|
+
| POST | `/tasks` | 提交任务 |
|
|
23
|
+
| GET | `/tasks` | 获取所有任务 |
|
|
24
|
+
| GET | `/tasks/:taskId` | 获取任务状态 |
|
|
25
|
+
| POST | `/spaces` | 创建共享空间 |
|
|
26
|
+
| GET | `/spaces/:spaceId` | 获取共享空间 |
|
|
27
|
+
| GET | `/agents` | 获取 Agent 列表 |
|
|
28
|
+
| POST | `/agents` | 注册 Agent |
|
|
29
|
+
| GET | `/events` | Server-Sent Events 流 |
|
|
30
|
+
| GET | `/ws-info` | WebSocket 信息 |
|
|
31
|
+
| POST | `/broadcast` | 广播事件 |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 端点详情
|
|
36
|
+
|
|
37
|
+
### 1. 健康检查
|
|
38
|
+
|
|
39
|
+
检查网关状态和所有 Agent 的在线情况。
|
|
40
|
+
|
|
41
|
+
**请求**
|
|
42
|
+
```http
|
|
43
|
+
GET /health
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**响应**
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"status": "ok",
|
|
50
|
+
"timestamp": 1708531200000,
|
|
51
|
+
"agents": [
|
|
52
|
+
{
|
|
53
|
+
"id": "claude-code",
|
|
54
|
+
"name": "Claude Code",
|
|
55
|
+
"status": "online"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### 2. 提交任务
|
|
64
|
+
|
|
65
|
+
向网关提交任务,自动路由到合适的 Agent 或指定的 Agent。
|
|
66
|
+
|
|
67
|
+
**请求**
|
|
68
|
+
```http
|
|
69
|
+
POST /tasks
|
|
70
|
+
Content-Type: application/json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**请求体**
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"source": "api",
|
|
77
|
+
"target": "gateway",
|
|
78
|
+
"correlation_id": "uuid-可选",
|
|
79
|
+
"payload": {
|
|
80
|
+
"task": "帮我写一个排序算法",
|
|
81
|
+
"options": {
|
|
82
|
+
"timeout": 300,
|
|
83
|
+
"stream": false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**完整请求体 (AgentMessage)**
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"id": "uuid-可选-会自动生成",
|
|
93
|
+
"type": "request",
|
|
94
|
+
"source": "api",
|
|
95
|
+
"target": "gateway",
|
|
96
|
+
"correlation_id": "uuid-可选",
|
|
97
|
+
"timestamp": 1708531200000,
|
|
98
|
+
"payload": {
|
|
99
|
+
"task": "任务描述",
|
|
100
|
+
"context": {
|
|
101
|
+
"shared_space_id": "空间ID-可选"
|
|
102
|
+
},
|
|
103
|
+
"files": ["文件路径-可选"],
|
|
104
|
+
"options": {
|
|
105
|
+
"stream": false,
|
|
106
|
+
"timeout": 300
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**响应** (202 Accepted)
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"task_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
116
|
+
"status": "pending",
|
|
117
|
+
"message": "Task submitted successfully"
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**错误响应** (500)
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"error": {
|
|
125
|
+
"code": "TASK_FAILED",
|
|
126
|
+
"message": "具体错误信息"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### 3. 获取所有任务
|
|
134
|
+
|
|
135
|
+
列出所有任务。
|
|
136
|
+
|
|
137
|
+
**请求**
|
|
138
|
+
```http
|
|
139
|
+
GET /tasks
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**响应**
|
|
143
|
+
```json
|
|
144
|
+
[
|
|
145
|
+
{
|
|
146
|
+
"id": "550e8400-e29b-41d4-a716-446655440000",
|
|
147
|
+
"status": "completed",
|
|
148
|
+
"assigned_agents": ["claude-code"],
|
|
149
|
+
"created_at": 1708531200000
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### 4. 获取任务状态
|
|
157
|
+
|
|
158
|
+
查询特定任务的详细状态和结果。
|
|
159
|
+
|
|
160
|
+
**请求**
|
|
161
|
+
```http
|
|
162
|
+
GET /tasks/:taskId
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**路径参数**
|
|
166
|
+
| 参数 | 类型 | 描述 |
|
|
167
|
+
|------|------|------|
|
|
168
|
+
| taskId | string | 任务 ID |
|
|
169
|
+
|
|
170
|
+
**响应**
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"id": "550e8400-e29b-41d4-a716-446655440000",
|
|
174
|
+
"status": "completed",
|
|
175
|
+
"assigned_agents": ["claude-code"],
|
|
176
|
+
"result": "任务执行结果",
|
|
177
|
+
"error": null,
|
|
178
|
+
"created_at": 1708531200000,
|
|
179
|
+
"updated_at": 1708531200100
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**错误响应** (404)
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"error": {
|
|
187
|
+
"code": "TASK_NOT_FOUND",
|
|
188
|
+
"message": "Task xxx not found"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### 5. 创建共享空间
|
|
196
|
+
|
|
197
|
+
创建一个用于多 Agent 协作的共享上下文空间。
|
|
198
|
+
|
|
199
|
+
**请求**
|
|
200
|
+
```http
|
|
201
|
+
POST /spaces
|
|
202
|
+
Content-Type: application/json
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**请求体**
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"metadata": {
|
|
209
|
+
"name": "项目A开发",
|
|
210
|
+
"description": "多人协作项目"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**响应** (201 Created)
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"space_id": "space-550e8400-e29b-41d4-a716-446655440000"
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### 6. 获取共享空间
|
|
225
|
+
|
|
226
|
+
获取共享空间的元数据。
|
|
227
|
+
|
|
228
|
+
**请求**
|
|
229
|
+
```http
|
|
230
|
+
GET /spaces/:spaceId
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**路径参数**
|
|
234
|
+
| 参数 | 类型 | 描述 |
|
|
235
|
+
|------|------|------|
|
|
236
|
+
| spaceId | string | 空间 ID |
|
|
237
|
+
|
|
238
|
+
**响应**
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"shared_space_id": "space-550e8400-e29b-41d4-a716-446655440000",
|
|
242
|
+
"message_count": 5,
|
|
243
|
+
"artifact_count": 3,
|
|
244
|
+
"metadata": {
|
|
245
|
+
"name": "项目A开发"
|
|
246
|
+
},
|
|
247
|
+
"created_at": 1708531200000,
|
|
248
|
+
"updated_at": 1708531200500
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**错误响应** (404)
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"error": {
|
|
256
|
+
"code": "SPACE_NOT_FOUND",
|
|
257
|
+
"message": "Shared space xxx not found"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### 7. 获取 Agent 列表
|
|
265
|
+
|
|
266
|
+
列出所有已注册的 Agent。
|
|
267
|
+
|
|
268
|
+
**请求**
|
|
269
|
+
```http
|
|
270
|
+
GET /agents
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**响应**
|
|
274
|
+
```json
|
|
275
|
+
[
|
|
276
|
+
{
|
|
277
|
+
"id": "claude-code",
|
|
278
|
+
"name": "Claude Code",
|
|
279
|
+
"type": "claude-code",
|
|
280
|
+
"capabilities": [
|
|
281
|
+
"code-generation",
|
|
282
|
+
"code-review",
|
|
283
|
+
"debugging",
|
|
284
|
+
"refactoring",
|
|
285
|
+
"documentation",
|
|
286
|
+
"file-operations"
|
|
287
|
+
],
|
|
288
|
+
"status": "online",
|
|
289
|
+
"lastSeen": 1708531200000
|
|
290
|
+
}
|
|
291
|
+
]
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
### 8. 注册 Agent
|
|
297
|
+
|
|
298
|
+
动态注册一个新的 Agent。
|
|
299
|
+
|
|
300
|
+
**请求**
|
|
301
|
+
```http
|
|
302
|
+
POST /agents
|
|
303
|
+
Content-Type: application/json
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**请求体**
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"id": "my-agent",
|
|
310
|
+
"name": "My Custom Agent",
|
|
311
|
+
"type": "http",
|
|
312
|
+
"capabilities": ["code-generation", "text-generation"],
|
|
313
|
+
"endpoint": "http://localhost:8080"
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**响应** (201 Created)
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"id": "my-agent",
|
|
321
|
+
"status": "registered"
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
### 9. Server-Sent Events (SSE)
|
|
328
|
+
|
|
329
|
+
订阅实时任务事件和 Agent 状态更新。
|
|
330
|
+
|
|
331
|
+
**请求**
|
|
332
|
+
```http
|
|
333
|
+
GET /events?taskId=xxx&spaceId=xxx
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**查询参数**
|
|
337
|
+
| 参数 | 类型 | 描述 |
|
|
338
|
+
|------|------|------|
|
|
339
|
+
| taskId | string | 可选 - 订阅特定任务的事件 |
|
|
340
|
+
| spaceId | string | 可选 - 订阅特定空间的事件 |
|
|
341
|
+
|
|
342
|
+
**响应**
|
|
343
|
+
```http
|
|
344
|
+
HTTP/1.1 200 OK
|
|
345
|
+
Content-Type: text/event-stream
|
|
346
|
+
Cache-Control: no-cache
|
|
347
|
+
Connection: keep-alive
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**事件格式**
|
|
351
|
+
```json
|
|
352
|
+
data: {"type": "connected", "client_id": "xxx"}
|
|
353
|
+
|
|
354
|
+
data: {"type": "task_status", "task": {...}}
|
|
355
|
+
|
|
356
|
+
data: {"type": "welcome", "agents": [...]}
|
|
357
|
+
|
|
358
|
+
data: {"type": "heartbeat", "timestamp": 1708531200000}
|
|
359
|
+
|
|
360
|
+
data: {"type": "task.submitted", "task_id": "xxx", "timestamp": 1708531200000}
|
|
361
|
+
|
|
362
|
+
data: {"type": "task.completed", "task_id": "xxx", "result": "xxx", "timestamp": 1708531200000}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
### 10. 广播事件
|
|
368
|
+
|
|
369
|
+
向所有连接的客户端广播事件。
|
|
370
|
+
|
|
371
|
+
**请求**
|
|
372
|
+
```http
|
|
373
|
+
POST /broadcast
|
|
374
|
+
Content-Type: application/json
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**请求体**
|
|
378
|
+
```json
|
|
379
|
+
{
|
|
380
|
+
"type": "custom_event",
|
|
381
|
+
"data": {
|
|
382
|
+
"message": "Hello all"
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**响应**
|
|
388
|
+
```json
|
|
389
|
+
{
|
|
390
|
+
"delivered": true,
|
|
391
|
+
"client_count": 5
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## 数据类型
|
|
398
|
+
|
|
399
|
+
### AgentMessage
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
interface AgentMessage {
|
|
403
|
+
// 基础字段
|
|
404
|
+
id: string;
|
|
405
|
+
type: 'request' | 'response' | 'event' | 'stream' | 'stream_end';
|
|
406
|
+
source: string;
|
|
407
|
+
target: string;
|
|
408
|
+
correlation_id: string;
|
|
409
|
+
timestamp: number;
|
|
410
|
+
|
|
411
|
+
// 请求内容
|
|
412
|
+
payload?: {
|
|
413
|
+
task?: string;
|
|
414
|
+
context?: {
|
|
415
|
+
shared_space_id: string;
|
|
416
|
+
history?: string[];
|
|
417
|
+
artifacts?: string[];
|
|
418
|
+
};
|
|
419
|
+
files?: string[];
|
|
420
|
+
options?: {
|
|
421
|
+
stream?: boolean;
|
|
422
|
+
timeout?: number;
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
// 事件驱动
|
|
427
|
+
event_type?: string;
|
|
428
|
+
event_data?: Record<string, unknown>;
|
|
429
|
+
|
|
430
|
+
// 响应
|
|
431
|
+
result?: unknown;
|
|
432
|
+
error?: {
|
|
433
|
+
code: string;
|
|
434
|
+
message: string;
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Task
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
interface Task {
|
|
443
|
+
id: string;
|
|
444
|
+
status: 'pending' | 'assigned' | 'running' | 'completed' | 'failed';
|
|
445
|
+
message: AgentMessage;
|
|
446
|
+
assignedAgents: string[];
|
|
447
|
+
result?: unknown;
|
|
448
|
+
error?: {
|
|
449
|
+
code: string;
|
|
450
|
+
message: string;
|
|
451
|
+
};
|
|
452
|
+
createdAt: number;
|
|
453
|
+
updatedAt: number;
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Agent
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
interface Agent {
|
|
461
|
+
id: string;
|
|
462
|
+
name: string;
|
|
463
|
+
type: string;
|
|
464
|
+
capabilities: string[];
|
|
465
|
+
status: 'online' | 'offline' | 'busy';
|
|
466
|
+
endpoint?: string;
|
|
467
|
+
lastSeen: number;
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## 错误码
|
|
474
|
+
|
|
475
|
+
| 错误码 | HTTP 状态码 | 描述 |
|
|
476
|
+
|--------|-------------|------|
|
|
477
|
+
| TASK_NOT_FOUND | 404 | 任务不存在 |
|
|
478
|
+
| TASK_FAILED | 500 | 任务执行失败 |
|
|
479
|
+
| SPACE_NOT_FOUND | 404 | 共享空间不存在 |
|
|
480
|
+
| AGENT_NOT_FOUND | 404 | Agent 不存在 |
|
|
481
|
+
| INVALID_REQUEST | 400 | 请求参数无效 |
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|
|
485
|
+
## 示例
|
|
486
|
+
|
|
487
|
+
### cURL
|
|
488
|
+
|
|
489
|
+
```bash
|
|
490
|
+
# 健康检查
|
|
491
|
+
curl http://localhost:3000/health
|
|
492
|
+
|
|
493
|
+
# 提交任务
|
|
494
|
+
curl -X POST http://localhost:3000/tasks \
|
|
495
|
+
-H "Content-Type: application/json" \
|
|
496
|
+
-d '{"payload": {"task": "帮我写一个排序算法"}}'
|
|
497
|
+
|
|
498
|
+
# 查询任务状态
|
|
499
|
+
curl http://localhost:3000/tasks/{task_id}
|
|
500
|
+
|
|
501
|
+
# 获取 Agent 列表
|
|
502
|
+
curl http://localhost:3000/agents
|
|
503
|
+
|
|
504
|
+
# 创建共享空间
|
|
505
|
+
curl -X POST http://localhost:3000/spaces \
|
|
506
|
+
-H "Content-Type: application/json" \
|
|
507
|
+
-d '{"metadata": {"name": "项目A"}}'
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### JavaScript
|
|
511
|
+
|
|
512
|
+
```javascript
|
|
513
|
+
const baseUrl = 'http://localhost:3000';
|
|
514
|
+
|
|
515
|
+
// 提交任务
|
|
516
|
+
async function submitTask(task) {
|
|
517
|
+
const response = await fetch(`${baseUrl}/tasks`, {
|
|
518
|
+
method: 'POST',
|
|
519
|
+
headers: { 'Content-Type': 'application/json' },
|
|
520
|
+
body: JSON.stringify({ payload: { task } })
|
|
521
|
+
});
|
|
522
|
+
return response.json();
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// 订阅任务事件
|
|
526
|
+
function subscribeTask(taskId) {
|
|
527
|
+
const eventSource = new EventSource(`${baseUrl}/events?taskId=${taskId}`);
|
|
528
|
+
eventSource.onmessage = (event) => {
|
|
529
|
+
const data = JSON.parse(event.data);
|
|
530
|
+
console.log('Event:', data);
|
|
531
|
+
};
|
|
532
|
+
return eventSource;
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## CLI 命令
|
|
539
|
+
|
|
540
|
+
安装 CLI 后可使用以下命令:
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
# 列出所有 Agent
|
|
544
|
+
agent-gateway agents
|
|
545
|
+
|
|
546
|
+
# 提交通用任务(自动路由)
|
|
547
|
+
agent-gateway task 帮我写一个排序算法
|
|
548
|
+
|
|
549
|
+
# 提交任务到指定 Agent
|
|
550
|
+
agent-gateway to claude-code 帮我review这段代码
|
|
551
|
+
|
|
552
|
+
# 创建共享空间
|
|
553
|
+
agent-gateway space create-space
|
|
554
|
+
|
|
555
|
+
# 列出所有任务
|
|
556
|
+
agent-gateway tasks
|
|
557
|
+
|
|
558
|
+
# 检查 Gateway 状态
|
|
559
|
+
agent-gateway health
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
## 许可
|
|
565
|
+
|
|
566
|
+
MIT License
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@starlink-awaken/agentmesh",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Unified Agent Gateway - Multi-Agent Scheduler and Router",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"private": false,
|
|
9
|
+
"bin": {
|
|
10
|
+
"agentmesh": "./bin/agentmesh"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"config",
|
|
15
|
+
"docs",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"CHANGELOG.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"start": "bun run src/index.ts",
|
|
22
|
+
"dev": "bun run src/index.ts",
|
|
23
|
+
"cli": "bun run src/cli.ts",
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"prepublishOnly": "bun run build"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"bun": ">=1.0.0",
|
|
30
|
+
"node": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/bun": "latest",
|
|
34
|
+
"@types/uuid": "^11.0.0",
|
|
35
|
+
"@types/ws": "^8.18.1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"typescript": "^5"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@fastify/cors": "^11.2.0",
|
|
42
|
+
"@fastify/websocket": "^11.2.0",
|
|
43
|
+
"chromadb": "^3.3.1",
|
|
44
|
+
"execa": "^9.6.1",
|
|
45
|
+
"fastify": "^5.7.4",
|
|
46
|
+
"pino": "^10.3.1",
|
|
47
|
+
"uuid": "^13.0.0",
|
|
48
|
+
"ws": "^8.19.0",
|
|
49
|
+
"yaml": "^2.8.2"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"agent",
|
|
53
|
+
"gateway",
|
|
54
|
+
"multi-agent",
|
|
55
|
+
"scheduler",
|
|
56
|
+
"router",
|
|
57
|
+
"orchestrator",
|
|
58
|
+
"claude",
|
|
59
|
+
"openclaw",
|
|
60
|
+
"ai",
|
|
61
|
+
"llm",
|
|
62
|
+
"automation"
|
|
63
|
+
],
|
|
64
|
+
"author": "Starlink Awaken Team <team@starlink-awaken.dev>",
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "https://github.com/starlink-awaken/agentmesh.git"
|
|
69
|
+
},
|
|
70
|
+
"bugs": {
|
|
71
|
+
"url": "https://github.com/starlink-awaken/agentmesh/issues"
|
|
72
|
+
},
|
|
73
|
+
"homepage": "https://github.com/starlink-awaken/agentmesh#readme"
|
|
74
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentMessage } from '../types/index.js';
|
|
2
|
+
|
|
3
|
+
export interface AgentAdapter {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
capabilities: string[];
|
|
8
|
+
|
|
9
|
+
invoke(request: AgentMessage): Promise<AgentMessage>;
|
|
10
|
+
invokeStream?(request: AgentMessage): AsyncGenerator<AgentMessage, void, unknown>;
|
|
11
|
+
health(): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Agent 适配器基类
|
|
16
|
+
*/
|
|
17
|
+
export abstract class BaseAgentAdapter implements AgentAdapter {
|
|
18
|
+
abstract id: string;
|
|
19
|
+
abstract name: string;
|
|
20
|
+
abstract type: string;
|
|
21
|
+
abstract capabilities: string[];
|
|
22
|
+
|
|
23
|
+
abstract invoke(request: AgentMessage): Promise<AgentMessage>;
|
|
24
|
+
|
|
25
|
+
async *invokeStream?(
|
|
26
|
+
request: AgentMessage
|
|
27
|
+
): AsyncGenerator<AgentMessage, void, unknown> {
|
|
28
|
+
// 默认实现:调用 invoke 并转换为流
|
|
29
|
+
const response = await this.invoke(request);
|
|
30
|
+
yield response;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
abstract health(): Promise<boolean>;
|
|
34
|
+
}
|