@xpert-ai/plugin-sdk.
Capability model
A capability key is a frozen object containing a stable ID, a description, and a TypeScript-only API type:get() and require(), while the stable ID lets the host and dynamically loaded plugins agree on the same contract.
The registry exposes four operations:
Resolve a capability in Agent middleware
Agent middleware receives the scoped registry oncontext.runtime.capabilities:
get() when the feature can be hidden or degraded. Use require() only after the plugin has established that the capability is mandatory for the current operation:
Resolve a capability in a NestJS provider
The platform registry is populated throughRuntimeCapabilityProvider discovery after Nest instantiates the modules. Inject XPERT_RUNTIME_CAPABILITIES_TOKEN, then resolve capabilities when an operation runs, after discovery; do not resolve factories in a service constructor.
Workspace Files is available directly in the current platform registry. Explicit operations still require the correct authorized volume; runtime-relative paths require a bound Project or Assistant. Creating a complete Agent runtime is not mandatory for every domain API.
Check factory availability in the platform registry. Checking its scoped operation key there does not establish whether the factory is installed.
authorizedScope comes from an authenticated and authorized request, resolved View context or restored job identity. Never construct tenant, organization, user, Assistant, Project, conversation or execution identity from iframe or tool input. A factory does not grant access.
Reuse the returned API within that operation only. Do not cache it in a singleton or register it back into the platform registry. Connector bindings, token caches and issued visual paths belong to one caller/execution.
Capabilities in the runtime package
See the SDK project integration guide for combining provisioning, project access and business task capabilities.
Continue with the detailed references:
- Workspace Files
- Knowledgebase capabilities
- Artifacts
- Sandbox Jobs
- Actor Token
- Project Provisioning
- Content and editors
- Agent invocation
- MCP Client
- REST Client
- Analytics and providers
- HTML Artifact documents
- Tool images
Define and test capability consumers
createRuntimeCapability<T>() creates a typed key for a host or plugin subsystem. Do not reuse a platform.* ID for a different contract. RuntimeCapabilityResolver is the read-only get() view to use when a consumer must not register implementations.
DefaultRuntimeCapabilityRegistry:
Compatibility rules
- Import keys and API types from
@xpert-ai/plugin-sdk; do not copy the interfaces into a plugin. - Choose a domain API, scoped factory or Agent facade according to its contract. Never fall back from a missing scoped API to broader authority.
- Use stable capability IDs across SDK copies; do not dispatch platform CQRS classes from plugins. Host-internal services keep normal Nest injection and are not exported merely to decouple modules.
- Treat capability availability as a runtime condition. Package installation alone does not prove that a host service, provider, binding, or registered Sandbox Action is ready.
- Keep portable references and structured DTOs at async boundaries. Do not pass raw file bytes, bearer tokens, host paths, or implementation instances through queues or persisted chat metadata.
- Keep capability results within the current authorized scope and re-resolve them for later jobs or callbacks.