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.Import convention
Always import from a specific subpath:velaclaw/plugin-sdk/channel-core; keep velaclaw/plugin-sdk/core for
the broader umbrella surface and shared helpers such as
buildChannelConfigSchema.
Do not add or depend on provider-named convenience seams such as
velaclaw/plugin-sdk/slack, velaclaw/plugin-sdk/discord,
velaclaw/plugin-sdk/signal, velaclaw/plugin-sdk/whatsapp, or
channel-branded helper seams. Bundled plugins should compose generic
SDK subpaths inside their own api.ts or runtime-api.ts barrels, and core
should either use those plugin-local barrels or add a narrow generic SDK
contract when the need is truly cross-channel.
The generated export map still contains a small set of bundled-plugin helper
seams such as plugin-sdk/feishu, plugin-sdk/feishu-setup,
plugin-sdk/zalo, plugin-sdk/zalo-setup, and plugin-sdk/matrix*. Those
subpaths exist for bundled-plugin maintenance and compatibility only; they are
intentionally omitted from the common table below and are not the recommended
import path for new third-party plugins.
Subpath reference
The most commonly used subpaths, grouped by purpose. The generated full list of 200+ subpaths lives inscripts/lib/plugin-sdk-entrypoints.json.
Reserved bundled-plugin helper subpaths still appear in that generated list.
Treat those as implementation detail/compatibility surfaces unless a doc page
explicitly promotes one as public.
Plugin entry
Channel subpaths
Channel subpaths
Provider subpaths
Provider subpaths
Auth and security subpaths
Auth and security subpaths
Runtime and storage subpaths
Runtime and storage subpaths
Capability and testing subpaths
Capability and testing subpaths
Memory subpaths
Memory subpaths
Reserved bundled-helper subpaths
Reserved bundled-helper subpaths
Registration API
Theregister(api) callback receives an VelaclawPluginApi object with these
methods:
Capability registration
Tools and commands
Infrastructure
Reserved core admin namespaces (
config.*, exec.approvals.*, wizard.*,
update.*) always stay operator.admin, even if a plugin tries to assign a
narrower gateway method scope. Prefer plugin-specific prefixes for
plugin-owned methods.
CLI registration metadata
api.registerCli(registrar, opts?) accepts two kinds of top-level metadata:
commands: explicit command roots owned by the registrardescriptors: parse-time command descriptors used for root CLI help, routing, and lazy plugin CLI registration
descriptors that cover every top-level command root exposed by that
registrar.
commands by itself only when you do not need lazy root CLI registration.
That eager compatibility path remains supported, but it does not install
descriptor-backed placeholders for parse-time lazy loading.
CLI backend registration
api.registerCliBackend(...) lets a plugin own the default config for a local
AI CLI backend such as codex-cli.
- The backend
idbecomes the provider prefix in model refs likecodex-cli/gpt-5. - The backend
configuses the same shape asagents.defaults.cliBackends.<id>. - User config still wins. Velaclaw merges
agents.defaults.cliBackends.<id>over the plugin default before running the CLI. - Use
normalizeConfigwhen a backend needs compatibility rewrites after merge (for example normalizing old flag shapes).
Exclusive slots
Memory embedding adapters
registerMemoryCapabilityis the preferred exclusive memory-plugin API.registerMemoryCapabilitymay also exposepublicArtifacts.listArtifacts(...)so companion plugins can consume exported memory artifacts throughvelaclaw/plugin-sdk/memory-host-coreinstead of reaching into a specific memory plugin’s private layout.registerMemoryPromptSection,registerMemoryFlushPlan, andregisterMemoryRuntimeare legacy-compatible exclusive memory-plugin APIs.registerMemoryEmbeddingProviderlets the active memory plugin register one or more embedding adapter ids (for exampleopenai,gemini, or a custom plugin-defined id).- User config such as
agents.defaults.memorySearch.providerandagents.defaults.memorySearch.fallbackresolves against those registered adapter ids.
Events and lifecycle
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 omittingblock), not as an override.before_install: returning{ block: true }is terminal. Once any handler sets it, lower-priority handlers are skipped.before_install: returning{ block: false }is treated as no decision (same as omittingblock), not as an override.reply_dispatch: returning{ handled: true, ... }is terminal. Once any handler claims dispatch, lower-priority handlers and the default model dispatch path are skipped.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 omittingcancel), not as an override.
API object fields
Internal module convention
Within your plugin, use local barrel files for internal imports:api.ts, runtime-api.ts,
index.ts, setup-entry.ts, and similar public entry files) now prefer the
active runtime config snapshot when Velaclaw is already running. If no runtime
snapshot exists yet, they fall back to the resolved config file on disk.
Provider plugins can also expose a narrow plugin-local contract barrel when a
helper is intentionally provider-specific and does not belong in a generic SDK
subpath yet. Current bundled example: the Anthropic provider keeps its Claude
stream helpers in its own public api.ts / contract-api.ts seam instead of
promoting Anthropic beta-header and service_tier logic into a generic
plugin-sdk/* contract.
Other current bundled examples:
@velaclaw/openai-provider:api.tsexports provider builders, default-model helpers, and realtime provider builders@velaclaw/openrouter-provider:api.tsexports the provider builder plus onboarding/config helpers
Related
- Entry Points —
definePluginEntryanddefineChannelPluginEntryoptions - Runtime Helpers — full
api.runtimenamespace reference - Setup and Config — packaging, manifests, config schemas
- Testing — test utilities and lint rules
- SDK Migration — migrating from deprecated surfaces
- Plugin Internals — deep architecture and capability model