refactor: 将客服后端重构为宿主可嵌入模块
- 注入数据库、运行时配置、统一响应、文件存储和平台 AI 能力,补充业务读写工具与客户快捷操作契约。 - 移除模块内重复的组织、客户、工单、标签、技能、旧工作流、MCP 和迁移实现,将身份权限与业务主体交由宿主管理。 - 使用 libSQL 重构向量存储,并完善图片消息、访客身份、排队调度、企业微信和支持聊天页面。 - 统一 HTTP、DTO 与 WebSocket 的 snake_case 协议,补齐模块初始化、业务动作和公共载荷等回归测试。
This commit is contained in:
+22
-273
@@ -2,18 +2,13 @@ package models
|
||||
|
||||
import (
|
||||
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Models 注册所有需要迁移和代码生成的模型。
|
||||
var Models = []any{
|
||||
&Migration{},
|
||||
&Company{},
|
||||
&Customer{},
|
||||
&CustomerIdentity{},
|
||||
&CustomerContact{},
|
||||
&Asset{},
|
||||
&Tag{},
|
||||
&Conversation{},
|
||||
&ConversationParticipant{},
|
||||
&ConversationReadState{},
|
||||
@@ -23,14 +18,8 @@ var Models = []any{
|
||||
&WxWorkKFMessageRef{},
|
||||
&ChannelMessageOutbox{},
|
||||
&ConversationAssignment{},
|
||||
&ConversationTag{},
|
||||
&QuickReply{},
|
||||
&ConversationEventLog{},
|
||||
&Ticket{},
|
||||
&TicketTag{},
|
||||
&TicketProgress{},
|
||||
&TicketView{},
|
||||
&TicketNoSequence{},
|
||||
&Notification{},
|
||||
&AIAgent{},
|
||||
&Channel{},
|
||||
@@ -46,20 +35,13 @@ var Models = []any{
|
||||
&KnowledgeRetrieveLog{},
|
||||
&KnowledgeRetrieveHit{},
|
||||
&KnowledgeFeedback{},
|
||||
&SkillDefinition{},
|
||||
&AgentRevision{},
|
||||
&AgentRun{},
|
||||
&AgentStep{},
|
||||
&AgentToolCall{},
|
||||
&AgentToolInvocation{},
|
||||
&AgentRunQualityFeedback{},
|
||||
&AIWorkflow{},
|
||||
&AIWorkflowVersion{},
|
||||
&AIAgentWorkflowBinding{},
|
||||
&AIWorkflowRun{},
|
||||
&AIWorkflowNodeRun{},
|
||||
&ConversationInterrupt{},
|
||||
&SystemConfig{},
|
||||
}
|
||||
|
||||
// AgentToolInvocation persists the idempotency boundary for a business tool.
|
||||
@@ -77,50 +59,6 @@ type AgentToolInvocation struct {
|
||||
AuditFields
|
||||
}
|
||||
|
||||
type Migration struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
Version int64 `gorm:"type:bigint;not null;uniqueIndex"`
|
||||
Remark string `gorm:"type:text"`
|
||||
Success bool `gorm:"not null;default:false"`
|
||||
ErrorInfo string `gorm:"type:text"`
|
||||
RetryCount int `gorm:"type:int;not null;default:0"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// SystemConfig 运营侧系统配置项;具体有哪些 config_key 由业务代码约定,表内一行一项。
|
||||
type SystemConfig struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
ConfigKey string `gorm:"column:config_key;type:varchar(128);not null;uniqueIndex"`
|
||||
ConfigValue string `gorm:"column:config_value;type:text;not null"`
|
||||
GroupCode string `gorm:"column:group_code;type:varchar(64);not null;default:'';index"`
|
||||
Title string `gorm:"type:varchar(200);not null;default:''"`
|
||||
Description string `gorm:"type:text"`
|
||||
Status enums.Status `gorm:"type:int;not null;default:0;index"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// TicketNoSequence 工单号日序列表。
|
||||
//
|
||||
// 每天一条记录,NextSeq 表示当日下一次可分配的序号。
|
||||
type TicketNoSequence struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
DateKey string `gorm:"column:date_key;type:varchar(8);not null;uniqueIndex"`
|
||||
NextSeq int64 `gorm:"column:next_seq;type:bigint;not null;default:1"`
|
||||
CreatedAt time.Time `gorm:"not null;index"`
|
||||
UpdatedAt time.Time `gorm:"not null;index"`
|
||||
}
|
||||
|
||||
// TicketView 工单工作台个人保存视图。
|
||||
type TicketView struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null;index"`
|
||||
Name string `gorm:"column:name;type:varchar(100);not null;default:'';index"`
|
||||
FiltersJSON string `gorm:"column:filters_json;type:text;not null"`
|
||||
SortNo int `gorm:"column:sort_no;type:int;not null;default:0;index"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// Notification 站内通知。
|
||||
type Notification struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
@@ -147,82 +85,17 @@ type AuditFields struct {
|
||||
UpdateUserName string `gorm:"type:varchar(100);not null;default:''"` // UpdateUserName 记录最后更新人名称;系统任务写system。
|
||||
}
|
||||
|
||||
// Company 客户公司(组织)表。
|
||||
//
|
||||
// 用于存储公司主体信息;Customer(人)可通过 CompanyID 关联到所属公司。
|
||||
type Company struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"` // ID 为公司主键。
|
||||
Name string `gorm:"type:varchar(200);not null;uniqueIndex:uk_company_name"` // Name 为公司名称(唯一)。
|
||||
Code string `gorm:"type:varchar(64);not null;index"` // Code 为公司编码/统一社会信用代码(可空语义用空串表示)。
|
||||
Status enums.Status `gorm:"type:int;not null;default:0"` // Status 为公司状态。
|
||||
Remark string `gorm:"type:text"` // Remark 为备注。
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// Customer 客户主表。
|
||||
//
|
||||
// 用于存储客户稳定画像信息,不包含平台身份映射和多联系方式明细。
|
||||
type Customer struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"` // ID 为客户主键。
|
||||
Name string `gorm:"type:varchar(100);not null;default:'';index"` // Name 为客户姓名或展示名称。
|
||||
Gender enums.Gender `gorm:"type:int;not null;default:0;"` // Gender 为性别:0未知 1男 2女。
|
||||
CompanyID int64 `gorm:"type:bigint;not null;default:0;index"` // CompanyID 为所属公司ID;0表示无所属公司(个人客户)。
|
||||
LastActiveAt *time.Time // LastActiveAt 为最近活跃时间。
|
||||
PrimaryMobile string `gorm:"type:varchar(32);not null;default:'';index"` // PrimaryMobile 为主手机号(冗余展示字段)。
|
||||
PrimaryEmail string `gorm:"type:varchar(100);not null;default:'';index"` // PrimaryEmail 为主邮箱(冗余展示字段)。
|
||||
Status enums.Status `gorm:"type:int;not null;default:0;"` // Status 为客户状态。
|
||||
Remark string `gorm:"type:text"` // Remark 为备注。
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// CustomerIdentity 客户第三方身份映射表。
|
||||
type CustomerIdentity struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
CustomerID int64 `gorm:"type:bigint;not null;uniqueIndex:uk_customer_external"` // 为所属客户ID。
|
||||
ExternalSource enums.ExternalSource `gorm:"type:varchar(30);uniqueIndex:uk_customer_external"` // 为外部身份来源
|
||||
ExternalID string `gorm:"type:varchar(128);index:idx_external_id;uniqueIndex:uk_customer_external"` // 为平台侧用户唯一ID,与访客 ExternalID 对齐。
|
||||
RawProfile string `gorm:"type:text"` // 为第三方原始资料JSON。
|
||||
Status enums.Status `gorm:"type:int;not null;default:0;index"` // 为映射状态。
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// CustomerContact 客户联系方式表。
|
||||
//
|
||||
// 用于维护客户的一对多联系方式,支持主联系方式、验证状态与失效标记。
|
||||
type CustomerContact struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
CustomerID int64 `gorm:"type:bigint;not null;index;uniqueIndex:uk_customer_contact"` // CustomerID 为所属客户ID。
|
||||
ContactType enums.ContactType `gorm:"type:varchar(30);not null;default:'';index;uniqueIndex:uk_customer_contact"` // ContactType 为联系方式类型:mobile/email/wechat/other。
|
||||
ContactValue string `gorm:"type:varchar(200);not null;default:'';index;uniqueIndex:uk_customer_contact"` // ContactValue 为联系方式值。
|
||||
IsPrimary bool `gorm:"not null;default:false;index"` // IsPrimary 表示是否主联系方式。
|
||||
IsVerified bool `gorm:"not null;default:false;index"` // IsVerified 表示是否已验证。
|
||||
VerifiedAt *time.Time // VerifiedAt 为验证时间。
|
||||
Source string `gorm:"type:varchar(30);not null;default:'';index"` // Source 为来源:manual/import/system。
|
||||
Status enums.Status `gorm:"type:int;not null;default:0;index"` // Status 为联系方式状态。
|
||||
Remark string `gorm:"type:varchar(255);not null;default:''"` // Remark 为备注。
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// Asset 存储的文件资源,如上传的附件等。
|
||||
type Asset struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
AssetID string `gorm:"type:varchar(64);not null;uniqueIndex"`
|
||||
Provider enums.AssetProvider `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
StorageKey string `gorm:"type:varchar(255);not null;default:'';uniqueIndex:uk_storage_key"`
|
||||
Filename string `gorm:"type:varchar(255);not null;default:''"`
|
||||
FileSize int64 `gorm:"type:bigint;not null;default:0"`
|
||||
MimeType string `gorm:"type:varchar(100);not null;default:''"`
|
||||
Status enums.AssetStatus `gorm:"type:int;not null;default:1;index"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
ParentID int64 `gorm:"type:bigint;not null;index"`
|
||||
Name string `gorm:"type:varchar(50);not null;"`
|
||||
Remark string `gorm:"type:text;"`
|
||||
SortNo int `gorm:"type:int;not null;default:0"`
|
||||
Status enums.Status `gorm:"type:int;not null;default:0"`
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
ConversationID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
AssetID string `gorm:"type:varchar(64);not null;uniqueIndex"`
|
||||
Provider enums.AssetProvider `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
StorageKey string `gorm:"type:varchar(255);not null;default:'';uniqueIndex:uk_storage_key"`
|
||||
Filename string `gorm:"type:varchar(255);not null;default:''"`
|
||||
FileSize int64 `gorm:"type:bigint;not null;default:0"`
|
||||
MimeType string `gorm:"type:varchar(100);not null;default:''"`
|
||||
Status enums.AssetStatus `gorm:"type:int;not null;default:1;index"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
@@ -231,8 +104,10 @@ type Conversation struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"` // ID 为会话主键。
|
||||
AIAgentID int64 `gorm:"type:bigint;not null;default:0;index"` // AIAgentID 为当前会话绑定的 AI Agent ID。
|
||||
ChannelID int64 `gorm:"type:bigint;not null;default:0;index"` // ChannelID 为该会话来源接入渠道ID。
|
||||
CustomerID int64 `gorm:"type:bigint;not null;default:0;index"` // CustomerID 为会话所属客户 ID。
|
||||
CustomerName string `gorm:"type:varchar(100);not null;default:'';index"` // CustomerName 为客户名称冗余字段,用于列表展示和搜索。
|
||||
CustomerType string `gorm:"type:varchar(30);not null;default:'';index"` // CustomerType 为 be-system 用户类型;匿名渠道使用来源类型。
|
||||
CustomerID int64 `gorm:"type:bigint;not null;default:0;index"` // CustomerID 为 be-system 用户 ID;匿名访客为 0。
|
||||
CustomerExternalID string `gorm:"type:varchar(128);not null;default:'';index"` // CustomerExternalID 为宿主用户或匿名渠道的稳定外部标识。
|
||||
CustomerName string `gorm:"type:varchar(100);not null;default:'';index"` // CustomerName 为显示名称快照,用于历史会话展示和搜索。
|
||||
Status enums.IMConversationStatus `gorm:"type:int;not null;default:1;index"` // Status 为会话状态,如待接入、处理中、已关闭。
|
||||
ServiceMode enums.IMConversationServiceMode `gorm:"type:int;not null;default:3;index"` // ServiceMode 为服务模式,如仅AI、仅人工、AI优先人工接管。
|
||||
Priority int `gorm:"type:int;not null;default:0;index"` // Priority 为会话优先级。
|
||||
@@ -246,6 +121,7 @@ type Conversation struct {
|
||||
AgentUnreadCount int `gorm:"type:int;not null;default:0"` // AgentUnreadCount 为客服侧未读数。
|
||||
HandoffAt *time.Time `gorm:"index"` // HandoffAt 为最近一次转人工时间。
|
||||
HandoffReason string `gorm:"type:varchar(255);not null;default:''"` // HandoffReason 为最近一次转人工原因。
|
||||
QueueEnteredAt *time.Time `gorm:"index"` // QueueEnteredAt 为本次进入人工待接入队列的时间。
|
||||
AIReplyRounds int `gorm:"type:int;not null;default:0"` // AIReplyRounds 为当前会话内 AI 已成功回复次数。
|
||||
ClosedAt *time.Time `gorm:"index"` // ClosedAt 为会话关闭时间。
|
||||
ClosedBy int64 `gorm:"type:bigint;not null;default:0;index"` // ClosedBy 为关闭人用户ID,访客关闭时写0。
|
||||
@@ -283,7 +159,6 @@ type Message struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
ConversationID int64 `gorm:"type:bigint;not null;index;uniqueIndex:uk_conversation_client_msg"`
|
||||
RequestID string `gorm:"type:varchar(128);not null;default:'';index"`
|
||||
WorkflowRunID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
ClientMsgID string `gorm:"type:varchar(128);not null;default:'';uniqueIndex:uk_conversation_client_msg"`
|
||||
SenderType enums.IMSenderType `gorm:"type:varchar(30);not null;default:'';index"`
|
||||
SenderID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
@@ -381,14 +256,6 @@ type ConversationAssignment struct {
|
||||
OperatorID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
}
|
||||
|
||||
// ConversationTag 会话标签关联
|
||||
type ConversationTag struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
ConversationID int64 `gorm:"type:bigint;not null;index;uniqueIndex:uk_conversation_tag"`
|
||||
TagID int64 `gorm:"type:bigint;not null;index;uniqueIndex:uk_conversation_tag"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// QuickReply 快捷回复。
|
||||
type QuickReply struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
@@ -404,6 +271,7 @@ type QuickReply struct {
|
||||
type AIAgent struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"` // ID 为 AI Agent 主键。
|
||||
Name string `gorm:"type:varchar(100);not null;default:'';index"` // Name 为 AI Agent 名称。
|
||||
Avatar string `gorm:"type:varchar(1024);not null;default:''"` // Avatar 为 AI Agent 在客服会话中展示的头像。
|
||||
Description string `gorm:"type:varchar(255);not null;default:''"` // Description 为 AI Agent 描述。
|
||||
Status enums.Status `gorm:"type:int;not null;index"` // Status 为 AI Agent
|
||||
AIConfigID int64 `gorm:"type:bigint;not null;default:0;index"` // AIConfigID 为关联的 AI 配置ID。
|
||||
@@ -422,8 +290,6 @@ type AIAgent struct {
|
||||
FallbackMode enums.AIAgentFallbackMode `gorm:"type:int;not null;default:1"` // FallbackMode 为知识不足时的回复策略。
|
||||
FallbackMessage string `gorm:"type:text"` // FallbackMessage 为知识不足回复文案。
|
||||
KnowledgeIDs string `gorm:"type:varchar(500);not null;default:''"` // KnowledgeIDs 为绑定的知识库ID列表,按顺序表示优先级。
|
||||
SkillIDs string `gorm:"type:varchar(500);not null;default:''"` // SkillIDs 为绑定的技能ID列表,按顺序表示允许路由的范围。
|
||||
AllowedMCPTools string `gorm:"type:text"` // AllowedMCPTools 为 Agent 允许调用的 MCP 工具白名单配置 JSON。
|
||||
PublishedRevisionID int64 `gorm:"type:bigint;not null;default:0;index"` // PublishedRevisionID 为当前已发布 Agent 配置快照ID。
|
||||
SortNo int `gorm:"type:int;not null;default:0;index"` // SortNo 为后台展示排序号。
|
||||
AuditFields
|
||||
@@ -450,7 +316,6 @@ type AgentRun struct {
|
||||
AIAgentID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
AgentRevisionID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
SourceMessageID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
WorkflowRunID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
Status string `gorm:"type:varchar(30);not null;default:'';index"`
|
||||
PromptTokens int `gorm:"type:int;not null;default:0"`
|
||||
CompletionTokens int `gorm:"type:int;not null;default:0"`
|
||||
@@ -466,7 +331,6 @@ type AgentRun struct {
|
||||
type AgentStep struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
AgentRunID int64 `gorm:"type:bigint;not null;index"`
|
||||
WorkflowRunID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
StepType string `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
StepCode string `gorm:"type:varchar(100);not null;default:'';index"`
|
||||
Status string `gorm:"type:varchar(30);not null;default:'';index"`
|
||||
@@ -506,79 +370,6 @@ type AgentRunQualityFeedback struct {
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// AIWorkflow 表示客服 AI Agent 可编辑会话流程主表。
|
||||
type AIWorkflow struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
Name string `gorm:"type:varchar(100);not null;default:'';index"`
|
||||
Description string `gorm:"type:text"`
|
||||
Status enums.Status `gorm:"type:int;not null;default:0;index"`
|
||||
DraftDefinition string
|
||||
PublishedVersionID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
SortNo int `gorm:"type:int;not null;default:0;index"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// AIWorkflowVersion 表示 AI 会话流程的不可变发布版本。
|
||||
type AIWorkflowVersion struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
WorkflowID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
Version int `gorm:"type:int;not null;default:0;index"`
|
||||
Status enums.Status `gorm:"type:int;not null;default:0;index"`
|
||||
Definition string
|
||||
DefinitionHash string `gorm:"type:varchar(64);not null;default:'';index"`
|
||||
PublishedAt *time.Time `gorm:"index"`
|
||||
PublishedByID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
PublishedByName string `gorm:"type:varchar(100);not null;default:''"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// AIAgentWorkflowBinding binds an Agent to one immutable, published workflow
|
||||
// version. Workflows are maintained independently and can be reused by many
|
||||
// Agents; Agent publication snapshots the binding set for reproducible runs.
|
||||
type AIAgentWorkflowBinding struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
AIAgentID int64 `gorm:"type:bigint;not null;index;uniqueIndex:uk_agent_workflow_binding"`
|
||||
WorkflowID int64 `gorm:"type:bigint;not null;index"`
|
||||
WorkflowVersionID int64 `gorm:"type:bigint;not null;index;uniqueIndex:uk_agent_workflow_binding"`
|
||||
ToolName string `gorm:"type:varchar(100);not null;default:''"`
|
||||
TriggerInstruction string `gorm:"type:text"`
|
||||
Priority int `gorm:"type:int;not null;default:0;index"`
|
||||
Enabled bool `gorm:"not null;default:true;index"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// AIWorkflowRun 表示一次会话 workflow 执行记录。
|
||||
type AIWorkflowRun struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
WorkflowID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
WorkflowVersionID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
ConversationID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
AIAgentID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
MessageID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
Status int `gorm:"type:int;not null;default:0;index"`
|
||||
StartedAt time.Time `gorm:"not null;index"`
|
||||
EndedAt *time.Time `gorm:"index"`
|
||||
InterruptType string `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
InterruptNodeID string `gorm:"type:varchar(100);not null;default:'';index"`
|
||||
ErrorMessage string `gorm:"type:text"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// AIWorkflowNodeRun 表示 workflow 执行中的单节点审计记录。
|
||||
type AIWorkflowNodeRun struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
WorkflowRunID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
NodeID string `gorm:"type:varchar(100);not null;default:'';index"`
|
||||
NodeType string `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
Status int `gorm:"type:int;not null;default:0;index"`
|
||||
InputPreview string `gorm:"type:text"`
|
||||
OutputPreview string `gorm:"type:text"`
|
||||
ErrorMessage string `gorm:"type:text"`
|
||||
StartedAt time.Time `gorm:"not null;index"`
|
||||
EndedAt *time.Time `gorm:"index"`
|
||||
DurationMS int `gorm:"type:int;not null;default:0"`
|
||||
}
|
||||
|
||||
// Channel 接入渠道配置。
|
||||
//
|
||||
// 用于统一描述系统的外部接入入口。不同渠道类型共享统一的接入配置骨架,
|
||||
@@ -617,39 +408,6 @@ type ConversationEventLog struct {
|
||||
CreatedAt time.Time `gorm:"not null;index"`
|
||||
}
|
||||
|
||||
// Ticket 客服问题记录。
|
||||
type Ticket struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
TicketNo string `gorm:"type:varchar(64);not null;default:'';uniqueIndex"`
|
||||
Title string `gorm:"type:varchar(255);not null;default:'';index"`
|
||||
Description string `gorm:"type:text"`
|
||||
Source enums.TicketSource `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
Channel string `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
CustomerID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
ConversationID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
Status enums.TicketStatus `gorm:"type:varchar(50);not null;default:'pending';index"`
|
||||
CurrentAssigneeID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
HandledAt *time.Time `gorm:"index"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// TicketTag 工单标签关联。
|
||||
type TicketTag struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
TicketID int64 `gorm:"type:bigint;not null;index;uniqueIndex:uk_ticket_tag"`
|
||||
TagID int64 `gorm:"type:bigint;not null;index;uniqueIndex:uk_ticket_tag"`
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// TicketProgress 工单处理进展。
|
||||
type TicketProgress struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
TicketID int64 `gorm:"type:bigint;not null;index"`
|
||||
Content string `gorm:"type:text"`
|
||||
AuthorID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
CreatedAt time.Time `gorm:"not null;index"`
|
||||
}
|
||||
|
||||
// AgentProfile 客服档案。
|
||||
type AgentProfile struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"` // ID 为客服档案主键。
|
||||
@@ -713,6 +471,12 @@ type AIConfig struct {
|
||||
Status enums.Status `gorm:"type:int;not null;index"` // Status 状态;同一 modelType 仅允许一条启用记录。
|
||||
SortNo int `gorm:"type:int;not null;index"` // SortNo 为排序号,用于后台展示和人工调整顺序。
|
||||
Remark string `gorm:"type:text"` // Remark 为备注,用于记录用途、成本、限制和切换说明等补充信息。
|
||||
Platform bool `gorm:"-" json:"-"` // Platform 标记该配置来自宿主平台代理,不写入数据库。
|
||||
ChatEnabled bool `gorm:"-" json:"-"` // ChatEnabled 标记平台代理文本模型能力已启用。
|
||||
VisionEnabled bool `gorm:"-" json:"-"` // VisionEnabled 标记平台代理视觉模型能力已启用。
|
||||
VisionModel string `gorm:"-" json:"-"` // VisionModel 为当前图片消息调用使用的平台代理模型名。
|
||||
EmbeddingEnabled bool `gorm:"-" json:"-"` // EmbeddingEnabled 标记平台代理向量模型能力已启用。
|
||||
HTTPClient *http.Client `gorm:"-" json:"-"` // HTTPClient 为宿主提供的授权签名客户端。
|
||||
AuditFields
|
||||
}
|
||||
|
||||
@@ -870,19 +634,6 @@ type KnowledgeFeedback struct {
|
||||
CreatedAt time.Time `gorm:"not null;index"`
|
||||
}
|
||||
|
||||
// SkillDefinition 表示可由后台配置并参与运行时路由的 Skill 定义。
|
||||
type SkillDefinition struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"` // ID 为 Skill 主键。
|
||||
Name string `gorm:"type:varchar(100);not null;default:'';index"` // Name 为 Skill 的展示名称,用于后台列表、配置页和人工选择场景。
|
||||
Description string `gorm:"type:varchar(255);not null;default:''"` // Description 为 Skill 的简要说明,用于描述该 Skill 的适用场景和职责边界。
|
||||
Instruction string // Instruction 为 Skill 的主体说明文档存储字段,使用 Markdown 编写,供 Agent 理解任务目标、步骤和工具使用要求。
|
||||
Examples string `gorm:"type:text"` // Examples 为示例问法 JSON 数组字符串。
|
||||
ToolWhitelist string `gorm:"type:text"` // ToolWhitelist 为允许使用的工具编码 JSON 数组字符串。
|
||||
Status enums.Status `gorm:"type:int;not null;default:0;index"` // Status 为 Skill 当前状态,使用全局通用状态:0启用 1禁用 2删除。
|
||||
Remark string `gorm:"type:text"` // Remark 为后台备注,用于记录配置说明、维护信息或内部协作信息。
|
||||
AuditFields
|
||||
}
|
||||
|
||||
// ConversationInterrupt 表示会话级待恢复中断记录。
|
||||
type ConversationInterrupt struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
@@ -892,8 +643,6 @@ type ConversationInterrupt struct {
|
||||
AgentStepID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
SourceMessageID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
LastResumeMessageID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
WorkflowRunID int64 `gorm:"type:bigint;not null;default:0;index"`
|
||||
WorkflowNodeID string `gorm:"type:varchar(100);not null;default:'';index"`
|
||||
CheckPointID string `gorm:"type:varchar(128);not null;default:'';uniqueIndex"`
|
||||
InterruptID string `gorm:"type:varchar(255);not null;default:'';index"`
|
||||
InterruptType string `gorm:"type:varchar(50);not null;default:'';index"`
|
||||
|
||||
Reference in New Issue
Block a user