gthinking 1.0.0

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 (53) hide show
  1. package/README.md +283 -0
  2. package/analysis.ts +986 -0
  3. package/creativity.ts +1002 -0
  4. package/dist/analysis.d.ts +52 -0
  5. package/dist/analysis.d.ts.map +1 -0
  6. package/dist/analysis.js +792 -0
  7. package/dist/analysis.js.map +1 -0
  8. package/dist/creativity.d.ts +80 -0
  9. package/dist/creativity.d.ts.map +1 -0
  10. package/dist/creativity.js +778 -0
  11. package/dist/creativity.js.map +1 -0
  12. package/dist/engine.d.ts +76 -0
  13. package/dist/engine.d.ts.map +1 -0
  14. package/dist/engine.js +675 -0
  15. package/dist/engine.js.map +1 -0
  16. package/dist/examples.d.ts +7 -0
  17. package/dist/examples.d.ts.map +1 -0
  18. package/dist/examples.js +506 -0
  19. package/dist/examples.js.map +1 -0
  20. package/dist/index.d.ts +38 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +126 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/learning.d.ts +72 -0
  25. package/dist/learning.d.ts.map +1 -0
  26. package/dist/learning.js +615 -0
  27. package/dist/learning.js.map +1 -0
  28. package/dist/planning.d.ts +58 -0
  29. package/dist/planning.d.ts.map +1 -0
  30. package/dist/planning.js +824 -0
  31. package/dist/planning.js.map +1 -0
  32. package/dist/reasoning.d.ts +72 -0
  33. package/dist/reasoning.d.ts.map +1 -0
  34. package/dist/reasoning.js +792 -0
  35. package/dist/reasoning.js.map +1 -0
  36. package/dist/search-discovery.d.ts +73 -0
  37. package/dist/search-discovery.d.ts.map +1 -0
  38. package/dist/search-discovery.js +505 -0
  39. package/dist/search-discovery.js.map +1 -0
  40. package/dist/types.d.ts +535 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/types.js +77 -0
  43. package/dist/types.js.map +1 -0
  44. package/engine.ts +928 -0
  45. package/examples.ts +717 -0
  46. package/index.ts +106 -0
  47. package/learning.ts +779 -0
  48. package/package.json +51 -0
  49. package/planning.ts +1028 -0
  50. package/reasoning.ts +1019 -0
  51. package/search-discovery.ts +654 -0
  52. package/tsconfig.json +25 -0
  53. package/types.ts +674 -0
