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,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learning Types for gthinking v2.0.0
|
|
3
|
+
* Types for learning and knowledge management functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { BaseResultSchema } from './core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Learning Context Schema
|
|
11
|
+
*/
|
|
12
|
+
export const LearningContextSchema = z.object({
|
|
13
|
+
id: z.string().uuid(),
|
|
14
|
+
sessionId: z.string(),
|
|
15
|
+
interactions: z.array(z.object({
|
|
16
|
+
id: z.string().uuid(),
|
|
17
|
+
query: z.string(),
|
|
18
|
+
response: z.string(),
|
|
19
|
+
timestamp: z.date(),
|
|
20
|
+
feedback: z.enum(['positive', 'negative', 'neutral']).optional(),
|
|
21
|
+
metadata: z.record(z.unknown()).default({}),
|
|
22
|
+
})).default([]),
|
|
23
|
+
patterns: z.array(z.object({
|
|
24
|
+
pattern: z.string(),
|
|
25
|
+
frequency: z.number().nonnegative(),
|
|
26
|
+
confidence: z.number().min(0).max(1),
|
|
27
|
+
lastSeen: z.date(),
|
|
28
|
+
})).default([]),
|
|
29
|
+
preferences: z.record(z.unknown()).default({}),
|
|
30
|
+
createdAt: z.date(),
|
|
31
|
+
updatedAt: z.date(),
|
|
32
|
+
lastAccessed: z.date(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Learning Context Type
|
|
37
|
+
*/
|
|
38
|
+
export type LearningContext = z.infer<typeof LearningContextSchema>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Knowledge Node Schema
|
|
42
|
+
*/
|
|
43
|
+
export const KnowledgeNodeSchema = z.object({
|
|
44
|
+
id: z.string().uuid(),
|
|
45
|
+
concept: z.string(),
|
|
46
|
+
category: z.string(),
|
|
47
|
+
description: z.string(),
|
|
48
|
+
confidence: z.number().min(0).max(1),
|
|
49
|
+
sources: z.array(z.string()),
|
|
50
|
+
relatedNodes: z.array(z.string().uuid()).default([]),
|
|
51
|
+
createdAt: z.date(),
|
|
52
|
+
updatedAt: z.date(),
|
|
53
|
+
accessCount: z.number().nonnegative().default(0),
|
|
54
|
+
successRate: z.number().min(0).max(1).default(0.5),
|
|
55
|
+
metadata: z.record(z.unknown()).default({}),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Knowledge Node Type
|
|
60
|
+
*/
|
|
61
|
+
export type KnowledgeNode = z.infer<typeof KnowledgeNodeSchema>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Knowledge Edge Schema
|
|
65
|
+
*/
|
|
66
|
+
export const KnowledgeEdgeSchema = z.object({
|
|
67
|
+
id: z.string().uuid(),
|
|
68
|
+
from: z.string().uuid(),
|
|
69
|
+
to: z.string().uuid(),
|
|
70
|
+
relation: z.string(),
|
|
71
|
+
strength: z.number().min(0).max(1),
|
|
72
|
+
bidirectional: z.boolean().default(false),
|
|
73
|
+
metadata: z.record(z.unknown()).default({}),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Knowledge Edge Type
|
|
78
|
+
*/
|
|
79
|
+
export type KnowledgeEdge = z.infer<typeof KnowledgeEdgeSchema>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Knowledge Graph Schema
|
|
83
|
+
*/
|
|
84
|
+
export const KnowledgeGraphSchema = z.object({
|
|
85
|
+
id: z.string().uuid(),
|
|
86
|
+
name: z.string(),
|
|
87
|
+
nodes: z.array(KnowledgeNodeSchema),
|
|
88
|
+
edges: z.array(KnowledgeEdgeSchema),
|
|
89
|
+
categories: z.array(z.string()).default([]),
|
|
90
|
+
createdAt: z.date(),
|
|
91
|
+
updatedAt: z.date(),
|
|
92
|
+
version: z.number().positive().default(1),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Knowledge Graph Type
|
|
97
|
+
*/
|
|
98
|
+
export type KnowledgeGraph = z.infer<typeof KnowledgeGraphSchema>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Pattern Schema
|
|
102
|
+
*/
|
|
103
|
+
export const PatternSchema = z.object({
|
|
104
|
+
id: z.string().uuid(),
|
|
105
|
+
name: z.string(),
|
|
106
|
+
description: z.string(),
|
|
107
|
+
examples: z.array(z.string()),
|
|
108
|
+
frequency: z.number().nonnegative(),
|
|
109
|
+
confidence: z.number().min(0).max(1),
|
|
110
|
+
firstSeen: z.date(),
|
|
111
|
+
lastSeen: z.date(),
|
|
112
|
+
successRate: z.number().min(0).max(1).default(0.5),
|
|
113
|
+
metadata: z.record(z.unknown()).default({}),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Pattern Type
|
|
118
|
+
*/
|
|
119
|
+
export type Pattern = z.infer<typeof PatternSchema>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* User Preference Schema
|
|
123
|
+
*/
|
|
124
|
+
export const UserPreferenceSchema = z.object({
|
|
125
|
+
id: z.string().uuid(),
|
|
126
|
+
category: z.string(),
|
|
127
|
+
key: z.string(),
|
|
128
|
+
value: z.unknown(),
|
|
129
|
+
confidence: z.number().min(0).max(1).default(0.5),
|
|
130
|
+
learnedFrom: z.array(z.string()).default([]),
|
|
131
|
+
updatedAt: z.date(),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* User Preference Type
|
|
136
|
+
*/
|
|
137
|
+
export type UserPreference = z.infer<typeof UserPreferenceSchema>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Interaction Record Schema
|
|
141
|
+
*/
|
|
142
|
+
export const InteractionRecordSchema = z.object({
|
|
143
|
+
id: z.string().uuid(),
|
|
144
|
+
sessionId: z.string(),
|
|
145
|
+
query: z.string(),
|
|
146
|
+
response: z.string(),
|
|
147
|
+
thinkingStages: z.array(z.string()).default([]),
|
|
148
|
+
duration: z.number().nonnegative(),
|
|
149
|
+
timestamp: z.date(),
|
|
150
|
+
feedback: z.object({
|
|
151
|
+
rating: z.number().min(1).max(5).optional(),
|
|
152
|
+
comment: z.string().optional(),
|
|
153
|
+
helpful: z.boolean().optional(),
|
|
154
|
+
}).optional(),
|
|
155
|
+
metadata: z.record(z.unknown()).default({}),
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Interaction Record Type
|
|
160
|
+
*/
|
|
161
|
+
export type InteractionRecord = z.infer<typeof InteractionRecordSchema>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Learning Result Schema
|
|
165
|
+
*/
|
|
166
|
+
export const LearningResultSchema = BaseResultSchema.extend({
|
|
167
|
+
context: LearningContextSchema.optional(),
|
|
168
|
+
patterns: z.array(PatternSchema).default([]),
|
|
169
|
+
preferences: z.array(UserPreferenceSchema).default([]),
|
|
170
|
+
relevantKnowledge: z.array(KnowledgeNodeSchema).default([]),
|
|
171
|
+
insights: z.array(z.string()).default([]),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Learning Result Type
|
|
176
|
+
*/
|
|
177
|
+
export type LearningResult = z.infer<typeof LearningResultSchema>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Persistence Config Schema
|
|
181
|
+
*/
|
|
182
|
+
export const PersistenceConfigSchema = z.object({
|
|
183
|
+
enabled: z.boolean().default(true),
|
|
184
|
+
strategy: z.enum(['memory', 'file', 'redis', 'database']).default('memory'),
|
|
185
|
+
autoSave: z.boolean().default(true),
|
|
186
|
+
autoSaveInterval: z.number().positive().default(60000), // 1 minute
|
|
187
|
+
maxContexts: z.number().positive().default(1000),
|
|
188
|
+
maxPatterns: z.number().positive().default(10000),
|
|
189
|
+
maxKnowledgeNodes: z.number().positive().default(50000),
|
|
190
|
+
ttl: z.number().positive().default(86400000), // 24 hours
|
|
191
|
+
compression: z.boolean().default(true),
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Persistence Config Type
|
|
196
|
+
*/
|
|
197
|
+
export type PersistenceConfig = z.infer<typeof PersistenceConfigSchema>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Query Context Request Schema
|
|
201
|
+
*/
|
|
202
|
+
export const QueryContextRequestSchema = z.object({
|
|
203
|
+
query: z.string(),
|
|
204
|
+
sessionId: z.string().optional(),
|
|
205
|
+
maxInteractions: z.number().positive().default(10),
|
|
206
|
+
maxPatterns: z.number().positive().default(5),
|
|
207
|
+
maxKnowledgeNodes: z.number().positive().default(10),
|
|
208
|
+
includePreferences: z.boolean().default(true),
|
|
209
|
+
similarityThreshold: z.number().min(0).max(1).default(0.7),
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Query Context Request Type
|
|
214
|
+
*/
|
|
215
|
+
export type QueryContextRequest = z.infer<typeof QueryContextRequestSchema>;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning Types for gthinking v2.0.0
|
|
3
|
+
* Types for planning and task management functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { BaseResultSchema, Priority, TaskStatus } from './core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Planning Request Schema
|
|
11
|
+
*/
|
|
12
|
+
export const PlanningRequestSchema = z.object({
|
|
13
|
+
goal: z.string().min(1).max(5000),
|
|
14
|
+
constraints: z.object({
|
|
15
|
+
deadline: z.date().optional(),
|
|
16
|
+
budget: z.number().positive().optional(),
|
|
17
|
+
resources: z.array(z.string()).default([]),
|
|
18
|
+
dependencies: z.array(z.string()).default([]),
|
|
19
|
+
mustInclude: z.array(z.string()).default([]),
|
|
20
|
+
mustExclude: z.array(z.string()).default([]),
|
|
21
|
+
}).default({}),
|
|
22
|
+
options: z.object({
|
|
23
|
+
granularity: z.enum(['coarse', 'medium', 'fine']).default('medium'),
|
|
24
|
+
includeRisks: z.boolean().default(true),
|
|
25
|
+
includeTimeline: z.boolean().default(true),
|
|
26
|
+
maxTasks: z.number().positive().default(50),
|
|
27
|
+
bufferPercentage: z.number().min(0).max(50).default(20),
|
|
28
|
+
}).default({}),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Planning Request Type
|
|
33
|
+
*/
|
|
34
|
+
export type PlanningRequest = z.infer<typeof PlanningRequestSchema>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Task Schema
|
|
38
|
+
*/
|
|
39
|
+
export const TaskSchema = z.object({
|
|
40
|
+
id: z.string().uuid(),
|
|
41
|
+
name: z.string(),
|
|
42
|
+
description: z.string(),
|
|
43
|
+
status: z.nativeEnum(TaskStatus).default(TaskStatus.PENDING),
|
|
44
|
+
priority: z.nativeEnum(Priority).default(Priority.MEDIUM),
|
|
45
|
+
estimatedDuration: z.number().positive(), // in minutes
|
|
46
|
+
actualDuration: z.number().nonnegative().optional(),
|
|
47
|
+
complexity: z.number().min(0).max(1).default(0.5),
|
|
48
|
+
dependencies: z.array(z.string().uuid()).default([]),
|
|
49
|
+
subtasks: z.array(z.string().uuid()).default([]),
|
|
50
|
+
parentId: z.string().uuid().optional(),
|
|
51
|
+
assignedTo: z.string().optional(),
|
|
52
|
+
resources: z.array(z.string()).default([]),
|
|
53
|
+
tags: z.array(z.string()).default([]),
|
|
54
|
+
startDate: z.date().optional(),
|
|
55
|
+
endDate: z.date().optional(),
|
|
56
|
+
deadline: z.date().optional(),
|
|
57
|
+
progress: z.number().min(0).max(100).default(0),
|
|
58
|
+
metadata: z.record(z.unknown()).default({}),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Task Type
|
|
63
|
+
*/
|
|
64
|
+
export type Task = z.infer<typeof TaskSchema>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Milestone Schema
|
|
68
|
+
*/
|
|
69
|
+
export const MilestoneSchema = z.object({
|
|
70
|
+
id: z.string().uuid(),
|
|
71
|
+
name: z.string(),
|
|
72
|
+
description: z.string(),
|
|
73
|
+
dueDate: z.date(),
|
|
74
|
+
tasks: z.array(z.string().uuid()),
|
|
75
|
+
deliverables: z.array(z.string()),
|
|
76
|
+
completed: z.boolean().default(false),
|
|
77
|
+
completionDate: z.date().optional(),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Milestone Type
|
|
82
|
+
*/
|
|
83
|
+
export type Milestone = z.infer<typeof MilestoneSchema>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Resource Schema
|
|
87
|
+
*/
|
|
88
|
+
export const ResourceSchema = z.object({
|
|
89
|
+
id: z.string().uuid(),
|
|
90
|
+
name: z.string(),
|
|
91
|
+
type: z.enum(['human', 'material', 'financial', 'time', 'tool', 'service']),
|
|
92
|
+
capacity: z.number().positive(),
|
|
93
|
+
allocated: z.number().nonnegative().default(0),
|
|
94
|
+
costPerUnit: z.number().nonnegative().default(0),
|
|
95
|
+
unit: z.string().default('hours'),
|
|
96
|
+
availability: z.array(z.object({
|
|
97
|
+
from: z.date(),
|
|
98
|
+
to: z.date(),
|
|
99
|
+
})).default([]),
|
|
100
|
+
skills: z.array(z.string()).default([]),
|
|
101
|
+
metadata: z.record(z.unknown()).default({}),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Resource Type
|
|
106
|
+
*/
|
|
107
|
+
export type Resource = z.infer<typeof ResourceSchema>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Timeline Schema
|
|
111
|
+
*/
|
|
112
|
+
export const TimelineSchema = z.object({
|
|
113
|
+
startDate: z.date(),
|
|
114
|
+
endDate: z.date(),
|
|
115
|
+
duration: z.number().positive(), // in minutes
|
|
116
|
+
phases: z.array(z.object({
|
|
117
|
+
name: z.string(),
|
|
118
|
+
startDate: z.date(),
|
|
119
|
+
endDate: z.date(),
|
|
120
|
+
tasks: z.array(z.string().uuid()),
|
|
121
|
+
})),
|
|
122
|
+
criticalPath: z.array(z.string().uuid()),
|
|
123
|
+
buffer: z.number().nonnegative(), // in minutes
|
|
124
|
+
milestones: z.array(MilestoneSchema),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Timeline Type
|
|
129
|
+
*/
|
|
130
|
+
export type Timeline = z.infer<typeof TimelineSchema>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Risk Schema
|
|
134
|
+
*/
|
|
135
|
+
export const RiskSchema = z.object({
|
|
136
|
+
id: z.string().uuid(),
|
|
137
|
+
description: z.string(),
|
|
138
|
+
category: z.enum(['technical', 'schedule', 'budget', 'resource', 'external', 'operational']),
|
|
139
|
+
probability: z.number().min(0).max(1),
|
|
140
|
+
impact: z.number().min(0).max(1),
|
|
141
|
+
riskScore: z.number().min(0).max(1),
|
|
142
|
+
mitigation: z.array(z.string()).default([]),
|
|
143
|
+
contingency: z.string().optional(),
|
|
144
|
+
owner: z.string().optional(),
|
|
145
|
+
status: z.enum(['identified', 'monitoring', 'mitigated', 'occurred', 'resolved']).default('identified'),
|
|
146
|
+
triggers: z.array(z.string()).default([]),
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Risk Type
|
|
151
|
+
*/
|
|
152
|
+
export type Risk = z.infer<typeof RiskSchema>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Plan Schema
|
|
156
|
+
*/
|
|
157
|
+
export const PlanSchema = z.object({
|
|
158
|
+
id: z.string().uuid(),
|
|
159
|
+
goal: z.string(),
|
|
160
|
+
description: z.string(),
|
|
161
|
+
tasks: z.array(TaskSchema),
|
|
162
|
+
timeline: TimelineSchema,
|
|
163
|
+
resources: z.array(ResourceSchema),
|
|
164
|
+
risks: z.array(RiskSchema),
|
|
165
|
+
assumptions: z.array(z.string()).default([]),
|
|
166
|
+
constraints: z.array(z.string()).default([]),
|
|
167
|
+
successCriteria: z.array(z.string()).default([]),
|
|
168
|
+
kpis: z.array(z.object({
|
|
169
|
+
metric: z.string(),
|
|
170
|
+
target: z.number(),
|
|
171
|
+
current: z.number().optional(),
|
|
172
|
+
unit: z.string(),
|
|
173
|
+
})).default([]),
|
|
174
|
+
createdAt: z.date(),
|
|
175
|
+
updatedAt: z.date(),
|
|
176
|
+
version: z.number().positive().default(1),
|
|
177
|
+
metadata: z.record(z.unknown()).default({}),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Plan Type
|
|
182
|
+
*/
|
|
183
|
+
export type Plan = z.infer<typeof PlanSchema>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Planning Result Schema
|
|
187
|
+
*/
|
|
188
|
+
export const PlanningResultSchema = BaseResultSchema.extend({
|
|
189
|
+
plan: PlanSchema,
|
|
190
|
+
alternatives: z.array(PlanSchema).default([]),
|
|
191
|
+
recommendations: z.array(z.string()).default([]),
|
|
192
|
+
warnings: z.array(z.string()).default([]),
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Planning Result Type
|
|
197
|
+
*/
|
|
198
|
+
export type PlanningResult = z.infer<typeof PlanningResultSchema>;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Progress Update Schema
|
|
202
|
+
*/
|
|
203
|
+
export const ProgressUpdateSchema = z.object({
|
|
204
|
+
taskId: z.string().uuid(),
|
|
205
|
+
progress: z.number().min(0).max(100),
|
|
206
|
+
status: z.nativeEnum(TaskStatus),
|
|
207
|
+
actualDuration: z.number().nonnegative().optional(),
|
|
208
|
+
notes: z.string().optional(),
|
|
209
|
+
blockers: z.array(z.string()).default([]),
|
|
210
|
+
timestamp: z.date(),
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Progress Update Type
|
|
215
|
+
*/
|
|
216
|
+
export type ProgressUpdate = z.infer<typeof ProgressUpdateSchema>;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Planning Stage Enum
|
|
220
|
+
*/
|
|
221
|
+
export enum PlanningStage {
|
|
222
|
+
INITIATION = 'initiation',
|
|
223
|
+
PLANNING = 'planning',
|
|
224
|
+
EXECUTION = 'execution',
|
|
225
|
+
MONITORING = 'monitoring',
|
|
226
|
+
CLOSING = 'closing',
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Planning Stage Schema
|
|
231
|
+
*/
|
|
232
|
+
export const PlanningStageSchema = z.nativeEnum(PlanningStage);
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Task Decomposition Rule Schema
|
|
236
|
+
*/
|
|
237
|
+
export const TaskDecompositionRuleSchema = z.object({
|
|
238
|
+
id: z.string().uuid(),
|
|
239
|
+
pattern: z.string(), // regex pattern
|
|
240
|
+
subtasks: z.array(z.object({
|
|
241
|
+
template: z.string(),
|
|
242
|
+
estimatedDuration: z.number().positive(),
|
|
243
|
+
complexity: z.number().min(0).max(1),
|
|
244
|
+
})),
|
|
245
|
+
priority: z.nativeEnum(Priority),
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Task Decomposition Rule Type
|
|
250
|
+
*/
|
|
251
|
+
export type TaskDecompositionRule = z.infer<typeof TaskDecompositionRuleSchema>;
|