gthinking 1.2.0 → 1.2.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 (67) hide show
  1. package/README.md +5 -0
  2. package/dist/engine.d.ts +15 -1
  3. package/dist/engine.d.ts.map +1 -1
  4. package/dist/engine.js +9 -11
  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/types/analysis.d.ts +54 -0
  11. package/dist/types/analysis.d.ts.map +1 -0
  12. package/dist/types/analysis.js +3 -0
  13. package/dist/types/analysis.js.map +1 -0
  14. package/dist/types/core.d.ts +66 -0
  15. package/dist/types/core.d.ts.map +1 -0
  16. package/dist/types/core.js +61 -0
  17. package/dist/types/core.js.map +1 -0
  18. package/dist/types/creativity.d.ts +58 -0
  19. package/dist/types/creativity.d.ts.map +1 -0
  20. package/dist/types/creativity.js +3 -0
  21. package/dist/types/creativity.js.map +1 -0
  22. package/dist/types/engine.d.ts +55 -0
  23. package/dist/types/engine.d.ts.map +1 -0
  24. package/dist/types/engine.js +3 -0
  25. package/dist/types/engine.js.map +1 -0
  26. package/dist/types/index.d.ts +10 -0
  27. package/dist/types/index.d.ts.map +1 -0
  28. package/dist/types/index.js +26 -0
  29. package/dist/types/index.js.map +1 -0
  30. package/dist/types/learning.d.ts +62 -0
  31. package/dist/types/learning.d.ts.map +1 -0
  32. package/dist/types/learning.js +3 -0
  33. package/dist/types/learning.js.map +1 -0
  34. package/dist/types/planning.d.ts +78 -0
  35. package/dist/types/planning.d.ts.map +1 -0
  36. package/dist/types/planning.js +3 -0
  37. package/dist/types/planning.js.map +1 -0
  38. package/dist/types/reasoning.d.ts +83 -0
  39. package/dist/types/reasoning.d.ts.map +1 -0
  40. package/dist/types/reasoning.js +13 -0
  41. package/dist/types/reasoning.js.map +1 -0
  42. package/dist/types/search.d.ts +56 -0
  43. package/dist/types/search.d.ts.map +1 -0
  44. package/dist/types/search.js +3 -0
  45. package/dist/types/search.js.map +1 -0
  46. package/dist/types/synthesis.d.ts +39 -0
  47. package/dist/types/synthesis.d.ts.map +1 -0
  48. package/dist/types/synthesis.js +3 -0
  49. package/dist/types/synthesis.js.map +1 -0
  50. package/dist/types.d.ts +1 -530
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/types.js +15 -70
  53. package/dist/types.js.map +1 -1
  54. package/engine.ts +22 -8
  55. package/llm-service.ts +39 -18
  56. package/package.json +1 -1
  57. package/types/analysis.ts +69 -0
  58. package/types/core.ts +90 -0
  59. package/types/creativity.ts +72 -0
  60. package/types/engine.ts +60 -0
  61. package/types/index.ts +9 -0
  62. package/types/learning.ts +69 -0
  63. package/types/planning.ts +85 -0
  64. package/types/reasoning.ts +92 -0
  65. package/types/search.ts +58 -0
  66. package/types/synthesis.ts +42 -0
  67. package/types.ts +1 -669
package/types.ts CHANGED
@@ -3,672 +3,4 @@
3
3
  * A comprehensive intelligent thinking framework for complex problem solving
4
4
  */
5
5
 
