@gotza02/seq-thinking 1.1.3 β 1.1.4
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/README.md +61 -130
- package/data/agents/1770117726716-lrnm415.json +68 -0
- package/data/agents/1770117726719-w6hsf3v.json +58 -0
- package/data/sessions/1770117726720-frcwj99.json +150 -0
- package/dist/agents/meta-reasoning-agent.d.ts +1 -1
- package/dist/agents/meta-reasoning-agent.d.ts.map +1 -1
- package/dist/agents/meta-reasoning-agent.js +7 -6
- package/dist/agents/meta-reasoning-agent.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp-server.js +1 -1
- package/package.json +1 -1
- package/src/agents/meta-reasoning-agent.ts +8 -7
- package/src/index.ts +1 -1
- package/src/mcp-server.ts +1 -1
package/README.md
CHANGED
|
@@ -1,73 +1,21 @@
|
|
|
1
1
|
# MCP Sequential Thinking with Swarm Coordination
|
|
2
2
|
|
|
3
|
-
[](https://github.com/yourusername/mcp-sequential-thinking)
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
|
|
7
|
-
Advanced Sequential Thinking MCP
|
|
7
|
+
**Advanced Sequential Thinking MCP Server** with integrated Swarm Intelligence. This tool empowers your AI environment with structured reasoning, self-correction, and a coordinated team of specialized agents, leveraging your existing local LLM CLI tools.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## π Key Features
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
* **π§ Advanced Sequential Thinking**: Supports branching, merging, and pruning of thought paths.
|
|
12
|
+
* **π€ Swarm Intelligence**: Coordinates specialized agents (**Reasoner**, **Critic**, **Synthesizer**, **Meta-Reasoner**) to solve complex problems.
|
|
13
|
+
* **π BYO-LLM (Bring Your Own LLM)**: Connects directly to **Gemini**, **Claude**, **Kimi**, and **OpenCode** via their CLI toolsβno extra API keys required if you're already logged in.
|
|
14
|
+
* **π Auto-Fallback & Robustness**: Automatically switches providers if one fails (e.g., `gemini` -> `claude`). Includes retry logic for resilient task execution.
|
|
15
|
+
* **πΎ Persistence**: Automatically saves sessions and agent states to disk (`./data/`), allowing you to resume complex reasoning tasks anytime.
|
|
16
|
+
* **π Self-Correction**: Proactively detects logical fallacies and confidence dips, triggering corrective actions.
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
- **Self-Correction Loops**: Automatically detect and fix reasoning errors.
|
|
15
|
-
- **Parallel Hypothesis Generation**: Explore multiple reasoning paths simultaneously.
|
|
16
|
-
- **Meta-Reasoning**: Reflect on and improve the thinking process.
|
|
17
|
-
- **Adaptive Granularity**: Adjust detail level based on problem complexity.
|
|
18
|
-
- **Persistence Layer**: All thinking sessions and agent states are saved to disk.
|
|
19
|
-
- **Swarm Agent Coordination**: Multiple specialized agents working together with retry logic.
|
|
20
|
-
|
|
21
|
-
## AI System Instructions
|
|
22
|
-
|
|
23
|
-
This project includes a [SYSTEM_INSTRUCTIONS.md](./SYSTEM_INSTRUCTIONS.md) file specifically designed to guide AI models on how to use these tools effectively. It covers initialization, branching, and swarm delegation strategies.
|
|
24
|
-
|
|
25
|
-
## Architecture
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
29
|
-
β MCP TOOL INTERFACE β
|
|
30
|
-
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
|
|
31
|
-
β β Sequential β β Swarm β β Tool Registry β β
|
|
32
|
-
β β Thinking β β Coordinationβ β β β
|
|
33
|
-
β ββββββββ¬βββββββ ββββββββ¬βββββββ βββββββββββββββββββββββββββ β
|
|
34
|
-
βββββββββββΌβββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
|
|
35
|
-
β β
|
|
36
|
-
βββββββββββΌβββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
|
|
37
|
-
β β ORCHESTRATION ENGINE β
|
|
38
|
-
β ββββββββ΄βββββββ ββββββββββββββββ ββββββββββββββββββββββββ β
|
|
39
|
-
β βState Managerβ β Flow Control β β Scheduler β β
|
|
40
|
-
β β(Persistence)β β (Retry Logic)β β β β
|
|
41
|
-
β ββββββββ΄βββββββ ββββββββββββββββ ββββββββββββββββββββββββ β
|
|
42
|
-
βββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
43
|
-
β
|
|
44
|
-
βββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
45
|
-
β β SWARM AGENT COORDINATOR β
|
|
46
|
-
β ββββββββ΄βββββββ βββββββββββββββ ββββββββββββββββββββββββ β
|
|
47
|
-
β β Reasoner β β Critic β β Synthesizer β β
|
|
48
|
-
β β Agents β β Agents β β Agents β β
|
|
49
|
-
β ββββββββ¬βββββββ ββββββββ¬βββββββ βββββββββββββ¬βββββββββββ β
|
|
50
|
-
βββββββββββΌβββββββββββββββββΌββββββββββββββββββββββΌβββββββββββββββββ
|
|
51
|
-
β β β
|
|
52
|
-
βββββββββββ΄βββββββββββββββββ΄ββββββββββββββββββββββ΄βββββββββββββββββ
|
|
53
|
-
β LLM ADAPTER (CLI BRIDGE) β
|
|
54
|
-
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
|
|
55
|
-
β β Gemini β β Claude β β Kimi β β OpenCode β β
|
|
56
|
-
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
|
|
57
|
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## LLM Providers (CLI Integration)
|
|
61
|
-
|
|
62
|
-
The system is designed to use LLMs that you have already logged into via your command line. This simplifies authentication and leverages your existing CLI tools.
|
|
63
|
-
|
|
64
|
-
Supported Providers:
|
|
65
|
-
- **gemini**: Uses `gemini ask "..."`
|
|
66
|
-
- **claude**: Uses `claude "..." --non-interactive` (Compatible with Claude Code)
|
|
67
|
-
- **kimi**: Uses `kimi chat "..."`
|
|
68
|
-
- **opencode**: Uses `opencode ask "..."`
|
|
69
|
-
|
|
70
|
-
## Installation
|
|
18
|
+
## π¦ Installation
|
|
71
19
|
|
|
72
20
|
```bash
|
|
73
21
|
# Clone the repository
|
|
@@ -81,18 +29,18 @@ npm install
|
|
|
81
29
|
npm run build
|
|
82
30
|
```
|
|
83
31
|
|
|
84
|
-
## Configuration
|
|
32
|
+
## βοΈ Configuration
|
|
85
33
|
|
|
86
|
-
Add this to your MCP
|
|
34
|
+
Add this configuration to your MCP client (e.g., `claude_desktop_config.json`, `gemini-cli.json`):
|
|
87
35
|
|
|
88
36
|
```json
|
|
89
37
|
{
|
|
90
38
|
"mcpServers": {
|
|
91
39
|
"advanced-thinking": {
|
|
92
40
|
"command": "node",
|
|
93
|
-
"args": ["/absolute/path/to/dist/mcp-server.js"],
|
|
41
|
+
"args": ["/absolute/path/to/mcp-sequential-thinking/dist/mcp-server.js"],
|
|
94
42
|
"env": {
|
|
95
|
-
"provider": "gemini",
|
|
43
|
+
"provider": "gemini,claude",
|
|
96
44
|
"MOCK_LLM": "false"
|
|
97
45
|
}
|
|
98
46
|
}
|
|
@@ -104,84 +52,67 @@ Add this to your MCP settings file (e.g., `claude_desktop_config.json`, `gemini-
|
|
|
104
52
|
|
|
105
53
|
| Variable | Description | Default | Example |
|
|
106
54
|
|----------|-------------|---------|---------|
|
|
107
|
-
| `provider` |
|
|
108
|
-
| `MOCK_LLM` | If `true`, returns mock
|
|
55
|
+
| `provider` | Comma-separated list of LLM CLIs to use. The system tries them in order. | `gemini` | `gemini,claude,kimi` |
|
|
56
|
+
| `MOCK_LLM` | If `true`, returns mock responses (for testing without API costs). | `false` | `true` |
|
|
109
57
|
|
|
110
|
-
|
|
58
|
+
**Supported CLI Tools:**
|
|
59
|
+
* **Gemini:** Requires `gemini` CLI installed and authenticated.
|
|
60
|
+
* **Claude:** Requires `claude` (Claude Code) CLI installed and authenticated.
|
|
61
|
+
* **Kimi:** Requires `kimi` CLI.
|
|
62
|
+
* **OpenCode:** Requires `opencode` CLI.
|
|
111
63
|
|
|
112
|
-
|
|
64
|
+
## π οΈ Usage
|
|
113
65
|
|
|
114
|
-
|
|
115
|
-
```json
|
|
116
|
-
"env": {
|
|
117
|
-
"provider": "gemini,claude,kimi"
|
|
118
|
-
}
|
|
119
|
-
```
|
|
66
|
+
This server provides two main tools to your AI client:
|
|
120
67
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
4. If `claude` fails, it tries `kimi`.
|
|
126
|
-
5. The first successful response is used.
|
|
68
|
+
### 1. `advanced_sequential_thinking`
|
|
69
|
+
The core thinking engine.
|
|
70
|
+
* **Operations:** `initialize`, `add_thought`, `branch_thought`, `self_correct`, `complete_session`, etc.
|
|
71
|
+
* **Use Case:** Deep, step-by-step problem solving with ability to backtrack.
|
|
127
72
|
|
|
128
|
-
###
|
|
73
|
+
### 2. `swarm_agent_coordination`
|
|
74
|
+
The workforce manager.
|
|
75
|
+
* **Operations:** `register_agent`, `assign_task`, `reach_consensus`, `resolve_conflict`.
|
|
76
|
+
* **Use Case:** Delegating sub-tasks to specialized "virtual experts" (e.g., asking a "Critic" agent to review a plan).
|
|
129
77
|
|
|
130
|
-
|
|
78
|
+
## π§ͺ Testing & Development
|
|
131
79
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
80
|
+
### Run Unit Tests
|
|
81
|
+
Verifies the logic of all components (Agents, Graph, Persistence).
|
|
82
|
+
```bash
|
|
83
|
+
# Run all tests using mock LLM data
|
|
84
|
+
export MOCK_LLM=true
|
|
85
|
+
npm test
|
|
139
86
|
```
|
|
140
87
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
Thinking sessions are automatically persisted to the `./data` directory.
|
|
144
|
-
- **Sessions**: Stored in `./data/sessions/`
|
|
145
|
-
- **Agents**: Stored in `./data/agents/`
|
|
146
|
-
|
|
147
|
-
This ensures that your reasoning state is preserved even if the MCP server restarts.
|
|
148
|
-
|
|
149
|
-
## Enhanced Swarm Logic
|
|
150
|
-
|
|
151
|
-
- **Automated Retries**: Tasks assigned to agents will automatically retry up to 3 times with exponential backoff on failure.
|
|
152
|
-
- **Intelligent Context**: When reaching consensus, agents receive current swarm statistics and history of previous votes to make more informed decisions.
|
|
153
|
-
- **Async Workflow**: All operations are non-blocking, ensuring the MCP server remains responsive during long reasoning tasks.
|
|
154
|
-
|
|
155
|
-
## API Documentation
|
|
156
|
-
|
|
157
|
-
*(Standard Sequential Thinking and Swarm Coordination operations are supported as documented in the internal tool definitions)*
|
|
158
|
-
|
|
159
|
-
## Testing
|
|
160
|
-
|
|
88
|
+
### Run Real-World Scenario
|
|
89
|
+
Simulates a full end-to-end workflow: creating a session, registering agents, delegating tasks, and self-correction.
|
|
161
90
|
```bash
|
|
162
|
-
# Run
|
|
91
|
+
# Run the E2E simulation
|
|
163
92
|
export MOCK_LLM=true
|
|
164
|
-
|
|
93
|
+
node dist/real_world_test.js
|
|
165
94
|
```
|
|
166
95
|
|
|
167
|
-
##
|
|
96
|
+
## ποΈ Architecture
|
|
168
97
|
|
|
169
|
-
|
|
98
|
+
The system is built on a modular architecture:
|
|
99
|
+
* **Orchestration Layer:** Manages state, flow control, and error handling.
|
|
100
|
+
* **Swarm Coordinator:** Assigns tasks based on agent capabilities and availability.
|
|
101
|
+
* **Thought Graph:** A directed acyclic graph (DAG) representing the reasoning process.
|
|
102
|
+
* **LLM Adapter:** A unified interface for communicating with various CLI-based models.
|
|
103
|
+
|
|
104
|
+
## π Changelog
|
|
170
105
|
|
|
171
|
-
|
|
106
|
+
### v1.1.4 (2026-02-03)
|
|
107
|
+
- **Fix:** Fixed a critical bug in `MetaReasoningAgent` that caused crashes when analyzing thoughts with missing confidence data.
|
|
108
|
+
- **Improvement:** Enhanced robustness of `overall` confidence calculation across all agents.
|
|
109
|
+
- **Doc:** Updated README with comprehensive usage and testing instructions.
|
|
172
110
|
|
|
173
111
|
### v1.1.3 (2026-02-03)
|
|
174
|
-
- **Feature
|
|
175
|
-
- **Feature
|
|
176
|
-
- **
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
- Added CLI-based LLM Adapters (Gemini, Claude, Kimi, OpenCode).
|
|
182
|
-
- Implemented Disk Persistence for sessions and agents.
|
|
183
|
-
- Added Task Retry logic in Swarm Coordinator.
|
|
184
|
-
- Updated all tests to support asynchronous operations.
|
|
185
|
-
|
|
186
|
-
### v1.0.0 (2025-02-03)
|
|
187
|
-
- Initial release with core swarm and sequential thinking logic.
|
|
112
|
+
- **Feature:** Multi-Provider Auto-Fallback.
|
|
113
|
+
- **Feature:** Dynamic Provider Selection per task.
|
|
114
|
+
- **Refactor:** Replaced console logs with structured `Logger`.
|
|
115
|
+
|
|
116
|
+
## π License
|
|
117
|
+
|
|
118
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"config": {
|
|
3
|
+
"id": "1770117726716-lrnm415",
|
|
4
|
+
"name": "LogicMaster",
|
|
5
|
+
"type": "reasoner",
|
|
6
|
+
"subtype": "chain_of_thought",
|
|
7
|
+
"capabilities": [
|
|
8
|
+
{
|
|
9
|
+
"name": "chain_of_thought",
|
|
10
|
+
"description": "Step-by-step reasoning",
|
|
11
|
+
"confidence": 0.9,
|
|
12
|
+
"performanceMetrics": {
|
|
13
|
+
"tasksCompleted": 0,
|
|
14
|
+
"averageQuality": 0,
|
|
15
|
+
"averageTimeMs": 0
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "tree_of_thought",
|
|
20
|
+
"description": "Explore multiple reasoning paths",
|
|
21
|
+
"confidence": 0.85,
|
|
22
|
+
"performanceMetrics": {
|
|
23
|
+
"tasksCompleted": 0,
|
|
24
|
+
"averageQuality": 0,
|
|
25
|
+
"averageTimeMs": 0
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "analogical_reasoning",
|
|
30
|
+
"description": "Reason by analogy",
|
|
31
|
+
"confidence": 0.8,
|
|
32
|
+
"performanceMetrics": {
|
|
33
|
+
"tasksCompleted": 0,
|
|
34
|
+
"averageQuality": 0,
|
|
35
|
+
"averageTimeMs": 0
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "abductive_reasoning",
|
|
40
|
+
"description": "Inference to best explanation",
|
|
41
|
+
"confidence": 0.75,
|
|
42
|
+
"performanceMetrics": {
|
|
43
|
+
"tasksCompleted": 0,
|
|
44
|
+
"averageQuality": 0,
|
|
45
|
+
"averageTimeMs": 0
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "problem_solving",
|
|
50
|
+
"description": "General problem-solving",
|
|
51
|
+
"confidence": 0.8,
|
|
52
|
+
"performanceMetrics": {
|
|
53
|
+
"tasksCompleted": 0,
|
|
54
|
+
"averageQuality": 0,
|
|
55
|
+
"averageTimeMs": 0
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"maxConcurrentTasks": 3,
|
|
60
|
+
"confidenceThreshold": 0.7,
|
|
61
|
+
"metadata": {
|
|
62
|
+
"createdAt": "2026-02-03T11:22:06.716Z",
|
|
63
|
+
"version": "1.0.0",
|
|
64
|
+
"config": {}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"performanceHistory": []
|
|
68
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"config": {
|
|
3
|
+
"id": "1770117726719-w6hsf3v",
|
|
4
|
+
"name": "SafetyCheck",
|
|
5
|
+
"type": "critic",
|
|
6
|
+
"subtype": "safety",
|
|
7
|
+
"capabilities": [
|
|
8
|
+
{
|
|
9
|
+
"name": "evaluation",
|
|
10
|
+
"description": "Evaluate outputs from other agents",
|
|
11
|
+
"confidence": 0.85,
|
|
12
|
+
"performanceMetrics": {
|
|
13
|
+
"tasksCompleted": 0,
|
|
14
|
+
"averageQuality": 0,
|
|
15
|
+
"averageTimeMs": 0
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "validation",
|
|
20
|
+
"description": "Validate correctness and accuracy",
|
|
21
|
+
"confidence": 0.8,
|
|
22
|
+
"performanceMetrics": {
|
|
23
|
+
"tasksCompleted": 0,
|
|
24
|
+
"averageQuality": 0,
|
|
25
|
+
"averageTimeMs": 0
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "feedback",
|
|
30
|
+
"description": "Provide constructive feedback",
|
|
31
|
+
"confidence": 0.9,
|
|
32
|
+
"performanceMetrics": {
|
|
33
|
+
"tasksCompleted": 0,
|
|
34
|
+
"averageQuality": 0,
|
|
35
|
+
"averageTimeMs": 0
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "logical_analysis",
|
|
40
|
+
"description": "Analyze logical consistency",
|
|
41
|
+
"confidence": 0.85,
|
|
42
|
+
"performanceMetrics": {
|
|
43
|
+
"tasksCompleted": 0,
|
|
44
|
+
"averageQuality": 0,
|
|
45
|
+
"averageTimeMs": 0
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"maxConcurrentTasks": 5,
|
|
50
|
+
"confidenceThreshold": 0.7,
|
|
51
|
+
"metadata": {
|
|
52
|
+
"createdAt": "2026-02-03T11:22:06.719Z",
|
|
53
|
+
"version": "1.0.0",
|
|
54
|
+
"config": {}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"performanceHistory": []
|
|
58
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "1770117726720-frcwj99",
|
|
3
|
+
"topic": "Architecting a scalable microservices system",
|
|
4
|
+
"status": "completed",
|
|
5
|
+
"currentBranchId": "main",
|
|
6
|
+
"branches": {
|
|
7
|
+
"_type": "Map",
|
|
8
|
+
"data": [
|
|
9
|
+
[
|
|
10
|
+
"main",
|
|
11
|
+
{
|
|
12
|
+
"id": "main",
|
|
13
|
+
"sessionId": "1770117726720-frcwj99",
|
|
14
|
+
"name": "Main",
|
|
15
|
+
"description": "Primary reasoning path",
|
|
16
|
+
"rootThoughtId": "",
|
|
17
|
+
"thoughtIds": [],
|
|
18
|
+
"parentBranchId": null,
|
|
19
|
+
"childBranchIds": [],
|
|
20
|
+
"status": "active",
|
|
21
|
+
"confidence": 0.5,
|
|
22
|
+
"metadata": {
|
|
23
|
+
"createdAt": "2026-02-03T11:22:06.720Z"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"thoughts": {
|
|
30
|
+
"_type": "Map",
|
|
31
|
+
"data": [
|
|
32
|
+
[
|
|
33
|
+
"1770117726722-j28xiub",
|
|
34
|
+
{
|
|
35
|
+
"id": "1770117726722-j28xiub",
|
|
36
|
+
"sessionId": "1770117726720-frcwj99",
|
|
37
|
+
"content": "We need to break down the monolithic application into smaller services.",
|
|
38
|
+
"stepNumber": 1,
|
|
39
|
+
"thoughtType": "analysis",
|
|
40
|
+
"confidence": {
|
|
41
|
+
"overall": 0.8,
|
|
42
|
+
"components": {
|
|
43
|
+
"logicalConsistency": 0.5,
|
|
44
|
+
"factualAccuracy": 0.5,
|
|
45
|
+
"reasoningQuality": 0.5,
|
|
46
|
+
"evidenceStrength": 0.5
|
|
47
|
+
},
|
|
48
|
+
"uncertaintyBounds": [
|
|
49
|
+
0.3,
|
|
50
|
+
0.7
|
|
51
|
+
],
|
|
52
|
+
"calibrationHistory": []
|
|
53
|
+
},
|
|
54
|
+
"parentThoughtId": null,
|
|
55
|
+
"childThoughtIds": [
|
|
56
|
+
"1770117726726-hkgov5d"
|
|
57
|
+
],
|
|
58
|
+
"branchId": "main",
|
|
59
|
+
"revisionOf": null,
|
|
60
|
+
"revisionHistory": [],
|
|
61
|
+
"metadata": {
|
|
62
|
+
"createdAt": "2026-02-03T11:22:06.722Z",
|
|
63
|
+
"modifiedAt": "2026-02-03T11:22:06.722Z",
|
|
64
|
+
"processingTimeMs": 0,
|
|
65
|
+
"tokensUsed": 0
|
|
66
|
+
},
|
|
67
|
+
"tags": [],
|
|
68
|
+
"assumptions": [],
|
|
69
|
+
"dependencies": []
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
"1770117726726-hkgov5d",
|
|
74
|
+
{
|
|
75
|
+
"id": "1770117726726-hkgov5d",
|
|
76
|
+
"sessionId": "1770117726720-frcwj99",
|
|
77
|
+
"content": "{\n \"conclusion\": \"[MOCK RESPONSE from gemini] I have analyzed your request: Based on these reasoning steps, provide a final co...\",\n \"reasoningChain\": [\n {\n \"step\": 1,\n \"content\": \"[MOCK RESPONSE from gemini] I have analyzed your request: Based on the current context, generate the next re...\",\n \"confidence\": 0.63,\n \"isFinal\": false\n },\n {\n \"step\": 2,\n \"content\": \"[MOCK RESPONSE from gemini] I have analyzed your request: Based on the current context, generate the next re...\",\n \"confidence\": 0.66,\n \"isFinal\": false\n },\n {\n \"step\": 3,\n \"content\": \"[MOCK RESPONSE from gemini] I have analyzed your request: Based on the current context, generate the next re...\",\n \"confidence\": 0.69,\n \"isFinal\": false\n },\n {\n \"step\": 4,\n \"content\": \"[MOCK RESPONSE from gemini] I have analyzed your request: Based on the current context, generate the next re...\",\n \"confidence\": 0.72,\n \"isFinal\": true\n }\n ],\n \"iterations\": 4,\n \"strategy\": \"chain_of_thought\",\n \"problem\": \"[object Object]\"\n}",
|
|
78
|
+
"stepNumber": 2,
|
|
79
|
+
"thoughtType": "synthesis",
|
|
80
|
+
"confidence": {
|
|
81
|
+
"overall": 0.675,
|
|
82
|
+
"components": {
|
|
83
|
+
"logicalConsistency": 0.5,
|
|
84
|
+
"factualAccuracy": 0.5,
|
|
85
|
+
"reasoningQuality": 0.5,
|
|
86
|
+
"evidenceStrength": 0.5
|
|
87
|
+
},
|
|
88
|
+
"uncertaintyBounds": [
|
|
89
|
+
0.3,
|
|
90
|
+
0.7
|
|
91
|
+
],
|
|
92
|
+
"calibrationHistory": []
|
|
93
|
+
},
|
|
94
|
+
"parentThoughtId": "1770117726722-j28xiub",
|
|
95
|
+
"childThoughtIds": [],
|
|
96
|
+
"branchId": "main",
|
|
97
|
+
"revisionOf": null,
|
|
98
|
+
"revisionHistory": [],
|
|
99
|
+
"metadata": {
|
|
100
|
+
"createdAt": "2026-02-03T11:22:06.726Z",
|
|
101
|
+
"modifiedAt": "2026-02-03T11:22:06.726Z",
|
|
102
|
+
"processingTimeMs": 0,
|
|
103
|
+
"tokensUsed": 0
|
|
104
|
+
},
|
|
105
|
+
"tags": [
|
|
106
|
+
"swarm-result",
|
|
107
|
+
"LogicMaster"
|
|
108
|
+
],
|
|
109
|
+
"assumptions": [],
|
|
110
|
+
"dependencies": []
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
"metaNotes": {
|
|
116
|
+
"_type": "Map",
|
|
117
|
+
"data": []
|
|
118
|
+
},
|
|
119
|
+
"context": {
|
|
120
|
+
"originalProblem": "Architecting a scalable microservices system",
|
|
121
|
+
"constraints": [],
|
|
122
|
+
"relevantInformation": [],
|
|
123
|
+
"workingMemory": {
|
|
124
|
+
"_type": "Map",
|
|
125
|
+
"data": []
|
|
126
|
+
},
|
|
127
|
+
"longTermReferences": []
|
|
128
|
+
},
|
|
129
|
+
"settings": {
|
|
130
|
+
"maxBranches": 5,
|
|
131
|
+
"maxDepth": 20,
|
|
132
|
+
"confidenceThreshold": 0.6,
|
|
133
|
+
"enableSelfCorrection": true,
|
|
134
|
+
"enableMetaReasoning": true,
|
|
135
|
+
"enableParallelHypotheses": true,
|
|
136
|
+
"adaptiveGranularity": true,
|
|
137
|
+
"granularitySettings": {
|
|
138
|
+
"minStepDetail": 0.1,
|
|
139
|
+
"maxStepDetail": 1,
|
|
140
|
+
"complexityThreshold": 0.7
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"metadata": {
|
|
144
|
+
"createdAt": "2026-02-03T11:22:06.720Z",
|
|
145
|
+
"lastActivityAt": "2026-02-03T11:22:06.726Z",
|
|
146
|
+
"totalThoughts": 2,
|
|
147
|
+
"totalBranches": 1,
|
|
148
|
+
"completedAt": "2026-02-03T11:22:06.734Z"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -75,7 +75,7 @@ export declare class MetaReasoningAgent extends BaseAgent {
|
|
|
75
75
|
* @param thoughts - Thoughts to analyze
|
|
76
76
|
* @returns Variance
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
calculateConfidenceVariance(thoughts: Thought[]): number;
|
|
79
79
|
/**
|
|
80
80
|
* Generate meta-observation for a thought
|
|
81
81
|
* @param thought - Thought to analyze
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-reasoning-agent.d.ts","sourceRoot":"","sources":["../../src/agents/meta-reasoning-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,OAAO,EAEb,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,UAAU,eAAe;IACvB,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,0BAA0B;IAC1B,OAAO,CAAC,kBAAk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;KAClC;IAqCD;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,eAAe,IAAI,eAAe,EAAE;IAIpC;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IA+D9C;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAc3B;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAkC9B;;;;OAIG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,2BAA2B,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM;IAUxD;;;;OAIG;IACH,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI;IAiCjE;;;OAGG;IACH,qBAAqB,IAAI,eAAe,EAAE;CAG3C"}
|
|
@@ -78,7 +78,7 @@ export class MetaReasoningAgent extends BaseAgent {
|
|
|
78
78
|
let systemPrompt = 'You are a meta-reasoning agent. Your role is to analyze and reflect on the thinking processes of other agents or sessions, identifying patterns, biases, and areas for improvement.';
|
|
79
79
|
const sessionData = input.session ? `Session Topic: ${input.session.topic}\nSession Status: ${input.session.status}\n` : '';
|
|
80
80
|
const thoughtsData = (input.thoughts || (input.session ? Array.from(input.session.thoughts.values()) : []))
|
|
81
|
-
.map(t => `Step ${t.stepNumber} (${t.thoughtType}, Confidence: ${t.confidence
|
|
81
|
+
.map(t => `Step ${t.stepNumber} (${t.thoughtType}, Confidence: ${t.confidence?.overall ?? 'N/A'}):\n${t.content}`).join('\n\n');
|
|
82
82
|
switch (input.operation) {
|
|
83
83
|
case 'reflect':
|
|
84
84
|
prompt = `Perform a comprehensive reflection on this thinking session. What are the key insights? What has been achieved? What is still missing?\n\n${sessionData}${thoughtsData}`;
|
|
@@ -154,8 +154,8 @@ export class MetaReasoningAgent extends BaseAgent {
|
|
|
154
154
|
const sorted = [...thoughts].sort((a, b) => a.metadata.createdAt.getTime() - b.metadata.createdAt.getTime());
|
|
155
155
|
const firstThird = sorted.slice(0, Math.ceil(sorted.length / 3));
|
|
156
156
|
const lastThird = sorted.slice(-Math.ceil(sorted.length / 3));
|
|
157
|
-
const initial = firstThird.reduce((sum, t) => sum + t.confidence.
|
|
158
|
-
const final = lastThird.reduce((sum, t) => sum + t.confidence.
|
|
157
|
+
const initial = firstThird.reduce((sum, t) => sum + (t.confidence?.overall ?? 0.5), 0) / firstThird.length;
|
|
158
|
+
const final = lastThird.reduce((sum, t) => sum + (t.confidence?.overall ?? 0.5), 0) / lastThird.length;
|
|
159
159
|
const diff = final - initial;
|
|
160
160
|
const threshold = 0.1;
|
|
161
161
|
let trend;
|
|
@@ -191,7 +191,7 @@ export class MetaReasoningAgent extends BaseAgent {
|
|
|
191
191
|
calculateConfidenceVariance(thoughts) {
|
|
192
192
|
if (thoughts.length < 2)
|
|
193
193
|
return 0;
|
|
194
|
-
const values = thoughts.map(t => t.confidence.
|
|
194
|
+
const values = thoughts.map(t => t.confidence?.overall ?? 0.5);
|
|
195
195
|
const mean = values.reduce((a, b) => a + b, 0) / values.length;
|
|
196
196
|
const squaredDiffs = values.map(v => Math.pow(v - mean, 2));
|
|
197
197
|
return squaredDiffs.reduce((a, b) => a + b, 0) / values.length;
|
|
@@ -205,13 +205,14 @@ export class MetaReasoningAgent extends BaseAgent {
|
|
|
205
205
|
const observations = [];
|
|
206
206
|
const triggeredActions = [];
|
|
207
207
|
// Check for high uncertainty
|
|
208
|
-
const
|
|
208
|
+
const confidence = thought.confidence || { overall: 0.5, uncertaintyBounds: [0.3, 0.7] };
|
|
209
|
+
const uncertaintyRange = (confidence.uncertaintyBounds?.[1] ?? 0.7) - (confidence.uncertaintyBounds?.[0] ?? 0.3);
|
|
209
210
|
if (uncertaintyRange > 0.4) {
|
|
210
211
|
observations.push('High uncertainty detected');
|
|
211
212
|
triggeredActions.push('gather_more_evidence');
|
|
212
213
|
}
|
|
213
214
|
// Check for low confidence
|
|
214
|
-
if (
|
|
215
|
+
if (confidence.overall < 0.4) {
|
|
215
216
|
observations.push('Low confidence in this thought');
|
|
216
217
|
triggeredActions.push('review_reasoning');
|
|
217
218
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-reasoning-agent.js","sourceRoot":"","sources":["../../src/agents/meta-reasoning-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,SAAS,EAOV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAarD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,0BAA0B;IAClB,kBAAkB,GAAsB,EAAE,CAAC;IAEnD;;;OAGG;IACH,YAAY,MAGX;QACC,MAAM,mBAAmB,GAAsB;YAC7C;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,WAAW,EAAE,yCAAyC;gBACtD,UAAU,EAAE,IAAI;gBAChB,kBAAkB,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE;aAC/E;YACD;gBACE,IAAI,EAAE,qBAAqB;gBAC3B,WAAW,EAAE,uCAAuC;gBACpD,UAAU,EAAE,GAAG;gBACf,kBAAkB,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE;aAC/E;YACD;gBACE,IAAI,EAAE,gBAAgB;gBACtB,WAAW,EAAE,mCAAmC;gBAChD,UAAU,EAAE,IAAI;gBAChB,kBAAkB,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE;aAC/E;YACD;gBACE,IAAI,EAAE,kBAAkB;gBACxB,WAAW,EAAE,qCAAqC;gBAClD,UAAU,EAAE,GAAG;gB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AAO;YACL,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,gBAAgB;SACjB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,qBAAqB;QACnB,OAAO,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/mcp-server.js
CHANGED
|
@@ -96,7 +96,7 @@ export class MCPServer {
|
|
|
96
96
|
registeredAgents = new Map();
|
|
97
97
|
dataDir = './data';
|
|
98
98
|
constructor() {
|
|
99
|
-
this.server = new Server({ name: 'mcp-sequential-thinking', version: '1.
|
|
99
|
+
this.server = new Server({ name: 'mcp-sequential-thinking', version: '1.1.4' }, { capabilities: { tools: {} } });
|
|
100
100
|
this.sessionManager = new SessionManager(this.dataDir);
|
|
101
101
|
this.swarmCoordinator = new SwarmCoordinator(this.dataDir);
|
|
102
102
|
this.setupHandlers();
|
package/package.json
CHANGED
|
@@ -114,7 +114,7 @@ export class MetaReasoningAgent extends BaseAgent {
|
|
|
114
114
|
|
|
115
115
|
const sessionData = input.session ? `Session Topic: ${input.session.topic}\nSession Status: ${input.session.status}\n` : '';
|
|
116
116
|
const thoughtsData = (input.thoughts || (input.session ? Array.from(input.session.thoughts.values()) : []))
|
|
117
|
-
.map(t => `Step ${t.stepNumber} (${t.thoughtType}, Confidence: ${t.confidence
|
|
117
|
+
.map(t => `Step ${t.stepNumber} (${t.thoughtType}, Confidence: ${t.confidence?.overall ?? 'N/A'}):\n${t.content}`).join('\n\n');
|
|
118
118
|
|
|
119
119
|
switch (input.operation) {
|
|
120
120
|
case 'reflect':
|
|
@@ -217,8 +217,8 @@ export class MetaReasoningAgent extends BaseAgent {
|
|
|
217
217
|
const firstThird = sorted.slice(0, Math.ceil(sorted.length / 3));
|
|
218
218
|
const lastThird = sorted.slice(-Math.ceil(sorted.length / 3));
|
|
219
219
|
|
|
220
|
-
const initial = firstThird.reduce((sum, t) => sum + t.confidence.
|
|
221
|
-
const final = lastThird.reduce((sum, t) => sum + t.confidence.
|
|
220
|
+
const initial = firstThird.reduce((sum, t) => sum + (t.confidence?.overall ?? 0.5), 0) / firstThird.length;
|
|
221
|
+
const final = lastThird.reduce((sum, t) => sum + (t.confidence?.overall ?? 0.5), 0) / lastThird.length;
|
|
222
222
|
|
|
223
223
|
const diff = final - initial;
|
|
224
224
|
const threshold = 0.1;
|
|
@@ -256,10 +256,10 @@ export class MetaReasoningAgent extends BaseAgent {
|
|
|
256
256
|
* @param thoughts - Thoughts to analyze
|
|
257
257
|
* @returns Variance
|
|
258
258
|
*/
|
|
259
|
-
|
|
259
|
+
calculateConfidenceVariance(thoughts: Thought[]): number {
|
|
260
260
|
if (thoughts.length < 2) return 0;
|
|
261
261
|
|
|
262
|
-
const values = thoughts.map(t => t.confidence.
|
|
262
|
+
const values = thoughts.map(t => t.confidence?.overall ?? 0.5);
|
|
263
263
|
const mean = values.reduce((a, b) => a + b, 0) / values.length;
|
|
264
264
|
const squaredDiffs = values.map(v => Math.pow(v - mean, 2));
|
|
265
265
|
|
|
@@ -276,14 +276,15 @@ export class MetaReasoningAgent extends BaseAgent {
|
|
|
276
276
|
const triggeredActions: string[] = [];
|
|
277
277
|
|
|
278
278
|
// Check for high uncertainty
|
|
279
|
-
const
|
|
279
|
+
const confidence = thought.confidence || { overall: 0.5, uncertaintyBounds: [0.3, 0.7] };
|
|
280
|
+
const uncertaintyRange = (confidence.uncertaintyBounds?.[1] ?? 0.7) - (confidence.uncertaintyBounds?.[0] ?? 0.3);
|
|
280
281
|
if (uncertaintyRange > 0.4) {
|
|
281
282
|
observations.push('High uncertainty detected');
|
|
282
283
|
triggeredActions.push('gather_more_evidence');
|
|
283
284
|
}
|
|
284
285
|
|
|
285
286
|
// Check for low confidence
|
|
286
|
-
if (
|
|
287
|
+
if (confidence.overall < 0.4) {
|
|
287
288
|
observations.push('Low confidence in this thought');
|
|
288
289
|
triggeredActions.push('review_reasoning');
|
|
289
290
|
}
|
package/src/index.ts
CHANGED
package/src/mcp-server.ts
CHANGED
|
@@ -97,7 +97,7 @@ export class MCPServer {
|
|
|
97
97
|
private dataDir = './data';
|
|
98
98
|
|
|
99
99
|
constructor() {
|
|
100
|
-
this.server = new Server({ name: 'mcp-sequential-thinking', version: '1.
|
|
100
|
+
this.server = new Server({ name: 'mcp-sequential-thinking', version: '1.1.4' }, { capabilities: { tools: {} } });
|
|
101
101
|
this.sessionManager = new SessionManager(this.dataDir);
|
|
102
102
|
this.swarmCoordinator = new SwarmCoordinator(this.dataDir);
|
|
103
103
|
this.setupHandlers();
|