docs: 更新 AGENTS/README 平台架构说明与月度总结,运行日志视图支持已取消状态

This commit is contained in:
2026-10-31 17:55:25 +08:00
parent 62de24eb4d
commit 85051f979b
201 changed files with 11049 additions and 7398 deletions
+54 -39
View File
@@ -3,10 +3,11 @@
> 本文档定义 37duAutomation 各交付物的**发版流程**与执行机**自动更新机制**。
> 发版统一走 agent CLI(中心机控制面),执行机端插件按账号权限自下载、壳子由用户点击升级。
> 打包产物位置、打包脚本见 [插件开发规范.md](./插件开发规范.md) 第 4 节。
> 最后更新:2026-10-31(壳子/中心机部分已按现役 electron-shell + controlplane-next 校准)。
## 1. 总览
版本源(插件包 + 壳子安装包 + 文件登记)全部在**中心机控制面**(内网 `http://172.30.30.243:8800`)。
版本源(插件包 + 壳子安装包 + 环境包 + 文件登记)全部在**中心机控制面**(内网 `http://172.30.30.243:8800`)。
> ⚠️ **发版必须指向内网库**(2026-10-15 踩坑):控制面有两套——
> 内网生产库 `http://172.30.30.243:8800`(执行机实际连接源,端口分工:8800 控制面 / 8802 文件服务器下载 /
@@ -17,16 +18,17 @@
| 交付物 | 更新机制 | 入口 |
|--------|----------|------|
| 插件 | 执行机登录后按账号权限自动同步(`plugin_sync.py`) | agent CLI `publish` / `grant` / `revoke` |
| 壳子(安装包) | 执行机自动下载 + 用户点击升级重启(`shell_updater.py`) | agent CLI `file push --category shell` |
| 中心机控制面 | 源码部署,不打包 | 宝塔上传 + 重启 / 前端构建发布 |
| 插件 | 执行机登录后按账号权限自动同步(`electron/plugin-sync.js`) | agent CLI `publish` / `grant` / `revoke` |
| 壳子(安装包) | 执行机自动下载 + 用户点击升级重启(`electron/shell-updater.js`,NSIS 静默) | agent CLI `file push --category shell` |
| 环境包(便携 Python) | 客户端自动检查下载并切换版本,保留上一版回滚(`electron/env-sync.js`) | agent CLI `file push --category python-env` |
| 中心机控制面 | 源码部署,不打包 | systemd 重启(见 [服务端部署 SOP](../部署/服务端前后端部署SOP.md)) |
## 2. 发版工具与鉴权
统一在 `desktop/` 目录下执行 agent CLI:
统一用仓库根 `tools/agent_cli.py`(任意 cwd 均可,已迁出废弃的 `desktop/controlplane`):
```powershell
d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent_cli
d:\work\code\37duAutomation\.venv\Scripts\python.exe tools\agent_cli.py
```
鉴权两种方式:
@@ -34,14 +36,17 @@ d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent
1. **密码登录(推荐,任意机器可用)**:
`--admin <管理员> --password <密码>`(或环境变量 `AGENT_ADMIN_PASSWORD` / `AGENT_ADMIN_ACCOUNT`),
并**一律显式加** `--base http://172.30.30.243:8800`(内网生产库,勿用公网旧库,见第 1 节警告)
2. **本机密钥自签(仅中心机本机)**:复用 `controlplane/.env` 与 `.admin_secret`
2. **本机密钥自签(仅中心机本机)**:读新中心机 `controlplane-next/server/.env` 的
`CONTROLPLANE_ADMIN_SECRET`,或 `%USERPROFILE%\.cool-admin\37du-center\.admin_secret`
配置只认新服务端:`desktop/controlplane-next/server/.env`(控制面 token)+ `desktop/fileserver/.env`(文件服务器地址/token)。
实际账号:管理员 `puddy`,密码 `123456`,中心机控制面 `http://172.30.30.243:8800`。
本开发机直接示例:
```powershell
d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
d:\work\code\37duAutomation\.venv\Scripts\python.exe tools\agent_cli.py `
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
publish <插件.zip> --id <id> --version <v>
```
@@ -50,10 +55,10 @@ d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent
1. **打包**:在插件目录(`plugins/XQ0001-0100/XQ00xx <中文名>/`)下执行 `_pack.py`,产物输出到仓库根 `dist-plugin/<id>_v<版本>.zip`
(zip 根必须含 `plugin.json`;带 UI 插件需先 `npm run build` 出 `ui/index.html`)。
2. **发布**:在 `desktop/` 下执行:
2. **发布**:任意 cwd 执行:
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
.venv\Scripts\python.exe tools\agent_cli.py `
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
publish dist-plugin\<id>_v<版本>.zip --id <id> --version <版本>
```
@@ -62,60 +67,70 @@ d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent
3. **授权 / 收回**(按账号管控可执行性):
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli --base http://172.30.30.243:8800 grant <账号> <id>
.venv\Scripts\python.exe -m controlplane.tools.agent_cli --base http://172.30.30.243:8800 revoke <账号> <id>
.venv\Scripts\python.exe tools\agent_cli.py --base http://172.30.30.243:8800 grant <账号> <id>
.venv\Scripts\python.exe tools\agent_cli.py --base http://172.30.30.243:8800 revoke <账号> <id>
```
4. **执行机端**:登录后按账号权限自动同步——`plugin_sync.py` 拉版本清单 → 下载 → sha256 校验 →
解压到 `plugins/<id>/` 原子替换 → 重载注册表;下次执行即用新版本。
4. **执行机端**:登录后按账号权限自动同步——`plugin-sync.js` 拉版本清单 → 下载票据 → 下载 → sha256 校验 →
解压到 `plugins/<id>/`(打包态为 `%LOCALAPPDATA%\37duAutomation\plugins`)原子替换 → 旧版备份到 `plugin_rollback/`;下次执行即用新版本。
被 revoke/下架/禁用的插件按管控清单停用或移除。
## 4. 壳子发版流程
## 4. 壳子 / 环境包发版流程
> 壳子 / 中心机 / 文件服务器的完整发版步骤见 [桌面端发版SOP](../桌面端/桌面端发版SOP.md),本节为摘要。
> 完整步骤(版本号、构建、打包、验证、升级链路)见 [桌面端发版SOP](../桌面端/桌面端发版SOP.md),本节为摘要。
按实际流程执行:
1. 改 `desktop/webhost/tools/shell.version` 与 `install.iss` 的 `MyAppVersion` 为新版本
2. `desktop/webhost/frontend` 下执行 `npm run build`
3. PyInstaller 打 `desktop/webhost/tools/37du-host.spec`、`37du-host-runner.spec`
(`37du-host-console.spec` 是调试版,不入安装包,可跳过)
4. `ISCC.exe desktop/webhost/tools/install.iss` 出安装包
5. 上传登记:
1. 改 `desktop/electron-shell/package.json` 的 `version`(唯一真源;打包时 `scripts/after-pack.js` 写入 exe 同级 `shell.version`)
2. 前端有改动时执行 `npm run copy-renderer`(`frontend/` → `renderer/dist`)
3. `npm run pack` → `dist-app/setup-37du-shell-<version>.exe`(electron-builder NSIS)
4. 上传 + 登记:
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
# 壳子
.venv\Scripts\python.exe tools\agent_cli.py `
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
file push <安装包> --category shell --version <新版本> [--notes "说明"]
# 环境包(有变更时)
.venv\Scripts\python.exe tools\agent_cli.py `
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
file push <python-env-<ver>.zip> --category python-env --version <ver> [--notes "说明"]
```
> 安装包上传到内网文件服务器(`FILESERVER_BASE_URL=172.30.30.243:8802`),并登记到**内网中心机**
> `file_sources(shell)`,执行机 `shell_updater` 从该直链下载。**不要用旧的 `shell-release` 子命令**。
> 安装包/环境包上传到内网文件服务器(`FILESERVER_BASE_URL=http://172.30.30.243:8802`),并登记到**内网中心机**
> `file_sources(category)`,执行机从该直链下载。**不要用旧的 `shell-release` 子命令**。
> 登记(`--base`)必须指内网库 `http://172.30.30.243:8800`,发到公网旧库执行机检测不到(见第 1 节警告)。
6. **执行机端**:自动下载安装包,前端提示后用户点击升级重启。
5. **执行机端**:自动下载安装包(sha256 校验)→ 前端提示 → 用户点击升级重启;环境包自动下载切换,无需用户操作。
## 5. 中心机发版流程
控制面为源码部署(宝塔 gunicorn 8800,不打包 exe):
控制面为源码部署(Node/Midway,systemd `37du-controlplane-next.service`,不打包 exe):
- 改后端代码:按 `docs/部署/控制面前后端部署SOP.md`「后端部署流程」上传文件 + 重启项目
- 改前端代码:按同一文档「前端部署流程」构建并发布到静态站 8090
- 改后端代码:`server` 下 `npm run build` → 上传 `/opt/37du/controlplane-next/server` → `systemctl restart 37du-controlplane-next.service`
- 改前端代码:`frontend` 下 `pnpm build` → 上传 `dist/` 到 `/opt/37du/controlplane-web` → 按需 `nginx -s reload`
- 数据库变更:手工执行 `migrations/*.sql` 后重启后端
- 详细步骤与排错见 [服务端部署 SOP](../部署/服务端前后端部署SOP.md)
## 6. 发布后检查
- 插件发布后:执行机下次启动自动检测下载;插件登录后按权限自动下载更新。
- 壳子发布后:执行机自动下载,前端提示后点击升级。
- 版本冲突 / 更新失败:查执行机 `plugin_sync.py` 与 `shell_updater.py` 日志;核对中心机版本清单与授权。
- 插件发布后:执行机下次启动/同步自动检测下载;插件按账号权限自动更新。
- 壳子发布后:执行机自动下载,前端提示后点击升级;升级后 `.env`、插件目录、环境包不被覆盖。
- 版本冲突 / 更新失败:查执行机 `logs/shell.log` 与 `plugin-sync.js` / `shell-updater.js` / `env-sync.js` 日志;核对中心机版本清单与授权。
## 7. Agent 技能(skills)
## 7. Agent 技能(skills,`.trae/skills/`,本地不入库)
发版/上传/账号管理已封装为 Trae agent 技能,agent 按需加载执行:
| 技能 | 用途 |
|------|------|
| `.trae/skills/37du-Agent-CLI/SKILL.md` | CLI 用法与鉴权总纲(先读) |
| `.trae/skills/37du-Plugin-Release/SKILL.md` | 插件发版 / 授权 / 状态管理 |
| `.trae/skills/37du-File-Release/SKILL.md` | 壳子/大文件上传发版(file push) |
| `.trae/skills/37du-Account-Permission/SKILL.md` | 账号与权限管理 |
| `37du-Agent-CLI` | CLI 用法与鉴权总纲(先读) |
| `37du-Plugin-Release` | 插件发版 / 授权 / 状态管理 |
| `37du-File-Release` | 壳子/环境包/大文件上传发版(file push) |
| `37du-Account-Permission` | 账号与权限管理 |
| `37du-Center-Deploy` | 中心机部署(SSH、编译、重启、验证) |
| `37du-Desktop-Auto` | 桌面自动化库 `libs/desktopauto` 用法与坑位 |
| `37du-AITable-CLI` | 钉钉 AI 表格库 `libs/aitable` 用法 |
| `37du-Yingdao-To-Plugin` | 影刀脚本转插件 |
| `37du-Monthly-Review` | 月度复盘 |
> 实际账号统一 `puddy / 123456`;`agent_cli` 已默认 `--admin puddy`,支持 `--json` 机器输出与 `ping` 预检。