メインコンテンツへスキップ

Plugin SDK Migration

OpenClawは、広範な後方互換レイヤーから、目的ごとに分かれた文書化済みimportを持つモダンなplugin アーキテクチャへ移行しました。あなたのpluginが新しい アーキテクチャ以前に作られたものであれば、このガイドが移行を助けます。

何が変わるのか

古いplugin systemは、pluginが必要なものを 単一のentry pointから何でもimportできる、2つの広く開かれたsurfaceを提供していました。
  • openclaw/plugin-sdk/compat — 数十の helperを再エクスポートする単一import。新しい pluginアーキテクチャを構築している間、古いhookベースpluginを動かし続けるために導入されました。
  • openclaw/extension-api — pluginに、埋め込みagent runnerのような host側helperへの直接アクセスを与えるbridge。
これら2つのsurfaceは現在どちらも非推奨です。実行時にはまだ動作しますが、新しい pluginはこれらを使ってはいけません。また既存pluginも、次の major releaseで削除される前に移行すべきです。
後方互換レイヤーは将来のmajor releaseで削除されます。 これらのsurfaceからimportしているpluginは、その時点で壊れます。

なぜ変わったのか

古いアプローチには問題がありました。
  • 起動が遅い — 1つのhelperをimportするだけで無関係なmoduleが数十個読み込まれていました
  • 循環依存 — 広範な再エクスポートにより、import cycleを簡単に作れてしまいました
  • 不明瞭なAPI surface — どのexportがstableで、どれがinternalなのかを判別する手段がありませんでした
モダンなplugin SDKはこれを解決します。各import path(openclaw/plugin-sdk/\<subpath\>) は、小さく自己完結したmoduleであり、明確な目的と文書化されたcontractを持ちます。 bundled channel向けのlegacy provider convenience seamも削除されました。 openclaw/plugin-sdk/slackopenclaw/plugin-sdk/discordopenclaw/plugin-sdk/signalopenclaw/plugin-sdk/whatsapp、 channel名付きhelper seam、および openclaw/plugin-sdk/telegram-core のようなimportは、 stableなplugin contractではなくprivateなmono-repo shortcutでした。代わりに 汎用の細いSDK subpathを使ってください。bundled plugin workspace内では、 provider所有helperはそのplugin自身の api.ts または runtime-api.ts に保持してください。 現在のbundled provider例:
  • AnthropicはClaude固有のstream helperを自分自身の api.ts / contract-api.ts seamに保持しています
  • OpenAIはprovider builder、default-model helper、realtime provider builderを自分自身の api.ts に保持しています
  • OpenRouterはprovider builderとonboarding/config helperを自分自身の api.ts に保持しています

移行方法

1

Windows wrapper fallback動作を監査する

あなたのpluginが openclaw/plugin-sdk/windows-spawn を使っている場合、解決できないWindows .cmd/.bat wrapperは、明示的に allowShellFallback: true を渡さない限りfail-closedするようになりました。
// Before
const program = applyWindowsSpawnProgramPolicy({ candidate });

// After
const program = applyWindowsSpawnProgramPolicy({
  candidate,
  // shell経由fallbackを意図的に受け入れる、信頼済みの互換性callerにのみ設定します。
  allowShellFallback: true,
});
callerが意図的にshell fallbackへ依存していない場合は、 allowShellFallback を設定せず、代わりにthrowされたerrorを処理してください。
2

非推奨importを見つける

あなたのplugin内で、どちらかの非推奨surfaceからのimportを検索します。
grep -r "plugin-sdk/compat" my-plugin/
grep -r "openclaw/extension-api" my-plugin/
3

目的別importへ置き換える

古いsurfaceの各exportは、特定のモダンimport pathへ対応しています。
// Before(非推奨の後方互換レイヤー)
import {
  createChannelReplyPipeline,
  createPluginRuntimeStore,
  resolveControlCommandGate,
} from "openclaw/plugin-sdk/compat";

// After(モダンな目的別import)
import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline";
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
import { resolveControlCommandGate } from "openclaw/plugin-sdk/command-auth";
host側helperについては、直接importする代わりに 注入されたplugin runtimeを使ってください。
// Before(非推奨extension-api bridge)
import { runEmbeddedPiAgent } from "openclaw/extension-api";
const result = await runEmbeddedPiAgent({ sessionId, prompt });

