会话阶段状态机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:
@@ -21,13 +21,7 @@ router.post('/:id/messages', wrap((req, res) => {
|
||||
if (!content) return res.status(400).json({ error: 'content 不能为空' });
|
||||
// deepThink:是否启用模型该「深度思考」参数(thinking_params 合并进上游请求体)
|
||||
const deepThink = !!(req.body && req.body.deepThink);
|
||||
// profile:本轮 prompt+tools 组合(config.yml 顶层 model_profiles 的名字;保留值 'default' = 显式全量(仍受全局 tools_deny 屏蔽);
|
||||
// 不传 = 随模型配置的 profile)。名字不存在直接 400 打回,不静默回退(难排查)。
|
||||
const profile = String((req.body && req.body.profile) || '').trim();
|
||||
if (profile && profile !== 'default' && !engine.hasModelProfile(profile)) {
|
||||
return res.status(400).json({ error: 'profile 不存在:' + profile + '(可选:' + Object.keys(engine.getConfig().model_profiles || {}).join(', ') + ')' });
|
||||
}
|
||||
const r = engine.postUserMessage(req.params.id, content, { deepThink, profile });
|
||||
const r = engine.postUserMessage(req.params.id, content, { deepThink });
|
||||
log.info('msg', (req.user || '-') + ' ' + req.params.id + ' 用户消息(' + (r && r.delivered || '?') + '):' +
|
||||
content.slice(0, 60).replace(/\s+/g, ' '));
|
||||
res.json(r);
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -106,9 +106,8 @@ router.get('/status', wrap((req, res) => {
|
||||
sys: { mem: collectMem(), cpu: collectCpu(), disks: collectDisks(cfg) },
|
||||
auth_enabled: !!(cfg.auth && cfg.auth.users && cfg.auth.users.length),
|
||||
running_sessions: engine.activeRuns(),
|
||||
// 可用的 prompt+tools 组合名(config.yml 顶层 model_profiles):前端模式选择器据此渲染;
|
||||
// 切换 = 发消息时带 profile 参数(见 routes/messages.js),纯内存选择,不碰配置不重启。
|
||||
model_profiles: Object.keys((engine.getConfig() || {}).model_profiles || {}),
|
||||
// 曾有的 model_profiles 可用名单字段已删:前端手动切换模式入口全部移除,名单再无消费方
|
||||
//(组合只经模型配置 profile: <名> 引用,或 advising 阶段强制命中,见 engine.resolveProfileName)。
|
||||
// 前端上传预处理参数(大图压缩阈值/尺寸/质量、大文件确认阈值),避免前端写死
|
||||
upload: cfg.upload || {},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user