Create a Plugin
Learn how to create custom plugins to extend IrisOS agent capabilities.
Overview
Plugins are modular extensions that add new capabilities to IrisOS agents. This guide will walk you through creating your own plugin from scratch.
Plugin Structure
A basic IrisOS plugin has the following structure:
@irisos/plugin-example/
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts # Main plugin export
│ ├── actions.ts # Custom actions
│ ├── providers.ts # Data providers
│ ├── services.ts # Services
│ └── types.ts # TypeScript types
├── tests/
│ └── index.test.ts
└── README.mdCreating Your First Plugin
1. Initialize the Plugin
2. Install Dependencies
3. Configure TypeScript
Create tsconfig.json:
4. Define Plugin Interface
Create src/types.ts:
Example Plugin: Weather Service
Let's create a weather plugin that fetches weather data:
1. Define Actions
Create src/actions.ts:
2. Create the Main Plugin
Create src/index.ts:
3. Update package.json
Advanced Plugin Features
Adding Providers
Providers supply data to agents:
Adding Services
Services run background tasks:
Adding Middleware
Testing Your Plugin
Create tests/weather.test.ts:
Plugin Configuration
Allow users to configure your plugin:
Building and Testing Locally
Using Your Plugin
Once built, use your plugin with agents:
Plugin Best Practices
Error Handling: Always handle errors gracefully
Validation: Validate all inputs and configuration
Documentation: Provide clear README and inline documentation
TypeScript: Use TypeScript for type safety
Testing: Write comprehensive tests
Versioning: Follow semantic versioning
Performance: Optimize for performance and resource usage
Security: Never expose API keys or sensitive data
Compatibility: Ensure compatibility with IrisOS versions
Clean Code: Follow coding standards and best practices
Publishing Your Plugin
See Publish a Plugin for publishing instructions.
Example Plugins for Reference
Study these official plugins for examples:
@irisos/plugin-evm- Blockchain interactions@irisos/plugin-discord- Platform integration@irisos/plugin-images- External API integration@irisos/plugin-sql- Database operations
Next Steps
Publish a Plugin - Publish your plugin to npm
Plugin Reference - Browse existing plugins
API Reference - API documentation
Need Help?
Last updated