// After(注入されたruntime)
const result = await api.runtime.agent.runEmbeddedPiAgent({ sessionId, prompt });
同じパターンは、他のlegacy bridge helperにも適用されます。
Old importModern equivalent
resolveAgentDirapi.runtime.agent.resolveAgentDir
resolveAgentWorkspaceDirapi.runtime.agent.resolveAgentWorkspaceDir
resolveAgentIdentityapi.runtime.agent.resolveAgentIdentity
resolveThinkingDefaultapi.runtime.agent.resolveThinkingDefault
resolveAgentTimeoutMsapi.runtime.agent.resolveAgentTimeoutMs
ensureAgentWorkspaceapi.runtime.agent.ensureAgentWorkspace
session store helpersapi.runtime.agent.session.*
4

buildしてテストする

pnpm build
pnpm test -- my-plugin/

Import pathリファレンス

Import path用途主なexport
plugin-sdk/plugin-entry正式なplugin entry helperdefinePluginEntry
plugin-sdk/corechannel entry definition/builder向けlegacy umbrella再エクスポートdefineChannelPluginEntry, createChatChannelPlugin
plugin-sdk/config-schemaルートconfig schema exportOpenClawSchema
plugin-sdk/provider-entry単一provider entry helperdefineSingleProviderPluginEntry
plugin-sdk/channel-core目的別channel entry definitionとbuilderdefineChannelPluginEntry, defineSetupPluginEntry, createChatChannelPlugin, createChannelPluginBase
plugin-sdk/setup共有setup wizard helperAllowlist prompt、setup status builder
plugin-sdk/setup-runtimesetup時runtime helperimport-safeなsetup patch adapter、lookup-note helper、promptResolvedAllowFromsplitSetupEntries、delegated setup proxy
plugin-sdk/setup-adapter-runtimesetup adapter helpercreateEnvPatchedAccountSetupAdapter
plugin-sdk/setup-toolssetup tooling helperformatCliCommand, detectBinary, extractArchive, resolveBrewExecutable, formatDocsLink, CONFIG_DIR
plugin-sdk/account-coremulti-account helperaccount list/config/action-gate helper
plugin-sdk/account-idaccount-id helperDEFAULT_ACCOUNT_ID、account-id正規化
plugin-sdk/account-resolutionaccount lookup helperaccount lookup + default-fallback helper
plugin-sdk/account-helpers細いaccount helperaccount list/account-action helper
plugin-sdk/channel-setupsetup wizard adaptercreateOptionalChannelSetupSurface, createOptionalChannelSetupAdapter, createOptionalChannelSetupWizard、および DEFAULT_ACCOUNT_ID, createTopLevelChannelDmPolicy, setSetupChannelEnabled, splitSetupEntries
plugin-sdk/channel-pairingDM pairing primitivecreateChannelPairingController
plugin-sdk/channel-reply-pipelinereply prefix + typing配線createChannelReplyPipeline
plugin-sdk/channel-config-helpersconfig adapter factorycreateHybridChannelConfigAdapter
plugin-sdk/channel-config-schemaconfig schema builderchannel config schema型
plugin-sdk/telegram-command-configTelegram command config helpercommand名正規化、description切り詰め、重複/競合検証
plugin-sdk/channel-policygroup/DM policy解決resolveChannelGroupRequireMention
plugin-sdk/channel-lifecycleaccount status追跡createAccountStatusSink
plugin-sdk/inbound-envelopeinbound envelope helper共通route + envelope builder helper
plugin-sdk/inbound-reply-dispatchinbound reply helper共通record-and-dispatch helper
plugin-sdk/messaging-targetsmessaging target解析target解析/一致helper
plugin-sdk/outbound-mediaoutbound media helper共通outbound media読み込み
plugin-sdk/outbound-runtimeoutbound runtime helperoutbound identity/send delegate helper
plugin-sdk/thread-bindings-runtimethread-binding helperthread-binding lifecycleとadapter helper
plugin-sdk/agent-media-payloadlegacy media payload helperlegacy field layout向けagent media payload builder
plugin-sdk/channel-runtime非推奨の互換shimlegacy channel runtime utilityのみ
plugin-sdk/channel-send-resultsend result型reply result型
plugin-sdk/runtime-store永続plugin storagecreatePluginRuntimeStore
plugin-sdk/runtime広範なruntime helperruntime/logging/backup/plugin-install helper
plugin-sdk/runtime-env細いruntime env helperlogger/runtime env、timeout、retry、backoff helper
plugin-sdk/plugin-runtime共有plugin runtime helperplugin commands/hooks/http/interactive helper
plugin-sdk/hook-runtimehook pipeline helper共通webhook/internal hook pipeline helper
plugin-sdk/lazy-runtimelazy runtime helpercreateLazyRuntimeModule, createLazyRuntimeMethod, createLazyRuntimeMethodBinder, createLazyRuntimeNamedExport, createLazyRuntimeSurface
plugin-sdk/process-runtimeprocess helper共通exec helper
plugin-sdk/cli-runtimeCLI runtime helpercommand formatting、wait、version helper
plugin-sdk/gateway-runtimeGateway helperGateway clientとchannel-status patch helper
plugin-sdk/config-runtimeconfig helperconfig load/write helper
plugin-sdk/telegram-command-configTelegram command helperbundled Telegram contract surfaceが利用できないときのfallback-stableなTelegram command検証helper
plugin-sdk/approval-runtimeapproval prompt helperexec/plugin approval payload、approval capability/profile helper、native approval routing/runtime helper
plugin-sdk/approval-auth-runtimeapproval auth helperapprover解決、same-chat action auth
plugin-sdk/approval-client-runtimeapproval client helpernative exec approval profile/filter helper
plugin-sdk/approval-delivery-runtimeapproval delivery helpernative approval capability/delivery adapter
plugin-sdk/approval-native-runtimeapproval target helpernative approval target/account binding helper
plugin-sdk/approval-reply-runtimeapproval reply helperexec/plugin approval reply payload helper
plugin-sdk/security-runtimesecurity helper共通trust、DM gating、external-content、secret-collection helper
plugin-sdk/ssrf-policySSRF policy helperhost allowlistとprivate-network policy helper
plugin-sdk/ssrf-runtimeSSRF runtime helperpinned-dispatcher、guarded fetch、SSRF policy helper
plugin-sdk/collection-runtimebounded cache helperpruneMapToMaxSize
plugin-sdk/diagnostic-runtimediagnostic gating helperisDiagnosticFlagEnabled, isDiagnosticsEnabled
plugin-sdk/error-runtimeerror formatting helperformatUncaughtError, isApprovalNotFoundError, error graph helper
plugin-sdk/fetch-runtimewrapped fetch/proxy helperresolveFetch、proxy helper
plugin-sdk/host-runtimehost正規化helpernormalizeHostname, normalizeScpRemoteHost
plugin-sdk/retry-runtimeretry helperRetryConfig, retryAsync, policy runner
plugin-sdk/allow-fromallowlist formattingformatAllowFromLowercase
plugin-sdk/allowlist-resolutionallowlist inputマッピングmapAllowlistResolutionInputs
plugin-sdk/command-authcommand gatingとcommand-surface helperresolveControlCommandGate, sender認可helper, command registry helper
plugin-sdk/secret-inputsecret input解析secret input helper
plugin-sdk/webhook-ingresswebhook request helperwebhook target utility
plugin-sdk/webhook-request-guardswebhook body guard helperrequest body read/limit helper
plugin-sdk/reply-runtime共有reply runtimeinbound dispatch、heartbeat、reply planner、chunking
plugin-sdk/reply-dispatch-runtime細いreply dispatch helperfinalize + provider dispatch helper
plugin-sdk/reply-historyreply-history helperbuildHistoryContext, buildPendingHistoryContextFromMap, recordPendingHistoryEntry, clearHistoryEntriesIfEnabled
plugin-sdk/reply-referencereply reference planningcreateReplyReferencePlanner
plugin-sdk/reply-chunkingreply chunk helpertext/markdown chunking helper
plugin-sdk/session-store-runtimesession store helperstore path + updated-at helper
plugin-sdk/state-pathsstate path helperstateとOAuth dir helper
plugin-sdk/routingrouting/session-key helperresolveAgentRoute, buildAgentSessionKey, resolveDefaultAgentBoundAccountId, session-key正規化helper
plugin-sdk/status-helperschannel status helperchannel/account status summary builder、runtime-state default、issue metadata helper
plugin-sdk/target-resolver-runtimetarget resolver helper共有target resolver helper
plugin-sdk/string-normalization-runtimestring正規化helperslug/string正規化helper
plugin-sdk/request-urlrequest URL helperrequest風inputからstring URLを抽出
plugin-sdk/run-commandtimed command helperstdout/stderrを正規化したtimed command runner
plugin-sdk/param-readersparam reader一般的なtool/CLI param reader
plugin-sdk/tool-sendtool send抽出tool argsから正規send target fieldを抽出
plugin-sdk/temp-pathtemp path helper共通temp-download path helper
plugin-sdk/logging-corelogging helpersubsystem loggerとredaction helper
plugin-sdk/markdown-table-runtimemarkdown-table helpermarkdown table mode helper
plugin-sdk/reply-payloadmessage reply型reply payload型
plugin-sdk/provider-setup厳選されたlocal/self-hosted provider setup helperself-hosted provider discovery/config helper
plugin-sdk/self-hosted-provider-setup目的別OpenAI互換self-hosted provider setup helper同じself-hosted provider discovery/config helper
plugin-sdk/provider-auth-runtimeprovider runtime auth helperruntime API-key解決helper
plugin-sdk/provider-auth-api-keyprovider API-key setup helperAPI-key onboarding/profile-write helper
plugin-sdk/provider-auth-resultprovider auth-result helper標準OAuth auth-result builder
plugin-sdk/provider-auth-loginprovider interactive login helper共通interactive login helper
plugin-sdk/provider-env-varsprovider env-var helperprovider auth env-var lookup helper
plugin-sdk/provider-model-shared共有provider model/replay helperProviderReplayFamily, buildProviderReplayFamilyHooks, normalizeModelCompat, 共有replay-policy builder、provider-endpoint helper、model-id正規化helper
plugin-sdk/provider-catalog-shared共有provider catalog helperfindCatalogTemplate, buildSingleProviderApiKeyCatalog, supportsNativeStreamingUsageCompat, applyProviderNativeStreamingUsageCompat
plugin-sdk/provider-onboardprovider onboarding patchonboarding config helper
plugin-sdk/provider-httpprovider HTTP helper汎用provider HTTP/endpoint capability helper
plugin-sdk/provider-web-fetchprovider web-fetch helperweb-fetch provider registration/cache helper
plugin-sdk/provider-web-searchprovider web-search helperweb-search provider registration/cache/config helper
plugin-sdk/provider-toolsprovider tool/schema compat helperProviderToolCompatFamily, buildProviderToolCompatFamilyHooks, Gemini schema cleanup + diagnostics、さらに resolveXaiModelCompatPatch / applyXaiModelCompat などのxAI compat helper
plugin-sdk/provider-usageprovider usage helperfetchClaudeUsage, fetchGeminiUsage, fetchGithubCopilotUsage、その他provider usage helper
plugin-sdk/provider-streamprovider stream wrapper helperProviderStreamFamily, buildProviderStreamFamilyHooks, composeProviderStreamWrappers, stream wrapper型、共有Anthropic/Bedrock/Google/Kilocode/Moonshot/OpenAI/OpenRouter/Z.A.I/MiniMax/Copilot wrapper helper
plugin-sdk/keyed-async-queue順序付きasync queueKeyedAsyncQueue
plugin-sdk/media-runtime共有media helpermedia fetch/transform/store helperとmedia payload builder
plugin-sdk/media-understandingmedia-understanding helpermedia understanding provider型とprovider向けimage/audio helper export
plugin-sdk/text-runtime共有text helperassistant可視text stripping、markdown render/chunking/table helper、redaction helper、directive-tag helper、safe-text utility、その他のtext/logging helper
plugin-sdk/text-chunkingtext chunking helperoutbound text chunking helper
plugin-sdk/speechspeech helperspeech provider型とprovider向けdirective、registry、validation helper
plugin-sdk/speech-core共有speech corespeech provider型、registry、directive、正規化
plugin-sdk/realtime-transcriptionrealtime transcription helperprovider型とregistry helper
plugin-sdk/realtime-voicerealtime voice helperprovider型とregistry helper
plugin-sdk/image-generation-core共有image-generation coreimage-generation型、failover、auth、registry helper
plugin-sdk/video-generationvideo-generation helpervideo-generation provider/request/result型
plugin-sdk/video-generation-core共有video-generation corevideo-generation型、failover helper、provider lookup、model-ref parsing
plugin-sdk/interactive-runtimeinteractive reply helperinteractive reply payload正規化/縮約
plugin-sdk/channel-config-primitiveschannel config primitive細いchannel config-schema primitive
plugin-sdk/channel-config-writeschannel config-write helperchannel config-write認可helper
plugin-sdk/channel-plugin-common共有channel prelude共有channel plugin prelude export
plugin-sdk/channel-statuschannel status helper共有channel status snapshot/summary helper
plugin-sdk/allowlist-config-editallowlist config helperallowlist config edit/read helper
plugin-sdk/group-accessgroup access helper共有group-access decision helper
plugin-sdk/direct-dmdirect-DM helper共有direct-DM auth/guard helper
plugin-sdk/extension-shared共有extension helperpassive-channel/status helper primitive
plugin-sdk/webhook-targetswebhook target helperwebhook target registryとroute-install helper
plugin-sdk/webhook-pathwebhook path helperwebhook path正規化helper
plugin-sdk/web-media共有web media helperremote/local media loading helper
plugin-sdk/zodZod再エクスポートplugin SDK consumer向けに再エクスポートされた zod
plugin-sdk/memory-corebundled memory-core helpermemory manager/config/file/CLI helper surface
plugin-sdk/memory-core-engine-runtimememory engine runtime facadememory index/search runtime facade
plugin-sdk/memory-core-host-engine-foundationmemory host foundation enginememory host foundation engine export
plugin-sdk/memory-core-host-engine-embeddingsmemory host embedding enginememory host embedding engine export
plugin-sdk/memory-core-host-engine-qmdmemory host QMD enginememory host QMD engine export
plugin-sdk/memory-core-host-engine-storagememory host storage enginememory host storage engine export
plugin-sdk/memory-core-host-multimodalmemory host multimodal helpermemory host multimodal helper
plugin-sdk/memory-core-host-querymemory host query helpermemory host query helper
plugin-sdk/memory-core-host-secretmemory host secret helpermemory host secret helper
plugin-sdk/memory-core-host-statusmemory host status helpermemory host status helper
plugin-sdk/memory-core-host-runtime-climemory host CLI runtimememory host CLI runtime helper
plugin-sdk/memory-core-host-runtime-corememory host core runtimememory host core runtime helper
plugin-sdk/memory-core-host-runtime-filesmemory host file/runtime helpermemory host file/runtime helper
plugin-sdk/memory-lancedbbundled memory-lancedb helpermemory-lancedb helper surface
plugin-sdk/testingtest utilitytest helperとmock
この一覧は意図的に、完全なSDK surfaceではなく、よく使う移行対象のサブセットです。200以上のentrypointからなる完全な一覧は scripts/lib/plugin-sdk-entrypoints.json にあります。 その一覧には依然として、一部のbundled-plugin helper seamも含まれています。たとえば plugin-sdk/feishu, plugin-sdk/feishu-setup, plugin-sdk/zalo, plugin-sdk/zalo-setup, plugin-sdk/matrix* などです。これらはbundled-pluginの保守と互換性のために 引き続きexportされていますが、一般的な移行一覧からは意図的に 除外されており、新しいplugin codeの推奨ターゲットではありません。 同じルールは、他のbundled-helper familyにも適用されます。たとえば:
  • browser support helper: plugin-sdk/browser-config-support, plugin-sdk/browser-support
  • Matrix: plugin-sdk/matrix*
  • LINE: plugin-sdk/line*
  • IRC: plugin-sdk/irc*
  • bundled helper/plugin surface: plugin-sdk/googlechat, plugin-sdk/zalouser, plugin-sdk/bluebubbles*, plugin-sdk/mattermost*, plugin-sdk/msteams, plugin-sdk/nextcloud-talk, plugin-sdk/nostr, plugin-sdk/tlon, plugin-sdk/twitch, plugin-sdk/github-copilot-login, plugin-sdk/github-copilot-token, plugin-sdk/diagnostics-otel, plugin-sdk/diffs, plugin-sdk/llm-task, plugin-sdk/thread-ownership, plugin-sdk/voice-call
plugin-sdk/github-copilot-token は現在、細いtoken-helper surfaceとして DEFAULT_COPILOT_API_BASE_URLderiveCopilotApiBaseUrlFromTokenresolveCopilotApiToken を公開しています。 作業に合った最も細いimportを使ってください。exportが見つからない場合は、 src/plugin-sdk/ のsourceを確認するか、Discordで質問してください。

削除スケジュール

When何が起こるか
Now非推奨surfaceが実行時warningを出します
Next major release非推奨surfaceが削除され、それを使い続けるpluginは失敗します
すべてのcore pluginはすでに移行済みです。外部pluginは 次のmajor releaseまでに移行すべきです。

警告を一時的に抑制する

移行作業中は、次の環境変数を設定してください。
OPENCLAW_SUPPRESS_PLUGIN_SDK_COMPAT_WARNING=1 openclaw gateway run
OPENCLAW_SUPPRESS_EXTENSION_API_WARNING=1 openclaw gateway run
これは一時的なescape hatchであり、恒久的な解決策ではありません。

関連