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,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Mapper - Maps workflow tool names to actual MCP tool implementations
|
|
3
|
+
* Enables workflows to call real tools instead of returning placeholders
|
|
4
|
+
*/
|
|
5
|
+
import { callGemini, GeminiModel } from "../tools/gemini-tools.js";
|
|
6
|
+
import { getAllPerplexityTools } from "../tools/perplexity-tools.js";
|
|
7
|
+
import { callOpenAI } from "../tools/openai-tools.js";
|
|
8
|
+
import { callGrok, GrokModel } from "../tools/grok-tools.js";
|
|
9
|
+
import { GPT5_MODELS, TOOL_DEFAULTS, } from "../config/model-constants.js";
|
|
10
|
+
import { validateToolInput } from "../utils/input-validator.js";
|
|
11
|
+
// Lazy load OpenRouter for Qwen models
|
|
12
|
+
let callOpenRouter = null;
|
|
13
|
+
let OpenRouterModel = null;
|
|
14
|
+
try {
|
|
15
|
+
const openRouterModule = await import("../tools/openrouter-tools.js");
|
|
16
|
+
callOpenRouter = openRouterModule.callOpenRouter;
|
|
17
|
+
OpenRouterModel = openRouterModule.OpenRouterModel;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// OpenRouter not available
|
|
21
|
+
}
|
|
22
|
+
// Import modes if available
|
|
23
|
+
let Verifier = null, Challenger = null, Scout = null, Auditor = null, CommitGuardian = null, Architect = null;
|
|
24
|
+
// Hunter removed - was non-functional stub implementation
|
|
25
|
+
try {
|
|
26
|
+
({ Verifier } = await import("../modes/verifier.js"));
|
|
27
|
+
}
|
|
28
|
+
catch { }
|
|
29
|
+
try {
|
|
30
|
+
({ Challenger } = await import("../modes/challenger.js"));
|
|
31
|
+
}
|
|
32
|
+
catch { }
|
|
33
|
+
try {
|
|
34
|
+
({ Scout } = await import("../modes/scout.js"));
|
|
35
|
+
}
|
|
36
|
+
catch { }
|
|
37
|
+
try {
|
|
38
|
+
({ Auditor } = await import("../modes/auditor.js"));
|
|
39
|
+
}
|
|
40
|
+
catch { }
|
|
41
|
+
try {
|
|
42
|
+
({ CommitGuardian } = await import("../modes/commit-guardian.js"));
|
|
43
|
+
}
|
|
44
|
+
catch { }
|
|
45
|
+
try {
|
|
46
|
+
({ Architect } = await import("../modes/architect.js"));
|
|
47
|
+
}
|
|
48
|
+
catch { }
|
|
49
|
+
/**
|
|
50
|
+
* Main tool execution function - routes to appropriate implementation
|
|
51
|
+
* Returns both the result and the actual model used
|
|
52
|
+
*/
|
|
53
|
+
export async function executeWorkflowTool(toolName, input, options = {}) {
|
|
54
|
+
console.error(`\n📥 [tool-mapper] Executing tool: ${toolName}`);
|
|
55
|
+
console.error(`📥 Input type: ${typeof input}`);
|
|
56
|
+
if (typeof input === 'object') {
|
|
57
|
+
console.error(`📥 Input keys: ${Object.keys(input).join(', ')}`);
|
|
58
|
+
console.error(`📥 Input values preview:`);
|
|
59
|
+
for (const [key, value] of Object.entries(input)) {
|
|
60
|
+
const preview = typeof value === 'string' ? value.substring(0, 100) : JSON.stringify(value);
|
|
61
|
+
console.error(` - ${key}: ${preview}...`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.error(`📥 Input value: ${String(input).substring(0, 100)}...`);
|
|
66
|
+
}
|
|
67
|
+
// ============================================
|
|
68
|
+
// UNIVERSAL INPUT NORMALIZATION
|
|
69
|
+
// Support ANY parameter name for maximum DX
|
|
70
|
+
// ============================================
|
|
71
|
+
// Extract a universal "main content" from common parameter names
|
|
72
|
+
// Priority order: most specific → most generic
|
|
73
|
+
const extractMainContent = () => {
|
|
74
|
+
if (typeof input === "string")
|
|
75
|
+
return input;
|
|
76
|
+
// Try all common parameter names (order matters!)
|
|
77
|
+
return input.requirements || // qwen_coder, task-specific
|
|
78
|
+
input.problem || // brainstorm, reasoning tools
|
|
79
|
+
input.query || // search/ask tools
|
|
80
|
+
input.topic || // research tools
|
|
81
|
+
input.prompt || // generic prompt
|
|
82
|
+
input.text || // text analysis
|
|
83
|
+
input.code || // code analysis
|
|
84
|
+
input.context || // context-based tools
|
|
85
|
+
input.content || // generic content
|
|
86
|
+
input.message || // generic message
|
|
87
|
+
input.instruction || // generic instruction
|
|
88
|
+
input.previousStep || // workflow chaining
|
|
89
|
+
"";
|
|
90
|
+
};
|
|
91
|
+
let prompt = extractMainContent();
|
|
92
|
+
console.error(`📥 Extracted main content: ${prompt.length} chars`);
|
|
93
|
+
if (prompt.length > 0) {
|
|
94
|
+
console.error(`📥 Preview: "${prompt.substring(0, 200)}..."`);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
console.error(`⚠️ WARNING: No content extracted from input!`);
|
|
98
|
+
if (typeof input === 'object') {
|
|
99
|
+
console.error(` Available input keys: ${Object.keys(input).join(', ')}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Validate and sanitize input (skip for internal workflow calls)
|
|
103
|
+
console.error(`🔒 Validation check: skipValidation=${options.skipValidation}, options=${JSON.stringify(options)}`);
|
|
104
|
+
if (options.skipValidation === true) {
|
|
105
|
+
console.error(`⏭️ ✅ SKIPPING VALIDATION (internal workflow call)`);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
console.error(`🔍 Running validation on prompt (length: ${prompt.length})`);
|
|
109
|
+
const validation = validateToolInput(prompt);
|
|
110
|
+
console.error(`🔍 Validation result: valid=${validation.valid}, error=${validation.error}`);
|
|
111
|
+
if (!validation.valid) {
|
|
112
|
+
console.error(`❌ Validation failed: ${validation.error}`);
|
|
113
|
+
console.error(`❌ Failed prompt length: ${prompt.length}`);
|
|
114
|
+
console.error(`❌ Failed prompt preview: "${prompt.substring(0, 500)}..."`);
|
|
115
|
+
return { result: `[Error: ${validation.error}]`, modelUsed: "error" };
|
|
116
|
+
}
|
|
117
|
+
prompt = validation.sanitized;
|
|
118
|
+
}
|
|
119
|
+
// Get defaults for this specific tool, fallback to generic defaults
|
|
120
|
+
const toolDefaults = TOOL_DEFAULTS[toolName] || {
|
|
121
|
+
maxTokens: 2000,
|
|
122
|
+
temperature: 0.7,
|
|
123
|
+
};
|
|
124
|
+
const { model = toolDefaults.model || "gpt-5-mini", maxTokens = options.maxTokens ?? toolDefaults.maxTokens ?? 2000, temperature = options.temperature ?? toolDefaults.temperature ?? 0.7, systemPrompt, } = options;
|
|
125
|
+
// Helper to convert to messages array format
|
|
126
|
+
const toMessages = (text, system) => {
|
|
127
|
+
const messages = [];
|
|
128
|
+
if (system) {
|
|
129
|
+
messages.push({ role: "system", content: system });
|
|
130
|
+
}
|
|
131
|
+
messages.push({ role: "user", content: text });
|
|
132
|
+
return messages;
|
|
133
|
+
};
|
|
134
|
+
// Helper to build result with model metadata
|
|
135
|
+
const buildResult = (result, actualModel) => {
|
|
136
|
+
return { result, modelUsed: actualModel };
|
|
137
|
+
};
|
|
138
|
+
try {
|
|
139
|
+
let actualModel = model; // Track the actual model used
|
|
140
|
+
// Route to appropriate tool based on name
|
|
141
|
+
switch (toolName) {
|
|
142
|
+
// ============ GEMINI TOOLS ============
|
|
143
|
+
case "gemini_query":
|
|
144
|
+
case "gemini_brainstorm":
|
|
145
|
+
case "gemini_analyze_code":
|
|
146
|
+
case "gemini_analyze_text":
|
|
147
|
+
actualModel = model === "flash" ? GeminiModel.FLASH : GeminiModel.PRO;
|
|
148
|
+
return buildResult(await callGemini(prompt, actualModel, systemPrompt, temperature, options.skipValidation || false), actualModel);
|
|
149
|
+
// ============ PERPLEXITY TOOLS ============
|
|
150
|
+
case "perplexity_ask":
|
|
151
|
+
case "perplexity_code_search":
|
|
152
|
+
case "perplexity_reason":
|
|
153
|
+
case "perplexity_research":
|
|
154
|
+
// Delegate to registered MCP tool implementations to ensure consistent behavior
|
|
155
|
+
const perplexityTools = getAllPerplexityTools();
|
|
156
|
+
const perplexityTool = perplexityTools.find(t => t.name === toolName);
|
|
157
|
+
if (!perplexityTool) {
|
|
158
|
+
return buildResult(`[Perplexity tool ${toolName} not available. Check PERPLEXITY_API_KEY]`, "error");
|
|
159
|
+
}
|
|
160
|
+
// Build args based on tool type
|
|
161
|
+
let perplexityArgs;
|
|
162
|
+
if (toolName === "perplexity_ask") {
|
|
163
|
+
perplexityArgs = { query: prompt, searchRecency: "month" };
|
|
164
|
+
}
|
|
165
|
+
else if (toolName === "perplexity_code_search") {
|
|
166
|
+
perplexityArgs = { query: prompt };
|
|
167
|
+
}
|
|
168
|
+
else if (toolName === "perplexity_reason") {
|
|
169
|
+
perplexityArgs = { problem: prompt };
|
|
170
|
+
}
|
|
171
|
+
else if (toolName === "perplexity_research") {
|
|
172
|
+
// Handle structured input for perplexity_research
|
|
173
|
+
let topic;
|
|
174
|
+
let questions;
|
|
175
|
+
let depth = "standard";
|
|
176
|
+
if (typeof input === 'object' && input.topic) {
|
|
177
|
+
topic = input.topic;
|
|
178
|
+
questions = input.questions;
|
|
179
|
+
depth = input.depth || "standard";
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
topic = prompt || "General research";
|
|
183
|
+
}
|
|
184
|
+
perplexityArgs = { topic, questions, depth };
|
|
185
|
+
}
|
|
186
|
+
const perplexityResult = await perplexityTool.execute(perplexityArgs, { log: console.error });
|
|
187
|
+
return buildResult(perplexityResult, "perplexity-sonar-pro");
|
|
188
|
+
// ============ QWEN TOOLS (via OpenRouter) ============
|
|
189
|
+
case "qwen_coder":
|
|
190
|
+
case "qwq_reason":
|
|
191
|
+
if (!callOpenRouter) {
|
|
192
|
+
return buildResult("[Qwen tools require OpenRouter API key. Add OPENROUTER_API_KEY to .env]", "error");
|
|
193
|
+
}
|
|
194
|
+
const qwenModel = toolName === "qwq_reason"
|
|
195
|
+
? OpenRouterModel.QWQ_32B
|
|
196
|
+
: OpenRouterModel.QWEN3_CODER;
|
|
197
|
+
return buildResult(await callOpenRouter(toMessages(prompt, systemPrompt), qwenModel, temperature, maxTokens), qwenModel);
|
|
198
|
+
// ============ KIMI TOOLS (via OpenRouter) ============
|
|
199
|
+
case "kimi_thinking":
|
|
200
|
+
if (!callOpenRouter) {
|
|
201
|
+
return buildResult("[Kimi tools require OpenRouter API key. Add OPENROUTER_API_KEY to .env]", "error");
|
|
202
|
+
}
|
|
203
|
+
const kimiModel = OpenRouterModel.KIMI_K2_THINKING;
|
|
204
|
+
return buildResult(await callOpenRouter(toMessages(prompt, systemPrompt), kimiModel, temperature, maxTokens), kimiModel);
|
|
205
|
+
// ============ OPENAI TOOLS ============
|
|
206
|
+
case "openai_brainstorm":
|
|
207
|
+
case "openai_analyze":
|
|
208
|
+
actualModel = model || "gpt-5";
|
|
209
|
+
return buildResult(await callOpenAI(toMessages(prompt, systemPrompt), actualModel, temperature, maxTokens, false, // requireConfirmation
|
|
210
|
+
options.skipValidation || false), actualModel);
|
|
211
|
+
case "gpt5_analyze":
|
|
212
|
+
return buildResult(await callOpenAI(toMessages(prompt, systemPrompt), "gpt-5-mini", 0.7, maxTokens), "gpt-5-mini");
|
|
213
|
+
case "openai_reason":
|
|
214
|
+
return buildResult(await callOpenAI(toMessages(prompt, systemPrompt), "gpt-5-mini", temperature, maxTokens), "gpt-5-mini");
|
|
215
|
+
// ============ GPT-5 TOOLS ============
|
|
216
|
+
case "gpt5":
|
|
217
|
+
case "gpt5_mini":
|
|
218
|
+
case "gpt5_nano":
|
|
219
|
+
const gpt5Model = toolName === "gpt5_nano"
|
|
220
|
+
? GPT5_MODELS.NANO
|
|
221
|
+
: toolName === "gpt5_mini"
|
|
222
|
+
? GPT5_MODELS.MINI
|
|
223
|
+
: GPT5_MODELS.FULL;
|
|
224
|
+
// GPT-5 models only support temperature=1.0
|
|
225
|
+
return buildResult(await callOpenAI(toMessages(prompt, systemPrompt), gpt5Model, 1.0, // Fixed temperature for GPT-5
|
|
226
|
+
maxTokens), gpt5Model);
|
|
227
|
+
// ============ GROK TOOLS ============
|
|
228
|
+
case "grok":
|
|
229
|
+
case "grok_reason":
|
|
230
|
+
case "grok_code":
|
|
231
|
+
case "grok_debug":
|
|
232
|
+
case "grok_brainstorm":
|
|
233
|
+
case "grok_heavy": // Grok Heavy is just grok-4-0709 with more backend resources
|
|
234
|
+
case "grok_search":
|
|
235
|
+
actualModel = GrokModel.GROK_4_FAST_REASONING; // Using fast reasoning (2M context, $0.20/$0.50)
|
|
236
|
+
return buildResult(await callGrok(toMessages(prompt, systemPrompt), actualModel, temperature, maxTokens), actualModel);
|
|
237
|
+
// ============ ADVANCED MODES ============
|
|
238
|
+
case "verifier":
|
|
239
|
+
if (Verifier) {
|
|
240
|
+
const verifier = new Verifier();
|
|
241
|
+
// Pass model, variant, and other options from workflow input
|
|
242
|
+
const verifyOptions = { maxTokens };
|
|
243
|
+
if (typeof input === 'object') {
|
|
244
|
+
if (input.model)
|
|
245
|
+
verifyOptions.model = input.model;
|
|
246
|
+
if (input.variant)
|
|
247
|
+
verifyOptions.variant = input.variant;
|
|
248
|
+
if (input.timeout)
|
|
249
|
+
verifyOptions.timeout = input.timeout;
|
|
250
|
+
}
|
|
251
|
+
const result = await verifier.verify(prompt, verifyOptions);
|
|
252
|
+
// Return synthesis property instead of JSON.stringify
|
|
253
|
+
return buildResult(result.synthesis || JSON.stringify(result, null, 2), "verifier-multi-model");
|
|
254
|
+
}
|
|
255
|
+
return buildResult(`[Verifier mode not available]`, "error");
|
|
256
|
+
case "challenger":
|
|
257
|
+
if (Challenger) {
|
|
258
|
+
const challenger = new Challenger();
|
|
259
|
+
// Pass model and other options from workflow input
|
|
260
|
+
const challengeOptions = { maxTokens };
|
|
261
|
+
if (typeof input === 'object') {
|
|
262
|
+
if (input.model)
|
|
263
|
+
challengeOptions.model = input.model;
|
|
264
|
+
if (input.thoroughness)
|
|
265
|
+
challengeOptions.thoroughness = input.thoroughness;
|
|
266
|
+
if (input.temperature)
|
|
267
|
+
challengeOptions.temperature = input.temperature;
|
|
268
|
+
}
|
|
269
|
+
const result = await challenger.challenge(prompt, challengeOptions);
|
|
270
|
+
// Return synthesis property instead of JSON.stringify
|
|
271
|
+
return buildResult(result.synthesis || JSON.stringify(result, null, 2), "challenger-multi-model");
|
|
272
|
+
}
|
|
273
|
+
return buildResult(`[Challenger mode not available]`, "error");
|
|
274
|
+
case "scout":
|
|
275
|
+
if (Scout) {
|
|
276
|
+
const scout = new Scout();
|
|
277
|
+
// Pass model and other options from workflow input
|
|
278
|
+
const scoutOptions = { maxTokens };
|
|
279
|
+
if (typeof input === 'object') {
|
|
280
|
+
if (input.model)
|
|
281
|
+
scoutOptions.model = input.model;
|
|
282
|
+
if (input.depth)
|
|
283
|
+
scoutOptions.depth = input.depth;
|
|
284
|
+
if (input.includeSources)
|
|
285
|
+
scoutOptions.includeSources = input.includeSources;
|
|
286
|
+
}
|
|
287
|
+
const result = await scout.scout(prompt, scoutOptions);
|
|
288
|
+
// Return synthesis property instead of JSON.stringify
|
|
289
|
+
return buildResult(result.synthesis || JSON.stringify(result, null, 2), "scout-perplexity");
|
|
290
|
+
}
|
|
291
|
+
return buildResult(`[Scout mode not available]`, "error");
|
|
292
|
+
case "auditor":
|
|
293
|
+
if (Auditor) {
|
|
294
|
+
const auditor = new Auditor();
|
|
295
|
+
// Pass options from workflow input
|
|
296
|
+
const auditOptions = { maxTokens };
|
|
297
|
+
if (typeof input === 'object') {
|
|
298
|
+
if (input.evidenceRequired !== undefined)
|
|
299
|
+
auditOptions.evidenceRequired = input.evidenceRequired;
|
|
300
|
+
}
|
|
301
|
+
const result = await auditor.audit(prompt, auditOptions);
|
|
302
|
+
// Return synthesis property instead of JSON.stringify
|
|
303
|
+
return buildResult(result.synthesis || JSON.stringify(result, null, 2), "auditor-multi-model");
|
|
304
|
+
}
|
|
305
|
+
return buildResult(`[Auditor mode not available]`, "error");
|
|
306
|
+
case "commit_guardian":
|
|
307
|
+
if (CommitGuardian) {
|
|
308
|
+
const guardian = new CommitGuardian();
|
|
309
|
+
// Pass options from workflow input
|
|
310
|
+
const guardianOptions = { maxTokens };
|
|
311
|
+
if (typeof input === 'object') {
|
|
312
|
+
if (input.strict !== undefined)
|
|
313
|
+
guardianOptions.strict = input.strict;
|
|
314
|
+
if (input.checkSecurity !== undefined)
|
|
315
|
+
guardianOptions.checkSecurity = input.checkSecurity;
|
|
316
|
+
if (input.checkQuality !== undefined)
|
|
317
|
+
guardianOptions.checkQuality = input.checkQuality;
|
|
318
|
+
if (input.checkTests !== undefined)
|
|
319
|
+
guardianOptions.checkTests = input.checkTests;
|
|
320
|
+
}
|
|
321
|
+
const result = await guardian.validate(prompt, guardianOptions);
|
|
322
|
+
// Return summary property instead of JSON.stringify
|
|
323
|
+
return buildResult(result.summary || JSON.stringify(result, null, 2), "commit-guardian");
|
|
324
|
+
}
|
|
325
|
+
return buildResult(`[CommitGuardian mode not available]`, "error");
|
|
326
|
+
case "architect":
|
|
327
|
+
if (Architect) {
|
|
328
|
+
const architect = new Architect();
|
|
329
|
+
// Pass options from workflow input
|
|
330
|
+
const architectOptions = { maxTokens };
|
|
331
|
+
if (typeof input === 'object') {
|
|
332
|
+
if (input.path)
|
|
333
|
+
architectOptions.path = input.path;
|
|
334
|
+
if (input.depth)
|
|
335
|
+
architectOptions.depth = input.depth;
|
|
336
|
+
if (input.focusAreas)
|
|
337
|
+
architectOptions.focusAreas = input.focusAreas;
|
|
338
|
+
}
|
|
339
|
+
const result = await architect.analyze(prompt, architectOptions);
|
|
340
|
+
// Return synthesis property instead of JSON.stringify
|
|
341
|
+
return buildResult(result.synthesis || JSON.stringify(result, null, 2), "architect-multi-model");
|
|
342
|
+
}
|
|
343
|
+
return buildResult(`[Architect mode not available]`, "error");
|
|
344
|
+
// ============ META TOOLS ============
|
|
345
|
+
case "think":
|
|
346
|
+
// Simple reflection tool - uses GPT-5-mini for cost efficiency
|
|
347
|
+
return buildResult(await callOpenAI(toMessages(`Reflect on the following and provide brief insights:\n\n${prompt}`, "You are a reflective thinking assistant. Provide concise, insightful analysis."), "gpt-5-mini", 0.7, 500), "gpt-5-mini");
|
|
348
|
+
case "focus":
|
|
349
|
+
// Deep analysis tool - uses GPT-5
|
|
350
|
+
return buildResult(await callOpenAI(toMessages(`Perform deep analysis and synthesis:\n\n${prompt}`, "You are an advanced analytical assistant. Provide comprehensive, synthesized insights."), "gpt-5", 0.8, maxTokens), "gpt-5");
|
|
351
|
+
case "code_reviewer":
|
|
352
|
+
return buildResult(await callOpenAI(toMessages(`Perform thorough code review:\n\n${prompt}`, "You are an expert code reviewer. Analyze for bugs, security issues, performance, and best practices."), "gpt-5", 0.5, maxTokens), "gpt-5");
|
|
353
|
+
case "test_architect":
|
|
354
|
+
return buildResult(await callOpenAI(toMessages(`Design comprehensive tests:\n\n${prompt}`, "You are a testing expert. Design thorough test suites with edge cases."), "gpt-5", 0.6, maxTokens), "gpt-5");
|
|
355
|
+
case "documentation_writer":
|
|
356
|
+
return buildResult(await callOpenAI(toMessages(`Create clear documentation:\n\n${prompt}`, "You are a technical writer. Create clear, comprehensive documentation."), "gpt-5-mini", 0.7, maxTokens), "gpt-5-mini");
|
|
357
|
+
// ============ DEFAULT ============
|
|
358
|
+
default:
|
|
359
|
+
console.warn(`⚠️ Unknown tool: ${toolName}, falling back to GPT-5-mini`);
|
|
360
|
+
return buildResult(await callOpenAI(toMessages(prompt), "gpt-5-mini", temperature, maxTokens), "gpt-5-mini");
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
365
|
+
console.error(`❌ Tool execution error for ${toolName}:`, errorMsg);
|
|
366
|
+
return buildResult(`[Error executing ${toolName}: ${errorMsg}]`, "error");
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Get list of available tools based on API keys
|
|
371
|
+
*/
|
|
372
|
+
export function getAvailableTools() {
|
|
373
|
+
const tools = [
|
|
374
|
+
"think",
|
|
375
|
+
"focus",
|
|
376
|
+
"code_reviewer",
|
|
377
|
+
"test_architect",
|
|
378
|
+
"documentation_writer",
|
|
379
|
+
];
|
|
380
|
+
// Check API keys
|
|
381
|
+
if (process.env.GOOGLE_API_KEY) {
|
|
382
|
+
tools.push("gemini_query", "gemini_brainstorm", "gemini_analyze_code");
|
|
383
|
+
}
|
|
384
|
+
if (process.env.PERPLEXITY_API_KEY) {
|
|
385
|
+
tools.push("perplexity_ask", "perplexity_research", "perplexity_reason", "perplexity_code_search");
|
|
386
|
+
}
|
|
387
|
+
if (process.env.OPENAI_API_KEY) {
|
|
388
|
+
tools.push("openai_brainstorm", "gpt5_analyze", "openai_reason", "gpt5", "gpt5_mini", "gpt5_nano");
|
|
389
|
+
}
|
|
390
|
+
if (process.env.XAI_API_KEY) {
|
|
391
|
+
tools.push("grok", "grok_reason", "grok_code", "grok_debug", "grok_brainstorm", "grok_search");
|
|
392
|
+
}
|
|
393
|
+
// Add modes if available
|
|
394
|
+
if (Verifier)
|
|
395
|
+
tools.push("verifier");
|
|
396
|
+
if (Challenger)
|
|
397
|
+
tools.push("challenger");
|
|
398
|
+
if (Scout)
|
|
399
|
+
tools.push("scout");
|
|
400
|
+
if (Auditor)
|
|
401
|
+
tools.push("auditor");
|
|
402
|
+
if (CommitGuardian)
|
|
403
|
+
tools.push("commit_guardian");
|
|
404
|
+
if (Architect)
|
|
405
|
+
tools.push("architect");
|
|
406
|
+
return tools;
|
|
407
|
+
}
|