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
@@ -1,10 +1,10 @@
package response
type AgentEvaluationResultResponse struct {
CaseID string `json:"caseId"`
CaseID string `json:"case_id"`
Category string `json:"category"`
Passed bool `json:"passed"`
ReplyText string `json:"replyText"`
ReplyText string `json:"reply_text"`
Interrupted bool `json:"interrupted"`
Error string `json:"error,omitempty"`
Finding string `json:"finding,omitempty"`
+24 -24
View File
@@ -11,30 +11,30 @@ type AgentUserOptionResponse struct {
type AgentProfileResponse struct {
ID int64 `json:"id"`
UserID int64 `json:"userId"`
TeamID int64 `json:"teamId"`
TeamName string `json:"teamName,omitempty"`
UserID int64 `json:"user_id"`
TeamID int64 `json:"team_id"`
TeamName string `json:"team_name,omitempty"`
Username string `json:"username,omitempty"`
Nickname string `json:"nickname,omitempty"`
AgentCode string `json:"agentCode"`
DisplayName string `json:"displayName"`
AgentCode string `json:"agent_code"`
DisplayName string `json:"display_name"`
Avatar string `json:"avatar"`
ServiceStatus enums.ServiceStatus `json:"serviceStatus"`
MaxConcurrentCount int `json:"maxConcurrentCount"`
PriorityLevel int `json:"priorityLevel"`
AutoAssignEnabled bool `json:"autoAssignEnabled"`
ReceiveOfflineMessage bool `json:"receiveOfflineMessage"`
LastOnlineAt string `json:"lastOnlineAt,omitempty"`
LastStatusAt string `json:"lastStatusAt,omitempty"`
ServiceStatus enums.ServiceStatus `json:"service_status"`
MaxConcurrentCount int `json:"max_concurrent_count"`
PriorityLevel int `json:"priority_level"`
AutoAssignEnabled bool `json:"auto_assign_enabled"`
ReceiveOfflineMessage bool `json:"receive_offline_message"`
LastOnlineAt string `json:"last_online_at,omitempty"`
LastStatusAt string `json:"last_status_at,omitempty"`
Remark string `json:"remark"`
}
type AgentTeamResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
LeaderUserID int64 `json:"leaderUserId"`
LeaderUsername string `json:"leaderUsername,omitempty"`
LeaderNickname string `json:"leaderNickname,omitempty"`
LeaderUserID int64 `json:"leader_user_id"`
LeaderUsername string `json:"leader_username,omitempty"`
LeaderNickname string `json:"leader_nickname,omitempty"`
Status enums.Status `json:"status"`
Description string `json:"description"`
Remark string `json:"remark"`
@@ -42,10 +42,10 @@ type AgentTeamResponse struct {
type AgentTeamScheduleResponse struct {
ID int64 `json:"id"`
TeamID int64 `json:"teamId"`
TeamName string `json:"teamName,omitempty"`
StartAt string `json:"startAt"`
EndAt string `json:"endAt"`
TeamID int64 `json:"team_id"`
TeamName string `json:"team_name,omitempty"`
StartAt string `json:"start_at"`
EndAt string `json:"end_at"`
Remark string `json:"remark"`
}
@@ -56,15 +56,15 @@ type AgentTeamScheduleBatchPreviewResponse struct {
}
type AgentTeamScheduleBatchPreviewItem struct {
TeamID int64 `json:"teamId"`
TeamName string `json:"teamName"`
TeamID int64 `json:"team_id"`
TeamName string `json:"team_name"`
Date string `json:"date"`
Weekday int `json:"weekday"`
StartAt string `json:"startAt"`
EndAt string `json:"endAt"`
StartAt string `json:"start_at"`
EndAt string `json:"end_at"`
Remark string `json:"remark"`
Conflict bool `json:"conflict"`
ConflictReason string `json:"conflictReason"`
ConflictReason string `json:"conflict_reason"`
}
type AgentTeamScheduleBatchGenerateResponse struct {
@@ -21,7 +21,7 @@ func TestAgentTeamScheduleResponseOmitsSourceType(t *testing.T) {
if err := json.Unmarshal(payload, &decoded); err != nil {
t.Fatalf("unmarshal response error = %v", err)
}
if _, ok := decoded["sourceType"]; ok {
t.Fatalf("sourceType should not be exposed: %s", payload)
if _, ok := decoded["source_type"]; ok {
t.Fatalf("source_type should not be exposed: %s", payload)
}
}
+39 -41
View File
@@ -4,62 +4,60 @@ import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type AgentRunResponse struct {
ID int64 `json:"id"`
ConversationID int64 `json:"conversationId"`
AIAgentID int64 `json:"aiAgentId"`
AgentRevisionID int64 `json:"agentRevisionId"`
SourceMessageID int64 `json:"sourceMessageId"`
WorkflowRunID int64 `json:"workflowRunId"`
ConversationID int64 `json:"conversation_id"`
AIAgentID int64 `json:"ai_agent_id"`
AgentRevisionID int64 `json:"agent_revision_id"`
SourceMessageID int64 `json:"source_message_id"`
Status string `json:"status"`
PromptTokens int `json:"promptTokens"`
CompletionTokens int `json:"completionTokens"`
StartedAt string `json:"startedAt"`
EndedAt string `json:"endedAt"`
DurationMS int64 `json:"durationMs"`
ErrorMessage string `json:"errorMessage"`
TraceData string `json:"traceData"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
StartedAt string `json:"started_at"`
EndedAt string `json:"ended_at"`
DurationMS int64 `json:"duration_ms"`
ErrorMessage string `json:"error_message"`
TraceData string `json:"trace_data"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Steps []AgentStepResponse `json:"steps,omitempty"`
ToolCalls []AgentToolCallResponse `json:"toolCalls,omitempty"`
QualityFeedback *AgentRunQualityFeedbackResponse `json:"qualityFeedback,omitempty"`
ToolCalls []AgentToolCallResponse `json:"tool_calls,omitempty"`
QualityFeedback *AgentRunQualityFeedbackResponse `json:"quality_feedback,omitempty"`
}
type AgentRunQualityFeedbackResponse struct {
ID int64 `json:"id"`
AgentRunID int64 `json:"agentRunId"`
ResolutionStatus enums.AgentRunResolutionStatus `json:"resolutionStatus"`
EvidenceStatus enums.AgentRunEvidenceStatus `json:"evidenceStatus"`
AgentRunID int64 `json:"agent_run_id"`
ResolutionStatus enums.AgentRunResolutionStatus `json:"resolution_status"`
EvidenceStatus enums.AgentRunEvidenceStatus `json:"evidence_status"`
Comment string `json:"comment"`
UpdateUserName string `json:"updateUserName"`
UpdatedAt string `json:"updatedAt"`
UpdateUserName string `json:"update_user_name"`
UpdatedAt string `json:"updated_at"`
}
type AgentStepResponse struct {
ID int64 `json:"id"`
AgentRunID int64 `json:"agentRunId"`
WorkflowRunID int64 `json:"workflowRunId"`
StepType string `json:"stepType"`
StepCode string `json:"stepCode"`
AgentRunID int64 `json:"agent_run_id"`
StepType string `json:"step_type"`
StepCode string `json:"step_code"`
Status string `json:"status"`
InputPreview string `json:"inputPreview"`
OutputPreview string `json:"outputPreview"`
ErrorMessage string `json:"errorMessage"`
StartedAt string `json:"startedAt"`
EndedAt string `json:"endedAt"`
DurationMS int `json:"durationMs"`
InputPreview string `json:"input_preview"`
OutputPreview string `json:"output_preview"`
ErrorMessage string `json:"error_message"`
StartedAt string `json:"started_at"`
EndedAt string `json:"ended_at"`
DurationMS int `json:"duration_ms"`
}
type AgentToolCallResponse struct {
ID int64 `json:"id"`
AgentRunID int64 `json:"agentRunId"`
AgentStepID int64 `json:"agentStepId"`
ToolCode string `json:"toolCode"`
RiskLevel string `json:"riskLevel"`
RequireConfirm bool `json:"requireConfirm"`
AgentRunID int64 `json:"agent_run_id"`
AgentStepID int64 `json:"agent_step_id"`
ToolCode string `json:"tool_code"`
RiskLevel string `json:"risk_level"`
RequireConfirm bool `json:"require_confirm"`
Status string `json:"status"`
ArgumentsPreview string `json:"argumentsPreview"`
ResultPreview string `json:"resultPreview"`
ErrorMessage string `json:"errorMessage"`
DurationMS int `json:"durationMs"`
CreatedAt string `json:"createdAt"`
ArgumentsPreview string `json:"arguments_preview"`
ResultPreview string `json:"result_preview"`
ErrorMessage string `json:"error_message"`
DurationMS int `json:"duration_ms"`
CreatedAt string `json:"created_at"`
}
+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"`
}
+23 -4
View File
@@ -21,10 +21,29 @@ func TestBuildAIConfigResponseOmitsAPIKey(t *testing.T) {
if err := json.Unmarshal(payload, &decoded); err != nil {
t.Fatalf("unmarshal response error = %v", err)
}
if _, ok := decoded["apiKey"]; ok {
t.Fatalf("apiKey should not be exposed: %s", payload)
if _, ok := decoded["api_key"]; ok {
t.Fatalf("api_key should not be exposed: %s", payload)
}
if got, ok := decoded["hasApiKey"].(bool); !ok || !got {
t.Fatalf("hasApiKey = %v, want true: %s", decoded["hasApiKey"], payload)
if got, ok := decoded["has_api_key"].(bool); !ok || !got {
t.Fatalf("has_api_key = %v, want true: %s", decoded["has_api_key"], payload)
}
}
func TestBuildAIConfigDetailResponseIncludesAPIKey(t *testing.T) {
payload, err := json.Marshal(BuildAIConfigDetailResponse(&models.AIConfig{
ID: 1,
Name: "test",
APIKey: "sk-secret",
}))
if err != nil {
t.Fatalf("marshal response error = %v", err)
}
var decoded map[string]any
if err := json.Unmarshal(payload, &decoded); err != nil {
t.Fatalf("unmarshal response error = %v", err)
}
if got := decoded["api_key"]; got != "sk-secret" {
t.Fatalf("api_key = %v, want sk-secret: %s", got, payload)
}
}
@@ -1,111 +0,0 @@
package response
import (
"code.tczkiot.com/wlw/ai-agent/internal/ai/workflow/dsl"
workflowregistry "code.tczkiot.com/wlw/ai-agent/internal/ai/workflow/registry"
workflowvalidator "code.tczkiot.com/wlw/ai-agent/internal/ai/workflow/validator"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
)
type AIWorkflowResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Status enums.Status `json:"status"`
DraftDefinition dsl.Definition `json:"draftDefinition"`
PublishedVersionID int64 `json:"publishedVersionId"`
SortNo int `json:"sortNo"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
}
type AIWorkflowVersionResponse struct {
ID int64 `json:"id"`
WorkflowID int64 `json:"workflowId"`
Version int `json:"version"`
Status enums.Status `json:"status"`
Definition dsl.Definition `json:"definition"`
DefinitionHash string `json:"definitionHash"`
PublishedAt string `json:"publishedAt"`
PublishedByID int64 `json:"publishedById"`
PublishedByName string `json:"publishedByName"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type AIWorkflowValidationResponse struct {
Valid bool `json:"valid"`
Errors []workflowvalidator.Error `json:"errors"`
}
type AIWorkflowTemplateResponse struct {
Code string `json:"code"`
Name string `json:"name"`
Description string `json:"description"`
Definition dsl.Definition `json:"definition"`
}
type AIWorkflowUsageResponse struct {
AIAgentID int64 `json:"aiAgentId"`
AIAgentName string `json:"aiAgentName"`
WorkflowVersionID int64 `json:"workflowVersionId"`
WorkflowVersion int `json:"workflowVersion"`
Enabled bool `json:"enabled"`
}
type AIWorkflowNodeSpecResponse struct {
Type string `json:"type"`
Title string `json:"title"`
Description string `json:"description"`
Icon string `json:"icon"`
Category string `json:"category"`
Executable bool `json:"executable"`
RiskLevel workflowregistry.NodeRiskLevel `json:"riskLevel"`
Interruptible bool `json:"interruptible"`
RequiresConfirmationPredecessor bool `json:"requiresConfirmationPredecessor"`
ConfigSchema any `json:"configSchema,omitempty"`
InputSchema []workflowregistry.VariableSpec `json:"inputSchema,omitempty"`
OutputSchema []workflowregistry.VariableSpec `json:"outputSchema,omitempty"`
DefaultInputs map[string]dsl.Value `json:"defaultInputs,omitempty"`
}
type AIWorkflowRunResponse struct {
ID int64 `json:"id"`
WorkflowID int64 `json:"workflowId"`
WorkflowVersionID int64 `json:"workflowVersionId"`
WorkflowVersion int `json:"workflowVersion"`
WorkflowName string `json:"workflowName"`
ConversationID int64 `json:"conversationId"`
AIAgentID int64 `json:"aiAgentId"`
AIAgentName string `json:"aiAgentName"`
MessageID int64 `json:"messageId"`
Status int `json:"status"`
StatusName string `json:"statusName"`
StartedAt string `json:"startedAt"`
EndedAt string `json:"endedAt"`
DurationMS int64 `json:"durationMs"`
InterruptType string `json:"interruptType"`
InterruptNodeID string `json:"interruptNodeId"`
ErrorMessage string `json:"errorMessage"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Definition dsl.Definition `json:"definition"`
Nodes []AIWorkflowNodeRunResponse `json:"nodes,omitempty"`
}
type AIWorkflowNodeRunResponse struct {
ID int64 `json:"id"`
WorkflowRunID int64 `json:"workflowRunId"`
NodeID string `json:"nodeId"`
NodeType string `json:"nodeType"`
Status int `json:"status"`
StatusName string `json:"statusName"`
InputPreview string `json:"inputPreview"`
OutputPreview string `json:"outputPreview"`
ErrorMessage string `json:"errorMessage"`
StartedAt string `json:"startedAt"`
EndedAt string `json:"endedAt"`
DurationMS int `json:"durationMs"`
}
+10 -10
View File
@@ -4,18 +4,18 @@ import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type AssetResponse struct {
ID int64 `json:"id"`
AssetID string `json:"assetId"`
AssetID string `json:"asset_id"`
Provider enums.AssetProvider `json:"provider"`
Filename string `json:"filename"`
FileSize int64 `json:"fileSize"`
MimeType string `json:"mimeType"`
FileSize int64 `json:"file_size"`
MimeType string `json:"mime_type"`
Status enums.AssetStatus `json:"status"`
StorageKey string `json:"storageKey"`
StorageKey string `json:"storage_key"`
URL string `json:"url"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
CreateUserID int64 `json:"createUserId"`
CreateUserName string `json:"createUserName"`
UpdateUserID int64 `json:"updateUserId"`
UpdateUserName string `json:"updateUserName"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
CreateUserID int64 `json:"create_user_id"`
CreateUserName string `json:"create_user_name"`
UpdateUserID int64 `json:"update_user_id"`
UpdateUserName string `json:"update_user_name"`
}
+21 -21
View File
@@ -8,40 +8,40 @@ import (
type ChannelResponse struct {
ID int64 `json:"id"`
ChannelType string `json:"channelType"`
ChannelID string `json:"channelId"`
AIAgentID int64 `json:"aiAgentId"`
AIAgentRolloutPercent int `json:"aiAgentRolloutPercent"`
PreviousAIAgentRolloutPercent int `json:"previousAiAgentRolloutPercent"`
AIAgentName string `json:"aiAgentName,omitempty"`
ChannelType string `json:"channel_type"`
ChannelID string `json:"channel_id"`
AIAgentID int64 `json:"ai_agent_id"`
AIAgentRolloutPercent int `json:"ai_agent_rollout_percent"`
PreviousAIAgentRolloutPercent int `json:"previous_ai_agent_rollout_percent"`
AIAgentName string `json:"ai_agent_name,omitempty"`
Name string `json:"name"`
ConfigJSON string `json:"configJson"`
ConfigJSON string `json:"config_json"`
Status enums.Status `json:"status"`
Remark string `json:"remark"`
}
type WxWorkKFAccountResponse struct {
OpenKfID string `json:"openKfId"`
OpenKfID string `json:"open_kf_id"`
Name string `json:"name"`
Avatar string `json:"avatar"`
ManagePrivilege bool `json:"managePrivilege"`
ManagePrivilege bool `json:"manage_privilege"`
}
type ChannelMessageOutboxResponse struct {
ID int64 `json:"id"`
ChannelType string `json:"channelType"`
ConversationID int64 `json:"conversationId"`
MessageID int64 `json:"messageId"`
ChannelType string `json:"channel_type"`
ConversationID int64 `json:"conversation_id"`
MessageID int64 `json:"message_id"`
Payload string `json:"payload"`
SendStatus string `json:"sendStatus"`
RetryCount int `json:"retryCount"`
NextRetryAt string `json:"nextRetryAt"`
LastError string `json:"lastError"`
SentAt string `json:"sentAt"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
SendStatus string `json:"send_status"`
RetryCount int `json:"retry_count"`
NextRetryAt string `json:"next_retry_at"`
LastError string `json:"last_error"`
SentAt string `json:"sent_at"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
func BuildChannelResponse(item *models.Channel) ChannelResponse {
@@ -1,14 +0,0 @@
package response
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type CompanyResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Code string `json:"code"`
CustomerCount int64 `json:"customerCount"`
Status enums.Status `json:"status"`
Remark string `json:"remark"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
@@ -2,49 +2,55 @@ package response
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type ConversationTagResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
}
type ConversationParticipantResponse struct {
ID int64 `json:"id"`
ParticipantType string `json:"participantType"`
ParticipantID int64 `json:"participantId"`
ExternalParticipantID string `json:"externalParticipantId,omitempty"`
JoinedAt string `json:"joinedAt,omitempty"`
LeftAt string `json:"leftAt,omitempty"`
ParticipantType string `json:"participant_type"`
ParticipantID int64 `json:"participant_id"`
ExternalParticipantID string `json:"external_participant_id,omitempty"`
JoinedAt string `json:"joined_at,omitempty"`
LeftAt string `json:"left_at,omitempty"`
Status enums.Status `json:"status"`
}
type ConversationResponse struct {
ID int64 `json:"id"`
AIAgentID int64 `json:"aiAgentId"`
ChannelID int64 `json:"channelId"`
CustomerID int64 `json:"customerId"`
CustomerName string `json:"customerName"`
AIAgentID int64 `json:"ai_agent_id"`
ChannelID int64 `json:"channel_id"`
CustomerType string `json:"customer_type"`
CustomerID int64 `json:"customer_id"`
CustomerExternalID string `json:"customer_external_id"`
CustomerName string `json:"customer_name"`
Status enums.IMConversationStatus `json:"status"`
ServiceMode enums.IMConversationServiceMode `json:"serviceMode"`
ServiceMode enums.IMConversationServiceMode `json:"service_mode"`
Priority int `json:"priority"`
CurrentAssigneeID int64 `json:"currentAssigneeId"`
CurrentAssigneeName string `json:"currentAssigneeName,omitempty"`
CurrentTeamID int64 `json:"currentTeamId"`
CurrentTeamName string `json:"currentTeamName,omitempty"`
LastMessageID int64 `json:"lastMessageId"`
LastMessageAt string `json:"lastMessageAt,omitempty"`
LastActiveAt string `json:"lastActiveAt,omitempty"`
LastMessageSummary string `json:"lastMessageSummary,omitempty"`
CustomerUnreadCount int `json:"customerUnreadCount"`
AgentUnreadCount int `json:"agentUnreadCount"`
CustomerLastReadMessageID int64 `json:"customerLastReadMessageId"`
CustomerLastReadAt string `json:"customerLastReadAt,omitempty"`
AgentLastReadMessageID int64 `json:"agentLastReadMessageId"`
AgentLastReadAt string `json:"agentLastReadAt,omitempty"`
CustomerOnline bool `json:"customerOnline"`
ClosedAt string `json:"closedAt,omitempty"`
ClosedBy int64 `json:"closedBy"`
ClosedByName string `json:"closedByName,omitempty"`
CloseReason string `json:"closeReason,omitempty"`
CurrentAssigneeID int64 `json:"current_assignee_id"`
CurrentAssigneeName string `json:"current_assignee_name,omitempty"`
CurrentTeamID int64 `json:"current_team_id"`
CurrentTeamName string `json:"current_team_name,omitempty"`
LastMessageID int64 `json:"last_message_id"`
LastMessageAt string `json:"last_message_at,omitempty"`
LastActiveAt string `json:"last_active_at,omitempty"`
LastMessageSummary string `json:"last_message_summary,omitempty"`
CustomerUnreadCount int `json:"customer_unread_count"`
AgentUnreadCount int `json:"agent_unread_count"`
CustomerLastReadMessageID int64 `json:"customer_last_read_message_id"`
CustomerLastReadAt string `json:"customer_last_read_at,omitempty"`
AgentLastReadMessageID int64 `json:"agent_last_read_message_id"`
AgentLastReadAt string `json:"agent_last_read_at,omitempty"`
CustomerOnline bool `json:"customer_online"`
QueueEnteredAt string `json:"queue_entered_at,omitempty"`
QueuePosition int `json:"queue_position"`
QueueAheadCount int `json:"queue_ahead_count"`
QueueWaitingCount int `json:"queue_waiting_count"`
QueueWaitSeconds int64 `json:"queue_wait_seconds"`
QueueEstimatedWaitSeconds int64 `json:"queue_estimated_wait_seconds"`
QueueEscalationLevel int `json:"queue_escalation_level"`
EffectivePriority int `json:"effective_priority"`
QueueServiceOnline bool `json:"queue_service_online"`
ClosedAt string `json:"closed_at,omitempty"`
ClosedBy int64 `json:"closed_by"`
ClosedByName string `json:"closed_by_name,omitempty"`
CloseReason string `json:"close_reason,omitempty"`
}
type ConversationDetailResponse struct {
@@ -1,18 +0,0 @@
package response
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type CustomerContactResponse struct {
ID int64 `json:"id"`
CustomerID int64 `json:"customerId"`
ContactType enums.ContactType `json:"contactType"`
ContactValue string `json:"contactValue"`
IsPrimary bool `json:"isPrimary"`
IsVerified bool `json:"isVerified"`
VerifiedAt string `json:"verifiedAt,omitempty"`
Source string `json:"source"`
Status enums.Status `json:"status"`
Remark string `json:"remark"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
@@ -0,0 +1,12 @@
package response
type CustomerQuickActionResponse struct {
Code string `json:"code"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
}
type CustomerQuickActionExecutionResponse struct {
CustomerMessage MessageResponse `json:"customer_message"`
ReplyMessage MessageResponse `json:"reply_message"`
}
@@ -1,18 +0,0 @@
package response
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type CustomerResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Gender enums.Gender `json:"gender"`
CompanyID int64 `json:"companyId"`
Company *CompanyResponse `json:"company"`
LastActiveAt string `json:"lastActiveAt"`
PrimaryMobile string `json:"primaryMobile"`
PrimaryEmail string `json:"primaryEmail"`
Status enums.Status `json:"status"`
Remark string `json:"remark"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
+35 -35
View File
@@ -2,25 +2,25 @@ package response
type DashboardOverviewResponse struct {
Range string `json:"range"`
GeneratedAt string `json:"generatedAt"`
GeneratedAt string `json:"generated_at"`
Summary DashboardSummaryResponse `json:"summary"`
ConversationStats DashboardSectionStatsResponse `json:"conversationStats"`
AgentStats DashboardAgentStatsResponse `json:"agentStats"`
AIStats DashboardAIStatsResponse `json:"aiStats"`
ConversationStats DashboardSectionStatsResponse `json:"conversation_stats"`
AgentStats DashboardAgentStatsResponse `json:"agent_stats"`
AIStats DashboardAIStatsResponse `json:"ai_stats"`
Alerts []DashboardAlertResponse `json:"alerts"`
QuickLinks []DashboardQuickLinkResponse `json:"quickLinks"`
QuickLinks []DashboardQuickLinkResponse `json:"quick_links"`
}
type DashboardSummaryResponse struct {
TodayNewConversations int64 `json:"todayNewConversations"`
ProcessingConversations int64 `json:"processingConversations"`
PendingDispatchConversations int64 `json:"pendingDispatchConversations"`
OnlineAgents int64 `json:"onlineAgents"`
AIServiceRate float64 `json:"aiServiceRate"`
TodayNewConversations int64 `json:"today_new_conversations"`
ProcessingConversations int64 `json:"processing_conversations"`
PendingDispatchConversations int64 `json:"pending_dispatch_conversations"`
OnlineAgents int64 `json:"online_agents"`
AIServiceRate float64 `json:"ai_service_rate"`
}
type DashboardSectionStatsResponse struct {
StatusDistribution []DashboardStatusDistributionItem `json:"statusDistribution"`
StatusDistribution []DashboardStatusDistributionItem `json:"status_distribution"`
Trend []DashboardTrendItem `json:"trend"`
}
@@ -32,39 +32,39 @@ type DashboardStatusDistributionItem struct {
type DashboardTrendItem struct {
Date string `json:"date"`
NewCount int64 `json:"newCount"`
ClosedCount int64 `json:"closedCount"`
NewCount int64 `json:"new_count"`
ClosedCount int64 `json:"closed_count"`
}
type DashboardAgentStatsResponse struct {
OnlineAgents int64 `json:"onlineAgents"`
BusyAgents int64 `json:"busyAgents"`
OfflineAgents int64 `json:"offlineAgents"`
TeamLoads []DashboardTeamLoadResponse `json:"teamLoads"`
OnlineAgents int64 `json:"online_agents"`
BusyAgents int64 `json:"busy_agents"`
OfflineAgents int64 `json:"offline_agents"`
TeamLoads []DashboardTeamLoadResponse `json:"team_loads"`
}
type DashboardTeamLoadResponse struct {
TeamID int64 `json:"teamId"`
TeamName string `json:"teamName"`
TotalAgents int64 `json:"totalAgents"`
OnlineAgents int64 `json:"onlineAgents"`
BusyAgents int64 `json:"busyAgents"`
OfflineAgents int64 `json:"offlineAgents"`
WaitingConversations int64 `json:"waitingConversations"`
ProcessingConversations int64 `json:"processingConversations"`
MaxConcurrentCapacity int64 `json:"maxConcurrentCapacity"`
LoadRate float64 `json:"loadRate"`
HasScheduleNow bool `json:"hasScheduleNow"`
TeamID int64 `json:"team_id"`
TeamName string `json:"team_name"`
TotalAgents int64 `json:"total_agents"`
OnlineAgents int64 `json:"online_agents"`
BusyAgents int64 `json:"busy_agents"`
OfflineAgents int64 `json:"offline_agents"`
WaitingConversations int64 `json:"waiting_conversations"`
ProcessingConversations int64 `json:"processing_conversations"`
MaxConcurrentCapacity int64 `json:"max_concurrent_capacity"`
LoadRate float64 `json:"load_rate"`
HasScheduleNow bool `json:"has_schedule_now"`
}
type DashboardAIStatsResponse struct {
EnabledAIAgents int64 `json:"enabledAiAgents"`
EnabledChannels int64 `json:"enabledChannels"`
TodayKnowledgeRetrieves int64 `json:"todayKnowledgeRetrieves"`
TodayKnowledgeRetrieveFailCount int64 `json:"todayKnowledgeRetrieveFailCount"`
TodayKnowledgeRetrieveFailRate float64 `json:"todayKnowledgeRetrieveFailRate"`
TodayAgentRunFailCount int64 `json:"todayAgentRunFailCount"`
TodayAIHandoffCount int64 `json:"todayAiHandoffCount"`
EnabledAIAgents int64 `json:"enabled_ai_agents"`
EnabledChannels int64 `json:"enabled_channels"`
TodayKnowledgeRetrieves int64 `json:"today_knowledge_retrieves"`
TodayKnowledgeRetrieveFailCount int64 `json:"today_knowledge_retrieve_fail_count"`
TodayKnowledgeRetrieveFailRate float64 `json:"today_knowledge_retrieve_fail_rate"`
TodayAgentRunFailCount int64 `json:"today_agent_run_fail_count"`
TodayAIHandoffCount int64 `json:"today_ai_handoff_count"`
}
type DashboardAlertResponse struct {
@@ -0,0 +1,40 @@
package response
import (
"go/ast"
"go/parser"
"go/token"
"reflect"
"strings"
"testing"
"unicode"
)
func TestPublicResponseJSONTagsUseSnakeCase(t *testing.T) {
packages, err := parser.ParseDir(token.NewFileSet(), ".", nil, 0)
if err != nil {
t.Fatalf("parse response package: %v", err)
}
pkg := packages["response"]
if pkg == nil {
t.Fatal("response package not found")
}
for filename, file := range pkg.Files {
ast.Inspect(file, func(node ast.Node) bool {
field, ok := node.(*ast.Field)
if !ok || field.Tag == nil {
return true
}
tag := reflect.StructTag(strings.Trim(field.Tag.Value, "`"))
name := strings.Split(tag.Get("json"), ",")[0]
for _, char := range name {
if unicode.IsUpper(char) {
t.Errorf("%s has non-snake-case JSON tag %q", filename, name)
break
}
}
return true
})
}
}
+153 -153
View File
@@ -9,109 +9,109 @@ type KnowledgeBaseResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
KnowledgeType string `json:"knowledgeType"`
KnowledgeTypeName string `json:"knowledgeTypeName"`
KnowledgeType string `json:"knowledge_type"`
KnowledgeTypeName string `json:"knowledge_type_name"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
DefaultTopK int `json:"defaultTopK"`
DefaultScoreThreshold float64 `json:"defaultScoreThreshold"`
DefaultRerankLimit int `json:"defaultRerankLimit"`
ChunkProvider string `json:"chunkProvider"`
ChunkTargetTokens int `json:"chunkTargetTokens"`
ChunkMaxTokens int `json:"chunkMaxTokens"`
ChunkOverlapTokens int `json:"chunkOverlapTokens"`
AnswerMode int `json:"answerMode"`
AnswerModeName string `json:"answerModeName"`
DocumentCount int64 `json:"documentCount"`
FAQCount int64 `json:"faqCount"`
StatusName string `json:"status_name"`
DefaultTopK int `json:"default_top_k"`
DefaultScoreThreshold float64 `json:"default_score_threshold"`
DefaultRerankLimit int `json:"default_rerank_limit"`
ChunkProvider string `json:"chunk_provider"`
ChunkTargetTokens int `json:"chunk_target_tokens"`
ChunkMaxTokens int `json:"chunk_max_tokens"`
ChunkOverlapTokens int `json:"chunk_overlap_tokens"`
AnswerMode int `json:"answer_mode"`
AnswerModeName string `json:"answer_mode_name"`
DocumentCount int64 `json:"document_count"`
FAQCount int64 `json:"faq_count"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
type KnowledgeDocumentResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
DirectoryID int64 `json:"directoryId"`
DirectoryName string `json:"directoryName,omitempty"`
DirectoryPath string `json:"directoryPath,omitempty"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
DirectoryID int64 `json:"directory_id"`
DirectoryName string `json:"directory_name,omitempty"`
DirectoryPath string `json:"directory_path,omitempty"`
Title string `json:"title"`
ContentType enums.KnowledgeDocumentContentType `json:"contentType"`
ContentType enums.KnowledgeDocumentContentType `json:"content_type"`
Content string `json:"content"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"indexStatus"`
IndexStatusName string `json:"indexStatusName"`
IndexedAt *time.Time `json:"indexedAt"`
IndexError string `json:"indexError"`
ContentHash string `json:"contentHash"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
StatusName string `json:"status_name"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"index_status"`
IndexStatusName string `json:"index_status_name"`
IndexedAt *time.Time `json:"indexed_at"`
IndexError string `json:"index_error"`
ContentHash string `json:"content_hash"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
type KnowledgeDocumentListResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
DirectoryID int64 `json:"directoryId"`
DirectoryName string `json:"directoryName,omitempty"`
DirectoryPath string `json:"directoryPath,omitempty"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
DirectoryID int64 `json:"directory_id"`
DirectoryName string `json:"directory_name,omitempty"`
DirectoryPath string `json:"directory_path,omitempty"`
Title string `json:"title"`
ContentType enums.KnowledgeDocumentContentType `json:"contentType"`
ContentType enums.KnowledgeDocumentContentType `json:"content_type"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"indexStatus"`
IndexStatusName string `json:"indexStatusName"`
IndexedAt *time.Time `json:"indexedAt"`
IndexError string `json:"indexError"`
ContentHash string `json:"contentHash"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
StatusName string `json:"status_name"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"index_status"`
IndexStatusName string `json:"index_status_name"`
IndexedAt *time.Time `json:"indexed_at"`
IndexError string `json:"index_error"`
ContentHash string `json:"content_hash"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
type KnowledgeFAQResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
DirectoryID int64 `json:"directoryId"`
DirectoryName string `json:"directoryName,omitempty"`
DirectoryPath string `json:"directoryPath,omitempty"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
DirectoryID int64 `json:"directory_id"`
DirectoryName string `json:"directory_name,omitempty"`
DirectoryPath string `json:"directory_path,omitempty"`
Question string `json:"question"`
Answer string `json:"answer"`
SimilarQuestions []string `json:"similarQuestions"`
SimilarQuestions []string `json:"similar_questions"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"indexStatus"`
IndexStatusName string `json:"indexStatusName"`
IndexedAt *time.Time `json:"indexedAt"`
IndexError string `json:"indexError"`
StatusName string `json:"status_name"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"index_status"`
IndexStatusName string `json:"index_status_name"`
IndexedAt *time.Time `json:"indexed_at"`
IndexError string `json:"index_error"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
type KnowledgeDirectoryResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
ParentID int64 `json:"parentId"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
ParentID int64 `json:"parent_id"`
Name string `json:"name"`
SortNo int `json:"sortNo"`
SortNo int `json:"sort_no"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
StatusName string `json:"status_name"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
Children []KnowledgeDirectoryResponse `json:"children"`
}
@@ -136,116 +136,116 @@ type KnowledgeFAQImportResult struct {
}
type KnowledgeSearchResult struct {
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
ChunkID int64 `json:"chunkId"`
DocumentID int64 `json:"documentId"`
DocumentTitle string `json:"documentTitle"`
FaqID int64 `json:"faqId"`
FaqQuestion string `json:"faqQuestion"`
ChunkNo int `json:"chunkNo"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
ChunkID int64 `json:"chunk_id"`
DocumentID int64 `json:"document_id"`
DocumentTitle string `json:"document_title"`
FaqID int64 `json:"faq_id"`
FaqQuestion string `json:"faq_question"`
ChunkNo int `json:"chunk_no"`
Title string `json:"title"`
SectionPath string `json:"sectionPath"`
SectionPath string `json:"section_path"`
Content string `json:"content"`
Score float64 `json:"score"`
RerankScore float64 `json:"rerankScore"`
RerankScore float64 `json:"rerank_score"`
}
type KnowledgeSearchResponse struct {
Question string `json:"question"`
Results []KnowledgeSearchResult `json:"results"`
HitCount int `json:"hitCount"`
LatencyMs int64 `json:"latencyMs"`
HitCount int `json:"hit_count"`
LatencyMs int64 `json:"latency_ms"`
}
type KnowledgeAnswerResponse struct {
Question string `json:"question"`
RewriteQuestion string `json:"rewriteQuestion,omitempty"`
RewriteQuestion string `json:"rewrite_question,omitempty"`
Answer string `json:"answer"`
AnswerStatus int `json:"answerStatus"`
AnswerStatusName string `json:"answerStatusName"`
AnswerStatus int `json:"answer_status"`
AnswerStatusName string `json:"answer_status_name"`
Citations []KnowledgeCitation `json:"citations"`
Hits []KnowledgeSearchResult `json:"hits"`
HitCount int `json:"hitCount"`
TopScore float64 `json:"topScore"`
LatencyMs int64 `json:"latencyMs"`
RetrieveMs int64 `json:"retrieveMs"`
GenerateMs int64 `json:"generateMs"`
PromptTokens int `json:"promptTokens"`
CompletionTokens int `json:"completionTokens"`
ModelName string `json:"modelName"`
RetrieveLogID int64 `json:"retrieveLogId"`
HitCount int `json:"hit_count"`
TopScore float64 `json:"top_score"`
LatencyMs int64 `json:"latency_ms"`
RetrieveMs int64 `json:"retrieve_ms"`
GenerateMs int64 `json:"generate_ms"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
ModelName string `json:"model_name"`
RetrieveLogID int64 `json:"retrieve_log_id"`
}
type KnowledgeCitation struct {
DocumentID int64 `json:"documentId"`
DocumentTitle string `json:"documentTitle"`
FaqID int64 `json:"faqId"`
FaqQuestion string `json:"faqQuestion"`
ChunkNo int `json:"chunkNo"`
DocumentID int64 `json:"document_id"`
DocumentTitle string `json:"document_title"`
FaqID int64 `json:"faq_id"`
FaqQuestion string `json:"faq_question"`
ChunkNo int `json:"chunk_no"`
Title string `json:"title"`
SectionPath string `json:"sectionPath"`
SectionPath string `json:"section_path"`
Snippet string `json:"snippet"`
Score float64 `json:"score"`
}
type KnowledgeRetrieveLogResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
Channel string `json:"channel"`
ChannelName string `json:"channelName"`
ChannelName string `json:"channel_name"`
Scene string `json:"scene"`
SceneName string `json:"sceneName"`
SessionID string `json:"sessionId"`
ConversationID int64 `json:"conversationId"`
RequestID string `json:"requestId"`
SceneName string `json:"scene_name"`
SessionID string `json:"session_id"`
ConversationID int64 `json:"conversation_id"`
RequestID string `json:"request_id"`
Question string `json:"question"`
RewriteQuestion string `json:"rewriteQuestion"`
RewriteQuestion string `json:"rewrite_question"`
Answer string `json:"answer"`
AnswerStatus int `json:"answerStatus"`
AnswerStatusName string `json:"answerStatusName"`
HitCount int `json:"hitCount"`
TopScore float64 `json:"topScore"`
ChunkProvider string `json:"chunkProvider"`
ChunkTargetTokens int `json:"chunkTargetTokens"`
ChunkMaxTokens int `json:"chunkMaxTokens"`
ChunkOverlapTokens int `json:"chunkOverlapTokens"`
RerankEnabled bool `json:"rerankEnabled"`
RerankLimit int `json:"rerankLimit"`
CitationCount int `json:"citationCount"`
UsedChunkCount int `json:"usedChunkCount"`
LatencyMs int64 `json:"latencyMs"`
RetrieveMs int64 `json:"retrieveMs"`
GenerateMs int64 `json:"generateMs"`
PromptTokens int `json:"promptTokens"`
CompletionTokens int `json:"completionTokens"`
ModelName string `json:"modelName"`
TraceData string `json:"traceData"`
CreatedAt time.Time `json:"createdAt"`
AnswerStatus int `json:"answer_status"`
AnswerStatusName string `json:"answer_status_name"`
HitCount int `json:"hit_count"`
TopScore float64 `json:"top_score"`
ChunkProvider string `json:"chunk_provider"`
ChunkTargetTokens int `json:"chunk_target_tokens"`
ChunkMaxTokens int `json:"chunk_max_tokens"`
ChunkOverlapTokens int `json:"chunk_overlap_tokens"`
RerankEnabled bool `json:"rerank_enabled"`
RerankLimit int `json:"rerank_limit"`
CitationCount int `json:"citation_count"`
UsedChunkCount int `json:"used_chunk_count"`
LatencyMs int64 `json:"latency_ms"`
RetrieveMs int64 `json:"retrieve_ms"`
GenerateMs int64 `json:"generate_ms"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
ModelName string `json:"model_name"`
TraceData string `json:"trace_data"`
CreatedAt time.Time `json:"created_at"`
}
type KnowledgeRetrieveHitResponse struct {
ID int64 `json:"id"`
RetrieveLogID int64 `json:"retrieveLogId"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
ChunkID int64 `json:"chunkId"`
DocumentID int64 `json:"documentId"`
DocumentTitle string `json:"documentTitle"`
FaqID int64 `json:"faqId"`
FaqQuestion string `json:"faqQuestion"`
ChunkNo int `json:"chunkNo"`
RetrieveLogID int64 `json:"retrieve_log_id"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
ChunkID int64 `json:"chunk_id"`
DocumentID int64 `json:"document_id"`
DocumentTitle string `json:"document_title"`
FaqID int64 `json:"faq_id"`
FaqQuestion string `json:"faq_question"`
ChunkNo int `json:"chunk_no"`
Title string `json:"title"`
SectionPath string `json:"sectionPath"`
ChunkType string `json:"chunkType"`
ChunkTypeName string `json:"chunkTypeName"`
SectionPath string `json:"section_path"`
ChunkType string `json:"chunk_type"`
ChunkTypeName string `json:"chunk_type_name"`
Provider string `json:"provider"`
RankNo int `json:"rankNo"`
RankNo int `json:"rank_no"`
Score float64 `json:"score"`
RerankScore float64 `json:"rerankScore"`
UsedInAnswer bool `json:"usedInAnswer"`
IsCitation bool `json:"isCitation"`
RerankScore float64 `json:"rerank_score"`
UsedInAnswer bool `json:"used_in_answer"`
IsCitation bool `json:"is_citation"`
Snippet string `json:"snippet"`
CreatedAt time.Time `json:"createdAt"`
CreatedAt time.Time `json:"created_at"`
}
type KnowledgeRetrieveLogDetailResponse struct {
@@ -255,12 +255,12 @@ type KnowledgeRetrieveLogDetailResponse struct {
type KnowledgeFeedbackResponse struct {
ID int64 `json:"id"`
RetrieveLogID int64 `json:"retrieveLogId"`
FeedbackType int `json:"feedbackType"`
FeedbackTypeName string `json:"feedbackTypeName"`
FeedbackReason string `json:"feedbackReason"`
UserID int64 `json:"userId"`
AgentID int64 `json:"agentId"`
RetrieveLogID int64 `json:"retrieve_log_id"`
FeedbackType int `json:"feedback_type"`
FeedbackTypeName string `json:"feedback_type_name"`
FeedbackReason string `json:"feedback_reason"`
UserID int64 `json:"user_id"`
AgentID int64 `json:"agent_id"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
CreatedAt time.Time `json:"created_at"`
}
-121
View File
@@ -1,121 +0,0 @@
package response
import (
"code.tczkiot.com/wlw/ai-agent/internal/ai/mcps"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
)
type MCPConnectionResponse struct {
ServerCode string `json:"serverCode"`
Endpoint string `json:"endpoint"`
Protocol string `json:"protocol"`
ServerName string `json:"serverName"`
Version string `json:"version"`
}
func BuildMCPConnectionResponse(item *mcps.ConnectionResult) *MCPConnectionResponse {
if item == nil {
return nil
}
return &MCPConnectionResponse{
ServerCode: item.ServerCode,
Endpoint: item.Endpoint,
Protocol: item.Protocol,
ServerName: item.ServerName,
Version: item.Version,
}
}
type MCPServerInfoResponse struct {
Code string `json:"code"`
Enabled bool `json:"enabled"`
Endpoint string `json:"endpoint"`
TimeoutMS int `json:"timeoutMs"`
}
func BuildMCPServerInfoResponses(items []mcps.ServerInfo) []MCPServerInfoResponse {
ret := make([]MCPServerInfoResponse, 0, len(items))
for _, item := range items {
ret = append(ret, MCPServerInfoResponse{
Code: item.Code,
Enabled: item.Enabled,
Endpoint: item.Endpoint,
TimeoutMS: item.TimeoutMS,
})
}
return ret
}
type MCPToolInfoResponse struct {
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description"`
InputSchema any `json:"inputSchema"`
OutputSchema any `json:"outputSchema,omitempty"`
ReadOnlyHint bool `json:"readOnlyHint"`
}
func BuildMCPToolInfoResponses(items []mcps.ToolInfo) []MCPToolInfoResponse {
ret := make([]MCPToolInfoResponse, 0, len(items))
for _, item := range items {
ret = append(ret, MCPToolInfoResponse{
Name: item.Name,
Title: item.Title,
Description: item.Description,
InputSchema: item.InputSchema,
OutputSchema: item.OutputSchema,
ReadOnlyHint: item.ReadOnlyHint,
})
}
return ret
}
type MCPToolCatalogResponse struct {
ToolCode string `json:"toolCode"`
ServerCode string `json:"serverCode"`
ToolName string `json:"toolName"`
SourceType enums.ToolSourceType `json:"sourceType"`
AutoInjected bool `json:"autoInjected"`
Title string `json:"title"`
Description string `json:"description"`
InputSchema any `json:"inputSchema"`
OutputSchema any `json:"outputSchema,omitempty"`
RiskLevel string `json:"riskLevel"`
RequireConfirmation bool `json:"requireConfirmation"`
RiskEditable bool `json:"riskEditable"`
}
type MCPToolResultContentResponse struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Data any `json:"data,omitempty"`
}
type MCPCallToolResponse struct {
ServerCode string `json:"serverCode"`
ToolName string `json:"toolName"`
IsError bool `json:"isError"`
Content []MCPToolResultContentResponse `json:"content"`
StructuredContent any `json:"structuredContent,omitempty"`
}
func BuildMCPCallToolResponse(item *mcps.ToolCallResult) *MCPCallToolResponse {
if item == nil {
return nil
}
content := make([]MCPToolResultContentResponse, 0, len(item.Content))
for _, c := range item.Content {
content = append(content, MCPToolResultContentResponse{
Type: c.Type,
Text: c.Text,
Data: c.Data,
})
}
return &MCPCallToolResponse{
ServerCode: item.ServerCode,
ToolName: item.ToolName,
IsError: item.IsError,
Content: content,
StructuredContent: item.StructuredContent,
}
}
+18 -19
View File
@@ -4,25 +4,24 @@ import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type MessageResponse struct {
ID int64 `json:"id"`
ConversationID int64 `json:"conversationId"`
RequestID string `json:"requestId,omitempty"`
WorkflowRunID int64 `json:"workflowRunId,omitempty"`
ClientMsgID string `json:"clientMsgId,omitempty"`
SenderType enums.IMSenderType `json:"senderType"`
SenderID int64 `json:"senderId"`
SenderName string `json:"senderName,omitempty"`
SenderAvatar string `json:"senderAvatar,omitempty"`
MessageType enums.IMMessageType `json:"messageType"`
ConversationID int64 `json:"conversation_id"`
RequestID string `json:"request_id,omitempty"`
ClientMsgID string `json:"client_msg_id,omitempty"`
SenderType enums.IMSenderType `json:"sender_type"`
SenderID int64 `json:"sender_id"`
SenderName string `json:"sender_name,omitempty"`
SenderAvatar string `json:"sender_avatar,omitempty"`
MessageType enums.IMMessageType `json:"message_type"`
Content string `json:"content"`
Payload string `json:"payload,omitempty"`
SendStatus enums.IMMessageStatus `json:"sendStatus"`
SentAt string `json:"sentAt,omitempty"`
DeliveredAt string `json:"deliveredAt,omitempty"`
ReadAt string `json:"readAt,omitempty"`
CustomerRead bool `json:"customerRead"`
CustomerReadAt string `json:"customerReadAt,omitempty"`
AgentRead bool `json:"agentRead"`
AgentReadAt string `json:"agentReadAt,omitempty"`
RecalledAt string `json:"recalledAt,omitempty"`
QuotedMessageID int64 `json:"quotedMessageId,omitempty"`
SendStatus enums.IMMessageStatus `json:"send_status"`
SentAt string `json:"sent_at,omitempty"`
DeliveredAt string `json:"delivered_at,omitempty"`
ReadAt string `json:"read_at,omitempty"`
CustomerRead bool `json:"customer_read"`
CustomerReadAt string `json:"customer_read_at,omitempty"`
AgentRead bool `json:"agent_read"`
AgentReadAt string `json:"agent_read_at,omitempty"`
RecalledAt string `json:"recalled_at,omitempty"`
QuotedMessageID int64 `json:"quoted_message_id,omitempty"`
}
@@ -2,17 +2,17 @@ package response
type NotificationResponse struct {
ID int64 `json:"id"`
RecipientUserID int64 `json:"recipientUserId"`
RecipientUserID int64 `json:"recipient_user_id"`
Title string `json:"title"`
Content string `json:"content"`
NotificationType string `json:"notificationType"`
BizType string `json:"bizType"`
BizID int64 `json:"bizId"`
ActionURL string `json:"actionUrl"`
ReadAt string `json:"readAt,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
NotificationType string `json:"notification_type"`
BizType string `json:"biz_type"`
BizID int64 `json:"biz_id"`
ActionURL string `json:"action_url"`
ReadAt string `json:"read_at,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
}
type NotificationUnreadCountResponse struct {
UnreadCount int64 `json:"unreadCount"`
UnreadCount int64 `json:"unread_count"`
}
@@ -4,10 +4,10 @@ import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type QuickReplyResponse struct {
ID int64 `json:"id"`
GroupName string `json:"groupName"`
GroupName string `json:"group_name"`
Title string `json:"title"`
Content string `json:"content"`
Status enums.Status `json:"status"`
SortNo int `json:"sortNo"`
CreatedBy int64 `json:"createdBy"`
SortNo int `json:"sort_no"`
CreatedBy int64 `json:"created_by"`
}
@@ -1,34 +0,0 @@
package response
import "time"
type SkillDefinitionResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Instruction string `json:"instruction"`
Examples []string `json:"examples"`
ToolWhitelist []string `json:"toolWhitelist"`
Status int `json:"status"`
StatusName string `json:"statusName"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
}
type SkillDebugRunResponse struct {
SkillDefinitionID int64 `json:"skillDefinitionId"`
SkillName string `json:"skillName"`
ReplyText string `json:"replyText"`
ToolWhitelist []string `json:"toolWhitelist"`
InvokedToolCodes []string `json:"invokedToolCodes"`
InterruptType string `json:"interruptType"`
CheckPointID string `json:"checkPointId"`
Interrupted bool `json:"interrupted"`
TraceData string `json:"traceData"`
ErrorMessage string `json:"errorMessage"`
ConversationID int64 `json:"conversationId"`
AIAgentID int64 `json:"aiAgentId"`
}
-26
View File
@@ -1,26 +0,0 @@
package response
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type TagResponse struct {
ID int64 `json:"id"`
ParentID int64 `json:"parentId"`
Name string `json:"name"`
Remark string `json:"remark"`
SortNo int `json:"sortNo"`
Status enums.Status `json:"status"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type TagTreeResponse struct {
ID int64 `json:"id"`
ParentID int64 `json:"parentId"`
Name string `json:"name"`
Remark string `json:"remark"`
SortNo int `json:"sortNo"`
Status enums.Status `json:"status"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Children []*TagTreeResponse `json:"children"`
}
@@ -1,55 +0,0 @@
package response
import "code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
type TicketProgressResponse struct {
ID int64 `json:"id"`
TicketID int64 `json:"ticketId"`
Content string `json:"content"`
AuthorID int64 `json:"authorId"`
AuthorName string `json:"authorName,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
}
type TicketResponse struct {
ID int64 `json:"id"`
TicketNo string `json:"ticketNo"`
Title string `json:"title"`
Description string `json:"description"`
Source enums.TicketSource `json:"source"`
Channel string `json:"channel"`
CustomerID int64 `json:"customerId"`
ConversationID int64 `json:"conversationId"`
Tags []TagResponse `json:"tags,omitempty"`
Status enums.TicketStatus `json:"status"`
CurrentAssigneeID int64 `json:"currentAssigneeId"`
CurrentAssigneeName string `json:"currentAssigneeName,omitempty"`
CreatedBy int64 `json:"createdBy"`
CreatedByName string `json:"createdByName,omitempty"`
HandledAt string `json:"handledAt,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
Customer *CustomerResponse `json:"customer,omitempty"`
}
type TicketDetailResponse struct {
Ticket TicketResponse `json:"ticket"`
Progresses []TicketProgressResponse `json:"progresses,omitempty"`
}
type TicketSummaryResponse struct {
All int64 `json:"all"`
Pending int64 `json:"pending"`
InProgress int64 `json:"inProgress"`
Done int64 `json:"done"`
Unassigned int64 `json:"unassigned"`
Mine int64 `json:"mine"`
Stale int64 `json:"stale"`
}
type TicketViewResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Filters map[string]any `json:"filters,omitempty"`
SortNo int `json:"sortNo"`
}
+3 -3
View File
@@ -1,11 +1,11 @@
package response
type WidgetConfigResponse struct {
ChannelID string `json:"channelId"`
ChannelType string `json:"channelType"`
ChannelID string `json:"channel_id"`
ChannelType string `json:"channel_type"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
ThemeColor string `json:"themeColor"`
ThemeColor string `json:"theme_color"`
Position string `json:"position"`
Width string `json:"width"`
}