feat: Agent CLI 与终端审计回放全面优化

- Agent CLI: 多轮对话、SSH 长连接、流式推理、Evolver 按用户隔离、历史侧栏
- 终端审计: 回放播放器、命令书签、筛选分页导出、命令输出统计、录制落盘修复
- 修复 session_commands 表迁移、Kill 竞态导致录制丢失、无录制会话回放提示
- 审计历史页只读(移除删除),移除回放弹框录制搜索
This commit is contained in:
Logan committed 2026-07-01 12:13:53 +08:00
1 parent 9a3dd304f7
commit 1acb0c49af
81 files changed
+3916 -1655

No files matched your search

+14 -12
View File
@@ -12,10 +12,11 @@ type LLMConfig struct {
Endpoint string `gorm:"size:500" json:"endpoint"` // 基础地址,如 https://api.openai.com/v1
Temperature float64 `gorm:"default:0.7" json:"temperature"` // 采样温度 0-2
MaxTokens int `gorm:"default:2000" json:"max_tokens"` // 最大输出 token
SystemPrompt string `gorm:"type:text" json:"system_prompt"` // 系统提示词(AIOps 运维助手角色)
Enabled bool `gorm:"default:false" json:"enabled"` // 是否启用
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
SystemPrompt string `gorm:"type:text" json:"system_prompt"` // 系统提示词(AIOps 运维助手角色)
Enabled bool `gorm:"default:false" json:"enabled"` // 是否启用
ReasoningEnabled bool `gorm:"default:false" json:"reasoning_enabled"` // 是否启用推理/Plan 模式(OpenAI o-series / DeepSeek R1 / Claude thinking 等) // Logan.Li
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 表名 // Logan.Li
@@ -23,14 +24,15 @@ func (LLMConfig) TableName() string { return "ai_llm_configs" }
// SaveLLMConfigRequest 保存 LLM 配置请求 // Logan.Li
type SaveLLMConfigRequest struct {
Provider string `json:"provider"`
Model string `json:"model"`
APIKey string `json:"api_key"` // 若为脱敏值(含 ****)则后端保留原值
Endpoint string `json:"endpoint"`
Temperature float64 `json:"temperature"`
MaxTokens int `json:"max_tokens"`
SystemPrompt string `json:"system_prompt"`
Enabled bool `json:"enabled"`
Provider string `json:"provider"`
Model string `json:"model"`
APIKey string `json:"api_key"` // 若为脱敏值(含 ****)则后端保留原值
Endpoint string `json:"endpoint"`
Temperature float64 `json:"temperature"`
MaxTokens int `json:"max_tokens"`
SystemPrompt string `json:"system_prompt"`
Enabled bool `json:"enabled"`
ReasoningEnabled bool `json:"reasoning_enabled"` // 是否启用推理/Plan 模式
}
// ChatMessage 对话消息 // Logan.Li
+6
View File
@@ -216,4 +216,10 @@ type ServerStats struct {
AvgCPU float64 `json:"avg_cpu"`
AvgMemory float64 `json:"avg_memory"`
AvgDisk float64 `json:"avg_disk"`
// 总资源概览(GB/核),用于仪表盘资源使用率卡片展示具体容量 // Logan.Li
TotalCPU int64 `json:"total_cpu"` // CPU 核心数合计
TotalMemory int64 `json:"total_memory"` // 内存总量 GB
UsedMemory int64 `json:"used_memory"` // 内存已用 GB
TotalDisk int64 `json:"total_disk"` // 磁盘总量 GB
UsedDisk int64 `json:"used_disk"` // 磁盘已用 GB
}
+4 -1
View File
@@ -11,6 +11,7 @@ type SessionCommand struct {
ServerID uint `json:"server_id"`
ServerName string `gorm:"size:128" json:"server_name"`
Command string `gorm:"type:text" json:"command"` // 执行的原始命令
OutputSize *int `json:"output_size"` // 下一条命令前累计的终端输出字节数,nil=历史未统计 // Logan.Li
Timestamp time.Time `json:"timestamp"` // 命令执行时间
CreatedAt time.Time `json:"created_at"`
}
@@ -19,12 +20,14 @@ func (SessionCommand) TableName() string {
return "sys_session_commands"
}
// SessionCommandQuery 会话命令查询
// SessionCommandQuery 会话命令查询 // Logan.Li
type SessionCommandQuery struct {
SessionID uint `form:"session_id"`
Username string `form:"username"`
ServerID uint `form:"server_id"`
Command string `form:"command"`
StartDate string `form:"start_date"` // YYYY-MM-DD
EndDate string `form:"end_date"`
Page int `form:"page,default=1"`
PageSize int `form:"page_size,default=20"`
}
+7
View File
@@ -0,0 +1,7 @@
package model
// SessionCommandItem 命令列表项(附带关联会话录制大小) // Logan.Li
type SessionCommandItem struct {
SessionCommand
SessionRecordSize int `gorm:"column:session_record_size" json:"session_record_size"` // 关联会话 record_size,0=无录制 // Logan.Li
}
+10 -6
View File
@@ -26,11 +26,15 @@ func (TerminalSession) TableName() string {
return "sys_terminal_sessions"
}
// TerminalSessionQuery 终端会话查询
// TerminalSessionQuery 终端会话查询 // Logan.Li
type TerminalSessionQuery struct {
ServerID uint `form:"server_id"`
Username string `form:"username"`
Status string `form:"status"`
Page int `form:"page,default=1"`
PageSize int `form:"page_size,default=20"`
ServerID uint `form:"server_id"`
Username string `form:"username"`
Status string `form:"status"`
Keyword string `form:"keyword"` // 模糊匹配用户/主机名/IP/客户端IP
StartDate string `form:"start_date"` // YYYY-MM-DD
EndDate string `form:"end_date"` // YYYY-MM-DD
HasRecord string `form:"has_record"` // 1/true 仅含录制
Page int `form:"page,default=1"`
PageSize int `form:"page_size,default=20"`
}