2.1 XpertPlugin
XpertPlugin is the main entry interface for plugins, defining plugin metadata (meta), configuration (config), lifecycle methods, and module registration logic.
- meta: Basic plugin metadata, including
name,version,category,icon,description, etc. - config: Defines the plugin’s configuration schema (based on
zod), supporting default values and UI form rendering. - register: Returns a
DynamicModuleto mount the plugin to the main application (optionally as global).
2.2 Plugin Lifecycle
The plugin system provides a complete set of lifecycle hooks for each plugin, allowing developers to execute initialization or cleanup logic at different stages.- onInit: Suitable for resource initialization (e.g., loading configs, registering resource pools).
- onStart: Suitable for starting background tasks or service listeners.
- onStop: Suitable for cleaning up resources, closing connections, releasing caches.
2.3 Plugin Health Check
Plugins can implement thecheckHealth method to report their running status, enabling unified health monitoring by the host system.
- status: Running status (
upordown) - details: Optional dependency check details, such as API connectivity or database status
2.4 Plugin Context
PluginContext provides plugins with runtime access to the host system, including application context, logging service, and configuration.
- app: NestJS’s
INestApplicationContext, allowing access to the DI container. - logger: Unified logging interface, supporting
debug,log,warn,error. - config: Final config object after zod validation and merging defaults.
- resolve: Retrieve other providers from the NestJS container.
2.5 Plugin Configuration Specification
Each plugin can define a configuration specification to constrain and validate config parameters, usually implemented via azod schema:
- Supports type safety (zod type inference)
- Supports default values and secure input (e.g., API key secrets)
- The host system automatically renders the config UI based on the schema
2.6 XpertServerPlugin Decorator
@XpertServerPlugin is an enhanced Nestjs Module class decorator, used to register plugins as NestJS modules and attach plugin metadata.
- Essentially extends NestJS’s
@Moduledecorator - Supports registering submodules, services, controllers, entities, etc.
- The plugin thus becomes a complete NestJS dynamic module
2.7 Enhancement Points
Enhancement points are the key mechanism for plugins to extend the host system. The host system defines a series of strategy interfaces, and plugins can implement these interfaces and use decorators to be automatically discovered and registered.IntegrationStrategy
Used to connect external systems or API services, such as Firecrawl, OpenAI, etc.- meta: Metadata for the integration provider (name, description, icon, etc.)
- execute: Executes the integration logic (e.g., calling external APIs)
DocumentSourceStrategy
Used to connect new data sources, such as web crawlers, file parsers, databases. Plugins only need to implement the corresponding interface to make the data source available to agents/BI.2.8 Strategy Registry
All strategy classes (Integration, DocumentSource, etc.) are registered to the strategy registry via decorators + NestJS dependency injection. For example, IntegrationStrategy:IntegrationStrategyRegistryautomatically discovers classes decorated with@IntegrationStrategyKey- Plugins do not need to manually register strategies; implementing the interface and using the decorator is enough for system recognition
2.9 Plugin Resources and Initialization Targets
Besides code extension points, a plugin can also declare resources that the host can initialize after the plugin bundle is loaded. The host reads the current bundle definitions live and exposes a plugin-side initialization entry. Resources are split by target:- Workspace: initialize into a workspace for
Skills,MCP, andApps - Xpert: initialize into an existing Xpert for
Hooks
- Already initialized resources are recognized as installed and do not reappear in the selectable list
- When the plugin bundle changes, the host can surface stale definitions as updateable resources
- Resource state refreshes with the host instead of relying on a stale static cache
assets/ are presentation metadata only. They are not installable resources.
2.10 Plugin Scope and Level
Plugin scope determines where a plugin instance is installed and who can see or manage it. Plugin level describes the type of platform capability the plugin provides. They are related, but they are not the same thing. Common scopes:
Runtime capability lookup follows this order:
meta.level = 'system' only when the plugin must be a platform singleton. Examples include plugins that define system-level database entities or modules that cannot safely exist in multiple tenant copies. System plugins are managed differently:
- They can be installed or updated only by a Super Admin in the Default tenant.
- The host stores them once under
system:global; repeated installs update the same singleton instance. - Ordinary tenants can see and use the resulting capabilities, but cannot install, uninstall, or configure the system instance from their organization view.
📌 Summary:
XpertPlugindefines plugin metadata, configuration, and lifecycleXpertServerPluginregisters plugins as NestJS modules- Enhancement points (Strategy) are the core for plugins to extend host system functionality
- All plugins form extensible and maintainable modules via lifecycle + strategy interfaces + config schema
- Plugin resources can be initialized into Workspace or Xpert targets with tracked installation state
- Plugin scope controls visibility and management;
systemplugins are platform singletons installed only from the Default tenant