Plugin Lifecycle
1. Discovery
OpenClaw discovers plugins from multiple sources:- Workspace packages -
extensions/directory (monorepo pattern) - npm packages - Installed via
openclaw plugins install <package> - Config entries - Listed in
config.jsonunderplugins.entries
2. Loading
Plugins are loaded using dynamic imports (jiti for TypeScript support):
- An object with
id,name, andregisterfunction - A function that receives the Plugin API directly
3. Registration
During registration, plugins use the Plugin API to register:- Channels -
api.registerChannel(plugin) - Tools -
api.registerTool(tool, options) - Hooks -
api.registerHook(events, handler, options) - Services -
api.registerService(service) - HTTP handlers -
api.registerHttpRoute({ path, handler }) - CLI commands -
api.registerCli(registrar) - Providers -
api.registerProvider(provider)
4. Activation
After registration, plugins can implement an optionalactivate method for deferred initialization:
Plugin API
TheOpenClawPluginApi provides access to:
Core Properties
id- Plugin identifiername- Plugin display nameversion- Plugin versionconfig- OpenClaw configurationpluginConfig- Plugin-specific configuration fromplugins.entries[id].configruntime- Runtime services (media, messaging, tools, logging)logger- Scoped logger for plugin messages
Registration Methods
registerChannel(registration)- Register a channel pluginregisterTool(tool, options)- Register an agent toolregisterHook(events, handler, options)- Register a lifecycle hookregisterService(service)- Register a background serviceregisterHttpRoute({ path, handler })- Register an HTTP routeregisterCli(registrar)- Register CLI commandsregisterProvider(provider)- Register an auth providerregisterCommand(command)- Register a plugin command
Utility Methods
resolvePath(input)- Resolve paths relative to plugin sourceon(hookName, handler)- Register lifecycle hooks (alternative API)
Runtime Services
Theapi.runtime object provides access to OpenClaw’s core services:
Plugin Configuration
Plugins can define configuration schemas:config.json:
Workspace Package Pattern
OpenClaw uses a monorepo pattern with workspace packages inextensions/:
package.jsonwithopenclaw.extensionsentry pointing toindex.ts- Entry point exports a plugin object
- Dependencies in
dependencies(notdevDependencies) openclawindevDependenciesorpeerDependencies
Plugin Dependencies
Plugins can have their own dependencies:dependencies. Development-only imports from openclaw/plugin-sdk should have openclaw in devDependencies or peerDependencies.
Plugin Isolation
Plugins run in the same process as OpenClaw core but are logically isolated:- Each plugin has a scoped logger (
api.logger) - Configuration is namespaced under
plugins.entries[id] - HTTP routes are normalized to prevent conflicts
- Tools can be marked
optionalto require explicit allowlisting
Error Handling
Plugins should handle errors gracefully:api.logger for diagnostic output.
Next Steps
- Getting Started Guide - Create your first plugin
- Plugin SDK Reference - Complete API documentation
- Hooks - Implement lifecycle hooks
- Tools - Add custom agent tools
- Channels - Build channel integrations

