gemi 0.124.0 → 0.125.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/dist/ai/AgentController.d.ts +185 -3
  2. package/dist/ai/AgentController.d.ts.map +1 -1
  3. package/dist/ai/client/index.d.ts +1 -1
  4. package/dist/ai/client/index.d.ts.map +1 -1
  5. package/dist/ai/client/index.js +38 -9
  6. package/dist/ai/client/index.js.map +1 -1
  7. package/dist/ai/client/reducer.d.ts.map +1 -1
  8. package/dist/ai/index.d.ts +2 -2
  9. package/dist/ai/index.d.ts.map +1 -1
  10. package/dist/ai/index.js +31 -48
  11. package/dist/ai/index.js.map +6 -15
  12. package/dist/ai/types.d.ts +26 -0
  13. package/dist/ai/types.d.ts.map +1 -1
  14. package/dist/ai/useChat.d.ts +35 -2
  15. package/dist/ai/useChat.d.ts.map +1 -1
  16. package/dist/app/index.js +1 -1
  17. package/dist/auth/AuthController.d.ts.map +1 -1
  18. package/dist/auth/AuthManager.d.ts +11 -0
  19. package/dist/auth/AuthManager.d.ts.map +1 -1
  20. package/dist/auth/AuthServiceProvider.d.ts +2 -0
  21. package/dist/auth/AuthServiceProvider.d.ts.map +1 -1
  22. package/dist/auth/config.d.ts +71 -2
  23. package/dist/auth/config.d.ts.map +1 -1
  24. package/dist/auth/oauth/providers.d.ts +10 -0
  25. package/dist/auth/oauth/providers.d.ts.map +1 -0
  26. package/dist/bun/plugin.js +1 -1
  27. package/dist/bun/preload.js +1 -1
  28. package/dist/{chunk-a3g7y70h.js → chunk-0x1s02r1.js} +3 -3
  29. package/dist/{chunk-a3g7y70h.js.map → chunk-0x1s02r1.js.map} +1 -1
  30. package/dist/{chunk-yzhv93b0.js → chunk-1jcngq6w.js} +3 -3
  31. package/dist/{chunk-yzhv93b0.js.map → chunk-1jcngq6w.js.map} +1 -1
  32. package/dist/{chunk-mrswc6qw.js → chunk-1mxb44n9.js} +2 -2
  33. package/dist/{chunk-mrswc6qw.js.map → chunk-1mxb44n9.js.map} +1 -1
  34. package/dist/{chunk-9tr92nwy.js → chunk-1n40bdxf.js} +2 -2
  35. package/dist/{chunk-9tr92nwy.js.map → chunk-1n40bdxf.js.map} +1 -1
  36. package/dist/chunk-1xmh61fg.js +5 -0
  37. package/dist/{chunk-70nnh0y7.js.map → chunk-1xmh61fg.js.map} +1 -1
  38. package/dist/{chunk-bt9qv2jj.js → chunk-3br5zr7a.js} +3 -3
  39. package/dist/{chunk-bt9qv2jj.js.map → chunk-3br5zr7a.js.map} +1 -1
  40. package/dist/{chunk-w61sphn5.js → chunk-3kxe9geg.js} +3 -3
  41. package/dist/{chunk-w61sphn5.js.map → chunk-3kxe9geg.js.map} +1 -1
  42. package/dist/{chunk-bnt8kx6x.js → chunk-5fh4pvyt.js} +2 -2
  43. package/dist/{chunk-bnt8kx6x.js.map → chunk-5fh4pvyt.js.map} +1 -1
  44. package/dist/{chunk-rpyczdta.js → chunk-6gwxvmjv.js} +3 -3
  45. package/dist/{chunk-rpyczdta.js.map → chunk-6gwxvmjv.js.map} +1 -1
  46. package/dist/{chunk-65s834td.js → chunk-6q6bhkyf.js} +1 -1
  47. package/dist/{chunk-fn2qfwgx.js → chunk-6vz75swk.js} +2 -2
  48. package/dist/{chunk-fn2qfwgx.js.map → chunk-6vz75swk.js.map} +1 -1
  49. package/dist/chunk-6wgh7nk6.js +15 -0
  50. package/dist/{chunk-n0r5xyk2.js.map → chunk-6wgh7nk6.js.map} +6 -5
  51. package/dist/chunk-7vrrgxwm.js +22 -0
  52. package/dist/chunk-7vrrgxwm.js.map +21 -0
  53. package/dist/{chunk-kzsjyvvc.js → chunk-7zj6bk9a.js} +2 -2
  54. package/dist/{chunk-kzsjyvvc.js.map → chunk-7zj6bk9a.js.map} +1 -1
  55. package/dist/{chunk-3hqwz48c.js → chunk-8tvfmy1a.js} +4 -4
  56. package/dist/{chunk-3hqwz48c.js.map → chunk-8tvfmy1a.js.map} +1 -1
  57. package/dist/{chunk-6bgb1nhq.js → chunk-910p6ne6.js} +2 -2
  58. package/dist/{chunk-6bgb1nhq.js.map → chunk-910p6ne6.js.map} +1 -1
  59. package/dist/{chunk-96a1459v.js → chunk-ap3g6rbw.js} +2 -2
  60. package/dist/{chunk-96a1459v.js.map → chunk-ap3g6rbw.js.map} +1 -1
  61. package/dist/{chunk-3j6s5bmx.js → chunk-ayfjjgv2.js} +1 -1
  62. package/dist/chunk-b4x1dt3s.js +10 -0
  63. package/dist/chunk-b4x1dt3s.js.map +43 -0
  64. package/dist/{chunk-f29pktad.js → chunk-b7a22evs.js} +3 -3
  65. package/dist/{chunk-f29pktad.js.map → chunk-b7a22evs.js.map} +1 -1
  66. package/dist/{chunk-qdj8ek8z.js → chunk-bny9s44t.js} +2 -2
  67. package/dist/{chunk-qdj8ek8z.js.map → chunk-bny9s44t.js.map} +1 -1
  68. package/dist/{chunk-1rnh9qrp.js → chunk-by5gwr8x.js} +2 -2
  69. package/dist/{chunk-1rnh9qrp.js.map → chunk-by5gwr8x.js.map} +1 -1
  70. package/dist/{chunk-nn2jeat2.js → chunk-c0qpv8x7.js} +2 -2
  71. package/dist/{chunk-17dndh5z.js.map → chunk-c0qpv8x7.js.map} +1 -1
  72. package/dist/{chunk-f4cmz31h.js → chunk-cpem1j1x.js} +2 -2
  73. package/dist/{chunk-f4cmz31h.js.map → chunk-cpem1j1x.js.map} +1 -1
  74. package/dist/{chunk-019wz697.js → chunk-crnfxn9n.js} +2 -2
  75. package/dist/{chunk-019wz697.js.map → chunk-crnfxn9n.js.map} +1 -1
  76. package/dist/{chunk-s5jxc63j.js → chunk-cwt8e782.js} +3 -3
  77. package/dist/{chunk-s5jxc63j.js.map → chunk-cwt8e782.js.map} +1 -1
  78. package/dist/{chunk-fw7ds23a.js → chunk-dxyxd7b3.js} +2 -2
  79. package/dist/{chunk-fw7ds23a.js.map → chunk-dxyxd7b3.js.map} +1 -1
  80. package/dist/{chunk-qhz0x97z.js → chunk-dy58aztm.js} +2 -2
  81. package/dist/{chunk-qhz0x97z.js.map → chunk-dy58aztm.js.map} +1 -1
  82. package/dist/{chunk-skf89vrv.js → chunk-entpqjyn.js} +2 -2
  83. package/dist/{chunk-skf89vrv.js.map → chunk-entpqjyn.js.map} +1 -1
  84. package/dist/{chunk-7gfdts60.js → chunk-eq5svwca.js} +2 -2
  85. package/dist/{chunk-7gfdts60.js.map → chunk-eq5svwca.js.map} +1 -1
  86. package/dist/{chunk-n1a2zj5z.js → chunk-erzfs4t2.js} +2 -2
  87. package/dist/{chunk-n1a2zj5z.js.map → chunk-erzfs4t2.js.map} +3 -3
  88. package/dist/{chunk-3y294mb8.js → chunk-ex41d03h.js} +2 -2
  89. package/dist/{chunk-3y294mb8.js.map → chunk-ex41d03h.js.map} +1 -1
  90. package/dist/{chunk-v2ggafz1.js → chunk-ey1xrbaz.js} +2 -2
  91. package/dist/{chunk-v2ggafz1.js.map → chunk-ey1xrbaz.js.map} +1 -1
  92. package/dist/chunk-eyptwf54.js +57 -0
  93. package/dist/{chunk-5j50q4g8.js.map → chunk-eyptwf54.js.map} +22 -19
  94. package/dist/{chunk-zsfwcdqn.js → chunk-g52fcwca.js} +2 -2
  95. package/dist/{chunk-zsfwcdqn.js.map → chunk-g52fcwca.js.map} +1 -1
  96. package/dist/{chunk-rttrpjqk.js → chunk-ghcvztxn.js} +2 -2
  97. package/dist/{chunk-rttrpjqk.js.map → chunk-ghcvztxn.js.map} +1 -1
  98. package/dist/{chunk-wbg2tza5.js → chunk-gp00enrk.js} +1 -1
  99. package/dist/{chunk-92sk56n0.js → chunk-h8w9mzjj.js} +6 -6
  100. package/dist/{chunk-92sk56n0.js.map → chunk-h8w9mzjj.js.map} +7 -7
  101. package/dist/{chunk-cfdwsvtx.js → chunk-hff9w6rt.js} +2 -2
  102. package/dist/{chunk-cfdwsvtx.js.map → chunk-hff9w6rt.js.map} +1 -1
  103. package/dist/{chunk-17dndh5z.js → chunk-hxn0s3zh.js} +2 -2
  104. package/dist/{chunk-nn2jeat2.js.map → chunk-hxn0s3zh.js.map} +1 -1
  105. package/dist/{chunk-8m2htvjn.js → chunk-hzen9gh4.js} +2 -2
  106. package/dist/{chunk-8m2htvjn.js.map → chunk-hzen9gh4.js.map} +1 -1
  107. package/dist/{chunk-c4jnxmf2.js → chunk-j10a0m7q.js} +1 -1
  108. package/dist/{chunk-5e22tm7m.js → chunk-j12hpdxk.js} +1 -1
  109. package/dist/{chunk-ykz38t0t.js → chunk-j5rwv09s.js} +2 -2
  110. package/dist/{chunk-ykz38t0t.js.map → chunk-j5rwv09s.js.map} +1 -1
  111. package/dist/{chunk-w4z6x54b.js → chunk-jykkqwcy.js} +3 -3
  112. package/dist/{chunk-w4z6x54b.js.map → chunk-jykkqwcy.js.map} +1 -1
  113. package/dist/{chunk-w3812s34.js → chunk-k1ebt28j.js} +2 -2
  114. package/dist/{chunk-w3812s34.js.map → chunk-k1ebt28j.js.map} +1 -1
  115. package/dist/{chunk-h3p8qzft.js → chunk-kcsa57km.js} +2 -2
  116. package/dist/{chunk-h3p8qzft.js.map → chunk-kcsa57km.js.map} +1 -1
  117. package/dist/{chunk-1qwhty9p.js → chunk-khdkrfxp.js} +2 -2
  118. package/dist/{chunk-1qwhty9p.js.map → chunk-khdkrfxp.js.map} +1 -1
  119. package/dist/{chunk-b5afy6k9.js → chunk-knq4ack4.js} +2 -2
  120. package/dist/{chunk-b5afy6k9.js.map → chunk-knq4ack4.js.map} +1 -1
  121. package/dist/{chunk-121p4g9j.js → chunk-m7pghdcy.js} +2 -2
  122. package/dist/{chunk-121p4g9j.js.map → chunk-m7pghdcy.js.map} +1 -1
  123. package/dist/{chunk-rtawbqec.js → chunk-mmqnq1qh.js} +3 -3
  124. package/dist/{chunk-rtawbqec.js.map → chunk-mmqnq1qh.js.map} +1 -1
  125. package/dist/{chunk-34fkx6kb.js → chunk-n3z83qhq.js} +2 -2
  126. package/dist/{chunk-34fkx6kb.js.map → chunk-n3z83qhq.js.map} +1 -1
  127. package/dist/{chunk-mvkz22p4.js → chunk-npbf06c1.js} +2 -2
  128. package/dist/{chunk-mvkz22p4.js.map → chunk-npbf06c1.js.map} +1 -1
  129. package/dist/{chunk-2affxmkn.js → chunk-p5df4pn7.js} +2 -2
  130. package/dist/{chunk-2affxmkn.js.map → chunk-p5df4pn7.js.map} +1 -1
  131. package/dist/{chunk-y434jc1c.js → chunk-p6jbmcrg.js} +2 -2
  132. package/dist/{chunk-y434jc1c.js.map → chunk-p6jbmcrg.js.map} +1 -1
  133. package/dist/{chunk-jctb7v53.js → chunk-p7mvp5nf.js} +2 -2
  134. package/dist/{chunk-jctb7v53.js.map → chunk-p7mvp5nf.js.map} +1 -1
  135. package/dist/{chunk-jys8y39p.js → chunk-q6ah4yjg.js} +2 -2
  136. package/dist/{chunk-jys8y39p.js.map → chunk-q6ah4yjg.js.map} +1 -1
  137. package/dist/{chunk-pmyh33v5.js → chunk-r923001x.js} +2 -2
  138. package/dist/{chunk-pmyh33v5.js.map → chunk-r923001x.js.map} +1 -1
  139. package/dist/{chunk-mqtfaqx5.js → chunk-rany5zgk.js} +2 -2
  140. package/dist/{chunk-mqtfaqx5.js.map → chunk-rany5zgk.js.map} +1 -1
  141. package/dist/{chunk-30xxc6r7.js → chunk-rmgkc3a2.js} +2 -2
  142. package/dist/{chunk-30xxc6r7.js.map → chunk-rmgkc3a2.js.map} +1 -1
  143. package/dist/{chunk-v8v5qfnh.js → chunk-rvspb96n.js} +3 -3
  144. package/dist/{chunk-v8v5qfnh.js.map → chunk-rvspb96n.js.map} +1 -1
  145. package/dist/{chunk-zsvav1dk.js → chunk-rwmja4zs.js} +2 -2
  146. package/dist/{chunk-zsvav1dk.js.map → chunk-rwmja4zs.js.map} +1 -1
  147. package/dist/{chunk-j7v7dft7.js → chunk-s4semb89.js} +1 -1
  148. package/dist/{chunk-szn2n976.js → chunk-s4xg69r9.js} +2 -2
  149. package/dist/{chunk-szn2n976.js.map → chunk-s4xg69r9.js.map} +1 -1
  150. package/dist/{chunk-4drnyymm.js → chunk-stn0a56e.js} +2 -2
  151. package/dist/{chunk-4drnyymm.js.map → chunk-stn0a56e.js.map} +1 -1
  152. package/dist/{chunk-pe46a5a5.js → chunk-sv125fqq.js} +2 -2
  153. package/dist/{chunk-pe46a5a5.js.map → chunk-sv125fqq.js.map} +1 -1
  154. package/dist/{chunk-dxfhhw5h.js → chunk-t2t63wa0.js} +2 -2
  155. package/dist/{chunk-dxfhhw5h.js.map → chunk-t2t63wa0.js.map} +1 -1
  156. package/dist/{chunk-675kzd7z.js → chunk-t6qpm2j7.js} +2 -2
  157. package/dist/{chunk-675kzd7z.js.map → chunk-t6qpm2j7.js.map} +1 -1
  158. package/dist/chunk-tabsxzg9.js +5 -0
  159. package/dist/chunk-tabsxzg9.js.map +13 -0
  160. package/dist/{chunk-qycwjzsv.js → chunk-vhvvjaj3.js} +3 -3
  161. package/dist/{chunk-qycwjzsv.js.map → chunk-vhvvjaj3.js.map} +1 -1
  162. package/dist/{chunk-sd0c2001.js → chunk-x2j84d06.js} +2 -2
  163. package/dist/{chunk-sd0c2001.js.map → chunk-x2j84d06.js.map} +1 -1
  164. package/dist/{chunk-75ewjc4a.js → chunk-xe2pm36q.js} +2 -2
  165. package/dist/{chunk-75ewjc4a.js.map → chunk-xe2pm36q.js.map} +1 -1
  166. package/dist/{chunk-z5jydj5r.js → chunk-xfvegbxn.js} +2 -2
  167. package/dist/{chunk-z5jydj5r.js.map → chunk-xfvegbxn.js.map} +1 -1
  168. package/dist/{chunk-2n4490pk.js → chunk-y9f2see3.js} +3 -3
  169. package/dist/{chunk-2n4490pk.js.map → chunk-y9f2see3.js.map} +1 -1
  170. package/dist/{chunk-nkzmk7v3.js → chunk-yhht1j7f.js} +2 -2
  171. package/dist/{chunk-nkzmk7v3.js.map → chunk-yhht1j7f.js.map} +1 -1
  172. package/dist/{chunk-nnarmbjv.js → chunk-z5nfve1k.js} +2 -2
  173. package/dist/chunk-z5nfve1k.js.map +10 -0
  174. package/dist/{chunk-fvrmptd0.js → chunk-zq5375wd.js} +3 -3
  175. package/dist/{chunk-fvrmptd0.js.map → chunk-zq5375wd.js.map} +1 -1
  176. package/dist/chunks/{ThemeProvider-CbOx8IRl.js → ThemeProvider-CS2a1snV.js} +27 -1
  177. package/dist/chunks/ThemeProvider-CS2a1snV.js.map +1 -0
  178. package/dist/client/Mutation.d.ts +7 -6
  179. package/dist/client/Mutation.d.ts.map +1 -1
  180. package/dist/client/MutationError.d.ts +53 -1
  181. package/dist/client/MutationError.d.ts.map +1 -1
  182. package/dist/client/QueryResource.d.ts +9 -0
  183. package/dist/client/QueryResource.d.ts.map +1 -1
  184. package/dist/client/auth/useEmailCode.d.ts +3 -3
  185. package/dist/client/auth/useForgotPassword.d.ts +1 -1
  186. package/dist/client/auth/useResetPassword.d.ts +1 -1
  187. package/dist/client/auth/useSignIn.d.ts +1 -1
  188. package/dist/client/auth/useSignOut.d.ts +1 -1
  189. package/dist/client/auth/useSignUp.d.ts +1 -1
  190. package/dist/client/index.d.ts +4 -2
  191. package/dist/client/index.d.ts.map +1 -1
  192. package/dist/client/index.js +136 -9
  193. package/dist/client/index.js.map +1 -1
  194. package/dist/client/useMutation.d.ts +18 -8
  195. package/dist/client/useMutation.d.ts.map +1 -1
  196. package/dist/client/useSetQueryData.d.ts +69 -0
  197. package/dist/client/useSetQueryData.d.ts.map +1 -0
  198. package/dist/config/index.js +1 -1
  199. package/dist/console/run.js +2 -2
  200. package/dist/console/run.js.map +1 -1
  201. package/dist/container/index.js +2 -2
  202. package/dist/container/index.js.map +1 -1
  203. package/dist/database/index.js +2 -2
  204. package/dist/database/index.js.map +1 -1
  205. package/dist/email/index.js +2 -2
  206. package/dist/email/index.js.map +1 -1
  207. package/dist/facades/Auth.d.ts +29 -2
  208. package/dist/facades/Auth.d.ts.map +1 -1
  209. package/dist/facades/RateLimiter.d.ts +16 -1
  210. package/dist/facades/RateLimiter.d.ts.map +1 -1
  211. package/dist/facades/index.js +2 -2
  212. package/dist/facades/index.js.map +1 -1
  213. package/dist/foundation/index.js +2 -2
  214. package/dist/foundation/index.js.map +1 -1
  215. package/dist/http/HttpRequest.d.ts +14 -0
  216. package/dist/http/HttpRequest.d.ts.map +1 -1
  217. package/dist/http/McpRouter.d.ts +121 -2
  218. package/dist/http/McpRouter.d.ts.map +1 -1
  219. package/dist/http/RateLimitExceededError.d.ts +24 -0
  220. package/dist/http/RateLimitExceededError.d.ts.map +1 -0
  221. package/dist/http/RateLimitMiddleware.d.ts +2 -5
  222. package/dist/http/RateLimitMiddleware.d.ts.map +1 -1
  223. package/dist/http/index.d.ts +2 -1
  224. package/dist/http/index.d.ts.map +1 -1
  225. package/dist/http/index.js +2 -2
  226. package/dist/http/index.js.map +1 -1
  227. package/dist/http/refusal.d.ts +6 -1
  228. package/dist/http/refusal.d.ts.map +1 -1
  229. package/dist/http/requestContext.d.ts +3 -1
  230. package/dist/http/requestContext.d.ts.map +1 -1
  231. package/dist/http/requestState.d.ts +57 -0
  232. package/dist/http/requestState.d.ts.map +1 -0
  233. package/dist/i18n/dictionaryRuntime.js +2 -2
  234. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  235. package/dist/i18n/index.js +2 -2
  236. package/dist/i18n/index.js.map +1 -1
  237. package/dist/kernel/index.js +2 -2
  238. package/dist/kernel/index.js.map +1 -1
  239. package/dist/orm/index.js +2 -2
  240. package/dist/orm/index.js.map +1 -1
  241. package/dist/server/Server.d.ts.map +1 -1
  242. package/dist/server/health.d.ts +67 -0
  243. package/dist/server/health.d.ts.map +1 -0
  244. package/dist/server/index.d.ts +1 -0
  245. package/dist/server/index.d.ts.map +1 -1
  246. package/dist/server/index.js +2 -2
  247. package/dist/server/index.js.map +5 -4
  248. package/dist/server/shutdown.d.ts +3 -4
  249. package/dist/server/shutdown.d.ts.map +1 -1
  250. package/dist/services/features/gate.d.ts +11 -0
  251. package/dist/services/features/gate.d.ts.map +1 -0
  252. package/dist/services/index.d.ts +4 -4
  253. package/dist/services/index.d.ts.map +1 -1
  254. package/dist/services/index.js +3 -3
  255. package/dist/services/index.js.map +2 -2
  256. package/dist/services/logging/LogManager.d.ts +1 -0
  257. package/dist/services/logging/LogManager.d.ts.map +1 -1
  258. package/dist/services/logging/config.d.ts +23 -1
  259. package/dist/services/logging/config.d.ts.map +1 -1
  260. package/dist/services/logging/consoleSink.d.ts +25 -0
  261. package/dist/services/logging/consoleSink.d.ts.map +1 -0
  262. package/dist/services/mcp/McpRegistry.d.ts +106 -14
  263. package/dist/services/mcp/McpRegistry.d.ts.map +1 -1
  264. package/dist/services/mcp/http/McpHttpServer.d.ts +41 -2
  265. package/dist/services/mcp/http/McpHttpServer.d.ts.map +1 -1
  266. package/dist/services/mcp/toAgentTools.d.ts +21 -3
  267. package/dist/services/mcp/toAgentTools.d.ts.map +1 -1
  268. package/dist/services/queue/work.js +2 -2
  269. package/dist/services/queue/work.js.map +1 -1
  270. package/dist/services/rate-limiter/RateLimiter.d.ts +12 -0
  271. package/dist/services/rate-limiter/RateLimiter.d.ts.map +1 -1
  272. package/dist/services/router/globalMiddleware.d.ts +4 -3
  273. package/dist/services/router/globalMiddleware.d.ts.map +1 -1
  274. package/dist/stats/route-table.js +1 -1
  275. package/dist/support/index.js +2 -2
  276. package/dist/support/index.js.map +1 -1
  277. package/dist/testing/index.js +1 -1
  278. package/dist/vitest/index.js +1 -1
  279. package/package.json +1 -1
  280. package/skills/gemi-react-best-practices/SKILL.md +1 -1
  281. package/skills/gemi-react-best-practices/rules/query-mutate-over-refetch.md +14 -0
  282. package/skills/gemi-react-best-practices/rules/routing-middleware-dsl.md +2 -1
  283. package/dist/chunk-5j50q4g8.js +0 -57
  284. package/dist/chunk-70nnh0y7.js +0 -5
  285. package/dist/chunk-kc924zjz.js +0 -5
  286. package/dist/chunk-kc924zjz.js.map +0 -12
  287. package/dist/chunk-n0r5xyk2.js +0 -14
  288. package/dist/chunk-nnarmbjv.js.map +0 -10
  289. package/dist/chunk-pya4rqm2.js +0 -5
  290. package/dist/chunk-pya4rqm2.js.map +0 -12
  291. package/dist/chunk-zmf3vhex.js +0 -10
  292. package/dist/chunk-zmf3vhex.js.map +0 -43
  293. package/dist/chunks/ThemeProvider-CbOx8IRl.js.map +0 -1
  294. /package/dist/{chunk-65s834td.js.map → chunk-6q6bhkyf.js.map} +0 -0
  295. /package/dist/{chunk-3j6s5bmx.js.map → chunk-ayfjjgv2.js.map} +0 -0
  296. /package/dist/{chunk-wbg2tza5.js.map → chunk-gp00enrk.js.map} +0 -0
  297. /package/dist/{chunk-c4jnxmf2.js.map → chunk-j10a0m7q.js.map} +0 -0
  298. /package/dist/{chunk-5e22tm7m.js.map → chunk-j12hpdxk.js.map} +0 -0
  299. /package/dist/{chunk-j7v7dft7.js.map → chunk-s4semb89.js.map} +0 -0
