@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,157 @@
1
+ /**
2
+ * GraphView — read-only graph traversal queries over an {@link IEdgeStore}.
3
+ *
4
+ * Provides BFS / topological / ancestor / descendant queries over the
5
+ * thought DAG. All methods return arrays of thought ids (ulid strings),
6
+ * never `ThoughtData` objects — the view is intentionally decoupled from
7
+ * `HistoryManager` so it can be reused by strategies that work purely in
8
+ * terms of graph structure.
9
+ *
10
+ * Construction is cheap (stores a reference to the underlying store).
11
+ * Each query reads the latest store state — no caching, no snapshots.
12
+ *
13
+ * @module core/graph/GraphView
14
+ */
15
+ import type { IEdgeStore } from '../../contracts/interfaces.js';
16
+ import type { SessionId, ThoughtId } from '../../contracts/ids.js';
17
+ /**
18
+ * Read-only traversal queries over an {@link IEdgeStore}.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const store = new EdgeStore();
23
+ * // ... populate store ...
24
+ * const view = new GraphView(store);
25
+ * const order = view.topological('s1');
26
+ * ```
27
+ */
28
+ export declare class GraphView {
29
+ private readonly _store;
30
+ /**
31
+ * Create a new GraphView backed by the given edge store.
32
+ *
33
+ * @param store - The edge store to query (held by reference, read-only access)
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const view = new GraphView(edgeStore);
38
+ * ```
39
+ */
40
+ constructor(store: IEdgeStore);
41
+ /**
42
+ * Return all thought ids in the session, ordered by BFS from roots.
43
+ *
44
+ * Roots are nodes with no incoming edges. Within a layer, neighbours
45
+ * are visited in `outgoing` order (which the underlying store keeps
46
+ * sorted by `createdAt` ascending).
47
+ *
48
+ * @param sessionId - Session to query
49
+ * @returns Thought ids in chronological BFS order
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const ids = view.chronological('s1');
54
+ * ```
55
+ */
56
+ chronological(sessionId: SessionId): readonly ThoughtId[];
57
+ /**
58
+ * Return all thought ids reachable from `rootThoughtId` via `'branch'`
59
+ * edges, including the root itself.
60
+ *
61
+ * Non-branch edges are ignored. Cycles (if any) do not cause infinite
62
+ * loops because each node is visited at most once.
63
+ *
64
+ * @param sessionId - Session to query
65
+ * @param rootThoughtId - The starting thought id (typically the branch root)
66
+ * @returns Thought ids forming the branch (includes root)
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const branchIds = view.branchThoughts('s1', 'thought-root');
71
+ * ```
72
+ */
73
+ branchThoughts(sessionId: SessionId, rootThoughtId: ThoughtId): readonly ThoughtId[];
74
+ /**
75
+ * Return a topological ordering of all thought ids in the session
76
+ * using Kahn's algorithm.
77
+ *
78
+ * @param sessionId - Session to query
79
+ * @returns Thought ids in topological order
80
+ * @throws {CycleDetectedError} If the graph contains a cycle
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const order = view.topological('s1');
85
+ * ```
86
+ */
87
+ topological(sessionId: SessionId): readonly ThoughtId[];
88
+ /**
89
+ * Return all ancestors of `thoughtId` via incoming-edge BFS.
90
+ *
91
+ * The starting node is NOT included. Cycles do not cause infinite loops.
92
+ *
93
+ * @param sessionId - Session to query
94
+ * @param thoughtId - The thought to traverse from
95
+ * @param maxDepth - Optional maximum traversal depth (1 = direct parents only)
96
+ * @returns Ancestor thought ids in BFS order
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const parents = view.ancestors('s1', 'thought-id', 1);
101
+ * ```
102
+ */
103
+ ancestors(sessionId: SessionId, thoughtId: ThoughtId, maxDepth?: number): readonly ThoughtId[];
104
+ /**
105
+ * Return all descendants of `thoughtId` via outgoing-edge BFS.
106
+ *
107
+ * The starting node is NOT included. Cycles do not cause infinite loops.
108
+ *
109
+ * @param sessionId - Session to query
110
+ * @param thoughtId - The thought to traverse from
111
+ * @param maxDepth - Optional maximum traversal depth (1 = direct children only)
112
+ * @returns Descendant thought ids in BFS order
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const children = view.descendants('s1', 'thought-id');
117
+ * ```
118
+ */
119
+ descendants(sessionId: SessionId, thoughtId: ThoughtId, maxDepth?: number): readonly ThoughtId[];
120
+ /**
121
+ * Return all thought ids in the session that have no outgoing edges.
122
+ *
123
+ * @param sessionId - Session to query
124
+ * @returns Thought ids that are graph leaves
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * const tips = view.leaves('s1');
129
+ * ```
130
+ */
131
+ leaves(sessionId: SessionId): readonly ThoughtId[];
132
+ /**
133
+ * Collect every node id referenced by the edges and a set of nodes
134
+ * that have at least one incoming edge.
135
+ */
136
+ private _collectNodes;
137
+ /**
138
+ * Find roots (no incoming) ordered by the earliest outgoing edge
139
+ * `createdAt`. Nodes with no outgoing edges fall back to the order
140
+ * they appear among edges (already sorted by `createdAt`).
141
+ */
142
+ private _findRoots;
143
+ /**
144
+ * BFS from a list of root ids, visiting each node at most once.
145
+ */
146
+ private _bfsFromRoots;
147
+ /**
148
+ * Build an in-degree map covering every node referenced by the edges.
149
+ */
150
+ private _buildInDegree;
151
+ /**
152
+ * Generic BFS closure in either direction. Excludes the start node
153
+ * from the result and respects an optional depth cap.
154
+ */
155
+ private _bfsClosure;
156
+ }
157
+ //# sourceMappingURL=GraphView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphView.d.ts","sourceRoot":"","sources":["../../../src/core/graph/GraphView.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInE;;;;;;;;;;GAUG;AACH,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IAEpC;;;;;;;;;OASG;gBACS,KAAK,EAAE,UAAU;IAI7B;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE;IAUzD;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE;IAkBpF;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE;IA4BvD;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE;IAI9F;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE;IAIhG;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE;IAelD;;;OAGG;IACH,OAAO,CAAC,aAAa;IAcrB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAmBlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAsBrB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;;OAGG;IACH,OAAO,CAAC,WAAW;CA+BnB"}
@@ -0,0 +1,149 @@
1
+ import { CycleDetectedError } from "../../errors.js";
2
+ class GraphView {
3
+ _store;
4
+ constructor(store){
5
+ this._store = store;
6
+ }
7
+ chronological(sessionId) {
8
+ const edges = this._store.edgesForSession(sessionId);
9
+ if (0 === edges.length) return [];
10
+ const { nodes, hasIncoming } = this._collectNodes(edges);
11
+ const roots = this._findRoots(nodes, hasIncoming, edges);
12
+ return this._bfsFromRoots(sessionId, roots);
13
+ }
14
+ branchThoughts(sessionId, rootThoughtId) {
15
+ const visited = new Set([
16
+ rootThoughtId
17
+ ]);
18
+ const order = [
19
+ rootThoughtId
20
+ ];
21
+ const queue = [
22
+ rootThoughtId
23
+ ];
24
+ while(queue.length > 0){
25
+ const current = queue.shift();
26
+ const out = this._store.outgoing(sessionId, current);
27
+ for (const edge of out)if ('branch' === edge.kind) {
28
+ if (!visited.has(edge.to)) {
29
+ visited.add(edge.to);
30
+ order.push(edge.to);
31
+ queue.push(edge.to);
32
+ }
33
+ }
34
+ }
35
+ return order;
36
+ }
37
+ topological(sessionId) {
38
+ const edges = this._store.edgesForSession(sessionId);
39
+ if (0 === edges.length) return [];
40
+ const inDegree = this._buildInDegree(edges);
41
+ const queue = [];
42
+ for (const [node, deg] of inDegree)if (0 === deg) queue.push(node);
43
+ const order = [];
44
+ while(queue.length > 0){
45
+ const node = queue.shift();
46
+ order.push(node);
47
+ for (const edge of this._store.outgoing(sessionId, node)){
48
+ const next = (inDegree.get(edge.to) ?? 0) - 1;
49
+ inDegree.set(edge.to, next);
50
+ if (0 === next) queue.push(edge.to);
51
+ }
52
+ }
53
+ if (order.length !== inDegree.size) throw new CycleDetectedError(`Cycle detected in session '${sessionId}': topological sort incomplete (${order.length}/${inDegree.size})`);
54
+ return order;
55
+ }
56
+ ancestors(sessionId, thoughtId, maxDepth) {
57
+ return this._bfsClosure(sessionId, thoughtId, maxDepth, 'incoming');
58
+ }
59
+ descendants(sessionId, thoughtId, maxDepth) {
60
+ return this._bfsClosure(sessionId, thoughtId, maxDepth, 'outgoing');
61
+ }
62
+ leaves(sessionId) {
63
+ const edges = this._store.edgesForSession(sessionId);
64
+ if (0 === edges.length) return [];
65
+ const { nodes } = this._collectNodes(edges);
66
+ const result = [];
67
+ for (const node of nodes)if (0 === this._store.outgoing(sessionId, node).length) result.push(node);
68
+ return result;
69
+ }
70
+ _collectNodes(edges) {
71
+ const nodes = new Set();
72
+ const hasIncoming = new Set();
73
+ for (const edge of edges){
74
+ nodes.add(edge.from);
75
+ nodes.add(edge.to);
76
+ hasIncoming.add(edge.to);
77
+ }
78
+ return {
79
+ nodes,
80
+ hasIncoming
81
+ };
82
+ }
83
+ _findRoots(nodes, hasIncoming, edges) {
84
+ const earliest = new Map();
85
+ for (const edge of edges)if (!earliest.has(edge.from)) earliest.set(edge.from, edge.createdAt);
86
+ const roots = [];
87
+ for (const node of nodes)if (!hasIncoming.has(node)) roots.push(node);
88
+ roots.sort((a, b)=>(earliest.get(a) ?? 1 / 0) - (earliest.get(b) ?? 1 / 0));
89
+ return roots;
90
+ }
91
+ _bfsFromRoots(sessionId, roots) {
92
+ const visited = new Set();
93
+ const order = [];
94
+ const queue = [];
95
+ for (const root of roots)if (!visited.has(root)) {
96
+ visited.add(root);
97
+ order.push(root);
98
+ queue.push(root);
99
+ }
100
+ while(queue.length > 0){
101
+ const node = queue.shift();
102
+ for (const edge of this._store.outgoing(sessionId, node))if (!visited.has(edge.to)) {
103
+ visited.add(edge.to);
104
+ order.push(edge.to);
105
+ queue.push(edge.to);
106
+ }
107
+ }
108
+ return order;
109
+ }
110
+ _buildInDegree(edges) {
111
+ const inDegree = new Map();
112
+ for (const edge of edges){
113
+ if (!inDegree.has(edge.from)) inDegree.set(edge.from, 0);
114
+ inDegree.set(edge.to, (inDegree.get(edge.to) ?? 0) + 1);
115
+ }
116
+ return inDegree;
117
+ }
118
+ _bfsClosure(sessionId, startId, maxDepth, direction) {
119
+ const cap = maxDepth ?? 1 / 0;
120
+ const visited = new Set([
121
+ startId
122
+ ]);
123
+ const order = [];
124
+ let frontier = [
125
+ startId
126
+ ];
127
+ let depth = 0;
128
+ while(frontier.length > 0 && depth < cap){
129
+ const next = [];
130
+ for (const node of frontier){
131
+ const edges = 'outgoing' === direction ? this._store.outgoing(sessionId, node) : this._store.incoming(sessionId, node);
132
+ for (const edge of edges){
133
+ const neighbour = 'outgoing' === direction ? edge.to : edge.from;
134
+ if (!visited.has(neighbour)) {
135
+ visited.add(neighbour);
136
+ order.push(neighbour);
137
+ next.push(neighbour);
138
+ }
139
+ }
140
+ }
141
+ frontier = next;
142
+ depth++;
143
+ }
144
+ return order;
145
+ }
146
+ }
147
+ export { GraphView };
148
+
149
+ //# sourceMappingURL=GraphView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/graph/GraphView.js","sources":["../../../src/core/graph/GraphView.ts"],"sourcesContent":["/**\n * GraphView — read-only graph traversal queries over an {@link IEdgeStore}.\n *\n * Provides BFS / topological / ancestor / descendant queries over the\n * thought DAG. All methods return arrays of thought ids (ulid strings),\n * never `ThoughtData` objects — the view is intentionally decoupled from\n * `HistoryManager` so it can be reused by strategies that work purely in\n * terms of graph structure.\n *\n * Construction is cheap (stores a reference to the underlying store).\n * Each query reads the latest store state — no caching, no snapshots.\n *\n * @module core/graph/GraphView\n */\n\nimport type { IEdgeStore } from '../../contracts/interfaces.js';\nimport type { SessionId, ThoughtId } from '../../contracts/ids.js';\nimport { CycleDetectedError } from '../../errors.js';\nimport type { Edge } from './Edge.js';\n\n/**\n * Read-only traversal queries over an {@link IEdgeStore}.\n *\n * @example\n * ```typescript\n * const store = new EdgeStore();\n * // ... populate store ...\n * const view = new GraphView(store);\n * const order = view.topological('s1');\n * ```\n */\nexport class GraphView {\n\tprivate readonly _store: IEdgeStore;\n\n\t/**\n\t * Create a new GraphView backed by the given edge store.\n\t *\n\t * @param store - The edge store to query (held by reference, read-only access)\n\t *\n\t * @example\n\t * ```typescript\n\t * const view = new GraphView(edgeStore);\n\t * ```\n\t */\n\tconstructor(store: IEdgeStore) {\n\t\tthis._store = store;\n\t}\n\n\t/**\n\t * Return all thought ids in the session, ordered by BFS from roots.\n\t *\n\t * Roots are nodes with no incoming edges. Within a layer, neighbours\n\t * are visited in `outgoing` order (which the underlying store keeps\n\t * sorted by `createdAt` ascending).\n\t *\n\t * @param sessionId - Session to query\n\t * @returns Thought ids in chronological BFS order\n\t *\n\t * @example\n\t * ```typescript\n\t * const ids = view.chronological('s1');\n\t * ```\n\t */\n\tchronological(sessionId: SessionId): readonly ThoughtId[] {\n\t\tconst edges = this._store.edgesForSession(sessionId);\n\t\tif (edges.length === 0) {\n\t\t\treturn [];\n\t\t}\n\t\tconst { nodes, hasIncoming } = this._collectNodes(edges);\n\t\tconst roots = this._findRoots(nodes, hasIncoming, edges);\n\t\treturn this._bfsFromRoots(sessionId, roots) as readonly ThoughtId[];\n\t}\n\n\t/**\n\t * Return all thought ids reachable from `rootThoughtId` via `'branch'`\n\t * edges, including the root itself.\n\t *\n\t * Non-branch edges are ignored. Cycles (if any) do not cause infinite\n\t * loops because each node is visited at most once.\n\t *\n\t * @param sessionId - Session to query\n\t * @param rootThoughtId - The starting thought id (typically the branch root)\n\t * @returns Thought ids forming the branch (includes root)\n\t *\n\t * @example\n\t * ```typescript\n\t * const branchIds = view.branchThoughts('s1', 'thought-root');\n\t * ```\n\t */\n\tbranchThoughts(sessionId: SessionId, rootThoughtId: ThoughtId): readonly ThoughtId[] {\n\t\tconst visited = new Set<string>([rootThoughtId]);\n\t\tconst order: string[] = [rootThoughtId];\n\t\tconst queue: string[] = [rootThoughtId];\n\t\twhile (queue.length > 0) {\n\t\t\tconst current = queue.shift()!;\n\t\t\tconst out = this._store.outgoing(sessionId, current as ThoughtId);\n\t\t\tfor (const edge of out) {\n\t\t\t\tif (edge.kind !== 'branch') continue;\n\t\t\t\tif (visited.has(edge.to)) continue;\n\t\t\t\tvisited.add(edge.to);\n\t\t\t\torder.push(edge.to);\n\t\t\t\tqueue.push(edge.to);\n\t\t\t}\n\t\t}\n\t\treturn order as ThoughtId[];\n\t}\n\n\t/**\n\t * Return a topological ordering of all thought ids in the session\n\t * using Kahn's algorithm.\n\t *\n\t * @param sessionId - Session to query\n\t * @returns Thought ids in topological order\n\t * @throws {CycleDetectedError} If the graph contains a cycle\n\t *\n\t * @example\n\t * ```typescript\n\t * const order = view.topological('s1');\n\t * ```\n\t */\n\ttopological(sessionId: SessionId): readonly ThoughtId[] {\n\t\tconst edges = this._store.edgesForSession(sessionId);\n\t\tif (edges.length === 0) {\n\t\t\treturn [];\n\t\t}\n\t\tconst inDegree = this._buildInDegree(edges);\n\t\tconst queue: string[] = [];\n\t\tfor (const [node, deg] of inDegree) {\n\t\t\tif (deg === 0) queue.push(node);\n\t\t}\n\t\tconst order: string[] = [];\n\t\twhile (queue.length > 0) {\n\t\t\tconst node = queue.shift()!;\n\t\t\torder.push(node);\n\t\t\tfor (const edge of this._store.outgoing(sessionId, node as ThoughtId)) {\n\t\t\t\tconst next = (inDegree.get(edge.to) ?? 0) - 1;\n\t\t\t\tinDegree.set(edge.to, next);\n\t\t\t\tif (next === 0) queue.push(edge.to);\n\t\t\t}\n\t\t}\n\t\tif (order.length !== inDegree.size) {\n\t\t\tthrow new CycleDetectedError(\n\t\t\t\t`Cycle detected in session '${sessionId}': topological sort incomplete (${order.length}/${inDegree.size})`\n\t\t\t);\n\t\t}\n\t\treturn order as ThoughtId[];\n\t}\n\n\t/**\n\t * Return all ancestors of `thoughtId` via incoming-edge BFS.\n\t *\n\t * The starting node is NOT included. Cycles do not cause infinite loops.\n\t *\n\t * @param sessionId - Session to query\n\t * @param thoughtId - The thought to traverse from\n\t * @param maxDepth - Optional maximum traversal depth (1 = direct parents only)\n\t * @returns Ancestor thought ids in BFS order\n\t *\n\t * @example\n\t * ```typescript\n\t * const parents = view.ancestors('s1', 'thought-id', 1);\n\t * ```\n\t */\n\tancestors(sessionId: SessionId, thoughtId: ThoughtId, maxDepth?: number): readonly ThoughtId[] {\n\t\treturn this._bfsClosure(sessionId, thoughtId, maxDepth, 'incoming') as readonly ThoughtId[];\n\t}\n\n\t/**\n\t * Return all descendants of `thoughtId` via outgoing-edge BFS.\n\t *\n\t * The starting node is NOT included. Cycles do not cause infinite loops.\n\t *\n\t * @param sessionId - Session to query\n\t * @param thoughtId - The thought to traverse from\n\t * @param maxDepth - Optional maximum traversal depth (1 = direct children only)\n\t * @returns Descendant thought ids in BFS order\n\t *\n\t * @example\n\t * ```typescript\n\t * const children = view.descendants('s1', 'thought-id');\n\t * ```\n\t */\n\tdescendants(sessionId: SessionId, thoughtId: ThoughtId, maxDepth?: number): readonly ThoughtId[] {\n\t\treturn this._bfsClosure(sessionId, thoughtId, maxDepth, 'outgoing') as readonly ThoughtId[];\n\t}\n\n\t/**\n\t * Return all thought ids in the session that have no outgoing edges.\n\t *\n\t * @param sessionId - Session to query\n\t * @returns Thought ids that are graph leaves\n\t *\n\t * @example\n\t * ```typescript\n\t * const tips = view.leaves('s1');\n\t * ```\n\t */\n\tleaves(sessionId: SessionId): readonly ThoughtId[] {\n\t\tconst edges = this._store.edgesForSession(sessionId);\n\t\tif (edges.length === 0) {\n\t\t\treturn [];\n\t\t}\n\t\tconst { nodes } = this._collectNodes(edges);\n\t\tconst result: string[] = [];\n\t\tfor (const node of nodes) {\n\t\t\tif (this._store.outgoing(sessionId, node as ThoughtId).length === 0) {\n\t\t\t\tresult.push(node);\n\t\t\t}\n\t\t}\n\t\treturn result as ThoughtId[];\n\t}\n\n\t/**\n\t * Collect every node id referenced by the edges and a set of nodes\n\t * that have at least one incoming edge.\n\t */\n\tprivate _collectNodes(edges: readonly Edge[]): {\n\t\tnodes: Set<string>;\n\t\thasIncoming: Set<string>;\n\t} {\n\t\tconst nodes = new Set<string>();\n\t\tconst hasIncoming = new Set<string>();\n\t\tfor (const edge of edges) {\n\t\t\tnodes.add(edge.from);\n\t\t\tnodes.add(edge.to);\n\t\t\thasIncoming.add(edge.to);\n\t\t}\n\t\treturn { nodes, hasIncoming };\n\t}\n\n\t/**\n\t * Find roots (no incoming) ordered by the earliest outgoing edge\n\t * `createdAt`. Nodes with no outgoing edges fall back to the order\n\t * they appear among edges (already sorted by `createdAt`).\n\t */\n\tprivate _findRoots(\n\t\tnodes: Set<string>,\n\t\thasIncoming: Set<string>,\n\t\tedges: readonly Edge[]\n\t): string[] {\n\t\tconst earliest = new Map<string, number>();\n\t\tfor (const edge of edges) {\n\t\t\tif (!earliest.has(edge.from)) {\n\t\t\t\tearliest.set(edge.from, edge.createdAt);\n\t\t\t}\n\t\t}\n\t\tconst roots: string[] = [];\n\t\tfor (const node of nodes) {\n\t\t\tif (!hasIncoming.has(node)) roots.push(node);\n\t\t}\n\t\troots.sort((a, b) => (earliest.get(a) ?? Infinity) - (earliest.get(b) ?? Infinity));\n\t\treturn roots;\n\t}\n\n\t/**\n\t * BFS from a list of root ids, visiting each node at most once.\n\t */\n\tprivate _bfsFromRoots(sessionId: SessionId, roots: readonly string[]): readonly string[] {\n\t\tconst visited = new Set<string>();\n\t\tconst order: string[] = [];\n\t\tconst queue: string[] = [];\n\t\tfor (const root of roots) {\n\t\t\tif (visited.has(root)) continue;\n\t\t\tvisited.add(root);\n\t\t\torder.push(root);\n\t\t\tqueue.push(root);\n\t\t}\n\t\twhile (queue.length > 0) {\n\t\t\tconst node = queue.shift()!;\n\t\t\tfor (const edge of this._store.outgoing(sessionId, node as ThoughtId)) {\n\t\t\t\tif (visited.has(edge.to)) continue;\n\t\t\t\tvisited.add(edge.to);\n\t\t\t\torder.push(edge.to);\n\t\t\t\tqueue.push(edge.to);\n\t\t\t}\n\t\t}\n\t\treturn order;\n\t}\n\n\t/**\n\t * Build an in-degree map covering every node referenced by the edges.\n\t */\n\tprivate _buildInDegree(edges: readonly Edge[]): Map<string, number> {\n\t\tconst inDegree = new Map<string, number>();\n\t\tfor (const edge of edges) {\n\t\t\tif (!inDegree.has(edge.from)) inDegree.set(edge.from, 0);\n\t\t\tinDegree.set(edge.to, (inDegree.get(edge.to) ?? 0) + 1);\n\t\t}\n\t\treturn inDegree;\n\t}\n\n\t/**\n\t * Generic BFS closure in either direction. Excludes the start node\n\t * from the result and respects an optional depth cap.\n\t */\n\tprivate _bfsClosure(\n\t\tsessionId: SessionId,\n\t\tstartId: string,\n\t\tmaxDepth: number | undefined,\n\t\tdirection: 'incoming' | 'outgoing'\n\t): readonly string[] {\n\t\tconst cap = maxDepth ?? Number.POSITIVE_INFINITY;\n\t\tconst visited = new Set<string>([startId]);\n\t\tconst order: string[] = [];\n\t\tlet frontier: string[] = [startId];\n\t\tlet depth = 0;\n\t\twhile (frontier.length > 0 && depth < cap) {\n\t\t\tconst next: string[] = [];\n\t\t\tfor (const node of frontier) {\n\t\t\t\tconst edges =\n\t\t\t\t\tdirection === 'outgoing'\n\t\t\t\t\t\t? this._store.outgoing(sessionId, node as ThoughtId)\n\t\t\t\t\t\t: this._store.incoming(sessionId, node as ThoughtId);\n\t\t\t\tfor (const edge of edges) {\n\t\t\t\t\tconst neighbour = direction === 'outgoing' ? edge.to : edge.from;\n\t\t\t\t\tif (visited.has(neighbour)) continue;\n\t\t\t\t\tvisited.add(neighbour);\n\t\t\t\t\torder.push(neighbour);\n\t\t\t\t\tnext.push(neighbour);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfrontier = next;\n\t\t\tdepth++;\n\t\t}\n\t\treturn order;\n\t}\n}\n"],"names":["GraphView","store","sessionId","edges","nodes","hasIncoming","roots","rootThoughtId","visited","Set","order","queue","current","out","edge","inDegree","node","deg","next","CycleDetectedError","thoughtId","maxDepth","result","earliest","Map","a","b","Infinity","root","startId","direction","cap","Number","frontier","depth","neighbour"],"mappings":";AA+BO,MAAMA;IACK,OAAmB;IAYpC,YAAYC,KAAiB,CAAE;QAC9B,IAAI,CAAC,MAAM,GAAGA;IACf;IAiBA,cAAcC,SAAoB,EAAwB;QACzD,MAAMC,QAAQ,IAAI,CAAC,MAAM,CAAC,eAAe,CAACD;QAC1C,IAAIC,AAAiB,MAAjBA,MAAM,MAAM,EACf,OAAO,EAAE;QAEV,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAE,GAAG,IAAI,CAAC,aAAa,CAACF;QAClD,MAAMG,QAAQ,IAAI,CAAC,UAAU,CAACF,OAAOC,aAAaF;QAClD,OAAO,IAAI,CAAC,aAAa,CAACD,WAAWI;IACtC;IAkBA,eAAeJ,SAAoB,EAAEK,aAAwB,EAAwB;QACpF,MAAMC,UAAU,IAAIC,IAAY;YAACF;SAAc;QAC/C,MAAMG,QAAkB;YAACH;SAAc;QACvC,MAAMI,QAAkB;YAACJ;SAAc;QACvC,MAAOI,MAAM,MAAM,GAAG,EAAG;YACxB,MAAMC,UAAUD,MAAM,KAAK;YAC3B,MAAME,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACX,WAAWU;YAC5C,KAAK,MAAME,QAAQD,IAClB,IAAIC,AAAc,aAAdA,KAAK,IAAI,EACb;gBAAA,KAAIN,QAAQ,GAAG,CAACM,KAAK,EAAE;oBACvBN,QAAQ,GAAG,CAACM,KAAK,EAAE;oBACnBJ,MAAM,IAAI,CAACI,KAAK,EAAE;oBAClBH,MAAM,IAAI,CAACG,KAAK,EAAE;;YAHgB;QAKpC;QACA,OAAOJ;IACR;IAeA,YAAYR,SAAoB,EAAwB;QACvD,MAAMC,QAAQ,IAAI,CAAC,MAAM,CAAC,eAAe,CAACD;QAC1C,IAAIC,AAAiB,MAAjBA,MAAM,MAAM,EACf,OAAO,EAAE;QAEV,MAAMY,WAAW,IAAI,CAAC,cAAc,CAACZ;QACrC,MAAMQ,QAAkB,EAAE;QAC1B,KAAK,MAAM,CAACK,MAAMC,IAAI,IAAIF,SACzB,IAAIE,AAAQ,MAARA,KAAWN,MAAM,IAAI,CAACK;QAE3B,MAAMN,QAAkB,EAAE;QAC1B,MAAOC,MAAM,MAAM,GAAG,EAAG;YACxB,MAAMK,OAAOL,MAAM,KAAK;YACxBD,MAAM,IAAI,CAACM;YACX,KAAK,MAAMF,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACZ,WAAWc,MAAoB;gBACtE,MAAME,OAAQH,AAAAA,CAAAA,SAAS,GAAG,CAACD,KAAK,EAAE,KAAK,KAAK;gBAC5CC,SAAS,GAAG,CAACD,KAAK,EAAE,EAAEI;gBACtB,IAAIA,AAAS,MAATA,MAAYP,MAAM,IAAI,CAACG,KAAK,EAAE;YACnC;QACD;QACA,IAAIJ,MAAM,MAAM,KAAKK,SAAS,IAAI,EACjC,MAAM,IAAII,mBACT,CAAC,2BAA2B,EAAEjB,UAAU,gCAAgC,EAAEQ,MAAM,MAAM,CAAC,CAAC,EAAEK,SAAS,IAAI,CAAC,CAAC,CAAC;QAG5G,OAAOL;IACR;IAiBA,UAAUR,SAAoB,EAAEkB,SAAoB,EAAEC,QAAiB,EAAwB;QAC9F,OAAO,IAAI,CAAC,WAAW,CAACnB,WAAWkB,WAAWC,UAAU;IACzD;IAiBA,YAAYnB,SAAoB,EAAEkB,SAAoB,EAAEC,QAAiB,EAAwB;QAChG,OAAO,IAAI,CAAC,WAAW,CAACnB,WAAWkB,WAAWC,UAAU;IACzD;IAaA,OAAOnB,SAAoB,EAAwB;QAClD,MAAMC,QAAQ,IAAI,CAAC,MAAM,CAAC,eAAe,CAACD;QAC1C,IAAIC,AAAiB,MAAjBA,MAAM,MAAM,EACf,OAAO,EAAE;QAEV,MAAM,EAAEC,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAACD;QACrC,MAAMmB,SAAmB,EAAE;QAC3B,KAAK,MAAMN,QAAQZ,MAClB,IAAI,AAA8D,MAA9D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACF,WAAWc,MAAmB,MAAM,EAC5DM,OAAO,IAAI,CAACN;QAGd,OAAOM;IACR;IAMQ,cAAcnB,KAAsB,EAG1C;QACD,MAAMC,QAAQ,IAAIK;QAClB,MAAMJ,cAAc,IAAII;QACxB,KAAK,MAAMK,QAAQX,MAAO;YACzBC,MAAM,GAAG,CAACU,KAAK,IAAI;YACnBV,MAAM,GAAG,CAACU,KAAK,EAAE;YACjBT,YAAY,GAAG,CAACS,KAAK,EAAE;QACxB;QACA,OAAO;YAAEV;YAAOC;QAAY;IAC7B;IAOQ,WACPD,KAAkB,EAClBC,WAAwB,EACxBF,KAAsB,EACX;QACX,MAAMoB,WAAW,IAAIC;QACrB,KAAK,MAAMV,QAAQX,MAClB,IAAI,CAACoB,SAAS,GAAG,CAACT,KAAK,IAAI,GAC1BS,SAAS,GAAG,CAACT,KAAK,IAAI,EAAEA,KAAK,SAAS;QAGxC,MAAMR,QAAkB,EAAE;QAC1B,KAAK,MAAMU,QAAQZ,MAClB,IAAI,CAACC,YAAY,GAAG,CAACW,OAAOV,MAAM,IAAI,CAACU;QAExCV,MAAM,IAAI,CAAC,CAACmB,GAAGC,IAAOH,AAAAA,CAAAA,SAAS,GAAG,CAACE,MAAME,KAAO,IAAMJ,CAAAA,SAAS,GAAG,CAACG,MAAMC,KAAO;QAChF,OAAOrB;IACR;IAKQ,cAAcJ,SAAoB,EAAEI,KAAwB,EAAqB;QACxF,MAAME,UAAU,IAAIC;QACpB,MAAMC,QAAkB,EAAE;QAC1B,MAAMC,QAAkB,EAAE;QAC1B,KAAK,MAAMiB,QAAQtB,MAClB,KAAIE,QAAQ,GAAG,CAACoB;YAChBpB,QAAQ,GAAG,CAACoB;YACZlB,MAAM,IAAI,CAACkB;YACXjB,MAAM,IAAI,CAACiB;;QAEZ,MAAOjB,MAAM,MAAM,GAAG,EAAG;YACxB,MAAMK,OAAOL,MAAM,KAAK;YACxB,KAAK,MAAMG,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACZ,WAAWc,MAClD,KAAIR,QAAQ,GAAG,CAACM,KAAK,EAAE;gBACvBN,QAAQ,GAAG,CAACM,KAAK,EAAE;gBACnBJ,MAAM,IAAI,CAACI,KAAK,EAAE;gBAClBH,MAAM,IAAI,CAACG,KAAK,EAAE;;QAEpB;QACA,OAAOJ;IACR;IAKQ,eAAeP,KAAsB,EAAuB;QACnE,MAAMY,WAAW,IAAIS;QACrB,KAAK,MAAMV,QAAQX,MAAO;YACzB,IAAI,CAACY,SAAS,GAAG,CAACD,KAAK,IAAI,GAAGC,SAAS,GAAG,CAACD,KAAK,IAAI,EAAE;YACtDC,SAAS,GAAG,CAACD,KAAK,EAAE,EAAGC,AAAAA,CAAAA,SAAS,GAAG,CAACD,KAAK,EAAE,KAAK,KAAK;QACtD;QACA,OAAOC;IACR;IAMQ,YACPb,SAAoB,EACpB2B,OAAe,EACfR,QAA4B,EAC5BS,SAAkC,EACd;QACpB,MAAMC,MAAMV,YAAYW,KAAwB;QAChD,MAAMxB,UAAU,IAAIC,IAAY;YAACoB;SAAQ;QACzC,MAAMnB,QAAkB,EAAE;QAC1B,IAAIuB,WAAqB;YAACJ;SAAQ;QAClC,IAAIK,QAAQ;QACZ,MAAOD,SAAS,MAAM,GAAG,KAAKC,QAAQH,IAAK;YAC1C,MAAMb,OAAiB,EAAE;YACzB,KAAK,MAAMF,QAAQiB,SAAU;gBAC5B,MAAM9B,QACL2B,AAAc,eAAdA,YACG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC5B,WAAWc,QAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACd,WAAWc;gBACpC,KAAK,MAAMF,QAAQX,MAAO;oBACzB,MAAMgC,YAAYL,AAAc,eAAdA,YAA2BhB,KAAK,EAAE,GAAGA,KAAK,IAAI;oBAChE,KAAIN,QAAQ,GAAG,CAAC2B;wBAChB3B,QAAQ,GAAG,CAAC2B;wBACZzB,MAAM,IAAI,CAACyB;wBACXjB,KAAK,IAAI,CAACiB;;gBACX;YACD;YACAF,WAAWf;YACXgB;QACD;QACA,OAAOxB;IACR;AACD"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Unique identifier generation utilities for thoughts and edges.
3
+ *
4
+ * @module core/ids
5
+ */
6
+ /**
7
+ * Generate a unique lexicographically-sortable identifier.
8
+ *
9
+ * Format: 8-char base36 timestamp + 20-char hex random (10 random bytes).
10
+ * Result is up to 28 characters, sortable by creation time.
11
+ *
12
+ * @returns A unique string identifier.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const id = generateUlid(); // '01h2k3m400a1b2c3d4e5f6...'
17
+ * ```
18
+ */
19
+ export declare function generateUlid(): string;
20
+ /**
21
+ * Valid session ID pattern: alphanumeric, hyphens, underscores.
22
+ *
23
+ * Length is enforced separately via {@link MAX_SESSION_ID_LENGTH}.
24
+ * Same character set as branch IDs.
25
+ */
26
+ export declare const SESSION_ID_PATTERN: RegExp;
27
+ /**
28
+ * Maximum session ID length (in characters).
29
+ *
30
+ * Allows compound identifiers (e.g. `user-123_task-abc`).
31
+ */
32
+ export declare const MAX_SESSION_ID_LENGTH = 100;
33
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/core/ids.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAIrC;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,QAAqB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
@@ -0,0 +1,11 @@
1
+ import * as __rspack_external_node_crypto_2e7c4b46 from "node:crypto";
2
+ function generateUlid() {
3
+ const timestamp = Date.now().toString(36).padStart(8, '0');
4
+ const random = __rspack_external_node_crypto_2e7c4b46.randomBytes(10).toString('hex');
5
+ return `${timestamp}${random}`;
6
+ }
7
+ const SESSION_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
8
+ const MAX_SESSION_ID_LENGTH = 100;
9
+ export { MAX_SESSION_ID_LENGTH, SESSION_ID_PATTERN, generateUlid };
10
+
11
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/ids.js","sources":["../../src/core/ids.ts"],"sourcesContent":["/**\n * Unique identifier generation utilities for thoughts and edges.\n *\n * @module core/ids\n */\n\nimport * as crypto from 'node:crypto';\n\n/**\n * Generate a unique lexicographically-sortable identifier.\n *\n * Format: 8-char base36 timestamp + 20-char hex random (10 random bytes).\n * Result is up to 28 characters, sortable by creation time.\n *\n * @returns A unique string identifier.\n *\n * @example\n * ```typescript\n * const id = generateUlid(); // '01h2k3m400a1b2c3d4e5f6...'\n * ```\n */\nexport function generateUlid(): string {\n\tconst timestamp = Date.now().toString(36).padStart(8, '0');\n\tconst random = crypto.randomBytes(10).toString('hex');\n\treturn `${timestamp}${random}`;\n}\n\n/**\n * Valid session ID pattern: alphanumeric, hyphens, underscores.\n *\n * Length is enforced separately via {@link MAX_SESSION_ID_LENGTH}.\n * Same character set as branch IDs.\n */\nexport const SESSION_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;\n\n/**\n * Maximum session ID length (in characters).\n *\n * Allows compound identifiers (e.g. `user-123_task-abc`).\n */\nexport const MAX_SESSION_ID_LENGTH = 100;\n"],"names":["generateUlid","timestamp","Date","random","crypto","SESSION_ID_PATTERN","MAX_SESSION_ID_LENGTH"],"mappings":";AAqBO,SAASA;IACf,MAAMC,YAAYC,KAAK,GAAG,GAAG,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG;IACtD,MAAMC,SAASC,uCAAAA,WAAkB,CAAC,IAAI,QAAQ,CAAC;IAC/C,OAAO,GAAGH,YAAYE,QAAQ;AAC/B;AAQO,MAAME,qBAAqB;AAO3B,MAAMC,wBAAwB"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Records verification outcomes for confidence calibration.
3
+ *
4
+ * No-op implementation when feature flag is disabled.
5
+ * Stores outcomes per-session in memory for later calibration use.
6
+ *
7
+ * @module core/reasoning/OutcomeRecorder
8
+ */
9
+ import type { IOutcomeRecorder, VerificationOutcome } from '../../contracts/interfaces.js';
10
+ import type { SessionId, ThoughtId } from '../../contracts/ids.js';
11
+ /**
12
+ * Configuration for OutcomeRecorder.
13
+ */
14
+ export interface OutcomeRecorderConfig {
15
+ /** Whether outcome recording is enabled. */
16
+ enabled: boolean;
17
+ }
18
+ /**
19
+ * Records verification outcomes for confidence calibration.
20
+ *
21
+ * When disabled (default), all methods are no-ops and return empty arrays.
22
+ * When enabled, outcomes are stored in memory per-session.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const recorder = new OutcomeRecorder({ enabled: true });
27
+ * recorder.recordVerification({
28
+ * thoughtId: 't1',
29
+ * thoughtNumber: 1,
30
+ * sessionId: 'session-a',
31
+ * predicted: 0.8,
32
+ * actual: 1,
33
+ * type: 'verification',
34
+ * });
35
+ * const outcomes = recorder.getOutcomes('session-a');
36
+ * ```
37
+ */
38
+ export declare class OutcomeRecorder implements IOutcomeRecorder {
39
+ private readonly _outcomes;
40
+ private readonly _enabled;
41
+ /**
42
+ * Whether outcome recording is currently enabled.
43
+ */
44
+ get enabled(): boolean;
45
+ /**
46
+ * Create a new OutcomeRecorder.
47
+ *
48
+ * @param config - Recorder configuration
49
+ */
50
+ constructor(config: OutcomeRecorderConfig);
51
+ /**
52
+ * Assert that a target is available for one outcome label.
53
+ *
54
+ * @param sessionId - Canonical session namespace
55
+ * @param thoughtId - Stable target identity
56
+ * @throws {ValidationError} When the target was already labeled
57
+ */
58
+ assertCanRecord(sessionId: SessionId, thoughtId: ThoughtId): void;
59
+ /**
60
+ * Record a verification outcome.
61
+ *
62
+ * No-op when outcome recording is disabled.
63
+ *
64
+ * @param outcome - The outcome data (recordedAt is auto-set)
65
+ */
66
+ recordVerification(outcome: Omit<VerificationOutcome, 'recordedAt'>): void;
67
+ /**
68
+ * Get all recorded outcomes for a session.
69
+ *
70
+ * @param sessionId - The session id to query
71
+ * @returns Array of outcomes (empty when disabled or no data)
72
+ */
73
+ getOutcomes(sessionId: SessionId): VerificationOutcome[];
74
+ /**
75
+ * Get outcomes across all sessions.
76
+ *
77
+ * @returns Flat array of all outcomes (empty when disabled)
78
+ */
79
+ getAllOutcomes(): VerificationOutcome[];
80
+ /**
81
+ * Clear outcomes for a specific session.
82
+ *
83
+ * @param sessionId - The session id to clear
84
+ */
85
+ clearOutcomes(sessionId: SessionId): void;
86
+ clearAllOutcomes(): void;
87
+ }
88
+ //# sourceMappingURL=OutcomeRecorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OutcomeRecorder.d.ts","sourceRoot":"","sources":["../../../src/core/reasoning/OutcomeRecorder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,4CAA4C;IAC5C,OAAO,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IACvD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkE;IAC5F,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IAEnC;;OAEG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;;OAIG;gBACS,MAAM,EAAE,qBAAqB;IAIzC;;;;;;OAMG;IACH,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAUjE;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,GAAG,IAAI;IAc1E;;;;;OAKG;IACH,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,mBAAmB,EAAE;IAKxD;;;;OAIG;IACH,cAAc,IAAI,mBAAmB,EAAE;IASvC;;;;OAIG;IACH,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIzC,gBAAgB,IAAI,IAAI;CAGxB"}
@@ -0,0 +1,51 @@
1
+ import { ValidationError } from "../../errors.js";
2
+ class OutcomeRecorder {
3
+ _outcomes = new Map();
4
+ _enabled;
5
+ get enabled() {
6
+ return this._enabled;
7
+ }
8
+ constructor(config){
9
+ this._enabled = config.enabled;
10
+ }
11
+ assertCanRecord(sessionId, thoughtId) {
12
+ if (!this._enabled) return;
13
+ if (this._outcomes.get(sessionId)?.has(thoughtId)) throw new ValidationError('verification_result', 'The verification target already has a recorded result');
14
+ }
15
+ recordVerification(outcome) {
16
+ if (!this._enabled) return;
17
+ this.assertCanRecord(outcome.sessionId, outcome.thoughtId);
18
+ const full = {
19
+ ...outcome,
20
+ recordedAt: Date.now()
21
+ };
22
+ const sessionOutcomes = this._outcomes.get(outcome.sessionId) ?? new Map();
23
+ sessionOutcomes.set(outcome.thoughtId, full);
24
+ this._outcomes.set(outcome.sessionId, sessionOutcomes);
25
+ }
26
+ getOutcomes(sessionId) {
27
+ if (!this._enabled) return [];
28
+ return [
29
+ ...this._outcomes.get(sessionId)?.values() ?? []
30
+ ].map((outcome)=>({
31
+ ...outcome
32
+ }));
33
+ }
34
+ getAllOutcomes() {
35
+ if (!this._enabled) return [];
36
+ const all = [];
37
+ for (const outcomes of this._outcomes.values())for (const outcome of outcomes.values())all.push({
38
+ ...outcome
39
+ });
40
+ return all;
41
+ }
42
+ clearOutcomes(sessionId) {
43
+ this._outcomes.delete(sessionId);
44
+ }
45
+ clearAllOutcomes() {
46
+ this._outcomes.clear();
47
+ }
48
+ }
49
+ export { OutcomeRecorder };
50
+
51
+ //# sourceMappingURL=OutcomeRecorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/reasoning/OutcomeRecorder.js","sources":["../../../src/core/reasoning/OutcomeRecorder.ts"],"sourcesContent":["/**\n * Records verification outcomes for confidence calibration.\n *\n * No-op implementation when feature flag is disabled.\n * Stores outcomes per-session in memory for later calibration use.\n *\n * @module core/reasoning/OutcomeRecorder\n */\n\nimport type { IOutcomeRecorder, VerificationOutcome } from '../../contracts/interfaces.js';\nimport type { SessionId, ThoughtId } from '../../contracts/ids.js';\nimport { ValidationError } from '../../errors.js';\n\n/**\n * Configuration for OutcomeRecorder.\n */\nexport interface OutcomeRecorderConfig {\n\t/** Whether outcome recording is enabled. */\n\tenabled: boolean;\n}\n\n/**\n * Records verification outcomes for confidence calibration.\n *\n * When disabled (default), all methods are no-ops and return empty arrays.\n * When enabled, outcomes are stored in memory per-session.\n *\n * @example\n * ```typescript\n * const recorder = new OutcomeRecorder({ enabled: true });\n * recorder.recordVerification({\n * thoughtId: 't1',\n * thoughtNumber: 1,\n * sessionId: 'session-a',\n * predicted: 0.8,\n * actual: 1,\n * type: 'verification',\n * });\n * const outcomes = recorder.getOutcomes('session-a');\n * ```\n */\nexport class OutcomeRecorder implements IOutcomeRecorder {\n\tprivate readonly _outcomes: Map<SessionId, Map<ThoughtId, VerificationOutcome>> = new Map();\n\tprivate readonly _enabled: boolean;\n\n\t/**\n\t * Whether outcome recording is currently enabled.\n\t */\n\tpublic get enabled(): boolean {\n\t\treturn this._enabled;\n\t}\n\n\t/**\n\t * Create a new OutcomeRecorder.\n\t *\n\t * @param config - Recorder configuration\n\t */\n\tconstructor(config: OutcomeRecorderConfig) {\n\t\tthis._enabled = config.enabled;\n\t}\n\n\t/**\n\t * Assert that a target is available for one outcome label.\n\t *\n\t * @param sessionId - Canonical session namespace\n\t * @param thoughtId - Stable target identity\n\t * @throws {ValidationError} When the target was already labeled\n\t */\n\tassertCanRecord(sessionId: SessionId, thoughtId: ThoughtId): void {\n\t\tif (!this._enabled) return;\n\t\tif (this._outcomes.get(sessionId)?.has(thoughtId)) {\n\t\t\tthrow new ValidationError(\n\t\t\t\t'verification_result',\n\t\t\t\t'The verification target already has a recorded result'\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Record a verification outcome.\n\t *\n\t * No-op when outcome recording is disabled.\n\t *\n\t * @param outcome - The outcome data (recordedAt is auto-set)\n\t */\n\trecordVerification(outcome: Omit<VerificationOutcome, 'recordedAt'>): void {\n\t\tif (!this._enabled) return;\n\t\tthis.assertCanRecord(outcome.sessionId, outcome.thoughtId);\n\n\t\tconst full: VerificationOutcome = {\n\t\t\t...outcome,\n\t\t\trecordedAt: Date.now(),\n\t\t};\n\n\t\tconst sessionOutcomes = this._outcomes.get(outcome.sessionId) ?? new Map();\n\t\tsessionOutcomes.set(outcome.thoughtId, full);\n\t\tthis._outcomes.set(outcome.sessionId, sessionOutcomes);\n\t}\n\n\t/**\n\t * Get all recorded outcomes for a session.\n\t *\n\t * @param sessionId - The session id to query\n\t * @returns Array of outcomes (empty when disabled or no data)\n\t */\n\tgetOutcomes(sessionId: SessionId): VerificationOutcome[] {\n\t\tif (!this._enabled) return [];\n\t\treturn [...(this._outcomes.get(sessionId)?.values() ?? [])].map((outcome) => ({ ...outcome }));\n\t}\n\n\t/**\n\t * Get outcomes across all sessions.\n\t *\n\t * @returns Flat array of all outcomes (empty when disabled)\n\t */\n\tgetAllOutcomes(): VerificationOutcome[] {\n\t\tif (!this._enabled) return [];\n\t\tconst all: VerificationOutcome[] = [];\n\t\tfor (const outcomes of this._outcomes.values()) {\n\t\t\tfor (const outcome of outcomes.values()) all.push({ ...outcome });\n\t\t}\n\t\treturn all;\n\t}\n\n\t/**\n\t * Clear outcomes for a specific session.\n\t *\n\t * @param sessionId - The session id to clear\n\t */\n\tclearOutcomes(sessionId: SessionId): void {\n\t\tthis._outcomes.delete(sessionId);\n\t}\n\n\tclearAllOutcomes(): void {\n\t\tthis._outcomes.clear();\n\t}\n}\n"],"names":["OutcomeRecorder","Map","config","sessionId","thoughtId","ValidationError","outcome","full","Date","sessionOutcomes","all","outcomes"],"mappings":";AAyCO,MAAMA;IACK,YAAiE,IAAIC,MAAM;IAC3E,SAAkB;IAKnC,IAAW,UAAmB;QAC7B,OAAO,IAAI,CAAC,QAAQ;IACrB;IAOA,YAAYC,MAA6B,CAAE;QAC1C,IAAI,CAAC,QAAQ,GAAGA,OAAO,OAAO;IAC/B;IASA,gBAAgBC,SAAoB,EAAEC,SAAoB,EAAQ;QACjE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;QACpB,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAACD,YAAY,IAAIC,YACtC,MAAM,IAAIC,gBACT,uBACA;IAGH;IASA,mBAAmBC,OAAgD,EAAQ;QAC1E,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;QACpB,IAAI,CAAC,eAAe,CAACA,QAAQ,SAAS,EAAEA,QAAQ,SAAS;QAEzD,MAAMC,OAA4B;YACjC,GAAGD,OAAO;YACV,YAAYE,KAAK,GAAG;QACrB;QAEA,MAAMC,kBAAkB,IAAI,CAAC,SAAS,CAAC,GAAG,CAACH,QAAQ,SAAS,KAAK,IAAIL;QACrEQ,gBAAgB,GAAG,CAACH,QAAQ,SAAS,EAAEC;QACvC,IAAI,CAAC,SAAS,CAAC,GAAG,CAACD,QAAQ,SAAS,EAAEG;IACvC;IAQA,YAAYN,SAAoB,EAAyB;QACxD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE;QAC7B,OAAO;eAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAACA,YAAY,YAAY,EAAE;SAAE,CAAC,GAAG,CAAC,CAACG,UAAa;gBAAE,GAAGA,OAAO;YAAC;IAC5F;IAOA,iBAAwC;QACvC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE;QAC7B,MAAMI,MAA6B,EAAE;QACrC,KAAK,MAAMC,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM,GAC3C,KAAK,MAAML,WAAWK,SAAS,MAAM,GAAID,IAAI,IAAI,CAAC;YAAE,GAAGJ,OAAO;QAAC;QAEhE,OAAOI;IACR;IAOA,cAAcP,SAAoB,EAAQ;QACzC,IAAI,CAAC,SAAS,CAAC,MAAM,CAACA;IACvB;IAEA,mBAAyB;QACxB,IAAI,CAAC,SAAS,CAAC,KAAK;IACrB;AACD"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Sequential reasoning strategy — the default policy that preserves existing
3
+ * {@link ThoughtProcessor} behavior. Continues the chain unless the current
4
+ * thought explicitly signals termination via `next_thought_needed === false`.
5
+ *
6
+ * Pure policy: no mutable state, no I/O, no module-level variables. All
7
+ * methods are deterministic functions of their inputs.
8
+ *
9
+ * @module core/reasoning/strategies/SequentialStrategy
10
+ */
11
+ import type { IReasoningStrategy, StrategyContext, StrategyDecision } from '../../../contracts/strategy.js';
12
+ /**
13
+ * Default sequential strategy. Mirrors the legacy linear thinking flow:
14
+ *
15
+ * - Continue while `next_thought_needed` is truthy (or unset).
16
+ * - Terminate as soon as `next_thought_needed === false`.
17
+ * - Branch when both `branch_from_thought` and `branch_id` are present.
18
+ *
19
+ * Type-agnostic: all `ThoughtType` variants (including `assumption`,
20
+ * `decomposition`, `backtrack`, `tool_call`, `tool_observation`, and the
21
+ * legacy six) pass through unchanged. The strategy intentionally inspects
22
+ * only `next_thought_needed`, `branch_from_thought`, and `branch_id` —
23
+ * type-aware behavior lives in evaluator/scoring layers, not here.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const strategy = new SequentialStrategy();
28
+ * const decision = strategy.decide(ctx);
29
+ * if (decision.action === 'terminate') stop();
30
+ * ```
31
+ */
32
+ export declare class SequentialStrategy implements IReasoningStrategy {
33
+ readonly name: "sequential";
34
+ /**
35
+ * Compute the next action for the chain.
36
+ *
37
+ * @param ctx - Read-only session snapshot.
38
+ * @returns `{ action: 'terminate' }` when current thought signals stop,
39
+ * otherwise `{ action: 'continue' }`.
40
+ */
41
+ decide(ctx: StrategyContext): StrategyDecision;
42
+ /**
43
+ * Predicate: should the chain branch right now?
44
+ * True iff both `branch_from_thought` and `branch_id` are set on the
45
+ * current thought.
46
+ */
47
+ shouldBranch(ctx: StrategyContext): boolean;
48
+ /**
49
+ * Predicate: should the chain terminate right now?
50
+ * True iff `next_thought_needed === false`.
51
+ */
52
+ shouldTerminate(ctx: StrategyContext): boolean;
53
+ }
54
+ //# sourceMappingURL=SequentialStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SequentialStrategy.d.ts","sourceRoot":"","sources":["../../../../src/core/reasoning/strategies/SequentialStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,MAAM,gCAAgC,CAAC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,kBAAmB,YAAW,kBAAkB;IAC5D,QAAQ,CAAC,IAAI,EAAG,YAAY,CAAU;IAEtC;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,eAAe,GAAG,gBAAgB;IAO9C;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO;IAK3C;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO;CAG9C"}
@@ -0,0 +1,22 @@
1
+ class SequentialStrategy {
2
+ name = 'sequential';
3
+ decide(ctx) {
4
+ if (false === ctx.currentThought.next_thought_needed) return {
5
+ action: 'terminate',
6
+ reason: 'next_thought_needed=false'
7
+ };
8
+ return {
9
+ action: 'continue'
10
+ };
11
+ }
12
+ shouldBranch(ctx) {
13
+ const t = ctx.currentThought;
14
+ return void 0 !== t.branch_from_thought && void 0 !== t.branch_id;
15
+ }
16
+ shouldTerminate(ctx) {
17
+ return false === ctx.currentThought.next_thought_needed;
18
+ }
19
+ }
20
+ export { SequentialStrategy };
21
+
22
+ //# sourceMappingURL=SequentialStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/reasoning/strategies/SequentialStrategy.js","sources":["../../../../src/core/reasoning/strategies/SequentialStrategy.ts"],"sourcesContent":["/**\n * Sequential reasoning strategy — the default policy that preserves existing\n * {@link ThoughtProcessor} behavior. Continues the chain unless the current\n * thought explicitly signals termination via `next_thought_needed === false`.\n *\n * Pure policy: no mutable state, no I/O, no module-level variables. All\n * methods are deterministic functions of their inputs.\n *\n * @module core/reasoning/strategies/SequentialStrategy\n */\n\nimport type {\n\tIReasoningStrategy,\n\tStrategyContext,\n\tStrategyDecision,\n} from '../../../contracts/strategy.js';\n\n/**\n * Default sequential strategy. Mirrors the legacy linear thinking flow:\n *\n * - Continue while `next_thought_needed` is truthy (or unset).\n * - Terminate as soon as `next_thought_needed === false`.\n * - Branch when both `branch_from_thought` and `branch_id` are present.\n *\n * Type-agnostic: all `ThoughtType` variants (including `assumption`,\n * `decomposition`, `backtrack`, `tool_call`, `tool_observation`, and the\n * legacy six) pass through unchanged. The strategy intentionally inspects\n * only `next_thought_needed`, `branch_from_thought`, and `branch_id` —\n * type-aware behavior lives in evaluator/scoring layers, not here.\n *\n * @example\n * ```ts\n * const strategy = new SequentialStrategy();\n * const decision = strategy.decide(ctx);\n * if (decision.action === 'terminate') stop();\n * ```\n */\nexport class SequentialStrategy implements IReasoningStrategy {\n\treadonly name = 'sequential' as const;\n\n\t/**\n\t * Compute the next action for the chain.\n\t *\n\t * @param ctx - Read-only session snapshot.\n\t * @returns `{ action: 'terminate' }` when current thought signals stop,\n\t * otherwise `{ action: 'continue' }`.\n\t */\n\tdecide(ctx: StrategyContext): StrategyDecision {\n\t\tif (ctx.currentThought.next_thought_needed === false) {\n\t\t\treturn { action: 'terminate', reason: 'next_thought_needed=false' };\n\t\t}\n\t\treturn { action: 'continue' };\n\t}\n\n\t/**\n\t * Predicate: should the chain branch right now?\n\t * True iff both `branch_from_thought` and `branch_id` are set on the\n\t * current thought.\n\t */\n\tshouldBranch(ctx: StrategyContext): boolean {\n\t\tconst t = ctx.currentThought;\n\t\treturn t.branch_from_thought !== undefined && t.branch_id !== undefined;\n\t}\n\n\t/**\n\t * Predicate: should the chain terminate right now?\n\t * True iff `next_thought_needed === false`.\n\t */\n\tshouldTerminate(ctx: StrategyContext): boolean {\n\t\treturn ctx.currentThought.next_thought_needed === false;\n\t}\n}\n"],"names":["SequentialStrategy","ctx","t","undefined"],"mappings":"AAqCO,MAAMA;IACH,OAAO,aAAsB;IAStC,OAAOC,GAAoB,EAAoB;QAC9C,IAAIA,AAA2C,UAA3CA,IAAI,cAAc,CAAC,mBAAmB,EACzC,OAAO;YAAE,QAAQ;YAAa,QAAQ;QAA4B;QAEnE,OAAO;YAAE,QAAQ;QAAW;IAC7B;IAOA,aAAaA,GAAoB,EAAW;QAC3C,MAAMC,IAAID,IAAI,cAAc;QAC5B,OAAOC,AAA0BC,WAA1BD,EAAE,mBAAmB,IAAkBA,AAAgBC,WAAhBD,EAAE,SAAS;IAC1D;IAMA,gBAAgBD,GAAoB,EAAW;QAC9C,OAAOA,AAA2C,UAA3CA,IAAI,cAAc,CAAC,mBAAmB;IAC9C;AACD"}