gthinking 1.3.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +34 -0
- package/ANALYSIS_SUMMARY.md +363 -0
- package/README.md +230 -250
- 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 -38
- 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 -720
- 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 -62
- package/dist/planning.d.ts.map +0 -1
- package/dist/planning.js +0 -886
- 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 -1009
- 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 -1101
- 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 -43
- package/types.ts +0 -6
- /package/dist/{server.d.ts → mcp/server.d.ts} +0 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reasoning Types for gthinking v2.0.0
|
|
3
|
+
* Types for reasoning and logical inference functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { BaseResultSchema } from './core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reasoning Type Enum
|
|
11
|
+
*/
|
|
12
|
+
export enum ReasoningType {
|
|
13
|
+
DEDUCTIVE = 'deductive',
|
|
14
|
+
INDUCTIVE = 'inductive',
|
|
15
|
+
ABDUCTIVE = 'abductive',
|
|
16
|
+
ANALOGICAL = 'analogical',
|
|
17
|
+
CAUSAL = 'causal',
|
|
18
|
+
COUNTERFACTUAL = 'counterfactual',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reasoning Type Schema
|
|
23
|
+
*/
|
|
24
|
+
export const ReasoningTypeSchema = z.nativeEnum(ReasoningType);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Reasoning Request Schema
|
|
28
|
+
*/
|
|
29
|
+
export const ReasoningRequestSchema = z.object({
|
|
30
|
+
problem: z.string().min(1).max(10000),
|
|
31
|
+
type: ReasoningTypeSchema.default(ReasoningType.DEDUCTIVE),
|
|
32
|
+
context: z.array(z.string()).default([]),
|
|
33
|
+
constraints: z.array(z.string()).default([]),
|
|
34
|
+
options: z.object({
|
|
35
|
+
maxSteps: z.number().positive().max(20).default(5),
|
|
36
|
+
confidence: z.number().min(0).max(1).default(0.7),
|
|
37
|
+
useLLM: z.boolean().default(true),
|
|
38
|
+
includeChainOfThought: z.boolean().default(true),
|
|
39
|
+
generateHypotheses: z.boolean().default(true),
|
|
40
|
+
decomposeProblem: z.boolean().default(true),
|
|
41
|
+
}).default({}),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Reasoning Request Type
|
|
46
|
+
*/
|
|
47
|
+
export type ReasoningRequest = z.infer<typeof ReasoningRequestSchema>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Reasoning Step Schema
|
|
51
|
+
*/
|
|
52
|
+
export const ReasoningStepSchema = z.object({
|
|
53
|
+
id: z.string().uuid(),
|
|
54
|
+
stepNumber: z.number().positive(),
|
|
55
|
+
type: z.enum(['premise', 'observation', 'inference', 'conclusion', 'hypothesis', 'evidence']),
|
|
56
|
+
content: z.string(),
|
|
57
|
+
premise: z.string().optional(),
|
|
58
|
+
inference: z.string().optional(),
|
|
59
|
+
conclusion: z.string().optional(),
|
|
60
|
+
confidence: z.number().min(0).max(1),
|
|
61
|
+
supportingEvidence: z.array(z.string()).default([]),
|
|
62
|
+
counterEvidence: z.array(z.string()).default([]),
|
|
63
|
+
assumptions: z.array(z.string()).default([]),
|
|
64
|
+
dependencies: z.array(z.string().uuid()).default([]),
|
|
65
|
+
metadata: z.record(z.unknown()).default({}),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Reasoning Step Type
|
|
70
|
+
*/
|
|
71
|
+
export type ReasoningStep = z.infer<typeof ReasoningStepSchema>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Hypothesis Schema
|
|
75
|
+
*/
|
|
76
|
+
export const HypothesisSchema = z.object({
|
|
77
|
+
id: z.string().uuid(),
|
|
78
|
+
statement: z.string(),
|
|
79
|
+
plausibility: z.number().min(0).max(1),
|
|
80
|
+
evidence: z.array(z.object({
|
|
81
|
+
description: z.string(),
|
|
82
|
+
supports: z.boolean(),
|
|
83
|
+
strength: z.number().min(0).max(1),
|
|
84
|
+
})),
|
|
85
|
+
testable: z.boolean(),
|
|
86
|
+
tested: z.boolean().default(false),
|
|
87
|
+
testResult: z.enum(['confirmed', 'rejected', 'inconclusive']).optional(),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Hypothesis Type
|
|
92
|
+
*/
|
|
93
|
+
export type Hypothesis = z.infer<typeof HypothesisSchema>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Chain of Thought Node Schema
|
|
97
|
+
*/
|
|
98
|
+
export const ChainOfThoughtNodeSchema = z.object({
|
|
99
|
+
id: z.string().uuid(),
|
|
100
|
+
content: z.string(),
|
|
101
|
+
type: z.enum(['question', 'observation', 'inference', 'conclusion', 'assumption']),
|
|
102
|
+
parentId: z.string().uuid().optional(),
|
|
103
|
+
children: z.array(z.string().uuid()).default([]),
|
|
104
|
+
depth: z.number().nonnegative(),
|
|
105
|
+
confidence: z.number().min(0).max(1),
|
|
106
|
+
supportingEvidence: z.array(z.string()).default([]),
|
|
107
|
+
metadata: z.record(z.unknown()).default({}),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Chain of Thought Node Type
|
|
112
|
+
*/
|
|
113
|
+
export type ChainOfThoughtNode = z.infer<typeof ChainOfThoughtNodeSchema>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Chain of Thought Schema
|
|
117
|
+
*/
|
|
118
|
+
export const ChainOfThoughtSchema = z.object({
|
|
119
|
+
id: z.string().uuid(),
|
|
120
|
+
question: z.string(),
|
|
121
|
+
nodes: z.array(ChainOfThoughtNodeSchema),
|
|
122
|
+
rootNodeId: z.string().uuid(),
|
|
123
|
+
maxDepth: z.number().positive(),
|
|
124
|
+
finalAnswer: z.string().optional(),
|
|
125
|
+
completeness: z.number().min(0).max(1),
|
|
126
|
+
coherence: z.number().min(0).max(1),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Chain of Thought Type
|
|
131
|
+
*/
|
|
132
|
+
export type ChainOfThought = z.infer<typeof ChainOfThoughtSchema>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Logical Rule Schema
|
|
136
|
+
*/
|
|
137
|
+
export const LogicalRuleSchema = z.object({
|
|
138
|
+
id: z.string().uuid(),
|
|
139
|
+
name: z.string(),
|
|
140
|
+
premises: z.array(z.string()),
|
|
141
|
+
conclusion: z.string(),
|
|
142
|
+
confidence: z.number().min(0).max(1),
|
|
143
|
+
domain: z.string().optional(),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Logical Rule Type
|
|
148
|
+
*/
|
|
149
|
+
export type LogicalRule = z.infer<typeof LogicalRuleSchema>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Analogy Schema
|
|
153
|
+
*/
|
|
154
|
+
export const AnalogySchema = z.object({
|
|
155
|
+
id: z.string().uuid(),
|
|
156
|
+
sourceDomain: z.string(),
|
|
157
|
+
targetDomain: z.string(),
|
|
158
|
+
mapping: z.array(z.object({
|
|
159
|
+
source: z.string(),
|
|
160
|
+
target: z.string(),
|
|
161
|
+
similarity: z.number().min(0).max(1),
|
|
162
|
+
})),
|
|
163
|
+
strength: z.number().min(0).max(1),
|
|
164
|
+
explanation: z.string(),
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Analogy Type
|
|
169
|
+
*/
|
|
170
|
+
export type Analogy = z.infer<typeof AnalogySchema>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Causal Chain Schema
|
|
174
|
+
*/
|
|
175
|
+
export const CausalChainSchema = z.object({
|
|
176
|
+
id: z.string().uuid(),
|
|
177
|
+
cause: z.string(),
|
|
178
|
+
effect: z.string(),
|
|
179
|
+
intermediates: z.array(z.object({
|
|
180
|
+
event: z.string(),
|
|
181
|
+
confidence: z.number().min(0).max(1),
|
|
182
|
+
})),
|
|
183
|
+
confidence: z.number().min(0).max(1),
|
|
184
|
+
evidence: z.array(z.string()),
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Causal Chain Type
|
|
189
|
+
*/
|
|
190
|
+
export type CausalChain = z.infer<typeof CausalChainSchema>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Counterfactual Scenario Schema
|
|
194
|
+
*/
|
|
195
|
+
export const CounterfactualScenarioSchema = z.object({
|
|
196
|
+
id: z.string().uuid(),
|
|
197
|
+
original: z.string(),
|
|
198
|
+
alternative: z.string(),
|
|
199
|
+
changes: z.array(z.string()),
|
|
200
|
+
consequences: z.array(z.object({
|
|
201
|
+
description: z.string(),
|
|
202
|
+
probability: z.number().min(0).max(1),
|
|
203
|
+
impact: z.enum(['low', 'medium', 'high', 'critical']),
|
|
204
|
+
})),
|
|
205
|
+
plausibility: z.number().min(0).max(1),
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Counterfactual Scenario Type
|
|
210
|
+
*/
|
|
211
|
+
export type CounterfactualScenario = z.infer<typeof CounterfactualScenarioSchema>;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Problem Component Schema
|
|
215
|
+
*/
|
|
216
|
+
export const ProblemComponentSchema = z.object({
|
|
217
|
+
id: z.string().uuid(),
|
|
218
|
+
name: z.string(),
|
|
219
|
+
description: z.string(),
|
|
220
|
+
type: z.enum(['subproblem', 'constraint', 'resource', 'objective', 'stakeholder']),
|
|
221
|
+
complexity: z.number().min(0).max(1),
|
|
222
|
+
dependencies: z.array(z.string().uuid()).default([]),
|
|
223
|
+
priority: z.number().min(1).max(5),
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Problem Component Type
|
|
228
|
+
*/
|
|
229
|
+
export type ProblemComponent = z.infer<typeof ProblemComponentSchema>;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Problem Decomposition Schema
|
|
233
|
+
*/
|
|
234
|
+
export const ProblemDecompositionSchema = z.object({
|
|
235
|
+
originalProblem: z.string(),
|
|
236
|
+
components: z.array(ProblemComponentSchema),
|
|
237
|
+
relationships: z.array(z.object({
|
|
238
|
+
from: z.string().uuid(),
|
|
239
|
+
to: z.string().uuid(),
|
|
240
|
+
type: z.enum(['depends_on', 'blocks', 'enables', 'conflicts_with']),
|
|
241
|
+
})),
|
|
242
|
+
complexity: z.number().min(0).max(1),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Problem Decomposition Type
|
|
247
|
+
*/
|
|
248
|
+
export type ProblemDecomposition = z.infer<typeof ProblemDecompositionSchema>;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Reasoning Session Schema
|
|
252
|
+
*/
|
|
253
|
+
export const ReasoningSessionSchema = z.object({
|
|
254
|
+
id: z.string().uuid(),
|
|
255
|
+
request: ReasoningRequestSchema,
|
|
256
|
+
steps: z.array(ReasoningStepSchema),
|
|
257
|
+
hypotheses: z.array(HypothesisSchema),
|
|
258
|
+
chainOfThought: ChainOfThoughtSchema.optional(),
|
|
259
|
+
decomposition: ProblemDecompositionSchema.optional(),
|
|
260
|
+
analogies: z.array(AnalogySchema).default([]),
|
|
261
|
+
causalChains: z.array(CausalChainSchema).default([]),
|
|
262
|
+
counterfactuals: z.array(CounterfactualScenarioSchema).default([]),
|
|
263
|
+
conclusion: z.string().optional(),
|
|
264
|
+
confidence: z.number().min(0).max(1),
|
|
265
|
+
startedAt: z.date(),
|
|
266
|
+
completedAt: z.date().optional(),
|
|
267
|
+
metadata: z.record(z.unknown()).default({}),
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Reasoning Session Type
|
|
272
|
+
*/
|
|
273
|
+
export type ReasoningSession = z.infer<typeof ReasoningSessionSchema>;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Reasoning Result Schema
|
|
277
|
+
*/
|
|
278
|
+
export const ReasoningResultSchema = BaseResultSchema.extend({
|
|
279
|
+
session: ReasoningSessionSchema,
|
|
280
|
+
conclusion: z.string(),
|
|
281
|
+
recommendations: z.array(z.string()),
|
|
282
|
+
confidenceBreakdown: z.record(z.number().min(0).max(1)).default({}),
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Reasoning Result Type
|
|
287
|
+
*/
|
|
288
|
+
export type ReasoningResult = z.infer<typeof ReasoningResultSchema>;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Types for gthinking v2.0.0
|
|
3
|
+
* Types for search and discovery functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { SourceType, BaseResultSchema } from './core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Search Provider Enum
|
|
11
|
+
*/
|
|
12
|
+
export enum SearchProvider {
|
|
13
|
+
GOOGLE = 'google',
|
|
14
|
+
BING = 'bing',
|
|
15
|
+
BRAVE = 'brave',
|
|
16
|
+
DUCKDUCKGO = 'duckduckgo',
|
|
17
|
+
KNOWLEDGE_BASE = 'knowledge_base',
|
|
18
|
+
CACHE = 'cache',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Search Provider Schema
|
|
23
|
+
*/
|
|
24
|
+
export const SearchProviderSchema = z.nativeEnum(SearchProvider);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Search Query Schema
|
|
28
|
+
*/
|
|
29
|
+
export const SearchQuerySchema = z.object({
|
|
30
|
+
query: z.string().min(1).max(1000),
|
|
31
|
+
maxResults: z.number().positive().max(100).default(10),
|
|
32
|
+
sources: z.array(SearchProviderSchema).default([SearchProvider.GOOGLE]),
|
|
33
|
+
filters: z.object({
|
|
34
|
+
dateRange: z.object({
|
|
35
|
+
from: z.date().optional(),
|
|
36
|
+
to: z.date().optional(),
|
|
37
|
+
}).optional(),
|
|
38
|
+
language: z.string().default('en'),
|
|
39
|
+
region: z.string().optional(),
|
|
40
|
+
safeSearch: z.boolean().default(true),
|
|
41
|
+
}).default({}),
|
|
42
|
+
timeout: z.number().positive().default(30000),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Search Query Type
|
|
47
|
+
*/
|
|
48
|
+
export type SearchQuery = z.infer<typeof SearchQuerySchema>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Search Result Item Schema
|
|
52
|
+
*/
|
|
53
|
+
export const SearchResultItemSchema = z.object({
|
|
54
|
+
id: z.string().uuid(),
|
|
55
|
+
title: z.string(),
|
|
56
|
+
url: z.string().url(),
|
|
57
|
+
snippet: z.string(),
|
|
58
|
+
source: SearchProviderSchema,
|
|
59
|
+
sourceType: z.nativeEnum(SourceType),
|
|
60
|
+
publishedDate: z.date().optional(),
|
|
61
|
+
credibility: z.number().min(0).max(1).default(0.5),
|
|
62
|
+
relevance: z.number().min(0).max(1).default(0.5),
|
|
63
|
+
engagement: z.number().min(0).max(1).default(0),
|
|
64
|
+
metadata: z.record(z.unknown()).default({}),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Search Result Item Type
|
|
69
|
+
*/
|
|
70
|
+
export type SearchResultItem = z.infer<typeof SearchResultItemSchema>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Search Result Schema
|
|
74
|
+
*/
|
|
75
|
+
export const SearchResultSchema = BaseResultSchema.extend({
|
|
76
|
+
query: SearchQuerySchema,
|
|
77
|
+
items: z.array(SearchResultItemSchema),
|
|
78
|
+
totalResults: z.number().nonnegative(),
|
|
79
|
+
searchTime: z.number().nonnegative(),
|
|
80
|
+
provider: SearchProviderSchema,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Search Result Type
|
|
85
|
+
*/
|
|
86
|
+
export type SearchResult = z.infer<typeof SearchResultSchema>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Aggregated Result Schema
|
|
90
|
+
*/
|
|
91
|
+
export const AggregatedResultSchema = z.object({
|
|
92
|
+
id: z.string().uuid(),
|
|
93
|
+
topic: z.string(),
|
|
94
|
+
summary: z.string(),
|
|
95
|
+
sources: z.array(SearchResultItemSchema),
|
|
96
|
+
consensusScore: z.number().min(0).max(1),
|
|
97
|
+
conflicts: z.array(z.object({
|
|
98
|
+
claim1: z.string(),
|
|
99
|
+
claim2: z.string(),
|
|
100
|
+
sources: z.array(z.string().uuid()),
|
|
101
|
+
})),
|
|
102
|
+
keyInsights: z.array(z.string()),
|
|
103
|
+
confidence: z.number().min(0).max(1),
|
|
104
|
+
timestamp: z.date(),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Aggregated Result Type
|
|
109
|
+
*/
|
|
110
|
+
export type AggregatedResult = z.infer<typeof AggregatedResultSchema>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Multi-Search Request Schema
|
|
114
|
+
*/
|
|
115
|
+
export const MultiSearchRequestSchema = z.object({
|
|
116
|
+
queries: z.array(z.string().min(1)).min(1).max(10),
|
|
117
|
+
options: SearchQuerySchema.shape.filters.default({}),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Multi-Search Request Type
|
|
122
|
+
*/
|
|
123
|
+
export type MultiSearchRequest = z.infer<typeof MultiSearchRequestSchema>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Search Cache Entry Schema
|
|
127
|
+
*/
|
|
128
|
+
export const SearchCacheEntrySchema = z.object({
|
|
129
|
+
key: z.string(),
|
|
130
|
+
query: SearchQuerySchema,
|
|
131
|
+
result: SearchResultSchema,
|
|
132
|
+
timestamp: z.date(),
|
|
133
|
+
ttl: z.number().positive(),
|
|
134
|
+
accessCount: z.number().nonnegative().default(0),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Search Cache Entry Type
|
|
139
|
+
*/
|
|
140
|
+
export type SearchCacheEntry = z.infer<typeof SearchCacheEntrySchema>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Knowledge Base Entry Schema
|
|
144
|
+
*/
|
|
145
|
+
export const KnowledgeBaseEntrySchema = z.object({
|
|
146
|
+
id: z.string().uuid(),
|
|
147
|
+
title: z.string(),
|
|
148
|
+
content: z.string(),
|
|
149
|
+
category: z.string(),
|
|
150
|
+
tags: z.array(z.string()),
|
|
151
|
+
credibility: z.number().min(0).max(1),
|
|
152
|
+
lastUpdated: z.date(),
|
|
153
|
+
source: z.string(),
|
|
154
|
+
metadata: z.record(z.unknown()).default({}),
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Knowledge Base Entry Type
|
|
159
|
+
*/
|
|
160
|
+
export type KnowledgeBaseEntry = z.infer<typeof KnowledgeBaseEntrySchema>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Web Search Config Schema
|
|
164
|
+
*/
|
|
165
|
+
export const WebSearchConfigSchema = z.object({
|
|
166
|
+
provider: SearchProviderSchema,
|
|
167
|
+
apiKey: z.string().min(1),
|
|
168
|
+
baseUrl: z.string().url().optional(),
|
|
169
|
+
rateLimitPerSecond: z.number().positive().default(1),
|
|
170
|
+
maxRetries: z.number().nonnegative().default(3),
|
|
171
|
+
timeout: z.number().positive().default(10000),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Web Search Config Type
|
|
176
|
+
*/
|
|
177
|
+
export type WebSearchConfig = z.infer<typeof WebSearchConfigSchema>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Search Ranking Weights Schema
|
|
181
|
+
*/
|
|
182
|
+
export const SearchRankingWeightsSchema = z.object({
|
|
183
|
+
relevance: z.number().min(0).max(1).default(0.4),
|
|
184
|
+
credibility: z.number().min(0).max(1).default(0.3),
|
|
185
|
+
freshness: z.number().min(0).max(1).default(0.15),
|
|
186
|
+
engagement: z.number().min(0).max(1).default(0.15),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Search Ranking Weights Type
|
|
191
|
+
*/
|
|
192
|
+
export type SearchRankingWeights = z.infer<typeof SearchRankingWeightsSchema>;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthesis Types for gthinking v2.0.0
|
|
3
|
+
* Types for synthesis and final output generation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { BaseResultSchema, ConfidenceLevel } from './core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Synthesis Request Schema
|
|
11
|
+
*/
|
|
12
|
+
export const SynthesisRequestSchema = z.object({
|
|
13
|
+
query: z.string().min(1),
|
|
14
|
+
stageResults: z.array(z.object({
|
|
15
|
+
stage: z.string(),
|
|
16
|
+
result: z.unknown(),
|
|
17
|
+
confidence: z.number().min(0).max(1),
|
|
18
|
+
})).min(1),
|
|
19
|
+
options: z.object({
|
|
20
|
+
includeDevilsAdvocate: z.boolean().default(true),
|
|
21
|
+
includeConfidenceBreakdown: z.boolean().default(true),
|
|
22
|
+
maxRecommendations: z.number().positive().default(5),
|
|
23
|
+
format: z.enum(['detailed', 'summary', 'structured', 'narrative']).default('detailed'),
|
|
24
|
+
language: z.string().default('en'),
|
|
25
|
+
}).default({}),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Synthesis Request Type
|
|
30
|
+
*/
|
|
31
|
+
export type SynthesisRequest = z.infer<typeof SynthesisRequestSchema>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Recommendation Schema
|
|
35
|
+
*/
|
|
36
|
+
export const RecommendationSchema = z.object({
|
|
37
|
+
id: z.string().uuid(),
|
|
38
|
+
priority: z.number().min(1).max(5),
|
|
39
|
+
title: z.string(),
|
|
40
|
+
description: z.string(),
|
|
41
|
+
rationale: z.string(),
|
|
42
|
+
confidence: z.number().min(0).max(1),
|
|
43
|
+
actions: z.array(z.string()),
|
|
44
|
+
expectedOutcome: z.string(),
|
|
45
|
+
risks: z.array(z.string()).default([]),
|
|
46
|
+
resources: z.array(z.string()).default([]),
|
|
47
|
+
timeline: z.string().optional(),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Recommendation Type
|
|
52
|
+
*/
|
|
53
|
+
export type Recommendation = z.infer<typeof RecommendationSchema>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Evaluation Result Schema
|
|
57
|
+
*/
|
|
58
|
+
export const EvaluationResultSchema = z.object({
|
|
59
|
+
criterion: z.string(),
|
|
60
|
+
score: z.number().min(0).max(1),
|
|
61
|
+
weight: z.number().min(0).max(1),
|
|
62
|
+
explanation: z.string(),
|
|
63
|
+
confidence: z.number().min(0).max(1),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Evaluation Result Type
|
|
68
|
+
*/
|
|
69
|
+
export type EvaluationResult = z.infer<typeof EvaluationResultSchema>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Devil's Advocate Point Schema
|
|
73
|
+
*/
|
|
74
|
+
export const DevilsAdvocatePointSchema = z.object({
|
|
75
|
+
id: z.string().uuid(),
|
|
76
|
+
target: z.string(), // What is being challenged
|
|
77
|
+
challenge: z.string(),
|
|
78
|
+
reasoning: z.string(),
|
|
79
|
+
severity: z.enum(['low', 'medium', 'high', 'critical']),
|
|
80
|
+
suggestedAlternative: z.string().optional(),
|
|
81
|
+
confidence: z.number().min(0).max(1),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Devil's Advocate Point Type
|
|
86
|
+
*/
|
|
87
|
+
export type DevilsAdvocatePoint = z.infer<typeof DevilsAdvocatePointSchema>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Confidence Breakdown Schema
|
|
91
|
+
*/
|
|
92
|
+
export const ConfidenceBreakdownSchema = z.object({
|
|
93
|
+
overall: z.number().min(0).max(1),
|
|
94
|
+
byStage: z.record(z.number().min(0).max(1)),
|
|
95
|
+
bySource: z.record(z.number().min(0).max(1)),
|
|
96
|
+
factors: z.array(z.object({
|
|
97
|
+
factor: z.string(),
|
|
98
|
+
impact: z.number().min(-1).max(1),
|
|
99
|
+
description: z.string(),
|
|
100
|
+
})),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Confidence Breakdown Type
|
|
105
|
+
*/
|
|
106
|
+
export type ConfidenceBreakdown = z.infer<typeof ConfidenceBreakdownSchema>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Synthesis Result Schema
|
|
110
|
+
*/
|
|
111
|
+
export const SynthesisResultSchema = BaseResultSchema.extend({
|
|
112
|
+
query: z.string(),
|
|
113
|
+
summary: z.string(),
|
|
114
|
+
keyFindings: z.array(z.string()),
|
|
115
|
+
recommendations: z.array(RecommendationSchema),
|
|
116
|
+
evaluation: z.array(EvaluationResultSchema),
|
|
117
|
+
devilsAdvocate: z.array(DevilsAdvocatePointSchema).default([]),
|
|
118
|
+
confidenceBreakdown: ConfidenceBreakdownSchema,
|
|
119
|
+
nextSteps: z.array(z.string()).default([]),
|
|
120
|
+
additionalConsiderations: z.array(z.string()).default([]),
|
|
121
|
+
sources: z.array(z.object({
|
|
122
|
+
id: z.string(),
|
|
123
|
+
name: z.string(),
|
|
124
|
+
type: z.string(),
|
|
125
|
+
credibility: z.number().min(0).max(1),
|
|
126
|
+
})).default([]),
|
|
127
|
+
metadata: z.record(z.unknown()).default({}),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Synthesis Result Type
|
|
132
|
+
*/
|
|
133
|
+
export type SynthesisResult = z.infer<typeof SynthesisResultSchema>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Output Format Enum
|
|
137
|
+
*/
|
|
138
|
+
export enum OutputFormat {
|
|
139
|
+
JSON = 'json',
|
|
140
|
+
MARKDOWN = 'markdown',
|
|
141
|
+
HTML = 'html',
|
|
142
|
+
PLAIN = 'plain',
|
|
143
|
+
STRUCTURED = 'structured',
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Output Format Schema
|
|
148
|
+
*/
|
|
149
|
+
export const OutputFormatSchema = z.nativeEnum(OutputFormat);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Format Options Schema
|
|
153
|
+
*/
|
|
154
|
+
export const FormatOptionsSchema = z.object({
|
|
155
|
+
format: OutputFormatSchema.default(OutputFormat.MARKDOWN),
|
|
156
|
+
includeMetadata: z.boolean().default(false),
|
|
157
|
+
includeTimestamps: z.boolean().default(true),
|
|
158
|
+
includeConfidence: z.boolean().default(true),
|
|
159
|
+
maxLength: z.number().positive().optional(),
|
|
160
|
+
language: z.string().default('en'),
|
|
161
|
+
template: z.string().optional(),
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Format Options Type
|
|
166
|
+
*/
|
|
167
|
+
export type FormatOptions = z.infer<typeof FormatOptionsSchema>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Formatted Output Schema
|
|
171
|
+
*/
|
|
172
|
+
export const FormattedOutputSchema = z.object({
|
|
173
|
+
content: z.string(),
|
|
174
|
+
format: OutputFormatSchema,
|
|
175
|
+
metadata: z.object({
|
|
176
|
+
generatedAt: z.date(),
|
|
177
|
+
version: z.string(),
|
|
178
|
+
confidence: z.number().min(0).max(1),
|
|
179
|
+
wordCount: z.number().nonnegative(),
|
|
180
|
+
charCount: z.number().nonnegative(),
|
|
181
|
+
}),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Formatted Output Type
|
|
186
|
+
*/
|
|
187
|
+
export type FormattedOutput = z.infer<typeof FormattedOutputSchema>;
|