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

266 lines (239 loc) • 8.61 kB
/** * Mode Selector Handler - Allows AI agents to choose their preferred debugging style * * Offers both: * 1. Direct tool access (detailed, hands-on) * 2. Orchestrator mode (automated, high-level) */ import { BaseHandler } from './base-handler.js'; export class ModeSelectorHandler extends BaseHandler { name = 'ModeSelectorHandler'; currentMode = 'direct'; modeHistory = []; tools = [ { name: 'get_current_mode', description: 'Check which AI-Debug mode is currently active (direct tools, orchestrators, or hybrid)', inputSchema: { type: 'object', properties: {}, required: [] } }, { name: 'switch_mode', description: 'Switch between debugging modes: direct (all 346+ tools), orchestrator (9 high-level orchestrators), or hybrid (both)', inputSchema: { type: 'object', properties: { mode: { type: 'string', enum: ['direct', 'orchestrator', 'hybrid'], description: 'Mode to switch to' }, reason: { type: 'string', description: 'Optional: Why you are switching modes' } }, required: ['mode'] } }, { name: 'compare_modes', description: 'Get a detailed comparison of the different AI-Debug modes to help choose the best one for your task', inputSchema: { type: 'object', properties: {}, required: [] } } ]; async handle(toolName, args) { switch (toolName) { case 'get_current_mode': return this.getCurrentMode(); case 'switch_mode': return this.switchMode(args); case 'compare_modes': return this.compareModes(); default: throw new Error(`Unknown tool: ${toolName}`); } } getCurrentMode() { const modeConfigs = { direct: { currentMode: 'direct', description: 'All 346+ debugging tools exposed directly', toolCount: 346, advantages: [ 'Full control over every debugging action', 'Detailed output from each tool', 'No information loss through summarization', 'Best for: Specific debugging tasks, getting exact data' ] }, orchestrator: { currentMode: 'orchestrator', description: 'Only 9 high-level orchestrators exposed', toolCount: 9, advantages: [ 'Simplified interface with fewer choices', 'Automated multi-step workflows', 'AI sub-agents handle complex sequences', 'Best for: High-level debugging, letting AI handle details' ] }, hybrid: { currentMode: 'hybrid', description: 'Both orchestrators AND essential direct tools', toolCount: 30, advantages: [ 'Balance of automation and control', 'Direct access to key tools like console logs', 'Orchestrators for complex workflows', 'Best for: Most debugging scenarios' ] } }; const config = modeConfigs[this.currentMode]; return { content: [{ type: 'text', text: `**Current AI-Debug Mode: ${this.currentMode.toUpperCase()}** ${config.description} **Advantages:** ${config.advantages.map(a => `• ${a}`).join('\n')} **Available tools:** ${config.toolCount} **Recent mode switches:** ${this.modeHistory.slice(-3).map(h => `• ${h.mode} at ${h.timestamp.toISOString()}${h.reason ? ` (${h.reason})` : ''}`).join('\n') || 'No recent switches'} šŸ’” Use \`switch_mode\` to change modes or \`compare_modes\` to see all options.` }] }; } async switchMode(args) { const { mode, reason } = args; const previousMode = this.currentMode; // Record the switch this.modeHistory.push({ mode, timestamp: new Date(), reason }); this.currentMode = mode; // In a real implementation, this would trigger a reload of available tools // For now, we'll just acknowledge the switch return { content: [{ type: 'text', text: `āœ… **Mode switched from ${previousMode} to ${mode}** ${reason ? `**Reason:** ${reason}\n\n` : ''} **What changed:** ${this.getModeSwitchSummary(previousMode, mode)} **Next steps:** 1. Run \`list_tools\` to see your new tool set 2. ${mode === 'direct' ? 'Use specific tools like `get_console_logs` for detailed data' : mode === 'orchestrator' ? 'Use orchestrators like `debug_orchestrator` for automated workflows' : 'Use both orchestrators and direct tools as needed'} šŸ’” You can switch back anytime with \`switch_mode\`.` }] }; } compareModes() { return { content: [{ type: 'text', text: `## šŸŽÆ AI-Debug Mode Comparison ### 1ļøāƒ£ **DIRECT MODE** (Current default) **Tools:** All 346+ individual tools **Best for:** When you need specific data or full control **Example workflow:** \`\`\`javascript // You control each step await inject_debugging({ url: "..." }) await get_console_logs({ sessionId: "..." }) await take_screenshot({ sessionId: "..." }) \`\`\` **Pros:** āœ… Full visibility into all data āœ… No information loss āœ… Complete control āœ… Best for specific debugging **Cons:** āŒ More tools to choose from āŒ You manage the workflow --- ### 2ļøāƒ£ **ORCHESTRATOR MODE** **Tools:** 9 high-level orchestrators only **Best for:** Automated debugging workflows **Example workflow:** \`\`\`javascript // AI handles the details await debug_orchestrator({ task: "Find why login fails" }) \`\`\` **Pros:** āœ… Simplified interface āœ… Automated workflows āœ… AI handles complexity āœ… Good for exploration **Cons:** āŒ Less detailed output āŒ Less direct control āŒ May miss specific data --- ### 3ļøāƒ£ **HYBRID MODE** (Recommended) **Tools:** Orchestrators + 15-20 essential tools **Best for:** Balance of control and automation **Example workflow:** \`\`\`javascript // Use orchestrators for complex tasks await debug_orchestrator({ task: "..." }) // But still access key data directly await get_console_logs({ sessionId: "..." }) \`\`\` **Pros:** āœ… Best of both worlds āœ… Automation + control āœ… Access to key data āœ… Flexible approach **Cons:** āŒ Still some complexity āŒ Need to choose approach --- **šŸŽÆ Recommendations:** • **Specific bug?** → Use DIRECT mode • **Exploring issues?** → Use ORCHESTRATOR mode • **General debugging?** → Use HYBRID mode • **Not sure?** → Start with HYBRID Use \`switch_mode\` to change anytime!` }] }; } getModeSwitchSummary(from, to) { const changes = { 'direct-orchestrator': `• From 346+ individual tools → 9 orchestrators only • From detailed control → automated workflows • From specific data access → high-level summaries`, 'orchestrator-direct': `• From 9 orchestrators → 346+ individual tools • From automated workflows → detailed control • From summaries → full data access`, 'direct-hybrid': `• Keeping all 346+ tools • Adding 9 orchestrators for complex workflows • Best of both approaches`, 'orchestrator-hybrid': `• Keeping 9 orchestrators • Adding ~20 essential direct tools • More control while keeping automation`, 'hybrid-direct': `• Removing orchestrators • Focusing on direct tool access only • Maximum control and detail`, 'hybrid-orchestrator': `• Removing direct tool access • Focusing on orchestrators only • Maximum automation` }; return changes[`${from}-${to}`] || '• Mode configuration updated'; } } //# sourceMappingURL=mode-selector-handler.js.map