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.
Files changed (271) hide show
  1. package/.eslintrc.js +34 -0
  2. package/ANALYSIS_SUMMARY.md +363 -0
  3. package/README.md +230 -245
  4. package/dist/analysis/analysis-engine.d.ts +63 -0
  5. package/dist/analysis/analysis-engine.d.ts.map +1 -0
  6. package/dist/analysis/analysis-engine.js +322 -0
  7. package/dist/analysis/analysis-engine.js.map +1 -0
  8. package/dist/core/config.d.ts +1419 -0
  9. package/dist/core/config.d.ts.map +1 -0
  10. package/dist/core/config.js +361 -0
  11. package/dist/core/config.js.map +1 -0
  12. package/dist/core/engine.d.ts +176 -0
  13. package/dist/core/engine.d.ts.map +1 -0
  14. package/dist/core/engine.js +604 -0
  15. package/dist/core/engine.js.map +1 -0
  16. package/dist/core/errors.d.ts +153 -0
  17. package/dist/core/errors.d.ts.map +1 -0
  18. package/dist/core/errors.js +287 -0
  19. package/dist/core/errors.js.map +1 -0
  20. package/dist/core/index.d.ts +7 -0
  21. package/dist/core/index.d.ts.map +1 -0
  22. package/dist/{types.js → core/index.js} +8 -4
  23. package/dist/core/index.js.map +1 -0
  24. package/dist/core/pipeline.d.ts +121 -0
  25. package/dist/core/pipeline.d.ts.map +1 -0
  26. package/dist/core/pipeline.js +289 -0
  27. package/dist/core/pipeline.js.map +1 -0
  28. package/dist/core/rate-limiter.d.ts +58 -0
  29. package/dist/core/rate-limiter.d.ts.map +1 -0
  30. package/dist/core/rate-limiter.js +133 -0
  31. package/dist/core/rate-limiter.js.map +1 -0
  32. package/dist/core/session-manager.d.ts +96 -0
  33. package/dist/core/session-manager.d.ts.map +1 -0
  34. package/dist/core/session-manager.js +223 -0
  35. package/dist/core/session-manager.js.map +1 -0
  36. package/dist/creativity/creativity-engine.d.ts +6 -0
  37. package/dist/creativity/creativity-engine.d.ts.map +1 -0
  38. package/dist/creativity/creativity-engine.js +17 -0
  39. package/dist/creativity/creativity-engine.js.map +1 -0
  40. package/dist/index.d.ts +24 -32
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +130 -104
  43. package/dist/index.js.map +1 -1
  44. package/dist/learning/learning-engine.d.ts +6 -0
  45. package/dist/learning/learning-engine.d.ts.map +1 -0
  46. package/dist/learning/learning-engine.js +17 -0
  47. package/dist/learning/learning-engine.js.map +1 -0
  48. package/dist/llm/index.d.ts +10 -0
  49. package/dist/llm/index.d.ts.map +1 -0
  50. package/dist/llm/index.js +26 -0
  51. package/dist/llm/index.js.map +1 -0
  52. package/dist/llm/llm-service.d.ts +109 -0
  53. package/dist/llm/llm-service.d.ts.map +1 -0
  54. package/dist/llm/llm-service.js +224 -0
  55. package/dist/llm/llm-service.js.map +1 -0
  56. package/dist/llm/providers/base.d.ts +85 -0
  57. package/dist/llm/providers/base.d.ts.map +1 -0
  58. package/dist/llm/providers/base.js +57 -0
  59. package/dist/llm/providers/base.js.map +1 -0
  60. package/dist/llm/providers/cli.d.ts +23 -0
  61. package/dist/llm/providers/cli.d.ts.map +1 -0
  62. package/dist/llm/providers/cli.js +158 -0
  63. package/dist/llm/providers/cli.js.map +1 -0
  64. package/dist/llm/providers/gemini.d.ts +30 -0
  65. package/dist/llm/providers/gemini.d.ts.map +1 -0
  66. package/dist/llm/providers/gemini.js +168 -0
  67. package/dist/llm/providers/gemini.js.map +1 -0
  68. package/dist/llm/sanitization.d.ts +50 -0
  69. package/dist/llm/sanitization.d.ts.map +1 -0
  70. package/dist/llm/sanitization.js +149 -0
  71. package/dist/llm/sanitization.js.map +1 -0
  72. package/dist/{server.d.ts.map → mcp/server.d.ts.map} +1 -1
  73. package/dist/mcp/server.js +108 -0
  74. package/dist/mcp/server.js.map +1 -0
  75. package/dist/planning/planning-engine.d.ts +6 -0
  76. package/dist/planning/planning-engine.d.ts.map +1 -0
  77. package/dist/planning/planning-engine.js +17 -0
  78. package/dist/planning/planning-engine.js.map +1 -0
  79. package/dist/reasoning/reasoning-engine.d.ts +6 -0
  80. package/dist/reasoning/reasoning-engine.d.ts.map +1 -0
  81. package/dist/reasoning/reasoning-engine.js +17 -0
  82. package/dist/reasoning/reasoning-engine.js.map +1 -0
  83. package/dist/search/search-engine.d.ts +99 -0
  84. package/dist/search/search-engine.d.ts.map +1 -0
  85. package/dist/search/search-engine.js +271 -0
  86. package/dist/search/search-engine.js.map +1 -0
  87. package/dist/synthesis/synthesis-engine.d.ts +6 -0
  88. package/dist/synthesis/synthesis-engine.d.ts.map +1 -0
  89. package/dist/synthesis/synthesis-engine.js +17 -0
  90. package/dist/synthesis/synthesis-engine.js.map +1 -0
  91. package/dist/types/analysis.d.ts +1534 -49
  92. package/dist/types/analysis.d.ts.map +1 -1
  93. package/dist/types/analysis.js +250 -0
  94. package/dist/types/analysis.js.map +1 -1
  95. package/dist/types/core.d.ts +257 -30
  96. package/dist/types/core.d.ts.map +1 -1
  97. package/dist/types/core.js +148 -18
  98. package/dist/types/core.js.map +1 -1
  99. package/dist/types/creativity.d.ts +2871 -56
  100. package/dist/types/creativity.d.ts.map +1 -1
  101. package/dist/types/creativity.js +195 -0
  102. package/dist/types/creativity.js.map +1 -1
  103. package/dist/types/index.d.ts +6 -2
  104. package/dist/types/index.d.ts.map +1 -1
  105. package/dist/types/index.js +17 -2
  106. package/dist/types/index.js.map +1 -1
  107. package/dist/types/learning.d.ts +851 -61
  108. package/dist/types/learning.d.ts.map +1 -1
  109. package/dist/types/learning.js +155 -0
  110. package/dist/types/learning.js.map +1 -1
  111. package/dist/types/planning.d.ts +2223 -71
  112. package/dist/types/planning.d.ts.map +1 -1
  113. package/dist/types/planning.js +190 -0
  114. package/dist/types/planning.js.map +1 -1
  115. package/dist/types/reasoning.d.ts +2209 -72
  116. package/dist/types/reasoning.d.ts.map +1 -1
  117. package/dist/types/reasoning.js +200 -1
  118. package/dist/types/reasoning.js.map +1 -1
  119. package/dist/types/search.d.ts +981 -53
  120. package/dist/types/search.d.ts.map +1 -1
  121. package/dist/types/search.js +137 -0
  122. package/dist/types/search.js.map +1 -1
  123. package/dist/types/synthesis.d.ts +583 -37
  124. package/dist/types/synthesis.d.ts.map +1 -1
  125. package/dist/types/synthesis.js +138 -0
  126. package/dist/types/synthesis.js.map +1 -1
  127. package/dist/utils/cache.d.ts +144 -0
  128. package/dist/utils/cache.d.ts.map +1 -0
  129. package/dist/utils/cache.js +288 -0
  130. package/dist/utils/cache.js.map +1 -0
  131. package/dist/utils/id-generator.d.ts +89 -0
  132. package/dist/utils/id-generator.d.ts.map +1 -0
  133. package/dist/utils/id-generator.js +132 -0
  134. package/dist/utils/id-generator.js.map +1 -0
  135. package/dist/utils/index.d.ts +11 -0
  136. package/dist/utils/index.d.ts.map +1 -0
  137. package/dist/utils/index.js +33 -0
  138. package/dist/utils/index.js.map +1 -0
  139. package/dist/utils/logger.d.ts +142 -0
  140. package/dist/utils/logger.d.ts.map +1 -0
  141. package/dist/utils/logger.js +248 -0
  142. package/dist/utils/logger.js.map +1 -0
  143. package/dist/utils/metrics.d.ts +149 -0
  144. package/dist/utils/metrics.d.ts.map +1 -0
  145. package/dist/utils/metrics.js +296 -0
  146. package/dist/utils/metrics.js.map +1 -0
  147. package/dist/utils/timer.d.ts +7 -0
  148. package/dist/utils/timer.d.ts.map +1 -0
  149. package/dist/utils/timer.js +17 -0
  150. package/dist/utils/timer.js.map +1 -0
  151. package/dist/utils/validation.d.ts +147 -0
  152. package/dist/utils/validation.d.ts.map +1 -0
  153. package/dist/utils/validation.js +275 -0
  154. package/dist/utils/validation.js.map +1 -0
  155. package/docs/API.md +411 -0
  156. package/docs/ARCHITECTURE.md +271 -0
  157. package/docs/CHANGELOG.md +283 -0
  158. package/jest.config.js +28 -0
  159. package/package.json +43 -30
  160. package/src/analysis/analysis-engine.ts +383 -0
  161. package/src/core/config.ts +406 -0
  162. package/src/core/engine.ts +785 -0
  163. package/src/core/errors.ts +349 -0
  164. package/src/core/index.ts +12 -0
  165. package/src/core/pipeline.ts +424 -0
  166. package/src/core/rate-limiter.ts +155 -0
  167. package/src/core/session-manager.ts +269 -0
  168. package/src/creativity/creativity-engine.ts +14 -0
  169. package/src/index.ts +178 -0
  170. package/src/learning/learning-engine.ts +14 -0
  171. package/src/llm/index.ts +10 -0
  172. package/src/llm/llm-service.ts +285 -0
  173. package/src/llm/providers/base.ts +146 -0
  174. package/src/llm/providers/cli.ts +186 -0
  175. package/src/llm/providers/gemini.ts +201 -0
  176. package/src/llm/sanitization.ts +178 -0
  177. package/src/mcp/server.ts +117 -0
  178. package/src/planning/planning-engine.ts +14 -0
  179. package/src/reasoning/reasoning-engine.ts +14 -0
  180. package/src/search/search-engine.ts +333 -0
  181. package/src/synthesis/synthesis-engine.ts +14 -0
  182. package/src/types/analysis.ts +337 -0
  183. package/src/types/core.ts +342 -0
  184. package/src/types/creativity.ts +268 -0
  185. package/src/types/index.ts +31 -0
  186. package/src/types/learning.ts +215 -0
  187. package/src/types/planning.ts +251 -0
  188. package/src/types/reasoning.ts +288 -0
  189. package/src/types/search.ts +192 -0
  190. package/src/types/synthesis.ts +187 -0
  191. package/src/utils/cache.ts +363 -0
  192. package/src/utils/id-generator.ts +135 -0
  193. package/src/utils/index.ts +22 -0
  194. package/src/utils/logger.ts +290 -0
  195. package/src/utils/metrics.ts +380 -0
  196. package/src/utils/timer.ts +15 -0
  197. package/src/utils/validation.ts +297 -0
  198. package/tests/setup.ts +22 -0
  199. package/tests/unit/cache.test.ts +189 -0
  200. package/tests/unit/engine.test.ts +179 -0
  201. package/tests/unit/validation.test.ts +218 -0
  202. package/tsconfig.json +17 -12
  203. package/GEMINI.md +0 -68
  204. package/analysis.ts +0 -1063
  205. package/creativity.ts +0 -1055
  206. package/dist/analysis.d.ts +0 -54
  207. package/dist/analysis.d.ts.map +0 -1
  208. package/dist/analysis.js +0 -866
  209. package/dist/analysis.js.map +0 -1
  210. package/dist/creativity.d.ts +0 -81
  211. package/dist/creativity.d.ts.map +0 -1
  212. package/dist/creativity.js +0 -828
  213. package/dist/creativity.js.map +0 -1
  214. package/dist/engine.d.ts +0 -90
  215. package/dist/engine.d.ts.map +0 -1
  216. package/dist/engine.js +0 -677
  217. package/dist/engine.js.map +0 -1
  218. package/dist/examples.d.ts +0 -7
  219. package/dist/examples.d.ts.map +0 -1
  220. package/dist/examples.js +0 -506
  221. package/dist/examples.js.map +0 -1
  222. package/dist/learning.d.ts +0 -72
  223. package/dist/learning.d.ts.map +0 -1
  224. package/dist/learning.js +0 -615
  225. package/dist/learning.js.map +0 -1
  226. package/dist/llm-service.d.ts +0 -21
  227. package/dist/llm-service.d.ts.map +0 -1
  228. package/dist/llm-service.js +0 -100
  229. package/dist/llm-service.js.map +0 -1
  230. package/dist/planning.d.ts +0 -58
  231. package/dist/planning.d.ts.map +0 -1
  232. package/dist/planning.js +0 -824
  233. package/dist/planning.js.map +0 -1
  234. package/dist/reasoning.d.ts +0 -73
  235. package/dist/reasoning.d.ts.map +0 -1
  236. package/dist/reasoning.js +0 -845
  237. package/dist/reasoning.js.map +0 -1
  238. package/dist/search-discovery.d.ts +0 -73
  239. package/dist/search-discovery.d.ts.map +0 -1
  240. package/dist/search-discovery.js +0 -548
  241. package/dist/search-discovery.js.map +0 -1
  242. package/dist/server.js +0 -113
  243. package/dist/server.js.map +0 -1
  244. package/dist/types/engine.d.ts +0 -55
  245. package/dist/types/engine.d.ts.map +0 -1
  246. package/dist/types/engine.js +0 -3
  247. package/dist/types/engine.js.map +0 -1
  248. package/dist/types.d.ts +0 -6
  249. package/dist/types.d.ts.map +0 -1
  250. package/dist/types.js.map +0 -1
  251. package/engine.ts +0 -947
  252. package/examples.ts +0 -717
  253. package/index.ts +0 -106
  254. package/learning.ts +0 -779
  255. package/llm-service.ts +0 -120
  256. package/planning.ts +0 -1028
  257. package/reasoning.ts +0 -1079
  258. package/search-discovery.ts +0 -700
  259. package/server.ts +0 -115
  260. package/types/analysis.ts +0 -69
  261. package/types/core.ts +0 -90
  262. package/types/creativity.ts +0 -72
  263. package/types/engine.ts +0 -60
  264. package/types/index.ts +0 -9
  265. package/types/learning.ts +0 -69
  266. package/types/planning.ts +0 -85
  267. package/types/reasoning.ts +0 -92
  268. package/types/search.ts +0 -58
  269. package/types/synthesis.ts +0 -42
  270. package/types.ts +0 -6
  271. /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>;