feat: 管理面板补齐(RAG导入/记忆添加/会话接history/诚实表述) + design/16 §4.6 IM多会话隔离+第三方身份+黑白名单
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:
1 parent
37e98ec584
commit
9c2a37c4ac
32 files changed
+1768
-136
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseChannelAccounts_Empty(t *testing.T) {
|
||||
t.Parallel()
|
||||
got, err := ParseChannelAccounts("")
|
||||
if err != nil {
|
||||
t.Fatalf("ParseChannelAccounts(empty): %v", err)
|
||||
}
|
||||
if len(got) != 0 {
|
||||
t.Fatalf("empty input = %d platforms, want 0", len(got))
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseChannelAccounts_MultiAccountWithAllowDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
raw := `{
|
||||
"telegram": [
|
||||
{"id":"conf0","config":{"bot_token":"t0"},"denyUsers":["12345"],"denyGroups":["-100"]},
|
||||
{"id":"conf1","config":{"bot_token":"t1"},"allowUsers":["u1","u2"],"allowGroups":["g1"]}
|
||||
],
|
||||
"qq-obv11": [
|
||||
{"id":"bot0","config":{"remote_url":"http://x","mode":"client"}}
|
||||
]
|
||||
}`
|
||||
got, err := ParseChannelAccounts(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseChannelAccounts: %v", err)
|
||||
}
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("platforms = %d, want 2", len(got))
|
||||
}
|
||||
tg := got["telegram"]
|
||||
if len(tg) != 2 {
|
||||
t.Fatalf("telegram accounts = %d, want 2", len(tg))
|
||||
}
|
||||
if tg[0].ID != "conf0" || tg[0].Config["bot_token"] != "t0" {
|
||||
t.Fatalf("account[0] = %+v", tg[0])
|
||||
}
|
||||
if !reflect.DeepEqual(tg[0].DenyUsers, []string{"12345"}) || !reflect.DeepEqual(tg[0].DenyGroups, []string{"-100"}) {
|
||||
t.Fatalf("account[0] deny lists = %+v", tg[0])
|
||||
}
|
||||
if !reflect.DeepEqual(tg[1].AllowUsers, []string{"u1", "u2"}) || !reflect.DeepEqual(tg[1].AllowGroups, []string{"g1"}) {
|
||||
t.Fatalf("account[1] allow lists = %+v", tg[1])
|
||||
}
|
||||
qq := got["qq-obv11"]
|
||||
if len(qq) != 1 || qq[0].ID != "bot0" || qq[0].Config["mode"] != "client" {
|
||||
t.Fatalf("qq accounts = %+v", qq)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseChannelAccounts_Malformed(t *testing.T) {
|
||||
t.Parallel()
|
||||
if _, err := ParseChannelAccounts(`{`); err == nil {
|
||||
t.Fatal("expected error for malformed JSON")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user