@gotza02/seq-thinking 1.1.21 → 1.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +98 -86
  2. package/SYSTEM_INSTRUCTIONS.md +35 -35
  3. package/dist/__tests__/agents/base-agent.js +215 -0
  4. package/dist/__tests__/agents/specialist-agent.js +75 -0
  5. package/dist/__tests__/specialist-agent.test.js +653 -30
  6. package/dist/__tests__/types/index.js +278 -0
  7. package/dist/__tests__/utils/llm-adapter.js +93 -0
  8. package/dist/__tests__/utils/logger.js +48 -0
  9. package/dist/constants.d.ts +69 -0
  10. package/dist/constants.d.ts.map +1 -0
  11. package/dist/constants.js +96 -0
  12. package/dist/constants.js.map +1 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/mcp-server.d.ts.map +1 -1
  18. package/dist/mcp-server.js +16 -2
  19. package/dist/mcp-server.js.map +1 -1
  20. package/dist/utils/llm-adapter.d.ts +4 -4
  21. package/dist/utils/llm-adapter.d.ts.map +1 -1
  22. package/dist/utils/llm-adapter.js +25 -23
  23. package/dist/utils/llm-adapter.js.map +1 -1
  24. package/dist/utils/persistence.d.ts +17 -0
  25. package/dist/utils/persistence.d.ts.map +1 -1
  26. package/dist/utils/persistence.js +60 -5
  27. package/dist/utils/persistence.js.map +1 -1
  28. package/dist/validation/index.d.ts +6 -0
  29. package/dist/validation/index.d.ts.map +1 -0
  30. package/dist/validation/index.js +6 -0
  31. package/dist/validation/index.js.map +1 -0
  32. package/dist/validation/schemas.d.ts +793 -0
  33. package/dist/validation/schemas.d.ts.map +1 -0
  34. package/dist/validation/schemas.js +340 -0
  35. package/dist/validation/schemas.js.map +1 -0
  36. package/dist/validation/schemas.test.d.ts +6 -0
  37. package/dist/validation/schemas.test.d.ts.map +1 -0
  38. package/dist/validation/schemas.test.js +171 -0
  39. package/dist/validation/schemas.test.js.map +1 -0
  40. package/package.json +7 -6
package/README.md CHANGED
@@ -1,35 +1,35 @@
1
1
  # MCP Sequential Thinking with Swarm Coordination
2
2
 
