Skip to content

官方插件模板

Workova 提供三类官方模板,覆盖最常见的插件开发场景。每个模板均包含完整的 manifest 和最小可运行代码。

模板一览

模板类型适用场景
tool-local-helpertool命令型插件:固定回复、本地脚本、外部工具封装
channel-dingtalk-webhookchannel渠道接入:钉钉机器人 Webhook 收发消息
openclaw-compatible-channelchannel迁移场景:已有 OpenClaw 插件快速接入

tool-local-helper

最简单的工具插件模板,包含一个固定回复命令和一个进程调用命令。

manifest 结构:

json
{
  "id": "tool-local-helper",
  "name": "本地工具助手",
  "version": "1.0.0",
  "kind": "tool",
  "capabilities": ["tool:command"],
  "config_schema": {
    "type": "object",
    "properties": {
      "welcome_text": {
        "type": "string",
        "title": "欢迎语",
        "default": "您好!"
      },
      "workspace_root": {
        "type": "string",
        "title": "工作区目录",
        "default": "."
      }
    }
  },
  "commands": [
    {
      "name": "hello",
      "type": "template",
      "description": "返回欢迎信息",
      "response_template": "{‌{config.welcome_text}‌}"
    },
    {
      "name": "list-files",
      "type": "process",
      "description": "列出目录文件",
      "program": "bash",
      "args": ["-c", "ls -la {‌{config.workspace_root}‌}"],
      "timeout_seconds": 10
    }
  ]
}

channel-dingtalk-webhook

钉钉 Webhook 渠道插件模板,包含完整的生命周期脚本和消息格式示例。

目录结构:

text
channel-dingtalk-webhook/
  plugin.manifest.json
  scripts/
    lifecycle.js          # 生命周期脚本(validate/receive/send)
  message-examples.json   # 各类消息格式示例

manifest 核心配置:

json
{
  "id": "channel-dingtalk-webhook",
  "name": "钉钉 Webhook",
  "version": "1.0.0",
  "kind": "channel",
  "capabilities": ["channel:dingtalk"],
  "config_schema": {
    "type": "object",
    "properties": {
      "webhook_url": {
        "type": "string",
        "title": "Webhook 地址"
      },
      "secret": {
        "type": "string",
        "title": "签名密钥",
        "secret": true,
        "widget": "password"
      }
    },
    "required": ["webhook_url"]
  },
  "entrypoints": {
    "channel_adapter": {
      "mode": "managed_webhook",
      "supported_channels": ["dingtalk"],
      "lifecycle": {
        "install": "scripts/lifecycle.js",
        "validate": "scripts/lifecycle.js",
        "receive": "scripts/lifecycle.js",
        "send": "scripts/lifecycle.js",
        "health": "scripts/lifecycle.js"
      }
    }
  }
}

TIP

模板中的 scripts/lifecycle.js 通过 WORKOVA_PLUGIN_ACTION 环境变量判断当前执行的生命周期阶段,在同一个脚本中处理所有事件。

openclaw-compatible-channel

适用于已有 OpenClaw 风格插件的迁移场景。使用 openclaw.plugin.json 格式声明:

json
{
  "id": "china-channels",
  "version": "0.1.0",
  "channels": ["dingtalk", "feishu"]
}

Workova 自动将其规范化为原生格式(kind: channelcompatibilityMode: openclaw)。

INFO

OpenClaw 兼容模式作为过渡方案,建议在功能稳定后逐步迁移为 Workova 原生 plugin.manifest.json,以获得完整的配置表单和生命周期支持。

使用方式

方式一:复制完整目录

将模板目录复制到插件目录后,修改 idnamedescription 等字段:

bash
cp -r templates/tool-local-helper .agents/plugins/my-tool

然后验证识别:

bash
workova plugin:validate --input '{"path": ".agents/plugins/my-tool"}'
workova plugin:list

方式二:仅复制 manifest

如果只需系统先识别插件,可仅复制 plugin.manifest.json,脚本和资源后续补充:

bash
mkdir -p .agents/plugins/my-tool
cp templates/tool-local-helper/plugin.manifest.json .agents/plugins/my-tool/

选择建议

需求推荐模板
第一次开发插件tool-local-helper
接入钉钉/飞书等消息平台channel-dingtalk-webhook
迁移已有 OpenClaw 插件openclaw-compatible-channel
接入 Telegram/Discord参考 channel-dingtalk-webhook 修改 modesupported_channels

相关文档

Workova 官方文档