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
+4 -11
View File
@@ -6,7 +6,6 @@ import (
"strings"
"time"
"code.tczkiot.com/wlw/ai-agent/internal/ai/mcps"
_ "code.tczkiot.com/wlw/ai-agent/internal/ai/runtime"
"code.tczkiot.com/wlw/ai-agent/internal/handlers/api"
"code.tczkiot.com/wlw/ai-agent/internal/middleware"
@@ -16,6 +15,7 @@ import (
"code.tczkiot.com/wlw/ai-agent/internal/pkg/i18nx"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/tracex"
"code.tczkiot.com/wlw/ai-agent/internal/services"
"code.tczkiot.com/wlw/ai-agent/internal/web/supportchat"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
@@ -60,7 +60,7 @@ func NewServer() (*gin.Engine, error) {
func corsMiddleware() gin.HandlerFunc {
allowedOrigins := config.Current().Server.CORS.AllowedOrigins
allowHeaders := "Origin, Content-Type, Accept, Authorization, X-Requested-With, X-Channel-Id"
allowHeaders := "Origin, Content-Type, Accept, Authorization, X-Requested-With, X-Channel-Id, X-External-Id, X-External-Name"
exposeHeaders := "Content-Length, Content-Type, Authorization"
allowMethods := "GET, POST, PUT, PATCH, DELETE, OPTIONS"
allowedOriginSet := make(map[string]struct{}, len(allowedOrigins))
@@ -147,7 +147,7 @@ func isWebsocketUpgrade(ctx *gin.Context) bool {
}
func addRouter(app *gin.Engine) {
app.Any("/api/mcp", gin.WrapH(mcps.NewHTTPHandler()))
supportchat.RegisterRoutes(app)
apiGroup := app.Group("/api")
apiGroup.GET("/health", api.Health)
@@ -163,12 +163,7 @@ func addRouter(app *gin.Engine) {
dashboardGroup := app.Group("/api/dashboard", middleware.AuthMiddleware)
registerDashboardDashboardRoutes(dashboardGroup.Group("/dashboard"))
registerDashboardCompanyRoutes(dashboardGroup.Group("/company"))
registerDashboardCustomerRoutes(dashboardGroup.Group("/customer"))
registerDashboardCustomerContactRoutes(dashboardGroup.Group("/customer-contact"))
registerDashboardTagRoutes(dashboardGroup.Group("/tag"))
registerDashboardConversationRoutes(dashboardGroup.Group("/conversation"))
registerDashboardTicketRoutes(dashboardGroup.Group("/ticket"))
registerDashboardNotificationRoutes(dashboardGroup.Group("/notification"))
registerDashboardQuickReplyRoutes(dashboardGroup.Group("/quick-reply"))
registerDashboardChannelRoutes(dashboardGroup.Group("/channel"))
@@ -176,9 +171,9 @@ func addRouter(app *gin.Engine) {
registerDashboardAgentTeamRoutes(dashboardGroup.Group("/agent-team"))
registerDashboardAgentTeamScheduleRoutes(dashboardGroup.Group("/agent-team-schedule"))
registerDashboardAIAgentRoutes(dashboardGroup.Group("/ai-agent"))
registerDashboardAIWorkflowRoutes(dashboardGroup.Group("/ai-workflow"))
registerDashboardAgentRunRoutes(dashboardGroup.Group("/agent-run"))
registerDashboardAIConfigRoutes(dashboardGroup.Group("/ai-config"))
registerDashboardPlatformAIRoutes(dashboardGroup.Group("/platform-ai"))
registerDashboardAssetRoutes(dashboardGroup.Group("/asset"))
registerDashboardKnowledgeBaseRoutes(dashboardGroup.Group("/knowledge-base"))
registerDashboardKnowledgeDirectoryRoutes(dashboardGroup.Group("/knowledge-directory"))
@@ -186,8 +181,6 @@ func addRouter(app *gin.Engine) {
registerDashboardKnowledgeFAQRoutes(dashboardGroup.Group("/knowledge-faq"))
registerDashboardKnowledgeRetrieveRoutes(dashboardGroup.Group("/knowledge-retrieve"))
registerDashboardKnowledgeRetrieveLogRoutes(dashboardGroup.Group("/knowledge-retrieve-log"))
registerDashboardSkillDefinitionRoutes(dashboardGroup.Group("/skill-definition"))
registerDashboardMCPRoutes(dashboardGroup.Group("/mcp"))
thirdGroup := app.Group("/api/third")
registerThirdWechatRoutes(thirdGroup.Group("/wechat"))