@cyanheads/mcp-ts-core 0.1.0-beta.12

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 (485) hide show
  1. package/CLAUDE.md +583 -0
  2. package/LICENSE +201 -0
  3. package/README.md +287 -0
  4. package/biome.json +103 -0
  5. package/dist/app.d.ts +82 -0
  6. package/dist/app.d.ts.map +1 -0
  7. package/dist/app.js +222 -0
  8. package/dist/app.js.map +1 -0
  9. package/dist/cli/init.d.ts +8 -0
  10. package/dist/cli/init.d.ts.map +1 -0
  11. package/dist/cli/init.js +161 -0
  12. package/dist/cli/init.js.map +1 -0
  13. package/dist/config/index.d.ts +349 -0
  14. package/dist/config/index.d.ts.map +1 -0
  15. package/dist/config/index.js +464 -0
  16. package/dist/config/index.js.map +1 -0
  17. package/dist/context.d.ts +119 -0
  18. package/dist/context.d.ts.map +1 -0
  19. package/dist/context.js +144 -0
  20. package/dist/context.js.map +1 -0
  21. package/dist/index.d.ts +8 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +9 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/mcp-server/prompts/prompt-registration.d.ts +33 -0
  26. package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -0
  27. package/dist/mcp-server/prompts/prompt-registration.js +91 -0
  28. package/dist/mcp-server/prompts/prompt-registration.js.map +1 -0
  29. package/dist/mcp-server/prompts/utils/newPromptDefinition.d.ts +49 -0
  30. package/dist/mcp-server/prompts/utils/newPromptDefinition.d.ts.map +1 -0
  31. package/dist/mcp-server/prompts/utils/newPromptDefinition.js +39 -0
  32. package/dist/mcp-server/prompts/utils/newPromptDefinition.js.map +1 -0
  33. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts +37 -0
  34. package/dist/mcp-server/prompts/utils/promptDefinition.d.ts.map +1 -0
  35. package/dist/mcp-server/prompts/utils/promptDefinition.js +2 -0
  36. package/dist/mcp-server/prompts/utils/promptDefinition.js.map +1 -0
  37. package/dist/mcp-server/resources/resource-registration.d.ts +27 -0
  38. package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -0
  39. package/dist/mcp-server/resources/resource-registration.js +85 -0
  40. package/dist/mcp-server/resources/resource-registration.js.map +1 -0
  41. package/dist/mcp-server/resources/utils/newResourceDefinition.d.ts +84 -0
  42. package/dist/mcp-server/resources/utils/newResourceDefinition.d.ts.map +1 -0
  43. package/dist/mcp-server/resources/utils/newResourceDefinition.js +40 -0
  44. package/dist/mcp-server/resources/utils/newResourceDefinition.js.map +1 -0
  45. package/dist/mcp-server/resources/utils/newResourceHandlerFactory.d.ts +32 -0
  46. package/dist/mcp-server/resources/utils/newResourceHandlerFactory.d.ts.map +1 -0
  47. package/dist/mcp-server/resources/utils/newResourceHandlerFactory.js +103 -0
  48. package/dist/mcp-server/resources/utils/newResourceHandlerFactory.js.map +1 -0
  49. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +94 -0
  50. package/dist/mcp-server/resources/utils/resourceDefinition.d.ts.map +1 -0
  51. package/dist/mcp-server/resources/utils/resourceDefinition.js +2 -0
  52. package/dist/mcp-server/resources/utils/resourceDefinition.js.map +1 -0
  53. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +14 -0
  54. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -0
  55. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +111 -0
  56. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -0
  57. package/dist/mcp-server/roots/roots-registration.d.ts +22 -0
  58. package/dist/mcp-server/roots/roots-registration.d.ts.map +1 -0
  59. package/dist/mcp-server/roots/roots-registration.js +25 -0
  60. package/dist/mcp-server/roots/roots-registration.js.map +1 -0
  61. package/dist/mcp-server/server.d.ts +34 -0
  62. package/dist/mcp-server/server.d.ts.map +1 -0
  63. package/dist/mcp-server/server.js +62 -0
  64. package/dist/mcp-server/server.js.map +1 -0
  65. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts +42 -0
  66. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts.map +1 -0
  67. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js +70 -0
  68. package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js.map +1 -0
  69. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts +109 -0
  70. package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts.map +1 -0
  71. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js +209 -0
  72. package/dist/mcp-server/tasks/core/storageBackedTaskStore.js.map +1 -0
  73. package/dist/mcp-server/tasks/core/taskManager.d.ts +103 -0
  74. package/dist/mcp-server/tasks/core/taskManager.d.ts.map +1 -0
  75. package/dist/mcp-server/tasks/core/taskManager.js +144 -0
  76. package/dist/mcp-server/tasks/core/taskManager.js.map +1 -0
  77. package/dist/mcp-server/tasks/core/taskTypes.d.ts +11 -0
  78. package/dist/mcp-server/tasks/core/taskTypes.d.ts.map +1 -0
  79. package/dist/mcp-server/tasks/core/taskTypes.js +13 -0
  80. package/dist/mcp-server/tasks/core/taskTypes.js.map +1 -0
  81. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts +108 -0
  82. package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts.map +1 -0
  83. package/dist/mcp-server/tasks/utils/taskToolDefinition.js +14 -0
  84. package/dist/mcp-server/tasks/utils/taskToolDefinition.js.map +1 -0
  85. package/dist/mcp-server/tools/tool-registration.d.ts +49 -0
  86. package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -0
  87. package/dist/mcp-server/tools/tool-registration.js +269 -0
  88. package/dist/mcp-server/tools/tool-registration.js.map +1 -0
  89. package/dist/mcp-server/tools/utils/newToolDefinition.d.ts +73 -0
  90. package/dist/mcp-server/tools/utils/newToolDefinition.d.ts.map +1 -0
  91. package/dist/mcp-server/tools/utils/newToolDefinition.js +45 -0
  92. package/dist/mcp-server/tools/utils/newToolDefinition.js.map +1 -0
  93. package/dist/mcp-server/tools/utils/newToolHandlerFactory.d.ts +33 -0
  94. package/dist/mcp-server/tools/utils/newToolHandlerFactory.d.ts.map +1 -0
  95. package/dist/mcp-server/tools/utils/newToolHandlerFactory.js +107 -0
  96. package/dist/mcp-server/tools/utils/newToolHandlerFactory.js.map +1 -0
  97. package/dist/mcp-server/tools/utils/toolDefinition.d.ts +118 -0
  98. package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -0
  99. package/dist/mcp-server/tools/utils/toolDefinition.js +2 -0
  100. package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -0
  101. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +34 -0
  102. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -0
  103. package/dist/mcp-server/tools/utils/toolHandlerFactory.js +68 -0
  104. package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -0
  105. package/dist/mcp-server/transports/ITransport.d.ts +15 -0
  106. package/dist/mcp-server/transports/ITransport.d.ts.map +1 -0
  107. package/dist/mcp-server/transports/ITransport.js +2 -0
  108. package/dist/mcp-server/transports/ITransport.js.map +1 -0
  109. package/dist/mcp-server/transports/auth/authFactory.d.ts +11 -0
  110. package/dist/mcp-server/transports/auth/authFactory.d.ts.map +1 -0
  111. package/dist/mcp-server/transports/auth/authFactory.js +43 -0
  112. package/dist/mcp-server/transports/auth/authFactory.js.map +1 -0
  113. package/dist/mcp-server/transports/auth/authMiddleware.d.ts +24 -0
  114. package/dist/mcp-server/transports/auth/authMiddleware.d.ts.map +1 -0
  115. package/dist/mcp-server/transports/auth/authMiddleware.js +69 -0
  116. package/dist/mcp-server/transports/auth/authMiddleware.js.map +1 -0
  117. package/dist/mcp-server/transports/auth/lib/authContext.d.ts +34 -0
  118. package/dist/mcp-server/transports/auth/lib/authContext.d.ts.map +1 -0
  119. package/dist/mcp-server/transports/auth/lib/authContext.js +25 -0
  120. package/dist/mcp-server/transports/auth/lib/authContext.js.map +1 -0
  121. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts +19 -0
  122. package/dist/mcp-server/transports/auth/lib/authTypes.d.ts.map +1 -0
  123. package/dist/mcp-server/transports/auth/lib/authTypes.js +2 -0
  124. package/dist/mcp-server/transports/auth/lib/authTypes.js.map +1 -0
  125. package/dist/mcp-server/transports/auth/lib/authUtils.d.ts +18 -0
  126. package/dist/mcp-server/transports/auth/lib/authUtils.d.ts.map +1 -0
  127. package/dist/mcp-server/transports/auth/lib/authUtils.js +64 -0
  128. package/dist/mcp-server/transports/auth/lib/authUtils.js.map +1 -0
  129. package/dist/mcp-server/transports/auth/lib/checkScopes.d.ts +25 -0
  130. package/dist/mcp-server/transports/auth/lib/checkScopes.d.ts.map +1 -0
  131. package/dist/mcp-server/transports/auth/lib/checkScopes.js +34 -0
  132. package/dist/mcp-server/transports/auth/lib/checkScopes.js.map +1 -0
  133. package/dist/mcp-server/transports/auth/lib/claimParser.d.ts +34 -0
  134. package/dist/mcp-server/transports/auth/lib/claimParser.d.ts.map +1 -0
  135. package/dist/mcp-server/transports/auth/lib/claimParser.js +58 -0
  136. package/dist/mcp-server/transports/auth/lib/claimParser.js.map +1 -0
  137. package/dist/mcp-server/transports/auth/lib/withAuth.d.ts +25 -0
  138. package/dist/mcp-server/transports/auth/lib/withAuth.d.ts.map +1 -0
  139. package/dist/mcp-server/transports/auth/lib/withAuth.js +30 -0
  140. package/dist/mcp-server/transports/auth/lib/withAuth.js.map +1 -0
  141. package/dist/mcp-server/transports/auth/strategies/authStrategy.d.ts +18 -0
  142. package/dist/mcp-server/transports/auth/strategies/authStrategy.d.ts.map +1 -0
  143. package/dist/mcp-server/transports/auth/strategies/authStrategy.js +2 -0
  144. package/dist/mcp-server/transports/auth/strategies/authStrategy.js.map +1 -0
  145. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts +14 -0
  146. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts.map +1 -0
  147. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +86 -0
  148. package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js.map +1 -0
  149. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts +14 -0
  150. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts.map +1 -0
  151. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +113 -0
  152. package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js.map +1 -0
  153. package/dist/mcp-server/transports/http/httpErrorHandler.d.ts +25 -0
  154. package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -0
  155. package/dist/mcp-server/transports/http/httpErrorHandler.js +112 -0
  156. package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -0
  157. package/dist/mcp-server/transports/http/httpTransport.d.ts +47 -0
  158. package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -0
  159. package/dist/mcp-server/transports/http/httpTransport.js +396 -0
  160. package/dist/mcp-server/transports/http/httpTransport.js.map +1 -0
  161. package/dist/mcp-server/transports/http/httpTypes.d.ts +17 -0
  162. package/dist/mcp-server/transports/http/httpTypes.d.ts.map +1 -0
  163. package/dist/mcp-server/transports/http/httpTypes.js +2 -0
  164. package/dist/mcp-server/transports/http/httpTypes.js.map +1 -0
  165. package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts +21 -0
  166. package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts.map +1 -0
  167. package/dist/mcp-server/transports/http/protectedResourceMetadata.js +44 -0
  168. package/dist/mcp-server/transports/http/protectedResourceMetadata.js.map +1 -0
  169. package/dist/mcp-server/transports/http/sessionIdUtils.d.ts +33 -0
  170. package/dist/mcp-server/transports/http/sessionIdUtils.d.ts.map +1 -0
  171. package/dist/mcp-server/transports/http/sessionIdUtils.js +54 -0
  172. package/dist/mcp-server/transports/http/sessionIdUtils.js.map +1 -0
  173. package/dist/mcp-server/transports/http/sessionStore.d.ts +87 -0
  174. package/dist/mcp-server/transports/http/sessionStore.d.ts.map +1 -0
  175. package/dist/mcp-server/transports/http/sessionStore.js +209 -0
  176. package/dist/mcp-server/transports/http/sessionStore.js.map +1 -0
  177. package/dist/mcp-server/transports/manager.d.ts +22 -0
  178. package/dist/mcp-server/transports/manager.d.ts.map +1 -0
  179. package/dist/mcp-server/transports/manager.js +62 -0
  180. package/dist/mcp-server/transports/manager.js.map +1 -0
  181. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts +44 -0
  182. package/dist/mcp-server/transports/stdio/stdioTransport.d.ts.map +1 -0
  183. package/dist/mcp-server/transports/stdio/stdioTransport.js +63 -0
  184. package/dist/mcp-server/transports/stdio/stdioTransport.js.map +1 -0
  185. package/dist/services/graph/core/GraphService.d.ts +205 -0
  186. package/dist/services/graph/core/GraphService.d.ts.map +1 -0
  187. package/dist/services/graph/core/GraphService.js +231 -0
  188. package/dist/services/graph/core/GraphService.js.map +1 -0
  189. package/dist/services/graph/core/IGraphProvider.d.ts +295 -0
  190. package/dist/services/graph/core/IGraphProvider.d.ts.map +1 -0
  191. package/dist/services/graph/core/IGraphProvider.js +8 -0
  192. package/dist/services/graph/core/IGraphProvider.js.map +1 -0
  193. package/dist/services/graph/types.d.ts +107 -0
  194. package/dist/services/graph/types.d.ts.map +1 -0
  195. package/dist/services/graph/types.js +8 -0
  196. package/dist/services/graph/types.js.map +1 -0
  197. package/dist/services/llm/core/ILlmProvider.d.ts +86 -0
  198. package/dist/services/llm/core/ILlmProvider.d.ts.map +1 -0
  199. package/dist/services/llm/core/ILlmProvider.js +2 -0
  200. package/dist/services/llm/core/ILlmProvider.js.map +1 -0
  201. package/dist/services/llm/providers/openrouter.provider.d.ts +187 -0
  202. package/dist/services/llm/providers/openrouter.provider.d.ts.map +1 -0
  203. package/dist/services/llm/providers/openrouter.provider.js +302 -0
  204. package/dist/services/llm/providers/openrouter.provider.js.map +1 -0
  205. package/dist/services/llm/types.d.ts +16 -0
  206. package/dist/services/llm/types.d.ts.map +1 -0
  207. package/dist/services/llm/types.js +9 -0
  208. package/dist/services/llm/types.js.map +1 -0
  209. package/dist/services/speech/core/ISpeechProvider.d.ts +92 -0
  210. package/dist/services/speech/core/ISpeechProvider.d.ts.map +1 -0
  211. package/dist/services/speech/core/ISpeechProvider.js +34 -0
  212. package/dist/services/speech/core/ISpeechProvider.js.map +1 -0
  213. package/dist/services/speech/core/SpeechService.d.ts +87 -0
  214. package/dist/services/speech/core/SpeechService.d.ts.map +1 -0
  215. package/dist/services/speech/core/SpeechService.js +135 -0
  216. package/dist/services/speech/core/SpeechService.js.map +1 -0
  217. package/dist/services/speech/providers/elevenlabs.provider.d.ts +77 -0
  218. package/dist/services/speech/providers/elevenlabs.provider.d.ts.map +1 -0
  219. package/dist/services/speech/providers/elevenlabs.provider.js +199 -0
  220. package/dist/services/speech/providers/elevenlabs.provider.js.map +1 -0
  221. package/dist/services/speech/providers/whisper.provider.d.ts +94 -0
  222. package/dist/services/speech/providers/whisper.provider.d.ts.map +1 -0
  223. package/dist/services/speech/providers/whisper.provider.js +240 -0
  224. package/dist/services/speech/providers/whisper.provider.js.map +1 -0
  225. package/dist/services/speech/types.d.ts +173 -0
  226. package/dist/services/speech/types.d.ts.map +1 -0
  227. package/dist/services/speech/types.js +8 -0
  228. package/dist/services/speech/types.js.map +1 -0
  229. package/dist/storage/core/IStorageProvider.d.ts +159 -0
  230. package/dist/storage/core/IStorageProvider.d.ts.map +1 -0
  231. package/dist/storage/core/IStorageProvider.js +2 -0
  232. package/dist/storage/core/IStorageProvider.js.map +1 -0
  233. package/dist/storage/core/StorageService.d.ts +22 -0
  234. package/dist/storage/core/StorageService.d.ts.map +1 -0
  235. package/dist/storage/core/StorageService.js +151 -0
  236. package/dist/storage/core/StorageService.js.map +1 -0
  237. package/dist/storage/core/storageFactory.d.ts +66 -0
  238. package/dist/storage/core/storageFactory.d.ts.map +1 -0
  239. package/dist/storage/core/storageFactory.js +122 -0
  240. package/dist/storage/core/storageFactory.js.map +1 -0
  241. package/dist/storage/core/storageValidation.d.ts +77 -0
  242. package/dist/storage/core/storageValidation.d.ts.map +1 -0
  243. package/dist/storage/core/storageValidation.js +303 -0
  244. package/dist/storage/core/storageValidation.js.map +1 -0
  245. package/dist/storage/providers/cloudflare/d1Provider.d.ts +94 -0
  246. package/dist/storage/providers/cloudflare/d1Provider.d.ts.map +1 -0
  247. package/dist/storage/providers/cloudflare/d1Provider.js +347 -0
  248. package/dist/storage/providers/cloudflare/d1Provider.js.map +1 -0
  249. package/dist/storage/providers/cloudflare/kvProvider.d.ts +21 -0
  250. package/dist/storage/providers/cloudflare/kvProvider.d.ts.map +1 -0
  251. package/dist/storage/providers/cloudflare/kvProvider.js +183 -0
  252. package/dist/storage/providers/cloudflare/kvProvider.js.map +1 -0
  253. package/dist/storage/providers/cloudflare/r2Provider.d.ts +28 -0
  254. package/dist/storage/providers/cloudflare/r2Provider.d.ts.map +1 -0
  255. package/dist/storage/providers/cloudflare/r2Provider.js +222 -0
  256. package/dist/storage/providers/cloudflare/r2Provider.js.map +1 -0
  257. package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts +20 -0
  258. package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts.map +1 -0
  259. package/dist/storage/providers/fileSystem/fileSystemProvider.js +282 -0
  260. package/dist/storage/providers/fileSystem/fileSystemProvider.js.map +1 -0
  261. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +21 -0
  262. package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -0
  263. package/dist/storage/providers/inMemory/inMemoryProvider.js +139 -0
  264. package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -0
  265. package/dist/storage/providers/supabase/supabase.types.d.ts +49 -0
  266. package/dist/storage/providers/supabase/supabase.types.d.ts.map +1 -0
  267. package/dist/storage/providers/supabase/supabase.types.js +8 -0
  268. package/dist/storage/providers/supabase/supabase.types.js.map +1 -0
  269. package/dist/storage/providers/supabase/supabaseProvider.d.ts +24 -0
  270. package/dist/storage/providers/supabase/supabaseProvider.d.ts.map +1 -0
  271. package/dist/storage/providers/supabase/supabaseProvider.js +209 -0
  272. package/dist/storage/providers/supabase/supabaseProvider.js.map +1 -0
  273. package/dist/testing/index.d.ts +53 -0
  274. package/dist/testing/index.d.ts.map +1 -0
  275. package/dist/testing/index.js +132 -0
  276. package/dist/testing/index.js.map +1 -0
  277. package/dist/types-global/errors.d.ts +83 -0
  278. package/dist/types-global/errors.d.ts.map +1 -0
  279. package/dist/types-global/errors.js +113 -0
  280. package/dist/types-global/errors.js.map +1 -0
  281. package/dist/utils/formatting/diffFormatter.d.ts +227 -0
  282. package/dist/utils/formatting/diffFormatter.d.ts.map +1 -0
  283. package/dist/utils/formatting/diffFormatter.js +369 -0
  284. package/dist/utils/formatting/diffFormatter.js.map +1 -0
  285. package/dist/utils/formatting/index.d.ts +9 -0
  286. package/dist/utils/formatting/index.d.ts.map +1 -0
  287. package/dist/utils/formatting/index.js +9 -0
  288. package/dist/utils/formatting/index.js.map +1 -0
  289. package/dist/utils/formatting/markdownBuilder.d.ts +543 -0
  290. package/dist/utils/formatting/markdownBuilder.d.ts.map +1 -0
  291. package/dist/utils/formatting/markdownBuilder.js +674 -0
  292. package/dist/utils/formatting/markdownBuilder.js.map +1 -0
  293. package/dist/utils/formatting/tableFormatter.d.ts +261 -0
  294. package/dist/utils/formatting/tableFormatter.d.ts.map +1 -0
  295. package/dist/utils/formatting/tableFormatter.js +456 -0
  296. package/dist/utils/formatting/tableFormatter.js.map +1 -0
  297. package/dist/utils/formatting/treeFormatter.d.ts +344 -0
  298. package/dist/utils/formatting/treeFormatter.d.ts.map +1 -0
  299. package/dist/utils/formatting/treeFormatter.js +400 -0
  300. package/dist/utils/formatting/treeFormatter.js.map +1 -0
  301. package/dist/utils/internal/encoding.d.ts +42 -0
  302. package/dist/utils/internal/encoding.d.ts.map +1 -0
  303. package/dist/utils/internal/encoding.js +87 -0
  304. package/dist/utils/internal/encoding.js.map +1 -0
  305. package/dist/utils/internal/error-handler/errorHandler.d.ts +140 -0
  306. package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -0
  307. package/dist/utils/internal/error-handler/errorHandler.js +318 -0
  308. package/dist/utils/internal/error-handler/errorHandler.js.map +1 -0
  309. package/dist/utils/internal/error-handler/helpers.d.ts +98 -0
  310. package/dist/utils/internal/error-handler/helpers.d.ts.map +1 -0
  311. package/dist/utils/internal/error-handler/helpers.js +214 -0
  312. package/dist/utils/internal/error-handler/helpers.js.map +1 -0
  313. package/dist/utils/internal/error-handler/mappings.d.ts +85 -0
  314. package/dist/utils/internal/error-handler/mappings.d.ts.map +1 -0
  315. package/dist/utils/internal/error-handler/mappings.js +234 -0
  316. package/dist/utils/internal/error-handler/mappings.js.map +1 -0
  317. package/dist/utils/internal/error-handler/types.d.ts +160 -0
  318. package/dist/utils/internal/error-handler/types.d.ts.map +1 -0
  319. package/dist/utils/internal/error-handler/types.js +6 -0
  320. package/dist/utils/internal/error-handler/types.js.map +1 -0
  321. package/dist/utils/internal/health.d.ts +60 -0
  322. package/dist/utils/internal/health.d.ts.map +1 -0
  323. package/dist/utils/internal/health.js +46 -0
  324. package/dist/utils/internal/health.js.map +1 -0
  325. package/dist/utils/internal/logger.d.ts +300 -0
  326. package/dist/utils/internal/logger.d.ts.map +1 -0
  327. package/dist/utils/internal/logger.js +573 -0
  328. package/dist/utils/internal/logger.js.map +1 -0
  329. package/dist/utils/internal/performance.d.ts +78 -0
  330. package/dist/utils/internal/performance.d.ts.map +1 -0
  331. package/dist/utils/internal/performance.js +227 -0
  332. package/dist/utils/internal/performance.js.map +1 -0
  333. package/dist/utils/internal/requestContext.d.ts +200 -0
  334. package/dist/utils/internal/requestContext.d.ts.map +1 -0
  335. package/dist/utils/internal/requestContext.js +163 -0
  336. package/dist/utils/internal/requestContext.js.map +1 -0
  337. package/dist/utils/internal/runtime.d.ts +49 -0
  338. package/dist/utils/internal/runtime.d.ts.map +1 -0
  339. package/dist/utils/internal/runtime.js +90 -0
  340. package/dist/utils/internal/runtime.js.map +1 -0
  341. package/dist/utils/internal/startupBanner.d.ts +23 -0
  342. package/dist/utils/internal/startupBanner.d.ts.map +1 -0
  343. package/dist/utils/internal/startupBanner.js +34 -0
  344. package/dist/utils/internal/startupBanner.js.map +1 -0
  345. package/dist/utils/metrics/tokenCounter.d.ts +97 -0
  346. package/dist/utils/metrics/tokenCounter.d.ts.map +1 -0
  347. package/dist/utils/metrics/tokenCounter.js +162 -0
  348. package/dist/utils/metrics/tokenCounter.js.map +1 -0
  349. package/dist/utils/network/fetchWithTimeout.d.ts +91 -0
  350. package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -0
  351. package/dist/utils/network/fetchWithTimeout.js +305 -0
  352. package/dist/utils/network/fetchWithTimeout.js.map +1 -0
  353. package/dist/utils/pagination/pagination.d.ts +157 -0
  354. package/dist/utils/pagination/pagination.d.ts.map +1 -0
  355. package/dist/utils/pagination/pagination.js +191 -0
  356. package/dist/utils/pagination/pagination.js.map +1 -0
  357. package/dist/utils/parsing/csvParser.d.ts +84 -0
  358. package/dist/utils/parsing/csvParser.d.ts.map +1 -0
  359. package/dist/utils/parsing/csvParser.js +132 -0
  360. package/dist/utils/parsing/csvParser.js.map +1 -0
  361. package/dist/utils/parsing/dateParser.d.ts +103 -0
  362. package/dist/utils/parsing/dateParser.d.ts.map +1 -0
  363. package/dist/utils/parsing/dateParser.js +142 -0
  364. package/dist/utils/parsing/dateParser.js.map +1 -0
  365. package/dist/utils/parsing/frontmatterParser.d.ts +91 -0
  366. package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -0
  367. package/dist/utils/parsing/frontmatterParser.js +163 -0
  368. package/dist/utils/parsing/frontmatterParser.js.map +1 -0
  369. package/dist/utils/parsing/index.d.ts +15 -0
  370. package/dist/utils/parsing/index.d.ts.map +1 -0
  371. package/dist/utils/parsing/index.js +15 -0
  372. package/dist/utils/parsing/index.js.map +1 -0
  373. package/dist/utils/parsing/jsonParser.d.ts +115 -0
  374. package/dist/utils/parsing/jsonParser.d.ts.map +1 -0
  375. package/dist/utils/parsing/jsonParser.js +177 -0
  376. package/dist/utils/parsing/jsonParser.js.map +1 -0
  377. package/dist/utils/parsing/pdfParser.d.ts +563 -0
  378. package/dist/utils/parsing/pdfParser.d.ts.map +1 -0
  379. package/dist/utils/parsing/pdfParser.js +775 -0
  380. package/dist/utils/parsing/pdfParser.js.map +1 -0
  381. package/dist/utils/parsing/thinkBlock.d.ts +31 -0
  382. package/dist/utils/parsing/thinkBlock.d.ts.map +1 -0
  383. package/dist/utils/parsing/thinkBlock.js +31 -0
  384. package/dist/utils/parsing/thinkBlock.js.map +1 -0
  385. package/dist/utils/parsing/xmlParser.d.ts +69 -0
  386. package/dist/utils/parsing/xmlParser.d.ts.map +1 -0
  387. package/dist/utils/parsing/xmlParser.js +140 -0
  388. package/dist/utils/parsing/xmlParser.js.map +1 -0
  389. package/dist/utils/parsing/yamlParser.d.ts +64 -0
  390. package/dist/utils/parsing/yamlParser.d.ts.map +1 -0
  391. package/dist/utils/parsing/yamlParser.js +129 -0
  392. package/dist/utils/parsing/yamlParser.js.map +1 -0
  393. package/dist/utils/scheduling/scheduler.d.ts +174 -0
  394. package/dist/utils/scheduling/scheduler.d.ts.map +1 -0
  395. package/dist/utils/scheduling/scheduler.js +248 -0
  396. package/dist/utils/scheduling/scheduler.js.map +1 -0
  397. package/dist/utils/security/idGenerator.d.ts +189 -0
  398. package/dist/utils/security/idGenerator.d.ts.map +1 -0
  399. package/dist/utils/security/idGenerator.js +301 -0
  400. package/dist/utils/security/idGenerator.js.map +1 -0
  401. package/dist/utils/security/index.d.ts +8 -0
  402. package/dist/utils/security/index.d.ts.map +1 -0
  403. package/dist/utils/security/index.js +8 -0
  404. package/dist/utils/security/index.js.map +1 -0
  405. package/dist/utils/security/rateLimiter.d.ts +171 -0
  406. package/dist/utils/security/rateLimiter.d.ts.map +1 -0
  407. package/dist/utils/security/rateLimiter.js +294 -0
  408. package/dist/utils/security/rateLimiter.js.map +1 -0
  409. package/dist/utils/security/sanitization.d.ts +430 -0
  410. package/dist/utils/security/sanitization.d.ts.map +1 -0
  411. package/dist/utils/security/sanitization.js +759 -0
  412. package/dist/utils/security/sanitization.js.map +1 -0
  413. package/dist/utils/telemetry/index.d.ts +12 -0
  414. package/dist/utils/telemetry/index.d.ts.map +1 -0
  415. package/dist/utils/telemetry/index.js +12 -0
  416. package/dist/utils/telemetry/index.js.map +1 -0
  417. package/dist/utils/telemetry/instrumentation.d.ts +62 -0
  418. package/dist/utils/telemetry/instrumentation.d.ts.map +1 -0
  419. package/dist/utils/telemetry/instrumentation.js +223 -0
  420. package/dist/utils/telemetry/instrumentation.js.map +1 -0
  421. package/dist/utils/telemetry/metrics.d.ts +170 -0
  422. package/dist/utils/telemetry/metrics.d.ts.map +1 -0
  423. package/dist/utils/telemetry/metrics.js +205 -0
  424. package/dist/utils/telemetry/metrics.js.map +1 -0
  425. package/dist/utils/telemetry/semconv.d.ts +147 -0
  426. package/dist/utils/telemetry/semconv.d.ts.map +1 -0
  427. package/dist/utils/telemetry/semconv.js +159 -0
  428. package/dist/utils/telemetry/semconv.js.map +1 -0
  429. package/dist/utils/telemetry/trace.d.ts +141 -0
  430. package/dist/utils/telemetry/trace.d.ts.map +1 -0
  431. package/dist/utils/telemetry/trace.js +193 -0
  432. package/dist/utils/telemetry/trace.js.map +1 -0
  433. package/dist/utils/types/guards.d.ts +209 -0
  434. package/dist/utils/types/guards.d.ts.map +1 -0
  435. package/dist/utils/types/guards.js +229 -0
  436. package/dist/utils/types/guards.js.map +1 -0
  437. package/dist/utils/types/index.d.ts +6 -0
  438. package/dist/utils/types/index.d.ts.map +1 -0
  439. package/dist/utils/types/index.js +6 -0
  440. package/dist/utils/types/index.js.map +1 -0
  441. package/dist/worker.d.ts +59 -0
  442. package/dist/worker.d.ts.map +1 -0
  443. package/dist/worker.js +216 -0
  444. package/dist/worker.js.map +1 -0
  445. package/package.json +377 -0
  446. package/skills/README.md +38 -0
  447. package/skills/add-export/SKILL.md +49 -0
  448. package/skills/add-prompt/SKILL.md +97 -0
  449. package/skills/add-provider/SKILL.md +53 -0
  450. package/skills/add-resource/SKILL.md +107 -0
  451. package/skills/add-service/SKILL.md +113 -0
  452. package/skills/add-tool/SKILL.md +110 -0
  453. package/skills/api-auth/SKILL.md +173 -0
  454. package/skills/api-config/SKILL.md +68 -0
  455. package/skills/api-context/SKILL.md +321 -0
  456. package/skills/api-errors/SKILL.md +146 -0
  457. package/skills/api-services/SKILL.md +24 -0
  458. package/skills/api-services/references/graph.md +124 -0
  459. package/skills/api-services/references/llm.md +46 -0
  460. package/skills/api-services/references/speech.md +72 -0
  461. package/skills/api-testing/SKILL.md +263 -0
  462. package/skills/api-utils/SKILL.md +106 -0
  463. package/skills/api-utils/references/formatting.md +237 -0
  464. package/skills/api-utils/references/parsing.md +263 -0
  465. package/skills/api-utils/references/security.md +226 -0
  466. package/skills/api-workers/SKILL.md +165 -0
  467. package/skills/devcheck/SKILL.md +31 -0
  468. package/skills/maintenance/SKILL.md +52 -0
  469. package/skills/migrate-mcp-ts-template/SKILL.md +131 -0
  470. package/skills/release/SKILL.md +67 -0
  471. package/skills/setup/SKILL.md +89 -0
  472. package/skills/walkthrough-init/SKILL.md +50 -0
  473. package/templates/.env.example +17 -0
  474. package/templates/AGENTS.md +113 -0
  475. package/templates/CLAUDE.md +113 -0
  476. package/templates/_tsconfig.json +33 -0
  477. package/templates/biome.template.json +43 -0
  478. package/templates/package.json +26 -0
  479. package/templates/src/index.ts +16 -0
  480. package/templates/src/mcp-server/prompts/definitions/echo.prompt.ts +19 -0
  481. package/templates/src/mcp-server/resources/definitions/echo.resource.ts +30 -0
  482. package/templates/src/mcp-server/tools/definitions/echo.tool.ts +24 -0
  483. package/templates/vitest.config.ts +12 -0
  484. package/tsconfig.base.json +44 -0
  485. package/vitest.config.base.ts +38 -0
