后端: 1.阶段 6 agent / memory 服务化收口 - 新增 cmd/agent 独立进程入口,承载 agent zrpc server、agent outbox relay / consumer 和运行时依赖初始化 - 补齐 services/agent/rpc 的 Chat stream 与 conversation meta/list/timeline、schedule-preview、context-stats、schedule-state unary RPC - 新增 gateway/client/agent 与 shared/contracts/agent,将 /api/v1/agent chat 和非 chat 门面切到 agent zrpc - 收缩 gateway 本地 AgentService 装配,双 RPC 开关开启时不再初始化本地 agent 编排、LLM、RAG 和 memory reader fallback - 将 backend/memory 物理迁入 services/memory,私有实现收入 internal,保留 module/model/observe 作为 memory 服务门面 - 调整 memory outbox、memory reader 和 agent 记忆渲染链路的 import 与服务边界,cmd/memory 独占 memory worker / consumer - 关闭 gateway 侧 agent outbox worker 所有权,agent relay / consumer 由 cmd/agent 独占,gateway 仅保留 HTTP/SSE 门面与迁移期开关回退 - 更新阶段 6 文档,记录 agent / memory 当前切流点、smoke 结果,以及 backend/client 与 gateway/shared 的目录收口口径
106 lines
2.7 KiB
Go
106 lines
2.7 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
// ItemDTO 是记忆条目对外读写 DTO。
|
|
//
|
|
// 职责边界:
|
|
// 1. 面向 memory 模块内部服务层使用;
|
|
// 2. 不直接绑定 GORM 标签,避免传输结构与存储结构强耦合。
|
|
type ItemDTO struct {
|
|
ID int64
|
|
UserID int
|
|
ConversationID string
|
|
AssistantID string
|
|
RunID string
|
|
MemoryType string
|
|
Title string
|
|
Content string
|
|
ContentHash string
|
|
Confidence float64
|
|
Importance float64
|
|
SensitivityLevel int
|
|
IsExplicit bool
|
|
Status string
|
|
TTLAt *time.Time
|
|
CreatedAt *time.Time
|
|
UpdatedAt *time.Time
|
|
}
|
|
|
|
// ItemQuery 描述 memory_items 的通用查询条件。
|
|
//
|
|
// 职责边界:
|
|
// 1. 只表达 memory 仓储层需要的过滤条件;
|
|
// 2. 不直接承载注入策略、重排策略等上层业务语义;
|
|
// 3. IncludeGlobal 用于“会话级 + 全局级”混合读取场景。
|
|
type ItemQuery struct {
|
|
UserID int
|
|
ConversationID string
|
|
AssistantID string
|
|
RunID string
|
|
Statuses []string
|
|
MemoryTypes []string
|
|
IncludeGlobal bool
|
|
OnlyUnexpired bool
|
|
Limit int
|
|
Now time.Time
|
|
}
|
|
|
|
// RetrieveRequest 描述“供提示词注入前读取”所需的最小参数。
|
|
type RetrieveRequest struct {
|
|
Query string
|
|
UserID int
|
|
ConversationID string
|
|
AssistantID string
|
|
RunID string
|
|
MemoryTypes []string
|
|
Limit int
|
|
Now time.Time
|
|
}
|
|
|
|
// ListItemsRequest 描述记忆管理页列表查询参数。
|
|
type ListItemsRequest struct {
|
|
UserID int
|
|
ConversationID string
|
|
Statuses []string
|
|
MemoryTypes []string
|
|
Limit int
|
|
}
|
|
|
|
// CreateItemFields 是 repo 层落库时真正需要的字段集合。
|
|
type CreateItemFields struct {
|
|
UserID int
|
|
ConversationID string
|
|
AssistantID string
|
|
RunID string
|
|
MemoryType string
|
|
Title string
|
|
Content string
|
|
NormalizedContent string
|
|
ContentHash string
|
|
Confidence float64
|
|
Importance float64
|
|
SensitivityLevel int
|
|
IsExplicit bool
|
|
Status string
|
|
TTLAt *time.Time
|
|
VectorStatus string
|
|
SourceMessageID *int64
|
|
SourceEventID *string
|
|
LastAccessAt *time.Time
|
|
}
|
|
|
|
// UpdateItemFields 是“用户管理侧修改记忆”时 repo 层允许更新的字段集合。
|
|
type UpdateItemFields struct {
|
|
MemoryType string
|
|
Title string
|
|
Content string
|
|
NormalizedContent string
|
|
ContentHash string
|
|
Confidence float64
|
|
Importance float64
|
|
SensitivityLevel int
|
|
IsExplicit bool
|
|
TTLAt *time.Time
|
|
}
|