refactor: 将客服后端重构为宿主可嵌入模块

- 注入数据库、运行时配置、统一响应、文件存储和平台 AI 能力,补充业务读写工具与客户快捷操作契约。

- 移除模块内重复的组织、客户、工单、标签、技能、旧工作流、MCP 和迁移实现,将身份权限与业务主体交由宿主管理。

- 使用 libSQL 重构向量存储,并完善图片消息、访客身份、排队调度、企业微信和支持聊天页面。

- 统一 HTTP、DTO 与 WebSocket 的 snake_case 协议,补齐模块初始化、业务动作和公共载荷等回归测试。
This commit is contained in:
t
2026-08-28 22:23:13 +08:00
parent 6845c728f8
commit 18c9354095
377 changed files with 13199 additions and 22881 deletions
+57 -79
View File
@@ -10,65 +10,46 @@ type AIAgentTeamResponse struct {
Name string `json:"name"`
}
type AIAgentSkillResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
}
type AIAgentMCPToolResponse struct {
ToolCode string `json:"toolCode"`
ServerCode string `json:"serverCode"`
ToolName string `json:"toolName"`
Title string `json:"title"`
Description string `json:"description"`
RiskLevel string `json:"riskLevel"`
RequireConfirmation bool `json:"requireConfirmation"`
Arguments map[string]string `json:"arguments"`
}
type AIAgentWorkflowBindingResponse struct {
ID int64 `json:"id"`
WorkflowID int64 `json:"workflowId"`
WorkflowVersionID int64 `json:"workflowVersionId"`
WorkflowName string `json:"workflowName"`
WorkflowVersion int `json:"workflowVersion"`
ToolName string `json:"toolName"`
TriggerInstruction string `json:"triggerInstruction"`
Priority int `json:"priority"`
Enabled bool `json:"enabled"`
}
type AgentRevisionResponse struct {
ID int64 `json:"id"`
AgentID int64 `json:"agentId"`
AgentID int64 `json:"agent_id"`
Revision int `json:"revision"`
Status enums.Status `json:"status"`
DefinitionHash string `json:"definitionHash"`
PublishedAt string `json:"publishedAt"`
PublishedByID int64 `json:"publishedById"`
PublishedByName string `json:"publishedByName"`
DefinitionHash string `json:"definition_hash"`
PublishedAt string `json:"published_at"`
PublishedByID int64 `json:"published_by_id"`
PublishedByName string `json:"published_by_name"`
}
type AIConfigResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Provider enums.AIProvider `json:"provider"`
BaseURL string `json:"baseUrl"`
HasAPIKey bool `json:"hasApiKey"`
ModelType enums.AIModelType `json:"modelType"`
ModelName string `json:"modelName"`
BaseURL string `json:"base_url"`
APIKey string `json:"api_key,omitempty"`
HasAPIKey bool `json:"has_api_key"`
ModelType enums.AIModelType `json:"model_type"`
ModelName string `json:"model_name"`
Dimension int `json:"dimension"`
MaxContextTokens int `json:"maxContextTokens"`
MaxOutputTokens int `json:"maxOutputTokens"`
TimeoutMS int `json:"timeoutMs"`
MaxRetryCount int `json:"maxRetryCount"`
RPMLimit int `json:"rpmLimit"`
TPMLimit int `json:"tpmLimit"`
MaxContextTokens int `json:"max_context_tokens"`
MaxOutputTokens int `json:"max_output_tokens"`
TimeoutMS int `json:"timeout_ms"`
MaxRetryCount int `json:"max_retry_count"`
RPMLimit int `json:"rpm_limit"`
TPMLimit int `json:"tpm_limit"`
Status enums.Status `json:"status"`
SortNo int `json:"sortNo"`
SortNo int `json:"sort_no"`
Remark string `json:"remark"`
}
func BuildAIConfigDetailResponse(item *models.AIConfig) AIConfigResponse {
result := BuildAIConfigResponse(item)
if item != nil {
result.APIKey = item.APIKey
}
return result
}
func BuildAIConfigResponse(item *models.AIConfig) AIConfigResponse {
return AIConfigResponse{
ID: item.ID,
@@ -92,39 +73,36 @@ func BuildAIConfigResponse(item *models.AIConfig) AIConfigResponse {
}
type AIAgentResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
AIConfigID int64 `json:"aiConfigId"`
AIConfigName string `json:"aiConfigName"`
MaxSteps int `json:"maxSteps"`
ContextWindow int `json:"contextWindow"`
ToolPolicy string `json:"toolPolicy"`
KnowledgePolicy string `json:"knowledgePolicy"`
ServiceMode enums.IMConversationServiceMode `json:"serviceMode"`
ServiceModeName string `json:"serviceModeName"`
SystemPrompt string `json:"systemPrompt"`
WelcomeMessage string `json:"welcomeMessage"`
ReplyTimeoutSeconds int `json:"replyTimeoutSeconds"`
RolloutPercent int `json:"rolloutPercent"`
PreviousRolloutPercent int `json:"previousRolloutPercent"`
Teams []AIAgentTeamResponse `json:"teams"`
HandoffMode enums.AIAgentHandoffMode `json:"handoffMode"`
HandoffModeName string `json:"handoffModeName"`
FallbackMode enums.AIAgentFallbackMode `json:"fallbackMode"`
FallbackModeName string `json:"fallbackModeName"`
FallbackMessage string `json:"fallbackMessage"`
KnowledgeBaseIDs []int64 `json:"knowledgeBaseIds"`
SkillIDs []int64 `json:"skillIds"`
Skills []AIAgentSkillResponse `json:"skills"`
MCPTools []AIAgentMCPToolResponse `json:"mcpTools"`
WorkflowBindings []AIAgentWorkflowBindingResponse `json:"workflowBindings"`
PublishedRevisionID int64 `json:"publishedRevisionId"`
SortNo int `json:"sortNo"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
ID int64 `json:"id"`
Name string `json:"name"`
Avatar string `json:"avatar"`
Description string `json:"description"`
Status enums.Status `json:"status"`
StatusName string `json:"status_name"`
AIConfigID int64 `json:"ai_config_id"`
AIConfigName string `json:"ai_config_name"`
MaxSteps int `json:"max_steps"`
ContextWindow int `json:"context_window"`
ToolPolicy string `json:"tool_policy"`
KnowledgePolicy string `json:"knowledge_policy"`
ServiceMode enums.IMConversationServiceMode `json:"service_mode"`
ServiceModeName string `json:"service_mode_name"`
SystemPrompt string `json:"system_prompt"`
WelcomeMessage string `json:"welcome_message"`
ReplyTimeoutSeconds int `json:"reply_timeout_seconds"`
RolloutPercent int `json:"rollout_percent"`
PreviousRolloutPercent int `json:"previous_rollout_percent"`
Teams []AIAgentTeamResponse `json:"teams"`
HandoffMode enums.AIAgentHandoffMode `json:"handoff_mode"`
HandoffModeName string `json:"handoff_mode_name"`
FallbackMode enums.AIAgentFallbackMode `json:"fallback_mode"`
FallbackModeName string `json:"fallback_mode_name"`
FallbackMessage string `json:"fallback_message"`
KnowledgeBaseIDs []int64 `json:"knowledge_base_ids"`
PublishedRevisionID int64 `json:"published_revision_id"`
SortNo int `json:"sort_no"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}