0.9.2:按官方挂法取指令接口,模型设置真的会落到部门身上
This commit is contained in:
parent
881560edab
commit
0bf18aacce
|
|
@ -1,6 +1,13 @@
|
|||
# Changelog
|
||||
|
||||
> 版本号以 `package.json` 为准(当前 0.9.1)。更早的 0.6.x 条目沿用旧编号,保留作历史。
|
||||
> 版本号以 `package.json` 为准(当前 0.9.2)。更早的 0.6.x 条目沿用旧编号,保留作历史。
|
||||
|
||||
## 0.9.2 — 模型设置这次真的会落到部门身上
|
||||
|
||||
- 面板原来从 `ctx.remote.commands` 取指令接口,新宿主把服务挂成 `remote.commands`(要写进 inject,用 `ctx.get` 取),所以一直报「没有直接执行指令的接口」;现在按官方挂法取,并在 inject 里声明 `remote.session` / `remote.subagents` / `remote.commands`。
|
||||
- 宿主返回的是 `{ ok, value: { commandId, result } }`,面板现在先解包再判断 `result.kind`,同步兼容旧的裸返回。
|
||||
- 保存失败时也会把 busy 放掉:以前宿主一拒绝,两个下拉框就永久变灰点不动。
|
||||
- 测试 55 项(新增「指令接口挂在 `ctx.get` 上也能静默执行」)。
|
||||
|
||||
## 0.9.1 — 三省与六部之间真的空开了
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dsh-sansheng-liubu-mode",
|
||||
"version": "0.9.1",
|
||||
"version": "0.9.2",
|
||||
"private": true,
|
||||
"description": "上朝:丞相统筹的三省六部多 Agent 模式",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -740,15 +740,16 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
const request = plan.via === "command"
|
||||
? host.routeModel(seat.role, plan.payload, seat.id)
|
||||
: host.selectModel(seat.id, plan.payload);
|
||||
request.then((result) => {
|
||||
const finish = (result) => {
|
||||
setBusy(false);
|
||||
if (result.ok) {
|
||||
if (result && result.ok) {
|
||||
if (plan.via === "command") writeSeatRoute(seat.role, plan.payload);
|
||||
setCatalog((prev) => ({ ...prev, current: plan.payload, fixed: plan.via === "command" ? true : prev.fixed }));
|
||||
} else {
|
||||
setNotice({ kind: "error", text: result.error });
|
||||
setNotice({ kind: "error", text: (result && result.error) || "宿主没有接受这次选择" });
|
||||
}
|
||||
});
|
||||
};
|
||||
request.then(finish, (error) => finish({ ok: false, error: String((error && error.message) || error) }));
|
||||
};
|
||||
const activeChildId = activeAddress && activeAddress.childSessionId
|
||||
? activeAddress.childSessionId
|
||||
|
|
@ -1267,15 +1268,24 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
}
|
||||
return { catalog };
|
||||
};
|
||||
/** 会话 RPC 面:改模型只认 sessionId,不需要该会话在本页登记。 */
|
||||
const remoteSession = () => {
|
||||
/** 取宿主挂出来的 remote 子服务:先问 ctx.get,再退回 ctx.remote 的属性。 */
|
||||
const remoteService = (name, key) => {
|
||||
try {
|
||||
const service = typeof ctx.get === "function" ? ctx.get(name) : undefined;
|
||||
if (service) return service;
|
||||
} catch (error) { /* 宿主没挂这个服务 */ }
|
||||
try {
|
||||
const remote = ctx.remote;
|
||||
const session = remote && remote.session;
|
||||
return session && typeof session.selectModel === "function" ? session : undefined;
|
||||
return remote && remote[key];
|
||||
} catch (error) { return undefined; }
|
||||
};
|
||||
|
||||
/** 会话 RPC 面:改模型只认 sessionId,不需要该会话在本页登记。 */
|
||||
const remoteSession = () => {
|
||||
const session = remoteService("remote.session", "session");
|
||||
return session && typeof session.selectModel === "function" ? session : undefined;
|
||||
};
|
||||
|
||||
/** 改模型时按这个顺序找执行者:部门自己 > 其它会话 > 丞相(只当执行上下文,不投递消息)。 */
|
||||
const routeCandidates = (preferredSessionId) => {
|
||||
const lead = currentSession();
|
||||
|
|
@ -1292,11 +1302,8 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
|
||||
/** 子会话投递面:用户直接派活给某个部门,绕开丞相。 */
|
||||
const remoteSubagents = () => {
|
||||
try {
|
||||
const remote = ctx.remote;
|
||||
const subagents = remote && remote.subagents;
|
||||
return subagents && typeof subagents.prompt === "function" ? subagents : undefined;
|
||||
} catch (error) { return undefined; }
|
||||
const subagents = remoteService("remote.subagents", "subagents");
|
||||
return subagents && typeof subagents.prompt === "function" ? subagents : undefined;
|
||||
};
|
||||
|
||||
/** 子会话地址:谁把我召来的。 */
|
||||
|
|
@ -1314,11 +1321,8 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
|
||||
/** 指令 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 commands = remoteService("remote.commands", "commands");
|
||||
return commands && typeof commands.execute === "function" ? commands : undefined;
|
||||
};
|
||||
|
||||
const sidebarNav = () => {
|
||||
|
|
@ -1563,7 +1567,15 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
return Promise.resolve()
|
||||
.then(() => commands.execute(agent, line, []))
|
||||
.then((result) => {
|
||||
const outcome = result && result.result;
|
||||
if (result && result.ok === false) {
|
||||
const failure = result.error;
|
||||
const detail = failure
|
||||
? (failure.code ? failure.code + ":" + failure.message : String(failure.message || failure))
|
||||
: "宿主拒绝了这条指令";
|
||||
return attempt(index + 1, detail);
|
||||
}
|
||||
const value = result && result.value !== undefined ? result.value : result;
|
||||
const outcome = value && value.result !== undefined ? value.result : value;
|
||||
if (outcome && outcome.kind === "success") return { ok: true, text: line, agent: agent };
|
||||
const detail = outcome && outcome.kind === "error" ? outcome.text : undefined;
|
||||
return attempt(index + 1, detail || "宿主没有执行这条指令(可能还没有重启)");
|
||||
|
|
@ -2046,7 +2058,7 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
}
|
||||
|
||||
exports.apply = apply;
|
||||
exports.inject = ["slots", "sessions", "uiWorkspace", "uiConversation", "modelDirectories", "remote", "remote.agentPresets", "sidebarRightTabs", "sidebarRight"];
|
||||
exports.inject = ["slots", "sessions", "uiWorkspace", "uiConversation", "modelDirectories", "remote", "remote.agentPresets", "remote.session", "remote.subagents", "remote.commands", "sidebarRightTabs", "sidebarRight"];
|
||||
exports.SanshengPanel = SanshengPanel;
|
||||
exports.PANEL_ID = PANEL_ID;
|
||||
exports.SANSENG_TAB_ID = SANSENG_TAB_ID;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dsh-sansheng-liubu-panel",
|
||||
"version": "0.9.1",
|
||||
"version": "0.9.2",
|
||||
"private": true,
|
||||
"description": "三省六部 Agent 面板:在 DSH Web GUI 中常驻显示并切换团队 Agent",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -138,11 +138,16 @@ function mockContext(prompts = []) { const registrations = []
|
|||
remote: {
|
||||
agentPresets: { list: async () => ({ ok: true, value: { presets: [] } }), select: async () => ({ ok: true }) },
|
||||
session: { selectModel: async () => ({ ok: true }) },
|
||||
commands: { execute: async () => ({ commandId: 'cmd-1', result: { kind: 'success' } }) },
|
||||
commands: { execute: async () => ({ ok: true, value: { commandId: 'cmd-1', result: { kind: 'success' } } }) },
|
||||
subagents: { prompt: async () => ({ messageId: 'msg-1' }) },
|
||||
},
|
||||
layout: { selectPanel(id) { selections.push(id) } },
|
||||
get() { return undefined },
|
||||
get(name) {
|
||||
if (name === 'remote.commands') return ctx.remote.commands
|
||||
if (name === 'remote.session') return ctx.remote.session
|
||||
if (name === 'remote.subagents') return ctx.remote.subagents
|
||||
return undefined
|
||||
},
|
||||
sidebarRightTabs: { register(descriptor) { tabTypes.push(descriptor); return () => {} } },
|
||||
sidebarRight: {
|
||||
openTab(kind, options) { openTabs.push({ sessionId: undefined, kind, options }) },
|
||||
|
|
@ -183,7 +188,7 @@ test('exports the panel and the seat mention helpers', () => {
|
|||
assert.equal(typeof exports.apply, 'function')
|
||||
assert.equal(exports.PANEL_ID, 'sansheng-liubu')
|
||||
assert.equal(typeof exports.SanshengPanel, 'function')
|
||||
assert.equal(JSON.stringify(exports.inject), JSON.stringify(['slots', 'sessions', 'uiWorkspace', 'uiConversation', 'modelDirectories', 'remote', 'remote.agentPresets', 'sidebarRightTabs', 'sidebarRight']))
|
||||
assert.equal(JSON.stringify(exports.inject), JSON.stringify(['slots', 'sessions', 'uiWorkspace', 'uiConversation', 'modelDirectories', 'remote', 'remote.agentPresets', 'remote.session', 'remote.subagents', 'remote.commands', 'sidebarRightTabs', 'sidebarRight']))
|
||||
})
|
||||
|
||||
test('registers the left nav row, one rail entry, the native header action and right sidebar tabs', () => {
|
||||
|
|
@ -977,6 +982,28 @@ test('宿主没有执行指令的接口时,报错要指明原因', async () =>
|
|||
assert.match(result.error, /remote.commands.execute/)
|
||||
})
|
||||
|
||||
test('指令接口挂在 ctx.get 上(官方挂法)时也照样静默执行', async () => {
|
||||
const executed = []
|
||||
const commands = {
|
||||
execute: async (agentId, line, attachments) => {
|
||||
executed.push({ agentId, line, attachments })
|
||||
return { ok: true, value: { commandId: 'cmd-9', result: { kind: 'success', text: '已固定' } } }
|
||||
},
|
||||
}
|
||||
const { host, prompts } = catalogHost({
|
||||
get: (name) => (name === 'remote.commands' ? commands : undefined),
|
||||
remote: {
|
||||
agentPresets: { list: async () => ({ ok: true, value: { presets: [] } }), select: async () => ({ ok: true }) },
|
||||
session: { selectModel: async () => ({ ok: true }) },
|
||||
},
|
||||
})
|
||||
const result = await host.routeModel('libu', { provider: 'deepseek', model: 'deepseek-chat' })
|
||||
assert.equal(result.ok, true)
|
||||
assert.equal(prompts.length, 0, '走指令就不该往会话里投提示词')
|
||||
assert.equal(executed.length, 1)
|
||||
assert.equal(executed[0].line, '/dept-model libu deepseek deepseek-chat')
|
||||
})
|
||||
|
||||
test('子会话的固定路由从面板记录里读出来当「当前模型」', async () => {
|
||||
const { exports, storage } = loadPlugin()
|
||||
storage.set('sansheng-liubu.route.gongbu', JSON.stringify({ provider: 'deepseek', model: 'deepseek-reasoner', reasoningEffort: 'high' }))
|
||||
|
|
|
|||
Loading…
Reference in New Issue