gthinking 1.3.0 → 2.1.1

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 (271) hide show
  1. package/.eslintrc.js +34 -0
  2. package/ANALYSIS_SUMMARY.md +363 -0
  3. package/README.md +230 -250
  4. package/dist/analysis/analysis-engine.d.ts +63 -0
  5. package/dist/analysis/analysis-engine.d.ts.map +1 -0
  6. package/dist/analysis/analysis-engine.js +322 -0
  7. package/dist/analysis/analysis-engine.js.map +1 -0
  8. package/dist/core/config.d.ts +1419 -0
  9. package/dist/core/config.d.ts.map +1 -0
  10. package/dist/core/config.js +361 -0
  11. package/dist/core/config.js.map +1 -0
  12. package/dist/core/engine.d.ts +176 -0
  13. package/dist/core/engine.d.ts.map +1 -0
  14. package/dist/core/engine.js +604 -0
  15. package/dist/core/engine.js.map +1 -0
  16. package/dist/core/errors.d.ts +153 -0
  17. package/dist/core/errors.d.ts.map +1 -0
  18. package/dist/core/errors.js +287 -0
  19. package/dist/core/errors.js.map +1 -0
  20. package/dist/core/index.d.ts +7 -0
  21. package/dist/core/index.d.ts.map +1 -0
  22. package/dist/{types.js → core/index.js} +8 -4
  23. package/dist/core/index.js.map +1 -0
  24. package/dist/core/pipeline.d.ts +121 -0
  25. package/dist/core/pipeline.d.ts.map +1 -0
  26. package/dist/core/pipeline.js +289 -0
  27. package/dist/core/pipeline.js.map +1 -0
  28. package/dist/core/rate-limiter.d.ts +58 -0
  29. package/dist/core/rate-limiter.d.ts.map +1 -0
  30. package/dist/core/rate-limiter.js +133 -0
  31. package/dist/core/rate-limiter.js.map +1 -0
  32. package/dist/core/session-manager.d.ts +96 -0
  33. package/dist/core/session-manager.d.ts.map +1 -0
  34. package/dist/core/session-manager.js +223 -0
  35. package/dist/core/session-manager.js.map +1 -0
  36. package/dist/creativity/creativity-engine.d.ts +6 -0
  37. package/dist/creativity/creativity-engine.d.ts.map +1 -0
  38. package/dist/creativity/creativity-engine.js +17 -0
  39. package/dist/creativity/creativity-engine.js.map +1 -0
  40. package/dist/index.d.ts +24 -32
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +130 -104
  43. package/dist/index.js.map +1 -1
  44. package/dist/learning/learning-engine.d.ts +6 -0
  45. package/dist/learning/learning-engine.d.ts.map +1 -0
  46. package/dist/learning/learning-engine.js +17 -0
  47. package/dist/learning/learning-engine.js.map +1 -0
  48. package/dist/llm/index.d.ts +10 -0
  49. package/dist/llm/index.d.ts.map +1 -0
  50. package/dist/llm/index.js +26 -0
  51. package/dist/llm/index.js.map +1 -0
  52. package/dist/llm/llm-service.d.ts +109 -0
  53. package/dist/llm/llm-service.d.ts.map +1 -0
  54. package/dist/llm/llm-service.js +224 -0
  55. package/dist/llm/llm-service.js.map +1 -0
  56. package/dist/llm/providers/base.d.ts +85 -0
  57. package/dist/llm/providers/base.d.ts.map +1 -0
  58. package/dist/llm/providers/base.js +57 -0
  59. package/dist/llm/providers/base.js.map +1 -0
  60. package/dist/llm/providers/cli.d.ts +23 -0
  61. package/dist/llm/providers/cli.d.ts.map +1 -0
  62. package/dist/llm/providers/cli.js +158 -0
  63. package/dist/llm/providers/cli.js.map +1 -0
  64. package/dist/llm/providers/gemini.d.ts +30 -0
  65. package/dist/llm/providers/gemini.d.ts.map +1 -0
  66. package/dist/llm/providers/gemini.js +168 -0
  67. package/dist/llm/providers/gemini.js.map +1 -0
  68. package/dist/llm/sanitization.d.ts +50 -0
  69. package/dist/llm/sanitization.d.ts.map +1 -0
  70. package/dist/llm/sanitization.js +149 -0
  71. package/dist/llm/sanitization.js.map +1 -0
  72. package/dist/{server.d.ts.map → mcp/server.d.ts.map} +1 -1
  73. package/dist/mcp/server.js +108 -0
  74. package/dist/mcp/server.js.map +1 -0
  75. package/dist/planning/planning-engine.d.ts +6 -0
  76. package/dist/planning/planning-engine.d.ts.map +1 -0
  77. package/dist/planning/planning-engine.js +17 -0
  78. package/dist/planning/planning-engine.js.map +1 -0
  79. package/dist/reasoning/reasoning-engine.d.ts +6 -0
  80. package/dist/reasoning/reasoning-engine.d.ts.map +1 -0
  81. package/dist/reasoning/reasoning-engine.js +17 -0
  82. package/dist/reasoning/reasoning-engine.js.map +1 -0
  83. package/dist/search/search-engine.d.ts +99 -0
  84. package/dist/search/search-engine.d.ts.map +1 -0
  85. package/dist/search/search-engine.js +271 -0
  86. package/dist/search/search-engine.js.map +1 -0
  87. package/dist/synthesis/synthesis-engine.d.ts +6 -0
  88. package/dist/synthesis/synthesis-engine.d.ts.map +1 -0
  89. package/dist/synthesis/synthesis-engine.js +17 -0
  90. package/dist/synthesis/synthesis-engine.js.map +1 -0
  91. package/dist/types/analysis.d.ts +1534 -49
  92. package/dist/types/analysis.d.ts.map +1 -1
  93. package/dist/types/analysis.js +250 -0
  94. package/dist/types/analysis.js.map +1 -1
  95. package/dist/types/core.d.ts +257 -30
  96. package/dist/types/core.d.ts.map +1 -1
  97. package/dist/types/core.js +148 -18
  98. package/dist/types/core.js.map +1 -1
  99. package/dist/types/creativity.d.ts +2871 -56
  100. package/dist/types/creativity.d.ts.map +1 -1
  101. package/dist/types/creativity.js +195 -0
  102. package/dist/types/creativity.js.map +1 -1
  103. package/dist/types/index.d.ts +6 -2
  104. package/dist/types/index.d.ts.map +1 -1
  105. package/dist/types/index.js +17 -2
  106. package/dist/types/index.js.map +1 -1
  107. package/dist/types/learning.d.ts +851 -61
  108. package/dist/types/learning.d.ts.map +1 -1
  109. package/dist/types/learning.js +155 -0
  110. package/dist/types/learning.js.map +1 -1
  111. package/dist/types/planning.d.ts +2223 -71
  112. package/dist/types/planning.d.ts.map +1 -1
  113. package/dist/types/planning.js +190 -0
  114. package/dist/types/planning.js.map +1 -1
  115. package/dist/types/reasoning.d.ts +2209 -72
  116. package/dist/types/reasoning.d.ts.map +1 -1
  117. package/dist/types/reasoning.js +200 -1
  118. package/dist/types/reasoning.js.map +1 -1
  119. package/dist/types/search.d.ts +981 -53
  120. package/dist/types/search.d.ts.map +1 -1
  121. package/dist/types/search.js +137 -0
  122. package/dist/types/search.js.map +1 -1
  123. package/dist/types/synthesis.d.ts +583 -38
  124. package/dist/types/synthesis.d.ts.map +1 -1
  125. package/dist/types/synthesis.js +138 -0
  126. package/dist/types/synthesis.js.map +1 -1
  127. package/dist/utils/cache.d.ts +144 -0
  128. package/dist/utils/cache.d.ts.map +1 -0
  129. package/dist/utils/cache.js +288 -0
  130. package/dist/utils/cache.js.map +1 -0
  131. package/dist/utils/id-generator.d.ts +89 -0
  132. package/dist/utils/id-generator.d.ts.map +1 -0
  133. package/dist/utils/id-generator.js +132 -0
  134. package/dist/utils/id-generator.js.map +1 -0
  135. package/dist/utils/index.d.ts +11 -0
  136. package/dist/utils/index.d.ts.map +1 -0
  137. package/dist/utils/index.js +33 -0
  138. package/dist/utils/index.js.map +1 -0
  139. package/dist/utils/logger.d.ts +142 -0
  140. package/dist/utils/logger.d.ts.map +1 -0
  141. package/dist/utils/logger.js +248 -0
  142. package/dist/utils/logger.js.map +1 -0
  143. package/dist/utils/metrics.d.ts +149 -0
  144. package/dist/utils/metrics.d.ts.map +1 -0
  145. package/dist/utils/metrics.js +296 -0
  146. package/dist/utils/metrics.js.map +1 -0
  147. package/dist/utils/timer.d.ts +7 -0
  148. package/dist/utils/timer.d.ts.map +1 -0
  149. package/dist/utils/timer.js +17 -0
  150. package/dist/utils/timer.js.map +1 -0
  151. package/dist/utils/validation.d.ts +147 -0
  152. package/dist/utils/validation.d.ts.map +1 -0
  153. package/dist/utils/validation.js +275 -0
  154. package/dist/utils/validation.js.map +1 -0
  155. package/docs/API.md +411 -0
  156. package/docs/ARCHITECTURE.md +271 -0
  157. package/docs/CHANGELOG.md +283 -0
  158. package/jest.config.js +28 -0
  159. package/package.json +43 -30
  160. package/src/analysis/analysis-engine.ts +383 -0
  161. package/src/core/config.ts +406 -0
  162. package/src/core/engine.ts +785 -0
  163. package/src/core/errors.ts +349 -0
  164. package/src/core/index.ts +12 -0
  165. package/src/core/pipeline.ts +424 -0
  166. package/src/core/rate-limiter.ts +155 -0
  167. package/src/core/session-manager.ts +269 -0
  168. package/src/creativity/creativity-engine.ts +14 -0
  169. package/src/index.ts +178 -0
  170. package/src/learning/learning-engine.ts +14 -0
  171. package/src/llm/index.ts +10 -0
  172. package/src/llm/llm-service.ts +285 -0
  173. package/src/llm/providers/base.ts +146 -0
  174. package/src/llm/providers/cli.ts +186 -0
  175. package/src/llm/providers/gemini.ts +201 -0
  176. package/src/llm/sanitization.ts +178 -0
  177. package/src/mcp/server.ts +117 -0
  178. package/src/planning/planning-engine.ts +14 -0
  179. package/src/reasoning/reasoning-engine.ts +14 -0
  180. package/src/search/search-engine.ts +333 -0
  181. package/src/synthesis/synthesis-engine.ts +14 -0
  182. package/src/types/analysis.ts +337 -0
  183. package/src/types/core.ts +342 -0
  184. package/src/types/creativity.ts +268 -0
  185. package/src/types/index.ts +31 -0
  186. package/src/types/learning.ts +215 -0
  187. package/src/types/planning.ts +251 -0
  188. package/src/types/reasoning.ts +288 -0
  189. package/src/types/search.ts +192 -0
  190. package/src/types/synthesis.ts +187 -0
  191. package/src/utils/cache.ts +363 -0
  192. package/src/utils/id-generator.ts +135 -0
  193. package/src/utils/index.ts +22 -0
  194. package/src/utils/logger.ts +290 -0
  195. package/src/utils/metrics.ts +380 -0
  196. package/src/utils/timer.ts +15 -0
  197. package/src/utils/validation.ts +297 -0
  198. package/tests/setup.ts +22 -0
  199. package/tests/unit/cache.test.ts +189 -0
  200. package/tests/unit/engine.test.ts +179 -0
  201. package/tests/unit/validation.test.ts +218 -0
  202. package/tsconfig.json +17 -12
  203. package/GEMINI.md +0 -68
  204. package/analysis.ts +0 -1063
  205. package/creativity.ts +0 -1055
  206. package/dist/analysis.d.ts +0 -54
  207. package/dist/analysis.d.ts.map +0 -1
  208. package/dist/analysis.js +0 -866
  209. package/dist/analysis.js.map +0 -1
  210. package/dist/creativity.d.ts +0 -81
  211. package/dist/creativity.d.ts.map +0 -1
  212. package/dist/creativity.js +0 -828
  213. package/dist/creativity.js.map +0 -1
  214. package/dist/engine.d.ts +0 -90
  215. package/dist/engine.d.ts.map +0 -1
  216. package/dist/engine.js +0 -720
  217. package/dist/engine.js.map +0 -1
  218. package/dist/examples.d.ts +0 -7
  219. package/dist/examples.d.ts.map +0 -1
  220. package/dist/examples.js +0 -506
  221. package/dist/examples.js.map +0 -1
  222. package/dist/learning.d.ts +0 -72
  223. package/dist/learning.d.ts.map +0 -1
  224. package/dist/learning.js +0 -615
  225. package/dist/learning.js.map +0 -1
  226. package/dist/llm-service.d.ts +0 -21
  227. package/dist/llm-service.d.ts.map +0 -1
  228. package/dist/llm-service.js +0 -100
  229. package/dist/llm-service.js.map +0 -1
  230. package/dist/planning.d.ts +0 -62
  231. package/dist/planning.d.ts.map +0 -1
  232. package/dist/planning.js +0 -886
  233. package/dist/planning.js.map +0 -1
  234. package/dist/reasoning.d.ts +0 -73
  235. package/dist/reasoning.d.ts.map +0 -1
  236. package/dist/reasoning.js +0 -845
  237. package/dist/reasoning.js.map +0 -1
  238. package/dist/search-discovery.d.ts +0 -73
  239. package/dist/search-discovery.d.ts.map +0 -1
  240. package/dist/search-discovery.js +0 -548
  241. package/dist/search-discovery.js.map +0 -1
  242. package/dist/server.js +0 -113
  243. package/dist/server.js.map +0 -1
  244. package/dist/types/engine.d.ts +0 -55
  245. package/dist/types/engine.d.ts.map +0 -1
  246. package/dist/types/engine.js +0 -3
  247. package/dist/types/engine.js.map +0 -1
  248. package/dist/types.d.ts +0 -6
  249. package/dist/types.d.ts.map +0 -1
  250. package/dist/types.js.map +0 -1
  251. package/engine.ts +0 -1009
  252. package/examples.ts +0 -717
  253. package/index.ts +0 -106
  254. package/learning.ts +0 -779
  255. package/llm-service.ts +0 -120
  256. package/planning.ts +0 -1101
  257. package/reasoning.ts +0 -1079
  258. package/search-discovery.ts +0 -700
  259. package/server.ts +0 -115
  260. package/types/analysis.ts +0 -69
  261. package/types/core.ts +0 -90
  262. package/types/creativity.ts +0 -72
  263. package/types/engine.ts +0 -60
  264. package/types/index.ts +0 -9
  265. package/types/learning.ts +0 -69
  266. package/types/planning.ts +0 -85
  267. package/types/reasoning.ts +0 -92
  268. package/types/search.ts +0 -58
  269. package/types/synthesis.ts +0 -43
  270. package/types.ts +0 -6
  271. /package/dist/{server.d.ts → mcp/server.d.ts} +0 -0
