|
|
@@ -18,7 +18,11 @@ OpenCode 状态监控工具,支持实时监控多个 OpenCode 实例的状态
|
|
|
从 `dist/` 目录下载对应平台的可执行文件:
|
|
|
|
|
|
- `opencode-monitor-linux-amd64` - Linux x86_64
|
|
|
+- `opencode-monitor-linux-arm64` - Linux ARM64
|
|
|
+- `opencode-monitor-darwin-amd64` - macOS Intel
|
|
|
+- `opencode-monitor-darwin-arm64` - macOS Apple Silicon
|
|
|
- `opencode-monitor-windows-amd64.exe` - Windows x86_64
|
|
|
+- `opencode-monitor-windows-arm64.exe` - Windows ARM64
|
|
|
|
|
|
### 从源码编译
|
|
|
|
|
|
@@ -62,9 +66,12 @@ make build-all
|
|
|
# 查看 MQTT 配置
|
|
|
./opencode-monitor config list
|
|
|
|
|
|
-# 设置 MQTT 配置
|
|
|
+# 设置 MQTT 配置(无认证)
|
|
|
./opencode-monitor config set --broker tcp://127.0.0.1:1883 --topic opencode/status
|
|
|
|
|
|
+# 设置 MQTT 配置(带认证)
|
|
|
+./opencode-monitor config set --broker tcp://127.0.0.1:1883 --username user --password pass --topic opencode/status
|
|
|
+
|
|
|
# 删除配置
|
|
|
./opencode-monitor config delete 1
|
|
|
```
|
|
|
@@ -83,38 +90,43 @@ make build-all
|
|
|
### 请求示例
|
|
|
|
|
|
```bash
|
|
|
-# 创建 MQTT 配置
|
|
|
+# 创建 MQTT 配置(无认证)
|
|
|
curl -X POST http://localhost:8080/api/mqtt \
|
|
|
-H "Content-Type: application/json" \
|
|
|
-d '{"broker":"tcp://127.0.0.1:1883","topic":"opencode/status"}'
|
|
|
|
|
|
+# 创建 MQTT 配置(带认证)
|
|
|
+curl -X POST http://localhost:8080/api/mqtt \
|
|
|
+ -H "Content-Type: application/json" \
|
|
|
+ -d '{"broker":"tcp://127.0.0.1:1883","username":"user","password":"pass","topic":"opencode/status"}'
|
|
|
+
|
|
|
# 获取所有配置
|
|
|
curl http://localhost:8080/api/mqtt
|
|
|
```
|
|
|
|
|
|
## MQTT 消息格式
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "port": 4096,
|
|
|
- "type": "session.status",
|
|
|
- "status": "忙碌",
|
|
|
- "tool": "bash",
|
|
|
- "state": "运行中: ls -la",
|
|
|
- "title": "",
|
|
|
- "timestamp": "2026-06-03T10:30:00Z"
|
|
|
-}
|
|
|
+MQTT 消息为纯文本格式,与控制台日志一致:
|
|
|
+
|
|
|
+```
|
|
|
+[14:30:00] [:4096] 状态: 忙碌
|
|
|
+[14:30:05] [:4096] 思考中...
|
|
|
+[14:30:10] [:4096] 工具: bash - 运行中: ls -la
|
|
|
+[14:30:15] [:4096] 状态: 空闲
|
|
|
+[14:30:20] [:4096] 错误
|
|
|
```
|
|
|
|
|
|
-### 消息类型
|
|
|
+### 推送的状态类型
|
|
|
|
|
|
-| 类型 | 说明 |
|
|
|
+| 状态 | 说明 |
|
|
|
|------|------|
|
|
|
-| session.status | 会话状态变化 |
|
|
|
-| session.idle | 会话空闲 |
|
|
|
-| message.part.updated | 消息部分更新 |
|
|
|
-| permission.updated | 权限请求 |
|
|
|
-| session.error | 会话错误 |
|
|
|
+| 空闲 | 会话空闲 |
|
|
|
+| 忙碌 | 会话忙碌 |
|
|
|
+| 重试中 | 会话重试中 |
|
|
|
+| 思考中 | 模型推理中 |
|
|
|
+| 运行中 | 工具执行中 |
|
|
|
+| 完成 | 工具执行完成 |
|
|
|
+| 错误 | 会话错误 |
|
|
|
|
|
|
## 命令行参数
|
|
|
|
|
|
@@ -143,6 +155,21 @@ curl http://localhost:8080/api/mqtt
|
|
|
--db string 数据库路径 (默认 "./data/config.db")
|
|
|
```
|
|
|
|
|
|
+### config set 命令
|
|
|
+
|
|
|
+```bash
|
|
|
+./opencode-monitor config set [选项]
|
|
|
+
|
|
|
+选项:
|
|
|
+ --broker MQTT Broker 地址 (必填)
|
|
|
+ --client-id MQTT 客户端 ID (默认 "opencode-monitor")
|
|
|
+ --username MQTT 用户名
|
|
|
+ --password MQTT 密码
|
|
|
+ --topic MQTT 主题 (默认 "opencode/status")
|
|
|
+ --enabled 是否启用 (true/false, 默认 true)
|
|
|
+ --db 数据库路径 (默认 "./data/config.db")
|
|
|
+```
|
|
|
+
|
|
|
## 项目结构
|
|
|
|
|
|
```
|