6
- // ============================================================================
7
- // CORE ENUMS
8
- // ============================================================================
9
-
10
- export enum ThinkingStage {
11
- SEARCH = 'search',
12
- ANALYSIS = 'analysis',
13
- REASONING = 'reasoning',
14
- LEARNING = 'learning',
15
- PLANNING = 'planning',
16
- CREATIVITY = 'creativity',
17
- SYNTHESIS = 'synthesis',
18
- EVALUATION = 'evaluation'
19
- }
20
-
21
- export enum ConfidenceLevel {
22
- VERY_LOW = 0.1,
23
- LOW = 0.3,
24
- MEDIUM = 0.5,
25
- HIGH = 0.7,
26
- VERY_HIGH = 0.9
27
- }
28
-
29
- export enum Priority {
30
- CRITICAL = 1,
31
- HIGH = 2,
32
- MEDIUM = 3,
33
- LOW = 4,
34
- MINIMAL = 5
35
- }
36
-
37
- export enum TaskStatus {
38
- PENDING = 'pending',
39
- IN_PROGRESS = 'in_progress',
40
- COMPLETED = 'completed',
41
- FAILED = 'failed',
42
- CANCELLED = 'cancelled'
43
- }
44
-
45
- export enum SourceType {
46
- WEB = 'web',
47
- DATABASE = 'database',
48
- API = 'api',
49
- CACHE = 'cache',
50
- KNOWLEDGE_BASE = 'knowledge_base',
51
- USER_INPUT = 'user_input'
52
- }
53
-
54
- export enum ReasoningType {
55
- DEDUCTIVE = 'deductive',
56
- INDUCTIVE = 'inductive',
57
- ABDUCTIVE = 'abductive',
58
- ANALOGICAL = 'analogical',
59
- CAUSAL = 'causal',
60
- COUNTERFACTUAL = 'counterfactual'
61
- }
62
-
63
- // ============================================================================
64
- // SEARCH & DISCOVERY TYPES
65
- // ============================================================================
66
-
67
- export interface SearchQuery {
68
- id: string;
69
- query: string;
70
- sources: SourceType[];
71
- filters: SearchFilters;
72
- maxResults: number;
73
- timeout: number;
74
- timestamp: Date;
75
- }
76
-
77
- export interface SearchFilters {
78
- dateRange?: { start: Date; end: Date };
79
- domains?: string[];
80
- excludeDomains?: string[];
81
- language?: string;
82
- contentType?: ('article' | 'video' | 'image' | 'pdf' | 'forum')[];
83
- minCredibility?: number;
84
- }
85
-
86
- export interface SearchResult {
87
- id: string;
88
- title: string;
89
- url: string;
90
- snippet: string;
91
- source: SourceType;
92
- credibility: number;
93
- relevance: number;
94
- timestamp: Date;
95
- metadata: ResultMetadata;
96
- }
97
-
98
- export interface ResultMetadata {
99
- author?: string;
100
- publishDate?: Date;
101
- wordCount?: number;
102
- readingTime?: number;
103
- relatedTopics?: string[];
104
- citations?: number;
105
- }
106
-
107
- export interface SearchSession {
108
- id: string;
109
- queries: SearchQuery[];
110
- results: SearchResult[];
111
- aggregatedResults: AggregatedResult[];
112
- startTime: Date;
113
- endTime?: Date;
114
- }
115
-
116
- export interface AggregatedResult {
117
- topic: string;
118
- results: SearchResult[];
119
- consensusScore: number;
120
- conflictingInfo: boolean;
121
- keyInsights: string[];
122
- }
123
-
124
- // ============================================================================
125
- // ANALYSIS TYPES
126
- // ============================================================================
127
-
128
- export interface AnalysisRequest {
129
- id: string;
130
- content: string;
131
- analysisTypes: AnalysisType[];
132
- context?: string;
133
- depth: 'surface' | 'moderate' | 'deep';
134
- }
135
-
136
- export type AnalysisType =
137
- | 'sentiment'
138
- | 'entity'
139
- | 'topic'
140
- | 'keyword'
141
- | 'summary'
142
- | 'fact_check'
143
- | 'comparison'
144
- | 'trend';
145
-
146
- export interface AnalysisResult {
147
- id: string;
148
- requestId: string;
149
- type: AnalysisType;
150
- findings: Finding[];
151
- confidence: number;
152
- processingTime: number;
153
- timestamp: Date;
154
- }
155
-
156
- export interface Finding {
157
- id: string;
158
- type: string;
159
- value: unknown;
160
- confidence: number;
161
- evidence: Evidence[];
162
- relatedFindings: string[];
163
- }
164
-
165
- export interface Evidence {
166
- source: string;
167
- excerpt: string;
168
- location: string;
169
- strength: number;
170
- }
171
-
172
- export interface ComparisonResult {
173
- id: string;
174
- subjects: string[];
175
- similarities: ComparisonPoint[];
176
- differences: ComparisonPoint[];
177
- conclusion: string;
178
- confidence: number;
179
- }
180
-
181
- export interface ComparisonPoint {
182
- aspect: string;
183
- values: Record<string, unknown>;
184
- significance: number;
185
- }
186
-
187
- export interface FactCheckResult {
188
- claim: string;
189
- verdict: 'true' | 'false' | 'partially_true' | 'unverifiable';
190
- confidence: number;
191
- sources: SearchResult[];
192
- explanation: string;
193
- corrections?: string[];
194
- }
195
-
196
- // ============================================================================
197
- // REASONING TYPES
198
- // ============================================================================
199
-
200
- export interface ReasoningSession {
201
- id: string;
202
- problem: string;
203
- type: ReasoningType;
204
- steps: ReasoningStep[];
205
- conclusion?: string;
206
- confidence: number;
207
- startTime: Date;
208
- endTime?: Date;
209
- }
210
-
211
- export interface ReasoningStep {
212
- id: string;
213
- stepNumber: number;
214
- premise: string;
215
- inference: string;
216
- evidence: Evidence[];
217
- assumptions: string[];
218
- confidence: number;
219
- nextSteps: string[];
220
- }
221
-
222
- export interface Hypothesis {
223
- id: string;
224
- statement: string;
225
- supportingEvidence: Evidence[];
226
- contradictingEvidence: Evidence[];
227
- tests: HypothesisTest[];
228
- status: 'proposed' | 'testing' | 'confirmed' | 'rejected';
229
- confidence: number;
230
- }
231
-
232
- export interface HypothesisTest {
233
- id: string;
234
- description: string;
235
- expectedOutcome: string;
236
- actualOutcome?: string;
237
- passed?: boolean;
238
- }
239
-
240
- export interface ChainOfThought {
241
- id: string;
242
- initialQuestion: string;
243
- thoughts: ThoughtNode[];
244
- finalAnswer?: string;
245
- completeness: number;
246
- }
247
-
248
- export interface ThoughtNode {
249
- id: string;
250
- content: string;
251
- parentId?: string;
252
- children: string[];
253
- depth: number;
254
- confidence: number;
255
- type: 'question' | 'observation' | 'inference' | 'conclusion';
256
- }
257
-
258
- export interface ProblemDecomposition {
259
- id: string;
260
- originalProblem: string;
261
- subProblems: SubProblem[];
262
- dependencies: Dependency[];
263
- solutionStrategy: string;
264
- }
265
-
266
- export interface SubProblem {
267
- id: string;
268
- description: string;
269
- difficulty: number;
270
- estimatedTime: number;
271
- prerequisites: string[];
272
- status: TaskStatus;
273
- }
274
-
275
- export interface Dependency {
276
- from: string;
277
- to: string;
278
- type: 'requires' | 'enables' | 'conflicts';
279
- }
280
-
281
- // ============================================================================
282
- // LEARNING TYPES
283
- // ============================================================================
284
-
285
- export interface LearningContext {
286
- id: string;
287
- sessionId: string;
288
- userId?: string;
289
- topic: string;
290
- previousInteractions: Interaction[];
291
- learnedPatterns: Pattern[];
292
- knowledgeGraph: KnowledgeGraph;
293
- preferences: UserPreferences;
294
- }
295
-
296
- export interface Interaction {
297
- id: string;
298
- timestamp: Date;
299
- query: string;
300
- response: string;
301
- feedback?: Feedback;
302
- contextSnapshot: unknown;
303
- }
304
-
305
- export interface Feedback {
306
- rating: number;
307
- comments?: string;
308
- helpful: boolean;
309
- corrections?: string[];
310
- }
311
-
312
- export interface Pattern {
313
- id: string;
314
- type: 'query_pattern' | 'response_pattern' | 'error_pattern' | 'success_pattern';
315
- pattern: string;
316
- frequency: number;
317
- successRate: number;
318
- lastObserved: Date;
319
- }
320
-
321
- export interface KnowledgeGraph {
322
- nodes: KnowledgeNode[];
323
- edges: KnowledgeEdge[];
324
- version: number;
325
- lastUpdated: Date;
326
- }
327
-
328
- export interface KnowledgeNode {
329
- id: string;
330
- label: string;
331
- type: 'concept' | 'entity' | 'fact' | 'rule';
332
- properties: Record<string, unknown>;
333
- confidence: number;
334
- sources: string[];
335
- }
336
-
337
- export interface KnowledgeEdge {
338
- from: string;
339
- to: string;
340
- relation: string;
341
- strength: number;
342
- evidence: string[];
343
- }
344
-
345
- export interface UserPreferences {
346
- responseStyle: 'concise' | 'detailed' | 'technical' | 'simple';
347
- preferredSources: SourceType[];
348
- topicInterests: string[];
349
- excludedTopics: string[];
350
- language: string;
351
- }
352
-
353
- // ============================================================================
354
- // PLANNING TYPES
355
- // ============================================================================
356
-
357
- export interface Plan {
358
- id: string;
359
- goal: string;
360
- tasks: Task[];
361
- milestones: Milestone[];
362
- resources: Resource[];
363
- timeline: Timeline;
364
- status: TaskStatus;
365
- createdAt: Date;
366
- updatedAt: Date;
367
- }
368
-
369
- export interface Task {
370
- id: string;
371
- title: string;
372
- description: string;
373
- priority: Priority;
374
- status: TaskStatus;
375
- estimatedDuration: number;
376
- actualDuration?: number;
377
- dependencies: string[];
378
- subtasks: string[];
379
- assignedTo?: string;
380
- tags: string[];
381
- startTime?: Date;
382
- endTime?: Date;
383
- }
384
-
385
- export interface Milestone {
386
- id: string;
387
- title: string;
388
- description: string;
389
- criteria: string[];
390
- deadline?: Date;
391
- completedAt?: Date;
392
- status: TaskStatus;
393
- }
394
-
395
- export interface Resource {
396
- id: string;
397
- type: 'human' | 'tool' | 'data' | 'time' | 'budget';
398
- name: string;
399
- availability: number;
400
- cost?: number;
401
- skills?: string[];
402
- }
403
-
404
- export interface Timeline {
405
- startDate: Date;
406
- endDate?: Date;
407
- phases: Phase[];
408
- criticalPath: string[];
409
- buffer: number;
410
- }
411
-
412
- export interface Phase {
413
- id: string;
414
- name: string;
415
- startDate: Date;
416
- endDate: Date;
417
- tasks: string[];
418
- dependencies: string[];
419
- }
420
-
421
- export interface ProgressReport {
422
- planId: string;
423
- timestamp: Date;
424
- overallProgress: number;
425
- completedTasks: number;
426
- totalTasks: number;
427
- onTrack: boolean;
428
- risks: Risk[];
429
- nextActions: string[];
430
- }
431
-
432
- export interface Risk {
433
- id: string;
434
- description: string;
435
- probability: number;
436
- impact: number;
437
- mitigation: string;
438
- status: 'identified' | 'mitigating' | 'resolved' | 'occurred';
439
- }
440
-
441
- // ============================================================================
442
- // CREATIVITY TYPES
443
- // ============================================================================
444
-
445
- export interface CreativeSession {
446
- id: string;
447
- prompt: string;
448
- techniques: CreativityTechnique[];
449
- ideas: Idea[];
450
- connections: Connection[];
451
- sessionDuration: number;
452
- divergentPhase: DivergentPhase;
453
- convergentPhase: ConvergentPhase;
454
- }
455
-
456
- export type CreativityTechnique =
457
- | 'brainstorming'
458
- | 'mind_mapping'
459
- | 'scamper'
460
- | 'six_thinking_hats'
461
- | 'lateral_thinking'
462
- | 'analogy'
463
- | 'reverse_thinking'
464
- | 'random_stimulus';
465
-
466
- export interface Idea {
467
- id: string;
468
- content: string;
469
- technique: CreativityTechnique;
470
- novelty: number;
471
- feasibility: number;
472
- impact: number;
473
- relatedIdeas: string[];
474
- tags: string[];
475
- generatedAt: Date;
476
- }
477
-
478
- export interface Connection {
479
- id: string;
480
- from: string;
481
- to: string;
482
- connectionType: 'similarity' | 'contrast' | 'cause_effect' | 'analogy' | 'combination';
483
- strength: number;
484
- insight: string;
485
- }
486
-
487
- export interface DivergentPhase {
488
- startTime: Date;
489
- endTime: Date;
490
- ideaCount: number;
491
- explorationBreadth: number;
492
- }
493
-
494
- export interface ConvergentPhase {
495
- startTime: Date;
496
- endTime: Date;
497
- selectedIdeas: string[];
498
- synthesis: string;
499
- actionItems: string[];
500
- }
501
-
502
- export interface OutOfBoxThinking {
503
- id: string;
504
- originalProblem: string;
505
- reframedProblems: ReframedProblem[];
506
- unconventionalApproaches: string[];
507
- breakthroughPotential: number;
508
- }
509
-
510
- export interface ReframedProblem {
511
- id: string;
512
- perspective: string;
513
- reframedStatement: string;
514
- assumptionsChallenged: string[];
515
- newPossibilities: string[];
516
- }
517
-
518
- // ============================================================================
519
- // SYNTHESIS & EVALUATION TYPES
520
- // ============================================================================
521
-
522
- export interface SynthesisResult {
523
- id: string;
524
- sources: string[];
525
- summary: string;
526
- keyInsights: string[];
527
- recommendations: Recommendation[];
528
- confidence: number;
529
- gaps: string[];
530
- uncertainties: string[];
531
- }
532
-
533
- export interface Recommendation {
534
- id: string;
535
- action: string;
536
- rationale: string;
537
- priority: Priority;
538
- expectedOutcome: string;
539
- risks: string[];
540
- confidence: number;
541
- }
542
-
543
- export interface EvaluationResult {
544
- id: string;
545
- target: string;
546
- criteria: EvaluationCriteria[];
547
- scores: Record<string, number>;
548
- overallScore: number;
549
- strengths: string[];
550
- weaknesses: string[];
551
- improvements: string[];
552
- }
553
-
554
- export interface EvaluationCriteria {
555
- id: string;
556
- name: string;
557
- weight: number;
558
- description: string;
559
- minScore: number;
560
- maxScore: number;
561
- }
562
-
563
- // ============================================================================
564
- // MAIN ENGINE TYPES
565
- // ============================================================================
566
-
567
- export interface SequentialThinkingConfig {
568
- maxSearchResults: number;
569
- analysisDepth: 'surface' | 'moderate' | 'deep';
570
- reasoningComplexity: 'simple' | 'moderate' | 'complex';
571
- learningEnabled: boolean;
572
- creativityLevel: 'conservative' | 'balanced' | 'adventurous';
573
- planningDetail: 'high_level' | 'detailed' | 'granular';
574
- timeout: number;
575
- retryAttempts: number;
576
- }
577
-
578
- export interface ThinkingRequest {
579
- id: string;
580
- query: string;
581
- context?: string;
582
- preferredStages?: ThinkingStage[];
583
- config?: Partial<SequentialThinkingConfig>;
584
- timeout?: number;
585
- }
586
-
587
- export interface ThinkingResponse {
588
- id: string;
589
- requestId: string;
590
- stages: StageResult[];
591
- finalAnswer: string;
592
- confidence: number;
593
- processingTime: number;
594
- metadata: ResponseMetadata;
595
- timestamp: Date;
596
- }
597
-
598
- export interface StageResult {
599
- stage: ThinkingStage;
600
- status: TaskStatus;
601
- input: unknown;
602
- output: unknown;
603
- processingTime: number;
604
- confidence: number;
605
- subResults?: unknown[];
606
- }
607
-
608
- export interface ResponseMetadata {
609
- sourcesUsed: number;
610
- reasoningSteps: number;
611
- ideasGenerated: number;
612
- tasksCreated: number;
613
- knowledgeNodesAccessed: number;
614
- }
615
-
616
- export interface ThinkingSession {
617
- id: string;
618
- requests: ThinkingRequest[];
619
- responses: ThinkingResponse[];
620
- context: LearningContext;
621
- startTime: Date;
622
- lastActivity: Date;
623
- }
624
-
625
- // ============================================================================
626
- // EVENT TYPES
627
- // ============================================================================
628
-
629
- export interface ThinkingEvent {
630
- id: string;
631
- type: ThinkingEventType;
632
- stage: ThinkingStage;
633
- timestamp: Date;
634
- data: unknown;
635
- sessionId: string;
636
- }
637
-
638
- export type ThinkingEventType =
639
- | 'stage_start'
640
- | 'stage_complete'
641
- | 'stage_error'
642
- | 'insight_found'
643
- | 'confidence_update'
644
- | 'search_result'
645
- | 'analysis_complete'
646
- | 'reasoning_step'
647
- | 'plan_created'
648
- | 'idea_generated';
649
-
650
- export interface EventHandler {
651
- (event: ThinkingEvent): void | Promise<void>;
652
- }
653
-
654
- // ============================================================================
655
- // ERROR TYPES
656
- // ============================================================================
657
-
658
- export class ThinkingError extends Error {
659
- constructor(
660
- message: string,
661
- public stage: ThinkingStage,
662
- public recoverable: boolean,
663
- public originalError?: Error
664
- ) {
665
- super(message);
666
- this.name = 'ThinkingError';
667
- }
668
- }
669
-
670
- export interface ErrorRecoveryStrategy {
671
- stage: ThinkingStage;
672
- condition: (error: ThinkingError) => boolean;
673
- action: (error: ThinkingError, context: unknown) => Promise<unknown>;
674
- }
6
+ export * from './types/index';