Skip to content

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

docs(plugins): document the renderer slot contract

vastsa81c4fb2342de
diff --git a/apps/desktop/resources/skills/plugin-development.md b/apps/desktop/resources/skills/plugin-development.md
index c94b775c0..71a17ce27 100644
--- a/apps/desktop/resources/skills/plugin-development.md
+++ b/apps/desktop/resources/skills/plugin-development.md
@@ -109,6 +109,49 @@ The panel receives `window.pluginBridge`, not `pi`. Use the fixed bridge channel
Arbitrary Electron IPC and
general custom panel RPC are not exposed.
+## Renderer slots
+
+A panel draws in its own window. A plugin that instead draws inside PI-Desktop's own window —
+controls in the composer, items on a message's action bar, a card for its own agent tool, a
+corner layer — declares a renderer entry module and asks for `renderer.extension`:
+
+```json
+{
+ "permissions": ["renderer.extension"],
+ "renderer": "renderer/index.mjs",
+ "rendererActions": ["plugin.call", "composer.insertText"],
+ "rendererCallMethods": ["openWorkspace"]
+}
+```
+
+The entry is an ES module that the host evaluates in its own window; the host hands it the
+renderer API, and the module registers components with `pi.slots.register({ slot, component })`.
+A component is a React function component that imports React from the host's import map
+(`import React from "react"`). Every registration returns a disposer and all of them run when
+the plugin unloads. The slots are:
+
+- `composerControl` — controls in the composer toolbar; `positions` picks left, right, or both
+- `composerTrigger` — the list behind one of the composer's trigger symbols: you supply the
+ items, the host draws the list
+- `userAction` / `assistantAction` — items on a message's action bar; `positions` picks a side
+- `entryExtra` — a block below an assistant reply
+- `toolCard` — the card for calls of one of your own agent tools; `toolName` names it
+- `blockRenderer` — a fenced code block tagged `<your-plugin-id>:<lang>`
+
+A dialog you draw yourself is not a slot: `pi.ui.openLayer()` hands you a layer to render into.
+Styles go through `pi.ui.injectStyle`, and the host is otherwise reached with `pi.dispatch`.
+
+Declare what you reach for. `rendererActions` whitelists the actions a component may dispatch —
+`plugin.call`, `composer.insertText`, `composer.readDraft`, `composer.replaceDraft`,
+`attachments.add`, `attachments.list`, `attachments.remove`, at most 16 — and
+`rendererCallMethods` whitelists the method names your `onRendererCall` answers for
+`plugin.call`, at most 32. A call outside those lists is refused, so a component can only act
+inside its own plugin. The module shares PI-Desktop's own document, so this is a contract rather
+than a sandbox: enable only code you trust.
+
+`examples/plugins/ui-slots-lab` mounts a sample on every slot, and
+`packages/plugin-sdk/src/renderer.ts` carries the types and the props each slot receives.
+
## Permissions
Every permission is declared in the manifest and granted at install time; an undeclared call
@@ -116,8 +159,8 @@ fails at runtime. Ask for the least you need — the plugins page shows the risk
user.
- High risk: `net.fetch`, `fs.write`, `fs.delete`, `agent.prompt.inject`,
- `agent.tool.register`, `agent.complete`, `session.read`, `mcp.server.local`,
- `mcp.server.remote`
+ `agent.tool.register`, `agent.complete`, `renderer.extension`, `session.read`,
+ `mcp.server.local`, `mcp.server.remote`
- Medium: `fs.read`, `clipboard.read`, `clipboard.write`, `shell.openExternal`,
`background.service`, `bus.publish`, `bus.subscribe`, `models.list`, `usage.read`
- Low: `ui.panel`, `ui.theme`, `notify` (Toast and best-effort native notifications)
diff --git a/docs/plugin-development.md b/docs/plugin-development.md
index e7da24c0f..8112a22e8 100644
--- a/docs/plugin-development.md
+++ b/docs/plugin-development.md
@@ -23,6 +23,7 @@ A plugin can contribute one or more of these capabilities:
| MCP server | Tools discovered from a local or remote MCP server | `contributes.mcpServers`, an MCP permission |
| Service | Resident work supervised by the host | `contributes.services`, `background.service` permission |
| Message bus | Typed-by-convention events between plugins | `contributes.bus`, bus permissions |
+| Renderer slot | UI drawn inside the app's own window: composer controls, message action bars, blocks below a reply, tool cards, code-block renderers, corner layers | `renderer`, `renderer.extension` permission, `packages/plugin-sdk/src/renderer.ts` |
Plugin entry code runs in a dedicated Node process. Panels run in sandboxed,
context-isolated Electron windows with no Node integration. Calls from either
@@ -808,6 +809,77 @@ What to know before you use it:
warning toast without blocking the import; the row shows a load error only if
the extension actually fails to load.
+
+### 6.12 Renderer slots
+
+Every surface above is a window or a page the plugin owns. A **renderer module**
+draws inside PI-Desktop's own window instead: controls in the composer toolbar,
+items on a message's action bar, a block below an assistant reply, the card for
+one of your own Agent tools, a renderer for a fenced code block, or a corner
+layer you manage yourself.
+
+```json
+{
+ "permissions": ["renderer.extension"],
+ "renderer": "renderer/index.mjs",
+ "rendererActions": ["plugin.call", "composer.insertText"],
+ "rendererCallMethods": ["openWorkspace"]
+}
+```
+
+The entry exports `onLoad(pi)`, the host evaluates it in its own window, and
+every load is handed a fresh `pi`. Components read the host through the module's
+own copy of it, because a component's props carry data and nothing else:
+
+```js
+import React from "react";
+
+let host = null;
+
+function InsertButton() {
+ return React.createElement(
+ "button",
+ { onClick: () => host.dispatch("composer.insertText", { text: "hello" }) },
+ "Insert",
+ );
+}
+
+export function onLoad(pi) {
+ host = pi;
+ pi.slots.register({ slot: "composerControl", component: InsertButton, positions: ["right"] });
+}
+```
+
+- `composerControl` — controls in the composer toolbar; `positions: ["left"]`
+ or `["right"]` selects a side, omitted means both
+- `composerTrigger` — the item list behind one of the composer's trigger
+ symbols: `{ slot: "composerTrigger", trigger: "#", items }`, and the host draws
+ the list
+- `userAction` / `assistantAction` — items on a message's action bar
+- `entryExtra` — a block below an assistant reply
+- `toolCard` — the card for calls of one of your own Agent tools; `toolName`
+ names it
+- `blockRenderer` — a fenced block tagged `<your-plugin-id>:<lang>`; `language`
+ names the tag
+
+A dialog you draw yourself is not a slot: `pi.ui.openLayer()` hands you a layer
+to render into, and the component draws inside it. Styles go through
+`pi.ui.injectStyle`, and `react` / `react-dom` resolve to the app's copies
+through the window's import map, so no bundled React is needed.
+
+`rendererActions` whitelists what a component may dispatch — `plugin.call`,
+`composer.insertText`, `composer.readDraft`, `composer.replaceDraft`,
+`attachments.add`, `attachments.list`, `attachments.remove`, at most 16 — and
+`rendererCallMethods` whitelists the method names `onRendererCall` answers for
+`plugin.call`, at most 32. A dispatch outside those lists is refused with
+`PLUGIN_ACTION_UNDECLARED` and a word outside the vocabulary with
+`PLUGIN_ACTION_UNKNOWN`. The module runs in the app's own document with the
+app's own React, so `renderer.extension` is a high-risk permission: grant it
+only to code you trust.
+
+`examples/plugins/ui-slots-lab` mounts a sample on every slot.
+`packages/plugin-sdk/src/renderer.ts` carries the types and each slot's props,
+and the manifest side is [spec 07-plugins/02 §3.2](spec/07-plugins/02-plugin-manifest-schema.md).
## 7. Permission design
Permissions are both declared in `manifest.json` and granted by the user.
@@ -817,7 +889,7 @@ Undeclared or ungranted API calls fail with `PERMISSION_DENIED`.
|---|---|
| Low | `ui.panel`, `ui.view`, `ui.theme`, `notify` |
| Medium | `clipboard.read`, `clipboard.write`, `fs.read`, `shell.openExternal`, `background.service`, `bus.publish`, `bus.subscribe`, `audio.playback.background`, `keyboard.globalShortcut` |
-| High | `fs.write`, `fs.delete`, `agent.tool.register`, `agent.prompt.inject`, `net.fetch`, `mcp.server.local`, `mcp.server.remote`, `audio.capture.background`, `net.websocket` |
+| High | `fs.write`, `fs.delete`, `agent.tool.register`, `agent.prompt.inject`, `renderer.extension`, `net.fetch`, `mcp.server.local`, `mcp.server.remote`, `audio.capture.background`, `net.websocket` |
`keyboard.globalShortcut` and `net.websocket` are implemented. `pi.audio.*`
exists and is callable, and its methods keep their permission gate, but this
diff --git a/docs/spec/07-plugins/02-plugin-manifest-schema.md b/docs/spec/07-plugins/02-plugin-manifest-schema.md
index d7e1d6aa4..9f70b6f4e 100644
--- a/docs/spec/07-plugins/02-plugin-manifest-schema.md
+++ b/docs/spec/07-plugins/02-plugin-manifest-schema.md
@@ -53,6 +53,9 @@ type PluginManifestV1 = {
repository?: string;
icon?: string; // relative path
main?: string; // plugin runtime entry
+ renderer?: string; // module the host evaluates to mount UI slots (§3.2)
+ rendererActions?: string[]; // actions a renderer component may dispatch, at most 16
+ rendererCallMethods?: string[]; // onRendererCall methods plugin.call may reach, at most 32
ui?: PluginUiConfig;
contributes?: PluginContributes;
permissions?: PluginPermission[];
@@ -137,6 +140,47 @@ Rules:
(`pi.app.getLocale`, `appearance:changed`); the plugin localizes itself
(ADR 0280).
+### 3.2 Renderer module (`renderer`)
+
+`renderer` names an ES module inside the package that the host evaluates in its
+own window to mount UI slot components:
+
+- `composerControl` — additive controls in the composer toolbar
+- `composerTrigger` — the item list behind one of the composer's trigger
+ symbols (data, not a component: the host draws the list)
+- `userAction` / `assistantAction` — additive items on a message's action bar
+- `entryExtra` — an additive block below an assistant reply
+- `toolCard` — the card for calls of one of the plugin's own Agent tools
+- `blockRenderer` — the renderer for a fenced block tagged `<pluginId>:<lang>`
+
+`pi.slots.register` returns a disposer, and every registration is withdrawn when
+the plugin unloads. A self-drawn dialog is not a slot: the plugin opens a layer
+with `pi.ui.openLayer` and draws into it (`docs/plugin-plan/ui/`).
+
+The module runs in the host's own realm, so this is a contract and not a sandbox
+boundary; the two whitelists are what keeps a component inside its own plugin.
+`rendererActions` lists the actions a component may dispatch, capped at 16, from
+the fixed vocabulary `plugin.call`, `composer.insertText`, `composer.readDraft`,
+`composer.replaceDraft`, `attachments.add`, `attachments.list`,
+`attachments.remove` — a word outside it is refused as `PLUGIN_ACTION_UNKNOWN`,
+and a word the manifest does not list as `PLUGIN_ACTION_UNDECLARED`.
+`rendererCallMethods` lists the method names the plugin's `onRendererCall`
+answers for `plugin.call`, capped at 32; the host adds the calling plugin's id,
+so a component only ever reaches its own plugin.
+
+```json
+{
+ "permissions": ["renderer.extension"],
+ "renderer": "renderer/index.mjs",
+ "rendererActions": ["plugin.call", "composer.insertText"],
+ "rendererCallMethods": ["openWorkspace"]
+}
+```
+
+Slot names, props and the caps are in `packages/plugin-sdk/src/renderer.ts`
+(`PLUGIN_RENDERER_SLOTS`, `PLUGIN_RENDERER_ACTIONS`, `PLUGIN_SLOT_POSITIONS`),
+and a worked example is `examples/plugins/ui-slots-lab`.
+
## 4. contributes
```ts
@@ -332,6 +376,7 @@ type PluginPermission =
| "fs.delete"
| "agent.tool.register"
| "agent.prompt.inject"
+ | "renderer.extension"
| "provider.register"
| "provider.oauth"
| "net.fetch"
@@ -556,6 +601,11 @@ MVP may implement only:
`contributes.commands`; `default`, when present, uses the same
modifier-plus-key / F-key grammar as `shortcut` settings
+19. `renderer` must be a `.js` or `.mjs` file inside the package;
+ `rendererActions` (at most 16) and `rendererCallMethods` (at most 32) are
+ lists of non-empty names and require `renderer`. Declaring any of the three
+ needs the `renderer.extension` permission (§3.2)
+
## 8. Example: minimal plugin
```json
diff --git a/docs/spec/07-plugins/13-plugin-permissions-matrix.md b/docs/spec/07-plugins/13-plugin-permissions-matrix.md
index 110bae9e0..8045a2abd 100644
--- a/docs/spec/07-plugins/13-plugin-permissions-matrix.md
+++ b/docs/spec/07-plugins/13-plugin-permissions-matrix.md
@@ -24,6 +24,7 @@ Provide a permission–capability–risk–default-policy reference table for re
| `agent.tool.register` | high | Register an agent tool | Confirm at install | Tool execution is audited separately |
| `agent.prompt.inject` | high | Inject a system prompt; activates `contributes.skills` | Deny by default / strong confirmation | Easily leads to behavior hijacking |
| `agent.extension` | high | Run `contributes.agentExtensions` modules inside the agent process | Explicit confirmation; local imports and development plugins only in v1.1 | Same access as the agent's own tools; the plugin sandbox does not apply (spec 16) |
+| `renderer.extension` | high | `manifest.renderer` is evaluated inside the host renderer to mount UI slots; `rendererActions` and `rendererCallMethods` open the actions and `onRendererCall` methods that module may use | Explicit confirmation; local imports and development plugins only in v1.1, matching `agent.extension` | The module shares the host's own document, so a slot is a contract rather than a sandbox. A component may dispatch only the reviewed vocabulary (`plugin.call`, `composer.insertText`, `composer.readDraft`, `composer.replaceDraft`, `attachments.add` / `list` / `remove`), capped at 16, and `plugin.call` reaches only the calling plugin's own `onRendererCall` methods, capped at 32. Registrations are withdrawn when the plugin unloads; a self-drawn dialog lives in a layer the plugin opened itself |
| `provider.register` | high | `contributes.providers` become rows in the native provider list, owned by the plugin and refreshed from the manifest on load | Explicit confirmation; local imports and development plugins only in v1.1, matching `agent.extension` | The user path refuses edits to the row (`PROVIDER_OWNED_BY_PLUGIN`); API-key credentials stay in the Host secret store under the usual provider refs |
| `provider.oauth` | high | `onProviderOAuth`; host-rendered `pi.providers.oauth.prompt` / `notify` for a declared OAuth provider | Explicit confirmation | Required with `provider.register` for `authKind: "oauth"`. The callback can read and refresh only that contribution's encrypted credential. The Host keeps refresh tokens out of the renderer and Agent Runtime. Host-mediated callback egress still needs `net.fetch` and `manifest.net.domains`; plugin entry code itself is not an OS sandbox. One account is stored per provider contribution; sign out clears it |
| `net.fetch` | high | `net.fetch` | Deny by default | Confined to `manifest.net.domains`; an empty or malformed list means no egress (§2A) |
@@ -134,6 +135,7 @@ so "Modify the files it lists" is followed by the list.
| `agent.tool.register` | Provide executable tools to the AI Agent | 向 AI Agent 提供可执行工具 |
| `agent.prompt.inject` | Adjust agent instructions | 调整智能体指令 |
| `agent.extension` | Run code inside the agent | 在 agent 内运行代码 |
+| `renderer.extension` | Draw UI in chat slots | 在聊天插槽绘制界面 |
| `net.fetch` | Access the network | 访问网络 |
| `shell.openExternal` | Open external links | 打开外部链接 |
| `ui.theme` | Provide a theme | 提供主题 |
diff --git a/docs/zh-CN/plugin-development.md b/docs/zh-CN/plugin-development.md
index 8f63c732a..c3d887eb9 100644
--- a/docs/zh-CN/plugin-development.md
+++ b/docs/zh-CN/plugin-development.md
@@ -23,6 +23,7 @@
| MCP 服务器 | 从本地或远程 MCP 服务器发现的工具 | `contributes.mcpServers`,MCP 权限 |
| 服务 | 驻地工作由主人监督 | `contributes.services`、`background.service` 权限 |
| 消息总线 | 插件之间按约定类型化事件 | `contributes.bus`,总线权限 |
+| 渲染器插槽 | 在应用自身窗口内绘制界面:输入区控件、消息操作栏、回复下方区块、工具卡、代码块渲染器、角落浮层 | `renderer`、`renderer.extension` 权限、`packages/plugin-sdk/src/renderer.ts` |
插件入口代码在专用的 Node 进程中运行。面板在沙盒中运行,
上下文隔离的 Electron 窗口,没有 Node 集成。来自任一方的呼叫
@@ -694,6 +695,65 @@ export default function (pi) {
Electron 头重建(`npx @electron/rebuild -v <electron 版本>`)即可修复。安装失败会清理
部分依赖并显示警告 toast,不会阻塞导入;只有扩展实际加载失败时插件行才显示 load error。
+### 6.11 渲染器插槽
+
+上面每一种界面都是插件自己拥有的窗口或页面。**渲染模块**则绘制在 PI-Desktop 自己的窗口里:
+输入区工具栏上的控件、消息操作栏上的条目、助手回复下方的区块、自有 Agent 工具的卡片、
+代码块的渲染器,或者你自己管理的角落浮层。
+
+```json
+{
+ "permissions": ["renderer.extension"],
+ "renderer": "renderer/index.mjs",
+ "rendererActions": ["plugin.call", "composer.insertText"],
+ "rendererCallMethods": ["openWorkspace"]
+}
+```
+
+入口导出 `onLoad(pi)`,宿主在自己的窗口中求值它,并且每次加载都会给一份新的 `pi`。
+组件的 props 只携带数据,因此组件通过模块自己保存的那份 `pi` 访问宿主:
+
+```js
+import React from "react";
+
+let host = null;
+
+function InsertButton() {
+ return React.createElement(
+ "button",
+ { onClick: () => host.dispatch("composer.insertText", { text: "hello" }) },
+ "Insert",
+ );
+}
+
+export function onLoad(pi) {
+ host = pi;
+ pi.slots.register({ slot: "composerControl", component: InsertButton, positions: ["right"] });
+}
+```
+
+- `composerControl` —— 输入区工具栏上的控件;`positions: ["left"]` 或 `["right"]` 选择一侧,省略即两侧
+- `composerTrigger` —— 输入区某个触发符背后的条目列表:`{ slot: "composerTrigger", trigger: "#", items }`,列表由宿主绘制
+- `userAction` / `assistantAction` —— 消息操作栏上的条目
+- `entryExtra` —— 助手回复下方的区块
+- `toolCard` —— 自有 Agent 工具调用的卡片;用 `toolName` 指定工具
+- `blockRenderer` —— 形如 `<你的插件id>:<lang>` 的代码块渲染器;`language` 指定标签
+
+自绘弹窗不是插槽:`pi.ui.openLayer()` 交给你一个可以渲染的层,组件在其中绘制。样式通过
+`pi.ui.injectStyle` 注入;`react` / `react-dom` 会通过窗口的 import map 解析到应用自带的副本,
+不需要打包自己的 React。
+
+`rendererActions` 限定组件可派发的动作——`plugin.call`、`composer.insertText`、
+`composer.readDraft`、`composer.replaceDraft`、`attachments.add`、`attachments.list`、
+`attachments.remove`,最多 16 个——`rendererCallMethods` 限定 `onRendererCall` 为
+`plugin.call` 应答的方法名,最多 32 个。白名单之外的派发返回 `PLUGIN_ACTION_UNDECLARED`,
+词表之外的词返回 `PLUGIN_ACTION_UNKNOWN`。模块与应用同文档、共用同一份 React,因此
+`renderer.extension` 是高风险权限:只授予你信任的代码。
+
+`examples/plugins/ui-slots-lab` 在每个插槽上都挂了一个样例。
+`packages/plugin-sdk/src/renderer.ts` 里有类型和各插槽的 props,manifest 侧见
+[规格 07-plugins/02 §3.2](spec/07-plugins/02-plugin-manifest-schema.md)。
+
## 7.权限设计
权限均在 `manifest.json` 中声明并由用户授予。
@@ -703,7 +763,7 @@ export default function (pi) {
|---|---|
| 低 | `ui.panel`、`ui.theme`、`notify` |
| 中等 | `clipboard.read`、`clipboard.write`、`fs.read`、`shell.openExternal`、`background.service`、`bus.publish`、`bus.subscribe`、`audio.playback.background`、`keyboard.globalShortcut` |
-| 高 | `fs.write`、`fs.delete`、`agent.tool.register`、`agent.prompt.inject`、`net.fetch`、`mcp.server.local`、`mcp.server.remote`、`audio.capture.background`、`net.websocket` |
+| 高 | `fs.write`、`fs.delete`、`agent.tool.register`、`agent.prompt.inject`、`renderer.extension`、`net.fetch`、`mcp.server.local`、`mcp.server.remote`、`audio.capture.background`、`net.websocket` |
`keyboard.globalShortcut` 与 `net.websocket` 已实现。`pi.audio.*` 已经存在并且
可以调用,其方法仍由权限把关,但当前宿主还没有设备后端:获得授权的调用会以
diff --git a/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md b/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md
index 633c5e58b..3e66624a0 100644
--- a/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md
+++ b/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md
@@ -38,6 +38,9 @@ type PluginManifestV1 = {
repository?: string;
icon?: string; // relative path
main?: string; // plugin runtime entry
+ renderer?: string; // 宿主求值以挂载 UI 插槽的模块(§3.2)
+ rendererActions?: string[]; // 渲染组件可派发的动作,最多 16 个
+ rendererCallMethods?: string[]; // plugin.call 可触达的 onRendererCall 方法,最多 32 个
ui?: PluginUiConfig;
contributes?: PluginContributes;
permissions?: PluginPermission[];
@@ -108,6 +111,41 @@ locale 声明。扩展页、插件启动器和市场(从 catalog 条目读取
视图、widget、生成式设置、toast、运行时命令标题——不在这里翻译。宿主只发布当前
语言(`pi.app.getLocale`、`appearance:changed`),由插件自行本地化(ADR 0280)。
+### 3.2 渲染模块(`renderer`)
+
+`renderer` 指向包内的一个 ES 模块,宿主会在自己的窗口中求值它,用来挂载 UI 插槽组件:
+
+- `composerControl` —— 输入区工具栏上的附加控件
+- `composerTrigger` —— 输入区某个触发符背后的条目列表(是数据不是组件:列表由宿主绘制)
+- `userAction` / `assistantAction` —— 消息操作栏左右两侧的附加项
+- `entryExtra` —— 助手回复下方的附加区块
+- `toolCard` —— 插件自有 Agent 工具调用的卡片
+- `blockRenderer` —— 形如 `<pluginId>:<lang>` 的代码块的渲染器
+
+`pi.slots.register` 返回一个注销函数,插件卸载时所有注册都会被撤销。自绘弹窗不是插槽:
+插件用 `pi.ui.openLayer` 打开一个层并在其中绘制(`docs/plugin-plan/ui/`)。
+
+模块与宿主同文档运行,因此这是契约而不是沙箱边界;真正把组件限制在自己插件内的,是两份白名单。
+`rendererActions` 列出组件可以派发的动作,最多 16 个,取自固定词表 `plugin.call`、
+`composer.insertText`、`composer.readDraft`、`composer.replaceDraft`、`attachments.add`、
+`attachments.list`、`attachments.remove`——词表之外返回 `PLUGIN_ACTION_UNKNOWN`,
+词表之内但未声明的返回 `PLUGIN_ACTION_UNDECLARED`。`rendererCallMethods` 列出插件的
+`onRendererCall` 为 `plugin.call` 应答的方法名,最多 32 个;宿主会注入调用方插件 id,
+因此组件只能触达自己的插件。
+
+```json
+{
+ "permissions": ["renderer.extension"],
+ "renderer": "renderer/index.mjs",
+ "rendererActions": ["plugin.call", "composer.insertText"],
+ "rendererCallMethods": ["openWorkspace"]
+}
+```
+
+插槽名、属性与上限见 `packages/plugin-sdk/src/renderer.ts`
+(`PLUGIN_RENDERER_SLOTS`、`PLUGIN_RENDERER_ACTIONS`、`PLUGIN_SLOT_POSITIONS`),
+完整示例见 `examples/plugins/ui-slots-lab`。
+
## 4. 贡献
```ts
@@ -276,6 +314,7 @@ type PluginPermission =
| "fs.delete"
| "agent.tool.register"
| "agent.prompt.inject"
+ | "renderer.extension"
| "provider.register"
| "net.fetch"
| "net.anyHost"
@@ -474,6 +513,10 @@ MVP 只能实现:
`contributes.commands` 里;`default` 若存在,使用与 `shortcut` 设置相同的
修饰键加按键 / F 键语法
+19. `renderer` 必须是包内的 `.js` 或 `.mjs` 文件;`rendererActions`(最多 16 条)与
+ `rendererCallMethods`(最多 32 条)是非空名字列表,且必须先有 `renderer` 才能声明。
+ 三者中声明任何一个都需要 `renderer.extension` 权限(§3.2)
+
## 8. 示例:最小插件
```json
diff --git a/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md b/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md
index a40b66767..83b9ac2ae 100644
--- a/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md
+++ b/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md
@@ -27,6 +27,7 @@
| `agent.tool.register` | 高 | 注册代理工具 | 安装时确认 | 工具执行情况单独审核 |
| `agent.prompt.inject` | 高 | 注入系统提示符;激活 `contributes.skills` | 默认拒绝/强确认 | 容易导致行为劫持 |
| `agent.extension` | 高 | 在 agent 进程内运行 `contributes.agentExtensions` 模块 | 显式确认;v1.1 仅限本地导入和开发插件 | 与 agent 自身工具同等权限;插件沙箱不适用(规格 16) |
+| `renderer.extension` | 高 | 在宿主渲染进程中执行 `manifest.renderer` 以挂载 UI 插槽;`rendererActions` 与 `rendererCallMethods` 决定该模块可以派发的动作与 `onRendererCall` 方法 | 显式确认;v1.1 仅限本地导入和开发插件,与 `agent.extension` 一致 | 模块与 PI-Desktop 同文档运行,因此插槽是契约而不是沙箱。组件只能派发经过审查的动作词表(`plugin.call`、`composer.insertText`、`composer.readDraft`、`composer.replaceDraft`、`attachments.add` / `list` / `remove`),最多 16 个;`plugin.call` 只能触达调用者自己插件的 `onRendererCall` 方法,最多 32 个。插件卸载时注册会被撤销;自绘弹窗位于插件自己打开的层中 |
| `provider.register` | 高 | `contributes.providers` 成为原生 Provider 列表中的行,归插件所有并在每次加载时按 manifest 刷新 | 显式确认;v1.1 仅限本地导入和开发插件,与 `agent.extension` 一致 | 用户路径拒绝编辑该行(`PROVIDER_OWNED_BY_PLUGIN`);API key 凭据仍存放在 Host secret store 的常规 provider 引用下 |
| `provider.oauth` | 高 | 已声明 OAuth provider 的 `onProviderOAuth`;宿主渲染的 `pi.providers.oauth.prompt` / `notify` | 显式确认 | `authKind: "oauth"` 需要与 `provider.register` 一起授予。回调只能读取和刷新该 provider 声明自己的加密凭据。Host 会把刷新令牌隔离在渲染进程与 Agent Runtime 之外。宿主代发的网络请求仍需 `net.fetch` 和 `manifest.net.domains`;插件入口代码本身不是操作系统沙箱。每个 provider 声明只保存一个账号;退出登录会清除凭据 |
| `net.fetch` | 高 | `net.fetch` | 默认拒绝 | 限定在 `manifest.net.domains` 之内;列表为空或非法即完全不放行出网(§2A) |
@@ -131,6 +132,7 @@ Agent,在 Plan 中不可见。主机返回 `PLUGIN_DISABLED_IN_PLAN`
| `agent.tool.register` | 为AI Agent提供可执行工具 | 向AI Agent提供可执行工具 |
| `agent.prompt.inject` | 调整代理指令 | 调整智能体指令 |
| `agent.extension` | 在 agent 内运行代码 | 在 agent 内运行代码 |
+| `renderer.extension` | Draw UI in chat slots | 在聊天插槽绘制界面 |
| `net.fetch` | 访问网络 | 访问网络 |
| `shell.openExternal` | 打开外部链接 | 打开外部链接 |
| `ui.theme` | 提供一个主题 | 提供主题 |