@farm.js/core 0.1.35 → 0.1.36

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 (214) hide show
  1. package/dist/{metadata-WGpBYcGn.d.mts → agent-mcp-BVExL8rZ.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-BnLDsUOS.d.ts → agent-mcp-luzfXK-P.d.ts} +45 -2
  5. package/dist/agent-runtime.cjs +5 -3
  6. package/dist/agent-runtime.d.mts +1 -1
  7. package/dist/agent-runtime.d.ts +1 -1
  8. package/dist/agent-runtime.mjs +4 -2
  9. package/dist/api/route-manager.cjs +6 -6
  10. package/dist/api/route-manager.d.mts +10 -4
  11. package/dist/api/route-manager.d.ts +10 -4
  12. package/dist/api/route-manager.mjs +5 -5
  13. package/dist/api/runtime.cjs +4 -4
  14. package/dist/api/runtime.d.mts +4 -62
  15. package/dist/api/runtime.d.ts +4 -62
  16. package/dist/api/runtime.mjs +3 -3
  17. package/dist/api.cjs +8 -8
  18. package/dist/api.d.mts +3 -3
  19. package/dist/api.d.ts +3 -3
  20. package/dist/api.mjs +7 -7
  21. package/dist/{app-D_j9AAVL.d.mts → app-BukwkFIu.d.mts} +17 -3
  22. package/dist/{app-BXB3JZYc.d.ts → app-Yfa2dsFy.d.ts} +17 -3
  23. package/dist/app-markdown.cjs +4 -4
  24. package/dist/app-markdown.d.mts +2 -2
  25. package/dist/app-markdown.d.ts +2 -2
  26. package/dist/app-markdown.mjs +3 -3
  27. package/dist/{chunk-4KU5Q7C2.mjs → chunk-276VJSM6.mjs} +221 -48
  28. package/dist/{chunk-PFQKNERH.cjs → chunk-2YTDKNH3.cjs} +364 -197
  29. package/dist/{chunk-UAORZ7QA.mjs → chunk-35GKZR22.mjs} +2 -2
  30. package/dist/{chunk-QAU5JD57.mjs → chunk-35WV46VL.mjs} +203 -36
  31. package/dist/{chunk-EFCQPQMG.cjs → chunk-42NHY7HW.cjs} +54 -4
  32. package/dist/{chunk-SOMHP6GF.mjs → chunk-4E5AEDKY.mjs} +2 -2
  33. package/dist/{chunk-UJD4PHYB.mjs → chunk-4E5WBPEG.mjs} +72 -354
  34. package/dist/{chunk-2G2NNLE2.mjs → chunk-4GLOOWKE.mjs} +4 -4
  35. package/dist/{chunk-62XKI4Z3.cjs → chunk-4NU4GGTC.cjs} +2 -2
  36. package/dist/{chunk-4JHOT46A.mjs → chunk-4WCZJQUO.mjs} +54 -4
  37. package/dist/chunk-4WQ6PGSJ.cjs +367 -0
  38. package/dist/{chunk-SMHH4VDG.mjs → chunk-4WVJLURN.mjs} +1 -1
  39. package/dist/chunk-6SJ2KJTA.mjs +314 -0
  40. package/dist/{chunk-IPXLADVO.cjs → chunk-ADEA7PN3.cjs} +122 -61
  41. package/dist/{chunk-CP6X4AEU.mjs → chunk-AJQTP4OO.mjs} +1 -1
  42. package/dist/{chunk-4MMGO7YW.cjs → chunk-AO6RYU5N.cjs} +31 -28
  43. package/dist/{chunk-GFHLGIYC.cjs → chunk-BO36SELV.cjs} +6 -6
  44. package/dist/{chunk-6TJOML4E.mjs → chunk-BPOF5U4N.mjs} +4 -4
  45. package/dist/{chunk-JHWOVJ3M.mjs → chunk-BUGNQIHC.mjs} +5 -0
  46. package/dist/{chunk-FTFYRMQQ.cjs → chunk-CBJJH36A.cjs} +50 -25
  47. package/dist/{chunk-7GLPRTTF.cjs → chunk-CGBDNNSM.cjs} +2 -2
  48. package/dist/chunk-CI6E3UOH.cjs +314 -0
  49. package/dist/{chunk-X6W5FFH6.cjs → chunk-D2BB47NB.cjs} +8 -8
  50. package/dist/chunk-DTSROJ5J.mjs +367 -0
  51. package/dist/{chunk-YC6V7PWE.cjs → chunk-DZ5ZVB2K.cjs} +1 -1
  52. package/dist/{chunk-DBNKI4NF.cjs → chunk-ECKF2BAM.cjs} +6 -2
  53. package/dist/{chunk-Q3VLETLE.mjs → chunk-EWET4D2Y.mjs} +1 -1
  54. package/dist/{chunk-HUMR6LSU.mjs → chunk-F5QO4FNE.mjs} +1 -1
  55. package/dist/{chunk-XBML5KMG.cjs → chunk-FO427P6I.cjs} +22 -12
  56. package/dist/{chunk-SAZVVAJH.mjs → chunk-GQRWBCWK.mjs} +8 -5
  57. package/dist/{chunk-F6Z3Y5KL.mjs → chunk-HOXTWRGB.mjs} +1 -1
  58. package/dist/{chunk-3BHT4WMP.cjs → chunk-JNUWCDTF.cjs} +6 -6
  59. package/dist/{chunk-73MC7ZL6.cjs → chunk-JZVADIOD.cjs} +2 -2
  60. package/dist/{chunk-OMVAU7NT.cjs → chunk-KIIMAWOJ.cjs} +11 -1
  61. package/dist/{chunk-43FMW62B.mjs → chunk-KMTGADN3.mjs} +28 -0
  62. package/dist/{chunk-6ETPZTJI.mjs → chunk-LSZAVSGY.mjs} +116 -55
  63. package/dist/{chunk-HMIJDL7S.mjs → chunk-MKYBIIAQ.mjs} +30 -5
  64. package/dist/{chunk-RU3M2FIK.cjs → chunk-MRMI32SN.cjs} +87 -369
  65. package/dist/{chunk-7L5V3KQO.cjs → chunk-N2NAS2AM.cjs} +2 -2
  66. package/dist/{chunk-ICUQICNC.cjs → chunk-NMHWYWDR.cjs} +654 -481
  67. package/dist/{chunk-G5RT7EXW.mjs → chunk-O6I6VWKK.mjs} +20 -5
  68. package/dist/{chunk-PDOCJ6RY.mjs → chunk-O6WAEAX3.mjs} +1 -1
  69. package/dist/{chunk-6DU6UFUE.mjs → chunk-OHLSEQ57.mjs} +16 -8
  70. package/dist/{chunk-3PXS2MHU.mjs → chunk-OO7GXVSR.mjs} +1 -1
  71. package/dist/chunk-PTZ2TVNE.cjs +178 -0
  72. package/dist/{chunk-6WCPV6G2.mjs → chunk-Q2KB32T4.mjs} +1 -1
  73. package/dist/{chunk-XCACDAZZ.cjs → chunk-S6VYG6XU.cjs} +23 -8
  74. package/dist/{chunk-VFQT3LAO.cjs → chunk-SDOTRX3V.cjs} +5 -5
  75. package/dist/{chunk-BMWDEBXO.cjs → chunk-SHLXACIO.cjs} +31 -3
  76. package/dist/{chunk-22LTEMGQ.mjs → chunk-T4OGRVNS.mjs} +13 -3
  77. package/dist/{chunk-ZXGAFZDO.cjs → chunk-T5OJPTVN.cjs} +2 -2
  78. package/dist/{chunk-VZJR7UTG.cjs → chunk-TE2G5ION.cjs} +2 -2
  79. package/dist/chunk-UH6QN5NL.mjs +178 -0
  80. package/dist/{chunk-F7JZENPF.cjs → chunk-UVW64BCB.cjs} +38 -30
  81. package/dist/{chunk-OKZUAXHF.mjs → chunk-VILIPRS6.mjs} +1 -1
  82. package/dist/{chunk-3UH7MRCP.cjs → chunk-VQLJWDVW.cjs} +13 -13
  83. package/dist/{chunk-VPTDD5XF.cjs → chunk-WBKEZXWE.cjs} +5 -0
  84. package/dist/{chunk-EJQT6KZN.cjs → chunk-WC5UV2HQ.cjs} +2 -2
  85. package/dist/{chunk-YULD7ICZ.mjs → chunk-WZ77PUAM.mjs} +1 -1
  86. package/dist/{chunk-C35ZBVRD.mjs → chunk-YWMZUGIS.mjs} +6 -2
  87. package/dist/{chunk-Y7RKTKYI.mjs → chunk-ZMMBIVQM.mjs} +10 -0
  88. package/dist/{chunk-ULAWS2PA.cjs → chunk-ZWM5KGAA.cjs} +6 -6
  89. package/dist/{client-plugins-CvIslxWi.d.mts → client-plugins-C3mK9Pol.d.mts} +98 -5
  90. package/dist/{client-plugins-HIyulDym.d.ts → client-plugins-r1mOtSC1.d.ts} +98 -5
  91. package/dist/client-plugins.d.mts +1 -1
  92. package/dist/client-plugins.d.ts +1 -1
  93. package/dist/client.d.mts +5 -5
  94. package/dist/client.d.ts +5 -5
  95. package/dist/config.d.mts +1 -1
  96. package/dist/config.d.ts +1 -1
  97. package/dist/{devtools-EE5RIBTH.mjs → devtools-ERIKFEXX.mjs} +9 -8
  98. package/dist/{devtools-EAUY43BS.cjs → devtools-JZJJY5CK.cjs} +10 -9
  99. package/dist/docs.cjs +12 -11
  100. package/dist/docs.d.mts +2 -2
  101. package/dist/docs.d.ts +2 -2
  102. package/dist/docs.mjs +11 -10
  103. package/dist/image/server.cjs +3 -3
  104. package/dist/image/server.mjs +2 -2
  105. package/dist/image/sharp.cjs +10 -10
  106. package/dist/image/sharp.mjs +2 -2
  107. package/dist/index.cjs +39 -35
  108. package/dist/index.d.mts +13 -13
  109. package/dist/index.d.ts +13 -13
  110. package/dist/index.mjs +38 -34
  111. package/dist/integrations.cjs +7 -3
  112. package/dist/integrations.d.mts +1 -1
  113. package/dist/integrations.d.ts +1 -1
  114. package/dist/integrations.mjs +6 -2
  115. package/dist/internal/app-markdown-runtime.cjs +3 -3
  116. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  117. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  118. package/dist/internal/app-markdown-runtime.mjs +2 -2
  119. package/dist/internal/build-runtime.cjs +27 -25
  120. package/dist/internal/build-runtime.d.mts +3 -3
  121. package/dist/internal/build-runtime.d.ts +3 -3
  122. package/dist/internal/build-runtime.mjs +26 -24
  123. package/dist/internal/cli-runtime.cjs +14 -13
  124. package/dist/internal/cli-runtime.mjs +13 -12
  125. package/dist/internal/client-error-overlay.cjs +4 -4
  126. package/dist/internal/client-error-overlay.mjs +1 -1
  127. package/dist/internal/compression-runtime.d.mts +1 -1
  128. package/dist/internal/compression-runtime.d.ts +1 -1
  129. package/dist/internal/config-runtime.cjs +10 -9
  130. package/dist/internal/config-runtime.d.mts +2 -2
  131. package/dist/internal/config-runtime.d.ts +2 -2
  132. package/dist/internal/config-runtime.mjs +9 -8
  133. package/dist/internal/isolated-boundary.cjs +2 -2
  134. package/dist/internal/isolated-boundary.d.mts +0 -1
  135. package/dist/internal/isolated-boundary.d.ts +0 -1
  136. package/dist/internal/isolated-boundary.mjs +1 -1
  137. package/dist/internal/metadata-image-runtime.cjs +3 -3
  138. package/dist/internal/metadata-image-runtime.mjs +2 -2
  139. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  140. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  141. package/dist/internal/production-runtime.cjs +23 -9
  142. package/dist/internal/production-runtime.d.mts +67 -27
  143. package/dist/internal/production-runtime.d.ts +67 -27
  144. package/dist/internal/production-runtime.mjs +26 -12
  145. package/dist/{layers-BRQF5ETU.mjs → layers-UTB43B7A.mjs} +1 -1
  146. package/dist/layers-VUWIOFEO.cjs +18 -0
  147. package/dist/markdown.cjs +1 -1
  148. package/dist/markdown.d.mts +1 -1
  149. package/dist/markdown.d.ts +1 -1
  150. package/dist/markdown.mjs +1 -1
  151. package/dist/middleware.cjs +6 -6
  152. package/dist/middleware.d.mts +3 -3
  153. package/dist/middleware.d.ts +3 -3
  154. package/dist/middleware.mjs +5 -5
  155. package/dist/navigation.d.mts +4 -4
  156. package/dist/navigation.d.ts +4 -4
  157. package/dist/{nitro-OVPLKPE2.cjs → nitro-7F65EZZS.cjs} +3 -3
  158. package/dist/{nitro-MXRDCXWZ.mjs → nitro-MPZJGPXK.mjs} +2 -2
  159. package/dist/plugin.cjs +23 -21
  160. package/dist/plugin.d.mts +1 -1
  161. package/dist/plugin.d.ts +1 -1
  162. package/dist/plugin.mjs +22 -20
  163. package/dist/{production-runtime-0sRnuYc-.d.mts → production-runtime-CCeVZXst.d.mts} +1 -1
  164. package/dist/{production-runtime-Crq6CJ-2.d.ts → production-runtime-DPnsggY3.d.ts} +1 -1
  165. package/dist/{render-plan-gs9GGPzw.d.mts → render-plan-BuGaPFe6.d.mts} +1 -1
  166. package/dist/{render-plan-8ozZh2Qv.d.ts → render-plan-Cw4f5E_R.d.ts} +1 -1
  167. package/dist/renderer/react/server.cjs +3 -3
  168. package/dist/renderer/react/server.mjs +1 -1
  169. package/dist/renderer-client.d.mts +3 -3
  170. package/dist/renderer-client.d.ts +3 -3
  171. package/dist/{request-B5G8rLBH.d.ts → request-Bkg-hERy.d.ts} +1 -1
  172. package/dist/{request-fkhiynXe.d.mts → request-CsGARcAw.d.mts} +1 -1
  173. package/dist/request.d.mts +2 -2
  174. package/dist/request.d.ts +2 -2
  175. package/dist/{route-rendering-lS5nUMua.d.ts → route-rendering-BUZMH_64.d.ts} +1 -1
  176. package/dist/{route-rendering-CLnS7AZj.d.mts → route-rendering-f11yh5dp.d.mts} +1 -1
  177. package/dist/{router-4iuiYnOW.d.ts → router-B8CR9GbD.d.ts} +1 -1
  178. package/dist/{router-ifU8Dui1.d.mts → router-Cp6yRE8A.d.mts} +1 -1
  179. package/dist/routes.d.mts +1 -1
  180. package/dist/routes.d.ts +1 -1
  181. package/dist/runtime-CAEv36S_.d.mts +69 -0
  182. package/dist/runtime-CQVsT330.d.ts +69 -0
  183. package/dist/server-action-security.cjs +3 -3
  184. package/dist/server-action-security.mjs +2 -2
  185. package/dist/server-fn.cjs +4 -4
  186. package/dist/server-fn.mjs +3 -3
  187. package/dist/server-plugins.d.mts +2 -2
  188. package/dist/server-plugins.d.ts +2 -2
  189. package/dist/server-query.cjs +5 -5
  190. package/dist/server-query.mjs +4 -4
  191. package/dist/server.cjs +42 -40
  192. package/dist/server.d.mts +7 -7
  193. package/dist/server.d.ts +7 -7
  194. package/dist/server.mjs +25 -23
  195. package/dist/{spa-router-DaJk5Re4.d.ts → spa-router-BuciWGCZ.d.ts} +2 -2
  196. package/dist/{spa-router-Bq7VCOwx.d.mts → spa-router-DwbqGkGj.d.mts} +2 -2
  197. package/dist/testing.cjs +8 -8
  198. package/dist/testing.d.mts +1 -1
  199. package/dist/testing.d.ts +1 -1
  200. package/dist/testing.mjs +6 -6
  201. package/dist/{utils-XJn0c9bj.d.mts → utils-B9V0S_yL.d.mts} +1 -1
  202. package/dist/{utils-BXLmFsVR.d.ts → utils-CaoWKtYM.d.ts} +1 -1
  203. package/dist/version.cjs +2 -2
  204. package/dist/version.mjs +1 -1
  205. package/dist/vite.cjs +23 -21
  206. package/dist/vite.d.mts +1 -1
  207. package/dist/vite.d.ts +1 -1
  208. package/dist/vite.mjs +22 -20
  209. package/dist/workflows.cjs +3 -3
  210. package/dist/workflows.mjs +2 -2
  211. package/package.json +1 -1
  212. package/dist/layers-4PNE2HOY.cjs +0 -18
  213. package/dist/{chunk-2F2ER724.cjs → chunk-BPMATOP2.cjs} +2 -2
  214. package/dist/{chunk-IHNMMXHV.mjs → chunk-OTC5BDGO.mjs} +3 -3
