Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(mcp-control): expose agent/pendingInteractive in the reviewed catalog

Michel Ruffieuxc5c5db146002
diff --git a/apps/desktop/electron/main/mcp-control.ts b/apps/desktop/electron/main/mcp-control.ts
index 301abd96e..55b661ab5 100644
--- a/apps/desktop/electron/main/mcp-control.ts
+++ b/apps/desktop/electron/main/mcp-control.ts
@@ -240,6 +240,7 @@ const CONTROL_OPERATION_SPECS: OperationSpec[] = [
spec("closeBehaviorGet", "window/closeBehavior/get", "Read close behavior.", "read", []),
spec("scheduledList", "scheduled/list", "List scheduled tasks.", "read", []),
spec("toolResolvePermission", "tool/resolvePermission", "Resolve a pending tool permission request.", "dangerous", ["resolution"]),
+ spec("pendingInteractive", "agent/pendingInteractive", "List pending Agent questions and tool permission requests.", "read", ["input"]),
spec("askToolResolve", "agent/askTool/resolve", "Answer an Agent question.", "dangerous", ["resolution"]),
spec("plansPending", "plans/pending", "List pending Plan or Goal approvals.", "read", ["input"]),
spec("plansResolve", "plans/resolve", "Approve or reject a Plan or Goal checkpoint.", "dangerous", ["resolution"]),
diff --git a/apps/desktop/test/mcp-control.test.mjs b/apps/desktop/test/mcp-control.test.mjs
index 921bbac2d..2f7d223a0 100644
--- a/apps/desktop/test/mcp-control.test.mjs
+++ b/apps/desktop/test/mcp-control.test.mjs
@@ -50,6 +50,34 @@ test("the plugin and MCP paths share desktop operation validation", async () =>
]);
});
+test("agent/pendingInteractive is a read operation that exposes the requestIds the resolve operations need", async () => {
+ const calls = [];
+ const pending = {
+ asks: [{ requestId: "r1", toolCallId: "t1", questions: [] }],
+ permissions: [],
+ };
+ const controller = createMcpControlController({
+ channels: {
+ pendingInteractive: "pi-desktop/agent/pendingInteractive",
+ },
+ invoke: async (channel, args) => {
+ calls.push({ channel, args });
+ return pending;
+ },
+ });
+
+ const listed = controller.operations.find((operation) => operation.id === "agent/pendingInteractive");
+ assert.equal(listed?.risk, "read");
+ const result = await controller.invoke({
+ operation: "agent/pendingInteractive",
+ args: [{ sessionId: "s1" }],
+ });
+ assert.deepEqual(calls, [
+ { channel: "pi-desktop/agent/pendingInteractive", args: [{ sessionId: "s1" }] },
+ ]);
+ assert.deepEqual(result, pending);
+});
+
async function post(url, token, body, headers = {}) {
const response = await fetch(url, {
method: "POST",
diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.md
index 20e7656ce..69ac7542f 100644
--- a/docs/spec/07-plugins/03-plugin-api.md
+++ b/docs/spec/07-plugins/03-plugin-api.md
@@ -1295,6 +1295,14 @@ open an existing durable session. Plugin-originated `session/create` and
`agent/prompt` calls refresh session state without changing the active
renderer session; `session/open` is explicit navigation.
+The catalog also includes the read `agent/pendingInteractive({ sessionId })`
+(`sessionId` is required), which returns `{ asks, permissions }`: the session's
+pending ask-tool and tool permission requests, the same payload the renderer
+reads to rebuild its cards. A plugin uses it to discover the `requestId` that
+the dangerous `agent/askTool/resolve` and `tool/resolvePermission` operations
+need. Like every shared catalog operation, it is also reachable through the
+local MCP control plane.
+
This is the first-party plugin gateway to the reviewed operation catalog shared
with the opt-in local MCP control plane (ADR 0203 / D370). The two catalogs
differ only for operations marked plugin-only: the six
diff --git a/docs/zh-CN/spec/07-plugins/03-plugin-api.md b/docs/zh-CN/spec/07-plugins/03-plugin-api.md
index 30fb78ba7..e85be700b 100644
--- a/docs/zh-CN/spec/07-plugins/03-plugin-api.md
+++ b/docs/zh-CN/spec/07-plugins/03-plugin-api.md
@@ -1073,6 +1073,12 @@ pi.desktop.invoke(input: {
`session/create` 和 `agent/prompt` 只刷新会话状态,不改变渲染器当前活动会话;
`session/open` 则是显式导航。
+目录还包含只读操作 `agent/pendingInteractive({ sessionId })`(`sessionId` 必填),
+返回 `{ asks, permissions }`,即该会话待处理的 ask 工具请求与工具权限请求,与渲染器
+重建卡片时读取的内容相同。插件借此获取危险操作 `agent/askTool/resolve` 和
+`tool/resolvePermission` 所需的 `requestId`。与其他共享目录操作一样,它也可通过
+本地 MCP 控制平面调用。
+
这是第一方插件通往与可选启用的本地 MCP 控制平面共用同一份已审查操作目录的
网关(ADR 0203 / D370)。两份目录的差异仅在于标记为 plugin-only 的操作:六个
`session/collaboration/*` 操作可以通过该网关调用,却被刻意排除在 MCP 可见目录