@iworkforces/tracelattice 2.0.3

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 (422) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +260 -0
  3. package/dist/CliLifecycle.d.ts +31 -0
  4. package/dist/CliLifecycle.d.ts.map +1 -0
  5. package/dist/CliLifecycle.js +90 -0
  6. package/dist/CliLifecycle.js.map +1 -0
  7. package/dist/ServerConfig.d.ts +290 -0
  8. package/dist/ServerConfig.d.ts.map +1 -0
  9. package/dist/ServerConfig.js +175 -0
  10. package/dist/ServerConfig.js.map +1 -0
  11. package/dist/cache/DiscoveryCache.d.ts +269 -0
  12. package/dist/cache/DiscoveryCache.d.ts.map +1 -0
  13. package/dist/cache/DiscoveryCache.js +104 -0
  14. package/dist/cache/DiscoveryCache.js.map +1 -0
  15. package/dist/cli.d.ts +3 -0
  16. package/dist/cli.d.ts.map +1 -0
  17. package/dist/cli.js +5177 -0
  18. package/dist/cli.js.map +1 -0
  19. package/dist/config/ConfigLoader.d.ts +270 -0
  20. package/dist/config/ConfigLoader.d.ts.map +1 -0
  21. package/dist/config/ConfigLoader.js +186 -0
  22. package/dist/config/ConfigLoader.js.map +1 -0
  23. package/dist/context/RequestContext.d.ts +43 -0
  24. package/dist/context/RequestContext.d.ts.map +1 -0
  25. package/dist/context/RequestContext.js +14 -0
  26. package/dist/context/RequestContext.js.map +1 -0
  27. package/dist/contracts/PersistenceBackend.d.ts +134 -0
  28. package/dist/contracts/PersistenceBackend.d.ts.map +1 -0
  29. package/dist/contracts/PersistenceBackend.js +6 -0
  30. package/dist/contracts/PersistenceBackend.js.map +1 -0
  31. package/dist/contracts/calibrator.d.ts +97 -0
  32. package/dist/contracts/calibrator.d.ts.map +1 -0
  33. package/dist/contracts/calibrator.js +1 -0
  34. package/dist/contracts/features.d.ts +35 -0
  35. package/dist/contracts/features.d.ts.map +1 -0
  36. package/dist/contracts/features.js +12 -0
  37. package/dist/contracts/features.js.map +1 -0
  38. package/dist/contracts/ids.d.ts +68 -0
  39. package/dist/contracts/ids.d.ts.map +1 -0
  40. package/dist/contracts/ids.js +40 -0
  41. package/dist/contracts/ids.js.map +1 -0
  42. package/dist/contracts/interfaces.d.ts +254 -0
  43. package/dist/contracts/interfaces.d.ts.map +1 -0
  44. package/dist/contracts/interfaces.js +1 -0
  45. package/dist/contracts/persistence-work.d.ts +96 -0
  46. package/dist/contracts/persistence-work.d.ts.map +1 -0
  47. package/dist/contracts/persistence-work.js +1 -0
  48. package/dist/contracts/reasoning-types.d.ts +21 -0
  49. package/dist/contracts/reasoning-types.d.ts.map +1 -0
  50. package/dist/contracts/reasoning-types.js +1 -0
  51. package/dist/contracts/strategy.d.ts +107 -0
  52. package/dist/contracts/strategy.d.ts.map +1 -0
  53. package/dist/contracts/strategy.js +1 -0
  54. package/dist/contracts/summary.d.ts +110 -0
  55. package/dist/contracts/summary.d.ts.map +1 -0
  56. package/dist/contracts/summary.js +1 -0
  57. package/dist/contracts/suspension.d.ts +215 -0
  58. package/dist/contracts/suspension.d.ts.map +1 -0
  59. package/dist/contracts/suspension.js +1 -0
  60. package/dist/contracts/transport.d.ts +26 -0
  61. package/dist/contracts/transport.d.ts.map +1 -0
  62. package/dist/contracts/transport.js +1 -0
  63. package/dist/core/CrossReferenceValidator.d.ts +18 -0
  64. package/dist/core/CrossReferenceValidator.d.ts.map +1 -0
  65. package/dist/core/CrossReferenceValidator.js +125 -0
  66. package/dist/core/CrossReferenceValidator.js.map +1 -0
  67. package/dist/core/HistoryManager.d.ts +215 -0
  68. package/dist/core/HistoryManager.d.ts.map +1 -0
  69. package/dist/core/HistoryManager.js +594 -0
  70. package/dist/core/HistoryManager.js.map +1 -0
  71. package/dist/core/IHistoryManager.d.ts +163 -0
  72. package/dist/core/IHistoryManager.d.ts.map +1 -0
  73. package/dist/core/IHistoryManager.js +1 -0
  74. package/dist/core/IThoughtFormatter.d.ts +51 -0
  75. package/dist/core/IThoughtFormatter.d.ts.map +1 -0
  76. package/dist/core/IThoughtFormatter.js +1 -0
  77. package/dist/core/InputNormalizer.d.ts +140 -0
  78. package/dist/core/InputNormalizer.d.ts.map +1 -0
  79. package/dist/core/InputNormalizer.js +95 -0
  80. package/dist/core/InputNormalizer.js.map +1 -0
  81. package/dist/core/PersistenceBuffer.d.ts +204 -0
  82. package/dist/core/PersistenceBuffer.d.ts.map +1 -0
  83. package/dist/core/PersistenceBuffer.js +382 -0
  84. package/dist/core/PersistenceBuffer.js.map +1 -0
  85. package/dist/core/PersistenceBufferErrors.d.ts +22 -0
  86. package/dist/core/PersistenceBufferErrors.d.ts.map +1 -0
  87. package/dist/core/PersistenceBufferErrors.js +30 -0
  88. package/dist/core/PersistenceBufferErrors.js.map +1 -0
  89. package/dist/core/PersistenceRestore.d.ts +21 -0
  90. package/dist/core/PersistenceRestore.d.ts.map +1 -0
  91. package/dist/core/PersistenceRestore.js +87 -0
  92. package/dist/core/PersistenceRestore.js.map +1 -0
  93. package/dist/core/PersistenceWorkQueue.d.ts +155 -0
  94. package/dist/core/PersistenceWorkQueue.d.ts.map +1 -0
  95. package/dist/core/PersistenceWorkQueue.js +298 -0
  96. package/dist/core/PersistenceWorkQueue.js.map +1 -0
  97. package/dist/core/PersistenceWriter.d.ts +55 -0
  98. package/dist/core/PersistenceWriter.d.ts.map +1 -0
  99. package/dist/core/PersistenceWriter.js +112 -0
  100. package/dist/core/PersistenceWriter.js.map +1 -0
  101. package/dist/core/SessionErrors.d.ts +37 -0
  102. package/dist/core/SessionErrors.d.ts.map +1 -0
  103. package/dist/core/SessionErrors.js +50 -0
  104. package/dist/core/SessionErrors.js.map +1 -0
  105. package/dist/core/SessionLifecycleCoordinator.d.ts +74 -0
  106. package/dist/core/SessionLifecycleCoordinator.d.ts.map +1 -0
  107. package/dist/core/SessionLifecycleCoordinator.js +222 -0
  108. package/dist/core/SessionLifecycleCoordinator.js.map +1 -0
  109. package/dist/core/SessionLock.d.ts +59 -0
  110. package/dist/core/SessionLock.d.ts.map +1 -0
  111. package/dist/core/SessionLock.js +39 -0
  112. package/dist/core/SessionLock.js.map +1 -0
  113. package/dist/core/SessionManager.d.ts +62 -0
  114. package/dist/core/SessionManager.d.ts.map +1 -0
  115. package/dist/core/SessionManager.js +75 -0
  116. package/dist/core/SessionManager.js.map +1 -0
  117. package/dist/core/SessionResetCoordinator.d.ts +37 -0
  118. package/dist/core/SessionResetCoordinator.d.ts.map +1 -0
  119. package/dist/core/SessionResetCoordinator.js +80 -0
  120. package/dist/core/SessionResetCoordinator.js.map +1 -0
  121. package/dist/core/ThoughtEvaluator.d.ts +48 -0
  122. package/dist/core/ThoughtEvaluator.d.ts.map +1 -0
  123. package/dist/core/ThoughtEvaluator.js +85 -0
  124. package/dist/core/ThoughtEvaluator.js.map +1 -0
  125. package/dist/core/ThoughtFormatter.d.ts +134 -0
  126. package/dist/core/ThoughtFormatter.d.ts.map +1 -0
  127. package/dist/core/ThoughtFormatter.js +118 -0
  128. package/dist/core/ThoughtFormatter.js.map +1 -0
  129. package/dist/core/ThoughtProcessor.d.ts +259 -0
  130. package/dist/core/ThoughtProcessor.d.ts.map +1 -0
  131. package/dist/core/ThoughtProcessor.js +451 -0
  132. package/dist/core/ThoughtProcessor.js.map +1 -0
  133. package/dist/core/ThoughtReferenceIndex.d.ts +23 -0
  134. package/dist/core/ThoughtReferenceIndex.d.ts.map +1 -0
  135. package/dist/core/ThoughtReferenceIndex.js +66 -0
  136. package/dist/core/ThoughtReferenceIndex.js.map +1 -0
  137. package/dist/core/VerificationOutcomeAdmission.d.ts +15 -0
  138. package/dist/core/VerificationOutcomeAdmission.d.ts.map +1 -0
  139. package/dist/core/VerificationOutcomeAdmission.js +28 -0
  140. package/dist/core/VerificationOutcomeAdmission.js.map +1 -0
  141. package/dist/core/compression/CompressionService.d.ts +76 -0
  142. package/dist/core/compression/CompressionService.d.ts.map +1 -0
  143. package/dist/core/compression/CompressionService.js +160 -0
  144. package/dist/core/compression/CompressionService.js.map +1 -0
  145. package/dist/core/compression/DehydrationPolicy.d.ts +75 -0
  146. package/dist/core/compression/DehydrationPolicy.d.ts.map +1 -0
  147. package/dist/core/compression/DehydrationPolicy.js +45 -0
  148. package/dist/core/compression/DehydrationPolicy.js.map +1 -0
  149. package/dist/core/compression/InMemorySummaryStore.d.ts +132 -0
  150. package/dist/core/compression/InMemorySummaryStore.d.ts.map +1 -0
  151. package/dist/core/compression/InMemorySummaryStore.js +69 -0
  152. package/dist/core/compression/InMemorySummaryStore.js.map +1 -0
  153. package/dist/core/compression/Summary.d.ts +74 -0
  154. package/dist/core/compression/Summary.d.ts.map +1 -0
  155. package/dist/core/compression/Summary.js +16 -0
  156. package/dist/core/compression/Summary.js.map +1 -0
  157. package/dist/core/evaluator/Aggregator.d.ts +40 -0
  158. package/dist/core/evaluator/Aggregator.d.ts.map +1 -0
  159. package/dist/core/evaluator/Aggregator.js +36 -0
  160. package/dist/core/evaluator/Aggregator.js.map +1 -0
  161. package/dist/core/evaluator/Calibrator.d.ts +52 -0
  162. package/dist/core/evaluator/Calibrator.d.ts.map +1 -0
  163. package/dist/core/evaluator/Calibrator.js +135 -0
  164. package/dist/core/evaluator/Calibrator.js.map +1 -0
  165. package/dist/core/evaluator/PatternDetector.d.ts +69 -0
  166. package/dist/core/evaluator/PatternDetector.d.ts.map +1 -0
  167. package/dist/core/evaluator/PatternDetector.js +192 -0
  168. package/dist/core/evaluator/PatternDetector.js.map +1 -0
  169. package/dist/core/evaluator/SignalComputer.d.ts +116 -0
  170. package/dist/core/evaluator/SignalComputer.d.ts.map +1 -0
  171. package/dist/core/evaluator/SignalComputer.js +110 -0
  172. package/dist/core/evaluator/SignalComputer.js.map +1 -0
  173. package/dist/core/evaluator/calibration-math.d.ts +39 -0
  174. package/dist/core/evaluator/calibration-math.d.ts.map +1 -0
  175. package/dist/core/evaluator/calibration-math.js +42 -0
  176. package/dist/core/evaluator/calibration-math.js.map +1 -0
  177. package/dist/core/evaluator/internals.d.ts +36 -0
  178. package/dist/core/evaluator/internals.d.ts.map +1 -0
  179. package/dist/core/evaluator/internals.js +43 -0
  180. package/dist/core/evaluator/internals.js.map +1 -0
  181. package/dist/core/graph/Edge.d.ts +58 -0
  182. package/dist/core/graph/Edge.d.ts.map +1 -0
  183. package/dist/core/graph/Edge.js +1 -0
  184. package/dist/core/graph/EdgeEmitter.d.ts +68 -0
  185. package/dist/core/graph/EdgeEmitter.d.ts.map +1 -0
  186. package/dist/core/graph/EdgeEmitter.js +118 -0
  187. package/dist/core/graph/EdgeEmitter.js.map +1 -0
  188. package/dist/core/graph/EdgeStore.d.ts +116 -0
  189. package/dist/core/graph/EdgeStore.d.ts.map +1 -0
  190. package/dist/core/graph/EdgeStore.js +107 -0
  191. package/dist/core/graph/EdgeStore.js.map +1 -0
  192. package/dist/core/graph/GraphView.d.ts +157 -0
  193. package/dist/core/graph/GraphView.d.ts.map +1 -0
  194. package/dist/core/graph/GraphView.js +149 -0
  195. package/dist/core/graph/GraphView.js.map +1 -0
  196. package/dist/core/ids.d.ts +33 -0
  197. package/dist/core/ids.d.ts.map +1 -0
  198. package/dist/core/ids.js +11 -0
  199. package/dist/core/ids.js.map +1 -0
  200. package/dist/core/reasoning/OutcomeRecorder.d.ts +88 -0
  201. package/dist/core/reasoning/OutcomeRecorder.d.ts.map +1 -0
  202. package/dist/core/reasoning/OutcomeRecorder.js +51 -0
  203. package/dist/core/reasoning/OutcomeRecorder.js.map +1 -0
  204. package/dist/core/reasoning/strategies/SequentialStrategy.d.ts +54 -0
  205. package/dist/core/reasoning/strategies/SequentialStrategy.d.ts.map +1 -0
  206. package/dist/core/reasoning/strategies/SequentialStrategy.js +22 -0
  207. package/dist/core/reasoning/strategies/SequentialStrategy.js.map +1 -0
  208. package/dist/core/reasoning/strategies/StrategyFactory.d.ts +25 -0
  209. package/dist/core/reasoning/strategies/StrategyFactory.d.ts.map +1 -0
  210. package/dist/core/reasoning/strategies/StrategyFactory.js +16 -0
  211. package/dist/core/reasoning/strategies/StrategyFactory.js.map +1 -0
  212. package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.d.ts +58 -0
  213. package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.d.ts.map +1 -0
  214. package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.js +103 -0
  215. package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.js.map +1 -0
  216. package/dist/core/reasoning/strategies/plateau.d.ts +18 -0
  217. package/dist/core/reasoning/strategies/plateau.d.ts.map +1 -0
  218. package/dist/core/reasoning/strategies/plateau.js +12 -0
  219. package/dist/core/reasoning/strategies/plateau.js.map +1 -0
  220. package/dist/core/reasoning/strategies/totScoring.d.ts +91 -0
  221. package/dist/core/reasoning/strategies/totScoring.d.ts.map +1 -0
  222. package/dist/core/reasoning/strategies/totScoring.js +88 -0
  223. package/dist/core/reasoning/strategies/totScoring.js.map +1 -0
  224. package/dist/core/reasoning.d.ts +179 -0
  225. package/dist/core/reasoning.d.ts.map +1 -0
  226. package/dist/core/reasoning.js +1 -0
  227. package/dist/core/step.d.ts +50 -0
  228. package/dist/core/step.d.ts.map +1 -0
  229. package/dist/core/step.js +1 -0
  230. package/dist/core/thought.d.ts +113 -0
  231. package/dist/core/thought.d.ts.map +1 -0
  232. package/dist/core/thought.js +1 -0
  233. package/dist/core/tools/InMemorySuspensionStore.d.ts +66 -0
  234. package/dist/core/tools/InMemorySuspensionStore.d.ts.map +1 -0
  235. package/dist/core/tools/InMemorySuspensionStore.js +121 -0
  236. package/dist/core/tools/InMemorySuspensionStore.js.map +1 -0
  237. package/dist/di/Container.d.ts +253 -0
  238. package/dist/di/Container.d.ts.map +1 -0
  239. package/dist/di/Container.js +111 -0
  240. package/dist/di/Container.js.map +1 -0
  241. package/dist/di/ServiceRegistry.d.ts +50 -0
  242. package/dist/di/ServiceRegistry.d.ts.map +1 -0
  243. package/dist/di/ServiceRegistry.js +1 -0
  244. package/dist/errors.d.ts +663 -0
  245. package/dist/errors.d.ts.map +1 -0
  246. package/dist/errors.js +282 -0
  247. package/dist/errors.js.map +1 -0
  248. package/dist/health/HealthChecker.d.ts +73 -0
  249. package/dist/health/HealthChecker.d.ts.map +1 -0
  250. package/dist/health/HealthChecker.js +70 -0
  251. package/dist/health/HealthChecker.js.map +1 -0
  252. package/dist/lib.d.ts +273 -0
  253. package/dist/lib.d.ts.map +1 -0
  254. package/dist/lib.js +409 -0
  255. package/dist/lib.js.map +1 -0
  256. package/dist/logger/NullLogger.d.ts +154 -0
  257. package/dist/logger/NullLogger.d.ts.map +1 -0
  258. package/dist/logger/NullLogger.js +24 -0
  259. package/dist/logger/NullLogger.js.map +1 -0
  260. package/dist/logger/StructuredLogger.d.ts +327 -0
  261. package/dist/logger/StructuredLogger.d.ts.map +1 -0
  262. package/dist/logger/StructuredLogger.js +72 -0
  263. package/dist/logger/StructuredLogger.js.map +1 -0
  264. package/dist/metrics/metrics.impl.d.ts +252 -0
  265. package/dist/metrics/metrics.impl.d.ts.map +1 -0
  266. package/dist/metrics/metrics.impl.js +197 -0
  267. package/dist/metrics/metrics.impl.js.map +1 -0
  268. package/dist/persistence/FileLegacyImport.d.ts +2 -0
  269. package/dist/persistence/FileLegacyImport.d.ts.map +1 -0
  270. package/dist/persistence/FileLegacyImport.js +183 -0
  271. package/dist/persistence/FileLegacyImport.js.map +1 -0
  272. package/dist/persistence/FilePersistence.d.ts +53 -0
  273. package/dist/persistence/FilePersistence.d.ts.map +1 -0
  274. package/dist/persistence/FilePersistence.js +312 -0
  275. package/dist/persistence/FilePersistence.js.map +1 -0
  276. package/dist/persistence/FileSnapshotTypes.d.ts +29 -0
  277. package/dist/persistence/FileSnapshotTypes.d.ts.map +1 -0
  278. package/dist/persistence/FileSnapshotTypes.js +1 -0
  279. package/dist/persistence/FileSnapshotV2.d.ts +377 -0
  280. package/dist/persistence/FileSnapshotV2.d.ts.map +1 -0
  281. package/dist/persistence/FileSnapshotV2.js +124 -0
  282. package/dist/persistence/FileSnapshotV2.js.map +1 -0
  283. package/dist/persistence/FileSnapshotValidation.d.ts +15 -0
  284. package/dist/persistence/FileSnapshotValidation.d.ts.map +1 -0
  285. package/dist/persistence/FileSnapshotValidation.js +64 -0
  286. package/dist/persistence/FileSnapshotValidation.js.map +1 -0
  287. package/dist/persistence/FileWriter.d.ts +30 -0
  288. package/dist/persistence/FileWriter.d.ts.map +1 -0
  289. package/dist/persistence/FileWriter.js +155 -0
  290. package/dist/persistence/FileWriter.js.map +1 -0
  291. package/dist/persistence/MemoryPersistence.d.ts +45 -0
  292. package/dist/persistence/MemoryPersistence.d.ts.map +1 -0
  293. package/dist/persistence/MemoryPersistence.js +180 -0
  294. package/dist/persistence/MemoryPersistence.js.map +1 -0
  295. package/dist/persistence/PersistenceCodec.d.ts +7 -0
  296. package/dist/persistence/PersistenceCodec.d.ts.map +1 -0
  297. package/dist/persistence/PersistenceCodec.js +97 -0
  298. package/dist/persistence/PersistenceCodec.js.map +1 -0
  299. package/dist/persistence/PersistenceErrors.d.ts +23 -0
  300. package/dist/persistence/PersistenceErrors.d.ts.map +1 -0
  301. package/dist/persistence/PersistenceErrors.js +26 -0
  302. package/dist/persistence/PersistenceErrors.js.map +1 -0
  303. package/dist/persistence/PersistenceFactory.d.ts +21 -0
  304. package/dist/persistence/PersistenceFactory.d.ts.map +1 -0
  305. package/dist/persistence/PersistenceFactory.js +28 -0
  306. package/dist/persistence/PersistenceFactory.js.map +1 -0
  307. package/dist/persistence/PersistenceScope.d.ts +42 -0
  308. package/dist/persistence/PersistenceScope.d.ts.map +1 -0
  309. package/dist/persistence/PersistenceScope.js +93 -0
  310. package/dist/persistence/PersistenceScope.js.map +1 -0
  311. package/dist/persistence/SessionScopedPersistence.d.ts +4 -0
  312. package/dist/persistence/SessionScopedPersistence.d.ts.map +1 -0
  313. package/dist/persistence/SessionScopedPersistence.js +9 -0
  314. package/dist/persistence/SessionScopedPersistence.js.map +1 -0
  315. package/dist/persistence/SqliteDriver.d.ts +22 -0
  316. package/dist/persistence/SqliteDriver.d.ts.map +1 -0
  317. package/dist/persistence/SqliteDriver.js +29 -0
  318. package/dist/persistence/SqliteDriver.js.map +1 -0
  319. package/dist/persistence/SqliteLegacyImport.d.ts +14 -0
  320. package/dist/persistence/SqliteLegacyImport.d.ts.map +1 -0
  321. package/dist/persistence/SqliteLegacyImport.js +136 -0
  322. package/dist/persistence/SqliteLegacyImport.js.map +1 -0
  323. package/dist/persistence/SqliteLegacySchema.d.ts +15 -0
  324. package/dist/persistence/SqliteLegacySchema.d.ts.map +1 -0
  325. package/dist/persistence/SqliteLegacySchema.js +72 -0
  326. package/dist/persistence/SqliteLegacySchema.js.map +1 -0
  327. package/dist/persistence/SqlitePayload.d.ts +11 -0
  328. package/dist/persistence/SqlitePayload.d.ts.map +1 -0
  329. package/dist/persistence/SqlitePayload.js +86 -0
  330. package/dist/persistence/SqlitePayload.js.map +1 -0
  331. package/dist/persistence/SqlitePersistence.d.ts +49 -0
  332. package/dist/persistence/SqlitePersistence.d.ts.map +1 -0
  333. package/dist/persistence/SqlitePersistence.js +248 -0
  334. package/dist/persistence/SqlitePersistence.js.map +1 -0
  335. package/dist/persistence/SqliteSchemaV2.d.ts +14 -0
  336. package/dist/persistence/SqliteSchemaV2.d.ts.map +1 -0
  337. package/dist/persistence/SqliteSchemaV2.js +129 -0
  338. package/dist/persistence/SqliteSchemaV2.js.map +1 -0
  339. package/dist/persistence/SqliteSnapshotWriter.d.ts +17 -0
  340. package/dist/persistence/SqliteSnapshotWriter.d.ts.map +1 -0
  341. package/dist/persistence/SqliteSnapshotWriter.js +30 -0
  342. package/dist/persistence/SqliteSnapshotWriter.js.map +1 -0
  343. package/dist/pool/ConnectionPool.d.ts +203 -0
  344. package/dist/pool/ConnectionPool.d.ts.map +1 -0
  345. package/dist/pool/ConnectionPool.js +303 -0
  346. package/dist/pool/ConnectionPool.js.map +1 -0
  347. package/dist/pool/IConnectionPool.d.ts +143 -0
  348. package/dist/pool/IConnectionPool.d.ts.map +1 -0
  349. package/dist/pool/IConnectionPool.js +1 -0
  350. package/dist/pool/PoolErrors.d.ts +11 -0
  351. package/dist/pool/PoolErrors.d.ts.map +1 -0
  352. package/dist/pool/PoolErrors.js +16 -0
  353. package/dist/pool/PoolErrors.js.map +1 -0
  354. package/dist/registry/BaseRegistry.d.ts +219 -0
  355. package/dist/registry/BaseRegistry.d.ts.map +1 -0
  356. package/dist/registry/BaseRegistry.js +215 -0
  357. package/dist/registry/BaseRegistry.js.map +1 -0
  358. package/dist/registry/SkillRegistry.d.ts +67 -0
  359. package/dist/registry/SkillRegistry.d.ts.map +1 -0
  360. package/dist/registry/SkillRegistry.js +87 -0
  361. package/dist/registry/SkillRegistry.js.map +1 -0
  362. package/dist/registry/ToolRegistry.d.ts +70 -0
  363. package/dist/registry/ToolRegistry.d.ts.map +1 -0
  364. package/dist/registry/ToolRegistry.js +96 -0
  365. package/dist/registry/ToolRegistry.js.map +1 -0
  366. package/dist/sanitize.d.ts +164 -0
  367. package/dist/sanitize.d.ts.map +1 -0
  368. package/dist/sanitize.js +100 -0
  369. package/dist/sanitize.js.map +1 -0
  370. package/dist/schema.d.ts +562 -0
  371. package/dist/schema.d.ts.map +1 -0
  372. package/dist/schema.js +251 -0
  373. package/dist/schema.js.map +1 -0
  374. package/dist/transport/BaseTransport.d.ts +166 -0
  375. package/dist/transport/BaseTransport.d.ts.map +1 -0
  376. package/dist/transport/BaseTransport.js +199 -0
  377. package/dist/transport/BaseTransport.js.map +1 -0
  378. package/dist/transport/HttpHelpers.d.ts +53 -0
  379. package/dist/transport/HttpHelpers.d.ts.map +1 -0
  380. package/dist/transport/HttpHelpers.js +44 -0
  381. package/dist/transport/HttpHelpers.js.map +1 -0
  382. package/dist/transport/HttpRequestLifecycle.d.ts +37 -0
  383. package/dist/transport/HttpRequestLifecycle.d.ts.map +1 -0
  384. package/dist/transport/HttpRequestLifecycle.js +87 -0
  385. package/dist/transport/HttpRequestLifecycle.js.map +1 -0
  386. package/dist/transport/HttpTransport.d.ts +140 -0
  387. package/dist/transport/HttpTransport.d.ts.map +1 -0
  388. package/dist/transport/HttpTransport.js +245 -0
  389. package/dist/transport/HttpTransport.js.map +1 -0
  390. package/dist/transport/SseTransport.d.ts +149 -0
  391. package/dist/transport/SseTransport.d.ts.map +1 -0
  392. package/dist/transport/SseTransport.js +470 -0
  393. package/dist/transport/SseTransport.js.map +1 -0
  394. package/dist/transport/StreamableHttpTransport.d.ts +225 -0
  395. package/dist/transport/StreamableHttpTransport.d.ts.map +1 -0
  396. package/dist/transport/StreamableHttpTransport.js +449 -0
  397. package/dist/transport/StreamableHttpTransport.js.map +1 -0
  398. package/dist/types/disposable.d.ts +22 -0
  399. package/dist/types/disposable.d.ts.map +1 -0
  400. package/dist/types/disposable.js +1 -0
  401. package/dist/types/server-config.d.ts +32 -0
  402. package/dist/types/server-config.d.ts.map +1 -0
  403. package/dist/types/server-config.js +1 -0
  404. package/dist/types/skill.d.ts +74 -0
  405. package/dist/types/skill.d.ts.map +1 -0
  406. package/dist/types/skill.js +1 -0
  407. package/dist/types/tool.d.ts +78 -0
  408. package/dist/types/tool.d.ts.map +1 -0
  409. package/dist/types/tool.js +1 -0
  410. package/dist/utils.d.ts +27 -0
  411. package/dist/utils.d.ts.map +1 -0
  412. package/dist/utils.js +6 -0
  413. package/dist/utils.js.map +1 -0
  414. package/dist/watchers/SkillWatcher.d.ts +25 -0
  415. package/dist/watchers/SkillWatcher.d.ts.map +1 -0
  416. package/dist/watchers/SkillWatcher.js +96 -0
  417. package/dist/watchers/SkillWatcher.js.map +1 -0
  418. package/dist/watchers/ToolWatcher.d.ts +24 -0
  419. package/dist/watchers/ToolWatcher.d.ts.map +1 -0
  420. package/dist/watchers/ToolWatcher.js +92 -0
  421. package/dist/watchers/ToolWatcher.js.map +1 -0
  422. package/package.json +106 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/SessionManager.js","sources":["../../src/core/SessionManager.ts"],"sourcesContent":["/**\n * Deterministic session cleanup candidate policy and periodic timer.\n *\n * @module SessionManager\n */\n\nimport type { SessionId } from '../contracts/ids.js';\nimport { NullLogger } from '../logger/NullLogger.js';\nimport type { Logger } from '../logger/StructuredLogger.js';\n\n/** Minimal session facts needed by capacity and TTL policy. */\nexport interface SessionLike {\n\treadonly lastAccessedAt: number;\n\treadonly owner?: string;\n\treadonly provenance?: 'restored';\n}\n\n/** Determines whether a candidate can be removed at this instant. */\nexport type SessionEligibility<S extends SessionLike> = (\n\tsessionId: SessionId,\n\tsession: S\n) => boolean;\n\n/** Configuration options for {@link SessionManager}. */\nexport interface SessionManagerConfig {\n\treadonly defaultSessionId: SessionId;\n\treadonly sessionTtlMs: number;\n\treadonly cleanupIntervalMs: number;\n\treadonly getMaxSessions: () => number;\n\treadonly maxSessionsPerOwner?: number;\n\treadonly logger?: Logger;\n}\n\ntype Candidate<S extends SessionLike> = {\n\treadonly sessionId: SessionId;\n\treadonly session: S;\n\treadonly insertionOrder: number;\n};\n\n/**\n * Produces complete candidate sets but never mutates the caller-owned session map.\n *\n * @example\n * ```ts\n * const victims = manager.planProspectiveAdmission(sessions, owner, lifecycle.isIdle);\n * ```\n */\nexport class SessionManager<S extends SessionLike> {\n\tprivate readonly _defaultSessionId: SessionId;\n\tprivate readonly _sessionTtlMs: number;\n\tprivate readonly _cleanupIntervalMs: number;\n\tprivate readonly _getMaxSessions: () => number;\n\tprivate readonly _maxSessionsPerOwner: number;\n\tprivate readonly _logger: Logger;\n\tprivate _cleanupTimer: ReturnType<typeof setInterval> | null = null;\n\n\tpublic constructor(config: SessionManagerConfig) {\n\t\tthis._defaultSessionId = config.defaultSessionId;\n\t\tthis._sessionTtlMs = config.sessionTtlMs;\n\t\tthis._cleanupIntervalMs = config.cleanupIntervalMs;\n\t\tthis._getMaxSessions = config.getMaxSessions;\n\t\tthis._maxSessionsPerOwner = config.maxSessionsPerOwner ?? 50;\n\t\tthis._logger = config.logger ?? new NullLogger();\n\t}\n\n\t/** @returns The periodic cleanup timer, when active. */\n\tpublic get timer(): ReturnType<typeof setInterval> | null {\n\t\treturn this._cleanupTimer;\n\t}\n\n\t/**\n\t * Starts periodic TTL candidate cleanup and observes every asynchronous rejection.\n\t */\n\tpublic startCleanupTimer(\n\t\tsessions: Map<SessionId, S>,\n\t\tisEligible: SessionEligibility<S>,\n\t\tcleanup: (sessionIds: readonly SessionId[]) => Promise<void>\n\t): void {\n\t\tif (this._cleanupTimer !== null) return;\n\t\tthis._cleanupTimer = setInterval(() => {\n\t\t\tconst candidates = this.staleSessionCandidates(sessions, isEligible);\n\t\t\tif (candidates.length === 0) return;\n\t\t\tvoid Promise.resolve()\n\t\t\t\t.then(() => cleanup(candidates))\n\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\tthis._logger.error('Session cleanup failed', { error });\n\t\t\t\t});\n\t\t}, this._cleanupIntervalMs);\n\t\tif (typeof this._cleanupTimer === 'object' && 'unref' in this._cleanupTimer) {\n\t\t\tthis._cleanupTimer.unref();\n\t\t}\n\t}\n\n\t/** Stops the periodic cleanup timer. */\n\tpublic stopCleanupTimer(): void {\n\t\tif (this._cleanupTimer === null) return;\n\t\tclearInterval(this._cleanupTimer);\n\t\tthis._cleanupTimer = null;\n\t}\n\n\t/**\n\t * Plans the complete victim union required before admitting one prospective session.\n\t *\n\t * Owner quota need is selected first. Those victims also satisfy global need, then\n\t * oldest globally eligible alternatives fill any remainder. `undefined` means no\n\t * complete eligible set exists; the input map is never modified.\n\t */\n\tpublic planProspectiveAdmission(\n\t\tsessions: ReadonlyMap<SessionId, S>,\n\t\towner: string | undefined,\n\t\tisEligible: SessionEligibility<S>\n\t): readonly SessionId[] | undefined {\n\t\tconst live = this._orderedLiveCandidates(sessions);\n\t\tconst selected: Candidate<S>[] = [];\n\t\tif (owner !== undefined) {\n\t\t\tconst ownerCount = live.filter((candidate) => candidate.session.owner === owner).length;\n\t\t\tconst ownerNeed = Math.max(0, ownerCount + 1 - this._maxSessionsPerOwner);\n\t\t\tselected.push(\n\t\t\t\t...live\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t(candidate) =>\n\t\t\t\t\t\t\tcandidate.session.owner === owner &&\n\t\t\t\t\t\t\tcandidate.sessionId !== this._defaultSessionId &&\n\t\t\t\t\t\t\tisEligible(candidate.sessionId, candidate.session)\n\t\t\t\t\t)\n\t\t\t\t\t.slice(0, ownerNeed)\n\t\t\t);\n\t\t\tif (selected.length < ownerNeed) return undefined;\n\t\t}\n\n\t\tconst globalNeed = Math.max(0, live.length + 1 - this._getMaxSessions());\n\t\tconst remainingNeed = Math.max(0, globalNeed - selected.length);\n\t\tconst selectedIds = new Set(selected.map((candidate) => candidate.sessionId));\n\t\tconst alternatives = live.filter(\n\t\t\t(candidate) =>\n\t\t\t\tcandidate.sessionId !== this._defaultSessionId &&\n\t\t\t\t!selectedIds.has(candidate.sessionId) &&\n\t\t\t\tisEligible(candidate.sessionId, candidate.session)\n\t\t);\n\t\tif (alternatives.length < remainingNeed) return undefined;\n\t\tselected.push(...alternatives.slice(0, remainingNeed));\n\t\treturn selected.map((candidate) => candidate.sessionId);\n\t}\n\n\t/** Returns stable oldest-first TTL candidates under the same eligibility rules. */\n\tpublic staleSessionCandidates(\n\t\tsessions: ReadonlyMap<SessionId, S>,\n\t\tisEligible: SessionEligibility<S>,\n\t\tnow: number = Date.now()\n\t): readonly SessionId[] {\n\t\treturn this._orderedLiveCandidates(sessions)\n\t\t\t.filter(\n\t\t\t\t(candidate) =>\n\t\t\t\t\tcandidate.sessionId !== this._defaultSessionId &&\n\t\t\t\t\tnow - candidate.session.lastAccessedAt > this._sessionTtlMs &&\n\t\t\t\t\tisEligible(candidate.sessionId, candidate.session)\n\t\t\t)\n\t\t\t.map((candidate) => candidate.sessionId);\n\t}\n\n\tprivate _orderedLiveCandidates(sessions: ReadonlyMap<SessionId, S>): Candidate<S>[] {\n\t\tconst candidates: Candidate<S>[] = [];\n\t\tlet insertionOrder = 0;\n\t\tfor (const [sessionId, session] of sessions) {\n\t\t\tif (session.provenance !== 'restored') {\n\t\t\t\tcandidates.push({ sessionId, session, insertionOrder });\n\t\t\t}\n\t\t\tinsertionOrder += 1;\n\t\t}\n\t\treturn candidates.sort(\n\t\t\t(left, right) =>\n\t\t\t\tleft.session.lastAccessedAt - right.session.lastAccessedAt ||\n\t\t\t\tleft.insertionOrder - right.insertionOrder\n\t\t);\n\t}\n}\n"],"names":["SessionManager","config","NullLogger","sessions","isEligible","cleanup","setInterval","candidates","Promise","error","clearInterval","owner","live","selected","undefined","ownerCount","candidate","ownerNeed","Math","globalNeed","remainingNeed","selectedIds","Set","alternatives","now","Date","insertionOrder","sessionId","session","left","right"],"mappings":";AA+CO,MAAMA;IACK,kBAA6B;IAC7B,cAAsB;IACtB,mBAA2B;IAC3B,gBAA8B;IAC9B,qBAA6B;IAC7B,QAAgB;IACzB,gBAAuD,KAAK;IAEpE,YAAmBC,MAA4B,CAAE;QAChD,IAAI,CAAC,iBAAiB,GAAGA,OAAO,gBAAgB;QAChD,IAAI,CAAC,aAAa,GAAGA,OAAO,YAAY;QACxC,IAAI,CAAC,kBAAkB,GAAGA,OAAO,iBAAiB;QAClD,IAAI,CAAC,eAAe,GAAGA,OAAO,cAAc;QAC5C,IAAI,CAAC,oBAAoB,GAAGA,OAAO,mBAAmB,IAAI;QAC1D,IAAI,CAAC,OAAO,GAAGA,OAAO,MAAM,IAAI,IAAIC;IACrC;IAGA,IAAW,QAA+C;QACzD,OAAO,IAAI,CAAC,aAAa;IAC1B;IAKO,kBACNC,QAA2B,EAC3BC,UAAiC,EACjCC,OAA4D,EACrD;QACP,IAAI,AAAuB,SAAvB,IAAI,CAAC,aAAa,EAAW;QACjC,IAAI,CAAC,aAAa,GAAGC,YAAY;YAChC,MAAMC,aAAa,IAAI,CAAC,sBAAsB,CAACJ,UAAUC;YACzD,IAAIG,AAAsB,MAAtBA,WAAW,MAAM,EAAQ;YACxBC,QAAQ,OAAO,GAClB,IAAI,CAAC,IAAMH,QAAQE,aACnB,KAAK,CAAC,CAACE;gBACP,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,0BAA0B;oBAA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ACK,YAAY,GAAG,CAACL,UAAU,SAAS,KACpCZ,WAAWY,UAAU,SAAS,EAAEA,UAAU,OAAO;QAEnD,IAAIO,aAAa,MAAM,GAAGH,eAAe;QACzCP,SAAS,IAAI,IAAIU,aAAa,KAAK,CAAC,GAAGH;QACvC,OAAOP,SAAS,GAAG,CAAC,CAACG,YAAcA,UAAU,SAAS;IACvD;IAGO,uBACNb,QAAmC,EACnCC,UAAiC,EACjCoB,MAAcC,KAAK,GAAG,EAAE,EACD;QACvB,OAAO,IAAI,CAAC,sBAAsB,CAACtB,UACjC,MAAM,CACN,CAACa,YACAA,UAAU,SAAS,KAAK,IAAI,CAAC,iBAAiB,IAC9CQ,MAAMR,UAAU,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,IAC3DZ,WAAWY,UAAU,SAAS,EAAEA,UAAU,OAAO,GAElD,GAAG,CAAC,CAACA,YAAcA,UAAU,SAAS;IACzC;IAEQ,uBAAuBb,QAAmC,EAAkB;QACnF,MAAMI,aAA6B,EAAE;QACrC,IAAImB,iBAAiB;QACrB,KAAK,MAAM,CAACC,WAAWC,QAAQ,IAAIzB,SAAU;YAC5C,IAAIyB,AAAuB,eAAvBA,QAAQ,UAAU,EACrBrB,WAAW,IAAI,CAAC;gBAAEoB;gBAAWC;gBAASF;YAAe;YAEtDA,kBAAkB;QACnB;QACA,OAAOnB,WAAW,IAAI,CACrB,CAACsB,MAAMC,QACND,KAAK,OAAO,CAAC,cAAc,GAAGC,MAAM,OAAO,CAAC,cAAc,IAC1DD,KAAK,cAAc,GAAGC,MAAM,cAAc;IAE7C;AACD"}
