/**
 * Plugin System for Code Buddy
 *
 * Enables extensibility through:
 * - Custom tool plugins
 * - Middleware plugins
 * - Theme plugins
 * - Integration plugins
 */
import { EventEmitter } from 'events';
export type PluginType = 'tool' | 'middleware' | 'theme' | 'integration';
export interface PluginManifest {
    name: string;
    version: string;
    description: string;
    author?: string;
    type: PluginType;
    main: string;
    dependencies?: Record<string, string>;
    permissions?: string[];
    config?: Record<string, unknown>;
}
export interface PluginContext {
    /** Plugin directory path */
    pluginDir: string;
    /** Plugin configuration */
    config: Record<string, unknown>;
    /** Logger instance */
    log: (message: string, level?: 'debug' | 'info' | 'warn' | 'error') => void;
    /** Emit events */
    emit: (event: string, data: unknown) => void;
}
export interface SystemPlugin {
    manifest: PluginManifest;
    /** Called when plugin is loaded */
    onLoad?: (context: PluginContext) => Promise<void>;
    /** Called when plugin is unloaded */
    onUnload?: () => Promise<void>;
    /** Called when plugin is enabled */
    onEnable?: () => Promise<void>;
    /** Called when plugin is disabled */
    onDisable?: () => Promise<void>;
}
export interface ToolPlugin extends SystemPlugin {
    type: 'tool';
    /** Tool definition for OpenAI function calling format */
    getToolDefinition: () => {
        type: 'function';
        function: {
            name: string;
            description: string;
            parameters: Record<string, unknown>;
        };
    };
    /** Execute the tool */
    execute: (args: Record<string, unknown>) => Promise<{
        success: boolean;
        output?: string;
        error?: string;
    }>;
}
export interface MiddlewarePlugin extends SystemPlugin {
    type: 'middleware';
    /** Priority (lower = earlier execution) */
    priority: number;
    /** Process request before sending to API */
    onRequest?: (request: unknown) => Promise<unknown>;
    /** Process response from API */
    onResponse?: (response: unknown) => Promise<unknown>;
    /** Process tool execution */
    onToolExecution?: (tool: string, args: unknown) => Promise<unknown>;
}
export interface LoadedPlugin {
    manifest: PluginManifest;
    instance: SystemPlugin;
    enabled: boolean;
    loadedAt: Date;
    path: string;
}
/**
 * Plugin Manager
 */
export declare class PluginManager extends EventEmitter {
    private plugins;
    private pluginDirs;
    constructor(pluginDirs?: string[]);
    /**
     * Get default plugin directories
     */
    private getDefaultPluginDirs;
    /**
     * Discover plugins in plugin directories
     */
    discoverPlugins(): Promise<PluginManifest[]>;
    /**
     * Load a plugin by name
     */
    loadPlugin(name: string): Promise<boolean>;
    /**
     * Unload a plugin
     */
    unloadPlugin(name: string): Promise<boolean>;
    /**
     * Enable a plugin
     */
    enablePlugin(name: string): Promise<boolean>;
    /**
     * Disable a plugin
     */
    disablePlugin(name: string): Promise<boolean>;
    /**
     * Get all loaded plugins
     */
    getLoadedPlugins(): LoadedPlugin[];
    /**
     * Get plugins by type
     */
    getPluginsByType(type: PluginType): LoadedPlugin[];
    /**
     * Get enabled tool plugins
     */
    getToolPlugins(): ToolPlugin[];
    /**
     * Get enabled middleware plugins (sorted by priority)
     */
    getMiddlewarePlugins(): MiddlewarePlugin[];
    /**
     * Validate plugin manifest
     */
    private validateManifest;
    /**
     * Load all discovered plugins
     */
    loadAllPlugins(): Promise<{
        loaded: string[];
        failed: string[];
    }>;
    /**
     * Unload all plugins
     */
    unloadAllPlugins(): Promise<void>;
    /**
     * Format plugins list for display
     */
    formatPluginList(): string;
    /**
     * Dispose and cleanup
     */
    dispose(): Promise<void>;
}
/**
 * Get or create the plugin manager
 */
export declare function getPluginManager(): PluginManager;
/**
 * Reset the plugin manager
 */
export declare function resetPluginManager(): Promise<void>;
