tracelattice 1.2.5

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 (294) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +112 -0
  3. package/dist/ServerConfig.d.ts +229 -0
  4. package/dist/ServerConfig.d.ts.map +1 -0
  5. package/dist/ServerConfig.js +121 -0
  6. package/dist/ServerConfig.js.map +1 -0
  7. package/dist/__tests__/base-registry.test.d.ts +2 -0
  8. package/dist/__tests__/base-registry.test.d.ts.map +1 -0
  9. package/dist/__tests__/base-transport-cov.test.d.ts +2 -0
  10. package/dist/__tests__/base-transport-cov.test.d.ts.map +1 -0
  11. package/dist/__tests__/base-transport.test.d.ts +2 -0
  12. package/dist/__tests__/base-transport.test.d.ts.map +1 -0
  13. package/dist/__tests__/config-loader.test.d.ts +2 -0
  14. package/dist/__tests__/config-loader.test.d.ts.map +1 -0
  15. package/dist/__tests__/connection-pool-cov.test.d.ts +2 -0
  16. package/dist/__tests__/connection-pool-cov.test.d.ts.map +1 -0
  17. package/dist/__tests__/connection-pool.test.d.ts +2 -0
  18. package/dist/__tests__/connection-pool.test.d.ts.map +1 -0
  19. package/dist/__tests__/container.test.d.ts +2 -0
  20. package/dist/__tests__/container.test.d.ts.map +1 -0
  21. package/dist/__tests__/crud.test.d.ts +2 -0
  22. package/dist/__tests__/crud.test.d.ts.map +1 -0
  23. package/dist/__tests__/discovery-cache.test.d.ts +2 -0
  24. package/dist/__tests__/discovery-cache.test.d.ts.map +1 -0
  25. package/dist/__tests__/errors.test.d.ts +2 -0
  26. package/dist/__tests__/errors.test.d.ts.map +1 -0
  27. package/dist/__tests__/factories.test.d.ts +2 -0
  28. package/dist/__tests__/factories.test.d.ts.map +1 -0
  29. package/dist/__tests__/health-checker-cov.test.d.ts +2 -0
  30. package/dist/__tests__/health-checker-cov.test.d.ts.map +1 -0
  31. package/dist/__tests__/health-checker.test.d.ts +2 -0
  32. package/dist/__tests__/health-checker.test.d.ts.map +1 -0
  33. package/dist/__tests__/helpers/factories.d.ts +36 -0
  34. package/dist/__tests__/helpers/factories.d.ts.map +1 -0
  35. package/dist/__tests__/helpers/index.d.ts +3 -0
  36. package/dist/__tests__/helpers/index.d.ts.map +1 -0
  37. package/dist/__tests__/helpers/timers.d.ts +4 -0
  38. package/dist/__tests__/helpers/timers.d.ts.map +1 -0
  39. package/dist/__tests__/history-manager.test.d.ts +2 -0
  40. package/dist/__tests__/history-manager.test.d.ts.map +1 -0
  41. package/dist/__tests__/http-helpers-cov.test.d.ts +2 -0
  42. package/dist/__tests__/http-helpers-cov.test.d.ts.map +1 -0
  43. package/dist/__tests__/http-transport-cov.test.d.ts +2 -0
  44. package/dist/__tests__/http-transport-cov.test.d.ts.map +1 -0
  45. package/dist/__tests__/http-transport.test.d.ts +2 -0
  46. package/dist/__tests__/http-transport.test.d.ts.map +1 -0
  47. package/dist/__tests__/input-normalizer.test.d.ts +8 -0
  48. package/dist/__tests__/input-normalizer.test.d.ts.map +1 -0
  49. package/dist/__tests__/integration.test.d.ts +2 -0
  50. package/dist/__tests__/integration.test.d.ts.map +1 -0
  51. package/dist/__tests__/lib-server.test.d.ts +2 -0
  52. package/dist/__tests__/lib-server.test.d.ts.map +1 -0
  53. package/dist/__tests__/memory-persistence.test.d.ts +2 -0
  54. package/dist/__tests__/memory-persistence.test.d.ts.map +1 -0
  55. package/dist/__tests__/metrics-integration.test.d.ts +2 -0
  56. package/dist/__tests__/metrics-integration.test.d.ts.map +1 -0
  57. package/dist/__tests__/persistence.test.d.ts +2 -0
  58. package/dist/__tests__/persistence.test.d.ts.map +1 -0
  59. package/dist/__tests__/reasoning-integration.test.d.ts +11 -0
  60. package/dist/__tests__/reasoning-integration.test.d.ts.map +1 -0
  61. package/dist/__tests__/reasoning-types.test.d.ts +2 -0
  62. package/dist/__tests__/reasoning-types.test.d.ts.map +1 -0
  63. package/dist/__tests__/request-context.test.d.ts +2 -0
  64. package/dist/__tests__/request-context.test.d.ts.map +1 -0
  65. package/dist/__tests__/sanitize.test.d.ts +2 -0
  66. package/dist/__tests__/sanitize.test.d.ts.map +1 -0
  67. package/dist/__tests__/schema.test.d.ts +2 -0
  68. package/dist/__tests__/schema.test.d.ts.map +1 -0
  69. package/dist/__tests__/sequentialthinking-tools.test.d.ts +2 -0
  70. package/dist/__tests__/sequentialthinking-tools.test.d.ts.map +1 -0
  71. package/dist/__tests__/server-config.test.d.ts +2 -0
  72. package/dist/__tests__/server-config.test.d.ts.map +1 -0
  73. package/dist/__tests__/skill-discovery.test.d.ts +2 -0
  74. package/dist/__tests__/skill-discovery.test.d.ts.map +1 -0
  75. package/dist/__tests__/skill-registry.test.d.ts +2 -0
  76. package/dist/__tests__/skill-registry.test.d.ts.map +1 -0
  77. package/dist/__tests__/skill-watcher.test.d.ts +2 -0
  78. package/dist/__tests__/skill-watcher.test.d.ts.map +1 -0
  79. package/dist/__tests__/sqlite-persistence.test.d.ts +2 -0
  80. package/dist/__tests__/sqlite-persistence.test.d.ts.map +1 -0
  81. package/dist/__tests__/sse-transport-cov.test.d.ts +2 -0
  82. package/dist/__tests__/sse-transport-cov.test.d.ts.map +1 -0
  83. package/dist/__tests__/sse-transport.test.d.ts +2 -0
  84. package/dist/__tests__/sse-transport.test.d.ts.map +1 -0
  85. package/dist/__tests__/streamable-http-cov.test.d.ts +2 -0
  86. package/dist/__tests__/streamable-http-cov.test.d.ts.map +1 -0
  87. package/dist/__tests__/streamable-http-transport.test.d.ts +2 -0
  88. package/dist/__tests__/streamable-http-transport.test.d.ts.map +1 -0
  89. package/dist/__tests__/structured-logger.test.d.ts +2 -0
  90. package/dist/__tests__/structured-logger.test.d.ts.map +1 -0
  91. package/dist/__tests__/thought-evaluator.test.d.ts +2 -0
  92. package/dist/__tests__/thought-evaluator.test.d.ts.map +1 -0
  93. package/dist/__tests__/thought-formatter.test.d.ts +2 -0
  94. package/dist/__tests__/thought-formatter.test.d.ts.map +1 -0
  95. package/dist/__tests__/thought-processor.test.d.ts +8 -0
  96. package/dist/__tests__/thought-processor.test.d.ts.map +1 -0
  97. package/dist/__tests__/tool-registry-cov.test.d.ts +2 -0
  98. package/dist/__tests__/tool-registry-cov.test.d.ts.map +1 -0
  99. package/dist/__tests__/tool-registry.test.d.ts +2 -0
  100. package/dist/__tests__/tool-registry.test.d.ts.map +1 -0
  101. package/dist/__tests__/tool-watcher.test.d.ts +2 -0
  102. package/dist/__tests__/tool-watcher.test.d.ts.map +1 -0
  103. package/dist/__tests__/worker-manager-cov.test.d.ts +2 -0
  104. package/dist/__tests__/worker-manager-cov.test.d.ts.map +1 -0
  105. package/dist/__tests__/worker-manager.test.d.ts +2 -0
  106. package/dist/__tests__/worker-manager.test.d.ts.map +1 -0
  107. package/dist/cache/DiscoveryCache.d.ts +269 -0
  108. package/dist/cache/DiscoveryCache.d.ts.map +1 -0
  109. package/dist/cache/DiscoveryCache.js +100 -0
  110. package/dist/cache/DiscoveryCache.js.map +1 -0
  111. package/dist/cli.d.ts +3 -0
  112. package/dist/cli.d.ts.map +1 -0
  113. package/dist/cli.js +114 -0
  114. package/dist/cli.js.map +1 -0
  115. package/dist/cluster/WorkerManager.d.ts +166 -0
  116. package/dist/cluster/WorkerManager.d.ts.map +1 -0
  117. package/dist/cluster/WorkerManager.js +202 -0
  118. package/dist/cluster/WorkerManager.js.map +1 -0
  119. package/dist/cluster/worker.d.ts +11 -0
  120. package/dist/cluster/worker.d.ts.map +1 -0
  121. package/dist/cluster/worker.js +36 -0
  122. package/dist/cluster/worker.js.map +1 -0
  123. package/dist/config/ConfigLoader.d.ts +224 -0
  124. package/dist/config/ConfigLoader.d.ts.map +1 -0
  125. package/dist/config/ConfigLoader.js +85 -0
  126. package/dist/config/ConfigLoader.js.map +1 -0
  127. package/dist/context/RequestContext.d.ts +61 -0
  128. package/dist/context/RequestContext.d.ts.map +1 -0
  129. package/dist/context/RequestContext.js +17 -0
  130. package/dist/context/RequestContext.js.map +1 -0
  131. package/dist/contracts/index.d.ts +10 -0
  132. package/dist/contracts/index.d.ts.map +1 -0
  133. package/dist/contracts/index.js +1 -0
  134. package/dist/contracts/interfaces.d.ts +107 -0
  135. package/dist/contracts/interfaces.d.ts.map +1 -0
  136. package/dist/contracts/interfaces.js +1 -0
  137. package/dist/core/HistoryManager.d.ts +514 -0
  138. package/dist/core/HistoryManager.d.ts.map +1 -0
  139. package/dist/core/HistoryManager.js +331 -0
  140. package/dist/core/HistoryManager.js.map +1 -0
  141. package/dist/core/IHistoryManager.d.ts +100 -0
  142. package/dist/core/IHistoryManager.d.ts.map +1 -0
  143. package/dist/core/IHistoryManager.js +1 -0
  144. package/dist/core/InputNormalizer.d.ts +139 -0
  145. package/dist/core/InputNormalizer.d.ts.map +1 -0
  146. package/dist/core/InputNormalizer.js +101 -0
  147. package/dist/core/InputNormalizer.js.map +1 -0
  148. package/dist/core/ThoughtEvaluator.d.ts +127 -0
  149. package/dist/core/ThoughtEvaluator.d.ts.map +1 -0
  150. package/dist/core/ThoughtEvaluator.js +346 -0
  151. package/dist/core/ThoughtEvaluator.js.map +1 -0
  152. package/dist/core/ThoughtFormatter.d.ts +133 -0
  153. package/dist/core/ThoughtFormatter.d.ts.map +1 -0
  154. package/dist/core/ThoughtFormatter.js +70 -0
  155. package/dist/core/ThoughtFormatter.js.map +1 -0
  156. package/dist/core/ThoughtProcessor.d.ts +218 -0
  157. package/dist/core/ThoughtProcessor.d.ts.map +1 -0
  158. package/dist/core/ThoughtProcessor.js +205 -0
  159. package/dist/core/ThoughtProcessor.js.map +1 -0
  160. package/dist/core/reasoning.d.ts +169 -0
  161. package/dist/core/reasoning.d.ts.map +1 -0
  162. package/dist/core/reasoning.js +1 -0
  163. package/dist/core/step.d.ts +45 -0
  164. package/dist/core/step.d.ts.map +1 -0
  165. package/dist/core/step.js +1 -0
  166. package/dist/core/thought.d.ts +190 -0
  167. package/dist/core/thought.d.ts.map +1 -0
  168. package/dist/core/thought.js +1 -0
  169. package/dist/di/Container.d.ts +226 -0
  170. package/dist/di/Container.d.ts.map +1 -0
  171. package/dist/di/Container.js +96 -0
  172. package/dist/di/Container.js.map +1 -0
  173. package/dist/di/ServiceRegistry.d.ts +32 -0
  174. package/dist/di/ServiceRegistry.d.ts.map +1 -0
  175. package/dist/di/ServiceRegistry.js +1 -0
  176. package/dist/errors.d.ts +482 -0
  177. package/dist/errors.d.ts.map +1 -0
  178. package/dist/errors.js +108 -0
  179. package/dist/errors.js.map +1 -0
  180. package/dist/health/HealthChecker.d.ts +73 -0
  181. package/dist/health/HealthChecker.d.ts.map +1 -0
  182. package/dist/health/HealthChecker.js +69 -0
  183. package/dist/health/HealthChecker.js.map +1 -0
  184. package/dist/index.d.ts +2 -0
  185. package/dist/index.d.ts.map +1 -0
  186. package/dist/index.js +1 -0
  187. package/dist/lib.d.ts +205 -0
  188. package/dist/lib.d.ts.map +1 -0
  189. package/dist/lib.js +219 -0
  190. package/dist/lib.js.map +1 -0
  191. package/dist/logger/NullLogger.d.ts +154 -0
  192. package/dist/logger/NullLogger.d.ts.map +1 -0
  193. package/dist/logger/NullLogger.js +24 -0
  194. package/dist/logger/NullLogger.js.map +1 -0
  195. package/dist/logger/StructuredLogger.d.ts +327 -0
  196. package/dist/logger/StructuredLogger.d.ts.map +1 -0
  197. package/dist/logger/StructuredLogger.js +72 -0
  198. package/dist/logger/StructuredLogger.js.map +1 -0
  199. package/dist/metrics/__tests__/metrics.test.d.ts +2 -0
  200. package/dist/metrics/__tests__/metrics.test.d.ts.map +1 -0
  201. package/dist/metrics/metrics.impl.d.ts +252 -0
  202. package/dist/metrics/metrics.impl.d.ts.map +1 -0
  203. package/dist/metrics/metrics.impl.js +197 -0
  204. package/dist/metrics/metrics.impl.js.map +1 -0
  205. package/dist/persistence/FilePersistence.d.ts +66 -0
  206. package/dist/persistence/FilePersistence.d.ts.map +1 -0
  207. package/dist/persistence/FilePersistence.js +132 -0
  208. package/dist/persistence/FilePersistence.js.map +1 -0
  209. package/dist/persistence/MemoryPersistence.d.ts +68 -0
  210. package/dist/persistence/MemoryPersistence.d.ts.map +1 -0
  211. package/dist/persistence/MemoryPersistence.js +51 -0
  212. package/dist/persistence/MemoryPersistence.js.map +1 -0
  213. package/dist/persistence/PersistenceBackend.d.ts +69 -0
  214. package/dist/persistence/PersistenceBackend.d.ts.map +1 -0
  215. package/dist/persistence/PersistenceBackend.js +1 -0
  216. package/dist/persistence/PersistenceFactory.d.ts +21 -0
  217. package/dist/persistence/PersistenceFactory.d.ts.map +1 -0
  218. package/dist/persistence/PersistenceFactory.js +25 -0
  219. package/dist/persistence/PersistenceFactory.js.map +1 -0
  220. package/dist/persistence/SqlitePersistence.d.ts +60 -0
  221. package/dist/persistence/SqlitePersistence.d.ts.map +1 -0
  222. package/dist/persistence/SqlitePersistence.js +136 -0
  223. package/dist/persistence/SqlitePersistence.js.map +1 -0
  224. package/dist/pool/ConnectionPool.d.ts +215 -0
  225. package/dist/pool/ConnectionPool.d.ts.map +1 -0
  226. package/dist/pool/ConnectionPool.js +187 -0
  227. package/dist/pool/ConnectionPool.js.map +1 -0
  228. package/dist/registry/BaseRegistry.d.ts +203 -0
  229. package/dist/registry/BaseRegistry.d.ts.map +1 -0
  230. package/dist/registry/BaseRegistry.js +165 -0
  231. package/dist/registry/BaseRegistry.js.map +1 -0
  232. package/dist/registry/SkillRegistry.d.ts +69 -0
  233. package/dist/registry/SkillRegistry.d.ts.map +1 -0
  234. package/dist/registry/SkillRegistry.js +88 -0
  235. package/dist/registry/SkillRegistry.js.map +1 -0
  236. package/dist/registry/ToolRegistry.d.ts +69 -0
  237. package/dist/registry/ToolRegistry.d.ts.map +1 -0
  238. package/dist/registry/ToolRegistry.js +93 -0
  239. package/dist/registry/ToolRegistry.js.map +1 -0
  240. package/dist/sanitize.d.ts +63 -0
  241. package/dist/sanitize.d.ts.map +1 -0
  242. package/dist/sanitize.js +14 -0
  243. package/dist/sanitize.js.map +1 -0
  244. package/dist/schema.d.ts +531 -0
  245. package/dist/schema.d.ts.map +1 -0
  246. package/dist/schema.js +204 -0
  247. package/dist/schema.js.map +1 -0
  248. package/dist/telemetry/Telemetry.d.ts +36 -0
  249. package/dist/telemetry/Telemetry.d.ts.map +1 -0
  250. package/dist/telemetry/Telemetry.js +68 -0
  251. package/dist/telemetry/Telemetry.js.map +1 -0
  252. package/dist/telemetry/__tests__/Telemetry.test.d.ts +2 -0
  253. package/dist/telemetry/__tests__/Telemetry.test.d.ts.map +1 -0
  254. package/dist/transport/BaseTransport.d.ts +184 -0
  255. package/dist/transport/BaseTransport.d.ts.map +1 -0
  256. package/dist/transport/BaseTransport.js +200 -0
  257. package/dist/transport/BaseTransport.js.map +1 -0
  258. package/dist/transport/HttpHelpers.d.ts +60 -0
  259. package/dist/transport/HttpHelpers.d.ts.map +1 -0
  260. package/dist/transport/HttpHelpers.js +50 -0
  261. package/dist/transport/HttpHelpers.js.map +1 -0
  262. package/dist/transport/HttpTransport.d.ts +134 -0
  263. package/dist/transport/HttpTransport.d.ts.map +1 -0
  264. package/dist/transport/HttpTransport.js +175 -0
  265. package/dist/transport/HttpTransport.js.map +1 -0
  266. package/dist/transport/SseTransport.d.ts +133 -0
  267. package/dist/transport/SseTransport.d.ts.map +1 -0
  268. package/dist/transport/SseTransport.js +318 -0
  269. package/dist/transport/SseTransport.js.map +1 -0
  270. package/dist/transport/StreamableHttpTransport.d.ts +224 -0
  271. package/dist/transport/StreamableHttpTransport.d.ts.map +1 -0
  272. package/dist/transport/StreamableHttpTransport.js +407 -0
  273. package/dist/transport/StreamableHttpTransport.js.map +1 -0
  274. package/dist/types/disposable.d.ts +22 -0
  275. package/dist/types/disposable.d.ts.map +1 -0
  276. package/dist/types/disposable.js +1 -0
  277. package/dist/types/server-config.d.ts +32 -0
  278. package/dist/types/server-config.d.ts.map +1 -0
  279. package/dist/types/server-config.js +1 -0
  280. package/dist/types/skill.d.ts +69 -0
  281. package/dist/types/skill.d.ts.map +1 -0
  282. package/dist/types/skill.js +1 -0
  283. package/dist/types/tool.d.ts +68 -0
  284. package/dist/types/tool.d.ts.map +1 -0
  285. package/dist/types/tool.js +1 -0
  286. package/dist/watchers/SkillWatcher.d.ts +132 -0
  287. package/dist/watchers/SkillWatcher.d.ts.map +1 -0
  288. package/dist/watchers/SkillWatcher.js +73 -0
  289. package/dist/watchers/SkillWatcher.js.map +1 -0
  290. package/dist/watchers/ToolWatcher.d.ts +109 -0
  291. package/dist/watchers/ToolWatcher.d.ts.map +1 -0
  292. package/dist/watchers/ToolWatcher.js +71 -0
  293. package/dist/watchers/ToolWatcher.js.map +1 -0
  294. package/package.json +95 -0
