enpilink 1.0.2

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 (477) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +289 -0
  3. package/bin/run.js +5 -0
  4. package/dist/cli/build-helpers.d.ts +8 -0
  5. package/dist/cli/build-helpers.js +105 -0
  6. package/dist/cli/build-helpers.js.map +1 -0
  7. package/dist/cli/build-helpers.test.d.ts +1 -0
  8. package/dist/cli/build-helpers.test.js +100 -0
  9. package/dist/cli/build-helpers.test.js.map +1 -0
  10. package/dist/cli/detect-port.d.ts +18 -0
  11. package/dist/cli/detect-port.js +50 -0
  12. package/dist/cli/detect-port.js.map +1 -0
  13. package/dist/cli/ensure-ssh-key.d.ts +17 -0
  14. package/dist/cli/ensure-ssh-key.js +45 -0
  15. package/dist/cli/ensure-ssh-key.js.map +1 -0
  16. package/dist/cli/ensure-ssh-key.test.d.ts +1 -0
  17. package/dist/cli/ensure-ssh-key.test.js +68 -0
  18. package/dist/cli/ensure-ssh-key.test.js.map +1 -0
  19. package/dist/cli/header.d.ts +4 -0
  20. package/dist/cli/header.js +6 -0
  21. package/dist/cli/header.js.map +1 -0
  22. package/dist/cli/resolve-views-dir.d.ts +1 -0
  23. package/dist/cli/resolve-views-dir.js +17 -0
  24. package/dist/cli/resolve-views-dir.js.map +1 -0
  25. package/dist/cli/run-command.d.ts +2 -0
  26. package/dist/cli/run-command.js +43 -0
  27. package/dist/cli/run-command.js.map +1 -0
  28. package/dist/cli/telemetry.d.ts +14 -0
  29. package/dist/cli/telemetry.js +24 -0
  30. package/dist/cli/telemetry.js.map +1 -0
  31. package/dist/cli/tunnel-control-server.d.ts +11 -0
  32. package/dist/cli/tunnel-control-server.js +35 -0
  33. package/dist/cli/tunnel-control-server.js.map +1 -0
  34. package/dist/cli/tunnel-control-server.test.d.ts +1 -0
  35. package/dist/cli/tunnel-control-server.test.js +39 -0
  36. package/dist/cli/tunnel-control-server.test.js.map +1 -0
  37. package/dist/cli/tunnel-handler.d.ts +3 -0
  38. package/dist/cli/tunnel-handler.js +48 -0
  39. package/dist/cli/tunnel-handler.js.map +1 -0
  40. package/dist/cli/tunnel-handler.test.d.ts +1 -0
  41. package/dist/cli/tunnel-handler.test.js +107 -0
  42. package/dist/cli/tunnel-handler.test.js.map +1 -0
  43. package/dist/cli/tunnel-providers/index.d.ts +5 -0
  44. package/dist/cli/tunnel-providers/index.js +5 -0
  45. package/dist/cli/tunnel-providers/index.js.map +1 -0
  46. package/dist/cli/tunnel-providers/srv-us.d.ts +18 -0
  47. package/dist/cli/tunnel-providers/srv-us.js +66 -0
  48. package/dist/cli/tunnel-providers/srv-us.js.map +1 -0
  49. package/dist/cli/tunnel-providers/srv-us.test.d.ts +1 -0
  50. package/dist/cli/tunnel-providers/srv-us.test.js +74 -0
  51. package/dist/cli/tunnel-providers/srv-us.test.js.map +1 -0
  52. package/dist/cli/tunnel-providers/types.d.ts +49 -0
  53. package/dist/cli/tunnel-providers/types.js +2 -0
  54. package/dist/cli/tunnel-providers/types.js.map +1 -0
  55. package/dist/cli/tunnel.d.ts +75 -0
  56. package/dist/cli/tunnel.js +254 -0
  57. package/dist/cli/tunnel.js.map +1 -0
  58. package/dist/cli/tunnel.test.d.ts +1 -0
  59. package/dist/cli/tunnel.test.js +255 -0
  60. package/dist/cli/tunnel.test.js.map +1 -0
  61. package/dist/cli/types.d.ts +5 -0
  62. package/dist/cli/types.js +2 -0
  63. package/dist/cli/types.js.map +1 -0
  64. package/dist/cli/use-execute-steps.d.ts +11 -0
  65. package/dist/cli/use-execute-steps.js +36 -0
  66. package/dist/cli/use-execute-steps.js.map +1 -0
  67. package/dist/cli/use-messages.d.ts +3 -0
  68. package/dist/cli/use-messages.js +11 -0
  69. package/dist/cli/use-messages.js.map +1 -0
  70. package/dist/cli/use-nodemon.d.ts +2 -0
  71. package/dist/cli/use-nodemon.js +73 -0
  72. package/dist/cli/use-nodemon.js.map +1 -0
  73. package/dist/cli/use-open-browser.d.ts +1 -0
  74. package/dist/cli/use-open-browser.js +44 -0
  75. package/dist/cli/use-open-browser.js.map +1 -0
  76. package/dist/cli/use-open-tunnel-browser.d.ts +6 -0
  77. package/dist/cli/use-open-tunnel-browser.js +19 -0
  78. package/dist/cli/use-open-tunnel-browser.js.map +1 -0
  79. package/dist/cli/use-tunnel.d.ts +17 -0
  80. package/dist/cli/use-tunnel.js +131 -0
  81. package/dist/cli/use-tunnel.js.map +1 -0
  82. package/dist/cli/use-typescript-check.d.ts +9 -0
  83. package/dist/cli/use-typescript-check.js +94 -0
  84. package/dist/cli/use-typescript-check.js.map +1 -0
  85. package/dist/commands/build.d.ts +8 -0
  86. package/dist/commands/build.js +97 -0
  87. package/dist/commands/build.js.map +1 -0
  88. package/dist/commands/create.d.ts +9 -0
  89. package/dist/commands/create.js +30 -0
  90. package/dist/commands/create.js.map +1 -0
  91. package/dist/commands/dev.d.ts +13 -0
  92. package/dist/commands/dev.js +112 -0
  93. package/dist/commands/dev.js.map +1 -0
  94. package/dist/commands/start.d.ts +10 -0
  95. package/dist/commands/start.js +76 -0
  96. package/dist/commands/start.js.map +1 -0
  97. package/dist/commands/telemetry/disable.d.ts +5 -0
  98. package/dist/commands/telemetry/disable.js +12 -0
  99. package/dist/commands/telemetry/disable.js.map +1 -0
  100. package/dist/commands/telemetry/enable.d.ts +5 -0
  101. package/dist/commands/telemetry/enable.js +12 -0
  102. package/dist/commands/telemetry/enable.js.map +1 -0
  103. package/dist/commands/telemetry/status.d.ts +5 -0
  104. package/dist/commands/telemetry/status.js +12 -0
  105. package/dist/commands/telemetry/status.js.map +1 -0
  106. package/dist/server/admin.d.ts +79 -0
  107. package/dist/server/admin.js +239 -0
  108. package/dist/server/admin.js.map +1 -0
  109. package/dist/server/admin.test.d.ts +1 -0
  110. package/dist/server/admin.test.js +226 -0
  111. package/dist/server/admin.test.js.map +1 -0
  112. package/dist/server/analytics.d.ts +60 -0
  113. package/dist/server/analytics.js +168 -0
  114. package/dist/server/analytics.js.map +1 -0
  115. package/dist/server/analytics.test.d.ts +1 -0
  116. package/dist/server/analytics.test.js +179 -0
  117. package/dist/server/analytics.test.js.map +1 -0
  118. package/dist/server/asset-base-url-transform-plugin.d.ts +11 -0
  119. package/dist/server/asset-base-url-transform-plugin.js +48 -0
  120. package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
  121. package/dist/server/asset-base-url-transform-plugin.test.d.ts +1 -0
  122. package/dist/server/asset-base-url-transform-plugin.test.js +134 -0
  123. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
  124. package/dist/server/auth.d.ts +20 -0
  125. package/dist/server/auth.js +28 -0
  126. package/dist/server/auth.js.map +1 -0
  127. package/dist/server/build-manifest.test.d.ts +1 -0
  128. package/dist/server/build-manifest.test.js +27 -0
  129. package/dist/server/build-manifest.test.js.map +1 -0
  130. package/dist/server/config/config.test.d.ts +1 -0
  131. package/dist/server/config/config.test.js +214 -0
  132. package/dist/server/config/config.test.js.map +1 -0
  133. package/dist/server/config/index.d.ts +3 -0
  134. package/dist/server/config/index.js +4 -0
  135. package/dist/server/config/index.js.map +1 -0
  136. package/dist/server/config/resolve.d.ts +73 -0
  137. package/dist/server/config/resolve.js +167 -0
  138. package/dist/server/config/resolve.js.map +1 -0
  139. package/dist/server/config/router.d.ts +23 -0
  140. package/dist/server/config/router.js +119 -0
  141. package/dist/server/config/router.js.map +1 -0
  142. package/dist/server/config/schema.d.ts +78 -0
  143. package/dist/server/config/schema.js +158 -0
  144. package/dist/server/config/schema.js.map +1 -0
  145. package/dist/server/content-helpers.d.ts +67 -0
  146. package/dist/server/content-helpers.js +79 -0
  147. package/dist/server/content-helpers.js.map +1 -0
  148. package/dist/server/content-helpers.test.d.ts +1 -0
  149. package/dist/server/content-helpers.test.js +70 -0
  150. package/dist/server/content-helpers.test.js.map +1 -0
  151. package/dist/server/express.d.ts +11 -0
  152. package/dist/server/express.js +129 -0
  153. package/dist/server/express.js.map +1 -0
  154. package/dist/server/express.test.d.ts +1 -0
  155. package/dist/server/express.test.js +464 -0
  156. package/dist/server/express.test.js.map +1 -0
  157. package/dist/server/file-ref.d.ts +28 -0
  158. package/dist/server/file-ref.js +27 -0
  159. package/dist/server/file-ref.js.map +1 -0
  160. package/dist/server/index.d.ts +17 -0
  161. package/dist/server/index.js +14 -0
  162. package/dist/server/index.js.map +1 -0
  163. package/dist/server/inferUtilityTypes.d.ts +64 -0
  164. package/dist/server/inferUtilityTypes.js +2 -0
  165. package/dist/server/inferUtilityTypes.js.map +1 -0
  166. package/dist/server/log-sink.d.ts +16 -0
  167. package/dist/server/log-sink.js +66 -0
  168. package/dist/server/log-sink.js.map +1 -0
  169. package/dist/server/metric.d.ts +12 -0
  170. package/dist/server/metric.js +13 -0
  171. package/dist/server/metric.js.map +1 -0
  172. package/dist/server/middleware.d.ts +137 -0
  173. package/dist/server/middleware.js +93 -0
  174. package/dist/server/middleware.js.map +1 -0
  175. package/dist/server/middleware.test-d.d.ts +1 -0
  176. package/dist/server/middleware.test-d.js +75 -0
  177. package/dist/server/middleware.test-d.js.map +1 -0
  178. package/dist/server/middleware.test.d.ts +1 -0
  179. package/dist/server/middleware.test.js +493 -0
  180. package/dist/server/middleware.test.js.map +1 -0
  181. package/dist/server/mock-seed.d.ts +62 -0
  182. package/dist/server/mock-seed.js +251 -0
  183. package/dist/server/mock-seed.js.map +1 -0
  184. package/dist/server/mock-seed.test.d.ts +1 -0
  185. package/dist/server/mock-seed.test.js +122 -0
  186. package/dist/server/mock-seed.test.js.map +1 -0
  187. package/dist/server/observability.d.ts +149 -0
  188. package/dist/server/observability.js +340 -0
  189. package/dist/server/observability.js.map +1 -0
  190. package/dist/server/observability.test.d.ts +1 -0
  191. package/dist/server/observability.test.js +251 -0
  192. package/dist/server/observability.test.js.map +1 -0
  193. package/dist/server/otel.d.ts +45 -0
  194. package/dist/server/otel.js +117 -0
  195. package/dist/server/otel.js.map +1 -0
  196. package/dist/server/otel.test.d.ts +1 -0
  197. package/dist/server/otel.test.js +122 -0
  198. package/dist/server/otel.test.js.map +1 -0
  199. package/dist/server/server.d.ts +422 -0
  200. package/dist/server/server.js +684 -0
  201. package/dist/server/server.js.map +1 -0
  202. package/dist/server/storage/index.d.ts +23 -0
  203. package/dist/server/storage/index.js +46 -0
  204. package/dist/server/storage/index.js.map +1 -0
  205. package/dist/server/storage/memory.d.ts +30 -0
  206. package/dist/server/storage/memory.js +98 -0
  207. package/dist/server/storage/memory.js.map +1 -0
  208. package/dist/server/storage/memory.test.d.ts +1 -0
  209. package/dist/server/storage/memory.test.js +81 -0
  210. package/dist/server/storage/memory.test.js.map +1 -0
  211. package/dist/server/storage/postgres.d.ts +65 -0
  212. package/dist/server/storage/postgres.js +242 -0
  213. package/dist/server/storage/postgres.js.map +1 -0
  214. package/dist/server/storage/postgres.test.d.ts +1 -0
  215. package/dist/server/storage/postgres.test.js +182 -0
  216. package/dist/server/storage/postgres.test.js.map +1 -0
  217. package/dist/server/storage/sqlite.d.ts +33 -0
  218. package/dist/server/storage/sqlite.js +250 -0
  219. package/dist/server/storage/sqlite.js.map +1 -0
  220. package/dist/server/storage/sqlite.test.d.ts +1 -0
  221. package/dist/server/storage/sqlite.test.js +133 -0
  222. package/dist/server/storage/sqlite.test.js.map +1 -0
  223. package/dist/server/storage/types.d.ts +119 -0
  224. package/dist/server/storage/types.js +11 -0
  225. package/dist/server/storage/types.js.map +1 -0
  226. package/dist/server/templateHelper.d.ts +16 -0
  227. package/dist/server/templateHelper.js +11 -0
  228. package/dist/server/templateHelper.js.map +1 -0
  229. package/dist/server/templates.generated.d.ts +4 -0
  230. package/dist/server/templates.generated.js +47 -0
  231. package/dist/server/templates.generated.js.map +1 -0
  232. package/dist/server/tunnel-proxy-router.d.ts +7 -0
  233. package/dist/server/tunnel-proxy-router.js +110 -0
  234. package/dist/server/tunnel-proxy-router.js.map +1 -0
  235. package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
  236. package/dist/server/tunnel-proxy-router.test.js +229 -0
  237. package/dist/server/tunnel-proxy-router.test.js.map +1 -0
  238. package/dist/server/viewsDevServer.d.ts +14 -0
  239. package/dist/server/viewsDevServer.js +45 -0
  240. package/dist/server/viewsDevServer.js.map +1 -0
  241. package/dist/test/utils.d.ts +127 -0
  242. package/dist/test/utils.js +247 -0
  243. package/dist/test/utils.js.map +1 -0
  244. package/dist/test/view.test.d.ts +1 -0
  245. package/dist/test/view.test.js +568 -0
  246. package/dist/test/view.test.js.map +1 -0
  247. package/dist/version.d.ts +1 -0
  248. package/dist/version.js +3 -0
  249. package/dist/version.js.map +1 -0
  250. package/dist/web/bridges/apps-sdk/adaptor.d.ts +54 -0
  251. package/dist/web/bridges/apps-sdk/adaptor.js +164 -0
  252. package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
  253. package/dist/web/bridges/apps-sdk/bridge.d.ts +11 -0
  254. package/dist/web/bridges/apps-sdk/bridge.js +47 -0
  255. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
  256. package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
  257. package/dist/web/bridges/apps-sdk/index.js +5 -0
  258. package/dist/web/bridges/apps-sdk/index.js.map +1 -0
  259. package/dist/web/bridges/apps-sdk/types.d.ts +147 -0
  260. package/dist/web/bridges/apps-sdk/types.js +10 -0
  261. package/dist/web/bridges/apps-sdk/types.js.map +1 -0
  262. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +13 -0
  263. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +18 -0
  264. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
  265. package/dist/web/bridges/get-adaptor.d.ts +9 -0
  266. package/dist/web/bridges/get-adaptor.js +15 -0
  267. package/dist/web/bridges/get-adaptor.js.map +1 -0
  268. package/dist/web/bridges/index.d.ts +5 -0
  269. package/dist/web/bridges/index.js +6 -0
  270. package/dist/web/bridges/index.js.map +1 -0
  271. package/dist/web/bridges/mcp-app/adaptor.d.ts +81 -0
  272. package/dist/web/bridges/mcp-app/adaptor.js +346 -0
  273. package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
  274. package/dist/web/bridges/mcp-app/bridge.d.ts +28 -0
  275. package/dist/web/bridges/mcp-app/bridge.js +124 -0
  276. package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
  277. package/dist/web/bridges/mcp-app/index.d.ts +4 -0
  278. package/dist/web/bridges/mcp-app/index.js +4 -0
  279. package/dist/web/bridges/mcp-app/index.js.map +1 -0
  280. package/dist/web/bridges/mcp-app/types.d.ts +8 -0
  281. package/dist/web/bridges/mcp-app/types.js +2 -0
  282. package/dist/web/bridges/mcp-app/types.js.map +1 -0
  283. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +19 -0
  284. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +19 -0
  285. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
  286. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.d.ts +1 -0
  287. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +26 -0
  288. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
  289. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  290. package/dist/web/bridges/mcp-app/view-tools.test.js +144 -0
  291. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  292. package/dist/web/bridges/types.d.ts +243 -0
  293. package/dist/web/bridges/types.js +2 -0
  294. package/dist/web/bridges/types.js.map +1 -0
  295. package/dist/web/bridges/use-host-context.d.ts +7 -0
  296. package/dist/web/bridges/use-host-context.js +13 -0
  297. package/dist/web/bridges/use-host-context.js.map +1 -0
  298. package/dist/web/components/modal-provider.d.ts +4 -0
  299. package/dist/web/components/modal-provider.js +45 -0
  300. package/dist/web/components/modal-provider.js.map +1 -0
  301. package/dist/web/create-store.d.ts +29 -0
  302. package/dist/web/create-store.js +64 -0
  303. package/dist/web/create-store.js.map +1 -0
  304. package/dist/web/create-store.test.d.ts +1 -0
  305. package/dist/web/create-store.test.js +129 -0
  306. package/dist/web/create-store.test.js.map +1 -0
  307. package/dist/web/data-llm.d.ts +47 -0
  308. package/dist/web/data-llm.js +100 -0
  309. package/dist/web/data-llm.js.map +1 -0
  310. package/dist/web/data-llm.test.d.ts +1 -0
  311. package/dist/web/data-llm.test.js +142 -0
  312. package/dist/web/data-llm.test.js.map +1 -0
  313. package/dist/web/generate-helpers.d.ts +120 -0
  314. package/dist/web/generate-helpers.js +115 -0
  315. package/dist/web/generate-helpers.js.map +1 -0
  316. package/dist/web/generate-helpers.test-d.d.ts +1 -0
  317. package/dist/web/generate-helpers.test-d.js +211 -0
  318. package/dist/web/generate-helpers.test-d.js.map +1 -0
  319. package/dist/web/generate-helpers.test.d.ts +1 -0
  320. package/dist/web/generate-helpers.test.js +17 -0
  321. package/dist/web/generate-helpers.test.js.map +1 -0
  322. package/dist/web/helpers/state.d.ts +7 -0
  323. package/dist/web/helpers/state.js +45 -0
  324. package/dist/web/helpers/state.js.map +1 -0
  325. package/dist/web/helpers/state.test.d.ts +1 -0
  326. package/dist/web/helpers/state.test.js +53 -0
  327. package/dist/web/helpers/state.test.js.map +1 -0
  328. package/dist/web/hooks/index.d.ts +17 -0
  329. package/dist/web/hooks/index.js +18 -0
  330. package/dist/web/hooks/index.js.map +1 -0
  331. package/dist/web/hooks/test/utils.d.ts +20 -0
  332. package/dist/web/hooks/test/utils.js +75 -0
  333. package/dist/web/hooks/test/utils.js.map +1 -0
  334. package/dist/web/hooks/use-call-tool.d.ts +146 -0
  335. package/dist/web/hooks/use-call-tool.js +96 -0
  336. package/dist/web/hooks/use-call-tool.js.map +1 -0
  337. package/dist/web/hooks/use-call-tool.test-d.d.ts +1 -0
  338. package/dist/web/hooks/use-call-tool.test-d.js +104 -0
  339. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
  340. package/dist/web/hooks/use-call-tool.test.d.ts +1 -0
  341. package/dist/web/hooks/use-call-tool.test.js +211 -0
  342. package/dist/web/hooks/use-call-tool.test.js.map +1 -0
  343. package/dist/web/hooks/use-display-mode.d.ts +24 -0
  344. package/dist/web/hooks/use-display-mode.js +29 -0
  345. package/dist/web/hooks/use-display-mode.js.map +1 -0
  346. package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
  347. package/dist/web/hooks/use-display-mode.test-d.js +8 -0
  348. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
  349. package/dist/web/hooks/use-display-mode.test.d.ts +1 -0
  350. package/dist/web/hooks/use-display-mode.test.js +41 -0
  351. package/dist/web/hooks/use-display-mode.test.js.map +1 -0
  352. package/dist/web/hooks/use-download.d.ts +5 -0
  353. package/dist/web/hooks/use-download.js +8 -0
  354. package/dist/web/hooks/use-download.js.map +1 -0
  355. package/dist/web/hooks/use-download.test.d.ts +1 -0
  356. package/dist/web/hooks/use-download.test.js +95 -0
  357. package/dist/web/hooks/use-download.test.js.map +1 -0
  358. package/dist/web/hooks/use-files.d.ts +39 -0
  359. package/dist/web/hooks/use-files.js +42 -0
  360. package/dist/web/hooks/use-files.js.map +1 -0
  361. package/dist/web/hooks/use-files.test.d.ts +1 -0
  362. package/dist/web/hooks/use-files.test.js +54 -0
  363. package/dist/web/hooks/use-files.test.js.map +1 -0
  364. package/dist/web/hooks/use-intent.d.ts +30 -0
  365. package/dist/web/hooks/use-intent.js +34 -0
  366. package/dist/web/hooks/use-intent.js.map +1 -0
  367. package/dist/web/hooks/use-intent.test.d.ts +1 -0
  368. package/dist/web/hooks/use-intent.test.js +85 -0
  369. package/dist/web/hooks/use-intent.test.js.map +1 -0
  370. package/dist/web/hooks/use-layout.d.ts +24 -0
  371. package/dist/web/hooks/use-layout.js +25 -0
  372. package/dist/web/hooks/use-layout.js.map +1 -0
  373. package/dist/web/hooks/use-layout.test.d.ts +1 -0
  374. package/dist/web/hooks/use-layout.test.js +96 -0
  375. package/dist/web/hooks/use-layout.test.js.map +1 -0
  376. package/dist/web/hooks/use-notify.d.ts +29 -0
  377. package/dist/web/hooks/use-notify.js +33 -0
  378. package/dist/web/hooks/use-notify.js.map +1 -0
  379. package/dist/web/hooks/use-notify.test.d.ts +1 -0
  380. package/dist/web/hooks/use-notify.test.js +105 -0
  381. package/dist/web/hooks/use-notify.test.js.map +1 -0
  382. package/dist/web/hooks/use-open-external.d.ts +20 -0
  383. package/dist/web/hooks/use-open-external.js +24 -0
  384. package/dist/web/hooks/use-open-external.js.map +1 -0
  385. package/dist/web/hooks/use-open-external.test.d.ts +1 -0
  386. package/dist/web/hooks/use-open-external.test.js +65 -0
  387. package/dist/web/hooks/use-open-external.test.js.map +1 -0
  388. package/dist/web/hooks/use-register-view-tool.d.ts +38 -0
  389. package/dist/web/hooks/use-register-view-tool.js +50 -0
  390. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  391. package/dist/web/hooks/use-request-close.d.ts +16 -0
  392. package/dist/web/hooks/use-request-close.js +21 -0
  393. package/dist/web/hooks/use-request-close.js.map +1 -0
  394. package/dist/web/hooks/use-request-close.test.d.ts +1 -0
  395. package/dist/web/hooks/use-request-close.test.js +52 -0
  396. package/dist/web/hooks/use-request-close.test.js.map +1 -0
  397. package/dist/web/hooks/use-request-modal.d.ts +24 -0
  398. package/dist/web/hooks/use-request-modal.js +31 -0
  399. package/dist/web/hooks/use-request-modal.js.map +1 -0
  400. package/dist/web/hooks/use-request-modal.test.d.ts +1 -0
  401. package/dist/web/hooks/use-request-modal.test.js +61 -0
  402. package/dist/web/hooks/use-request-modal.test.js.map +1 -0
  403. package/dist/web/hooks/use-request-size.d.ts +20 -0
  404. package/dist/web/hooks/use-request-size.js +24 -0
  405. package/dist/web/hooks/use-request-size.js.map +1 -0
  406. package/dist/web/hooks/use-request-size.test.d.ts +1 -0
  407. package/dist/web/hooks/use-request-size.test.js +65 -0
  408. package/dist/web/hooks/use-request-size.test.js.map +1 -0
  409. package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -0
  410. package/dist/web/hooks/use-send-follow-up-message.js +25 -0
  411. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
  412. package/dist/web/hooks/use-set-open-in-app-url.d.ts +18 -0
  413. package/dist/web/hooks/use-set-open-in-app-url.js +25 -0
  414. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
  415. package/dist/web/hooks/use-set-open-in-app-url.test.d.ts +1 -0
  416. package/dist/web/hooks/use-set-open-in-app-url.test.js +43 -0
  417. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
  418. package/dist/web/hooks/use-tool-info.d.ts +87 -0
  419. package/dist/web/hooks/use-tool-info.js +49 -0
  420. package/dist/web/hooks/use-tool-info.js.map +1 -0
  421. package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
  422. package/dist/web/hooks/use-tool-info.test-d.js +91 -0
  423. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
  424. package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
  425. package/dist/web/hooks/use-tool-info.test.js +130 -0
  426. package/dist/web/hooks/use-tool-info.test.js.map +1 -0
  427. package/dist/web/hooks/use-user.d.ts +20 -0
  428. package/dist/web/hooks/use-user.js +37 -0
  429. package/dist/web/hooks/use-user.js.map +1 -0
  430. package/dist/web/hooks/use-user.test.d.ts +1 -0
  431. package/dist/web/hooks/use-user.test.js +122 -0
  432. package/dist/web/hooks/use-user.test.js.map +1 -0
  433. package/dist/web/hooks/use-view-state.d.ts +25 -0
  434. package/dist/web/hooks/use-view-state.js +32 -0
  435. package/dist/web/hooks/use-view-state.js.map +1 -0
  436. package/dist/web/hooks/use-view-state.test.d.ts +1 -0
  437. package/dist/web/hooks/use-view-state.test.js +177 -0
  438. package/dist/web/hooks/use-view-state.test.js.map +1 -0
  439. package/dist/web/index.d.ts +7 -0
  440. package/dist/web/index.js +8 -0
  441. package/dist/web/index.js.map +1 -0
  442. package/dist/web/mount-view.d.ts +20 -0
  443. package/dist/web/mount-view.js +46 -0
  444. package/dist/web/mount-view.js.map +1 -0
  445. package/dist/web/plugin/data-llm.test.d.ts +1 -0
  446. package/dist/web/plugin/data-llm.test.js +81 -0
  447. package/dist/web/plugin/data-llm.test.js.map +1 -0
  448. package/dist/web/plugin/plugin.d.ts +33 -0
  449. package/dist/web/plugin/plugin.js +189 -0
  450. package/dist/web/plugin/plugin.js.map +1 -0
  451. package/dist/web/plugin/scan-views.d.ts +16 -0
  452. package/dist/web/plugin/scan-views.js +88 -0
  453. package/dist/web/plugin/scan-views.js.map +1 -0
  454. package/dist/web/plugin/scan-views.test.d.ts +1 -0
  455. package/dist/web/plugin/scan-views.test.js +99 -0
  456. package/dist/web/plugin/scan-views.test.js.map +1 -0
  457. package/dist/web/plugin/transform-data-llm.d.ts +12 -0
  458. package/dist/web/plugin/transform-data-llm.js +96 -0
  459. package/dist/web/plugin/transform-data-llm.js.map +1 -0
  460. package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
  461. package/dist/web/plugin/transform-data-llm.test.js +81 -0
  462. package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
  463. package/dist/web/plugin/validate-view.d.ts +1 -0
  464. package/dist/web/plugin/validate-view.js +9 -0
  465. package/dist/web/plugin/validate-view.js.map +1 -0
  466. package/dist/web/plugin/validate-view.test.d.ts +1 -0
  467. package/dist/web/plugin/validate-view.test.js +24 -0
  468. package/dist/web/plugin/validate-view.test.js.map +1 -0
  469. package/dist/web/proxy.d.ts +1 -0
  470. package/dist/web/proxy.js +52 -0
  471. package/dist/web/proxy.js.map +1 -0
  472. package/dist/web/types.d.ts +20 -0
  473. package/dist/web/types.js +2 -0
  474. package/dist/web/types.js.map +1 -0
  475. package/package.json +125 -0
  476. package/scripts/postinstall.mjs +45 -0
  477. package/tsconfig.base.json +36 -0
