Plugin Setup and Config
Plugin 打包(package.json 中繼資料)、manifests(openclaw.plugin.json)、setup entries 與 config schemas 的參考。
套件中繼資料
你的package.json 需要 openclaw 欄位,告訴外掛系統你的外掛提供什麼:
Channel 外掛:
openclaw 欄位
延遲完整載入
Channel 外掛可以選擇加入延遲載入:setupEntry,即使是已設定的頻道也是如此。完整 entry 在 gateway 開始監聽後載入。
Plugin manifest
每個原生外掛必須在套件根中運送openclaw.plugin.json。OpenClaw 使用它在不執行外掛代碼的情況下驗證 config。
kind 與 channels:
Setup entry
setup-entry.ts 檔案是 index.ts 的輕量級替代方案,OpenClaw 在只需要 setup 介面時載入(onboarding、config 修復、禁用 channel 檢查)。
setupEntry 而不是完整 entry:
- Channel 已禁用但需要 setup/onboarding 介面
- Channel 已啟用但未設定
- 延遲載入已啟用(
deferConfiguredChannelFullLoadUntilAfterListen)
setupEntry 必須註冊:
- Channel plugin 物件(透過
defineSetupPluginEntry) - Gateway 監聽前所需的任何 HTTP routes
- Startup 期間需要的任何 gateway 方法
setupEntry 不應包括:
- CLI 註冊
- 背景服務
- 重型 runtime imports(crypto、SDK)
- 只在 startup 後需要的 gateway 方法
Config schema
Plugin config 被驗證為你的 manifest 中的 JSON Schema。使用者透過以下方式設定外掛:api.pluginConfig。
針對 channel 特定的 config,改用 channel config 區段:
建置 channel config schemas
使用buildChannelConfigSchema 從 openclaw/plugin-sdk/core 將 Zod schema 轉換為 OpenClaw 驗證的 ChannelConfigSchema 包裝器:
Setup 精靈
Channel 外掛可以為openclaw onboard 提供互動式 setup 精靈。精靈是 ChannelPlugin 上的 ChannelSetupWizard 物件:
ChannelSetupWizard 型別支援 credentials、textInputs、dmPolicy、allowFrom、groupAccess、prepare、finalize 等。參考捆綁外掛(例如 extensions/discord/src/channel.setup.ts)以取得完整範例。
針對只需要標準 note -> prompt -> parse -> merge -> patch flow 的 DM allowlist prompts,優先使用來自 openclaw/plugin-sdk/setup 的共享 setup 輔助函式:createPromptParsedAllowFromForAccount(...)、createTopLevelChannelParsedAllowFromPrompt(...) 與 createNestedChannelParsedAllowFromPrompt(...)。
針對只按標籤、分數與可選額外行變更的 channel setup 狀態塊,優先使用 openclaw/plugin-sdk/setup 中的 createStandardChannelSetupStatus(...) 而不是在每個外掛中手動推出相同的 status 物件。
對於應該只在特定脈絡中出現的可選 setup 介面,使用 openclaw/plugin-sdk/channel-setup 中的 createOptionalChannelSetupSurface:
發佈與安裝
外部外掛: 發佈至 ClawHub 或 npm,然後安裝:extensions/ 下,它們在建置期間自動發現。
使用者可以瀏覽與安裝:
針對 npm 源的 installs,
openclaw plugins install 執行 npm install --ignore-scripts(沒有生命週期指令稿)。保持外掛相依樹為純 JS/TS,避免需要 postinstall 建置的套件。相關
- SDK 進入點 —
definePluginEntry與defineChannelPluginEntry - Plugin Manifest — 完整 manifest schema 參考
- 建置外掛 — 逐步入門指南