Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(wps): 面板装好了却摸不到文档工具,重连后还会一直卡在「正在处理…」

lmliheng9e1b5897fbd3
diff --git a/plugins/use-wps-office/plugin.json b/plugins/use-wps-office/plugin.json
index 13e1c8a4..fd17e3c4 100644
--- a/plugins/use-wps-office/plugin.json
+++ b/plugins/use-wps-office/plugin.json
@@ -3,7 +3,7 @@
"description_zh": "把 Adelie 的对话搬进 WPS 文字。运行时就是一个零依赖的 Node 文件:它托管 WPS 加载项的面板页,用一条本机命令通道让面板去改那份打开的文档,把这九个文档操作(读、搜、替换、插入、删除、插分隔符、新建、定位)当作 MCP 工具交给 Agent,并通过 WPS 自己的本机上架服务登记加载项。全程不出这台机器,只走回环地址,不对网络开端口。",
"short_description": "Adelie inside WPS Writer: a side panel that reads and edits the open document.",
"short_description_zh": "在 WPS 文字里开一个 Adelie 侧栏,能读能改当前这篇文档。",
- "version": "2026.10.15.1",
+ "version": "2026.10.15.3",
"category": "office-productivity",
"preinstall": false
}
diff --git a/plugins/use-wps-office/skills/wps-office/kit/adelie.mjs b/plugins/use-wps-office/skills/wps-office/kit/adelie.mjs
index 9a11f993..12919bda 100644
--- a/plugins/use-wps-office/skills/wps-office/kit/adelie.mjs
+++ b/plugins/use-wps-office/skills/wps-office/kit/adelie.mjs
@@ -266,7 +266,11 @@ export class Adelie {
);
}
- /** Write the agent's config. The server merges per key, so sending `tools` alone is safe. */
+ /**
+ * Write the agent's config. The server merges per key, so sending one key alone is safe —
+ * but only the keys it knows (`mcpServers`, `toolsBuiltin`, …); anything else is answered
+ * with a 200 and dropped, which is why the MCP entry is `mcpServers` and not `tools`.
+ */
async updateAgentConfig(config) {
const projectId = await this.projectId();
return this.json(
diff --git a/plugins/use-wps-office/skills/wps-office/kit/install.mjs b/plugins/use-wps-office/skills/wps-office/kit/install.mjs
index a6159a56..2a96ecf9 100644
--- a/plugins/use-wps-office/skills/wps-office/kit/install.mjs
+++ b/plugins/use-wps-office/skills/wps-office/kit/install.mjs
@@ -158,16 +158,17 @@ async function registerMcp(adelie, url) {
say(` ✗ 读不到 Agent 配置:${err.message}`);
return false;
}
- const servers = Array.isArray(view?.config?.tools?.mcpServers)
- ? view.config.tools.mcpServers
- : [];
+ // `mcpServers` is a top-level key of the config DTO and of the update body alike: the update
+ // endpoint merges only the keys it knows and answers 200 to everything else, so a `tools`
+ // wrapper lands nowhere and leaves an install that reported success without registering tools.
+ const servers = Array.isArray(view?.config?.mcpServers) ? view.config.mcpServers : [];
const others = servers.filter((s) => s?.name !== MCP_SERVER_NAME);
const existing = servers.find((s) => s?.name === MCP_SERVER_NAME);
const same =
existing !== undefined && JSON.stringify(existing.config) === JSON.stringify(entry.config);
if (!same) {
try {
- await adelie.updateAgentConfig({ tools: { mcpServers: [...others, entry] } });
+ await adelie.updateAgentConfig({ mcpServers: [...others, entry] });
say(
` ✓ 已写入 Agent「${adelie.config.agentId}」的配置(原有 ${others.length} 个 MCP 服务器不动)`,
);
diff --git a/plugins/use-wps-office/skills/wps-office/kit/serve.mjs b/plugins/use-wps-office/skills/wps-office/kit/serve.mjs
index e10c11c7..5c50c678 100644
--- a/plugins/use-wps-office/skills/wps-office/kit/serve.mjs
+++ b/plugins/use-wps-office/skills/wps-office/kit/serve.mjs
@@ -764,6 +764,16 @@ async function main() {
if (route === "GET /panel/events") {
const stream = startEventStream(res);
panelEventClients.add(stream);
+ // A panel that opens (or reopens) after the turn started hears no `task_state` until the
+ // next one — and a panel whose first frame never says "not running" waits forever with
+ // "正在处理…" for a turn that already finished. Say where the turn stands, right now.
+ try {
+ stream.write(
+ `data: ${JSON.stringify({ type: "status", running: translator.running, queued: 0 })}\n\n`,
+ );
+ } catch {
+ panelEventClients.delete(stream);
+ }
const timer = setInterval(() => {
try {
stream.write("event: ping\ndata: {}\n\n");
diff --git a/plugins/use-wps-office/skills/wps-office/kit/uninstall.mjs b/plugins/use-wps-office/skills/wps-office/kit/uninstall.mjs
index 7c9bd3eb..3d8ccb62 100644
--- a/plugins/use-wps-office/skills/wps-office/kit/uninstall.mjs
+++ b/plugins/use-wps-office/skills/wps-office/kit/uninstall.mjs
@@ -6,7 +6,7 @@
*
* - the WPS add-on record named `adelie_wps_panel` (disabled, not deleted — WPS keeps its
* own list, and disabling is the reversible half of what the installer did);
- * - the `wps` entry in the agent's `tools.mcpServers`;
+ * - the `wps` entry in the agent's config (`mcpServers`, a top-level key of the DTO);
* - `…\Startup\adelie-wps-bridge.cmd`.
*
* Files that hold your settings and history (`<数据根>/wps-bridge/`) are kept: pass `--purge`
@@ -69,14 +69,14 @@ async function main() {
} else {
try {
const view = await adelie.agentConfig();
- const servers = Array.isArray(view?.config?.tools?.mcpServers)
- ? view.config.tools.mcpServers
- : [];
+ // Same top-level key as the installer writes (see its comment): a `tools` wrapper is
+ // accepted with a 200 and ignored, which would leave the entry in place.
+ const servers = Array.isArray(view?.config?.mcpServers) ? view.config.mcpServers : [];
const kept = servers.filter((s) => s?.name !== MCP_SERVER_NAME);
if (kept.length === servers.length) {
say(` ✓ 配置里本来就没有「${MCP_SERVER_NAME}」。`);
} else {
- await adelie.updateAgentConfig({ tools: { mcpServers: kept } });
+ await adelie.updateAgentConfig({ mcpServers: kept });
say(` ✓ 已移除(其余 ${kept.length} 个 MCP 服务器不动)。`);
}
} catch (err) {
diff --git a/plugins/use-wps-office/test/bridge.test.mjs b/plugins/use-wps-office/test/bridge.test.mjs
index bb1117d2..a248897e 100644
--- a/plugins/use-wps-office/test/bridge.test.mjs
+++ b/plugins/use-wps-office/test/bridge.test.mjs
@@ -431,6 +431,15 @@ test("Adelie 的流被归一化成面板要的几种事件", async () => {
const events = await sseClient(`${bang.url}/panel/events`);
await waitFor("桥订阅上 Adelie 的会话流", () => api.connectedStreams() > 0);
+ // The first frame tells a freshly connected panel what the turn is doing right now: without
+ // it a panel has nothing to correct its own "正在处理…" with, and keeps showing a turn that
+ // ended before it ever connected.
+ assert.deepEqual(await events.next((e) => e.type === "status"), {
+ type: "status",
+ running: false,
+ queued: 0,
+ });
+
api.emit({ type: "task_state", state: "running", queued: 0 });
assert.deepEqual(await events.next((e) => e.type === "status"), {
type: "status",
@@ -438,6 +447,16 @@ test("Adelie 的流被归一化成面板要的几种事件", async () => {
queued: 0,
});
+ // …and a panel that connects in the middle of a turn is told about that one, because the next
+ // `task_state` is minutes away and until then the judge of "is it busy" is this frame alone.
+ const late = await sseClient(`${bang.url}/panel/events`);
+ assert.deepEqual(await late.next((e) => e.type === "status"), {
+ type: "status",
+ running: true,
+ queued: 0,
+ });
+ await late.close();
+
api.emit({
type: "model_msg",
payload: { type: "partial_text", event_type: "delta", text: "好的," },
diff --git a/plugins/use-wps-office/test/install.test.mjs b/plugins/use-wps-office/test/install.test.mjs
index 00284ca3..13c31d95 100644
--- a/plugins/use-wps-office/test/install.test.mjs
+++ b/plugins/use-wps-office/test/install.test.mjs
@@ -52,11 +52,20 @@ function readJson(req) {
});
}
-/** A fake Adelie that keeps the agent config in memory and records every write. */
+/**
+ * A fake Adelie that keeps the agent config in memory and records every write.
+ *
+ * The shape is the real DTO's (`packages/server/src/api/types.ts` → `AgentConfigDto`): MCP
+ * servers sit at the *top level* of `config`, there is no `tools` wrapper around them, and the
+ * update endpoint merges only the keys it knows — a body carrying `tools` is answered with a
+ * 200 and dropped on the floor. A kinder fake would hide exactly the mistake this file exists
+ * to catch, so the fake has to be as unforgiving as the server.
+ */
function fakeAdelie() {
const state = {
config: {
- tools: { builtin: ["read_file"], mcpServers: [{ name: "other", config: { url: "x" } }] },
+ toolsBuiltin: [{ name: "read_file" }],
+ mcpServers: [{ name: "other", config: { url: "x" } }],
},
writes: [],
probes: [],
@@ -75,11 +84,10 @@ function fakeAdelie() {
if (req.method === "PUT") {
const body = await readJson(req);
state.writes.push(body);
- state.config = {
- ...state.config,
- ...body.config,
- tools: { ...state.config.tools, ...(body.config?.tools ?? {}) },
- };
+ const next = body?.config ?? {};
+ if (Array.isArray(next.mcpServers)) {
+ state.config = { ...state.config, mcpServers: next.mcpServers };
+ }
return json({ config: state.config });
}
}
@@ -162,7 +170,7 @@ test("安装:把桥登记成一个 MCP 服务器,别的不动,并真的连
assert.match(out, /已写入 Agent/);
assert.match(out, /Adelie 连上了/);
- const servers = api.state.config.tools.mcpServers;
+ const servers = api.state.config.mcpServers;
assert.deepEqual(
servers.map((s) => s.name).sort(),
["other", "wps"],
@@ -201,14 +209,24 @@ test("再装一次:不重复写、不重复登记", async () => {
assert.match(out, /已经是这一条/);
assert.match(out, /已经在跑/);
assert.equal(api.state.writes.length, before, "第二次安装不该再写配置");
- assert.equal(api.state.config.tools.mcpServers.length, 2);
+ assert.equal(api.state.config.mcpServers.length, 2);
});
test("卸载:摘掉桥的工具,其余保留", async () => {
+ // The entry is seeded here rather than leaned on from the install tests above: this test is
+ // about the removal, and a fake that quietly ignores the wrong key must not be able to make
+ // it pass by having nothing to remove.
+ api.state.config = {
+ ...api.state.config,
+ mcpServers: [
+ ...api.state.config.mcpServers.filter((s) => s.name !== "wps"),
+ { name: "wps", config: { transport: "http", url: "http://127.0.0.1:1/mcp" } },
+ ],
+ };
const { code, out } = await run(UNINSTALL, ["--root", root, "--adelie", adelieUrl, "--no-wps"]);
assert.equal(code, 0, out);
assert.deepEqual(
- api.state.config.tools.mcpServers.map((s) => s.name),
+ api.state.config.mcpServers.map((s) => s.name),
["other"],
);
assert.ok(fs.existsSync(path.join(root, "wps-bridge", "config.json")), "默认要留着设置和日志");