























@@ -1,24 +1,23 @@
11---
2-title: "Plugin SDK Overview"
3-sidebarTitle: "SDK Overview"
2+title: "Plugin SDK overview"
3+sidebarTitle: "SDK overview"
44summary: "Import map, registration API reference, and SDK architecture"
55read_when:
66 - You need to know which SDK subpath to import from
77 - You want a reference for all registration methods on OpenClawPluginApi
88 - You are looking up a specific SDK export
99---
101011-# Plugin SDK Overview
12-1311The plugin SDK is the typed contract between plugins and core. This page is the
1412reference for **what to import** and **what you can register**.
15131614<Tip>
17-**Looking for a how-to guide?**
18-- First plugin? Start with [Getting Started](/plugins/building-plugins)
19-- Channel plugin? See [Channel Plugins](/plugins/sdk-channel-plugins)
20-- Provider plugin? See [Provider Plugins](/plugins/sdk-provider-plugins)
21-</Tip>
15+ Looking for a how-to guide instead?
16+17+- First plugin? Start with [Building plugins](/plugins/building-plugins).
18+- Channel plugin? See [Channel plugins](/plugins/sdk-channel-plugins).
19+- Provider plugin? See [Provider plugins](/plugins/sdk-provider-plugins).
20+</Tip>
22212322## Import convention
2423@@ -35,29 +34,26 @@ prefer `openclaw/plugin-sdk/channel-core`; keep `openclaw/plugin-sdk/core` for
3534the broader umbrella surface and shared helpers such as
3635`buildChannelConfigSchema`.
373638-Do not add or depend on provider-named convenience seams such as
39-`openclaw/plugin-sdk/slack`, `openclaw/plugin-sdk/discord`,
40-`openclaw/plugin-sdk/signal`, `openclaw/plugin-sdk/whatsapp`, or
41-channel-branded helper seams. Bundled plugins should compose generic
42-SDK subpaths inside their own `api.ts` or `runtime-api.ts` barrels, and core
43-should either use those plugin-local barrels or add a narrow generic SDK
44-contract when the need is truly cross-channel.
45-46-The generated export map still contains a small set of bundled-plugin helper
47-seams such as `plugin-sdk/feishu`, `plugin-sdk/feishu-setup`,
48-`plugin-sdk/zalo`, `plugin-sdk/zalo-setup`, and `plugin-sdk/matrix*`. Those
49-subpaths exist for bundled-plugin maintenance and compatibility only; they are
50-intentionally omitted from the common table below and are not the recommended
51-import path for new third-party plugins.
37+<Warning>
38+ Do not import provider- or channel-branded convenience seams (for example
39+`openclaw/plugin-sdk/slack`, `.../discord`, `.../signal`, `.../whatsapp`).
40+ Bundled plugins compose generic SDK subpaths inside their own `api.ts` /
41+`runtime-api.ts` barrels; core consumers should either use those plugin-local
42+ barrels or add a narrow generic SDK contract when a need is truly
43+ cross-channel.
44+45+A small set of bundled-plugin helper seams (`plugin-sdk/feishu`,
46+`plugin-sdk/zalo`, `plugin-sdk/matrix*`, and similar) still appear in the
47+generated export map. They exist for bundled-plugin maintenance only and are
48+not recommended import paths for new third-party plugins.
49+</Warning>
52505351## Subpath reference
54525553The most commonly used subpaths, grouped by purpose. The generated full list of
56-200+ subpaths lives in `scripts/lib/plugin-sdk-entrypoints.json`.
57-58-Reserved bundled-plugin helper subpaths still appear in that generated list.
59-Treat those as implementation detail/compatibility surfaces unless a doc page
60-explicitly promotes one as public.
54+200+ subpaths lives in `scripts/lib/plugin-sdk-entrypoints.json`; reserved
55+bundled-plugin helper subpaths appear there but are implementation detail
56+unless a doc page explicitly promotes them.
61576258### Plugin entry
6359@@ -355,18 +351,23 @@ methods:
355351| `api.registerMemoryPromptSupplement(builder)` | Additive memory-adjacent prompt section |
356352| `api.registerMemoryCorpusSupplement(adapter)` | Additive memory search/read corpus |
357353358-Reserved core admin namespaces (`config.*`, `exec.approvals.*`, `wizard.*`,
359-`update.*`) always stay `operator.admin`, even if a plugin tries to assign a
360-narrower gateway method scope. Prefer plugin-specific prefixes for
361-plugin-owned methods.
354+<Note>
355+ Reserved core admin namespaces (`config.*`, `exec.approvals.*`, `wizard.*`,
356+`update.*`) always stay `operator.admin`, even if a plugin tries to assign a
357+ narrower gateway method scope. Prefer plugin-specific prefixes for
358+ plugin-owned methods.
359+</Note>
360+361+<Accordion title="When to use registerEmbeddedExtensionFactory">
362+ Use `api.registerEmbeddedExtensionFactory(...)` when a plugin needs Pi-native
363+ event timing during OpenClaw embedded runs — for example async `tool_result`
364+ rewrites that must happen before the final tool-result message is emitted.
362365363-Use `api.registerEmbeddedExtensionFactory(...)` when a plugin needs Pi-native
364-event timing during OpenClaw embedded runs, for example async `tool_result`
365-rewrites that must happen before the final tool-result message is emitted.
366-This is a bundled-plugin seam today: only bundled plugins may register one, and
367-they must declare `contracts.embeddedExtensionFactories: ["pi"]` in
366+This is a bundled-plugin seam today: only bundled plugins may register one,
367+and they must declare `contracts.embeddedExtensionFactories: ["pi"]` in
368368`openclaw.plugin.json`. Keep normal OpenClaw plugin hooks for everything that
369369does not require that lower-level seam.
370+</Accordion>
370371371372### CLI registration metadata
372373@@ -500,23 +501,20 @@ my-plugin/
500501</Warning>
501502502503Facade-loaded bundled plugin public surfaces (`api.ts`, `runtime-api.ts`,
503-`index.ts`, `setup-entry.ts`, and similar public entry files) now prefer the
504+`index.ts`, `setup-entry.ts`, and similar public entry files) prefer the
504505active runtime config snapshot when OpenClaw is already running. If no runtime
505506snapshot exists yet, they fall back to the resolved config file on disk.
506507507-Provider plugins can also expose a narrow plugin-local contract barrel when a
508+Provider plugins can expose a narrow plugin-local contract barrel when a
508509helper is intentionally provider-specific and does not belong in a generic SDK
509-subpath yet. Current bundled example: the Anthropic provider keeps its Claude
510-stream helpers in its own public `api.ts` / `contract-api.ts` seam instead of
511-promoting Anthropic beta-header and `service_tier` logic into a generic
512-`plugin-sdk/*` contract.
513-514-Other current bundled examples:
510+subpath yet. Bundled examples:
515511516-- `@openclaw/openai-provider`: `api.ts` exports provider builders,
517- default-model helpers, and realtime provider builders
518-- `@openclaw/openrouter-provider`: `api.ts` exports the provider builder plus
519- onboarding/config helpers
512+- **Anthropic**: public `api.ts` / `contract-api.ts` seam for Claude
513+ beta-header and `service_tier` stream helpers.
514+- **`@openclaw/openai-provider`**: `api.ts` exports provider builders,
515+ default-model helpers, and realtime provider builders.
516+- **`@openclaw/openrouter-provider`**: `api.ts` exports the provider builder
517+ plus onboarding/config helpers.
520518521519<Warning>
522520 Extension production code should also avoid `openclaw/plugin-sdk/<other-plugin>`
@@ -527,9 +525,23 @@ Other current bundled examples:
527525528526## Related
529527530-- [Entry Points](/plugins/sdk-entrypoints) — `definePluginEntry` and `defineChannelPluginEntry` options
531-- [Runtime Helpers](/plugins/sdk-runtime) — full `api.runtime` namespace reference
532-- [Setup and Config](/plugins/sdk-setup) — packaging, manifests, config schemas
533-- [Testing](/plugins/sdk-testing) — test utilities and lint rules
534-- [SDK Migration](/plugins/sdk-migration) — migrating from deprecated surfaces
535-- [Plugin Internals](/plugins/architecture) — deep architecture and capability model
528+<CardGroup cols={2}>
529+<Card title="Entry points" icon="door-open" href="/plugins/sdk-entrypoints">
530+`definePluginEntry` and `defineChannelPluginEntry` options.
531+</Card>
532+<Card title="Runtime helpers" icon="gears" href="/plugins/sdk-runtime">
533+Full `api.runtime` namespace reference.
534+</Card>
535+<Card title="Setup and config" icon="sliders" href="/plugins/sdk-setup">
536+Packaging, manifests, and config schemas.
537+</Card>
538+<Card title="Testing" icon="vial" href="/plugins/sdk-testing">
539+Test utilities and lint rules.
540+</Card>
541+<Card title="SDK migration" icon="arrows-turn-right" href="/plugins/sdk-migration">
542+Migrating from deprecated surfaces.
543+</Card>
544+<Card title="Plugin internals" icon="diagram-project" href="/plugins/architecture">
545+Deep architecture and capability model.
546+</Card>
547+</CardGroup>
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。