feat(plugins): implement plugin loader and integration points#135
Merged
sasagar merged 1 commit intofeature/plugin-event-busfrom Jan 28, 2026
Merged
feat(plugins): implement plugin loader and integration points#135sasagar merged 1 commit intofeature/plugin-event-busfrom
sasagar merged 1 commit intofeature/plugin-event-busfrom
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
4 tasks
b6ec65c to
ad0b799
Compare
85c8d41 to
c189281
Compare
1979651 to
d83663b
Compare
- Add PluginLoader class for plugin discovery and lifecycle management - Implement DatabasePluginConfigStorage for persistent config - Add plugin routes for admin API - Support both array and object formats for plugin dependencies - Provide proper PluginContext to ActivityPub handlers - Fix TypeScript errors in test files
d83663b to
e1b6e9d
Compare
c189281 to
1615cb0
Compare
4 tasks
sasagar
added a commit
that referenced
this pull request
Jan 28, 2026
* feat(plugins): implement event bus foundation for plugin system - Add typed EventBus class with before/after event patterns - Define plugin type interfaces (PluginUser, PluginNote, PluginFollow, PluginActivity) - Use Visibility union type for type safety in note visibility - Implement event payload types for all lifecycle events - Add note lifecycle events: beforeCreate, afterCreate, beforeDelete, afterDelete - Add user lifecycle events: beforeRegister, afterRegister, beforeLogin, afterLogin, afterLogout - Add follow lifecycle events: afterCreate, afterDelete - Add ActivityPub events: beforeInbox, afterInbox, beforeDelivery, afterDelivery - Add moderation events: userSuspended, noteDeleted - Integrate EventBus into DI container and middleware - Emit events in NoteService, AuthService, FollowService - Apply modifiedPayload from beforeCreate/beforeRegister events - Remove PII (email) from user:beforeRegister payload - Remove PII (ipAddress, userAgent) from user:beforeLogin payload - Add shared toPluginUser/toPluginNote utility functions - Add test helper factory functions - Document composite followId format for delete events - Document emitBefore error handling behavior * feat(plugins): implement plugin loader and integration points (#135) - Add PluginLoader class for plugin discovery and lifecycle management - Implement DatabasePluginConfigStorage for persistent config - Add plugin routes for admin API - Support both array and object formats for plugin dependencies - Provide proper PluginContext to ActivityPub handlers - Fix TypeScript errors in test files * feat(plugins): implement frontend plugin slots, admin UI, and sample plugin (#138) Frontend Plugin System: - Add PluginRegistry singleton for managing plugin state - Create PluginSlot component for rendering plugin-provided components - Define slot types (19 locations: note, compose, profile, settings, admin, etc.) - Export public API from lib/plugins/index.ts Admin Plugin Management: - Add /admin/plugins page for viewing and managing plugins - Enable/disable plugins through admin interface - Display plugin status and version - Add Plugins link to AdminNav Sample Plugin: - Add hello-world sample plugin demonstrating: - Plugin manifest (plugin.json) - Event subscriptions (note:afterCreate) - Custom API routes (/api/x/hello-world/) - Configuration storage - Add plugins/README.md with development documentation - Add comment explaining context unavailability in onUnload Backend Updates: - Add plugin routes at /api/plugins - Add enabled check middleware for plugin routes (404 when disabled) - Add enabled check for ActivityPub handlers - Fix logger signature to accept variadic args - Add manifest.id vs plugin.id mismatch validation - Add PII comment for afterLogin event - Remove sensitive fields (error, loadedAt) from public plugin endpoints - Add description to plugin list API response README Documentation: - Update Phase 7 status to Complete - Add Plugin System feature description - Add Plugin Development documentation link - Fix slot count (19 locations) * chore(deps): update dependencies Frontend: - waku: 1.0.0-alpha.2 → 1.0.0-alpha.3 - jotai: 2.16.0 → 2.17.0 - @lingui/*: 5.7.0 → 5.9.0 - react/react-dom: 19.2.3 → 19.2.4 - react-hook-form: 7.68.0 → 7.71.1 - lucide-react: 0.561.0 → 0.563.0 - katex: 0.16.27 → 0.16.28 Backend: - hono: 4.11.1 → 4.11.7 - zod: 4.2.1 → 4.3.6 - pino: 10.1.0 → 10.3.0 - pg: 8.16.3 → 8.17.2 - ioredis: 5.8.2 → 5.9.2 - bullmq: 5.66.1 → 5.67.2 - @aws-sdk/client-s3: 3.954.0 → 3.975.0 - mysql2: 3.16.0 → 3.16.2 - better-sqlite3: 12.5.0 → 12.6.2 Dev Tools: - oxlint: 1.33.0 → 1.42.0 - @playwright/test: 1.57.0 → 1.58.0 - @types/bun: 1.3.4 → 1.3.7 - typedoc: 0.28.15 → 0.28.16 - vitest: 4.0.16 → 4.0.18 Jotai v2.17.0 deprecates loadable, setSelf, and removes unstable_onInit, but these are not used in our codebase. * fix: address CodeRabbit review comments - Move pluginLoader middleware before routes for proper execution order - Add db parameter to initializePluginSystem for persistent config storage - Remove unused getAll/setMultiple methods from DatabasePluginConfigStorage - Fix Database type to use NodePgDatabase instead of PostgresJsDatabase * fix: address additional CodeRabbit review comments - Use top-level await for plugin initialization to avoid race conditions - Fix middleware type in loader.ts (unknown[] → MiddlewareHandler[]) - Remove unnecessary type cast in init.ts - Track plugin handler errors in compositeHandler for accurate metrics * fix: address additional plugin system review comments - Wrap plugin middleware with runtime enabled check to skip when disabled - Fix loadManifest to ignore npm object-form dependencies in package.json (only array-form plugin IDs are accepted from package.json)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements Phase 2 of the plugin system: Plugin Loader and Integration Points.
Depends on: #134 (Phase 1 - Event Bus)
Changes
PluginLoader class (
packages/backend/src/plugins/loader.ts)Plugin Configuration Storage
InMemoryPluginConfigStoragefor development/testingDatabasePluginConfigStoragefor production (persistent)plugin_configstable in database schemaPlugin System Initialization (
packages/backend/src/plugins/init.ts)/api/x/{pluginId}/App Integration (
packages/backend/src/index.ts)PLUGINS_ENABLED,PLUGINS_DIR)Plugin Directory Structure
Plugins are loaded from the
./pluginsdirectory (configurable viaPLUGINS_DIR):Environment Variables
PLUGINS_ENABLED: Set to "false" to disable plugin system (default: enabled)PLUGINS_DIR: Plugin directory path (default: "./plugins")INSTANCE_NAME: Instance name passed to plugin contextTest plan