tachibot-mcp 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/.env.example +260 -0
  2. package/CHANGELOG.md +54 -0
  3. package/CODE_OF_CONDUCT.md +56 -0
  4. package/CONTRIBUTING.md +54 -0
  5. package/Dockerfile +36 -0
  6. package/LICENSE +644 -0
  7. package/README.md +201 -0
  8. package/SECURITY.md +95 -0
  9. package/dist/personality/komaai-expressions.js +12 -0
  10. package/dist/profiles/balanced.json +33 -0
  11. package/dist/profiles/code_focus.json +33 -0
  12. package/dist/profiles/full.json +33 -0
  13. package/dist/profiles/minimal.json +33 -0
  14. package/dist/profiles/research_power.json +33 -0
  15. package/dist/scripts/build-profiles.js +46 -0
  16. package/dist/src/application/services/focus/FocusModeRegistry.js +46 -0
  17. package/dist/src/application/services/focus/FocusTool.service.js +109 -0
  18. package/dist/src/application/services/focus/ModeRegistry.js +46 -0
  19. package/dist/src/application/services/focus/modes/focus-deep.mode.js +27 -0
  20. package/dist/src/application/services/focus/modes/status.mode.js +50 -0
  21. package/dist/src/application/services/focus/modes/tachibot-status.mode.js +50 -0
  22. package/dist/src/collaborative-orchestrator.js +391 -0
  23. package/dist/src/config/model-constants.js +188 -0
  24. package/dist/src/config/model-defaults.js +57 -0
  25. package/dist/src/config/model-preferences.js +382 -0
  26. package/dist/src/config/timeout-config.js +130 -0
  27. package/dist/src/config.js +173 -0
  28. package/dist/src/domain/interfaces/IFocusMode.js +5 -0
  29. package/dist/src/domain/interfaces/IProvider.js +6 -0
  30. package/dist/src/domain/interfaces/ITool.js +5 -0
  31. package/dist/src/focus-deep.js +245 -0
  32. package/dist/src/infrastructure/ascii/art/robots.ascii.js +16 -0
  33. package/dist/src/mcp-client.js +90 -0
  34. package/dist/src/memory/index.js +17 -0
  35. package/dist/src/memory/memory-config.js +135 -0
  36. package/dist/src/memory/memory-interface.js +174 -0
  37. package/dist/src/memory/memory-manager.js +383 -0
  38. package/dist/src/memory/providers/devlog-provider.js +385 -0
  39. package/dist/src/memory/providers/hybrid-provider.js +399 -0
  40. package/dist/src/memory/providers/local-provider.js +388 -0
  41. package/dist/src/memory/providers/mem0-provider.js +337 -0
  42. package/dist/src/modes/architect.js +477 -0
  43. package/dist/src/modes/auditor.js +362 -0
  44. package/dist/src/modes/challenger.js +841 -0
  45. package/dist/src/modes/code-reviewer.js +382 -0
  46. package/dist/src/modes/commit-guardian.js +424 -0
  47. package/dist/src/modes/documentation-writer.js +572 -0
  48. package/dist/src/modes/scout.js +587 -0
  49. package/dist/src/modes/shared/helpers/challenger-helpers.js +454 -0
  50. package/dist/src/modes/shared/helpers/index.js +17 -0
  51. package/dist/src/modes/shared/helpers/scout-helpers.js +270 -0
  52. package/dist/src/modes/shared/helpers/verifier-helpers.js +332 -0
  53. package/dist/src/modes/test-architect.js +767 -0
  54. package/dist/src/modes/verifier.js +378 -0
  55. package/dist/src/monitoring/performance-monitor.js +435 -0
  56. package/dist/src/optimization/batch-executor.js +121 -0
  57. package/dist/src/optimization/context-pruner.js +196 -0
  58. package/dist/src/optimization/cost-monitor.js +338 -0
  59. package/dist/src/optimization/index.js +65 -0
  60. package/dist/src/optimization/model-router.js +264 -0
  61. package/dist/src/optimization/result-cache.js +114 -0
  62. package/dist/src/optimization/token-optimizer.js +257 -0
  63. package/dist/src/optimization/token-tracker.js +118 -0
  64. package/dist/src/orchestrator-instructions.js +128 -0
  65. package/dist/src/orchestrator-lite.js +139 -0
  66. package/dist/src/orchestrator.js +191 -0
  67. package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionEngine.js +1 -0
  68. package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionStrategy.js +5 -0
  69. package/dist/src/orchestrators/collaborative/interfaces/IVisualizationRenderer.js +1 -0
  70. package/dist/src/orchestrators/collaborative/registries/ModelProviderRegistry.js +95 -0
  71. package/dist/src/orchestrators/collaborative/registries/ToolAdapterRegistry.js +64 -0
  72. package/dist/src/orchestrators/collaborative/services/tool-execution/ToolExecutionService.js +502 -0
  73. package/dist/src/orchestrators/collaborative/services/visualization/VisualizationService.js +206 -0
  74. package/dist/src/orchestrators/collaborative/types/session-types.js +5 -0
  75. package/dist/src/profiles/balanced.js +37 -0
  76. package/dist/src/profiles/code_focus.js +37 -0
  77. package/dist/src/profiles/debug_intensive.js +59 -0
  78. package/dist/src/profiles/full.js +37 -0
  79. package/dist/src/profiles/minimal.js +37 -0
  80. package/dist/src/profiles/research_code.js +59 -0
  81. package/dist/src/profiles/research_power.js +37 -0
  82. package/dist/src/profiles/types.js +5 -0
  83. package/dist/src/profiles/workflow_builder.js +53 -0
  84. package/dist/src/prompt-engineer-lite.js +78 -0
  85. package/dist/src/prompt-engineer.js +399 -0
  86. package/dist/src/reasoning-chain.js +508 -0
  87. package/dist/src/sequential-thinking.js +291 -0
  88. package/dist/src/server-diagnostic.js +74 -0
  89. package/dist/src/server-raw.js +158 -0
  90. package/dist/src/server-simple.js +58 -0
  91. package/dist/src/server.js +514 -0
  92. package/dist/src/session/session-logger.js +617 -0
  93. package/dist/src/session/session-manager.js +571 -0
  94. package/dist/src/session/session-tools.js +400 -0
  95. package/dist/src/tools/advanced-modes.js +200 -0
  96. package/dist/src/tools/claude-integration.js +356 -0
  97. package/dist/src/tools/consolidated/ai-router.js +174 -0
  98. package/dist/src/tools/consolidated/ai-tool.js +48 -0
  99. package/dist/src/tools/consolidated/brainstorm-tool.js +87 -0
  100. package/dist/src/tools/consolidated/environment-detector.js +80 -0
  101. package/dist/src/tools/consolidated/index.js +50 -0
  102. package/dist/src/tools/consolidated/search-tool.js +110 -0
  103. package/dist/src/tools/consolidated/workflow-tool.js +238 -0
  104. package/dist/src/tools/gemini-tools.js +329 -0
  105. package/dist/src/tools/grok-enhanced.js +376 -0
  106. package/dist/src/tools/grok-tools.js +299 -0
  107. package/dist/src/tools/lmstudio-tools.js +223 -0
  108. package/dist/src/tools/openai-tools.js +498 -0
  109. package/dist/src/tools/openrouter-tools.js +317 -0
  110. package/dist/src/tools/optimized-wrapper.js +204 -0
  111. package/dist/src/tools/perplexity-tools.js +294 -0
  112. package/dist/src/tools/pingpong-tool.js +343 -0
  113. package/dist/src/tools/qwen-wrapper.js +74 -0
  114. package/dist/src/tools/tool-router.js +444 -0
  115. package/dist/src/tools/unified-ai-provider.js +260 -0
  116. package/dist/src/tools/workflow-runner.js +425 -0
  117. package/dist/src/tools/workflow-validator-tool.js +107 -0
  118. package/dist/src/types.js +23 -0
  119. package/dist/src/utils/input-validator.js +130 -0
  120. package/dist/src/utils/model-router.js +91 -0
  121. package/dist/src/utils/progress-stream.js +255 -0
  122. package/dist/src/utils/provider-router.js +88 -0
  123. package/dist/src/utils/smart-api-client.js +146 -0
  124. package/dist/src/utils/table-builder.js +218 -0
  125. package/dist/src/utils/timestamp-formatter.js +134 -0
  126. package/dist/src/utils/tool-compressor.js +257 -0
  127. package/dist/src/utils/tool-config.js +201 -0
  128. package/dist/src/validators/dependency-graph-validator.js +147 -0
  129. package/dist/src/validators/interpolation-validator.js +222 -0
  130. package/dist/src/validators/output-usage-validator.js +151 -0
  131. package/dist/src/validators/syntax-validator.js +102 -0
  132. package/dist/src/validators/tool-registry-validator.js +123 -0
  133. package/dist/src/validators/tool-types.js +97 -0
  134. package/dist/src/validators/types.js +8 -0
  135. package/dist/src/validators/workflow-validator.js +134 -0
  136. package/dist/src/visualizer-lite.js +42 -0
  137. package/dist/src/visualizer.js +179 -0
  138. package/dist/src/workflows/circuit-breaker.js +199 -0
  139. package/dist/src/workflows/custom-workflows.js +451 -0
  140. package/dist/src/workflows/engine/AutoSynthesizer.js +97 -0
  141. package/dist/src/workflows/engine/StepParameterResolver.js +74 -0
  142. package/dist/src/workflows/engine/VariableInterpolator.js +123 -0
  143. package/dist/src/workflows/engine/WorkflowDiscovery.js +125 -0
  144. package/dist/src/workflows/engine/WorkflowExecutionEngine.js +485 -0
  145. package/dist/src/workflows/engine/WorkflowExecutor.js +113 -0
  146. package/dist/src/workflows/engine/WorkflowFileManager.js +244 -0
  147. package/dist/src/workflows/engine/WorkflowHelpers.js +114 -0
  148. package/dist/src/workflows/engine/WorkflowOutputFormatter.js +83 -0
  149. package/dist/src/workflows/engine/events/WorkflowEventBus.js +132 -0
  150. package/dist/src/workflows/engine/events/interfaces/IEventBus.js +5 -0
  151. package/dist/src/workflows/engine/handlers/ErrorRecoveryHandler.js +162 -0
  152. package/dist/src/workflows/engine/handlers/PromptEnhancementHandler.js +115 -0
  153. package/dist/src/workflows/engine/handlers/SessionPersistenceHandler.js +167 -0
  154. package/dist/src/workflows/engine/handlers/StepExecutionHandler.js +231 -0
  155. package/dist/src/workflows/engine/handlers/ToolInvocationHandler.js +46 -0
  156. package/dist/src/workflows/engine/interfaces/IAutoSynthesizer.js +5 -0
  157. package/dist/src/workflows/engine/interfaces/IStepParameterResolver.js +5 -0
  158. package/dist/src/workflows/engine/interfaces/IVariableInterpolator.js +5 -0
  159. package/dist/src/workflows/engine/interfaces/IWorkflowDiscovery.js +4 -0
  160. package/dist/src/workflows/engine/interfaces/IWorkflowFileManager.js +5 -0
  161. package/dist/src/workflows/engine/interfaces/IWorkflowOutputFormatter.js +5 -0
  162. package/dist/src/workflows/engine/state/WorkflowStateMachine.js +194 -0
  163. package/dist/src/workflows/engine/state/interfaces/IStateMachine.js +17 -0
  164. package/dist/src/workflows/fallback-strategies.js +373 -0
  165. package/dist/src/workflows/message-queue.js +455 -0
  166. package/dist/src/workflows/model-router.js +189 -0
  167. package/dist/src/workflows/orchestrator-examples.js +174 -0
  168. package/dist/src/workflows/orchestrator-integration.js +200 -0
  169. package/dist/src/workflows/self-healing.js +524 -0
  170. package/dist/src/workflows/tool-mapper.js +407 -0
  171. package/dist/src/workflows/tool-orchestrator.js +796 -0
  172. package/dist/src/workflows/workflow-engine.js +573 -0
  173. package/dist/src/workflows/workflow-parser.js +283 -0
  174. package/dist/src/workflows/workflow-types.js +95 -0
  175. package/dist/src/workflows.js +568 -0
  176. package/dist/test-workflow-file-output.js +93 -0
  177. package/docs/API_KEYS.md +570 -0
  178. package/docs/CLAUDE_CODE_SETUP.md +181 -0
  179. package/docs/CLAUDE_DESKTOP_MANUAL.md +127 -0
  180. package/docs/CONFIGURATION.md +745 -0
  181. package/docs/FOCUS_MODES.md +240 -0
  182. package/docs/INSTALLATION_BOTH.md +145 -0
  183. package/docs/TERMS.md +352 -0
  184. package/docs/TOOLS_REFERENCE.md +1622 -0
  185. package/docs/TOOL_PARAMETERS.md +496 -0
  186. package/docs/TOOL_PROFILES.md +236 -0
  187. package/docs/WORKFLOWS.md +987 -0
  188. package/docs/WORKFLOW_OUTPUT.md +198 -0
  189. package/docs/WORKFLOW_PROGRESS_TRACKING.md +305 -0
  190. package/docs/workflows/design-brainstorm.md +335 -0
  191. package/package.json +97 -0
  192. package/profiles/balanced.json +37 -0
  193. package/profiles/code_focus.json +37 -0
  194. package/profiles/debug_intensive.json +34 -0
  195. package/profiles/full.json +37 -0
  196. package/profiles/minimal.json +37 -0
  197. package/profiles/research_power.json +37 -0
  198. package/profiles/workflow_builder.json +37 -0
  199. package/smithery.yaml +66 -0
  200. package/start.sh +8 -0
  201. package/tools.config.json +81 -0
  202. package/tsconfig.json +18 -0
  203. package/workflows/accessibility-code-audit.yaml +92 -0
  204. package/workflows/code-architecture-review.yaml +202 -0
  205. package/workflows/code-review.yaml +142 -0
  206. package/workflows/core/iterative-problem-solver.yaml +283 -0
  207. package/workflows/creative-brainstorm-yaml.yaml +215 -0
  208. package/workflows/pingpong.yaml +141 -0
  209. package/workflows/system/README.md +412 -0
  210. package/workflows/system/challenger.yaml +175 -0
  211. package/workflows/system/scout.yaml +164 -0
  212. package/workflows/system/verifier.yaml +133 -0
  213. package/workflows/ultra-creative-brainstorm.yaml +318 -0
  214. package/workflows/ux-research-flow.yaml +92 -0
