@farm.js/core 0.1.73 → 0.1.74

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 (362) hide show
  1. package/dist/{agent-mcp-handler-RK7LDYEL.mjs → agent-mcp-handler-HX4F4VKN.mjs} +4 -4
  2. package/dist/{agent-mcp-handler-VBCA3WZ6.cjs → agent-mcp-handler-NRIL4JBC.cjs} +5 -5
  3. package/dist/{agent-mcp.d-PvEf-1mi.d.mts → agent-mcp.d-BEhDfdWc.d.mts} +1 -1
  4. package/dist/{agent-mcp.d-D_gHjCAE.d.ts → agent-mcp.d-CX8_oOT_.d.ts} +1 -1
  5. package/dist/agent-runtime.cjs +4 -4
  6. package/dist/agent-runtime.d.mts +4 -4
  7. package/dist/agent-runtime.d.ts +4 -4
  8. package/dist/agent-runtime.mjs +3 -3
  9. package/dist/{analyzer-MFYCJT75.mjs → analyzer-2K35LIQZ.mjs} +2 -2
  10. package/dist/analyzer-6EOYURMV.cjs +16 -0
  11. package/dist/api/client.d.mts +3 -3
  12. package/dist/api/client.d.ts +3 -3
  13. package/dist/api/client.native.d.mts +4 -4
  14. package/dist/api/client.native.d.ts +4 -4
  15. package/dist/api/node.cjs +9 -8
  16. package/dist/api/node.d.mts +6 -6
  17. package/dist/api/node.d.ts +6 -6
  18. package/dist/api/node.mjs +8 -7
  19. package/dist/api/route-manager.cjs +11 -9
  20. package/dist/api/route-manager.d.mts +9 -7
  21. package/dist/api/route-manager.d.ts +9 -7
  22. package/dist/api/route-manager.mjs +10 -8
  23. package/dist/api/runtime.cjs +8 -7
  24. package/dist/api/runtime.d.mts +5 -5
  25. package/dist/api/runtime.d.ts +5 -5
  26. package/dist/api/runtime.mjs +7 -6
  27. package/dist/{api-client.d-Bp35zMqR.d.mts → api-client.d-CyVmI4Di.d.mts} +2 -2
  28. package/dist/{api-client.d-CFI_xL0V.d.ts → api-client.d-DrTM7BdH.d.ts} +2 -2
  29. package/dist/api.cjs +13 -11
  30. package/dist/api.d.mts +9 -9
  31. package/dist/api.d.ts +9 -9
  32. package/dist/api.mjs +12 -10
  33. package/dist/{app-manifest.d-CN7cEWHX.d.mts → app-manifest.d-BcXt2yCx.d.mts} +10 -1
  34. package/dist/{app-manifest.d-BpVTg43i.d.ts → app-manifest.d-CVEx1CFB.d.ts} +10 -1
  35. package/dist/app-markdown.cjs +8 -4
  36. package/dist/app-markdown.d.mts +6 -6
  37. package/dist/app-markdown.d.ts +6 -6
  38. package/dist/app-markdown.mjs +7 -3
  39. package/dist/{app.d-DO4PTCWm.d.ts → app.d-B6i8CSrx.d.ts} +30 -4
  40. package/dist/{app.d-BFWzAdTe.d.mts → app.d-DowzSmT5.d.mts} +30 -4
  41. package/dist/cache.cjs +2 -2
  42. package/dist/cache.d.mts +8 -0
  43. package/dist/cache.d.ts +8 -0
  44. package/dist/cache.mjs +1 -1
  45. package/dist/chunk-2DOI6HLJ.cjs +284 -0
  46. package/dist/chunk-2GQBBOFH.mjs +76 -0
  47. package/dist/{chunk-5LOARKDP.cjs → chunk-2TZ3F6TN.cjs} +29 -17
  48. package/dist/{chunk-TDCP3Z4T.cjs → chunk-35GBGSQZ.cjs} +3 -3
  49. package/dist/{chunk-VPETSSWN.cjs → chunk-3BUJIPKE.cjs} +2 -2
  50. package/dist/{chunk-Y5LEPEVH.mjs → chunk-3ODLJRA6.mjs} +1 -1
  51. package/dist/{chunk-DMAP4RND.cjs → chunk-3OMLZLDE.cjs} +54 -16
  52. package/dist/{chunk-VNBDN5W2.cjs → chunk-47ZDUDN5.cjs} +64 -27
  53. package/dist/{chunk-2W4GNXGX.cjs → chunk-4AB62NMW.cjs} +2 -2
  54. package/dist/{chunk-HDPT6OYE.cjs → chunk-4M5ESTJ2.cjs} +10 -2
  55. package/dist/{chunk-TAU3OF5B.cjs → chunk-56HHUSR5.cjs} +420 -337
  56. package/dist/chunk-5XD2ULJG.mjs +114 -0
  57. package/dist/{chunk-JX5VOLAV.cjs → chunk-65OS2TOT.cjs} +4 -4
  58. package/dist/{chunk-7GMBETHM.mjs → chunk-6JEXH7N6.mjs} +1 -1
  59. package/dist/{chunk-TY5KCYDE.mjs → chunk-72NTEYCX.mjs} +10 -3
  60. package/dist/{chunk-KDOZORJD.cjs → chunk-737MIVX3.cjs} +22 -22
  61. package/dist/{chunk-ROCF6UQD.cjs → chunk-77SVUQM5.cjs} +74 -17
  62. package/dist/{chunk-CKQAQFF6.mjs → chunk-7RKHXF4P.mjs} +2 -2
  63. package/dist/{chunk-GJEC5S4V.mjs → chunk-7VCLTNED.mjs} +1 -1
  64. package/dist/{chunk-CLEWORVY.cjs → chunk-ACAEFEOH.cjs} +38 -41
  65. package/dist/{chunk-OBYM5S5G.mjs → chunk-AL6E63FZ.mjs} +2 -2
  66. package/dist/{chunk-DQ2DI3Y7.mjs → chunk-AO5IRA2N.mjs} +2 -2
  67. package/dist/{chunk-CYRIIVD4.mjs → chunk-AU5UPNOD.mjs} +2 -2
  68. package/dist/{chunk-Z3IN6GEX.mjs → chunk-B3XY6FMC.mjs} +69 -12
  69. package/dist/{chunk-U7VH3Q5E.cjs → chunk-B5WZP3T3.cjs} +15 -2
  70. package/dist/{chunk-IBVN7SW5.mjs → chunk-BFOMCSZ2.mjs} +292 -120
  71. package/dist/{chunk-I4KPA2C6.mjs → chunk-BIX46FTI.mjs} +1 -1
  72. package/dist/{chunk-YZLEOMMA.mjs → chunk-BNXV3PRM.mjs} +4 -4
  73. package/dist/{chunk-3GNVIYPO.cjs → chunk-BSJMWCWM.cjs} +7 -7
  74. package/dist/{chunk-WVQNXXNE.cjs → chunk-BWFBTTJ5.cjs} +2 -2
  75. package/dist/{chunk-FEFCISOX.cjs → chunk-CEVXKJKF.cjs} +2 -2
  76. package/dist/{chunk-B67CW2LM.mjs → chunk-CF77L6RL.mjs} +33 -36
  77. package/dist/{chunk-OB45EAQL.mjs → chunk-CXQZQK6R.mjs} +3 -2
  78. package/dist/{chunk-255J7K4X.mjs → chunk-D2IAYGYA.mjs} +1 -1
  79. package/dist/{chunk-ILQ5DKYF.cjs → chunk-D4TYE6MY.cjs} +2 -2
  80. package/dist/{chunk-4YHGQDTT.cjs → chunk-DM2YGTRH.cjs} +24 -17
  81. package/dist/{chunk-ICFPTHXM.mjs → chunk-DRBXYJZ6.mjs} +7 -3
  82. package/dist/{chunk-E3HDJCWF.mjs → chunk-DRHHTHA3.mjs} +1 -1
  83. package/dist/{chunk-YXIQYWOK.cjs → chunk-DTBRSRTR.cjs} +23 -5
  84. package/dist/{chunk-JZQS3ZOI.mjs → chunk-E4T7WJJN.mjs} +10 -2
  85. package/dist/{chunk-YAEN3L2F.cjs → chunk-EF5AP4CV.cjs} +21 -2
  86. package/dist/{chunk-SPP3EZTJ.cjs → chunk-EHJOSIXM.cjs} +137 -67
  87. package/dist/{chunk-JZBU7V4D.mjs → chunk-ELJQWUAR.mjs} +125 -55
  88. package/dist/{chunk-DMXMIE2C.cjs → chunk-ENYBDM4U.cjs} +2 -2
  89. package/dist/{chunk-ZFEJ2SF2.cjs → chunk-EWIEJQP6.cjs} +28 -28
  90. package/dist/{chunk-ODBM54RT.cjs → chunk-F244KE2D.cjs} +7 -7
  91. package/dist/{chunk-WW3LRNQV.mjs → chunk-FCBUNILW.mjs} +1 -1
  92. package/dist/{chunk-GZOKWJIW.mjs → chunk-FEQ72ZHD.mjs} +16 -9
  93. package/dist/{chunk-ME7RVELR.mjs → chunk-FGXSWRWA.mjs} +20 -1
  94. package/dist/{chunk-2AFW7673.cjs → chunk-FNWL5DMG.cjs} +4 -3
  95. package/dist/{chunk-XUSJVHHD.cjs → chunk-FYV6DTAG.cjs} +738 -485
  96. package/dist/{chunk-7PPLTD3P.cjs → chunk-G7S6XG6X.cjs} +6 -6
  97. package/dist/{chunk-AQIO3RNL.mjs → chunk-GK2GBIXD.mjs} +3 -3
  98. package/dist/{chunk-IHTDLCDJ.cjs → chunk-GRHSQYD4.cjs} +17 -4
  99. package/dist/{chunk-W44X6IC2.cjs → chunk-HBLYSWIJ.cjs} +13 -9
  100. package/dist/chunk-HK4VJI27.cjs +76 -0
  101. package/dist/{chunk-EGIY4A7V.cjs → chunk-HKZVC5GP.cjs} +2 -2
  102. package/dist/{chunk-EYPSKXO4.mjs → chunk-HRQV5Q3J.mjs} +1 -1
  103. package/dist/{chunk-S7MWSFFP.cjs → chunk-IBEHVSU4.cjs} +2 -2
  104. package/dist/{chunk-JMOCMXTQ.mjs → chunk-IG4IQMIW.mjs} +1 -1
  105. package/dist/{chunk-GPO3LJDJ.cjs → chunk-IJFNXP3D.cjs} +2 -2
  106. package/dist/{chunk-FRO4BB2T.mjs → chunk-IP2R2TAE.mjs} +1 -1
  107. package/dist/{chunk-FETMUBIA.mjs → chunk-IZ5WOTQP.mjs} +1 -1
  108. package/dist/{chunk-CSLHNBPS.cjs → chunk-J42QN7OC.cjs} +6 -6
  109. package/dist/{chunk-NDDRTFN4.mjs → chunk-J7EUGGTY.mjs} +2 -2
  110. package/dist/{chunk-MJEKMT6B.mjs → chunk-JI6N4W2I.mjs} +125 -42
  111. package/dist/{chunk-GJ7QVFAG.mjs → chunk-JOECBGY7.mjs} +1 -1
  112. package/dist/{chunk-CL52PD6D.cjs → chunk-JSUVQ5HG.cjs} +8 -8
  113. package/dist/{chunk-DZHTNSQ5.cjs → chunk-JWHRVBCZ.cjs} +14 -14
  114. package/dist/{chunk-462MUII7.mjs → chunk-JZ43UD6S.mjs} +7 -7
  115. package/dist/{chunk-RLEALQEN.mjs → chunk-KIRIFO6T.mjs} +43 -5
  116. package/dist/{chunk-XGTFLG73.cjs → chunk-KMYOKQPP.cjs} +18 -11
  117. package/dist/{chunk-WX63N6C5.mjs → chunk-KNEYWPZV.mjs} +64 -27
  118. package/dist/{chunk-XI3OXOMK.mjs → chunk-KUMKBBYP.mjs} +1 -1
  119. package/dist/{chunk-VT25ERQK.mjs → chunk-KWUZJZ23.mjs} +21 -3
  120. package/dist/{chunk-SVQX5HYW.mjs → chunk-LHFGTR7F.mjs} +2 -2
  121. package/dist/{chunk-4P5634G6.cjs → chunk-LIQJYEQP.cjs} +14 -9
  122. package/dist/chunk-LXTYJ2HW.mjs +139 -0
  123. package/dist/{chunk-5PDMBWAF.cjs → chunk-MKQ27TGW.cjs} +5 -5
  124. package/dist/{chunk-SUQACHER.mjs → chunk-MQ5HA7H2.mjs} +2 -2
  125. package/dist/{chunk-HY6IVQ54.mjs → chunk-MUITBU5Z.mjs} +1 -1
  126. package/dist/{chunk-QKEZLYON.cjs → chunk-NET6PBUH.cjs} +2 -2
  127. package/dist/{chunk-YBY34UHB.mjs → chunk-NKETXVKP.mjs} +15 -2
  128. package/dist/chunk-NRWEY2CM.mjs +25 -0
  129. package/dist/chunk-NU5XLYRN.cjs +139 -0
  130. package/dist/{chunk-HTXKSREF.cjs → chunk-NXGQIXR7.cjs} +345 -173
  131. package/dist/{chunk-PXAHSCR6.cjs → chunk-O2A6HE76.cjs} +4 -4
  132. package/dist/{chunk-OAEDVXVE.mjs → chunk-O6K4G7YA.mjs} +5 -2
  133. package/dist/{chunk-73K53YPP.mjs → chunk-OSKIG4OP.mjs} +1 -1
  134. package/dist/{chunk-OXNZUCHN.cjs → chunk-P3EZKU6L.cjs} +18 -18
  135. package/dist/{chunk-HGB4PM2C.cjs → chunk-PG6ZIHKE.cjs} +102 -30
  136. package/dist/{chunk-YZK64PZT.cjs → chunk-Q3MVNRAO.cjs} +1071 -650
  137. package/dist/{chunk-AZ6IW6SF.mjs → chunk-Q4G52OSW.mjs} +1 -1
  138. package/dist/{chunk-TPYAYFMF.cjs → chunk-QL3YZTGZ.cjs} +2 -2
  139. package/dist/{chunk-UVZMSRHF.mjs → chunk-R4BWNP73.mjs} +2 -2
  140. package/dist/{chunk-OIP62QEL.mjs → chunk-R6Q6VSGU.mjs} +24 -9
  141. package/dist/{chunk-B6RBJJ5G.mjs → chunk-RBRIKT6B.mjs} +15 -2
  142. package/dist/{chunk-C6CUUBY5.cjs → chunk-RHI67C2V.cjs} +5 -5
  143. package/dist/chunk-RK3YYUX6.cjs +114 -0
  144. package/dist/{chunk-Y2LU4LE5.mjs → chunk-ROPMQNCG.mjs} +2 -2
  145. package/dist/{chunk-QIXEU2WV.cjs → chunk-RQ4UZJPR.cjs} +3 -3
  146. package/dist/{chunk-UVQRMUAR.cjs → chunk-RSL3YFJG.cjs} +1 -1
  147. package/dist/{chunk-JWY66PID.cjs → chunk-S3D6SL2V.cjs} +9 -6
  148. package/dist/{chunk-4HGLJOXZ.cjs → chunk-TPDKFRQX.cjs} +11 -11
  149. package/dist/{chunk-6O6PAZZR.mjs → chunk-UHAARKF3.mjs} +2 -2
  150. package/dist/{chunk-QSTRBKHZ.mjs → chunk-UJWRXBVP.mjs} +2 -2
  151. package/dist/{chunk-KTDG4THT.cjs → chunk-V6T3UJAH.cjs} +7 -7
  152. package/dist/{chunk-IXZSBO76.mjs → chunk-VFPFXMTF.mjs} +1 -1
  153. package/dist/{chunk-CPMME66W.mjs → chunk-VKLV7GF4.mjs} +72 -0
  154. package/dist/{chunk-TU6VAH4V.cjs → chunk-VKRMO3EZ.cjs} +8 -8
  155. package/dist/chunk-VWIW47FW.cjs +25 -0
  156. package/dist/{chunk-LGR7565L.cjs → chunk-VZKCGHWC.cjs} +39 -24
  157. package/dist/{chunk-JWLRBDDC.cjs → chunk-WH3PBJS7.cjs} +2 -2
  158. package/dist/{chunk-QGCSUC5O.mjs → chunk-WS4SLJW5.mjs} +403 -150
  159. package/dist/{chunk-5OFNUETM.mjs → chunk-WTTJ2YS2.mjs} +9 -1
  160. package/dist/{chunk-RLFGKJQ6.mjs → chunk-X2KNHD4B.mjs} +14 -2
  161. package/dist/{chunk-5CFHQ7HM.mjs → chunk-XXKMAHYE.mjs} +1 -1
  162. package/dist/{chunk-MBCRWU3P.cjs → chunk-XZPI44Q7.cjs} +4 -4
  163. package/dist/{chunk-ACGBXN3U.cjs → chunk-Y4FEQBKY.cjs} +17 -9
  164. package/dist/{chunk-4CTCSKAF.mjs → chunk-YH33PZ3K.mjs} +1 -1
  165. package/dist/chunk-YQWRBBAA.mjs +284 -0
  166. package/dist/{chunk-REK6HZSU.mjs → chunk-YWDRWG4L.mjs} +962 -541
  167. package/dist/{chunk-E46NXBNJ.mjs → chunk-ZD7JUTBY.mjs} +11 -6
  168. package/dist/{chunk-JDO346NV.mjs → chunk-ZLRWO5GK.mjs} +1 -1
  169. package/dist/{chunk-HFUOLILA.cjs → chunk-ZRCGPSUM.cjs} +4 -4
  170. package/dist/{chunk-4Z3YLMSW.cjs → chunk-ZZGANFQH.cjs} +10 -10
  171. package/dist/client/lifecycle.d.mts +1 -1
  172. package/dist/client/lifecycle.d.ts +1 -1
  173. package/dist/{client-component.d-sF-Znk0j.d.ts → client-component.d-DYOwmq0c.d.ts} +80 -3
  174. package/dist/{client-component.d-C71rMuHF.d.mts → client-component.d-edV76QvU.d.mts} +80 -3
  175. package/dist/{client-plugins.d-MFibjgBg.d.ts → client-plugins.d-BmJYW2FY.d.ts} +19 -6
  176. package/dist/{client-plugins.d-B-Gd9mWR.d.mts → client-plugins.d-DwvqqGsU.d.mts} +19 -6
  177. package/dist/client-plugins.d.mts +4 -4
  178. package/dist/client-plugins.d.ts +4 -4
  179. package/dist/client.cjs +6 -5
  180. package/dist/client.d.mts +11 -11
  181. package/dist/client.d.ts +11 -11
  182. package/dist/client.mjs +5 -4
  183. package/dist/config.d.mts +4 -4
  184. package/dist/config.d.ts +4 -4
  185. package/dist/cron.cjs +6 -2
  186. package/dist/cron.d.mts +11 -2
  187. package/dist/cron.d.ts +11 -2
  188. package/dist/cron.mjs +7 -3
  189. package/dist/desktop.d.mts +5 -5
  190. package/dist/desktop.d.ts +5 -5
  191. package/dist/{devtools-TDIJ6HVC.mjs → devtools-WPX62NG2.mjs} +10 -9
  192. package/dist/{devtools-6K4QXFRL.cjs → devtools-YMDS7PUA.cjs} +12 -11
  193. package/dist/docs.cjs +13 -12
  194. package/dist/docs.d.mts +5 -5
  195. package/dist/docs.d.ts +5 -5
  196. package/dist/docs.mjs +12 -11
  197. package/dist/{endpoint.d-BkMSCRf6.d.mts → endpoint.d-BXbBpKoh.d.mts} +42 -1
  198. package/dist/{endpoint.d-BgHn0lhl.d.ts → endpoint.d-Dx_1k6Du.d.ts} +42 -1
  199. package/dist/environment/vite.cjs +3 -3
  200. package/dist/environment/vite.mjs +2 -2
  201. package/dist/headers.cjs +3 -3
  202. package/dist/{headers.d-uQ6BR59u.d.ts → headers.d-BIbQyAxJ.d.ts} +1 -1
  203. package/dist/{headers.d-BUxGJTsj.d.mts → headers.d-BtNxFc2s.d.mts} +1 -1
  204. package/dist/headers.mjs +2 -2
  205. package/dist/index.cjs +70 -59
  206. package/dist/{index.d-BCGfxCXY.d.ts → index.d-CQ_wUzOV.d.ts} +1 -1
  207. package/dist/{index.d-CuWOJ-un.d.mts → index.d-CQdDRXd1.d.mts} +1 -1
  208. package/dist/index.d.mts +62 -28
  209. package/dist/index.d.ts +62 -28
  210. package/dist/index.mjs +66 -55
  211. package/dist/integrations/orm.d.mts +4 -4
  212. package/dist/integrations/orm.d.ts +4 -4
  213. package/dist/integrations.cjs +4 -4
  214. package/dist/integrations.d.mts +4 -4
  215. package/dist/integrations.d.ts +4 -4
  216. package/dist/integrations.mjs +3 -3
  217. package/dist/internal/app-markdown-runtime.cjs +7 -3
  218. package/dist/internal/app-markdown-runtime.d.mts +17 -6
  219. package/dist/internal/app-markdown-runtime.d.ts +17 -6
  220. package/dist/internal/app-markdown-runtime.mjs +6 -2
  221. package/dist/internal/build-runtime.cjs +41 -39
  222. package/dist/internal/build-runtime.d.mts +6 -6
  223. package/dist/internal/build-runtime.d.ts +6 -6
  224. package/dist/internal/build-runtime.mjs +40 -38
  225. package/dist/internal/cli-runtime.cjs +20 -19
  226. package/dist/internal/cli-runtime.mjs +19 -18
  227. package/dist/internal/client-error-overlay.cjs +6 -6
  228. package/dist/internal/client-error-overlay.mjs +2 -2
  229. package/dist/internal/client-runtime.cjs +6 -2
  230. package/dist/internal/client-runtime.d.mts +21 -9
  231. package/dist/internal/client-runtime.d.ts +21 -9
  232. package/dist/internal/client-runtime.mjs +5 -1
  233. package/dist/internal/compression-runtime.d.mts +4 -4
  234. package/dist/internal/compression-runtime.d.ts +4 -4
  235. package/dist/internal/config-runtime.cjs +12 -11
  236. package/dist/internal/config-runtime.d.mts +6 -6
  237. package/dist/internal/config-runtime.d.ts +6 -6
  238. package/dist/internal/config-runtime.mjs +11 -10
  239. package/dist/internal/form-actions.cjs +5 -4
  240. package/dist/internal/form-actions.d.mts +2 -2
  241. package/dist/internal/form-actions.d.ts +2 -2
  242. package/dist/internal/form-actions.mjs +4 -3
  243. package/dist/internal/infra-analytics-runtime.cjs +10 -10
  244. package/dist/internal/infra-analytics-runtime.mjs +8 -8
  245. package/dist/internal/native-server-fns.cjs +4 -4
  246. package/dist/internal/native-server-fns.mjs +3 -3
  247. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  248. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  249. package/dist/internal/production-runtime.cjs +32 -22
  250. package/dist/internal/production-runtime.d.mts +64 -13
  251. package/dist/internal/production-runtime.d.ts +64 -13
  252. package/dist/internal/production-runtime.mjs +31 -21
  253. package/dist/internal/react-cache.cjs +3 -3
  254. package/dist/internal/react-cache.mjs +1 -1
  255. package/dist/internal/vercel-edge-middleware.cjs +4 -4
  256. package/dist/internal/vercel-edge-middleware.mjs +3 -3
  257. package/dist/{lifecycle.d-keQs5Swc.d.mts → lifecycle.d-OtGWAvJT.d.mts} +4 -0
  258. package/dist/{lifecycle.d-keQs5Swc.d.ts → lifecycle.d-OtGWAvJT.d.ts} +4 -0
  259. package/dist/{manager-JIA66YJ2.mjs → manager-RHB2P35B.mjs} +4 -1
  260. package/dist/{manager-JOHU6BQI.cjs → manager-S77ZARTC.cjs} +5 -2
  261. package/dist/markdown.cjs +2 -2
  262. package/dist/markdown.d.mts +4 -4
  263. package/dist/markdown.d.ts +4 -4
  264. package/dist/markdown.mjs +1 -1
  265. package/dist/middleware.cjs +6 -6
  266. package/dist/middleware.d.mts +4 -4
  267. package/dist/middleware.d.ts +4 -4
  268. package/dist/middleware.mjs +5 -5
  269. package/dist/{mount.d-BIYmcGGg.d.mts → mount.d-6bhpBQQB.d.mts} +1 -1
  270. package/dist/{mount.d-q8k0cJV0.d.ts → mount.d-C-u7rFkM.d.ts} +1 -1
  271. package/dist/{native-server-fn-handler-EP5AFJYE.mjs → native-server-fn-handler-I66X4E5S.mjs} +6 -5
  272. package/dist/{native-server-fn-handler-QRTXGZA4.cjs → native-server-fn-handler-W4FSD76W.cjs} +7 -6
  273. package/dist/{native-tree-OYGKP2NZ.mjs → native-tree-3X23BT3N.mjs} +2 -2
  274. package/dist/{native-tree-R6CQMDTI.cjs → native-tree-TAPKR7QJ.cjs} +3 -3
  275. package/dist/{navigation-delegate.d-CYBUupsv.d.mts → navigation-delegate.d-nx6gtsY4.d.mts} +1 -1
  276. package/dist/{navigation-delegate.d-Btfs6Uoa.d.ts → navigation-delegate.d-xsG4T1x-.d.ts} +1 -1
  277. package/dist/navigation.cjs +4 -4
  278. package/dist/navigation.d.mts +7 -7
  279. package/dist/navigation.d.ts +7 -7
  280. package/dist/navigation.mjs +3 -3
  281. package/dist/{nitro-2LMOMIST.cjs → nitro-SSFTPZMW.cjs} +4 -4
  282. package/dist/{nitro-72TFIGGO.mjs → nitro-XTQ2HKDL.mjs} +1 -1
  283. package/dist/plugin.cjs +36 -33
  284. package/dist/plugin.d.mts +7 -7
  285. package/dist/plugin.d.ts +7 -7
  286. package/dist/plugin.mjs +35 -32
  287. package/dist/query/client.cjs +5 -5
  288. package/dist/query/client.mjs +1 -1
  289. package/dist/{render-plan.d-BlyxqKMu.d.mts → render-plan.d-B5y3h97B.d.mts} +1 -1
  290. package/dist/{render-plan.d-0FHusf1D.d.ts → render-plan.d-gW0fwKz2.d.ts} +1 -1
  291. package/dist/renderer-client.cjs +4 -4
  292. package/dist/renderer-client.d.mts +7 -7
  293. package/dist/renderer-client.d.ts +7 -7
  294. package/dist/renderer-client.mjs +1 -1
  295. package/dist/request.cjs +2 -2
  296. package/dist/{request.d-CX-gks1l.d.mts → request.d-B0ugAadD.d.ts} +9 -2
  297. package/dist/{request.d-CPdVjssg.d.ts → request.d-DLq33nYo.d.mts} +9 -2
  298. package/dist/request.d.mts +5 -5
  299. package/dist/request.d.ts +5 -5
  300. package/dist/request.mjs +1 -1
  301. package/dist/{route-rendering.d-CcvZ_4N2.d.mts → route-rendering.d-DSeIV7yV.d.mts} +1 -1
  302. package/dist/{route-rendering.d-DcOoSNoG.d.ts → route-rendering.d-ytaqDQD6.d.ts} +1 -1
  303. package/dist/{route.d-DrXkpvcg.d.mts → route.d-Cd4Fi6BA.d.ts} +3 -1
  304. package/dist/{route.d-hs-_cyHn.d.ts → route.d-ShmtqqVQ.d.mts} +3 -1
  305. package/dist/{router.d-D2QnK8cM.d.ts → router.d-BaEAEGPg.d.ts} +1 -1
  306. package/dist/{router.d-C8RHma4A.d.mts → router.d-Chd5cpe3.d.mts} +1 -1
  307. package/dist/routes.cjs +5 -3
  308. package/dist/routes.d.mts +4 -4
  309. package/dist/routes.d.ts +4 -4
  310. package/dist/routes.mjs +4 -2
  311. package/dist/{rsc-pipeline-LC2FBZAR.mjs → rsc-pipeline-DPMYONEV.mjs} +12 -11
  312. package/dist/{rsc-pipeline-NTAM65NT.cjs → rsc-pipeline-XIUUMMG5.cjs} +13 -12
  313. package/dist/{runtime-U4PAMTVH.cjs → runtime-WD77S3C5.cjs} +25 -25
  314. package/dist/{runtime-MWAC7NWR.mjs → runtime-XIUJZTZ3.mjs} +16 -16
  315. package/dist/{runtime.d-BQUHHq8M.d.mts → runtime.d-DpCs0eAO.d.mts} +3 -3
  316. package/dist/{runtime.d-1l_1bLrL.d.ts → runtime.d-h2USyQsz.d.ts} +3 -3
  317. package/dist/server-action-security.cjs +5 -3
  318. package/dist/server-action-security.d.mts +11 -3
  319. package/dist/server-action-security.d.ts +11 -3
  320. package/dist/server-action-security.mjs +4 -2
  321. package/dist/server-fn-client.d.mts +3 -3
  322. package/dist/server-fn-client.d.ts +3 -3
  323. package/dist/server-fn.cjs +6 -5
  324. package/dist/server-fn.d.mts +1 -1
  325. package/dist/server-fn.d.ts +1 -1
  326. package/dist/server-fn.mjs +5 -4
  327. package/dist/server-plugins.cjs +4 -4
  328. package/dist/server-plugins.d.mts +53 -9
  329. package/dist/server-plugins.d.ts +53 -9
  330. package/dist/server-plugins.mjs +3 -3
  331. package/dist/server-query-client.d.mts +1 -1
  332. package/dist/server-query-client.d.ts +1 -1
  333. package/dist/server-query.cjs +7 -6
  334. package/dist/server-query.d.mts +1 -1
  335. package/dist/server-query.d.ts +1 -1
  336. package/dist/server-query.mjs +6 -5
  337. package/dist/server.cjs +62 -67
  338. package/dist/server.d.mts +14 -14
  339. package/dist/server.d.ts +14 -14
  340. package/dist/server.mjs +41 -46
  341. package/dist/{spa-router.d-BzPdi48R.d.mts → spa-router.d-DCQVtEaE.d.mts} +11 -5
  342. package/dist/{spa-router.d-BJtXNeqo.d.ts → spa-router.d-DpdJHs1q.d.ts} +11 -5
  343. package/dist/testing.cjs +16 -14
  344. package/dist/testing.d.mts +4 -4
  345. package/dist/testing.d.ts +4 -4
  346. package/dist/testing.mjs +12 -10
  347. package/dist/theme/server.cjs +3 -3
  348. package/dist/theme/server.mjs +2 -2
  349. package/dist/{utils.d-B4ZW-6z6.d.mts → utils.d-DKDZtAY5.d.mts} +1 -1
  350. package/dist/{utils.d-DquC6qxy.d.ts → utils.d-DmicwMvS.d.ts} +1 -1
  351. package/dist/version.cjs +2 -2
  352. package/dist/version.mjs +1 -1
  353. package/dist/vite.cjs +36 -33
  354. package/dist/vite.d.mts +13 -8
  355. package/dist/vite.d.ts +13 -8
  356. package/dist/vite.mjs +35 -32
  357. package/package.json +1 -1
  358. package/dist/analyzer-V5ZMRIIY.cjs +0 -16
  359. package/dist/chunk-6I4BFRE7.cjs +0 -51
  360. package/dist/chunk-EIVGPQN5.mjs +0 -51
  361. /package/dist/{chunk-QEJWNXRI.cjs → chunk-EMRYJG4U.cjs} +0 -0
  362. /package/dist/{chunk-TXE4SAMV.mjs → chunk-H2ZJ35NW.mjs} +0 -0
