Version: 0.9.76.dev.260505
后端: 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 的目录收口口径
This commit is contained in:
52
backend/shared/contracts/agent/query.go
Normal file
52
backend/shared/contracts/agent/query.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package agent
|
||||
|
||||
// ConversationQueryRequest 描述 gateway 查询单个 agent 会话资源的最小跨进程参数。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. UserID 由 gateway 鉴权后填充,不信任前端传入;
|
||||
// 2. ConversationID 只表达会话归属,不承载 HTTP query 或 SSE 细节;
|
||||
// 3. 会话是否存在、是否属于当前用户仍由 agent 服务内部校验。
|
||||
type ConversationQueryRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
ConversationID string `json:"conversation_id"`
|
||||
}
|
||||
|
||||
// ConversationListRequest 描述 gateway 拉取当前用户会话列表的最小查询条件。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. Page/PageSize 允许为 0,默认值和上限由 agent 服务统一兜底;
|
||||
// 2. Status 只透传过滤条件,合法值仍由 agent 服务决定;
|
||||
// 3. 不包含消息正文,避免列表接口被扩成重查询。
|
||||
type ConversationListRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"page_size,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// SaveScheduleStatePlacedItem 描述前端拖拽后的单个 task_item 绝对时间位置。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 字段形状与 HTTP 入参保持一致,避免 gateway 做额外翻译;
|
||||
// 2. 这里只承载跨进程 JSON 契约,不判断节次、周次或 task_item 是否有效;
|
||||
// 3. agent 服务会把绝对坐标转换为内部 ScheduleState 相对坐标。
|
||||
type SaveScheduleStatePlacedItem struct {
|
||||
TaskItemID int `json:"task_item_id"`
|
||||
Week int `json:"week"`
|
||||
DayOfWeek int `json:"day_of_week"`
|
||||
StartSection int `json:"start_section"`
|
||||
EndSection int `json:"end_section"`
|
||||
EmbedCourseEventID int `json:"embed_course_event_id,omitempty"`
|
||||
}
|
||||
|
||||
// SaveScheduleStateRequest 描述 gateway 暂存会话内排程拖拽状态的跨进程命令。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. UserID 由 gateway 注入,用于 agent 服务做会话归属校验;
|
||||
// 2. ConversationID 指向当前会话快照;
|
||||
// 3. Items 只包含用户拖拽后的 task_item 位置,不承载课程写入或正式确认语义。
|
||||
type SaveScheduleStateRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
ConversationID string `json:"conversation_id"`
|
||||
Items []SaveScheduleStatePlacedItem `json:"items"`
|
||||
}
|
||||
30
backend/shared/contracts/agent/types.go
Normal file
30
backend/shared/contracts/agent/types.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package agent
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// ChatRequest 是 Gateway 调用 agent RPC Chat 流时使用的最小跨进程契约。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 只承载 Gateway 已完成鉴权与会话归一化后的字段;
|
||||
// 2. 不承载 HTTP header、SSE 细节或 Gin 上下文;
|
||||
// 3. extra_json 只负责透传 extra 的 JSON 快照,不在契约层解释业务语义。
|
||||
type ChatRequest struct {
|
||||
Message string `json:"message"`
|
||||
Thinking string `json:"thinking,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
UserID int `json:"user_id"`
|
||||
ConversationID string `json:"conversation_id"`
|
||||
ExtraJSON json.RawMessage `json:"extra_json,omitempty"`
|
||||
}
|
||||
|
||||
// ChatChunk 是 agent RPC Chat 流回传给 Gateway 的最小分块契约。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. payload 保持前端现有 SSE data 负载格式,不在 Gateway 二次改写;
|
||||
// 2. done 只表达“流是否结束”,不包含额外业务语义;
|
||||
// 3. error_json 只表达服务端错误快照,最终由 Gateway 转换成既有 SSE 错误形态。
|
||||
type ChatChunk struct {
|
||||
Payload string `json:"payload,omitempty"`
|
||||
Done bool `json:"done,omitempty"`
|
||||
ErrorJSON json.RawMessage `json:"error_json,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user