@@ -0,0 +1,796 @@
1
+ import { EventEmitter } from 'events';
2
+ import { modelPreferences } from '../config/model-preferences.js';
3
+ // Available Tachibot-MCP tools with their capabilities
4
+ export const FOCUS_MCP_TOOLS = {
5
+ // PRIMARY STABLE MODELS (Use these first)
6
+ gpt5_mini: {
7
+ id: 'gpt5_mini',
8
+ name: 'GPT-5-mini',
9
+ description: 'Cost-effective GPT-5 reasoning variant with balanced performance',
10
+ category: 'reasoning',
11
+ capabilities: ['advanced_reasoning', 'multi_step_analysis', 'rapid_adaptation'],
12
+ strengths: ['flagship_quality', 'fast_response', 'cost_effective'],
13
+ weaknesses: ['none'],
14
+ bestFor: ['production_reasoning', 'stable_workflows', 'cost_effective_tasks'],
15
+ costLevel: 'low',
16
+ timeComplexity: 'fast',
17
+ reliability: 0.92,
18
+ outputs: ['reasoning', 'analysis', 'structured_output']
19
+ },
20
+ gemini_25_pro: {
21
+ id: 'gemini_25_pro',
22
+ name: 'Gemini 2.5 Pro',
23
+ description: 'Alternative provider for diversified reasoning',
24
+ category: 'reasoning',
25
+ capabilities: ['large_context', 'multi_modal', 'comprehensive_analysis'],
26
+ strengths: ['different_provider', 'large_context_window', 'visual_understanding'],
27
+ weaknesses: ['different_api', 'may_have_different_behavior'],
28
+ bestFor: ['alternative_perspective', 'large_context_tasks', 'multi_modal_analysis'],
29
+ costLevel: 'medium',
30
+ timeComplexity: 'medium',
31
+ reliability: 0.85,
32
+ outputs: ['comprehensive_analysis', 'multi_modal_output', 'reasoning']
33
+ },
34
+ gpt5: {
35
+ id: 'gpt5',
36
+ name: 'GPT-5 Flagship',
37
+ description: 'Primary flagship reasoning model for advanced tasks',
38
+ category: 'reasoning',
39
+ capabilities: ['flagship_reasoning', 'long_horizon_planning', 'multi_domain_synthesis'],
40
+ strengths: ['highest_accuracy', 'deep_context_integration', 'strategic_reasoning'],
41
+ weaknesses: ['premium_cost'],
42
+ bestFor: ['critical_reasoning', 'high_stakes_analysis', 'executive_briefings'],
43
+ costLevel: 'high',
44
+ timeComplexity: 'medium',
45
+ reliability: 0.92,
46
+ outputs: ['reasoning', 'analysis', 'strategic_plan']
47
+ },
48
+ // Core Focus Tools
49
+ think: {
50
+ id: 'think',
51
+ name: 'Think Tool',
52
+ description: 'Simple thinking and reasoning cache',
53
+ category: 'reasoning',
54
+ capabilities: ['reflection', 'memory', 'quick_reasoning'],
55
+ strengths: ['fast', 'lightweight', 'good_for_simple_reasoning'],
56
+ weaknesses: ['no_research', 'limited_complexity'],
57
+ bestFor: ['quick_thoughts', 'memory_aid', 'simple_logic'],
58
+ costLevel: 'low',
59
+ timeComplexity: 'fast',
60
+ reliability: 0.9,
61
+ outputs: ['thought', 'reflection']
62
+ },
63
+ focus: {
64
+ id: 'focus',
65
+ name: 'Focus Deep Reasoning',
66
+ description: 'Multi-AI collaborative reasoning with specialized modes',
67
+ category: 'reasoning',
68
+ capabilities: ['deep_reasoning', 'multi_model', 'collaborative', 'specialized_modes'],
69
+ strengths: ['comprehensive_analysis', 'multiple_perspectives', 'domain_specific'],
70
+ weaknesses: ['high_cost', 'slow', 'token_heavy'],
71
+ bestFor: ['complex_problems', 'multi_perspective_analysis', 'technical_domains'],
72
+ costLevel: 'high',
73
+ timeComplexity: 'slow',
74
+ reliability: 0.95,
75
+ outputs: ['reasoning_chain', 'consensus', 'multiple_perspectives']
76
+ },
77
+ nextThought: {
78
+ id: 'nextThought',
79
+ name: 'Sequential Thinking',
80
+ description: 'Step-by-step sequential reasoning with branching',
81
+ category: 'reasoning',
82
+ capabilities: ['sequential_thinking', 'branching', 'iteration', 'revision'],
83
+ strengths: ['structured_thinking', 'iterative_improvement', 'revision_capability'],
84
+ weaknesses: ['linear_approach', 'no_research'],
85
+ bestFor: ['step_by_step_problems', 'iterative_reasoning', 'structured_analysis'],
86
+ costLevel: 'medium',
87
+ timeComplexity: 'medium',
88
+ reliability: 0.85,
89
+ outputs: ['thought_sequence', 'reasoning_steps', 'final_conclusion']
90
+ },
91
+ // Research Tools - Different Variants for Different Needs
92
+ scout: {
93
+ id: 'scout',
94
+ name: 'Scout Research Tool',
95
+ description: 'Quick hybrid intelligence gathering for initial context (uses research_scout variant)',
96
+ category: 'research',
97
+ capabilities: ['quick_research', 'context_discovery', 'initial_exploration', 'problem_scouting'],
98
+ strengths: ['fast_context', 'good_starting_point', 'broad_overview'],
99
+ weaknesses: ['surface_level', 'not_comprehensive'],
100
+ bestFor: ['initial_exploration', 'context_gathering', 'problem_understanding', 'quick_overview'],
101
+ costLevel: 'low',
102
+ timeComplexity: 'fast',
103
+ reliability: 0.8,
104
+ outputs: ['initial_findings', 'context_overview', 'problem_landscape']
105
+ },
106
+ perplexity_ask: {
107
+ id: 'perplexity_ask',
108
+ name: 'Perplexity Direct Ask',
109
+ description: 'Direct web search and information retrieval using Perplexity Sonar Pro',
110
+ category: 'research',
111
+ capabilities: ['web_search', 'current_information', 'direct_answers', 'fact_retrieval'],
112
+ strengths: ['current_data', 'direct_answers', 'fast_results'],
113
+ weaknesses: ['single_query_focus', 'limited_depth'],
114
+ bestFor: ['specific_questions', 'current_events', 'fact_checking', 'quick_answers'],
115
+ costLevel: 'medium',
116
+ timeComplexity: 'fast',
117
+ reliability: 0.9,
118
+ outputs: ['direct_answer', 'sources', 'current_information']
119
+ },
120
+ perplexity_research: {
121
+ id: 'perplexity_research',
122
+ name: 'Perplexity Deep Research',
123
+ description: 'Comprehensive research with evidence gathering and synthesis',
124
+ category: 'research',
125
+ capabilities: ['deep_research', 'evidence_synthesis', 'comprehensive_investigation', 'multi_query'],
126
+ strengths: ['comprehensive_coverage', 'evidence_based', 'thorough_analysis'],
127
+ weaknesses: ['expensive', 'time_consuming', 'may_be_overwhelming'],
128
+ bestFor: ['research_projects', 'comprehensive_analysis', 'evidence_gathering', 'academic_research'],
129
+ costLevel: 'high',
130
+ timeComplexity: 'slow',
131
+ reliability: 0.95,
132
+ outputs: ['research_report', 'evidence_collection', 'comprehensive_findings']
133
+ },
134
+ perplexity_reason: {
135
+ id: 'perplexity_reason',
136
+ name: 'Perplexity Reasoning Pro',
137
+ description: 'Complex reasoning using Perplexity Sonar Reasoning Pro model with web data',
138
+ category: 'reasoning',
139
+ capabilities: ['reasoning_with_data', 'evidence_based_reasoning', 'analytical_reasoning', 'data_synthesis'],
140
+ strengths: ['data_informed_reasoning', 'current_information', 'analytical_approach'],
141
+ weaknesses: ['research_dependent', 'may_be_biased_to_web_sources'],
142
+ bestFor: ['data_driven_decisions', 'evidence_based_reasoning', 'analytical_problems'],
143
+ costLevel: 'high',
144
+ timeComplexity: 'medium',
145
+ reliability: 0.9,
146
+ outputs: ['reasoned_analysis', 'data_supported_conclusions', 'evidence_chain']
147
+ },
148
+ focus_deep_research: {
149
+ id: 'focus_deep_research',
150
+ name: 'Focus Deep Research Workflow',
151
+ description: 'Multi-AI comprehensive investigation with evidence gathering (Focus workflow)',
152
+ category: 'research',
153
+ capabilities: ['multi_ai_research', 'comprehensive_investigation', 'pattern_recognition', 'systematic_analysis'],
154
+ strengths: ['multiple_perspectives', 'thorough_coverage', 'systematic_approach'],
155
+ weaknesses: ['very_expensive', 'very_slow', 'complex_output'],
156
+ bestFor: ['complex_research_projects', 'multi_perspective_analysis', 'systematic_investigation'],
157
+ costLevel: 'high',
158
+ timeComplexity: 'slow',
159
+ reliability: 0.95,
160
+ outputs: ['multi_perspective_research', 'comprehensive_analysis', 'research_synthesis']
161
+ },
162
+ challenger: {
163
+ id: 'challenger',
164
+ name: 'Critical Challenger',
165
+ description: 'Critical thinking and echo chamber prevention with counter-arguments',
166
+ category: 'validation',
167
+ capabilities: ['critical_analysis', 'counter_arguments', 'assumption_challenging', 'bias_detection'],
168
+ strengths: ['critical_thinking', 'bias_detection', 'alternative_perspectives'],
169
+ weaknesses: ['potentially_negative', 'no_solutions_offered'],
170
+ bestFor: ['validation', 'assumption_testing', 'bias_checking', 'critical_review'],
171
+ costLevel: 'medium',
172
+ timeComplexity: 'medium',
173
+ reliability: 0.85,
174
+ outputs: ['challenges', 'counter_arguments', 'assumptions_questioned']
175
+ },
176
+ verifier: {
177
+ id: 'verifier',
178
+ name: 'Multi-Model Verifier',
179
+ description: 'Multi-model parallel verification with consensus analysis',
180
+ category: 'validation',
181
+ capabilities: ['consensus_building', 'multi_model_verification', 'fact_checking', 'validation'],
182
+ strengths: ['consensus_approach', 'multiple_models', 'reliability'],
183
+ weaknesses: ['expensive', 'slow', 'may_not_reach_consensus'],
184
+ bestFor: ['final_validation', 'consensus_building', 'fact_verification', 'quality_assurance'],
185
+ costLevel: 'high',
186
+ timeComplexity: 'slow',
187
+ reliability: 0.95,
188
+ outputs: ['consensus_score', 'verification_result', 'model_agreement']
189
+ },
190
+ auditor: {
191
+ id: 'auditor',
192
+ name: 'Evidence Auditor',
193
+ description: 'Evidence-based verification and systematic assumption checking',
194
+ category: 'validation',
195
+ capabilities: ['evidence_verification', 'assumption_checking', 'systematic_analysis', 'quality_audit'],
196
+ strengths: ['evidence_based', 'systematic', 'thorough_checking'],
197
+ weaknesses: ['requires_evidence', 'may_be_overly_critical'],
198
+ bestFor: ['quality_assurance', 'evidence_validation', 'systematic_checking'],
199
+ costLevel: 'medium',
200
+ timeComplexity: 'medium',
201
+ reliability: 0.9,
202
+ outputs: ['audit_results', 'evidence_assessment', 'quality_score']
203
+ },
204
+ commit_guardian: {
205
+ id: 'commit_guardian',
206
+ name: 'Commit Guardian',
207
+ description: 'Pre-commit validation for security, quality, and tests',
208
+ category: 'validation',
209
+ capabilities: ['pre_commit_validation', 'security_check', 'quality_check', 'test_validation'],
210
+ strengths: ['comprehensive_validation', 'security_focused', 'code_quality'],
211
+ weaknesses: ['development_specific', 'strict_criteria'],
212
+ bestFor: ['code_validation', 'pre_deployment', 'quality_gates'],
213
+ costLevel: 'medium',
214
+ timeComplexity: 'medium',
215
+ reliability: 0.85,
216
+ outputs: ['validation_results', 'security_assessment', 'quality_metrics']
217
+ },
218
+ architect: {
219
+ id: 'architect',
220
+ name: 'System Architect',
221
+ description: 'Full codebase analysis with Gemini 2.5 Pro and specialized verification',
222
+ category: 'analysis',
223
+ capabilities: ['system_design', 'architecture_analysis', 'codebase_analysis', 'design_patterns'],
224
+ strengths: ['holistic_view', 'system_thinking', 'design_expertise'],
225
+ weaknesses: ['high_level_focus', 'may_miss_details'],
226
+ bestFor: ['system_design', 'architecture_review', 'high_level_planning'],
227
+ costLevel: 'high',
228
+ timeComplexity: 'slow',
229
+ reliability: 0.9,
230
+ outputs: ['architecture_design', 'system_analysis', 'design_recommendations']
231
+ },
232
+ // Helper tools from modes directory
233
+ code_reviewer: {
234
+ id: 'code_reviewer',
235
+ name: 'Code Reviewer',
236
+ description: 'Comprehensive code review with Socratic questioning',
237
+ category: 'analysis',
238
+ capabilities: ['code_review', 'socratic_questioning', 'issue_detection', 'improvement_suggestions'],
239
+ strengths: ['thorough_analysis', 'educational_approach', 'improvement_focused'],
240
+ weaknesses: ['code_specific', 'may_be_overwhelming'],
241
+ bestFor: ['code_quality', 'learning', 'improvement_suggestions'],
242
+ costLevel: 'medium',
243
+ timeComplexity: 'medium',
244
+ reliability: 0.85,
245
+ outputs: ['review_results', 'issues', 'suggestions', 'questions']
246
+ },
247
+ test_architect: {
248
+ id: 'test_architect',
249
+ name: 'Test Architect',
250
+ description: 'Comprehensive test suite design with edge cases and mocking',
251
+ category: 'testing',
252
+ capabilities: ['test_design', 'edge_case_generation', 'mock_generation', 'test_architecture'],
253
+ strengths: ['comprehensive_testing', 'edge_case_coverage', 'testing_strategy'],
254
+ weaknesses: ['testing_focused', 'implementation_required'],
255
+ bestFor: ['test_planning', 'quality_assurance', 'edge_case_identification'],
256
+ costLevel: 'medium',
257
+ timeComplexity: 'medium',
258
+ reliability: 0.8,
259
+ outputs: ['test_suite', 'test_cases', 'mocks', 'test_strategy']
260
+ },
261
+ documentation_writer: {
262
+ id: 'documentation_writer',
263
+ name: 'Documentation Writer',
264
+ description: 'Auto-generates README, API docs, inline comments, narrative docs',
265
+ category: 'generation',
266
+ capabilities: ['documentation_generation', 'readme_creation', 'api_docs', 'narrative_docs'],
267
+ strengths: ['comprehensive_docs', 'multiple_formats', 'narrative_style'],
268
+ weaknesses: ['generic_output', 'requires_refinement'],
269
+ bestFor: ['documentation', 'readme_generation', 'api_documentation'],
270
+ costLevel: 'medium',
271
+ timeComplexity: 'medium',
272
+ reliability: 0.75,
273
+ outputs: ['readme', 'api_docs', 'comments', 'documentation']
274
+ }
275
+ };
276
+ export class ToolOrchestrator extends EventEmitter {
277
+ constructor() {
278
+ super();
279
+ this.availableTools = new Map();
280
+ this.usageStats = new Map();
281
+ this.performanceHistory = new Map(); // Response times
282
+ this.failureStreaks = new Map();
283
+ this.demotedModels = new Set();
284
+ this.initializeTools();
285
+ }
286
+ initializeTools() {
287
+ Object.values(FOCUS_MCP_TOOLS).forEach(tool => {
288
+ this.availableTools.set(tool.id, tool);
289
+ this.usageStats.set(tool.id, { uses: 0, successes: 0, failures: 0 });
290
+ this.performanceHistory.set(tool.id, []);
291
+ this.failureStreaks.set(tool.id, 0);
292
+ });
293
+ }
294
+ // Analyze task to determine requirements
295
+ analyzeTask(query, context) {
296
+ const fullText = `${query} ${context || ''}`.toLowerCase();
297
+ // Keyword analysis
298
+ const keywords = this.extractKeywords(fullText);
299
+ // Category detection
300
+ const category = this.detectCategory(fullText, keywords);
301
+ // Complexity assessment
302
+ const complexity = this.assessComplexity(fullText, keywords);
303
+ // Domain detection
304
+ const domain = this.detectDomain(fullText, keywords);
305
+ // Requirements extraction
306
+ const timeConstraint = this.detectTimeConstraint(fullText);
307
+ const qualityRequirement = this.detectQualityRequirement(fullText);
308
+ const costBudget = this.detectCostBudget(fullText);
309
+ return {
310
+ category,
311
+ complexity,
312
+ domain,
313
+ timeConstraint,
314
+ qualityRequirement,
315
+ costBudget,
316
+ keywords
317
+ };
318
+ }
319
+ // Main orchestration method: choose best tools for task
320
+ orchestrateTools(analysis, maxTools = 3) {
321
+ const candidateTools = Array.from(this.availableTools.values());
322
+ // Score each tool for this task
323
+ const scoredTools = candidateTools.map(tool => ({
324
+ ...tool,
325
+ score: this.calculateToolScore(tool, analysis)
326
+ }));
327
+ // Sort by score and select top tools
328
+ const selectedTools = scoredTools
329
+ .sort((a, b) => b.score - a.score)
330
+ .slice(0, maxTools)
331
+ .filter(tool => tool.score > 0.3) // Minimum threshold
332
+ .map(tool => tool.id);
333
+ this.emit('tools-selected', { analysis, selectedTools, scores: scoredTools });
334
+ return selectedTools;
335
+ }
336
+ // Calculate tool fitness score for specific task
337
+ calculateToolScore(tool, analysis) {
338
+ let score = 0;
339
+ // Category match (most important)
340
+ if (tool.category === analysis.category)
341
+ score += 0.4;
342
+ else if (this.isRelatedCategory(tool.category, analysis.category))
343
+ score += 0.2;
344
+ // Capability match
345
+ const capabilityMatch = this.calculateCapabilityMatch(tool, analysis);
346
+ score += capabilityMatch * 0.3;
347
+ // Cost/time constraints
348
+ const constraintMatch = this.calculateConstraintMatch(tool, analysis);
349
+ score += constraintMatch * 0.2;
350
+ // Historical performance
351
+ const performanceScore = this.calculatePerformanceScore(tool.id);
352
+ score += performanceScore * 0.1;
353
+ return Math.min(score, 1.0);
354
+ }
355
+ calculateCapabilityMatch(tool, analysis) {
356
+ const relevantCapabilities = analysis.keywords.filter(keyword => tool.capabilities.some(cap => cap.includes(keyword)) ||
357
+ tool.bestFor.some(use => use.includes(keyword)) ||
358
+ tool.strengths.some(strength => strength.includes(keyword)));
359
+ return relevantCapabilities.length / Math.max(analysis.keywords.length, 1);
360
+ }
361
+ calculateConstraintMatch(tool, analysis) {
362
+ let match = 1.0;
363
+ // Time constraint penalty
364
+ if (analysis.timeConstraint === 'urgent' && tool.timeComplexity === 'slow')
365
+ match -= 0.5;
366
+ if (analysis.timeConstraint === 'flexible' && tool.timeComplexity === 'fast')
367
+ match += 0.1;
368
+ // Cost constraint penalty
369
+ if (analysis.costBudget === 'low' && tool.costLevel === 'high')
370
+ match -= 0.6;
371
+ if (analysis.costBudget === 'medium' && tool.costLevel === 'high')
372
+ match -= 0.3;
373
+ // Quality requirement bonus
374
+ if (analysis.qualityRequirement === 'critical' && tool.reliability > 0.9)
375
+ match += 0.2;
376
+ return Math.max(match, 0);
377
+ }
378
+ calculatePerformanceScore(toolId) {
379
+ const stats = this.usageStats.get(toolId);
380
+ if (!stats || stats.uses === 0)
381
+ return 0.5; // Neutral for unused tools
382
+ return stats.successes / stats.uses; // Success rate
383
+ }
384
+ // Smart workflow composition: suggest tool sequences using user preferences
385
+ composeWorkflow(analysis) {
386
+ const workflow = [];
387
+ const allowExpensive = analysis.costBudget === 'high' || modelPreferences.isModelAvailable('grok_heavy');
388
+ // Research phase - intelligent selection
389
+ if (analysis.category === 'research' || analysis.complexity === 'complex') {
390
+ const researchModel = modelPreferences.getBestModelForTask('research', allowExpensive);
391
+ if (researchModel) {
392
+ workflow.push({
393
+ toolId: researchModel,
394
+ reason: `User-preferred research model: ${researchModel}`
395
+ });
396
+ }
397
+ else {
398
+ const researchTool = this.selectResearchTool(analysis);
399
+ workflow.push(researchTool);
400
+ }
401
+ }
402
+ // Analysis phase - use user preferences
403
+ if (analysis.category === 'analysis' || analysis.domain === 'technical') {
404
+ const analysisModel = modelPreferences.getBestModelForTask('analysis', allowExpensive);
405
+ if (analysisModel) {
406
+ workflow.push({
407
+ toolId: analysisModel,
408
+ reason: `User-preferred analysis model: ${analysisModel}`
409
+ });
410
+ }
411
+ else {
412
+ workflow.push({
413
+ toolId: 'gpt5_mini',
414
+ reason: 'Default analysis model'
415
+ });
416
+ }
417
+ if (analysis.keywords.includes('code') || analysis.keywords.includes('system')) {
418
+ const codeModel = modelPreferences.getBestModelForTask('code', allowExpensive);
419
+ if (codeModel) {
420
+ workflow.push({
421
+ toolId: codeModel,
422
+ reason: `User-preferred code analysis: ${codeModel}`
423
+ });
424
+ }
425
+ else {
426
+ workflow.push({
427
+ toolId: 'architect',
428
+ reason: 'System-level analysis and design'
429
+ });
430
+ }
431
+ }
432
+ }
433
+ // Reasoning phase - prioritize user preferences
434
+ const reasoningModel = modelPreferences.getBestModelForTask('reasoning', allowExpensive);
435
+ if (analysis.complexity === 'complex' || analysis.qualityRequirement === 'critical') {
436
+ // Use user's preferred reasoning model
437
+ if (reasoningModel) {
438
+ workflow.push({
439
+ toolId: reasoningModel,
440
+ reason: `PRIMARY: User-preferred reasoning model (${reasoningModel})`
441
+ });
442
+ // Add fallback chain
443
+ const fallbacks = modelPreferences.getFallbackChain(reasoningModel);
444
+ if (fallbacks.length > 0 && analysis.qualityRequirement === 'critical') {
445
+ workflow.push({
446
+ toolId: fallbacks[0],
447
+ reason: `Backup reasoning model: ${fallbacks[0]}`
448
+ });
449
+ }
450
+ }
451
+ else {
452
+ // Fallback to default stable model
453
+ const defaultFlagship = modelPreferences.isModelAvailable('gpt5') ? 'gpt5' : 'gpt-5-mini';
454
+ workflow.push({
455
+ toolId: defaultFlagship,
456
+ reason: defaultFlagship === 'gpt5'
457
+ ? 'Default flagship reasoning model'
458
+ : 'Default GPT-5 Mini reasoning model'
459
+ });
460
+ }
461
+ // Add collaborative reasoning for critical tasks if user has tokens
462
+ if (analysis.qualityRequirement === 'critical' && allowExpensive) {
463
+ // Check for specific high-end models
464
+ if (modelPreferences.isModelAvailable('grok_heavy')) {
465
+ workflow.push({
466
+ toolId: 'grok_heavy',
467
+ reason: 'Grok Heavy - 256k context deep reasoning (user has tokens)'
468
+ });
469
+ }
470
+ if (modelPreferences.isModelAvailable('gpt5_reason')) {
471
+ workflow.push({
472
+ toolId: 'gpt5_reason',
473
+ reason: 'GPT-5 - Advanced mathematical/scientific reasoning'
474
+ });
475
+ }
476
+ if (modelPreferences.isModelAvailable('deepseek_r1')) {
477
+ workflow.push({
478
+ toolId: 'deepseek_r1',
479
+ reason: 'DeepSeek R1 - Cost-effective deep reasoning'
480
+ });
481
+ }
482
+ }
483
+ }
484
+ else if (analysis.complexity === 'medium') {
485
+ // Use preferred model or default
486
+ if (reasoningModel) {
487
+ workflow.push({
488
+ toolId: reasoningModel,
489
+ reason: `User-preferred reasoning: ${reasoningModel}`
490
+ });
491
+ }
492
+ else {
493
+ const defaultFlagship = modelPreferences.isModelAvailable('gpt5_mini')
494
+ ? 'gpt5_mini'
495
+ : modelPreferences.isModelAvailable('gpt5')
496
+ ? 'gpt5'
497
+ : 'gpt-5-mini';
498
+ workflow.push({
499
+ toolId: defaultFlagship,
500
+ reason: 'Default GPT-5 reasoning for medium complexity'
501
+ });
502
+ }
503
+ // Add sequential thinking if needed
504
+ if (analysis.keywords.includes('step') || analysis.keywords.includes('sequential')) {
505
+ workflow.push({
506
+ toolId: 'nextThought',
507
+ reason: 'Structured sequential thinking supplement'
508
+ });
509
+ }
510
+ }
511
+ else {
512
+ // Simple tasks - use lightweight model unless user prefers otherwise
513
+ if (reasoningModel && modelPreferences.getModelConfig(reasoningModel)?.priority <= 5) {
514
+ workflow.push({
515
+ toolId: reasoningModel,
516
+ reason: `User-preferred quick reasoning: ${reasoningModel}`
517
+ });
518
+ }
519
+ else {
520
+ workflow.push({
521
+ toolId: 'think',
522
+ reason: 'Simple reasoning cache and reflection'
523
+ });
524
+ }
525
+ }
526
+ // Alternative perspective - check for diverse models
527
+ if (analysis.qualityRequirement === 'critical' || analysis.keywords.includes('perspective')) {
528
+ // Add different provider models for perspective
529
+ if (modelPreferences.isModelAvailable('gemini_25_pro')) {
530
+ workflow.push({
531
+ toolId: 'gemini_25_pro',
532
+ reason: 'Gemini perspective for diversity'
533
+ });
534
+ }
535
+ if (modelPreferences.isModelAvailable('qwq_reason')) {
536
+ workflow.push({
537
+ toolId: 'qwq_reason',
538
+ reason: 'QwQ reasoning for alternative approach'
539
+ });
540
+ }
541
+ }
542
+ // Validation phase
543
+ if (analysis.qualityRequirement === 'critical') {
544
+ workflow.push({
545
+ toolId: 'challenger',
546
+ reason: 'Challenge assumptions and find weaknesses'
547
+ });
548
+ workflow.push({
549
+ toolId: 'verifier',
550
+ reason: 'Multi-model consensus validation'
551
+ });
552
+ }
553
+ else if (analysis.qualityRequirement === 'high') {
554
+ workflow.push({
555
+ toolId: 'challenger',
556
+ reason: 'Critical evaluation'
557
+ });
558
+ }
559
+ // Filter out disabled models
560
+ return workflow.filter(step => {
561
+ // Skip if model is explicitly disabled
562
+ const config = modelPreferences.getModelConfig(step.toolId);
563
+ if (config && !config.enabled)
564
+ return false;
565
+ // Skip GPT-5 variants unless explicitly enabled
566
+ if (step.toolId.includes('gpt5') && !modelPreferences.isModelAvailable(step.toolId)) {
567
+ return false;
568
+ }
569
+ return true;
570
+ });
571
+ }
572
+ // Update tool performance based on execution results
573
+ updateToolPerformance(toolId, success, responseTime) {
574
+ const stats = this.usageStats.get(toolId);
575
+ if (stats) {
576
+ stats.uses++;
577
+ if (success)
578
+ stats.successes++;
579
+ else
580
+ stats.failures++;
581
+ }
582
+ if (success) {
583
+ this.failureStreaks.set(toolId, 0);
584
+ if (this.demotedModels.has(toolId)) {
585
+ const restoredPriority = toolId === 'gpt5' ? 0 : toolId === 'gpt5_mini' ? 1 : undefined;
586
+ modelPreferences.setModelPreference(toolId, {
587
+ enabled: true,
588
+ ...(restoredPriority !== undefined ? { priority: restoredPriority } : {})
589
+ });
590
+ this.demotedModels.delete(toolId);
591
+ }
592
+ }
593
+ else {
594
+ const streak = (this.failureStreaks.get(toolId) || 0) + 1;
595
+ this.failureStreaks.set(toolId, streak);
596
+ this.handleModelDemotion(toolId, streak);
597
+ }
598
+ const history = this.performanceHistory.get(toolId);
599
+ if (history) {
600
+ history.push(responseTime);
601
+ if (history.length > 100)
602
+ history.shift(); // Keep only recent 100 records
603
+ }
604
+ this.emit('tool-performance-updated', { toolId, success, responseTime });
605
+ }
606
+ handleModelDemotion(toolId, streak) {
607
+ const isGPT5Family = toolId === 'gpt5' || toolId === 'gpt5_mini';
608
+ if (!isGPT5Family) {
609
+ return;
610
+ }
611
+ const demotionThreshold = toolId === 'gpt5' ? 2 : 3;
612
+ if (streak < demotionThreshold || this.demotedModels.has(toolId)) {
613
+ return;
614
+ }
615
+ modelPreferences.setModelPreference(toolId, { enabled: false, priority: 99 });
616
+ this.demotedModels.add(toolId);
617
+ this.emit('model-demoted', {
618
+ model: toolId,
619
+ reason: `Automatic demotion after ${streak} consecutive failures`
620
+ });
621
+ }
622
+ // Get tool recommendations with explanations
623
+ recommendTools(query, context) {
624
+ const analysis = this.analyzeTask(query, context);
625
+ const primaryTools = this.orchestrateTools(analysis, 2);
626
+ const workflow = this.composeWorkflow(analysis);
627
+ return {
628
+ primary: primaryTools.map(toolId => ({
629
+ toolId,
630
+ reason: this.explainToolChoice(toolId, analysis)
631
+ })),
632
+ workflow,
633
+ analysis
634
+ };
635
+ }
636
+ explainToolChoice(toolId, analysis) {
637
+ const tool = this.availableTools.get(toolId);
638
+ if (!tool)
639
+ return 'Unknown tool';
640
+ const reasons = [];
641
+ if (tool.category === analysis.category) {
642
+ reasons.push(`Perfect category match (${analysis.category})`);
643
+ }
644
+ if (analysis.complexity === 'complex' && tool.reliability > 0.9) {
645
+ reasons.push('High reliability for complex task');
646
+ }
647
+ if (analysis.timeConstraint === 'urgent' && tool.timeComplexity === 'fast') {
648
+ reasons.push('Fast execution for urgent task');
649
+ }
650
+ if (tool.bestFor.some(use => analysis.keywords.some(keyword => use.includes(keyword)))) {
651
+ reasons.push('Specialized for your specific needs');
652
+ }
653
+ return reasons.join('; ') || 'Good general fit';
654
+ }
655
+ // Intelligent research tool selection
656
+ selectResearchTool(analysis) {
657
+ const text = analysis.keywords.join(' ').toLowerCase();
658
+ // Quick fact-checking or simple questions
659
+ if (analysis.complexity === 'simple' &&
660
+ (text.includes('what') || text.includes('when') || text.includes('who'))) {
661
+ return {
662
+ toolId: 'perplexity_ask',
663
+ reason: 'Quick fact-checking for simple question'
664
+ };
665
+ }
666
+ // Initial exploration and context gathering
667
+ if (analysis.keywords.includes('understand') ||
668
+ analysis.keywords.includes('explore') ||
669
+ analysis.timeConstraint === 'urgent') {
670
+ return {
671
+ toolId: 'scout',
672
+ reason: 'Fast initial exploration and context gathering'
673
+ };
674
+ }
675
+ // Comprehensive research projects
676
+ if (analysis.complexity === 'complex' &&
677
+ (analysis.qualityRequirement === 'critical' ||
678
+ text.includes('comprehensive') ||
679
+ text.includes('thorough'))) {
680
+ // Multi-AI research for most critical projects
681
+ if (analysis.costBudget === 'high' && analysis.qualityRequirement === 'critical') {
682
+ return {
683
+ toolId: 'focus_deep_research',
684
+ reason: 'Multi-AI comprehensive research for critical project'
685
+ };
686
+ }
687
+ // Deep Perplexity research for thorough investigation
688
+ return {
689
+ toolId: 'perplexity_research',
690
+ reason: 'Comprehensive research with evidence gathering'
691
+ };
692
+ }
693
+ // Data-driven reasoning tasks
694
+ if (analysis.category === 'reasoning' &&
695
+ (text.includes('analyze') || text.includes('decide') || text.includes('compare'))) {
696
+ return {
697
+ toolId: 'perplexity_reason',
698
+ reason: 'Evidence-based reasoning with current data'
699
+ };
700
+ }
701
+ // Default: scout for general exploration
702
+ return {
703
+ toolId: 'scout',
704
+ reason: 'General context exploration and information gathering'
705
+ };
706
+ }
707
+ // Helper methods for task analysis
708
+ extractKeywords(text) {
709
+ const commonKeywords = [
710
+ 'code', 'system', 'design', 'architecture', 'test', 'debug', 'analyze',
711
+ 'research', 'validate', 'review', 'optimize', 'security', 'performance',
712
+ 'documentation', 'api', 'database', 'algorithm', 'reasoning', 'problem'
713
+ ];
714
+ return commonKeywords.filter(keyword => text.includes(keyword));
715
+ }
716
+ detectCategory(text, keywords) {
717
+ if (keywords.some(k => ['research', 'investigate', 'find'].includes(k)))
718
+ return 'research';
719
+ if (keywords.some(k => ['analyze', 'review', 'examine'].includes(k)))
720
+ return 'analysis';
721
+ if (keywords.some(k => ['think', 'reason', 'solve'].includes(k)))
722
+ return 'reasoning';
723
+ if (keywords.some(k => ['validate', 'verify', 'check'].includes(k)))
724
+ return 'validation';
725
+ if (keywords.some(k => ['create', 'generate', 'build'].includes(k)))
726
+ return 'generation';
727
+ if (keywords.some(k => ['test', 'debug'].includes(k)))
728
+ return 'testing';
729
+ return 'reasoning';
730
+ }
731
+ assessComplexity(text, keywords) {
732
+ if (text.length > 500 || keywords.length > 5)
733
+ return 'complex';
734
+ if (text.length > 200 || keywords.length > 3)
735
+ return 'medium';
736
+ return 'simple';
737
+ }
738
+ detectDomain(text, keywords) {
739
+ if (keywords.some(k => ['code', 'system', 'api', 'architecture'].includes(k)))
740
+ return 'technical';
741
+ if (keywords.some(k => ['creative', 'design', 'innovative'].includes(k)))
742
+ return 'creative';
743
+ if (keywords.some(k => ['analyze', 'data', 'metrics'].includes(k)))
744
+ return 'analytical';
745
+ return 'general';
746
+ }
747
+ detectTimeConstraint(text) {
748
+ if (text.includes('urgent') || text.includes('quickly') || text.includes('asap'))
749
+ return 'urgent';
750
+ if (text.includes('when possible') || text.includes('no rush'))
751
+ return 'flexible';
752
+ return 'normal';
753
+ }
754
+ detectQualityRequirement(text) {
755
+ if (text.includes('critical') || text.includes('production') || text.includes('important'))
756
+ return 'critical';
757
+ if (text.includes('thorough') || text.includes('comprehensive'))
758
+ return 'high';
759
+ return 'basic';
760
+ }
761
+ detectCostBudget(text) {
762
+ if (text.includes('expensive') || text.includes('comprehensive'))
763
+ return 'high';
764
+ if (text.includes('quick') || text.includes('simple'))
765
+ return 'low';
766
+ return 'medium';
767
+ }
768
+ isRelatedCategory(toolCategory, taskCategory) {
769
+ const related = {
770
+ 'analysis': ['reasoning', 'validation'],
771
+ 'reasoning': ['analysis', 'validation'],
772
+ 'validation': ['analysis', 'reasoning'],
773
+ 'research': ['analysis'],
774
+ 'generation': ['reasoning'],
775
+ 'testing': ['validation', 'analysis']
776
+ };
777
+ return related[toolCategory]?.includes(taskCategory) || false;
778
+ }
779
+ // Get orchestrator status and capabilities
780
+ getStatus() {
781
+ const performanceStats = {};
782
+ for (const [toolId, stats] of this.usageStats.entries()) {
783
+ const history = this.performanceHistory.get(toolId) || [];
784
+ performanceStats[toolId] = {
785
+ successRate: stats.uses > 0 ? stats.successes / stats.uses : 0,
786
+ avgResponseTime: history.length > 0 ? history.reduce((a, b) => a + b, 0) / history.length : 0
787
+ };
788
+ }
789
+ return {
790
+ availableTools: Array.from(this.availableTools.keys()),
791
+ categories: [...new Set(Array.from(this.availableTools.values()).map(t => t.category))],
792
+ totalTools: this.availableTools.size,
793
+ performanceStats
794
+ };
795
+ }
796
+ }