feat: Agent 任务名与对话标题双能力自动生成

新增 task_auto_title_enabled / chat_auto_title_enabled(默认关)、
共享 GenerateAutoTitle、spawn_task 同步写 name、对话首条先截断再异步 AI,
设置页「自动标题」双 Switch。closes #55
This commit is contained in:
artex-bot committed 2026-10-27 12:33:53 +08:00
1 parent e740334b90
commit 6c781f21f4
11 files changed
+310 -1

No files matched your search

+16
View File
@@ -3443,6 +3443,8 @@ func (s *Server) settingsPayload() map[string]any {
"traffic_capture": s.m.TrafficEnabled(),
"agent_traffic_binding": s.m.pg.GetBool(settingAgentTrafficBinding, false),
"task_intelligence_enabled": s.m.pg.GetBool(db.SettingTaskIntelligence, false),
db.SettingTaskAutoTitle: s.m.pg.GetBool(db.SettingTaskAutoTitle, false),
db.SettingChatAutoTitle: s.m.pg.GetBool(db.SettingChatAutoTitle, false),
db.SettingCredentialAgent: s.m.pg.GetBool(db.SettingCredentialAgent, false),
db.SettingCredentialTraffic: s.m.pg.GetBool(db.SettingCredentialAgent, false) && s.m.pg.GetBool(db.SettingCredentialTraffic, false),
"llm_record": s.m.LLMRecordEnabled(),
@@ -3517,6 +3519,8 @@ func (s *Server) putSettings(w http.ResponseWriter, r *http.Request) {
TrafficCapture *bool `json:"traffic_capture"`
AgentTrafficBinding *bool `json:"agent_traffic_binding"`
TaskIntelligence *bool `json:"task_intelligence_enabled"`
TaskAutoTitle *bool `json:"task_auto_title_enabled"`
ChatAutoTitle *bool `json:"chat_auto_title_enabled"`
CredentialAgent *bool `json:"credential_agent_enabled"`
CredentialTraffic *bool `json:"credential_traffic_binding"`
LLMRecord *bool `json:"llm_record"` // LLM 录制开关(默认关);即时生效,无需重建 agent
@@ -3689,6 +3693,18 @@ func (s *Server) putSettings(w http.ResponseWriter, r *http.Request) {
return
}
}
if req.TaskAutoTitle != nil {
if err := s.m.pg.SetBool(db.SettingTaskAutoTitle, *req.TaskAutoTitle); err != nil {
writeErr(w, 500, err.Error())
return
}
}
if req.ChatAutoTitle != nil {
if err := s.m.pg.SetBool(db.SettingChatAutoTitle, *req.ChatAutoTitle); err != nil {
writeErr(w, 500, err.Error())
return
}
}
if req.AgentTrafficBinding != nil {
if err := s.m.pg.SetBool(settingAgentTrafficBinding, *req.AgentTrafficBinding); err != nil {
writeErr(w, 500, err.Error())