3
- [![Version](https://img.shields.io/badge/version-1.1.21-blue.svg)](https://www.npmjs.com/package/@gotza02/seq-thinking)
3
+ [![Version](https://img.shields.io/badge/version-1.1.23-blue.svg)](https://www.npmjs.com/package/@gotza02/seq-thinking)
4
4
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
5
5
  [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
6
6
 
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.
7
+ **Advanced Sequential Thinking MCP Server** ที่มาพร้อมกับ Swarm Intelligence แบบบูรณาการ เครื่องมือนี้ช่วยเพิ่มประสิทธิภาพให้กับสภาพแวดล้อม AI ของคุณด้วยการให้เหตุผลแบบมีโครงสร้าง การแก้ไขตนเอง และทีมเอเจนต์เฉพาะทางที่ประสานงานกัน โดยใช้ประโยชน์จากเครื่องมือ CLI ของ LLM ในเครื่องที่มีอยู่แล้ว
8
8
 
9
- ## 🚀 Key Features
9
+ ## 🚀 คุณสมบัติหลัก
10
10
 
11
- * **🧠 Advanced Sequential Thinking**: Supports branching, merging, and pruning of thought paths.
12
- * **🤖 Swarm Intelligence**: Coordinates specialized agents (**Reasoner**, **Critic**, **Synthesizer**, **Meta-Reasoner**, **Specialist**) with Mutex-based concurrency control to prevent race conditions.
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 & Recovery**: Automatically saves sessions, agent states, and tasks to disk. Includes a Recovery System that restores interrupted tasks to a pending state on restart.
16
- * **🔍 Self-Correction**: Proactively detects logical fallacies and confidence dips, triggering corrective actions.
11
+ * **🧠 Advanced Sequential Thinking**: รองรับการแตกกิ่ง การรวมกัน และการตัดแต่งเส้นทางการคิด
12
+ * **🤖 Swarm Intelligence**: ประสานงานเอเจนต์เฉพาะทาง (**Reasoner**, **Critic**, **Synthesizer**, **Meta-Reasoner**, **Specialist**) พร้อมการควบคุมการทำงานพร้อมกันแบบ Mutex เพื่อป้องกันปัญหา race condition
13
+ * **🔌 BYO-LLM (Bring Your Own LLM)**: เชื่อมต่อโดยตรงกับ **Gemini**, **Claude**, **Kimi**, และ **OpenCode** ผ่าน CLI tools ของพวกเขา—ไม่ต้องใช้ API keys เพิ่มเติมหากคุณล็อกอินอยู่แล้ว
14
+ * **🔄 Auto-Fallback และความทนทาน**: สลับผู้ให้บริการอัตโนมัติหากผู้ใดผู้หนึ่งล้มเหลว (เช่น `gemini` -> `claude`) รวมถึงลอจิกการ retry สำหรับการดำเนินการงานที่ยืดหยุ่น
15
+ * **💾 การเก็บข้อมูลและการกู้คืน**: บันทึกเซสชัน สถานะเอเจนต์ และงานไปยังดิสก์อัตโนมัติ รวมถึงระบบกู้คืนที่คืนค่างานที่ถูกขัดจังหวะให้กลับสู่สถานะ pending เมื่อรีสตาร์ท
16
+ * **🔍 การแก้ไขตนเอง**: ตรวจจับ logical fallacies และการลดลงของความมั่นใจแบบ proactive พร้อมกระตุ้นการดำเนินการแก้ไข
17
17
 
18
- ## 📦 Quick Start (NPX)
18
+ ## 📦 เริ่มต้นใช้งานอย่างรวดเร็ว (NPX)
19
19
 
20
- You can run this MCP server directly using `npx` without cloning the repository. This is the recommended method.
20
+ คุณสามารถรัน MCP server นี้ได้โดยตรงโดยใช้ `npx` โดยไม่ต้อง clone repository วิธีนี้เป็นวิธีที่แนะนำ
21
21
 
22
- **Prerequisites:** Node.js v18 or higher.
22
+ **ข้อกำหนดเบื้องต้น:** Node.js v18 หรือสูงกว่า
23
23
 
24
24
  ```bash
25
25
  npx -y @gotza02/seq-thinking
26
26
  ```
27
27
 
28
- ## ⚙️ MCP Configuration
28
+ ## ⚙️ การตั้งค่า MCP
29
29
 
30
- To use this tool with MCP clients (like **Claude Desktop**, **Cline**, or **Cursor**), add the following configuration to your settings file.
30
+ หากต้องการใช้เครื่องมือนี้กับ MCP clients (เช่น **Claude Desktop**, **Cline**, หรือ **Cursor**) ให้เพิ่มการตั้งค่าต่อไปนี้ลงในไฟล์ settings ของคุณ
31
31
 
32
- **For Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS, or `%APPDATA%\Claude\claude_desktop_config.json` on Windows):
32
+ **สำหรับ Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json` บน macOS หรือ `%APPDATA%\Claude\claude_desktop_config.json` บน Windows):
33
33
 
34
34
  ```json
35
35
  {
@@ -48,138 +48,150 @@ To use this tool with MCP clients (like **Claude Desktop**, **Cline**, or **Curs
48
48
  }
49
49
  ```
50
50
 
51
- ### Environment Variables
51
+ ### ตัวแปรสภาพแวดล้อม (Environment Variables)
52
52
 
53
- | Variable | Description | Default | Example |
53
+ | ตัวแปร | คำอธิบาย | ค่าเริ่มต้น | ตัวอย่าง |
54
54
  |----------|-------------|---------|---------|
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` |
57
- | `LOG_LEVEL` | Logging verbosity (`DEBUG`, `INFO`, `WARN`, `ERROR`). | `INFO` | `DEBUG` |
58
- | `MCP_DATA_DIR` | Custom directory for session/agent persistence. | `./data` | `/home/user/mcp-data` |
59
- | `TMPDIR` | If `MCP_DATA_DIR` is not set, data will be stored in `$TMPDIR/data`. | `./` | `/tmp` |
55
+ | `provider` | รายการ LLM CLIs ที่คั่นด้วยจุลภาค ระบบจะลองใช้ตามลำดับ | `gemini` | `gemini,claude,kimi` |
56
+ | `MOCK_LLM` | หากเป็น `true` จะคืนค่า mock responses (สำหรับการทดสอบโดยไม่มีค่าใช้จ่าย API) | `false` | `true` |
57
+ | `LOG_LEVEL` | ระดับความละเอียดของการบันทึก (`DEBUG`, `INFO`, `WARN`, `ERROR`) | `INFO` | `DEBUG` |
58
+ | `MCP_DATA_DIR` | ไดเรกทอรีที่กำหนดเองสำหรับการเก็บข้อมูลเซสชัน/เอเจนต์ | `./data` | `/home/user/mcp-data` |
59
+ | `TMPDIR` | หากไม่ได้ตั้งค่า `MCP_DATA_DIR` ข้อมูลจะถูกเก็บใน `$TMPDIR/data` | `./` | `/tmp` |
60
60
 
61
- **Supported CLI Tools:**
62
- * **Gemini:** Requires `gemini` CLI installed and authenticated.
63
- * **Claude:** Requires `claude` (Claude Code) CLI installed and authenticated.
64
- * **Kimi:** Requires `kimi` (Kimi Code CLI) installed and authenticated.
65
- * **OpenCode:** Requires `opencode` CLI.
61
+ **เครื่องมือ CLI ที่รองรับ:**
62
+ * **Gemini:** ต้องติดตั้ง `gemini` CLI และยืนยันตัวตนแล้ว
63
+ * **Claude:** ต้องติดตั้ง `claude` (Claude Code) CLI และยืนยันตัวตนแล้ว
64
+ * **Kimi:** ต้องติดตั้ง `kimi` (Kimi Code CLI) และยืนยันตัวตนแล้ว
65
+ * **OpenCode:** ต้องติดตั้ง `opencode` CLI
66
66
 
67
- ## 🛠️ Usage
67
+ ## 🛠️ การใช้งาน
68
68
 
69
- This server provides two main tools to your AI client:
69
+ เซิร์ฟเวอร์นี้ให้บริการเครื่องมือหลัก 2 อย่างแก่ AI client ของคุณ:
70
70
 
71
71
  ### 1. `advanced_sequential_thinking`
72
- The core thinking engine.
73
- * **Operations:** `initialize`, `add_thought`, `branch_thought`, `self_correct`, `complete_session`, etc.
74
- * **Use Case:** Deep, step-by-step problem solving with ability to backtrack.
72
+ เครื่องยนต์การคิดหลัก
73
+ * **Operations:** `initialize`, `add_thought`, `branch_thought`, `self_correct`, `complete_session`, ฯลฯ
74
+ * **กรณีใช้งาน:** การแก้ปัญหาเชิงลึกแบบเป็นขั้นตอนพร้อมความสามารถในการย้อนกลับ
75
75
 
76
76
  ### 2. `swarm_agent_coordination`
77
- The workforce manager.
78
- * **Operations:** `register_agent`, `assign_task`, `reach_consensus`, `resolve_conflict`.
79
- * **Use Case:** Delegating sub-tasks to specialized "virtual experts" (e.g., asking a "Critic" agent to review a plan).
77
+ ผู้จัดการทีมงาน
78
+ * **Operations:** `register_agent`, `assign_task`, `reach_consensus`, `resolve_conflict`
79
+ * **กรณีใช้งาน:** มอบหมายงานย่อยให้กับ "ผู้เชี่ยวชาญเสมือน" เฉพาะทาง (เช่น ขอให้เอเจนต์ "Critic" ตรวจสอบแผน)
80
80
 
81
- ## 👨‍💻 Development & Local Installation
81
+ ## 👨‍💻 การพัฒนาและการติดตั้งในเครื่อง
82
82
 
83
- If you want to modify the code or contribute:
83
+ หากคุณต้องการแก้ไขโค้ดหรือมีส่วนร่วม:
84
84
 
85
85
  ```bash
86
- # Clone the repository
86
+ # Clone repository
87
87
  git clone https://github.com/yourusername/mcp-sequential-thinking.git
88
88
  cd mcp-sequential-thinking
89
89
 
90
- # Install dependencies
90
+ # ติดตั้ง dependencies
91
91
  npm install
92
92
 
93
- # Build the project
93
+ # Build โปรเจกต์
94
94
  npm run build
95
95
 
96
- # Run tests
96
+ # รันการทดสอบ
97
97
  export MOCK_LLM=true
98
98
  npm test
99
99
  ```
100
100
 
101
- ## 🏗️ Architecture
101
+ ## 🏗️ สถาปัตยกรรม
102
102
 
103
- The system is built on a modular architecture:
104
- * **Orchestration Layer:** Manages state, flow control, and error handling.
105
- * **Swarm Coordinator:** Assigns tasks based on agent capabilities and availability.
106
- * **Thought Graph:** A directed acyclic graph (DAG) representing the reasoning process.
107
- * **LLM Adapter:** A unified interface for communicating with various CLI-based models.
103
+ ระบบถูกสร้างบนสถาปัตยกรรมแบบโมดูลาร์:
104
+ * **Orchestration Layer:** จัดการสถานะ การควบคุม flow และการจัดการข้อผิดพลาด
105
+ * **Swarm Coordinator:** มอบหมายงานตามความสามารถและความพร้อมของเอเจนต์
106
+ * **Thought Graph:** กราฟแบบ directed acyclic graph (DAG) ที่แสดงกระบวนการให้เหตุผล
107
+ * **LLM Adapter:** อินเทอร์เฟซแบบรวมศูนย์สำหรับสื่อสารกับโมเดลต่างๆ ที่ใช้ CLI
108
108
 
109
- ## 📝 Changelog
109
+ ## 📝 ประวัติการเปลี่ยนแปลง (Changelog)
110
+
111
+ ### v1.1.23 (2026-02-04)
112
+ - **Security (สำคัญ):** แก้ไขช่องโหว่ Shell Injection โดยใช้ execFile แทน exec
113
+ - **Security (สำคัญ):** แก้ไขช่องโหว่ Path Traversal โดยเพิ่มการตรวจสอบ ID
114
+ - **คุณสมบัติ:** สร้างระบบ Zod Validation สำหรับตรวจสอบ inputs ทั้งหมด
115
+ - **คุณสมบัติ:** รวมค่าคงที่ทั้งหมดไว้ใน constants.ts
116
+ - **แก้ไข:** แก้ไข version mismatch (1.1.21 → 1.1.22)
117
+ - **ปรับปรุง:** เพิ่ม Unit Tests สำหรับ SpecialistAgent จาก 3 เป็น 38 tests
118
+ - **เอกสาร:** เพิ่มเอกสาร API Reference (docs/API.md)
119
+
120
+ ### v1.1.22 (2026-02-04)
121
+ - **แก้ไข (สำคัญ):** ใช้งาน input sanitization ใน `handleSequentialThinking` เพื่อลบ XML tags ที่เกิดจาก hallucination (เช่น `<arg_key>`) ออกจากสตริง operation แก้ไขข้อผิดพลาด "Unknown operation" เมื่อ LLM สร้าง arguments ของเครื่องมือผิดรูปแบบ
110
122
 
111
123
  ### v1.1.21 (2026-02-04)
112
- - **Fix (Swarm):** Significantly improved technical robustness of Swarm Agent Delegation.
113
- - **Improvement:** Added comprehensive logging across the task lifecycle (submission, assignment, execution).
114
- - **Improvement:** Enhanced error handling in `delegate_to_swarm` operation to capture and report execution exceptions.
115
- - **Fix:** Fixed a bug where failed agent execution wasn't properly triggering the reassignment logic.
124
+ - **แก้ไข (Swarm):** ปรับปรุงความทนทานทางเทคนิคของ Swarm Agent Delegation อย่างมาก
125
+ - **ปรับปรุง:** เพิ่มการบันทึกอย่างครอบคลุมตลอดวงจรชีวิตของงาน (submission, assignment, execution)
126
+ - **ปรับปรุง:** ปรับปรุงการจัดการข้อผิดพลาดใน operation `delegate_to_swarm` เพื่อจับและรายงานข้อยกเว้นการดำเนินการ
127
+ - **แก้ไข:** แก้ไขบั๊กที่การดำเนินการของเอเจนต์ล้มเหลวไม่ได้กระตุ้นลอจิกการมอบหมายใหม่
116
128
 
117
129
  ### v1.1.20 (2026-02-04)
118
- - **Fix (Kimi):** Updated `kimi` CLI integration to use the correct non-interactive syntax (`kimi --quiet --prompt`). Fixes issues where `kimi chat` was failing due to incorrect command structure.
130
+ - **แก้ไข (Kimi):** อัปเดตการบูรณาการ `kimi` CLI ให้ใช้ syntax แบบ non-interactive ที่ถูกต้อง (`kimi --quiet --prompt`) แก้ไขปัญหาที่ `kimi chat` ล้มเหลวเนื่องจากโครงสร้างคำสั่งไม่ถูกต้อง
119
131
 
120
132
  ### v1.1.19 (2026-02-04)
121
- - **Feature (Persistence):** Implemented Task Journaling and Recovery System. Interrupted tasks (e.g., due to crash/restart) are now automatically restored to a PENDING state.
122
- - **Feature (Concurrency):** Added Mutex-based locking to Swarm Coordinator to prevent race conditions during task assignment and execution.
123
- - **Improvement:** Enhanced `TaskQueueManager` with integrated persistence logic.
133
+ - **คุณสมบัติ (Persistence):** ใช้งานระบบ Task Journaling และ Recovery งานที่ถูกขัดจังหวะ (เช่น เนื่องจาก crash/restart) จะถูกกู้คืนให้กลับสู่สถานะ PENDING โดยอัตโนมัติ
134
+ - **คุณสมบัติ (Concurrency):** เพิ่ม Mutex-based locking ให้กับ Swarm Coordinator เพื่อป้องกัน race conditions ระหว่างการมอบหมายและดำเนินการงาน
135
+ - **ปรับปรุง:** ปรับปรุง `TaskQueueManager` ด้วยลอจิกการเก็บข้อมูลแบบบูรณาการ
124
136
 
125
137
  ### v1.1.18 (2026-02-03)
126
- - **Fix:** Critical fix for binary distribution. Restored `cli.js` entry point to ensure compatibility with `npx` and global installation.
127
- - **Improvement:** More robust main module detection for ESM.
138
+ - **แก้ไข:** แก้ไขสำคัญสำหรับการกระจาย binary คืนค่า entry point `cli.js` เพื่อให้เข้ากันได้กับ `npx` และการติดตั้งแบบ global
139
+ - **ปรับปรุง:** ตรวจจับโมดูลหลักที่แข็งแกร่งขึ้นสำหรับ ESM
128
140
 
129
141
  ### v1.1.17 (2026-02-03)
130
- - **Improvement:** Optimized data directory logic to default to `./data` in the current directory even if `TMPDIR` is present (common in CLI environments), while still allowing `TMPDIR` and `MCP_DATA_DIR` overrides.
142
+ - **ปรับปรุง:** ปรับปรุงลอจิกไดเรกทอรีข้อมูลให้ค่าเริ่มต้นเป็น `./data` ในไดเรกทอรีปัจจุบัน แม้ว่าจะมี `TMPDIR` (พบบ่อยในสภาพแวดล้อม CLI) ในขณะที่ยังอนุญาตให้ override ด้วย `TMPDIR` และ `MCP_DATA_DIR` ได้
131
143
 
132
144
  ### v1.1.16 (2026-02-03)
133
- - **Feature:** Added support for `MCP_DATA_DIR` and `TMPDIR` environment variables for flexible data persistence locations.
145
+ - **คุณสมบัติ:** เพิ่มการรองรับตัวแปรสภาพแวดล้อม `MCP_DATA_DIR` และ `TMPDIR` สำหรับตำแหน่งการเก็บข้อมูลที่ยืดหยุ่น
134
146
 
135
147
  ### v1.1.15 (2026-02-03)
136
- - **Feature:** Added support for `LOG_LEVEL` environment variable.
137
- - **Improvement:** Better constructor initialization for `MCPServer`.
148
+ - **คุณสมบัติ:** เพิ่มการรองรับตัวแปรสภาพแวดล้อม `LOG_LEVEL`
149
+ - **ปรับปรุง:** การเริ่มต้น constructor ที่ดีขึ้นสำหรับ `MCPServer`
138
150
 
139
151
  ### v1.1.14 (2026-02-03)
140
- - **Fix:** Improved robustness of `register_agent` operation.
141
- - **Fix:** Added aliasing for `type` field to `agentType` to support legacy/confused AI client calls.
142
- - **Fix:** Added support for extracting `capabilities` from a nested `payload` object.
152
+ - **แก้ไข:** ปรับปรุงความทนทานของ operation `register_agent`
153
+ - **แก้ไข:** เพิ่ม aliasing สำหรับฟิลด์ `type` เป็น `agentType` เพื่อรองรับการเรียกจาก AI client รุ่นเก่า/สับสน
154
+ - **แก้ไข:** เพิ่มการรองรับการดึง `capabilities` จากออบเจกต์ `payload` ที่ซ้อนอยู่
143
155
 
144
156
  ### v1.1.13 (2026-02-03)
145
- - **Feature:** Added `SpecialistAgent` type to swarm coordination.
146
- - **Fix:** Added support for `specialist` and `utility` agent types in `register_agent` operation.
147
- - **Fix:** Enhanced capability normalization allowing `string[]` when registering agents.
157
+ - **คุณสมบัติ:** เพิ่มประเภท `SpecialistAgent` ให้กับ swarm coordination
158
+ - **แก้ไข:** เพิ่มการรองรับประเภทเอเจนต์ `specialist` และ `utility` ใน operation `register_agent`
159
+ - **แก้ไข:** ปรับปรุงการปรับค่า capabilities ให้รองรับ `string[]` เมื่อลงทะเบียนเอเจนต์
148
160
 
149
161
  ### v1.1.12 (2026-02-03)
150
- - **Fix:** Corrected module resolution issues in binary entry point.
151
- - **Cleanup:** Removed redundant root-level CLI files.
152
- - **Improvement:** Optimized `package.json` for reliable `npx` distribution.
162
+ - **แก้ไข:** แก้ไขปัญหาการแก้ไขโมดูลใน entry point แบบ binary
163
+ - **Cleanup:** ลบไฟล์ CLI ระดับ root ที่ซ้ำซ้อน
164
+ - **ปรับปรุง:** ปรับปรุง `package.json` สำหรับการกระจาย `npx` ที่เชื่อถือได้
153
165
 
154
166
  ### v1.1.11 (2026-02-03)
155
- - **Fix:** Final fix for binary distribution issues.
167
+ - **แก้ไข:** แก้ไขสุดท้ายสำหรับปัญหาการกระจาย binary
156
168
 
157
169
  ### v1.1.10 (2026-02-03)
158
- - **Fix:** Refactored binary distribution to ensure reliable `npx` execution.
170
+ - **แก้ไข:** ปรับโครงสร้างการกระจาย binary เพื่อให้การดำเนินการ `npx` เชื่อถือได้
159
171
 
160
172
  ### v1.1.9 (2026-02-03)
161
- - **Fix:** Added multiple bin aliases to improve `npx` compatibility.
173
+ - **แก้ไข:** เพิ่ม bin aliases หลายอันเพื่อปรับปรุงความเข้ากันได้กับ `npx`
162
174
 
163
175
  ### v1.1.8 (2026-02-03)
164
- - **Fix:** Restored standard bin configuration.
176
+ - **แก้ไข:** คืนค่าการตั้งค่า bin มาตรฐาน
165
177
 
166
178
  ### v1.1.7 (2026-02-03)
167
- - **Fix:** Corrected bin path in package.json to ensure `npx` execution compatibility.
179
+ - **แก้ไข:** แก้ไข bin path ใน package.json เพื่อให้เข้ากันได้กับการดำเนินการ `npx`
168
180
 
169
181
  ### v1.1.5 (2026-02-03)
170
- - **Doc:** Updated README to prioritize `npx` usage for easier installation.
171
- - **Doc:** Updated MCP configuration examples to use `npx` command.
182
+ - **เอกสาร:** อัปเดต README เพื่อให้ความสำคัญกับการใช้งาน `npx` เพื่อการติดตั้งที่ง่ายขึ้น
183
+ - **เอกสาร:** อัปเดตตัวอย่างการตั้งค่า MCP ให้ใช้คำสั่ง `npx`
172
184
 
173
185
  ### v1.1.4 (2026-02-03)
174
- - **Fix:** Fixed a critical bug in `MetaReasoningAgent` that caused crashes when analyzing thoughts with missing confidence data.
175
- - **Improvement:** Enhanced robustness of `overall` confidence calculation across all agents.
176
- - **Doc:** Updated README with comprehensive usage and testing instructions.
186
+ - **แก้ไข:** แก้ไขบั๊กสำคัญใน `MetaReasoningAgent` ที่ทำให้เกิดการ crash เมื่อวิเคราะห์ thoughts ที่ขาดข้อมูล confidence
187
+ - **ปรับปรุง:** ปรับปรุงความทนทานของการคำนวณ confidence `overall` ในเอเจนต์ทั้งหมด
188
+ - **เอกสาร:** อัปเดต README ด้วยคำแนะนำการใช้งานและการทดสอบที่ครอบคลุม
177
189
 
178
190
  ### v1.1.3 (2026-02-03)
179
- - **Feature:** Multi-Provider Auto-Fallback.
180
- - **Feature:** Dynamic Provider Selection per task.
181
- - **Refactor:** Replaced console logs with structured `Logger`.
191
+ - **คุณสมบัติ:** Multi-Provider Auto-Fallback
192
+ - **คุณสมบัติ:** Dynamic Provider Selection ต่องาน
193
+ - **ปรับโครงสร้าง:** แทนที่ console logs ด้วย `Logger` แบบมีโครงสร้าง
182
194
 
183
- ## 📄 License
195
+ ## 📄 ใบอนุญาต
184
196
 
185
- MIT License - see [LICENSE](LICENSE) file for details.
197
+ MIT License - ดูรายละเอียดในไฟล์ [LICENSE](LICENSE)
@@ -1,50 +1,50 @@
1
- # AI System Instructions for MCP Sequential Thinking
1
+ # คำแนะนำระบบ AI สำหรับ MCP Sequential Thinking
2
2
 
3
- This document provides instructions for AI models (like Gemini or Claude) on how to effectively utilize this MCP server to solve complex problems.
3
+ เอกสารนี้ให้คำแนะนำสำหรับโมเดล AI (เช่น Gemini หรือ Claude) เกี่ยวกับวิธีการใช้งาน MCP server นี้อย่างมีประสิทธิภาพเพื่อแก้ไขปัญหาที่ซับซ้อน
4
4
 
5
- ## 1. When to Use These Tools
5
+ ## 1. เมื่อใดควรใช้เครื่องมือเหล่านี้
6
6
 
7
- You should invoke the `advanced_sequential_thinking` tool when:
8
- - The user's request is complex, ambiguous, or requires multi-step planning.
9
- - You need to explore multiple hypotheses or alternative solutions.
10
- - You need to perform self-correction or verify your own reasoning.
11
- - The task requires a "System 2" thinking approach (deliberative and analytical).
7
+ คุณควรเรียกใช้เครื่องมือ `advanced_sequential_thinking` เมื่อ:
8
+ - คำขอของผู้ใช้มีความซับซ้อน คลุมเครือ หรือต้องการการวางแผนหลายขั้นตอน
9
+ - คุณต้องสำรวจสมมติฐานหรือทางเลือกอื่นหลายๆ อย่าง
10
+ - คุณต้องดำเนินการแก้ไขตนเองหรือตรวจสอบการให้เหตุผลของตนเอง
11
+ - งานต้องการวิธีการคิดแบบ "System 2" (การพิจารณาอย่างรอบคอบและวิเคราะห์)
12
12
 
13
- ## 2. Decision Logic for Tools
13
+ ## 2. ตรรกะการตัดสินใจสำหรับเครื่องมือ
14
14
 
15
- | tool | Use Case |
15
+ | เครื่องมือ | กรณีการใช้งาน |
16
16
  |------|----------|
17
- | `advanced_sequential_thinking` | Core reasoning, branching, and meta-reflection. |
18
- | `swarm_agent_coordination` | Delegating specific sub-tasks to specialized agents (e.g., Fact-checking, Code Critique). |
17
+ | `advanced_sequential_thinking` | การให้เหตุผลหลัก การแบ่งกิ่ง และการทบทวนเชิงเมตา |
18
+ | `swarm_agent_coordination` | มอบหมายงานย่อยเฉพาะทางให้กับเอเจนต์ผู้เชี่ยวชาญ (เช่น การตรวจสอบข้อเท็จจริง การวิจารณ์โค้ด) |
19
19
 
20
- ## 3. Recommended Workflow
20
+ ## 3. ขั้นตอนการทำงานที่แนะนำ
21
21
 
22
- ### Phase A: Initialization
23
- 1. **Initialize**: Create a session with a clear `topic`.
24
- 2. **Adjust Granularity**: Check if the topic is complex enough to require high detail.
22
+ ### เฟส A: การเริ่มต้น
23
+ 1. **initialize**: สร้างเซสชันด้วย `topic` ที่ชัดเจน
24
+ 2. **adjust_granularity**: ตรวจสอบว่าหัวข้อมีความซับซ้อนเพียงพอที่ต้องการรายละเอียดสูงหรือไม่
25
25
 
26
- ### Phase B: Iterative Reasoning
27
- 1. **Add Thoughts**: Progress step-by-step. Use `thoughtType` (analysis, hypothesis, etc.) correctly.
28
- 2. **Branching**: If you reach a decision point with multiple viable paths, use `branch_thought` to explore them in parallel.
29
- 3. **Self-Correction**: Periodically call `self_correct` or `add_meta_thought` to reflect on your progress.
26
+ ### เฟส B: การให้เหตุผลแบบทำซ้ำ
27
+ 1. **add_thought**: ดำเนินการทีละขั้นตอน ใช้ `thoughtType` (analysis, hypothesis, ฯลฯ) ให้ถูกต้อง
28
+ 2. **branch_thought**: หากคุณถึงจุดตัดสินใจที่มีหลายเส้นทางที่เป็นไปได้ ให้ใช้ `branch_thought` เพื่อสำรวจพร้อมกัน
29
+ 3. **self_correct**: เรียกใช้ `self_correct` หรือ `add_meta_thought` เป็นระยะเพื่อทบทวนความคืบหน้าของคุณ
30
30
 
31
- ### Phase C: Swarm Delegation (Optional)
32
- 1. **Register Agents**: If you need specialized help, register a `critic` or `reasoner`.
33
- 2. **Delegate**: Use `delegate_to_swarm` to let another "brain" analyze a specific thought.
34
- 3. **Consensus**: Use `reach_consensus` if multiple agents have different outputs.
31
+ ### เฟส C: การมอบหมายให้ Swarm (เลือกใช้)
32
+ 1. **register_agent**: หากคุณต้องการความช่วยเหลือเฉพาะทาง ให้ลงทะเบียน `critic` หรือ `reasoner`
33
+ 2. **delegate_to_swarm**: ใช้ `delegate_to_swarm` เพื่อให้ "สมอง" อื่นวิเคราะห์ความคิดเฉพาะข้อ
34
+ 3. **reach_consensus**: ใช้ `reach_consensus` หากเอเจนต์หลายตัวมีผลลัพธ์ที่แตกต่างกัน
35
35
 
36
- ### Phase D: Conclusion
37
- 1. **Merge**: Combine successful branches using `merge_branches`.
38
- 2. **Complete**: Finalize the session and present the consolidated result to the user.
36
+ ### เฟส D: การสรุป
37
+ 1. **merge_branches**: รวมกิ่งที่ประสบความสำเร็จโดยใช้ `merge_branches`
38
+ 2. **complete**: สรุปเซสชันและนำเสนอผลลัพธ์ที่รวบรวมให้กับผู้ใช้
39
39
 
40
- ## 4. Best Practices for the AI
40
+ ## 4. แนวทางปฏิบัติที่ดีที่สุดสำหรับ AI
41
41
 
42
- - **Maintain Context**: Keep track of the `sessionId`. Use it for all related thoughts.
43
- - **Calibrate Confidence**: Be honest about confidence levels. If confidence drops below 0.5, explicitly use a `self_correction` thought.
44
- - **Label Everything**: Use `tags` and `thoughtType` diligently. This helps the system (and the user) understand your mental map.
45
- - **Meta-Reflection**: Don't just think; think about *how* you are thinking. If you get stuck, use `add_meta_thought` to analyze the pattern.
42
+ - **รักษาบริบท**: ติดตาม `sessionId` ใช้งานสำหรับความคิดที่เกี่ยวข้องทั้งหมด
43
+ - **ปรับเทียบความมั่นใจ**: แสดงความซื่อสัตย์เกี่ยวกับระดับความมั่นใจ หากความมั่นใจต่ำกว่า 0.5 ให้ใช้ความคิด `self_correction` อย่างชัดเจน
44
+ - **ติดป้ายทุกอย่าง**: ใช้ `tags` และ `thoughtType` อย่างขยัน สิ่งนี้ช่วยให้ระบบ (และผู้ใช้) เข้าใจแผนที่ความคิดของคุณ
45
+ - **การทบทวนเชิงเมตา**: ไม่เพียงแค่คิด แต่ต้องคิดถึง *วิธี* ที่คุณกำลังคิด หากคุณติดขัด ให้ใช้ `add_meta_thought` เพื่อวิเคราะห์รูปแบบ
46
46
 
47
- ## 5. System Prompt Template
47
+ ## 5. เทมเพลตคำสั่งระบบ
48
48
 
49
- When using this MCP server, you may internalize this instruction:
50
- > "I will use the Sequential Thinking MCP to map out my reasoning process. I will treat complex problems as a graph of thoughts, allowing myself to branch, backtrack, and consult specialized swarm agents when needed to ensure the highest quality output."
49
+ เมื่อใช้ MCP server นี้ คุณอาจทำให้คำสั่งนี้เป็นส่วนหนึ่งของตนเอง:
50
+ > "ฉันจะใช้ Sequential Thinking MCP เพื่อสร้างแผนที่กระบวนการให้เหตุผลของฉัน ฉันจะถือปัญหาที่ซับซ้อนเป็นกราฟของความคิด อนุญาตให้ตนเองแบ่งกิ่ง ย้อนกลับ และปรึกษาเอเจนต์ swarm ผู้เชี่ยวชาญเมื่อจำเป็นเพื่อให้ได้ผลลัพธ์ที่มีคุณภาพสูงสุด"
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Base Agent Class
3
+ * @module agents/base-agent
4
+ * @version 1.0.0
5
+ */
6
+ import { AgentType, AgentStatus } from '../types/index.js';
7
+ import { Logger } from '../utils/logger.js';
8
+ /**
9
+ * Abstract base class for all agents
10
+ */
11
+ export class BaseAgent {
12
+ /** Agent ID */
13
+ id;
14
+ /** Agent configuration */
15
+ config;
16
+ /** Current status */
17
+ status = AgentStatus.IDLE;
18
+ /** Current task IDs */
19
+ currentTasks = new Set();
20
+ /** Performance history */
21
+ performanceHistory = [];
22
+ /** Message handlers */
23
+ messageHandlers = [];
24
+ /**
25
+ * Create a new base agent
26
+ * @param config - Agent configuration
27
+ */
28
+ constructor(config) {
29
+ this.id = config.id || `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
30
+ this.config = {
31
+ id: this.id,
32
+ name: config.name,
33
+ type: config.type || AgentType.UTILITY,
34
+ subtype: config.subtype,
35
+ capabilities: config.capabilities || [],
36
+ maxConcurrentTasks: config.maxConcurrentTasks || 3,
37
+ confidenceThreshold: config.confidenceThreshold || 0.7,
38
+ metadata: {
39
+ createdAt: new Date(),
40
+ version: '1.0.0',
41
+ config: config.metadata?.config || {}
42
+ }
43
+ };
44
+ }
45
+ /**
46
+ * Execute a task
47
+ * @param task - Task to execute
48
+ * @returns Task result
49
+ */
50
+ async execute(task) {
51
+ const startTime = Date.now();
52
+ this.status = AgentStatus.BUSY;
53
+ this.currentTasks.add(task.id);
54
+ try {
55
+ const result = await this.process(task);
56
+ const processingTime = Date.now() - startTime;
57
+ this.performanceHistory.push({
58
+ taskId: task.id,
59
+ quality: result.confidence,
60
+ timeMs: processingTime,
61
+ timestamp: new Date()
62
+ });
63
+ this.currentTasks.delete(task.id);
64
+ this.status = this.currentTasks.size === 0 ? AgentStatus.IDLE : AgentStatus.BUSY;
65
+ return result;
66
+ }
67
+ catch (error) {
68
+ this.currentTasks.delete(task.id);
69
+ this.status = this.currentTasks.size === 0 ? AgentStatus.IDLE : AgentStatus.BUSY;
70
+ return {
71
+ taskId: task.id,
72
+ agentId: this.id,
73
+ success: false,
74
+ output: null,
75
+ confidence: 0,
76
+ processingTimeMs: Date.now() - startTime,
77
+ metadata: {
78
+ tokensUsed: 0,
79
+ reasoningSteps: 0,
80
+ intermediateResults: [],
81
+ error: error instanceof Error ? error.message : String(error)
82
+ }
83
+ };
84
+ }
85
+ }
86
+ /**
87
+ * Register a message handler
88
+ * @param handler - Message handler function
89
+ * @returns Unsubscribe function
90
+ */
91
+ onMessage(handler) {
92
+ this.messageHandlers.push(handler);
93
+ return () => {
94
+ const index = this.messageHandlers.indexOf(handler);
95
+ if (index > -1) {
96
+ this.messageHandlers.splice(index, 1);
97
+ }
98
+ };
99
+ }
100
+ /**
101
+ * Receive a message
102
+ * @param message - Message to receive
103
+ */
104
+ receiveMessage(message) {
105
+ for (const handler of this.messageHandlers) {
106
+ try {
107
+ const result = handler(message);
108
+ if (result instanceof Promise) {
109
+ result.catch(error => {
110
+ Logger.error(`Error in message handler for agent ${this.id}`, { error });
111
+ });
112
+ }
113
+ }
114
+ catch (error) {
115
+ Logger.error(`Error in message handler for agent ${this.id}`, { error });
116
+ }
117
+ }
118
+ }
119
+ /**
120
+ * Get agent status
121
+ * @returns Current status
122
+ */
123
+ getStatus() {
124
+ return this.status;
125
+ }
126
+ /**
127
+ * Set agent status
128
+ * @param status - New status
129
+ */
130
+ setStatus(status) {
131
+ this.status = status;
132
+ }
133
+ /**
134
+ * Get current task IDs
135
+ * @returns Array of task IDs
136
+ */
137
+ getCurrentTasks() {
138
+ return Array.from(this.currentTasks);
139
+ }
140
+ /**
141
+ * Get performance metrics
142
+ * @returns Performance metrics
143
+ */
144
+ getPerformanceMetrics() {
145
+ if (this.performanceHistory.length === 0) {
146
+ return {
147
+ tasksCompleted: 0,
148
+ averageQuality: 0,
149
+ averageTimeMs: 0,
150
+ successRate: 0
151
+ };
152
+ }
153
+ const completed = this.performanceHistory.length;
154
+ const avgQuality = this.performanceHistory.reduce((sum, p) => sum + p.quality, 0) / completed;
155
+ const avgTime = this.performanceHistory.reduce((sum, p) => sum + p.timeMs, 0) / completed;
156
+ const successRate = this.performanceHistory.filter(p => p.quality > 0.5).length / completed;
157
+ return {
158
+ tasksCompleted: completed,
159
+ averageQuality: avgQuality,
160
+ averageTimeMs: avgTime,
161
+ successRate
162
+ };
163
+ }
164
+ /**
165
+ * Check if agent has a capability
166
+ * @param capabilityName - Capability name
167
+ * @returns True if agent has capability
168
+ */
169
+ hasCapability(capabilityName) {
170
+ return this.getCapabilities().some(c => c.name === capabilityName);
171
+ }
172
+ /**
173
+ * Get capability confidence
174
+ * @param capabilityName - Capability name
175
+ * @returns Confidence level (0-1)
176
+ */
177
+ getCapabilityConfidence(capabilityName) {
178
+ const cap = this.getCapabilities().find(c => c.name === capabilityName);
179
+ return cap?.confidence || 0;
180
+ }
181
+ /**
182
+ * Check if agent can handle a task
183
+ * @param task - Task to check
184
+ * @returns True if agent can handle task
185
+ */
186
+ canHandleTask(task) {
187
+ const requiredCaps = task.requirements.requiredCapabilities;
188
+ return requiredCaps.every(cap => this.hasCapability(cap));
189
+ }
190
+ /**
191
+ * Create a task result
192
+ * @param taskId - Task ID
193
+ * @param output - Output data
194
+ * @param confidence - Confidence level
195
+ * @param processingTimeMs - Processing time in ms
196
+ * @param metadata - Additional metadata
197
+ * @returns Task result
198
+ */
199
+ createTaskResult(taskId, output, confidence, processingTimeMs, metadata = {}) {
200
+ return {
201
+ taskId,
202
+ agentId: this.id,
203
+ success: confidence > 0.5,
204
+ output,
205
+ confidence,
206
+ processingTimeMs,
207
+ metadata: {
208
+ tokensUsed: metadata.tokensUsed || 0,
209
+ reasoningSteps: metadata.reasoningSteps || 1,
210
+ intermediateResults: metadata.intermediateResults || [],
211
+ error: metadata.error
212
+ }
213
+ };
214
+ }
215
+ }