概述

插件是 OpenClaw 的扩展机制,用于添加新能力:channel、模型提供商、Agent harness、工具、Skills、语音、实时转录、图像/视频/音乐生成、Web 搜索等。分为 Native 插件(openclaw.plugin.json + 运行时模块,进程内执行)和 Bundle 插件(Codex/Claude/Cursor 兼容布局)。主要分发渠道为 ClawHub,npm 仍支持直接安装。

核心功能

  • 多来源安装:ClawHub、npm、git、本地目录/archive
  • 发现优先级:plugins.load.paths → workspace plugins → global plugins → bundled plugins
  • 启用规则:plugins.deny 优先于 allow;workspace 插件默认禁用需显式启用;bundled 插件多数默认启用
  • 插件槽(slots):独占类别,如 memory(memory-core/memory-lancedb)、contextEngine
  • 热重载:/plugins enable|disable 触发进程内 Gateway 插件重载;install/update 需重启 Gateway
  • Plugin API:插件导出 register(api) 入口,通过 api.registrationMode 区分 full/discovery/setup-only 等模式
  • 生命周期钩子:before_tool_call、before_install、message_sending、before_model_resolve、llm_input/output 等

配置/使用

安装与管理

# 安装
openclaw plugins install clawhub:openclaw-codex-app-server
openclaw plugins install npm:@acme/openclaw-plugin
openclaw plugins install git:github.com/acme/openclaw-plugin@v1.0.0
openclaw plugins install ./my-plugin
 
# 列出/检查
openclaw plugins list
openclaw plugins inspect <id> --runtime --json
 
# 启用/禁用
openclaw plugins enable <id>
openclaw plugins disable <id>
 
# 更新/卸载
openclaw plugins update --all
openclaw plugins uninstall <id>

配置结构

{
  plugins: {
    enabled: true,
    allow: ["voice-call"],       // 非空时为独占白名单
    deny: ["untrusted-plugin"],  // deny 优先于 allow
    load: { paths: ["~/Projects/oss/voice-call-plugin"] },
    slots: {
      memory: "memory-core",     // 或 "memory-lancedb"
      contextEngine: "legacy",
    },
    entries: {
      "voice-call": { enabled: true, config: { provider: "twilio" } },
    },
  },
}

Plugin API 注册方法

方法注册内容
registerProvider模型提供商(LLM)
registerChannel聊天 channel
registerToolAgent 工具
registerHook / on(...)生命周期钩子
registerSpeechProviderTTS/STT
registerImageGenerationProvider图像生成
registerWebSearchProviderWeb 搜索
registerCommand / registerCliCLI 命令
registerService后台服务

插件状态说明

  • Disabled:存在但被禁用,配置保留
  • Missing:配置引用了未发现的插件 id
  • Invalid:插件存在但配置不符合 schema,openclaw doctor --fix 可隔离

相关页面

  • concepts/tool-clawhub — ClawHub 插件/Skill 注册表
  • concepts/tool-skills — 插件可附带 Skills
  • concepts/tool-slash-commands — 插件可注册 slash command
  • concepts/tool-capability-cookbook — 为 OpenClaw 核心添加新能力的贡献者指南