Skip to main content
The @proj-airi/plugin-sdk is currently in active development. APIs may change without warning.

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:
  1. Loading - Plugin module is imported
  2. Loaded - Plugin is successfully loaded
  3. Authenticating - Establishing secure connection
  4. Authenticated - Authentication successful
  5. Announced - Plugin registered in module registry
  6. Preparing - Checking dependencies and prerequisites
  7. Prepared - Ready for configuration
  8. Configuration Needed - Waiting for user configuration
  9. Configured - Configuration applied
  10. 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

Each plugin should have a single, well-defined purpose. Split complex functionality into multiple plugins.
Return false from init() to abort initialization. Emit status events for degraded states.
Declare capabilities for features you provide, and wait for capabilities you depend on.
Always validate configuration data before applying it. Provide clear error messages.
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