实时3D可视化仪表盘,将OpenClaw的AI Agent和Session展示为3D世界中的大陆和小黄人。
~/.openclaw/
├── agents/
│ ├── main/ # Agent名称
│ │ └── sessions/
│ │ ├── sessions.json # 所有会话的元信息
│ │ ├── {sessionId}.jsonl # 每个会话的实时消息日志
│ │ └── ...
│ ├── xiaohong/
│ │ └── sessions/
│ └── xiaolan/
│ └── sessions/
{
"agent:main:feishu:group:oc_e785f48d5df0065f1db1e99ef0d6c730": {
"sessionId": "7461d057-c1f7-4056-b1c0-9550d926e154",
"displayName": "OpenClaw开发群",
"updatedAt": 1774549219230
},
"agent:main:cron:6ae68f9e-9d3b-45cf-ba85-ed0b85e33419": {
"sessionId": "b32acddc-914f-48f5-ae71-8b12b919253b"
}
}agent:main:main→ 主会话agent:main:feishu:group:{groupId}→ 飞书群组会话agent:main:feishu:dm:{userId}→ 飞书私信会话agent:main:cron:{cronId}→ 定时任务会话agent:main:subagent:{subagentId}→ 子代理会话
{
"type": "message",
"id": "db1d98c4",
"parentId": "a6c6274e",
"timestamp": "2026-03-24T05:06:21.490Z",
"message": {
"role": "user|assistant|toolResult",
"content": [...]
}
}-
user - 用户消息
content: 字符串或数组- 飞书格式:
[message_id: om_xxx]\n发送者: 消息内容
-
assistant - AI回复
content: 数组,包含多种类型:{type: "thinking", thinking: "..."}- 思考过程{type: "toolCall", name: "工具名", arguments: {...}}- 工具调用{type: "text", text: "回复文本"}- 最终回复
-
toolResult - 工具返回结果
toolName: 工具名称content: 数组,包含{type: "text", text: "结果"}
openclawRoot: ~/.openclaw # OpenClaw根目录
server:
port: 7777
host: '0.0.0.0'
auth:
enabled: true # 是否启用token认证
display:
showCron: false # 是否显示定时任务
showSubagent: false # 是否显示子代理
recentMinutes: 10 # 显示最近多少分钟的消息- 扫描
~/.openclaw/agents/目录 - 读取每个agent的
sessions.json - 构建
agentState全局对象
- 使用
chokidar监听.jsonl文件变化 - 文件增长时读取新增行
- 解析消息并通过
processLine()广播事件
- 解析JSONL行
- 根据消息角色创建不同事件:
user_msg- 用户发送消息thinking- AI思考中tool_use- AI调用工具tool_result- 工具返回结果reply_text/reply_intermediate- AI回复
| 接口 | 方法 | 说明 |
|---|---|---|
/api/world |
GET | 获取世界状态(agents、sessions) |
/api/config |
GET | 获取配置 |
/api/events |
GET | SSE事件流 |
/api/messages/:sessionId |
GET | 获取会话原始消息(支持分页) |
/api/session-state/:sessionId |
GET | 获取预计算的会话状态 |
/api/users/position |
POST | 更新用户位置(HTTP) |
/api/minions/positions |
POST | 更新小黄人位置 |
/api/chat/send |
POST | 发送世界聊天 |
/api/auth/verify |
GET | 验证token |
-
SSE (Server-Sent Events) - 服务端推送
- 连接:
GET /api/events - 事件类型:
init,event,users,chat,control
- 连接:
-
WebSocket - 双向通信(位置同步)
- 客户端发送:
{type: "position", userId, x, y, z, yaw, pitch, name} - 服务端广播: 用户位置更新
- 客户端发送:
-
HTTP REST - 请求/响应
- 获取数据、发送消息等
Scene
├── Lights (环境光、太阳光、补光、边缘光)
├── Atmosphere (太阳、云朵、萤火虫、花瓣)
├── Continents[] (每个Agent一个大陆)
│ ├── Ground (地形)
│ ├── House (房子+装饰)
│ ├── Trees[] (树木)
│ ├── Flowers[] (花朵)
│ ├── Bushes[] (灌木)
│ ├── Pond (池塘)
│ ├── Furniture (桌椅、床)
│ ├── Fence (围栏)
│ ├── LampPost (路灯)
│ └── Bench (长椅)
├── Minions[] (每个Session一个小黄人)
│ ├── Body (身体)
│ ├── Head (头)
│ ├── Eyes (眼睛)
│ ├── Arms (手臂)
│ ├── Legs (腿)
│ └── Label (名称标签)
└── UserAvatars[] (其他在线用户)
| 函数 | 说明 |
|---|---|
initWorld(worldData) |
初始化世界,创建所有大陆和小黄人 |
createContinent(agentName, index) |
创建一个Agent的大陆 |
createMinion(profile) |
创建一个小黄人 |
animateMinions(dt, time) |
更新小黄人动画 |
applySessionState(minion, data) |
应用服务端预计算的状态 |
updateBubbleContent(m) |
更新气泡显示内容 |
connectSSE() |
连接SSE事件流 |
connectWS() |
连接WebSocket |
idle → thinking → done
↑ ↓
└────────┘
idle- 空闲,无对话thinking- 正在处理用户消息done- 已回复用户
每个小黄人有一个气泡,显示:
- 顶部: 用户消息 + 发送者名字
- 中间: 思考过程事件列表
- 底部: AI回复(如果有)
{
type: 'think|tool_use|tool_result',
text: '显示文本', // 截断后的文本
fullText: '完整文本', // 完整内容,点击预览用
args: '工具参数', // 仅tool_use
result: '结果', // 仅tool_result
ts: '时间戳'
}openclawRoot: ~/.openclaw
server:
port: 7777
auth:
enabled: true
display:
showCron: false
showSubagent: false
recentMinutes: 10# 代码位置
/root/.openclaw/workspace-xiaohong/openclaw-monitor
# 开发分支
git checkout -b feature/xxx
# ... 修改代码 ...
git add -A && git commit -m "xxx"
git push origin feature/xxxgit checkout main
git pull origin main
git merge feature/xxx --no-edit
git push origin main# 生产代码位置
/root/openclaw-monitor
# 拉取最新代码
cd /root/openclaw-monitor && git pull origin main
# 重启服务
systemctl --user restart openclaw-monitor
# 查看状态
systemctl --user status openclaw-monitorcd /tmp/esbuild-fix
cp /root/openclaw-monitor/public/monitor-app.js app.js
npx esbuild app.js --bundle --format=esm --outfile=/root/openclaw-monitor/public/bundle.js- 不要直接修改其他代理的代码
- 提交前先pull最新主分支
- 检查冲突再合并
- 每个代理在独立分支开发
- 合并后重启生产服务
A: 检查SSE连接是否正常,或通过 /api/session-state/:sessionId 获取最新状态
A: 检查 config.yaml 中 showCron 和 showSubagent 配置
A: 检查 config.yaml 中 auth.enabled 配置,token在 /tmp/openclaw/auth-token.txt
A: fuser -k 7777/tcp 或使用systemd管理