thread-master/apps/backend/internal/module/inspire/domain/domain.go

97 lines
3.6 KiB
Go
Raw Normal View History

2026-07-13 01:15:30 +00:00
package domain
import (
"errors"
"time"
)
var (
ErrNotFound = errors.New("inspire not found")
ErrForbidden = errors.New("inspire forbidden")
ErrValidation = errors.New("inspire validation")
ErrRemoved = errors.New("legacy inspire API removed")
)
func NowNano() int64 { return time.Now().UTC().UnixNano() }
type TrendItem struct {
ID string `bson:"_id" json:"id"`
OwnerUID int64 `bson:"owner_uid" json:"owner_uid"` // 0 = global seed
Kind string `bson:"kind" json:"kind"`
Label string `bson:"label" json:"label"`
Summary string `bson:"summary" json:"summary"`
Heat int `bson:"heat" json:"heat"`
Keywords []string `bson:"keywords" json:"keywords"`
Samples []string `bson:"samples" json:"samples"`
SourceLabel string `bson:"source_label" json:"source_label"`
ObservedAt int64 `bson:"observed_at" json:"observed_at"`
}
type Element struct {
ID string `bson:"_id" json:"id"`
OwnerUID int64 `bson:"owner_uid" json:"owner_uid"`
Kind string `bson:"kind" json:"kind"`
Title string `bson:"title" json:"title"`
Body string `bson:"body" json:"body"`
RefID string `bson:"ref_id,omitempty" json:"ref_id,omitempty"`
Reusable bool `bson:"reusable" json:"reusable"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
}
type ChatMessage struct {
ID string `bson:"id" json:"id"`
Role string `bson:"role" json:"role"` // user|assistant|system
Text string `bson:"text" json:"text"`
Draft *ChatDraft `bson:"draft,omitempty" json:"draft,omitempty"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
}
type ChatDraft struct {
Title string `bson:"title,omitempty" json:"title,omitempty"`
Body string `bson:"body" json:"body"`
}
// Session — 一位會員可有多則靈感對話active 由 Repository 的 active 指標維護。
type Session struct {
ID string `bson:"_id" json:"id"`
OwnerUID int64 `bson:"owner_uid" json:"owner_uid"`
Title string `bson:"title,omitempty" json:"title,omitempty"`
Messages []ChatMessage `bson:"messages" json:"messages"`
PinnedElementIDs []string `bson:"pinned_element_ids" json:"pinned_element_ids"`
// ContextSummary — 舊對話摺疊摘要AI 無狀態,不能只靠「同一個 session」記住
// 每 inspireSummarizeEvery 則訊息才重算,平常只帶摘要 + 最近幾則
ContextSummary string `bson:"context_summary,omitempty" json:"context_summary,omitempty"`
SummaryMsgCount int `bson:"summary_msg_count,omitempty" json:"summary_msg_count,omitempty"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
}
// SessionSummary — 列表用輕量摘要(不含完整 messages
type SessionSummary struct {
ID string `json:"id"`
Title string `json:"title"`
Preview string `json:"preview"`
MessageCount int `json:"message_count"`
UpdatedAt int64 `json:"updated_at"`
CreatedAt int64 `json:"created_at"`
Active bool `json:"active"`
}
type ResearchHit struct {
ID string `json:"id"`
Title string `json:"title"`
Snippet string `json:"snippet"`
URL string `json:"url"`
Summary string `json:"summary,omitempty"`
LearnPoints []string `json:"learn_points,omitempty"`
ReplyHooks []string `json:"reply_hooks,omitempty"`
SourceLabel string `json:"source_label,omitempty"`
}
type GeneratedImage struct {
ID string `json:"id"`
URL string `json:"url"`
Prompt string `json:"prompt"`
}