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
+27 -48
View File
@@ -2,39 +2,20 @@ package request
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type AIAgentMCPToolRequest 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 AIAgentWorkflowBindingRequest struct {
WorkflowVersionID int64 `json:"workflowVersionId"`
ToolName string `json:"toolName"`
TriggerInstruction string `json:"triggerInstruction"`
Priority int `json:"priority"`
Enabled bool `json:"enabled"`
}
type CreateAIConfigRequest struct {
Name string `json:"name"`
Provider enums.AIProvider `json:"provider"`
BaseURL string `json:"baseUrl"`
APIKey string `json:"apiKey"`
ModelType enums.AIModelType `json:"modelType"`
ModelName string `json:"modelName"`
BaseURL string `json:"base_url"`
APIKey string `json:"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"`
Remark string `json:"remark"`
}
@@ -54,25 +35,23 @@ type UpdateAIConfigStatusRequest struct {
type CreateAIAgentRequest struct {
Name string `json:"name"`
Avatar string `json:"avatar"`
Description string `json:"description"`
AIConfigID int64 `json:"aiConfigId"`
MaxSteps int `json:"maxSteps"`
ContextWindow int `json:"contextWindow"`
ToolPolicy string `json:"toolPolicy"`
KnowledgePolicy string `json:"knowledgePolicy"`
ServiceMode enums.IMConversationServiceMode `json:"serviceMode"`
SystemPrompt string `json:"systemPrompt"`
WelcomeMessage string `json:"welcomeMessage"`
ReplyTimeoutSeconds int `json:"replyTimeoutSeconds"`
RolloutPercent int `json:"rolloutPercent"`
TeamIDs []int64 `json:"teamIds"`
HandoffMode enums.AIAgentHandoffMode `json:"handoffMode"`
FallbackMode enums.AIAgentFallbackMode `json:"fallbackMode"`
FallbackMessage string `json:"fallbackMessage"`
KnowledgeBaseIDs []int64 `json:"knowledgeBaseIds"`
SkillIDs []int64 `json:"skillIds"`
MCPTools []AIAgentMCPToolRequest `json:"mcpTools"`
WorkflowBindings []AIAgentWorkflowBindingRequest `json:"workflowBindings"`
AIConfigID int64 `json:"ai_config_id"`
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"`
SystemPrompt string `json:"system_prompt"`
WelcomeMessage string `json:"welcome_message"`
ReplyTimeoutSeconds int `json:"reply_timeout_seconds"`
RolloutPercent int `json:"rollout_percent"`
TeamIDs []int64 `json:"team_ids"`
HandoffMode enums.AIAgentHandoffMode `json:"handoff_mode"`
FallbackMode enums.AIAgentFallbackMode `json:"fallback_mode"`
FallbackMessage string `json:"fallback_message"`
KnowledgeBaseIDs []int64 `json:"knowledge_base_ids"`
}
type UpdateAIAgentRequest struct {
@@ -90,7 +69,7 @@ type PublishAIAgentRequest struct {
type RollbackAIAgentRequest struct {
ID int64 `json:"id"`
RevisionID int64 `json:"revisionId"`
RevisionID int64 `json:"revision_id"`
}
type RollbackAIAgentRolloutRequest struct {