Skip to main content

Plugin SDK Overview

The plugin SDK is the typed contract between plugins and core. This page is the reference for what to import and what you can register.
Looking for a how-to guide? - First plugin? Start with Getting Started - Channel plugin? See Channel Plugins - Provider plugin? See Provider Plugins

Import convention

Always import from a specific subpath:
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
Each subpath is a small, self-contained module. This keeps startup fast and prevents circular dependency issues.

Subpath reference

The most commonly used subpaths, grouped by purpose. The full list of 100+ subpaths is in scripts/lib/plugin-sdk-entrypoints.json.

Plugin entry

SubpathKey exports
plugin-sdk/plugin-entrydefinePluginEntry
plugin-sdk/coredefineChannelPluginEntry, createChatChannelPlugin, createChannelPluginBase, defineSetupPluginEntry, buildChannelConfigSchema
SubpathKey exports
plugin-sdk/channel-setupcreateOptionalChannelSetupSurface
plugin-sdk/channel-pairingcreateChannelPairingController
plugin-sdk/channel-reply-pipelinecreateChannelReplyPipeline
plugin-sdk/channel-config-helperscreateHybridChannelConfigAdapter
plugin-sdk/channel-config-schemaChannel config schema types
plugin-sdk/channel-policyresolveChannelGroupRequireMention
plugin-sdk/channel-lifecyclecreateAccountStatusSink
plugin-sdk/channel-inboundDebounce, mention matching, envelope helpers
plugin-sdk/channel-send-resultReply result types
plugin-sdk/channel-actionscreateMessageToolButtonsSchema, createMessageToolCardSchema
plugin-sdk/channel-targetsTarget parsing/matching helpers
plugin-sdk/channel-contractChannel contract types
plugin-sdk/channel-feedbackFeedback/reaction wiring
| Subpath | Key exports | | --- | --- | | plugin-sdk/provider-auth | createProviderApiKeyAuthMethod, ensureApiKeyFromOptionEnvOrPrompt, upsertAuthProfile | | plugin-sdk/provider-models | normalizeModelCompat | | plugin-sdk/provider-catalog | Catalog type re-exports | | plugin-sdk/provider-usage | fetchClaudeUsage and similar | | plugin-sdk/provider-stream | Stream wrapper types | | plugin-sdk/provider-onboard | Onboarding config patch helpers |
| Subpath | Key exports | | --- | --- | | plugin-sdk/command-auth | resolveControlCommandGate | | plugin-sdk/allow-from | formatAllowFromLowercase | | plugin-sdk/secret-input | Secret input parsing helpers | | plugin-sdk/webhook-ingress | Webhook request/target helpers |
| Subpath | Key exports | | --- | --- | | plugin-sdk/runtime-store | createPluginRuntimeStore | | plugin-sdk/config-runtime | Config load/write helpers | | plugin-sdk/infra-runtime | System event/heartbeat helpers | | plugin-sdk/agent-runtime | Agent dir/identity/workspace helpers | | plugin-sdk/directory-runtime | Config-backed directory query/dedup | | plugin-sdk/keyed-async-queue | KeyedAsyncQueue |
SubpathKey exports
plugin-sdk/image-generationImage generation provider types
plugin-sdk/media-understandingMedia understanding provider types
plugin-sdk/speechSpeech provider types
plugin-sdk/testinginstallCommonResolveTargetErrorCases, shouldAckReaction

Registration API

The register(api) callback receives an OpenClawPluginApi object with these methods:

Capability registration

MethodWhat it registers
api.registerProvider(...)Text inference (LLM)
api.registerChannel(...)Messaging channel
api.registerSpeechProvider(...)Text-to-speech / STT synthesis
api.registerMediaUnderstandingProvider(...)Image/audio/video analysis
api.registerImageGenerationProvider(...)Image generation
api.registerWebSearchProvider(...)Web search

Tools and commands

MethodWhat it registers
api.registerTool(tool, opts?)Agent tool (required or { optional: true })
api.registerCommand(def)Custom command (bypasses the LLM)

Infrastructure

MethodWhat it registers
api.registerHook(events, handler, opts?)Event hook
api.registerHttpRoute(params)Gateway HTTP endpoint
api.registerGatewayMethod(name, handler)Gateway RPC method
api.registerCli(registrar, opts?)CLI subcommand
api.registerService(service)Background service
api.registerInteractiveHandler(registration)Interactive handler

Exclusive slots

MethodWhat it registers
api.registerContextEngine(id, factory)Context engine (one active at a time)
api.registerMemoryPromptSection(builder)Memory prompt section builder

Events and lifecycle

MethodWhat it does
api.on(hookName, handler, opts?)Typed lifecycle hook
api.onConversationBindingResolved(handler)Conversation binding callback

Hook decision semantics

  • before_tool_call: returning { block: true } is terminal. Once any handler sets it, lower-priority handlers are skipped.
  • before_tool_call: returning { block: false } is treated as no decision (same as omitting block), not as an override.
  • message_sending: returning { cancel: true } is terminal. Once any handler sets it, lower-priority handlers are skipped.
  • message_sending: returning { cancel: false } is treated as no decision (same as omitting cancel), not as an override.

API object fields

FieldTypeDescription
api.idstringPlugin id
api.namestringDisplay name
api.versionstring?Plugin version (optional)
api.descriptionstring?Plugin description (optional)
api.sourcestringPlugin source path
api.rootDirstring?Plugin root directory (optional)
api.configOpenClawConfigCurrent config snapshot
api.pluginConfigRecord<string, unknown>Plugin-specific config from plugins.entries.<id>.config
api.runtimePluginRuntimeRuntime helpers
api.loggerPluginLoggerScoped logger (debug, info, warn, error)
api.registrationModePluginRegistrationMode"full", "setup-only", or "setup-runtime"
api.resolvePath(input)(string) => stringResolve path relative to plugin root

Internal module convention

Within your plugin, use local barrel files for internal imports:
my-plugin/
  api.ts            # Public exports for external consumers
  runtime-api.ts    # Internal-only runtime exports
  index.ts          # Plugin entry point
  setup-entry.ts    # Lightweight setup-only entry (optional)
Never import your own plugin through openclaw/plugin-sdk/<your-plugin> from production code. Route internal imports through ./api.ts or ./runtime-api.ts. The SDK path is the external contract only.

This page is sourced from openclaw/openclaw.
Last modified on March 27, 2026