




























@@ -183,81 +183,12 @@ local proof.
183183 </Step>
184184</Steps>
185185186-## Plugin capabilities
187-188-A single plugin can register any number of capabilities via the `api` object:
189-190-| Capability | Registration method | Detailed guide |
191-| ---------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------- |
192-| Text inference (LLM) | `api.registerProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins) |
193-| CLI inference backend | `api.registerCliBackend(...)` | [CLI Backend Plugins](/plugins/cli-backend-plugins) |
194-| Channel / messaging | `api.registerChannel(...)` | [Channel Plugins](/plugins/sdk-channel-plugins) |
195-| Speech (TTS/STT) | `api.registerSpeechProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
196-| Realtime transcription | `api.registerRealtimeTranscriptionProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
197-| Realtime voice | `api.registerRealtimeVoiceProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
198-| Media understanding | `api.registerMediaUnderstandingProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
199-| Image generation | `api.registerImageGenerationProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
200-| Music generation | `api.registerMusicGenerationProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
201-| Video generation | `api.registerVideoGenerationProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
202-| Web fetch | `api.registerWebFetchProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
203-| Web search | `api.registerWebSearchProvider(...)` | [Provider Plugins](/plugins/sdk-provider-plugins#step-5-add-extra-capabilities) |
204-| Tool-result middleware | `api.registerAgentToolResultMiddleware(...)` | [SDK Overview](/plugins/sdk-overview#registration-api) |
205-| Agent tools | `api.registerTool(...)` | Below |
206-| Custom commands | `api.registerCommand(...)` | [Entry Points](/plugins/sdk-entrypoints) |
207-| Plugin hooks | `api.on(...)` | [Plugin hooks](/plugins/hooks) |
208-| Internal event hooks | `api.registerHook(...)` | [Entry Points](/plugins/sdk-entrypoints) |
209-| HTTP routes | `api.registerHttpRoute(...)` | [Internals](/plugins/architecture-internals#gateway-http-routes) |
210-| CLI subcommands | `api.registerCli(...)` | [Entry Points](/plugins/sdk-entrypoints) |
211-212-For the full registration API, see [SDK Overview](/plugins/sdk-overview#registration-api).
213-214-Bundled plugins can use `api.registerAgentToolResultMiddleware(...)` when they
215-need async tool-result rewriting before the model sees the output. Declare the
216-targeted runtimes in `contracts.agentToolResultMiddleware`, for example
217-`["pi", "codex"]`. This is a trusted bundled-plugin seam; external
218-plugins should prefer regular OpenClaw plugin hooks unless OpenClaw grows an
219-explicit trust policy for this capability.
220-221-If your plugin registers custom gateway RPC methods, keep them on a
222-plugin-specific prefix. Core admin namespaces (`config.*`,
223-`exec.approvals.*`, `wizard.*`, `update.*`) stay reserved and always resolve to
224-`operator.admin`, even if a plugin asks for a narrower scope.
225-226-`openclaw/plugin-sdk/gateway-method-runtime` is a reserved control-plane bridge
227-for plugin HTTP routes that declare
228-`contracts.gatewayMethodDispatch: ["authenticated-request"]`. It is an
229-intentional-use guard for reviewed native plugins, not a sandbox boundary.
230-231-Hook guard semantics to keep in mind:
232-233-- `before_tool_call`: `{ block: true }` is terminal and stops lower-priority handlers.
234-- `before_tool_call`: `{ block: false }` is treated as no decision.
235-- `before_tool_call`: `{ requireApproval: { ... } }` pauses agent execution and prompts the user for approval via the exec approval overlay, native channel approval clients, or the `/approve` command on any channel.
236-- `before_install`: `{ block: true }` is terminal and stops lower-priority handlers.
237-- `before_install`: `{ block: false }` is treated as no decision.
238-- `message_sending`: `{ cancel: true }` is terminal and stops lower-priority handlers.
239-- `message_sending`: `{ cancel: false }` is treated as no decision.
240-- `message_received`: prefer the typed `threadId` field when you need inbound thread/topic routing. Keep `metadata` for channel-specific extras.
241-- `message_sending`: prefer typed `replyToId` / `threadId` routing fields over channel-specific metadata keys.
242-243-The `/approve` command handles both exec and plugin approvals with bounded fallback: when an exec approval id is not found, OpenClaw retries the same id through plugin approvals. Plugin approval forwarding can be configured independently via `approvals.plugin` in config.
244-245-If custom approval plumbing needs to detect that same bounded fallback case,
246-prefer `isApprovalNotFoundError` from `openclaw/plugin-sdk/error-runtime`
247-instead of matching approval-expiry strings manually.
248-249-See [Plugin hooks](/plugins/hooks) for examples and the hook reference.
250-251-## Registering agent tools
252-253-Tools are typed functions the LLM can call. They can be required (always
254-available) or optional (user opt-in):
255-256-For simple plugins that only own a fixed set of tools, prefer
257-[`defineToolPlugin`](/plugins/tool-plugins). It generates manifest metadata and
258-keeps `contracts.tools` aligned. Use the lower-level `api.registerTool(...)`
259-surface when the plugin also owns channels, providers, hooks, services,
260-commands, or fully dynamic tool registration.
186+<a id="registering-agent-tools"></a>
187+188+## Registering tools
189+190+Tools can be required or optional. Required tools are always available when the
191+plugin is enabled. Optional tools require user opt-in.
261192262193```typescript
263194register(api) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。