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,154 @@
1
+ /**
2
+ * Null logger that discards all log messages.
3
+ *
4
+ * This logger implements the same interface as `StructuredLogger` but
5
+ * silently discards all log messages. It's useful as a default/fallback
6
+ * logger when logging is disabled or when no logger is provided.
7
+ *
8
+ * @module logger
9
+ */
10
+ import type { LogLevel, Logger, LoggerOptions } from './StructuredLogger.js';
11
+ /**
12
+ * Null logger that discards all log messages.
13
+ *
14
+ * This class provides a no-op implementation of the logger interface.
15
+ * All method calls are silent and have no effect, making it suitable
16
+ * for use as a default logger when logging is disabled or not needed.
17
+ *
18
+ * @remarks
19
+ * The `NullLogger` implements the same interface as `StructuredLogger`,
20
+ * making them interchangeable. Use `NullLogger` when:
21
+ * - You want to disable logging completely
22
+ * - You need a logger placeholder that can be swapped later
23
+ * - Testing components that don't need output
24
+ * - Reducing overhead in performance-critical sections
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { NullLogger } from './logger/index.js';
29
+ *
30
+ * // Create a null logger
31
+ * const logger = new NullLogger();
32
+ *
33
+ * // All log calls are silently discarded
34
+ * logger.debug('This will not appear');
35
+ * logger.info('Nor will this');
36
+ * logger.warn('Or this warning');
37
+ * logger.error('Or even this error');
38
+ *
39
+ * // Methods exist for compatibility but have no effect
40
+ * logger.setLevel('debug');
41
+ * const level = logger.getLevel(); // Returns 'error' (default)
42
+ * ```
43
+ */
44
+ export declare class NullLogger implements Logger {
45
+ /**
46
+ * Current minimum log level.
47
+ *
48
+ * @remarks
49
+ * Since all messages are discarded, the level setting has no practical
50
+ * effect. This property exists only for interface compatibility.
51
+ * @private
52
+ */
53
+ private _level;
54
+ /**
55
+ * Creates a new NullLogger instance.
56
+ *
57
+ * @param options - Configuration options (ignored, but accepted for interface compatibility)
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Create a null logger
62
+ * const logger1 = new NullLogger();
63
+ *
64
+ * // With options (ignored)
65
+ * const logger2 = new NullLogger({
66
+ * level: 'debug',
67
+ * context: 'MyApp',
68
+ * pretty: true
69
+ * });
70
+ * ```
71
+ */
72
+ constructor(options?: LoggerOptions);
73
+ /**
74
+ * Log a debug message (no-op).
75
+ *
76
+ * This method exists for interface compatibility but does nothing.
77
+ *
78
+ * @param _message - Ignored
79
+ * @param _meta - Ignored
80
+ */
81
+ debug(_message: string, _meta?: Record<string, unknown>): void;
82
+ /**
83
+ * Log an info message (no-op).
84
+ *
85
+ * This method exists for interface compatibility but does nothing.
86
+ *
87
+ * @param _message - Ignored
88
+ * @param _meta - Ignored
89
+ */
90
+ info(_message: string, _meta?: Record<string, unknown>): void;
91
+ /**
92
+ * Log a warning message (no-op).
93
+ *
94
+ * This method exists for interface compatibility but does nothing.
95
+ *
96
+ * @param _message - Ignored
97
+ * @param _meta - Ignored
98
+ */
99
+ warn(_message: string, _meta?: Record<string, unknown>): void;
100
+ /**
101
+ * Log an error message (no-op).
102
+ *
103
+ * This method exists for interface compatibility but does nothing.
104
+ *
105
+ * @param _message - Ignored
106
+ * @param _meta - Ignored
107
+ */
108
+ error(_message: string, _meta?: Record<string, unknown>): void;
109
+ /**
110
+ * Sets the minimum log level (no-op).
111
+ *
112
+ * This method exists for interface compatibility but has no effect
113
+ * since all messages are discarded anyway.
114
+ *
115
+ * @param level - The new minimum log level (ignored)
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * logger.setLevel('debug'); // No effect
120
+ * ```
121
+ */
122
+ setLevel(level: LogLevel): void;
123
+ /**
124
+ * Gets the current minimum log level.
125
+ *
126
+ * @returns The current log level (stored value, unused)
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * const currentLevel = logger.getLevel();
131
+ * console.log(`Current level: ${currentLevel}`); // 'error' by default
132
+ * ```
133
+ */
134
+ getLevel(): LogLevel;
135
+ /**
136
+ * Creates a child null logger (returns a new NullLogger).
137
+ *
138
+ * This method exists for interface compatibility. It returns a new
139
+ * `NullLogger` instance (not a child with extended context) since
140
+ * context tracking is not applicable for a no-op logger.
141
+ *
142
+ * @param _context - Additional context (ignored)
143
+ * @returns A new NullLogger instance
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const nullLogger = new NullLogger();
148
+ * const childLogger = nullLogger.createChild('ChildModule');
149
+ * // childLogger is also a NullLogger
150
+ * ```
151
+ */
152
+ createChild(_context: string): NullLogger;
153
+ }
154
+ //# sourceMappingURL=NullLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NullLogger.d.ts","sourceRoot":"","sources":["../../src/logger/NullLogger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,UAAW,YAAW,MAAM;IACxC;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAW;IAEzB;;;;;;;;;;;;;;;;;OAiBG;gBACS,OAAO,GAAE,aAAkB;IAIvC;;;;;;;OAOG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAE9D;;;;;;;OAOG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAE7D;;;;;;;OAOG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAE7D;;;;;;;OAOG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAE9D;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/B;;;;;;;;;;OAUG;IACH,QAAQ,IAAI,QAAQ;IAIpB;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU;CAGzC"}
@@ -0,0 +1,24 @@
1
+ class NullLogger {
2
+ _level;
3
+ constructor(options = {}){
4
+ this._level = options.level ?? 'error';
5
+ }
6
+ debug(_message, _meta) {}
7
+ info(_message, _meta) {}
8
+ warn(_message, _meta) {}
9
+ error(_message, _meta) {}
10
+ setLevel(level) {
11
+ this._level = level;
12
+ }
13
+ getLevel() {
14
+ return this._level;
15
+ }
16
+ createChild(_context) {
17
+ return new NullLogger({
18
+ level: this._level
19
+ });
20
+ }
21
+ }
22
+ export { NullLogger };
23
+
24
+ //# sourceMappingURL=NullLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger/NullLogger.js","sources":["../../src/logger/NullLogger.ts"],"sourcesContent":["/**\n * Null logger that discards all log messages.\n *\n * This logger implements the same interface as `StructuredLogger` but\n * silently discards all log messages. It's useful as a default/fallback\n * logger when logging is disabled or when no logger is provided.\n *\n * @module logger\n */\n\nimport type { LogLevel, Logger, LoggerOptions } from './StructuredLogger.js';\n\n/**\n * Null logger that discards all log messages.\n *\n * This class provides a no-op implementation of the logger interface.\n * All method calls are silent and have no effect, making it suitable\n * for use as a default logger when logging is disabled or not needed.\n *\n * @remarks\n * The `NullLogger` implements the same interface as `StructuredLogger`,\n * making them interchangeable. Use `NullLogger` when:\n * - You want to disable logging completely\n * - You need a logger placeholder that can be swapped later\n * - Testing components that don't need output\n * - Reducing overhead in performance-critical sections\n *\n * @example\n * ```typescript\n * import { NullLogger } from './logger/index.js';\n *\n * // Create a null logger\n * const logger = new NullLogger();\n *\n * // All log calls are silently discarded\n * logger.debug('This will not appear');\n * logger.info('Nor will this');\n * logger.warn('Or this warning');\n * logger.error('Or even this error');\n *\n * // Methods exist for compatibility but have no effect\n * logger.setLevel('debug');\n * const level = logger.getLevel(); // Returns 'error' (default)\n * ```\n */\nexport class NullLogger implements Logger {\n\t/**\n\t * Current minimum log level.\n\t *\n\t * @remarks\n\t * Since all messages are discarded, the level setting has no practical\n\t * effect. This property exists only for interface compatibility.\n\t * @private\n\t */\n\tprivate _level: LogLevel;\n\n\t/**\n\t * Creates a new NullLogger instance.\n\t *\n\t * @param options - Configuration options (ignored, but accepted for interface compatibility)\n\t *\n\t * @example\n\t * ```typescript\n\t * // Create a null logger\n\t * const logger1 = new NullLogger();\n\t *\n\t * // With options (ignored)\n\t * const logger2 = new NullLogger({\n\t * level: 'debug',\n\t * context: 'MyApp',\n\t * pretty: true\n\t * });\n\t * ```\n\t */\n\tconstructor(options: LoggerOptions = {}) {\n\t\tthis._level = options.level ?? 'error';\n\t}\n\n\t/**\n\t * Log a debug message (no-op).\n\t *\n\t * This method exists for interface compatibility but does nothing.\n\t *\n\t * @param _message - Ignored\n\t * @param _meta - Ignored\n\t */\n\tdebug(_message: string, _meta?: Record<string, unknown>): void {}\n\n\t/**\n\t * Log an info message (no-op).\n\t *\n\t * This method exists for interface compatibility but does nothing.\n\t *\n\t * @param _message - Ignored\n\t * @param _meta - Ignored\n\t */\n\tinfo(_message: string, _meta?: Record<string, unknown>): void {}\n\n\t/**\n\t * Log a warning message (no-op).\n\t *\n\t * This method exists for interface compatibility but does nothing.\n\t *\n\t * @param _message - Ignored\n\t * @param _meta - Ignored\n\t */\n\twarn(_message: string, _meta?: Record<string, unknown>): void {}\n\n\t/**\n\t * Log an error message (no-op).\n\t *\n\t * This method exists for interface compatibility but does nothing.\n\t *\n\t * @param _message - Ignored\n\t * @param _meta - Ignored\n\t */\n\terror(_message: string, _meta?: Record<string, unknown>): void {}\n\n\t/**\n\t * Sets the minimum log level (no-op).\n\t *\n\t * This method exists for interface compatibility but has no effect\n\t * since all messages are discarded anyway.\n\t *\n\t * @param level - The new minimum log level (ignored)\n\t *\n\t * @example\n\t * ```typescript\n\t * logger.setLevel('debug'); // No effect\n\t * ```\n\t */\n\tsetLevel(level: LogLevel): void {\n\t\tthis._level = level;\n\t}\n\n\t/**\n\t * Gets the current minimum log level.\n\t *\n\t * @returns The current log level (stored value, unused)\n\t *\n\t * @example\n\t * ```typescript\n\t * const currentLevel = logger.getLevel();\n\t * console.log(`Current level: ${currentLevel}`); // 'error' by default\n\t * ```\n\t */\n\tgetLevel(): LogLevel {\n\t\treturn this._level;\n\t}\n\n\t/**\n\t * Creates a child null logger (returns a new NullLogger).\n\t *\n\t * This method exists for interface compatibility. It returns a new\n\t * `NullLogger` instance (not a child with extended context) since\n\t * context tracking is not applicable for a no-op logger.\n\t *\n\t * @param _context - Additional context (ignored)\n\t * @returns A new NullLogger instance\n\t *\n\t * @example\n\t * ```typescript\n\t * const nullLogger = new NullLogger();\n\t * const childLogger = nullLogger.createChild('ChildModule');\n\t * // childLogger is also a NullLogger\n\t * ```\n\t */\n\tcreateChild(_context: string): NullLogger {\n\t\treturn new NullLogger({ level: this._level });\n\t}\n}\n"],"names":["NullLogger","options","_message","_meta","level","_context"],"mappings":"AA6CO,MAAMA;IASJ,OAAiB;IAoBzB,YAAYC,UAAyB,CAAC,CAAC,CAAE;QACxC,IAAI,CAAC,MAAM,GAAGA,QAAQ,KAAK,IAAI;IAChC;IAUA,MAAMC,QAAgB,EAAEC,KAA+B,EAAQ,CAAC;IAUhE,KAAKD,QAAgB,EAAEC,KAA+B,EAAQ,CAAC;IAU/D,KAAKD,QAAgB,EAAEC,KAA+B,EAAQ,CAAC;IAU/D,MAAMD,QAAgB,EAAEC,KAA+B,EAAQ,CAAC;IAehE,SAASC,KAAe,EAAQ;QAC/B,IAAI,CAAC,MAAM,GAAGA;IACf;IAaA,WAAqB;QACpB,OAAO,IAAI,CAAC,MAAM;IACnB;IAmBA,YAAYC,QAAgB,EAAc;QACzC,OAAO,IAAIL,WAAW;YAAE,OAAO,IAAI,CAAC,MAAM;QAAC;IAC5C;AACD"}
@@ -0,0 +1,327 @@
1
+ /**
2
+ * Lightweight structured logging without external dependencies.
3
+ *
4
+ * This module provides a structured logging implementation that writes to stderr
5
+ * for MCP server compatibility. It supports multiple log levels, pretty printing,
6
+ * and hierarchical child loggers with inherited context.
7
+ *
8
+ * @module logger
9
+ */
10
+ /**
11
+ * Log level severity ordering.
12
+ *
13
+ * Levels are ordered from least severe (debug) to most severe (error).
14
+ * Only messages at or above the configured level will be logged.
15
+ */
16
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
17
+ /**
18
+ * Common logger interface for all logger implementations.
19
+ *
20
+ * This interface defines the contract that all loggers must implement,
21
+ * allowing them to be used interchangeably throughout the application.
22
+ */
23
+ export interface Logger {
24
+ /**
25
+ * Log a debug message.
26
+ * @param message - The message to log
27
+ * @param meta - Optional structured metadata
28
+ */
29
+ debug(message: string, meta?: Record<string, unknown>): void;
30
+ /**
31
+ * Log an info message.
32
+ * @param message - The message to log
33
+ * @param meta - Optional structured metadata
34
+ */
35
+ info(message: string, meta?: Record<string, unknown>): void;
36
+ /**
37
+ * Log a warning message.
38
+ * @param message - The message to log
39
+ * @param meta - Optional structured metadata
40
+ */
41
+ warn(message: string, meta?: Record<string, unknown>): void;
42
+ /**
43
+ * Log an error message.
44
+ * @param message - The message to log
45
+ * @param meta - Optional structured metadata
46
+ */
47
+ error(message: string, meta?: Record<string, unknown>): void;
48
+ /**
49
+ * Sets the minimum log level.
50
+ * @param level - The new minimum log level
51
+ */
52
+ setLevel(level: LogLevel): void;
53
+ /**
54
+ * Gets the current minimum log level.
55
+ * @returns The current log level
56
+ */
57
+ getLevel(): LogLevel;
58
+ }
59
+ /**
60
+ * A single log entry with all relevant metadata.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const entry: LogEntry = {
65
+ * level: 'info',
66
+ * message: 'Server started',
67
+ * timestamp: '2026-01-18T10:30:00.000Z',
68
+ * context: 'SequentialThinking',
69
+ * meta: { port: 3000 }
70
+ * };
71
+ * ```
72
+ */
73
+ export interface LogEntry {
74
+ /** Severity level of the log entry. */
75
+ level: LogLevel;
76
+ /** The primary log message. */
77
+ message: string;
78
+ /** ISO 8601 timestamp of when the log was created. */
79
+ timestamp: string;
80
+ /** Optional context/module name for categorization. */
81
+ context?: string;
82
+ /** Optional request correlation ID for tracing. */
83
+ requestId?: string;
84
+ /** Additional structured metadata to include with the log. */
85
+ meta?: Record<string, unknown>;
86
+ }
87
+ /**
88
+ * Configuration options for creating a `StructuredLogger` instance.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const options: LoggerOptions = {
93
+ * level: 'debug',
94
+ * context: 'MyModule',
95
+ * pretty: true
96
+ * };
97
+ * ```
98
+ */
99
+ export interface LoggerOptions {
100
+ /**
101
+ * Minimum log level to output.
102
+ * Messages below this level will be suppressed.
103
+ * @default 'info'
104
+ */
105
+ level?: LogLevel;
106
+ /**
107
+ * Default context for log messages.
108
+ * Can be extended with child loggers.
109
+ * @default 'SequentialThinking'
110
+ */
111
+ context?: string;
112
+ /**
113
+ * Whether to enable pretty (human-readable) output.
114
+ * When false, outputs JSON-formatted logs.
115
+ * @default true
116
+ */
117
+ pretty?: boolean;
118
+ }
119
+ /**
120
+ * Structured logger with level filtering and context support.
121
+ *
122
+ * This logger provides structured logging capabilities with configurable
123
+ * output formats, log levels, and hierarchical context. All output is
124
+ * written to stderr for compatibility with MCP servers.
125
+ *
126
+ * @remarks
127
+ * **Log Level Priority** (lowest to highest):
128
+ * - `debug` (0) - Detailed debugging information
129
+ * - `info` (1) - General informational messages
130
+ * - `warn` (2) - Warning messages for potential issues
131
+ * - `error` (3) - Error messages for failures
132
+ *
133
+ * Only messages at or above the configured level will be output.
134
+ *
135
+ * **Output Formats:**
136
+ * - Pretty (default): `[timestamp] [LEVEL] [context] message {meta}`
137
+ * - JSON: `{"level":"info","message":"...","timestamp":"...","context":"...","meta":{...}}`
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * // Create a logger
142
+ * const logger = new StructuredLogger({
143
+ * level: 'info',
144
+ * context: 'SequentialThinking',
145
+ * pretty: true
146
+ * });
147
+ *
148
+ * // Log messages
149
+ * logger.debug('Detailed debug info', { userId: '123' });
150
+ * logger.info('Server started', { port: 3000 });
151
+ * logger.warn('High memory usage', { usage: '85%' });
152
+ * logger.error('Connection failed', { error: 'ECONNREFUSED' });
153
+ *
154
+ * // Create a child logger with extended context
155
+ * const childLogger = logger.createChild('Database');
156
+ * childLogger.info('Query executed', { rows: 42 });
157
+ * // Output: [timestamp] [INFO] [SequentialThinking:Database] Query executed {"rows":42}
158
+ * ```
159
+ */
160
+ export declare class StructuredLogger {
161
+ /** Current minimum log level. */
162
+ private _level;
163
+ /** Default context for log messages. */
164
+ private _context;
165
+ /** Whether pretty printing is enabled. */
166
+ private _pretty;
167
+ /**
168
+ * Log level priority ordering for filtering.
169
+ * Higher numbers = higher severity.
170
+ * @private
171
+ */
172
+ private static readonly LEVEL_PRIORITY;
173
+ /**
174
+ * Creates a new StructuredLogger instance.
175
+ *
176
+ * @param options - Configuration options for the logger
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * // Default configuration
181
+ * const logger1 = new StructuredLogger();
182
+ *
183
+ * // Custom configuration
184
+ * const logger2 = new StructuredLogger({
185
+ * level: 'debug',
186
+ * context: 'MyApp',
187
+ * pretty: false // JSON output
188
+ * });
189
+ * ```
190
+ */
191
+ constructor(options?: LoggerOptions);
192
+ /**
193
+ * Determines whether a message at the given level should be logged.
194
+ * @param level - The log level to check
195
+ * @returns true if the level meets the threshold, false otherwise
196
+ * @private
197
+ */
198
+ private shouldLog;
199
+ /**
200
+ * Formats a log entry for output.
201
+ * @param entry - The log entry to format
202
+ * @returns Formatted string representation
203
+ * @private
204
+ */
205
+ private format;
206
+ /**
207
+ * Internal logging method that handles level filtering and output.
208
+ * @param level - The log level for this message
209
+ * @param message - The message to log
210
+ * @param meta - Optional structured metadata
211
+ * @private
212
+ */
213
+ private log;
214
+ /**
215
+ * Log a debug message.
216
+ *
217
+ * Debug messages contain detailed information typically used for
218
+ * troubleshooting and development. Only output when log level is 'debug'.
219
+ *
220
+ * @param message - The message to log
221
+ * @param meta - Optional structured metadata
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * logger.debug('Processing request', { path: '/api/users', method: 'GET' });
226
+ * ```
227
+ */
228
+ debug(message: string, meta?: Record<string, unknown>): void;
229
+ /**
230
+ * Log an info message.
231
+ *
232
+ * Info messages contain general informational messages about normal operation.
233
+ * Output when log level is 'info' or lower.
234
+ *
235
+ * @param message - The message to log
236
+ * @param meta - Optional structured metadata
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * logger.info('Server started', { port: 3000, env: 'production' });
241
+ * ```
242
+ */
243
+ info(message: string, meta?: Record<string, unknown>): void;
244
+ /**
245
+ * Log a warning message.
246
+ *
247
+ * Warning messages indicate potential issues that don't prevent operation
248
+ * but may require attention. Output when log level is 'warn' or lower.
249
+ *
250
+ * @param message - The message to log
251
+ * @param meta - Optional structured metadata
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * logger.warn('High memory usage detected', { usage: '85%', threshold: '80%' });
256
+ * ```
257
+ */
258
+ warn(message: string, meta?: Record<string, unknown>): void;
259
+ /**
260
+ * Log an error message.
261
+ *
262
+ * Error messages indicate failures or error conditions. Always output
263
+ * regardless of log level setting.
264
+ *
265
+ * @param message - The message to log
266
+ * @param meta - Optional structured metadata
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * logger.error('Database connection failed', { error: err.message, code: err.code });
271
+ * ```
272
+ */
273
+ error(message: string, meta?: Record<string, unknown>): void;
274
+ /**
275
+ * Creates a child logger with inherited settings and extended context.
276
+ *
277
+ * Child loggers inherit the parent's log level and pretty print setting,
278
+ * but have their context appended to the parent's context for hierarchical logging.
279
+ *
280
+ * @param context - Additional context to append to the parent's context
281
+ * @returns A new logger instance with extended context
282
+ *
283
+ * @example
284
+ * ```typescript
285
+ * const parentLogger = new StructuredLogger({ context: 'App' });
286
+ * const dbLogger = parentLogger.createChild('Database');
287
+ * const queryLogger = dbLogger.createChild('Query');
288
+ *
289
+ * parentLogger.info('Starting up');
290
+ * // Output: [timestamp] [INFO] [App] Starting up
291
+ *
292
+ * dbLogger.info('Connected');
293
+ * // Output: [timestamp] [INFO] [App:Database] Connected
294
+ *
295
+ * queryLogger.info('Executed in 5ms');
296
+ * // Output: [timestamp] [INFO] [App:Database:Query] Executed in 5ms
297
+ * ```
298
+ */
299
+ createChild(context: string): StructuredLogger;
300
+ /**
301
+ * Sets the minimum log level.
302
+ *
303
+ * Only messages at or above this level will be output.
304
+ *
305
+ * @param level - The new minimum log level
306
+ *
307
+ * @example
308
+ * ```typescript
309
+ * logger.setLevel('debug'); // Enable all logging
310
+ * logger.setLevel('error'); // Only show errors
311
+ * ```
312
+ */
313
+ setLevel(level: LogLevel): void;
314
+ /**
315
+ * Gets the current minimum log level.
316
+ *
317
+ * @returns The current log level
318
+ *
319
+ * @example
320
+ * ```typescript
321
+ * const currentLevel = logger.getLevel();
322
+ * console.log(`Current level: ${currentLevel}`);
323
+ * ```
324
+ */
325
+ getLevel(): LogLevel;
326
+ }
327
+ //# sourceMappingURL=StructuredLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StructuredLogger.d.ts","sourceRoot":"","sources":["../../src/logger/StructuredLogger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACtB;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE7D;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE5D;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE5D;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE7D;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEhC;;;OAGG;IACH,QAAQ,IAAI,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,QAAQ;IACxB,uCAAuC;IACvC,KAAK,EAAE,QAAQ,CAAC;IAEhB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAEhB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAElB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC;IAEjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,gBAAgB;IAC5B,iCAAiC;IACjC,OAAO,CAAC,MAAM,CAAW;IAEzB,wCAAwC;IACxC,OAAO,CAAC,QAAQ,CAAS;IAEzB,0CAA0C;IAC1C,OAAO,CAAC,OAAO,CAAU;IAEzB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAKpC;IAEF;;;;;;;;;;;;;;;;;OAiBG;gBACS,OAAO,GAAE,aAAkB;IAMvC;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAIjB;;;;;OAKG;IACH,OAAO,CAAC,MAAM;IASd;;;;;;OAMG;IACH,OAAO,CAAC,GAAG;IAoBX;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI5D;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI5D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB;IAQ9C;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/B;;;;;;;;;;OAUG;IACH,QAAQ,IAAI,QAAQ;CAGpB"}
@@ -0,0 +1,72 @@
1
+ import { getRequestId } from "../context/RequestContext.js";
2
+ class StructuredLogger {
3
+ _level;
4
+ _context;
5
+ _pretty;
6
+ static LEVEL_PRIORITY = {
7
+ debug: 0,
8
+ info: 1,
9
+ warn: 2,
10
+ error: 3
11
+ };
12
+ constructor(options = {}){
13
+ this._level = options.level ?? 'info';
14
+ this._context = options.context ?? 'SequentialThinking';
15
+ this._pretty = options.pretty ?? true;
16
+ }
17
+ shouldLog(level) {
18
+ return StructuredLogger.LEVEL_PRIORITY[level] >= StructuredLogger.LEVEL_PRIORITY[this._level];
19
+ }
20
+ format(entry) {
21
+ if (this._pretty) {
22
+ const metaStr = entry.meta ? ` ${JSON.stringify(entry.meta)}` : '';
23
+ const requestIdStr = entry.requestId ? ` [${entry.requestId}]` : '';
24
+ return `[${entry.timestamp}] [${entry.level.toUpperCase()}]${entry.context ? ` [${entry.context}]` : ''}${requestIdStr} ${entry.message}${metaStr}`;
25
+ }
26
+ return JSON.stringify(entry);
27
+ }
28
+ log(level, message, meta) {
29
+ if (!this.shouldLog(level)) return;
30
+ const requestId = getRequestId();
31
+ const entry = {
32
+ level,
33
+ message,
34
+ timestamp: new Date().toISOString(),
35
+ context: this._context,
36
+ meta,
37
+ ...requestId ? {
38
+ requestId
39
+ } : {}
40
+ };
41
+ const formatted = this.format(entry);
42
+ console.error(formatted);
43
+ }
44
+ debug(message, meta) {
45
+ this.log('debug', message, meta);
46
+ }
47
+ info(message, meta) {
48
+ this.log('info', message, meta);
49
+ }
50
+ warn(message, meta) {
51
+ this.log('warn', message, meta);
52
+ }
53
+ error(message, meta) {
54
+ this.log('error', message, meta);
55
+ }
56
+ createChild(context) {
57
+ return new StructuredLogger({
58
+ level: this._level,
59
+ context: `${this._context}:${context}`,
60
+ pretty: this._pretty
61
+ });
62
+ }
63
+ setLevel(level) {
64
+ this._level = level;
65
+ }
66
+ getLevel() {
67
+ return this._level;
68
+ }
69
+ }
70
+ export { StructuredLogger };
71
+
72
+ //# sourceMappingURL=StructuredLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger/StructuredLogger.js","sources":["../../src/logger/StructuredLogger.ts"],"sourcesContent":["/**\n * Lightweight structured logging without external dependencies.\n *\n * This module provides a structured logging implementation that writes to stderr\n * for MCP server compatibility. It supports multiple log levels, pretty printing,\n * and hierarchical child loggers with inherited context.\n *\n * @module logger\n */\n\nimport { getRequestId } from '../context/RequestContext.js';\n\n/**\n * Log level severity ordering.\n *\n * Levels are ordered from least severe (debug) to most severe (error).\n * Only messages at or above the configured level will be logged.\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Common logger interface for all logger implementations.\n *\n * This interface defines the contract that all loggers must implement,\n * allowing them to be used interchangeably throughout the application.\n */\nexport interface Logger {\n\t/**\n\t * Log a debug message.\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t */\n\tdebug(message: string, meta?: Record<string, unknown>): void;\n\n\t/**\n\t * Log an info message.\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t */\n\tinfo(message: string, meta?: Record<string, unknown>): void;\n\n\t/**\n\t * Log a warning message.\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t */\n\twarn(message: string, meta?: Record<string, unknown>): void;\n\n\t/**\n\t * Log an error message.\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t */\n\terror(message: string, meta?: Record<string, unknown>): void;\n\n\t/**\n\t * Sets the minimum log level.\n\t * @param level - The new minimum log level\n\t */\n\tsetLevel(level: LogLevel): void;\n\n\t/**\n\t * Gets the current minimum log level.\n\t * @returns The current log level\n\t */\n\tgetLevel(): LogLevel;\n}\n\n/**\n * A single log entry with all relevant metadata.\n *\n * @example\n * ```typescript\n * const entry: LogEntry = {\n * level: 'info',\n * message: 'Server started',\n * timestamp: '2026-01-18T10:30:00.000Z',\n * context: 'SequentialThinking',\n * meta: { port: 3000 }\n * };\n * ```\n */\nexport interface LogEntry {\n\t/** Severity level of the log entry. */\n\tlevel: LogLevel;\n\n\t/** The primary log message. */\n\tmessage: string;\n\n\t/** ISO 8601 timestamp of when the log was created. */\n\ttimestamp: string;\n\n\t/** Optional context/module name for categorization. */\n\tcontext?: string;\n\n\t/** Optional request correlation ID for tracing. */\n\trequestId?: string;\n\n\t/** Additional structured metadata to include with the log. */\n\tmeta?: Record<string, unknown>;\n}\n\n/**\n * Configuration options for creating a `StructuredLogger` instance.\n *\n * @example\n * ```typescript\n * const options: LoggerOptions = {\n * level: 'debug',\n * context: 'MyModule',\n * pretty: true\n * };\n * ```\n */\nexport interface LoggerOptions {\n\t/**\n\t * Minimum log level to output.\n\t * Messages below this level will be suppressed.\n\t * @default 'info'\n\t */\n\tlevel?: LogLevel;\n\n\t/**\n\t * Default context for log messages.\n\t * Can be extended with child loggers.\n\t * @default 'SequentialThinking'\n\t */\n\tcontext?: string;\n\n\t/**\n\t * Whether to enable pretty (human-readable) output.\n\t * When false, outputs JSON-formatted logs.\n\t * @default true\n\t */\n\tpretty?: boolean;\n}\n\n/**\n * Structured logger with level filtering and context support.\n *\n * This logger provides structured logging capabilities with configurable\n * output formats, log levels, and hierarchical context. All output is\n * written to stderr for compatibility with MCP servers.\n *\n * @remarks\n * **Log Level Priority** (lowest to highest):\n * - `debug` (0) - Detailed debugging information\n * - `info` (1) - General informational messages\n * - `warn` (2) - Warning messages for potential issues\n * - `error` (3) - Error messages for failures\n *\n * Only messages at or above the configured level will be output.\n *\n * **Output Formats:**\n * - Pretty (default): `[timestamp] [LEVEL] [context] message {meta}`\n * - JSON: `{\"level\":\"info\",\"message\":\"...\",\"timestamp\":\"...\",\"context\":\"...\",\"meta\":{...}}`\n *\n * @example\n * ```typescript\n * // Create a logger\n * const logger = new StructuredLogger({\n * level: 'info',\n * context: 'SequentialThinking',\n * pretty: true\n * });\n *\n * // Log messages\n * logger.debug('Detailed debug info', { userId: '123' });\n * logger.info('Server started', { port: 3000 });\n * logger.warn('High memory usage', { usage: '85%' });\n * logger.error('Connection failed', { error: 'ECONNREFUSED' });\n *\n * // Create a child logger with extended context\n * const childLogger = logger.createChild('Database');\n * childLogger.info('Query executed', { rows: 42 });\n * // Output: [timestamp] [INFO] [SequentialThinking:Database] Query executed {\"rows\":42}\n * ```\n */\nexport class StructuredLogger {\n\t/** Current minimum log level. */\n\tprivate _level: LogLevel;\n\n\t/** Default context for log messages. */\n\tprivate _context: string;\n\n\t/** Whether pretty printing is enabled. */\n\tprivate _pretty: boolean;\n\n\t/**\n\t * Log level priority ordering for filtering.\n\t * Higher numbers = higher severity.\n\t * @private\n\t */\n\tprivate static readonly LEVEL_PRIORITY: Record<LogLevel, number> = {\n\t\tdebug: 0,\n\t\tinfo: 1,\n\t\twarn: 2,\n\t\terror: 3,\n\t};\n\n\t/**\n\t * Creates a new StructuredLogger instance.\n\t *\n\t * @param options - Configuration options for the logger\n\t *\n\t * @example\n\t * ```typescript\n\t * // Default configuration\n\t * const logger1 = new StructuredLogger();\n\t *\n\t * // Custom configuration\n\t * const logger2 = new StructuredLogger({\n\t * level: 'debug',\n\t * context: 'MyApp',\n\t * pretty: false // JSON output\n\t * });\n\t * ```\n\t */\n\tconstructor(options: LoggerOptions = {}) {\n\t\tthis._level = options.level ?? 'info';\n\t\tthis._context = options.context ?? 'SequentialThinking';\n\t\tthis._pretty = options.pretty ?? true;\n\t}\n\n\t/**\n\t * Determines whether a message at the given level should be logged.\n\t * @param level - The log level to check\n\t * @returns true if the level meets the threshold, false otherwise\n\t * @private\n\t */\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn StructuredLogger.LEVEL_PRIORITY[level] >= StructuredLogger.LEVEL_PRIORITY[this._level];\n\t}\n\n\t/**\n\t * Formats a log entry for output.\n\t * @param entry - The log entry to format\n\t * @returns Formatted string representation\n\t * @private\n\t */\n\tprivate format(entry: LogEntry): string {\n\t\tif (this._pretty) {\n\t\t\tconst metaStr = entry.meta ? ` ${JSON.stringify(entry.meta)}` : '';\n\t\t\tconst requestIdStr = entry.requestId ? ` [${entry.requestId}]` : '';\n\t\t\treturn `[${entry.timestamp}] [${entry.level.toUpperCase()}]${entry.context ? ` [${entry.context}]` : ''}${requestIdStr} ${entry.message}${metaStr}`;\n\t\t}\n\t\treturn JSON.stringify(entry);\n\t}\n\n\t/**\n\t * Internal logging method that handles level filtering and output.\n\t * @param level - The log level for this message\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t * @private\n\t */\n\tprivate log(level: LogLevel, message: string, meta?: Record<string, unknown>): void {\n\t\tif (!this.shouldLog(level)) return;\n\n\t\tconst requestId = getRequestId();\n\n\t\tconst entry: LogEntry = {\n\t\t\tlevel,\n\t\t\tmessage,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcontext: this._context,\n\t\t\tmeta,\n\t\t\t...(requestId ? { requestId } : {}),\n\t\t};\n\n\t\tconst formatted = this.format(entry);\n\n\t\t// Write to stderr for MCP server compatibility\n\t\tconsole.error(formatted);\n\t}\n\n\t/**\n\t * Log a debug message.\n\t *\n\t * Debug messages contain detailed information typically used for\n\t * troubleshooting and development. Only output when log level is 'debug'.\n\t *\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t *\n\t * @example\n\t * ```typescript\n\t * logger.debug('Processing request', { path: '/api/users', method: 'GET' });\n\t * ```\n\t */\n\tdebug(message: string, meta?: Record<string, unknown>): void {\n\t\tthis.log('debug', message, meta);\n\t}\n\n\t/**\n\t * Log an info message.\n\t *\n\t * Info messages contain general informational messages about normal operation.\n\t * Output when log level is 'info' or lower.\n\t *\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t *\n\t * @example\n\t * ```typescript\n\t * logger.info('Server started', { port: 3000, env: 'production' });\n\t * ```\n\t */\n\tinfo(message: string, meta?: Record<string, unknown>): void {\n\t\tthis.log('info', message, meta);\n\t}\n\n\t/**\n\t * Log a warning message.\n\t *\n\t * Warning messages indicate potential issues that don't prevent operation\n\t * but may require attention. Output when log level is 'warn' or lower.\n\t *\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t *\n\t * @example\n\t * ```typescript\n\t * logger.warn('High memory usage detected', { usage: '85%', threshold: '80%' });\n\t * ```\n\t */\n\twarn(message: string, meta?: Record<string, unknown>): void {\n\t\tthis.log('warn', message, meta);\n\t}\n\n\t/**\n\t * Log an error message.\n\t *\n\t * Error messages indicate failures or error conditions. Always output\n\t * regardless of log level setting.\n\t *\n\t * @param message - The message to log\n\t * @param meta - Optional structured metadata\n\t *\n\t * @example\n\t * ```typescript\n\t * logger.error('Database connection failed', { error: err.message, code: err.code });\n\t * ```\n\t */\n\terror(message: string, meta?: Record<string, unknown>): void {\n\t\tthis.log('error', message, meta);\n\t}\n\n\t/**\n\t * Creates a child logger with inherited settings and extended context.\n\t *\n\t * Child loggers inherit the parent's log level and pretty print setting,\n\t * but have their context appended to the parent's context for hierarchical logging.\n\t *\n\t * @param context - Additional context to append to the parent's context\n\t * @returns A new logger instance with extended context\n\t *\n\t * @example\n\t * ```typescript\n\t * const parentLogger = new StructuredLogger({ context: 'App' });\n\t * const dbLogger = parentLogger.createChild('Database');\n\t * const queryLogger = dbLogger.createChild('Query');\n\t *\n\t * parentLogger.info('Starting up');\n\t * // Output: [timestamp] [INFO] [App] Starting up\n\t *\n\t * dbLogger.info('Connected');\n\t * // Output: [timestamp] [INFO] [App:Database] Connected\n\t *\n\t * queryLogger.info('Executed in 5ms');\n\t * // Output: [timestamp] [INFO] [App:Database:Query] Executed in 5ms\n\t * ```\n\t */\n\tcreateChild(context: string): StructuredLogger {\n\t\treturn new StructuredLogger({\n\t\t\tlevel: this._level,\n\t\t\tcontext: `${this._context}:${context}`,\n\t\t\tpretty: this._pretty,\n\t\t});\n\t}\n\n\t/**\n\t * Sets the minimum log level.\n\t *\n\t * Only messages at or above this level will be output.\n\t *\n\t * @param level - The new minimum log level\n\t *\n\t * @example\n\t * ```typescript\n\t * logger.setLevel('debug'); // Enable all logging\n\t * logger.setLevel('error'); // Only show errors\n\t * ```\n\t */\n\tsetLevel(level: LogLevel): void {\n\t\tthis._level = level;\n\t}\n\n\t/**\n\t * Gets the current minimum log level.\n\t *\n\t * @returns The current log level\n\t *\n\t * @example\n\t * ```typescript\n\t * const currentLevel = logger.getLevel();\n\t * console.log(`Current level: ${currentLevel}`);\n\t * ```\n\t */\n\tgetLevel(): LogLevel {\n\t\treturn this._level;\n\t}\n}\n"],"names":["StructuredLogger","options","level","entry","metaStr","JSON","requestIdStr","message","meta","requestId","getRequestId","Date","formatted","console","context"],"mappings":";AAkLO,MAAMA;IAEJ,OAAiB;IAGjB,SAAiB;IAGjB,QAAiB;IAOzB,OAAwB,iBAA2C;QAClE,OAAO;QACP,MAAM;QACN,MAAM;QACN,OAAO;IACR,EAAE;IAoBF,YAAYC,UAAyB,CAAC,CAAC,CAAE;QACxC,IAAI,CAAC,MAAM,GAAGA,QAAQ,KAAK,IAAI;QAC/B,IAAI,CAAC,QAAQ,GAAGA,QAAQ,OAAO,IAAI;QACnC,IAAI,CAAC,OAAO,GAAGA,QAAQ,MAAM,IAAI;IAClC;IAQQ,UAAUC,KAAe,EAAW;QAC3C,OAAOF,iBAAiB,cAAc,CAACE,MAAM,IAAIF,iBAAiB,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9F;IAQQ,OAAOG,KAAe,EAAU;QACvC,IAAI,IAAI,CAAC,OAAO,EAAE;YACjB,MAAMC,UAAUD,MAAM,IAAI,GAAG,CAAC,CAAC,EAAEE,KAAK,SAAS,CAACF,MAAM,IAAI,GAAG,GAAG;YAChE,MAAMG,eAAeH,MAAM,SAAS,GAAG,CAAC,EAAE,EAAEA,MAAM,SAAS,CAAC,CAAC,CAAC,GAAG;YACjE,OAAO,CAAC,CAAC,EAAEA,MAAM,SAAS,CAAC,GAAG,EAAEA,MAAM,KAAK,CAAC,WAAW,GAAG,CAAC,EAAEA,MAAM,OAAO,GAAG,CAAC,EAAE,EAAEA,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,KAAKG,aAAa,CAAC,EAAEH,MAAM,OAAO,GAAGC,SAAS;QACpJ;QACA,OAAOC,KAAK,SAAS,CAACF;IACvB;IASQ,IAAID,KAAe,EAAEK,OAAe,EAAEC,IAA8B,EAAQ;QACnF,IAAI,CAAC,IAAI,CAAC,SAAS,CAACN,QAAQ;QAE5B,MAAMO,YAAYC;QAElB,MAAMP,QAAkB;YACvBD;YACAK;YACA,WAAW,IAAII,OAAO,WAAW;YACjC,SAAS,IAAI,CAAC,QAAQ;YACtBH;YACA,GAAIC,YAAY;gBAAEA;YAAU,IAAI,CAAC,CAAC;QACnC;QAEA,MAAMG,YAAY,IAAI,CAAC,MAAM,CAACT;QAG9BU,QAAQ,KAAK,CAACD;IACf;IAgBA,MAAML,OAAe,EAAEC,IAA8B,EAAQ;QAC5D,IAAI,CAAC,GAAG,CAAC,SAASD,SAASC;IAC5B;IAgBA,KAAKD,OAAe,EAAEC,IAA8B,EAAQ;QAC3D,IAAI,CAAC,GAAG,CAAC,QAAQD,SAASC;IAC3B;IAgBA,KAAKD,OAAe,EAAEC,IAA8B,EAAQ;QAC3D,IAAI,CAAC,GAAG,CAAC,QAAQD,SAASC;IAC3B;IAgBA,MAAMD,OAAe,EAAEC,IAA8B,EAAQ;QAC5D,IAAI,CAAC,GAAG,CAAC,SAASD,SAASC;IAC5B;IA2BA,YAAYM,OAAe,EAAoB;QAC9C,OAAO,IAAId,iBAAiB;YAC3B,OAAO,IAAI,CAAC,MAAM;YAClB,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAEc,SAAS;YACtC,QAAQ,IAAI,CAAC,OAAO;QACrB;IACD;IAeA,SAASZ,KAAe,EAAQ;QAC/B,IAAI,CAAC,MAAM,GAAGA;IACf;IAaA,WAAqB;QACpB,OAAO,IAAI,CAAC,MAAM;IACnB;AACD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=metrics.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.test.d.ts","sourceRoot":"","sources":["../../../src/metrics/__tests__/metrics.test.ts"],"names":[],"mappings":""}