用户画像(跨会话、按登录用户隔离,只记称谓/行业/偏好三字段):新建/清空会话时把画像渲染文本+现取的近期关注(最近5条会话标题,不入库)冻结进sessions.profile_snapshot,buildMessages以system后首条user恒定注入(不入messages表故阶段归档/压缩免疫,字节恒定不破前缀缓存);唯一更新时机enterExecuting落槌——advising轮历史+当前画像+任务书快照喂一次模型调用(templates/profile-prompt.txt锁三字段JSON全量覆写语义:未提及原值拷回、被纠正才改写/清空),服务端按字段覆写、漏字段/解析失败保旧值,fire-and-forget永不抛出;user_profiles表(user主键,data JSON,enabled开关);/api/profile读写按req.user隔离,账户设置页新增用户画像子页(可见可改可停用,停用即清现存快照且不再提取);auth未启用=空串键隐式单用户

This commit is contained in:
2026-09-25 17:54:09 +08:00
parent 511c884e2b
commit 7708eea46a
10 changed files with 283 additions and 4 deletions
+3 -1
View File
@@ -60,7 +60,8 @@ agent/
│ │ │ ├── system-prompt.txt system prompt 静态模板(每次请求复用,利于上游前缀缓存)
│ │ │ ├── advising-system.txt 顾问阶段提示词(内置 profile:advising,phase=advising 时强制命中,见 §4.1)
│ │ │ ├── compress-prompt.txt 上下文压缩提示词(压缩回合末尾追加为 user 消息,历史照常走 messages)
│ │ │ └── title-prompt.txt 会话标题自动生成提示词(首次交互结束后触发,{{language}} 填配置语言)
│ │ │ ├── title-prompt.txt 会话标题自动生成提示词(首次交互结束后触发,{{language}} 填配置语言)
│ │ │ └── profile-prompt.txt 用户画像提取提示词(advising→executing 落槌时触发一次,输出锁三字段 JSON,见 user-profile.js)
│ │ └── public/ 前端 H5 SPA(无构建,Vanilla JS 经典脚本多文件 + SSE)
│ │ ├── index.html 主页(HTML+样式;脚本全部在 js/,按序加载共享全局作用域)
│ │ ├── login.html 登录页
@@ -447,6 +448,7 @@ AI 通过 `schedule` 工具为所在会话建周期性任务(`scheduled_tasks`
| `/api/config` | `routes/config.js` | `GET /` 原文+生效(脱敏)、`POST /validate`、`PUT /` 整文件保存、`PATCH /` 单项修改(path/value/op[delete\|append]) |
| `/api/platforms` | `routes/platforms.js` | `GET /balance?pi=&ki=` 余额 |
| `/api/system` | `routes/system.js` | `GET /status` + `/restart?force=...`(原 `model_profiles` 可用名单字段已删,前端无消费方) |
| `/api/profile` | `routes/profile.js` | `GET /` 读画像、`PUT /` 保存(三字段 + enabled);按 `req.user` 隔离,逻辑全在 `user-profile.js`(快照冻结见 engine `createSession`/`clearSessionMessages`,提取见 `enterExecuting`) |
| `/api/models` | `server.js` | 空闲/占用模型池 + token 用量 |
| `/api/health` | `server.js` | 健康检查 |
| `/api/login` `/api/login_restore` `/api/logout` `/api/password` `/api/me` | `auth.js` | 认证路由(认证前) |