@farm.js/core 0.1.35 → 0.1.37

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 (285) hide show
  1. package/dist/{metadata-BnLDsUOS.d.ts → agent-mcp-BC0bAGVF.d.mts} +45 -2
  2. package/dist/agent-mcp-handler-LPJ2CADR.mjs +19 -0
  3. package/dist/agent-mcp-handler-SJAHFSPI.cjs +19 -0
  4. package/dist/{metadata-WGpBYcGn.d.mts → agent-mcp-jyDHbQKe.d.ts} +45 -2
  5. package/dist/agent-runtime.cjs +6 -4
  6. package/dist/agent-runtime.d.mts +1 -1
  7. package/dist/agent-runtime.d.ts +1 -1
  8. package/dist/agent-runtime.mjs +5 -3
  9. package/dist/api/client.cjs +3 -3
  10. package/dist/api/client.mjs +2 -2
  11. package/dist/api/route-manager.cjs +9 -9
  12. package/dist/api/route-manager.d.mts +10 -4
  13. package/dist/api/route-manager.d.ts +10 -4
  14. package/dist/api/route-manager.mjs +8 -8
  15. package/dist/api/runtime.cjs +6 -6
  16. package/dist/api/runtime.d.mts +4 -62
  17. package/dist/api/runtime.d.ts +4 -62
  18. package/dist/api/runtime.mjs +5 -5
  19. package/dist/api.cjs +13 -12
  20. package/dist/api.d.mts +3 -3
  21. package/dist/api.d.ts +3 -3
  22. package/dist/api.mjs +12 -11
  23. package/dist/{app-BXB3JZYc.d.ts → app-CKO3iN1c.d.ts} +17 -3
  24. package/dist/{app-D_j9AAVL.d.mts → app-Cbkj9ufe.d.mts} +17 -3
  25. package/dist/app-markdown.cjs +6 -4
  26. package/dist/app-markdown.d.mts +3 -3
  27. package/dist/app-markdown.d.ts +3 -3
  28. package/dist/app-markdown.mjs +5 -3
  29. package/dist/{chunk-F7JZENPF.cjs → chunk-3A4KGQYI.cjs} +38 -30
  30. package/dist/{chunk-4MMGO7YW.cjs → chunk-3IP27TCG.cjs} +43 -32
  31. package/dist/{chunk-FDR64H6B.mjs → chunk-3KGDJLJK.mjs} +41 -2
  32. package/dist/{chunk-UJD4PHYB.mjs → chunk-4E5WBPEG.mjs} +72 -354
  33. package/dist/{chunk-KXWRO25S.cjs → chunk-4GPOC4LN.cjs} +3 -3
  34. package/dist/{chunk-Z2HLU4IX.cjs → chunk-4GWRFP22.cjs} +23 -2
  35. package/dist/{chunk-4KU5Q7C2.mjs → chunk-4P6ULFMD.mjs} +253 -67
  36. package/dist/chunk-4WQ6PGSJ.cjs +367 -0
  37. package/dist/{chunk-SMHH4VDG.mjs → chunk-4WVJLURN.mjs} +1 -1
  38. package/dist/{chunk-2F2ER724.cjs → chunk-5BXGGEC7.cjs} +27 -22
  39. package/dist/{chunk-3BHT4WMP.cjs → chunk-5D2JIPLH.cjs} +8 -8
  40. package/dist/{chunk-AHGECQEW.mjs → chunk-666CKENS.mjs} +1 -1
  41. package/dist/{chunk-GFHLGIYC.cjs → chunk-6LGFV2CQ.cjs} +8 -8
  42. package/dist/chunk-6SJ2KJTA.mjs +314 -0
  43. package/dist/{chunk-PFQKNERH.cjs → chunk-6TJITR2B.cjs} +457 -218
  44. package/dist/{chunk-73MC7ZL6.cjs → chunk-75X755YZ.cjs} +2 -2
  45. package/dist/{chunk-3UH7MRCP.cjs → chunk-7DWNJI73.cjs} +13 -13
  46. package/dist/{chunk-7L5V3KQO.cjs → chunk-7O5M4UKW.cjs} +2 -2
  47. package/dist/{chunk-BJPBQNIE.cjs → chunk-7SQ5SGYZ.cjs} +2 -2
  48. package/dist/{chunk-27ZWSI3W.cjs → chunk-ADOAUDQ6.cjs} +2 -2
  49. package/dist/{chunk-CP6X4AEU.mjs → chunk-AJQTP4OO.mjs} +1 -1
  50. package/dist/{chunk-YKX5BK66.cjs → chunk-ATWHHSY2.cjs} +7 -7
  51. package/dist/{chunk-EFCQPQMG.cjs → chunk-B5PFZLKV.cjs} +89 -8
  52. package/dist/{chunk-FNO7A7CM.cjs → chunk-BHY547NB.cjs} +34 -16
  53. package/dist/{chunk-JHWOVJ3M.mjs → chunk-BUGNQIHC.mjs} +5 -0
  54. package/dist/{chunk-7GLPRTTF.cjs → chunk-CGBDNNSM.cjs} +2 -2
  55. package/dist/chunk-CI6E3UOH.cjs +314 -0
  56. package/dist/{chunk-2G2NNLE2.mjs → chunk-CQMVIOYP.mjs} +5 -5
  57. package/dist/{chunk-X6W5FFH6.cjs → chunk-CVH2BXPY.cjs} +8 -8
  58. package/dist/{chunk-TKSCR644.cjs → chunk-D3C5LBQY.cjs} +2 -2
  59. package/dist/{chunk-PZNL3WEG.mjs → chunk-DMEPTZTI.mjs} +22 -11
  60. package/dist/chunk-DTSROJ5J.mjs +367 -0
  61. package/dist/{chunk-DBNKI4NF.cjs → chunk-ECKF2BAM.cjs} +6 -2
  62. package/dist/{chunk-GQ3Z3IZI.cjs → chunk-EMMQ64QW.cjs} +18 -18
  63. package/dist/{chunk-6DU6UFUE.mjs → chunk-EXG5LD6B.mjs} +16 -8
  64. package/dist/{chunk-HUMR6LSU.mjs → chunk-F5QO4FNE.mjs} +1 -1
  65. package/dist/{chunk-YULD7ICZ.mjs → chunk-FBOJ55OM.mjs} +1 -1
  66. package/dist/{chunk-IHNMMXHV.mjs → chunk-FGRYBX5X.mjs} +15 -10
  67. package/dist/{chunk-D227TIEN.cjs → chunk-FWE7LEQC.cjs} +13 -13
  68. package/dist/{chunk-3BU22U3M.cjs → chunk-G2TEB74S.cjs} +5 -2
  69. package/dist/{chunk-G5RT7EXW.mjs → chunk-HEVMCTSR.mjs} +21 -6
  70. package/dist/{chunk-W7LF2J2S.mjs → chunk-HMRSWN47.mjs} +1 -1
  71. package/dist/{chunk-JG6DJF5A.mjs → chunk-HZFM2LWQ.mjs} +22 -1
  72. package/dist/{chunk-UAORZ7QA.mjs → chunk-IAIYV4RZ.mjs} +2 -2
  73. package/dist/{chunk-F2SE2VDO.mjs → chunk-IHQIOZLC.mjs} +1 -1
  74. package/dist/{chunk-2NNMOPDN.mjs → chunk-J3ANCZKA.mjs} +4 -1
  75. package/dist/{chunk-C4SPBWFM.cjs → chunk-JEZO6VUR.cjs} +10 -1
  76. package/dist/{chunk-SC2WYWPF.mjs → chunk-JPNFPAZ4.mjs} +3 -3
  77. package/dist/{chunk-F6Z3Y5KL.mjs → chunk-K3SAEIM3.mjs} +5 -2
  78. package/dist/{chunk-QAU5JD57.mjs → chunk-K4I4O5TS.mjs} +289 -50
  79. package/dist/{chunk-KN7K4VQN.mjs → chunk-KDTBF3UU.mjs} +1 -1
  80. package/dist/{chunk-OMVAU7NT.cjs → chunk-KIIMAWOJ.cjs} +11 -1
  81. package/dist/{chunk-43FMW62B.mjs → chunk-KMTGADN3.mjs} +28 -0
  82. package/dist/{chunk-QORUJDIV.mjs → chunk-KPFKMDM7.mjs} +2 -2
  83. package/dist/{chunk-YSCV4SJF.cjs → chunk-L5H2GSUC.cjs} +4 -4
  84. package/dist/{chunk-YDQZGSDS.mjs → chunk-LBDP3YT3.mjs} +1 -1
  85. package/dist/{chunk-6ETPZTJI.mjs → chunk-LBGILORX.mjs} +116 -55
  86. package/dist/{chunk-IPXLADVO.cjs → chunk-LOFKRKO7.cjs} +122 -61
  87. package/dist/{chunk-ULAWS2PA.cjs → chunk-LPFV45AY.cjs} +29 -26
  88. package/dist/{chunk-3KZS4SUS.mjs → chunk-MCIZVNOQ.mjs} +1 -1
  89. package/dist/{chunk-RU3M2FIK.cjs → chunk-MRMI32SN.cjs} +87 -369
  90. package/dist/{chunk-XCMCS4DA.mjs → chunk-ND2CWPOD.mjs} +2 -2
  91. package/dist/{chunk-XCACDAZZ.cjs → chunk-NDILNQ4L.cjs} +25 -10
  92. package/dist/{chunk-6TJOML4E.mjs → chunk-NFMDCAOS.mjs} +14 -11
  93. package/dist/{chunk-UXFQ3UDA.cjs → chunk-NICDYKBS.cjs} +42 -3
  94. package/dist/{chunk-EZDQRNQ7.mjs → chunk-NNSAQX3U.mjs} +23 -5
  95. package/dist/{chunk-YC6V7PWE.cjs → chunk-NQ6QFZWD.cjs} +1 -1
  96. package/dist/{chunk-PDOCJ6RY.mjs → chunk-O6WAEAX3.mjs} +1 -1
  97. package/dist/{chunk-U4KT7QP3.cjs → chunk-OW67PDDS.cjs} +14 -1
  98. package/dist/{chunk-77GNHH2Z.cjs → chunk-PMQHMWZU.cjs} +3 -3
  99. package/dist/chunk-PTZ2TVNE.cjs +178 -0
  100. package/dist/{chunk-6WCPV6G2.mjs → chunk-Q2KB32T4.mjs} +1 -1
  101. package/dist/{chunk-ICUQICNC.cjs → chunk-Q5FYSK45.cjs} +718 -532
  102. package/dist/{chunk-5SJWVY6R.mjs → chunk-QHSH7IH4.mjs} +9 -0
  103. package/dist/{chunk-Q3VLETLE.mjs → chunk-RRMVL6CJ.mjs} +4 -4
  104. package/dist/{chunk-IZY3V5XW.mjs → chunk-S3VWVTVA.mjs} +14 -1
  105. package/dist/{chunk-FFFW3OQ7.cjs → chunk-S6FJO323.cjs} +2 -2
  106. package/dist/{chunk-VFQT3LAO.cjs → chunk-SDOTRX3V.cjs} +5 -5
  107. package/dist/chunk-SGBZPZUW.mjs +75 -0
  108. package/dist/{chunk-BMWDEBXO.cjs → chunk-SHLXACIO.cjs} +31 -3
  109. package/dist/{chunk-ZXGAFZDO.cjs → chunk-T5OJPTVN.cjs} +2 -2
  110. package/dist/{chunk-2ELDTQRN.mjs → chunk-TDNWPAVR.mjs} +1 -1
  111. package/dist/{chunk-VZJR7UTG.cjs → chunk-TE2G5ION.cjs} +2 -2
  112. package/dist/{chunk-IHNIDL6H.cjs → chunk-TO4GJ56K.cjs} +22 -11
  113. package/dist/{chunk-4JHOT46A.mjs → chunk-TPLJVC7E.mjs} +86 -5
  114. package/dist/{chunk-NRSN7G7E.mjs → chunk-TW4GYDBJ.mjs} +1 -1
  115. package/dist/{chunk-XBML5KMG.cjs → chunk-U6MPZ35Q.cjs} +24 -14
  116. package/dist/chunk-UH6QN5NL.mjs +178 -0
  117. package/dist/{chunk-FTFYRMQQ.cjs → chunk-UJZLSXUB.cjs} +53 -28
  118. package/dist/chunk-UXHS27O6.cjs +75 -0
  119. package/dist/{chunk-DQQOKWYA.cjs → chunk-VR4GD5I3.cjs} +3 -3
  120. package/dist/{chunk-22LTEMGQ.mjs → chunk-VXAWRDK7.mjs} +14 -4
  121. package/dist/{chunk-62XKI4Z3.cjs → chunk-W2YDNK66.cjs} +6 -3
  122. package/dist/{chunk-VPTDD5XF.cjs → chunk-WBKEZXWE.cjs} +5 -0
  123. package/dist/{chunk-EJQT6KZN.cjs → chunk-WC5UV2HQ.cjs} +2 -2
  124. package/dist/{chunk-SAZVVAJH.mjs → chunk-WQ7T2263.mjs} +18 -7
  125. package/dist/chunk-WRPHYQVY.mjs +109 -0
  126. package/dist/chunk-WT4TGLXT.cjs +109 -0
  127. package/dist/{chunk-SOMHP6GF.mjs → chunk-XOPOIFTJ.mjs} +2 -2
  128. package/dist/{chunk-3PXS2MHU.mjs → chunk-YCKO6FRS.mjs} +1 -1
  129. package/dist/{chunk-C35ZBVRD.mjs → chunk-YWMZUGIS.mjs} +6 -2
  130. package/dist/{chunk-HMIJDL7S.mjs → chunk-Z5BEWYVO.mjs} +31 -6
  131. package/dist/{chunk-OKZUAXHF.mjs → chunk-Z7LA7MHQ.mjs} +1 -1
  132. package/dist/{chunk-Y7RKTKYI.mjs → chunk-ZMMBIVQM.mjs} +10 -0
  133. package/dist/{client-plugins-HIyulDym.d.ts → client-plugins-C8DjftDF.d.ts} +112 -5
  134. package/dist/{client-plugins-CvIslxWi.d.mts → client-plugins-CV4eJ9De.d.mts} +112 -5
  135. package/dist/client-plugins.d.mts +1 -1
  136. package/dist/client-plugins.d.ts +1 -1
  137. package/dist/client.cjs +8 -8
  138. package/dist/client.d.mts +5 -5
  139. package/dist/client.d.ts +5 -5
  140. package/dist/client.mjs +7 -7
  141. package/dist/config.d.mts +1 -1
  142. package/dist/config.d.ts +1 -1
  143. package/dist/{devtools-EAUY43BS.cjs → devtools-JXFQNWSH.cjs} +11 -10
  144. package/dist/{devtools-EE5RIBTH.mjs → devtools-KVOY2TCZ.mjs} +10 -9
  145. package/dist/docs.cjs +13 -12
  146. package/dist/docs.d.mts +2 -2
  147. package/dist/docs.d.ts +2 -2
  148. package/dist/docs.mjs +12 -11
  149. package/dist/headers.cjs +4 -4
  150. package/dist/headers.mjs +3 -3
  151. package/dist/i18n/client.cjs +11 -11
  152. package/dist/i18n/client.mjs +3 -3
  153. package/dist/image/server.cjs +3 -3
  154. package/dist/image/server.mjs +2 -2
  155. package/dist/image/sharp.cjs +10 -10
  156. package/dist/image/sharp.mjs +2 -2
  157. package/dist/index.cjs +61 -54
  158. package/dist/index.d.mts +14 -14
  159. package/dist/index.d.ts +14 -14
  160. package/dist/index.mjs +60 -53
  161. package/dist/integrations.cjs +8 -4
  162. package/dist/integrations.d.mts +1 -1
  163. package/dist/integrations.d.ts +1 -1
  164. package/dist/integrations.mjs +7 -3
  165. package/dist/internal/app-markdown-runtime.cjs +5 -3
  166. package/dist/internal/app-markdown-runtime.d.mts +19 -5
  167. package/dist/internal/app-markdown-runtime.d.ts +19 -5
  168. package/dist/internal/app-markdown-runtime.mjs +4 -2
  169. package/dist/internal/build-runtime.cjs +38 -34
  170. package/dist/internal/build-runtime.d.mts +3 -3
  171. package/dist/internal/build-runtime.d.ts +3 -3
  172. package/dist/internal/build-runtime.mjs +37 -33
  173. package/dist/internal/cli-runtime.cjs +17 -16
  174. package/dist/internal/cli-runtime.mjs +16 -15
  175. package/dist/internal/client-error-overlay.cjs +4 -4
  176. package/dist/internal/client-error-overlay.mjs +1 -1
  177. package/dist/internal/client-runtime.cjs +2 -2
  178. package/dist/internal/client-runtime.mjs +1 -1
  179. package/dist/internal/compression-runtime.d.mts +1 -1
  180. package/dist/internal/compression-runtime.d.ts +1 -1
  181. package/dist/internal/config-runtime.cjs +11 -10
  182. package/dist/internal/config-runtime.d.mts +2 -2
  183. package/dist/internal/config-runtime.d.ts +2 -2
  184. package/dist/internal/config-runtime.mjs +10 -9
  185. package/dist/internal/infra-analytics-runtime.cjs +5 -5
  186. package/dist/internal/infra-analytics-runtime.mjs +3 -3
  187. package/dist/internal/isolated-boundary.cjs +2 -2
  188. package/dist/internal/isolated-boundary.d.mts +0 -1
  189. package/dist/internal/isolated-boundary.d.ts +0 -1
  190. package/dist/internal/isolated-boundary.mjs +1 -1
  191. package/dist/internal/metadata-image-runtime.cjs +3 -3
  192. package/dist/internal/metadata-image-runtime.mjs +2 -2
  193. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  194. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  195. package/dist/internal/production-runtime.cjs +27 -48
  196. package/dist/internal/production-runtime.d.mts +67 -27
  197. package/dist/internal/production-runtime.d.ts +67 -27
  198. package/dist/internal/production-runtime.mjs +34 -55
  199. package/dist/{layers-BRQF5ETU.mjs → layers-UTB43B7A.mjs} +1 -1
  200. package/dist/layers-VUWIOFEO.cjs +18 -0
  201. package/dist/markdown.cjs +1 -1
  202. package/dist/markdown.d.mts +1 -1
  203. package/dist/markdown.d.ts +1 -1
  204. package/dist/markdown.mjs +1 -1
  205. package/dist/middleware.cjs +10 -10
  206. package/dist/middleware.d.mts +6 -4
  207. package/dist/middleware.d.ts +6 -4
  208. package/dist/middleware.mjs +9 -9
  209. package/dist/navigation.cjs +7 -7
  210. package/dist/navigation.d.mts +4 -4
  211. package/dist/navigation.d.ts +4 -4
  212. package/dist/navigation.mjs +6 -6
  213. package/dist/{nitro-OVPLKPE2.cjs → nitro-7F65EZZS.cjs} +3 -3
  214. package/dist/{nitro-MXRDCXWZ.mjs → nitro-MPZJGPXK.mjs} +2 -2
  215. package/dist/plugin.cjs +31 -28
  216. package/dist/plugin.d.mts +1 -1
  217. package/dist/plugin.d.ts +1 -1
  218. package/dist/plugin.mjs +30 -27
  219. package/dist/{production-runtime-Crq6CJ-2.d.ts → production-runtime-C2kkrPVZ.d.ts} +1 -1
  220. package/dist/{production-runtime-0sRnuYc-.d.mts → production-runtime-Du_FHb2-.d.mts} +1 -1
  221. package/dist/query/client.cjs +9 -9
  222. package/dist/query/client.mjs +4 -4
  223. package/dist/{render-plan-8ozZh2Qv.d.ts → render-plan-BnnPTpus.d.ts} +1 -1
  224. package/dist/{render-plan-gs9GGPzw.d.mts → render-plan-Cgx7v8tJ.d.mts} +1 -1
  225. package/dist/renderer/react/server.cjs +3 -3
  226. package/dist/renderer/react/server.mjs +1 -1
  227. package/dist/renderer-client.cjs +12 -12
  228. package/dist/renderer-client.d.mts +3 -3
  229. package/dist/renderer-client.d.ts +3 -3
  230. package/dist/renderer-client.mjs +4 -4
  231. package/dist/{request-B5G8rLBH.d.ts → request-BNWr7r5e.d.ts} +1 -1
  232. package/dist/{request-fkhiynXe.d.mts → request-sKayKcop.d.mts} +1 -1
  233. package/dist/request.cjs +3 -3
  234. package/dist/request.d.mts +2 -2
  235. package/dist/request.d.ts +2 -2
  236. package/dist/request.mjs +2 -2
  237. package/dist/{route-rendering-lS5nUMua.d.ts → route-rendering-Bx4Auw6Q.d.ts} +1 -1
  238. package/dist/{route-rendering-CLnS7AZj.d.mts → route-rendering-DWFp3Yq4.d.mts} +1 -1
  239. package/dist/{router-ifU8Dui1.d.mts → router-BK6K42Ij.d.mts} +1 -1
  240. package/dist/{router-4iuiYnOW.d.ts → router-DnW_2tQi.d.ts} +1 -1
  241. package/dist/routes.cjs +2 -2
  242. package/dist/routes.d.mts +1 -1
  243. package/dist/routes.d.ts +1 -1
  244. package/dist/routes.mjs +1 -1
  245. package/dist/runtime-CA3Ei5k_.d.ts +69 -0
  246. package/dist/runtime-DJDaCMd_.d.mts +69 -0
  247. package/dist/server-action-security.cjs +3 -3
  248. package/dist/server-action-security.mjs +2 -2
  249. package/dist/server-fn.cjs +5 -5
  250. package/dist/server-fn.mjs +4 -4
  251. package/dist/server-plugins.cjs +5 -5
  252. package/dist/server-plugins.d.mts +2 -2
  253. package/dist/server-plugins.d.ts +2 -2
  254. package/dist/server-plugins.mjs +4 -4
  255. package/dist/server-query.cjs +6 -6
  256. package/dist/server-query.mjs +5 -5
  257. package/dist/server.cjs +57 -54
  258. package/dist/server.d.mts +7 -7
  259. package/dist/server.d.ts +7 -7
  260. package/dist/server.mjs +35 -32
  261. package/dist/{spa-router-Bq7VCOwx.d.mts → spa-router-D6fUA4Rn.d.mts} +2 -2
  262. package/dist/{spa-router-DaJk5Re4.d.ts → spa-router-Mwbd7g2L.d.ts} +2 -2
  263. package/dist/testing.cjs +13 -13
  264. package/dist/testing.d.mts +1 -1
  265. package/dist/testing.d.ts +1 -1
  266. package/dist/testing.mjs +10 -10
  267. package/dist/theme/server.cjs +4 -4
  268. package/dist/theme/server.mjs +3 -3
  269. package/dist/{utils-BXLmFsVR.d.ts → utils-BwVcAfUR.d.ts} +1 -1
  270. package/dist/{utils-XJn0c9bj.d.mts → utils-p9Hs-jCc.d.mts} +1 -1
  271. package/dist/version.cjs +2 -2
  272. package/dist/version.mjs +1 -1
  273. package/dist/vite.cjs +31 -28
  274. package/dist/vite.d.mts +1 -1
  275. package/dist/vite.d.ts +1 -1
  276. package/dist/vite.mjs +30 -27
  277. package/dist/workflows.cjs +3 -3
  278. package/dist/workflows.mjs +2 -2
  279. package/package.json +1 -1
  280. package/types/middleware.d.ts +5 -1
  281. package/dist/chunk-FXEF4PPL.mjs +0 -47
  282. package/dist/chunk-XD32KALF.cjs +0 -47
  283. package/dist/layers-4PNE2HOY.cjs +0 -18
  284. /package/dist/{chunk-SJNMVDDF.cjs → chunk-FUCSUGDM.cjs} +0 -0
  285. /package/dist/{chunk-UDNPLXW7.mjs → chunk-MYIZXDZA.mjs} +0 -0