@@ -0,0 +1,482 @@
1
+ /**
2
+ * Custom error types for the TraceLattice server.
3
+ *
4
+ * This module defines a hierarchy of error classes for handling various
5
+ * error conditions that can occur in the sequential thinking server.
6
+ * All errors extend the base `SequentialThinkingError` class with
7
+ * specific error codes for programmatic handling.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { ToolNotFoundError, SkillDiscoveryError } from './errors.js';
12
+ *
13
+ * // Throw a tool not found error
14
+ * throw new ToolNotFoundError('my-tool');
15
+ *
16
+ * // Catch and handle specific errors
17
+ * try {
18
+ * await discoverSkills(dir);
19
+ * } catch (error) {
20
+ * if (error instanceof SkillDiscoveryError) {
21
+ * console.error(`Failed to discover skills: ${error.message}`);
22
+ * console.error(`Error code: ${error.code}`);
23
+ * }
24
+ * }
25
+ * ```
26
+ * @module errors
27
+ */
28
+ /**
29
+ * Base error class for all Sequential Thinking server errors.
30
+ *
31
+ * This error extends the native `Error` class and adds a `code` property
32
+ * for programmatic error identification and handling. All specific error
33
+ * types in the system extend this base class.
34
+ *
35
+ * @remarks
36
+ * **Error Codes:**
37
+ * - `TOOL_NOT_FOUND` - A requested tool was not found
38
+ * - `SKILL_NOT_FOUND` - A requested skill was not found
39
+ * - `INVALID_THOUGHT` - Thought validation failed
40
+ * - `SKILL_DISCOVERY_FAILED` - Skill discovery operation failed
41
+ * - `HISTORY_LIMIT_EXCEEDED` - History size limit was exceeded
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Throw a custom sequential thinking error
46
+ * throw new SequentialThinkingError('Custom error message', 'CUSTOM_CODE');
47
+ *
48
+ * // Check if an error is a SequentialThinkingError
49
+ * if (error instanceof SequentialThinkingError) {
50
+ * console.error(`Error [${error.code}]: ${error.message}`);
51
+ * }
52
+ * ```
53
+ */
54
+ export declare class SequentialThinkingError extends Error {
55
+ /** The error code for programmatic identification. */
56
+ readonly code: string;
57
+ /**
58
+ * Creates a new SequentialThinkingError.
59
+ *
60
+ * @param message - Human-readable error message
61
+ * @param code - Error code for programmatic handling
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const error = new SequentialThinkingError(
66
+ * 'Something went wrong',
67
+ * 'CUSTOM_ERROR'
68
+ * );
69
+ * console.log(error.code); // 'CUSTOM_ERROR'
70
+ * ```
71
+ */
72
+ constructor(message: string, code: string);
73
+ }
74
+ export declare class ConfigurationError extends SequentialThinkingError {
75
+ constructor(message: string);
76
+ }
77
+ /**
78
+ * Error thrown when a requested tool is not found in the registry.
79
+ *
80
+ * This error is thrown when attempting to retrieve, update, or delete
81
+ * a tool that doesn't exist in the tool registry.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const tool = registry.getTool('non-existent-tool');
86
+ * if (!tool) {
87
+ * throw new ToolNotFoundError('non-existent-tool');
88
+ * }
89
+ * ```
90
+ */
91
+ export declare class ToolNotFoundError extends SequentialThinkingError {
92
+ /**
93
+ * Creates a new ToolNotFoundError.
94
+ *
95
+ * @param toolName - The name of the tool that was not found
96
+ * @param action - Optional action being performed (e.g., 'remove', 'update')
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * throw new ToolNotFoundError('my-custom-tool');
101
+ * // Error: tool 'my-custom-tool' not found
102
+ *
103
+ * throw new ToolNotFoundError('my-custom-tool', 'remove');
104
+ * // Error: tool 'my-custom-tool' not found, cannot remove
105
+ * // Code: TOOL_NOT_FOUND
106
+ * ```
107
+ */
108
+ constructor(toolName: string, action?: string);
109
+ }
110
+ /**
111
+ * Error thrown when a requested skill is not found in the registry.
112
+ *
113
+ * This error is thrown when attempting to retrieve, update, or delete
114
+ * a skill that doesn't exist in the skill registry.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const skill = registry.getSkill('non-existent-skill');
119
+ * if (!skill) {
120
+ * throw new SkillNotFoundError('non-existent-skill');
121
+ * }
122
+ * ```
123
+ */
124
+ export declare class SkillNotFoundError extends SequentialThinkingError {
125
+ /**
126
+ * Creates a new SkillNotFoundError.
127
+ *
128
+ * @param skillName - The name of the skill that was not found
129
+ * @param action - Optional action being performed (e.g., 'remove', 'update')
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * throw new SkillNotFoundError('my-custom-skill');
134
+ * // Error: skill 'my-custom-skill' not found
135
+ *
136
+ * throw new SkillNotFoundError('my-custom-skill', 'remove');
137
+ * // Error: skill 'my-custom-skill' not found, cannot remove
138
+ * // Code: SKILL_NOT_FOUND
139
+ * ```
140
+ */
141
+ constructor(skillName: string, action?: string);
142
+ }
143
+ /**
144
+ * Error thrown when thought validation fails.
145
+ *
146
+ * This error is thrown when a thought fails validation, typically due to
147
+ * invalid values, missing required fields, or constraint violations.
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * // Validate thought number
152
+ * if (thought.thought_number < 1) {
153
+ * throw new InvalidThoughtError(thought.thought_number, 'thought_number must be >= 1');
154
+ * }
155
+ * ```
156
+ */
157
+ export declare class InvalidThoughtError extends SequentialThinkingError {
158
+ /**
159
+ * Creates a new InvalidThoughtError.
160
+ *
161
+ * @param thoughtNumber - The thought number that failed validation
162
+ * @param reason - Human-readable explanation of why validation failed
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * throw new InvalidThoughtError(5, 'thought_number exceeds total_thoughts');
167
+ * // Error: Invalid thought 5: thought_number exceeds total_thoughts
168
+ * // Code: INVALID_THOUGHT
169
+ * ```
170
+ */
171
+ constructor(thoughtNumber: number, reason: string);
172
+ }
173
+ /**
174
+ * Error thrown when skill discovery fails.
175
+ *
176
+ * This error is thrown when the skill discovery process encounters an issue,
177
+ * such as filesystem errors, invalid skill files, or parsing failures.
178
+ *
179
+ * @remarks
180
+ * The original error that caused the discovery failure is preserved in the
181
+ * `cause` property for debugging purposes.
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * try {
186
+ * await discoverSkills('./skills');
187
+ * } catch (error) {
188
+ * throw new SkillDiscoveryError('./skills', error as Error);
189
+ * }
190
+ * ```
191
+ */
192
+ export declare class SkillDiscoveryError extends SequentialThinkingError {
193
+ /** The underlying error that caused the discovery failure. */
194
+ readonly cause: Error;
195
+ /**
196
+ * Creates a new SkillDiscoveryError.
197
+ *
198
+ * @param directory - The directory where discovery failed
199
+ * @param cause - The underlying error that caused the failure
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * try {
204
+ * const skills = await loadSkills('./invalid-directory');
205
+ * } catch (error) {
206
+ * throw new SkillDiscoveryError('./invalid-directory', error as Error);
207
+ * }
208
+ * ```
209
+ */
210
+ constructor(directory: string, cause: Error);
211
+ }
212
+ /**
213
+ * Error thrown when history size exceeds the configured limit.
214
+ *
215
+ * This error is thrown when an operation would cause the history size
216
+ * to exceed the maximum configured size limit.
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * if (history.length >= maxSize) {
221
+ * throw new HistoryLimitExceededError(history.length, maxSize);
222
+ * }
223
+ * ```
224
+ */
225
+ export declare class HistoryLimitExceededError extends SequentialThinkingError {
226
+ /**
227
+ * Creates a new HistoryLimitExceededError.
228
+ *
229
+ * @param currentSize - The current history size
230
+ * @param maxSize - The maximum allowed size
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * throw new HistoryLimitExceededError(1500, 1000);
235
+ * // Error: History size 1500 exceeds limit 1000
236
+ * // Code: HISTORY_LIMIT_EXCEEDED
237
+ * ```
238
+ */
239
+ constructor(currentSize: number, maxSize: number);
240
+ }
241
+ /**
242
+ * Error thrown when attempting to add a skill that already exists.
243
+ *
244
+ * This error is thrown when trying to register a skill with a name that
245
+ * is already present in the skill registry.
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * if (registry.hasSkill(skill.name)) {
250
+ * throw new DuplicateSkillError(skill.name);
251
+ * }
252
+ * ```
253
+ */
254
+ export declare class DuplicateSkillError extends SequentialThinkingError {
255
+ /**
256
+ * Creates a new DuplicateSkillError.
257
+ *
258
+ * @param skillName - The name of the duplicate skill
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * throw new DuplicateSkillError('my-skill');
263
+ * // Error: skill 'my-skill' already exists
264
+ * // Code: DUPLICATE_SKILL
265
+ * ```
266
+ */
267
+ constructor(skillName: string);
268
+ }
269
+ /**
270
+ * Error thrown when a skill has invalid data.
271
+ *
272
+ * This error is thrown when a skill fails validation, typically due to
273
+ * missing required fields or invalid values.
274
+ *
275
+ * @example
276
+ * ```typescript
277
+ * if (!skill.name) {
278
+ * throw new InvalidSkillError('Skill must have a valid name');
279
+ * }
280
+ * ```
281
+ */
282
+ export declare class InvalidSkillError extends SequentialThinkingError {
283
+ /**
284
+ * Creates a new InvalidSkillError.
285
+ *
286
+ * @param reason - The reason for the validation failure
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * throw new InvalidSkillError('Skill must have a valid name');
291
+ * // Error: Invalid skill: Skill must have a valid name
292
+ * // Code: INVALID_SKILL
293
+ * ```
294
+ */
295
+ constructor(reason: string);
296
+ }
297
+ /**
298
+ * Error thrown when attempting to add a tool that already exists.
299
+ *
300
+ * This error is thrown when trying to register a tool with a name that
301
+ * is already present in the tool registry.
302
+ *
303
+ * @example
304
+ * ```typescript
305
+ * if (registry.hasTool(tool.name)) {
306
+ * throw new DuplicateToolError(tool.name);
307
+ * }
308
+ * ```
309
+ */
310
+ export declare class DuplicateToolError extends SequentialThinkingError {
311
+ /**
312
+ * Creates a new DuplicateToolError.
313
+ *
314
+ * @param toolName - The name of the duplicate tool
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * throw new DuplicateToolError('my-tool');
319
+ * // Error: tool 'my-tool' already exists
320
+ * // Code: DUPLICATE_TOOL
321
+ * ```
322
+ */
323
+ constructor(toolName: string);
324
+ }
325
+ /**
326
+ * Error thrown when a tool has invalid data.
327
+ *
328
+ * This error is thrown when a tool fails validation, typically due to
329
+ * missing required fields or invalid values.
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * if (!tool.name) {
334
+ * throw new InvalidToolError('Tool must have a valid name');
335
+ * }
336
+ * ```
337
+ */
338
+ export declare class InvalidToolError extends SequentialThinkingError {
339
+ /**
340
+ * Creates a new InvalidToolError.
341
+ *
342
+ * @param reason - The reason for the validation failure
343
+ *
344
+ * @example
345
+ * ```typescript
346
+ * throw new InvalidToolError('Tool must have a valid name');
347
+ * // Error: Invalid tool: Tool must have a valid name
348
+ * // Code: INVALID_TOOL
349
+ * ```
350
+ */
351
+ constructor(reason: string);
352
+ }
353
+ /**
354
+ * Error thrown when attempting to process a session that is not active.
355
+ *
356
+ * This error is thrown when trying to use a session that has been closed
357
+ * or deactivated.
358
+ *
359
+ * @example
360
+ * ```typescript
361
+ * if (!session.isActive) {
362
+ * throw new SessionNotActiveError(sessionId);
363
+ * }
364
+ * ```
365
+ */
366
+ export declare class SessionNotActiveError extends SequentialThinkingError {
367
+ /**
368
+ * Creates a new SessionNotActiveError.
369
+ *
370
+ * @param sessionId - The ID of the inactive session
371
+ *
372
+ * @example
373
+ * ```typescript
374
+ * throw new SessionNotActiveError('session-123');
375
+ * // Error: Session 'session-123' is not active
376
+ * // Code: SESSION_NOT_ACTIVE
377
+ * ```
378
+ */
379
+ constructor(sessionId: string);
380
+ }
381
+ /**
382
+ * Error thrown when a requested session is not found in the pool.
383
+ *
384
+ * This error is thrown when attempting to retrieve, process, or close
385
+ * a session that doesn't exist in the session pool.
386
+ *
387
+ * @example
388
+ * ```typescript
389
+ * const session = pool.getSession('non-existent-session');
390
+ * if (!session) {
391
+ * throw new SessionNotFoundError('non-existent-session');
392
+ * }
393
+ * ```
394
+ */
395
+ export declare class SessionNotFoundError extends SequentialThinkingError {
396
+ /**
397
+ * Creates a new SessionNotFoundError.
398
+ *
399
+ * @param sessionId - The ID of the session that was not found
400
+ *
401
+ * @example
402
+ * ```typescript
403
+ * throw new SessionNotFoundError('session-123');
404
+ * // Error: Session not found: session-123
405
+ * // Code: SESSION_NOT_FOUND
406
+ * ```
407
+ */
408
+ constructor(sessionId: string);
409
+ }
410
+ /**
411
+ * Error thrown when the maximum number of sessions has been reached.
412
+ *
413
+ * This error is thrown when trying to create a new session when the
414
+ * pool has reached its configured maximum session limit.
415
+ *
416
+ * @example
417
+ * ```typescript
418
+ * if (pool.sessionCount >= pool.maxSessions) {
419
+ * throw new MaxSessionsReachedError(pool.maxSessions);
420
+ * }
421
+ * ```
422
+ */
423
+ export declare class MaxSessionsReachedError extends SequentialThinkingError {
424
+ /**
425
+ * Creates a new MaxSessionsReachedError.
426
+ *
427
+ * @param maxSessions - The maximum number of sessions allowed
428
+ *
429
+ * @example
430
+ * ```typescript
431
+ * throw new MaxSessionsReachedError(100);
432
+ * // Error: Max sessions (100) reached. Wait for a session to close or increase maxSessions.
433
+ * // Code: MAX_SESSIONS_REACHED
434
+ * ```
435
+ */
436
+ constructor(maxSessions: number);
437
+ }
438
+ /**
439
+ * Error thrown when attempting to use a terminated connection pool.
440
+ *
441
+ * This error is thrown when trying to create sessions or process requests
442
+ * after the connection pool has been terminated.
443
+ *
444
+ * @example
445
+ * ```typescript
446
+ * if (pool.isTerminated) {
447
+ * throw new PoolTerminatedError();
448
+ * }
449
+ * ```
450
+ */
451
+ export declare class PoolTerminatedError extends SequentialThinkingError {
452
+ /**
453
+ * Creates a new PoolTerminatedError.
454
+ *
455
+ * @example
456
+ * ```typescript
457
+ * throw new PoolTerminatedError();
458
+ * // Error: ConnectionPool has been terminated
459
+ * // Code: POOL_TERMINATED
460
+ * ```
461
+ */
462
+ constructor();
463
+ }
464
+ /**
465
+ * Error thrown when input validation fails due to invalid or malicious data.
466
+ *
467
+ * This error is thrown when user input fails security or format validation,
468
+ * such as path traversal attempts or invalid identifier formats.
469
+ *
470
+ * @example
471
+ * ```typescript
472
+ * if (!BRANCH_ID_PATTERN.test(branchId)) {
473
+ * throw new ValidationError('branchId', 'Invalid format');
474
+ * }
475
+ * ```
476
+ */
477
+ export declare class ValidationError extends SequentialThinkingError {
478
+ /** The field that failed validation. */
479
+ readonly field: string;
480
+ constructor(field: string, reason: string);
481
+ }
482
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,sDAAsD;IACtD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;;;;;;;;;;;;;OAcG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAMzC;AAED,qBAAa,kBAAmB,SAAQ,uBAAuB;gBAClD,OAAO,EAAE,MAAM;CAI3B;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAkB,SAAQ,uBAAuB;IAC7D;;;;;;;;;;;;;;;OAeG;gBACS,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAO7C;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,kBAAmB,SAAQ,uBAAuB;IAC9D;;;;;;;;;;;;;;;OAeG;gBACS,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAO9C;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,SAAQ,uBAAuB;IAC/D;;;;;;;;;;;;OAYG;gBACS,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAIjD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,mBAAoB,SAAQ,uBAAuB;IAC/D,8DAA8D;IAC9D,SAAyB,KAAK,EAAE,KAAK,CA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,MAAM,CAAC;gBAElB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAKzC"}
package/dist/errors.js ADDED
@@ -0,0 +1,108 @@
1
+ class SequentialThinkingError extends Error {
2
+ code;
3
+ constructor(message, code){
4
+ super(message);
5
+ this.code = code;
6
+ this.name = 'SequentialThinkingError';
7
+ Error.captureStackTrace(this, this.constructor);
8
+ }
9
+ }
10
+ class ConfigurationError extends SequentialThinkingError {
11
+ constructor(message){
12
+ super(message, 'CONFIGURATION_ERROR');
13
+ this.name = 'ConfigurationError';
14
+ }
15
+ }
16
+ class ToolNotFoundError extends SequentialThinkingError {
17
+ constructor(toolName, action){
18
+ const message = action ? `Tool '${toolName}' not found, cannot ${action}` : `Tool '${toolName}' not found`;
19
+ super(message, 'TOOL_NOT_FOUND');
20
+ this.name = 'ToolNotFoundError';
21
+ }
22
+ }
23
+ class SkillNotFoundError extends SequentialThinkingError {
24
+ constructor(skillName, action){
25
+ const message = action ? `Skill '${skillName}' not found, cannot ${action}` : `Skill '${skillName}' not found`;
26
+ super(message, 'SKILL_NOT_FOUND');
27
+ this.name = 'SkillNotFoundError';
28
+ }
29
+ }
30
+ class InvalidThoughtError extends SequentialThinkingError {
31
+ constructor(thoughtNumber, reason){
32
+ super(`Invalid thought ${thoughtNumber}: ${reason}`, 'INVALID_THOUGHT');
33
+ this.name = 'InvalidThoughtError';
34
+ }
35
+ }
36
+ class SkillDiscoveryError extends SequentialThinkingError {
37
+ cause;
38
+ constructor(directory, cause){
39
+ super(`Failed to discover skills in ${directory}: ${cause.message}`, 'SKILL_DISCOVERY_FAILED');
40
+ this.name = 'SkillDiscoveryError';
41
+ this.cause = cause;
42
+ }
43
+ }
44
+ class HistoryLimitExceededError extends SequentialThinkingError {
45
+ constructor(currentSize, maxSize){
46
+ super(`History size ${currentSize} exceeds limit ${maxSize}`, 'HISTORY_LIMIT_EXCEEDED');
47
+ this.name = 'HistoryLimitExceededError';
48
+ }
49
+ }
50
+ class DuplicateSkillError extends SequentialThinkingError {
51
+ constructor(skillName){
52
+ super(`skill '${skillName}' already exists`, 'DUPLICATE_SKILL');
53
+ this.name = 'DuplicateSkillError';
54
+ }
55
+ }
56
+ class InvalidSkillError extends SequentialThinkingError {
57
+ constructor(reason){
58
+ super(`Invalid skill: ${reason}`, 'INVALID_SKILL');
59
+ this.name = 'InvalidSkillError';
60
+ }
61
+ }
62
+ class DuplicateToolError extends SequentialThinkingError {
63
+ constructor(toolName){
64
+ super(`tool '${toolName}' already exists`, 'DUPLICATE_TOOL');
65
+ this.name = 'DuplicateToolError';
66
+ }
67
+ }
68
+ class InvalidToolError extends SequentialThinkingError {
69
+ constructor(reason){
70
+ super(`Invalid tool: ${reason}`, 'INVALID_TOOL');
71
+ this.name = 'InvalidToolError';
72
+ }
73
+ }
74
+ class SessionNotActiveError extends SequentialThinkingError {
75
+ constructor(sessionId){
76
+ super(`Session '${sessionId}' is not active`, 'SESSION_NOT_ACTIVE');
77
+ this.name = 'SessionNotActiveError';
78
+ }
79
+ }
80
+ class SessionNotFoundError extends SequentialThinkingError {
81
+ constructor(sessionId){
82
+ super(`Session not found: ${sessionId}`, 'SESSION_NOT_FOUND');
83
+ this.name = 'SessionNotFoundError';
84
+ }
85
+ }
86
+ class MaxSessionsReachedError extends SequentialThinkingError {
87
+ constructor(maxSessions){
88
+ super(`Max sessions (${maxSessions}) reached. Wait for a session to close or increase maxSessions.`, 'MAX_SESSIONS_REACHED');
89
+ this.name = 'MaxSessionsReachedError';
90
+ }
91
+ }
92
+ class PoolTerminatedError extends SequentialThinkingError {
93
+ constructor(){
94
+ super('ConnectionPool has been terminated', 'POOL_TERMINATED');
95
+ this.name = 'PoolTerminatedError';
96
+ }
97
+ }
98
+ class ValidationError extends SequentialThinkingError {
99
+ field;
100
+ constructor(field, reason){
101
+ super(`Validation failed for '${field}': ${reason}`, 'VALIDATION_ERROR');
102
+ this.name = 'ValidationError';
103
+ this.field = field;
104
+ }
105
+ }
106
+ export { ConfigurationError, DuplicateSkillError, DuplicateToolError, HistoryLimitExceededError, InvalidSkillError, InvalidThoughtError, InvalidToolError, MaxSessionsReachedError, PoolTerminatedError, SequentialThinkingError, SessionNotActiveError, SessionNotFoundError, SkillDiscoveryError, SkillNotFoundError, ToolNotFoundError, ValidationError };
107
+
108
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sources":["../src/errors.ts"],"sourcesContent":["/**\n * Custom error types for the TraceLattice server.\n *\n * This module defines a hierarchy of error classes for handling various\n * error conditions that can occur in the sequential thinking server.\n * All errors extend the base `SequentialThinkingError` class with\n * specific error codes for programmatic handling.\n *\n * @example\n * ```typescript\n * import { ToolNotFoundError, SkillDiscoveryError } from './errors.js';\n *\n * // Throw a tool not found error\n * throw new ToolNotFoundError('my-tool');\n *\n * // Catch and handle specific errors\n * try {\n * await discoverSkills(dir);\n * } catch (error) {\n * if (error instanceof SkillDiscoveryError) {\n * console.error(`Failed to discover skills: ${error.message}`);\n * console.error(`Error code: ${error.code}`);\n * }\n * }\n * ```\n * @module errors\n */\n\n/**\n * Base error class for all Sequential Thinking server errors.\n *\n * This error extends the native `Error` class and adds a `code` property\n * for programmatic error identification and handling. All specific error\n * types in the system extend this base class.\n *\n * @remarks\n * **Error Codes:**\n * - `TOOL_NOT_FOUND` - A requested tool was not found\n * - `SKILL_NOT_FOUND` - A requested skill was not found\n * - `INVALID_THOUGHT` - Thought validation failed\n * - `SKILL_DISCOVERY_FAILED` - Skill discovery operation failed\n * - `HISTORY_LIMIT_EXCEEDED` - History size limit was exceeded\n *\n * @example\n * ```typescript\n * // Throw a custom sequential thinking error\n * throw new SequentialThinkingError('Custom error message', 'CUSTOM_CODE');\n *\n * // Check if an error is a SequentialThinkingError\n * if (error instanceof SequentialThinkingError) {\n * console.error(`Error [${error.code}]: ${error.message}`);\n * }\n * ```\n */\nexport class SequentialThinkingError extends Error {\n\t/** The error code for programmatic identification. */\n\tpublic readonly code: string;\n\n\t/**\n\t * Creates a new SequentialThinkingError.\n\t *\n\t * @param message - Human-readable error message\n\t * @param code - Error code for programmatic handling\n\t *\n\t * @example\n\t * ```typescript\n\t * const error = new SequentialThinkingError(\n\t * 'Something went wrong',\n\t * 'CUSTOM_ERROR'\n\t * );\n\t * console.log(error.code); // 'CUSTOM_ERROR'\n\t * ```\n\t */\n\tconstructor(message: string, code: string) {\n\t\tsuper(message);\n\t\tthis.code = code;\n\t\tthis.name = 'SequentialThinkingError';\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\n}\n\nexport class ConfigurationError extends SequentialThinkingError {\n\tconstructor(message: string) {\n\t\tsuper(message, 'CONFIGURATION_ERROR');\n\t\tthis.name = 'ConfigurationError';\n\t}\n}\n\n/**\n * Error thrown when a requested tool is not found in the registry.\n *\n * This error is thrown when attempting to retrieve, update, or delete\n * a tool that doesn't exist in the tool registry.\n *\n * @example\n * ```typescript\n * const tool = registry.getTool('non-existent-tool');\n * if (!tool) {\n * throw new ToolNotFoundError('non-existent-tool');\n * }\n * ```\n */\nexport class ToolNotFoundError extends SequentialThinkingError {\n\t/**\n\t * Creates a new ToolNotFoundError.\n\t *\n\t * @param toolName - The name of the tool that was not found\n\t * @param action - Optional action being performed (e.g., 'remove', 'update')\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new ToolNotFoundError('my-custom-tool');\n\t * // Error: tool 'my-custom-tool' not found\n\t *\n\t * throw new ToolNotFoundError('my-custom-tool', 'remove');\n\t * // Error: tool 'my-custom-tool' not found, cannot remove\n\t * // Code: TOOL_NOT_FOUND\n\t * ```\n\t */\n\tconstructor(toolName: string, action?: string) {\n\t\tconst message = action\n\t\t\t? `Tool '${toolName}' not found, cannot ${action}`\n\t\t\t: `Tool '${toolName}' not found`;\n\t\tsuper(message, 'TOOL_NOT_FOUND');\n\t\tthis.name = 'ToolNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when a requested skill is not found in the registry.\n *\n * This error is thrown when attempting to retrieve, update, or delete\n * a skill that doesn't exist in the skill registry.\n *\n * @example\n * ```typescript\n * const skill = registry.getSkill('non-existent-skill');\n * if (!skill) {\n * throw new SkillNotFoundError('non-existent-skill');\n * }\n * ```\n */\nexport class SkillNotFoundError extends SequentialThinkingError {\n\t/**\n\t * Creates a new SkillNotFoundError.\n\t *\n\t * @param skillName - The name of the skill that was not found\n\t * @param action - Optional action being performed (e.g., 'remove', 'update')\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new SkillNotFoundError('my-custom-skill');\n\t * // Error: skill 'my-custom-skill' not found\n\t *\n\t * throw new SkillNotFoundError('my-custom-skill', 'remove');\n\t * // Error: skill 'my-custom-skill' not found, cannot remove\n\t * // Code: SKILL_NOT_FOUND\n\t * ```\n\t */\n\tconstructor(skillName: string, action?: string) {\n\t\tconst message = action\n\t\t\t? `Skill '${skillName}' not found, cannot ${action}`\n\t\t\t: `Skill '${skillName}' not found`;\n\t\tsuper(message, 'SKILL_NOT_FOUND');\n\t\tthis.name = 'SkillNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when thought validation fails.\n *\n * This error is thrown when a thought fails validation, typically due to\n * invalid values, missing required fields, or constraint violations.\n *\n * @example\n * ```typescript\n * // Validate thought number\n * if (thought.thought_number < 1) {\n * throw new InvalidThoughtError(thought.thought_number, 'thought_number must be >= 1');\n * }\n * ```\n */\nexport class InvalidThoughtError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidThoughtError.\n\t *\n\t * @param thoughtNumber - The thought number that failed validation\n\t * @param reason - Human-readable explanation of why validation failed\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidThoughtError(5, 'thought_number exceeds total_thoughts');\n\t * // Error: Invalid thought 5: thought_number exceeds total_thoughts\n\t * // Code: INVALID_THOUGHT\n\t * ```\n\t */\n\tconstructor(thoughtNumber: number, reason: string) {\n\t\tsuper(`Invalid thought ${thoughtNumber}: ${reason}`, 'INVALID_THOUGHT');\n\t\tthis.name = 'InvalidThoughtError';\n\t}\n}\n\n/**\n * Error thrown when skill discovery fails.\n *\n * This error is thrown when the skill discovery process encounters an issue,\n * such as filesystem errors, invalid skill files, or parsing failures.\n *\n * @remarks\n * The original error that caused the discovery failure is preserved in the\n * `cause` property for debugging purposes.\n *\n * @example\n * ```typescript\n * try {\n * await discoverSkills('./skills');\n * } catch (error) {\n * throw new SkillDiscoveryError('./skills', error as Error);\n * }\n * ```\n */\nexport class SkillDiscoveryError extends SequentialThinkingError {\n\t/** The underlying error that caused the discovery failure. */\n\tpublic override readonly cause: Error;\n\n\t/**\n\t * Creates a new SkillDiscoveryError.\n\t *\n\t * @param directory - The directory where discovery failed\n\t * @param cause - The underlying error that caused the failure\n\t *\n\t * @example\n\t * ```typescript\n\t * try {\n\t * const skills = await loadSkills('./invalid-directory');\n\t * } catch (error) {\n\t * throw new SkillDiscoveryError('./invalid-directory', error as Error);\n\t * }\n\t * ```\n\t */\n\tconstructor(directory: string, cause: Error) {\n\t\tsuper(`Failed to discover skills in ${directory}: ${cause.message}`, 'SKILL_DISCOVERY_FAILED');\n\t\tthis.name = 'SkillDiscoveryError';\n\t\tthis.cause = cause;\n\t}\n}\n\n/**\n * Error thrown when history size exceeds the configured limit.\n *\n * This error is thrown when an operation would cause the history size\n * to exceed the maximum configured size limit.\n *\n * @example\n * ```typescript\n * if (history.length >= maxSize) {\n * throw new HistoryLimitExceededError(history.length, maxSize);\n * }\n * ```\n */\nexport class HistoryLimitExceededError extends SequentialThinkingError {\n\t/**\n\t * Creates a new HistoryLimitExceededError.\n\t *\n\t * @param currentSize - The current history size\n\t * @param maxSize - The maximum allowed size\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new HistoryLimitExceededError(1500, 1000);\n\t * // Error: History size 1500 exceeds limit 1000\n\t * // Code: HISTORY_LIMIT_EXCEEDED\n\t * ```\n\t */\n\tconstructor(currentSize: number, maxSize: number) {\n\t\tsuper(`History size ${currentSize} exceeds limit ${maxSize}`, 'HISTORY_LIMIT_EXCEEDED');\n\t\tthis.name = 'HistoryLimitExceededError';\n\t}\n}\n\n/**\n * Error thrown when attempting to add a skill that already exists.\n *\n * This error is thrown when trying to register a skill with a name that\n * is already present in the skill registry.\n *\n * @example\n * ```typescript\n * if (registry.hasSkill(skill.name)) {\n * throw new DuplicateSkillError(skill.name);\n * }\n * ```\n */\nexport class DuplicateSkillError extends SequentialThinkingError {\n\t/**\n\t * Creates a new DuplicateSkillError.\n\t *\n\t * @param skillName - The name of the duplicate skill\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new DuplicateSkillError('my-skill');\n\t * // Error: skill 'my-skill' already exists\n\t * // Code: DUPLICATE_SKILL\n\t * ```\n\t */\n\tconstructor(skillName: string) {\n\t\tsuper(`skill '${skillName}' already exists`, 'DUPLICATE_SKILL');\n\t\tthis.name = 'DuplicateSkillError';\n\t}\n}\n\n/**\n * Error thrown when a skill has invalid data.\n *\n * This error is thrown when a skill fails validation, typically due to\n * missing required fields or invalid values.\n *\n * @example\n * ```typescript\n * if (!skill.name) {\n * throw new InvalidSkillError('Skill must have a valid name');\n * }\n * ```\n */\nexport class InvalidSkillError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidSkillError.\n\t *\n\t * @param reason - The reason for the validation failure\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidSkillError('Skill must have a valid name');\n\t * // Error: Invalid skill: Skill must have a valid name\n\t * // Code: INVALID_SKILL\n\t * ```\n\t */\n\tconstructor(reason: string) {\n\t\tsuper(`Invalid skill: ${reason}`, 'INVALID_SKILL');\n\t\tthis.name = 'InvalidSkillError';\n\t}\n}\n\n/**\n * Error thrown when attempting to add a tool that already exists.\n *\n * This error is thrown when trying to register a tool with a name that\n * is already present in the tool registry.\n *\n * @example\n * ```typescript\n * if (registry.hasTool(tool.name)) {\n * throw new DuplicateToolError(tool.name);\n * }\n * ```\n */\nexport class DuplicateToolError extends SequentialThinkingError {\n\t/**\n\t * Creates a new DuplicateToolError.\n\t *\n\t * @param toolName - The name of the duplicate tool\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new DuplicateToolError('my-tool');\n\t * // Error: tool 'my-tool' already exists\n\t * // Code: DUPLICATE_TOOL\n\t * ```\n\t */\n\tconstructor(toolName: string) {\n\t\tsuper(`tool '${toolName}' already exists`, 'DUPLICATE_TOOL');\n\t\tthis.name = 'DuplicateToolError';\n\t}\n}\n\n/**\n * Error thrown when a tool has invalid data.\n *\n * This error is thrown when a tool fails validation, typically due to\n * missing required fields or invalid values.\n *\n * @example\n * ```typescript\n * if (!tool.name) {\n * throw new InvalidToolError('Tool must have a valid name');\n * }\n * ```\n */\nexport class InvalidToolError extends SequentialThinkingError {\n\t/**\n\t * Creates a new InvalidToolError.\n\t *\n\t * @param reason - The reason for the validation failure\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new InvalidToolError('Tool must have a valid name');\n\t * // Error: Invalid tool: Tool must have a valid name\n\t * // Code: INVALID_TOOL\n\t * ```\n\t */\n\tconstructor(reason: string) {\n\t\tsuper(`Invalid tool: ${reason}`, 'INVALID_TOOL');\n\t\tthis.name = 'InvalidToolError';\n\t}\n}\n\n/**\n * Error thrown when attempting to process a session that is not active.\n *\n * This error is thrown when trying to use a session that has been closed\n * or deactivated.\n *\n * @example\n * ```typescript\n * if (!session.isActive) {\n * throw new SessionNotActiveError(sessionId);\n * }\n * ```\n */\nexport class SessionNotActiveError extends SequentialThinkingError {\n\t/**\n\t * Creates a new SessionNotActiveError.\n\t *\n\t * @param sessionId - The ID of the inactive session\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new SessionNotActiveError('session-123');\n\t * // Error: Session 'session-123' is not active\n\t * // Code: SESSION_NOT_ACTIVE\n\t * ```\n\t */\n\tconstructor(sessionId: string) {\n\t\tsuper(`Session '${sessionId}' is not active`, 'SESSION_NOT_ACTIVE');\n\t\tthis.name = 'SessionNotActiveError';\n\t}\n}\n\n/**\n * Error thrown when a requested session is not found in the pool.\n *\n * This error is thrown when attempting to retrieve, process, or close\n * a session that doesn't exist in the session pool.\n *\n * @example\n * ```typescript\n * const session = pool.getSession('non-existent-session');\n * if (!session) {\n * throw new SessionNotFoundError('non-existent-session');\n * }\n * ```\n */\nexport class SessionNotFoundError extends SequentialThinkingError {\n\t/**\n\t * Creates a new SessionNotFoundError.\n\t *\n\t * @param sessionId - The ID of the session that was not found\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new SessionNotFoundError('session-123');\n\t * // Error: Session not found: session-123\n\t * // Code: SESSION_NOT_FOUND\n\t * ```\n\t */\n\tconstructor(sessionId: string) {\n\t\tsuper(`Session not found: ${sessionId}`, 'SESSION_NOT_FOUND');\n\t\tthis.name = 'SessionNotFoundError';\n\t}\n}\n\n/**\n * Error thrown when the maximum number of sessions has been reached.\n *\n * This error is thrown when trying to create a new session when the\n * pool has reached its configured maximum session limit.\n *\n * @example\n * ```typescript\n * if (pool.sessionCount >= pool.maxSessions) {\n * throw new MaxSessionsReachedError(pool.maxSessions);\n * }\n * ```\n */\nexport class MaxSessionsReachedError extends SequentialThinkingError {\n\t/**\n\t * Creates a new MaxSessionsReachedError.\n\t *\n\t * @param maxSessions - The maximum number of sessions allowed\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new MaxSessionsReachedError(100);\n\t * // Error: Max sessions (100) reached. Wait for a session to close or increase maxSessions.\n\t * // Code: MAX_SESSIONS_REACHED\n\t * ```\n\t */\n\tconstructor(maxSessions: number) {\n\t\tsuper(\n\t\t\t`Max sessions (${maxSessions}) reached. Wait for a session to close or increase maxSessions.`,\n\t\t\t'MAX_SESSIONS_REACHED'\n\t\t);\n\t\tthis.name = 'MaxSessionsReachedError';\n\t}\n}\n\n/**\n * Error thrown when attempting to use a terminated connection pool.\n *\n * This error is thrown when trying to create sessions or process requests\n * after the connection pool has been terminated.\n *\n * @example\n * ```typescript\n * if (pool.isTerminated) {\n * throw new PoolTerminatedError();\n * }\n * ```\n */\nexport class PoolTerminatedError extends SequentialThinkingError {\n\t/**\n\t * Creates a new PoolTerminatedError.\n\t *\n\t * @example\n\t * ```typescript\n\t * throw new PoolTerminatedError();\n\t * // Error: ConnectionPool has been terminated\n\t * // Code: POOL_TERMINATED\n\t * ```\n\t */\n\tconstructor() {\n\t\tsuper('ConnectionPool has been terminated', 'POOL_TERMINATED');\n\t\tthis.name = 'PoolTerminatedError';\n\t}\n}\n\n/**\n * Error thrown when input validation fails due to invalid or malicious data.\n *\n * This error is thrown when user input fails security or format validation,\n * such as path traversal attempts or invalid identifier formats.\n *\n * @example\n * ```typescript\n * if (!BRANCH_ID_PATTERN.test(branchId)) {\n * throw new ValidationError('branchId', 'Invalid format');\n * }\n * ```\n */\nexport class ValidationError extends SequentialThinkingError {\n\t/** The field that failed validation. */\n\tpublic readonly field: string;\n\n\tconstructor(field: string, reason: string) {\n\t\tsuper(`Validation failed for '${field}': ${reason}`, 'VALIDATION_ERROR');\n\t\tthis.name = 'ValidationError';\n\t\tthis.field = field;\n\t}\n}\n"],"names":["SequentialThinkingError","Error","message","code","ConfigurationError","ToolNotFoundError","toolName","action","SkillNotFoundError","skillName","InvalidThoughtError","thoughtNumber","reason","SkillDiscoveryError","directory","cause","HistoryLimitExceededError","currentSize","maxSize","DuplicateSkillError","InvalidSkillError","DuplicateToolError","InvalidToolError","SessionNotActiveError","sessionId","SessionNotFoundError","MaxSessionsReachedError","maxSessions","PoolTerminatedError","ValidationError","field"],"mappings":"AAsDO,MAAMA,gCAAgCC;IAE5B,KAAa;IAiB7B,YAAYC,OAAe,EAAEC,IAAY,CAAE;QAC1C,KAAK,CAACD;QACN,IAAI,CAAC,IAAI,GAAGC;QACZ,IAAI,CAAC,IAAI,GAAG;QACZF,MAAM,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW;IAC/C;AACD;AAEO,MAAMG,2BAA2BJ;IACvC,YAAYE,OAAe,CAAE;QAC5B,KAAK,CAACA,SAAS;QACf,IAAI,CAAC,IAAI,GAAG;IACb;AACD;AAgBO,MAAMG,0BAA0BL;IAiBtC,YAAYM,QAAgB,EAAEC,MAAe,CAAE;QAC9C,MAAML,UA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