AI Forge Documentation

Plugin Development

Extend AI Agents with Custom Plugins

Build custom plugins to extend your AI agents with specialized functionality. Create trading strategies, data connectors, notification systems, and AI models that integrate seamlessly with the AI Forge ecosystem.

Simple SDK
Plugin marketplace
Revenue sharing
Hot reloading

Plugin Types

🔌

Data Connectors

Beginner

Connect to external APIs and data sources

Price feedsSocial media APIsNews sourcesBlockchain data
📈

Trading Strategies

Intermediate

Custom trading algorithms and decision logic

Technical indicatorsArbitrage strategiesRisk modelsPortfolio optimizers
🔔

Notification Systems

Beginner

Alert and communication integrations

Discord botsTelegram alertsEmail notificationsWebhook integrations
🤖

AI Models

Advanced

Custom machine learning models and algorithms

Sentiment analysisPrice predictionPattern recognitionNatural language processing

Development Process

1

Plugin Structure

Create the basic plugin structure and configuration

// plugin.json
{
  "name": "custom-trading-strategy",
  "version": "1.0.0",
  "description": "Advanced momentum trading strategy",
  "author": "Your Name",
  "category": "trading",
  "dependencies": {
    "@aiforge/plugin-sdk": "^1.0.0",
    "technicalindicators": "^3.1.0"
  },
  "permissions": [
    "market_data",
    "trading",
    "portfolio_read"
  ]
}
2

Plugin Implementation

Implement your plugin's core functionality

// index.js
import { Plugin } from '@aiforge/plugin-sdk'

export default class CustomTradingStrategy extends Plugin {
  constructor(config) {
    super(config)
    this.name = 'Custom Trading Strategy'
    this.version = '1.0.0'
  }

  async initialize() {
    // Plugin initialization logic
    this.rsiPeriod = this.config.rsiPeriod || 14
    this.macdPeriod = this.config.macdPeriod || 12
    console.log('Trading strategy plugin initialized')
  }

  async execute(data) {
    // Main plugin logic
    const signals = await this.generateSignals(data)
    return {
      action: signals.action, // 'buy', 'sell', 'hold'
      confidence: signals.confidence,
      reasoning: signals.reasoning
    }
  }
}
3

Testing & Validation

Test your plugin with sample data and validation

// test.js
import CustomTradingStrategy from './index.js'

const plugin = new CustomTradingStrategy({
  rsiPeriod: 14,
  macdPeriod: 12
})

// Test with sample data
const testData = {
  prices: [100, 102, 98, 105, 107, 103],
  volume: [1000, 1200, 800, 1500, 1800, 1100]
}

const result = await plugin.execute(testData)
console.log('Plugin result:', result)

// Validate output format
assert(result.action in ['buy', 'sell', 'hold'])
assert(typeof result.confidence === 'number')
assert(result.confidence >= 0 && result.confidence <= 1)
4

Deployment

Package and deploy your plugin to the marketplace

# Package plugin
npm run build

# Test plugin locally
aiforge plugin test ./dist

# Deploy to marketplace
aiforge plugin deploy ./dist --public

# Install in agent
aiforge agent install custom-trading-strategy

Plugin API Reference

Core Methods

Essential plugin lifecycle methods

  • initialize()Plugin setup and configuration
  • execute(data)Main plugin execution logic
  • cleanup()Cleanup resources on shutdown
  • validate(config)Validate plugin configuration

Data Access

Methods to access agent and market data

  • getMarketData(symbol, timeframe)Get price data
  • getPortfolio()Access current portfolio state
  • getAccountBalance()Get account balances
  • getHistoricalData(params)Access historical data

Agent Interaction

Methods to interact with the agent system

  • sendNotification(message)Send alerts/notifications
  • logEvent(event)Log custom events
  • updateState(state)Update plugin state
  • scheduleTask(task, interval)Schedule recurring tasks

Trading Functions

Methods for trading operations (requires permissions)

  • executeTrade(order)Execute trading orders
  • getOpenOrders()Get active orders
  • cancelOrder(orderId)Cancel existing orders
  • getTradeHistory()Access trade history

Complete Plugin Example

Momentum Trading Strategy Plugin

A complete example showing how to build a trading strategy plugin using technical indicators.

import { Plugin } from '@aiforge/plugin-sdk'
import { RSI, MACD } from 'technicalindicators'

export default class MomentumStrategy extends Plugin {
  async initialize() {
    this.rsi = new RSI({ period: 14 })
    this.macd = new MACD({ fastPeriod: 12, slowPeriod: 26, signalPeriod: 9 })
  }

  async execute(data) {
    const { prices, volumes } = data
    
    // Calculate technical indicators
    const rsiValue = this.rsi.nextValue(prices[prices.length - 1])
    const macdResult = this.macd.nextValue(prices[prices.length - 1])
    
    // Generate trading signal
    let signal = 'hold'
    let confidence = 0
    
    if (rsiValue < 30 && macdResult.MACD > macdResult.signal) {
      signal = 'buy'
      confidence = 0.8
    } else if (rsiValue > 70 && macdResult.MACD < macdResult.signal) {
      signal = 'sell'
      confidence = 0.7
    }
    
    return {
      action: signal,
      confidence: confidence,
      reasoning: `RSI: ${rsiValue.toFixed(2)}, MACD: ${macdResult.MACD.toFixed(4)}`,
      indicators: {
        rsi: rsiValue,
        macd: macdResult
      }
    }
  }
}

Plugin Marketplace

Monetize Your Plugins

Publish your plugins to the AI Forge marketplace and earn revenue from downloads and usage.

70%
Revenue Share
1000+
Active Developers
50K+
Plugin Downloads

Publishing Benefits

  • 70% revenue share on all sales
  • Global distribution to all AI Forge users
  • Automatic updates and version management
  • Analytics and usage statistics

Quality Standards

  • Code review and security audit
  • Performance and reliability testing
  • Documentation requirements
  • User feedback and rating system

Ready to Build?