UNPKG

@vfarcic/dot-ai

Version:

AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance

81 lines (80 loc) 2.48 kB
"use strict"; /** * Plugin Registry - Unified Plugin Tool Invocation * * PRD #359: Provides a single, consistent way to invoke plugin tools from anywhere * in the codebase. Replaces scattered plugin manager passing and module-level setters. * * Usage: * // At startup (src/mcp/server.ts): * initializePluginRegistry(pluginManager); * * // Anywhere in the codebase: * const response = await invokePluginTool('agentic-tools', 'vector_search', { ... }); */ Object.defineProperty(exports, "__esModule", { value: true }); exports.initializePluginRegistry = initializePluginRegistry; exports.getPluginManager = getPluginManager; exports.isPluginInitialized = isPluginInitialized; exports.invokePluginTool = invokePluginTool; exports.resetPluginRegistry = resetPluginRegistry; /** * Global plugin manager instance (set once at startup) */ let pluginManager = null; /** * Initialize the plugin registry with a PluginManager instance. * Must be called once at startup before any plugin tool invocations. */ function initializePluginRegistry(pm) { pluginManager = pm; } /** * Get the PluginManager instance. * Returns null if not initialized. */ function getPluginManager() { return pluginManager; } /** * Check if the plugin registry is initialized. */ function isPluginInitialized() { return pluginManager !== null; } /** * Invoke a tool on a specific plugin. * * @param plugin - The plugin name (e.g., 'agentic-tools') * @param tool - The tool name (e.g., 'vector_search', 'kubectl_get_resource_json') * @param args - Tool arguments * @returns InvokeResponse with success/error status and result * @throws Error if plugin registry is not initialized * * @example * // Invoke a vector tool * const response = await invokePluginTool('agentic-tools', 'vector_search', { * collection: 'capabilities', * embedding: [...], * limit: 10 * }); * * // Invoke a kubectl tool * const response = await invokePluginTool('agentic-tools', 'kubectl_get_resource_json', { * resource: 'namespace/kube-system', * field: 'metadata' * }); */ async function invokePluginTool(plugin, tool, args) { if (!pluginManager) { throw new Error('Plugin registry not initialized. Call initializePluginRegistry() at startup.'); } return pluginManager.invokeToolOnPlugin(plugin, tool, args); } /** * Reset the plugin registry (for testing only). * @internal */ function resetPluginRegistry() { pluginManager = null; }