@@ -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,8 +2013,10 @@ 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);
@@ -2017,17 +2026,32 @@ function resolveIntegrationMiddlewareParams(entry, pathname, config) {
2017
2026
  });
2018
2027
  compiledIntegrationGuards.set(entry, compiled);
2019
2028
  }
2020
- for (const candidate of routePathname === pathname ? [pathname] : [pathname, routePathname]) {
2029
+ for (const candidate of candidates) {
2021
2030
  const result = _chunkZ2HLU4IXcjs.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;
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 _chunkOMVAU7NTcjs = require('./chunk-OMVAU7NT.cjs');
3
+ var _chunkKIIMAWOJcjs = require('./chunk-KIIMAWOJ.cjs');
4
4
 
5
5
 
6
6
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -583,7 +583,7 @@ function createOptimizedImageResponse(request, image, config) {
583
583
  if (image.contentType === "image/svg+xml" && config.dangerouslyAllowSVG) {
584
584
  headers.set("content-security-policy", "default-src 'none'; sandbox");
585
585
  }
586
- if (_chunkOMVAU7NTcjs.matchesFarmIfNoneMatch.call(void 0, request.headers.get("if-none-match"), image.etag)) {
586
+ if (_chunkKIIMAWOJcjs.matchesFarmIfNoneMatch.call(void 0, request.headers.get("if-none-match"), image.etag)) {
587
587
  headers.delete("content-length");
588
588
  return new Response(null, { status: 304, headers });
589
589
  }
@@ -0,0 +1,314 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
+
4
+
5
+ var _chunkPTZ2TVNEcjs = require('./chunk-PTZ2TVNE.cjs');
6
+
7
+
8
+ var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
9
+
10
+
11
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
12
+
13
+ // src/agent-mcp-handler.ts
14
+ var INSTRUCTIONS = "This server reads the site's public pages. Call list_pages or search_pages to find a page, then read_page with its path to get the page as Markdown. It cannot change anything.";
15
+ var MAX_BODY_BYTES = 64 * 1024;
16
+ var MAX_BATCH = 16;
17
+ var READ_TIMEOUT_MS = 3e4;
18
+ var _FarmMCPRequestError = class _FarmMCPRequestError extends Error {
19
+ constructor(code, message) {
20
+ super(message);
21
+ this.code = code;
22
+ }
23
+ };
24
+ _chunkS3JO3N4Hcjs.__name.call(void 0, _FarmMCPRequestError, "FarmMCPRequestError");
25
+ var FarmMCPRequestError = _FarmMCPRequestError;
26
+ var PARSE_ERROR = -32700;
27
+ var INVALID_REQUEST = -32600;
28
+ var METHOD_NOT_FOUND = -32601;
29
+ var INVALID_PARAMS = -32602;
30
+ var INTERNAL_ERROR = -32603;
31
+ var TRANSPORT_ERROR = -32e3;
32
+ async function handleFarmDefaultMCPRequest(request, context) {
33
+ const method = request.method.toUpperCase();
34
+ if (method !== "POST") {
35
+ return transportError(405, "Method not allowed. Send MCP requests with POST.", {
36
+ Allow: "POST"
37
+ });
38
+ }
39
+ const origin = request.headers.get("origin");
40
+ if (origin && !isSameOrigin(origin, request.url)) {
41
+ return transportError(403, "Cross-origin requests are not allowed.");
42
+ }
43
+ const protocolHeader = request.headers.get("mcp-protocol-version");
44
+ if (protocolHeader && !_chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.includes(protocolHeader.trim())) {
45
+ return transportError(
46
+ 400,
47
+ `Unsupported MCP-Protocol-Version: ${protocolHeader.slice(0, 32)}. Supported: ${_chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.join(", ")}.`
48
+ );
49
+ }
50
+ const contentType = _nullishCoalesce(request.headers.get("content-type"), () => ( ""));
51
+ if (!/^application\/json\s*(?:;|$)/i.test(contentType.trim())) {
52
+ return transportError(415, "Content-Type must be application/json.");
53
+ }
54
+ const text = await readBody(request);
55
+ if (text === null) return transportError(413, "The request body is too large.");
56
+ let message;
57
+ try {
58
+ message = JSON.parse(text);
59
+ } catch (e) {
60
+ return json(400, rpcError(null, { code: PARSE_ERROR, message: "Parse error." }));
61
+ }
62
+ if (Array.isArray(message)) {
63
+ if (message.length === 0 || message.length > MAX_BATCH) {
64
+ return json(
65
+ 400,
66
+ rpcError(null, { code: INVALID_REQUEST, message: "Invalid batch of JSON-RPC messages." })
67
+ );
68
+ }
69
+ const replies = (await Promise.all(message.map((item) => answerMessage(item, request, context)))).filter((reply2) => reply2 !== void 0);
70
+ return replies.length ? json(200, replies) : new Response(null, { status: 202 });
71
+ }
72
+ const reply = await answerMessage(message, request, context);
73
+ return reply === void 0 ? new Response(null, { status: 202 }) : json(200, reply);
74
+ }
75
+ _chunkS3JO3N4Hcjs.__name.call(void 0, handleFarmDefaultMCPRequest, "handleFarmDefaultMCPRequest");
76
+ async function answerMessage(message, request, context) {
77
+ if (!isRecord(message) || message.jsonrpc !== "2.0") {
78
+ return rpcError(readId(message), { code: INVALID_REQUEST, message: "Invalid Request." });
79
+ }
80
+ const hasId = "id" in message;
81
+ if (typeof message.method !== "string") {
82
+ if (hasId && ("result" in message || "error" in message)) return void 0;
83
+ return rpcError(readId(message), { code: INVALID_REQUEST, message: "Invalid Request." });
84
+ }
85
+ if (!hasId) return void 0;
86
+ const id = readId(message);
87
+ if (id === void 0) {
88
+ return rpcError(null, { code: INVALID_REQUEST, message: "Invalid Request id." });
89
+ }
90
+ try {
91
+ const result = await dispatch(message.method, message.params, request, context);
92
+ return { jsonrpc: "2.0", id, result };
93
+ } catch (error) {
94
+ if (error instanceof FarmMCPRequestError) {
95
+ return rpcError(id, { code: error.code, message: error.message });
96
+ }
97
+ return rpcError(id, { code: INTERNAL_ERROR, message: "Internal error." });
98
+ }
99
+ }
100
+ _chunkS3JO3N4Hcjs.__name.call(void 0, answerMessage, "answerMessage");
101
+ async function dispatch(method, params, request, context) {
102
+ switch (method) {
103
+ case "initialize": {
104
+ const requested = isRecord(params) ? params.protocolVersion : void 0;
105
+ const protocolVersion = typeof requested === "string" && _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.includes(requested) ? requested : _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS[0];
106
+ return {
107
+ protocolVersion,
108
+ capabilities: { tools: { listChanged: false } },
109
+ serverInfo: {
110
+ name: context.server.name,
111
+ version: context.server.version,
112
+ ...context.server.title ? { title: context.server.title } : {},
113
+ description: _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_DESCRIPTION
114
+ },
115
+ instructions: INSTRUCTIONS
116
+ };
117
+ }
118
+ case "ping":
119
+ return {};
120
+ case "tools/list":
121
+ return { tools: _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_TOOLS };
122
+ case "tools/call":
123
+ return callTool(params, request, context);
124
+ default:
125
+ throw new FarmMCPRequestError(METHOD_NOT_FOUND, `Method not found: ${method.slice(0, 64)}`);
126
+ }
127
+ }
128
+ _chunkS3JO3N4Hcjs.__name.call(void 0, dispatch, "dispatch");
129
+ async function callTool(params, request, context) {
130
+ if (!isRecord(params) || typeof params.name !== "string") {
131
+ throw new FarmMCPRequestError(INVALID_PARAMS, "tools/call needs a tool name.");
132
+ }
133
+ const tool = _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_TOOLS.find(({ name }) => name === params.name);
134
+ if (!tool) {
135
+ throw new FarmMCPRequestError(INVALID_PARAMS, `Unknown tool: ${params.name.slice(0, 64)}`);
136
+ }
137
+ const args = _nullishCoalesce(params.arguments, () => ( {}));
138
+ if (!isRecord(args)) return toolError("Arguments must be an object.");
139
+ const allowed = new Set(Object.keys(tool.inputSchema.properties));
140
+ const unknown = Object.keys(args).find((key) => !allowed.has(key));
141
+ if (unknown) return toolError(`Unknown argument: ${unknown.slice(0, 64)}.`);
142
+ if (tool.name === "list_pages") return pagesResult(await context.listPages());
143
+ if (tool.name === "search_pages") {
144
+ const query = args.query;
145
+ if (typeof query !== "string" || !query.trim() || query.length > 200) {
146
+ return toolError("query must be a non-empty string of at most 200 characters.");
147
+ }
148
+ const limit = _nullishCoalesce(args.limit, () => ( 10));
149
+ if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1 || limit > 50) {
150
+ return toolError("limit must be a whole number from 1 to 50.");
151
+ }
152
+ return pagesResult(searchPages(await context.listPages(), query, limit));
153
+ }
154
+ const path = args.path;
155
+ if (typeof path !== "string" || !path.trim() || path.length > 2048) {
156
+ return toolError('path must be a page path such as "/about".');
157
+ }
158
+ const pagePath = toPagePath(path, request.url, context.basePath);
159
+ const pages = await context.listPages();
160
+ const page = pagePath ? pages.find((candidate) => candidate.path === pagePath) : void 0;
161
+ if (!page) {
162
+ return toolError(
163
+ `No public page at ${JSON.stringify(path.slice(0, 200))}. Call list_pages for the pages this server can read.`
164
+ );
165
+ }
166
+ const markdown = await readWithTimeout(context.readMarkdown, page.markdownUrl);
167
+ if (markdown === null) {
168
+ return toolError(`${page.path} did not answer with Markdown. Try again later.`);
169
+ }
170
+ return { content: [{ type: "text", text: markdown }] };
171
+ }
172
+ _chunkS3JO3N4Hcjs.__name.call(void 0, callTool, "callTool");
173
+ function pagesResult(pages) {
174
+ const structured = {
175
+ pages: pages.map(({ path, title, url, description }) => ({
176
+ path,
177
+ title,
178
+ url,
179
+ ...description ? { description } : {}
180
+ }))
181
+ };
182
+ return {
183
+ content: [{ type: "text", text: JSON.stringify(structured) }],
184
+ structuredContent: structured
185
+ };
186
+ }
187
+ _chunkS3JO3N4Hcjs.__name.call(void 0, pagesResult, "pagesResult");
188
+ function toolError(text) {
189
+ return { content: [{ type: "text", text }], isError: true };
190
+ }
191
+ _chunkS3JO3N4Hcjs.__name.call(void 0, toolError, "toolError");
192
+ function searchPages(pages, query, limit) {
193
+ const terms = query.toLowerCase().split(/\s+/).filter(Boolean).slice(0, 16);
194
+ return pages.map((page) => {
195
+ const title = page.title.toLowerCase();
196
+ const rest = `${_nullishCoalesce(page.description, () => ( ""))} ${page.path}`.toLowerCase();
197
+ let score = 0;
198
+ for (const term of terms) {
199
+ if (title.includes(term)) score += 2;
200
+ else if (rest.includes(term)) score += 1;
201
+ else return null;
202
+ }
203
+ return { page, score };
204
+ }).filter((match) => match !== null).sort(
205
+ (left, right) => right.score - left.score || left.page.path.localeCompare(right.page.path)
206
+ ).slice(0, limit).map(({ page }) => page);
207
+ }
208
+ _chunkS3JO3N4Hcjs.__name.call(void 0, searchPages, "searchPages");
209
+ function toPagePath(input, requestUrl, basePath) {
210
+ let url;
211
+ try {
212
+ url = new URL(input.trim(), requestUrl);
213
+ } catch (e2) {
214
+ return null;
215
+ }
216
+ if (url.origin !== new URL(requestUrl).origin) return null;
217
+ let path = url.pathname;
218
+ try {
219
+ path = decodeURI(path);
220
+ } catch (e3) {
221
+ return null;
222
+ }
223
+ path = _chunkI57LW5VZcjs.stripFarmBasePath.call(void 0, path, basePath);
224
+ if (path === "/index.md") return "/";
225
+ if (path.toLowerCase().endsWith(".md")) path = path.slice(0, -3) || "/";
226
+ return path.length > 1 ? path.replace(/\/+$/, "") || "/" : path;
227
+ }
228
+ _chunkS3JO3N4Hcjs.__name.call(void 0, toPagePath, "toPagePath");
229
+ async function readWithTimeout(read, url) {
230
+ let timer;
231
+ const timedOut = new Promise((resolve) => {
232
+ timer = setTimeout(resolve, READ_TIMEOUT_MS, null);
233
+ });
234
+ try {
235
+ return await Promise.race([read(url), timedOut]);
236
+ } finally {
237
+ clearTimeout(timer);
238
+ }
239
+ }
240
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readWithTimeout, "readWithTimeout");
241
+ async function readBody(request) {
242
+ const declared = Number(request.headers.get("content-length"));
243
+ if (Number.isFinite(declared) && declared > MAX_BODY_BYTES) {
244
+ await _optionalChain([request, 'access', _ => _.body, 'optionalAccess', _2 => _2.cancel, 'call', _3 => _3(), 'access', _4 => _4.catch, 'call', _5 => _5(() => {
245
+ })]);
246
+ return null;
247
+ }
248
+ if (!request.body) return "";
249
+ const reader = request.body.getReader();
250
+ const chunks = [];
251
+ let size = 0;
252
+ for (; ; ) {
253
+ const { done, value } = await reader.read();
254
+ if (done) break;
255
+ size += value.byteLength;
256
+ if (size > MAX_BODY_BYTES) {
257
+ await reader.cancel().catch(() => {
258
+ });
259
+ return null;
260
+ }
261
+ chunks.push(value);
262
+ }
263
+ const body = new Uint8Array(size);
264
+ let offset = 0;
265
+ for (const chunk of chunks) {
266
+ body.set(chunk, offset);
267
+ offset += chunk.byteLength;
268
+ }
269
+ return new TextDecoder().decode(body);
270
+ }
271
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readBody, "readBody");
272
+ function isSameOrigin(origin, requestUrl) {
273
+ try {
274
+ return new URL(origin).host === new URL(requestUrl).host;
275
+ } catch (e4) {
276
+ return false;
277
+ }
278
+ }
279
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isSameOrigin, "isSameOrigin");
280
+ function readId(message) {
281
+ if (!isRecord(message)) return null;
282
+ const { id } = message;
283
+ return typeof id === "string" || typeof id === "number" && Number.isFinite(id) || id === null ? id : void 0;
284
+ }
285
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readId, "readId");
286
+ function rpcError(id, error) {
287
+ return { jsonrpc: "2.0", id: _nullishCoalesce(id, () => ( null)), error };
288
+ }
289
+ _chunkS3JO3N4Hcjs.__name.call(void 0, rpcError, "rpcError");
290
+ function json(status, body) {
291
+ return new Response(JSON.stringify(body), {
292
+ status,
293
+ headers: {
294
+ "Content-Type": "application/json; charset=utf-8",
295
+ "Cache-Control": "no-store",
296
+ "X-Content-Type-Options": "nosniff"
297
+ }
298
+ });
299
+ }
300
+ _chunkS3JO3N4Hcjs.__name.call(void 0, json, "json");
301
+ function transportError(status, message, headers = {}) {
302
+ const response = json(status, rpcError(null, { code: TRANSPORT_ERROR, message }));
303
+ for (const [name, value] of Object.entries(headers)) response.headers.set(name, value);
304
+ return response;
305
+ }
306
+ _chunkS3JO3N4Hcjs.__name.call(void 0, transportError, "transportError");
307
+ function isRecord(value) {
308
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
309
+ }
310
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isRecord, "isRecord");
311
+
312
+
313
+
314
+ exports.handleFarmDefaultMCPRequest = handleFarmDefaultMCPRequest;
@@ -4,13 +4,13 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkGFHLGIYCcjs = require('./chunk-GFHLGIYC.cjs');
7
+ var _chunkBO36SELVcjs = require('./chunk-BO36SELV.cjs');
8
8
 