@@ -0,0 +1,37 @@
1
+ import type { PersistenceBackend } from '../contracts/PersistenceBackend.js';
2
+ import type { IEdgeStore } from '../contracts/interfaces.js';
3
+ import type { SessionId } from '../contracts/ids.js';
4
+ import type { ISummaryStore } from '../contracts/summary.js';
5
+ import type { Logger } from '../logger/StructuredLogger.js';
6
+ interface ResetBarrier {
7
+ withSessionResetBarrier(sessionId: SessionId, operation: () => Promise<void>): Promise<void>;
8
+ withGlobalResetBarrier(operation: () => Promise<void>): Promise<void>;
9
+ }
10
+ export interface SessionResetCoordinatorConfig<SessionState> {
11
+ readonly persistence: PersistenceBackend | null;
12
+ readonly barrier: ResetBarrier | null;
13
+ readonly edgeStore?: IEdgeStore;
14
+ readonly summaryStore?: ISummaryStore;
15
+ readonly sessions: Map<SessionId, SessionState>;
16
+ readonly createSessionState: (owner: string | undefined) => SessionState;
17
+ readonly logger: Logger;
18
+ }
19
+ export declare class SessionResetCoordinator<SessionState> {
20
+ private readonly _persistence;
21
+ private readonly _barrier;
22
+ private readonly _edgeStore?;
23
+ private readonly _summaryStore?;
24
+ private readonly _sessions;
25
+ private readonly _createSessionState;
26
+ private readonly _logger;
27
+ constructor(config: SessionResetCoordinatorConfig<SessionState>);
28
+ clearSession(sessionId: SessionId): void;
29
+ clearAll(): void;
30
+ resetSession(sessionId: SessionId, preservedOwner: string | undefined, clearAuxiliaryState?: () => void): Promise<void>;
31
+ resetAll(clearAuxiliaryState?: () => void): Promise<void>;
32
+ private _replaceLiveSession;
33
+ private _clearSessionStores;
34
+ private _clearAllLiveState;
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=SessionResetCoordinator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionResetCoordinator.d.ts","sourceRoot":"","sources":["../../src/core/SessionResetCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAI5D,UAAU,YAAY;IACrB,uBAAuB,CAAC,SAAS,EAAE,SAAS,EA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AM,IAAI,GAC9B,OAAO,CAAC,IAAI,CAAC;IAeV,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAe/D,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,kBAAkB;CAM1B"}
@@ -0,0 +1,80 @@
1
+ import { requireSessionScopedPersistence } from "../persistence/SessionScopedPersistence.js";
2
+ import { AsyncResetRequiredError } from "./SessionErrors.js";
3
+ class SessionResetCoordinator {
4
+ _persistence;
5
+ _barrier;
6
+ _edgeStore;
7
+ _summaryStore;
8
+ _sessions;
9
+ _createSessionState;
10
+ _logger;
11
+ constructor(config){
12
+ this._persistence = config.persistence;
13
+ this._barrier = config.barrier;
14
+ this._edgeStore = config.edgeStore;
15
+ this._summaryStore = config.summaryStore;
16
+ this._sessions = config.sessions;
17
+ this._createSessionState = config.createSessionState;
18
+ this._logger = config.logger;
19
+ }
20
+ clearSession(sessionId) {
21
+ if (null !== this._persistence) throw new AsyncResetRequiredError('session', sessionId);
22
+ this._clearSessionStores(sessionId);
23
+ this._sessions.delete(sessionId);
24
+ this._logger.info('Session cleared', {
25
+ sessionId
26
+ });
27
+ }
28
+ clearAll() {
29
+ if (null !== this._persistence) throw new AsyncResetRequiredError('all');
30
+ this._clearAllLiveState();
31
+ }
32
+ async resetSession(sessionId, preservedOwner, clearAuxiliaryState) {
33
+ if (null === this._persistence) {
34
+ this._replaceLiveSession(sessionId, preservedOwner);
35
+ clearAuxiliaryState?.();
36
+ return;
37
+ }
38
+ const scopedPersistence = requireSessionScopedPersistence(this._persistence, 'clearSession');
39
+ if (null === this._barrier) throw new AsyncResetRequiredError('session', sessionId);
40
+ await this._barrier.withSessionResetBarrier(sessionId, async ()=>{
41
+ await scopedPersistence.clearSession(sessionId);
42
+ this._replaceLiveSession(sessionId, preservedOwner);
43
+ clearAuxiliaryState?.();
44
+ });
45
+ }
46
+ async resetAll(clearAuxiliaryState) {
47
+ const persistence = this._persistence;
48
+ if (null === persistence) {
49
+ this._clearAllLiveState();
50
+ clearAuxiliaryState?.();
51
+ return;
52
+ }
53
+ if (null === this._barrier) throw new AsyncResetRequiredError('all');
54
+ await this._barrier.withGlobalResetBarrier(async ()=>{
55
+ await persistence.clear();
56
+ this._clearAllLiveState();
57
+ clearAuxiliaryState?.();
58
+ });
59
+ }
60
+ _replaceLiveSession(sessionId, owner) {
61
+ this._clearSessionStores(sessionId);
62
+ this._sessions.set(sessionId, this._createSessionState(owner));
63
+ this._logger.info('Session reset', {
64
+ sessionId
65
+ });
66
+ }
67
+ _clearSessionStores(sessionId) {
68
+ this._edgeStore?.clearSession(sessionId);
69
+ this._summaryStore?.clearSession(sessionId);
70
+ }
71
+ _clearAllLiveState() {
72
+ this._edgeStore?.clearAll();
73
+ this._summaryStore?.clearAll();
74
+ this._sessions.clear();
75
+ this._logger.info('History cleared (all sessions)');
76
+ }
77
+ }
78
+ export { SessionResetCoordinator };
79
+
80
+ //# sourceMappingURL=SessionResetCoordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/SessionResetCoordinator.js","sources":["../../src/core/SessionResetCoordinator.ts"],"sourcesContent":["import type { PersistenceBackend } from '../contracts/PersistenceBackend.js';\nimport type { IEdgeStore } from '../contracts/interfaces.js';\nimport type { SessionId } from '../contracts/ids.js';\nimport type { ISummaryStore } from '../contracts/summary.js';\nimport type { Logger } from '../logger/StructuredLogger.js';\nimport { requireSessionScopedPersistence } from '../persistence/SessionScopedPersistence.js';\nimport { AsyncResetRequiredError } from './SessionErrors.js';\n\ninterface ResetBarrier {\n\twithSessionResetBarrier(sessionId: SessionId, operation: () => Promise<void>): Promise<void>;\n\twithGlobalResetBarrier(operation: () => Promise<void>): Promise<void>;\n}\n\nexport interface SessionResetCoordinatorConfig<SessionState> {\n\treadonly persistence: PersistenceBackend | null;\n\treadonly barrier: ResetBarrier | null;\n\treadonly edgeStore?: IEdgeStore;\n\treadonly summaryStore?: ISummaryStore;\n\treadonly sessions: Map<SessionId, SessionState>;\n\treadonly createSessionState: (owner: string | undefined) => SessionState;\n\treadonly logger: Logger;\n}\n\nexport class SessionResetCoordinator<SessionState> {\n\tprivate readonly _persistence: PersistenceBackend | null;\n\tprivate readonly _barrier: ResetBarrier | null;\n\tprivate readonly _edgeStore?: IEdgeStore;\n\tprivate readonly _summaryStore?: ISummaryStore;\n\tprivate readonly _sessions: Map<SessionId, SessionState>;\n\tprivate readonly _createSessionState: (owner: string | undefined) => SessionState;\n\tprivate readonly _logger: Logger;\n\n\tconstructor(config: SessionResetCoordinatorConfig<SessionState>) {\n\t\tthis._persistence = config.persistence;\n\t\tthis._barrier = config.barrier;\n\t\tthis._edgeStore = config.edgeStore;\n\t\tthis._summaryStore = config.summaryStore;\n\t\tthis._sessions = config.sessions;\n\t\tthis._createSessionState = config.createSessionState;\n\t\tthis._logger = config.logger;\n\t}\n\n\tclearSession(sessionId: SessionId): void {\n\t\tif (this._persistence !== null) throw new AsyncResetRequiredError('session', sessionId);\n\t\tthis._clearSessionStores(sessionId);\n\t\tthis._sessions.delete(sessionId);\n\t\tthis._logger.info('Session cleared', { sessionId });\n\t}\n\n\tclearAll(): void {\n\t\tif (this._persistence !== null) throw new AsyncResetRequiredError('all');\n\t\tthis._clearAllLiveState();\n\t}\n\n\tasync resetSession(\n\t\tsessionId: SessionId,\n\t\tpreservedOwner: string | undefined,\n\t\tclearAuxiliaryState?: () => void\n\t): Promise<void> {\n\t\tif (this._persistence === null) {\n\t\t\tthis._replaceLiveSession(sessionId, preservedOwner);\n\t\t\tclearAuxiliaryState?.();\n\t\t\treturn;\n\t\t}\n\t\tconst scopedPersistence = requireSessionScopedPersistence(this._persistence, 'clearSession');\n\t\tif (this._barrier === null) throw new AsyncResetRequiredError('session', sessionId);\n\t\tawait this._barrier.withSessionResetBarrier(sessionId, async () => {\n\t\t\tawait scopedPersistence.clearSession(sessionId);\n\t\t\tthis._replaceLiveSession(sessionId, preservedOwner);\n\t\t\tclearAuxiliaryState?.();\n\t\t});\n\t}\n\n\tasync resetAll(clearAuxiliaryState?: () => void): Promise<void> {\n\t\tconst persistence = this._persistence;\n\t\tif (persistence === null) {\n\t\t\tthis._clearAllLiveState();\n\t\t\tclearAuxiliaryState?.();\n\t\t\treturn;\n\t\t}\n\t\tif (this._barrier === null) throw new AsyncResetRequiredError('all');\n\t\tawait this._barrier.withGlobalResetBarrier(async () => {\n\t\t\tawait persistence.clear();\n\t\t\tthis._clearAllLiveState();\n\t\t\tclearAuxiliaryState?.();\n\t\t});\n\t}\n\n\tprivate _replaceLiveSession(sessionId: SessionId, owner: string | undefined): void {\n\t\tthis._clearSessionStores(sessionId);\n\t\tthis._sessions.set(sessionId, this._createSessionState(owner));\n\t\tthis._logger.info('Session reset', { sessionId });\n\t}\n\n\tprivate _clearSessionStores(sessionId: SessionId): void {\n\t\tthis._edgeStore?.clearSession(sessionId);\n\t\tthis._summaryStore?.clearSession(sessionId);\n\t}\n\n\tprivate _clearAllLiveState(): void {\n\t\tthis._edgeStore?.clearAll();\n\t\tthis._summaryStore?.clearAll();\n\t\tthis._sessions.clear();\n\t\tthis._logger.info('History cleared (all sessions)');\n\t}\n}\n"],"names":["SessionResetCoordinator","config","sessionId","AsyncResetRequiredError","preservedOwner","clearAuxiliaryState","scopedPersistence","requireSessionScopedPersistence","persistence","owner"],"mappings":";;AAuBO,MAAMA;IACK,aAAwC;IACxC,SAA8B;IAC9B,WAAwB;IACxB,cAA8B;IAC9B,UAAwC;IACxC,oBAAiE;IACjE,QAAgB;IAEjC,YAAYC,MAAmD,CAAE;QAChE,IAAI,CAAC,YAAY,GAAGA,OAAO,WAAW;QACtC,IAAI,CAAC,QAAQ,GAAGA,OAAO,OAAO;QAC9B,IAAI,CAAC,UAAU,GAAGA,OAAO,SAAS;QAClC,IAAI,CAAC,aAAa,GAAGA,OAAO,YAAY;QACxC,IAAI,CAAC,SAAS,GAAGA,OAAO,QAAQ;QAChC,IAAI,CAAC,mBAAmB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vBH;QACD;IACD;IAEQ,oBAAoBH,SAAoB,EAAEO,KAAyB,EAAQ;QAClF,IAAI,CAAC,mBAAmB,CAACP;QACzB,IAAI,CAAC,SAAS,CAAC,GAAG,CAACA,WAAW,IAAI,CAAC,mBAAmB,CAACO;QACvD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB;YAAEP;QAAU;IAChD;IAEQ,oBAAoBA,SAAoB,EAAQ;QACvD,IAAI,CAAC,UAAU,EAAE,aAAaA;QAC9B,IAAI,CAAC,aAAa,EAAE,aAAaA;IAClC;IAEQ,qBAA2B;QAClC,IAAI,CAAC,UAAU,EAAE;QACjB,IAAI,CAAC,aAAa,EAAE;QACpB,IAAI,CAAC,SAAS,CAAC,KAAK;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IACnB;AACD"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Quality signal computation for sequential thinking.
3
+ *
4
+ * Thin facade that composes the extracted evaluator submodules
5
+ * ({@link SignalComputer}, {@link Aggregator}, {@link PatternDetector})
6
+ * to preserve the original {@link ThoughtEvaluator} public API.
7
+ *
8
+ * @module core/ThoughtEvaluator
9
+ */
10
+ import type { ICalibrator } from '../contracts/calibrator.js';
11
+ import { type SessionId } from '../contracts/ids.js';
12
+ import type { ConfidenceSignals, PatternSignal, ReasoningStats } from './reasoning.js';
13
+ import type { ThoughtData } from './thought.js';
14
+ /** Explicit thought and canonical session used for response calibration. */
15
+ export interface ConfidenceSignalContext {
16
+ readonly currentThought: ThoughtData;
17
+ readonly sessionId: SessionId;
18
+ }
19
+ /**
20
+ * Stateless service that computes quality signals and reasoning analytics
21
+ * from thought history and branch data.
22
+ *
23
+ * @remarks
24
+ * All methods are pure computations — no side effects, no I/O, no internal state.
25
+ * Designed to be registered as transient in the DI container.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const evaluator = new ThoughtEvaluator();
30
+ * const signals = evaluator.computeConfidenceSignals(history, branches);
31
+ * const stats = evaluator.computeReasoningStats(history, branches);
32
+ * const patterns = evaluator.computePatternSignals(history, branches);
33
+ * ```
34
+ */
35
+ export declare class ThoughtEvaluator {
36
+ private readonly _signalComputer;
37
+ private readonly _aggregator;
38
+ private readonly _patternDetector;
39
+ private readonly _calibrator;
40
+ constructor(calibrator?: ICalibrator);
41
+ /** Compute confidence signals from history context. Pure computation. */
42
+ computeConfidenceSignals(history: ThoughtData[], branches: Record<string, ThoughtData[]>, context?: ConfidenceSignalContext): ConfidenceSignals;
43
+ /** Compute aggregated reasoning analytics. Pure computation. */
44
+ computeReasoningStats(history: ThoughtData[], branches: Record<string, ThoughtData[]>): ReasoningStats;
45
+ /** Detect reasoning patterns (anti-patterns and positive signals). Pure computation. */
46
+ computePatternSignals(history: ThoughtData[], branches: Record<string, ThoughtData[]>): PatternSignal[];
47
+ }
48
+ //# sourceMappingURL=ThoughtEvaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThoughtEvaluator.d.ts","sourceRoot":"","sources":["../../src/core/ThoughtEvaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAGX,WAAW,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD,4EAA4E;AAC5E,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC9B;AAmDD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IACnD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;gBAE9B,UAAU,CAAC,EAAE,WAAW;IAOpC,yEAAyE;IAClE,wBAAwB,CAC9B,OAAO,EAAE,WAAW,EAAE,EACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,EACvC,OAAO,CAAC,EAAE,uBAAuB,GAC/B,iBAAiB;IAqBpB,gEAAgE;IACzD,qBAAqB,CAC3B,OAAO,EAAE,WAAW,EAAE,EACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,GACrC,cAAc;IAKjB,wFAAwF;IACjF,qBAAqB,CAC3B,OAAO,EAAE,WAAW,EAAE,EACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,GACrC,aAAa,EAAE;CAIlB"}
@@ -0,0 +1,85 @@
1
+ import { GLOBAL_SESSION_ID } from "../contracts/ids.js";
2
+ import { Aggregator } from "./evaluator/Aggregator.js";
3
+ import { PatternDetector } from "./evaluator/PatternDetector.js";
4
+ import { SignalComputer } from "./evaluator/SignalComputer.js";
5
+ class NoOpCalibrator {
6
+ enabled = false;
7
+ calibrate(rawConfidence, _type, _sessionId) {
8
+ const raw = Math.min(1, Math.max(0, rawConfidence));
9
+ return {
10
+ raw,
11
+ calibrated: raw,
12
+ temperature: 1.0,
13
+ priorWeight: 0
14
+ };
15
+ }
16
+ metrics(_sessionId) {
17
+ return {
18
+ brierScore: null,
19
+ ece: null,
20
+ sampleCount: 0,
21
+ perTypeBrier: {
22
+ regular: null,
23
+ hypothesis: null,
24
+ verification: null,
25
+ critique: null,
26
+ synthesis: null,
27
+ meta: null,
28
+ tool_call: null,
29
+ tool_observation: null,
30
+ assumption: null,
31
+ decomposition: null,
32
+ backtrack: null
33
+ }
34
+ };
35
+ }
36
+ refit(_sessionId) {}
37
+ clearSession(_sessionId) {}
38
+ clearAll() {}
39
+ }
40
+ class ThoughtEvaluator {
41
+ _signalComputer;
42
+ _aggregator;
43
+ _patternDetector;
44
+ _calibrator;
45
+ constructor(calibrator){
46
+ this._signalComputer = new SignalComputer();
47
+ this._aggregator = new Aggregator();
48
+ this._patternDetector = new PatternDetector();
49
+ this._calibrator = calibrator ?? new NoOpCalibrator();
50
+ }
51
+ computeConfidenceSignals(history, branches, context) {
52
+ const { history: h, branches: b } = filterRetracted(history, branches);
53
+ const signals = this._signalComputer.computeConfidenceSignals(h, b);
54
+ if (!this._calibrator.enabled) return signals;
55
+ const thought = context?.currentThought ?? h[h.length - 1];
56
+ if (thought?.confidence === void 0) return signals;
57
+ const sessionId = context?.sessionId ?? thought.session_id ?? GLOBAL_SESSION_ID;
58
+ const result = this._calibrator.calibrate(thought.confidence, thought.thought_type ?? 'regular', sessionId);
59
+ return {
60
+ ...signals,
61
+ calibrated_confidence: result.calibrated,
62
+ calibration_metrics: this._calibrator.metrics(sessionId)
63
+ };
64
+ }
65
+ computeReasoningStats(history, branches) {
66
+ const { history: h, branches: b } = filterRetracted(history, branches);
67
+ return this._aggregator.computeReasoningStats(h, b);
68
+ }
69
+ computePatternSignals(history, branches) {
70
+ const { history: h, branches: b } = filterRetracted(history, branches);
71
+ return this._patternDetector.computePatternSignals(h, b);
72
+ }
73
+ }
74
+ function filterRetracted(history, branches) {
75
+ const h = history.filter((t)=>!t.retracted);
76
+ const b = {};
77
+ for (const [id, list] of Object.entries(branches))b[id] = list.filter((t)=>!t.retracted);
78
+ return {
79
+ history: h,
80
+ branches: b
81
+ };
82
+ }
83
+ export { ThoughtEvaluator };
84
+
85
+ //# sourceMappingURL=ThoughtEvaluator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/ThoughtEvaluator.js","sources":["../../src/core/ThoughtEvaluator.ts"],"sourcesContent":["/**\n * Quality signal computation for sequential thinking.\n *\n * Thin facade that composes the extracted evaluator submodules\n * ({@link SignalComputer}, {@link Aggregator}, {@link PatternDetector})\n * to preserve the original {@link ThoughtEvaluator} public API.\n *\n * @module core/ThoughtEvaluator\n */\n\nimport type {\n\tCalibrationMetrics,\n\tCalibrationResult,\n\tICalibrator,\n} from '../contracts/calibrator.js';\nimport { GLOBAL_SESSION_ID, type SessionId } from '../contracts/ids.js';\nimport type { ConfidenceSignals, PatternSignal, ReasoningStats, ThoughtType } from './reasoning.js';\nimport type { ThoughtData } from './thought.js';\nimport { Aggregator } from './evaluator/Aggregator.js';\nimport { PatternDetector } from './evaluator/PatternDetector.js';\nimport { SignalComputer } from './evaluator/SignalComputer.js';\n\n/** Explicit thought and canonical session used for response calibration. */\nexport interface ConfidenceSignalContext {\n\treadonly currentThought: ThoughtData;\n\treadonly sessionId: SessionId;\n}\n\n/**\n * No-op calibrator used when calibration is disabled or no calibrator is injected.\n *\n * @remarks\n * Returns the raw confidence unchanged, exposes `enabled = false`, and reports\n * empty metrics. Keeps the {@link ThoughtEvaluator} constructor zero-arg compatible.\n */\nclass NoOpCalibrator implements ICalibrator {\n\tpublic readonly enabled = false;\n\n\tpublic calibrate(\n\t\trawConfidence: number,\n\t\t_type: ThoughtType,\n\t\t_sessionId: SessionId\n\t): CalibrationResult {\n\t\tconst raw = Math.min(1, Math.max(0, rawConfidence));\n\t\treturn { raw, calibrated: raw, temperature: 1.0, priorWeight: 0 };\n\t}\n\n\tpublic metrics(_sessionId?: SessionId): CalibrationMetrics {\n\t\treturn {\n\t\t\tbrierScore: null,\n\t\t\tece: null,\n\t\t\tsampleCount: 0,\n\t\t\tperTypeBrier: {\n\t\t\t\tregular: null,\n\t\t\t\thypothesis: null,\n\t\t\t\tverification: null,\n\t\t\t\tcritique: null,\n\t\t\t\tsynthesis: null,\n\t\t\t\tmeta: null,\n\t\t\t\ttool_call: null,\n\t\t\t\ttool_observation: null,\n\t\t\t\tassumption: null,\n\t\t\t\tdecomposition: null,\n\t\t\t\tbacktrack: null,\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic refit(_sessionId?: SessionId): void {\n\t\t// no-op\n\t}\n\n\tpublic clearSession(_sessionId: SessionId): void {}\n\n\tpublic clearAll(): void {}\n}\n\n/**\n * Stateless service that computes quality signals and reasoning analytics\n * from thought history and branch data.\n *\n * @remarks\n * All methods are pure computations — no side effects, no I/O, no internal state.\n * Designed to be registered as transient in the DI container.\n *\n * @example\n * ```typescript\n * const evaluator = new ThoughtEvaluator();\n * const signals = evaluator.computeConfidenceSignals(history, branches);\n * const stats = evaluator.computeReasoningStats(history, branches);\n * const patterns = evaluator.computePatternSignals(history, branches);\n * ```\n */\nexport class ThoughtEvaluator {\n\tprivate readonly _signalComputer: SignalComputer;\n\tprivate readonly _aggregator: Aggregator;\n\tprivate readonly _patternDetector: PatternDetector;\n\tprivate readonly _calibrator: ICalibrator;\n\n\tconstructor(calibrator?: ICalibrator) {\n\t\tthis._signalComputer = new SignalComputer();\n\t\tthis._aggregator = new Aggregator();\n\t\tthis._patternDetector = new PatternDetector();\n\t\tthis._calibrator = calibrator ?? new NoOpCalibrator();\n\t}\n\n\t/** Compute confidence signals from history context. Pure computation. */\n\tpublic computeConfidenceSignals(\n\t\thistory: ThoughtData[],\n\t\tbranches: Record<string, ThoughtData[]>,\n\t\tcontext?: ConfidenceSignalContext\n\t): ConfidenceSignals {\n\t\tconst { history: h, branches: b } = filterRetracted(history, branches);\n\t\tconst signals = this._signalComputer.computeConfidenceSignals(h, b);\n\t\tif (!this._calibrator.enabled) return signals;\n\n\t\tconst thought = context?.currentThought ?? h[h.length - 1];\n\t\tif (thought?.confidence === undefined) return signals;\n\t\tconst sessionId = context?.sessionId ?? thought.session_id ?? GLOBAL_SESSION_ID;\n\n\t\tconst result = this._calibrator.calibrate(\n\t\t\tthought.confidence,\n\t\t\tthought.thought_type ?? 'regular',\n\t\t\tsessionId\n\t\t);\n\t\treturn {\n\t\t\t...signals,\n\t\t\tcalibrated_confidence: result.calibrated,\n\t\t\tcalibration_metrics: this._calibrator.metrics(sessionId),\n\t\t};\n\t}\n\n\t/** Compute aggregated reasoning analytics. Pure computation. */\n\tpublic computeReasoningStats(\n\t\thistory: ThoughtData[],\n\t\tbranches: Record<string, ThoughtData[]>\n\t): ReasoningStats {\n\t\tconst { history: h, branches: b } = filterRetracted(history, branches);\n\t\treturn this._aggregator.computeReasoningStats(h, b);\n\t}\n\n\t/** Detect reasoning patterns (anti-patterns and positive signals). Pure computation. */\n\tpublic computePatternSignals(\n\t\thistory: ThoughtData[],\n\t\tbranches: Record<string, ThoughtData[]>\n\t): PatternSignal[] {\n\t\tconst { history: h, branches: b } = filterRetracted(history, branches);\n\t\treturn this._patternDetector.computePatternSignals(h, b);\n\t}\n}\n\n/**\n * Filters out logically retracted thoughts from history and branches.\n * Retracted thoughts remain in storage (event-sourcing) but are excluded\n * from quality signal calculations.\n */\nfunction filterRetracted(\n\thistory: ThoughtData[],\n\tbranches: Record<string, ThoughtData[]>\n): { history: ThoughtData[]; branches: Record<string, ThoughtData[]> } {\n\tconst h = history.filter((t) => !t.retracted);\n\tconst b: Record<string, ThoughtData[]> = {};\n\tfor (const [id, list] of Object.entries(branches)) {\n\t\tb[id] = list.filter((t) => !t.retracted);\n\t}\n\treturn { history: h, branches: b };\n}\n"],"names":["NoOpCalibrator","rawConfidence","_type","_sessionId","raw","Math","ThoughtEvaluator","calibrator","SignalComputer","Aggregator","PatternDetector","history","branches","context","h","b","filterRetracted","signals","thought","undefined","sessionId","GLOBAL_SESSION_ID","result","t","id","list","Object"],"mappings":";;;;AAmCA,MAAMA;IACW,UAAU,MAAM;IAEzB,UACNC,aAAqB,EACrBC,KAAkB,EAClBC,UAAqB,EACD;QACpB,MAAMC,MAAMC,KAAK,GAAG,CAAC,GAAGA,KAAK,GAAG,CAAC,GAAGJ;QACpC,OAAO;YAAEG;YAAK,YAAYA;YAAK,aAAa;YAAK,aAAa;QAAE;IACjE;IAEO,QAAQD,UAAsB,EAAsB;QAC1D,OAAO;YACN,YAAY;YACZ,KAAK;YACL,aAAa;YACb,cAAc;gBACb,SAAS;gBACT,YAAY;gBACZ,cAAc;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gBAAgBL,SAASC;QAC7D,OAAO,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAACE,GAAGC;IAClD;IAGO,sBACNJ,OAAsB,EACtBC,QAAuC,EACrB;QAClB,MAAM,EAAE,SAASE,CAAC,EAAE,UAAUC,CAAC,EAAE,GAAGC,gBAAgBL,SAASC;QAC7D,OAAO,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,CAACE,GAAGC;IACvD;AACD;AAOA,SAASC,gBACRL,OAAsB,EACtBC,QAAuC;IAEvC,MAAME,IAAIH,QAAQ,MAAM,CAAC,CAACY,IAAM,CAACA,EAAE,SAAS;IAC5C,MAAMR,IAAmC,CAAC;IAC1C,KAAK,MAAM,CAACS,IAAIC,KAAK,IAAIC,OAAO,OAAO,CAACd,UACvCG,CAAC,CAACS,GAAG,GAAGC,KAAK,MAAM,CAAC,CAACF,IAAM,CAACA,EAAE,SAAS;IAExC,OAAO;QAAE,SAAST;QAAG,UAAUC;IAAE;AAClC"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Display formatting for thoughts and recommendations.
3
+ *
4
+ * This module provides the `ThoughtFormatter` class which handles all
5
+ * presentation logic for thought data, including clean, simple output
6
+ * formatting and structured display of tool/skill recommendations.
7
+ *
8
+ * @module formatter
9
+ */
10
+ import type { IThoughtFormatter } from './IThoughtFormatter.js';
11
+ import type { StepRecommendation } from './step.js';
12
+ import type { ThoughtData } from './thought.js';
13
+ /**
14
+ * Formatter for thought data and step recommendations.
15
+ *
16
+ * This class separates presentation concerns from business logic, providing
17
+ * clean, readable output for thoughts with structured display of
18
+ * tool and skill recommendations.
19
+ *
20
+ * @remarks
21
+ * Output Format is clean and simple:
22
+ * - 💭 Thought - Regular thought (blue)
23
+ * - đŸ”Ŧ Hypothesis - Proposed explanation (magenta)
24
+ * - ✅ Verification - Testing a hypothesis (green)
25
+ * - 🔍 Critique - Self-critique of reasoning (red)
26
+ * - đŸ§Ŧ Synthesis - Combining thoughts/branches (cyan)
27
+ * - 🧠 Meta - Metacognitive observation (gray)
28
+ * - 🔄 Revision - Thought that revises a previous thought (yellow)
29
+ * - đŸŒŋ Branch - Thought that creates a new branch (green)
30
+ * @example
31
+ * ```typescript
32
+ * const formatter = new ThoughtFormatter();
33
+ *
34
+ * // Format a thought with recommendations
35
+ * const output = formatter.formatThought({
36
+ * thought: 'I need to analyze the data structure',
37
+ * thought_number: 1,
38
+ * total_thoughts: 3,
39
+ * next_thought_needed: true,
40
+ * current_step: {
41
+ * step_description: 'Analyze data structure',
42
+ * recommended_tools: [{
43
+ * tool_name: 'Read',
44
+ * confidence: 0.95,
45
+ * rationale: 'Direct file reading',
46
+ * priority: 1,
47
+ * suggested_inputs: { file_path: './data/schema.json' }
48
+ * }],
49
+ * expected_outcome: 'Understanding of data schema'
50
+ * }
51
+ * });
52
+ *
53
+ * console.log(output);
54
+ * ```
55
+ */
56
+ export declare class ThoughtFormatter implements IThoughtFormatter {
57
+ /**
58
+ * Formats a step recommendation into a readable string.
59
+ *
60
+ * Creates a structured display of the step description, recommended tools,
61
+ * recommended skills, expected outcome, and conditions for the next step.
62
+ *
63
+ * @param step - The step recommendation to format
64
+ * @returns A formatted string representation of the recommendation
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const step: StepRecommendation = {
69
+ * step_description: 'Search for API endpoints',
70
+ * recommended_tools: [{
71
+ * tool_name: 'Grep',
72
+ * confidence: 0.9,
73
+ * rationale: 'Best for searching code patterns',
74
+ * priority: 1,
75
+ * suggested_inputs: { pattern: 'export.*function' }
76
+ * }],
77
+ * expected_outcome: 'List of all exported API functions',
78
+ * next_step_conditions: ['If no results, try broader pattern']
79
+ * };
80
+ *
81
+ * const formatted = formatter.formatRecommendation(step);
82
+ * console.log(formatted);
83
+ * ```
84
+ */
85
+ formatRecommendation(step: StepRecommendation): string;
86
+ /**
87
+ * Formats a thought into a clean, simple display.
88
+ *
89
+ * Creates a clean output containing the thought content with an appropriate
90
+ * header indicating the thought type. Priority order for icon selection:
91
+ * `is_revision` > `branch_from_thought` > `thought_type`.
92
+ *
93
+ * Supported `thought_type` icons:
94
+ * - `'regular'` (or undefined): 💭 blue "Thought" (default)
95
+ * - `'hypothesis'`: đŸ”Ŧ magenta "Hypothesis"
96
+ * - `'verification'`: ✅ green "Verification"
97
+ * - `'critique'`: 🔍 red "Critique"
98
+ * - `'synthesis'`: đŸ§Ŧ cyan "Synthesis"
99
+ * - `'meta'`: 🧠 gray "Meta"
100
+ *
101
+ * @param thoughtData - The thought data to format
102
+ * @returns A formatted string with thought and recommendations
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * // Regular thought
107
+ * const regular = formatter.formatThought({
108
+ * thought: 'I should read the configuration file',
109
+ * thought_number: 1,
110
+ * total_thoughts: 3,
111
+ * next_thought_needed: true
112
+ * });
113
+ * // Output: 💭 Thought 1/3: I should read the configuration file
114
+ *
115
+ * // With recommendation
116
+ * const withRec = formatter.formatThought({
117
+ * thought: 'I need to search the codebase',
118
+ * thought_number: 1,
119
+ * total_thoughts: 3,
120
+ * next_thought_needed: true,
121
+ * current_step: {
122
+ * step_description: 'Search for files',
123
+ * recommended_tools: [{ tool_name: 'Grep', priority: 1 }],
124
+ * expected_outcome: 'List of matching files'
125
+ * }
126
+ * });
127
+ * // Output:
128
+ * // 💭 Thought 1/3: I need to search the codebase
129
+ * // → Tools: Grep | List of matching files
130
+ * ```
131
+ */
132
+ formatThought(thoughtData: ThoughtData): string;
133
+ }
134
+ //# sourceMappingURL=ThoughtFormatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThoughtFormatter.d.ts","sourceRoot":"","sources":["../../src/core/ThoughtFormatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAShD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;IACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACI,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM;IAuB7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACI,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM;CAsCtD"}
@@ -0,0 +1,118 @@
1
+ import chalk from "chalk";
2
+ import { assertNever } from "../utils.js";
3
+ class ThoughtFormatter {
4
+ formatRecommendation(step) {
5
+ const parts = [];
6
+ if (step.recommended_tools?.length) {
7
+ const toolNames = step.recommended_tools.map((t)=>t.tool_name).join(', ');
8
+ parts.push(chalk.cyan(`Tools: ${toolNames}`));
9
+ }
10
+ if (step.recommended_skills?.length) {
11
+ const skillNames = step.recommended_skills.map((s)=>s.skill_name).join(', ');
12
+ parts.push(chalk.green(`Skills: ${skillNames}`));
13
+ }
14
+ if (step.expected_outcome) parts.push(chalk.gray(`→ ${step.expected_outcome}`));
15
+ return parts.join(' | ');
16
+ }
17
+ formatThought(thoughtData) {
18
+ const { thought_number, total_thoughts, thought, current_step } = thoughtData;
19
+ const { icon, label, suffix } = resolveThoughtDisplay(thoughtData);
20
+ const retractedTag = thoughtData.retracted ? chalk.red.strikethrough('[RETRACTED] ') : '';
21
+ const header = `${icon} ${label} ${thought_number}/${total_thoughts}${suffix}: ${retractedTag}`;
22
+ const lines = [];
23
+ lines.push(`${header}${thought}`);
24
+ if (current_step) {
25
+ const recommendation = this.formatRecommendation(current_step);
26
+ lines.push(` ${recommendation}`);
27
+ }
28
+ if (thoughtData.id) lines.push(` ${chalk.gray(`🆔 ${thoughtData.id}`)}`);
29
+ if (thoughtData.meta_observation) lines.push(` ${chalk.gray(`📝 ${thoughtData.meta_observation}`)}`);
30
+ return lines.join('\n');
31
+ }
32
+ }
33
+ function resolveThoughtDisplay(thoughtData) {
34
+ if (thoughtData.is_revision) return {
35
+ icon: chalk.yellow('🔄'),
36
+ label: 'Revision',
37
+ suffix: chalk.gray(` (revise #${thoughtData.revises_thought})`)
38
+ };
39
+ if (thoughtData.branch_from_thought) return {
40
+ icon: chalk.green('đŸŒŋ'),
41
+ label: 'Branch',
42
+ suffix: chalk.gray(` (from #${thoughtData.branch_from_thought})`)
43
+ };
44
+ const thoughtType = thoughtData.thought_type ?? 'regular';
45
+ switch(thoughtType){
46
+ case 'hypothesis':
47
+ return {
48
+ icon: chalk.magenta('đŸ”Ŧ'),
49
+ label: 'Hypothesis',
50
+ suffix: ''
51
+ };
52
+ case 'verification':
53
+ return {
54
+ icon: chalk.green('✅'),
55
+ label: 'Verification',
56
+ suffix: ''
57
+ };
58
+ case 'critique':
59
+ return {
60
+ icon: chalk.red('🔍'),
61
+ label: 'Critique',
62
+ suffix: ''
63
+ };
64
+ case 'synthesis':
65
+ return {
66
+ icon: chalk.cyan('đŸ§Ŧ'),
67
+ label: 'Synthesis',
68
+ suffix: ''
69
+ };
70
+ case 'meta':
71
+ return {
72
+ icon: chalk.gray('🧠'),
73
+ label: 'Meta',
74
+ suffix: ''
75
+ };
76
+ case 'tool_call':
77
+ return {
78
+ icon: chalk.yellow('🔧'),
79
+ label: 'Tool Call',
80
+ suffix: ''
81
+ };
82
+ case 'tool_observation':
83
+ return {
84
+ icon: chalk.yellow('đŸ‘ī¸'),
85
+ label: 'Tool Observation',
86
+ suffix: ''
87
+ };
88
+ case 'assumption':
89
+ return {
90
+ icon: chalk.yellow('💡'),
91
+ label: 'Assumption',
92
+ suffix: ''
93
+ };
94
+ case 'decomposition':
95
+ return {
96
+ icon: chalk.cyan('🧩'),
97
+ label: 'Decomposition',
98
+ suffix: ''
99
+ };
100
+ case 'backtrack':
101
+ return {
102
+ icon: chalk.red('â†Šī¸'),
103
+ label: 'Backtrack',
104
+ suffix: ''
105
+ };
106
+ case 'regular':
107
+ return {
108
+ icon: chalk.blue('💭'),
109
+ label: 'Thought',
110
+ suffix: ''
111
+ };
112
+ default:
113
+ assertNever(thoughtType);
114
+ }
115
+ }
116
+ export { ThoughtFormatter };
117
+
118
+ //# sourceMappingURL=ThoughtFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/ThoughtFormatter.js","sources":["../../src/core/ThoughtFormatter.ts"],"sourcesContent":["/**\n * Display formatting for thoughts and recommendations.\n *\n * This module provides the `ThoughtFormatter` class which handles all\n * presentation logic for thought data, including clean, simple output\n * formatting and structured display of tool/skill recommendations.\n *\n * @module formatter\n */\n\nimport chalk from 'chalk';\nimport type { IThoughtFormatter } from './IThoughtFormatter.js';\nimport type { ThoughtType } from './reasoning.js';\nimport type { StepRecommendation } from './step.js';\nimport type { ThoughtData } from './thought.js';\nimport { assertNever } from '../utils.js';\n\ntype ThoughtDisplay = {\n\treadonly icon: string;\n\treadonly label: string;\n\treadonly suffix: string;\n};\n\n/**\n * Formatter for thought data and step recommendations.\n *\n * This class separates presentation concerns from business logic, providing\n * clean, readable output for thoughts with structured display of\n * tool and skill recommendations.\n *\n * @remarks\n * Output Format is clean and simple:\n * - 💭 Thought - Regular thought (blue)\n * - đŸ”Ŧ Hypothesis - Proposed explanation (magenta)\n * - ✅ Verification - Testing a hypothesis (green)\n * - 🔍 Critique - Self-critique of reasoning (red)\n * - đŸ§Ŧ Synthesis - Combining thoughts/branches (cyan)\n * - 🧠 Meta - Metacognitive observation (gray)\n * - 🔄 Revision - Thought that revises a previous thought (yellow)\n * - đŸŒŋ Branch - Thought that creates a new branch (green)\n * @example\n * ```typescript\n * const formatter = new ThoughtFormatter();\n *\n * // Format a thought with recommendations\n * const output = formatter.formatThought({\n * thought: 'I need to analyze the data structure',\n * thought_number: 1,\n * total_thoughts: 3,\n * next_thought_needed: true,\n * current_step: {\n * step_description: 'Analyze data structure',\n * recommended_tools: [{\n * tool_name: 'Read',\n * confidence: 0.95,\n * rationale: 'Direct file reading',\n * priority: 1,\n * suggested_inputs: { file_path: './data/schema.json' }\n * }],\n * expected_outcome: 'Understanding of data schema'\n * }\n * });\n *\n * console.log(output);\n * ```\n */\nexport class ThoughtFormatter implements IThoughtFormatter {\n\t/**\n\t * Formats a step recommendation into a readable string.\n\t *\n\t * Creates a structured display of the step description, recommended tools,\n\t * recommended skills, expected outcome, and conditions for the next step.\n\t *\n\t * @param step - The step recommendation to format\n\t * @returns A formatted string representation of the recommendation\n\t *\n\t * @example\n\t * ```typescript\n\t * const step: StepRecommendation = {\n\t * step_description: 'Search for API endpoints',\n\t * recommended_tools: [{\n\t * tool_name: 'Grep',\n\t * confidence: 0.9,\n\t * rationale: 'Best for searching code patterns',\n\t * priority: 1,\n\t * suggested_inputs: { pattern: 'export.*function' }\n\t * }],\n\t * expected_outcome: 'List of all exported API functions',\n\t * next_step_conditions: ['If no results, try broader pattern']\n\t * };\n\t *\n\t * const formatted = formatter.formatRecommendation(step);\n\t * console.log(formatted);\n\t * ```\n\t */\n\tpublic formatRecommendation(step: StepRecommendation): string {\n\t\tconst parts: string[] = [];\n\n\t\t// Add tools if present\n\t\tif (step.recommended_tools?.length) {\n\t\t\tconst toolNames = step.recommended_tools.map((t) => t.tool_name).join(', ');\n\t\t\tparts.push(chalk.cyan(`Tools: ${toolNames}`));\n\t\t}\n\n\t\t// Add skills if present\n\t\tif (step.recommended_skills?.length) {\n\t\t\tconst skillNames = step.recommended_skills.map((s) => s.skill_name).join(', ');\n\t\t\tparts.push(chalk.green(`Skills: ${skillNames}`));\n\t\t}\n\n\t\t// Add expected outcome\n\t\tif (step.expected_outcome) {\n\t\t\tparts.push(chalk.gray(`→ ${step.expected_outcome}`));\n\t\t}\n\n\t\treturn parts.join(' | ');\n\t}\n\n\t/**\n\t * Formats a thought into a clean, simple display.\n\t *\n\t * Creates a clean output containing the thought content with an appropriate\n\t * header indicating the thought type. Priority order for icon selection:\n\t * `is_revision` > `branch_from_thought` > `thought_type`.\n\t *\n\t * Supported `thought_type` icons:\n\t * - `'regular'` (or undefined): 💭 blue \"Thought\" (default)\n\t * - `'hypothesis'`: đŸ”Ŧ magenta \"Hypothesis\"\n\t * - `'verification'`: ✅ green \"Verification\"\n\t * - `'critique'`: 🔍 red \"Critique\"\n\t * - `'synthesis'`: đŸ§Ŧ cyan \"Synthesis\"\n\t * - `'meta'`: 🧠 gray \"Meta\"\n\t *\n\t * @param thoughtData - The thought data to format\n\t * @returns A formatted string with thought and recommendations\n\t *\n\t * @example\n\t * ```typescript\n\t * // Regular thought\n\t * const regular = formatter.formatThought({\n\t * thought: 'I should read the configuration file',\n\t * thought_number: 1,\n\t * total_thoughts: 3,\n\t * next_thought_needed: true\n\t * });\n\t * // Output: 💭 Thought 1/3: I should read the configuration file\n\t *\n\t * // With recommendation\n\t * const withRec = formatter.formatThought({\n\t * thought: 'I need to search the codebase',\n\t * thought_number: 1,\n\t * total_thoughts: 3,\n\t * next_thought_needed: true,\n\t * current_step: {\n\t * step_description: 'Search for files',\n\t * recommended_tools: [{ tool_name: 'Grep', priority: 1 }],\n\t * expected_outcome: 'List of matching files'\n\t * }\n\t * });\n\t * // Output:\n\t * // 💭 Thought 1/3: I need to search the codebase\n\t * // → Tools: Grep | List of matching files\n\t * ```\n\t */\n\tpublic formatThought(thoughtData: ThoughtData): string {\n\t\tconst {\n\t\t\tthought_number,\n\t\t\ttotal_thoughts,\n\t\t\tthought,\n\t\t\tcurrent_step,\n\t\t} = thoughtData;\n\n\t\tconst { icon, label, suffix } = resolveThoughtDisplay(thoughtData);\n\n\t\t// Build header: \"💭 Thought 1/3: \"\n\t\tconst retractedTag = thoughtData.retracted ? chalk.red.strikethrough('[RETRACTED] ') : '';\n\t\tconst header = `${icon} ${label} ${thought_number}/${total_thoughts}${suffix}: ${retractedTag}`;\n\n\t\t// Build content lines\n\t\tconst lines: string[] = [];\n\n\t\t// Add the thought content\n\t\tlines.push(`${header}${thought}`);\n\n\t\t// Add recommendation if present\n\t\tif (current_step) {\n\t\t\tconst recommendation = this.formatRecommendation(current_step);\n\t\t\tlines.push(` ${recommendation}`);\n\t\t}\n\n\t\t// Add id if present (for DAG debugging)\n\t\tif (thoughtData.id) {\n\t\t\tlines.push(` ${chalk.gray(`🆔 ${thoughtData.id}`)}`);\n\t\t}\n\n\t\t// Add meta observation if present\n\t\tif (thoughtData.meta_observation) {\n\t\t\tlines.push(` ${chalk.gray(`📝 ${thoughtData.meta_observation}`)}`);\n\t\t}\n\n\t\treturn lines.join('\\n');\n\t}\n}\n\nfunction resolveThoughtDisplay(thoughtData: ThoughtData): ThoughtDisplay {\n\tif (thoughtData.is_revision) {\n\t\treturn {\n\t\t\ticon: chalk.yellow('🔄'),\n\t\t\tlabel: 'Revision',\n\t\t\tsuffix: chalk.gray(` (revise #${thoughtData.revises_thought})`),\n\t\t};\n\t}\n\n\tif (thoughtData.branch_from_thought) {\n\t\treturn {\n\t\t\ticon: chalk.green('đŸŒŋ'),\n\t\t\tlabel: 'Branch',\n\t\t\tsuffix: chalk.gray(` (from #${thoughtData.branch_from_thought})`),\n\t\t};\n\t}\n\n\tconst thoughtType: ThoughtType = thoughtData.thought_type ?? 'regular';\n\tswitch (thoughtType) {\n\t\tcase 'hypothesis':\n\t\t\treturn { icon: chalk.magenta('đŸ”Ŧ'), label: 'Hypothesis', suffix: '' };\n\t\tcase 'verification':\n\t\t\treturn { icon: chalk.green('✅'), label: 'Verification', suffix: '' };\n\t\tcase 'critique':\n\t\t\treturn { icon: chalk.red('🔍'), label: 'Critique', suffix: '' };\n\t\tcase 'synthesis':\n\t\t\treturn { icon: chalk.cyan('đŸ§Ŧ'), label: 'Synthesis', suffix: '' };\n\t\tcase 'meta':\n\t\t\treturn { icon: chalk.gray('🧠'), label: 'Meta', suffix: '' };\n\t\tcase 'tool_call':\n\t\t\treturn { icon: chalk.yellow('🔧'), label: 'Tool Call', suffix: '' };\n\t\tcase 'tool_observation':\n\t\t\treturn { icon: chalk.yellow('đŸ‘ī¸'), label: 'Tool Observation', suffix: '' };\n\t\tcase 'assumption':\n\t\t\treturn { icon: chalk.yellow('💡'), label: 'Assumption', suffix: '' };\n\t\tcase 'decomposition':\n\t\t\treturn { icon: chalk.cyan('🧩'), label: 'Decomposition', suffix: '' };\n\t\tcase 'backtrack':\n\t\t\treturn { icon: chalk.red('â†Šī¸'), label: 'Backtrack', suffix: '' };\n\t\tcase 'regular':\n\t\t\treturn { icon: chalk.blue('💭'), label: 'Thought', suffix: '' };\n\t\tdefault:\n\t\t\tassertNever(thoughtType);\n\t}\n}\n"],"names":["ThoughtFormatter","step","parts","toolNames","t","chalk","skillNames","s","thoughtData","thought_number","total_thoughts","thought","current_step","icon","label","suffix","resolveThoughtDisplay","retractedTag","header","lines","recommendation","thoughtType","assertNever"],"mappings":";;AAkEO,MAAMA;IA6BL,qBAAqBC,IAAwB,EAAU;QAC7D,MAAMC,QAAkB,EAAE;QAG1B,IAAID,KAAK,iBAAiB,EAAE,QAAQ;YACnC,MAAME,YAAYF,KAAK,iBAAiB,CAAC,GAAG,CAAC,CAACG,IAAMA,EAAE,SAAS,EAAE,IAAI,CAAC;YACtEF,MAAM,IAAI,CAACG,MAAM,IAAI,CAAC,CAAC,OAAO,EAAEF,WAAW;QAC5C;QAGA,IAAIF,KAAK,kBAAkB,EAAE,QAAQ;YACpC,MAAMK,aAAaL,KAAK,kBAAkB,CAAC,GAAG,CAAC,CAACM,IAAMA,EAAE,UAAU,EAAE,IAAI,CAAC;YACzEL,MAAM,IAAI,CAACG,MAAM,KAAK,CAAC,CAAC,QAAQ,EAAEC,YAAY;QAC/C;QAGA,IAAIL,KAAK,gBAAgB,EACxBC,MAAM,IAAI,CAACG,MAAM,IAAI,CAAC,CAAC,EAAE,EAAEJ,KAAK,gBAAgB,EAAE;QAGnD,OAAOC,MAAM,IAAI,CAAC;IACnB;IAgDO,cAAcM,WAAwB,EAAU;QACtD,MAAM,EACLC,cAAc,EACdC,cAAc,EACdC,OAAO,EACPC,YAAY,EACZ,GAAGJ;QAEJ,MAAM,EAAEK,IAAI,EAAEC,KAAK,EAAEC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