import type { FastifyInstance } from 'fastify'; import { EventEmitter } from 'node:events'; import type { AgentPlugin, PluginConfig, LoadedPlugin, PluginEventMap, PluginHealthStatus } from './types.js'; import type { AgentConfig } from '../lib/config.js'; import type { ChildProcessManager } from '../services/child-process-manager.js'; /** * Agent internals passed to plugin context */ export interface AgentInternals { /** Current agent config */ config: AgentConfig; /** Child process manager (if exec mode) */ childProcessManager: ChildProcessManager | null; /** Restart child process callback */ restartChild?: (reason: string) => Promise; } /** * Plugin loader options */ export interface PluginLoaderOptions { /** Plugin directory for local plugins */ pluginDir?: string; /** Skip npm package discovery */ skipNpmDiscovery?: boolean; } /** * Manages plugin discovery, loading, and lifecycle */ export declare class PluginLoader extends EventEmitter { private readonly plugins; private agentInternals; private readonly options; private isStarted; constructor(agentInternals: AgentInternals, options?: PluginLoaderOptions); /** * Load all plugins from config and auto-discovered locations */ loadPlugins(config: AgentConfig): Promise; /** * Load a single plugin by config */ loadPlugin(config: PluginConfig): Promise; /** * Load plugins from local directory */ private loadLocalPlugins; /** * Validate plugin has required fields */ private validatePlugin; /** * Initialize all loaded plugins */ initializePlugins(): Promise; /** * Start all initialized plugins */ startPlugins(): Promise; /** * Stop all running plugins */ stopPlugins(): Promise; /** * Register plugin routes on Fastify server */ registerRoutes(fastify: FastifyInstance): Promise; /** * Dispatch event to all plugins */ dispatchEvent(eventType: K, event: PluginEventMap[K]): Promise; /** * Collect health status from all plugins */ collectHealthStatus(): Promise; /** * Get loaded plugins */ getPlugins(): AgentPlugin[]; /** * Get plugin by name */ getPlugin(name: string): AgentPlugin | undefined; /** * Get plugin status */ getPluginStatus(name: string): LoadedPlugin['status'] | undefined; /** * Get all plugin statuses */ getAllPluginStatuses(): { name: string; status: LoadedPlugin['status']; error?: string; }[]; /** * Check if any plugins are loaded */ hasPlugins(): boolean; /** * Get plugin info for registration with vault. * Returns basic info about loaded plugins. */ getPluginInfo(): { name: string; package: string; version: string; }[]; /** * Update agent internals (called when config changes) */ updateInternals(internals: Partial): void; } /** * Get or create the plugin loader instance */ export declare function getPluginLoader(): PluginLoader | null; /** * Create and set the plugin loader instance */ export declare function createPluginLoader(agentInternals: AgentInternals, options?: PluginLoaderOptions): PluginLoader; /** * Clear the plugin loader instance (for testing) */ export declare function clearPluginLoader(): void; //# sourceMappingURL=loader.d.ts.map