A2A Agent 系统 - 通信与发现
发现机制
UDP 多播发现
MulticastDiscovery 基于 UDP 多播实现本地网络自动发现:- 发现请求:广播查找特定 Agent
- 宣告:向网络宣告自身存在
- 监听:持续监听其他 Agent 的宣告
通信机制
A2AServer - HTTP 端点
| 端点 | 方法 | 描述 |
|---|---|---|
/.well-known/agent.json | GET | 获取 Agent Card |
/tasks/send | POST | 发送任务 |
/tasks/{id} | GET | 查询任务状态 |
/tasks/{id}/cancel | POST | 取消任务 |
/tasks/{id}/subscribe | POST | 订阅任务通知 |
A2AClient - 客户端能力
- 发送消息给其他 Agent
- 查询远程任务状态
- 订阅任务完成通知
- 获取其他 Agent 的能力卡
任务管理 API
任务生命周期
pending → working → completed/failed/canceled
任务状态查询
{
"id": "task-123",
"status": "completed",
"artifacts": [...],
"history": [...]
}
进程管理
- 单机 Agent 启动器:
bin/a2agent.php - 集群启动器:
bin/a2agent-cluster.php