gthinking 1.2.1 → 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.
- package/.eslintrc.js +34 -0
- package/ANALYSIS_SUMMARY.md +363 -0
- package/README.md +230 -245
- package/dist/analysis/analysis-engine.d.ts +63 -0
- package/dist/analysis/analysis-engine.d.ts.map +1 -0
- package/dist/analysis/analysis-engine.js +322 -0
- package/dist/analysis/analysis-engine.js.map +1 -0
- package/dist/core/config.d.ts +1419 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +361 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/engine.d.ts +176 -0
- package/dist/core/engine.d.ts.map +1 -0
- package/dist/core/engine.js +604 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/errors.d.ts +153 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +287 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/{types.js → core/index.js} +8 -4
- package/dist/core/index.js.map +1 -0
- package/dist/core/pipeline.d.ts +121 -0
- package/dist/core/pipeline.d.ts.map +1 -0
- package/dist/core/pipeline.js +289 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/rate-limiter.d.ts +58 -0
- package/dist/core/rate-limiter.d.ts.map +1 -0
- package/dist/core/rate-limiter.js +133 -0
- package/dist/core/rate-limiter.js.map +1 -0
- package/dist/core/session-manager.d.ts +96 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +223 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/creativity/creativity-engine.d.ts +6 -0
- package/dist/creativity/creativity-engine.d.ts.map +1 -0
- package/dist/creativity/creativity-engine.js +17 -0
- package/dist/creativity/creativity-engine.js.map +1 -0
- package/dist/index.d.ts +24 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +130 -104
- package/dist/index.js.map +1 -1
- package/dist/learning/learning-engine.d.ts +6 -0
- package/dist/learning/learning-engine.d.ts.map +1 -0
- package/dist/learning/learning-engine.js +17 -0
- package/dist/learning/learning-engine.js.map +1 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +26 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm-service.d.ts +109 -0
- package/dist/llm/llm-service.d.ts.map +1 -0
- package/dist/llm/llm-service.js +224 -0
- package/dist/llm/llm-service.js.map +1 -0
- package/dist/llm/providers/base.d.ts +85 -0
- package/dist/llm/providers/base.d.ts.map +1 -0
- package/dist/llm/providers/base.js +57 -0
- package/dist/llm/providers/base.js.map +1 -0
- package/dist/llm/providers/cli.d.ts +23 -0
- package/dist/llm/providers/cli.d.ts.map +1 -0
- package/dist/llm/providers/cli.js +158 -0
- package/dist/llm/providers/cli.js.map +1 -0
- package/dist/llm/providers/gemini.d.ts +30 -0
- package/dist/llm/providers/gemini.d.ts.map +1 -0
- package/dist/llm/providers/gemini.js +168 -0
- package/dist/llm/providers/gemini.js.map +1 -0
- package/dist/llm/sanitization.d.ts +50 -0
- package/dist/llm/sanitization.d.ts.map +1 -0
- package/dist/llm/sanitization.js +149 -0
- package/dist/llm/sanitization.js.map +1 -0
- package/dist/{server.d.ts.map → mcp/server.d.ts.map} +1 -1
- package/dist/mcp/server.js +108 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/planning/planning-engine.d.ts +6 -0
- package/dist/planning/planning-engine.d.ts.map +1 -0
- package/dist/planning/planning-engine.js +17 -0
- package/dist/planning/planning-engine.js.map +1 -0
- package/dist/reasoning/reasoning-engine.d.ts +6 -0
- package/dist/reasoning/reasoning-engine.d.ts.map +1 -0
- package/dist/reasoning/reasoning-engine.js +17 -0
- package/dist/reasoning/reasoning-engine.js.map +1 -0
- package/dist/search/search-engine.d.ts +99 -0
- package/dist/search/search-engine.d.ts.map +1 -0
- package/dist/search/search-engine.js +271 -0
- package/dist/search/search-engine.js.map +1 -0
- package/dist/synthesis/synthesis-engine.d.ts +6 -0
- package/dist/synthesis/synthesis-engine.d.ts.map +1 -0
- package/dist/synthesis/synthesis-engine.js +17 -0
- package/dist/synthesis/synthesis-engine.js.map +1 -0
- package/dist/types/analysis.d.ts +1534 -49
- package/dist/types/analysis.d.ts.map +1 -1
- package/dist/types/analysis.js +250 -0
- package/dist/types/analysis.js.map +1 -1
- package/dist/types/core.d.ts +257 -30
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js +148 -18
- package/dist/types/core.js.map +1 -1
- package/dist/types/creativity.d.ts +2871 -56
- package/dist/types/creativity.d.ts.map +1 -1
- package/dist/types/creativity.js +195 -0
- package/dist/types/creativity.js.map +1 -1
- package/dist/types/index.d.ts +6 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +17 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/learning.d.ts +851 -61
- package/dist/types/learning.d.ts.map +1 -1
- package/dist/types/learning.js +155 -0
- package/dist/types/learning.js.map +1 -1
- package/dist/types/planning.d.ts +2223 -71
- package/dist/types/planning.d.ts.map +1 -1
- package/dist/types/planning.js +190 -0
- package/dist/types/planning.js.map +1 -1
- package/dist/types/reasoning.d.ts +2209 -72
- package/dist/types/reasoning.d.ts.map +1 -1
- package/dist/types/reasoning.js +200 -1
- package/dist/types/reasoning.js.map +1 -1
- package/dist/types/search.d.ts +981 -53
- package/dist/types/search.d.ts.map +1 -1
- package/dist/types/search.js +137 -0
- package/dist/types/search.js.map +1 -1
- package/dist/types/synthesis.d.ts +583 -37
- package/dist/types/synthesis.d.ts.map +1 -1
- package/dist/types/synthesis.js +138 -0
- package/dist/types/synthesis.js.map +1 -1
- package/dist/utils/cache.d.ts +144 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +288 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/id-generator.d.ts +89 -0
- package/dist/utils/id-generator.d.ts.map +1 -0
- package/dist/utils/id-generator.js +132 -0
- package/dist/utils/id-generator.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +33 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +142 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +248 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/metrics.d.ts +149 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/utils/metrics.js +296 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/timer.d.ts +7 -0
- package/dist/utils/timer.d.ts.map +1 -0
- package/dist/utils/timer.js +17 -0
- package/dist/utils/timer.js.map +1 -0
- package/dist/utils/validation.d.ts +147 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +275 -0
- package/dist/utils/validation.js.map +1 -0
- package/docs/API.md +411 -0
- package/docs/ARCHITECTURE.md +271 -0
- package/docs/CHANGELOG.md +283 -0
- package/jest.config.js +28 -0
- package/package.json +43 -30
- package/src/analysis/analysis-engine.ts +383 -0
- package/src/core/config.ts +406 -0
- package/src/core/engine.ts +785 -0
- package/src/core/errors.ts +349 -0
- package/src/core/index.ts +12 -0
- package/src/core/pipeline.ts +424 -0
- package/src/core/rate-limiter.ts +155 -0
- package/src/core/session-manager.ts +269 -0
- package/src/creativity/creativity-engine.ts +14 -0
- package/src/index.ts +178 -0
- package/src/learning/learning-engine.ts +14 -0
- package/src/llm/index.ts +10 -0
- package/src/llm/llm-service.ts +285 -0
- package/src/llm/providers/base.ts +146 -0
- package/src/llm/providers/cli.ts +186 -0
- package/src/llm/providers/gemini.ts +201 -0
- package/src/llm/sanitization.ts +178 -0
- package/src/mcp/server.ts +117 -0
- package/src/planning/planning-engine.ts +14 -0
- package/src/reasoning/reasoning-engine.ts +14 -0
- package/src/search/search-engine.ts +333 -0
- package/src/synthesis/synthesis-engine.ts +14 -0
- package/src/types/analysis.ts +337 -0
- package/src/types/core.ts +342 -0
- package/src/types/creativity.ts +268 -0
- package/src/types/index.ts +31 -0
- package/src/types/learning.ts +215 -0
- package/src/types/planning.ts +251 -0
- package/src/types/reasoning.ts +288 -0
- package/src/types/search.ts +192 -0
- package/src/types/synthesis.ts +187 -0
- package/src/utils/cache.ts +363 -0
- package/src/utils/id-generator.ts +135 -0
- package/src/utils/index.ts +22 -0
- package/src/utils/logger.ts +290 -0
- package/src/utils/metrics.ts +380 -0
- package/src/utils/timer.ts +15 -0
- package/src/utils/validation.ts +297 -0
- package/tests/setup.ts +22 -0
- package/tests/unit/cache.test.ts +189 -0
- package/tests/unit/engine.test.ts +179 -0
- package/tests/unit/validation.test.ts +218 -0
- package/tsconfig.json +17 -12
- package/GEMINI.md +0 -68
- package/analysis.ts +0 -1063
- package/creativity.ts +0 -1055
- package/dist/analysis.d.ts +0 -54
- package/dist/analysis.d.ts.map +0 -1
- package/dist/analysis.js +0 -866
- package/dist/analysis.js.map +0 -1
- package/dist/creativity.d.ts +0 -81
- package/dist/creativity.d.ts.map +0 -1
- package/dist/creativity.js +0 -828
- package/dist/creativity.js.map +0 -1
- package/dist/engine.d.ts +0 -90
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -677
- package/dist/engine.js.map +0 -1
- package/dist/examples.d.ts +0 -7
- package/dist/examples.d.ts.map +0 -1
- package/dist/examples.js +0 -506
- package/dist/examples.js.map +0 -1
- package/dist/learning.d.ts +0 -72
- package/dist/learning.d.ts.map +0 -1
- package/dist/learning.js +0 -615
- package/dist/learning.js.map +0 -1
- package/dist/llm-service.d.ts +0 -21
- package/dist/llm-service.d.ts.map +0 -1
- package/dist/llm-service.js +0 -100
- package/dist/llm-service.js.map +0 -1
- package/dist/planning.d.ts +0 -58
- package/dist/planning.d.ts.map +0 -1
- package/dist/planning.js +0 -824
- package/dist/planning.js.map +0 -1
- package/dist/reasoning.d.ts +0 -73
- package/dist/reasoning.d.ts.map +0 -1
- package/dist/reasoning.js +0 -845
- package/dist/reasoning.js.map +0 -1
- package/dist/search-discovery.d.ts +0 -73
- package/dist/search-discovery.d.ts.map +0 -1
- package/dist/search-discovery.js +0 -548
- package/dist/search-discovery.js.map +0 -1
- package/dist/server.js +0 -113
- package/dist/server.js.map +0 -1
- package/dist/types/engine.d.ts +0 -55
- package/dist/types/engine.d.ts.map +0 -1
- package/dist/types/engine.js +0 -3
- package/dist/types/engine.js.map +0 -1
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/engine.ts +0 -947
- package/examples.ts +0 -717
- package/index.ts +0 -106
- package/learning.ts +0 -779
- package/llm-service.ts +0 -120
- package/planning.ts +0 -1028
- package/reasoning.ts +0 -1079
- package/search-discovery.ts +0 -700
- package/server.ts +0 -115
- package/types/analysis.ts +0 -69
- package/types/core.ts +0 -90
- package/types/creativity.ts +0 -72
- package/types/engine.ts +0 -60
- package/types/index.ts +0 -9
- package/types/learning.ts +0 -69
- package/types/planning.ts +0 -85
- package/types/reasoning.ts +0 -92
- package/types/search.ts +0 -58
- package/types/synthesis.ts +0 -42
- package/types.ts +0 -6
- /package/dist/{server.d.ts → mcp/server.d.ts} +0 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Types and Enums for gthinking v2.0.0
|
|
3
|
+
* Fundamental types used across the entire system
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Thinking Stage Enum - Represents different stages in the thinking pipeline
|
|
10
|
+
*/
|
|
11
|
+
export enum ThinkingStage {
|
|
12
|
+
SEARCH = 'search',
|
|
13
|
+
ANALYSIS = 'analysis',
|
|
14
|
+
REASONING = 'reasoning',
|
|
15
|
+
LEARNING = 'learning',
|
|
16
|
+
PLANNING = 'planning',
|
|
17
|
+
CREATIVITY = 'creativity',
|
|
18
|
+
SYNTHESIS = 'synthesis',
|
|
19
|
+
EVALUATION = 'evaluation',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Confidence Level Enum - Represents confidence levels for results
|
|
24
|
+
*/
|
|
25
|
+
export enum ConfidenceLevel {
|
|
26
|
+
VERY_LOW = 0.2,
|
|
27
|
+
LOW = 0.4,
|
|
28
|
+
MEDIUM = 0.6,
|
|
29
|
+
HIGH = 0.8,
|
|
30
|
+
VERY_HIGH = 0.95,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Priority Enum - Represents task priorities
|
|
35
|
+
*/
|
|
36
|
+
export enum Priority {
|
|
37
|
+
CRITICAL = 5,
|
|
38
|
+
HIGH = 4,
|
|
39
|
+
MEDIUM = 3,
|
|
40
|
+
LOW = 2,
|
|
41
|
+
MINIMAL = 1,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Task Status Enum - Represents task execution status
|
|
46
|
+
*/
|
|
47
|
+
export enum TaskStatus {
|
|
48
|
+
PENDING = 'pending',
|
|
49
|
+
IN_PROGRESS = 'in_progress',
|
|
50
|
+
COMPLETED = 'completed',
|
|
51
|
+
FAILED = 'failed',
|
|
52
|
+
CANCELLED = 'cancelled',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Source Type Enum - Represents types of information sources
|
|
57
|
+
*/
|
|
58
|
+
export enum SourceType {
|
|
59
|
+
WEB = 'web',
|
|
60
|
+
KNOWLEDGE_BASE = 'knowledge_base',
|
|
61
|
+
CACHE = 'cache',
|
|
62
|
+
USER_INPUT = 'user_input',
|
|
63
|
+
LLM = 'llm',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Zod Schema for ThinkingStage validation
|
|
68
|
+
*/
|
|
69
|
+
export const ThinkingStageSchema = z.nativeEnum(ThinkingStage);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Zod Schema for ConfidenceLevel validation
|
|
73
|
+
*/
|
|
74
|
+
export const ConfidenceLevelSchema = z.nativeEnum(ConfidenceLevel);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Zod Schema for Priority validation
|
|
78
|
+
*/
|
|
79
|
+
export const PrioritySchema = z.nativeEnum(Priority);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Zod Schema for TaskStatus validation
|
|
83
|
+
*/
|
|
84
|
+
export const TaskStatusSchema = z.nativeEnum(TaskStatus);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Zod Schema for SourceType validation
|
|
88
|
+
*/
|
|
89
|
+
export const SourceTypeSchema = z.nativeEnum(SourceType);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Base Configuration Schema
|
|
93
|
+
*/
|
|
94
|
+
export const BaseConfigSchema = z.object({
|
|
95
|
+
timeout: z.number().positive().default(60000),
|
|
96
|
+
maxRetries: z.number().nonnegative().default(3),
|
|
97
|
+
enableCache: z.boolean().default(true),
|
|
98
|
+
logLevel: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Base Configuration Type
|
|
103
|
+
*/
|
|
104
|
+
export type BaseConfig = z.infer<typeof BaseConfigSchema>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Base Result Schema
|
|
108
|
+
*/
|
|
109
|
+
export const BaseResultSchema = z.object({
|
|
110
|
+
success: z.boolean(),
|
|
111
|
+
confidence: z.number().min(0).max(1),
|
|
112
|
+
timestamp: z.date(),
|
|
113
|
+
duration: z.number().nonnegative(),
|
|
114
|
+
errors: z.array(z.string()).default([]),
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Base Result Type
|
|
119
|
+
*/
|
|
120
|
+
export type BaseResult = z.infer<typeof BaseResultSchema>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Thinking Error Class - Custom error for thinking operations
|
|
124
|
+
*/
|
|
125
|
+
export class ThinkingError extends Error {
|
|
126
|
+
public readonly stage: ThinkingStage | undefined;
|
|
127
|
+
public readonly code: string;
|
|
128
|
+
public readonly timestamp: Date;
|
|
129
|
+
public readonly details: Record<string, unknown>;
|
|
130
|
+
|
|
131
|
+
constructor(
|
|
132
|
+
message: string,
|
|
133
|
+
code: string,
|
|
134
|
+
stage?: ThinkingStage,
|
|
135
|
+
details: Record<string, unknown> = {}
|
|
136
|
+
) {
|
|
137
|
+
super(message);
|
|
138
|
+
this.name = 'ThinkingError';
|
|
139
|
+
this.code = code;
|
|
140
|
+
this.stage = stage;
|
|
141
|
+
this.timestamp = new Date();
|
|
142
|
+
this.details = details;
|
|
143
|
+
Error.captureStackTrace(this, this.constructor);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
toJSON(): Record<string, unknown> {
|
|
147
|
+
return {
|
|
148
|
+
name: this.name,
|
|
149
|
+
message: this.message,
|
|
150
|
+
code: this.code,
|
|
151
|
+
stage: this.stage,
|
|
152
|
+
timestamp: this.timestamp,
|
|
153
|
+
details: this.details,
|
|
154
|
+
stack: this.stack,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Validation Error Class - For input validation errors
|
|
161
|
+
*/
|
|
162
|
+
export class ValidationError extends ThinkingError {
|
|
163
|
+
constructor(message: string, details: Record<string, unknown> = {}) {
|
|
164
|
+
super(message, 'VALIDATION_ERROR', undefined, details);
|
|
165
|
+
this.name = 'ValidationError';
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Timeout Error Class - For operation timeout errors
|
|
171
|
+
*/
|
|
172
|
+
export class TimeoutError extends ThinkingError {
|
|
173
|
+
constructor(message: string, stage?: ThinkingStage) {
|
|
174
|
+
super(message, 'TIMEOUT_ERROR', stage);
|
|
175
|
+
this.name = 'TimeoutError';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Cache Error Class - For caching operation errors
|
|
181
|
+
*/
|
|
182
|
+
export class CacheError extends ThinkingError {
|
|
183
|
+
constructor(message: string, details: Record<string, unknown> = {}) {
|
|
184
|
+
super(message, 'CACHE_ERROR', undefined, details);
|
|
185
|
+
this.name = 'CacheError';
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Metrics Interface - For tracking operation metrics
|
|
191
|
+
*/
|
|
192
|
+
export interface Metrics {
|
|
193
|
+
startTime: number;
|
|
194
|
+
endTime?: number;
|
|
195
|
+
duration?: number;
|
|
196
|
+
stageDurations: Map<ThinkingStage, number>;
|
|
197
|
+
cacheHits: number;
|
|
198
|
+
cacheMisses: number;
|
|
199
|
+
retryCount: number;
|
|
200
|
+
errorCount: number;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Create initial metrics object
|
|
205
|
+
*/
|
|
206
|
+
export function createMetrics(): Metrics {
|
|
207
|
+
return {
|
|
208
|
+
startTime: Date.now(),
|
|
209
|
+
stageDurations: new Map(),
|
|
210
|
+
cacheHits: 0,
|
|
211
|
+
cacheMisses: 0,
|
|
212
|
+
retryCount: 0,
|
|
213
|
+
errorCount: 0,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Event Types for the thinking engine
|
|
219
|
+
*/
|
|
220
|
+
export type ThinkingEventType =
|
|
221
|
+
| 'thinking:start'
|
|
222
|
+
| 'thinking:stage:start'
|
|
223
|
+
| 'thinking:stage:complete'
|
|
224
|
+
| 'thinking:stage:error'
|
|
225
|
+
| 'thinking:complete'
|
|
226
|
+
| 'thinking:error'
|
|
227
|
+
| 'thinking:cancelled';
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Event Payload Interface
|
|
231
|
+
*/
|
|
232
|
+
export interface ThinkingEventPayload {
|
|
233
|
+
sessionId: string;
|
|
234
|
+
stage?: ThinkingStage;
|
|
235
|
+
timestamp: Date;
|
|
236
|
+
data?: unknown;
|
|
237
|
+
error?: ThinkingError;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Event Handler Type
|
|
242
|
+
*/
|
|
243
|
+
export type ThinkingEventHandler = (payload: ThinkingEventPayload) => void | Promise<void>;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Engine Configuration Interface
|
|
247
|
+
* Flat configuration structure used by internal components
|
|
248
|
+
*/
|
|
249
|
+
export interface EngineConfig {
|
|
250
|
+
// LLM Config
|
|
251
|
+
llmProvider: 'gemini' | 'claude' | 'openai' | 'kimi' | 'custom' | 'cli';
|
|
252
|
+
llmApiKey?: string;
|
|
253
|
+
llmModel?: string;
|
|
254
|
+
llmCliCommand?: string;
|
|
255
|
+
llmCliArgs?: string[];
|
|
256
|
+
llmCliPromptPassingMethod?: 'stdin' | 'arg';
|
|
257
|
+
llmCliPromptFlag?: string;
|
|
258
|
+
llmTimeoutMs?: number;
|
|
259
|
+
llmMaxRetries?: number;
|
|
260
|
+
|
|
261
|
+
// Rate Limit Config
|
|
262
|
+
rateLimitEnabled?: boolean;
|
|
263
|
+
rateLimitRequestsPerMinute?: number;
|
|
264
|
+
rateLimitBurstSize?: number;
|
|
265
|
+
|
|
266
|
+
// Session Config
|
|
267
|
+
sessionMaxAgeMs?: number;
|
|
268
|
+
sessionCleanupIntervalMs?: number;
|
|
269
|
+
maxConcurrentSessions?: number;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Thinking Request Interface
|
|
274
|
+
*/
|
|
275
|
+
export interface ThinkingRequest {
|
|
276
|
+
id?: string;
|
|
277
|
+
query: string;
|
|
278
|
+
context?: string[];
|
|
279
|
+
preferredStages?: ThinkingStage[];
|
|
280
|
+
options?: {
|
|
281
|
+
depth?: 'shallow' | 'medium' | 'deep';
|
|
282
|
+
complexity?: 'simple' | 'moderate' | 'complex';
|
|
283
|
+
timeout?: number;
|
|
284
|
+
maxStages?: number;
|
|
285
|
+
stream?: boolean;
|
|
286
|
+
[key: string]: unknown;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Thinking Response Interface
|
|
292
|
+
*/
|
|
293
|
+
export interface ThinkingResponse extends BaseResult {
|
|
294
|
+
query: string;
|
|
295
|
+
[key: string]: unknown;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Stage Result Interface
|
|
300
|
+
*/
|
|
301
|
+
export interface StageResult extends BaseResult {
|
|
302
|
+
stage: ThinkingStage;
|
|
303
|
+
status: string;
|
|
304
|
+
data: unknown;
|
|
305
|
+
error?: Error;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Stream Chunk Interface
|
|
310
|
+
*/
|
|
311
|
+
export interface StreamChunk {
|
|
312
|
+
id: string;
|
|
313
|
+
stage: ThinkingStage;
|
|
314
|
+
content: string;
|
|
315
|
+
done: boolean;
|
|
316
|
+
metadata?: Record<string, unknown>;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Session Interface
|
|
321
|
+
*/
|
|
322
|
+
export interface Session {
|
|
323
|
+
id: string;
|
|
324
|
+
status: TaskStatus;
|
|
325
|
+
startTime: number;
|
|
326
|
+
lastAccessedAt: number;
|
|
327
|
+
results: Record<string, unknown>;
|
|
328
|
+
error?: Error;
|
|
329
|
+
metadata: Record<string, unknown>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Session Schema
|
|
334
|
+
*/
|
|
335
|
+
export const SessionSchema = z.object({
|
|
336
|
+
id: z.string().uuid(),
|
|
337
|
+
status: TaskStatusSchema,
|
|
338
|
+
startTime: z.number(),
|
|
339
|
+
lastAccessedAt: z.number(),
|
|
340
|
+
results: z.record(z.unknown()),
|
|
341
|
+
metadata: z.record(z.unknown()),
|
|
342
|
+
});
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creativity Types for gthinking v2.0.0
|
|
3
|
+
* Types for creative thinking and ideation functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { BaseResultSchema } from './core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creativity Technique Enum
|
|
11
|
+
*/
|
|
12
|
+
export enum CreativityTechnique {
|
|
13
|
+
BRAINSTORMING = 'brainstorming',
|
|
14
|
+
SCAMPER = 'scamper',
|
|
15
|
+
SIX_THINKING_HATS = 'six_thinking_hats',
|
|
16
|
+
MIND_MAPPING = 'mind_mapping',
|
|
17
|
+
ANALOGY = 'analogy',
|
|
18
|
+
REVERSE_THINKING = 'reverse_thinking',
|
|
19
|
+
RANDOM_STIMULUS = 'random_stimulus',
|
|
20
|
+
LATERAL_THINKING = 'lateral_thinking',
|
|
21
|
+
OUT_OF_BOX = 'out_of_box',
|
|
22
|
+
CONCEPT_CONNECTION = 'concept_connection',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Creativity Technique Schema
|
|
27
|
+
*/
|
|
28
|
+
export const CreativityTechniqueSchema = z.nativeEnum(CreativityTechnique);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creative Session Request Schema
|
|
32
|
+
*/
|
|
33
|
+
export const CreativeSessionRequestSchema = z.object({
|
|
34
|
+
challenge: z.string().min(1).max(5000),
|
|
35
|
+
techniques: z.array(CreativityTechniqueSchema).default([CreativityTechnique.BRAINSTORMING]),
|
|
36
|
+
options: z.object({
|
|
37
|
+
ideaCount: z.number().positive().max(100).default(20),
|
|
38
|
+
timeLimit: z.number().positive().default(30), // in minutes
|
|
39
|
+
diversityWeight: z.number().min(0).max(1).default(0.5),
|
|
40
|
+
noveltyWeight: z.number().min(0).max(1).default(0.5),
|
|
41
|
+
feasibilityWeight: z.number().min(0).max(1).default(0.5),
|
|
42
|
+
includeWildIdeas: z.boolean().default(true),
|
|
43
|
+
useLLM: z.boolean().default(true),
|
|
44
|
+
}).default({}),
|
|
45
|
+
context: z.object({
|
|
46
|
+
domain: z.string().optional(),
|
|
47
|
+
constraints: z.array(z.string()).default([]),
|
|
48
|
+
resources: z.array(z.string()).default([]),
|
|
49
|
+
previousIdeas: z.array(z.string()).default([]),
|
|
50
|
+
}).default({}),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Creative Session Request Type
|
|
55
|
+
*/
|
|
56
|
+
export type CreativeSessionRequest = z.infer<typeof CreativeSessionRequestSchema>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Idea Schema
|
|
60
|
+
*/
|
|
61
|
+
export const IdeaSchema = z.object({
|
|
62
|
+
id: z.string().uuid(),
|
|
63
|
+
content: z.string(),
|
|
64
|
+
technique: CreativityTechniqueSchema,
|
|
65
|
+
novelty: z.number().min(0).max(1),
|
|
66
|
+
feasibility: z.number().min(0).max(1),
|
|
67
|
+
impact: z.number().min(0).max(1),
|
|
68
|
+
diversity: z.number().min(0).max(1),
|
|
69
|
+
overallScore: z.number().min(0).max(1),
|
|
70
|
+
tags: z.array(z.string()).default([]),
|
|
71
|
+
relatedIdeas: z.array(z.string().uuid()).default([]),
|
|
72
|
+
generatedAt: z.date(),
|
|
73
|
+
metadata: z.record(z.unknown()).default({}),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Idea Type
|
|
78
|
+
*/
|
|
79
|
+
export type Idea = z.infer<typeof IdeaSchema>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Connection Schema
|
|
83
|
+
*/
|
|
84
|
+
export const ConnectionSchema = z.object({
|
|
85
|
+
id: z.string().uuid(),
|
|
86
|
+
from: z.string().uuid(),
|
|
87
|
+
to: z.string().uuid(),
|
|
88
|
+
type: z.enum(['similar', 'opposite', 'complementary', 'causal', 'analogous', 'random']),
|
|
89
|
+
strength: z.number().min(0).max(1),
|
|
90
|
+
explanation: z.string(),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Connection Type
|
|
95
|
+
*/
|
|
96
|
+
export type Connection = z.infer<typeof ConnectionSchema>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Mind Map Node Schema
|
|
100
|
+
*/
|
|
101
|
+
export const MindMapNodeSchema = z.object({
|
|
102
|
+
id: z.string().uuid(),
|
|
103
|
+
label: z.string(),
|
|
104
|
+
parentId: z.string().uuid().optional(),
|
|
105
|
+
children: z.array(z.string().uuid()).default([]),
|
|
106
|
+
depth: z.number().nonnegative(),
|
|
107
|
+
ideas: z.array(z.string().uuid()).default([]),
|
|
108
|
+
category: z.string().optional(),
|
|
109
|
+
color: z.string().optional(),
|
|
110
|
+
position: z.object({
|
|
111
|
+
x: z.number(),
|
|
112
|
+
y: z.number(),
|
|
113
|
+
}).optional(),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Mind Map Node Type
|
|
118
|
+
*/
|
|
119
|
+
export type MindMapNode = z.infer<typeof MindMapNodeSchema>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Mind Map Schema
|
|
123
|
+
*/
|
|
124
|
+
export const MindMapSchema = z.object({
|
|
125
|
+
id: z.string().uuid(),
|
|
126
|
+
centralTopic: z.string(),
|
|
127
|
+
nodes: z.array(MindMapNodeSchema),
|
|
128
|
+
connections: z.array(ConnectionSchema),
|
|
129
|
+
rootNodeId: z.string().uuid(),
|
|
130
|
+
maxDepth: z.number().positive(),
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Mind Map Type
|
|
135
|
+
*/
|
|
136
|
+
export type MindMap = z.infer<typeof MindMapSchema>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* SCAMPER Element Schema
|
|
140
|
+
*/
|
|
141
|
+
export const ScamperElementSchema = z.object({
|
|
142
|
+
letter: z.enum(['S', 'C', 'A', 'M', 'P', 'E', 'R']),
|
|
143
|
+
action: z.string(),
|
|
144
|
+
description: z.string(),
|
|
145
|
+
ideas: z.array(IdeaSchema),
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* SCAMPER Element Type
|
|
150
|
+
*/
|
|
151
|
+
export type ScamperElement = z.infer<typeof ScamperElementSchema>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Six Hats Result Schema
|
|
155
|
+
*/
|
|
156
|
+
export const SixHatsResultSchema = z.object({
|
|
157
|
+
hat: z.enum(['white', 'red', 'black', 'yellow', 'green', 'blue']),
|
|
158
|
+
perspective: z.string(),
|
|
159
|
+
ideas: z.array(IdeaSchema),
|
|
160
|
+
insights: z.array(z.string()),
|
|
161
|
+
concerns: z.array(z.string()).default([]),
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Six Hats Result Type
|
|
166
|
+
*/
|
|
167
|
+
export type SixHatsResult = z.infer<typeof SixHatsResultSchema>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Analogy Result Schema
|
|
171
|
+
*/
|
|
172
|
+
export const AnalogyResultSchema = z.object({
|
|
173
|
+
sourceDomain: z.string(),
|
|
174
|
+
targetDomain: z.string(),
|
|
175
|
+
mapping: z.array(z.object({
|
|
176
|
+
source: z.string(),
|
|
177
|
+
target: z.string(),
|
|
178
|
+
insight: z.string(),
|
|
179
|
+
})),
|
|
180
|
+
ideas: z.array(IdeaSchema),
|
|
181
|
+
strength: z.number().min(0).max(1),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Analogy Result Type
|
|
186
|
+
*/
|
|
187
|
+
export type AnalogyResult = z.infer<typeof AnalogyResultSchema>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Creative Session Schema
|
|
191
|
+
*/
|
|
192
|
+
export const CreativeSessionSchema = z.object({
|
|
193
|
+
id: z.string().uuid(),
|
|
194
|
+
request: CreativeSessionRequestSchema,
|
|
195
|
+
ideas: z.array(IdeaSchema),
|
|
196
|
+
connections: z.array(ConnectionSchema),
|
|
197
|
+
mindMap: MindMapSchema.optional(),
|
|
198
|
+
scamper: z.array(ScamperElementSchema).optional(),
|
|
199
|
+
sixHats: z.array(SixHatsResultSchema).optional(),
|
|
200
|
+
analogies: z.array(AnalogyResultSchema).default([]),
|
|
201
|
+
topIdeas: z.array(z.string().uuid()).default([]),
|
|
202
|
+
startedAt: z.date(),
|
|
203
|
+
completedAt: z.date().optional(),
|
|
204
|
+
metadata: z.record(z.unknown()).default({}),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Creative Session Type
|
|
209
|
+
*/
|
|
210
|
+
export type CreativeSession = z.infer<typeof CreativeSessionSchema>;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Creative Result Schema
|
|
214
|
+
*/
|
|
215
|
+
export const CreativeResultSchema = BaseResultSchema.extend({
|
|
216
|
+
session: CreativeSessionSchema,
|
|
217
|
+
topIdeas: z.array(IdeaSchema),
|
|
218
|
+
recommendations: z.array(z.string()).default([]),
|
|
219
|
+
nextSteps: z.array(z.string()).default([]),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Creative Result Type
|
|
224
|
+
*/
|
|
225
|
+
export type CreativeResult = z.infer<typeof CreativeResultSchema>;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Idea Evaluation Criteria Schema
|
|
229
|
+
*/
|
|
230
|
+
export const IdeaEvaluationCriteriaSchema = z.object({
|
|
231
|
+
novelty: z.object({
|
|
232
|
+
weight: z.number().min(0).max(1).default(0.25),
|
|
233
|
+
description: z.string().default('How unique and original is the idea?'),
|
|
234
|
+
}),
|
|
235
|
+
feasibility: z.object({
|
|
236
|
+
weight: z.number().min(0).max(1).default(0.25),
|
|
237
|
+
description: z.string().default('How practical and implementable is the idea?'),
|
|
238
|
+
}),
|
|
239
|
+
impact: z.object({
|
|
240
|
+
weight: z.number().min(0).max(1).default(0.25),
|
|
241
|
+
description: z.string().default('What is the potential impact of the idea?'),
|
|
242
|
+
}),
|
|
243
|
+
diversity: z.object({
|
|
244
|
+
weight: z.number().min(0).max(1).default(0.25),
|
|
245
|
+
description: z.string().default('How different is this idea from others?'),
|
|
246
|
+
}),
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Idea Evaluation Criteria Type
|
|
251
|
+
*/
|
|
252
|
+
export type IdeaEvaluationCriteria = z.infer<typeof IdeaEvaluationCriteriaSchema>;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Perspective Schema for Out-of-Box thinking
|
|
256
|
+
*/
|
|
257
|
+
export const PerspectiveSchema = z.object({
|
|
258
|
+
id: z.string().uuid(),
|
|
259
|
+
name: z.string(),
|
|
260
|
+
description: z.string(),
|
|
261
|
+
questions: z.array(z.string()),
|
|
262
|
+
ideas: z.array(IdeaSchema),
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Perspective Type
|
|
267
|
+
*/
|
|
268
|
+
export type Perspective = z.infer<typeof PerspectiveSchema>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types Index for gthinking v2.0.0
|
|
3
|
+
* Central export point for all types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Core Types
|
|
7
|
+
export * from './core';
|
|
8
|
+
|
|
9
|
+
// Search Types
|
|
10
|
+
export * from './search';
|
|
11
|
+
|
|
12
|
+
// Analysis Types
|
|
13
|
+
export * from './analysis';
|
|
14
|
+
|
|
15
|
+
// Reasoning Types
|
|
16
|
+
export * from './reasoning';
|
|
17
|
+
|
|
18
|
+
// Planning Types
|
|
19
|
+
export * from './planning';
|
|
20
|
+
|
|
21
|
+
// Creativity Types
|
|
22
|
+
export * from './creativity';
|
|
23
|
+
|
|
24
|
+
// Learning Types
|
|
25
|
+
export * from './learning';
|
|
26
|
+
|
|
27
|
+
// Synthesis Types
|
|
28
|
+
export * from './synthesis';
|
|
29
|
+
|
|
30
|
+
// Re-export zod for convenience
|
|
31
|
+
export { z } from 'zod';
|