0.8.0:模型设置换完即存,改走 commands/execute 不再触发智能体思考
This commit is contained in:
parent
763fb7ec8d
commit
e0a5eddda1
|
|
@ -1,7 +1,13 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
> 版本号以 `package.json` 为准(当前 0.7.2)。更早的 0.6.x 条目沿用旧编号,保留作历史。
|
> 版本号以 `package.json` 为准(当前 0.8.0)。更早的 0.6.x 条目沿用旧编号,保留作历史。
|
||||||
|
|
||||||
|
## 0.8.0 — 换完即存,不再惊动智能体
|
||||||
|
|
||||||
|
- 模型和推理等级改成**选完就保存**,去掉「保存模型设置」按钮;脚注直接显示「自动保存 · 当前:…」。
|
||||||
|
- 保存改走宿主 `commands/execute` 直接执行 `/dept-model`:不投递提示词、不在对话里留消息、不触发模型轮次,丞相不会因此进入大段推理。
|
||||||
|
- 宿主没有这个接口或指令尚未加载时,只在前端报错(「宿主没有执行这条指令」),不会退化成一条普通消息发给智能体。
|
||||||
|
- 测试新增两项:确认改模型时**不**调用 `session.prompt`、以及缺接口时的报错;全量 50 项通过。
|
||||||
## 0.7.2 — 三省与六部之间松一点
|
## 0.7.2 — 三省与六部之间松一点
|
||||||
|
|
||||||
- 三省(`.sl-grid-3`)与六部(`.sl-grid-6`)的卡片间距从 8–10px 统一到 12px,三个容器断点(含 ≤620px 的两列布局)一起调,窄侧栏下也不再挤在一起。
|
- 三省(`.sl-grid-3`)与六部(`.sl-grid-6`)的卡片间距从 8–10px 统一到 12px,三个容器断点(含 ≤620px 的两列布局)一起调,窄侧栏下也不再挤在一起。
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "dsh-sansheng-liubu-mode",
|
"name": "dsh-sansheng-liubu-mode",
|
||||||
"version": "0.7.2",
|
"version": "0.8.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "上朝:丞相统筹的三省六部多 Agent 模式",
|
"description": "上朝:丞相统筹的三省六部多 Agent 模式",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
||||||
|
|
@ -721,17 +721,17 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
||||||
const currentModelValue = catalog.current ? catalog.current.provider + "/" + catalog.current.model : "";
|
const currentModelValue = catalog.current ? catalog.current.provider + "/" + catalog.current.model : "";
|
||||||
const currentEffortValue = (catalog.current && catalog.current.reasoningEffort) || "";
|
const currentEffortValue = (catalog.current && catalog.current.reasoningEffort) || "";
|
||||||
const modelDirty = draftModel !== currentModelValue || draftEffort !== currentEffortValue;
|
const modelDirty = draftModel !== currentModelValue || draftEffort !== currentEffortValue;
|
||||||
const canSaveModel = Boolean(chosenOption && seat && modelDirty && !busy);
|
|
||||||
|
|
||||||
const applyModel = () => {
|
const applySelection = (option, effort) => {
|
||||||
if (!chosenOption || !seat) return;
|
if (!option || !seat) return;
|
||||||
const plan = modelSwitchPlan(catalog.current, {
|
const plan = modelSwitchPlan(catalog.current, {
|
||||||
provider: chosenOption.provider,
|
provider: option.provider,
|
||||||
model: chosenOption.model,
|
model: option.model,
|
||||||
reasoningEffort: draftEffort || undefined,
|
reasoningEffort: effort || undefined,
|
||||||
}, catalog.subagent || !seat.id);
|
}, catalog.subagent || !seat.id);
|
||||||
if (!plan.ok) { setNotice({ kind: "error", text: plan.reason }); return; }
|
if (!plan.ok) return;
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
|
setNotice(null);
|
||||||
const request = plan.via === "command"
|
const request = plan.via === "command"
|
||||||
? host.routeModel(seat.role, plan.payload)
|
? host.routeModel(seat.role, plan.payload)
|
||||||
: host.selectModel(seat.id, plan.payload);
|
: host.selectModel(seat.id, plan.payload);
|
||||||
|
|
@ -739,14 +739,12 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
if (plan.via === "command") writeSeatRoute(seat.role, plan.payload);
|
if (plan.via === "command") writeSeatRoute(seat.role, plan.payload);
|
||||||
setNotice({ kind: "ok", text: (plan.via === "command" ? "已把 " + seat.label + " 固定为 " : "已切换到 ") + chosenOption.label });
|
|
||||||
setCatalog((prev) => ({ ...prev, current: plan.payload, fixed: plan.via === "command" ? true : prev.fixed }));
|
setCatalog((prev) => ({ ...prev, current: plan.payload, fixed: plan.via === "command" ? true : prev.fixed }));
|
||||||
} else {
|
} else {
|
||||||
setNotice({ kind: "error", text: result.error });
|
setNotice({ kind: "error", text: result.error });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeChildId = activeAddress && activeAddress.childSessionId
|
const activeChildId = activeAddress && activeAddress.childSessionId
|
||||||
? activeAddress.childSessionId
|
? activeAddress.childSessionId
|
||||||
: focusedSessionId !== leadSessionId ? focusedSessionId : undefined;
|
: focusedSessionId !== leadSessionId ? focusedSessionId : undefined;
|
||||||
|
|
@ -941,10 +939,13 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
||||||
disabled: catalog.status === "loading" || busy,
|
disabled: catalog.status === "loading" || busy,
|
||||||
"aria-label": "部门模型",
|
"aria-label": "部门模型",
|
||||||
onChange: (event) => {
|
onChange: (event) => {
|
||||||
setDraftModel(event.target.value);
|
const value = event.target.value;
|
||||||
const option = catalog.options.find((entry) => entry.rowId === event.target.value);
|
const option = catalog.options.find((entry) => entry.rowId === value);
|
||||||
setDraftEffort(option && option.defaultEffort ? option.defaultEffort : "");
|
const effort = option && option.defaultEffort ? option.defaultEffort : "";
|
||||||
},
|
setDraftModel(value);
|
||||||
|
setDraftEffort(effort);
|
||||||
|
applySelection(option, effort);
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
h("option", { value: "", children: catalog.status === "loading" ? "读取中…" : "选择模型" }),
|
h("option", { value: "", children: catalog.status === "loading" ? "读取中…" : "选择模型" }),
|
||||||
...catalog.options.map((option) => h("option", { key: option.rowId, value: option.rowId, children: option.label })),
|
...catalog.options.map((option) => h("option", { key: option.rowId, value: option.rowId, children: option.label })),
|
||||||
|
|
@ -957,7 +958,11 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
||||||
value: draftEffort,
|
value: draftEffort,
|
||||||
disabled: catalog.status === "loading" || busy || !chosenOption,
|
disabled: catalog.status === "loading" || busy || !chosenOption,
|
||||||
"aria-label": "部门推理等级",
|
"aria-label": "部门推理等级",
|
||||||
onChange: (event) => setDraftEffort(event.target.value),
|
onChange: (event) => {
|
||||||
|
const value = event.target.value;
|
||||||
|
setDraftEffort(value);
|
||||||
|
applySelection(chosenOption, value);
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
h("option", { value: "", children: "默认" }),
|
h("option", { value: "", children: "默认" }),
|
||||||
...(chosenOption ? chosenOption.efforts : []).map((effort) => h("option", { key: effort.id, value: effort.id, children: effort.name })),
|
...(chosenOption ? chosenOption.efforts : []).map((effort) => h("option", { key: effort.id, value: effort.id, children: effort.name })),
|
||||||
|
|
@ -966,22 +971,20 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
h("div", { className: "sl-model-foot" }, [
|
h("div", { className: "sl-model-foot" }, [
|
||||||
h("button", {
|
h("small", {
|
||||||
type: "button",
|
className: notice && notice.kind === "error" ? "is-dirty" : "",
|
||||||
className: "sl-btn",
|
children: busy || modelDirty
|
||||||
disabled: !canSaveModel,
|
? "自动保存中…"
|
||||||
onClick: applyModel,
|
: notice && notice.kind === "error"
|
||||||
children: busy ? "保存中…" : "保存模型设置",
|
? "保存失败,换一次再试"
|
||||||
}),
|
: catalog.fixed
|
||||||
h("small", { className: modelDirty ? "is-dirty" : "", children: modelDirty
|
? "自动保存 · 该部门固定使用此模型"
|
||||||
? "有未保存的更改"
|
: !seat.present
|
||||||
: catalog.fixed
|
? "自动保存 · 召见时按此模型开工"
|
||||||
? "该部门固定使用此模型"
|
: catalog.inherited
|
||||||
: !seat.present
|
? "自动保存 · 当前跟随默认(" + modelLabel(catalog.current) + ")"
|
||||||
? "该部门还没召见;保存后在召见时生效"
|
: "自动保存 · 当前:" + (catalog.current ? modelLabel(catalog.current) : "未设置"),
|
||||||
: catalog.inherited
|
}),
|
||||||
? (catalog.unresolved ? "该部门会话未在本页打开,选好保存后直接生效" : "当前:跟随默认(" + modelLabel(catalog.current) + ")")
|
|
||||||
: "当前:" + (catalog.current ? modelLabel(catalog.current) : "未设置") }),
|
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
catalog.error ? h("div", { className: "sl-error", children: catalog.error }) : null,
|
catalog.error ? h("div", { className: "sl-error", children: catalog.error }) : null,
|
||||||
|
|
@ -1225,7 +1228,6 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
||||||
}
|
}
|
||||||
return { catalog };
|
return { catalog };
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 会话 RPC 面:改模型只认 sessionId,不需要该会话在本页登记。 */
|
/** 会话 RPC 面:改模型只认 sessionId,不需要该会话在本页登记。 */
|
||||||
const remoteSession = () => {
|
const remoteSession = () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -1235,6 +1237,15 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
||||||
} catch (error) { return undefined; }
|
} catch (error) { return undefined; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 指令 RPC 面:直接执行斜杠指令,不经过模型,也不进对话。 */
|
||||||
|
const remoteCommands = () => {
|
||||||
|
try {
|
||||||
|
const remote = ctx.remote;
|
||||||
|
const commands = remote && remote.commands;
|
||||||
|
return commands && typeof commands.execute === "function" ? commands : undefined;
|
||||||
|
} catch (error) { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
const sidebarNav = () => {
|
const sidebarNav = () => {
|
||||||
const candidates = [];
|
const candidates = [];
|
||||||
try { if (typeof ctx.get === "function") candidates.push(ctx.get("sidebarRight")); } catch (error) { /* 忽略 */ }
|
try { if (typeof ctx.get === "function") candidates.push(ctx.get("sidebarRight")); } catch (error) { /* 忽略 */ }
|
||||||
|
|
@ -1463,15 +1474,22 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
||||||
}, (error) => ({ ok: false, error: String((error && error.message) || error) }));
|
}, (error) => ({ ok: false, error: String((error && error.message) || error) }));
|
||||||
},
|
},
|
||||||
/** 子会话不能直接改模型,改由丞相会话把指令下发给模式插件。 */
|
/** 子会话不能直接改模型,改由丞相会话把指令下发给模式插件。 */
|
||||||
|
/** 子会话不能直接改模型:用 commands/execute 直接跑指令,全程不碰模型。 */
|
||||||
routeModel(role, payload) {
|
routeModel(role, payload) {
|
||||||
|
const commands = remoteCommands();
|
||||||
|
if (!commands) return Promise.resolve({ ok: false, error: "当前宿主没有直接执行指令的接口(remote.commands.execute)" });
|
||||||
const lead = currentSession();
|
const lead = currentSession();
|
||||||
if (!lead) return Promise.resolve({ ok: false, error: "没有可下发指令的丞相会话" });
|
if (!lead) return Promise.resolve({ ok: false, error: "没有可下发指令的丞相会话" });
|
||||||
const text = "/" + DEPT_MODEL_COMMAND + " " + role + " " + payload.provider + " " + payload.model +
|
const line = "/" + DEPT_MODEL_COMMAND + " " + role + " " + payload.provider + " " + payload.model +
|
||||||
(payload.reasoningEffort ? " " + payload.reasoningEffort : "");
|
(payload.reasoningEffort ? " " + payload.reasoningEffort : "");
|
||||||
return deliverPrompt(lead, text).then((result) => {
|
return Promise.resolve()
|
||||||
if (result.ok) return { ok: true, text: text };
|
.then(() => commands.execute(lead, line, []))
|
||||||
return { ok: false, error: result.error || "下发部门模型失败" };
|
.then((result) => {
|
||||||
});
|
const outcome = result && result.result;
|
||||||
|
if (outcome && outcome.kind === "success") return { ok: true, text: line };
|
||||||
|
const detail = outcome && outcome.kind === "error" ? outcome.text : undefined;
|
||||||
|
return { ok: false, error: detail || "宿主没有执行这条指令(可能还没有重启)" };
|
||||||
|
}, (error) => ({ ok: false, error: String((error && error.message) || error) }));
|
||||||
},
|
},
|
||||||
selectPreset(sessionId, presetId) {
|
selectPreset(sessionId, presetId) {
|
||||||
const remote = presetsRemote();
|
const remote = presetsRemote();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "dsh-sansheng-liubu-panel",
|
"name": "dsh-sansheng-liubu-panel",
|
||||||
"version": "0.7.2",
|
"version": "0.8.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "三省六部 Agent 面板:在 DSH Web GUI 中常驻显示并切换团队 Agent",
|
"description": "三省六部 Agent 面板:在 DSH Web GUI 中常驻显示并切换团队 Agent",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ function mockContext(prompts = []) { const registrations = []
|
||||||
remote: {
|
remote: {
|
||||||
agentPresets: { list: async () => ({ ok: true, value: { presets: [] } }), select: async () => ({ ok: true }) },
|
agentPresets: { list: async () => ({ ok: true, value: { presets: [] } }), select: async () => ({ ok: true }) },
|
||||||
session: { selectModel: async () => ({ ok: true }) },
|
session: { selectModel: async () => ({ ok: true }) },
|
||||||
|
commands: { execute: async () => ({ commandId: 'cmd-1', result: { kind: 'success' } }) },
|
||||||
},
|
},
|
||||||
layout: { selectPanel(id) { selections.push(id) } },
|
layout: { selectPanel(id) { selections.push(id) } },
|
||||||
get() { return undefined },
|
get() { return undefined },
|
||||||
|
|
@ -931,8 +932,9 @@ test('正常路径给出全局清单与该会话自己的当前选择', async ()
|
||||||
assert.deepEqual(result.current, { provider: 'p', model: 'm' })
|
assert.deepEqual(result.current, { provider: 'p', model: 'm' })
|
||||||
})
|
})
|
||||||
|
|
||||||
test('部门是子会话时,改模型改由丞相会话下发 /dept-model', async () => {
|
test('部门是子会话时,改模型靠宿主直接执行指令,不投递给模型', async () => {
|
||||||
const prompts = []
|
const prompts = []
|
||||||
|
const executed = []
|
||||||
const { host } = catalogHost({
|
const { host } = catalogHost({
|
||||||
sessions: {
|
sessions: {
|
||||||
list: () => [],
|
list: () => [],
|
||||||
|
|
@ -942,12 +944,36 @@ test('部门是子会话时,改模型改由丞相会话下发 /dept-model', as
|
||||||
subagentAddress: () => ({ parentSessionId: 'lead-1', childSessionId: 'gongbu-1' }),
|
subagentAddress: () => ({ parentSessionId: 'lead-1', childSessionId: 'gongbu-1' }),
|
||||||
refreshProjections: async () => {},
|
refreshProjections: async () => {},
|
||||||
},
|
},
|
||||||
|
remote: {
|
||||||
|
agentPresets: { list: async () => ({ ok: true, value: { presets: [] } }), select: async () => ({ ok: true }) },
|
||||||
|
session: { selectModel: async () => ({ ok: true }) },
|
||||||
|
commands: {
|
||||||
|
execute: async (agentId, line, attachments) => {
|
||||||
|
executed.push({ agentId, line, attachments })
|
||||||
|
return { commandId: 'cmd-1', result: { kind: 'success', text: '好' } }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
const result = await host.routeModel('gongbu', { provider: 'deepseek', model: 'deepseek-chat', reasoningEffort: 'high' })
|
const result = await host.routeModel('gongbu', { provider: 'deepseek', model: 'deepseek-chat', reasoningEffort: 'high' })
|
||||||
assert.equal(result.ok, true)
|
assert.equal(result.ok, true)
|
||||||
assert.equal(prompts.length, 1)
|
assert.equal(prompts.length, 0, '不能向会话投递提示词,否则会触发模型思考')
|
||||||
assert.equal(prompts[0].sessionId, 'lead-1', '指令投给丞相会话')
|
assert.equal(executed.length, 1)
|
||||||
assert.equal(prompts[0].parts[0].text, '/dept-model gongbu deepseek deepseek-chat high')
|
assert.equal(executed[0].agentId, 'lead-1')
|
||||||
|
assert.equal(executed[0].line, '/dept-model gongbu deepseek deepseek-chat high')
|
||||||
|
assert.equal(executed[0].attachments.length, 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('宿主没有执行指令的接口时,报错要指明原因', async () => {
|
||||||
|
const { host } = catalogHost({
|
||||||
|
remote: {
|
||||||
|
agentPresets: { list: async () => ({ ok: true, value: { presets: [] } }), select: async () => ({ ok: true }) },
|
||||||
|
session: { selectModel: async () => ({ ok: true }) },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const result = await host.routeModel('gongbu', { provider: 'deepseek', model: 'deepseek-chat' })
|
||||||
|
assert.equal(result.ok, false)
|
||||||
|
assert.match(result.error, /remote.commands.execute/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('子会话的固定路由从面板记录里读出来当「当前模型」', async () => {
|
test('子会话的固定路由从面板记录里读出来当「当前模型」', async () => {
|
||||||
|
|
|
||||||
|
|
@ -819,6 +819,9 @@ function createDemoContext(options = {}) {
|
||||||
session: {
|
session: {
|
||||||
selectModel: async () => ({ ok: true }),
|
selectModel: async () => ({ ok: true }),
|
||||||
},
|
},
|
||||||
|
commands: {
|
||||||
|
execute: async (_agentId, line) => ({ commandId: 'preview-command', result: { kind: 'success', text: line } }),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
get: () => undefined,
|
get: () => undefined,
|
||||||
layout: { selectPanel: () => {} },
|
layout: { selectPanel: () => {} },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue