feat: 管理面板补齐(RAG导入/记忆添加/会话接history/诚实表述) + design/16 §4.6 IM多会话隔离+第三方身份+黑白名单
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

agent-98 面板批次:
- 会话管理面板改接 history.ListSessions(主web+次级) + 新建次级会话按钮
- 记忆面板手动添加入口 POST /admin/memories(owner)
- 知识库真正实现 IndexDocument(分块+落projectindex) + POST /admin/rag 导入端点
- 三面板空态诚实表述(去除'后端M10+提供')
- RAG嵌入降级到keyword/line(无直属embedder,不伪造语义,符合红线)

agent-99 design/16 §4.6:
- model.Message.SenderName + 迁移0006 sender_name 列
- 第三方身份边界: session.ResolveActor判定(非LLM猜) + [第三方·昵称]前缀(不改源content)
- 群聊/陌生人落独立sess-xxx(persistIsolated),不写主会话,不广播
- 黑/白名单(allowGroups/denyGroups/allowUsers/denyUsers)最前拦截,不进LLM
- 多账号 CHANNELS_JSON 配置 + 每平台多实例
- 管理只读 GET /admin/channels/{platform}/messages(该平台非主人消息流)

实机验证(JWT): 会话管理返回主会话web / 记忆添加成功 / RAG导入documents非空+Cyrene命中; 后端build/vet/test全绿 + 前端build绿
This commit is contained in:
Aska committed 2026-09-07 05:13:36 +08:00
1 parent 37e98ec584
commit 9c2a37c4ac
32 files changed
+1768 -136

No files matched your search

+56
View File
@@ -367,3 +367,59 @@ func TestDeleteSession(t *testing.T) {
t.Fatalf("delete main err = %v, want ErrImmutableMain", err)
}
}
func TestSenderNameRoundTripOnListRecentAndPlatformLog(t *testing.T) {
t.Parallel()
st := newStore(t)
ctx := context.Background()
// An isolated group session carries the sender display name (design/16 §4.6).
groupID := "sess-g"
if err := st.Append(ctx, Message{SessionID: groupID, Role: RoleUser, Content: "hello all", Platform: "telegram", SenderName: "张三", DeviceID: "telegram:-20:9", CreatedAt: 1000}); err != nil {
t.Fatalf("append group msg: %v", err)
}
// An owner-private message on the main session carries no sender name.
if err := st.Append(ctx, Message{SessionID: MainSessionID, Role: RoleUser, Content: "hi", Platform: "telegram", CreatedAt: 900}); err != nil {
t.Fatalf("append main msg: %v", err)
}
// An unrelated platform on the main session should not leak into the log.
if err := st.Append(ctx, Message{SessionID: MainSessionID, Role: RoleUser, Content: "web msg", Platform: "web", CreatedAt: 800}); err != nil {
t.Fatalf("append web msg: %v", err)
}
// List reads the sender_name back.
ls, err := st.List(ctx, groupID, 0, 50, "")
if err != nil {
t.Fatalf("list: %v", err)
}
if len(ls) != 1 || ls[0].SenderName != "张三" || ls[0].Content != "hello all" {
t.Fatalf("list = %+v, want SenderName 张三", ls)
}
// Recent reads it too.
rs, err := st.Recent(ctx, groupID, 5)
if err != nil {
t.Fatalf("recent: %v", err)
}
if len(rs) != 1 || rs[0].SenderName != "张三" {
t.Fatalf("recent = %+v, want SenderName 张三", rs)
}
// Platform log surfaces only the isolated (non-main) messages of the platform,
// newest first, excluding the owner-private mirror on the main session.
log, err := st.ListPlatformLog(ctx, "telegram", 0, 50)
if err != nil {
t.Fatalf("platform log: %v", err)
}
if len(log) != 1 {
t.Fatalf("platform log = %+v, want only the isolated group message", log)
}
if log[0].SessionID != groupID || log[0].SenderName != "张三" {
t.Fatalf("platform log[0] = %+v, want group session with SenderName 张三", log[0])
}
// A platform with only main-session messages yields an empty log.
if log, err := st.ListPlatformLog(ctx, "web", 0, 50); err != nil || len(log) != 0 {
t.Fatalf("web platform log = %+v, err=%v; want empty", log, err)
}
}