OpenClaw LAN Mesh
局域网 Agent 互联插件 —— 让多个 OpenClaw 实例在局域网内自主通信、委派任务。
特性
- Peer-to-Peer 通信:Agent 之间直接发送消息
- 任务委派与执行:将任务委派给远程 Agent,远程 Agent 自动在独立 session 中执行并返回结果
- Agent Profile:每个实例维护详细档案(能力、硬件、负载、历史)
- 配对认证:预共享 Token 对,只有配对的 Agent 才能互通
- 任务接受模式:auto/manual/off 灵活控制
- Skill 驱动:Agent 自主判断何时调用远程 Agent
架构
┌─────────────┐ HTTP/REST ┌─────────────┐
│ Agent A │ ◄───────────────► │ Agent B │
│ (MacBook) │ Port 18789 │ (Server) │
│ │ Bearer Token │ │
│ Profile │ │ Profile │
│ Registry │ │ Registry │
│ TaskMgr │ │ TaskMgr │
│ Executor │ │ Executor │
└─────────────┘ └─────────────┘
安装
> 要求:OpenClaw >= 2026.3.12
方式一:一键安装
git clone https://github.com/xiaodongzheng/openclaw-lan-mesh.git
cd openclaw-lan-mesh
./install.sh
安装脚本会自动:注册插件、生成 LAN Token、提示后续配置步骤。
方式二:OpenClaw CLI
# 从本地克隆安装(link 模式,修改源码后 restart 即生效)
git clone https://github.com/xiaodongzheng/openclaw-lan-mesh.git
openclaw plugins install --link openclaw-lan-mesh/plugin
openclaw daemon restart
方式三:手动安装
git clone https://github.com/xiaodongzheng/openclaw-lan-mesh.git
cd openclaw-lan-mesh/plugin
npm install
openclaw plugins install --link .
openclaw daemon restart
配置
1. 生成 LAN Token
每个实例需要一个入站认证 Token(安装脚本会自动生成):
# 生成随机 token
openssl rand -hex 32
# 写入 ~/.openclaw/.env
OPENCLAW_LAN_TOKEN=<本机入站token>
LAN_PEER_<PEER_ID>_TOKEN=<对方的入站token>
2. 配置 Profile 和 Peers
编辑 ~/.openclaw/openclaw.json:
{
"plugins": {
"entries": {
"openclaw-lan-mesh": {
"enabled": true,
"config": {
"profile": {
"name": "我的Agent",
"role": "开发助手",
"capabilities": ["coding", "research"],
"models": ["openai-codex/gpt-5.4"],
"tools": ["bash", "python", "git"],
"hardware": {
"cpu": "Apple M1 Max",
"memory": "32GB"
}
},
"peers": {
"server-219": {
"host": "192.168.1.219",
"port": 18789,
"tokenEnvVar": "LAN_PEER_SERVER219_TOKEN"
}
},
"acceptMode": "auto"
}
}
}
}
}
3. 验证
# 健康检查(无需认证)
curl http://localhost:18789/lan/health
# 查看 Profile(需认证)
LAN_TOKEN=$(grep OPENCLAW_LAN_TOKEN ~/.openclaw/.env | cut -d= -f2)
curl -H "Authorization: Bearer $LAN_TOKEN" http://localhost:18789/lan/profile
使用
斜杠命令
| 命令 | 说明 | |------|------| | /lan-status | 查看本机状态和已连接的 Peers | | /lan-send <peerId> <text> | 向 Peer 发送消息 | | /lan-accept <auto\|manual\|off> | 设置任务接受模式 |
远程任务委派
LAN_TOKEN=$(grep OPENCLAW_LAN_TOKEN ~/.openclaw/.env | cut -d= -f2)
curl -X POST http://localhost:18789/lan/task \
-H "Authorization: Bearer $LAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "task-001",
"protocolVersion": "1.0",
"type": "task",
"from": "my-agent",
"to": "target-agent",
"timestamp": 1234567890000,
"payload": {
"description": "帮我查一下今天的天气",
"mode": "fire-and-forget",
"timeout": 60000
}
}'
协议文档
- PROTOCOL.md — 完整通信协议规范
- PROFILE_SCHEMA.md — Agent Profile 字段定义
部署示例
开发
cd plugin
npm install
npm run dev # tsc --watch
# 修改代码后:
openclaw daemon restart
开发路线
- [x] Phase 1:基础通信 + Profile + 配对认证
- [x] Phase 2:任务委派 + 接受控制
- [x] Phase 3:任务执行引擎(subagent 独立 session + lan_task_reply Tool)
- [ ] Phase 4:mDNS 自动发现 + TLS + WebSocket
License
MIT





