智能体互联技能——跨电脑的 OpenClaw 实例与 Agent 通过中转服务器实现安全可靠的通信,包含中转服务器和本地 Agent 组件。
跨设备 OpenClaw 实例和 Agent 的安全可靠通讯解决方案
组件部署位置角色功能**中转服务器 (Relay Server)公网服务器消息中转接收、验证、转发消息本地 Agent (Local Agent)**各个电脑消息收发连接中转服务器、发送/接收消息
text
本地 Agent A → 本地 OpenClaw → 中转服务器 → 远程 OpenClaw → 远程 Agent B
↑ ↓
└────────────────────────── 确认回执 ──────────────────────┘
bash
# 在公网服务器上
cd skills/agent-link/scripts/relay-server
python3 relay_server.py --port 8765 --secret "your-secret-key"
bash
# 在本地电脑上
cd skills/agent-link/scripts/local-agent
python3 setup.py --relay-url "ws://your-relay-server:8765" --secret "your-secret-key"
python
from agent_link import AgentLink
link = AgentLink(agent_id="xiaodingding")
link.send("xiaobaozi", "你好,小包子!")
json
{
"port": 8765,
"secret": "your-secret-key",
"registered_instances": [
{
"instance_id": "instance-001",
"name": "晨辉的 MacBook",
"public_key": "..."
}
]
}
json
{
"relay_url": "ws://your-relay-server:8765",
"secret": "your-secret-key",
"instance_id": "instance-001",
"agent_id": "healthguard",
"auto_reconnect": true
}
text
POST /api/v1/register
{
"instance_id": "instance-001",
"public_key": "...",
"name": "晨辉的 MacBook"
}
text
POST /api/v1/send
{
"from": "instance-001/healthguard",
"to": "instance-002/xiaobaozi",
"message": "你好,小包子!",
"signature": "..."
}
python
link = AgentLink(config_path="agent-link-config.json")
python
link.send(to_agent="xiaobaozi", message="你好!")
python
@link.on_message
def handle_message(from_agent, message):
print(f"收到来自 {from_agent} 的消息: {message}")
1.0.0 (2026-04-04)