@@ -139,6 +139,12 @@ function resolveFarmWebRequestOrigin(request, options = {}) {
139
139
  const proto = forwardedProto === "https" || forwardedProto === "http" ? forwardedProto : url.protocol === "https:" ? "https" : "http";
140
140
  return resolveRequestOrigin(proto, forwardedHost, url.host);
141
141
  }
142
+ function _withFarmTrustedProxyOrigin(request) {
143
+ const url = new URL(request.url);
144
+ const origin = resolveFarmWebRequestOrigin(request, { trustProxy: true });
145
+ if (origin === url.origin) return request;
146
+ return new Request(`${origin}${url.pathname}${url.search}`, request);
147
+ }
142
148
  function createWebRequestFromFarmRequest(req, options = {}) {
143
149
  const fullUrl = resolveFarmRequestURL(req, options).toString();
144
150
  const headers = new Headers();
@@ -157,7 +163,8 @@ function createWebRequestFromFarmRequest(req, options = {}) {
157
163
  const method = (req.method || "GET").toUpperCase();
158
164
  const init = {
159
165
  method: req.method,
160
- headers
166
+ headers,
167
+ ...options.signal ? { signal: options.signal } : {}
161
168
  };
162
169
  if (method !== "GET" && method !== "HEAD") {
163
170
  init.body = Readable.toWeb(req);
@@ -213,6 +220,7 @@ export {
213
220
  parseFarmRequestTarget,
214
221
  resolveFarmRequestURL,
215
222
  resolveFarmWebRequestOrigin,
223
+ _withFarmTrustedProxyOrigin,
216
224
  createWebRequestFromFarmRequest,
217
225
  _runWithCurrentRequest,
218
226
  getCurrentRequest,
@@ -1,6 +1,9 @@
1
+ import {
2
+ resolveRouteOpenAPIConfig
3
+ } from "./chunk-NRWEY2CM.mjs";
1
4
  import {
2
5
  findProgrammaticRouteFilesInDir
3
- } from "./chunk-TXE4SAMV.mjs";
6
+ } from "./chunk-H2ZJ35NW.mjs";
4
7
  import {
5
8
  isFarmAPIRouteFileName
6
9
  } from "./chunk-YX6AFPXC.mjs";
@@ -18,7 +21,7 @@ import {
18
21
  matchAPIRouteAtBasePath,
19
22
  mergePluginAPIRoutes,
20
23
  resolveAPIRouteEndpoint
21
- } from "./chunk-TY5KCYDE.mjs";
24
+ } from "./chunk-72NTEYCX.mjs";
22
25
  import {
23
26
  registerAPIRouteShape
24
27
  } from "./chunk-GWXZS7K5.mjs";
@@ -181,11 +184,18 @@ var APIRouteManager = class _APIRouteManager {
181
184
  getFarmRouteRuntimeConfig(routeModule),
182
185
  `API route "${routePath}"`
183
186
  );
187
+ const routeOpenAPI = resolveRouteOpenAPIConfig(
188
+ routeModule.openapi,
189
+ `API route "${routePath}"`
190
+ );
184
191
  this.registerRouteShape(routePath, filePath, appDir);
185
192
  const existingRoute = this.routes.get(routePath);
186
193
  const mergedMethods = existingRoute ? [...existingRoute.methods] : [];
194
+ const openapi = { ...existingRoute?.openapi };
187
195
  for (const method of availableMethods) {
188
196
  if (!mergedMethods.includes(method)) mergedMethods.push(method);
197
+ if (routeOpenAPI) openapi[method] = routeOpenAPI;
198
+ else delete openapi[method];
189
199
  }
190
200
  this.routes.set(routePath, {
191
201
  ...existingRoute,
@@ -193,6 +203,7 @@ var APIRouteManager = class _APIRouteManager {
193
203
  filePath,
194
204
  methods: mergedMethods,
195
205
  endpoints: { ...existingRoute?.endpoints, ...endpoints },
206
+ openapi: Object.keys(openapi).length > 0 ? openapi : void 0,
196
207
  ...runtimeConfig
197
208
  });
198
209
  const nextSources = new Map(existingSources);
@@ -302,6 +313,7 @@ var APIRouteManager = class _APIRouteManager {
302
313
  existingRoute.methods.push(normalizedMethod);
303
314
  }
304
315
  existingRoute.endpoints[normalizedMethod] = endpoint;
316
+ delete existingRoute.openapi?.[normalizedMethod];
305
317
  Object.assign(existingRoute, runtimeConfig);
306
318
  const sources = this.endpointSources.get(routePath) ?? /* @__PURE__ */ new Map();
307
319
  sources.set(normalizedMethod, { appDir, filePath });
@@ -25,7 +25,7 @@ import {
25
25
  } from "./chunk-UTUS6JUH.mjs";
26
26
  import {
27
27
  getIntegrationSchemas
28
- } from "./chunk-WW3LRNQV.mjs";
28
+ } from "./chunk-FCBUNILW.mjs";
29
29
  import {
30
30
  resolveSchemaModels
31
31
  } from "./chunk-F3N52U7S.mjs";
@@ -5,7 +5,7 @@
5
5
  var _chunk2RCCFB2Ycjs = require('./chunk-2RCCFB2Y.cjs');
6
6
 
7
7
 
8
- var _chunkHDPT6OYEcjs = require('./chunk-HDPT6OYE.cjs');
8
+ var _chunk4M5ESTJ2cjs = require('./chunk-4M5ESTJ2.cjs');
9
9
 
10
10
  // src/plugins/redirects.ts
11
11
  var FARM_CONFIG_REDIRECTS_PLUGIN_NAME = "farm:redirects";
@@ -24,7 +24,7 @@ function createRedirectsPlugin(redirects, {
24
24
  if (overrideBeforeRequest) {
25
25
  await overrideBeforeRequest(req, res, context);
26
26
  }
27
- const redirect = matchRedirect(_chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req));
27
+ const redirect = matchRedirect(_chunk4M5ESTJ2cjs.resolveFarmRequestURL.call(void 0, req));
28
28
  if (!redirect) return;
29
29
  res.setHeader("Content-Type", "text/plain;charset=UTF-8");
30
30
  res.writeHead(redirect.statusCode, {
@@ -137,7 +137,7 @@ function createHeadersPlugin(headers, {
137
137
  if (overrideBeforeRequest) {
138
138
  await overrideBeforeRequest(req, res, context);
139
139
  }
140
- installConfigResponseHeaders(res, matchHeaders(_chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req)));
140
+ installConfigResponseHeaders(res, matchHeaders(_chunk4M5ESTJ2cjs.resolveFarmRequestURL.call(void 0, req)));
141
141
  },
142
142
  async afterResponse(req, res, context) {
143
143
  if (overrideAfterResponse) {
@@ -163,7 +163,7 @@ function createRewritesPlugin(rewrites, {
163
163
  if (overrideBeforeRequest) {
164
164
  await overrideBeforeRequest(req, res, context);
165
165
  }
166
- const url = _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req);
166
+ const url = _chunk4M5ESTJ2cjs.resolveFarmRequestURL.call(void 0, req);
167
167
  const destinationUrl = matchRewrite(url);
168
168
  if (destinationUrl) {
169
169
  req.url = destinationUrl.origin === url.origin ? destinationUrl.pathname + destinationUrl.search : destinationUrl.href;
@@ -8,7 +8,7 @@ var _chunkMHLNWRCJcjs = require('./chunk-MHLNWRCJ.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunkJWLRBDDCcjs = require('./chunk-JWLRBDDC.cjs');
11
+ var _chunkWH3PBJS7cjs = require('./chunk-WH3PBJS7.cjs');
12
12
 
13
13
 
14
14
 
@@ -39,7 +39,7 @@ var _chunk2OF5RPVUcjs = require('./chunk-2OF5RPVU.cjs');
39
39
  var _chunkEVIWKPJVcjs = require('./chunk-EVIWKPJV.cjs');
40
40
 
41
41
 
42
- var _chunkHDPT6OYEcjs = require('./chunk-HDPT6OYE.cjs');
42
+ var _chunk4M5ESTJ2cjs = require('./chunk-4M5ESTJ2.cjs');
43
43
 
44
44
 
45
45
 
@@ -57,7 +57,7 @@ var CookieJarImpl = class {
57
57
  constructor(req, res) {
58
58
  this.req = req;
59
59
  this.res = res;
60
- this.cookies = _chunkJWLRBDDCcjs.parseMiddlewareCookieHeader.call(void 0, req.headers.cookie);
60
+ this.cookies = _chunkWH3PBJS7cjs.parseMiddlewareCookieHeader.call(void 0, req.headers.cookie);
61
61
  const existing = res.getHeader("Set-Cookie");
62
62
  this.setCookies = Array.isArray(existing) ? existing.map(String) : existing === void 0 ? [] : [String(existing)];
63
63
  }
@@ -66,13 +66,13 @@ var CookieJarImpl = class {
66
66
  }
67
67
  set(name, value, options = {}) {
68
68
  this.cookies[name] = value;
69
- const cookieString = _chunkJWLRBDDCcjs.serializeMiddlewareCookie.call(void 0, name, value, options);
69
+ const cookieString = _chunkWH3PBJS7cjs.serializeMiddlewareCookie.call(void 0, name, value, options);
70
70
  this.setCookies.push(cookieString);
71
71
  this.res.setHeader("Set-Cookie", this.setCookies);
72
72
  }
73
73
  delete(name, options = {}) {
74
74
  delete this.cookies[name];
75
- this.setCookies.push(_chunkJWLRBDDCcjs.serializeMiddlewareCookieDeletion.call(void 0, name, options));
75
+ this.setCookies.push(_chunkWH3PBJS7cjs.serializeMiddlewareCookieDeletion.call(void 0, name, options));
76
76
  this.res.setHeader("Set-Cookie", this.setCookies);
77
77
  }
78
78
  getAll() {
@@ -80,7 +80,7 @@ var CookieJarImpl = class {
80
80
  }
81
81
  };
82
82
  function createContext(req, res, viteServer, parent, server, toRoutePathname) {
83
- const url = _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req, { trustProxy: _optionalChain([server, 'optionalAccess', _ => _.trustProxy]) });
83
+ const url = _chunk4M5ESTJ2cjs.resolveFarmRequestURL.call(void 0, req, { trustProxy: _optionalChain([server, 'optionalAccess', _ => _.trustProxy]) });
84
84
  const headers = /* @__PURE__ */ new Map();
85
85
  const data = _optionalChain([parent, 'optionalAccess', _2 => _2.data]) ? new Map(parent.data) : /* @__PURE__ */ new Map();
86
86
  const locals = _optionalChain([parent, 'optionalAccess', _3 => _3.locals]) ? new Map(parent.locals) : /* @__PURE__ */ new Map();
@@ -301,7 +301,7 @@ var MiddlewareManager = class {
301
301
  _chunkSNP33A33cjs.toFileModuleUrl.call(void 0, filePath)
302
302
  );
303
303
  }
304
- const normalized = _chunkJWLRBDDCcjs.normalizeMiddlewareModule.call(void 0, module, routePath);
304
+ const normalized = _chunkWH3PBJS7cjs.normalizeMiddlewareModule.call(void 0, module, routePath);
305
305
  if (!normalized) {
306
306
  throw new Error("must export a default handler or a named middleware handler");
307
307
  }
@@ -323,7 +323,7 @@ var MiddlewareManager = class {
323
323
  * Execute middleware for a request
324
324
  */
325
325
  async execute(req, res) {
326
- const url = _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req, { trustProxy: _optionalChain([this, 'access', _6 => _6.server, 'optionalAccess', _7 => _7.trustProxy]) });
326
+ const url = _chunk4M5ESTJ2cjs.resolveFarmRequestURL.call(void 0, req, { trustProxy: _optionalChain([this, 'access', _6 => _6.server, 'optionalAccess', _7 => _7.trustProxy]) });
327
327
  const pathname = url.pathname;
328
328
  const toRoutePathname = (value) => _optionalChain([this, 'access', _8 => _8.i18n, 'optionalAccess', _9 => _9.enabled]) ? _chunkOWQV6MLMcjs.stripFarmLocaleFromPathname.call(void 0, value, this.i18n) : _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, value, _nullishCoalesce(_optionalChain([this, 'access', _10 => _10.i18n, 'optionalAccess', _11 => _11.basePath]), () => ( "/")));
329
329
  const routePathname = toRoutePathname(pathname);
@@ -371,7 +371,7 @@ var MiddlewareManager = class {
371
371
  for (; ; ) {
372
372
  for (const entry of pass) yield { ...entry, pathname: passPathname };
373
373
  const rewrittenPathname = toRoutePathname(
374
- _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req, { trustProxy }).pathname
374
+ _chunk4M5ESTJ2cjs.resolveFarmRequestURL.call(void 0, req, { trustProxy }).pathname
375
375
  );
376
376
  if (rewrittenPathname === passPathname) return;
377
377
  passPathname = rewrittenPathname;
@@ -460,6 +460,14 @@ var MiddlewareManager = class {
460
460
  durationMs: Date.now() - middlewareStartTime
461
461
  });
462
462
  } catch (error) {
463
+ if ((_chunk7JUIK547cjs.isFarmRedirectError.call(void 0, error) || _chunk7JUIK547cjs.isFarmNotFoundError.call(void 0, error)) && !res.headersSent && !res.writableEnded) {
464
+ for (const [key, value] of ctx.headers) {
465
+ try {
466
+ res.setHeader(key, value);
467
+ } catch (e2) {
468
+ }
469
+ }
470
+ }
463
471
  _chunkEVIWKPJVcjs.emitFarmEvent.call(void 0,
464
472
  _chunk7JUIK547cjs.isFarmRedirectError.call(void 0, error) || _chunk7JUIK547cjs.isFarmNotFoundError.call(void 0, error) ? {
465
473
  type: "middleware.shortCircuit",
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-LLZSYFOM.mjs";
11
11
  import {
12
12
  _readFarmRenderedHtml
13
- } from "./chunk-CPMME66W.mjs";
13
+ } from "./chunk-VKLV7GF4.mjs";
14
14
 
15
15
  // src/mobile/native-tree.ts
16
16
  var URLENCODED = "application/x-www-form-urlencoded";
@@ -0,0 +1,284 @@
1
+ import {
2
+ _listFarmRegisteredMCPServers
3
+ } from "./chunk-C7GJDVN4.mjs";
4
+ import {
5
+ emitFarmEvent
6
+ } from "./chunk-2DA7CLY7.mjs";
7
+ import {
8
+ applyFarmBasePath,
9
+ stripFarmBasePath
10
+ } from "./chunk-SF3JB56B.mjs";
11
+
12
+ // src/registered-mcp.ts
13
+ var TOOL_NAME = /^[a-zA-Z0-9_.:/-]{1,128}$/;
14
+ var MAX_REQUEST_BYTES = 1024 * 1024;
15
+ var MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
16
+ var MAX_CALLS = 32;
17
+ var MAX_TOOLS = 500;
18
+ var MAX_PAGES = 10;
19
+ var LIST_TIMEOUT_MS = 5e3;
20
+ var MAX_SCHEMA_BYTES = 64 * 1024;
21
+ var MAX_SCHEMA_DEPTH = 32;
22
+ var MANIFEST_PATH = /^(?=.{1,256}$)(?:\/[a-zA-Z0-9_.:[\]()*-]+)+$/;
23
+ var isObject = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
24
+ var isRequestId = (value) => typeof value === "string" || typeof value === "number";
25
+ function servedAt(pathname, basePath) {
26
+ const path = stripFarmBasePath(pathname, basePath);
27
+ const normalized = path.length > 1 ? path.replace(/\/+$/, "") : path;
28
+ const servers = _listFarmRegisteredMCPServers().filter(
29
+ (server) => server.path !== void 0
30
+ );
31
+ return servers.find((server) => server.path === normalized) ?? (servers.length === 1 ? servers[0] : void 0);
32
+ }
33
+ async function readText(body, limit) {
34
+ const reader = body.getReader();
35
+ const decoder = new TextDecoder();
36
+ let text = "";
37
+ let size = 0;
38
+ try {
39
+ for (; ; ) {
40
+ const { done, value } = await reader.read();
41
+ if (done) return text + decoder.decode();
42
+ size += value.byteLength;
43
+ if (size > limit) throw new RangeError("The body is larger than Farm reads.");
44
+ text += decoder.decode(value, { stream: true });
45
+ }
46
+ } finally {
47
+ reader.cancel().catch(() => {
48
+ });
49
+ }
50
+ }
51
+ function parseMessages(text, eventStream) {
52
+ const parse = (json) => {
53
+ try {
54
+ const value = JSON.parse(json);
55
+ return Array.isArray(value) ? value : [value];
56
+ } catch {
57
+ return [];
58
+ }
59
+ };
60
+ if (!eventStream) return parse(text);
61
+ return text.split(/\r?\n\r?\n/).flatMap((event) => {
62
+ const data = event.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(line.startsWith("data: ") ? 6 : 5));
63
+ return data.length ? parse(data.join("\n")) : [];
64
+ });
65
+ }
66
+ var isEventStream = (response) => response.headers.get("content-type")?.toLowerCase().includes("text/event-stream") ?? false;
67
+ async function _readFarmRegisteredMCPCalls(request, basePath) {
68
+ if (request.method !== "POST" || !request.body) return void 0;
69
+ const server = servedAt(new URL(request.url).pathname, basePath);
70
+ if (!server) return void 0;
71
+ if (!request.headers.get("content-type")?.toLowerCase().includes("json")) return void 0;
72
+ if (Number(request.headers.get("content-length")) > MAX_REQUEST_BYTES) return void 0;
73
+ const startedAt = performance.now();
74
+ let messages;
75
+ try {
76
+ messages = parseMessages(await readText(request.clone().body, MAX_REQUEST_BYTES), false);
77
+ } catch {
78
+ return void 0;
79
+ }
80
+ const calls = messages.slice(0, MAX_CALLS).flatMap((message) => {
81
+ if (!isObject(message) || message.method !== "tools/call" || !isRequestId(message.id)) {
82
+ return [];
83
+ }
84
+ const tool = isObject(message.params) ? message.params.name : void 0;
85
+ return typeof tool === "string" && TOOL_NAME.test(tool) ? [{ id: message.id, tool }] : [];
86
+ });
87
+ return calls.length ? { server, calls, startedAt } : void 0;
88
+ }
89
+ function _observeFarmRegisteredMCPResponse(response, observed, waitUntil) {
90
+ if (!observed || !response.ok || !response.body) return response;
91
+ const eventStream = isEventStream(response);
92
+ if (!eventStream && !response.headers.get("content-type")?.toLowerCase().includes("json")) {
93
+ return response;
94
+ }
95
+ const [sent, read] = response.body.tee();
96
+ const done = reportOutcomes(read, eventStream, observed);
97
+ waitUntil?.(done);
98
+ return new Response(sent, {
99
+ status: response.status,
100
+ statusText: response.statusText,
101
+ headers: response.headers
102
+ });
103
+ }
104
+ async function reportOutcomes(body, eventStream, { server, calls, startedAt }) {
105
+ const pending = new Map(calls.map((call) => [call.id, call.tool]));
106
+ const answer = (message) => {
107
+ if (!isObject(message) || !isRequestId(message.id) || !isObject(message.result)) return;
108
+ const tool = pending.get(message.id);
109
+ if (tool === void 0) return;
110
+ pending.delete(message.id);
111
+ const outcome = message.result.isError === true ? "error" : "success";
112
+ emitFarmEvent({
113
+ type: "mcp.tool.complete",
114
+ level: outcome === "error" ? "error" : "info",
115
+ route: server.path,
116
+ server: server.name,
117
+ tool,
118
+ outcome,
119
+ durationMs: Math.max(0, performance.now() - startedAt)
120
+ });
121
+ };
122
+ const reader = body.getReader();
123
+ const decoder = new TextDecoder();
124
+ let buffered = "";
125
+ let size = 0;
126
+ try {
127
+ while (pending.size) {
128
+ const { done, value } = await reader.read();
129
+ if (done) break;
130
+ size += value.byteLength;
131
+ if (size > MAX_RESPONSE_BYTES) return;
132
+ buffered += decoder.decode(value, { stream: true });
133
+ if (!eventStream) continue;
134
+ buffered = buffered.replace(/\r\n/g, "\n");
135
+ const end = buffered.lastIndexOf("\n\n");
136
+ if (end === -1) continue;
137
+ for (const message of parseMessages(buffered.slice(0, end), true)) answer(message);
138
+ buffered = buffered.slice(end + 2);
139
+ }
140
+ buffered += decoder.decode();
141
+ for (const message of parseMessages(buffered, eventStream)) answer(message);
142
+ } catch {
143
+ } finally {
144
+ reader.cancel().catch(() => {
145
+ });
146
+ }
147
+ }
148
+ var singleLine = (value, max) => typeof value === "string" && value.length <= max && // oxlint-disable-next-line no-control-regex -- refuses control characters.
149
+ !/[\u0000-\u001f\u007f]/.test(value);
150
+ var paragraph = (value, max) => typeof value === "string" && value.length <= max && // oxlint-disable-next-line no-control-regex -- refuses control characters but line breaks.
151
+ !/[\u0000-\u0008\u000b-\u001f\u007f]/.test(value);
152
+ function boundedSchema(value) {
153
+ if (!isObject(value)) return void 0;
154
+ const depth = (node, level) => level <= MAX_SCHEMA_DEPTH && (!node || typeof node !== "object" || Object.values(node).every((child) => depth(child, level + 1)));
155
+ if (!depth(value, 0)) return void 0;
156
+ return new TextEncoder().encode(JSON.stringify(value)).byteLength <= MAX_SCHEMA_BYTES ? value : void 0;
157
+ }
158
+ function manifestTool(input) {
159
+ if (!isObject(input) || typeof input.name !== "string" || !TOOL_NAME.test(input.name)) {
160
+ return void 0;
161
+ }
162
+ const annotations = isObject(input.annotations) ? input.annotations : {};
163
+ const title = input.title ?? annotations.title;
164
+ const hints = Object.fromEntries(
165
+ ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"].filter((hint) => typeof annotations[hint] === "boolean").map((hint) => [hint, annotations[hint]])
166
+ );
167
+ const inputSchema = boundedSchema(input.inputSchema);
168
+ const outputSchema = boundedSchema(input.outputSchema);
169
+ return {
170
+ name: input.name,
171
+ ...singleLine(title, 200) ? { title } : {},
172
+ ...paragraph(input.description, 2e3) ? { description: input.description } : {},
173
+ source: "defineTool",
174
+ ...hints,
175
+ ...inputSchema ? { inputSchema } : {},
176
+ ...outputSchema ? { outputSchema } : {}
177
+ };
178
+ }
179
+ async function listTools(handle, url, signal) {
180
+ const tools = [];
181
+ const names = /* @__PURE__ */ new Set();
182
+ let cursor;
183
+ for (let page = 0; page < MAX_PAGES; page++) {
184
+ const response = await handle(
185
+ new Request(url, {
186
+ method: "POST",
187
+ headers: {
188
+ accept: "application/json, text/event-stream",
189
+ "content-type": "application/json"
190
+ },
191
+ body: JSON.stringify({
192
+ jsonrpc: "2.0",
193
+ id: page + 1,
194
+ method: "tools/list",
195
+ params: cursor ? { cursor } : {}
196
+ }),
197
+ signal
198
+ })
199
+ );
200
+ if (!response) return void 0;
201
+ if (response.status === 401 || response.status === 403) {
202
+ await response.body?.cancel().catch(() => {
203
+ });
204
+ return page === 0 ? { authorization: "required" } : void 0;
205
+ }
206
+ if (!response.ok || !response.body) {
207
+ await response.body?.cancel().catch(() => {
208
+ });
209
+ return void 0;
210
+ }
211
+ const answer = parseMessages(
212
+ await readText(response.body, MAX_RESPONSE_BYTES),
213
+ isEventStream(response)
214
+ ).find((message) => isObject(message) && message.id === page + 1);
215
+ const result = isObject(answer) && isObject(answer.result) ? answer.result : void 0;
216
+ if (!result || !Array.isArray(result.tools)) return void 0;
217
+ for (const tool of result.tools.map(manifestTool)) {
218
+ if (!tool || names.has(tool.name) || tools.length >= MAX_TOOLS) continue;
219
+ names.add(tool.name);
220
+ tools.push(tool);
221
+ }
222
+ cursor = typeof result.nextCursor === "string" && result.nextCursor ? result.nextCursor : void 0;
223
+ if (!cursor || tools.length >= MAX_TOOLS) break;
224
+ }
225
+ return { authorization: "none", tools };
226
+ }
227
+ var LISTINGS = /* @__PURE__ */ new WeakMap();
228
+ async function _listFarmRegisteredMCPServerTools(handle, request, options) {
229
+ const servers = _listFarmRegisteredMCPServers().filter(
230
+ (server) => server.path !== void 0 && MANIFEST_PATH.test(server.path) && singleLine(server.name, 128) && singleLine(server.version, 64)
231
+ );
232
+ const listings = await Promise.all(
233
+ servers.map((server) => {
234
+ if (options.guardCoversPath?.(server.path)) {
235
+ return Promise.resolve({ authorization: "required" });
236
+ }
237
+ const cached = options.cache ? LISTINGS.get(server) : void 0;
238
+ if (cached) return cached;
239
+ const controller = new AbortController();
240
+ let timer;
241
+ const listing = Promise.race([
242
+ listTools(
243
+ handle,
244
+ new URL(applyFarmBasePath(server.path, options.basePath), request.url),
245
+ controller.signal
246
+ ),
247
+ new Promise((resolve) => {
248
+ timer = setTimeout(() => {
249
+ controller.abort();
250
+ resolve(void 0);
251
+ }, LIST_TIMEOUT_MS);
252
+ })
253
+ ]).catch(() => void 0).finally(() => clearTimeout(timer));
254
+ if (options.cache) {
255
+ LISTINGS.set(server, listing);
256
+ void listing.then((value) => {
257
+ if (!value && LISTINGS.get(server) === listing) LISTINGS.delete(server);
258
+ });
259
+ }
260
+ return listing;
261
+ })
262
+ );
263
+ return servers.flatMap((server, index) => {
264
+ const listing = listings[index];
265
+ if (!listing) return [];
266
+ return [
267
+ {
268
+ name: server.name,
269
+ version: server.version,
270
+ path: server.path,
271
+ authorization: listing.authorization,
272
+ resources: [],
273
+ prompts: [],
274
+ tools: listing.authorization === "none" ? listing.tools : []
275
+ }
276
+ ];
277
+ });
278
+ }
279
+
280
+ export {
281
+ _readFarmRegisteredMCPCalls,
282
+ _observeFarmRegisteredMCPResponse,
283
+ _listFarmRegisteredMCPServerTools
284
+ };