feat: 增加 AI Agent 自主诊断执行模式

This commit is contained in:
cnbugs
2026-07-25 12:21:54 +08:00
parent 26ae846501
commit 4f3a7833a0
8 changed files with 659 additions and 1 deletions
+8
View File
@@ -13,6 +13,12 @@
- **健康评分**:100 分制量化集群健康度(严重问题 -15 分,警告 -5 分)
- **AI 智能分析**:接入 OpenAI 兼容接口,自动分析诊断报告
- 根因定位、影响评估、修复命令、优先级排序、预防建议
- **AI 自主诊断(双执行模式)**:启动前可选择命令执行方式
- **手动执行命令**:Agent 只生成命令,用户复制到自己的终端执行,服务端不会运行
- **AI 执行命令**:自动执行 `get``describe``logs``top` 等只读 kubectl 命令
- 实时展示思考步骤、执行命令和真实输出
- 即使选择 AI 执行,`apply``delete``patch``scale``rollout``exec` 等命令仍必须人工确认
- 禁止 shell、管道、重定向和多命令拼接
- **AI 追问对话**:基于诊断上下文多轮追问,深入排查问题
- **Web 仪表盘**Vue3 + Element Plus,实时展示诊断结果
@@ -55,6 +61,8 @@ KUBECONFIG_PATH=
| POST | `/api/diagnose` | 执行诊断 `{"namespace":"", "checks":[]}` |
| GET | `/api/diagnosis/latest` | 获取最近诊断结果 |
| POST | `/api/analyze` | AI 分析诊断结果 `{"question":""}` |
| GET | `/api/agent/diagnose/stream` | 自主诊断 SSE 流,`execution_mode=manual|ai` |
| POST | `/api/agent/approve` | 批准或拒绝待执行命令 `{"approval_id":"...","approved":true}` |
| POST | `/api/chat` | AI 多轮对话 `{"messages":[...]}` |
| GET | `/api/report` | 获取诊断报告文本 |