@@ -0,0 +1,178 @@
1
+ import {
2
+ collectFarmLlmsTxtPages
3
+ } from "./chunk-DTSROJ5J.mjs";
4
+ import {
5
+ getFarmMarkdownMirrorPath,
6
+ isFarmMarkdownMirrorExposed
7
+ } from "./chunk-WWIKMBRN.mjs";
8
+ import {
9
+ _listFarmMCPCatalogs,
10
+ _listFarmRegisteredMCPServers
11
+ } from "./chunk-ZLAT2CWY.mjs";
12
+ import {
13
+ applyFarmBasePath,
14
+ stripFarmBasePath
15
+ } from "./chunk-4RB44K6Z.mjs";
16
+ import {
17
+ __name
18
+ } from "./chunk-LPEX4YW6.mjs";
19
+
20
+ // src/agent-mcp.ts
21
+ var FARM_DEFAULT_MCP_PATH = "/mcp";
22
+ var FARM_DEFAULT_MCP_PROTOCOL_VERSIONS = [
23
+ "2025-11-25",
24
+ "2025-06-18",
25
+ "2025-03-26",
26
+ "2024-11-05"
27
+ ];
28
+ var FARM_DEFAULT_MCP_DESCRIPTION = "Read-only access to this site's public pages: list, search, and read them as Markdown.";
29
+ var READ_ONLY = {
30
+ readOnlyHint: true,
31
+ destructiveHint: false,
32
+ idempotentHint: true,
33
+ openWorldHint: false
34
+ };
35
+ var PAGE_SCHEMA = {
36
+ type: "object",
37
+ properties: {
38
+ path: { type: "string", description: `The page's path, such as "/about".` },
39
+ title: { type: "string" },
40
+ url: { type: "string", description: "The page's absolute URL." },
41
+ description: { type: "string" }
42
+ },
43
+ required: ["path", "title", "url"]
44
+ };
45
+ var PAGES_OUTPUT_SCHEMA = {
46
+ type: "object",
47
+ properties: { pages: { type: "array", items: PAGE_SCHEMA } },
48
+ required: ["pages"]
49
+ };
50
+ var FARM_DEFAULT_MCP_TOOLS = [
51
+ {
52
+ name: "list_pages",
53
+ title: "List pages",
54
+ description: "List this site's public pages with each page's path, title, URL, and description. Pass a page's path to read_page to read it as Markdown.",
55
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
56
+ outputSchema: PAGES_OUTPUT_SCHEMA,
57
+ annotations: READ_ONLY
58
+ },
59
+ {
60
+ name: "search_pages",
61
+ title: "Search pages",
62
+ description: "Search this site's public pages by title, description, and path. Every word of the query must match. Returns the matching pages, best match first.",
63
+ inputSchema: {
64
+ type: "object",
65
+ properties: {
66
+ query: {
67
+ type: "string",
68
+ minLength: 1,
69
+ maxLength: 200,
70
+ description: 'Words to look for, such as "pricing" or "getting started".'
71
+ },
72
+ limit: {
73
+ type: "integer",
74
+ minimum: 1,
75
+ maximum: 50,
76
+ default: 10,
77
+ description: "The most pages to return."
78
+ }
79
+ },
80
+ required: ["query"],
81
+ additionalProperties: false
82
+ },
83
+ outputSchema: PAGES_OUTPUT_SCHEMA,
84
+ annotations: READ_ONLY
85
+ },
86
+ {
87
+ name: "read_page",
88
+ title: "Read a page",
89
+ description: `Read one of this site's public pages as Markdown. Takes a path from list_pages or search_pages, such as "/" or "/about".`,
90
+ inputSchema: {
91
+ type: "object",
92
+ properties: {
93
+ path: {
94
+ type: "string",
95
+ minLength: 1,
96
+ maxLength: 2048,
97
+ description: `The page's path, such as "/about", or its full URL on this site.`
98
+ }
99
+ },
100
+ required: ["path"],
101
+ additionalProperties: false
102
+ },
103
+ annotations: READ_ONLY
104
+ }
105
+ ];
106
+ function collectFarmDefaultMCPPages(sources, options) {
107
+ const readable = [];
108
+ for (const source of sources) {
109
+ const module = isRecord(source.module) ? source.module : void 0;
110
+ if (module?.__farmRouteGuard) continue;
111
+ if (!isFarmMarkdownMirrorExposed(options.markdown, source.pattern)) continue;
112
+ readable.push({ pattern: source.pattern, metadata: module?.metadata });
113
+ }
114
+ return collectFarmLlmsTxtPages(readable, {
115
+ origin: options.origin,
116
+ basePath: options.basePath,
117
+ markdown: options.markdown
118
+ }).map((page) => ({
119
+ path: page.path,
120
+ title: page.title,
121
+ url: `${options.origin}${applyFarmBasePath(page.path, options.basePath)}`,
122
+ ...page.description ? { description: page.description } : {},
123
+ markdownUrl: `${options.origin}${applyFarmBasePath(
124
+ getFarmMarkdownMirrorPath(page.path),
125
+ options.basePath
126
+ )}`
127
+ }));
128
+ }
129
+ __name(collectFarmDefaultMCPPages, "collectFarmDefaultMCPPages");
130
+ function createFarmDefaultMCPServer(app, farmVersion) {
131
+ const name = typeof app?.name === "string" && app.name.trim() ? app.name.trim() : "farm-app";
132
+ const version = typeof app?.version === "string" && app.version.trim() ? app.version.trim() : farmVersion;
133
+ return {
134
+ name,
135
+ version,
136
+ description: FARM_DEFAULT_MCP_DESCRIPTION,
137
+ protocolVersions: [...FARM_DEFAULT_MCP_PROTOCOL_VERSIONS],
138
+ path: FARM_DEFAULT_MCP_PATH
139
+ };
140
+ }
141
+ __name(createFarmDefaultMCPServer, "createFarmDefaultMCPServer");
142
+ function resolveFarmDefaultMCPServer(server) {
143
+ if (!server) return void 0;
144
+ if (_listFarmMCPCatalogs().length > 0 || _listFarmRegisteredMCPServers().length > 0) {
145
+ return void 0;
146
+ }
147
+ return server;
148
+ }
149
+ __name(resolveFarmDefaultMCPServer, "resolveFarmDefaultMCPServer");
150
+ function isFarmDefaultMCPPathname(pathname, basePath) {
151
+ const path = stripFarmBasePath(pathname, basePath);
152
+ return path === FARM_DEFAULT_MCP_PATH || path === `${FARM_DEFAULT_MCP_PATH}/`;
153
+ }
154
+ __name(isFarmDefaultMCPPathname, "isFarmDefaultMCPPathname");
155
+ function farmConfigMountsMCP(config) {
156
+ const { mcp } = config;
157
+ if (isRecord(mcp) && mcp.enabled !== false) return true;
158
+ return Boolean(
159
+ config.plugins?.some((plugin) => isRecord(plugin) && plugin.name === "farm:api-mcp")
160
+ );
161
+ }
162
+ __name(farmConfigMountsMCP, "farmConfigMountsMCP");
163
+ function isRecord(value) {
164
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
165
+ }
166
+ __name(isRecord, "isRecord");
167
+
168
+ export {
169
+ FARM_DEFAULT_MCP_PATH,
170
+ FARM_DEFAULT_MCP_PROTOCOL_VERSIONS,
171
+ FARM_DEFAULT_MCP_DESCRIPTION,
172
+ FARM_DEFAULT_MCP_TOOLS,
173
+ collectFarmDefaultMCPPages,
174
+ createFarmDefaultMCPServer,
175
+ resolveFarmDefaultMCPServer,
176
+ isFarmDefaultMCPPathname,
177
+ farmConfigMountsMCP
178
+ };
@@ -4,7 +4,7 @@ var _chunkG643DQCHcjs = require('./chunk-G643DQCH.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunkZ2HLU4IXcjs = require('./chunk-Z2HLU4IX.cjs');
7
+ var _chunk4GWRFP22cjs = require('./chunk-4GWRFP22.cjs');
8
8
 
9
9
 
10
10
 
@@ -16,7 +16,7 @@ var _chunkZ2HLU4IXcjs = require('./chunk-Z2HLU4IX.cjs');
16
16
 
17
17
 
18
18
 
19
- var _chunkOMVAU7NTcjs = require('./chunk-OMVAU7NT.cjs');
19
+ var _chunkKIIMAWOJcjs = require('./chunk-KIIMAWOJ.cjs');
20
20
 
21
21
 
22
22
 
@@ -24,6 +24,10 @@ var _chunkUQZ4AYTHcjs = require('./chunk-UQZ4AYTH.cjs');
24
24
 
25
25
 
26
26
 
27
+ var _chunkKNBBQHO2cjs = require('./chunk-KNBBQHO2.cjs');
28
+
29
+
30
+
27
31
  var _chunkNZKJGRB3cjs = require('./chunk-NZKJGRB3.cjs');
28
32
 
29
33
 
@@ -839,9 +843,9 @@ function createIntegrationPlugin(integrationKey, integration) {
839
843
  if (!bodyLoaded) {
840
844
  bodyLoaded = true;
841
845
  if (req.method && req.method !== "GET" && req.method !== "HEAD") {
842
- requestBody = await _chunkOMVAU7NTcjs.readNodeRequestBody.call(void 0,
846
+ requestBody = await _chunkKIIMAWOJcjs.readNodeRequestBody.call(void 0,
843
847
  req,
844
- _chunkOMVAU7NTcjs.resolveFarmServerConfig.call(void 0, context.config.server).bodySizeLimit
848
+ _chunkKIIMAWOJcjs.resolveFarmServerConfig.call(void 0, context.config.server).bodySizeLimit
845
849
  );
846
850
  }
847
851
  }
@@ -851,7 +855,7 @@ function createIntegrationPlugin(integrationKey, integration) {
851
855
  try {
852
856
  return createWebRequest(req, fullUrl, await getRequestBody());
853
857
  } catch (error) {
854
- const response = _chunkOMVAU7NTcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
858
+ const response = _chunkKIIMAWOJcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
855
859
  if (!response) throw error;
856
860
  await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, response);
857
861
  return null;
@@ -1558,12 +1562,12 @@ function createFormInput(formData) {
1558
1562
  _chunkS3JO3N4Hcjs.__name.call(void 0, createFormInput, "createFormInput");
1559
1563
  async function dispatchIntegrationRequest(runtime, request, options = {}) {
1560
1564
  try {
1561
- request = await _chunkOMVAU7NTcjs.bufferFarmRequestBody.call(void 0,
1565
+ request = await _chunkKIIMAWOJcjs.bufferFarmRequestBody.call(void 0,
1562
1566
  request,
1563
- _chunkOMVAU7NTcjs.resolveFarmServerConfig.call(void 0, runtime.config.server).bodySizeLimit
1567
+ _chunkKIIMAWOJcjs.resolveFarmServerConfig.call(void 0, runtime.config.server).bodySizeLimit
1564
1568
  );
1565
1569
  } catch (error) {
1566
- const response = _chunkOMVAU7NTcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
1570
+ const response = _chunkKIIMAWOJcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
1567
1571
  if (response) return response;
1568
1572
  throw error;
1569
1573
  }
@@ -1577,10 +1581,12 @@ async function dispatchIntegrationRequest(runtime, request, options = {}) {
1577
1581
  const middleware = [...integration.middleware || []];
1578
1582
  const forwardedSetCookies = [];
1579
1583
  for (const entry of middleware) {
1584
+ if (_optionalChain([options, 'access', _24 => _24.ranMiddleware, 'optionalAccess', _25 => _25.has, 'call', _26 => _26(entry)])) continue;
1580
1585
  const params = resolveIntegrationMiddlewareParams(entry, pathname, runtime.config);
1581
1586
  if (!params) {
1582
1587
  continue;
1583
1588
  }
1589
+ _optionalChain([options, 'access', _27 => _27.ranMiddleware, 'optionalAccess', _28 => _28.add, 'call', _29 => _29(entry)]);
1584
1590
  const handlerContext = createServerIntegrationHandlerContext({
1585
1591
  runtime,
1586
1592
  route: {
@@ -1819,7 +1825,7 @@ async function dispatchIntegrationRequest(runtime, request, options = {}) {
1819
1825
  }
1820
1826
  }
1821
1827
  if (forwardedSetCookies.length > 0) {
1822
- _optionalChain([options, 'access', _24 => _24.onForwardedCookies, 'optionalCall', _25 => _25(forwardedSetCookies)]);
1828
+ _optionalChain([options, 'access', _30 => _30.onForwardedCookies, 'optionalCall', _31 => _31(forwardedSetCookies)]);
1823
1829
  }
1824
1830
  return null;
1825
1831
  }
@@ -1845,6 +1851,7 @@ async function dispatchIntegrationRequests(integrations, runtime, request, optio
1845
1851
  request.clone(),
1846
1852
  {
1847
1853
  currentRequest: options.currentRequest,
1854
+ ranMiddleware: options.ranMiddleware,
1848
1855
  onForwardedCookies: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (cookies) => setCookies.push(...cookies), "onForwardedCookies")
1849
1856
  }
1850
1857
  );
@@ -1931,38 +1938,38 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, createServerIntegrationHandlerContext, "cr
1931
1938
  function createServerIntegrationRequestContextStore(request, currentRequest) {
1932
1939
  return {
1933
1940
  get(key) {
1934
- const requestValue = _chunkOMVAU7NTcjs.getRequestContext.call(void 0, request, key);
1941
+ const requestValue = _chunkKIIMAWOJcjs.getRequestContext.call(void 0, request, key);
1935
1942
  if (requestValue !== void 0) {
1936
1943
  return requestValue;
1937
1944
  }
1938
1945
  if (currentRequest) {
1939
- return _chunkOMVAU7NTcjs.getRequestContext.call(void 0, currentRequest, key);
1946
+ return _chunkKIIMAWOJcjs.getRequestContext.call(void 0, currentRequest, key);
1940
1947
  }
1941
1948
  return void 0;
1942
1949
  },
1943
1950
  set(key, value, options) {
1944
- _chunkOMVAU7NTcjs.setRequestContext.call(void 0, request, key, value, options);
1951
+ _chunkKIIMAWOJcjs.setRequestContext.call(void 0, request, key, value, options);
1945
1952
  if (currentRequest) {
1946
- _chunkOMVAU7NTcjs.setRequestContext.call(void 0, currentRequest, key, value, options);
1953
+ _chunkKIIMAWOJcjs.setRequestContext.call(void 0, currentRequest, key, value, options);
1947
1954
  }
1948
1955
  },
1949
1956
  has(key) {
1950
- return _chunkOMVAU7NTcjs.hasRequestContext.call(void 0, request, key) || !!currentRequest && _chunkOMVAU7NTcjs.hasRequestContext.call(void 0, currentRequest, key);
1957
+ return _chunkKIIMAWOJcjs.hasRequestContext.call(void 0, request, key) || !!currentRequest && _chunkKIIMAWOJcjs.hasRequestContext.call(void 0, currentRequest, key);
1951
1958
  },
1952
1959
  delete(key) {
1953
- const deletedRequest = _chunkOMVAU7NTcjs.deleteRequestContext.call(void 0, request, key);
1954
- const deletedCurrent = currentRequest ? _chunkOMVAU7NTcjs.deleteRequestContext.call(void 0, currentRequest, key) : false;
1960
+ const deletedRequest = _chunkKIIMAWOJcjs.deleteRequestContext.call(void 0, request, key);
1961
+ const deletedCurrent = currentRequest ? _chunkKIIMAWOJcjs.deleteRequestContext.call(void 0, currentRequest, key) : false;
1955
1962
  return deletedRequest || deletedCurrent;
1956
1963
  },
1957
1964
  clear() {
1958
- _chunkOMVAU7NTcjs.clearRequestContext.call(void 0, request);
1965
+ _chunkKIIMAWOJcjs.clearRequestContext.call(void 0, request);
1959
1966
  if (currentRequest) {
1960
- _chunkOMVAU7NTcjs.clearRequestContext.call(void 0, currentRequest);
1967
+ _chunkKIIMAWOJcjs.clearRequestContext.call(void 0, currentRequest);
1961
1968
  }
1962
1969
  },
1963
1970
  snapshot(options) {
1964
- const merged = currentRequest ? _chunkOMVAU7NTcjs.getRequestContextSnapshot.call(void 0, currentRequest, options) : /* @__PURE__ */ new Map();
1965
- const requestSnapshot = _chunkOMVAU7NTcjs.getRequestContextSnapshot.call(void 0, request, options);
1971
+ const merged = currentRequest ? _chunkKIIMAWOJcjs.getRequestContextSnapshot.call(void 0, currentRequest, options) : /* @__PURE__ */ new Map();
1972
+ const requestSnapshot = _chunkKIIMAWOJcjs.getRequestContextSnapshot.call(void 0, request, options);
1966
1973
  for (const [key, value] of requestSnapshot) {
1967
1974
  merged.set(key, value);
1968
1975
  }
@@ -2006,28 +2013,45 @@ function resolveIntegrationMiddlewareParams(entry, pathname, config) {
2006
2013
  const params = resolveMatcherParams(entry.matcher, pathname);
2007
2014
  if (params || !entry.matcher) return params;
2008
2015
  const routePathname = resolveIntegrationRoutePathname(pathname, config);
2009
- if (routePathname !== pathname) {
2010
- const routeParams = resolveMatcherParams(entry.matcher, routePathname);
2016
+ const candidates = [.../* @__PURE__ */ new Set([pathname, ...getIntegrationAPIPathnames(config)(routePathname)])];
2017
+ for (const candidate of candidates) {
2018
+ if (candidate === pathname) continue;
2019
+ const routeParams = resolveMatcherParams(entry.matcher, candidate);
2011
2020
  if (routeParams) return routeParams;
2012
2021
  }
2013
2022
  let compiled = compiledIntegrationGuards.get(entry);
2014
2023
  if (!compiled) {
2015
- compiled = _chunkZ2HLU4IXcjs.compileMiddlewareConfig.call(void 0, {
2024
+ compiled = _chunk4GWRFP22cjs.compileMiddlewareConfig.call(void 0, {
2016
2025
  matcher: typeof entry.matcher === "string" ? entry.matcher : [...entry.matcher]
2017
2026
  });
2018
2027
  compiledIntegrationGuards.set(entry, compiled);
2019
2028
  }
2020
- for (const candidate of routePathname === pathname ? [pathname] : [pathname, routePathname]) {
2021
- const result = _chunkZ2HLU4IXcjs.matchesCompiledMiddlewareConfig.call(void 0, candidate, compiled, noMiddlewareContext);
2029
+ for (const candidate of candidates) {
2030
+ const result = _chunk4GWRFP22cjs.matchesCompiledMiddlewareConfig.call(void 0, candidate, compiled, noMiddlewareContext);
2022
2031
  if (result.matched) return _nullishCoalesce(result.params, () => ( {}));
2023
2032
  }
2024
2033
  return null;
2025
2034
  }
2026
2035
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationMiddlewareParams, "resolveIntegrationMiddlewareParams");
2036
+ var FARM_INTEGRATION_API_BASE_PATH_KEY = "__farmAPIServerBasePath";
2037
+ var integrationAPIPathnames = /* @__PURE__ */ new WeakMap();
2038
+ function getIntegrationAPIPathnames(config) {
2039
+ if (!config) return (pathname) => [pathname];
2040
+ let toPathnames = integrationAPIPathnames.get(config);
2041
+ if (!toPathnames) {
2042
+ const recorded = config[FARM_INTEGRATION_API_BASE_PATH_KEY];
2043
+ const api2 = config.api;
2044
+ const serverBasePath = typeof recorded === "string" ? recorded : typeof _optionalChain([api2, 'optionalAccess', _32 => _32.baseURL]) === "string" && typeof api2.basePath === "string" ? _chunkKNBBQHO2cjs.resolveFarmAPIServerBasePath.call(void 0, api2) : void 0;
2045
+ toPathnames = _chunkKNBBQHO2cjs.createFarmAPIMiddlewarePathnames.call(void 0, serverBasePath);
2046
+ integrationAPIPathnames.set(config, toPathnames);
2047
+ }
2048
+ return toPathnames;
2049
+ }
2050
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getIntegrationAPIPathnames, "getIntegrationAPIPathnames");
2027
2051
  function resolveIntegrationRoutePathname(pathname, config) {
2028
- const basePath = typeof _optionalChain([config, 'optionalAccess', _26 => _26.basePath]) === "string" ? config.basePath : void 0;
2052
+ const basePath = typeof _optionalChain([config, 'optionalAccess', _33 => _33.basePath]) === "string" ? config.basePath : void 0;
2029
2053
  let routePathname = basePath ? _chunkI57LW5VZcjs.stripFarmBasePath.call(void 0, pathname, basePath) : pathname;
2030
- const i18n = _optionalChain([config, 'optionalAccess', _27 => _27.i18n]);
2054
+ const i18n = _optionalChain([config, 'optionalAccess', _34 => _34.i18n]);
2031
2055
  if (i18n && Array.isArray(i18n.locales) && i18n.locales.length > 0) {
2032
2056
  routePathname = _chunkBIDYX3SLcjs.resolveFarmLocalePath.call(void 0, routePathname, {
2033
2057
  locales: i18n.locales,
@@ -2159,4 +2183,5 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeMatcher, "normalizeMatcher");
2159
2183
 
2160
2184
 
2161
2185
 
2162
- exports.getFarmPluginIntegrationContext = getFarmPluginIntegrationContext; exports.FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY; exports.FARM_INTEGRATION_SET_COOKIES_KEY = FARM_INTEGRATION_SET_COOKIES_KEY; exports.forwardIntegrationSetCookies = forwardIntegrationSetCookies; exports.defineIntegrationSchema = defineIntegrationSchema; exports.getFarmIntegrationPluginServerRuntime = getFarmIntegrationPluginServerRuntime; exports.getFarmIntegrationPluginOwner = getFarmIntegrationPluginOwner; exports.createIntegrationRoute = createIntegrationRoute; exports.integrationRoute = integrationRoute; exports.defineIntegration = defineIntegration; exports.isFarmIntegration = isFarmIntegration; exports.resolveIntegrationPlugins = resolveIntegrationPlugins; exports.getIntegrationProviders = getIntegrationProviders; exports.isFarmIntegrationProviderComponentReference = isFarmIntegrationProviderComponentReference; exports.getIntegrationDocumentNavigationMatchers = getIntegrationDocumentNavigationMatchers; exports.getIntegrationSchemas = getIntegrationSchemas; exports.getRegisteredIntegrationRuntime = getRegisteredIntegrationRuntime; exports.getRegisteredIntegrations = getRegisteredIntegrations; exports.getRegisteredIntegrationSchemas = getRegisteredIntegrationSchemas; exports.matchIntegrationRoute = matchIntegrationRoute; exports.matchRegisteredIntegrationRoute = matchRegisteredIntegrationRoute; exports.getRegisteredIntegrationAPIManifest = getRegisteredIntegrationAPIManifest; exports.dispatchIntegrationRequest = dispatchIntegrationRequest; exports.dispatchIntegrationRequests = dispatchIntegrationRequests;
2186
+
2187
+ exports.getFarmPluginIntegrationContext = getFarmPluginIntegrationContext; exports.FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY; exports.FARM_INTEGRATION_SET_COOKIES_KEY = FARM_INTEGRATION_SET_COOKIES_KEY; exports.forwardIntegrationSetCookies = forwardIntegrationSetCookies; exports.defineIntegrationSchema = defineIntegrationSchema; exports.getFarmIntegrationPluginServerRuntime = getFarmIntegrationPluginServerRuntime; exports.getFarmIntegrationPluginOwner = getFarmIntegrationPluginOwner; exports.createIntegrationRoute = createIntegrationRoute; exports.integrationRoute = integrationRoute; exports.defineIntegration = defineIntegration; exports.isFarmIntegration = isFarmIntegration; exports.resolveIntegrationPlugins = resolveIntegrationPlugins; exports.getIntegrationProviders = getIntegrationProviders; exports.isFarmIntegrationProviderComponentReference = isFarmIntegrationProviderComponentReference; exports.getIntegrationDocumentNavigationMatchers = getIntegrationDocumentNavigationMatchers; exports.getIntegrationSchemas = getIntegrationSchemas; exports.getRegisteredIntegrationRuntime = getRegisteredIntegrationRuntime; exports.getRegisteredIntegrations = getRegisteredIntegrations; exports.getRegisteredIntegrationSchemas = getRegisteredIntegrationSchemas; exports.matchIntegrationRoute = matchIntegrationRoute; exports.matchRegisteredIntegrationRoute = matchRegisteredIntegrationRoute; exports.getRegisteredIntegrationAPIManifest = getRegisteredIntegrationAPIManifest; exports.dispatchIntegrationRequest = dispatchIntegrationRequest; exports.dispatchIntegrationRequests = dispatchIntegrationRequests; exports.FARM_INTEGRATION_API_BASE_PATH_KEY = FARM_INTEGRATION_API_BASE_PATH_KEY;
@@ -0,0 +1,75 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/api/dev-dispatch.ts
6
+ var _http = require('http'); var _http2 = _interopRequireDefault(_http);
7
+ var _https = require('https'); var _https2 = _interopRequireDefault(_https);
8
+ var _stream = require('stream');
9
+ function createFarmDevServerDispatch(server) {
10
+ return (request) => new Promise((resolve, reject) => {
11
+ const address = _optionalChain([server, 'access', _ => _.httpServer, 'optionalAccess', _2 => _2.address, 'call', _3 => _3()]);
12
+ if (!address || typeof address === "string") {
13
+ throw new Error(
14
+ "Farm cannot dispatch an app endpoint request: the Vite dev server has no listening HTTP server."
15
+ );
16
+ }
17
+ const url = new URL(request.url);
18
+ const headers = {};
19
+ request.headers.forEach((value, name) => {
20
+ headers[name] = value;
21
+ });
22
+ headers.host = url.host;
23
+ const secure = Boolean(server.config.server.https);
24
+ const outgoing = (secure ? _https2.default : _http2.default).request(
25
+ {
26
+ host: loopbackAddress(address),
27
+ port: address.port,
28
+ method: request.method,
29
+ path: `${url.pathname}${url.search}`,
30
+ headers,
31
+ signal: request.signal,
32
+ // The listener is this process's own dev server, often with a self-signed certificate.
33
+ ...secure ? { rejectUnauthorized: false } : {}
34
+ },
35
+ (incoming) => {
36
+ const responseHeaders = new Headers();
37
+ for (const [name, value] of Object.entries(incoming.headers)) {
38
+ if (value === void 0) continue;
39
+ for (const entry of Array.isArray(value) ? value : [value]) {
40
+ responseHeaders.append(name, entry);
41
+ }
42
+ }
43
+ const status = _nullishCoalesce(incoming.statusCode, () => ( 502));
44
+ const hasBody = request.method !== "HEAD" && status !== 204 && status !== 205 && status !== 304;
45
+ if (!hasBody) incoming.resume();
46
+ try {
47
+ resolve(
48
+ new Response(
49
+ hasBody ? _stream.Readable.toWeb(incoming) : null,
50
+ { status, statusText: incoming.statusMessage, headers: responseHeaders }
51
+ )
52
+ );
53
+ } catch (error) {
54
+ incoming.destroy();
55
+ reject(error);
56
+ }
57
+ }
58
+ );
59
+ outgoing.on("error", reject);
60
+ if (request.body) {
61
+ _stream.Readable.fromWeb(request.body).on("error", (error) => outgoing.destroy(error)).pipe(outgoing);
62
+ } else {
63
+ outgoing.end();
64
+ }
65
+ });
66
+ }
67
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmDevServerDispatch, "createFarmDevServerDispatch");
68
+ function loopbackAddress({ address }) {
69
+ return address === "0.0.0.0" ? "127.0.0.1" : address === "::" ? "::1" : address;
70
+ }
71
+ _chunkS3JO3N4Hcjs.__name.call(void 0, loopbackAddress, "loopbackAddress");
72
+
73
+
74
+
75
+ exports.createFarmDevServerDispatch = createFarmDevServerDispatch;
@@ -3,18 +3,18 @@
3
3
  var _chunkAI7QMY7Ocjs = require('./chunk-AI7QMY7O.cjs');
4
4
 
5
5
 
6
- var _chunkUXFQ3UDAcjs = require('./chunk-UXFQ3UDA.cjs');
6
+ var _chunkNICDYKBScjs = require('./chunk-NICDYKBS.cjs');
7
7
 
8
8
 
9
9
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
10
10
 
11
11
  // src/headers.ts
12
12
  function headers() {
13
- return new Headers(_chunkUXFQ3UDAcjs.getCurrentRequest.call(void 0, ).headers);
13
+ return new Headers(_chunkNICDYKBScjs.getCurrentRequest.call(void 0, ).headers);
14
14
  }
15
15
  _chunkS3JO3N4Hcjs.__name.call(void 0, headers, "headers");
16
16
  function cookies() {
17
- const cookieHeader = _chunkUXFQ3UDAcjs.getCurrentRequest.call(void 0, ).headers.get("cookie") || "";
17
+ const cookieHeader = _chunkNICDYKBScjs.getCurrentRequest.call(void 0, ).headers.get("cookie") || "";
18
18
  const parsed = _chunkAI7QMY7Ocjs.parseRequestCookieHeader.call(void 0, cookieHeader);
19
19
  return {
20
20
  get(name) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  findProgrammaticRouteFilesInDir
3
- } from "./chunk-UDNPLXW7.mjs";
3
+ } from "./chunk-MYIZXDZA.mjs";
4
4
  import {
5
5
  isFarmAPIRouteFileName
6
6
  } from "./chunk-CU625VAY.mjs";
@@ -17,7 +17,7 @@ import {
17
17
  matchAPIRouteAtBasePath,
18
18
  mergePluginAPIRoutes,
19
19
  resolveAPIRouteEndpoint
20
- } from "./chunk-G5RT7EXW.mjs";
20
+ } from "./chunk-HEVMCTSR.mjs";
21
21
  import {
22
22
  registerAPIRouteShape
23
23
  } from "./chunk-W3B4PKAW.mjs";
@@ -31,7 +31,7 @@ import {
31
31
  import {
32
32
  loadFarmDevModule,
33
33
  toFileModuleUrl
34
- } from "./chunk-43FMW62B.mjs";
34
+ } from "./chunk-KMTGADN3.mjs";
35
35
  import {
36
36
  logger
37
37
  } from "./chunk-KI3MESHB.mjs";
@@ -68,6 +68,15 @@ var _APIRouteManager = class _APIRouteManager {
68
68
  this.i18n = options.i18n;
69
69
  this.bodySizeLimit = options.bodySizeLimit;
70
70
  this.basePath = options.basePath;
71
+ this.dispatch = options.dispatch;
72
+ }
73
+ /** Every file the current handlers were loaded from: route files and root routes files. */
74
+ getSourceFiles() {
75
+ const files = /* @__PURE__ */ new Set();
76
+ for (const sources of this.endpointSources.values()) {
77
+ for (const { filePath } of sources.values()) files.add(filePath);
78
+ }
79
+ return files;
71
80
  }
72
81
  /**
73
82
  * Discover route.ts files in /app/api and explicit endpoints in root routes.ts
@@ -94,7 +103,8 @@ var _APIRouteManager = class _APIRouteManager {
94
103
  }
95
104
  this.routes = new Map(
96
105
  mergePluginAPIRoutes([...this.routes.values()], this.plugins, void 0, {
97
- bodySizeLimit: this.bodySizeLimit
106
+ bodySizeLimit: this.bodySizeLimit,
107
+ dispatch: this.dispatch
98
108
  }).map((route) => [route.path, route])
99
109
  );
100
110
  } catch (error) {
@@ -1,6 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkULAWS2PAcjs = require('./chunk-ULAWS2PA.cjs');
3
+ var _chunkLPFV45AYcjs = require('./chunk-LPFV45AY.cjs');
4
+
5
+
6
+ var _chunk4GWRFP22cjs = require('./chunk-4GWRFP22.cjs');
4
7
 
5
8
 
6
9
  var _chunkHLJ6MBUZcjs = require('./chunk-HLJ6MBUZ.cjs');
@@ -210,7 +213,7 @@ var _MiddlewareChainImpl = class _MiddlewareChainImpl {
210
213
  */
211
214
  when(condition, fn) {
212
215
  const conditionalMiddleware = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (ctx, next) => {
213
- const shouldRun = typeof condition === "function" ? condition(ctx) : condition;
216
+ const shouldRun = typeof condition === "function" ? _chunk4GWRFP22cjs.matchesMiddlewarePredicate.call(void 0, condition, ctx) : condition;
214
217
  if (!shouldRun) {
215
218
  return next();
216
219
  }
@@ -415,7 +418,7 @@ function farmMiddlewarePlugin(options = {}) {
415
418
  mode: server.config.mode === "production" ? "production" : "development",
416
419
  basePath: _nullishCoalesce(options.basePath, () => ( "/"))
417
420
  });
418
- manager = new (0, _chunkULAWS2PAcjs.MiddlewareManager)(
421
+ manager = new (0, _chunkLPFV45AYcjs.MiddlewareManager)(
419
422
  getMiddlewareAppDirectory(server.config.root, srcDir),
420
423
  server,
421
424
  options.middleware,
@@ -190,6 +190,7 @@ function createFarmConfigResolutionPlugin(options) {
190
190
  };
191
191
  }
192
192
  _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmConfigResolutionPlugin, "createFarmConfigResolutionPlugin");
193
+ var FARM_CONFIG_ROOT = /* @__PURE__ */ Symbol.for("farm.configRoot");
193
194
  async function loadFarmConfigFile(configPath, options) {
194
195
  const { transform } = await import("rolldown/utils");
195
196
  const cacheRoot = _path2.default.resolve(options.cacheRoot || options.root);
@@ -207,6 +208,9 @@ async function loadFarmConfigFile(configPath, options) {
207
208
  plugins: [createFarmConfigResolutionPlugin({ transform })]
208
209
  });
209
210
  const moduleUrl = `${_url.pathToFileURL.call(void 0, modulePath).href}?t=${Date.now()}`;
211
+ const configRootState = globalThis;
212
+ const previousConfigRoot = configRootState[FARM_CONFIG_ROOT];
213
+ configRootState[FARM_CONFIG_ROOT] = cacheRoot;
210
214
  try {
211
215
  const loaded = await import(
212
216
  /* @vite-ignore */
@@ -218,6 +222,7 @@ async function loadFarmConfigFile(configPath, options) {
218
222
  }
219
223
  return config;
220
224
  } finally {
225
+ configRootState[FARM_CONFIG_ROOT] = previousConfigRoot;
221
226
  await _promises.unlink.call(void 0, modulePath).catch(() => void 0);
222
227
  }
223
228
  }
@@ -8,7 +8,7 @@ var _chunkLYLEZIG3cjs = require('./chunk-LYLEZIG3.cjs');
8
8
  var _chunkTKJZFIMLcjs = require('./chunk-TKJZFIML.cjs');
9
9
 
10
10
 
11
- var _chunkOMVAU7NTcjs = require('./chunk-OMVAU7NT.cjs');
11
+ var _chunkKIIMAWOJcjs = require('./chunk-KIIMAWOJ.cjs');
12
12
 
13
13
 
14
14
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -137,7 +137,7 @@ async function finalizeMetadataImageResponse(body, headers, options) {
137
137
  responseHeaders.set("ETag", etag);
138
138
  responseHeaders.set("Content-Length", String(body.byteLength));
139
139
  responseHeaders.set("X-Content-Type-Options", "nosniff");
140
- if (_chunkOMVAU7NTcjs.matchesFarmIfNoneMatch.call(void 0, options.ifNoneMatch, etag)) {
140
+ if (_chunkKIIMAWOJcjs.matchesFarmIfNoneMatch.call(void 0, options.ifNoneMatch, etag)) {
141
141
  return new Response(null, { status: 304, headers: responseHeaders });
142
142
  }
143
143
  return new Response(_optionalChain([options, 'access', _4 => _4.method, 'optionalAccess', _5 => _5.toUpperCase, 'call', _6 => _6()]) === "HEAD" ? null : body, {