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.
- package/.env.example +260 -0
- package/CHANGELOG.md +54 -0
- package/CODE_OF_CONDUCT.md +56 -0
- package/CONTRIBUTING.md +54 -0
- package/Dockerfile +36 -0
- package/LICENSE +644 -0
- package/README.md +201 -0
- package/SECURITY.md +95 -0
- package/dist/personality/komaai-expressions.js +12 -0
- package/dist/profiles/balanced.json +33 -0
- package/dist/profiles/code_focus.json +33 -0
- package/dist/profiles/full.json +33 -0
- package/dist/profiles/minimal.json +33 -0
- package/dist/profiles/research_power.json +33 -0
- package/dist/scripts/build-profiles.js +46 -0
- package/dist/src/application/services/focus/FocusModeRegistry.js +46 -0
- package/dist/src/application/services/focus/FocusTool.service.js +109 -0
- package/dist/src/application/services/focus/ModeRegistry.js +46 -0
- package/dist/src/application/services/focus/modes/focus-deep.mode.js +27 -0
- package/dist/src/application/services/focus/modes/status.mode.js +50 -0
- package/dist/src/application/services/focus/modes/tachibot-status.mode.js +50 -0
- package/dist/src/collaborative-orchestrator.js +391 -0
- package/dist/src/config/model-constants.js +188 -0
- package/dist/src/config/model-defaults.js +57 -0
- package/dist/src/config/model-preferences.js +382 -0
- package/dist/src/config/timeout-config.js +130 -0
- package/dist/src/config.js +173 -0
- package/dist/src/domain/interfaces/IFocusMode.js +5 -0
- package/dist/src/domain/interfaces/IProvider.js +6 -0
- package/dist/src/domain/interfaces/ITool.js +5 -0
- package/dist/src/focus-deep.js +245 -0
- package/dist/src/infrastructure/ascii/art/robots.ascii.js +16 -0
- package/dist/src/mcp-client.js +90 -0
- package/dist/src/memory/index.js +17 -0
- package/dist/src/memory/memory-config.js +135 -0
- package/dist/src/memory/memory-interface.js +174 -0
- package/dist/src/memory/memory-manager.js +383 -0
- package/dist/src/memory/providers/devlog-provider.js +385 -0
- package/dist/src/memory/providers/hybrid-provider.js +399 -0
- package/dist/src/memory/providers/local-provider.js +388 -0
- package/dist/src/memory/providers/mem0-provider.js +337 -0
- package/dist/src/modes/architect.js +477 -0
- package/dist/src/modes/auditor.js +362 -0
- package/dist/src/modes/challenger.js +841 -0
- package/dist/src/modes/code-reviewer.js +382 -0
- package/dist/src/modes/commit-guardian.js +424 -0
- package/dist/src/modes/documentation-writer.js +572 -0
- package/dist/src/modes/scout.js +587 -0
- package/dist/src/modes/shared/helpers/challenger-helpers.js +454 -0
- package/dist/src/modes/shared/helpers/index.js +17 -0
- package/dist/src/modes/shared/helpers/scout-helpers.js +270 -0
- package/dist/src/modes/shared/helpers/verifier-helpers.js +332 -0
- package/dist/src/modes/test-architect.js +767 -0
- package/dist/src/modes/verifier.js +378 -0
- package/dist/src/monitoring/performance-monitor.js +435 -0
- package/dist/src/optimization/batch-executor.js +121 -0
- package/dist/src/optimization/context-pruner.js +196 -0
- package/dist/src/optimization/cost-monitor.js +338 -0
- package/dist/src/optimization/index.js +65 -0
- package/dist/src/optimization/model-router.js +264 -0
- package/dist/src/optimization/result-cache.js +114 -0
- package/dist/src/optimization/token-optimizer.js +257 -0
- package/dist/src/optimization/token-tracker.js +118 -0
- package/dist/src/orchestrator-instructions.js +128 -0
- package/dist/src/orchestrator-lite.js +139 -0
- package/dist/src/orchestrator.js +191 -0
- package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionEngine.js +1 -0
- package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionStrategy.js +5 -0
- package/dist/src/orchestrators/collaborative/interfaces/IVisualizationRenderer.js +1 -0
- package/dist/src/orchestrators/collaborative/registries/ModelProviderRegistry.js +95 -0
- package/dist/src/orchestrators/collaborative/registries/ToolAdapterRegistry.js +64 -0
- package/dist/src/orchestrators/collaborative/services/tool-execution/ToolExecutionService.js +502 -0
- package/dist/src/orchestrators/collaborative/services/visualization/VisualizationService.js +206 -0
- package/dist/src/orchestrators/collaborative/types/session-types.js +5 -0
- package/dist/src/profiles/balanced.js +37 -0
- package/dist/src/profiles/code_focus.js +37 -0
- package/dist/src/profiles/debug_intensive.js +59 -0
- package/dist/src/profiles/full.js +37 -0
- package/dist/src/profiles/minimal.js +37 -0
- package/dist/src/profiles/research_code.js +59 -0
- package/dist/src/profiles/research_power.js +37 -0
- package/dist/src/profiles/types.js +5 -0
- package/dist/src/profiles/workflow_builder.js +53 -0
- package/dist/src/prompt-engineer-lite.js +78 -0
- package/dist/src/prompt-engineer.js +399 -0
- package/dist/src/reasoning-chain.js +508 -0
- package/dist/src/sequential-thinking.js +291 -0
- package/dist/src/server-diagnostic.js +74 -0
- package/dist/src/server-raw.js +158 -0
- package/dist/src/server-simple.js +58 -0
- package/dist/src/server.js +514 -0
- package/dist/src/session/session-logger.js +617 -0
- package/dist/src/session/session-manager.js +571 -0
- package/dist/src/session/session-tools.js +400 -0
- package/dist/src/tools/advanced-modes.js +200 -0
- package/dist/src/tools/claude-integration.js +356 -0
- package/dist/src/tools/consolidated/ai-router.js +174 -0
- package/dist/src/tools/consolidated/ai-tool.js +48 -0
- package/dist/src/tools/consolidated/brainstorm-tool.js +87 -0
- package/dist/src/tools/consolidated/environment-detector.js +80 -0
- package/dist/src/tools/consolidated/index.js +50 -0
- package/dist/src/tools/consolidated/search-tool.js +110 -0
- package/dist/src/tools/consolidated/workflow-tool.js +238 -0
- package/dist/src/tools/gemini-tools.js +329 -0
- package/dist/src/tools/grok-enhanced.js +376 -0
- package/dist/src/tools/grok-tools.js +299 -0
- package/dist/src/tools/lmstudio-tools.js +223 -0
- package/dist/src/tools/openai-tools.js +498 -0
- package/dist/src/tools/openrouter-tools.js +317 -0
- package/dist/src/tools/optimized-wrapper.js +204 -0
- package/dist/src/tools/perplexity-tools.js +294 -0
- package/dist/src/tools/pingpong-tool.js +343 -0
- package/dist/src/tools/qwen-wrapper.js +74 -0
- package/dist/src/tools/tool-router.js +444 -0
- package/dist/src/tools/unified-ai-provider.js +260 -0
- package/dist/src/tools/workflow-runner.js +425 -0
- package/dist/src/tools/workflow-validator-tool.js +107 -0
- package/dist/src/types.js +23 -0
- package/dist/src/utils/input-validator.js +130 -0
- package/dist/src/utils/model-router.js +91 -0
- package/dist/src/utils/progress-stream.js +255 -0
- package/dist/src/utils/provider-router.js +88 -0
- package/dist/src/utils/smart-api-client.js +146 -0
- package/dist/src/utils/table-builder.js +218 -0
- package/dist/src/utils/timestamp-formatter.js +134 -0
- package/dist/src/utils/tool-compressor.js +257 -0
- package/dist/src/utils/tool-config.js +201 -0
- package/dist/src/validators/dependency-graph-validator.js +147 -0
- package/dist/src/validators/interpolation-validator.js +222 -0
- package/dist/src/validators/output-usage-validator.js +151 -0
- package/dist/src/validators/syntax-validator.js +102 -0
- package/dist/src/validators/tool-registry-validator.js +123 -0
- package/dist/src/validators/tool-types.js +97 -0
- package/dist/src/validators/types.js +8 -0
- package/dist/src/validators/workflow-validator.js +134 -0
- package/dist/src/visualizer-lite.js +42 -0
- package/dist/src/visualizer.js +179 -0
- package/dist/src/workflows/circuit-breaker.js +199 -0
- package/dist/src/workflows/custom-workflows.js +451 -0
- package/dist/src/workflows/engine/AutoSynthesizer.js +97 -0
- package/dist/src/workflows/engine/StepParameterResolver.js +74 -0
- package/dist/src/workflows/engine/VariableInterpolator.js +123 -0
- package/dist/src/workflows/engine/WorkflowDiscovery.js +125 -0
- package/dist/src/workflows/engine/WorkflowExecutionEngine.js +485 -0
- package/dist/src/workflows/engine/WorkflowExecutor.js +113 -0
- package/dist/src/workflows/engine/WorkflowFileManager.js +244 -0
- package/dist/src/workflows/engine/WorkflowHelpers.js +114 -0
- package/dist/src/workflows/engine/WorkflowOutputFormatter.js +83 -0
- package/dist/src/workflows/engine/events/WorkflowEventBus.js +132 -0
- package/dist/src/workflows/engine/events/interfaces/IEventBus.js +5 -0
- package/dist/src/workflows/engine/handlers/ErrorRecoveryHandler.js +162 -0
- package/dist/src/workflows/engine/handlers/PromptEnhancementHandler.js +115 -0
- package/dist/src/workflows/engine/handlers/SessionPersistenceHandler.js +167 -0
- package/dist/src/workflows/engine/handlers/StepExecutionHandler.js +231 -0
- package/dist/src/workflows/engine/handlers/ToolInvocationHandler.js +46 -0
- package/dist/src/workflows/engine/interfaces/IAutoSynthesizer.js +5 -0
- package/dist/src/workflows/engine/interfaces/IStepParameterResolver.js +5 -0
- package/dist/src/workflows/engine/interfaces/IVariableInterpolator.js +5 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowDiscovery.js +4 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowFileManager.js +5 -0
- package/dist/src/workflows/engine/interfaces/IWorkflowOutputFormatter.js +5 -0
- package/dist/src/workflows/engine/state/WorkflowStateMachine.js +194 -0
- package/dist/src/workflows/engine/state/interfaces/IStateMachine.js +17 -0
- package/dist/src/workflows/fallback-strategies.js +373 -0
- package/dist/src/workflows/message-queue.js +455 -0
- package/dist/src/workflows/model-router.js +189 -0
- package/dist/src/workflows/orchestrator-examples.js +174 -0
- package/dist/src/workflows/orchestrator-integration.js +200 -0
- package/dist/src/workflows/self-healing.js +524 -0
- package/dist/src/workflows/tool-mapper.js +407 -0
- package/dist/src/workflows/tool-orchestrator.js +796 -0
- package/dist/src/workflows/workflow-engine.js +573 -0
- package/dist/src/workflows/workflow-parser.js +283 -0
- package/dist/src/workflows/workflow-types.js +95 -0
- package/dist/src/workflows.js +568 -0
- package/dist/test-workflow-file-output.js +93 -0
- package/docs/API_KEYS.md +570 -0
- package/docs/CLAUDE_CODE_SETUP.md +181 -0
- package/docs/CLAUDE_DESKTOP_MANUAL.md +127 -0
- package/docs/CONFIGURATION.md +745 -0
- package/docs/FOCUS_MODES.md +240 -0
- package/docs/INSTALLATION_BOTH.md +145 -0
- package/docs/TERMS.md +352 -0
- package/docs/TOOLS_REFERENCE.md +1622 -0
- package/docs/TOOL_PARAMETERS.md +496 -0
- package/docs/TOOL_PROFILES.md +236 -0
- package/docs/WORKFLOWS.md +987 -0
- package/docs/WORKFLOW_OUTPUT.md +198 -0
- package/docs/WORKFLOW_PROGRESS_TRACKING.md +305 -0
- package/docs/workflows/design-brainstorm.md +335 -0
- package/package.json +97 -0
- package/profiles/balanced.json +37 -0
- package/profiles/code_focus.json +37 -0
- package/profiles/debug_intensive.json +34 -0
- package/profiles/full.json +37 -0
- package/profiles/minimal.json +37 -0
- package/profiles/research_power.json +37 -0
- package/profiles/workflow_builder.json +37 -0
- package/smithery.yaml +66 -0
- package/start.sh +8 -0
- package/tools.config.json +81 -0
- package/tsconfig.json +18 -0
- package/workflows/accessibility-code-audit.yaml +92 -0
- package/workflows/code-architecture-review.yaml +202 -0
- package/workflows/code-review.yaml +142 -0
- package/workflows/core/iterative-problem-solver.yaml +283 -0
- package/workflows/creative-brainstorm-yaml.yaml +215 -0
- package/workflows/pingpong.yaml +141 -0
- package/workflows/system/README.md +412 -0
- package/workflows/system/challenger.yaml +175 -0
- package/workflows/system/scout.yaml +164 -0
- package/workflows/system/verifier.yaml +133 -0
- package/workflows/ultra-creative-brainstorm.yaml +318 -0
- package/workflows/ux-research-flow.yaml +92 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModeRegistry - Registry pattern for Focus modes
|
|
3
|
+
* Follows Open/Closed Principle - add new modes without modifying this class
|
|
4
|
+
*/
|
|
5
|
+
export class ModeRegistry {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.modes = new Map();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Register a focus mode
|
|
11
|
+
* @param mode Mode implementation to register
|
|
12
|
+
*/
|
|
13
|
+
register(mode) {
|
|
14
|
+
this.modes.set(mode.modeName, mode);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get a focus mode by name
|
|
18
|
+
* @param name Mode name
|
|
19
|
+
* @returns Mode implementation or undefined
|
|
20
|
+
*/
|
|
21
|
+
get(name) {
|
|
22
|
+
return this.modes.get(name);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get all registered mode names
|
|
26
|
+
* @returns Array of mode names
|
|
27
|
+
*/
|
|
28
|
+
getAllNames() {
|
|
29
|
+
return Array.from(this.modes.keys());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check if a mode is registered
|
|
33
|
+
* @param name Mode name
|
|
34
|
+
* @returns true if mode exists
|
|
35
|
+
*/
|
|
36
|
+
has(name) {
|
|
37
|
+
return this.modes.has(name);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get count of registered modes
|
|
41
|
+
* @returns Number of modes
|
|
42
|
+
*/
|
|
43
|
+
get size() {
|
|
44
|
+
return this.modes.size;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FocusDeep Mode - Ultimate reasoning combining Sequential Thinking + Multi-Model
|
|
3
|
+
* Extracted from server.ts (Phase 2: SOLID refactoring)
|
|
4
|
+
* Wraps existing focus-deep.ts functionality
|
|
5
|
+
*/
|
|
6
|
+
import { createFocusDeepPlan, generateFocusDeepVisualization } from '../../../../focus-deep.js';
|
|
7
|
+
export class FocusDeepMode {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.modeName = 'focus-deep';
|
|
10
|
+
this.description = 'Ultimate reasoning combining Sequential Thinking + Multi-Model orchestration';
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
const query = params.query;
|
|
14
|
+
const domain = params.domain;
|
|
15
|
+
const plan = createFocusDeepPlan(query, domain);
|
|
16
|
+
const viz = generateFocusDeepVisualization(plan);
|
|
17
|
+
return {
|
|
18
|
+
output: viz,
|
|
19
|
+
metadata: {
|
|
20
|
+
mode: this.modeName,
|
|
21
|
+
sessionId: plan.sessionId,
|
|
22
|
+
models: plan.availableModels,
|
|
23
|
+
estimatedThoughts: plan.estimatedThoughts
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Mode - Display system status
|
|
3
|
+
* Extracted from server.ts lines 379-400 (Phase 2: SOLID refactoring)
|
|
4
|
+
*/
|
|
5
|
+
import { canRunFocusDeep } from '../../../../focus-deep.js';
|
|
6
|
+
import { isPerplexityAvailable } from '../../../../tools/perplexity-tools.js';
|
|
7
|
+
import { isGrokAvailable } from '../../../../tools/grok-tools.js';
|
|
8
|
+
import { getProviderInfo } from '../../../../tools/unified-ai-provider.js';
|
|
9
|
+
import { loadConfig } from '../../../../config.js';
|
|
10
|
+
export class StatusMode {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.modeName = 'status';
|
|
13
|
+
this.description = 'Display system status and available features';
|
|
14
|
+
}
|
|
15
|
+
async execute(params) {
|
|
16
|
+
const config = loadConfig();
|
|
17
|
+
const providerInfo = getProviderInfo();
|
|
18
|
+
const availableProviders = Object.entries(providerInfo)
|
|
19
|
+
.filter(([_, info]) => info.available)
|
|
20
|
+
.map(([name]) => name);
|
|
21
|
+
const statusInfo = canRunFocusDeep();
|
|
22
|
+
let status = `# 🔧 Focus MCP Server Status\n\n`;
|
|
23
|
+
status += `**Mode**: ${config.isClaudeCode ? 'Claude Code' : 'Standalone'}\n`;
|
|
24
|
+
if (config.isClaudeCode) {
|
|
25
|
+
status += `**Claude Model**: ${config.claudeModel || 'Not detected'}\n`;
|
|
26
|
+
}
|
|
27
|
+
status += `\n**Available Features**:\n`;
|
|
28
|
+
status += `- Think tool: ✅ Always available\n`;
|
|
29
|
+
status += `- Sequential thinking: ✅ Always available\n`;
|
|
30
|
+
status += `- Unified AI providers: ${availableProviders.join(', ') || 'None configured'}\n`;
|
|
31
|
+
status += `- Perplexity tools: ${isPerplexityAvailable() ? '✅ Available' : '❌ Need PERPLEXITY_API_KEY'}\n`;
|
|
32
|
+
status += `- Grok tools: ${isGrokAvailable() ? '✅ Available' : '❌ Need GROK_API_KEY'}\n`;
|
|
33
|
+
// Check LM Studio async
|
|
34
|
+
const lmstudioAvailable = availableProviders.includes('lmstudio');
|
|
35
|
+
const lmstudioModel = lmstudioAvailable ? 'local-model' : 'Not connected';
|
|
36
|
+
status += `- LM Studio tools: ${lmstudioAvailable ? `✅ Available (${lmstudioModel})` : '❌ Start LM Studio'}\n`;
|
|
37
|
+
status += `\n**Focus-Deep Status**:\n`;
|
|
38
|
+
status += `- Quality: ${statusInfo.quality}\n`;
|
|
39
|
+
status += `- Available models: ${statusInfo.models.join(', ')}\n`;
|
|
40
|
+
return {
|
|
41
|
+
output: status,
|
|
42
|
+
metadata: {
|
|
43
|
+
mode: this.modeName,
|
|
44
|
+
timestamp: Date.now(),
|
|
45
|
+
providers: availableProviders,
|
|
46
|
+
quality: statusInfo.quality
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Mode - Display system status
|
|
3
|
+
* Extracted from server.ts lines 379-400 (Phase 2: SOLID refactoring)
|
|
4
|
+
*/
|
|
5
|
+
import { canRunFocusDeep } from '../../../../focus-deep.js';
|
|
6
|
+
import { isPerplexityAvailable } from '../../../../tools/perplexity-tools.js';
|
|
7
|
+
import { isGrokAvailable } from '../../../../tools/grok-tools.js';
|
|
8
|
+
import { getProviderInfo } from '../../../../tools/unified-ai-provider.js';
|
|
9
|
+
import { loadConfig } from '../../../../config.js';
|
|
10
|
+
export class TachibotStatusMode {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.modeName = 'tachibot-status';
|
|
13
|
+
this.description = 'Display TachiBot system status and available features';
|
|
14
|
+
}
|
|
15
|
+
async execute(params) {
|
|
16
|
+
const config = loadConfig();
|
|
17
|
+
const providerInfo = getProviderInfo();
|
|
18
|
+
const availableProviders = Object.entries(providerInfo)
|
|
19
|
+
.filter(([_, info]) => info.available)
|
|
20
|
+
.map(([name]) => name);
|
|
21
|
+
const statusInfo = canRunFocusDeep();
|
|
22
|
+
let status = `# 🔧 Focus MCP Server Status\n\n`;
|
|
23
|
+
status += `**Mode**: ${config.isClaudeCode ? 'Claude Code' : 'Standalone'}\n`;
|
|
24
|
+
if (config.isClaudeCode) {
|
|
25
|
+
status += `**Claude Model**: ${config.claudeModel || 'Not detected'}\n`;
|
|
26
|
+
}
|
|
27
|
+
status += `\n**Available Features**:\n`;
|
|
28
|
+
status += `- Think tool: ✅ Always available\n`;
|
|
29
|
+
status += `- Sequential thinking: ✅ Always available\n`;
|
|
30
|
+
status += `- Unified AI providers: ${availableProviders.join(', ') || 'None configured'}\n`;
|
|
31
|
+
status += `- Perplexity tools: ${isPerplexityAvailable() ? '✅ Available' : '❌ Need PERPLEXITY_API_KEY'}\n`;
|
|
32
|
+
status += `- Grok tools: ${isGrokAvailable() ? '✅ Available' : '❌ Need GROK_API_KEY'}\n`;
|
|
33
|
+
// Check LM Studio async
|
|
34
|
+
const lmstudioAvailable = availableProviders.includes('lmstudio');
|
|
35
|
+
const lmstudioModel = lmstudioAvailable ? 'local-model' : 'Not connected';
|
|
36
|
+
status += `- LM Studio tools: ${lmstudioAvailable ? `✅ Available (${lmstudioModel})` : '❌ Start LM Studio'}\n`;
|
|
37
|
+
status += `\n**Focus-Deep Status**:\n`;
|
|
38
|
+
status += `- Quality: ${statusInfo.quality}\n`;
|
|
39
|
+
status += `- Available models: ${statusInfo.models.join(', ')}\n`;
|
|
40
|
+
return {
|
|
41
|
+
output: status,
|
|
42
|
+
metadata: {
|
|
43
|
+
mode: this.modeName,
|
|
44
|
+
timestamp: Date.now(),
|
|
45
|
+
providers: availableProviders,
|
|
46
|
+
quality: statusInfo.quality
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { TechnicalDomain, REASONING_TEMPLATES } from "./reasoning-chain.js";
|
|
2
|
+
import { sessionLogger } from "./session/session-logger.js";
|
|
3
|
+
import { sessionManager } from "./session/session-manager.js";
|
|
4
|
+
import { ToolRouter } from "./tools/tool-router.js";
|
|
5
|
+
import { getMemoryManager } from "./memory/index.js";
|
|
6
|
+
import { VisualizationService } from "./orchestrators/collaborative/services/visualization/VisualizationService.js";
|
|
7
|
+
import { ToolExecutionService } from "./orchestrators/collaborative/services/tool-execution/ToolExecutionService.js";
|
|
8
|
+
export class CollaborativeOrchestrator {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.sessions = new Map();
|
|
11
|
+
this.modelTurnTaking = true;
|
|
12
|
+
this.enableVisualization = true;
|
|
13
|
+
this.modelPreferences = {}; // Global model preferences
|
|
14
|
+
this.sessionConfig = {
|
|
15
|
+
verbose: false,
|
|
16
|
+
saveSession: false,
|
|
17
|
+
outputFormat: "markdown",
|
|
18
|
+
includeTimestamps: true,
|
|
19
|
+
includeModelMetadata: true
|
|
20
|
+
};
|
|
21
|
+
this.mcpServer = null;
|
|
22
|
+
this.memoryManager = null;
|
|
23
|
+
this.enableMemory = false;
|
|
24
|
+
this.toolRouter = new ToolRouter({
|
|
25
|
+
verboseLogging: false,
|
|
26
|
+
qualityPriority: true,
|
|
27
|
+
fallbackEnabled: true
|
|
28
|
+
});
|
|
29
|
+
// Phase 2: Initialize visualization service
|
|
30
|
+
this.visualizationService = new VisualizationService({
|
|
31
|
+
modelTurnTaking: this.modelTurnTaking,
|
|
32
|
+
enableVisualization: this.enableVisualization
|
|
33
|
+
});
|
|
34
|
+
// Phase 4: Initialize tool execution service
|
|
35
|
+
this.toolExecutionService = new ToolExecutionService({
|
|
36
|
+
toolRouter: this.toolRouter,
|
|
37
|
+
memoryManager: this.memoryManager || undefined, // Convert null to undefined
|
|
38
|
+
enableMemory: this.enableMemory,
|
|
39
|
+
verbose: this.sessionConfig.verbose || false
|
|
40
|
+
});
|
|
41
|
+
// Initialize memory manager if configured
|
|
42
|
+
this.initializeMemory().catch(console.error);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Initialize memory manager
|
|
46
|
+
*/
|
|
47
|
+
async initializeMemory() {
|
|
48
|
+
try {
|
|
49
|
+
// Check if memory is enabled via environment variable
|
|
50
|
+
if (process.env.ENABLE_MEMORY === 'true' || process.env.MEMORY_PROVIDER) {
|
|
51
|
+
this.memoryManager = await getMemoryManager();
|
|
52
|
+
this.enableMemory = true;
|
|
53
|
+
console.error('🧠 Memory system initialized');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error('Failed to initialize memory:', error);
|
|
58
|
+
this.enableMemory = false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Set MCP server reference for tool execution
|
|
63
|
+
*/
|
|
64
|
+
setMCPServer(server) {
|
|
65
|
+
this.mcpServer = server;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Configure session logging
|
|
69
|
+
*/
|
|
70
|
+
configureSessionLogging(config) {
|
|
71
|
+
this.sessionConfig = { ...this.sessionConfig, ...config };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Start a Deep Reasoning session - multi-model collaborative thinking
|
|
75
|
+
*/
|
|
76
|
+
async startDeepReasoning(problem, domain = TechnicalDomain.ARCHITECTURE, modelOverrides, sessionOptions) {
|
|
77
|
+
const template = REASONING_TEMPLATES.deep_reasoning;
|
|
78
|
+
const sessionId = this.generateSessionId();
|
|
79
|
+
// Merge session options
|
|
80
|
+
const config = { ...this.sessionConfig, ...sessionOptions };
|
|
81
|
+
// Start session logging if enabled
|
|
82
|
+
if (config.verbose || config.saveSession) {
|
|
83
|
+
// Update sessionLogger config to match the request config
|
|
84
|
+
sessionLogger.updateConfig({
|
|
85
|
+
saveSession: config.saveSession ?? true,
|
|
86
|
+
verbose: config.verbose ?? false
|
|
87
|
+
});
|
|
88
|
+
await sessionManager.startSession("deep-reasoning", problem, config);
|
|
89
|
+
}
|
|
90
|
+
// Apply model overrides to the chain
|
|
91
|
+
const steps = template.chain.map(step => {
|
|
92
|
+
const model = modelOverrides?.[step.model] || this.modelPreferences[step.model] || step.model;
|
|
93
|
+
return {
|
|
94
|
+
...step,
|
|
95
|
+
model,
|
|
96
|
+
prompt: step.prompt.replace("{problem}", problem)
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
const session = {
|
|
100
|
+
id: sessionId,
|
|
101
|
+
domain,
|
|
102
|
+
objective: problem,
|
|
103
|
+
chain: {
|
|
104
|
+
domain,
|
|
105
|
+
objective: problem,
|
|
106
|
+
steps,
|
|
107
|
+
maxRounds: 5
|
|
108
|
+
},
|
|
109
|
+
responses: [],
|
|
110
|
+
currentStep: 0,
|
|
111
|
+
status: "active",
|
|
112
|
+
startTime: new Date(),
|
|
113
|
+
modelOverrides
|
|
114
|
+
};
|
|
115
|
+
this.sessions.set(sessionId, session);
|
|
116
|
+
return this.generateOrchestrationPlan(session);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Start a custom reasoning chain
|
|
120
|
+
*/
|
|
121
|
+
async startCustomChain(chainConfig) {
|
|
122
|
+
const sessionId = this.generateSessionId();
|
|
123
|
+
const session = {
|
|
124
|
+
id: sessionId,
|
|
125
|
+
domain: chainConfig.domain,
|
|
126
|
+
objective: chainConfig.objective,
|
|
127
|
+
chain: chainConfig,
|
|
128
|
+
responses: [],
|
|
129
|
+
currentStep: 0,
|
|
130
|
+
status: "active",
|
|
131
|
+
startTime: new Date()
|
|
132
|
+
};
|
|
133
|
+
this.sessions.set(sessionId, session);
|
|
134
|
+
return this.generateOrchestrationPlan(session);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Start a ping-pong brainstorm session
|
|
138
|
+
*/
|
|
139
|
+
async startPingPongBrainstorm(problem, domain = TechnicalDomain.ARCHITECTURE, sessionOptions) {
|
|
140
|
+
return this.startTemplateSession("pingpong_brainstorm", problem, domain);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Start a dynamic debate session
|
|
144
|
+
*/
|
|
145
|
+
async startDynamicDebate(debateTopic, domain = TechnicalDomain.ARCHITECTURE, sessionOptions) {
|
|
146
|
+
return this.startTemplateSession("dynamic_debate", debateTopic, domain);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Start a template-based reasoning session
|
|
150
|
+
*/
|
|
151
|
+
async startTemplateSession(templateName, problem, domain) {
|
|
152
|
+
const template = REASONING_TEMPLATES[templateName];
|
|
153
|
+
if (!template) {
|
|
154
|
+
throw new Error(`Template ${templateName} not found`);
|
|
155
|
+
}
|
|
156
|
+
const sessionId = this.generateSessionId();
|
|
157
|
+
const actualDomain = domain || TechnicalDomain.ARCHITECTURE;
|
|
158
|
+
const session = {
|
|
159
|
+
id: sessionId,
|
|
160
|
+
domain: actualDomain,
|
|
161
|
+
objective: problem,
|
|
162
|
+
chain: {
|
|
163
|
+
domain: actualDomain,
|
|
164
|
+
objective: problem,
|
|
165
|
+
steps: template.chain.map(step => ({
|
|
166
|
+
...step,
|
|
167
|
+
prompt: step.prompt
|
|
168
|
+
.replace("{problem}", problem)
|
|
169
|
+
.replace("{system}", problem)
|
|
170
|
+
.replace("{algorithm_problem}", problem)
|
|
171
|
+
.replace("{code}", problem)
|
|
172
|
+
.replace("{feature}", problem)
|
|
173
|
+
.replace("{bug_description}", problem)
|
|
174
|
+
})),
|
|
175
|
+
maxRounds: 5
|
|
176
|
+
},
|
|
177
|
+
responses: [],
|
|
178
|
+
currentStep: 0,
|
|
179
|
+
status: "active",
|
|
180
|
+
startTime: new Date(),
|
|
181
|
+
metadata: {
|
|
182
|
+
templateName,
|
|
183
|
+
templateDescription: template.description
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
this.sessions.set(sessionId, session);
|
|
187
|
+
return this.generateOrchestrationPlan(session);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Generate visual orchestration plan for a session
|
|
191
|
+
* Phase 2: Delegates to VisualizationService
|
|
192
|
+
*/
|
|
193
|
+
generateOrchestrationPlan(session) {
|
|
194
|
+
return this.visualizationService.generateOrchestrationPlan(session);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Generate TachiBot visualization for the session
|
|
198
|
+
* Phase 2: Delegates to VisualizationService
|
|
199
|
+
*/
|
|
200
|
+
generateTachiBotVisualization(session) {
|
|
201
|
+
return this.visualizationService.generateTachiBotVisualization(session);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get icon for reasoning mode
|
|
205
|
+
* Phase 2: Delegates to VisualizationService
|
|
206
|
+
*/
|
|
207
|
+
getModeIcon(mode) {
|
|
208
|
+
return this.visualizationService.getModeIcon(mode);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Generate example workflows for different technical domains
|
|
212
|
+
* Phase 2: Delegates to VisualizationService
|
|
213
|
+
*/
|
|
214
|
+
getExampleWorkflows() {
|
|
215
|
+
return this.visualizationService.getExampleWorkflows();
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get available templates
|
|
219
|
+
* Phase 2: Delegates to VisualizationService
|
|
220
|
+
*/
|
|
221
|
+
getAvailableTemplates() {
|
|
222
|
+
return this.visualizationService.getAvailableTemplates();
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Set global model preferences
|
|
226
|
+
*/
|
|
227
|
+
setModelPreferences(preferences) {
|
|
228
|
+
this.modelPreferences = { ...this.modelPreferences, ...preferences };
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Use Grok 4 Heavy for all Grok operations
|
|
232
|
+
*/
|
|
233
|
+
useGrok4Heavy() {
|
|
234
|
+
// Use GROK_4_0709 as the "heavy" model (reasoning model)
|
|
235
|
+
this.modelPreferences['grok'] = 'grok-4-0709';
|
|
236
|
+
this.modelPreferences['grok-4'] = 'grok-4-0709';
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Generate session ID
|
|
240
|
+
*/
|
|
241
|
+
generateSessionId() {
|
|
242
|
+
return `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Get session status
|
|
246
|
+
*/
|
|
247
|
+
getSessionStatus(sessionId) {
|
|
248
|
+
return this.sessions.get(sessionId) || null;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* List active sessions
|
|
252
|
+
*/
|
|
253
|
+
listActiveSessions() {
|
|
254
|
+
const activeSessions = Array.from(this.sessions.values())
|
|
255
|
+
.filter(s => s.status === "active");
|
|
256
|
+
if (activeSessions.length === 0) {
|
|
257
|
+
return "No active reasoning sessions.";
|
|
258
|
+
}
|
|
259
|
+
let output = `# Active Reasoning Sessions\n\n`;
|
|
260
|
+
activeSessions.forEach(session => {
|
|
261
|
+
output += `- **${session.id}**: ${session.objective} (Step ${session.currentStep}/${session.chain.steps.length})\n`;
|
|
262
|
+
});
|
|
263
|
+
return output;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Execute reasoning chain with session logging
|
|
267
|
+
*/
|
|
268
|
+
async executeWithLogging(session, verbose = false, saveSession = false) {
|
|
269
|
+
const config = { ...this.sessionConfig, verbose, saveSession };
|
|
270
|
+
// Start session logging
|
|
271
|
+
if (config.verbose || config.saveSession) {
|
|
272
|
+
// Update sessionLogger config to match the request config
|
|
273
|
+
sessionLogger.updateConfig({
|
|
274
|
+
saveSession: config.saveSession ?? true,
|
|
275
|
+
verbose: config.verbose ?? false
|
|
276
|
+
});
|
|
277
|
+
await sessionManager.startSession(session.chain.steps[0]?.mode || "reasoning", session.objective, config);
|
|
278
|
+
}
|
|
279
|
+
const modelContributions = new Map();
|
|
280
|
+
const insights = [];
|
|
281
|
+
const actionItems = [];
|
|
282
|
+
// Execute each step in the chain
|
|
283
|
+
for (let i = 0; i < session.chain.steps.length; i++) {
|
|
284
|
+
const step = session.chain.steps[i];
|
|
285
|
+
session.currentStep = i;
|
|
286
|
+
// Log step if verbose
|
|
287
|
+
if (config.verbose) {
|
|
288
|
+
console.error(`\n📍 Step ${i + 1}/${session.chain.steps.length}: ${step.mode}`);
|
|
289
|
+
console.error(`Model: ${step.model}`);
|
|
290
|
+
}
|
|
291
|
+
// Execute real tool instead of simulation
|
|
292
|
+
const response = await this.executeRealTool(step.model, step.prompt, step.mode);
|
|
293
|
+
// Log to session
|
|
294
|
+
if (config.verbose || config.saveSession) {
|
|
295
|
+
await sessionLogger.logStep(step.model, this.getProviderForModel(step.model), step.mode, step.prompt, response, { stepNumber: i + 1 });
|
|
296
|
+
}
|
|
297
|
+
// Store response
|
|
298
|
+
session.responses.push({
|
|
299
|
+
model: step.model,
|
|
300
|
+
content: response,
|
|
301
|
+
reasoning: `Mode: ${step.mode}`
|
|
302
|
+
});
|
|
303
|
+
// Track contributions
|
|
304
|
+
const contributions = modelContributions.get(step.model) || [];
|
|
305
|
+
contributions.push(response);
|
|
306
|
+
modelContributions.set(step.model, contributions);
|
|
307
|
+
}
|
|
308
|
+
// Generate synthesis
|
|
309
|
+
const finalSynthesis = this.generateSynthesis(session.responses);
|
|
310
|
+
// Log synthesis
|
|
311
|
+
if (config.verbose || config.saveSession) {
|
|
312
|
+
await sessionLogger.addSynthesis(finalSynthesis);
|
|
313
|
+
await sessionManager.endSession(config.saveSession);
|
|
314
|
+
}
|
|
315
|
+
session.status = "completed";
|
|
316
|
+
return {
|
|
317
|
+
session,
|
|
318
|
+
finalSynthesis,
|
|
319
|
+
modelContributions,
|
|
320
|
+
consensusScore: this.calculateConsensus(session.responses),
|
|
321
|
+
insights,
|
|
322
|
+
actionItems
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Execute real tool based on model and reasoning mode
|
|
327
|
+
* Phase 4: Delegates to ToolExecutionService (extracted 842 lines!)
|
|
328
|
+
*/
|
|
329
|
+
async executeRealTool(model, prompt, mode, context) {
|
|
330
|
+
// Update service with current settings
|
|
331
|
+
this.toolExecutionService.setVerbose(this.sessionConfig.verbose || false);
|
|
332
|
+
// Delegate to tool execution service
|
|
333
|
+
return await this.toolExecutionService.executeRealTool(model, prompt, mode, context);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Set memory context for the session
|
|
337
|
+
*/
|
|
338
|
+
setMemoryContext(context) {
|
|
339
|
+
if (this.memoryManager) {
|
|
340
|
+
this.memoryManager.setContext(context);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Get memory metrics
|
|
345
|
+
*/
|
|
346
|
+
async getMemoryMetrics() {
|
|
347
|
+
if (!this.memoryManager)
|
|
348
|
+
return null;
|
|
349
|
+
return await this.memoryManager.getMetrics();
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Get provider name for a model
|
|
353
|
+
*/
|
|
354
|
+
getProviderForModel(model) {
|
|
355
|
+
if (model.startsWith('gpt'))
|
|
356
|
+
return 'openai';
|
|
357
|
+
if (model.startsWith('claude'))
|
|
358
|
+
return 'anthropic';
|
|
359
|
+
if (model.startsWith('gemini'))
|
|
360
|
+
return 'google';
|
|
361
|
+
if (model.startsWith('grok'))
|
|
362
|
+
return 'xai';
|
|
363
|
+
if (model.startsWith('kimi'))
|
|
364
|
+
return 'moonshot';
|
|
365
|
+
if (model.includes('perplexity'))
|
|
366
|
+
return 'perplexity';
|
|
367
|
+
return 'unknown';
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Generate synthesis from model responses
|
|
371
|
+
*/
|
|
372
|
+
generateSynthesis(responses) {
|
|
373
|
+
if (responses.length === 0)
|
|
374
|
+
return '';
|
|
375
|
+
// Simple synthesis - combine all responses
|
|
376
|
+
const combined = responses.map((r, i) => `### ${i + 1}. ${r.model}\n\n${r.content}`).join('\n\n---\n\n');
|
|
377
|
+
return `# Synthesis of ${responses.length} Model Responses\n\n${combined}`;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Calculate consensus score from responses
|
|
381
|
+
*/
|
|
382
|
+
calculateConsensus(responses) {
|
|
383
|
+
if (responses.length < 2)
|
|
384
|
+
return 1.0;
|
|
385
|
+
// Simple consensus score based on response similarity
|
|
386
|
+
// For now, return a fixed score - can be enhanced later
|
|
387
|
+
return 0.85;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
// Export singleton instance
|
|
391
|
+
export const collaborativeOrchestrator = new CollaborativeOrchestrator();
|