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

82 lines 2.88 kB
/** * Auto-Delegation Wrapper * * Provides a simple interface for automatic sub-agent delegation * with elegant fallback to direct tool execution. */ import { IntelligentSubAgentOrchestrator } from './intelligent-sub-agent-orchestrator.js'; import { UserFriendlyLogger } from './user-friendly-logger.js'; import { getErrorMessage } from './error-helper.js'; export class AutoDelegationWrapper { static instance; orchestrator; logger; constructor() { this.orchestrator = new IntelligentSubAgentOrchestrator(); this.logger = new UserFriendlyLogger('AutoDelegation'); } static getInstance() { if (!AutoDelegationWrapper.instance) { AutoDelegationWrapper.instance = new AutoDelegationWrapper(); } return AutoDelegationWrapper.instance; } /** * Smart execution with automatic sub-agent delegation */ async execute(taskDescription, options = {}) { this.logger.info(`🎯 Auto-delegating task: "${taskDescription.substring(0, 60)}..."`); try { const result = await this.orchestrator.executeTask(taskDescription, options); if (result.success) { if (result.usedSubAgent) { this.logger.success(`🤖 Sub-agent ${result.agentType} completed task successfully (saved ${result.contextSavedTokens} tokens)`); } else { this.logger.info(`🔄 Fallback execution completed: ${result.fallbackReason}`); } } else { this.logger.warn(`⚠️ Task execution failed: ${result.fallbackReason}`); } return result; } catch (error) { this.logger.error(`❌ Auto-delegation error: ${getErrorMessage(error)}`); return { success: false, usedSubAgent: false, fallbackReason: `Auto-delegation error: ${getErrorMessage(error)}`, executionTimeMs: 0 }; } } /** * Get orchestrator status for monitoring */ getStatus() { return this.orchestrator.getStatus(); } /** * Get performance statistics */ getStats() { return this.orchestrator.getDelegationStats(); } } /** * Convenience function for easy usage throughout the codebase */ export async function smartExecute(taskDescription, options = {}) { const wrapper = AutoDelegationWrapper.getInstance(); return wrapper.execute(taskDescription, options); } /** * Convenience function to check if sub-agents are available */ export async function areSubAgentsAvailable() { const wrapper = AutoDelegationWrapper.getInstance(); const status = wrapper.getStatus(); return status.subAgentsAvailable; } //# sourceMappingURL=auto-delegation-wrapper.js.map