Skip to main content

2.4.1 Plugin contract

KcodePlugin is the boundary between a demo and the platform. It carries metadata, optional routes, navigation, permissions, settings, commands, lifecycle hooks, and an entry component. See the plugin contract.

2.4.2 Registration validation

The PluginRegistry validates every plugin before it stores a frozen snapshot.

2.4.3 Permissions

Plugins declare permissions. The kernel’s PermissionService stores grants per subject. A subject with platform.admin passes every check. DemoAuthService.hasPermission applies the same administrator rule.

2.4.4 Events

Plugins communicate through an event bus on PluginContext. Handlers run in order, and failures reach the publisher. Examples used by bundled plugins include operations.refresh.requested, operations.dashboard.initialized, and wheremybot.lifecycle.changed.

2.4.5 Configuration

The ConfigurationStore keeps one in-memory namespace for each plugin. A plugin can read or write only settings it declared, and set validates the value against the declared type, options, and required flag. Values are not persisted.

2.4.6 Service interfaces and mocks

Each plugin defines service interfaces such as OperationsService or MeetingService. Mock classes simulate latency and in-memory state behind them. To use a real provider, implement the interface and construct it where the plugin wires its service.

2.4.7 Design system

@kcode/design-system provides a dark, high-contrast visual language as CSS tokens plus primitives, patterns, and charts. Plugins use these primitives instead of defining a parallel visual language.

2.4.8 Logging and notifications

ConsoleLogger and InMemoryNotificationService in @kcode/services implement the SDK’s Logger and NotificationService. The kernel scopes each plugin’s logger with plugin:<id>. In the web app, the runtime logs to the browser console with a [pluginId] prefix and shows toasts for notifications.

2.4.9 Testing

Contract tests (*.contract.test.ts) cover the kernel (kernel.contract.test.ts) and demo authentication (demo-auth-service.contract.test.ts). Run them with pnpm test.