gthinking 1.2.0 → 1.3.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 (72) hide show
  1. package/README.md +10 -0
  2. package/dist/engine.d.ts +15 -1
  3. package/dist/engine.d.ts.map +1 -1
  4. package/dist/engine.js +53 -12
  5. package/dist/engine.js.map +1 -1
  6. package/dist/llm-service.d.ts +1 -0
  7. package/dist/llm-service.d.ts.map +1 -1
  8. package/dist/llm-service.js +34 -16
  9. package/dist/llm-service.js.map +1 -1
  10. package/dist/planning.d.ts +5 -1
  11. package/dist/planning.d.ts.map +1 -1
  12. package/dist/planning.js +62 -0
  13. package/dist/planning.js.map +1 -1
  14. package/dist/types/analysis.d.ts +54 -0
  15. package/dist/types/analysis.d.ts.map +1 -0
  16. package/dist/types/analysis.js +3 -0
  17. package/dist/types/analysis.js.map +1 -0
  18. package/dist/types/core.d.ts +66 -0
  19. package/dist/types/core.d.ts.map +1 -0
  20. package/dist/types/core.js +61 -0
  21. package/dist/types/core.js.map +1 -0
  22. package/dist/types/creativity.d.ts +58 -0
  23. package/dist/types/creativity.d.ts.map +1 -0
  24. package/dist/types/creativity.js +3 -0
  25. package/dist/types/creativity.js.map +1 -0
  26. package/dist/types/engine.d.ts +55 -0
  27. package/dist/types/engine.d.ts.map +1 -0
  28. package/dist/types/engine.js +3 -0
  29. package/dist/types/engine.js.map +1 -0
  30. package/dist/types/index.d.ts +10 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/index.js +26 -0
  33. package/dist/types/index.js.map +1 -0
  34. package/dist/types/learning.d.ts +62 -0
  35. package/dist/types/learning.d.ts.map +1 -0
  36. package/dist/types/learning.js +3 -0
  37. package/dist/types/learning.js.map +1 -0
  38. package/dist/types/planning.d.ts +78 -0
  39. package/dist/types/planning.d.ts.map +1 -0
  40. package/dist/types/planning.js +3 -0
  41. package/dist/types/planning.js.map +1 -0
  42. package/dist/types/reasoning.d.ts +83 -0
  43. package/dist/types/reasoning.d.ts.map +1 -0
  44. package/dist/types/reasoning.js +13 -0
  45. package/dist/types/reasoning.js.map +1 -0
  46. package/dist/types/search.d.ts +56 -0
  47. package/dist/types/search.d.ts.map +1 -0
  48. package/dist/types/search.js +3 -0
  49. package/dist/types/search.js.map +1 -0
  50. package/dist/types/synthesis.d.ts +40 -0
  51. package/dist/types/synthesis.d.ts.map +1 -0
  52. package/dist/types/synthesis.js +3 -0
  53. package/dist/types/synthesis.js.map +1 -0
  54. package/dist/types.d.ts +1 -530
  55. package/dist/types.d.ts.map +1 -1
  56. package/dist/types.js +15 -70
  57. package/dist/types.js.map +1 -1
  58. package/engine.ts +85 -9
  59. package/llm-service.ts +39 -18
  60. package/package.json +1 -1
  61. package/planning.ts +73 -0
  62. package/types/analysis.ts +69 -0
  63. package/types/core.ts +90 -0
  64. package/types/creativity.ts +72 -0
  65. package/types/engine.ts +60 -0
  66. package/types/index.ts +9 -0
  67. package/types/learning.ts +69 -0
  68. package/types/planning.ts +85 -0
  69. package/types/reasoning.ts +92 -0
  70. package/types/search.ts +58 -0
  71. package/types/synthesis.ts +43 -0
  72. package/types.ts +1 -669
