Overview
The Plugin SDK enables developers to create plugins that extend AIRI’s capabilities. Plugins can provide AI models, tools, integrations, and custom features through a standardized lifecycle and communication protocol.Installation
Architecture
The Plugin SDK follows a host-guest architecture:- Plugin Host: Manages plugin lifecycle, communication channels, and capability orchestration
- Plugins: Independent modules that contribute features through a standardized protocol
- Channels: Transport-agnostic communication layer (in-memory, WebSocket, Worker)
- Protocol: Structured events and lifecycle phases
Key Concepts
Plugin Lifecycle
Plugins progress through defined phases:- Loading - Plugin module is imported
- Loaded - Plugin is successfully loaded
- Authenticating - Establishing secure connection
- Authenticated - Authentication successful
- Announced - Plugin registered in module registry
- Preparing - Checking dependencies and prerequisites
- Prepared - Ready for configuration
- Configuration Needed - Waiting for user configuration
- Configured - Configuration applied
- Ready - Plugin is fully active
Transport Types
The SDK supports multiple transport mechanisms:- In-Memory: Direct function calls within the same process
- WebSocket: Remote communication over network (planned)
- Worker: Web Workers or Node.js worker threads (planned)
- Electron IPC: Electron main/renderer process communication (planned)
Capabilities
Plugins contribute capabilities that other plugins can depend on:Basic Plugin Structure
Plugin Manifest
Plugins are loaded via a manifest that specifies entrypoints for different runtimes:Core APIs
The SDK provides several API modules:Protocol APIs
Communication with the plugin host:- Capabilities: Announce and wait for capabilities
- Resources: Manage resources and providers
Client APIs
Access to client-side functionality:- Resources: Access shared resources
- Providers: Query available providers
Event-Driven Architecture
Plugins communicate through events using@moeru/eventa:
TypeScript Support
The SDK provides full TypeScript type definitions:Testing Plugins
Test your plugins using the plugin host:Plugin Examples
Simple Tool Provider
LLM Provider
Best Practices
Keep plugins focused
Keep plugins focused
Each plugin should have a single, well-defined purpose. Split complex functionality into multiple plugins.
Handle errors gracefully
Handle errors gracefully
Return
false from init() to abort initialization. Emit status events for degraded states.Use capabilities for dependencies
Use capabilities for dependencies
Declare capabilities for features you provide, and wait for capabilities you depend on.
Validate configuration
Validate configuration
Always validate configuration data before applying it. Provide clear error messages.
Implement cleanup
Implement cleanup
Clean up resources when the plugin is stopped or reloaded.
Next Steps
Creating Plugins
Step-by-step guide to building your first plugin
Plugin API Reference
Complete API reference for plugin development
