@casys/mcp-server 0.26.0 → 0.27.0

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 (299) hide show
  1. package/CHANGELOG.md +1779 -0
  2. package/LICENSE +21 -0
  3. package/README.md +19 -5
  4. package/esm/_dnt.polyfills.d.ts +12 -0
  5. package/esm/_dnt.polyfills.d.ts.map +1 -0
  6. package/esm/_dnt.polyfills.js +15 -0
  7. package/esm/_dnt.shims.d.ts +2 -0
  8. package/esm/_dnt.shims.d.ts.map +1 -0
  9. package/esm/_dnt.shims.js +57 -0
  10. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts +33 -0
  11. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts.map +1 -0
  12. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.js +48 -0
  13. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts +106 -0
  14. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.js +636 -0
  16. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts +67 -0
  17. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts.map +1 -0
  18. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.js +1393 -0
  19. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts +44 -0
  20. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts.map +1 -0
  21. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.js +117 -0
  22. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts +3 -0
  23. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts.map +1 -0
  24. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.js +103 -0
  25. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts +3 -0
  26. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.js +32 -0
  28. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts +3 -0
  29. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts.map +1 -0
  30. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.js +96 -0
  31. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts +3 -0
  32. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts.map +1 -0
  33. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.js +159 -0
  34. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts +3 -0
  35. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.js +14 -0
  37. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts +3 -0
  38. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.js +10 -0
  40. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts +3 -0
  41. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts.map +1 -0
  42. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.js +22 -0
  43. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts +3 -0
  44. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts.map +1 -0
  45. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.js +29 -0
  46. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts +3 -0
  47. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts.map +1 -0
  48. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.js +19 -0
  49. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts +3 -0
  50. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.js +30 -0
  52. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts +3 -0
  53. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts.map +1 -0
  54. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.js +10 -0
  55. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts +3 -0
  56. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts.map +1 -0
  57. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.js +14 -0
  58. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts +3 -0
  59. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts.map +1 -0
  60. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.js +9 -0
  61. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts +3 -0
  62. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.js +81 -0
  64. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts +3 -0
  65. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts.map +1 -0
  66. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.js +20 -0
  67. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts +32 -0
  68. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts.map +1 -0
  69. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.js +6 -0
  70. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts +4 -0
  71. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.js +13 -0
  73. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts +51 -0
  74. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.js +53 -0
  76. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts +79 -0
  77. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts.map +1 -0
  78. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.js +91 -0
  79. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts +100 -0
  80. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts.map +1 -0
  81. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.js +33 -0
  82. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts +111 -0
  83. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts.map +1 -0
  84. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.js +104 -0
  85. package/esm/mod.d.ts +102 -0
  86. package/esm/mod.d.ts.map +1 -0
  87. package/esm/mod.js +103 -0
  88. package/esm/package.json +3 -0
  89. package/esm/src/auth/as-metadata-proxy.d.ts +112 -0
  90. package/esm/src/auth/as-metadata-proxy.d.ts.map +1 -0
  91. package/esm/src/auth/as-metadata-proxy.js +171 -0
  92. package/esm/src/auth/config.d.ts +117 -0
  93. package/esm/src/auth/config.d.ts.map +1 -0
  94. package/esm/src/auth/config.js +219 -0
  95. package/esm/src/auth/jwt-provider.d.ts +157 -0
  96. package/esm/src/auth/jwt-provider.d.ts.map +1 -0
  97. package/esm/src/auth/jwt-provider.js +187 -0
  98. package/esm/src/auth/middleware.d.ts +61 -0
  99. package/esm/src/auth/middleware.d.ts.map +1 -0
  100. package/esm/src/auth/middleware.js +209 -0
  101. package/esm/src/auth/mod.d.ts +23 -0
  102. package/esm/src/auth/mod.d.ts.map +1 -0
  103. package/esm/src/auth/mod.js +27 -0
  104. package/esm/src/auth/multi-tenant-middleware.d.ts +131 -0
  105. package/esm/src/auth/multi-tenant-middleware.d.ts.map +1 -0
  106. package/esm/src/auth/multi-tenant-middleware.js +128 -0
  107. package/esm/src/auth/presets.d.ts +231 -0
  108. package/esm/src/auth/presets.d.ts.map +1 -0
  109. package/esm/src/auth/presets.js +223 -0
  110. package/{src/auth/provider.ts → esm/src/auth/provider.d.ts} +13 -15
  111. package/esm/src/auth/provider.d.ts.map +1 -0
  112. package/esm/src/auth/provider.js +34 -0
  113. package/esm/src/auth/scope-middleware.d.ts +30 -0
  114. package/esm/src/auth/scope-middleware.d.ts.map +1 -0
  115. package/esm/src/auth/scope-middleware.js +48 -0
  116. package/esm/src/auth/static-token-provider.d.ts +155 -0
  117. package/esm/src/auth/static-token-provider.d.ts.map +1 -0
  118. package/esm/src/auth/static-token-provider.js +256 -0
  119. package/esm/src/auth/types.d.ts +151 -0
  120. package/esm/src/auth/types.d.ts.map +1 -0
  121. package/esm/src/auth/types.js +64 -0
  122. package/esm/src/client-auth/callback-server.d.ts +34 -0
  123. package/esm/src/client-auth/callback-server.d.ts.map +1 -0
  124. package/esm/src/client-auth/callback-server.js +141 -0
  125. package/esm/src/client-auth/client-id-metadata.d.ts +29 -0
  126. package/esm/src/client-auth/client-id-metadata.d.ts.map +1 -0
  127. package/esm/src/client-auth/client-id-metadata.js +149 -0
  128. package/esm/src/client-auth/connect.d.ts +32 -0
  129. package/esm/src/client-auth/connect.d.ts.map +1 -0
  130. package/esm/src/client-auth/connect.js +47 -0
  131. package/esm/src/client-auth/mod.d.ts +19 -0
  132. package/esm/src/client-auth/mod.d.ts.map +1 -0
  133. package/{src/client-auth/mod.ts → esm/src/client-auth/mod.js} +1 -26
  134. package/esm/src/client-auth/provider.d.ts +78 -0
  135. package/esm/src/client-auth/provider.d.ts.map +1 -0
  136. package/esm/src/client-auth/provider.js +246 -0
  137. package/esm/src/client-auth/token-store/file-store.d.ts +20 -0
  138. package/esm/src/client-auth/token-store/file-store.d.ts.map +1 -0
  139. package/esm/src/client-auth/token-store/file-store.js +62 -0
  140. package/esm/src/client-auth/token-store/memory-store.d.ts +14 -0
  141. package/esm/src/client-auth/token-store/memory-store.d.ts.map +1 -0
  142. package/esm/src/client-auth/token-store/memory-store.js +25 -0
  143. package/esm/src/client-auth/types.d.ts +89 -0
  144. package/esm/src/client-auth/types.d.ts.map +1 -0
  145. package/esm/src/client-auth/types.js +10 -0
  146. package/esm/src/concurrency/rate-limiter.d.ts +87 -0
  147. package/esm/src/concurrency/rate-limiter.d.ts.map +1 -0
  148. package/esm/src/concurrency/rate-limiter.js +165 -0
  149. package/esm/src/concurrency/request-queue.d.ts +71 -0
  150. package/esm/src/concurrency/request-queue.d.ts.map +1 -0
  151. package/esm/src/concurrency/request-queue.js +128 -0
  152. package/esm/src/http/body.d.ts +20 -0
  153. package/esm/src/http/body.d.ts.map +1 -0
  154. package/esm/src/http/body.js +63 -0
  155. package/esm/src/http/request-guards.d.ts +54 -0
  156. package/esm/src/http/request-guards.d.ts.map +1 -0
  157. package/esm/src/http/request-guards.js +114 -0
  158. package/esm/src/http/wire.d.ts +26 -0
  159. package/esm/src/http/wire.d.ts.map +1 -0
  160. package/{src/http/wire.ts → esm/src/http/wire.js} +13 -19
  161. package/esm/src/inspector/launcher.d.ts +48 -0
  162. package/esm/src/inspector/launcher.d.ts.map +1 -0
  163. package/esm/src/inspector/launcher.js +100 -0
  164. package/esm/src/mcp-app.d.ts +728 -0
  165. package/esm/src/mcp-app.d.ts.map +1 -0
  166. package/esm/src/mcp-app.js +3530 -0
  167. package/{src/middleware/backpressure.ts → esm/src/middleware/backpressure.d.ts} +2 -14
  168. package/esm/src/middleware/backpressure.d.ts.map +1 -0
  169. package/esm/src/middleware/backpressure.js +31 -0
  170. package/esm/src/middleware/mod.d.ts +11 -0
  171. package/esm/src/middleware/mod.d.ts.map +1 -0
  172. package/{src/middleware/mod.ts → esm/src/middleware/mod.js} +0 -10
  173. package/{src/middleware/rate-limit.ts → esm/src/middleware/rate-limit.d.ts} +2 -25
  174. package/esm/src/middleware/rate-limit.d.ts.map +1 -0
  175. package/esm/src/middleware/rate-limit.js +33 -0
  176. package/esm/src/middleware/runner.d.ts +32 -0
  177. package/esm/src/middleware/runner.d.ts.map +1 -0
  178. package/esm/src/middleware/runner.js +49 -0
  179. package/esm/src/middleware/types.d.ts +76 -0
  180. package/esm/src/middleware/types.d.ts.map +1 -0
  181. package/esm/src/middleware/types.js +9 -0
  182. package/esm/src/middleware/validation.d.ts +24 -0
  183. package/esm/src/middleware/validation.d.ts.map +1 -0
  184. package/esm/src/middleware/validation.js +30 -0
  185. package/esm/src/mrtr/capability-check.d.ts +75 -0
  186. package/esm/src/mrtr/capability-check.d.ts.map +1 -0
  187. package/esm/src/mrtr/capability-check.js +233 -0
  188. package/esm/src/mrtr/mod.d.ts +18 -0
  189. package/esm/src/mrtr/mod.d.ts.map +1 -0
  190. package/esm/src/mrtr/mod.js +12 -0
  191. package/esm/src/mrtr/replay-store.d.ts +50 -0
  192. package/esm/src/mrtr/replay-store.d.ts.map +1 -0
  193. package/esm/src/mrtr/replay-store.js +61 -0
  194. package/esm/src/mrtr/request-state.d.ts +181 -0
  195. package/esm/src/mrtr/request-state.d.ts.map +1 -0
  196. package/esm/src/mrtr/request-state.js +313 -0
  197. package/esm/src/mrtr/retry-guard.d.ts +61 -0
  198. package/esm/src/mrtr/retry-guard.d.ts.map +1 -0
  199. package/esm/src/mrtr/retry-guard.js +53 -0
  200. package/esm/src/mrtr/types.d.ts +99 -0
  201. package/esm/src/mrtr/types.d.ts.map +1 -0
  202. package/esm/src/mrtr/types.js +14 -0
  203. package/esm/src/observability/metrics.d.ts +104 -0
  204. package/esm/src/observability/metrics.d.ts.map +1 -0
  205. package/esm/src/observability/metrics.js +207 -0
  206. package/{src/observability/mod.ts → esm/src/observability/mod.d.ts} +2 -11
  207. package/esm/src/observability/mod.d.ts.map +1 -0
  208. package/esm/src/observability/mod.js +11 -0
  209. package/esm/src/observability/otel.d.ts +73 -0
  210. package/esm/src/observability/otel.d.ts.map +1 -0
  211. package/esm/src/observability/otel.js +260 -0
  212. package/esm/src/runtime/runtime.d.ts +10 -0
  213. package/esm/src/runtime/runtime.d.ts.map +1 -0
  214. package/esm/src/runtime/runtime.deno.d.ts +50 -0
  215. package/esm/src/runtime/runtime.deno.d.ts.map +1 -0
  216. package/esm/src/runtime/runtime.deno.js +120 -0
  217. package/{src/runtime/runtime.ts → esm/src/runtime/runtime.js} +5 -14
  218. package/esm/src/runtime/runtime.node.d.ts +51 -0
  219. package/esm/src/runtime/runtime.node.d.ts.map +1 -0
  220. package/esm/src/runtime/runtime.node.js +268 -0
  221. package/{src/runtime/types.ts → esm/src/runtime/types.d.ts} +28 -51
  222. package/esm/src/runtime/types.d.ts.map +1 -0
  223. package/esm/src/runtime/types.js +12 -0
  224. package/esm/src/security/channel-hmac.d.ts +43 -0
  225. package/esm/src/security/channel-hmac.d.ts.map +1 -0
  226. package/{src/security/channel-hmac.ts → esm/src/security/channel-hmac.js} +12 -17
  227. package/esm/src/security/csp.d.ts +50 -0
  228. package/esm/src/security/csp.d.ts.map +1 -0
  229. package/esm/src/security/csp.js +63 -0
  230. package/esm/src/security/message-signer.d.ts +88 -0
  231. package/esm/src/security/message-signer.d.ts.map +1 -0
  232. package/esm/src/security/message-signer.js +166 -0
  233. package/esm/src/subscriptions/subscription-registry.d.ts +256 -0
  234. package/esm/src/subscriptions/subscription-registry.d.ts.map +1 -0
  235. package/esm/src/subscriptions/subscription-registry.js +406 -0
  236. package/{src/tasks/mod.ts → esm/src/tasks/mod.d.ts} +3 -23
  237. package/esm/src/tasks/mod.d.ts.map +1 -0
  238. package/esm/src/tasks/mod.js +11 -0
  239. package/esm/src/tasks/task-store.d.ts +342 -0
  240. package/esm/src/tasks/task-store.d.ts.map +1 -0
  241. package/esm/src/tasks/task-store.js +649 -0
  242. package/esm/src/transport/request-headers.d.ts +145 -0
  243. package/esm/src/transport/request-headers.d.ts.map +1 -0
  244. package/esm/src/transport/request-headers.js +525 -0
  245. package/esm/src/types.d.ts +776 -0
  246. package/esm/src/types.d.ts.map +1 -0
  247. package/esm/src/types.js +92 -0
  248. package/esm/src/ui/viewer-utils.d.ts +45 -0
  249. package/esm/src/ui/viewer-utils.d.ts.map +1 -0
  250. package/esm/src/ui/viewer-utils.js +97 -0
  251. package/esm/src/validation/schema-validator.d.ts +115 -0
  252. package/esm/src/validation/schema-validator.d.ts.map +1 -0
  253. package/esm/src/validation/schema-validator.js +249 -0
  254. package/package.json +35 -23
  255. package/mod.ts +0 -302
  256. package/src/auth/as-metadata-proxy.ts +0 -288
  257. package/src/auth/config.ts +0 -368
  258. package/src/auth/jwt-provider.ts +0 -327
  259. package/src/auth/middleware.ts +0 -257
  260. package/src/auth/mod.ts +0 -89
  261. package/src/auth/multi-tenant-middleware.ts +0 -236
  262. package/src/auth/presets.ts +0 -351
  263. package/src/auth/scope-middleware.ts +0 -59
  264. package/src/auth/static-token-provider.ts +0 -197
  265. package/src/auth/types.ts +0 -207
  266. package/src/client-auth/callback-server.ts +0 -166
  267. package/src/client-auth/client-id-metadata.ts +0 -260
  268. package/src/client-auth/connect.ts +0 -72
  269. package/src/client-auth/provider.ts +0 -300
  270. package/src/client-auth/token-store/file-store.ts +0 -73
  271. package/src/client-auth/token-store/memory-store.ts +0 -32
  272. package/src/client-auth/types.ts +0 -95
  273. package/src/concurrency/rate-limiter.ts +0 -190
  274. package/src/concurrency/request-queue.ts +0 -140
  275. package/src/http/body.ts +0 -72
  276. package/src/http/request-guards.ts +0 -137
  277. package/src/inspector/launcher.ts +0 -131
  278. package/src/mcp-app.ts +0 -4426
  279. package/src/middleware/runner.ts +0 -63
  280. package/src/middleware/types.ts +0 -104
  281. package/src/middleware/validation.ts +0 -28
  282. package/src/mrtr/capability-check.ts +0 -303
  283. package/src/mrtr/mod.ts +0 -46
  284. package/src/mrtr/replay-store.ts +0 -103
  285. package/src/mrtr/request-state.ts +0 -435
  286. package/src/mrtr/types.ts +0 -107
  287. package/src/observability/metrics.ts +0 -336
  288. package/src/observability/otel.ts +0 -330
  289. package/src/runtime/runtime.deno.ts +0 -149
  290. package/src/runtime/runtime.node.ts +0 -324
  291. package/src/security/csp.ts +0 -89
  292. package/src/security/message-signer.ts +0 -223
  293. package/src/subscriptions/subscription-registry.ts +0 -558
  294. package/src/tasks/task-store.ts +0 -1014
  295. package/src/testdata/stdio-e2e-server.ts +0 -110
  296. package/src/transport/request-headers.ts +0 -661
  297. package/src/types.ts +0 -907
  298. package/src/ui/viewer-utils.ts +0 -117
  299. package/src/validation/schema-validator.ts +0 -307
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IAEpB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC;IAErD;;;;OAIG;IACH,eAAe,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IAEjB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IAEb,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB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AM,EAAE,KAAK,GAAG,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;KACzD,CAAC,CAAC;IAEH;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAE9D;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;CAC3D;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC/B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B,0BAA0B;IAC1B,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Type definitions for the MCP Concurrent Server Framework
3
+ *
4
+ * This module provides TypeScript types for building high-performance
5
+ * MCP servers with built-in concurrency control and backpressure.
6
+ *
7
+ * @module lib/server/types
8
+ */
9
+ /** MCP Apps MIME type constant */
10
+ export const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";
11
+ /** URI scheme for MCP Apps resources */
12
+ export const MCP_APP_URI_SCHEME = "ui:";
13
+ /**
14
+ * Well-known extension identifier for the MCP Apps protocol.
15
+ *
16
+ * Clients advertise MCP Apps support by including this key in
17
+ * `clientCapabilities.extensions` (per the MCP SDK 1.29 extensions
18
+ * feature). Servers read it via {@link getMcpAppsCapability} to decide
19
+ * whether to register UI-rendering tools or fall back to text-only.
20
+ *
21
+ * @see {@link https://github.com/modelcontextprotocol/ext-apps | MCP Apps spec}
22
+ */
23
+ export const MCP_APPS_EXTENSION_ID = "io.modelcontextprotocol/ui";
24
+ /**
25
+ * MCP Apps protocol spec version this package targets.
26
+ *
27
+ * Matches the dated spec at
28
+ * https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx
29
+ *
30
+ * Bump this constant in the same commit that adopts a newer dated spec.
31
+ */
32
+ export const MCP_APPS_PROTOCOL_VERSION = "2026-01-26";
33
+ /**
34
+ * Read the MCP Apps capability from a client's advertised capabilities.
35
+ *
36
+ * Best-effort, defensive reader. Returns `undefined` for any of:
37
+ * - `null` / `undefined` input
38
+ * - `clientCapabilities` without an `extensions` field
39
+ * - `extensions` without the {@link MCP_APPS_EXTENSION_ID} key
40
+ * - extension value that is not a plain object (string, number, null, ...)
41
+ *
42
+ * Malformed `mimeTypes` (wrong type, non-string entries) are silently
43
+ * filtered rather than thrown — agents reading this function need a
44
+ * predictable contract that never crashes downstream consumers on
45
+ * untrusted client data.
46
+ *
47
+ * **Validation scope:** this function only validates the *type* of
48
+ * `mimeTypes` entries (must be string). It does NOT validate that the
49
+ * strings look like valid mime types (e.g. empty strings or garbage
50
+ * content pass through). Consumers should compare against known
51
+ * constants like {@link MCP_APP_MIME_TYPE} via `.includes()` rather
52
+ * than treating the array as a generic allowlist.
53
+ *
54
+ * @param clientCapabilities - The `ClientCapabilities` object from the
55
+ * MCP SDK initialize handshake. May be `null` or `undefined` if the
56
+ * client never sent capabilities.
57
+ * @returns The MCP Apps capability if the client advertised support,
58
+ * otherwise `undefined`.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const cap = getMcpAppsCapability(client.getClientCapabilities());
63
+ * if (cap?.mimeTypes?.includes(MCP_APP_MIME_TYPE)) {
64
+ * // register UI-rendering tools
65
+ * } else {
66
+ * // register text-only fallback tools
67
+ * }
68
+ * ```
69
+ */
70
+ export function getMcpAppsCapability(clientCapabilities) {
71
+ if (clientCapabilities === null || clientCapabilities === undefined) {
72
+ return undefined;
73
+ }
74
+ const extensions = clientCapabilities.extensions;
75
+ if (extensions === null || typeof extensions !== "object") {
76
+ return undefined;
77
+ }
78
+ const raw = extensions[MCP_APPS_EXTENSION_ID];
79
+ if (raw === null || typeof raw !== "object") {
80
+ return undefined;
81
+ }
82
+ // We have a capability object — extract known fields defensively.
83
+ const result = {};
84
+ const rawMimeTypes = raw.mimeTypes;
85
+ if (Array.isArray(rawMimeTypes)) {
86
+ const validMimeTypes = rawMimeTypes.filter((m) => typeof m === "string");
87
+ if (validMimeTypes.length > 0) {
88
+ result.mimeTypes = validMimeTypes;
89
+ }
90
+ }
91
+ return result;
92
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * MCP Apps Viewer Utilities
3
+ *
4
+ * Shared functions for resolving viewer dist paths and discovering
5
+ * viewer directories. Used by registerViewers() and the build pipeline.
6
+ *
7
+ * @module lib/server/src/ui/viewer-utils
8
+ */
9
+ /**
10
+ * Resolve the dist path for a viewer's built index.html.
11
+ *
12
+ * Checks two candidate locations relative to the module URL:
13
+ * 1. ./src/ui/dist/{viewerName}/index.html (Deno dev)
14
+ * 2. ./ui-dist/{viewerName}/index.html (npm package)
15
+ *
16
+ * @param moduleUrl - import.meta.url of the consumer's server.ts
17
+ * @param viewerName - Viewer directory name (e.g. "invoice-viewer")
18
+ * @param exists - Function to check if a path exists (injectable for tests)
19
+ * @returns Absolute path to index.html, or null if not found
20
+ */
21
+ export declare function resolveViewerDistPath(moduleUrl: string, viewerName: string, exists: (path: string) => boolean): string | null;
22
+ /** Minimal entry returned by a directory reader */
23
+ export interface DirEntry {
24
+ name: string;
25
+ isDirectory: boolean;
26
+ }
27
+ /** Injectable filesystem operations for discoverViewers */
28
+ export interface DiscoverViewersFS {
29
+ readDir: (path: string) => DirEntry[];
30
+ hasIndexHtml: (uiDir: string, viewerName: string) => boolean;
31
+ }
32
+ /**
33
+ * Auto-discover viewer directories inside a UI root folder.
34
+ *
35
+ * A viewer is a directory that:
36
+ * - Is not in the skip list (shared, dist, node_modules, .cache, .vite)
37
+ * - Does not start with "."
38
+ * - Contains an index.html file
39
+ *
40
+ * @param uiDir - Absolute path to the UI root directory
41
+ * @param fs - Injectable filesystem operations
42
+ * @returns Sorted array of viewer names
43
+ */
44
+ export declare function discoverViewers(uiDir: string, fs: DiscoverViewersFS): string[];
45
+ //# sourceMappingURL=viewer-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewer-utils.d.ts","sourceRoot":"","sources":["../../../src/src/ui/viewer-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwBH;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAChC,MAAM,GAAG,IAAI,CA2Bf;AAED,mDAAmD;AACnD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,2DAA2D;AAC3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;IACtC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,iBAAiB,GACpB,MAAM,EAAE,CAaV"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * MCP Apps Viewer Utilities
3
+ *
4
+ * Shared functions for resolving viewer dist paths and discovering
5
+ * viewer directories. Used by registerViewers() and the build pipeline.
6
+ *
7
+ * @module lib/server/src/ui/viewer-utils
8
+ */
9
+ /** Directories to skip during auto-discovery */
10
+ const SKIP_DIRS = new Set([
11
+ "shared",
12
+ "dist",
13
+ "node_modules",
14
+ ".cache",
15
+ ".vite",
16
+ ]);
17
+ /**
18
+ * Convert a file:// URL to a filesystem path.
19
+ * Handles Windows drive letters and UNC paths.
20
+ */
21
+ function fileUrlToPath(url) {
22
+ const decoded = decodeURIComponent(url.pathname);
23
+ // Windows: /C:/path → C:/path
24
+ if (/^\/[A-Za-z]:\//.test(decoded))
25
+ return decoded.slice(1);
26
+ // UNC: //host/share
27
+ if (url.host.length > 0)
28
+ return `//${url.host}${decoded}`;
29
+ return decoded;
30
+ }
31
+ /**
32
+ * Resolve the dist path for a viewer's built index.html.
33
+ *
34
+ * Checks two candidate locations relative to the module URL:
35
+ * 1. ./src/ui/dist/{viewerName}/index.html (Deno dev)
36
+ * 2. ./ui-dist/{viewerName}/index.html (npm package)
37
+ *
38
+ * @param moduleUrl - import.meta.url of the consumer's server.ts
39
+ * @param viewerName - Viewer directory name (e.g. "invoice-viewer")
40
+ * @param exists - Function to check if a path exists (injectable for tests)
41
+ * @returns Absolute path to index.html, or null if not found
42
+ */
43
+ export function resolveViewerDistPath(moduleUrl, viewerName, exists) {
44
+ // When consumed from JSR or any remote registry, import.meta.url is an
45
+ // HTTPS URL. fileUrlToPath() only handles file:// — passing an HTTPS URL
46
+ // produces a broken UNC-like path ("//jsr.io/..."). Return the raw resolved
47
+ // URL string instead; the caller's exists/readFile callbacks are responsible
48
+ // for handling remote URLs (e.g., via fetch()).
49
+ if (moduleUrl.startsWith("https://") || moduleUrl.startsWith("http://")) {
50
+ const candidates = [
51
+ new URL(`./src/ui/dist/${viewerName}/index.html`, moduleUrl).href,
52
+ new URL(`./ui-dist/${viewerName}/index.html`, moduleUrl).href,
53
+ ];
54
+ for (const candidate of candidates) {
55
+ if (exists(candidate))
56
+ return candidate;
57
+ }
58
+ return null;
59
+ }
60
+ const candidates = [
61
+ fileUrlToPath(new URL(`./src/ui/dist/${viewerName}/index.html`, moduleUrl)),
62
+ fileUrlToPath(new URL(`./ui-dist/${viewerName}/index.html`, moduleUrl)),
63
+ ];
64
+ for (const candidate of candidates) {
65
+ if (exists(candidate))
66
+ return candidate;
67
+ }
68
+ return null;
69
+ }
70
+ /**
71
+ * Auto-discover viewer directories inside a UI root folder.
72
+ *
73
+ * A viewer is a directory that:
74
+ * - Is not in the skip list (shared, dist, node_modules, .cache, .vite)
75
+ * - Does not start with "."
76
+ * - Contains an index.html file
77
+ *
78
+ * @param uiDir - Absolute path to the UI root directory
79
+ * @param fs - Injectable filesystem operations
80
+ * @returns Sorted array of viewer names
81
+ */
82
+ export function discoverViewers(uiDir, fs) {
83
+ const entries = fs.readDir(uiDir);
84
+ const viewers = [];
85
+ for (const entry of entries) {
86
+ if (!entry.isDirectory)
87
+ continue;
88
+ if (entry.name.startsWith("."))
89
+ continue;
90
+ if (SKIP_DIRS.has(entry.name))
91
+ continue;
92
+ if (!fs.hasIndexHtml(uiDir, entry.name))
93
+ continue;
94
+ viewers.push(entry.name);
95
+ }
96
+ return viewers.sort();
97
+ }
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Schema Validator
3
+ *
4
+ * JSON Schema validation using ajv for MCP tool arguments.
5
+ * Compiles schemas once for optimal performance.
6
+ *
7
+ * @module lib/server/schema-validator
8
+ */
9
+ /**
10
+ * Validation error with formatted message
11
+ */
12
+ export interface ValidationError {
13
+ /** Error message */
14
+ message: string;
15
+ /** Path to invalid property */
16
+ path: string;
17
+ /** Invalid value */
18
+ value?: unknown;
19
+ /** Expected type or constraint */
20
+ expected?: string;
21
+ }
22
+ /**
23
+ * Validation result
24
+ */
25
+ export interface ValidationResult {
26
+ valid: boolean;
27
+ errors: ValidationError[];
28
+ }
29
+ /**
30
+ * One immutable, compiled input-schema policy.
31
+ *
32
+ * McpApp stores this beside the tool handler so an in-flight call keeps the
33
+ * schema it entered with even if live registration later replaces or removes
34
+ * the public tool name.
35
+ */
36
+ export interface CompiledSchemaValidator {
37
+ validate(args: Record<string, unknown>): ValidationResult;
38
+ validateOrThrow(toolName: string, args: Record<string, unknown>): void;
39
+ }
40
+ /**
41
+ * Schema validator with compiled schema caching
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const validator = new SchemaValidator();
46
+ *
47
+ * // Register tool schema
48
+ * validator.addSchema("my_tool", {
49
+ * type: "object",
50
+ * properties: { count: { type: "number" } },
51
+ * required: ["count"]
52
+ * });
53
+ *
54
+ * // Validate arguments
55
+ * const result = validator.validate("my_tool", { count: 5 });
56
+ * if (!result.valid) {
57
+ * console.error(result.errors);
58
+ * }
59
+ * ```
60
+ */
61
+ export declare class SchemaValidator {
62
+ private ajv;
63
+ private validators;
64
+ constructor();
65
+ /**
66
+ * Add a schema for a tool
67
+ *
68
+ * @param toolName - Name of the tool
69
+ * @param schema - JSON Schema for tool arguments
70
+ */
71
+ addSchema(toolName: string, schema: Record<string, unknown>): CompiledSchemaValidator;
72
+ /**
73
+ * Compile a schema into a standalone validation snapshot.
74
+ *
75
+ * The returned object closes over one Ajv function rather than looking up a
76
+ * mutable tool name. This is useful for request snapshots and remains safe to
77
+ * retain after the name is unregistered from this cache.
78
+ */
79
+ compileSchema(schema: Record<string, unknown>): CompiledSchemaValidator;
80
+ /**
81
+ * Remove a schema
82
+ */
83
+ removeSchema(toolName: string): void;
84
+ /**
85
+ * Check if a schema exists
86
+ */
87
+ hasSchema(toolName: string): boolean;
88
+ /**
89
+ * Validate arguments against a tool's schema
90
+ *
91
+ * @param toolName - Name of the tool
92
+ * @param args - Arguments to validate
93
+ * @returns Validation result with errors if invalid
94
+ */
95
+ validate(toolName: string, args: Record<string, unknown>): ValidationResult;
96
+ /**
97
+ * Validate and throw if invalid
98
+ *
99
+ * @throws Error with formatted validation message
100
+ */
101
+ validateOrThrow(toolName: string, args: Record<string, unknown>): void;
102
+ /**
103
+ * Format ajv errors into readable messages
104
+ */
105
+ private formatErrors;
106
+ /**
107
+ * Get number of registered schemas
108
+ */
109
+ get count(): number;
110
+ /**
111
+ * Clear all schemas
112
+ */
113
+ clear(): void;
114
+ }
115
+ //# sourceMappingURL=schema-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-validator.d.ts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AO,CAAC,GAAG,gBAAgB;IAU3E;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAKtE;;OAEG;IACH,OAAO,CAAC,YAAY;IAmHpB;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Schema Validator
3
+ *
4
+ * JSON Schema validation using ajv for MCP tool arguments.
5
+ * Compiles schemas once for optimal performance.
6
+ *
7
+ * @module lib/server/schema-validator
8
+ */
9
+ // deno-lint-ignore-file no-explicit-any
10
+ // Draft 2020-12, not ajv's default export (draft-07). Spec 2026-07-28
11
+ // (SEP-2106) allows any JSON Schema 2020-12 keyword in `inputSchema` /
12
+ // `outputSchema`, and the draft-07 build treats the keywords added in 2020-12 —
13
+ // `prefixItems`, `unevaluatedProperties`, `unevaluatedItems`, `$dynamicRef` —
14
+ // as unknown. Combined with `strict: false` that failure is silent: the schema
15
+ // compiles, the constraint is never applied, and a violating payload validates
16
+ // clean. A tool author's declared boundary has to actually hold.
17
+ //
18
+ // Spelled as the full `dist/` path, not `ajv/2020`: `build-node.sh` copies
19
+ // import specifiers verbatim into the npm distribution, and ajv 8 ships no
20
+ // `exports` map and no root-level `2020.js`, so `ajv/2020` resolves under
21
+ // Deno's import map and then fails at runtime in Node with ERR_MODULE_NOT_FOUND.
22
+ // This path resolves under both.
23
+ import AjvDefault from "ajv/dist/2020.js";
24
+ // Get the Ajv constructor (handles ESM/CJS differences)
25
+ const Ajv = AjvDefault.default ?? AjvDefault;
26
+ /**
27
+ * Count with its noun, agreeing in number.
28
+ *
29
+ * A bound of 1 is a legitimate schema (`minItems: 1`), and "must have at least
30
+ * 1 items" reads as a bug in the server rather than a problem with the input.
31
+ */
32
+ function plural(n, singular, plural = `${singular}s`) {
33
+ return `${n} ${n === 1 ? singular : plural}`;
34
+ }
35
+ /**
36
+ * Schema validator with compiled schema caching
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const validator = new SchemaValidator();
41
+ *
42
+ * // Register tool schema
43
+ * validator.addSchema("my_tool", {
44
+ * type: "object",
45
+ * properties: { count: { type: "number" } },
46
+ * required: ["count"]
47
+ * });
48
+ *
49
+ * // Validate arguments
50
+ * const result = validator.validate("my_tool", { count: 5 });
51
+ * if (!result.valid) {
52
+ * console.error(result.errors);
53
+ * }
54
+ * ```
55
+ */
56
+ export class SchemaValidator {
57
+ ajv;
58
+ validators = new Map();
59
+ constructor() {
60
+ this.ajv = new Ajv({
61
+ allErrors: true, // Report all errors, not just first
62
+ strict: false, // Allow additional keywords
63
+ useDefaults: true, // Apply default values
64
+ coerceTypes: false, // Don't coerce types (strict validation)
65
+ });
66
+ }
67
+ /**
68
+ * Add a schema for a tool
69
+ *
70
+ * @param toolName - Name of the tool
71
+ * @param schema - JSON Schema for tool arguments
72
+ */
73
+ addSchema(toolName, schema) {
74
+ // Compilation happens before the map update. A malformed replacement
75
+ // therefore leaves the previously cached schema intact.
76
+ const compiled = this.compileSchema(schema);
77
+ this.validators.set(toolName, compiled);
78
+ return compiled;
79
+ }
80
+ /**
81
+ * Compile a schema into a standalone validation snapshot.
82
+ *
83
+ * The returned object closes over one Ajv function rather than looking up a
84
+ * mutable tool name. This is useful for request snapshots and remains safe to
85
+ * retain after the name is unregistered from this cache.
86
+ */
87
+ compileSchema(schema) {
88
+ const validate = this.ajv.compile(schema);
89
+ const run = (args) => {
90
+ const valid = validate(args);
91
+ if (valid) {
92
+ return { valid: true, errors: [] };
93
+ }
94
+ return {
95
+ valid: false,
96
+ errors: this.formatErrors(validate.errors || []),
97
+ };
98
+ };
99
+ return Object.freeze({
100
+ validate: run,
101
+ validateOrThrow: (toolName, args) => {
102
+ const result = run(args);
103
+ if (!result.valid) {
104
+ const messages = result.errors.map((e) => e.message).join("; ");
105
+ throw new Error(`Invalid arguments for ${toolName}: ${messages}`);
106
+ }
107
+ },
108
+ });
109
+ }
110
+ /**
111
+ * Remove a schema
112
+ */
113
+ removeSchema(toolName) {
114
+ this.validators.delete(toolName);
115
+ }
116
+ /**
117
+ * Check if a schema exists
118
+ */
119
+ hasSchema(toolName) {
120
+ return this.validators.has(toolName);
121
+ }
122
+ /**
123
+ * Validate arguments against a tool's schema
124
+ *
125
+ * @param toolName - Name of the tool
126
+ * @param args - Arguments to validate
127
+ * @returns Validation result with errors if invalid
128
+ */
129
+ validate(toolName, args) {
130
+ const compiled = this.validators.get(toolName);
131
+ if (!compiled) {
132
+ // No schema registered - pass through
133
+ return { valid: true, errors: [] };
134
+ }
135
+ return compiled.validate(args);
136
+ }
137
+ /**
138
+ * Validate and throw if invalid
139
+ *
140
+ * @throws Error with formatted validation message
141
+ */
142
+ validateOrThrow(toolName, args) {
143
+ const compiled = this.validators.get(toolName);
144
+ if (compiled)
145
+ compiled.validateOrThrow(toolName, args);
146
+ }
147
+ /**
148
+ * Format ajv errors into readable messages
149
+ */
150
+ formatErrors(errors) {
151
+ return errors.map((error) => {
152
+ const path = error.instancePath || "/";
153
+ const param = error.params;
154
+ let message;
155
+ let expected;
156
+ switch (error.keyword) {
157
+ case "required":
158
+ message = `Missing required property: ${param.missingProperty}`;
159
+ break;
160
+ case "type":
161
+ message = `Property ${path} must be ${param.type}`;
162
+ expected = param.type;
163
+ break;
164
+ case "enum":
165
+ message = `Property ${path} must be one of: ${param.allowedValues?.join(", ")}`;
166
+ expected = param.allowedValues?.join(" | ");
167
+ break;
168
+ case "minimum":
169
+ message = `Property ${path} must be >= ${param.limit}`;
170
+ expected = `>= ${param.limit}`;
171
+ break;
172
+ case "maximum":
173
+ message = `Property ${path} must be <= ${param.limit}`;
174
+ expected = `<= ${param.limit}`;
175
+ break;
176
+ case "minLength":
177
+ message =
178
+ `Property ${path} must have at least ${param.limit} characters`;
179
+ expected = `length >= ${param.limit}`;
180
+ break;
181
+ case "maxLength":
182
+ message =
183
+ `Property ${path} must have at most ${param.limit} characters`;
184
+ expected = `length <= ${param.limit}`;
185
+ break;
186
+ case "pattern":
187
+ message = `Property ${path} must match pattern: ${param.pattern}`;
188
+ expected = param.pattern;
189
+ break;
190
+ // Collection bounds. ajv enforces these already — what was missing is a
191
+ // message shaped like the others, with a structured `expected`. Without
192
+ // it these fell through to `default` and surfaced ajv's bare prose
193
+ // ("must NOT have more than 8 items"), which states the limit but names
194
+ // neither the property nor an `expected` a caller can act on.
195
+ //
196
+ // `expected` says "items"/"properties" rather than "length": it is read
197
+ // on its own as a recovery hint, where "length <= 8" is indistinguishable
198
+ // from the character bound that minLength/maxLength above produce.
199
+ case "minItems":
200
+ message = `Property ${path} must have at least ${plural(param.limit, "item")}`;
201
+ expected = `items >= ${param.limit}`;
202
+ break;
203
+ case "maxItems":
204
+ message = `Property ${path} must have at most ${plural(param.limit, "item")}`;
205
+ expected = `items <= ${param.limit}`;
206
+ break;
207
+ case "uniqueItems":
208
+ // ajv reports the two colliding array indices, zero-based, and in
209
+ // either order depending on how it optimised the comparison. The
210
+ // indices are not what is equal — the items at them are.
211
+ message =
212
+ `Property ${path} must not contain duplicate items (items at indices ${param.j} and ${param.i} are equal)`;
213
+ expected = "unique items";
214
+ break;
215
+ case "minProperties":
216
+ message = `Property ${path} must have at least ${plural(param.limit, "property", "properties")}`;
217
+ expected = `properties >= ${param.limit}`;
218
+ break;
219
+ case "maxProperties":
220
+ message = `Property ${path} must have at most ${plural(param.limit, "property", "properties")}`;
221
+ expected = `properties <= ${param.limit}`;
222
+ break;
223
+ case "additionalProperties":
224
+ message = `Unknown property: ${param.additionalProperty}`;
225
+ break;
226
+ default:
227
+ message = error.message || `Validation failed at ${path}`;
228
+ }
229
+ return {
230
+ message,
231
+ path,
232
+ value: error.data,
233
+ expected,
234
+ };
235
+ });
236
+ }
237
+ /**
238
+ * Get number of registered schemas
239
+ */
240
+ get count() {
241
+ return this.validators.size;
242
+ }
243
+ /**
244
+ * Clear all schemas
245
+ */
246
+ clear() {
247
+ this.validators.clear();
248
+ }
249
+ }