9
9
 
10
10
  var _chunkSK35NQKKcjs = require('./chunk-SK35NQKK.cjs');
11
11
 
12
12
 
13
- var _chunkZXGAFZDOcjs = require('./chunk-ZXGAFZDO.cjs');
13
+ var _chunkT5OJPTVNcjs = require('./chunk-T5OJPTVN.cjs');
14
14
 
15
15
 
16
16
 
@@ -35,7 +35,7 @@ function createServerQuery(options) {
35
35
  throw new TypeError("createServerQuery requires a key function");
36
36
  }
37
37
  const staleTime = normalizeServerQueryStaleTime(options.staleTime);
38
- const execute = _chunkGFHLGIYCcjs.createServerFn.call(void 0, {
38
+ const execute = _chunkBO36SELVcjs.createServerFn.call(void 0, {
39
39
  input: options.input,
40
40
  middleware: options.middleware,
41
41
  handler: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (context) => {
@@ -45,7 +45,7 @@ function createServerQuery(options) {
45
45
  const cacheKey = _chunkNYJMY3JAcjs.createFarmCacheKey.call(void 0, ["route-data", routeKey]);
46
46
  const producer = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
47
47
  const value = await options.handler(context);
48
- return _chunkGFHLGIYCcjs._parseServerFnSchema.call(void 0, options.output, value, "output", "createServerQuery");
48
+ return _chunkBO36SELVcjs._parseServerFnSchema.call(void 0, options.output, value, "output", "createServerQuery");
49
49
  }, "producer");
50
50
  let data;
51
51
  let updatedAt;
@@ -70,7 +70,7 @@ function createServerQuery(options) {
70
70
  });
71
71
  const query = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (input) => {
72
72
  const result = await execute(input);
73
- return _chunkZXGAFZDOcjs.getServerActionExecutionContext.call(void 0, ) ? result : result.data;
73
+ return _chunkT5OJPTVNcjs.getServerActionExecutionContext.call(void 0, ) ? result : result.data;
74
74
  }, "query");
75
75
  Object.defineProperties(query, {
76
76
  [FARM_SERVER_QUERY_SYMBOL]: {
@@ -90,10 +90,10 @@ function createServerQuery(options) {
90
90
  enumerable: false
91
91
  }
92
92
  });
93
- _chunkGFHLGIYCcjs._attachServerFunctionDescriptor.call(void 0,
93
+ _chunkBO36SELVcjs._attachServerFunctionDescriptor.call(void 0,
94
94
  query,
95
- _chunkGFHLGIYCcjs.createServerFunctionDescriptor.call(void 0, "query", options, async (value) => {
96
- const result = await _chunkGFHLGIYCcjs._runServerFunctionForCaller.call(void 0,
95
+ _chunkBO36SELVcjs.createServerFunctionDescriptor.call(void 0, "query", options, async (value) => {
96
+ const result = await _chunkBO36SELVcjs._runServerFunctionForCaller.call(void 0,
97
97
  execute,
98
98
  value
99
99
  );