package/engine.ts DELETED
@@ -1,1009 +0,0 @@
1
- /**
2
- * Sequential Thinking Engine
3
- * Main orchestrator that integrates all thinking modules
4
- */
5
-
6
- import {
7
- // Core types
8
- SequentialThinkingConfig,
9
- ThinkingRequest,
10
- ThinkingResponse,
11
- ThinkingSession,
12
- ThinkingStage,
13
- StageResult,
14
- ResponseMetadata,
15
- TaskStatus,
16
- ThinkingEvent,
17
- ThinkingError,
18
-
19
- // Search types
20
- SearchResult,
21
- AggregatedResult,
22
- SourceType,
23
-
24
- // Analysis types
25
- AnalysisResult,
26
- AnalysisType,
27
-
28
- // Reasoning types
29
- ReasoningSession,
30
- ReasoningType,
31
- ChainOfThought,
32
-
33
- // Learning types
34
- LearningContext,
35
- Interaction,
36
- KnowledgeNode,
37
-
38
- // Planning types
39
- Plan,
40
- Task,
41
- Resource,
42
- ProgressReport,
43
-
44
- // Creativity types
45
- CreativeSession,
46
- CreativityTechnique,
47
- OutOfBoxThinking,
48
-
49
- // Synthesis types
50
- SynthesisResult,
51
- Recommendation
52
- } from './types';
53
-
54
- import { EventEmitter } from 'events';
55
-
56
- // Import all engines
57
- import { SearchDiscoveryEngine } from './search-discovery';
58
- import { AnalysisEngine } from './analysis';
59
- import { ReasoningEngine } from './reasoning';
60
- import { LearningEngine } from './learning';
61
- import { PlanningEngine } from './planning';
62
- import { CreativityEngine } from './creativity';
63
-
64
- // ============================================================================
65
- // SYNTHESIS ENGINE
66
- // ============================================================================
67
-
68
- class SynthesisEngine {
69
- synthesize(
70
- query: string,
71
- searchResults: SearchResult[],
72
- analysisResults: AnalysisResult[],
73
- reasoningSession?: ReasoningSession,
74
- creativeSession?: CreativeSession
75
- ): SynthesisResult {
76
- // Extract key insights from each component
77
- const insights = this.extractInsights(
78
- searchResults,
79
- analysisResults,
80
- reasoningSession,
81
- creativeSession
82
- );
83
-
84
- // Generate summary
85
- const summary = this.generateSummary(query, insights);
86
-
87
- // Generate recommendations
88
- const recommendations = this.generateRecommendations(
89
- query,
90
- insights,
91
- reasoningSession
92
- );
93
-
94
- // Identify gaps and uncertainties
95
- const gaps = this.identifyGaps(searchResults, analysisResults);
96
- const uncertainties = this.identifyUncertainties(reasoningSession);
97
-
98
- // Generate Devil's Advocate critique
99
- const critique = this.generateCritique(
100
- query,
101
- insights,
102
- recommendations,
103
- uncertainties
104
- );
105
-
106
- // Calculate confidence
107
- const confidence = this.calculateSynthesisConfidence(
108
- searchResults,
109
- analysisResults,
110
- reasoningSession
111
- );
112
-
113
- return {
114
- id: `synthesis_${Date.now()}`,
115
- sources: [
116
- ...searchResults.map(r => r.url),
117
- reasoningSession ? `reasoning_${reasoningSession.id}` : 'reasoning_skipped'
118
- ],
119
- summary,
120
- keyInsights: insights,
121
- recommendations,
122
- confidence,
123
- gaps,
124
- uncertainties,
125
- critique
126
- };
127
- }
128
-
129
- private generateCritique(
130
- query: string,
131
- insights: string[],
132
- recommendations: Recommendation[],
133
- uncertainties: string[]
134
- ): string {
135
- const parts: string[] = [];
136
-
137
- parts.push(`Devil's Advocate Review for: "${query}"`);
138
-
139
- if (uncertainties.length > 0) {
140
- parts.push('The proposed conclusion relies on uncertain premises:');
141
- uncertainties.slice(0, 3).forEach(u => parts.push(`- ${u}`));
142
- } else {
143
- parts.push('The reasoning appears consistent, but consider if key assumptions were inverted.');
144
- }
145
-
146
- if (recommendations.length > 0) {
147
- parts.push(`Counter-point to primary recommendation ("${recommendations[0].action}"):`);
148
- parts.push(`- Consider that ${recommendations[0].risks.join(' or ')} might be underestimated.`);
149
- parts.push('- What if the opposite approach was taken?');
150
- }
151
-
152
- if (insights.length < 3) {
153
- parts.push('Warning: limited insights generated. Conclusion may be premature.');
154
- }
155
-
156
- return parts.join('\n');
157
- }
158
-
159
- private extractInsights(
160
- searchResults: SearchResult[],
161
- analysisResults: AnalysisResult[],
162
- reasoningSession?: ReasoningSession,
163
- creativeSession?: CreativeSession
164
- ): string[] {
165
- const insights: string[] = [];
166
-
167
- // From search
168
- if (searchResults.length > 0) {
169
- const topResult = searchResults[0];
170
- insights.push(`Key finding from research: ${topResult.snippet.substring(0, 100)}...`);
171
- }
172
-
173
- // From analysis
174
- analysisResults.forEach(result => {
175
- result.findings.forEach(finding => {
176
- if (finding.confidence > 0.7) {
177
- insights.push(`${result.type}: ${JSON.stringify(finding.value).substring(0, 100)}`);
178
- }
179
- });
180
- });
181
-
182
- // From reasoning
183
- if (reasoningSession && reasoningSession.steps.length > 0) {
184
- const lastStep = reasoningSession.steps[reasoningSession.steps.length - 1];
185
- insights.push(`Reasoning conclusion: ${lastStep.inference}`);
186
- }
187
-
188
- // From creativity
189
- if (creativeSession) {
190
- const topIdeas = creativeSession.ideas
191
- .sort((a, b) => (b.novelty + b.feasibility + b.impact) - (a.novelty + a.feasibility + a.impact))
192
- .slice(0, 2);
193
-
194
- topIdeas.forEach(idea => {
195
- insights.push(`Creative insight: ${idea.content.substring(0, 80)}...`);
196
- });
197
- }
198
-
199
- return insights;
200
- }
201
-
202
- private generateSummary(query: string, insights: string[]): string {
203
- return `Analysis of "${query}" reveals ${insights.length} key insights. ` +
204
- `The synthesis combines research findings, logical reasoning, and creative exploration ` +
205
- `to provide a comprehensive understanding of the topic.`;
206
- }
207
-
208
- private generateRecommendations(
209
- query: string,
210
- insights: string[],
211
- reasoningSession?: ReasoningSession
212
- ): Recommendation[] {
213
- const recommendations: Recommendation[] = [];
214
-
215
- // Based on reasoning
216
- if (reasoningSession && reasoningSession.conclusion) {
217
- recommendations.push({
218
- id: `rec_${Date.now()}_1`,
219
- action: `Proceed with approach suggested by ${reasoningSession.type} reasoning`,
220
- rationale: reasoningSession.conclusion,
221
- priority: reasoningSession.confidence > 0.7 ? 1 : 2,
222
- expectedOutcome: 'Resolution based on logical analysis',
223
- risks: ['Reasoning assumptions may not hold'],
224
- confidence: reasoningSession.confidence
225
- });
226
- }
227
-
228
- // General recommendations
229
- recommendations.push({
230
- id: `rec_${Date.now()}_2`,
231
- action: 'Gather additional data to validate findings',
232
- rationale: 'More information increases confidence',
233
- priority: 3,
234
- expectedOutcome: 'Improved decision quality',
235
- risks: ['Time delay'],
236
- confidence: 0.8
237
- });
238
-
239
- return recommendations;
240
- }
241
-
242
- private identifyGaps(
243
- searchResults: SearchResult[],
244
- analysisResults: AnalysisResult[]
245
- ): string[] {
246
- const gaps: string[] = [];
247
-
248
- if (searchResults.length < 5) {
249
- gaps.push('Limited research coverage');
250
- }
251
-
252
- const lowConfidenceAnalysis = analysisResults.filter(r => r.confidence < 0.5);
253
- if (lowConfidenceAnalysis.length > 0) {
254
- gaps.push('Some analyses have low confidence');
255
- }
256
-
257
- return gaps;
258
- }
259
-
260
- private identifyUncertainties(reasoningSession?: ReasoningSession): string[] {
261
- const uncertainties: string[] = [];
262
-
263
- if (reasoningSession) {
264
- reasoningSession.steps.forEach(step => {
265
- if (step.confidence < 0.7) {
266
- uncertainties.push(`Step ${step.stepNumber}: ${step.inference}`);
267
- }
268
- });
269
- }
270
-
271
- return uncertainties;
272
- }
273
-
274
- private calculateSynthesisConfidence(
275
- searchResults: SearchResult[],
276
- analysisResults: AnalysisResult[],
277
- reasoningSession?: ReasoningSession
278
- ): number {
279
- const factors = [
280
- searchResults.length > 0 ? searchResults[0].credibility : 0,
281
- analysisResults.length > 0 ?
282
- analysisResults.reduce((sum, r) => sum + r.confidence, 0) / analysisResults.length : 0,
283
- ];
284
-
285
- if (reasoningSession) {
286
- factors.push(reasoningSession.confidence);
287
- }
288
-
289
- return factors.reduce((sum, f) => sum + f, 0) / factors.length;
290
- }
291
- }
292
-
293
- // ============================================================================
294
- // MAIN SEQUENTIAL THINKING ENGINE
295
- // ============================================================================
296
-
297
- export interface SequentialThinkingEngineDeps {
298
- searchEngine?: SearchDiscoveryEngine;
299
- analysisEngine?: AnalysisEngine;
300
- reasoningEngine?: ReasoningEngine;
301
- learningEngine?: LearningEngine;
302
- planningEngine?: PlanningEngine;
303
- creativityEngine?: CreativityEngine;
304
- }
305
-
306
- export class SequentialThinkingEngine extends EventEmitter {
307
- private searchEngine: SearchDiscoveryEngine;
308
- private analysisEngine: AnalysisEngine;
309
- private reasoningEngine: ReasoningEngine;
310
- private learningEngine: LearningEngine;
311
- private planningEngine: PlanningEngine;
312
- private creativityEngine: CreativityEngine;
313
- private synthesisEngine: SynthesisEngine;
314
-
315
- private config: SequentialThinkingConfig;
316
- private sessions: Map<string, ThinkingSession> = new Map();
317
-
318
- constructor(
319
- config: Partial<SequentialThinkingConfig> = {},
320
- deps: SequentialThinkingEngineDeps = {}
321
- ) {
322
- super();
323
-
324
- this.config = {
325
- maxSearchResults: 10,
326
- analysisDepth: 'moderate',
327
- reasoningComplexity: 'moderate',
328
- learningEnabled: true,
329
- creativityLevel: 'balanced',
330
- planningDetail: 'detailed',
331
- timeout: 60000,
332
- retryAttempts: 3,
333
- ...config
334
- };
335
-
336
- // Initialize all engines (inject or default)
337
- this.searchEngine = deps.searchEngine || new SearchDiscoveryEngine();
338
- this.analysisEngine = deps.analysisEngine || new AnalysisEngine();
339
- this.reasoningEngine = deps.reasoningEngine || new ReasoningEngine();
340
- this.learningEngine = deps.learningEngine || new LearningEngine();
341
- this.planningEngine = deps.planningEngine || new PlanningEngine();
342
- this.creativityEngine = deps.creativityEngine || new CreativityEngine();
343
-
344
- // Synthesis engine is internal for now, but could be injected too
345
- this.synthesisEngine = new SynthesisEngine();
346
-
347
- // Set up event forwarding
348
- this.setupEventForwarding();
349
- }
350
-
351
- private setupEventForwarding(): void {
352
- // Forward events from all engines
353
- const engines = [
354
- this.searchEngine,
355
- this.analysisEngine,
356
- this.reasoningEngine,
357
- this.learningEngine,
358
- this.planningEngine,
359
- this.creativityEngine
360
- ];
361
-
362
- engines.forEach(engine => {
363
- engine.on('*', (event: ThinkingEvent) => {
364
- this.emit(event.type, event);
365
- });
366
- });
367
- }
368
-
369
- /**
370
- * Process a thinking request through all stages
371
- */
372
- async think(request: ThinkingRequest): Promise<ThinkingResponse> {
373
- const startTime = Date.now();
374
- const stageResults: StageResult[] = [];
375
-
376
- // Create or get session
377
- const session = this.getOrCreateSession(request);
378
-
379
- // Dynamic Pipeline: Determine stages if not explicitly provided
380
- if (!request.preferredStages || request.preferredStages.length === 0) {
381
- request.preferredStages = this.planningEngine.determineThinkingStages(request.query);
382
-
383
- this.emit('planning_dynamic', {
384
- id: request.id,
385
- stage: ThinkingStage.PLANNING,
386
- timestamp: new Date(),
387
- data: {
388
- message: 'Dynamic pipeline generated',
389
- stages: request.preferredStages
390
- }
391
- } as ThinkingEvent);
392
- }
393
-
394
- // Merge config
395
- const config = { ...this.config, ...request.config };
396
-
397
- this.emit('thinking_start', {
398
- id: request.id,
399
- stage: ThinkingStage.SEARCH,
400
- timestamp: new Date(),
401
- data: { query: request.query }
402
- } as ThinkingEvent);
403
-
404
- try {
405
- // Stage 1: Search & Discovery
406
- if (this.shouldExecuteStage(request, ThinkingStage.SEARCH)) {
407
- const searchResult = await this.executeSearch(request, config);
408
- stageResults.push(searchResult);
409
- }
410
-
411
- // Stage 2: Analysis
412
- if (this.shouldExecuteStage(request, ThinkingStage.ANALYSIS)) {
413
- const analysisResult = await this.executeAnalysis(request, stageResults, config);
414
- stageResults.push(analysisResult);
415
- }
416
-
417
- // Stage 3: Reasoning
418
- if (this.shouldExecuteStage(request, ThinkingStage.REASONING)) {
419
- const reasoningResult = await this.executeReasoning(request, stageResults, config);
420
- stageResults.push(reasoningResult);
421
- }
422
-
423
- // Stage 4: Learning (context enrichment)
424
- if (config.learningEnabled && this.shouldExecuteStage(request, ThinkingStage.LEARNING)) {
425
- const learningResult = await this.executeLearning(request, stageResults, config);
426
- stageResults.push(learningResult);
427
- }
428
-
429
- // Stage 5: Planning (if applicable)
430
- if (this.shouldExecuteStage(request, ThinkingStage.PLANNING) && this.isPlanningRequest(request)) {
431
- const planningResult = await this.executePlanning(request, stageResults, config);
432
- stageResults.push(planningResult);
433
- }
434
-
435
- // Stage 6: Creativity
436
- if (this.shouldExecuteStage(request, ThinkingStage.CREATIVITY)) {
437
- const creativityResult = await this.executeCreativity(request, stageResults, config);
438
- stageResults.push(creativityResult);
439
- }
440
-
441
- // Stage 7: Synthesis
442
- const synthesisResult = await this.executeSynthesis(request, stageResults, config);
443
- stageResults.push(synthesisResult);
444
-
445
- // Generate final response
446
- const response = this.generateResponse(request, stageResults, startTime);
447
-
448
- // Record interaction for learning
449
- if (config.learningEnabled) {
450
- this.learningEngine.recordInteraction(
451
- session.id,
452
- request.query,
453
- response.finalAnswer
454
- );
455
- }
456
-
457
- this.emit('thinking_complete', {
458
- id: request.id,
459
- stage: ThinkingStage.EVALUATION,
460
- timestamp: new Date(),
461
- data: {
462
- response,
463
- stagesExecuted: stageResults.length,
464
- processingTime: Date.now() - startTime
465
- }
466
- } as ThinkingEvent);
467
-
468
- return response;
469
-
470
- } catch (error) {
471
- this.emit('thinking_error', {
472
- id: request.id,
473
- stage: ThinkingStage.EVALUATION,
474
- timestamp: new Date(),
475
- data: { error }
476
- } as ThinkingEvent);
477
-
478
- throw new ThinkingError(
479
- `Thinking process failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
480
- ThinkingStage.EVALUATION,
481
- false,
482
- error instanceof Error ? error : undefined
483
- );
484
- }
485
- }
486
-
487
- // ============================================================================
488
- // STAGE EXECUTORS
489
- // ============================================================================
490
-
491
- private async executeSearch(
492
- request: ThinkingRequest,
493
- config: SequentialThinkingConfig
494
- ): Promise<StageResult> {
495
- const startTime = Date.now();
496
-
497
- const searchResults = await this.searchEngine.search(request.query, {
498
- maxResults: config.maxSearchResults,
499
- sources: [SourceType.WEB, SourceType.KNOWLEDGE_BASE]
500
- });
501
-
502
- return {
503
- stage: ThinkingStage.SEARCH,
504
- status: TaskStatus.COMPLETED,
505
- input: { query: request.query },
506
- output: { results: searchResults, count: searchResults.length },
507
- processingTime: Date.now() - startTime,
508
- confidence: searchResults.length > 0 ? searchResults[0].credibility : 0
509
- };
510
- }
511
-
512
- private async executeAnalysis(
513
- request: ThinkingRequest,
514
- previousResults: StageResult[],
515
- config: SequentialThinkingConfig
516
- ): Promise<StageResult> {
517
- const startTime = Date.now();
518
-
519
- const searchResult = previousResults.find(r => r.stage === ThinkingStage.SEARCH);
520
- const content = searchResult ?
521
- (searchResult.output as any).results.map((r: SearchResult) => r.snippet).join(' ') :
522
- request.query;
523
-
524
- const analysisTypes: AnalysisType[] = config.analysisDepth === 'deep' ?
525
- ['sentiment', 'entity', 'topic', 'keyword', 'summary', 'fact_check'] :
526
- config.analysisDepth === 'surface' ?
527
- ['summary', 'keyword'] :
528
- ['sentiment', 'topic', 'summary'];
529
-
530
- const analysisResults = await this.analysisEngine.analyze(content, {
531
- types: analysisTypes,
532
- depth: config.analysisDepth,
533
- context: request.context
534
- });
535
-
536
- const avgConfidence = analysisResults.reduce((sum, r) => sum + r.confidence, 0) /
537
- analysisResults.length;
538
-
539
- return {
540
- stage: ThinkingStage.ANALYSIS,
541
- status: TaskStatus.COMPLETED,
542
- input: { content: content.substring(0, 200) },
543
- output: { results: analysisResults },
544
- processingTime: Date.now() - startTime,
545
- confidence: avgConfidence
546
- };
547
- }
548
-
549
- private async executeReasoning(
550
- request: ThinkingRequest,
551
- previousResults: StageResult[],
552
- config: SequentialThinkingConfig
553
- ): Promise<StageResult> {
554
- const startTime = Date.now();
555
-
556
- const reasoningType = this.inferReasoningType(request.query);
557
- const maxSteps = config.reasoningComplexity === 'complex' ? 7 :
558
- config.reasoningComplexity === 'simple' ? 3 : 5;
559
-
560
- const reasoningSession = await this.reasoningEngine.reason(request.query, {
561
- type: reasoningType,
562
- maxSteps,
563
- generateCOT: true
564
- });
565
-
566
- return {
567
- stage: ThinkingStage.REASONING,
568
- status: TaskStatus.COMPLETED,
569
- input: { problem: request.query },
570
- output: {
571
- session: reasoningSession,
572
- conclusion: reasoningSession.conclusion,
573
- steps: reasoningSession.steps.length
574
- },
575
- processingTime: Date.now() - startTime,
576
- confidence: reasoningSession.confidence
577
- };
578
- }
579
-
580
- private async executeLearning(
581
- request: ThinkingRequest,
582
- previousResults: StageResult[],
583
- config: SequentialThinkingConfig
584
- ): Promise<StageResult> {
585
- const startTime = Date.now();
586
-
587
- // Get relevant context
588
- const context = this.learningEngine.getOrCreateContext(request.id);
589
- const relevantContext = this.learningEngine.getRelevantContext(request.id, request.query);
590
-
591
- return {
592
- stage: ThinkingStage.LEARNING,
593
- status: TaskStatus.COMPLETED,
594
- input: { query: request.query },
595
- output: {
596
- context,
597
- relevantInteractions: relevantContext.interactions.length,
598
- relevantPatterns: relevantContext.patterns.length,
599
- relevantKnowledge: relevantContext.knowledge.length
600
- },
601
- processingTime: Date.now() - startTime,
602
- confidence: relevantContext.patterns.length > 0 ? 0.8 : 0.5
603
- };
604
- }
605
-
606
- private async executePlanning(
607
- request: ThinkingRequest,
608
- previousResults: StageResult[],
609
- config: SequentialThinkingConfig
610
- ): Promise<StageResult> {
611
- const startTime = Date.now();
612
-
613
- const plan = this.planningEngine.createPlan(request.query, {
614
- resources: [],
615
- deadline: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000) // 30 days
616
- });
617
-
618
- return {
619
- stage: ThinkingStage.PLANNING,
620
- status: TaskStatus.COMPLETED,
621
- input: { goal: request.query },
622
- output: {
623
- plan,
624
- taskCount: plan.tasks.length,
625
- estimatedDuration: plan.tasks.reduce((sum, t) => sum + t.estimatedDuration, 0)
626
- },
627
- processingTime: Date.now() - startTime,
628
- confidence: 0.75
629
- };
630
- }
631
-
632
- private async executeCreativity(
633
- request: ThinkingRequest,
634
- previousResults: StageResult[],
635
- config: SequentialThinkingConfig
636
- ): Promise<StageResult> {
637
- const startTime = Date.now();
638
-
639
- const techniques: CreativityTechnique[] = config.creativityLevel === 'adventurous' ?
640
- ['brainstorming', 'scamper', 'six_thinking_hats', 'lateral_thinking', 'analogy'] :
641
- config.creativityLevel === 'conservative' ?
642
- ['brainstorming'] :
643
- ['brainstorming', 'scamper', 'analogy'];
644
-
645
- const creativeSession = await this.creativityEngine.startSession(request.query, {
646
- techniques,
647
- ideaCount: 15
648
- });
649
-
650
- return {
651
- stage: ThinkingStage.CREATIVITY,
652
- status: TaskStatus.COMPLETED,
653
- input: { prompt: request.query },
654
- output: {
655
- session: creativeSession,
656
- ideaCount: creativeSession.ideas.length,
657
- connectionCount: creativeSession.connections.length,
658
- topIdeas: creativeSession.convergentPhase.selectedIdeas
659
- },
660
- processingTime: Date.now() - startTime,
661
- confidence: creativeSession.ideas.length > 5 ? 0.8 : 0.5
662
- };
663
- }
664
-
665
- private async executeSynthesis(
666
- request: ThinkingRequest,
667
- stageResults: StageResult[],
668
- config: SequentialThinkingConfig
669
- ): Promise<StageResult> {
670
- const startTime = Date.now();
671
-
672
- const searchResults = (stageResults.find(r => r.stage === ThinkingStage.SEARCH)?.output as any)?.results || [];
673
- const analysisResults = (stageResults.find(r => r.stage === ThinkingStage.ANALYSIS)?.output as any)?.results || [];
674
- const reasoningSession = (stageResults.find(r => r.stage === ThinkingStage.REASONING)?.output as any)?.session;
675
- const creativeSession = (stageResults.find(r => r.stage === ThinkingStage.CREATIVITY)?.output as any)?.session;
676
-
677
- const synthesis = this.synthesisEngine.synthesize(
678
- request.query,
679
- searchResults,
680
- analysisResults,
681
- reasoningSession,
682
- creativeSession
683
- );
684
-
685
- return {
686
- stage: ThinkingStage.SYNTHESIS,
687
- status: TaskStatus.COMPLETED,
688
- input: { query: request.query },
689
- output: { synthesis },
690
- processingTime: Date.now() - startTime,
691
- confidence: synthesis.confidence
692
- };
693
- }
694
-
695
- // ============================================================================
696
- // RESPONSE GENERATION
697
- // ============================================================================
698
-
699
- private generateResponse(
700
- request: ThinkingRequest,
701
- stageResults: StageResult[],
702
- startTime: number
703
- ): ThinkingResponse {
704
- const synthesisResult = stageResults.find(r => r.stage === ThinkingStage.SYNTHESIS);
705
- const synthesis = (synthesisResult?.output as any)?.synthesis as SynthesisResult;
706
-
707
- const reasoningResult = stageResults.find(r => r.stage === ThinkingStage.REASONING);
708
- const reasoning = (reasoningResult?.output as any)?.session as ReasoningSession;
709
-
710
- const creativeResult = stageResults.find(r => r.stage === ThinkingStage.CREATIVITY);
711
- const creative = (creativeResult?.output as any)?.session as CreativeSession;
712
-
713
- // Build final answer
714
- const parts: string[] = [];
715
-
716
- // Add synthesis summary
717
- if (synthesis) {
718
- parts.push(synthesis.summary);
719
- parts.push('');
720
- parts.push('Key Insights:');
721
- synthesis.keyInsights.forEach((insight, i) => {
722
- parts.push(`${i + 1}. ${insight}`);
723
- });
724
- }
725
-
726
- // Add reasoning conclusion
727
- if (reasoning?.conclusion) {
728
- parts.push('');
729
- parts.push('Reasoning:');
730
- parts.push(reasoning.conclusion);
731
- }
732
-
733
- // Add critique (Devil's Advocate)
734
- if (synthesis?.critique) {
735
- parts.push('');
736
- parts.push('---');
737
- parts.push(synthesis.critique);
738
- parts.push('---');
739
- }
740
-
741
- // Add creative insights
742
- if (creative) {
743
- parts.push('');
744
- parts.push('Creative Perspectives:');
745
- const topIdeas = creative.ideas
746
- .sort((a, b) => (b.novelty + b.feasibility + b.impact) - (a.novelty + a.feasibility + a.impact))
747
- .slice(0, 3);
748
-
749
- topIdeas.forEach((idea, i) => {
750
- parts.push(`${i + 1}. ${idea.content.substring(0, 100)}...`);
751
- });
752
- }
753
-
754
- // Add recommendations
755
- if (synthesis?.recommendations) {
756
- parts.push('');
757
- parts.push('Recommendations:');
758
- synthesis.recommendations.forEach((rec, i) => {
759
- parts.push(`${i + 1}. ${rec.action} (Confidence: ${Math.round(rec.confidence * 100)}%)`);
760
- });
761
- }
762
-
763
- const finalAnswer = parts.join('\n');
764
-
765
- // Calculate metadata
766
- const searchResult = stageResults.find(r => r.stage === ThinkingStage.SEARCH);
767
- const sourcesUsed = ((searchResult?.output as any)?.results as SearchResult[] || []).length;
768
-
769
- const reasoningSteps = reasoning?.steps.length || 0;
770
- const ideasGenerated = creative?.ideas.length || 0;
771
-
772
- const planningResult = stageResults.find(r => r.stage === ThinkingStage.PLANNING);
773
- const tasksCreated = ((planningResult?.output as any)?.plan as Plan)?.tasks.length || 0;
774
-
775
- const metadata: ResponseMetadata = {
776
- sourcesUsed,
777
- reasoningSteps,
778
- ideasGenerated,
779
- tasksCreated,
780
- knowledgeNodesAccessed: 0
781
- };
782
-
783
- // Calculate overall confidence
784
- const confidenceScores = stageResults.map(r => r.confidence).filter(c => c > 0);
785
- const overallConfidence = confidenceScores.length > 0 ?
786
- confidenceScores.reduce((sum, c) => sum + c, 0) / confidenceScores.length :
787
- 0.5;
788
-
789
- return {
790
- id: `response_${Date.now()}`,
791
- requestId: request.id,
792
- stages: stageResults,
793
- finalAnswer,
794
- confidence: overallConfidence,
795
- processingTime: Date.now() - startTime,
796
- metadata,
797
- timestamp: new Date()
798
- };
799
- }
800
-
801
- // ============================================================================
802
- // UTILITY METHODS
803
- // ============================================================================
804
-
805
- private getOrCreateSession(request: ThinkingRequest): ThinkingSession {
806
- if (this.sessions.has(request.id)) {
807
- return this.sessions.get(request.id)!;
808
- }
809
-
810
- const session: ThinkingSession = {
811
- id: request.id,
812
- requests: [request],
813
- responses: [],
814
- context: this.learningEngine.getOrCreateContext(request.id),
815
- startTime: new Date(),
816
- lastActivity: new Date()
817
- };
818
-
819
- this.sessions.set(request.id, session);
820
- return session;
821
- }
822
-
823
- private shouldExecuteStage(request: ThinkingRequest, stage: ThinkingStage): boolean {
824
- if (!request.preferredStages) return true;
825
- return request.preferredStages.length === 0 || request.preferredStages.includes(stage);
826
- }
827
-
828
- private isPlanningRequest(request: ThinkingRequest): boolean {
829
- const planningKeywords = ['plan', 'build', 'create', 'develop', 'implement', 'project', 'strategy'];
830
- return planningKeywords.some(kw => request.query.toLowerCase().includes(kw));
831
- }
832
-
833
- private inferReasoningType(query: string): ReasoningType {
834
- const queryLower = query.toLowerCase();
835
-
836
- if (queryLower.includes('why') || queryLower.includes('because')) {
837
- return ReasoningType.CAUSAL;
838
- }
839
- if (queryLower.includes('what if') || queryLower.includes('suppose')) {
840
- return ReasoningType.COUNTERFACTUAL;
841
- }
842
- if (queryLower.includes('similar') || queryLower.includes('like')) {
843
- return ReasoningType.ANALOGICAL;
844
- }
845
- if (queryLower.includes('pattern') || queryLower.includes('trend')) {
846
- return ReasoningType.INDUCTIVE;
847
- }
848
- if (queryLower.includes('best explanation') || queryLower.includes('probably')) {
849
- return ReasoningType.ABDUCTIVE;
850
- }
851
-
852
- return ReasoningType.DEDUCTIVE;
853
- }
854
-
855
- // ============================================================================
856
- // PUBLIC API METHODS
857
- // ============================================================================
858
-
859
- /**
860
- * Quick search and answer
861
- */
862
- async quickSearch(query: string): Promise<ThinkingResponse> {
863
- return this.think({
864
- id: `quick_${Date.now()}`,
865
- query,
866
- preferredStages: [ThinkingStage.SEARCH, ThinkingStage.ANALYSIS, ThinkingStage.SYNTHESIS],
867
- config: {
868
- analysisDepth: 'surface',
869
- reasoningComplexity: 'simple',
870
- learningEnabled: false,
871
- creativityLevel: 'conservative'
872
- }
873
- });
874
- }
875
-
876
- /**
877
- * Deep analysis with all stages
878
- */
879
- async deepAnalysis(query: string, context?: string): Promise<ThinkingResponse> {
880
- return this.think({
881
- id: `deep_${Date.now()}`,
882
- query,
883
- context,
884
- config: {
885
- analysisDepth: 'deep',
886
- reasoningComplexity: 'complex',
887
- learningEnabled: true,
888
- creativityLevel: 'adventurous',
889
- planningDetail: 'granular'
890
- }
891
- });
892
- }
893
-
894
- /**
895
- * Creative problem solving
896
- */
897
- async creativeSolve(problem: string): Promise<ThinkingResponse> {
898
- return this.think({
899
- id: `creative_${Date.now()}`,
900
- query: problem,
901
- preferredStages: [
902
- ThinkingStage.SEARCH,
903
- ThinkingStage.ANALYSIS,
904
- ThinkingStage.REASONING,
905
- ThinkingStage.CREATIVITY,
906
- ThinkingStage.SYNTHESIS
907
- ],
908
- config: {
909
- creativityLevel: 'adventurous',
910
- analysisDepth: 'moderate'
911
- }
912
- });
913
- }
914
-
915
- /**
916
- * Create a plan for a goal
917
- */
918
- async createPlan(goal: string, options?: { resources?: Resource[]; deadline?: Date }): Promise<Plan> {
919
- return this.planningEngine.createPlan(goal, options);
920
- }
921
-
922
- /**
923
- * Update config
924
- */
925
- updateConfig(config: Partial<SequentialThinkingConfig>): void {
926
- this.config = { ...this.config, ...config };
927
- }
928
-
929
- /**
930
- * Get session history
931
- */
932
- getSession(sessionId: string): ThinkingSession | undefined {
933
- return this.sessions.get(sessionId);
934
- }
935
-
936
- /**
937
- * Get all sessions
938
- */
939
- getAllSessions(): ThinkingSession[] {
940
- return Array.from(this.sessions.values());
941
- }
942
-
943
- /**
944
- * Export knowledge graph
945
- */
946
- exportKnowledgeGraph(): string {
947
- return this.learningEngine.exportKnowledgeGraph();
948
- }
949
-
950
- /**
951
- * Import knowledge graph
952
- */
953
- importKnowledgeGraph(json: string): void {
954
- this.learningEngine.importKnowledgeGraph(json);
955
- }
956
- }
957
-
958
- // ============================================================================
959
- // EXPORT SINGLETON INSTANCE
960
- // ============================================================================
961
-
962
- export const thinkingEngine = new SequentialThinkingEngine();
963
-
964
- // ============================================================================
965
- // EXAMPLE USAGE
966
- // ============================================================================
967
-
968
- /*
969
- // Basic usage
970
- const response = await thinkingEngine.think({
971
- id: 'request_1',
972
- query: 'What are the implications of quantum computing for cybersecurity?',
973
- config: {
974
- analysisDepth: 'deep',
975
- reasoningComplexity: 'complex'
976
- }
977
- });
978
-
979
- console.log(response.finalAnswer);
980
- console.log(`Confidence: ${response.confidence}`);
981
- console.log(`Processing time: ${response.processingTime}ms`);
982
-
983
- // Quick search
984
- const quick = await thinkingEngine.quickSearch('Latest AI trends 2024');
985
-
986
- // Deep analysis
987
- const deep = await thinkingEngine.deepAnalysis(
988
- 'How will climate change affect global food security?',
989
- 'Focus on agricultural impacts'
990
- );
991
-
992
- // Creative problem solving
993
- const creative = await thinkingEngine.creativeSolve(
994
- 'How can we make public transportation more appealing?'
995
- );
996
-
997
- // Create a plan
998
- const plan = await thinkingEngine.createPlan(
999
- 'Launch a sustainable fashion brand',
1000
- {
1001
- deadline: new Date(Date.now() + 180 * 24 * 60 * 60 * 1000) // 6 months
1002
- }
1003
- );
1004
-
1005
- // Listen to events
1006
- thinkingEngine.on('thinking_complete', (event) => {
1007
- console.log(`Thinking completed: ${event.data.processingTime}ms`);
1008
- });
1009
- */