需求
在安装插件之前,请确保你具备:- 一个已检出或已安装的 OpenClaw 环境,并可使用
openclawCLI - 可访问所选来源的网络连接,例如 ClawHub、npm 或 git 主机
- 该插件安装文档中列出的任何插件专用凭据、配置键或操作系统工具
- 重新加载或重启为你的通道提供服务的 Gateway 的权限
快速开始
查找插件
在 ClawHub 中搜索公开插件包:ClawHub 是社区插件的主要发现入口。在发布切换期间,普通的裸包规格仍然会从 npm 安装,除非它们匹配某个官方插件 id。与捆绑插件匹配的原始
@openclaw/* 包规格会使用当前 OpenClaw 构建中的捆绑副本。当你需要特定来源时,请使用显式前缀。配置并启用它
在 如果你的配置使用了严格的
plugins.entries.<id>.config 下配置插件专用设置。
如果插件尚未启用,请启用它:plugins.allow 列表,则在插件能够加载之前,
该已安装插件的 id 必须存在于其中。
openclaw plugins install 会把已安装的 id 添加到现有的 plugins.allow 列表中,
并从 plugins.deny 中移除同一 id,以便显式安装的插件在重启后可以加载。让 Gateway 重新加载
安装、更新或卸载插件代码需要重启 Gateway。
当已管理的 Gateway 正在运行且启用了配置重载时,OpenClaw 会检测到已更改的插件安装记录并自动重启 Gateway。
如果 Gateway 未受管理或禁用了重载,请手动重启:启用和禁用操作会更新配置并刷新冷态注册表。
运行时检查仍然是验证活动运行时表面的最清晰路径。
配置
选择安装来源
| 来源 | 适用场景 | 示例 |
|---|---|---|
| ClawHub | 你希望使用 OpenClaw 原生的发现、扫描、版本元数据和安装提示 | openclaw plugins install clawhub:<package> |
| npm | 你需要直接使用 npm 注册表或 dist-tag 工作流 | openclaw plugins install npm:<package> |
| git | 你需要仓库中的分支、标签或提交 | openclaw plugins install git:github.com/<owner>/<repo>@<ref> |
| local path | 你正在同一台机器上开发或测试插件 | openclaw plugins install --link ./my-plugin |
| marketplace | 你正在安装一个兼容 Claude 的 marketplace 插件 | openclaw plugins install <plugin> --marketplace <source> |
@openclaw/* 包规格也会在回退到 npm 之前解析为捆绑副本。若你明确想要外部 npm 包而不是镜像自带的捆绑副本,请使用 npm:@openclaw/<plugin>@<version>。当你需要确定性的来源选择时,请使用 clawhub:、npm:、git: 或 npm-pack:。有关完整命令契约,请参见 openclaw plugins。
For npm installs, unpinned package specs and @latest choose the newest stable
package that advertises compatibility with this OpenClaw build. If npm’s
current latest release declares a newer openclaw.compat.pluginApi or
openclaw.install.minHostVersion, OpenClaw scans older stable package versions
and installs the newest one that fits. Exact versions and explicit channel tags
such as @beta stay pinned to the selected package and fail when incompatible.
Operator install policy
Configuresecurity.installPolicy to run a trusted local policy command before
plugin install or update proceeds. The policy receives metadata plus the staged
source path and can allow or block the install. It runs before plugin
before_install hooks. The deprecated --dangerously-force-unsafe-install
flag is accepted for compatibility but does not bypass install policy, hooks, or
OpenClaw’s built-in plugin dependency denylist.
See Skills config
for the shared security.installPolicy exec schema used by both skills and
plugins.
Configure plugin policy
常见的插件配置形状如下:plugins.enabled: falsedisables all plugins and skips plugin discovery/load work. Stale plugin references are inert while this is active; re-enable plugins before running doctor cleanup when you want stale ids removed.plugins.denywins over allow and per-plugin enablement.plugins.allowis an exclusive allowlist. Plugin-owned tools outside the allowlist stay unavailable, even whentools.allowincludes"*".plugins.entries.<id>.enabled: falsedisables one plugin while preserving its config.plugins.load.pathsadds explicit local plugin files or directories. Managedplugins installlocal paths must be plugin directories or archives; useplugins.load.pathsfor standalone plugin files.- Workspace-origin plugins are disabled by default; explicitly enable or allowlist them before using local workspace code.
- Bundled plugins follow their built-in default-on/default-off metadata unless config explicitly overrides them.
plugins.slots.<slot>chooses one plugin for exclusive categories such as memory and context engines. Slot selection force-enables the selected plugin for that slot by counting as explicit activation; it can load even when it would otherwise be opt-in.plugins.denyandplugins.entries.<id>.enabled: falsestill block it.- Bundled opt-in plugins can auto-activate when config names one of their owned surfaces, such as a provider/model ref, channel config, CLI backend, or agent harness runtime.
- OpenAI-family Codex routing keeps provider and runtime plugin boundaries
separate: legacy Codex model refs are legacy config repaired by doctor, while the bundled
codexplugin owns Codex app-server runtime for canonicalopenai/*agent refs, explicitagentRuntime.id: "codex", and legacycodex/*refs.
openclaw doctor 或 openclaw doctor --fix。
了解插件格式
OpenClaw 识别两种插件格式:| 格式 | 加载方式 | 适用场景 |
|---|---|---|
| 原生 OpenClaw 插件 | openclaw.plugin.json 以及在进程内加载的运行时模块 | 你正在安装或构建 OpenClaw 专用的运行时能力 |
| 兼容包 | 映射到 OpenClaw 插件清单的 Codex、Claude 或 Cursor 插件布局 | 你正在复用兼容的技能、命令、钩子或包元数据 |
openclaw plugins list、openclaw plugins inspect、
openclaw plugins enable 和 openclaw plugins disable 中。有关包兼容边界,请参见
插件包;有关原生插件作者指南,请参见
构建插件。
插件钩子
插件可以在运行时注册钩子,但有两种不同的 API,它们的职责也不同。- 对运行时生命周期钩子,请使用
api.on(...)的类型化钩子。这是用于中间件、策略、消息重写、提示词塑形和工具控制的首选接口。 - 仅当你想参与 钩子 中描述的内部钩子系统时,才使用
api.registerHook(...)。这主要用于粗粒度的命令/生命周期副作用,以及与现有 HOOK 风格自动化的兼容。
- 如果处理程序需要优先级、合并语义或阻止/取消行为,请使用类型化插件钩子。
- 如果处理程序只是响应
command:new、command:reset、message:sent或类似的粗粒度事件,api.registerHook(...)就足够了。
openclaw hooks list 中以
plugin:<id> 的形式出现。你不能通过 openclaw hooks 启用或禁用它们;
应改为启用或禁用该插件。
验证活动 Gateway
openclaw plugins list 和普通的 openclaw plugins inspect 读取的是冷态配置、
清单和注册表状态。它们不能证明已经运行的 Gateway 是否导入了相同的插件代码。
当某个插件看起来已经安装,但实时聊天流量没有使用它时:
openclaw gateway run 子进程,
而不仅仅是包装器或守护进程。
故障排查
| 症状 | 检查 | 修复 |
|---|---|---|
插件出现在 plugins list 中,但运行时钩子不执行 | 使用 openclaw plugins inspect <id> --runtime --json,并通过 gateway status --deep --require-rpc 确认活动 Gateway | 在安装、更新、配置或源代码变更后重启正在运行的 Gateway |
| 出现重复的通道或工具所有权诊断 | 运行 openclaw plugins list --enabled --verbose,使用 --runtime --json 检查每个可疑插件,并比较通道/工具所有权 | 禁用其中一个所有者,移除陈旧安装,或在有意替换时使用清单中的 preferOver |
| 配置显示某个插件缺失 | 查看 插件清单 以确认它是内置、官方外部还是仅源码插件 | 安装外部包、启用内置插件,或移除陈旧配置 |
| 安装期间配置无效 | 读取校验消息;当它指向陈旧插件状态时,运行 openclaw doctor --fix | doctor 可以通过禁用该条目并移除无效负载来隔离无效的插件配置 |
| 插件路径因可疑所有权或权限被阻止 | 在配置错误之前检查诊断信息 | 修复文件系统所有权/权限,然后运行 openclaw plugins registry --refresh |
OPENCLAW_NIX_MODE=1 阻止生命周期命令 | 确认该安装由 Nix 管理 | 在 Nix 源中更改插件选择,而不是使用插件变更命令 |
| 运行时依赖导入失败 | 检查插件是通过 npm/git/ClawHub 安装,还是从本地路径加载 | 运行 openclaw plugins update <id>、重新安装该来源,或自行安装本地插件依赖 |
openclaw doctor --fix 可移除陈旧的插件和通道条目。
没有陈旧插件证据的未知通道键仍然会校验失败,以便拼写错误保持可见。
对于有意的通道替换,首选插件应声明
channelConfigs.<channel-id>.preferOver,并指向旧的或优先级更低的
插件 id。如果两个插件都显式启用,OpenClaw 会保留该请求,并报告重复的通道或工具诊断,
而不是静默选择某一个所有者。
如果某个已安装包报告它 requires compiled runtime output for TypeScript entry ...,说明该包发布时没有包含 OpenClaw 在运行时所需的 JavaScript 文件。
请在发布者提供编译后的 JavaScript 后更新或重新安装,或者在此之前禁用/卸载该插件。
被阻止的插件路径所有权
如果插件诊断提示blocked plugin candidate: suspicious ownership (... uid=1000, expected uid=0 or root)
并且随后配置校验显示 plugin present but blocked,说明 OpenClaw 发现的插件
文件归属于与加载它们的进程不同的 Unix 用户。请保持插件配置不变;修复文件系统所有权,或以拥有状态目录的相同用户运行 OpenClaw。
对于 Docker 安装,官方镜像以 node(uid 1000)运行,因此
宿主机绑定挂载的 OpenClaw 配置和工作区目录通常应归属于 uid 1000:
openclaw doctor --fix 或
openclaw plugins registry --refresh,以便持久化的插件注册表与
已修复的文件保持一致。