feat: RAG 知识库真实数据 + 渠道端到端接线(并行∦wire.go)+ 主会话收口
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

【渠道端到端·接线(agent-72)】
- 新建 internal/services/channelbridge/:桥接服务(Start 对配置渠道 Connect(10s超时/warn)+SetMessageHandler+ReadMessages;
  入站 UnifiedMessage→sessions.GetOrCreate(ResolveActor 白名单结构性识别)→loop.Run→SendMessage 回执,chat 文本)。
- cmd/cyrene/channels.go:从 CHANNEL_* env 读 4 渠道凭据(telegram/qq_obv11/weixin_ilink/webhook)。
- wire.go:app 加 channelBridge 字段,wireChannels 构造适配器+bridge.Start(),close() 收尾。
- 无真凭据降级:无 CHANNEL_* → configured()false 跳过不 dial;Connect 失败 Warn 不阻启动;
  webhook 仅入站(回执 ErrUnsupported 记 debug)。身份识别绝不靠提示词。收发端到端待凭据验证。

【RAG 知识库(agent-71)】
- internal/runtime/knowledge/:真实数据源(doc=资料/记忆=经历 分离 design/03 §3③)。
  ListDocuments 走 projectindex.ListProjects(+ListChapters)、Search 走 projectindex.Search(标题/描述+章节
  命中行+上下文)+retriever.Retrieve(配 vector 真语义,命中标 semantic:true)。
- gateway/server.go:RagStore 接口+Deps.RAG 可空+3 路由(GET /admin/rag、POST /admin/rag/query、/delete)。
- admin.go:adminListRag/adminSearchRag(空 query 400)/adminDeleteRag(写 501 not_implemented,M10)。
- projectindex/store.go:ListProjects/ListChapters。
- 前端 Rag.tsx:docs 从 GET /admin/rag 拉、检索走 POST /admin/rag/query、删除调真端点(501 显示 Notice),
  上传/分块/嵌入显示 M10 Notice;api.ts/types.ts 加 adminListRag/adminSearchRag/adminDeleteRag。

【主会话收口 wire.go】projStore 提到 app struct+wireMemory 赋值;knowledge.New(...) 注入 gateway.Deps.RAG。

实机验证:admin/rag 200(documents[] 空表非壳)、channels 枚举 4 渠道、health ok。
go build/vet/test 全绿 + 前端 tsc。wire.go 567 行。

遗留(记录):① 群聊/陌生人 MemWritable 记忆隔离未接 loop(AGENTS.md 红线,待修) ② webhook InboundHandler
需 gateway 挂载 ③ RAG 语义路径 persona-scoped(project 记忆其他 persona 不浮现)。
This commit is contained in:
Aska committed 2026-09-06 20:09:09 +08:00
1 parent 518bd0a230
commit dbcf3df8a3
13 files changed
+1510 -104

No files matched your search

+25
View File
@@ -4,6 +4,8 @@ import type {
AdminIoTDevice,
AdminLlmConfig,
AdminPluginRecord,
AdminRagHit,
AdminRagResponse,
AdminUserRecord,
ApiErrorShape,
ChatSyncResult,
@@ -244,3 +246,26 @@ export function adminGetLlm(): Promise<AdminLlmConfig> {
export function adminListAutomations(): Promise<AdminAutomationRecord[]> {
return request<AdminAutomationRecord[]>("/admin/automations");
}
/** GET /api/v1/admin/rag — lists knowledge documents; when query is present the
* backend also returns matching hits. */
export function adminListRag(query?: string): Promise<AdminRagResponse> {
const qs = query ? `?query=${encodeURIComponent(query)}` : "";
return request<AdminRagResponse>(`/admin/rag${qs}`);
}
/** POST /api/v1/admin/rag/query — runs a real knowledge-base query. */
export function adminSearchRag(
query: string
): Promise<{ query: string; hits: AdminRagHit[] }> {
return request<{ query: string; hits: AdminRagHit[] }>("/admin/rag/query", {
method: "POST",
body: JSON.stringify({ query }),
});
}
/** POST /api/v1/admin/rag/delete — deletes a document. The backend returns a
* clear 501 until M10 lands the write path (upload/chunk/embed/delete). */
export function adminDeleteRag(id: string): Promise<{ id: string }> {
return request<{ id: string }>("/admin/rag/delete", {
method: "POST",
body: JSON.stringify({ id }),
});
}
+25
View File
@@ -249,6 +249,31 @@ export interface AdminLogRecord {
msg: string;
}
/** A knowledge-base document (GET /api/v1/admin/rag). */
export interface AdminRagDoc {
id: string;
name: string;
desc?: string;
chunks: number;
embedded: boolean;
}
/** One RAG retrieval hit (GET /api/v1/admin/rag?query= / POST /rag/query). */
export interface AdminRagHit {
docId: string;
docName: string;
chapter?: string;
text: string;
score: number;
semantic: boolean;
}
/** The GET /api/v1/admin/rag response shape. */
export interface AdminRagResponse {
documents: AdminRagDoc[];
hits?: AdminRagHit[];
}
/** One audit entry: who / what / when / result. */
export interface AuditRecord {
id: string;