UNPKG

ai-debug-local-mcp

Version:

🎯 ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh

112 lines 4.66 kB
/** * Tool Compatibility Bridge - Connects v2 stateless architecture with original handler system * * This bridge ensures all 388 original tools work in the new v2 architecture * while maintaining the stateless benefits and crash prevention. */ // import { DebugRequest, DebugResponse } from '../core/stateless-debug-service.js'; import { CompleteToolRegistry } from '../handlers/complete-tool-registry.js'; import { UniversalRealHandler } from '../handlers/universal-real-handler.js'; export class ToolCompatibilityBridge { handlerRegistry; initialized = false; constructor() { this.handlerRegistry = new CompleteToolRegistry(); } async initialize() { if (this.initialized) return; try { // Register handlers in priority order: // 1. Universal Real Handler (for ALL tools with real implementations) const universalRealHandler = new UniversalRealHandler(); await universalRealHandler.initialize(); await this.handlerRegistry.registerHandler(universalRealHandler); // No fallback handler needed - Universal Real Handler covers all tools this.initialized = true; console.error(`🔧 Tool Compatibility Bridge initialized:`); console.log(` • ${this.handlerRegistry.getHandlerCount()} handlers registered`); console.log(` • ${this.handlerRegistry.getToolCount()} total tools available`); console.error(` • ✅ REAL implementations for ALL tools (no duplicates)`); console.error(` • 🚀 Full functionality achieved with stateless architecture`); } catch (error) { console.error('❌ Failed to initialize Tool Compatibility Bridge:', error); throw error; } } async getAllAvailableTools() { await this.initialize(); try { return await this.handlerRegistry.getAllAvailableTools(); } catch (error) { console.error('❌ Failed to get available tools:', error); // Fallback to basic tools if registry fails return [ { name: 'inject_debugging', description: 'Launch debugging session' }, { name: 'take_screenshot', description: 'Capture visual state' }, { name: 'run_audit', description: 'Run quality audits' } ]; } } async executeStatelessTool(request) { const startTime = Date.now(); await this.initialize(); try { // Create isolated execution context const isolatedContext = { sessionId: request.id, request: request.params || {}, cleanup: [] }; // Execute tool through handler registry with stateless guarantees const result = await this.handlerRegistry.executeHandler(request.type, request.params || {}, isolatedContext); // Ensure cleanup happens regardless of success/failure await this.performCleanup(isolatedContext); return { id: request.id, success: true, data: result, executionTime: Date.now() - startTime, resourcesUsed: { memory: process.memoryUsage().heapUsed / 1024 / 1024, cpu: process.cpuUsage().user / 1000 } }; } catch (error) { console.error(`❌ Tool execution failed for ${request.type}:`, error); return { id: request.id, success: false, error: error.message || 'Unknown error', executionTime: Date.now() - startTime, resourcesUsed: { memory: process.memoryUsage().heapUsed / 1024 / 1024, cpu: process.cpuUsage().user / 1000 } }; } } async performCleanup(context) { for (const cleanupFn of context.cleanup) { try { await cleanupFn(); } catch (error) { console.warn('⚠️ Cleanup function failed:', error); } } } async getToolCapabilities() { await this.initialize(); const tools = await this.getAllAvailableTools(); const categories = Array.from(new Set(tools.map(tool => tool.name.split('_')[0]))); return { totalTools: tools.length, categories: categories }; } } //# sourceMappingURL=tool-compatibility-bridge.js.map