@@ -22,6 +22,7 @@ export declare class LogManager {
22
22
  * `httpProd` sets `ROOT_DIR` from, a moment later.
23
23
  */
24
24
  private get logsDirPath();
25
+ private readonly consoleThreshold;
25
26
  constructor(config: Required<LogConfig>);
26
27
  /**
27
28
  * Idempotent. `LogServiceProvider.boot()` calls this so the storage
@@ -1 +1 @@
1
- {"version":3,"file":"LogManager.d.ts","sourceRoot":"","sources":["../../../services/logging/LogManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAapC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD,qBAAa,UAAU;IA0BF,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC;IAzB9C,MAAM,CAAC,KAAK,SAAS;IAErB,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,OAAO,CAAS;IAEzB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,WAAW,CAA8B;IAC1C,kBAA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,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAuF9B,QAAQ;CAkBf"}
@@ -1,6 +1,28 @@
1
- import type { LogEntry } from "./types";
1
+ import type { LogEntry, LogLevel } from "./types";
2
+ /**
3
+ * How the console sink writes an entry.
4
+ *
5
+ * - `"text"`: one readable line, `2026-10-11T09:00:00.000Z ERROR Payment failed {"orderId":1}`.
6
+ * - `"json"`: one JSON object per line, `{"timestamp":…,"level":"error","message":…,"orderId":1}`,
7
+ * which platform log viewers (Railway, Fly, Datadog, …) parse into structured fields.
8
+ */
9
+ export type LogConsoleFormat = "text" | "json";
2
10
  export interface LogConfig {
3
11
  maxFileSize?: number;
12
+ /**
13
+ * Also write every entry to the process's stdout (`debug`, `info`, `notice`)
14
+ * or stderr (`warning` and above), so platform log collectors pick it up.
15
+ *
16
+ * `true` writes every level, a level writes that level and above, `false`
17
+ * turns the sink off. Default: `true` when `NODE_ENV` is `"development"`
18
+ * (`gemi dev`), `false` otherwise.
19
+ */
20
+ console?: boolean | LogLevel;
21
+ /**
22
+ * Line format of the console sink. Default: `"text"` in development,
23
+ * `"json"` otherwise.
24
+ */
25
+ consoleFormat?: LogConsoleFormat;
4
26
  onLogFileClosed?: (file: File) => void | Promise<void>;
5
27
  onLogCreated?: (logEntry: LogEntry) => void | Promise<void>;
6
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../services/logging/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAE5D;AAED,wBAAgB,iBAAiB,IAAI,QAAQ,CAAC,SAAS,CAAC,CAMvD"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../services/logging/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAG/C,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE7B;;;OAGG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC;IAEjC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAE5D;AAED,wBAAgB,iBAAiB,IAAI,QAAQ,CAAC,SAAS,CAAC,CASvD"}
@@ -0,0 +1,25 @@
1
+ import type { LogConsoleFormat } from "./config";
2
+ import type { LogLevel } from "./types";
3
+ /**
4
+ * The lowest level index the console sink writes, or `-1` when it is off.
5
+ * An unknown string is treated as `true` rather than silently dropping every
6
+ * entry: a typo in the config should not hide the logs.
7
+ */
8
+ export declare function consoleThreshold(option: boolean | LogLevel | undefined): number;
9
+ export type ConsoleLogLine = {
10
+ timestamp: string;
11
+ level: LogLevel;
12
+ message: string;
13
+ /** Only what the caller passed, plus `method` and `path` inside a request. */
14
+ metadata: Record<string, unknown>;
15
+ };
16
+ export declare function formatConsoleLine(line: ConsoleLogLine, format: LogConsoleFormat): string;
17
+ /**
18
+ * Writes one entry to stdout or stderr. Never throws: a closed pipe must not
19
+ * become the caller's error.
20
+ */
21
+ export declare function writeConsoleLine(line: ConsoleLogLine, options: {
22
+ threshold: number;
23
+ format: LogConsoleFormat;
24
+ }): void;
25
+ //# sourceMappingURL=consoleSink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consoleSink.d.ts","sourceRoot":"","sources":["../../../services/logging/consoleSink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAexC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,UAStE;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AA6CF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,gBAAgB,GACvB,MAAM,CAeR;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,QAgBzD"}
@@ -1,4 +1,4 @@
1
- import type { ToolContext } from "../../ai/Agent";
1
+ import type { AnyAgentTool, ToolContext } from "../../ai/Agent";
2
2
  import type { User } from "../../auth/types";
3
3
  import type { ProgressSink } from "../../http/modelOriginated";
4
4
  import { type SafeFetchOptions } from "../../http/safeFetch";
@@ -102,6 +102,12 @@ export type McpRemoteFileOptions = {
102
102
  export type McpRegistryOptions = {
103
103
  /** Remote callers' file arguments. See `McpRemoteFileOptions`. */
104
104
  files?: McpRemoteFileOptions;
105
+ /**
106
+ * Answers whether a tool's `feature` is on for the ambient request (#885).
107
+ * Defaults to `Features.enabled` through the container; a test passes its
108
+ * own.
109
+ */
110
+ featureOn?: (key: string) => boolean | Promise<boolean>;
105
111
  };
106
112
  /** What `execute` takes beside the call itself. */
107
113
  export type McpExecuteOptions = {
@@ -168,29 +174,33 @@ export type McpToolAnnotations = {
168
174
  * One tool, described without committing to who consumes it.
169
175
  *
170
176
  * The registry's native output. An in-process agent projects it to an
171
- * `AgentTool` (`toAgentTools`); v2's `tools/list` will project it to JSON.
177
+ * `AgentTool` (`toAgentTools`); v2's `tools/list` projects it to JSON.
172
178
  * Emitting `AgentTool`s here instead would leave v2 reversing JSON Schema back
173
179
  * out of them.
180
+ *
181
+ * Two kinds (#759), told apart by `kind`: a route the app exposed with
182
+ * `fromApiRoute`, and a native tool it registered with `fromTool`. Only a
183
+ * route has a `method` and a `url`.
174
184
  */
175
- export interface McpToolDescriptor {
185
+ export type McpToolDescriptor = McpRouteToolDescriptor | McpNativeToolDescriptor;
186
+ /** What every tool has, whatever it runs. */
187
+ interface McpToolDescriptorBase {
176
188
  /** The `routes` key, verbatim. See `McpRouter`. */
177
189
  readonly name: string;
178
190
  readonly description: string;
179
- readonly method: McpMethod;
180
- /** The route's path as declared, params unfilled. */
181
- readonly url: string;
182
191
  /**
183
- * What the model fills in: the declared `input`, plus a string for every
184
- * `"input"` path param and every `"input"` file field, and the model-facing
185
- * field of every `this.param(...)` (#767), under its own name and schema.
186
- * Bound params and bound files are not in it at all, and neither is the raw
187
- * name of a param the model names in its own terms.
192
+ * What the model fills in. For a route: the declared `input`, plus a string
193
+ * for every `"input"` path param and every `"input"` file field, and the
194
+ * model-facing field of every `this.param(...)` (#767), under its own name
195
+ * and schema. Bound params and bound files are not in it at all, and neither
196
+ * is the raw name of a param the model names in its own terms. For a native
197
+ * tool: the tool's own `inputSchema`.
188
198
  */
189
199
  readonly inputSchema: Schema<Record<string, unknown>>;
190
200
  /**
191
- * The route meta's `output`: the shape of what the tool answers, after
192
- * `result`. Absent when the meta declares none. v2's `tools/list` emits it
193
- * as `outputSchema`.
201
+ * The shape of what the tool answers: a route meta's `output` (after
202
+ * `result`), a native tool's `outputSchema`. Absent when there is none. v2's
203
+ * `tools/list` emits it as `outputSchema`.
194
204
  */
195
205
  readonly outputSchema?: AnySchema;
196
206
  /** The meta's `title`: a name for a client to show. Absent when it declares none. */
@@ -198,9 +208,29 @@ export interface McpToolDescriptor {
198
208
  readonly annotations: Readonly<McpToolAnnotations>;
199
209
  readonly tags: readonly string[];
200
210
  readonly requiresApproval: boolean;
211
+ /**
212
+ * The meta's `feature`: the `app/features` key the tool is offered behind
213
+ * (#885). Absent when it has none. `available` and `execute` apply it;
214
+ * `list` and `descriptors` do not.
215
+ */
216
+ readonly feature?: string;
217
+ }
218
+ /** A route exposed with `fromApiRoute`. */
219
+ export interface McpRouteToolDescriptor extends McpToolDescriptorBase {
220
+ readonly kind: "route";
221
+ readonly method: McpMethod;
222
+ /** The route's path as declared, params unfilled. */
223
+ readonly url: string;
201
224
  /** The controller method mounted at the route, when there is one (#502). */
202
225
  readonly source?: RouteSource;
203
226
  }
227
+ /** An `AgentTool` registered with `fromTool` (#759). */
228
+ export interface McpNativeToolDescriptor extends McpToolDescriptorBase {
229
+ readonly kind: "tool";
230
+ readonly method?: undefined;
231
+ readonly url?: undefined;
232
+ readonly source?: undefined;
233
+ }
204
234
  /**
205
235
  * Narrows `list`. Data rather than a predicate, because v2's per-token
206
236
  * visibility will come from a token's grants, which are data. Both fields
@@ -230,6 +260,23 @@ export declare class McpCallRefusedError extends Error {
230
260
  readonly reason: "unknown-tool" | "approval-required";
231
261
  constructor(message: string, reason: "unknown-tool" | "approval-required");
232
262
  }
263
+ /**
264
+ * The call a native tool is running for (#759): who is calling, the request
265
+ * their identity comes from, the tool and its parsed arguments. `undefined`
266
+ * when the tool was not called through the registry — an agent holding the
267
+ * `AgentTool` directly, or a run with no request to act as.
268
+ *
269
+ * What lets a composite tool run the routes it composes as its own caller:
270
+ *
271
+ * ```ts
272
+ * const call = mcpCallOf(ctx);
273
+ * if (!call) throw new ToolError("…");
274
+ * const pages = await registry.execute(call.caller, "list-pages", {}, ctx);
275
+ * ```
276
+ *
277
+ * A remote caller is held there to the tools its scopes reach, as anywhere.
278
+ */
279
+ export declare function mcpCallOf(ctx: ToolContext): McpCallContext | undefined;
233
280
  /**
234
281
  * The tools an app's `McpRouter` declares, resolved against the api route
235
282
  * table, and the one place a call to them is dispatched.
@@ -260,6 +307,7 @@ export declare class McpRegistry<R extends McpRouter<any> = McpRouter<any>> {
260
307
  /** Each scope, resolved to the names of the tools it reaches. */
261
308
  private readonly scopeTools;
262
309
  private readonly files;
310
+ private readonly featureOn;
263
311
  constructor(router: McpRouter<any>, dispatcher: Pick<ApiRouteDispatcher, "flatRoutes" | "dispatchAs" | "getRouteHandlerAndParams">, options?: McpRegistryOptions);
264
312
  /**
265
313
  * The tools `caller` may see, narrowed by `filter`.
@@ -272,6 +320,13 @@ export declare class McpRegistry<R extends McpRouter<any> = McpRouter<any>> {
272
320
  * does not exist.
273
321
  */
274
322
  list(caller: McpCaller, filter?: McpToolFilter): McpToolDescriptor[];
323
+ /**
324
+ * `list`, narrowed to the tools whose `feature` is on for the ambient
325
+ * request (#885): what the remote endpoint's `tools/list` answers. A tool
326
+ * with no `feature` is always in it. Evaluated in the caller's request
327
+ * context, so a feature's `when` sees the signed-in user.
328
+ */
329
+ available(caller: McpCaller, filter?: McpToolFilter): Promise<McpToolDescriptor[]>;
275
330
  /**
276
331
  * The same listing without a caller, for a projection built once before any
277
332
  * caller exists — `toAgentTools`. It is not per-caller visibility, and a
@@ -327,6 +382,7 @@ export declare class McpRegistry<R extends McpRouter<any> = McpRouter<any>> {
327
382
  * wrote the document it is reading.
328
383
  */
329
384
  execute(caller: McpCaller, name: string, args: unknown, ctx?: ToolContext, options?: McpExecuteOptions): Promise<unknown>;
385
+ private isOn;
330
386
  private plan;
331
387
  /**
332
388
  * What a remote caller sends for a file field: `{ name, mimeType, data }`,
@@ -340,6 +396,41 @@ export declare class McpRegistry<R extends McpRouter<any> = McpRouter<any>> {
340
396
  * so.
341
397
  */
342
398
  private remoteFileSchema;
399
+ /**
400
+ * A native tool (#759), checked as a route is: at boot, with a sentence
401
+ * naming the tool, so a tool the registry cannot list or run fails here
402
+ * rather than on the first call.
403
+ */
404
+ private planNative;
405
+ /**
406
+ * The `AgentTool` registered as the native tool `name`.
407
+ *
408
+ * @internal For `toAgentTools`, which carries its `timeoutMs` and `async`.
409
+ */
410
+ nativeTool(name: string): AnyAgentTool;
411
+ /**
412
+ * Starts a native tool for a local caller, and answers what its `execute`
413
+ * returns — a promise or a generator, untouched — so `toAgentTools` hands
414
+ * the agent loop exactly what the tool would have, its yields and its job
415
+ * handle included.
416
+ *
417
+ * Without a caller — a run that was not started inside a request — the tool
418
+ * runs as the agent would run it directly, and `mcpCallOf` answers
419
+ * `undefined` inside it.
420
+ *
421
+ * @internal For `toAgentTools`. App code calls `execute`.
422
+ */
423
+ startNative(caller: McpCaller | undefined, name: string, args: unknown, ctx: ToolContext): ReturnType<NonNullable<AnyAgentTool["execute"]>>;
424
+ /** Hands the tool a context of its own, keyed to the call, and starts it. */
425
+ private runNative;
426
+ /**
427
+ * `execute` for a native tool. Local: run with the caller's `ctx`, its
428
+ * yields reported to `options.progress`. Remote: the meta's `remote` builds
429
+ * the context, and the answer is held to what a route's is — parsed by the
430
+ * output schema when there is one, cut at `MAX_RESULT_BODY` — and every
431
+ * failure but a `ToolError` is the server's, logged.
432
+ */
433
+ private executeNative;
343
434
  private fillPath;
344
435
  private formData;
345
436
  /**
@@ -388,4 +479,5 @@ export declare class McpRegistry<R extends McpRouter<any> = McpRouter<any>> {
388
479
  */
389
480
  private bind;
390
481
  }
482
+ export {};
391
483
  //# sourceMappingURL=McpRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpRegistry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AC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE;IAIjD;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAIjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,OAAO,CACX,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,GAAG,CAAC,EAAE,WAAW,EACjB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,OAAO,CAAC;YA6HL,IAAI;IAMlB,OAAO,CAAC,IAAI;IAwLZ;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;IA6DxB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IA0ElB;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAQtC;;;;;;;;;;;OAWG;IACH,WAAW,CACT,MAAM,EAAE,SAAS,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,WAAW,GACf,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;IAiBnD,6EAA6E;IAC7E,OAAO,CAAC,SAAS;IASjB;;;;;;OAMG;YACW,aAAa;YA8Gb,QAAQ;YAuCR,QAAQ;IA6CtB;;;;;;OAMG;YACW,UAAU;IAgExB,+EAA+E;IAC/E,OAAO,CAAC,MAAM;IAOd;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAuCrB;;;;;;;;;;;;;;OAcG;YACW,OAAO;IAgDrB;;;;;;;;;;OAUG;YACW,IAAI;CAcnB"}
@@ -1,4 +1,5 @@
1
1
  import { type NonceStore } from "../../../ai/store/Nonces";
2
+ import type { FeatureKey } from "../../../client/rpc";
2
3
  import { type McpRegistry } from "../McpRegistry";
3
4
  import { type McpCallerResolver } from "./callers";
4
5
  /**
@@ -10,6 +11,27 @@ export type McpRemoteHttpConfig = {
10
11
  * read, until an app turns it on.
11
12
  */
12
13
  enabled?: boolean;
14
+ /**
15
+ * Serves the endpoint only while this `app/features` flag is on (#885), so
16
+ * turning it on or off is a switch in the `FeatureFlag` table rather than a
17
+ * deploy. `enabled` still has to be `true`: it is what builds and checks the
18
+ * endpoint at boot (`url`, `resolvers`, `SECRET`), whatever the flag says.
19
+ *
20
+ * Off: the endpoint and every resolver endpoint — the OAuth metadata,
21
+ * registration, authorize, consent, token and revoke — answer as they do
22
+ * with `enabled: false`, falling through to the app's routes (a 404).
23
+ *
24
+ * Asked only for the paths the endpoint can own: its path, the paths under
25
+ * it, and `/.well-known/…`, so the rest of the app's traffic never
26
+ * evaluates it. With `feature` set, a custom resolver's `handle()` is asked
27
+ * only for those paths too. It is evaluated before any credential is read,
28
+ * so there is no user: use it as an on/off switch — a `when` sees an
29
+ * anonymous request.
30
+ *
31
+ * `server.version` does not change with it, nor with the features of
32
+ * individual tools: see `server`.
33
+ */
34
+ feature?: FeatureKey;
13
35
  /**
14
36
  * The endpoint's canonical URL, like `"https://example.com/mcp"`: where it
15
37
  * is served (its path), which host it answers on, and the OAuth `resource`
@@ -43,7 +65,17 @@ export type McpRemoteHttpConfig = {
43
65
  } | false;
44
66
  /** The largest request body accepted, in bytes. Default: room for one file of `files.maxBytes` as base64, plus 1 MiB. */
45
67
  maxBodyBytes?: number;
46
- /** What `initialize` and `server/discover` say about the server. */
68
+ /**
69
+ * What `initialize` and `server/discover` say about the server.
70
+ *
71
+ * `version` is sent as given. gemi does not fold feature state into it — not
72
+ * the endpoint's `feature`, nor a tool's — because tools behind a `when` are
73
+ * per user: two callers would be told different versions of one server,
74
+ * and a client comparing them would read a flag as a deploy. A flip reaches
75
+ * clients through `tools/list`, which is cached privately for 60 s. An app
76
+ * that derives `version` from its tool names should hash every declared tool
77
+ * (`registry.descriptors()`), not the ones a caller is shown.
78
+ */
47
79
  server?: {
48
80
  name?: string;
49
81
  version?: string;
@@ -85,11 +117,16 @@ export declare class McpHttpServer {
85
117
  private readonly instructions?;
86
118
  private readonly nonces;
87
119
  private readonly approvalTimeoutMs;
120
+ /** `feature`: the flag the endpoint is served behind, if any (#885). */
121
+ private readonly feature?;
122
+ private readonly featureOn;
88
123
  /** Legacy elicitations waiting for the client's answer, by the request id they were sent under. */
89
124
  private readonly pending;
90
125
  /** Legacy calls in flight, so `notifications/cancelled` can stop one. */
91
126
  private readonly inflight;
92
- constructor(registry: McpRegistry, config: McpRemoteHttpConfig);
127
+ constructor(registry: McpRegistry, config: McpRemoteHttpConfig, options?: {
128
+ featureOn?: (key: string) => boolean | Promise<boolean>;
129
+ });
93
130
  /** The endpoint's URL as a resource identifier: no trailing slash, no query. */
94
131
  get resource(): string;
95
132
  /**
@@ -101,6 +138,8 @@ export declare class McpHttpServer {
101
138
  * and is answered by the app's ordinary routes, never by this.
102
139
  */
103
140
  handle(req: Request): Promise<Response | null>;
141
+ /** The endpoint's path, a path under it, or `/.well-known/…`. */
142
+ private ownsPath;
104
143
  private post;
105
144
  private dispatch;
106
145
  private modern;
@@ -1 +1 @@
1
- {"version":3,"file":"McpHttpServer.d.ts","sourceRoot":"","sources":["../../../../services/mcp/http/McpHttpServer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAK7E,OAAO,EAIL,KAAK,WAAW,EAGjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAe,KAAK,iBAAiB,EAA0B,MAAM,WAAW,CAAC;AAuBxF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAChC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;;;OAKG;IACH,SAAS,CAAC,EAAE;QA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EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;KAAO;IAsD3E,gFAAgF;IAChF,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;;;;;OAOG;IACG,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IA4CpD,iEAAiE;IACjE,OAAO,CAAC,QAAQ;YAYF,IAAI;YA8DJ,QAAQ;YA8FR,MAAM;YAyBN,MAAM;IAapB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,UAAU;IA6BlB;;;;;;;OAOG;IACH,OAAO,CAAC,OAAO;IAiBf,OAAO,CAAC,kBAAkB;YAkCZ,QAAQ;IA2DtB,OAAO,CAAC,UAAU;IAIlB;;;;;;;;;;;;OAYG;YACW,QAAQ;YAyFR,UAAU;IAaxB;;;;;OAKG;YACW,OAAO;IA4CrB,OAAO,CAAC,YAAY;IAapB;;;;OAIG;YACW,aAAa;YAMb,KAAK;CAKpB"}
@@ -1,5 +1,5 @@
1
1
  import { AgentTool, ToolNamespace, type AnyAgentTool, type ToolEntry, type ToolShapesOf } from "../../ai/Agent";
2
- import type { McpRouteDeclaration, McpRouter } from "../../http/McpRouter";
2
+ import type { McpRouteDeclaration, McpRouter, McpToolDeclaration } from "../../http/McpRouter";
3
3
  import type { McpRegistry, McpToolFilter } from "./McpRegistry";
4
4
  /** One namespace `toAgentTools` groups a tag's tools into. */
5
5
  export type McpToolNamespaceOptions = {
@@ -34,6 +34,18 @@ export type ToAgentToolsOptions = {
34
34
  type RoutesOf<R> = R extends {
35
35
  routes: infer T;
36
36
  } ? T : never;
37
+ /** What a declaration types its tool as: a route's or a native tool's (#759). */
38
+ type ToolTypesOf<D> = D extends McpRouteDeclaration<any, any, infer I, infer O, infer T> ? {
39
+ input: I;
40
+ output: O;
41
+ tags: T;
42
+ progress: never;
43
+ } : D extends McpToolDeclaration<infer I, infer O, infer T, infer P> ? {
44
+ input: I;
45
+ output: O;
46
+ tags: T;
47
+ progress: P;
48
+ } : never;
37
49
  /** Whether a filter's field narrows by literals, rather than by `string`s. */
38
50
  type LiteralsOf<L> = L extends readonly (infer X)[] ? (string extends X ? never : X) : never;
39
51
  /** Whether the tool `N`, declared as `D`, passes the filter `F`. */
@@ -41,7 +53,9 @@ type Passes<N, D, F> = (F extends {
41
53
  names: readonly string[];
42
54
  } ? [LiteralsOf<F["names"]>] extends [never] ? true : N extends LiteralsOf<F["names"]> ? true : false : true) extends true ? F extends {
43
55
  tags: readonly string[];
44
- } ? [LiteralsOf<F["tags"]>] extends [never] ? true : D extends McpRouteDeclaration<any, any, any, any, infer T> ? string extends T[number] ? true : [Extract<T[number], LiteralsOf<F["tags"]>>] extends [never] ? false : true : true : true : false;
56
+ } ? [LiteralsOf<F["tags"]>] extends [never] ? true : ToolTypesOf<D> extends {
57
+ tags: infer T extends readonly string[];
58
+ } ? string extends T[number] ? true : [Extract<T[number], LiteralsOf<F["tags"]>>] extends [never] ? false : true : true : true : false;
45
59
  /**
46
60
  * The tools of the router `R` that pass the filter `F`, as `toAgentTools`
47
61
  * builds them: named by their `routes` key, with the input the model sends and
@@ -49,7 +63,11 @@ type Passes<N, D, F> = (F extends {
49
63
  * container answers) gives `AnyAgentTool`, as before.
50
64
  */
51
65
  export type McpAgentTool<R extends McpRouter<any>, F = {}> = string extends keyof RoutesOf<R> ? AnyAgentTool : {
52
- [N in keyof RoutesOf<R> & string]: Passes<N, RoutesOf<R>[N], F> extends true ? RoutesOf<R>[N] extends McpRouteDeclaration<any, any, infer I, infer O, any> ? AgentTool<N, I, O, never> : never : never;
66
+ [N in keyof RoutesOf<R> & string]: Passes<N, RoutesOf<R>[N], F> extends true ? ToolTypesOf<RoutesOf<R>[N]> extends {
67
+ input: infer I;
68
+ output: infer O;
69
+ progress: infer P;
70
+ } ? AgentTool<N, I, O, P> : never : never;
53
71
  }[keyof RoutesOf<R> & string];
54
72
  /**
55
73
  * The client's shapes of the router's tools, as `ToolShapesOf` gives them for
@@ -1 +1 @@
1
- {"version":3,"file":"toAgentTools.d.ts","sourceRoot":"","sources":["../../../services/mcp/toAgentTools.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,KAAK,EAAE,WAAW,EAAqB,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnF,8DAA8D;AAC9D,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,4DAA4D;IAC5D,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CACtD,CAAC;AAIF,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAE7D,8EAA8E;AAC9E,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,SAAS,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AAE7F,oEAAoE;AACpE,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAEjB,CAAC,CAAC,SAAS;IAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACnC,CAAC,UAA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  // @bun
2
- import{Rc as H,Uc as _}from"../../chunk-92sk56n0.js";import{gi as O}from"../../chunk-skf89vrv.js";import"../../chunk-mqtfaqx5.js";import"../../chunk-pe46a5a5.js";import"../../chunk-qycwjzsv.js";import"../../chunk-mvkz22p4.js";import"../../chunk-rpyczdta.js";import"../../chunk-zsvav1dk.js";import{Cj as Z,yj as U,zj as V}from"../../chunk-nnarmbjv.js";import{Gj as Y}from"../../chunk-nkzmk7v3.js";import"../../chunk-17dndh5z.js";import X from"path";function T(z){if(!z.config.get("route.channels"))return null;let C=z.config.get("broadcast",{}).driver;if(!(C===void 0||C==="memory"||C instanceof O))return null;return'[gemi] Broadcasts from this worker reach no one: the broadcast driver is "memory", which delivers to the sockets of the process that emits, and a worker has none. Set `driver: "redis"` in app/config/broadcast.ts.'}class J extends Error{name="QueueWorkerRefused"}class N{kernel;stopping;keepAlive;settings;constructor(z,C={}){this.kernel=z;this.settings={...V(),...C}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let z=this.kernel.app;if(!z.bound(H))throw new J("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let C=z.make(H);if(!C.durable)throw new J('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');C.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${C.config.concurrency} job(s) at a time.`);let E=T(z);if(E)console.warn(E)}stop(z={}){return this.stopping??=this.drain({...this.settings,...z}),this.stopping}async drain(z){U();let C=this.kernel.app,E=C.resolved(H)?C.make(H):void 0;if(E)console.log(`[gemi] Shutting down: waiting for ${E.running} running job(s) (up to ${z.timeoutMs/1000}s).`),await E.drain(z.timeoutMs);let F=await this.kernel.shutdown({timeoutMs:z.providerTimeoutMs});clearInterval(this.keepAlive);let G=(E?.running??0)===0&&F.failed.length===0&&F.timedOut.length===0;return console.log(`[gemi] Shutdown ${G?"complete":"finished with errors"}.`),G?0:1}}async function $(){let z=Y();process.env.ROOT_DIR=z,process.env.APP_DIR=X.join(z,"app"),_();let C=X.join(z,"app/kernel/Kernel.ts"),{default:E}=await import(C);if(typeof E!=="function")return console.error(`[gemi] ${C} has no default export to boot the worker from.`),1;let F=new E;F.boot();let G=new N(F);Z(()=>G.stop());try{await G.start()}catch(L){if(!(L instanceof J))throw L;return console.error(L.message),1}return}$().then((z)=>{if(z!==void 0)process.exit(z)},(z)=>{console.error("[gemi] The queue worker failed to start:",z),process.exit(1)});
2
+ import{Dd as H,Gd as _}from"../../chunk-h8w9mzjj.js";import{$i as O}from"../../chunk-entpqjyn.js";import"../../chunk-rany5zgk.js";import"../../chunk-sv125fqq.js";import"../../chunk-vhvvjaj3.js";import"../../chunk-npbf06c1.js";import"../../chunk-6gwxvmjv.js";import"../../chunk-rwmja4zs.js";import{rk as U,sk as V,wk as Z}from"../../chunk-z5nfve1k.js";import{Ak as Y}from"../../chunk-yhht1j7f.js";import"../../chunk-hxn0s3zh.js";import X from"path";function T(z){if(!z.config.get("route.channels"))return null;let C=z.config.get("broadcast",{}).driver;if(!(C===void 0||C==="memory"||C instanceof O))return null;return'[gemi] Broadcasts from this worker reach no one: the broadcast driver is "memory", which delivers to the sockets of the process that emits, and a worker has none. Set `driver: "redis"` in app/config/broadcast.ts.'}class J extends Error{name="QueueWorkerRefused"}class N{kernel;stopping;keepAlive;settings;constructor(z,C={}){this.kernel=z;this.settings={...V(),...C}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let z=this.kernel.app;if(!z.bound(H))throw new J("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let C=z.make(H);if(!C.durable)throw new J('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');C.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${C.config.concurrency} job(s) at a time.`);let E=T(z);if(E)console.warn(E)}stop(z={}){return this.stopping??=this.drain({...this.settings,...z}),this.stopping}async drain(z){U();let C=this.kernel.app,E=C.resolved(H)?C.make(H):void 0;if(E)console.log(`[gemi] Shutting down: waiting for ${E.running} running job(s) (up to ${z.timeoutMs/1000}s).`),await E.drain(z.timeoutMs);let F=await this.kernel.shutdown({timeoutMs:z.providerTimeoutMs});clearInterval(this.keepAlive);let G=(E?.running??0)===0&&F.failed.length===0&&F.timedOut.length===0;return console.log(`[gemi] Shutdown ${G?"complete":"finished with errors"}.`),G?0:1}}async function $(){let z=Y();process.env.ROOT_DIR=z,process.env.APP_DIR=X.join(z,"app"),_();let C=X.join(z,"app/kernel/Kernel.ts"),{default:E}=await import(C);if(typeof E!=="function")return console.error(`[gemi] ${C} has no default export to boot the worker from.`),1;let F=new E;F.boot();let G=new N(F);Z(()=>G.stop());try{await G.start()}catch(L){if(!(L instanceof J))throw L;return console.error(L.message),1}return}$().then((z)=>{if(z!==void 0)process.exit(z)},(z)=>{console.error("[gemi] The queue worker failed to start:",z),process.exit(1)});
3
3
 
4
- //# debugId=FEF3202E4247CD0A64756E2164756E21
4
+ //# debugId=8AEC8B819AB1457C64756E2164756E21
@@ -7,6 +7,6 @@
7
7
  "import type { Application, ShutdownReport } from \"../../foundation/Application\";\nimport { markShuttingDown, shutdownSettings, type ShutdownSettings } from \"../../server/shutdown\";\nimport { memoryBroadcastInWorker } from \"../broadcast/workerWarning\";\nimport { QueueManager } from \"./QueueManager\";\n\n/** The part of a `Kernel` a worker drives. */\nexport type WorkerKernel = {\n readonly app: Application;\n waitForBoot(): Promise<void>;\n shutdown(options?: { timeoutMs?: number }): Promise<ShutdownReport>;\n};\n\n/**\n * A worker that was told to start in an application it cannot claim for. The\n * message is written for the operator reading the deploy's logs.\n */\nexport class QueueWorkerRefused extends Error {\n name = \"QueueWorkerRefused\";\n}\n\n/**\n * The process `gemi queue:work` runs: the application booted as a server boots\n * it, claiming from the queue, and no `Bun.serve`. It exists so job capacity\n * can be scaled apart from request traffic, which needs a driver both kinds of\n * process can reach; see `start` for why the memory driver is refused.\n *\n * The caller marks the process as a worker (`markQueueWorker`) before the\n * kernel registers, so every claim rule that asks `claimsInThisProcess` sees a\n * process that claims, whatever `GEMI_QUEUE_CLAIM` says.\n */\nexport class QueueWorker {\n private stopping: Promise<number> | undefined;\n private keepAlive: ReturnType<typeof setInterval> | undefined;\n private readonly settings: ShutdownSettings;\n\n /**\n * `settings` default to the `GEMI_SHUTDOWN_*` variables, read here rather\n * than at the signal so a bad value is warned about while the deploy is\n * being watched, as `Server.start` does.\n */\n constructor(\n private readonly kernel: WorkerKernel,\n settings: Partial<ShutdownSettings> = {},\n ) {\n this.settings = { ...shutdownSettings(), ...settings };\n }\n\n /**\n * Boots the application and starts claiming. Rejects with\n * `QueueWorkerRefused` when the application has no queue, or its queue uses\n * the memory driver.\n *\n * Refused rather than warned about, because a memory worker can never do\n * anything: its jobs live in a `Map` in the process that dispatched them,\n * so a worker's is always empty. Left running, it looks like a healthy\n * deploy — a process up, no errors — that runs nothing, and scaling it out\n * adds no capacity. An exit the platform reports as a crash loop is a form\n * of the mistake someone will see.\n */\n async start(): Promise<void> {\n await this.kernel.waitForBoot();\n // A signal during the boot has already drained and cleared the handle\n // below. Going on would start the loop again and arm a handle nothing\n // clears, holding open a worker that has finished shutting down.\n if (this.stopping) return;\n\n const application = this.kernel.app;\n // `bound`, not `make` in a try: an application built without the queue\n // provider is a configuration to name, not an unbound-token stack trace.\n if (!application.bound(QueueManager)) {\n throw new QueueWorkerRefused(\n \"[gemi] `gemi queue:work` has no queue to claim from: this application \" +\n \"does not register QueueServiceProvider.\",\n );\n }\n const queue = application.make(QueueManager);\n if (!queue.durable) {\n throw new QueueWorkerRefused(\n \"[gemi] `gemi queue:work` refuses to start: the queue uses the memory \" +\n \"driver, which keeps each job in the process that dispatched it, so \" +\n 'a worker never sees one. Set `driver: \"database\"` (or another driver ' +\n \"every process can reach) in app/config/queue.ts, or run jobs in the \" +\n \"server and drop the worker.\",\n );\n }\n\n // Idempotent: a production boot with a durable driver has already started\n // it (`startClaimingIfServing`). Development has not, and a worker claims\n // in either.\n queue.start();\n // The queue's poll timer is unref'd, so that a script's queue does not\n // hold it open; here the queue is the process, and without a handle of its\n // own an idle worker would exit 0 as soon as it booted.\n this.keepAlive = setInterval(() => {}, 1 << 30);\n console.log(\n `[gemi] Queue worker started: claiming up to ${queue.config.concurrency} job(s) at a time.`,\n );\n const broadcastWarning = memoryBroadcastInWorker(application);\n if (broadcastWarning) console.warn(broadcastWarning);\n }\n\n /**\n * Stops claiming, waits for the running jobs, runs every provider's\n * `shutdown()`, and resolves with the exit code: 0 when no job was left\n * running and every provider finished in time, 1 otherwise. Idempotent.\n *\n * `gemi start`'s drain, with the jobs where the requests were:\n * `isShuttingDown()` turns true, which stops a durable queue claiming;\n * running jobs get `timeoutMs` (`GEMI_SHUTDOWN_TIMEOUT`), which a server\n * spends on requests; then `Application.shutdown` gets `providerTimeoutMs`,\n * and in it the queue provider waits for whatever is still running and\n * names it. The two budgets add up as they do for a server, so a worker\n * fits the same grace period. `delayMs` is not waited: it is for a load\n * balancer, and nothing routes to a worker.\n */\n stop(settings: Partial<ShutdownSettings> = {}): Promise<number> {\n this.stopping ??= this.drain({ ...this.settings, ...settings });\n return this.stopping;\n }\n\n private async drain(settings: ShutdownSettings): Promise<number> {\n markShuttingDown();\n const application = this.kernel.app;\n // Resolving the manager now would build a driver only to stop it, which\n // is what a signal during the boot, before the provider resolved it, finds.\n const queue = application.resolved(QueueManager) ? application.make(QueueManager) : undefined;\n if (queue) {\n console.log(\n `[gemi] Shutting down: waiting for ${queue.running} running job(s) ` +\n `(up to ${settings.timeoutMs / 1000}s).`,\n );\n await queue.drain(settings.timeoutMs);\n }\n\n const report = await this.kernel.shutdown({ timeoutMs: settings.providerTimeoutMs });\n clearInterval(this.keepAlive);\n const clean =\n (queue?.running ?? 0) === 0 && report.failed.length === 0 && report.timedOut.length === 0;\n console.log(`[gemi] Shutdown ${clean ? \"complete\" : \"finished with errors\"}.`);\n return clean ? 0 : 1;\n }\n}\n"
8
8
  ],
9
9
  "mappings": ";gcAYA,kBCDO,OAAS,DAAuB,DAAC,AAAyC,DAC/E,CAAI,DAAC,AAAY,KAAO,IAAI,gBAAgB,EAAG,OAAO,KACtD,IAAM,EAAS,EAAY,OAAO,IAAqB,YAAa,CAAC,CAAC,EAAE,OAGxE,GAAI,EADF,IAAW,QAAa,IAAW,UAAY,aAAkB,GACtD,OAAO,KACpB,MACE,uNCFG,MAAM,UAA2B,KAAM,CAC5C,KAAO,oBACT,CAYO,MAAM,CAAY,CAWJ,OAVX,SACA,UACS,SAOjB,WAAW,CACQ,EACjB,EAAsC,CAAC,EACvC,CAFiB,cAGjB,KAAK,SAAW,IAAK,EAAiB,KAAM,CAAS,OAejD,MAAK,EAAkB,CAK3B,GAJA,MAAM,KAAK,OAAO,YAAY,EAI1B,KAAK,SAAU,OAEnB,IAAM,EAAc,KAAK,OAAO,IAGhC,GAAI,CAAC,EAAY,MAAM,CAAY,EACjC,MAAM,IAAI,EACR,+GAEF,EAEF,IAAM,EAAQ,EAAY,KAAK,CAAY,EAC3C,GAAI,CAAC,EAAM,QACT,MAAM,IAAI,EACR,8SAKF,EAMF,EAAM,MAAM,EAIZ,KAAK,UAAY,YAAY,IAAM,GAAI,UAAO,EAC9C,QAAQ,IACN,+CAA+C,EAAM,OAAO,+BAC9D,EACA,IAAM,EAAmB,EAAwB,CAAW,EAC5D,GAAI,EAAkB,QAAQ,KAAK,CAAgB,EAiBrD,IAAI,CAAC,EAAsC,CAAC,EAAoB,CAE9D,OADA,KAAK,WAAa,KAAK,MAAM,IAAK,KAAK,YAAa,CAAS,CAAC,EACvD,KAAK,cAGA,MAAK,CAAC,EAA6C,CAC/D,EAAiB,EACjB,IAAM,EAAc,KAAK,OAAO,IAG1B,EAAQ,EAAY,SAAS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umeOptions {
9
9
  /** How much this call costs. Defaults to `1`. */
10
10
  cost?: number;
11
11
  }
12
+ /**
13
+ * What a refusal from `enforce` says: a string, or one built from the result
14
+ * that refused it (`retryAfter` is in milliseconds).
15
+ */
16
+ export type RateLimitMessage = string | ((result: RateLimitResult) => string);
12
17
  export declare class RateLimiter {
13
18
  config: Required<RateLimiterConfig>;
14
19
  static token: string;
@@ -21,5 +26,12 @@ export declare class RateLimiter {
21
26
  * are written in — and converted to the milliseconds drivers work in.
22
27
  */
23
28
  consume(key: string, options?: ConsumeOptions): Promise<RateLimitResult>;
29
+ /**
30
+ * `consume`, refusing the request when it does not fit: over budget it throws
31
+ * `RateLimitExceededError`, the same 429 the `rate-limit` middleware answers
32
+ * (`Retry-After` and `X-RateLimit-*` headers, `{ error: { kind: "rate_limit",
33
+ * message, status: 429, retryAfter } }`). Within budget it returns the result.
34
+ */
35
+ enforce(key: string, options?: ConsumeOptions, message?: RateLimitMessage): Promise<RateLimitResult>;
24
36
  }
25
37
  //# sourceMappingURL=RateLimiter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RateLimiter.d.ts","sourceRoot":"","sources":["../../../services/rate-limiter/RateLimiter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,WAAW;IAGH,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IAFtD,MAAM,CAAC,KAAK,SAAiB;gBAEV,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IAEtD,IAAI,MAAM,IAAI,iBAAiB,CAE9B;IAED;;;;;OAKG;IACG,OAAO,CACX,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,eAAe,CAAC;CAsB5B"}
1
+ {"version":3,"file":"RateLimiter.d.ts","sourceRoot":"","sources":["../../../services/rate-limiter/RateLimiter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,MAAM,CAAC,CAAC;AAE9E,qBAAa,WAAW;IAGH,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IAFtD,MAAM,CAAC,KAAK,SAAiB;gBAEV,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IAEtD,IAAI,MAAM,IAAI,iBAAiB,CAE9B;IAED;;;;;OAKG;IACG,OAAO,CACX,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,eAAe,CAAC;IAuB3B;;;;;OAKG;IACG,OAAO,CACX,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,cAAmB,EAC5B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,eAAe,CAAC;CAU5B"}
@@ -25,9 +25,10 @@ export interface GlobalMiddlewareOutcome {
25
25
  * `HttpRequest` a global middleware gets has no params and an empty
26
26
  * `routePath`, and its `kind` is read off the url the way `App.fetch` picks a
27
27
  * dispatcher. The scope is not the one the route later runs in: the route's
28
- * dispatcher opens a fresh one, as it always has. Two things cross over.
29
- * Headers and cookies reach the response through `apply`, and the user is
30
- * `carried` into the route's context, so a gate that looked the user up does
28
+ * dispatcher opens a fresh one, as it always has. Three things cross over.
29
+ * Headers and cookies reach the response through `apply`; the request state
30
+ * the list set (`req.state`, #887) is `carried` into the route's request; and
31
+ * so is the user, so a gate that looked the user up does
31
32
  * not make `auth` or `Auth.user()` look them up again. Both trust a user they
32
33
  * find on the context without checking it against a session or asking for a
33
34
  * token, so whatever a global middleware sets is treated as authenticated by
@@ -1 +1 @@
1
- {"version":3,"file":"globalMiddleware.d.ts","sourceRoot":"","sources":["../../../services/router/globalMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,2BAA2B,CAAC;AAShF,MAAM,WAAW,uBAAuB;IACtC,+EAA+E;IAC/E,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACpC;;;OAGG;IACH,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CAChC;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAuDxF"}
1
+ {"version":3,"file":"globalMiddleware.d.ts","sourceRoot":"","sources":["../../../services/router/globalMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,2BAA2B,CAAC;AAShF,MAAM,WAAW,uBAAuB;IACtC,+EAA+E;IAC/E,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACpC;;;OAGG;IACH,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CAChC;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAuDxF"}
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import"../chunk-17dndh5z.js";import M from"path";import{writeFileSync as Q}from"fs";var L=new Set(["FILE","REDIRECT"]);function H(j){return j.run(()=>{let x=[];for(let{group:z,view:D}of j.domains().viewGroups())for(let[G,B]of Object.entries(D.flatViewRoutes)){let C=D.routeManifest[G]??B.segments.map((K)=>K.viewPath);if(C.length===0||L.has(C.at(-1)))continue;x.push({path:G,group:z,views:C,...B.static?{static:{...B.static.layout?{layout:B.static.layout}:{},...B.static.navigation?{navigation:!0}:{}}}:{}})}return x})}var J=process.argv[2];async function U(){if(!J)throw Error("usage: route-table <out.json>");let j=M.resolve(process.cwd(),"app/kernel/Kernel.ts"),x=await import(j);if(typeof x.default!=="function")throw Error(`${j} has no default export (the Kernel subclass).`);let z=new x.default;z.boot();try{Q(J,JSON.stringify(H(z)))}finally{z.destroy()}}U().then(()=>process.exit(0),(j)=>{console.error(j?.stack??String(j)),process.exit(1)});
2
+ import"../chunk-hxn0s3zh.js";import M from"path";import{writeFileSync as Q}from"fs";var L=new Set(["FILE","REDIRECT"]);function H(j){return j.run(()=>{let x=[];for(let{group:z,view:D}of j.domains().viewGroups())for(let[G,B]of Object.entries(D.flatViewRoutes)){let C=D.routeManifest[G]??B.segments.map((K)=>K.viewPath);if(C.length===0||L.has(C.at(-1)))continue;x.push({path:G,group:z,views:C,...B.static?{static:{...B.static.layout?{layout:B.static.layout}:{},...B.static.navigation?{navigation:!0}:{}}}:{}})}return x})}var J=process.argv[2];async function U(){if(!J)throw Error("usage: route-table <out.json>");let j=M.resolve(process.cwd(),"app/kernel/Kernel.ts"),x=await import(j);if(typeof x.default!=="function")throw Error(`${j} has no default export (the Kernel subclass).`);let z=new x.default;z.boot();try{Q(J,JSON.stringify(H(z)))}finally{z.destroy()}}U().then(()=>process.exit(0),(j)=>{console.error(j?.stack??String(j)),process.exit(1)});
3
3
 
4
4
  //# debugId=05EB0087C5A2060D64756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Yc as Y}from"../chunk-30xxc6r7.js";import{ki as M}from"../chunk-pe46a5a5.js";import{mj as P,oj as R}from"../chunk-rpyczdta.js";import"../chunk-zsvav1dk.js";import{Dj as Q,Ej as U,Fj as V,Gj as W}from"../chunk-nkzmk7v3.js";import"../chunk-17dndh5z.js";class S{static token;async boot(){}static inject(){if(!this.token)throw Error(`Service [${this.name}] does not declare a \`static token\`, so the container has no key to resolve it by.`);try{return R(this)}catch(x){throw Error(`Could not inject [${this.name}]. Services are constructed when the kernel boots, so `+"inject() only works from code that runs after that \u2014 a constructor default or a method "+`body, never module top level. Check that [${this.name}] is listed in \`services\` on your Kernel.`,{cause:x})}}static with(x){let f=new this;for(let[C,g]of Object.entries(x))if(g!==void 0)f[C]=g;return f}}import{readdir as z}from"fs/promises";import{join as B,parse as j}from"path";var H=[".ts",".tsx",".js",".mjs",".jsx"];function J(x={}){let f={};for(let[C,g]of Object.entries(x))f[C]=q(g);return new P(f)}async function L(x,f=new P){let C=[];try{C=await z(x)}catch(D){return f}let g=C.filter((D)=>{let{ext:v,name:F}=j(D);return H.includes(v)&&!F.startsWith(".")}).sort();for(let D of g){let{name:v}=j(D),F=await import(B(x,D));f.set(v,q(F))}return f}function q(x){if(x&&typeof x==="object"&&"default"in x)return x.default;return x}export{M as withDefaults,Q as sourceFiles,W as projectRoot,L as loadConfigFrom,V as discoverClasses,J as createConfigRepository,Y as ServiceProvider,S as Service,P as Repository,U as DiscoveryError};
2
+ import{Ld as Y}from"../chunk-rmgkc3a2.js";import{dj as M}from"../chunk-sv125fqq.js";import{fk as P,hk as R}from"../chunk-6gwxvmjv.js";import"../chunk-rwmja4zs.js";import{Ak as W,xk as Q,yk as U,zk as V}from"../chunk-yhht1j7f.js";import"../chunk-hxn0s3zh.js";class S{static token;async boot(){}static inject(){if(!this.token)throw Error(`Service [${this.name}] does not declare a \`static token\`, so the container has no key to resolve it by.`);try{return R(this)}catch(x){throw Error(`Could not inject [${this.name}]. Services are constructed when the kernel boots, so `+"inject() only works from code that runs after that \u2014 a constructor default or a method "+`body, never module top level. Check that [${this.name}] is listed in \`services\` on your Kernel.`,{cause:x})}}static with(x){let f=new this;for(let[C,g]of Object.entries(x))if(g!==void 0)f[C]=g;return f}}import{readdir as z}from"fs/promises";import{join as B,parse as j}from"path";var H=[".ts",".tsx",".js",".mjs",".jsx"];function J(x={}){let f={};for(let[C,g]of Object.entries(x))f[C]=q(g);return new P(f)}async function L(x,f=new P){let C=[];try{C=await z(x)}catch(D){return f}let g=C.filter((D)=>{let{ext:v,name:F}=j(D);return H.includes(v)&&!F.startsWith(".")}).sort();for(let D of g){let{name:v}=j(D),F=await import(B(x,D));f.set(v,q(F))}return f}function q(x){if(x&&typeof x==="object"&&"default"in x)return x.default;return x}export{M as withDefaults,Q as sourceFiles,W as projectRoot,L as loadConfigFrom,V as discoverClasses,J as createConfigRepository,Y as ServiceProvider,S as Service,P as Repository,U as DiscoveryError};
3
3
 
4
- //# debugId=B8296DBCE0424B4764756E2164756E21
4
+ //# debugId=3937A60BDA2B21DC64756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "import { readdir } from \"node:fs/promises\";\nimport { join, parse } from \"node:path\";\n\nimport { Repository } from \"./Repository\";\n\nconst CONFIG_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".mjs\", \".jsx\"];\n\n// Builds a Repository from an already-imported map of config modules. The map\n// key becomes the top-level config key, so `{ mail: mailModule }` is readable\n// as `config.get(\"mail.driver\")`. Each entry may be either the module namespace\n// (its `default` export is unwrapped) or the config object itself.\nexport function createConfigRepository(\n modules: Record<string, any> = {},\n): Repository {\n const items: Record<string, any> = {};\n\n for (const [key, mod] of Object.entries(modules)) {\n items[key] = unwrap(mod);\n }\n\n return new Repository(items);\n}\n\n// Reads every config module in an app's `app/config` directory into a\n// Repository. The file's basename is the top-level key: `app/config/mail.ts`\n// populates `mail.*`. A missing directory yields an empty Repository so apps\n// that declare no config still boot.\nexport async function loadConfigFrom(\n directory: string,\n repository = new Repository(),\n): Promise<Repository> {\n let entries: string[] = [];\n\n try {\n entries = await readdir(directory);\n } catch (err) {\n return repository;\n }\n\n const files = entries\n .filter((entry) => {\n const { ext, name } = parse(entry);\n return CONFIG_EXTENSIONS.includes(ext) && !name.startsWith(\".\");\n })\n .sort();\n\n for (const file of files) {\n const { name } = parse(file);\n const mod = await import(join(directory, file));\n repository.set(name, unwrap(mod));\n }\n\n return repository;\n}\n\nfunction unwrap(mod: any) {\n if (mod && typeof mod === \"object\" && \"default\" in mod) {\n return mod.default;\n }\n return mod;\n}\n"
7
7
  ],
8
8
  "mappings": ";2RAgCO,CAAe,JAAQ,EAOrB,OAMD,AAAI,EAAkB,QAmBrB,OAAS,EAKX,CACH,GAAI,CAAC,KAAK,MACR,MAAU,MACR,YAAY,KAAK,0FACnB,EAGF,GAAI,CACF,OAAO,EAAI,IAAuB,EAClC,MAAO,EAAO,CACd,MAAU,MACR,qBAAqB,KAAK,6DACxB,+FACA,6CAA6C,KAAK,kDAEpD,CAAE,OAAM,CACV,SAoBG,KAAuB,CAAoB,EAA0B,CAC1E,IAAM,EAAW,IAAI,KACrB,QAAY,EAAK,KAAU,OAAO,QAAQ,CAAS,EACjD,GAAI,IAAU,OAAW,EAAS,GAAO,EAE3C,OAAO,EAEX,CChHA,kBAAS,oBACT,eAAS,WAAM,aAIf,IAAM,EAAoB,CAAC,MAAO,OAAQ,MAAO,OAAQ,MAAM,EAMxD,SAAS,CAAsB,CACpC,EAA+B,CAAC,EACpB,CACZ,IAAM,EAA6B,CAAC,EAEpC,QAAY,EAAK,KAAQ,OAAO,QAAQ,CAAO,EAC7C,EAAM,GAAO,EAAO,CAAG,E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