Tools
Composer Predictions
Context-aware next-step prompts for OpenClaw Control UI. Click to edit, never auto-send.
Install
npm install
npm
README
# OpenClaw Composer Predictions · 输入预测插件
**Native Control UI next-step prompt prediction plugin for OpenClaw `2026.12.1` — part of the Composer Predictions sister suite.**
**OpenClaw `2026.12.1` 原生 Control UI 输入框预测插件——与 Hermes 官方目录插件、DeepSeek Harness 插件一脉相承的三端姐妹套件成员。**
[**v0.1.4 Release**](https://github.com/xuhuawork/openclaw-composer-predictions/releases/tag/v0.1.4) · [**Local Verification Report**](./docs/验收报告-v0.1.3.md) · [**⭐ Star on GitHub**](https://github.com/xuhuawork/openclaw-composer-predictions) · [**English ↓**](#english) · [**简体中文 ↓**](#简体中文)
[](https://github.com/xuhuawork/openclaw-composer-predictions) [](https://github.com/xuhuawork/openclaw-composer-predictions) [](https://github.com/xuhuawork/hermes-composer-predictions) [](https://github.com/xuhuawork/dsh-composer-predictions) [](https://github.com/xuhuawork/openclaw-composer-predictions/issues)

> **Direct 2-line full-prompt cards · Editable draft only (never auto-sends) · 5s overwrite lock · 0B prompt-cache drift · Ephemeral opt-in · Single-agent authenticated dispatch · 18/18 tests**
> **直出两行完整提示词卡片 · 仅填可编辑草稿(绝不自动发送)· 5 秒防误覆盖锁 · 0B 主会话缓存污染 · 默认关闭按需开启 · 单代理鉴权转发 · 18/18 测试通过**
<details>
<summary>Light theme / Chinese UI preview · 亮色 / 中文界面高清预览</summary>

</details>
### Composer Predictions Sister Suite · 三端姐妹插件矩阵
| Platform · 平台 | Repository · 仓库 | Version | Status · 收录与适配状态 |
| :--- | :--- | :--- | :--- |
| **Hermes Desktop** | [`xuhuawork/hermes-composer-predictions`](https://github.com/xuhuawork/hermes-composer-predictions) | `v0.3.1` | Official Hermes Plugin Catalog · Awesome Hermes (EN & ZH) |
| **DeepSeek Harness (DSH)** | [`xuhuawork/dsh-composer-predictions`](https://github.com/xuhuawork/dsh-composer-predictions) | `v0.2.3` | Awesome DSH Plugin · DSH Hub Verified · dsh.so Low Risk |
| **OpenClaw (`2026.12.1`)** *(this repo)* | [`xuhuawork/openclaw-composer-predictions`](https://github.com/xuhuawork/openclaw-composer-predictions) | `v0.1.4` | Native Control UI Replacement · Verified Local Package |
---
<a id="english"></a>
## English
### What's new in v0.1.4
- **Direct 2-line full-prompt prediction cards (WYSIWYG):** Replaces truncated short labels with up to 4 complete, ready-to-send 1–2 line prompt cards (`15–42` Chinese characters or `8–22` English words) in a responsive 2-column grid (automatically stacks to 1 column below `500px`). Overflow tooltips appear automatically only when text exceeds 2 lines or on keyboard focus.
- **Sister-suite parity:** Aligned card layout, prompt schema, and `I✦` interaction semantics with Hermes (`v0.3.1`) and DeepSeek Harness (`v0.2.3`).
### Quick Install
Back up your target gateway configuration first, then install via the OpenClaw `2026.12.1` CLI:
```sh
openclaw plugins install ./releases/openclaw-composer-predictions-0.1.4.tgz --force --accept-capabilities
```
> **Flag transparency:** `--force` and `--accept-capabilities` confirm that you have reviewed the local package source/replacement and its declared capabilities; they do **not** mark the plugin as an officially trusted plugin.
After restarting the gateway:
1. Open Control UI → **Settings → Plugins → Advanced → Custom UI → Message Composer** and select **Composer Predictions**.
2. Return to the chat view and click the **`I✦`** prediction switch (**opt-in by default**).
### Core Guarantees & Security Boundaries
- **Draft-only, never auto-sends + 5s overwrite guard:** Clicking a card or pressing `Option + 1..4` (Windows/Linux `Alt + 1..4`) calls only the native `setDraft` contract—never `send`. When a different non-empty draft exists in the mounted native editor, the first selection warns without overwriting; a second selection of the same card within 5 seconds replaces it. Any manual edit resets confirmation immediately. Press `Option/Alt + R` to refresh.
- **0-byte main-session prompt-cache drift:** Reads at most the **latest 6 nonempty visible `user`/`assistant` messages** (`12,000` UTF-16 code units max). Tool output, hidden reasoning, system prompts, and local drafts are never sent. No chat turn is started and no history is mutated.
- **Ephemeral opt-in & fail-closed DOM protection:** The toggle lives strictly inside the current composer instance and defaults to **OFF** on reload, navigation, or session switch (does not read legacy global enable state). Because `2026.12.1` replacement props may lag behind live typing, overwrite protection inspects only the single native editor mounted by this plugin—never another pane—and fails closed if the editor structure is unknown or ambiguous.
- **Single-agent compatibility & least-privilege gateway dispatch:**
- Supports **OpenClaw `2026.12.1`** with a **single-agent gateway** only. Multi-agent configurations fail closed before inference—the plugin never requests agent, model, or authentication overrides, and ships no built-in API keys or model URLs.
- Uses the agent's default configured model (does not guarantee following temporary per-chat model overrides; admins can constrain models via `llm.allowedCompletionModels`).
- Registers `openclaw-composer-predictions.prepare` via public `registerGatewayMethod` (requiring `operator.write` and existing session `sessionAccess`), declares `contracts.gatewayMethodDispatch: ["authenticated-request"]`, forwards `chat.history` via `dispatchGatewayMethod` preserving original caller/session/scope checks, and runs tool-free text completion via the officially recommended `api.runtime.llm.complete` (using fresh `isolated-agent-runtime` when the gateway uses Codex runtime, with no fallback to untrusted transports).
- Selection is disabled while disconnected, generating, or sending; turn caches are isolated by connection, agent, session generation, and visible content.
> Reference official release docs:
> - `docs/plugins/manifest/capabilities.md` (L131): authenticated dispatch preserves original client permissions without creating a synthetic caller.
> - `docs/plugins/sdk-runtime/gateway-and-nodes.md` (L110–146): authenticated requests and public dispatch.
> - `docs/plugins/sdk-runtime/models.md` (L185–348, L381–386): host-managed `llm.complete` and model/agent override limits.
### Architecture
| Layer | File | Responsibility |
|---|---|---|
| Pure Core | [`src/core.js`](./src/core.js) | Visible turn extraction (`<=6` msgs, `<=12,000` UTF-16 units), user-prose language lock, prompt builder, JSON parser |
| Gateway Method | [`src/index.js`](./src/index.js) | Authenticated `openclaw-composer-predictions.prepare` RPC, single-agent gate, `api.runtime.llm.complete`, scoped LRU cache |
| Control UI Replacement | [`src/control-ui.js`](./src/control-ui.js), [`src/control-ui.css`](./src/control-ui.css) | Native `mountDefault` wrapper, `I✦` ephemeral toggle, 2-line full-prompt card grid, live DOM 5s overwrite guard, `⌥1–4` / `⌥R` |
| Plugin Manifest | [`openclaw.plugin.json`](./openclaw.plugin.json) | `replacement` UI capability, `conversationAccess: ["read"]`, `tools: []`, `gatewayMethodDispatch: ["authenticated-request"]` |
---
<a id="简体中文"></a>
## 简体中文
### v0.1.4 更新亮点
- **所见即所得,直出两行完整提示词卡片:** 将旧版短标签升级为最多 4 张 1–2 行完整可执行提示词卡片(中文约 15–42 字 / 英文 8–22 词),响应式双列排布(宽度 `<500px` 自动切单列),扫一眼即可决定,无需悬停猜词;仅在超出两行或键盘聚焦时自动显示完整提示气泡。
- **三端交互与协议统一:** 与 Hermes(`v0.3.1`)、DeepSeek Harness(`v0.2.3`)对齐提示词结构、卡片密度与 `I✦` 视觉语言。独立中文说明另见 [README.zh-CN.md](./README.zh-CN.md)。
### 兼容性与权限边界
- 仅支持 **OpenClaw `2026.12.1`**、网关**只有一个代理**的配置。多代理配置在推理前安全拒绝,不申请代理、模型或认证覆盖权限。使用该代理默认配置的模型,不保证跟随聊天会话的临时模型切换;管理员可用 `llm.allowedCompletionModels` 限定宿主默认模型。无内置 API 密钥或模型地址。
- 通过公开 `registerGatewayMethod` 注册 `openclaw-composer-predictions.prepare`,要求 `operator.write` 和现有会话的 `sessionAccess`;声明 `contracts.gatewayMethodDispatch: ["authenticated-request"]`,用 `dispatchGatewayMethod("chat.history", ...)` 保留原始客户端、会话与作用域检查;使用官方推荐 `api.runtime.llm.complete` 完成无工具文本补全(原网关主模型为 Codex runtime 时走全新 `isolated-agent-runtime` 且不回退到其他传输),不再调用受信任限制的 `api.runtime.gateway.request` / `subagent.complete`。不启动聊天回合,也不写入对话。
### 快速安装与使用
先备份目标网关配置,再使用目标版本 CLI 安装:
```sh
openclaw plugins install ./releases/openclaw-composer-predictions-0.1.4.tgz --force --accept-capabilities
```
> 以上两个标志分别确认已审阅本地包来源/替换旧包以及声明的能力,**不会**把插件标记为官方可信插件。
重启目标网关后,在 Control UI **「设置 → 插件 → 高级 → 自定义界面 → 消息编辑器」** 选择 **Composer Predictions**,返回聊天页点击左侧 **`I✦`** 输入预测开关即可使用:
- **默认关闭、按实例隔离**:开关只保存在当前编辑器实例内,刷新、离开或切换会话后自动重置为关闭,不读取旧版本全局启用记录。
- **0B 缓存损耗**:最多读取最近 6 条用户/助手可见文本(总长最多 `12,000` UTF-16 单位),工具内容、思考内容与本地草稿绝不参与请求。
- **只填草稿 + 5 秒防误覆盖锁**:点击或按 `Option+1~4`(Windows/Linux 为 `Alt+1~4`)只调用原生 `setDraft`,绝不调用 `send`;草稿实时读取本插件挂载的唯一原生编辑器 DOM(未知或歧义结构安全拒绝填入),已有不同草稿时须在 5 秒内再次选择同一建议才替换,任何手动编辑立即重置确认。按 `Option/Alt + R` 刷新。断线、生成中和发送中自动禁用选择,缓存按连接 / 代理 / 会话世代 / 可见内容隔离。
---
## Local Development & Verification · 本地开发与验收
Node.js 版本按宿主 `2026.12.1` 要求(`>=22.19.0`):
```sh
npm install
npm run build # official `openclaw plugins build`
npm test # 18/18 unit & Control UI tests passing
```
> 本包不包含本地验收模型、网关凭据、用户配置或测试会话。本机真网关验收记录另见 [docs/验收报告-v0.1.3.md](./docs/验收报告-v0.1.3.md)(本地固定响应模型只能证明真实网关与 UI 链路,不能证明外部真实模型的建议质量或认证可用性)。
---
## Community & Acknowledgments · 社区与致谢
- Thanks to the [LINUX DO](https://linux.do) developer community for open-source discussion, testing, and feedback.
- 感谢 [LINUX DO](https://linux.do) 开发者社区的开源交流、试用与改
... (truncated)
tools
Comments
Sign in to leave a comment