会话阶段状态机advising/executing(单会话单问题:先聊清再干活):新建会话与「清空」落advising——resolveProfileName两档化(phase=advising强制命中内置advising组合,否则随模型配置profile,tools_allow只留read_file/fetch/write_file、不带skill故模板无技能清单段,配advising-system.txt:问答判意图引导澄清、每轮至多1-2问防过度追问);唯一出口是任务书正门——runLoopInner工具批跑完后,advising回合内write_file/edit_file成功落任务目录根task.md(argsHitTaskBrief,上传同名与terminal间接创建不算;批量末尾统一切,防父assistant先存档后落库回执成孤儿行被上游拒收)即enterExecuting:全史标archived+插type=task_brief磁盘快照行作执行阶段唯一上下文起点+phase翻转与SSE phase广播,下一迭代重读历史重解profile天然切默认组合、同回合开工(幂等:执行中再改task.md只是普通编辑);回头路只有清空(archiveTaskBrief把旧task.md mv进.task-history/task-<ts>.md防污染新规划,点目录沿用.imgcache隐式约定);压缩对phase中性(压完回原模式,task_brief不豁免存档,漂移可控因压缩本就用户主导);定时投递前强制executing(无人值守不能被顾问话术卡住);db迁移存量phase回填executing零打扰、sessions.profile列废弃不读写;运行期手动切profile全拆(消息级参数/bind的profile分支/setSessionProfile与hasModelProfile/status的model_profiles名单/bind弹窗模式区),头部徽标机位复用为阶段徽标(仅advising显灯泡,SSE phase驱动,转执行toast反馈)

This commit is contained in:
2026-09-25 11:54:20 +08:00
parent a70e5d267b
commit 7f8cf64e88
15 changed files with 245 additions and 157 deletions
+5 -17
View File
@@ -226,26 +226,14 @@ router.get('/:id', wrap((req, res) => {
// 按需加载单条消息的完整内容(用于 tool 消息的懒加载)
router.get('/:id/messages/:mid', wrap(getMessage));
// 一路由双语义(弹窗内模型/模式两套选择共用):model_id=手动占模型(仅已结版/已终止,见 bindToSession);
// profile=会话模式绑定(任意状态,''解绑,'default' 归一为 '')。各传各的,同传先模式后模型。
// 手动占用空闲模型(仅已结版/已终止可绑,见 bindToSession):状态栏「选择模型」弹窗发起。
// 曾有的 profile 会话模式绑定已废弃:profile 只由「阶段强制 + 模型配置默认」决定(见 engine.resolveProfileName)。
router.post('/:id/bind', wrap((req, res) => {
const body = req.body || {};
let prof;
if (body.profile !== undefined && body.profile !== null) {
const p = String(body.profile).trim();
if (p && p !== 'default' && !engine.hasModelProfile(p)) {
throw Object.assign(new Error('profile 不存在:' + p + '(可选:' + Object.keys(engine.getConfig().model_profiles || {}).join(', ') + ')'), { status_code: 400 });
}
prof = engine.setSessionProfile(req.params.id, p);
}
const mid = body.model_id;
const mid = (req.body || {}).model_id;
if (mid === undefined || mid === null || String(mid).trim() === '') {
if (prof === undefined) throw Object.assign(new Error('model_id / profile 至少传一项'), { status_code: 400 });
return res.json({ ok: true, profile: prof });
throw Object.assign(new Error('model_id 不能为空'), { status_code: 400 });
}
const r = engine.bindToSession(req.params.id, mid);
if (prof !== undefined) r.profile = prof;
res.json(r);
res.json(engine.bindToSession(req.params.id, mid));
}));
router.patch('/:id', wrap((req, res) => {