@@ -0,0 +1,174 @@
1
+ /**
2
+ * @fileoverview Provides a singleton service for scheduling and managing cron jobs.
3
+ *
4
+ * Wraps the `node-cron` library with a unified interface for defining, starting,
5
+ * stopping, and listing recurring tasks. The `node-cron` module is loaded lazily
6
+ * on first use — it is not imported at startup. This keeps the module importable
7
+ * in any environment; runtime errors surface only when scheduling is actually
8
+ * attempted in an unsupported environment (e.g., Cloudflare Workers).
9
+ *
10
+ * **Node.js only.** Calling `schedule()` in a non-Node.js runtime throws
11
+ * `McpError(ConfigurationError)`.
12
+ *
13
+ * @module src/utils/scheduling/scheduler
14
+ */
15
+ import type { ScheduledTask } from 'node-cron';
16
+ import type { RequestContext } from '../../utils/internal/requestContext.js';
17
+ /**
18
+ * Represents a scheduled job managed by the {@link SchedulerService}.
19
+ *
20
+ * @example
21
+ * const jobs = scheduler.listJobs();
22
+ * for (const job of jobs) {
23
+ * console.log(`${job.id} (${job.schedule}): running=${job.isRunning}`);
24
+ * }
25
+ */
26
+ export interface Job {
27
+ /** Human-readable description of what the job does. */
28
+ description: string;
29
+ /** Unique identifier for the job, supplied at scheduling time. */
30
+ id: string;
31
+ /**
32
+ * Whether the task function is currently executing.
33
+ * The scheduler skips a tick if `true` to prevent overlapping runs.
34
+ */
35
+ isRunning: boolean;
36
+ /** Cron pattern that defines the job's schedule (e.g., `'0 * * * *'`). */
37
+ schedule: string;
38
+ /** The underlying `node-cron` task instance. Use `start()`/`stop()` via the service rather than directly. */
39
+ task: ScheduledTask;
40
+ }
41
+ /**
42
+ * Singleton service for scheduling and managing cron jobs.
43
+ *
44
+ * Depends on the `node-cron` peer dependency, which is loaded lazily on the
45
+ * first call to {@link schedule}. Cron jobs skip overlapping executions: if a
46
+ * task is still running when its next tick fires, that tick is logged and
47
+ * discarded. Each execution receives a fresh {@link RequestContext} for
48
+ * correlated logging.
49
+ *
50
+ * Use the pre-constructed {@link schedulerService} export rather than
51
+ * instantiating this class directly.
52
+ *
53
+ * @example
54
+ * import { schedulerService } from '../../utils/scheduling/scheduler.js';
55
+ *
56
+ * await schedulerService.schedule(
57
+ * 'cleanup',
58
+ * '0 3 * * *',
59
+ * async (ctx) => { await purgeOldRecords(ctx); },
60
+ * 'Nightly cleanup of expired records',
61
+ * );
62
+ * schedulerService.start('cleanup');
63
+ */
64
+ export declare class SchedulerService {
65
+ private static instance;
66
+ private jobs;
67
+ /** @private */
68
+ private constructor();
69
+ /**
70
+ * Returns the singleton instance of {@link SchedulerService}, creating it on
71
+ * first call.
72
+ *
73
+ * @returns The shared `SchedulerService` instance.
74
+ * @example
75
+ * const scheduler = SchedulerService.getInstance();
76
+ */
77
+ static getInstance(): SchedulerService;
78
+ /**
79
+ * Registers and creates a new cron job. The job is created in a stopped
80
+ * state — call {@link start} to begin execution.
81
+ *
82
+ * Lazily imports `node-cron` on the first call. Validates the cron pattern
83
+ * before storing the job. Each execution of `taskFunction` receives a fresh
84
+ * {@link RequestContext} with `operation` set to `scheduler:job:<id>`.
85
+ * Overlapping runs are skipped: if the previous execution is still in
86
+ * progress when the next tick fires, that tick is logged and discarded.
87
+ * Errors thrown by `taskFunction` are caught and logged; they do not
88
+ * propagate to the scheduler.
89
+ *
90
+ * @param id - Unique identifier for the job. Must not already be registered.
91
+ * @param schedule - Standard cron expression (five or six fields, e.g. `'0 * * * *'`).
92
+ * @param taskFunction - Async (or sync) function to run on each tick. Receives a
93
+ * `RequestContext` scoped to the job execution.
94
+ * @param description - Human-readable description stored on the {@link Job} object.
95
+ * @returns The newly created {@link Job} (in stopped state).
96
+ * @throws {McpError} `Conflict` (-32002) if a job with the same `id` already exists.
97
+ * @throws {McpError} `InvalidParams` (-32602) if `schedule` is not a valid cron expression.
98
+ * @throws {McpError} `ConfigurationError` (-32008) if called outside a Node.js runtime.
99
+ * @example
100
+ * const job = await schedulerService.schedule(
101
+ * 'ping',
102
+ * '* * * * *',
103
+ * async (ctx) => { logger.info('ping', ctx); },
104
+ * 'Logs a ping every minute',
105
+ * );
106
+ * schedulerService.start('ping');
107
+ */
108
+ schedule(id: string, schedule: string, taskFunction: (context: RequestContext) => void | Promise<void>, description: string): Promise<Job>;
109
+ /**
110
+ * Starts a previously registered job, causing it to execute on its cron schedule.
111
+ *
112
+ * @param id - ID of the job to start, as supplied to {@link schedule}.
113
+ * @returns `void`
114
+ * @throws {McpError} `NotFound` (-32001) if no job with the given `id` exists.
115
+ * @example
116
+ * schedulerService.start('cleanup');
117
+ */
118
+ start(id: string): void;
119
+ /**
120
+ * Stops a running job. The job remains registered and can be restarted with
121
+ * {@link start}. Any in-progress execution completes normally.
122
+ *
123
+ * @param id - ID of the job to stop.
124
+ * @returns `void`
125
+ * @throws {McpError} `NotFound` (-32001) if no job with the given `id` exists.
126
+ * @example
127
+ * schedulerService.stop('cleanup');
128
+ */
129
+ stop(id: string): void;
130
+ /**
131
+ * Stops and permanently removes a job from the scheduler. The job cannot be
132
+ * restarted after removal; call {@link schedule} to re-register it.
133
+ *
134
+ * @param id - ID of the job to remove.
135
+ * @returns `void`
136
+ * @throws {McpError} `NotFound` (-32001) if no job with the given `id` exists.
137
+ * @example
138
+ * schedulerService.remove('cleanup');
139
+ */
140
+ remove(id: string): void;
141
+ /**
142
+ * Looks up a job by ID.
143
+ *
144
+ * @param id - Job ID to look up.
145
+ * @returns The {@link Job} record.
146
+ * @throws {McpError} `NotFound` (-32001) if the job does not exist.
147
+ */
148
+ private resolveJob;
149
+ /**
150
+ * Returns a snapshot of all currently registered jobs, regardless of their
151
+ * running state.
152
+ *
153
+ * @returns Array of all {@link Job} objects in insertion order.
154
+ * @example
155
+ * for (const job of schedulerService.listJobs()) {
156
+ * console.log(job.id, job.isRunning ? 'running' : 'stopped');
157
+ * }
158
+ */
159
+ listJobs(): Job[];
160
+ }
161
+ /**
162
+ * Pre-constructed singleton instance of {@link SchedulerService}.
163
+ *
164
+ * Import and use this throughout the application rather than calling
165
+ * `SchedulerService.getInstance()` directly.
166
+ *
167
+ * @example
168
+ * import { schedulerService } from '../../utils/scheduling/scheduler.js';
169
+ *
170
+ * await schedulerService.schedule('heartbeat', '* * * * *', heartbeatFn, 'Heartbeat');
171
+ * schedulerService.start('heartbeat');
172
+ */
173
+ export declare const schedulerService: SchedulerService;
174
+ //# sourceMappingURL=sche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;;;;;;;;;OASG;IACI,QAAQ,IAAI,GAAG,EAAE;CAGzB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,kBAAiC,CAAC"}
@@ -0,0 +1,248 @@
1
+ import { JsonRpcErrorCode, McpError } from '../../types-global/errors.js';
2
+ import { logger } from '../../utils/internal/logger.js';
3
+ import { requestContextService } from '../../utils/internal/requestContext.js';
4
+ import { runtimeCaps } from '../../utils/internal/runtime.js';
5
+ /**
6
+ * Lazily loads the `node-cron` module on first call and caches the resulting
7
+ * promise so subsequent calls resolve from the same import. Throws
8
+ * `McpError(ConfigurationError)` immediately if called outside a Node.js runtime.
9
+ *
10
+ * @throws {McpError} `ConfigurationError` when not running in Node.js.
11
+ */
12
+ let cronModulePromise = null;
13
+ async function loadCron() {
14
+ if (!runtimeCaps.isNode) {
15
+ throw new McpError(JsonRpcErrorCode.ConfigurationError, 'SchedulerService requires a Node.js runtime. Cron scheduling is not available in Workers or browser environments.');
16
+ }
17
+ if (!cronModulePromise) {
18
+ cronModulePromise = import('node-cron');
19
+ }
20
+ return await cronModulePromise;
21
+ }
22
+ /**
23
+ * Singleton service for scheduling and managing cron jobs.
24
+ *
25
+ * Depends on the `node-cron` peer dependency, which is loaded lazily on the
26
+ * first call to {@link schedule}. Cron jobs skip overlapping executions: if a
27
+ * task is still running when its next tick fires, that tick is logged and
28
+ * discarded. Each execution receives a fresh {@link RequestContext} for
29
+ * correlated logging.
30
+ *
31
+ * Use the pre-constructed {@link schedulerService} export rather than
32
+ * instantiating this class directly.
33
+ *
34
+ * @example
35
+ * import { schedulerService } from '../../utils/scheduling/scheduler.js';
36
+ *
37
+ * await schedulerService.schedule(
38
+ * 'cleanup',
39
+ * '0 3 * * *',
40
+ * async (ctx) => { await purgeOldRecords(ctx); },
41
+ * 'Nightly cleanup of expired records',
42
+ * );
43
+ * schedulerService.start('cleanup');
44
+ */
45
+ export class SchedulerService {
46
+ static instance;
47
+ jobs = new Map();
48
+ /** @private */
49
+ constructor() {
50
+ // The constructor is intentionally left empty to prevent instantiation with 'new'.
51
+ // Logging has been removed from here to break a circular dependency
52
+ // with the logger, which was causing a ReferenceError on startup.
53
+ }
54
+ /**
55
+ * Returns the singleton instance of {@link SchedulerService}, creating it on
56
+ * first call.
57
+ *
58
+ * @returns The shared `SchedulerService` instance.
59
+ * @example
60
+ * const scheduler = SchedulerService.getInstance();
61
+ */
62
+ static getInstance() {
63
+ if (!SchedulerService.instance) {
64
+ SchedulerService.instance = new SchedulerService();
65
+ }
66
+ return SchedulerService.instance;
67
+ }
68
+ /**
69
+ * Registers and creates a new cron job. The job is created in a stopped
70
+ * state — call {@link start} to begin execution.
71
+ *
72
+ * Lazily imports `node-cron` on the first call. Validates the cron pattern
73
+ * before storing the job. Each execution of `taskFunction` receives a fresh
74
+ * {@link RequestContext} with `operation` set to `scheduler:job:<id>`.
75
+ * Overlapping runs are skipped: if the previous execution is still in
76
+ * progress when the next tick fires, that tick is logged and discarded.
77
+ * Errors thrown by `taskFunction` are caught and logged; they do not
78
+ * propagate to the scheduler.
79
+ *
80
+ * @param id - Unique identifier for the job. Must not already be registered.
81
+ * @param schedule - Standard cron expression (five or six fields, e.g. `'0 * * * *'`).
82
+ * @param taskFunction - Async (or sync) function to run on each tick. Receives a
83
+ * `RequestContext` scoped to the job execution.
84
+ * @param description - Human-readable description stored on the {@link Job} object.
85
+ * @returns The newly created {@link Job} (in stopped state).
86
+ * @throws {McpError} `Conflict` (-32002) if a job with the same `id` already exists.
87
+ * @throws {McpError} `InvalidParams` (-32602) if `schedule` is not a valid cron expression.
88
+ * @throws {McpError} `ConfigurationError` (-32008) if called outside a Node.js runtime.
89
+ * @example
90
+ * const job = await schedulerService.schedule(
91
+ * 'ping',
92
+ * '* * * * *',
93
+ * async (ctx) => { logger.info('ping', ctx); },
94
+ * 'Logs a ping every minute',
95
+ * );
96
+ * schedulerService.start('ping');
97
+ */
98
+ async schedule(id, schedule, taskFunction, description) {
99
+ if (this.jobs.has(id)) {
100
+ throw new McpError(JsonRpcErrorCode.Conflict, `Job with ID '${id}' already exists.`);
101
+ }
102
+ const cron = await loadCron();
103
+ if (!cron.validate(schedule)) {
104
+ throw new McpError(JsonRpcErrorCode.InvalidParams, `Invalid cron schedule: ${schedule}`);
105
+ }
106
+ const task = cron.createTask(schedule, async () => {
107
+ const job = this.jobs.get(id);
108
+ const context = requestContextService.createRequestContext({
109
+ operation: `scheduler:job:${id}`,
110
+ jobId: id,
111
+ schedule,
112
+ });
113
+ if (job?.isRunning) {
114
+ logger.warning(`Job '${id}' is already running. Skipping this execution.`, context);
115
+ return;
116
+ }
117
+ if (job) {
118
+ job.isRunning = true;
119
+ }
120
+ logger.info(`Starting job '${id}'...`, context);
121
+ try {
122
+ await Promise.resolve(taskFunction(context));
123
+ logger.info(`Job '${id}' completed successfully.`, context);
124
+ }
125
+ catch (error) {
126
+ const err = error instanceof Error ? error : new Error(String(error));
127
+ logger.error(`Job '${id}' failed.`, err, context);
128
+ }
129
+ finally {
130
+ if (job) {
131
+ job.isRunning = false;
132
+ }
133
+ }
134
+ });
135
+ const newJob = {
136
+ id,
137
+ schedule,
138
+ description,
139
+ task,
140
+ isRunning: false,
141
+ };
142
+ const context = requestContextService.createRequestContext({
143
+ operation: 'scheduler:schedule',
144
+ jobId: id,
145
+ });
146
+ this.jobs.set(id, newJob);
147
+ logger.info(`Job '${id}' scheduled: ${description}`, context);
148
+ return newJob;
149
+ }
150
+ /**
151
+ * Starts a previously registered job, causing it to execute on its cron schedule.
152
+ *
153
+ * @param id - ID of the job to start, as supplied to {@link schedule}.
154
+ * @returns `void`
155
+ * @throws {McpError} `NotFound` (-32001) if no job with the given `id` exists.
156
+ * @example
157
+ * schedulerService.start('cleanup');
158
+ */
159
+ start(id) {
160
+ const job = this.resolveJob(id);
161
+ void job.task.start();
162
+ const context = requestContextService.createRequestContext({
163
+ operation: 'scheduler:start',
164
+ jobId: id,
165
+ });
166
+ logger.info(`Job '${id}' started.`, context);
167
+ }
168
+ /**
169
+ * Stops a running job. The job remains registered and can be restarted with
170
+ * {@link start}. Any in-progress execution completes normally.
171
+ *
172
+ * @param id - ID of the job to stop.
173
+ * @returns `void`
174
+ * @throws {McpError} `NotFound` (-32001) if no job with the given `id` exists.
175
+ * @example
176
+ * schedulerService.stop('cleanup');
177
+ */
178
+ stop(id) {
179
+ const job = this.resolveJob(id);
180
+ void job.task.stop();
181
+ const context = requestContextService.createRequestContext({
182
+ operation: 'scheduler:stop',
183
+ jobId: id,
184
+ });
185
+ logger.info(`Job '${id}' stopped.`, context);
186
+ }
187
+ /**
188
+ * Stops and permanently removes a job from the scheduler. The job cannot be
189
+ * restarted after removal; call {@link schedule} to re-register it.
190
+ *
191
+ * @param id - ID of the job to remove.
192
+ * @returns `void`
193
+ * @throws {McpError} `NotFound` (-32001) if no job with the given `id` exists.
194
+ * @example
195
+ * schedulerService.remove('cleanup');
196
+ */
197
+ remove(id) {
198
+ const job = this.resolveJob(id);
199
+ void job.task.stop();
200
+ this.jobs.delete(id);
201
+ const context = requestContextService.createRequestContext({
202
+ operation: 'scheduler:remove',
203
+ jobId: id,
204
+ });
205
+ logger.info(`Job '${id}' removed.`, context);
206
+ }
207
+ /**
208
+ * Looks up a job by ID.
209
+ *
210
+ * @param id - Job ID to look up.
211
+ * @returns The {@link Job} record.
212
+ * @throws {McpError} `NotFound` (-32001) if the job does not exist.
213
+ */
214
+ resolveJob(id) {
215
+ const job = this.jobs.get(id);
216
+ if (!job) {
217
+ throw new McpError(JsonRpcErrorCode.NotFound, `Job with ID '${id}' not found.`);
218
+ }
219
+ return job;
220
+ }
221
+ /**
222
+ * Returns a snapshot of all currently registered jobs, regardless of their
223
+ * running state.
224
+ *
225
+ * @returns Array of all {@link Job} objects in insertion order.
226
+ * @example
227
+ * for (const job of schedulerService.listJobs()) {
228
+ * console.log(job.id, job.isRunning ? 'running' : 'stopped');
229
+ * }
230
+ */
231
+ listJobs() {
232
+ return Array.from(this.jobs.values());
233
+ }
234
+ }
235
+ /**
236
+ * Pre-constructed singleton instance of {@link SchedulerService}.
237
+ *
238
+ * Import and use this throughout the application rather than calling
239
+ * `SchedulerService.getInstance()` directly.
240
+ *
241
+ * @example
242
+ * import { schedulerService } from '../../utils/scheduling/scheduler.js';
243
+ *
244
+ * await schedulerService.schedule('heartbeat', '* * * * *', heartbeatFn, 'Heartbeat');
245
+ * schedulerService.start('heartbeat');
246
+ */
247
+ export const schedulerService = SchedulerService.getInstance();
248
+ //# sourceMappingURL=scheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../../src/utils/scheduling/scheduler.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;;GAMG;AACH,IAAI,iBAAiB,GAA+C,IAAI,CAAC;AAEzE,KAAK,UAAU,QAAQ;IACrB,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,IAAI,QAAQ,CAChB,gBAAgB,CAAC,kBAAkB,EACnC,mHAAmH,CACpH,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,iBAAiB,CAAC;AACjC,CAAC;AA2BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAC,QAAQ,CAAmB;IAClC,IAAI,GAAqB,IAAI,GAAG,EAAE,CAAC;IAE3C,eAAe;IACf;QACE,mFAAmF;QACnF,oEAAoE;QACpE,kEAAkE;IACpE,CAAC;IAED;;;;;;;OAOG;IACI,MAA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,QAAQ,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;;;;;;OASG;IACI,QAAQ;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAC"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Defines the structure for configuring entity prefixes.
3
+ * Keys are entity type names (e.g., "project", "task"), and values are their corresponding ID prefixes (e.g., "PROJ", "TASK").
4
+ */
5
+ export interface EntityPrefixConfig {
6
+ [key: string]: string;
7
+ }
8
+ /**
9
+ * Defines options for customizing ID generation.
10
+ */
11
+ export interface IdGenerationOptions {
12
+ /** Character set to draw from when building the random part. Defaults to `A-Z0-9`. */
13
+ charset?: string;
14
+ /** Length of the random part of the ID. Defaults to `6`. */
15
+ length?: number;
16
+ /** String placed between the prefix and the random part. Defaults to `'_'`. */
17
+ separator?: string;
18
+ }
19
+ /**
20
+ * A generic ID Generator class for creating and managing unique, prefixed identifiers.
21
+ * Allows defining custom prefixes, generating random strings, and validating/normalizing IDs.
22
+ */
23
+ export declare class IdGenerator {
24
+ /**
25
+ * Default character set for the random part of the ID.
26
+ * @private
27
+ */
28
+ private static DEFAULT_CHARSET;
29
+ /**
30
+ * Default separator character between prefix and random part.
31
+ * @private
32
+ */
33
+ private static DEFAULT_SEPARATOR;
34
+ /**
35
+ * Default length for the random part of the ID.
36
+ * @private
37
+ */
38
+ private static DEFAULT_LENGTH;
39
+ /**
40
+ * Stores the mapping of entity types to their prefixes.
41
+ * @private
42
+ */
43
+ private entityPrefixes;
44
+ /**
45
+ * Stores a reverse mapping from prefixes (case-insensitive) to entity types.
46
+ * @private
47
+ */
48
+ private prefixToEntityType;
49
+ /**
50
+ * Constructs an `IdGenerator` instance.
51
+ * @param entityPrefixes - An initial map of entity types to their prefixes.
52
+ */
53
+ constructor(entityPrefixes?: EntityPrefixConfig);
54
+ /**
55
+ * Sets or updates the entity prefix configuration and rebuilds the internal reverse lookup map.
56
+ * @param entityPrefixes - A map where keys are entity type names and values are their desired ID prefixes.
57
+ */
58
+ setEntityPrefixes(entityPrefixes: EntityPrefixConfig): void;
59
+ /**
60
+ * Retrieves a copy of the current entity prefix configuration.
61
+ * @returns The current entity prefix configuration.
62
+ */
63
+ getEntityPrefixes(): EntityPrefixConfig;
64
+ /**
65
+ * Generates a cryptographically secure random string.
66
+ * @param length - The desired length of the random string. Defaults to `IdGenerator.DEFAULT_LENGTH`.
67
+ * @param charset - The character set to use. Defaults to `IdGenerator.DEFAULT_CHARSET`.
68
+ * @returns The generated random string.
69
+ */
70
+ generateRandomString(length?: number, charset?: string): string;
71
+ /**
72
+ * Generates a unique ID, optionally prepended with a prefix.
73
+ * @param prefix - An optional prefix for the ID.
74
+ * @param options - Optional parameters for ID generation (length, separator, charset).
75
+ * @returns A unique identifier string.
76
+ */
77
+ generate(prefix?: string, options?: IdGenerationOptions): string;
78
+ /**
79
+ * Generates a unique ID for a specified entity type, using its configured prefix.
80
+ * @param entityType - The type of entity (must be registered).
81
+ * @param options - Optional parameters for ID generation.
82
+ * @returns A unique identifier string for the entity (e.g., "PROJ_A6B3J0").
83
+ * @throws {McpError} If the `entityType` is not registered.
84
+ */
85
+ generateForEntity(entityType: string, options?: IdGenerationOptions): string;
86
+ /**
87
+ * Validates if an ID conforms to the expected format for a specific entity type.
88
+ * @param id - The ID string to validate.
89
+ * @param entityType - The expected entity type of the ID.
90
+ * @param options - Optional parameters used during generation for validation consistency.
91
+ * The `charset` from these options will be used for validation.
92
+ * @returns `true` if the ID is valid, `false` otherwise.
93
+ */
94
+ isValid(id: string, entityType: string, options?: IdGenerationOptions): boolean;
95
+ /**
96
+ * Escapes special characters in a string for use in a regular expression.
97
+ * @param str - The string to escape.
98
+ * @returns The escaped string.
99
+ * @private
100
+ */
101
+ private escapeRegex;
102
+ /**
103
+ * Strips the prefix and separator from an ID string, returning only the random part.
104
+ * If the separator does not appear in the string, the original ID is returned unchanged.
105
+ * Handles edge cases where the separator character appears in the random part by
106
+ * rejoining all parts after the first split.
107
+ *
108
+ * @param id - The full ID string (e.g., `"PROJ_A6B3J0"`).
109
+ * @param separator - The separator character used in the ID. Defaults to `'_'`.
110
+ * @returns The random part of the ID without the prefix (e.g., `"A6B3J0"`), or the
111
+ * original string if the separator is not present.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * idGenerator.stripPrefix('PROJ_A6B3J0'); // → 'A6B3J0'
116
+ * idGenerator.stripPrefix('PROJ-A6B3J0', '-'); // → 'A6B3J0'
117
+ * idGenerator.stripPrefix('NOPREFIXID'); // → 'NOPREFIXID'
118
+ * ```
119
+ */
120
+ stripPrefix(id: string, separator?: string): string;
121
+ /**
122
+ * Determines the entity type from an ID string by its prefix (case-insensitive).
123
+ * @param id - The ID string (e.g., "PROJ_A6B3J0").
124
+ * @param separator - The separator used in the ID. Defaults to `IdGenerator.DEFAULT_SEPARATOR`.
125
+ * @returns The determined entity type.
126
+ * @throws {McpError} If ID format is invalid or prefix is unknown.
127
+ */
128
+ getEntityType(id: string, separator?: string): string;
129
+ /**
130
+ * Normalizes an entity ID so that the prefix matches its registered casing and the random
131
+ * part is uppercased. Delegates to {@link getEntityType} to resolve the canonical prefix.
132
+ *
133
+ * Note: Uppercasing the random part is correct for the default `A-Z0-9` charset. For custom
134
+ * charsets that include lowercase or non-alphabetic characters, `toUpperCase()` may produce
135
+ * unexpected results.
136
+ *
137
+ * @param id - The ID to normalize (e.g., `"proj_a6b3j0"`).
138
+ * @param separator - The separator used in the ID. Defaults to `'_'`.
139
+ * @returns The normalized ID with canonical prefix casing and uppercase random part
140
+ * (e.g., `"PROJ_A6B3J0"`).
141
+ * @throws {McpError} With {@link JsonRpcErrorCode.ValidationError} if the entity type
142
+ * cannot be determined from the ID's prefix.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * idGenerator.setEntityPrefixes({ project: 'PROJ' });
147
+ * idGenerator.normalize('proj_a6b3j0'); // → 'PROJ_A6B3J0'
148
+ * idGenerator.normalize('PROJ_a6b3j0'); // → 'PROJ_A6B3J0'
149
+ * ```
150
+ */
151
+ normalize(id: string, separator?: string): string;
152
+ }
153
+ /**
154
+ * Default singleton instance of {@link IdGenerator}, initialized with no entity prefixes.
155
+ * Call `idGenerator.setEntityPrefixes({ ... })` during application startup to register prefixes
156
+ * before calling `generateForEntity` or `getEntityType`.
157
+ */
158
+ export declare const idGenerator: IdGenerator;
159
+ /**
160
+ * Generates a standard Version 4 UUID using the Web Crypto API (`crypto.randomUUID()`).
161
+ * Cross-runtime: works in Node.js 19+, Cloudflare Workers, and browsers.
162
+ *
163
+ * @returns A new UUID v4 string (e.g., `"110e8400-e29b-41d4-a716-446655440000"`).
164
+ *
165
+ * @example
166
+ * ```ts
167
+ * const id = generateUUID(); // → '110e8400-e29b-41d4-a716-446655440000'
168
+ * ```
169
+ */
170
+ export declare const generateUUID: () => string;
171
+ /**
172
+ * Generates a short, human-readable request context ID in the format `XXXXX-XXXXX`
173
+ * (two 5-character alphanumeric segments joined by a hyphen, e.g., `"A3K9Z-BQ72M"`).
174
+ *
175
+ * This function is self-contained — it does not call `IdGenerator` or any other module-level
176
+ * export — specifically to avoid circular dependencies with `requestContextService`, which
177
+ * itself calls this function during initialization.
178
+ *
179
+ * Uses rejection sampling against the Web Crypto API for uniform, bias-free character selection.
180
+ *
181
+ * @returns A 11-character string in `XXXXX-XXXXX` format suitable for request tracing.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * const reqId = generateRequestContextId(); // → 'A3K9Z-BQ72M'
186
+ * ```
187
+ */
188
+ export declare const generateRequestContextId: () => string;
189
+ //# sourceMappingURL=idGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idGenerator.d.ts","sourceRoot":"","sources":["../../../src/utils/security/idG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