package/engine.ts CHANGED
@@ -95,6 +95,14 @@ class SynthesisEngine {
95
95
  const gaps = this.identifyGaps(searchResults, analysisResults);
96
96
  const uncertainties = this.identifyUncertainties(reasoningSession);
97
97
 
98
+ // Generate Devil's Advocate critique
99
+ const critique = this.generateCritique(
100
+ query,
101
+ insights,
102
+ recommendations,
103
+ uncertainties
104
+ );
105
+
98
106
  // Calculate confidence
99
107
  const confidence = this.calculateSynthesisConfidence(
100
108
  searchResults,
@@ -113,10 +121,41 @@ class SynthesisEngine {
113
121
  recommendations,
114
122
  confidence,
115
123
  gaps,
116
- uncertainties
124
+ uncertainties,
125
+ critique
117
126
  };
118
127
  }
119
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
+
120
159
  private extractInsights(
121
160
  searchResults: SearchResult[],
122
161
  analysisResults: AnalysisResult[],
@@ -255,6 +294,15 @@ class SynthesisEngine {
255
294
  // MAIN SEQUENTIAL THINKING ENGINE
256
295
  // ============================================================================
257
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
+
258
306
  export class SequentialThinkingEngine extends EventEmitter {
259
307
  private searchEngine: SearchDiscoveryEngine;
260
308
  private analysisEngine: AnalysisEngine;
@@ -267,7 +315,10 @@ export class SequentialThinkingEngine extends EventEmitter {
267
315
  private config: SequentialThinkingConfig;
268
316
  private sessions: Map<string, ThinkingSession> = new Map();
269
317
 
270
- constructor(config: Partial<SequentialThinkingConfig> = {}) {
318
+ constructor(
319
+ config: Partial<SequentialThinkingConfig> = {},
320
+ deps: SequentialThinkingEngineDeps = {}
321
+ ) {
271
322
  super();
272
323
 
273
324
  this.config = {
@@ -282,13 +333,15 @@ export class SequentialThinkingEngine extends EventEmitter {
282
333
  ...config
283
334
  };
284
335
 
285
- // Initialize all engines
286
- this.searchEngine = new SearchDiscoveryEngine();
287
- this.analysisEngine = new AnalysisEngine();
288
- this.reasoningEngine = new ReasoningEngine();
289
- this.learningEngine = new LearningEngine();
290
- this.planningEngine = new PlanningEngine();
291
- this.creativityEngine = new CreativityEngine();
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
292
345
  this.synthesisEngine = new SynthesisEngine();
293
346
 
294
347
  // Set up event forwarding
@@ -323,6 +376,21 @@ export class SequentialThinkingEngine extends EventEmitter {
323
376
  // Create or get session
324
377
  const session = this.getOrCreateSession(request);
325
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
+
326
394
  // Merge config
327
395
  const config = { ...this.config, ...request.config };
328
396
 
@@ -662,6 +730,14 @@ export class SequentialThinkingEngine extends EventEmitter {
662
730
  parts.push(reasoning.conclusion);
663
731
  }
664
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
+
665
741
  // Add creative insights
666
742
  if (creative) {
667
743
  parts.push('');
package/llm-service.ts CHANGED
@@ -1,8 +1,5 @@
1
1
 
2
- import { exec } from 'child_process';
3
- import { promisify } from 'util';
4
-
5
- const execAsync = promisify(exec);
2
+ import { spawn } from 'child_process';
6
3
 
7
4
  export type LLMProvider = 'gemini' | 'claude' | 'kimi' | 'opencode' | 'openai';
8
5
 
@@ -20,6 +17,39 @@ export class LLMService {
20
17
  this.detectProvider();
21
18
  }
22
19
 
20
+ private async spawnCommand(command: string, args: string[]): Promise<string> {
21
+ return new Promise((resolve, reject) => {
22
+ const child = spawn(command, args);
23
+ let stdout = '';
24
+ let stderr = '';
25
+
26
+ child.stdout.on('data', (data) => {
27
+ stdout += data.toString();
28
+ });
29
+
30
+ child.stderr.on('data', (data) => {
31
+ stderr += data.toString();
32
+ });
33
+
34
+ child.on('close', (code) => {
35
+ if (code === 0) {
36
+ resolve(stdout.trim());
37
+ } else {
38
+ // Check if it's just a command not found check (checking 'which')
39
+ if (command === 'which' && code === 1) {
40
+ reject(new Error('Command not found'));
41
+ return;
42
+ }
43
+ reject(new Error(`Command '${command}' failed with code ${code}: ${stderr}`));
44
+ }
45
+ });
46
+
47
+ child.on('error', (err) => {
48
+ reject(err);
49
+ });
50
+ });
51
+ }
52
+
23
53
  private async detectProvider() {
24
54
  if (process.env.LLM_PROVIDER) {
25
55
  this.defaultProvider = process.env.LLM_PROVIDER as LLMProvider;
@@ -31,7 +61,7 @@ export class LLMService {
31
61
 
32
62
  for (const p of providers) {
33
63
  try {
34
- await execAsync(`which ${p}`);
64
+ await this.spawnCommand('which', [p]);
35
65
  this.defaultProvider = p;
36
66
  break;
37
67
  } catch (e) {
@@ -71,28 +101,19 @@ export class LLMService {
71
101
  }
72
102
 
73
103
  private async callGemini(prompt: string): Promise<string> {
74
- // Escape double quotes for shell safety (basic)
75
- const safePrompt = prompt.replace(/"/g, '\\"');
76
- const { stdout } = await execAsync(`gemini "${safePrompt}"`);
77
- return stdout.trim();
104
+ return this.spawnCommand('gemini', [prompt]);
78
105
  }
79
106
 
80
107
  private async callClaude(prompt: string): Promise<string> {
81
- const safePrompt = prompt.replace(/"/g, '\\"');
82
- const { stdout } = await execAsync(`claude "${safePrompt}"`);
83
- return stdout.trim();
108
+ return this.spawnCommand('claude', [prompt]);
84
109
  }
85
110
 
86
111
  private async callKimi(prompt: string): Promise<string> {
87
- const safePrompt = prompt.replace(/"/g, '\\"');
88
- const { stdout } = await execAsync(`kimi "${safePrompt}"`);
89
- return stdout.trim();
112
+ return this.spawnCommand('kimi', [prompt]);
90
113
  }
91
114
 
92
115
  private async callOpenCode(prompt: string): Promise<string> {
93
- const safePrompt = prompt.replace(/"/g, '\\"');
94
- const { stdout } = await execAsync(`opencode "${safePrompt}"`);
95
- return stdout.trim();
116
+ return this.spawnCommand('opencode', [prompt]);
96
117
  }
97
118
  }
98
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gthinking",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "A comprehensive intelligent sequential thinking framework for complex problem solving",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/planning.ts CHANGED
@@ -562,6 +562,79 @@ export class PlanningEngine extends EventEmitter {
562
562
  this.riskAnalyzer = new RiskAnalyzer();
563
563
  }
564
564
 
565
+ /**
566
+ * Dynamically determine the required thinking stages based on the query
567
+ */
568
+ determineThinkingStages(query: string): ThinkingStage[] {
569
+ const stages: ThinkingStage[] = [];
570
+ const lowerQuery = query.toLowerCase();
571
+
572
+ // Always include Analysis and Synthesis
573
+ stages.push(ThinkingStage.ANALYSIS);
574
+
575
+ // Search needed?
576
+ if (
577
+ lowerQuery.includes('search') ||
578
+ lowerQuery.includes('find') ||
579
+ lowerQuery.includes('what is') ||
580
+ lowerQuery.includes('latest') ||
581
+ lowerQuery.includes('research')
582
+ ) {
583
+ stages.push(ThinkingStage.SEARCH);
584
+ }
585
+
586
+ // Reasoning needed? (Default to yes for most queries unless very simple)
587
+ if (
588
+ lowerQuery.includes('why') ||
589
+ lowerQuery.includes('how') ||
590
+ lowerQuery.includes('compare') ||
591
+ lowerQuery.includes('analyze') ||
592
+ lowerQuery.includes('reason') ||
593
+ stages.length === 1 // If only analysis so far, add reasoning
594
+ ) {
595
+ stages.push(ThinkingStage.REASONING);
596
+ }
597
+
598
+ // Creativity needed?
599
+ if (
600
+ lowerQuery.includes('create') ||
601
+ lowerQuery.includes('idea') ||
602
+ lowerQuery.includes('brainstorm') ||
603
+ lowerQuery.includes('innovate') ||
604
+ lowerQuery.includes('design') ||
605
+ lowerQuery.includes('generate')
606
+ ) {
607
+ stages.push(ThinkingStage.CREATIVITY);
608
+ }
609
+
610
+ // Planning needed?
611
+ if (
612
+ lowerQuery.includes('plan') ||
613
+ lowerQuery.includes('roadmap') ||
614
+ lowerQuery.includes('schedule') ||
615
+ lowerQuery.includes('timeline') ||
616
+ lowerQuery.includes('project') ||
617
+ lowerQuery.includes('steps to')
618
+ ) {
619
+ stages.push(ThinkingStage.PLANNING);
620
+ }
621
+
622
+ // Ensure logical order
623
+ const orderedStages: ThinkingStage[] = [];
624
+ if (stages.includes(ThinkingStage.SEARCH)) orderedStages.push(ThinkingStage.SEARCH);
625
+ if (stages.includes(ThinkingStage.ANALYSIS)) orderedStages.push(ThinkingStage.ANALYSIS);
626
+ if (stages.includes(ThinkingStage.REASONING)) orderedStages.push(ThinkingStage.REASONING);
627
+ // Learning is usually implicit/config-based, but we can add it if context is key
628
+ // stages.push(ThinkingStage.LEARNING);
629
+ if (stages.includes(ThinkingStage.PLANNING)) orderedStages.push(ThinkingStage.PLANNING);
630
+ if (stages.includes(ThinkingStage.CREATIVITY)) orderedStages.push(ThinkingStage.CREATIVITY);
631
+
632
+ // Always synthesis at the end
633
+ orderedStages.push(ThinkingStage.SYNTHESIS);
634
+
635
+ return orderedStages;
636
+ }
637
+
565
638
  /**
566
639
  * Create a comprehensive plan
567
640
  */
@@ -0,0 +1,69 @@
1
+ import { SearchResult } from './search';
2
+
3
+ export interface AnalysisRequest {
4
+ id: string;
5
+ content: string;
6
+ analysisTypes: AnalysisType[];
7
+ context?: string;
8
+ depth: 'surface' | 'moderate' | 'deep';
9
+ }
10
+
11
+ export type AnalysisType =
12
+ | 'sentiment'
13
+ | 'entity'
14
+ | 'topic'
15
+ | 'keyword'
16
+ | 'summary'
17
+ | 'fact_check'
18
+ | 'comparison'
19
+ | 'trend';
20
+
21
+ export interface AnalysisResult {
22
+ id: string;
23
+ requestId: string;
24
+ type: AnalysisType;
25
+ findings: Finding[];
26
+ confidence: number;
27
+ processingTime: number;
28
+ timestamp: Date;
29
+ }
30
+
31
+ export interface Finding {
32
+ id: string;
33
+ type: string;
34
+ value: unknown;
35
+ confidence: number;
36
+ evidence: Evidence[];
37
+ relatedFindings: string[];
38
+ }
39
+
40
+ export interface Evidence {
41
+ source: string;
42
+ excerpt: string;
43
+ location: string;
44
+ strength: number;
45
+ }
46
+
47
+ export interface ComparisonResult {
48
+ id: string;
49
+ subjects: string[];
50
+ similarities: ComparisonPoint[];
51
+ differences: ComparisonPoint[];
52
+ conclusion: string;
53
+ confidence: number;
54
+ }
55
+
56
+ export interface ComparisonPoint {
57
+ aspect: string;
58
+ values: Record<string, unknown>;
59
+ significance: number;
60
+ }
61
+
62
+ export interface FactCheckResult {
63
+ claim: string;
64
+ verdict: 'true' | 'false' | 'partially_true' | 'unverifiable';
65
+ confidence: number;
66
+ sources: SearchResult[];
67
+ explanation: string;
68
+ corrections?: string[];
69
+ }
package/types/core.ts ADDED
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Core Types and Enums
3
+ */
4
+
5
+ export enum ThinkingStage {
6
+ SEARCH = 'search',
7
+ ANALYSIS = 'analysis',
8
+ REASONING = 'reasoning',
9
+ LEARNING = 'learning',
10
+ PLANNING = 'planning',
11
+ CREATIVITY = 'creativity',
12
+ SYNTHESIS = 'synthesis',
13
+ EVALUATION = 'evaluation'
14
+ }
15
+
16
+ export enum ConfidenceLevel {
17
+ VERY_LOW = 0.1,
18
+ LOW = 0.3,
19
+ MEDIUM = 0.5,
20
+ HIGH = 0.7,
21
+ VERY_HIGH = 0.9
22
+ }
23
+
24
+ export enum Priority {
25
+ CRITICAL = 1,
26
+ HIGH = 2,
27
+ MEDIUM = 3,
28
+ LOW = 4,
29
+ MINIMAL = 5
30
+ }
31
+
32
+ export enum TaskStatus {
33
+ PENDING = 'pending',
34
+ IN_PROGRESS = 'in_progress',
35
+ COMPLETED = 'completed',
36
+ FAILED = 'failed',
37
+ CANCELLED = 'cancelled'
38
+ }
39
+
40
+ export enum SourceType {
41
+ WEB = 'web',
42
+ DATABASE = 'database',
43
+ API = 'api',
44
+ CACHE = 'cache',
45
+ KNOWLEDGE_BASE = 'knowledge_base',
46
+ USER_INPUT = 'user_input'
47
+ }
48
+
49
+ export type ThinkingEventType =
50
+ | 'stage_start'
51
+ | 'stage_complete'
52
+ | 'stage_error'
53
+ | 'insight_found'
54
+ | 'confidence_update'
55
+ | 'search_result'
56
+ | 'analysis_complete'
57
+ | 'reasoning_step'
58
+ | 'plan_created'
59
+ | 'idea_generated';
60
+
61
+ export interface ThinkingEvent {
62
+ id: string;
63
+ type: ThinkingEventType;
64
+ stage: ThinkingStage;
65
+ timestamp: Date;
66
+ data: unknown;
67
+ sessionId: string;
68
+ }
69
+
70
+ export interface EventHandler {
71
+ (event: ThinkingEvent): void | Promise<void>;
72
+ }
73
+
74
+ export class ThinkingError extends Error {
75
+ constructor(
76
+ message: string,
77
+ public stage: ThinkingStage,
78
+ public recoverable: boolean,
79
+ public originalError?: Error
80
+ ) {
81
+ super(message);
82
+ this.name = 'ThinkingError';
83
+ }
84
+ }
85
+
86
+ export interface ErrorRecoveryStrategy {
87
+ stage: ThinkingStage;
88
+ condition: (error: ThinkingError) => boolean;
89
+ action: (error: ThinkingError, context: unknown) => Promise<unknown>;
90
+ }
@@ -0,0 +1,72 @@
1
+ export interface CreativeSession {
2
+ id: string;
3
+ prompt: string;
4
+ techniques: CreativityTechnique[];
5
+ ideas: Idea[];
6
+ connections: Connection[];
7
+ sessionDuration: number;
8
+ divergentPhase: DivergentPhase;
9
+ convergentPhase: ConvergentPhase;
10
+ }
11
+
12
+ export type CreativityTechnique =
13
+ | 'brainstorming'
14
+ | 'mind_mapping'
15
+ | 'scamper'
16
+ | 'six_thinking_hats'
17
+ | 'lateral_thinking'
18
+ | 'analogy'
19
+ | 'reverse_thinking'
20
+ | 'random_stimulus';
21
+
22
+ export interface Idea {
23
+ id: string;
24
+ content: string;
25
+ technique: CreativityTechnique;
26
+ novelty: number;
27
+ feasibility: number;
28
+ impact: number;
29
+ relatedIdeas: string[];
30
+ tags: string[];
31
+ generatedAt: Date;
32
+ }
33
+
34
+ export interface Connection {
35
+ id: string;
36
+ from: string;
37
+ to: string;
38
+ connectionType: 'similarity' | 'contrast' | 'cause_effect' | 'analogy' | 'combination';
39
+ strength: number;
40
+ insight: string;
41
+ }
42
+
43
+ export interface DivergentPhase {
44
+ startTime: Date;
45
+ endTime: Date;
46
+ ideaCount: number;
47
+ explorationBreadth: number;
48
+ }
49
+
50
+ export interface ConvergentPhase {
51
+ startTime: Date;
52
+ endTime: Date;
53
+ selectedIdeas: string[];
54
+ synthesis: string;
55
+ actionItems: string[];
56
+ }
57
+
58
+ export interface OutOfBoxThinking {
59
+ id: string;
60
+ originalProblem: string;
61
+ reframedProblems: ReframedProblem[];
62
+ unconventionalApproaches: string[];
63
+ breakthroughPotential: number;
64
+ }
65
+
66
+ export interface ReframedProblem {
67
+ id: string;
68
+ perspective: string;
69
+ reframedStatement: string;
70
+ assumptionsChallenged: string[];
71
+ newPossibilities: string[];
72
+ }
@@ -0,0 +1,60 @@
1
+ import { ThinkingStage, TaskStatus } from './core';
2
+ import { LearningContext } from './learning';
3
+
4
+ export interface SequentialThinkingConfig {
5
+ maxSearchResults: number;
6
+ analysisDepth: 'surface' | 'moderate' | 'deep';
7
+ reasoningComplexity: 'simple' | 'moderate' | 'complex';
8
+ learningEnabled: boolean;
9
+ creativityLevel: 'conservative' | 'balanced' | 'adventurous';
10
+ planningDetail: 'high_level' | 'detailed' | 'granular';
11
+ timeout: number;
12
+ retryAttempts: number;
13
+ }
14
+
15
+ export interface ThinkingRequest {
16
+ id: string;
17
+ query: string;
18
+ context?: string;
19
+ preferredStages?: ThinkingStage[];
20
+ config?: Partial<SequentialThinkingConfig>;
21
+ timeout?: number;
22
+ }
23
+
24
+ export interface ThinkingResponse {
25
+ id: string;
26
+ requestId: string;
27
+ stages: StageResult[];
28
+ finalAnswer: string;
29
+ confidence: number;
30
+ processingTime: number;
31
+ metadata: ResponseMetadata;
32
+ timestamp: Date;
33
+ }
34
+
35
+ export interface StageResult {
36
+ stage: ThinkingStage;
37
+ status: TaskStatus;
38
+ input: unknown;
39
+ output: unknown;
40
+ processingTime: number;
41
+ confidence: number;
42
+ subResults?: unknown[];
43
+ }
44
+
45
+ export interface ResponseMetadata {
46
+ sourcesUsed: number;
47
+ reasoningSteps: number;
48
+ ideasGenerated: number;
49
+ tasksCreated: number;
50
+ knowledgeNodesAccessed: number;
51
+ }
52
+
53
+ export interface ThinkingSession {
54
+ id: string;
55
+ requests: ThinkingRequest[];
56
+ responses: ThinkingResponse[];
57
+ context: LearningContext;
58
+ startTime: Date;
59
+ lastActivity: Date;
60
+ }
package/types/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ export * from './core';
2
+ export * from './search';
3
+ export * from './analysis';
4
+ export * from './reasoning';
5
+ export * from './learning';
6
+ export * from './planning';
7
+ export * from './creativity';
8
+ export * from './synthesis';
9
+ export * from './engine';
@@ -0,0 +1,69 @@
1
+ import { SourceType } from './core';
2
+
3
+ export interface LearningContext {
4
+ id: string;
5
+ sessionId: string;
6
+ userId?: string;
7
+ topic: string;
8
+ previousInteractions: Interaction[];
9
+ learnedPatterns: Pattern[];
10
+ knowledgeGraph: KnowledgeGraph;
11
+ preferences: UserPreferences;
12
+ }
13
+
14
+ export interface Interaction {
15
+ id: string;
16
+ timestamp: Date;
17
+ query: string;
18
+ response: string;
19
+ feedback?: Feedback;
20
+ contextSnapshot: unknown;
21
+ }
22
+
23
+ export interface Feedback {
24
+ rating: number;
25
+ comments?: string;
26
+ helpful: boolean;
27
+ corrections?: string[];
28
+ }
29
+
30
+ export interface Pattern {
31
+ id: string;
32
+ type: 'query_pattern' | 'response_pattern' | 'error_pattern' | 'success_pattern';
33
+ pattern: string;
34
+ frequency: number;
35
+ successRate: number;
36
+ lastObserved: Date;
37
+ }
38
+
39
+ export interface KnowledgeGraph {
40
+ nodes: KnowledgeNode[];
41
+ edges: KnowledgeEdge[];
42
+ version: number;
43
+ lastUpdated: Date;
44
+ }
45
+
46
+ export interface KnowledgeNode {
47
+ id: string;
48
+ label: string;
49
+ type: 'concept' | 'entity' | 'fact' | 'rule';
50
+ properties: Record<string, unknown>;
51
+ confidence: number;
52
+ sources: string[];
53
+ }
54
+
55
+ export interface KnowledgeEdge {
56
+ from: string;
57
+ to: string;
58
+ relation: string;
59
+ strength: number;
60
+ evidence: string[];
61
+ }
62
+
63
+ export interface UserPreferences {
64
+ responseStyle: 'concise' | 'detailed' | 'technical' | 'simple';
65
+ preferredSources: SourceType[];
66
+ topicInterests: string[];
67
+ excludedTopics: string[];
68
+ language: string;
69
+ }