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,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sequential Thinking Implementation
|
|
3
|
+
* Based on the official MCP Sequential Thinking server
|
|
4
|
+
* Enhanced with multi-model orchestration capabilities
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
export class SequentialThinking {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.sessions = new Map();
|
|
10
|
+
this.currentSessionId = null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Start a new sequential thinking session
|
|
14
|
+
*/
|
|
15
|
+
startSession(objective, estimatedThoughts = 5) {
|
|
16
|
+
const sessionId = this.generateSessionId();
|
|
17
|
+
const session = {
|
|
18
|
+
id: sessionId,
|
|
19
|
+
thoughts: [],
|
|
20
|
+
currentThought: 0,
|
|
21
|
+
totalThoughts: estimatedThoughts,
|
|
22
|
+
status: "active",
|
|
23
|
+
objective
|
|
24
|
+
};
|
|
25
|
+
this.sessions.set(sessionId, session);
|
|
26
|
+
this.currentSessionId = sessionId;
|
|
27
|
+
return sessionId;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Add a next thought to the session
|
|
31
|
+
*/
|
|
32
|
+
nextThought(thought, nextThoughtNeeded, thoughtNumber, totalThoughts, isRevision, revisesThought, branchFromThought, model) {
|
|
33
|
+
const session = this.getCurrentSession();
|
|
34
|
+
if (!session) {
|
|
35
|
+
throw new Error("No active thinking session");
|
|
36
|
+
}
|
|
37
|
+
// Handle branching
|
|
38
|
+
if (branchFromThought !== undefined) {
|
|
39
|
+
return this.branchThinking(session, thought, branchFromThought, model);
|
|
40
|
+
}
|
|
41
|
+
// Create the thought object
|
|
42
|
+
const newThought = {
|
|
43
|
+
number: thoughtNumber || session.currentThought + 1,
|
|
44
|
+
content: thought,
|
|
45
|
+
model: model || "default",
|
|
46
|
+
timestamp: new Date(),
|
|
47
|
+
isRevision,
|
|
48
|
+
revisesThought
|
|
49
|
+
};
|
|
50
|
+
// Handle revision
|
|
51
|
+
if (isRevision && revisesThought !== undefined) {
|
|
52
|
+
// Mark the original thought as revised
|
|
53
|
+
const originalThought = session.thoughts.find(t => t.number === revisesThought);
|
|
54
|
+
if (originalThought) {
|
|
55
|
+
originalThought.metadata = {
|
|
56
|
+
...originalThought.metadata,
|
|
57
|
+
revisedBy: newThought.number
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Add the thought
|
|
62
|
+
session.thoughts.push(newThought);
|
|
63
|
+
session.currentThought = newThought.number;
|
|
64
|
+
// Update total thoughts if provided
|
|
65
|
+
if (totalThoughts !== undefined) {
|
|
66
|
+
session.totalThoughts = totalThoughts;
|
|
67
|
+
}
|
|
68
|
+
// Check if we're done
|
|
69
|
+
if (!nextThoughtNeeded) {
|
|
70
|
+
session.status = "completed";
|
|
71
|
+
}
|
|
72
|
+
// Generate guidance for next step
|
|
73
|
+
const guidance = this.generateGuidance(session, nextThoughtNeeded);
|
|
74
|
+
return {
|
|
75
|
+
thoughtAdded: newThought,
|
|
76
|
+
sessionStatus: session,
|
|
77
|
+
guidance
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Branch the thinking into an alternative path
|
|
82
|
+
*/
|
|
83
|
+
branchThinking(session, thought, branchFromThought, model) {
|
|
84
|
+
// Create a new branch session
|
|
85
|
+
const branchId = `${session.id}_branch_${Date.now()}`;
|
|
86
|
+
// Copy thoughts up to branch point
|
|
87
|
+
const branchSession = {
|
|
88
|
+
id: branchId,
|
|
89
|
+
thoughts: session.thoughts
|
|
90
|
+
.filter(t => t.number <= branchFromThought)
|
|
91
|
+
.map(t => ({ ...t })),
|
|
92
|
+
currentThought: branchFromThought,
|
|
93
|
+
totalThoughts: session.totalThoughts,
|
|
94
|
+
status: "active",
|
|
95
|
+
objective: session.objective,
|
|
96
|
+
context: `Branch from thought ${branchFromThought}`
|
|
97
|
+
};
|
|
98
|
+
// Add the new branching thought
|
|
99
|
+
const newThought = {
|
|
100
|
+
number: branchFromThought + 1,
|
|
101
|
+
content: thought,
|
|
102
|
+
model: model || "default",
|
|
103
|
+
timestamp: new Date(),
|
|
104
|
+
branchFromThought
|
|
105
|
+
};
|
|
106
|
+
branchSession.thoughts.push(newThought);
|
|
107
|
+
branchSession.currentThought = newThought.number;
|
|
108
|
+
// Store the branch
|
|
109
|
+
if (!session.branches) {
|
|
110
|
+
session.branches = [];
|
|
111
|
+
}
|
|
112
|
+
session.branches.push(branchSession);
|
|
113
|
+
this.sessions.set(branchId, branchSession);
|
|
114
|
+
return {
|
|
115
|
+
thoughtAdded: newThought,
|
|
116
|
+
sessionStatus: branchSession,
|
|
117
|
+
guidance: `Branched from thought ${branchFromThought}. New branch ID: ${branchId}`
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Generate guidance for the next thinking step
|
|
122
|
+
*/
|
|
123
|
+
generateGuidance(session, continueThinking) {
|
|
124
|
+
if (!continueThinking) {
|
|
125
|
+
return this.generateSummary(session);
|
|
126
|
+
}
|
|
127
|
+
const progress = (session.currentThought / session.totalThoughts) * 100;
|
|
128
|
+
const thoughtsSoFar = session.thoughts.length;
|
|
129
|
+
let guidance = `## Thinking Progress: ${progress.toFixed(0)}%\n\n`;
|
|
130
|
+
guidance += `Thoughts completed: ${thoughtsSoFar}/${session.totalThoughts}\n\n`;
|
|
131
|
+
// Suggest next steps based on progress
|
|
132
|
+
if (progress < 30) {
|
|
133
|
+
guidance += "🔍 **Early Stage**: Focus on understanding and decomposing the problem.\n";
|
|
134
|
+
guidance += "Consider: What are the key components? What constraints exist?\n";
|
|
135
|
+
}
|
|
136
|
+
else if (progress < 60) {
|
|
137
|
+
guidance += "🔧 **Middle Stage**: Explore solutions and alternatives.\n";
|
|
138
|
+
guidance += "Consider: What approaches could work? What are the trade-offs?\n";
|
|
139
|
+
guidance += "You may want to branch to explore alternatives.\n";
|
|
140
|
+
}
|
|
141
|
+
else if (progress < 90) {
|
|
142
|
+
guidance += "🎯 **Late Stage**: Refine and validate your approach.\n";
|
|
143
|
+
guidance += "Consider: Are there edge cases? Can we optimize further?\n";
|
|
144
|
+
guidance += "You may want to revise earlier thoughts with new insights.\n";
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
guidance += "✨ **Final Stage**: Synthesize and conclude.\n";
|
|
148
|
+
guidance += "Consider: What's the final solution? What are the next steps?\n";
|
|
149
|
+
}
|
|
150
|
+
// Check if revision might be helpful
|
|
151
|
+
if (thoughtsSoFar > 3 && !session.thoughts.some(t => t.isRevision)) {
|
|
152
|
+
guidance += "\n💡 **Tip**: Consider revising earlier thoughts if new insights emerged.\n";
|
|
153
|
+
}
|
|
154
|
+
return guidance;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Generate a summary of the thinking session
|
|
158
|
+
*/
|
|
159
|
+
generateSummary(session) {
|
|
160
|
+
let summary = `## 🎯 Thinking Session Complete\n\n`;
|
|
161
|
+
summary += `**Objective**: ${session.objective || "Not specified"}\n`;
|
|
162
|
+
summary += `**Total Thoughts**: ${session.thoughts.length}\n`;
|
|
163
|
+
// Count revisions and branches
|
|
164
|
+
const revisions = session.thoughts.filter(t => t.isRevision).length;
|
|
165
|
+
const branches = session.branches?.length || 0;
|
|
166
|
+
if (revisions > 0) {
|
|
167
|
+
summary += `**Revisions Made**: ${revisions}\n`;
|
|
168
|
+
}
|
|
169
|
+
if (branches > 0) {
|
|
170
|
+
summary += `**Alternative Branches**: ${branches}\n`;
|
|
171
|
+
}
|
|
172
|
+
summary += `\n### Thought Progression:\n\n`;
|
|
173
|
+
// Group thoughts by model if multi-model
|
|
174
|
+
const modelGroups = new Map();
|
|
175
|
+
session.thoughts.forEach(thought => {
|
|
176
|
+
const model = thought.model || "default";
|
|
177
|
+
if (!modelGroups.has(model)) {
|
|
178
|
+
modelGroups.set(model, []);
|
|
179
|
+
}
|
|
180
|
+
modelGroups.get(model).push(thought);
|
|
181
|
+
});
|
|
182
|
+
if (modelGroups.size > 1) {
|
|
183
|
+
summary += "**Multi-Model Contributions**:\n";
|
|
184
|
+
modelGroups.forEach((thoughts, model) => {
|
|
185
|
+
summary += `- ${model}: ${thoughts.length} thoughts\n`;
|
|
186
|
+
});
|
|
187
|
+
summary += "\n";
|
|
188
|
+
}
|
|
189
|
+
// Key thoughts
|
|
190
|
+
summary += "### Key Insights:\n\n";
|
|
191
|
+
// First thought (problem understanding)
|
|
192
|
+
if (session.thoughts[0]) {
|
|
193
|
+
summary += `1. **Initial Understanding** (Thought 1):\n ${session.thoughts[0].content.substring(0, 200)}...\n\n`;
|
|
194
|
+
}
|
|
195
|
+
// Middle insight (if exists)
|
|
196
|
+
const middleIdx = Math.floor(session.thoughts.length / 2);
|
|
197
|
+
if (session.thoughts[middleIdx] && session.thoughts.length > 2) {
|
|
198
|
+
summary += `2. **Mid-Process Insight** (Thought ${middleIdx + 1}):\n ${session.thoughts[middleIdx].content.substring(0, 200)}...\n\n`;
|
|
199
|
+
}
|
|
200
|
+
// Final conclusion
|
|
201
|
+
const lastThought = session.thoughts[session.thoughts.length - 1];
|
|
202
|
+
if (lastThought) {
|
|
203
|
+
summary += `3. **Final Conclusion** (Thought ${lastThought.number}):\n ${lastThought.content.substring(0, 300)}...\n\n`;
|
|
204
|
+
}
|
|
205
|
+
// Branches summary
|
|
206
|
+
if (session.branches && session.branches.length > 0) {
|
|
207
|
+
summary += "### Alternative Paths Explored:\n";
|
|
208
|
+
session.branches.forEach((branch, idx) => {
|
|
209
|
+
summary += `- Branch ${idx + 1}: ${branch.context || "Alternative approach"}\n`;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return summary;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get current session
|
|
216
|
+
*/
|
|
217
|
+
getCurrentSession() {
|
|
218
|
+
if (!this.currentSessionId)
|
|
219
|
+
return null;
|
|
220
|
+
return this.sessions.get(this.currentSessionId) || null;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* List all sessions
|
|
224
|
+
*/
|
|
225
|
+
listSessions() {
|
|
226
|
+
const all = Array.from(this.sessions.values());
|
|
227
|
+
return {
|
|
228
|
+
active: all.filter(s => s.status === "active"),
|
|
229
|
+
completed: all.filter(s => s.status === "completed")
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Generate session ID
|
|
234
|
+
*/
|
|
235
|
+
generateSessionId() {
|
|
236
|
+
return `think_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Create multi-model thinking chain
|
|
240
|
+
*/
|
|
241
|
+
createMultiModelChain(objective, models) {
|
|
242
|
+
const sessionId = this.startSession(objective, models.length);
|
|
243
|
+
let plan = `## Multi-Model Sequential Thinking Plan\n\n`;
|
|
244
|
+
plan += `**Objective**: ${objective}\n`;
|
|
245
|
+
plan += `**Models**: ${models.join(" → ")}\n\n`;
|
|
246
|
+
plan += `### Execution Steps:\n\n`;
|
|
247
|
+
models.forEach((model, idx) => {
|
|
248
|
+
const stage = this.getStageDescription(idx, models.length);
|
|
249
|
+
plan += `${idx + 1}. **${model}**: ${stage}\n`;
|
|
250
|
+
});
|
|
251
|
+
plan += `\n### How to Execute:\n`;
|
|
252
|
+
plan += `Use \`nextThought\` with each model in sequence.\n`;
|
|
253
|
+
plan += `Each model builds on previous thoughts.\n`;
|
|
254
|
+
plan += `Revise or branch as insights emerge.\n`;
|
|
255
|
+
return { sessionId, plan };
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Get stage description based on position
|
|
259
|
+
*/
|
|
260
|
+
getStageDescription(index, total) {
|
|
261
|
+
const position = index / total;
|
|
262
|
+
if (position === 0) {
|
|
263
|
+
return "Initial analysis and problem decomposition";
|
|
264
|
+
}
|
|
265
|
+
else if (position < 0.3) {
|
|
266
|
+
return "Explore approaches and identify constraints";
|
|
267
|
+
}
|
|
268
|
+
else if (position < 0.6) {
|
|
269
|
+
return "Develop and evaluate solutions";
|
|
270
|
+
}
|
|
271
|
+
else if (position < 0.8) {
|
|
272
|
+
return "Refine and optimize approach";
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
return "Synthesize insights and finalize solution";
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// Export singleton instance
|
|
280
|
+
export const sequentialThinking = new SequentialThinking();
|
|
281
|
+
// Schema for tool parameters
|
|
282
|
+
export const NextThoughtSchema = z.object({
|
|
283
|
+
thought: z.string(),
|
|
284
|
+
nextThoughtNeeded: z.boolean(),
|
|
285
|
+
thoughtNumber: z.number().optional(),
|
|
286
|
+
totalThoughts: z.number().optional(),
|
|
287
|
+
isRevision: z.boolean().optional(),
|
|
288
|
+
revisesThought: z.number().optional(),
|
|
289
|
+
branchFromThought: z.number().optional(),
|
|
290
|
+
model: z.string().optional()
|
|
291
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// IMMEDIATE DIAGNOSTIC - Log before ANY imports or operations
|
|
3
|
+
console.error("🔴 DIAGNOSTIC: Script started at", new Date().toISOString());
|
|
4
|
+
console.error("🔴 DIAGNOSTIC: Process info:", {
|
|
5
|
+
pid: process.pid,
|
|
6
|
+
cwd: process.cwd(),
|
|
7
|
+
argv: process.argv,
|
|
8
|
+
nodeVersion: process.version,
|
|
9
|
+
platform: process.platform
|
|
10
|
+
});
|
|
11
|
+
// Keep alive IMMEDIATELY
|
|
12
|
+
process.stdin.resume();
|
|
13
|
+
const keepAlive = setInterval(() => { }, 2147483647); // Max 32-bit int
|
|
14
|
+
console.error("🔴 DIAGNOSTIC: Keepalive set");
|
|
15
|
+
// Now try imports
|
|
16
|
+
console.error("🔴 DIAGNOSTIC: Starting imports...");
|
|
17
|
+
(async () => {
|
|
18
|
+
try {
|
|
19
|
+
// Test if we can even import
|
|
20
|
+
const { FastMCP } = await import("fastmcp");
|
|
21
|
+
const { z } = await import("zod");
|
|
22
|
+
console.error("🔴 DIAGNOSTIC: FastMCP imported successfully");
|
|
23
|
+
const server = new FastMCP({
|
|
24
|
+
name: "tachibot-mcp",
|
|
25
|
+
version: "2.0.0"
|
|
26
|
+
});
|
|
27
|
+
console.error("🔴 DIAGNOSTIC: FastMCP instance created");
|
|
28
|
+
// Add a simple tool
|
|
29
|
+
server.addTool({
|
|
30
|
+
name: "diagnostic_test",
|
|
31
|
+
description: "Test diagnostic tool",
|
|
32
|
+
parameters: z.object({
|
|
33
|
+
message: z.string()
|
|
34
|
+
}),
|
|
35
|
+
execute: async (args) => {
|
|
36
|
+
console.error("🔴 DIAGNOSTIC: Tool executed with:", args);
|
|
37
|
+
return `Diagnostic response: ${args.message}`;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
console.error("🔴 DIAGNOSTIC: Tool added");
|
|
41
|
+
// Start server
|
|
42
|
+
console.error("🔴 DIAGNOSTIC: Starting server...");
|
|
43
|
+
server.start({
|
|
44
|
+
transportType: "stdio"
|
|
45
|
+
});
|
|
46
|
+
console.error("🔴 DIAGNOSTIC: Server.start() called");
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error("🔴 DIAGNOSTIC ERROR:", error);
|
|
50
|
+
console.error("🔴 DIAGNOSTIC: Keeping process alive despite error");
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
53
|
+
// Add multiple safety nets
|
|
54
|
+
process.on('SIGINT', () => {
|
|
55
|
+
console.error('🔴 DIAGNOSTIC: SIGINT received');
|
|
56
|
+
clearInterval(keepAlive);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
});
|
|
59
|
+
process.on('SIGTERM', () => {
|
|
60
|
+
console.error('🔴 DIAGNOSTIC: SIGTERM received');
|
|
61
|
+
clearInterval(keepAlive);
|
|
62
|
+
process.exit(0);
|
|
63
|
+
});
|
|
64
|
+
process.on('uncaughtException', (error) => {
|
|
65
|
+
console.error('🔴 DIAGNOSTIC: Uncaught Exception:', error);
|
|
66
|
+
});
|
|
67
|
+
process.on('unhandledRejection', (reason) => {
|
|
68
|
+
console.error('🔴 DIAGNOSTIC: Unhandled Rejection:', reason);
|
|
69
|
+
});
|
|
70
|
+
process.on('exit', (code) => {
|
|
71
|
+
console.error('🔴 DIAGNOSTIC: Process exiting with code:', code);
|
|
72
|
+
});
|
|
73
|
+
console.error("🔴 DIAGNOSTIC: All handlers set, process should stay alive");
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// IMMEDIATE LOG - Before ANY code execution
|
|
3
|
+
process.stderr.write("🔥 RAW MCP: Process started PID=" + process.pid + "\n");
|
|
4
|
+
// RAW MCP Server - No FastMCP dependency
|
|
5
|
+
console.error("🟢 RAW MCP: Starting at", new Date().toISOString());
|
|
6
|
+
// Keep process alive
|
|
7
|
+
process.stdin.resume();
|
|
8
|
+
setInterval(() => {
|
|
9
|
+
console.error("🟢 RAW MCP: Heartbeat", new Date().toISOString());
|
|
10
|
+
}, 30000);
|
|
11
|
+
console.error("🟢 RAW MCP: Setting up readline for JSON-RPC");
|
|
12
|
+
import * as readline from 'readline';
|
|
13
|
+
const rl = readline.createInterface({
|
|
14
|
+
input: process.stdin,
|
|
15
|
+
output: process.stdout,
|
|
16
|
+
terminal: false
|
|
17
|
+
});
|
|
18
|
+
// Server capabilities
|
|
19
|
+
const serverInfo = {
|
|
20
|
+
name: "tachibot-mcp",
|
|
21
|
+
version: "2.0.0"
|
|
22
|
+
};
|
|
23
|
+
const tools = {
|
|
24
|
+
test: {
|
|
25
|
+
description: "Test tool",
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
message: { type: "string" }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
think: {
|
|
34
|
+
description: "Log a thought",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
thought: { type: "string" }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Send JSON-RPC response
|
|
44
|
+
function sendResponse(id, result) {
|
|
45
|
+
const response = {
|
|
46
|
+
jsonrpc: "2.0",
|
|
47
|
+
id: id,
|
|
48
|
+
result: result
|
|
49
|
+
};
|
|
50
|
+
console.log(JSON.stringify(response));
|
|
51
|
+
console.error("🟢 RAW MCP: Sent response for id", id);
|
|
52
|
+
}
|
|
53
|
+
// Send JSON-RPC error
|
|
54
|
+
function sendError(id, code, message) {
|
|
55
|
+
const response = {
|
|
56
|
+
jsonrpc: "2.0",
|
|
57
|
+
id: id,
|
|
58
|
+
error: {
|
|
59
|
+
code: code,
|
|
60
|
+
message: message
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
console.log(JSON.stringify(response));
|
|
64
|
+
console.error("🟢 RAW MCP: Sent error for id", id);
|
|
65
|
+
}
|
|
66
|
+
// Handle JSON-RPC requests
|
|
67
|
+
rl.on('line', (line) => {
|
|
68
|
+
console.error("🟢 RAW MCP: Received line:", line.substring(0, 100) + "...");
|
|
69
|
+
try {
|
|
70
|
+
const request = JSON.parse(line);
|
|
71
|
+
console.error("🟢 RAW MCP: Parsed request method:", request.method);
|
|
72
|
+
if (request.method === "initialize") {
|
|
73
|
+
console.error("🟢 RAW MCP: Handling initialize");
|
|
74
|
+
// Match the client's protocol version
|
|
75
|
+
const clientVersion = request.params?.protocolVersion || "2024-11-05";
|
|
76
|
+
console.error("🟢 RAW MCP: Client protocol version:", clientVersion);
|
|
77
|
+
sendResponse(request.id, {
|
|
78
|
+
protocolVersion: clientVersion, // Echo back client's version
|
|
79
|
+
capabilities: {
|
|
80
|
+
tools: {}
|
|
81
|
+
},
|
|
82
|
+
serverInfo: serverInfo
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else if (request.method === "initialized") {
|
|
86
|
+
console.error("🟢 RAW MCP: Client initialized");
|
|
87
|
+
// No response needed for notification
|
|
88
|
+
}
|
|
89
|
+
else if (request.method === "tools/list") {
|
|
90
|
+
console.error("🟢 RAW MCP: Listing tools");
|
|
91
|
+
sendResponse(request.id, {
|
|
92
|
+
tools: Object.entries(tools).map(([name, tool]) => ({
|
|
93
|
+
name: name,
|
|
94
|
+
description: tool.description,
|
|
95
|
+
inputSchema: tool.inputSchema
|
|
96
|
+
}))
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else if (request.method === "tools/call") {
|
|
100
|
+
console.error("🟢 RAW MCP: Tool call:", request.params?.name);
|
|
101
|
+
const toolName = request.params?.name;
|
|
102
|
+
const args = request.params?.arguments || {};
|
|
103
|
+
if (toolName === "test") {
|
|
104
|
+
sendResponse(request.id, {
|
|
105
|
+
content: [{
|
|
106
|
+
type: "text",
|
|
107
|
+
text: `Test response: ${args.message || "no message"}`
|
|
108
|
+
}]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else if (toolName === "think") {
|
|
112
|
+
console.error("🟢 RAW MCP: Think:", args.thought);
|
|
113
|
+
sendResponse(request.id, {
|
|
114
|
+
content: [{
|
|
115
|
+
type: "text",
|
|
116
|
+
text: `Thought recorded: ${args.thought || "no thought"}`
|
|
117
|
+
}]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
sendError(request.id, -32601, `Unknown tool: ${toolName}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.error("🟢 RAW MCP: Unknown method:", request.method);
|
|
126
|
+
sendError(request.id, -32601, `Method not found: ${request.method}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
console.error("🟢 RAW MCP: Error processing request:", error);
|
|
131
|
+
// Try to send error response if we can parse the id
|
|
132
|
+
try {
|
|
133
|
+
const partial = JSON.parse(line);
|
|
134
|
+
if (partial.id) {
|
|
135
|
+
sendError(partial.id, -32700, "Parse error");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Can't even parse id, ignore
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
// Handle errors and signals
|
|
144
|
+
process.on('SIGINT', () => {
|
|
145
|
+
console.error('🟢 RAW MCP: SIGINT received');
|
|
146
|
+
process.exit(0);
|
|
147
|
+
});
|
|
148
|
+
process.on('SIGTERM', () => {
|
|
149
|
+
console.error('🟢 RAW MCP: SIGTERM received');
|
|
150
|
+
process.exit(0);
|
|
151
|
+
});
|
|
152
|
+
process.on('uncaughtException', (error) => {
|
|
153
|
+
console.error('🟢 RAW MCP: Uncaught Exception:', error);
|
|
154
|
+
});
|
|
155
|
+
process.on('unhandledRejection', (reason) => {
|
|
156
|
+
console.error('🟢 RAW MCP: Unhandled Rejection:', reason);
|
|
157
|
+
});
|
|
158
|
+
console.error("🟢 RAW MCP: Server ready and listening");
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Simplified server with guaranteed keepalive
|
|
3
|
+
import { FastMCP } from "fastmcp";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
// CRITICAL: Keep the process alive FIRST
|
|
6
|
+
process.stdin.resume();
|
|
7
|
+
setInterval(() => { }, 1 << 30); // Keepalive forever
|
|
8
|
+
// Log to stderr only
|
|
9
|
+
const log = (...args) => console.error(...args);
|
|
10
|
+
log("🚀 TachiBot MCP Server (Simplified) Starting...");
|
|
11
|
+
const server = new FastMCP({
|
|
12
|
+
name: "tachibot-mcp",
|
|
13
|
+
version: "2.0.0"
|
|
14
|
+
});
|
|
15
|
+
// Add minimal test tools
|
|
16
|
+
server.addTool({
|
|
17
|
+
name: "think",
|
|
18
|
+
description: "Log a thought",
|
|
19
|
+
parameters: z.object({
|
|
20
|
+
thought: z.string()
|
|
21
|
+
}),
|
|
22
|
+
execute: async (args) => {
|
|
23
|
+
log("Think:", args.thought);
|
|
24
|
+
return `Thought recorded: ${args.thought}`;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
server.addTool({
|
|
28
|
+
name: "test",
|
|
29
|
+
description: "Test tool",
|
|
30
|
+
parameters: z.object({
|
|
31
|
+
message: z.string()
|
|
32
|
+
}),
|
|
33
|
+
execute: async (args) => {
|
|
34
|
+
return `Test response: ${args.message}`;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
// Start server
|
|
38
|
+
log("Starting FastMCP server...");
|
|
39
|
+
server.start({
|
|
40
|
+
transportType: "stdio"
|
|
41
|
+
});
|
|
42
|
+
log("✅ Server started and will stay alive");
|
|
43
|
+
// Handle signals
|
|
44
|
+
process.on('SIGINT', () => {
|
|
45
|
+
log('Received SIGINT, shutting down...');
|
|
46
|
+
process.exit(0);
|
|
47
|
+
});
|
|
48
|
+
process.on('SIGTERM', () => {
|
|
49
|
+
log('Received SIGTERM, shutting down...');
|
|
50
|
+
process.exit(0);
|
|
51
|
+
});
|
|
52
|
+
// Log any errors but don't crash
|
|
53
|
+
process.on('uncaughtException', (error) => {
|
|
54
|
+
log('Uncaught Exception:', error);
|
|
55
|
+
});
|
|
56
|
+
process.on('unhandledRejection', (reason) => {
|
|
57
|
+
log('Unhandled Rejection:', reason);
|
|
58
|
+
});
|