@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,179 @@
1
+ /**
2
+ * Reasoning type definitions for advanced sequential thinking.
3
+ *
4
+ * Provides type-level constructs for classifying thoughts, computing confidence
5
+ * signals from reasoning history, and aggregating session analytics.
6
+ *
7
+ * @module core/reasoning
8
+ */
9
+ import type { CalibrationMetrics } from '../contracts/calibrator.js';
10
+ import type { PatternName as ContractPatternName, ThoughtType as ContractThoughtType } from '../contracts/reasoning-types.js';
11
+ export type ThoughtType = ContractThoughtType;
12
+ export type PatternName = ContractPatternName;
13
+ /**
14
+ * A detected reasoning pattern — surfaced as metadata or a warning.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const signal: PatternSignal = {
19
+ * pattern: 'hypothesis-without-verification',
20
+ * severity: 'warning',
21
+ * message: 'Hypothesis H1 has no matching verification thought.',
22
+ * thought_range: [3, 7],
23
+ * };
24
+ * ```
25
+ */
26
+ export interface PatternSignal {
27
+ /** Machine-readable pattern identifier. */
28
+ /** Machine-readable pattern identifier. */
29
+ pattern: PatternName;
30
+ /** Severity: 'warning' surfaces as a hint, 'info' is metadata only. */
31
+ severity: 'info' | 'warning';
32
+ /** Human-readable description of the detected pattern. */
33
+ message: string;
34
+ /** Thought number range [start, end] where the pattern was detected. */
35
+ thought_range: [number, number];
36
+ }
37
+ /**
38
+ * Signals about reasoning quality computed from history.
39
+ *
40
+ * These metrics are derived from the thought chain and provide insight into
41
+ * the depth, breadth, and completeness of the reasoning process.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const signals: ConfidenceSignals = {
46
+ * reasoning_depth: 5,
47
+ * revision_count: 1,
48
+ * branch_count: 2,
49
+ * thought_type_distribution: {
50
+ * regular: 3,
51
+ * hypothesis: 1,
52
+ * verification: 1,
53
+ * critique: 0,
54
+ * synthesis: 0,
55
+ * meta: 0,
56
+ * },
57
+ * has_hypothesis: true,
58
+ * has_verification: true,
59
+ * average_confidence: 0.85,
60
+ * structural_quality: 0.72,
61
+ * quality_components: {
62
+ * type_diversity: 0.65,
63
+ * verification_coverage: 1.0,
64
+ * depth_efficiency: 0.6,
65
+ * confidence_stability: 0.85,
66
+ * },
67
+ * };
68
+ * ```
69
+ */
70
+ export interface ConfidenceSignals {
71
+ /** Length of thought chain to this point. */
72
+ readonly reasoning_depth: number;
73
+ /** How many revisions in this chain. */
74
+ readonly revision_count: number;
75
+ /** Active branches. */
76
+ readonly branch_count: number;
77
+ /** Distribution of thought types used. */
78
+ readonly thought_type_distribution: Record<ThoughtType, number>;
79
+ /** Whether any hypothesis exists in chain. */
80
+ readonly has_hypothesis: boolean;
81
+ /** Whether any verification exists. */
82
+ readonly has_verification: boolean;
83
+ /** Mean of explicit confidence values, null if none. */
84
+ readonly average_confidence: number | null;
85
+ /**
86
+ * Composite structural quality score (0-1).
87
+ * Geometric mean of quality_components with floor of 0.01 per component.
88
+ * Only present when history has ≥1 thought.
89
+ */
90
+ readonly structural_quality?: number;
91
+ /**
92
+ * Individual quality components that feed into structural_quality.
93
+ * Only present when structural_quality is present.
94
+ */
95
+ readonly quality_components?: {
96
+ /** Shannon entropy of thought_type distribution / log2(6), normalized 0-1. */
97
+ readonly type_diversity: number;
98
+ /** verified_hypotheses / total_hypotheses. 1.0 if no hypotheses exist. */
99
+ readonly verification_coverage: number;
100
+ /** max(chain_depth, branch_count + 1) / total_thoughts, clamped to [0, 1]. Branching is desirable. */
101
+ readonly depth_efficiency: number;
102
+ /** 1 - stddev(confidence values). Defaults to 0.5 if no confidence values. Null when fewer than 2 confidence values. */
103
+ readonly confidence_stability: number | null;
104
+ };
105
+ /**
106
+ * Raw (unfloored) quality components before the 0.01 floor is applied.
107
+ * Only present when quality_components is present.
108
+ * Useful for debugging quality score calculations.
109
+ */
110
+ readonly quality_components_raw?: {
111
+ /** Shannon entropy / log2(6) — may be below 0.01 floor. */
112
+ readonly type_diversity: number;
113
+ /** verified / total hypotheses — may be below 0.01 floor. */
114
+ readonly verification_coverage: number;
115
+ /** depth / total — may be below 0.01 floor. */
116
+ readonly depth_efficiency: number;
117
+ /** 1 - stddev — may be below 0.01 floor. Null when fewer than 2 confidence values. */
118
+ readonly confidence_stability: number | null;
119
+ };
120
+ /** Calibrated confidence score (post temperature scaling + prior shrinkage). Only present when features.calibration=true. */
121
+ readonly calibrated_confidence?: number;
122
+ /** Calibration quality metrics for the session. Only present when features.calibration=true. */
123
+ readonly calibration_metrics?: CalibrationMetrics;
124
+ }
125
+ /**
126
+ * Aggregated analytics about the reasoning session.
127
+ *
128
+ * Provides a comprehensive summary of the reasoning process including
129
+ * thought counts, branch metrics, hypothesis tracking, and quality scores.
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const stats: ReasoningStats = {
134
+ * total_thoughts: 12,
135
+ * total_branches: 3,
136
+ * total_revisions: 2,
137
+ * total_merges: 1,
138
+ * chain_depth: 8,
139
+ * thought_type_counts: {
140
+ * regular: 6,
141
+ * hypothesis: 2,
142
+ * verification: 2,
143
+ * critique: 1,
144
+ * synthesis: 1,
145
+ * meta: 0,
146
+ * },
147
+ * hypothesis_count: 2,
148
+ * verified_hypothesis_count: 1,
149
+ * unresolved_hypothesis_count: 1,
150
+ * average_quality_score: 0.78,
151
+ * average_confidence: 0.82,
152
+ * };
153
+ * ```
154
+ */
155
+ export interface ReasoningStats {
156
+ /** Total thoughts in session. */
157
+ readonly total_thoughts: number;
158
+ /** Total branches created. */
159
+ readonly total_branches: number;
160
+ /** Total revision operations. */
161
+ readonly total_revisions: number;
162
+ /** Total merge operations (DAG topology). */
163
+ readonly total_merges: number;
164
+ /** Longest sequential chain depth. */
165
+ readonly chain_depth: number;
166
+ /** Count of each thought type. */
167
+ readonly thought_type_counts: Record<ThoughtType, number>;
168
+ /** Hypotheses created. */
169
+ readonly hypothesis_count: number;
170
+ /** Hypotheses that have been verified. */
171
+ readonly verified_hypothesis_count: number;
172
+ /** Hypotheses without verification. */
173
+ readonly unresolved_hypothesis_count: number;
174
+ /** Average quality score across thoughts with scores, null if none. */
175
+ readonly average_quality_score: number | null;
176
+ /** Average confidence across thoughts with confidence, null if none. */
177
+ readonly average_confidence: number | null;
178
+ }
179
+ //# sourceMappingURL=reasoning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoning.d.ts","sourceRoot":"","sources":["../../src/core/reasoning.ts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,EAAE,MAAM,CAAC;IAElC,0CAA0C;IAC1C,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAE3C,uCAAuC;IACvC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;IAE7C,uEAAuE;IACvE,QAAQ,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9C,wEAAwE;IACxE,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Step recommendation type for coordinated multi-step thought processes.
3
+ *
4
+ * @module types/step
5
+ */
6
+ import type { SkillRecommendation } from '../types/skill.js';
7
+ import type { ToolRecommendation } from '../types/tool.js';
8
+ /**
9
+ * Represents a coordinated step in a multi-step thought process.
10
+ *
11
+ * Step recommendations combine tool and skill recommendations to provide
12
+ * a comprehensive plan for completing a specific task, including expected
13
+ * outcomes and conditions for moving to the next step.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const step: StepRecommendation = {
18
+ * step_description: 'Search for TypeScript documentation',
19
+ * recommended_tools: [
20
+ * {
21
+ * tool_name: 'mcp__tavily-mcp__tavily-search',
22
+ * confidence: 0.9,
23
+ * rationale: 'Best for web search',
24
+ * priority: 1
25
+ * }
26
+ * ],
27
+ * recommended_skills: [],
28
+ * expected_outcome: 'Search results with TypeScript documentation links',
29
+ * next_step_conditions: ['If no results found, try broader search terms']
30
+ * };
31
+ * ```
32
+ *
33
+ * NOTE: Kept as a hand-written interface (not inferred from `StepRecommendationSchema`)
34
+ * because it composes `ToolRecommendation` / `SkillRecommendation`, which are themselves
35
+ * stricter than their schemas (required vs optional fields). An inferred type would
36
+ * weaken those nested guarantees.
37
+ */
38
+ export interface StepRecommendation {
39
+ /** Human-readable description of what needs to be done in this step. */
40
+ step_description: string;
41
+ /** Array of tools recommended for this step, ordered by priority. */
42
+ recommended_tools: ToolRecommendation[];
43
+ /** Optional array of skills recommended for this step. */
44
+ recommended_skills?: SkillRecommendation[];
45
+ /** Description of what to expect after completing this step. */
46
+ expected_outcome: string;
47
+ /** Optional conditions to consider when determining the next step. */
48
+ next_step_conditions?: string[];
49
+ }
50
+ //# sourceMappingURL=step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/core/step.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,kBAAkB;IAClC,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,CAAC;IAEzB,qEAAqE;IACrE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC;IAExC,0DAA0D;IAC1D,kBAAkB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAE3C,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC;IAEzB,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Core data structure for a thought in the sequential thinking process.
3
+ *
4
+ * @module types/thought
5
+ */
6
+ import type { BranchId, SessionId, ThoughtId, SuspensionToken } from '../contracts/ids.js';
7
+ import type { SchemaOutput } from '../schema.js';
8
+ import type { StepRecommendation } from './step.js';
9
+ /**
10
+ * Core data structure for a thought in the sequential thinking process.
11
+ *
12
+ * Thoughts represent individual reasoning steps that can be chained together
13
+ * to form complex reasoning chains. Each thought can reference previous thoughts,
14
+ * create branches, and include tool/skill recommendations.
15
+ *
16
+ * @remarks
17
+ * - Thoughts are numbered sequentially within a branch
18
+ * - Branching allows exploring alternative reasoning paths
19
+ * - Revisions allow correcting or updating previous thoughts
20
+ * - The `next_thought_needed` flag controls continuation
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const thought: ThoughtData = {
25
+ * available_mcp_tools: ['Read', 'Write', 'Bash'],
26
+ * available_skills: ['commit', 'pdf'],
27
+ * thought: 'I should read the package.json to understand dependencies',
28
+ * thought_number: 1,
29
+ * total_thoughts: 5,
30
+ * next_thought_needed: true,
31
+ * current_step: {
32
+ * step_description: 'Read package.json',
33
+ * recommended_tools: [{
34
+ * tool_name: 'Read',
35
+ * confidence: 1.0,
36
+ * rationale: 'Direct file reading',
37
+ * priority: 1
38
+ * }],
39
+ * expected_outcome: 'Contents of package.json'
40
+ * }
41
+ * };
42
+ * ```
43
+ */
44
+ export type ThoughtData = Omit<SchemaOutput, 'id' | 'session_id' | 'continuation_token' | 'register_branch_id' | 'branch_id' | 'merge_branch_ids' | 'current_step' | 'previous_steps'> & {
45
+ /** Unique identifier for this thought (branded ThoughtId). Auto-generated when not provided. */
46
+ id?: ThoughtId;
47
+ /** Session identifier (branded SessionId) for state isolation. */
48
+ session_id?: SessionId;
49
+ /** Continuation token (branded SuspensionToken) linking tool_observation back to suspended tool_call. */
50
+ continuation_token?: SuspensionToken;
51
+ /** Branch identifier (branded BranchId) for branching reasoning paths. */
52
+ branch_id?: BranchId;
53
+ /** Branch identifiers (branded BranchId[]) being merged into current context. */
54
+ merge_branch_ids?: BranchId[];
55
+ /**
56
+ * When true, this thought has been logically retracted by a subsequent
57
+ * `backtrack` thought. The thought remains in history (append-only,
58
+ * event-sourcing) but is excluded from quality calculations.
59
+ * Default: false. Not part of schema input — set by ThoughtProcessor during processing.
60
+ */
61
+ retracted?: boolean;
62
+ /** Current step recommendation (post-normalization, with defaults filled). */
63
+ current_step?: StepRecommendation;
64
+ /** Previously recommended steps (post-normalization, with defaults filled). */
65
+ previous_steps?: StepRecommendation[];
66
+ };
67
+ /**
68
+ * Discriminated union variants of `ThoughtData` after `_validateNewTypes`
69
+ * has guaranteed per-type invariants. Allows downstream methods to consume
70
+ * narrowed thoughts without `!` non-null assertions.
71
+ */
72
+ import type { ThoughtType } from './reasoning.js';
73
+ /** A `tool_call` thought with `tool_name` guaranteed by validation. */
74
+ export type ToolCallThought = ThoughtData & {
75
+ readonly thought_type: 'tool_call';
76
+ readonly tool_name: string;
77
+ };
78
+ /** A `tool_observation` thought with `continuation_token` guaranteed. */
79
+ export type ToolObservationThought = ThoughtData & {
80
+ readonly thought_type: 'tool_observation';
81
+ readonly continuation_token: SuspensionToken;
82
+ };
83
+ /** A `backtrack` thought with `backtrack_target` guaranteed. */
84
+ export type BacktrackThought = ThoughtData & {
85
+ readonly thought_type: 'backtrack';
86
+ readonly backtrack_target: number;
87
+ };
88
+ /** A `verification` thought with `verification_target` guaranteed. */
89
+ export type VerificationThought = ThoughtData & {
90
+ readonly thought_type: 'verification';
91
+ readonly verification_target: number;
92
+ };
93
+ /** A `critique` thought with `verification_target` guaranteed. */
94
+ export type CritiqueThought = ThoughtData & {
95
+ readonly thought_type: 'critique';
96
+ readonly verification_target: number;
97
+ };
98
+ /** A `synthesis` thought with non-empty `synthesis_sources` guaranteed. */
99
+ export type SynthesisThought = ThoughtData & {
100
+ readonly thought_type: 'synthesis';
101
+ readonly synthesis_sources: readonly number[];
102
+ };
103
+ /** Catch-all for thought types with no per-type field invariants. */
104
+ export type BaseThought = ThoughtData & {
105
+ readonly thought_type: Exclude<ThoughtType, 'tool_call' | 'tool_observation' | 'backtrack' | 'verification' | 'critique' | 'synthesis'>;
106
+ };
107
+ /**
108
+ * Discriminated union of validated thoughts. Returned by
109
+ * `ThoughtProcessor._validateNewTypes` to encode invariants in the type system
110
+ * and eliminate `!` non-null assertions in downstream handlers.
111
+ */
112
+ export type ValidatedThought = ToolCallThought | ToolObservationThought | BacktrackThought | VerificationThought | CritiqueThought | SynthesisThought | BaseThought;
113
+ //# sourceMappingURL=thought.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thought.d.ts","sourceRoot":"","sources":["../../src/core/thought.ts"],"names":[],"mappings":"AAAA;;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BAAkB,EAAE,eAAe,CAAC;CAC7C,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAC5C,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC/C,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAC;IACtC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC3C,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAC5C,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C,CAAC;AAEF,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACvC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAC7B,WAAW,EACX,WAAW,GAAG,kBAAkB,GAAG,WAAW,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,CAC1F,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACzB,eAAe,GACf,sBAAsB,GACtB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * In-memory implementation of {@link ISuspensionStore}.
3
+ *
4
+ * Stores suspension records in process memory with optional background
5
+ * sweeping of expired entries. Suitable for single-process deployments;
6
+ * cluster setups should provide a shared backend.
7
+ *
8
+ * @module core/tools/InMemorySuspensionStore
9
+ */
10
+ import type { ISuspensionStore, SuspensionRecord } from '../../contracts/suspension.js';
11
+ import { type SessionId, type SuspensionToken } from '../../contracts/ids.js';
12
+ import type { Logger } from '../../logger/StructuredLogger.js';
13
+ /**
14
+ * Configuration for {@link InMemorySuspensionStore}.
15
+ */
16
+ export interface InMemorySuspensionStoreConfig {
17
+ /** Default TTL applied to records that omit `ttlMs`. Defaults to 60_000ms. */
18
+ ttlMs?: number;
19
+ /** Sweep interval for the background expiry timer. Defaults to 60_000ms. */
20
+ sweepIntervalMs?: number;
21
+ /** Optional logger; reserved for future diagnostic output. */
22
+ /** Optional logger for diagnostic output. */
23
+ logger?: Logger;
24
+ }
25
+ /**
26
+ * In-memory suspension store with TTL expiry and background sweep.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const store = new InMemorySuspensionStore({ ttlMs: 30_000 });
31
+ * store.start();
32
+ * const rec = store.suspend({
33
+ * sessionId: 's1',
34
+ * toolCallThoughtNumber: 3,
35
+ * toolCallThoughtId: 'thought-3',
36
+ * toolName: 'search',
37
+ * toolArguments: { q: 'foo' },
38
+ * expiresAt: 0,
39
+ * });
40
+ * const resumed = store.resume(rec.token);
41
+ * store.stop();
42
+ * ```
43
+ */
44
+ export declare class InMemorySuspensionStore implements ISuspensionStore {
45
+ private readonly _byToken;
46
+ private readonly _bySession;
47
+ private readonly _admissionTails;
48
+ private readonly _ttlMs;
49
+ private readonly _sweepIntervalMs;
50
+ private _timer;
51
+ constructor(config?: InMemorySuspensionStoreConfig);
52
+ suspend(record: Omit<SuspensionRecord, 'token' | 'createdAt'> & {
53
+ ttlMs?: number;
54
+ }): SuspensionRecord;
55
+ resume(token: string): SuspensionRecord | null;
56
+ compareAndAdmit(token: SuspensionToken, expectedSessionId: SessionId, admit: (record: SuspensionRecord) => void): Promise<SuspensionRecord>;
57
+ peek(token: string): SuspensionRecord | null;
58
+ expireOlderThan(now: number): number;
59
+ clearSession(sessionId: string): void;
60
+ clearAll(): void;
61
+ size(sessionId?: string): number;
62
+ start(): void;
63
+ stop(): void;
64
+ private _delete;
65
+ }
66
+ //# sourceMappingURL=InMemorySuspensionStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InMemorySuspensionStore.d.ts","sourceRoot":"","sources":["../../../src/core/tools/InMemorySuspensionStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAGN,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAG/D;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC7C,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAC/D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqD;IAC9E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmD;IAC9E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkD;IAClF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,MAAM,CAA+C;gBAEjD,MAAM,GAAE,6BAAkC;IAKtD,OAAO,CACN,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,WAAW,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACxE,gBAAgB;IA4BnB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAWxC,eAAe,CACpB,KAAK,EAAE,eAAe,EACtB,iBAAiB,EAAE,SAAS,EAC5B,KAAK,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,GACvC,OAAO,CAAC,gBAAgB,CAAC;IAsC5B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAI5C,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAWpC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IASrC,QAAQ,IAAI,IAAI;IAKhB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAKhC,KAAK,IAAI,IAAI;IAQb,IAAI,IAAI,IAAI;IAMZ,OAAO,CAAC,OAAO;CAQf"}
@@ -0,0 +1,121 @@
1
+ import { asSessionId, generateSuspensionToken } from "../../contracts/ids.js";
2
+ import { SuspensionExpiredError, SuspensionNotFoundError } from "../../errors.js";
3
+ const DEFAULT_TTL_MS = 300000;
4
+ const DEFAULT_SWEEP_INTERVAL_MS = 60000;
5
+ class InMemorySuspensionStore {
6
+ _byToken = new Map();
7
+ _bySession = new Map();
8
+ _admissionTails = new Map();
9
+ _ttlMs;
10
+ _sweepIntervalMs;
11
+ _timer = null;
12
+ constructor(config = {}){
13
+ this._ttlMs = config.ttlMs ?? DEFAULT_TTL_MS;
14
+ this._sweepIntervalMs = config.sweepIntervalMs ?? DEFAULT_SWEEP_INTERVAL_MS;
15
+ }
16
+ suspend(record) {
17
+ const token = generateSuspensionToken();
18
+ const createdAt = Date.now();
19
+ const ttlMs = record.ttlMs ?? this._ttlMs;
20
+ const expiresAt = createdAt + ttlMs;
21
+ const full = {
22
+ token,
23
+ sessionId: record.sessionId,
24
+ toolCallThoughtNumber: record.toolCallThoughtNumber,
25
+ toolCallThoughtId: record.toolCallThoughtId,
26
+ toolName: record.toolName,
27
+ toolArguments: record.toolArguments,
28
+ createdAt,
29
+ expiresAt
30
+ };
31
+ this._byToken.set(token, full);
32
+ let bucket = this._bySession.get(full.sessionId);
33
+ if (!bucket) {
34
+ bucket = new Set();
35
+ this._bySession.set(full.sessionId, bucket);
36
+ }
37
+ bucket.add(token);
38
+ return full;
39
+ }
40
+ resume(token) {
41
+ const rec = this._byToken.get(token);
42
+ if (!rec) return null;
43
+ if (rec.expiresAt <= Date.now()) {
44
+ this._delete(token, rec.sessionId);
45
+ return null;
46
+ }
47
+ this._delete(token, rec.sessionId);
48
+ return rec;
49
+ }
50
+ async compareAndAdmit(token, expectedSessionId, admit) {
51
+ const previous = this._admissionTails.get(token) ?? Promise.resolve();
52
+ const release = Promise.withResolvers();
53
+ const tail = previous.then(()=>release.promise, ()=>release.promise);
54
+ this._admissionTails.set(token, tail);
55
+ try {
56
+ await previous.then(()=>void 0, ()=>void 0);
57
+ const record = this._byToken.get(token);
58
+ if (void 0 === record) throw new SuspensionNotFoundError('Suspension token not found: ' + token);
59
+ const now = Date.now();
60
+ if (record.expiresAt <= now) {
61
+ this._delete(token, record.sessionId);
62
+ throw new SuspensionExpiredError('Suspension token expired: ' + token);
63
+ }
64
+ if (record.sessionId !== expectedSessionId) throw new SuspensionNotFoundError('Suspension token not found: ' + token);
65
+ admit(record);
66
+ this._delete(token, record.sessionId);
67
+ return record;
68
+ } finally{
69
+ release.resolve();
70
+ if (this._admissionTails.get(token) === tail) this._admissionTails.delete(token);
71
+ }
72
+ }
73
+ peek(token) {
74
+ return this._byToken.get(token) ?? null;
75
+ }
76
+ expireOlderThan(now) {
77
+ let removed = 0;
78
+ for (const [token, rec] of this._byToken)if (rec.expiresAt <= now) {
79
+ this._delete(token, rec.sessionId);
80
+ removed++;
81
+ }
82
+ return removed;
83
+ }
84
+ clearSession(sessionId) {
85
+ const bucket = this._bySession.get(asSessionId(sessionId));
86
+ if (!bucket) return;
87
+ for (const token of bucket)this._byToken.delete(token);
88
+ this._bySession.delete(asSessionId(sessionId));
89
+ }
90
+ clearAll() {
91
+ this._byToken.clear();
92
+ this._bySession.clear();
93
+ }
94
+ size(sessionId) {
95
+ if (void 0 === sessionId) return this._byToken.size;
96
+ return this._bySession.get(asSessionId(sessionId))?.size ?? 0;
97
+ }
98
+ start() {
99
+ if (null !== this._timer) return;
100
+ this._timer = setInterval(()=>{
101
+ this.expireOlderThan(Date.now());
102
+ }, this._sweepIntervalMs);
103
+ this._timer.unref?.();
104
+ }
105
+ stop() {
106
+ if (null === this._timer) return;
107
+ clearInterval(this._timer);
108
+ this._timer = null;
109
+ }
110
+ _delete(token, sessionId) {
111
+ this._byToken.delete(token);
112
+ const bucket = this._bySession.get(sessionId);
113
+ if (bucket) {
114
+ bucket.delete(token);
115
+ if (0 === bucket.size) this._bySession.delete(sessionId);
116
+ }
117
+ }
118
+ }
119
+ export { InMemorySuspensionStore };
120
+
121
+ //# sourceMappingURL=InMemorySuspensionStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core/tools/InMemorySuspensionStore.js","sources":["../../../src/core/tools/InMemorySuspensionStore.ts"],"sourcesContent":["/**\n * In-memory implementation of {@link ISuspensionStore}.\n *\n * Stores suspension records in process memory with optional background\n * sweeping of expired entries. Suitable for single-process deployments;\n * cluster setups should provide a shared backend.\n *\n * @module core/tools/InMemorySuspensionStore\n */\n\nimport type { ISuspensionStore, SuspensionRecord } from '../../contracts/suspension.js';\nimport {\n\tgenerateSuspensionToken,\n\tasSessionId,\n\ttype SessionId,\n\ttype SuspensionToken,\n} from '../../contracts/ids.js';\nimport type { Logger } from '../../logger/StructuredLogger.js';\nimport { SuspensionExpiredError, SuspensionNotFoundError } from '../../errors.js';\n\n/**\n * Configuration for {@link InMemorySuspensionStore}.\n */\nexport interface InMemorySuspensionStoreConfig {\n\t/** Default TTL applied to records that omit `ttlMs`. Defaults to 60_000ms. */\n\tttlMs?: number;\n\t/** Sweep interval for the background expiry timer. Defaults to 60_000ms. */\n\tsweepIntervalMs?: number;\n\t/** Optional logger; reserved for future diagnostic output. */\n\t/** Optional logger for diagnostic output. */\n\tlogger?: Logger;\n}\n\nconst DEFAULT_TTL_MS = 300_000;\nconst DEFAULT_SWEEP_INTERVAL_MS = 60_000;\n\n/**\n * In-memory suspension store with TTL expiry and background sweep.\n *\n * @example\n * ```typescript\n * const store = new InMemorySuspensionStore({ ttlMs: 30_000 });\n * store.start();\n * const rec = store.suspend({\n * sessionId: 's1',\n * toolCallThoughtNumber: 3,\n * toolCallThoughtId: 'thought-3',\n * toolName: 'search',\n * toolArguments: { q: 'foo' },\n * expiresAt: 0,\n * });\n * const resumed = store.resume(rec.token);\n * store.stop();\n * ```\n */\nexport class InMemorySuspensionStore implements ISuspensionStore {\n\tprivate readonly _byToken: Map<SuspensionToken, SuspensionRecord> = new Map();\n\tprivate readonly _bySession: Map<SessionId, Set<SuspensionToken>> = new Map();\n\tprivate readonly _admissionTails: Map<SuspensionToken, Promise<void>> = new Map();\n\tprivate readonly _ttlMs: number;\n\tprivate readonly _sweepIntervalMs: number;\n\tprivate _timer: ReturnType<typeof setInterval> | null = null;\n\n\tconstructor(config: InMemorySuspensionStoreConfig = {}) {\n\t\tthis._ttlMs = config.ttlMs ?? DEFAULT_TTL_MS;\n\t\tthis._sweepIntervalMs = config.sweepIntervalMs ?? DEFAULT_SWEEP_INTERVAL_MS;\n\t}\n\n\tsuspend(\n\t\trecord: Omit<SuspensionRecord, 'token' | 'createdAt'> & { ttlMs?: number }\n\t): SuspensionRecord {\n\t\tconst token = generateSuspensionToken();\n\t\tconst createdAt = Date.now();\n\t\tconst ttlMs = record.ttlMs ?? this._ttlMs;\n\t\tconst expiresAt = createdAt + ttlMs;\n\n\t\tconst full: SuspensionRecord = {\n\t\t\ttoken,\n\t\t\tsessionId: record.sessionId,\n\t\t\ttoolCallThoughtNumber: record.toolCallThoughtNumber,\n\t\t\ttoolCallThoughtId: record.toolCallThoughtId,\n\t\t\ttoolName: record.toolName,\n\t\t\ttoolArguments: record.toolArguments,\n\t\t\tcreatedAt,\n\t\t\texpiresAt,\n\t\t};\n\n\t\tthis._byToken.set(token, full);\n\t\tlet bucket = this._bySession.get(full.sessionId);\n\t\tif (!bucket) {\n\t\t\tbucket = new Set();\n\t\t\tthis._bySession.set(full.sessionId, bucket);\n\t\t}\n\t\tbucket.add(token);\n\n\t\treturn full;\n\t}\n\n\tresume(token: string): SuspensionRecord | null {\n\t\tconst rec = this._byToken.get(token as SuspensionToken);\n\t\tif (!rec) return null;\n\t\tif (rec.expiresAt <= Date.now()) {\n\t\t\tthis._delete(token as SuspensionToken, rec.sessionId);\n\t\t\treturn null;\n\t\t}\n\t\tthis._delete(token as SuspensionToken, rec.sessionId);\n\t\treturn rec;\n\t}\n\n\tasync compareAndAdmit(\n\t\ttoken: SuspensionToken,\n\t\texpectedSessionId: SessionId,\n\t\tadmit: (record: SuspensionRecord) => void\n\t): Promise<SuspensionRecord> {\n\t\tconst previous = this._admissionTails.get(token) ?? Promise.resolve();\n\t\tconst release = Promise.withResolvers<void>();\n\t\tconst tail = previous.then(\n\t\t\t() => release.promise,\n\t\t\t() => release.promise\n\t\t);\n\t\tthis._admissionTails.set(token, tail);\n\n\t\ttry {\n\t\t\tawait previous.then(\n\t\t\t\t() => undefined,\n\t\t\t\t() => undefined\n\t\t\t);\n\t\t\tconst record = this._byToken.get(token);\n\t\t\tif (record === undefined) {\n\t\t\t\tthrow new SuspensionNotFoundError('Suspension token not found: ' + token);\n\t\t\t}\n\t\t\tconst now = Date.now();\n\t\t\tif (record.expiresAt <= now) {\n\t\t\t\tthis._delete(token, record.sessionId);\n\t\t\t\tthrow new SuspensionExpiredError('Suspension token expired: ' + token);\n\t\t\t}\n\t\t\tif (record.sessionId !== expectedSessionId) {\n\t\t\t\tthrow new SuspensionNotFoundError('Suspension token not found: ' + token);\n\t\t\t}\n\n\t\t\tadmit(record);\n\t\t\tthis._delete(token, record.sessionId);\n\t\t\treturn record;\n\t\t} finally {\n\t\t\trelease.resolve();\n\t\t\tif (this._admissionTails.get(token) === tail) {\n\t\t\t\tthis._admissionTails.delete(token);\n\t\t\t}\n\t\t}\n\t}\n\n\tpeek(token: string): SuspensionRecord | null {\n\t\treturn this._byToken.get(token as SuspensionToken) ?? null;\n\t}\n\n\texpireOlderThan(now: number): number {\n\t\tlet removed = 0;\n\t\tfor (const [token, rec] of this._byToken) {\n\t\t\tif (rec.expiresAt <= now) {\n\t\t\t\tthis._delete(token, rec.sessionId);\n\t\t\t\tremoved++;\n\t\t\t}\n\t\t}\n\t\treturn removed;\n\t}\n\n\tclearSession(sessionId: string): void {\n\t\tconst bucket = this._bySession.get(asSessionId(sessionId));\n\t\tif (!bucket) return;\n\t\tfor (const token of bucket) {\n\t\t\tthis._byToken.delete(token);\n\t\t}\n\t\tthis._bySession.delete(asSessionId(sessionId));\n\t}\n\n\tclearAll(): void {\n\t\tthis._byToken.clear();\n\t\tthis._bySession.clear();\n\t}\n\n\tsize(sessionId?: string): number {\n\t\tif (sessionId === undefined) return this._byToken.size;\n\t\treturn this._bySession.get(asSessionId(sessionId))?.size ?? 0;\n\t}\n\n\tstart(): void {\n\t\tif (this._timer !== null) return;\n\t\tthis._timer = setInterval(() => {\n\t\t\tthis.expireOlderThan(Date.now());\n\t\t}, this._sweepIntervalMs);\n\t\tthis._timer.unref?.();\n\t}\n\n\tstop(): void {\n\t\tif (this._timer === null) return;\n\t\tclearInterval(this._timer);\n\t\tthis._timer = null;\n\t}\n\n\tprivate _delete(token: SuspensionToken, sessionId: SessionId): void {\n\t\tthis._byToken.delete(token);\n\t\tconst bucket = this._bySession.get(sessionId);\n\t\tif (bucket) {\n\t\t\tbucket.delete(token);\n\t\t\tif (bucket.size === 0) this._bySession.delete(sessionId);\n\t\t}\n\t}\n}\n"],"names":["DEFAULT_TTL_MS","DEFAULT_SWEEP_INTERVAL_MS","InMemorySuspensionStore","Map","config","record","token","generateSuspensionToken","createdAt","Date","ttlMs","expiresAt","full","bucket","Set","rec","expectedSessionId","admit","previous","Promise","release","tail","undefined","SuspensionNotFoundError","now","SuspensionExpiredError","removed","sessionId","asSessionId","setInterval","clearInterval"],"m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