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
JavaScript
/**
* 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