package/examples.ts ADDED
@@ -0,0 +1,717 @@
1
+ /**
2
+ * Sequential Thinking System - Examples
3
+ * ตัวอย่างการใช้งานที่ครอบคลุมทุกฟีเจอร์
4
+ */
5
+
6
+ import {
7
+ // Core
8
+ SequentialThinkingEngine,
9
+ thinkingEngine,
10
+ think,
11
+ analyze,
12
+ solveCreatively,
13
+ createPlan,
14
+
15
+ // Engines
16
+ searchEngine,
17
+ analysisEngine,
18
+ reasoningEngine,
19
+ learningEngine,
20
+ planningEngine,
21
+ creativityEngine,
22
+
23
+ // Types
24
+ ThinkingStage,
25
+ ReasoningType,
26
+ SourceType,
27
+ Priority,
28
+ TaskStatus
29
+ } from './index';
30
+
31
+ // ============================================================================
32
+ // EXAMPLE 1: BASIC USAGE
33
+ // ============================================================================
34
+
35
+ async function basicUsageExample() {
36
+ console.log('=== Example 1: Basic Usage ===\n');
37
+
38
+ // Simple query
39
+ const response = await thinkingEngine.think({
40
+ id: 'basic_1',
41
+ query: 'What are the benefits of TypeScript over JavaScript?'
42
+ });
43
+
44
+ console.log('Query: What are the benefits of TypeScript over JavaScript?');
45
+ console.log('Answer:', response.finalAnswer);
46
+ console.log('Confidence:', response.confidence);
47
+ console.log('Processing Time:', response.processingTime, 'ms');
48
+ console.log('Stages executed:', response.stages.map(s => s.stage).join(', '));
49
+ console.log();
50
+ }
51
+
52
+ // ============================================================================
53
+ // EXAMPLE 2: QUICK SEARCH
54
+ // ============================================================================
55
+
56
+ async function quickSearchExample() {
57
+ console.log('=== Example 2: Quick Search ===\n');
58
+
59
+ // Using convenience function
60
+ const answer = await think('Latest AI breakthroughs 2024');
61
+
62
+ console.log('Query: Latest AI breakthroughs 2024');
63
+ console.log('Answer:', answer.substring(0, 500) + '...');
64
+ console.log();
65
+ }
66
+
67
+ // ============================================================================
68
+ // EXAMPLE 3: DEEP ANALYSIS
69
+ // ============================================================================
70
+
71
+ async function deepAnalysisExample() {
72
+ console.log('=== Example 3: Deep Analysis ===\n');
73
+
74
+ const response = await thinkingEngine.deepAnalysis(
75
+ 'Impact of climate change on global food security',
76
+ 'Focus on developing countries and agricultural adaptation strategies'
77
+ );
78
+
79
+ console.log('Query: Impact of climate change on global food security');
80
+ console.log('Context: Focus on developing countries');
81
+ console.log('Answer:', response.finalAnswer.substring(0, 800) + '...');
82
+ console.log('Metadata:', response.metadata);
83
+ console.log();
84
+ }
85
+
86
+ // ============================================================================
87
+ // EXAMPLE 4: CREATIVE PROBLEM SOLVING
88
+ // ============================================================================
89
+
90
+ async function creativeProblemSolvingExample() {
91
+ console.log('=== Example 4: Creative Problem Solving ===\n');
92
+
93
+ const response = await thinkingEngine.creativeSolve(
94
+ 'How can we make public transportation more appealing to young professionals?'
95
+ );
96
+
97
+ console.log('Problem: How can we make public transportation more appealing?');
98
+ console.log('Solution:', response.finalAnswer.substring(0, 800) + '...');
99
+ console.log('Ideas Generated:', response.metadata.ideasGenerated);
100
+ console.log();
101
+ }
102
+
103
+ // ============================================================================
104
+ // EXAMPLE 5: SEARCH MODULE
105
+ // ============================================================================
106
+
107
+ async function searchModuleExample() {
108
+ console.log('=== Example 5: Search Module ===\n');
109
+
110
+ // Basic search
111
+ const results = await searchEngine.search('machine learning applications', {
112
+ maxResults: 5,
113
+ sources: [SourceType.WEB, SourceType.KNOWLEDGE_BASE],
114
+ filters: {
115
+ minCredibility: 0.7,
116
+ language: 'en'
117
+ }
118
+ });
119
+
120
+ console.log('Search: machine learning applications');
121
+ console.log('Results found:', results.length);
122
+
123
+ results.slice(0, 3).forEach((result, i) => {
124
+ console.log(`\n${i + 1}. ${result.title}`);
125
+ console.log(` Credibility: ${result.credibility}`);
126
+ console.log(` Relevance: ${result.relevance}`);
127
+ console.log(` Snippet: ${result.snippet.substring(0, 100)}...`);
128
+ });
129
+
130
+ // Multi-search with aggregation
131
+ const aggregatedResults = await searchEngine.multiSearch([
132
+ 'AI in healthcare',
133
+ 'machine learning medical diagnosis',
134
+ 'healthcare automation technology'
135
+ ], {
136
+ aggregate: true,
137
+ maxResultsPerQuery: 5
138
+ });
139
+
140
+ console.log('\nAggregated Topics:', (aggregatedResults as any).length);
141
+ console.log();
142
+ }
143
+
144
+ // ============================================================================
145
+ // EXAMPLE 6: ANALYSIS MODULE
146
+ // ============================================================================
147
+
148
+ async function analysisModuleExample() {
149
+ console.log('=== Example 6: Analysis Module ===\n');
150
+
151
+ const content = `
152
+ Artificial Intelligence is transforming the healthcare industry in remarkable ways.
153
+ Machine learning algorithms can now detect diseases with unprecedented accuracy.
154
+ However, there are legitimate concerns about privacy and data security.
155
+ The future of AI in healthcare looks promising, but we must address these challenges.
156
+ Many experts believe that AI will augment rather than replace human doctors.
157
+ `;
158
+
159
+ const analysis = await analysisEngine.analyze(content, {
160
+ types: ['sentiment', 'entity', 'topic', 'keyword', 'summary'],
161
+ depth: 'deep',
162
+ context: 'Healthcare technology analysis'
163
+ });
164
+
165
+ console.log('Content analyzed:', content.substring(0, 100) + '...');
166
+ console.log('Analysis types:', analysis.map(a => a.type).join(', '));
167
+
168
+ analysis.forEach(result => {
169
+ console.log(`\n${result.type.toUpperCase()}:`);
170
+ console.log(` Confidence: ${result.confidence}`);
171
+ console.log(` Findings: ${result.findings.length}`);
172
+ result.findings.slice(0, 2).forEach((finding, i) => {
173
+ console.log(` ${i + 1}. ${JSON.stringify(finding.value).substring(0, 80)}...`);
174
+ });
175
+ });
176
+
177
+ // Comparison
178
+ const comparison = analysisEngine.compare(
179
+ ['Article A', 'Article B'],
180
+ [
181
+ 'AI is revolutionizing healthcare with machine learning.',
182
+ 'Machine learning brings both opportunities and challenges to medicine.'
183
+ ]
184
+ );
185
+
186
+ console.log('\nComparison:');
187
+ console.log(' Similarities:', comparison.similarities.length);
188
+ console.log(' Differences:', comparison.differences.length);
189
+ console.log(' Conclusion:', comparison.conclusion);
190
+ console.log();
191
+ }
192
+
193
+ // ============================================================================
194
+ // EXAMPLE 7: REASONING MODULE
195
+ // ============================================================================
196
+
197
+ async function reasoningModuleExample() {
198
+ console.log('=== Example 7: Reasoning Module ===\n');
199
+
200
+ // Deductive reasoning
201
+ const deductiveResult = await reasoningEngine.reason(
202
+ 'All software requires maintenance. This application is software. Therefore...',
203
+ { type: ReasoningType.DEDUCTIVE, maxSteps: 3 }
204
+ );
205
+
206
+ console.log('Deductive Reasoning:');
207
+ console.log(' Problem:', deductiveResult.problem);
208
+ console.log(' Conclusion:', deductiveResult.conclusion);
209
+ console.log(' Steps:', deductiveResult.steps.length);
210
+ console.log(' Confidence:', deductiveResult.confidence);
211
+
212
+ // Inductive reasoning
213
+ const inductiveResult = await reasoningEngine.reason(
214
+ 'Every software project with good documentation succeeded. ' +
215
+ 'Projects with poor documentation often failed. Therefore...',
216
+ { type: ReasoningType.INDUCTIVE, maxSteps: 4 }
217
+ );
218
+
219
+ console.log('\nInductive Reasoning:');
220
+ console.log(' Conclusion:', inductiveResult.conclusion);
221
+
222
+ // Hypothesis testing
223
+ const hypothesis = reasoningEngine.createHypothesis(
224
+ 'Using TypeScript reduces bug count by 30%'
225
+ );
226
+
227
+ reasoningEngine.addEvidenceToHypothesis(
228
+ hypothesis.id,
229
+ {
230
+ source: 'research_study',
231
+ excerpt: 'TypeScript projects had 15% fewer bugs on average',
232
+ location: 'paper_section_3',
233
+ strength: 0.8
234
+ },
235
+ true
236
+ );
237
+
238
+ console.log('\nHypothesis:', hypothesis.statement);
239
+ console.log(' Status:', hypothesis.status);
240
+ console.log(' Confidence:', hypothesis.confidence);
241
+
242
+ // Problem decomposition
243
+ const decomposition = reasoningEngine.decomposeProblem(
244
+ 'Build a scalable microservices architecture with AI capabilities'
245
+ );
246
+
247
+ console.log('\nProblem Decomposition:');
248
+ console.log(' Original:', decomposition.originalProblem);
249
+ console.log(' Sub-problems:', decomposition.subProblems.length);
250
+ console.log(' Strategy:', decomposition.solutionStrategy);
251
+
252
+ // Chain of Thought
253
+ const cot = reasoningEngine.generateChainOfThought(
254
+ 'How can we improve software development productivity?',
255
+ 4
256
+ );
257
+
258
+ console.log('\nChain of Thought:');
259
+ console.log(' Question:', cot.initialQuestion);
260
+ console.log(' Thoughts:', cot.thoughts.length);
261
+ console.log(' Completeness:', cot.completeness);
262
+ console.log();
263
+ }
264
+
265
+ // ============================================================================
266
+ // EXAMPLE 8: LEARNING MODULE
267
+ // ============================================================================
268
+
269
+ async function learningModuleExample() {
270
+ console.log('=== Example 8: Learning Module ===\n');
271
+
272
+ // Create context
273
+ const context = learningEngine.getOrCreateContext('session_123', 'user_456');
274
+ console.log('Learning Context created:', context.id);
275
+
276
+ // Record interactions
277
+ const interaction1 = learningEngine.recordInteraction(
278
+ 'session_123',
279
+ 'What are the benefits of TypeScript?',
280
+ 'TypeScript offers type safety, better IDE support, and easier refactoring...'
281
+ );
282
+
283
+ const interaction2 = learningEngine.recordInteraction(
284
+ 'session_123',
285
+ 'How do I set up TypeScript?',
286
+ 'To set up TypeScript, first install it with npm install typescript...',
287
+ { rating: 5, helpful: true, comments: 'Very helpful explanation!' }
288
+ );
289
+
290
+ console.log('Interactions recorded:', 2);
291
+
292
+ // Get relevant context
293
+ const relevant = learningEngine.getRelevantContext(
294
+ 'session_123',
295
+ 'TypeScript configuration'
296
+ );
297
+
298
+ console.log('Relevant interactions:', relevant.interactions.length);
299
+ console.log('Relevant patterns:', relevant.patterns.length);
300
+ console.log('Context summary:', relevant.summary.substring(0, 100) + '...');
301
+
302
+ // Add knowledge
303
+ const node = learningEngine.addKnowledge(
304
+ 'TypeScript',
305
+ 'concept',
306
+ {
307
+ category: 'programming_language',
308
+ creator: 'Microsoft',
309
+ releaseYear: 2012
310
+ },
311
+ ['official_documentation', 'wikipedia']
312
+ );
313
+
314
+ console.log('\nKnowledge added:', node.label, '(', node.id, ')');
315
+
316
+ // Connect knowledge
317
+ const jsNode = learningEngine.addKnowledge(
318
+ 'JavaScript',
319
+ 'concept',
320
+ { category: 'programming_language' },
321
+ ['mdn']
322
+ );
323
+
324
+ learningEngine.connectKnowledge(
325
+ node.id,
326
+ jsNode.id,
327
+ 'superset_of',
328
+ 0.95,
329
+ ['TypeScript is a superset of JavaScript']
330
+ );
331
+
332
+ console.log('Knowledge connected:', node.label, '->', jsNode.label);
333
+
334
+ // Query knowledge
335
+ const results = learningEngine.queryKnowledge('programming');
336
+ console.log('Knowledge query results:', results.length);
337
+
338
+ // Get patterns
339
+ const patterns = learningEngine.getTopPatterns(5);
340
+ console.log('Top patterns:', patterns.length);
341
+ console.log();
342
+ }
343
+
344
+ // ============================================================================
345
+ // EXAMPLE 9: PLANNING MODULE
346
+ // ============================================================================
347
+
348
+ async function planningModuleExample() {
349
+ console.log('=== Example 9: Planning Module ===\n');
350
+
351
+ // Create a plan
352
+ const plan = planningEngine.createPlan(
353
+ 'Build a scalable e-commerce platform with AI recommendations',
354
+ {
355
+ resources: [
356
+ {
357
+ id: 'dev1',
358
+ type: 'human',
359
+ name: 'Senior Backend Developer',
360
+ availability: 0.8,
361
+ skills: ['backend', 'microservices', 'typescript', 'nodejs']
362
+ },
363
+ {
364
+ id: 'dev2',
365
+ type: 'human',
366
+ name: 'ML Engineer',
367
+ availability: 0.6,
368
+ skills: ['machine_learning', 'python', 'tensorflow', 'recommendation_systems']
369
+ },
370
+ {
371
+ id: 'dev3',
372
+ type: 'human',
373
+ name: 'Frontend Developer',
374
+ availability: 0.9,
375
+ skills: ['frontend', 'react', 'typescript']
376
+ }
377
+ ],
378
+ deadline: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000) // 90 days
379
+ }
380
+ );
381
+
382
+ console.log('Plan created:', plan.id);
383
+ console.log('Goal:', plan.goal);
384
+ console.log('Tasks:', plan.tasks.length);
385
+ console.log('Milestones:', plan.milestones.length);
386
+ console.log('Resources:', plan.resources.length);
387
+
388
+ // Display tasks
389
+ console.log('\nTasks (Top 5):');
390
+ plan.tasks.slice(0, 5).forEach((task, i) => {
391
+ console.log(` ${i + 1}. ${task.title}`);
392
+ console.log(` Priority: ${Priority[task.priority]}`);
393
+ console.log(` Duration: ${task.estimatedDuration} minutes`);
394
+ console.log(` Assigned to: ${task.assignedTo || 'Unassigned'}`);
395
+ });
396
+
397
+ // Update task progress
398
+ planningEngine.updateTaskProgress(plan.id, plan.tasks[0].id, 50, TaskStatus.IN_PROGRESS);
399
+ planningEngine.updateTaskProgress(plan.id, plan.tasks[0].id, 100, TaskStatus.COMPLETED);
400
+
401
+ console.log('\nTask progress updated');
402
+
403
+ // Generate progress report
404
+ const report = planningEngine.generateProgressReport(plan.id);
405
+
406
+ console.log('\nProgress Report:');
407
+ console.log(' Overall Progress:', report.overallProgress.toFixed(1), '%');
408
+ console.log(' Completed Tasks:', report.completedTasks, '/', report.totalTasks);
409
+ console.log(' On Track:', report.onTrack);
410
+ console.log(' Risks:', report.risks.length);
411
+ console.log(' Next Actions:', report.nextActions);
412
+
413
+ // Adjust plan
414
+ const adjustedPlan = planningEngine.adjustPlan(plan.id, {
415
+ addTasks: [
416
+ {
417
+ title: 'Security audit',
418
+ description: 'Perform comprehensive security review',
419
+ priority: Priority.HIGH,
420
+ status: TaskStatus.PENDING,
421
+ estimatedDuration: 480, // 8 hours
422
+ dependencies: [],
423
+ subtasks: [],
424
+ tags: ['security', 'audit']
425
+ }
426
+ ]
427
+ });
428
+
429
+ console.log('\nPlan adjusted. New task count:', adjustedPlan.tasks.length);
430
+ console.log();
431
+ }
432
+
433
+ // ============================================================================
434
+ // EXAMPLE 10: CREATIVITY MODULE
435
+ // ============================================================================
436
+
437
+ async function creativityModuleExample() {
438
+ console.log('=== Example 10: Creativity Module ===\n');
439
+
440
+ // Start creative session
441
+ const session = creativityEngine.startSession(
442
+ 'How can we improve remote team collaboration?',
443
+ {
444
+ techniques: [
445
+ 'brainstorming',
446
+ 'scamper',
447
+ 'six_thinking_hats'
448
+ ],
449
+ ideaCount: 20
450
+ }
451
+ );
452
+
453
+ console.log('Creative Session:', session.id);
454
+ console.log('Prompt:', session.prompt);
455
+ console.log('Techniques used:', session.techniques.join(', '));
456
+ console.log('Ideas generated:', session.ideas.length);
457
+ console.log('Connections found:', session.connections.length);
458
+ console.log('Session duration:', session.sessionDuration, 'ms');
459
+
460
+ // Display top ideas
461
+ console.log('\nTop Ideas:');
462
+ const topIdeas = session.ideas
463
+ .sort((a, b) => (b.novelty + b.feasibility + b.impact) - (a.novelty + a.feasibility + a.impact))
464
+ .slice(0, 5);
465
+
466
+ topIdeas.forEach((idea, i) => {
467
+ console.log(` ${i + 1}. ${idea.content.substring(0, 80)}...`);
468
+ console.log(` Novelty: ${idea.novelty.toFixed(2)}`);
469
+ console.log(` Feasibility: ${idea.feasibility.toFixed(2)}`);
470
+ console.log(` Impact: ${idea.impact.toFixed(2)}`);
471
+ console.log(` Technique: ${idea.technique}`);
472
+ });
473
+
474
+ // Out-of-box thinking
475
+ const outOfBox = creativityEngine.thinkOutOfBox(
476
+ 'Our product has low user engagement'
477
+ );
478
+
479
+ console.log('\nOut-of-Box Thinking:');
480
+ console.log(' Original Problem:', outOfBox.originalProblem);
481
+ console.log(' Breakthrough Potential:', outOfBox.breakthroughPotential.toFixed(2));
482
+ console.log(' Reframed Perspectives:', outOfBox.reframedProblems.length);
483
+
484
+ outOfBox.reframedProblems.slice(0, 3).forEach((reframe, i) => {
485
+ console.log(`\n ${i + 1}. ${reframe.perspective}`);
486
+ console.log(` Statement: ${reframe.reframedStatement.substring(0, 80)}...`);
487
+ });
488
+
489
+ // Generate combinations
490
+ const combinations = creativityEngine.generateCombinations(
491
+ ['AI', 'collaboration', 'gamification', 'VR', 'blockchain'],
492
+ 5
493
+ );
494
+
495
+ console.log('\nNovel Combinations:');
496
+ combinations.forEach((combo, i) => {
497
+ console.log(` ${i + 1}. ${combo}`);
498
+ });
499
+
500
+ // Apply SCAMPER
501
+ const scamperResults = creativityEngine.applyScamper(
502
+ 'Traditional education system'
503
+ );
504
+
505
+ console.log('\nSCAMPER Analysis:');
506
+ scamperResults.forEach((result, i) => {
507
+ console.log(` ${result.technique}:`);
508
+ console.log(` Q: ${result.question}`);
509
+ console.log(` Idea: ${result.idea}`);
510
+ });
511
+
512
+ // Apply Six Thinking Hats
513
+ const hatsAnalysis = creativityEngine.applySixHats(
514
+ 'Implementing AI in healthcare'
515
+ );
516
+
517
+ console.log('\nSix Thinking Hats:');
518
+ hatsAnalysis.forEach((result) => {
519
+ console.log(` ${result.hat} Hat (${result.perspective}):`);
520
+ result.insights.slice(0, 2).forEach(insight => {
521
+ console.log(` - ${insight}`);
522
+ });
523
+ });
524
+
525
+ console.log();
526
+ }
527
+
528
+ // ============================================================================
529
+ // EXAMPLE 11: ADVANCED CONFIGURATION
530
+ // ============================================================================
531
+
532
+ async function advancedConfigurationExample() {
533
+ console.log('=== Example 11: Advanced Configuration ===\n');
534
+
535
+ // Create custom engine with specific configuration
536
+ const customEngine = new SequentialThinkingEngine({
537
+ maxSearchResults: 15,
538
+ analysisDepth: 'deep',
539
+ reasoningComplexity: 'complex',
540
+ learningEnabled: true,
541
+ creativityLevel: 'adventurous',
542
+ planningDetail: 'granular',
543
+ timeout: 120000,
544
+ retryAttempts: 3
545
+ });
546
+
547
+ // Listen to events
548
+ customEngine.on('thinking_start', (event) => {
549
+ console.log('Event: Thinking started');
550
+ });
551
+
552
+ customEngine.on('search_complete', (event) => {
553
+ console.log('Event: Search completed');
554
+ });
555
+
556
+ customEngine.on('analysis_complete', (event) => {
557
+ console.log('Event: Analysis completed');
558
+ });
559
+
560
+ customEngine.on('reasoning_complete', (event) => {
561
+ console.log('Event: Reasoning completed');
562
+ });
563
+
564
+ customEngine.on('thinking_complete', (event) => {
565
+ console.log('Event: Thinking completed');
566
+ });
567
+
568
+ // Execute with specific stages
569
+ const response = await customEngine.think({
570
+ id: 'advanced_1',
571
+ query: 'What are the ethical implications of autonomous weapons?',
572
+ preferredStages: [
573
+ ThinkingStage.SEARCH,
574
+ ThinkingStage.ANALYSIS,
575
+ ThinkingStage.REASONING,
576
+ ThinkingStage.CREATIVITY,
577
+ ThinkingStage.SYNTHESIS
578
+ ],
579
+ config: {
580
+ analysisDepth: 'deep',
581
+ reasoningComplexity: 'complex',
582
+ creativityLevel: 'adventurous'
583
+ },
584
+ timeout: 90000
585
+ });
586
+
587
+ console.log('\nAdvanced Query: What are the ethical implications of autonomous weapons?');
588
+ console.log('Stages executed:', response.stages.map(s => s.stage).join(' → '));
589
+ console.log('Confidence:', response.confidence.toFixed(2));
590
+ console.log('Processing Time:', response.processingTime, 'ms');
591
+ console.log('Sources Used:', response.metadata.sourcesUsed);
592
+ console.log('Reasoning Steps:', response.metadata.reasoningSteps);
593
+ console.log('Ideas Generated:', response.metadata.ideasGenerated);
594
+ console.log('\nAnswer preview:', response.finalAnswer.substring(0, 300) + '...');
595
+ console.log();
596
+ }
597
+
598
+ // ============================================================================
599
+ // EXAMPLE 12: COMPLETE WORKFLOW
600
+ // ============================================================================
601
+
602
+ async function completeWorkflowExample() {
603
+ console.log('=== Example 12: Complete Workflow ===\n');
604
+
605
+ // Scenario: A company wants to enter a new market
606
+
607
+ console.log('Scenario: Company wants to enter the Asian market with AI products\n');
608
+
609
+ // Step 1: Research
610
+ console.log('Step 1: Researching market...');
611
+ const researchResponse = await thinkingEngine.think({
612
+ id: 'workflow_research',
613
+ query: 'AI market trends and opportunities in Asia 2024',
614
+ preferredStages: [ThinkingStage.SEARCH, ThinkingStage.ANALYSIS, ThinkingStage.SYNTHESIS],
615
+ config: { analysisDepth: 'deep' }
616
+ });
617
+
618
+ console.log('Research completed. Key findings:', researchResponse.metadata.sourcesUsed, 'sources');
619
+
620
+ // Step 2: Strategic Analysis
621
+ console.log('\nStep 2: Strategic analysis...');
622
+ const strategyResponse = await thinkingEngine.think({
623
+ id: 'workflow_strategy',
624
+ query: 'What are the competitive advantages needed for AI companies in Asian markets?',
625
+ preferredStages: [ThinkingStage.SEARCH, ThinkingStage.ANALYSIS, ThinkingStage.REASONING, ThinkingStage.SYNTHESIS],
626
+ config: { reasoningComplexity: 'complex' }
627
+ });
628
+
629
+ console.log('Strategy analysis completed. Reasoning steps:', strategyResponse.metadata.reasoningSteps);
630
+
631
+ // Step 3: Creative Solutions
632
+ console.log('\nStep 3: Generating creative approaches...');
633
+ const creativeResponse = await thinkingEngine.creativeSolve(
634
+ 'How can an AI company differentiate itself in competitive Asian markets?'
635
+ );
636
+
637
+ console.log('Creative solutions generated:', creativeResponse.metadata.ideasGenerated, 'ideas');
638
+
639
+ // Step 4: Create Implementation Plan
640
+ console.log('\nStep 4: Creating implementation plan...');
641
+ const plan = await thinkingEngine.createPlan(
642
+ 'Launch AI product in Asian markets within 12 months',
643
+ {
644
+ resources: [
645
+ { id: 'pm1', type: 'human', name: 'Product Manager', availability: 1.0, skills: ['product', 'strategy'] },
646
+ { id: 'dev1', type: 'human', name: 'Engineering Team', availability: 0.8, skills: ['ai', 'development'] },
647
+ { id: 'mkt1', type: 'human', name: 'Marketing Team', availability: 0.7, skills: ['marketing', 'localization'] }
648
+ ],
649
+ deadline: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000)
650
+ }
651
+ );
652
+
653
+ console.log('Plan created with', plan.tasks.length, 'tasks');
654
+
655
+ // Step 5: Generate Progress Report
656
+ console.log('\nStep 5: Initial progress assessment...');
657
+ const progressReport = planningEngine.generateProgressReport(plan.id);
658
+
659
+ console.log('Progress Report:');
660
+ console.log(' - Overall Progress:', progressReport.overallProgress.toFixed(1), '%');
661
+ console.log(' - On Track:', progressReport.onTrack);
662
+ console.log(' - Identified Risks:', progressReport.risks.length);
663
+ console.log(' - Next Actions:', progressReport.nextActions.length);
664
+
665
+ // Summary
666
+ console.log('\n=== Workflow Summary ===');
667
+ console.log('✓ Market research completed');
668
+ console.log('✓ Strategic analysis completed');
669
+ console.log('✓ Creative solutions generated');
670
+ console.log('✓ Implementation plan created');
671
+ console.log('✓ Progress tracking initiated');
672
+ console.log('\nThe company now has:');
673
+ console.log(' - Comprehensive market understanding');
674
+ console.log(' - Strategic recommendations');
675
+ console.log(' - Creative differentiation ideas');
676
+ console.log(' - Detailed implementation roadmap');
677
+ console.log();
678
+ }
679
+
680
+ // ============================================================================
681
+ // RUN ALL EXAMPLES
682
+ // ============================================================================
683
+
684
+ async function runAllExamples() {
685
+ console.log('╔════════════════════════════════════════════════════════════════╗');
686
+ console.log('║ Sequential Thinking System - Comprehensive Examples ║');
687
+ console.log('╚════════════════════════════════════════════════════════════════╝\n');
688
+
689
+ try {
690
+ await basicUsageExample();
691
+ await quickSearchExample();
692
+ await deepAnalysisExample();
693
+ await creativeProblemSolvingExample();
694
+ await searchModuleExample();
695
+ await analysisModuleExample();
696
+ await reasoningModuleExample();
697
+ await learningModuleExample();
698
+ await planningModuleExample();
699
+ await creativityModuleExample();
700
+ await advancedConfigurationExample();
701
+ await completeWorkflowExample();
702
+
703
+ console.log('╔════════════════════════════════════════════════════════════════╗');
704
+ console.log('║ All examples completed successfully! ║');
705
+ console.log('╚════════════════════════════════════════════════════════════════╝');
706
+
707
+ } catch (error) {
708
+ console.error('Error running examples:', error);
709
+ }
710
+ }
711
+
712
+ // Run examples if this file is executed directly
713
+ if (require.main === module) {
714
+ runAllExamples();
715
+ }
716
+
717
+ export { runAllExamples };