Files
Cyrene/backend/platform-bridge/internal/bridge/unified.go
T
AskaEth a9c79d7887 feat: ASR语音转写管线 + 群聊身份混淆修复
- 新增ASR语音识别管线: QQ语音→下载音频→qwen3-asr-flash转录→注入用户消息
- 模型名称全部从models.json路由获取,无硬编码
- 修复群聊中AI将非管理员用户误称为管理员昵称(叶酱)的问题
  - 助手回复缓存时标注[回复 昵称 (UID)],防止对话历史中身份混淆
  - 群聊上下文指令改为肯定性表述,移除具体名称提及
- trace面板时间戳改为YYYY-MM-DD HH:MM:SS格式,耗时统一显示为秒
- 修复Go time.Duration纳秒值在前端显示问题(Duration/1e6转毫秒)
- 新增video_tool插件模板
- 优化OpenAI adapter reasoning_content处理

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-31 16:46:47 +08:00

86 lines
3.7 KiB
Go

package bridge
import "time"
// UnifiedMessage is the internal message format all platforms convert to.
type UnifiedMessage struct {
SenderID string `json:"sender_id"`
SenderName string `json:"sender_name"`
Platform string `json:"platform"`
ChannelID string `json:"channel_id"`
ChannelType string `json:"channel_type"` // "direct", "group", "channel"
Content string `json:"content"`
ContentType string `json:"content_type"` // "text", "image", "voice", "file", "mixed"
Attachments []Attachment `json:"attachments,omitempty"`
MessageID string `json:"message_id,omitempty"`
ReplyTo string `json:"reply_to,omitempty"`
Mentions []string `json:"mentions,omitempty"`
RawData interface{} `json:"raw_data,omitempty"`
Timestamp time.Time `json:"timestamp"`
// Routing metadata.
RouteType string `json:"route_type,omitempty"` // "normal", "silent", "admin_mention"
OriginalSenderUID string `json:"original_sender_uid,omitempty"` // preserved before identity mapping
OriginalSenderName string `json:"original_sender_name,omitempty"` // preserved before identity mapping
GroupName string `json:"group_name,omitempty"` // resolved group name for group chats
OriginalRawMessage interface{} `json:"-"` // preserved for SendMessage wiring
BotUID string `json:"-"` // bot's own platform UID, set by router
}
// Attachment represents a file/image/voice/video attachment.
type Attachment struct {
Type string `json:"type"` // "image", "voice", "file", "video"
URL string `json:"url,omitempty"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
Size int64 `json:"size,omitempty"`
Duration int `json:"duration,omitempty"` // video/voice duration in seconds
}
// UnifiedResponse is AI-Core's response converted to unified format.
type UnifiedResponse struct {
Messages []ResponseMessage `json:"messages"`
ReplyTo string `json:"reply_to,omitempty"`
Platform string `json:"platform"`
PlatformHints PlatformHints `json:"platform_hints,omitempty"`
}
// ResponseMessage is a single message in a response.
type ResponseMessage struct {
DisplayType string `json:"display_type"` // "chat", "action", "thinking", "system_info", "tool_progress"
Content string `json:"content"`
FormatMode string `json:"format_mode"` // "plain", "markdown", "html"
}
// PlatformHints tells the adapter how to deliver the response.
type PlatformHints struct {
TypingIndicator bool `json:"typing_indicator"` // show "typing..." before sending
BurstMode bool `json:"burst_mode"` // send multiple messages rapidly
ReplyAsThread bool `json:"reply_as_thread"` // reply in a thread
}
// PlatformCapabilities declares what a platform supports.
type PlatformCapabilities struct {
MaxMessageLength int `json:"max_message_length"`
SupportsMarkdown bool `json:"supports_markdown"`
SupportsImage bool `json:"supports_image"`
SupportsVoice bool `json:"supports_voice"`
SupportsEmoji bool `json:"supports_emoji"`
SupportsReaction bool `json:"supports_reaction"`
SupportsTypingHint bool `json:"supports_typing_hint"`
RecommendBurstMax int `json:"recommend_burst_max"`
}
// PlatformMessage is the platform-specific message format returned by an adapter.
type PlatformMessage struct {
Content string `json:"content"`
FormatMode string `json:"format_mode,omitempty"`
ReplyTo string `json:"reply_to,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
RawBody interface{} `json:"raw_body,omitempty"`
}