@@ -0,0 +1,14 @@
1
+ export { AdminTokenMissingError, adminAuthMiddleware, adminEnabled, ensureAdminStorage, mountAdmin, readAdminToken, } from "./admin.js";
2
+ export { analyticsEnabled, installAnalytics, mockEnabled, } from "./analytics.js";
3
+ export { InvalidTokenError, mcpAuthMetadataRouter, optionalBearerAuth, requireBearerAuth, } from "./auth.js";
4
+ export { allKeyMeta, BOOTSTRAP_KEYS, bootstrapSchema, configSchema, createConfigRouter, ENV_VARS, isBootstrapKey, isKnownKey, isRuntimeKey, isSecretKey, keyMeta, loadConfigFile, MASKED, RUNTIME_KEYS, resolveConfig, runtimeSchema, SECRET_KEYS, validateRuntimeWrite, } from "./config/index.js";
5
+ export { audio, embeddedResource, image, resourceLink, text, } from "./content-helpers.js";
6
+ export { FileRef } from "./file-ref.js";
7
+ export { getActiveStorage, serverLog } from "./log-sink.js";
8
+ export { generateMockEvents, generateMockLogs, MOCK_SEED, mulberry32, seedMockData, } from "./mock-seed.js";
9
+ export { createObservabilityRouter, percentile, summarize, } from "./observability.js";
10
+ export { createOtelSink, initOtel, otelEnabled, otelEndpoint, } from "./otel.js";
11
+ export { __setBuildManifest, McpServer, normalizeContent, } from "./server.js";
12
+ export { DEFAULT_DB_PATH, DEFAULT_MEMORY_CAP, MemoryStorageAdapter, PostgresStorageAdapter, registerStorageAdapter, resolvePostgresConnectionString, resolveStorageAdapter, SqliteStorageAdapter, } from "./storage/index.js";
13
+ export { viewsDevServer } from "./viewsDevServer.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAEhB,gBAAgB,EAChB,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAIL,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,UAAU,EACV,cAAc,EAGd,eAAe,EAIf,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,EAEX,OAAO,EACP,cAAc,EACd,MAAM,EAGN,YAAY,EAGZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,KAAK,EACL,YAAY,EACZ,IAAI,GACL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AASxC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAU5D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EAET,UAAU,EACV,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,yBAAyB,EAKzB,UAAU,EAEV,SAAS,GAGV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,QAAQ,EAER,WAAW,EACX,YAAY,GACb,MAAM,WAAW,CAAC;AAcnB,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EAEpB,sBAAsB,EAEtB,sBAAsB,EACtB,+BAA+B,EAC/B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAW5B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export {\n AdminTokenMissingError,\n adminAuthMiddleware,\n adminEnabled,\n ensureAdminStorage,\n mountAdmin,\n readAdminToken,\n} from \"./admin.js\";\nexport {\n analyticsEnabled,\n type InstallAnalyticsOptions,\n installAnalytics,\n mockEnabled,\n} from \"./analytics.js\";\nexport {\n type AuthInfo,\n type AuthMetadataOptions,\n type BearerAuthMiddlewareOptions,\n InvalidTokenError,\n mcpAuthMetadataRouter,\n optionalBearerAuth,\n requireBearerAuth,\n} from \"./auth.js\";\nexport {\n allKeyMeta,\n BOOTSTRAP_KEYS,\n type BootstrapConfig,\n type BootstrapKey,\n bootstrapSchema,\n type Config,\n type ConfigKey,\n type ConfigSource,\n configSchema,\n createConfigRouter,\n ENV_VARS,\n isBootstrapKey,\n isKnownKey,\n isRuntimeKey,\n isSecretKey,\n type KeyMeta,\n keyMeta,\n loadConfigFile,\n MASKED,\n type ResolvedConfig,\n type ResolvedSetting,\n RUNTIME_KEYS,\n type RuntimeConfig,\n type RuntimeKey,\n resolveConfig,\n runtimeSchema,\n SECRET_KEYS,\n validateRuntimeWrite,\n} from \"./config/index.js\";\nexport {\n audio,\n embeddedResource,\n image,\n resourceLink,\n text,\n} from \"./content-helpers.js\";\nexport { FileRef } from \"./file-ref.js\";\nexport type {\n AnyToolRegistry,\n InferTools,\n ToolInput,\n ToolNames,\n ToolOutput,\n ToolResponseMetadata,\n} from \"./inferUtilityTypes.js\";\nexport { getActiveStorage, serverLog } from \"./log-sink.js\";\nexport type {\n McpExtra,\n McpMethodString,\n McpMiddlewareFilter,\n McpMiddlewareFn,\n McpResultFor,\n McpTypedMiddlewareFn,\n McpWildcard,\n} from \"./middleware.js\";\nexport {\n generateMockEvents,\n generateMockLogs,\n MOCK_SEED,\n type MockSeedOptions,\n mulberry32,\n seedMockData,\n} from \"./mock-seed.js\";\nexport {\n createObservabilityRouter,\n type LatencyBucket,\n type MethodStat,\n type ObservabilityDisabled,\n type ObservabilitySummary,\n percentile,\n type SummarizeOptions,\n summarize,\n type TimeBucket,\n type ToolStat,\n} from \"./observability.js\";\nexport {\n createOtelSink,\n initOtel,\n type OtelSink,\n otelEnabled,\n otelEndpoint,\n} from \"./otel.js\";\nexport type {\n HandlerContent,\n KnownToolMeta,\n McpServerTypes,\n SecurityScheme,\n ToolDef,\n ToolMeta,\n ViewConfig,\n ViewCsp,\n ViewHostType,\n ViewName,\n ViewNameRegistry,\n} from \"./server.js\";\nexport {\n __setBuildManifest,\n McpServer,\n normalizeContent,\n} from \"./server.js\";\nexport {\n DEFAULT_DB_PATH,\n DEFAULT_MEMORY_CAP,\n MemoryStorageAdapter,\n type PgPoolLike,\n PostgresStorageAdapter,\n type PostgresStorageOptions,\n registerStorageAdapter,\n resolvePostgresConnectionString,\n resolveStorageAdapter,\n SqliteStorageAdapter,\n} from \"./storage/index.js\";\nexport type {\n AnalyticsEvent,\n ConfigAuditEntry,\n EventQuery,\n LogEntry,\n LogQuery,\n StorageAdapter,\n StorageAdapterFactory,\n StorageAdapterOptions,\n} from \"./storage/types.js\";\nexport { viewsDevServer } from \"./viewsDevServer.js\";\n"]}
@@ -0,0 +1,64 @@
1
+ import type { McpServerTypes, ToolDef } from "./server.js";
2
+ /**
3
+ * Any tool registry shape (includes both views and regular tools).
4
+ * Used as a constraint for type parameters that accept tool registries.
5
+ */
6
+ export type AnyToolRegistry = Record<string, ToolDef>;
7
+ /**
8
+ * Extract the tool registry type from an McpServer instance.
9
+ * This includes both views (registered via view()) and regular tools (registered via registerTool()).
10
+ *
11
+ * Uses the `$types` property pattern for cross-package type inference.
12
+ * This works across package boundaries because TypeScript uses structural typing
13
+ * on the shape of `$types`, rather than nominal typing on the McpServer class itself.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * type MyTools = InferTools<MyServer>;
18
+ * // { "search": ToolDef<...>, "calculate": ToolDef<...> }
19
+ * ```
20
+ */
21
+ export type InferTools<ServerType> = ServerType extends {
22
+ $types: McpServerTypes<infer W>;
23
+ } ? W : never;
24
+ type ExtractTool<ServerType, K extends ToolNames<ServerType>> = InferTools<ServerType>[K];
25
+ /**
26
+ * Get a union of all tool names from an McpServer instance.
27
+ * This includes both views and regular tools.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * type Names = ToolNames<MyServer>;
32
+ * // "search" | "calculate" | "details"
33
+ * ```
34
+ */
35
+ export type ToolNames<ServerType> = keyof InferTools<ServerType> & string;
36
+ /**
37
+ * Get the input type for a specific tool (view or regular tool).
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * type SearchInput = ToolInput<MyServer, "search">;
42
+ * ```
43
+ */
44
+ export type ToolInput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["input"];
45
+ /**
46
+ * Get the output type for a specific tool (view or regular tool).
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * type SearchOutput = ToolOutput<MyServer, "search">;
51
+ * ```
52
+ */
53
+ export type ToolOutput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["output"];
54
+ /**
55
+ * Get the responseMetadata type for a specific tool (view or regular tool).
56
+ * This is inferred from the `_meta` property of the tool callback's return value.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * type SearchMeta = ToolResponseMetadata<MyServer, "search">;
61
+ * ```
62
+ */
63
+ export type ToolResponseMetadata<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["responseMetadata"];
64
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inferUtilityTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inferUtilityTypes.js","sourceRoot":"","sources":["../../src/server/inferUtilityTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { McpServerTypes, ToolDef } from \"./server.js\";\n\n/**\n * Any tool registry shape (includes both views and regular tools).\n * Used as a constraint for type parameters that accept tool registries.\n */\nexport type AnyToolRegistry = Record<string, ToolDef>;\n\n/**\n * Extract the tool registry type from an McpServer instance.\n * This includes both views (registered via view()) and regular tools (registered via registerTool()).\n *\n * Uses the `$types` property pattern for cross-package type inference.\n * This works across package boundaries because TypeScript uses structural typing\n * on the shape of `$types`, rather than nominal typing on the McpServer class itself.\n *\n * @example\n * ```ts\n * type MyTools = InferTools<MyServer>;\n * // { \"search\": ToolDef<...>, \"calculate\": ToolDef<...> }\n * ```\n */\nexport type InferTools<ServerType> = ServerType extends {\n $types: McpServerTypes<infer W>;\n}\n ? W\n : never;\ntype ExtractTool<\n ServerType,\n K extends ToolNames<ServerType>,\n> = InferTools<ServerType>[K];\n\n/**\n * Get a union of all tool names from an McpServer instance.\n * This includes both views and regular tools.\n *\n * @example\n * ```ts\n * type Names = ToolNames<MyServer>;\n * // \"search\" | \"calculate\" | \"details\"\n * ```\n */\nexport type ToolNames<ServerType> = keyof InferTools<ServerType> & string;\n\n/**\n * Get the input type for a specific tool (view or regular tool).\n *\n * @example\n * ```ts\n * type SearchInput = ToolInput<MyServer, \"search\">;\n * ```\n */\nexport type ToolInput<\n ServerType,\n ToolName extends ToolNames<ServerType>,\n> = ExtractTool<ServerType, ToolName>[\"input\"];\n\n/**\n * Get the output type for a specific tool (view or regular tool).\n *\n * @example\n * ```ts\n * type SearchOutput = ToolOutput<MyServer, \"search\">;\n * ```\n */\nexport type ToolOutput<\n ServerType,\n ToolName extends ToolNames<ServerType>,\n> = ExtractTool<ServerType, ToolName>[\"output\"];\n\n/**\n * Get the responseMetadata type for a specific tool (view or regular tool).\n * This is inferred from the `_meta` property of the tool callback's return value.\n *\n * @example\n * ```ts\n * type SearchMeta = ToolResponseMetadata<MyServer, \"search\">;\n * ```\n */\nexport type ToolResponseMetadata<\n ServerType,\n ToolName extends ToolNames<ServerType>,\n> = ExtractTool<ServerType, ToolName>[\"responseMetadata\"];\n"]}
@@ -0,0 +1,16 @@
1
+ import type { LogEntry, StorageAdapter } from "./storage/types.js";
2
+ /** Set the active storage instance (called by `installAnalytics`). */
3
+ export declare function setActiveStorage(storage: StorageAdapter | null): void;
4
+ /**
5
+ * The active {@link StorageAdapter} for this process, or `null` when analytics
6
+ * is disabled / before startup. M3's observability API should read from this
7
+ * (or the equivalent `server.storage` getter) so it sees exactly the data the
8
+ * server writes.
9
+ */
10
+ export declare function getActiveStorage(): StorageAdapter | null;
11
+ /**
12
+ * The framework's server-log hook. Prints to the console as usual AND, when an
13
+ * active storage is set, mirrors the line to `storage.appendLog` without
14
+ * blocking and swallowing any error.
15
+ */
16
+ export declare function serverLog(level: LogEntry["level"], msg: string, data?: unknown): void;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Log capture sink (M2) + shared active-storage holder.
3
+ *
4
+ * The module keeps a single process-wide reference to the active
5
+ * {@link StorageAdapter} (set by `installAnalytics` at startup, cleared on
6
+ * shutdown). This is the in-process handoff the observability API (M3) reads
7
+ * from — see {@link getActiveStorage} and the `McpServer.storage` getter.
8
+ *
9
+ * {@link serverLog} is the minimal, surgical logging hook the framework uses to
10
+ * mirror its own logs to storage IN ADDITION to printing them. It is cheap,
11
+ * async (fire-and-forget), and error-swallowing — log capture must never break
12
+ * or slow the server, and when analytics is OFF there is no active storage so
13
+ * it is a plain `console.*` call with no extra cost.
14
+ */
15
+ let activeStorage = null;
16
+ /** Set the active storage instance (called by `installAnalytics`). */
17
+ export function setActiveStorage(storage) {
18
+ activeStorage = storage;
19
+ }
20
+ /**
21
+ * The active {@link StorageAdapter} for this process, or `null` when analytics
22
+ * is disabled / before startup. M3's observability API should read from this
23
+ * (or the equivalent `server.storage` getter) so it sees exactly the data the
24
+ * server writes.
25
+ */
26
+ export function getActiveStorage() {
27
+ return activeStorage;
28
+ }
29
+ /** Map a log level to the name of the `console` method to print with. */
30
+ const CONSOLE_METHOD = {
31
+ debug: "debug",
32
+ info: "info",
33
+ warning: "warn",
34
+ error: "error",
35
+ };
36
+ /**
37
+ * The framework's server-log hook. Prints to the console as usual AND, when an
38
+ * active storage is set, mirrors the line to `storage.appendLog` without
39
+ * blocking and swallowing any error.
40
+ */
41
+ export function serverLog(level, msg, data) {
42
+ // Resolve the console method by name at call time so test spies / runtime
43
+ // console replacements are honored (binding the ref at module init would not).
44
+ const method = CONSOLE_METHOD[level] ?? "log";
45
+ if (data !== undefined) {
46
+ console[method](msg, data);
47
+ }
48
+ else {
49
+ console[method](msg);
50
+ }
51
+ const storage = activeStorage;
52
+ if (!storage) {
53
+ return;
54
+ }
55
+ // Fire-and-forget; never block the caller; never throw.
56
+ void appendSafely(storage, { ts: Date.now(), level, msg, data });
57
+ }
58
+ async function appendSafely(storage, entry) {
59
+ try {
60
+ await storage.appendLog(entry);
61
+ }
62
+ catch {
63
+ // Log capture must never break or slow the server.
64
+ }
65
+ }
66
+ //# sourceMappingURL=log-sink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-sink.js","sourceRoot":"","sources":["../../src/server/log-sink.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,IAAI,aAAa,GAA0B,IAAI,CAAC;AAEhD,sEAAsE;AACtE,MAAM,UAAU,gBAAgB,CAAC,OAA8B;IAC7D,aAAa,GAAG,OAAO,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,yEAAyE;AACzE,MAAM,cAAc,GAGhB;IACF,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,OAAO;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,KAAwB,EACxB,GAAW,EACX,IAAc;IAEd,0EAA0E;IAC1E,+EAA+E;IAC/E,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;IAC9C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,OAAO,GAAG,aAAa,CAAC;IAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,wDAAwD;IACxD,KAAK,YAAY,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,OAAuB,EACvB,KAAe;IAEf,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,mDAAmD;IACrD,CAAC;AACH,CAAC","sourcesContent":["import type { LogEntry, StorageAdapter } from \"./storage/types.js\";\n\n/**\n * Log capture sink (M2) + shared active-storage holder.\n *\n * The module keeps a single process-wide reference to the active\n * {@link StorageAdapter} (set by `installAnalytics` at startup, cleared on\n * shutdown). This is the in-process handoff the observability API (M3) reads\n * from — see {@link getActiveStorage} and the `McpServer.storage` getter.\n *\n * {@link serverLog} is the minimal, surgical logging hook the framework uses to\n * mirror its own logs to storage IN ADDITION to printing them. It is cheap,\n * async (fire-and-forget), and error-swallowing — log capture must never break\n * or slow the server, and when analytics is OFF there is no active storage so\n * it is a plain `console.*` call with no extra cost.\n */\n\nlet activeStorage: StorageAdapter | null = null;\n\n/** Set the active storage instance (called by `installAnalytics`). */\nexport function setActiveStorage(storage: StorageAdapter | null): void {\n activeStorage = storage;\n}\n\n/**\n * The active {@link StorageAdapter} for this process, or `null` when analytics\n * is disabled / before startup. M3's observability API should read from this\n * (or the equivalent `server.storage` getter) so it sees exactly the data the\n * server writes.\n */\nexport function getActiveStorage(): StorageAdapter | null {\n return activeStorage;\n}\n\n/** Map a log level to the name of the `console` method to print with. */\nconst CONSOLE_METHOD: Record<\n LogEntry[\"level\"],\n \"debug\" | \"info\" | \"warn\" | \"error\"\n> = {\n debug: \"debug\",\n info: \"info\",\n warning: \"warn\",\n error: \"error\",\n};\n\n/**\n * The framework's server-log hook. Prints to the console as usual AND, when an\n * active storage is set, mirrors the line to `storage.appendLog` without\n * blocking and swallowing any error.\n */\nexport function serverLog(\n level: LogEntry[\"level\"],\n msg: string,\n data?: unknown,\n): void {\n // Resolve the console method by name at call time so test spies / runtime\n // console replacements are honored (binding the ref at module init would not).\n const method = CONSOLE_METHOD[level] ?? \"log\";\n if (data !== undefined) {\n console[method](msg, data);\n } else {\n console[method](msg);\n }\n\n const storage = activeStorage;\n if (!storage) {\n return;\n }\n // Fire-and-forget; never block the caller; never throw.\n void appendSafely(storage, { ts: Date.now(), level, msg, data });\n}\n\nasync function appendSafely(\n storage: StorageAdapter,\n entry: LogEntry,\n): Promise<void> {\n try {\n await storage.appendLog(entry);\n } catch {\n // Log capture must never break or slow the server.\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Metrics are removed in enpilink. Upstream emitted a DogStatsD/UDP counter to
3
+ * a hardcoded vendor IP for every tool call; that coupling is gone.
4
+ *
5
+ * The monitoring slot is now filled by the opt-in analytics installer in
6
+ * `./analytics.ts` (`installAnalytics`), which records `tool_call` events to a
7
+ * pluggable {@link StorageAdapter} — but ONLY when `ENPILINK_ANALYTICS` is set,
8
+ * so the default remains zero monitoring middleware and zero network activity.
9
+ *
10
+ * This file is retained as a thin re-export for discoverability.
11
+ */
12
+ export { installAnalytics } from "./analytics.js";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Metrics are removed in enpilink. Upstream emitted a DogStatsD/UDP counter to
3
+ * a hardcoded vendor IP for every tool call; that coupling is gone.
4
+ *
5
+ * The monitoring slot is now filled by the opt-in analytics installer in
6
+ * `./analytics.ts` (`installAnalytics`), which records `tool_call` events to a
7
+ * pluggable {@link StorageAdapter} — but ONLY when `ENPILINK_ANALYTICS` is set,
8
+ * so the default remains zero monitoring middleware and zero network activity.
9
+ *
10
+ * This file is retained as a thin re-export for discoverability.
11
+ */
12
+ export { installAnalytics } from "./analytics.js";
13
+ //# sourceMappingURL=metric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metric.js","sourceRoot":"","sources":["../../src/server/metric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Metrics are removed in enpilink. Upstream emitted a DogStatsD/UDP counter to\n * a hardcoded vendor IP for every tool call; that coupling is gone.\n *\n * The monitoring slot is now filled by the opt-in analytics installer in\n * `./analytics.ts` (`installAnalytics`), which records `tool_call` events to a\n * pluggable {@link StorageAdapter} — but ONLY when `ENPILINK_ANALYTICS` is set,\n * so the default remains zero monitoring middleware and zero network activity.\n *\n * This file is retained as a thin re-export for discoverability.\n */\nexport { installAnalytics } from \"./analytics.js\";\n"]}
@@ -0,0 +1,137 @@
1
+ import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
3
+ import type { CallToolResult, CancelTaskResult, ClientNotification, ClientRequest, CompleteResult, EmptyResult, GetPromptResult, GetTaskPayloadResult, GetTaskResult, InitializeResult, ListPromptsResult, ListResourcesResult, ListResourceTemplatesResult, ListTasksResult, ListToolsResult, ReadResourceResult, ServerNotification, ServerRequest, ServerResult } from "@modelcontextprotocol/sdk/types.js";
4
+ /**
5
+ * The `extra` context object provided by the MCP SDK to request handlers.
6
+ */
7
+ export type McpExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
8
+ /**
9
+ * A single MCP middleware function following the onion model.
10
+ * Call `next()` to invoke the next middleware or the final handler.
11
+ * For notifications, `extra` is `undefined` (SDK does not provide extra context)
12
+ * and `next()` resolves to `undefined`.
13
+ */
14
+ export type McpMiddlewareFn = (request: {
15
+ method: string;
16
+ params: Record<string, unknown>;
17
+ }, extra: McpExtra | undefined, next: () => Promise<unknown>) => Promise<unknown> | unknown;
18
+ /**
19
+ * MCP methods the server handles (incoming from client).
20
+ */
21
+ export type McpMethodString = ClientRequest["method"] | ClientNotification["method"];
22
+ /**
23
+ * Resolve the `params` type for a specific MCP method (request or notification)
24
+ * from the SDK's typed unions. Falls back to `Record<string, unknown>` for
25
+ * unknown methods. Used by {@link McpTypedMiddlewareFn} to narrow the request
26
+ * shape in typed middleware.
27
+ */
28
+ export type McpRequestParams<M extends string> = Extract<ClientRequest, {
29
+ method: M;
30
+ }> extends {
31
+ params: infer P;
32
+ } ? P : Extract<ClientNotification, {
33
+ method: M;
34
+ }> extends {
35
+ params: infer P;
36
+ } ? P : Record<string, unknown>;
37
+ /**
38
+ * Resolve the `extra` arg type for a specific MCP method: {@link McpExtra} for
39
+ * request methods, `undefined` for notification methods (the SDK does not
40
+ * pass extra context for notifications).
41
+ */
42
+ export type McpExtraFor<M extends string> = M extends ClientRequest["method"] ? McpExtra : M extends ClientNotification["method"] ? undefined : McpExtra | undefined;
43
+ /** Maps each MCP request method to its SDK result type. */
44
+ interface McpResultMap {
45
+ ping: EmptyResult;
46
+ initialize: InitializeResult;
47
+ "tools/list": ListToolsResult;
48
+ "tools/call": CallToolResult;
49
+ "resources/list": ListResourcesResult;
50
+ "resources/templates/list": ListResourceTemplatesResult;
51
+ "resources/read": ReadResourceResult;
52
+ "resources/subscribe": EmptyResult;
53
+ "resources/unsubscribe": EmptyResult;
54
+ "prompts/list": ListPromptsResult;
55
+ "prompts/get": GetPromptResult;
56
+ "completion/complete": CompleteResult;
57
+ "logging/setLevel": EmptyResult;
58
+ "tasks/get": GetTaskResult;
59
+ "tasks/result": GetTaskPayloadResult;
60
+ "tasks/list": ListTasksResult;
61
+ "tasks/cancel": CancelTaskResult;
62
+ }
63
+ /**
64
+ * Map an MCP method string to its corresponding result type.
65
+ * For request methods, resolves to the specific SDK result type.
66
+ * For wildcard patterns (e.g. `"tools/*"`), resolves to the union of matching result types.
67
+ * For notification methods, resolves to `undefined`.
68
+ * For unknown/unmatched methods, falls back to `ServerResult`.
69
+ */
70
+ export type McpResultFor<M extends string> = M extends keyof McpResultMap ? McpResultMap[M] : M extends `${infer Prefix}/*` ? [McpResultMap[keyof McpResultMap & `${Prefix}/${string}`]] extends [never] ? M extends ToWildcard<ClientNotification["method"]> ? undefined : ServerResult : McpResultMap[keyof McpResultMap & `${Prefix}/${string}`] : M extends ClientNotification["method"] ? undefined : ServerResult;
71
+ /**
72
+ * Typed middleware function for a specific method. Narrows `request.params`
73
+ * via {@link McpRequestParams}, `extra` via {@link McpExtraFor}, and the
74
+ * resolved value of `next()` via {@link McpResultFor}.
75
+ */
76
+ export type McpTypedMiddlewareFn<M extends string> = (request: {
77
+ method: M;
78
+ params: McpRequestParams<M>;
79
+ }, extra: McpExtraFor<M>, next: () => Promise<McpResultFor<M>>) => Promise<unknown> | unknown;
80
+ /** Extracts `"prefix/*"` from `"prefix/anything"` — distributive over unions. */
81
+ type ToWildcard<T extends string> = T extends `${infer Prefix}/${string}` ? `${Prefix}/*` : never;
82
+ /** Wildcard prefixes derived from method strings (e.g. `"tools/*"` from `"tools/call"`). */
83
+ export type McpWildcard = ToWildcard<McpMethodString>;
84
+ /** Category keywords matching all requests or all notifications. */
85
+ type McpCategory = "request" | "notification";
86
+ /**
87
+ * A single filter pattern for MCP middleware:
88
+ * - Exact method: `"tools/call"`
89
+ * - Wildcard: `"tools/*"`
90
+ * - Category: `"request"` | `"notification"`
91
+ * - Escape hatch: arbitrary string via `string & {}`
92
+ */
93
+ type McpMiddlewareFilterPattern = McpMethodString | McpWildcard | McpCategory | (string & {});
94
+ /**
95
+ * Filter determining which MCP methods a middleware applies to.
96
+ * A single pattern or an array of patterns (OR logic).
97
+ */
98
+ export type McpMiddlewareFilter = McpMiddlewareFilterPattern | McpMiddlewareFilterPattern[];
99
+ /**
100
+ * Internal entry stored for each registered middleware.
101
+ * `filter: null` means catch-all (matches everything).
102
+ */
103
+ export type McpMiddlewareEntry = {
104
+ filter: McpMiddlewareFilter | null;
105
+ handler: McpMiddlewareFn;
106
+ };
107
+ type HandlerMap = Map<string, (...args: unknown[]) => Promise<unknown>>;
108
+ /**
109
+ * Extract the TS-private `_requestHandlers` and `_notificationHandlers` maps
110
+ * from the SDK's `Server` (extends `Protocol`). These are runtime-accessible
111
+ * but declared `private` in TypeScript.
112
+ *
113
+ * Validates with `instanceof Map` so an incompatible SDK version fails fast
114
+ * instead of silently breaking.
115
+ */
116
+ export declare function getHandlerMaps(server: Server): {
117
+ requestHandlers: HandlerMap;
118
+ notificationHandlers: HandlerMap;
119
+ };
120
+ /**
121
+ * Check if a single filter pattern matches a given method.
122
+ *
123
+ * - Exact: `"tools/call"` matches only `"tools/call"`
124
+ * - Wildcard: `"tools/*"` matches any method starting with `"tools/"`
125
+ * - Category `"request"`: matches when `isNotification` is false
126
+ * - Category `"notification"`: matches when `isNotification` is true
127
+ */
128
+ export declare function matchesFilter(method: string, filter: string, isNotification: boolean): boolean;
129
+ /**
130
+ * Build an onion-model middleware chain for a specific method.
131
+ *
132
+ * Filters `entries` to those matching `method`, then composes them
133
+ * so the first registered middleware is the outermost layer.
134
+ * `next()` is guarded against multiple calls within a single middleware.
135
+ */
136
+ export declare function buildMiddlewareChain(method: string, isNotification: boolean, originalHandler: (...args: unknown[]) => Promise<unknown>, entries: McpMiddlewareEntry[]): (...args: unknown[]) => Promise<unknown>;
137
+ export {};
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Extract the TS-private `_requestHandlers` and `_notificationHandlers` maps
3
+ * from the SDK's `Server` (extends `Protocol`). These are runtime-accessible
4
+ * but declared `private` in TypeScript.
5
+ *
6
+ * Validates with `instanceof Map` so an incompatible SDK version fails fast
7
+ * instead of silently breaking.
8
+ */
9
+ export function getHandlerMaps(server) {
10
+ const obj = server;
11
+ if (!("_requestHandlers" in obj && obj._requestHandlers instanceof Map) ||
12
+ !("_notificationHandlers" in obj && obj._notificationHandlers instanceof Map)) {
13
+ throw new Error("Incompatible MCP SDK version: expected _requestHandlers and _notificationHandlers on Server");
14
+ }
15
+ return {
16
+ requestHandlers: obj._requestHandlers,
17
+ notificationHandlers: obj._notificationHandlers,
18
+ };
19
+ }
20
+ /**
21
+ * Check if a single filter pattern matches a given method.
22
+ *
23
+ * - Exact: `"tools/call"` matches only `"tools/call"`
24
+ * - Wildcard: `"tools/*"` matches any method starting with `"tools/"`
25
+ * - Category `"request"`: matches when `isNotification` is false
26
+ * - Category `"notification"`: matches when `isNotification` is true
27
+ */
28
+ export function matchesFilter(method, filter, isNotification) {
29
+ if (filter === "request") {
30
+ return !isNotification;
31
+ }
32
+ if (filter === "notification") {
33
+ return isNotification;
34
+ }
35
+ if (filter.endsWith("/*")) {
36
+ const prefix = filter.slice(0, -1); // "tools/*" → "tools/"
37
+ return method.startsWith(prefix);
38
+ }
39
+ return method === filter;
40
+ }
41
+ function matchesAnyFilter(method, filter, isNotification) {
42
+ if (filter === null) {
43
+ return true;
44
+ }
45
+ if (typeof filter === "string") {
46
+ return matchesFilter(method, filter, isNotification);
47
+ }
48
+ return filter.some((pattern) => matchesFilter(method, pattern, isNotification));
49
+ }
50
+ /**
51
+ * Build an onion-model middleware chain for a specific method.
52
+ *
53
+ * Filters `entries` to those matching `method`, then composes them
54
+ * so the first registered middleware is the outermost layer.
55
+ * `next()` is guarded against multiple calls within a single middleware.
56
+ */
57
+ export function buildMiddlewareChain(method, isNotification, originalHandler, entries) {
58
+ const applicable = entries.filter((entry) => matchesAnyFilter(method, entry.filter, isNotification));
59
+ if (applicable.length === 0) {
60
+ return originalHandler;
61
+ }
62
+ return (...args) => {
63
+ const rawRequest = args[0];
64
+ // SDK calls request handlers as handler(request, extra) but
65
+ // notification handlers as handler(notification) — no extra arg.
66
+ const extra = isNotification ? undefined : args[1];
67
+ const mcpRequest = {
68
+ method,
69
+ params: rawRequest?.params ?? {},
70
+ };
71
+ let index = 0;
72
+ const executeLayer = () => {
73
+ const entry = applicable[index++];
74
+ if (!entry) {
75
+ if (rawRequest) {
76
+ rawRequest.params = mcpRequest.params;
77
+ }
78
+ return originalHandler(...args);
79
+ }
80
+ let nextCalled = false;
81
+ const next = () => {
82
+ if (nextCalled) {
83
+ throw new Error(`next() called multiple times in middleware for "${method}"`);
84
+ }
85
+ nextCalled = true;
86
+ return executeLayer();
87
+ };
88
+ return Promise.resolve(entry.handler(mcpRequest, extra, next));
89
+ };
90
+ return executeLayer();
91
+ };
92
+ }
93
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport type {\n CallToolResult,\n CancelTaskResult,\n ClientNotification,\n ClientRequest,\n CompleteResult,\n EmptyResult,\n GetPromptResult,\n GetTaskPayloadResult,\n GetTaskResult,\n InitializeResult,\n ListPromptsResult,\n ListResourcesResult,\n ListResourceTemplatesResult,\n ListTasksResult,\n ListToolsResult,\n ReadResourceResult,\n ServerNotification,\n ServerRequest,\n ServerResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\n\n/**\n * The `extra` context object provided by the MCP SDK to request handlers.\n */\nexport type McpExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;\n\n/**\n * A single MCP middleware function following the onion model.\n * Call `next()` to invoke the next middleware or the final handler.\n * For notifications, `extra` is `undefined` (SDK does not provide extra context)\n * and `next()` resolves to `undefined`.\n */\nexport type McpMiddlewareFn = (\n request: { method: string; params: Record<string, unknown> },\n extra: McpExtra | undefined,\n next: () => Promise<unknown>,\n) => Promise<unknown> | unknown;\n\n/**\n * MCP methods the server handles (incoming from client).\n */\nexport type McpMethodString =\n | ClientRequest[\"method\"]\n | ClientNotification[\"method\"];\n\n/**\n * Resolve the `params` type for a specific MCP method (request or notification)\n * from the SDK's typed unions. Falls back to `Record<string, unknown>` for\n * unknown methods. Used by {@link McpTypedMiddlewareFn} to narrow the request\n * shape in typed middleware.\n */\nexport type McpRequestParams<M extends string> =\n Extract<ClientRequest, { method: M }> extends { params: infer P }\n ? P\n : Extract<ClientNotification, { method: M }> extends { params: infer P }\n ? P\n : Record<string, unknown>;\n\n/**\n * Resolve the `extra` arg type for a specific MCP method: {@link McpExtra} for\n * request methods, `undefined` for notification methods (the SDK does not\n * pass extra context for notifications).\n */\nexport type McpExtraFor<M extends string> = M extends ClientRequest[\"method\"]\n ? McpExtra\n : M extends ClientNotification[\"method\"]\n ? undefined\n : McpExtra | undefined;\n\n/** Maps each MCP request method to its SDK result type. */\ninterface McpResultMap {\n ping: EmptyResult;\n initialize: InitializeResult;\n \"tools/list\": ListToolsResult;\n \"tools/call\": CallToolResult;\n \"resources/list\": ListResourcesResult;\n \"resources/templates/list\": ListResourceTemplatesResult;\n \"resources/read\": ReadResourceResult;\n \"resources/subscribe\": EmptyResult;\n \"resources/unsubscribe\": EmptyResult;\n \"prompts/list\": ListPromptsResult;\n \"prompts/get\": GetPromptResult;\n \"completion/complete\": CompleteResult;\n \"logging/setLevel\": EmptyResult;\n \"tasks/get\": GetTaskResult;\n \"tasks/result\": GetTaskPayloadResult;\n \"tasks/list\": ListTasksResult;\n \"tasks/cancel\": CancelTaskResult;\n}\n\n/**\n * Map an MCP method string to its corresponding result type.\n * For request methods, resolves to the specific SDK result type.\n * For wildcard patterns (e.g. `\"tools/*\"`), resolves to the union of matching result types.\n * For notification methods, resolves to `undefined`.\n * For unknown/unmatched methods, falls back to `ServerResult`.\n */\nexport type McpResultFor<M extends string> = M extends keyof McpResultMap\n ? McpResultMap[M]\n : M extends `${infer Prefix}/*`\n ? [McpResultMap[keyof McpResultMap & `${Prefix}/${string}`]] extends [never]\n ? M extends ToWildcard<ClientNotification[\"method\"]>\n ? undefined\n : ServerResult\n : McpResultMap[keyof McpResultMap & `${Prefix}/${string}`]\n : M extends ClientNotification[\"method\"]\n ? undefined\n : ServerResult;\n\n/**\n * Typed middleware function for a specific method. Narrows `request.params`\n * via {@link McpRequestParams}, `extra` via {@link McpExtraFor}, and the\n * resolved value of `next()` via {@link McpResultFor}.\n */\nexport type McpTypedMiddlewareFn<M extends string> = (\n request: { method: M; params: McpRequestParams<M> },\n extra: McpExtraFor<M>,\n next: () => Promise<McpResultFor<M>>,\n) => Promise<unknown> | unknown;\n\n/** Extracts `\"prefix/*\"` from `\"prefix/anything\"` — distributive over unions. */\ntype ToWildcard<T extends string> = T extends `${infer Prefix}/${string}`\n ? `${Prefix}/*`\n : never;\n\n/** Wildcard prefixes derived from method strings (e.g. `\"tools/*\"` from `\"tools/call\"`). */\nexport type McpWildcard = ToWildcard<McpMethodString>;\n\n/** Category keywords matching all requests or all notifications. */\ntype McpCategory = \"request\" | \"notification\";\n\n/**\n * A single filter pattern for MCP middleware:\n * - Exact method: `\"tools/call\"`\n * - Wildcard: `\"tools/*\"`\n * - Category: `\"request\"` | `\"notification\"`\n * - Escape hatch: arbitrary string via `string & {}`\n */\ntype McpMiddlewareFilterPattern =\n | McpMethodString\n | McpWildcard\n | McpCategory\n | (string & {});\n\n/**\n * Filter determining which MCP methods a middleware applies to.\n * A single pattern or an array of patterns (OR logic).\n */\nexport type McpMiddlewareFilter =\n | McpMiddlewareFilterPattern\n | McpMiddlewareFilterPattern[];\n\n/**\n * Internal entry stored for each registered middleware.\n * `filter: null` means catch-all (matches everything).\n */\nexport type McpMiddlewareEntry = {\n filter: McpMiddlewareFilter | null;\n handler: McpMiddlewareFn;\n};\n\ntype HandlerMap = Map<string, (...args: unknown[]) => Promise<unknown>>;\n\n/**\n * Extract the TS-private `_requestHandlers` and `_notificationHandlers` maps\n * from the SDK's `Server` (extends `Protocol`). These are runtime-accessible\n * but declared `private` in TypeScript.\n *\n * Validates with `instanceof Map` so an incompatible SDK version fails fast\n * instead of silently breaking.\n */\nexport function getHandlerMaps(server: Server) {\n const obj: object = server;\n\n if (\n !(\"_requestHandlers\" in obj && obj._requestHandlers instanceof Map) ||\n !(\n \"_notificationHandlers\" in obj && obj._notificationHandlers instanceof Map\n )\n ) {\n throw new Error(\n \"Incompatible MCP SDK version: expected _requestHandlers and _notificationHandlers on Server\",\n );\n }\n\n return {\n requestHandlers: obj._requestHandlers as HandlerMap,\n notificationHandlers: obj._notificationHandlers as HandlerMap,\n };\n}\n\n/**\n * Check if a single filter pattern matches a given method.\n *\n * - Exact: `\"tools/call\"` matches only `\"tools/call\"`\n * - Wildcard: `\"tools/*\"` matches any method starting with `\"tools/\"`\n * - Category `\"request\"`: matches when `isNotification` is false\n * - Category `\"notification\"`: matches when `isNotification` is true\n */\nexport function matchesFilter(\n method: string,\n filter: string,\n isNotification: boolean,\n): boolean {\n if (filter === \"request\") {\n return !isNotification;\n }\n if (filter === \"notification\") {\n return isNotification;\n }\n if (filter.endsWith(\"/*\")) {\n const prefix = filter.slice(0, -1); // \"tools/*\" → \"tools/\"\n return method.startsWith(prefix);\n }\n return method === filter;\n}\n\nfunction matchesAnyFilter(\n method: string,\n filter: McpMiddlewareFilter | null,\n isNotification: boolean,\n): boolean {\n if (filter === null) {\n return true;\n }\n if (typeof filter === \"string\") {\n return matchesFilter(method, filter, isNotification);\n }\n return filter.some((pattern) =>\n matchesFilter(method, pattern, isNotification),\n );\n}\n\n/**\n * Build an onion-model middleware chain for a specific method.\n *\n * Filters `entries` to those matching `method`, then composes them\n * so the first registered middleware is the outermost layer.\n * `next()` is guarded against multiple calls within a single middleware.\n */\nexport function buildMiddlewareChain(\n method: string,\n isNotification: boolean,\n originalHandler: (...args: unknown[]) => Promise<unknown>,\n entries: McpMiddlewareEntry[],\n) {\n const applicable = entries.filter((entry) =>\n matchesAnyFilter(method, entry.filter, isNotification),\n );\n\n if (applicable.length === 0) {\n return originalHandler;\n }\n\n return (...args: unknown[]) => {\n const rawRequest = args[0] as Record<string, unknown> | undefined;\n // SDK calls request handlers as handler(request, extra) but\n // notification handlers as handler(notification) — no extra arg.\n const extra = isNotification ? undefined : (args[1] as McpExtra);\n const mcpRequest = {\n method,\n params: (rawRequest?.params as Record<string, unknown>) ?? {},\n };\n\n let index = 0;\n\n const executeLayer = (): Promise<unknown> => {\n const entry = applicable[index++];\n if (!entry) {\n if (rawRequest) {\n rawRequest.params = mcpRequest.params;\n }\n return originalHandler(...args);\n }\n\n let nextCalled = false;\n\n const next = (): Promise<unknown> => {\n if (nextCalled) {\n throw new Error(\n `next() called multiple times in middleware for \"${method}\"`,\n );\n }\n nextCalled = true;\n return executeLayer();\n };\n\n return Promise.resolve(entry.handler(mcpRequest, extra, next));\n };\n\n return executeLayer();\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,75 @@
1
+ import { expectTypeOf, test } from "vitest";
2
+ const server = null;
3
+ test("request category narrows extra and next() result", () => {
4
+ server.mcpMiddleware("request", async (_request, extra, next) => {
5
+ expectTypeOf(extra).toEqualTypeOf();
6
+ extra.signal;
7
+ const result = await next();
8
+ expectTypeOf(result).toEqualTypeOf();
9
+ return result;
10
+ });
11
+ });
12
+ test("notification category narrows extra and next() result", () => {
13
+ server.mcpMiddleware("notification", async (_request, extra, next) => {
14
+ expectTypeOf(extra).toEqualTypeOf();
15
+ // @ts-expect-error extra is undefined, cannot access .signal
16
+ extra.signal;
17
+ const result = await next();
18
+ expectTypeOf(result).toEqualTypeOf();
19
+ });
20
+ });
21
+ test("exact method tools/call narrows params, extra, and next() result", () => {
22
+ server.mcpMiddleware("tools/call", async (request, extra, next) => {
23
+ expectTypeOf(request.params.name).toBeString();
24
+ expectTypeOf(extra).toEqualTypeOf();
25
+ const result = await next();
26
+ expectTypeOf(result).toEqualTypeOf();
27
+ return result;
28
+ });
29
+ });
30
+ test("exact method tools/list narrows next() to ListToolsResult", () => {
31
+ server.mcpMiddleware("tools/list", async (_request, _extra, next) => {
32
+ const result = await next();
33
+ expectTypeOf(result).toEqualTypeOf();
34
+ return result;
35
+ });
36
+ });
37
+ test("exact notification method narrows extra and next() result", () => {
38
+ server.mcpMiddleware("notifications/initialized", async (_request, extra, next) => {
39
+ expectTypeOf(extra).toEqualTypeOf();
40
+ // @ts-expect-error extra is undefined
41
+ extra.signal;
42
+ const result = await next();
43
+ expectTypeOf(result).toEqualTypeOf();
44
+ });
45
+ });
46
+ test("McpTypedMiddlewareFn narrows params, extra, and next() per method", () => {
47
+ expectTypeOf().toBeString();
48
+ expectTypeOf().toEqualTypeOf();
49
+ expectTypeOf().toEqualTypeOf();
50
+ expectTypeOf().toEqualTypeOf();
51
+ expectTypeOf().toEqualTypeOf();
52
+ });
53
+ test("McpResultFor maps methods to correct result types", () => {
54
+ expectTypeOf().toEqualTypeOf();
55
+ expectTypeOf().toEqualTypeOf();
56
+ expectTypeOf().toEqualTypeOf();
57
+ });
58
+ test("wildcard tools/* narrows next() to union of tools result types", () => {
59
+ server.mcpMiddleware("tools/*", async (_request, _extra, next) => {
60
+ const result = await next();
61
+ expectTypeOf(result).toEqualTypeOf();
62
+ return result;
63
+ });
64
+ });
65
+ test("McpResultFor resolves wildcards to union of matching result types", () => {
66
+ expectTypeOf().toEqualTypeOf();
67
+ });
68
+ test("catch-all middleware has no narrowing on extra or params", () => {
69
+ server.mcpMiddleware((_request, extra, next) => {
70
+ expectTypeOf(extra).toEqualTypeOf();
71
+ expectTypeOf(_request.params).toEqualTypeOf();
72
+ return next();
73
+ });
74
+ });
75
+ //# sourceMappingURL=middleware.test-d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.test-d.js","sourceRoot":"","sources":["../../src/server/middleware.test-d.ts"],"names":[],"mappings":"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","sourcesContent":["import type {\n CallToolResult,\n ListToolsResult,\n ServerResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { expectTypeOf, test } from \"vitest\";\nimport type {\n McpExtra,\n McpResultFor,\n McpTypedMiddlewareFn,\n} from \"./middleware.js\";\nimport type { McpServer } from \"./server.js\";\n\nconst server = null as unknown as McpServer;\n\ntest(\"request category narrows extra and next() result\", () => {\n server.mcpMiddleware(\"request\", async (_request, extra, next) => {\n expectTypeOf(extra).toEqualTypeOf<McpExtra>();\n extra.signal;\n const result = await next();\n expectTypeOf(result).toEqualTypeOf<ServerResult>();\n return result;\n });\n});\n\ntest(\"notification category narrows extra and next() result\", () => {\n server.mcpMiddleware(\"notification\", async (_request, extra, next) => {\n expectTypeOf(extra).toEqualTypeOf<undefined>();\n // @ts-expect-error extra is undefined, cannot access .signal\n extra.signal;\n const result = await next();\n expectTypeOf(result).toEqualTypeOf<undefined>();\n });\n});\n\ntest(\"exact method tools/call narrows params, extra, and next() result\", () => {\n server.mcpMiddleware(\"tools/call\", async (request, extra, next) => {\n expectTypeOf(request.params.name).toBeString();\n expectTypeOf(extra).toEqualTypeOf<McpExtra>();\n const result = await next();\n expectTypeOf(result).toEqualTypeOf<CallToolResult>();\n return result;\n });\n});\n\ntest(\"exact method tools/list narrows next() to ListToolsResult\", () => {\n server.mcpMiddleware(\"tools/list\", async (_request, _extra, next) => {\n const result = await next();\n expectTypeOf(result).toEqualTypeOf<ListToolsResult>();\n return result;\n });\n});\n\ntest(\"exact notification method narrows extra and next() result\", () => {\n server.mcpMiddleware(\n \"notifications/initialized\",\n async (_request, extra, next) => {\n expectTypeOf(extra).toEqualTypeOf<undefined>();\n // @ts-expect-error extra is undefined\n extra.signal;\n const result = await next();\n expectTypeOf(result).toEqualTypeOf<undefined>();\n },\n );\n});\n\ntest(\"McpTypedMiddlewareFn narrows params, extra, and next() per method\", () => {\n expectTypeOf<\n Parameters<McpTypedMiddlewareFn<\"tools/call\">>[0][\"params\"][\"name\"]\n >().toBeString();\n expectTypeOf<\n Parameters<McpTypedMiddlewareFn<\"tools/call\">>[1]\n >().toEqualTypeOf<McpExtra>();\n expectTypeOf<\n Parameters<McpTypedMiddlewareFn<\"notifications/initialized\">>[1]\n >().toEqualTypeOf<undefined>();\n expectTypeOf<\n ReturnType<Parameters<McpTypedMiddlewareFn<\"tools/list\">>[2]>\n >().toEqualTypeOf<Promise<ListToolsResult>>();\n expectTypeOf<\n ReturnType<Parameters<McpTypedMiddlewareFn<\"notifications/initialized\">>[2]>\n >().toEqualTypeOf<Promise<undefined>>();\n});\n\ntest(\"McpResultFor maps methods to correct result types\", () => {\n expectTypeOf<McpResultFor<\"tools/list\">>().toEqualTypeOf<ListToolsResult>();\n expectTypeOf<McpResultFor<\"tools/call\">>().toEqualTypeOf<CallToolResult>();\n expectTypeOf<\n McpResultFor<\"notifications/initialized\">\n >().toEqualTypeOf<undefined>();\n});\n\ntest(\"wildcard tools/* narrows next() to union of tools result types\", () => {\n server.mcpMiddleware(\"tools/*\", async (_request, _extra, next) => {\n const result = await next();\n expectTypeOf(result).toEqualTypeOf<ListToolsResult | CallToolResult>();\n return result;\n });\n});\n\ntest(\"McpResultFor resolves wildcards to union of matching result types\", () => {\n expectTypeOf<McpResultFor<\"tools/*\">>().toEqualTypeOf<\n ListToolsResult | CallToolResult\n >();\n});\n\ntest(\"catch-all middleware has no narrowing on extra or params\", () => {\n server.mcpMiddleware((_request, extra, next) => {\n expectTypeOf(extra).toEqualTypeOf<McpExtra | undefined>();\n expectTypeOf(_request.params).toEqualTypeOf<Record<string, unknown>>();\n return next();\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};