@farm.js/core 0.1.26 → 0.1.27

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 (171) hide show
  1. package/dist/agent-runtime.d.mts +7 -9
  2. package/dist/agent-runtime.d.ts +7 -9
  3. package/dist/api/client.cjs +3 -3
  4. package/dist/api/client.d.mts +4 -5
  5. package/dist/api/client.d.ts +4 -5
  6. package/dist/api/client.mjs +2 -2
  7. package/dist/api/route-manager.cjs +6 -5
  8. package/dist/api/route-manager.d.mts +6 -8
  9. package/dist/api/route-manager.d.ts +6 -8
  10. package/dist/api/route-manager.mjs +5 -4
  11. package/dist/api/runtime.cjs +10 -4
  12. package/dist/api/runtime.d.mts +35 -3
  13. package/dist/api/runtime.d.ts +35 -3
  14. package/dist/api/runtime.mjs +9 -3
  15. package/dist/{api-client-Cx54IR5g.d.mts → api-client-BjMmY8OD.d.mts} +2 -3
  16. package/dist/{api-client-DykpaKcY.d.ts → api-client-CyFtZFJ4.d.ts} +2 -3
  17. package/dist/api.cjs +9 -8
  18. package/dist/api.d.mts +8 -10
  19. package/dist/api.d.ts +8 -10
  20. package/dist/api.mjs +9 -8
  21. package/dist/{app-29vG5tmY.d.mts → app-BfzZdjgX.d.mts} +3 -4
  22. package/dist/{app-Cx71s_PT.d.ts → app-CXK7Prrt.d.ts} +3 -4
  23. package/dist/app-markdown.cjs +10 -4
  24. package/dist/app-markdown.d.mts +8 -10
  25. package/dist/app-markdown.d.ts +8 -10
  26. package/dist/app-markdown.mjs +9 -3
  27. package/dist/{chunk-74RZNRY6.mjs → chunk-3PTVHMLD.mjs} +1 -1
  28. package/dist/{chunk-OFKG57MZ.mjs → chunk-4FHDV7VM.mjs} +2 -2
  29. package/dist/{chunk-KLSSO6YD.mjs → chunk-4UNKCNSL.mjs} +1 -1
  30. package/dist/chunk-5MKEDGLD.cjs +53 -0
  31. package/dist/{chunk-2CT6XUNO.cjs → chunk-DQMTHWPI.cjs} +4 -4
  32. package/dist/{chunk-ALIFMS4A.cjs → chunk-FOT7LZEO.cjs} +1 -1
  33. package/dist/{chunk-DU2CASV6.mjs → chunk-FPW4W3VW.mjs} +1 -1
  34. package/dist/{chunk-RCYINC4A.cjs → chunk-HF5SIACK.cjs} +3 -3
  35. package/dist/{chunk-ARXCHQLX.mjs → chunk-HG237IEY.mjs} +4 -4
  36. package/dist/{chunk-BD2U4ZL6.cjs → chunk-JQGDQO2I.cjs} +8 -8
  37. package/dist/{chunk-RAI7NULA.mjs → chunk-JT25KHDI.mjs} +1 -1
  38. package/dist/{chunk-WFPRVVF2.cjs → chunk-KAERLFD3.cjs} +16 -11
  39. package/dist/{chunk-H7CJRJ4L.cjs → chunk-LAHZ7LZA.cjs} +16 -16
  40. package/dist/{chunk-JM5GQL4H.mjs → chunk-MBFURXAC.mjs} +1 -1
  41. package/dist/{chunk-QLXEYIAW.cjs → chunk-NPFGGBM5.cjs} +13 -13
  42. package/dist/{chunk-VZWO3XVL.mjs → chunk-O2LV5XDG.mjs} +2 -2
  43. package/dist/chunk-O6XNAMBV.mjs +53 -0
  44. package/dist/{chunk-UXQXGB5A.mjs → chunk-OGHTEYXS.mjs} +11 -10
  45. package/dist/{chunk-OOIL3BWR.mjs → chunk-POXI72VV.mjs} +12 -0
  46. package/dist/{chunk-QGG336NI.mjs → chunk-Q4BHBO6V.mjs} +1 -1
  47. package/dist/{chunk-3WSWXPYM.cjs → chunk-QI7WQSMI.cjs} +4 -4
  48. package/dist/{chunk-PPIW3MH6.mjs → chunk-QQQNJS2E.mjs} +1 -1
  49. package/dist/{chunk-W2HZKYES.cjs → chunk-TDWFCC2T.cjs} +2 -2
  50. package/dist/{chunk-3TQG7CGC.cjs → chunk-UNSKL6BI.cjs} +78 -77
  51. package/dist/{chunk-QPPQHB6X.mjs → chunk-UWTQTZFN.mjs} +17 -11
  52. package/dist/{chunk-YMUH2BLR.mjs → chunk-WIVTGKLY.mjs} +7 -2
  53. package/dist/{chunk-QJ4D3UKJ.cjs → chunk-WJKVTJJR.cjs} +4 -4
  54. package/dist/{chunk-OAVTUMJP.cjs → chunk-YXM74XOW.cjs} +9 -9
  55. package/dist/{chunk-SZ4LYNUX.cjs → chunk-YZBV7733.cjs} +82 -76
  56. package/dist/{chunk-QIH2HD6H.cjs → chunk-ZSO5GWGD.cjs} +33 -21
  57. package/dist/{client-plugins-B8RPJnot.d.mts → client-plugins-1GS4zubE.d.mts} +1799 -1623
  58. package/dist/{client-plugins-bPBf4haK.d.ts → client-plugins-B1Za6F5x.d.ts} +1799 -1623
  59. package/dist/client-plugins.d.mts +7 -9
  60. package/dist/client-plugins.d.ts +7 -9
  61. package/dist/client.cjs +4 -4
  62. package/dist/client.d.mts +9 -11
  63. package/dist/client.d.ts +9 -11
  64. package/dist/client.mjs +3 -3
  65. package/dist/config.d.mts +7 -9
  66. package/dist/config.d.ts +7 -9
  67. package/dist/{devtools-5D4ZDRPR.mjs → devtools-6RN6KHTW.mjs} +6 -3
  68. package/dist/{devtools-QZJEUOJW.cjs → devtools-CQJ3H6MX.cjs} +7 -4
  69. package/dist/docs.cjs +9 -6
  70. package/dist/docs.mjs +8 -5
  71. package/dist/{endpoint-1zA994xL.d.ts → endpoint-CA-TNX60.d.ts} +1 -1
  72. package/dist/{endpoint-DAc96i93.d.mts → endpoint-CCHFqyTE.d.mts} +1 -1
  73. package/dist/index.cjs +21 -20
  74. package/dist/index.d.mts +15 -17
  75. package/dist/index.d.ts +15 -17
  76. package/dist/index.mjs +21 -20
  77. package/dist/{integration-api-BbaiokCC.d.ts → integration-api-0y4FXJpC.d.mts} +128 -1
  78. package/dist/{integration-api-BbaiokCC.d.mts → integration-api-BPJo5oXb.d.ts} +128 -1
  79. package/dist/integrations.d.mts +7 -9
  80. package/dist/integrations.d.ts +7 -9
  81. package/dist/internal/app-markdown-runtime.cjs +9 -3
  82. package/dist/internal/app-markdown-runtime.d.mts +8 -9
  83. package/dist/internal/app-markdown-runtime.d.ts +8 -9
  84. package/dist/internal/app-markdown-runtime.mjs +8 -2
  85. package/dist/internal/build-runtime.cjs +17 -16
  86. package/dist/internal/build-runtime.d.mts +9 -11
  87. package/dist/internal/build-runtime.d.ts +9 -11
  88. package/dist/internal/build-runtime.mjs +16 -15
  89. package/dist/internal/cli-runtime.cjs +8 -5
  90. package/dist/internal/cli-runtime.mjs +7 -4
  91. package/dist/internal/client-error-overlay.cjs +4 -4
  92. package/dist/internal/client-error-overlay.mjs +1 -1
  93. package/dist/internal/compression-runtime.d.mts +7 -9
  94. package/dist/internal/compression-runtime.d.ts +7 -9
  95. package/dist/internal/config-runtime.cjs +7 -4
  96. package/dist/internal/config-runtime.d.mts +8 -10
  97. package/dist/internal/config-runtime.d.ts +8 -10
  98. package/dist/internal/config-runtime.mjs +6 -3
  99. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  100. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  101. package/dist/internal/production-runtime.cjs +7 -5
  102. package/dist/internal/production-runtime.d.mts +12 -14
  103. package/dist/internal/production-runtime.d.ts +12 -14
  104. package/dist/internal/production-runtime.mjs +6 -4
  105. package/dist/markdown.cjs +8 -2
  106. package/dist/markdown.d.mts +35 -153
  107. package/dist/markdown.d.ts +35 -153
  108. package/dist/markdown.mjs +7 -1
  109. package/dist/{metadata-CzBP4Mfp.d.ts → metadata-7LKgQEWF.d.ts} +1 -1
  110. package/dist/{metadata-C3na4CBj.d.mts → metadata-B9mCxKgp.d.mts} +1 -1
  111. package/dist/middleware.d.mts +8 -10
  112. package/dist/middleware.d.ts +8 -10
  113. package/dist/navigation.d.mts +9 -11
  114. package/dist/navigation.d.ts +9 -11
  115. package/dist/{nitro-ZKLGOTVY.mjs → nitro-NAKCRVHX.mjs} +4 -3
  116. package/dist/{nitro-KQDU7CFE.cjs → nitro-VYDZGYFY.cjs} +4 -3
  117. package/dist/plugin.cjs +13 -12
  118. package/dist/plugin.d.mts +8 -10
  119. package/dist/plugin.d.ts +8 -10
  120. package/dist/plugin.mjs +12 -11
  121. package/dist/{production-runtime-CYg4wM4E.d.ts → production-runtime-B3xnY6fI.d.ts} +1 -1
  122. package/dist/{production-runtime-DP94hPGe.d.mts → production-runtime-DramhI0c.d.mts} +1 -1
  123. package/dist/{render-plan-Bl6Fzg5z.d.ts → render-plan-CpW32tOL.d.ts} +1 -1
  124. package/dist/{render-plan-CKAJg0jC.d.mts → render-plan-CtQB-zHS.d.mts} +1 -1
  125. package/dist/renderer-client.d.mts +5 -7
  126. package/dist/renderer-client.d.ts +5 -7
  127. package/dist/{request-CR-Bp1Px.d.ts → request-BVGGeQv4.d.ts} +1 -1
  128. package/dist/{request-CrBCcPZZ.d.mts → request-DlLVBKe3.d.mts} +1 -1
  129. package/dist/request.d.mts +8 -10
  130. package/dist/request.d.ts +8 -10
  131. package/dist/{route-rendering-CZH5FegB.d.ts → route-rendering-BdEldajn.d.ts} +1 -1
  132. package/dist/{route-rendering-C1NAHo-C.d.mts → route-rendering-DChYLNdh.d.mts} +1 -1
  133. package/dist/{router-Cg_kD3Bd.d.ts → router-D0Az-1Nu.d.ts} +1 -1
  134. package/dist/{router-B57eDJ3u.d.mts → router-D5htHn_M.d.mts} +1 -1
  135. package/dist/routes.d.mts +5 -7
  136. package/dist/routes.d.ts +5 -7
  137. package/dist/server-fn-client.d.mts +3 -4
  138. package/dist/server-fn-client.d.ts +3 -4
  139. package/dist/server-fn.d.mts +1 -1
  140. package/dist/server-fn.d.ts +1 -1
  141. package/dist/server-plugins.d.mts +7 -9
  142. package/dist/server-plugins.d.ts +7 -9
  143. package/dist/server-query-client.d.mts +1 -1
  144. package/dist/server-query-client.d.ts +1 -1
  145. package/dist/server-query.d.mts +1 -1
  146. package/dist/server-query.d.ts +1 -1
  147. package/dist/server.cjs +198 -104
  148. package/dist/server.d.mts +12 -14
  149. package/dist/server.d.ts +12 -14
  150. package/dist/server.mjs +184 -90
  151. package/dist/{spa-router-DTdbuinx.d.mts → spa-router-DVfSJZ5o.d.mts} +2 -2
  152. package/dist/{spa-router-BstQUO6Q.d.ts → spa-router-DmwP_7QL.d.ts} +2 -2
  153. package/dist/testing.cjs +6 -5
  154. package/dist/testing.d.mts +6 -8
  155. package/dist/testing.d.ts +6 -8
  156. package/dist/testing.mjs +5 -4
  157. package/dist/{utils-CS3ZLnEJ.d.mts → utils-B_Rmr0-n.d.mts} +1 -1
  158. package/dist/{utils-D3rdsIvM.d.ts → utils-Dv0OuLtF.d.ts} +1 -1
  159. package/dist/version.cjs +2 -2
  160. package/dist/version.mjs +1 -1
  161. package/dist/vite.cjs +13 -12
  162. package/dist/vite.d.mts +7 -9
  163. package/dist/vite.d.ts +7 -9
  164. package/dist/vite.mjs +12 -11
  165. package/package.json +1 -1
  166. package/dist/route-B0XrsrFk.d.mts +0 -128
  167. package/dist/route-DOEpbyWZ.d.ts +0 -128
  168. package/dist/{chunk-GDUYXFIS.mjs → chunk-6EG7U4NF.mjs} +3 -3
  169. package/dist/{chunk-YAOX43YI.cjs → chunk-C7OUJ6JI.cjs} +2 -2
  170. package/dist/{chunk-IXTFU4PL.cjs → chunk-NL3ZSMZB.cjs} +2 -2
  171. package/dist/{chunk-L6V3P73N.mjs → chunk-UOXGA6TO.mjs} +4 -4
@@ -17,7 +17,7 @@ var _chunkLYLEZIG3cjs = require('./chunk-LYLEZIG3.cjs');
17
17
 
18
18
 
19
19
 
20
- var _chunkYAOX43YIcjs = require('./chunk-YAOX43YI.cjs');
20
+ var _chunkC7OUJ6JIcjs = require('./chunk-C7OUJ6JI.cjs');
21
21
 
22
22
 
23
23
  var _chunkWMAPPDMMcjs = require('./chunk-WMAPPDMM.cjs');
@@ -93,7 +93,7 @@ var _APIRouteManager = class _APIRouteManager {
93
93
  await this.loadProgrammaticApiRoutes(appDir);
94
94
  }
95
95
  this.routes = new Map(
96
- _chunkYAOX43YIcjs.mergePluginAPIRoutes.call(void 0, [...this.routes.values()], this.plugins, void 0, {
96
+ _chunkC7OUJ6JIcjs.mergePluginAPIRoutes.call(void 0, [...this.routes.values()], this.plugins, void 0, {
97
97
  bodySizeLimit: this.bodySizeLimit
98
98
  }).map((route) => [route.path, route])
99
99
  );
@@ -140,7 +140,7 @@ var _APIRouteManager = class _APIRouteManager {
140
140
  const routeModule = await this.loadModule(filePath);
141
141
  const endpoints = {};
142
142
  const availableMethods = [];
143
- for (const method of _chunkYAOX43YIcjs.API_ROUTE_METHODS) {
143
+ for (const method of _chunkC7OUJ6JIcjs.API_ROUTE_METHODS) {
144
144
  if (routeModule[method]) {
145
145
  endpoints[method] = routeModule[method];
146
146
  availableMethods.push(method);
@@ -322,7 +322,7 @@ var _APIRouteManager = class _APIRouteManager {
322
322
  const url = new URL(request.url);
323
323
  const pathname = url.pathname;
324
324
  const method = request.method.toUpperCase();
325
- const match = _chunkYAOX43YIcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
325
+ const match = _chunkC7OUJ6JIcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
326
326
  if (!match) {
327
327
  return new Response(JSON.stringify({ error: "Not Found" }), {
328
328
  status: 404,
@@ -330,19 +330,19 @@ var _APIRouteManager = class _APIRouteManager {
330
330
  });
331
331
  }
332
332
  const { route, params } = match;
333
- const endpoint = _chunkYAOX43YIcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
333
+ const endpoint = _chunkC7OUJ6JIcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
334
334
  if (!endpoint) {
335
335
  return new Response(JSON.stringify({ error: "Method Not Allowed" }), {
336
336
  status: 405,
337
337
  headers: {
338
- Allow: _chunkYAOX43YIcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
338
+ Allow: _chunkC7OUJ6JIcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
339
339
  "Content-Type": "application/json"
340
340
  }
341
341
  });
342
342
  }
343
343
  const invoke = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
344
344
  try {
345
- return await _chunkYAOX43YIcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, this.bodySizeLimit);
345
+ return await _chunkC7OUJ6JIcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, this.bodySizeLimit);
346
346
  } catch (error) {
347
347
  if (options.throwOnError) throw error;
348
348
  console.error(`[API Error] ${pathname}:`, error);
@@ -364,7 +364,7 @@ var _APIRouteManager = class _APIRouteManager {
364
364
  return Boolean(this.matchRoute(pathname));
365
365
  }
366
366
  matchRoute(pathname) {
367
- return _chunkYAOX43YIcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
367
+ return _chunkC7OUJ6JIcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
368
368
  }
369
369
  /**
370
370
  * Get all routes for client type generation
@@ -2,7 +2,7 @@ import {
2
2
  getFarmMarkdownMirrorPath,
3
3
  isFarmMarkdownMirrorExposed,
4
4
  matchesFarmMarkdownRoutePattern
5
- } from "./chunk-OOIL3BWR.mjs";
5
+ } from "./chunk-POXI72VV.mjs";
6
6
  import {
7
7
  FARM_INTERNAL_READ_HEADER
8
8
  } from "./chunk-MVL2RAJW.mjs";
@@ -28,7 +28,7 @@ var _chunkPSV6XKPOcjs = require('./chunk-PSV6XKPO.cjs');
28
28
 
29
29
 
30
30
 
31
- var _chunk2CT6XUNOcjs = require('./chunk-2CT6XUNO.cjs');
31
+ var _chunkDQMTHWPIcjs = require('./chunk-DQMTHWPI.cjs');
32
32
 
33
33
 
34
34
  var _chunkYFPGHF5Fcjs = require('./chunk-YFPGHF5F.cjs');
@@ -47,7 +47,7 @@ var _chunkVEKFLAQMcjs = require('./chunk-VEKFLAQM.cjs');
47
47
  var _chunkOHY2ZWUGcjs = require('./chunk-OHY2ZWUG.cjs');
48
48
 
49
49
 
50
- var _chunkQIH2HD6Hcjs = require('./chunk-QIH2HD6H.cjs');
50
+ var _chunkZSO5GWGDcjs = require('./chunk-ZSO5GWGD.cjs');
51
51
 
52
52
 
53
53
  var _chunkUYIHRDE4cjs = require('./chunk-UYIHRDE4.cjs');
@@ -133,9 +133,9 @@ function resolveFarmAgentConfig(input) {
133
133
  const jsonLd = _optionalChain([input, 'optionalAccess', _ => _.jsonLd]);
134
134
  return {
135
135
  jsonLd: !jsonLd ? false : jsonLd === true ? {} : jsonLd,
136
- noindexPreviews: _chunk2CT6XUNOcjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.noindexPreviews])),
137
- llmsTxt: _chunk2CT6XUNOcjs.resolveFarmLlmsTxtConfig.call(void 0, _optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt])),
138
- crawlers: _chunk2CT6XUNOcjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([input, 'optionalAccess', _4 => _4.crawlers])),
136
+ noindexPreviews: _chunkDQMTHWPIcjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.noindexPreviews])),
137
+ llmsTxt: _chunkDQMTHWPIcjs.resolveFarmLlmsTxtConfig.call(void 0, _optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt])),
138
+ crawlers: _chunkDQMTHWPIcjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([input, 'optionalAccess', _4 => _4.crawlers])),
139
139
  apiCatalog: resolveFarmApiCatalogEnabled(_optionalChain([input, 'optionalAccess', _5 => _5.apiCatalog]))
140
140
  };
141
141
  }
@@ -288,6 +288,10 @@ function hasCustomFarmRouteContext(config) {
288
288
  return config[FARM_RESOLVED_CUSTOM_CONTEXT] === true;
289
289
  }
290
290
  _chunkS3JO3N4Hcjs.__name.call(void 0, hasCustomFarmRouteContext, "hasCustomFarmRouteContext");
291
+ function isResolvedFarmConfig(config) {
292
+ return Object.prototype.hasOwnProperty.call(config, FARM_RESOLVED_CUSTOM_CONTEXT);
293
+ }
294
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isResolvedFarmConfig, "isResolvedFarmConfig");
291
295
  function normalizeDeployTarget(target) {
292
296
  if (!target) return void 0;
293
297
  if (target === "cloudflare-pages" || target === "cloudflare_pages") return "cloudflare";
@@ -680,9 +684,9 @@ async function resolveConfig(userConfig, mode) {
680
684
  const routeRules = _chunkQ5B3KJBPcjs.normalizeRouteRules.call(void 0, userConfig.routeRules);
681
685
  const routeRuleRedirects = _chunkQ5B3KJBPcjs.routeRulesToRedirects.call(void 0, routeRules);
682
686
  const routeRuleHeaders = _chunkQ5B3KJBPcjs.routeRulesToHeaders.call(void 0, routeRules);
683
- const security = _chunk2CT6XUNOcjs.resolveFarmSecurityConfig.call(void 0, userConfig.security);
684
- const securityHeader = _chunk2CT6XUNOcjs.getFarmSecurityHeader.call(void 0, security);
685
- if (_chunk2CT6XUNOcjs.farmCspBlocksFrameworkInlineScripts.call(void 0, security)) {
687
+ const security = _chunkDQMTHWPIcjs.resolveFarmSecurityConfig.call(void 0, userConfig.security);
688
+ const securityHeader = _chunkDQMTHWPIcjs.getFarmSecurityHeader.call(void 0, security);
689
+ if (_chunkDQMTHWPIcjs.farmCspBlocksFrameworkInlineScripts.call(void 0, security)) {
686
690
  _chunk5QIKR7RRcjs.logger.warn(
687
691
  "security.csp blocks the inline scripts Farm injects for theming and hydration. Set security.csp.nonce to true for managed dynamic nonces and prerendered hashes, or make the governing script directive allow 'unsafe-inline' without a nonce, hash, or 'strict-dynamic' source."
688
692
  );
@@ -691,7 +695,7 @@ async function resolveConfig(userConfig, mode) {
691
695
  const root = userConfig.root || process.cwd();
692
696
  const srcDir = userConfig.srcDir || "src";
693
697
  const docs = await resolveDocsConfig(userConfig.docs, { root, srcDir });
694
- const md = _chunkQIH2HD6Hcjs.resolveMarkdownConfig.call(void 0, userConfig.md);
698
+ const md = _chunkZSO5GWGDcjs.resolveMarkdownConfig.call(void 0, userConfig.md);
695
699
  const mdx = _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, userConfig.mdx);
696
700
  const env = _chunkVEKFLAQMcjs.resolveEnv.call(void 0, userConfig.env, process.env);
697
701
  _chunkVEKFLAQMcjs.setEnv.call(void 0, env);
@@ -782,7 +786,7 @@ async function resolveConfig(userConfig, mode) {
782
786
  ], "headers"),
783
787
  routeRules,
784
788
  images: _chunkYFPGHF5Fcjs.resolveFarmImageConfig.call(void 0, userConfig.images),
785
- performance: _chunk2CT6XUNOcjs.resolveFarmPerformanceConfig.call(void 0, userConfig.performance),
789
+ performance: _chunkDQMTHWPIcjs.resolveFarmPerformanceConfig.call(void 0, userConfig.performance),
786
790
  theme: _chunkOI6CMLWXcjs.resolveFarmThemeConfig.call(void 0, userConfig.theme, basePath),
787
791
  publicDir: userConfig.publicDir || "public",
788
792
  i18n: _chunkHBTUGXHScjs.resolveFarmI18nConfig.call(void 0, userConfig.i18n, { root, mode, basePath }),
@@ -886,4 +890,5 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, loadConfig, "loadConfig");
886
890
 
887
891
 
888
892
 
889
- exports.hasCustomFarmRouteContext = hasCustomFarmRouteContext; exports.normalizeDeployTarget = normalizeDeployTarget; exports.getPresetForDeployTarget = getPresetForDeployTarget; exports.getDeployTargetForPreset = getDeployTargetForPreset; exports.getDefaultDeployOutputDir = getDefaultDeployOutputDir; exports.resolveDeployOutputPath = resolveDeployOutputPath; exports.resolveDeployConfig = resolveDeployConfig; exports.resolveMigrationsConfig = resolveMigrationsConfig; exports.resolveDocsConfig = resolveDocsConfig; exports.resolveConfig = resolveConfig; exports.loadConfig = loadConfig;
893
+
894
+ exports.hasCustomFarmRouteContext = hasCustomFarmRouteContext; exports.isResolvedFarmConfig = isResolvedFarmConfig; exports.normalizeDeployTarget = normalizeDeployTarget; exports.getPresetForDeployTarget = getPresetForDeployTarget; exports.getDeployTargetForPreset = getDeployTargetForPreset; exports.getDefaultDeployOutputDir = getDefaultDeployOutputDir; exports.resolveDeployOutputPath = resolveDeployOutputPath; exports.resolveDeployConfig = resolveDeployConfig; exports.resolveMigrationsConfig = resolveMigrationsConfig; exports.resolveDocsConfig = resolveDocsConfig; exports.resolveConfig = resolveConfig; exports.loadConfig = loadConfig;
@@ -6,7 +6,7 @@ var _chunk4PPEPOZZcjs = require('./chunk-4PPEPOZZ.cjs');
6
6
  var _chunkMQ3H6LT5cjs = require('./chunk-MQ3H6LT5.cjs');
7
7
 
8
8
 
9
- var _chunkBD2U4ZL6cjs = require('./chunk-BD2U4ZL6.cjs');
9
+ var _chunkJQGDQO2Icjs = require('./chunk-JQGDQO2I.cjs');
10
10
 
11
11
 
12
12
  var _chunkN4RLRSWWcjs = require('./chunk-N4RLRSWW.cjs');
@@ -19,7 +19,7 @@ var _chunk2CQ74SP6cjs = require('./chunk-2CQ74SP6.cjs');
19
19
 
20
20
 
21
21
 
22
- var _chunkYAOX43YIcjs = require('./chunk-YAOX43YI.cjs');
22
+ var _chunkC7OUJ6JIcjs = require('./chunk-C7OUJ6JI.cjs');
23
23
 
24
24
 
25
25
  var _chunk6V4TDWECcjs = require('./chunk-6V4TDWEC.cjs');
@@ -105,7 +105,7 @@ function farmApiPlugin(options = {}) {
105
105
  const existing = apiRoutesCache.get(routePath);
106
106
  const existingFile = _optionalChain([endpointSources, 'access', _ => _.get, 'call', _2 => _2(routePath), 'optionalAccess', _3 => _3.get, 'call', _4 => _4(normalizedMethod)]);
107
107
  if (existingFile) {
108
- throw new (0, _chunkBD2U4ZL6cjs.APIRouteConflictError)(routePath, normalizedMethod, existingFile, filePath);
108
+ throw new (0, _chunkJQGDQO2Icjs.APIRouteConflictError)(routePath, normalizedMethod, existingFile, filePath);
109
109
  }
110
110
  if (existing) {
111
111
  if (!existing.methods.includes(normalizedMethod)) {
@@ -189,7 +189,7 @@ function farmApiPlugin(options = {}) {
189
189
  const url = new URL(request.url);
190
190
  const method = request.method.toUpperCase();
191
191
  const pathname = url.pathname;
192
- const match = _chunkYAOX43YIcjs.matchAPIRouteAtBasePath.call(void 0, apiRoutesCache, pathname, basePath);
192
+ const match = _chunkC7OUJ6JIcjs.matchAPIRouteAtBasePath.call(void 0, apiRoutesCache, pathname, basePath);
193
193
  if (!match) {
194
194
  return new Response(JSON.stringify({ error: "Not Found" }), {
195
195
  status: 404,
@@ -197,18 +197,18 @@ function farmApiPlugin(options = {}) {
197
197
  });
198
198
  }
199
199
  const { route, params } = match;
200
- const endpoint = _chunkYAOX43YIcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
200
+ const endpoint = _chunkC7OUJ6JIcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
201
201
  if (!endpoint) {
202
202
  return new Response(JSON.stringify({ error: "Method Not Allowed" }), {
203
203
  status: 405,
204
204
  headers: {
205
- Allow: _chunkYAOX43YIcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
205
+ Allow: _chunkC7OUJ6JIcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
206
206
  "Content-Type": "application/json"
207
207
  }
208
208
  });
209
209
  }
210
210
  try {
211
- return await _chunkYAOX43YIcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, bodySizeLimit);
211
+ return await _chunkC7OUJ6JIcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, bodySizeLimit);
212
212
  } catch (error) {
213
213
  return new Response(JSON.stringify({ error: error.message || "Internal Server Error" }), {
214
214
  status: 500,
@@ -255,7 +255,7 @@ function farmApiPlugin(options = {}) {
255
255
  const routeModule = await _chunkBMWDEBXOcjs.loadFarmDevModule.call(void 0, server, filePath);
256
256
  const endpoints = {};
257
257
  const availableMethods = [];
258
- for (const method of _chunkYAOX43YIcjs.API_ROUTE_METHODS) {
258
+ for (const method of _chunkC7OUJ6JIcjs.API_ROUTE_METHODS) {
259
259
  if (routeModule[method]) {
260
260
  availableMethods.push(method);
261
261
  endpoints[method] = routeModule[method];
@@ -268,7 +268,7 @@ function farmApiPlugin(options = {}) {
268
268
  log(`API route discovered: ${availableMethods.join(", ")} ${routePath}`);
269
269
  }
270
270
  } catch (e) {
271
- if (e instanceof _chunkBD2U4ZL6cjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
271
+ if (e instanceof _chunkJQGDQO2Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
272
272
  log(`API route load failed at ${filePath}: ${e.message}`);
273
273
  }
274
274
  }
@@ -295,7 +295,7 @@ function farmApiPlugin(options = {}) {
295
295
  }
296
296
  }
297
297
  } catch (e) {
298
- if (e instanceof _chunkBD2U4ZL6cjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
298
+ if (e instanceof _chunkJQGDQO2Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
299
299
  log(`Root routes.ts load failed: ${e.message}`);
300
300
  }
301
301
  break;
@@ -326,7 +326,7 @@ function farmApiPlugin(options = {}) {
326
326
  }
327
327
  }
328
328
  } catch (e) {
329
- if (e instanceof _chunkBD2U4ZL6cjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
329
+ if (e instanceof _chunkJQGDQO2Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
330
330
  log(`Programmatic routes file load failed at ${routeFile}: ${e.message}`);
331
331
  }
332
332
  }
@@ -378,7 +378,7 @@ function farmApiPlugin(options = {}) {
378
378
  const pathname = url.split("?")[0];
379
379
  const method = req.method || "GET";
380
380
  if (discoveryPromise) await waitForDiscovery();
381
- if (!_chunkYAOX43YIcjs.matchAPIRouteAtBasePath.call(void 0, apiRoutesCache, pathname, basePath)) {
381
+ if (!_chunkC7OUJ6JIcjs.matchAPIRouteAtBasePath.call(void 0, apiRoutesCache, pathname, basePath)) {
382
382
  return next();
383
383
  }
384
384
  if (!apiRouterHandler) {
@@ -399,7 +399,7 @@ function farmApiPlugin(options = {}) {
399
399
  }
400
400
  const currentUrl = req.url || url;
401
401
  const currentPathname = currentUrl.split("?")[0];
402
- if (currentPathname !== pathname && !_chunkYAOX43YIcjs.matchAPIRouteAtBasePath.call(void 0, apiRoutesCache, currentPathname, basePath)) {
402
+ if (currentPathname !== pathname && !_chunkC7OUJ6JIcjs.matchAPIRouteAtBasePath.call(void 0, apiRoutesCache, currentPathname, basePath)) {
403
403
  return next();
404
404
  }
405
405
  const fullUrl = _chunk5ZSWG4UXcjs.resolveFarmRequestURL.call(void 0, req);
@@ -503,7 +503,7 @@ function farmApiPlugin(options = {}) {
503
503
  log(`API router recreated`);
504
504
  } catch (e) {
505
505
  restoreRouteState(previousState);
506
- if (e instanceof _chunkBD2U4ZL6cjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
506
+ if (e instanceof _chunkJQGDQO2Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
507
507
  log(`Root routes.ts HMR failed: ${e.message}`);
508
508
  }
509
509
  return [];
@@ -531,7 +531,7 @@ function farmApiPlugin(options = {}) {
531
531
  const routeModule = await _chunkBMWDEBXOcjs.loadFarmDevModule.call(void 0, server, file);
532
532
  removeEndpointsFromFile(file);
533
533
  const availableMethods = [];
534
- for (const method of _chunkYAOX43YIcjs.API_ROUTE_METHODS) {
534
+ for (const method of _chunkC7OUJ6JIcjs.API_ROUTE_METHODS) {
535
535
  if (!routeModule[method]) continue;
536
536
  availableMethods.push(method);
537
537
  addEndpoint(routePath, file, method, routeModule[method]);
@@ -541,7 +541,7 @@ function farmApiPlugin(options = {}) {
541
541
  log(`API router recreated`);
542
542
  } catch (e) {
543
543
  restoreRouteState(previousState);
544
- if (e instanceof _chunkBD2U4ZL6cjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
544
+ if (e instanceof _chunkJQGDQO2Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
545
545
  log(`API route HMR failed: ${e.message}`);
546
546
  }
547
547
  return [];
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createFarmMarkdownViewResponse,
3
3
  requestAcceptsMarkdown
4
- } from "./chunk-OOIL3BWR.mjs";
4
+ } from "./chunk-POXI72VV.mjs";
5
5
  import {
6
6
  __name
7
7
  } from "./chunk-LPEX4YW6.mjs";
@@ -3,14 +3,14 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk3WSWXPYMcjs = require('./chunk-3WSWXPYM.cjs');
6
+ var _chunkQI7WQSMIcjs = require('./chunk-QI7WQSMI.cjs');
7
7
 
8
8
 
9
9
 
10
10
  var _chunkIK6LVLKCcjs = require('./chunk-IK6LVLKC.cjs');
11
11
 
12
12
 
13
- var _chunkWFPRVVF2cjs = require('./chunk-WFPRVVF2.cjs');
13
+ var _chunkKAERLFD3cjs = require('./chunk-KAERLFD3.cjs');
14
14
 
15
15
 
16
16
  var _chunk75WGQVQAcjs = require('./chunk-75WGQVQA.cjs');
@@ -39,7 +39,7 @@ function createFarmDocsAdapterRuntimeConfig(docs, options, moduleConfig) {
39
39
  ...moduleConfig ? { ...moduleConfig, ...docs.configOverrides } : _nullishCoalesce(docs.runtimeConfig, () => ( docs.config)),
40
40
  entry: docs.config.entry || docs.entry.replace(/^\/+|\/+$/g, "") || "docs",
41
41
  docsPath: docs.entry,
42
- contentDir: _chunk3WSWXPYMcjs.resolveFarmDocsContentDir.call(void 0, docs, options)
42
+ contentDir: _chunkQI7WQSMIcjs.resolveFarmDocsContentDir.call(void 0, docs, options)
43
43
  };
44
44
  }
45
45
  _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmDocsAdapterRuntimeConfig, "createFarmDocsAdapterRuntimeConfig");
@@ -274,25 +274,25 @@ function getDocsDescription(docs) {
274
274
  }
275
275
  _chunkS3JO3N4Hcjs.__name.call(void 0, getDocsDescription, "getDocsDescription");
276
276
  function getLoadedDocsPages(context) {
277
- return _chunk3WSWXPYMcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs).map((page) => _chunk3WSWXPYMcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, page.slug)).filter((page) => Boolean(page));
277
+ return _chunkQI7WQSMIcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs).map((page) => _chunkQI7WQSMIcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, page.slug)).filter((page) => Boolean(page));
278
278
  }
279
279
  _chunkS3JO3N4Hcjs.__name.call(void 0, getLoadedDocsPages, "getLoadedDocsPages");
280
280
  function toDocsSourcePage(page) {
281
281
  return {
282
- ..._chunk3WSWXPYMcjs.toFarmDocsMarkdownPage.call(void 0, page),
282
+ ..._chunkQI7WQSMIcjs.toFarmDocsMarkdownPage.call(void 0, page),
283
283
  sourcePath: page.sourcePath
284
284
  };
285
285
  }
286
286
  _chunkS3JO3N4Hcjs.__name.call(void 0, toDocsSourcePage, "toDocsSourcePage");
287
287
  function toDocsSitemapPage(page) {
288
288
  return {
289
- ..._chunk3WSWXPYMcjs.toFarmDocsMarkdownPage.call(void 0, page),
289
+ ..._chunkQI7WQSMIcjs.toFarmDocsMarkdownPage.call(void 0, page),
290
290
  sourcePath: page.sourcePath
291
291
  };
292
292
  }
293
293
  _chunkS3JO3N4Hcjs.__name.call(void 0, toDocsSitemapPage, "toDocsSitemapPage");
294
294
  function toDocsLlmsPage(page) {
295
- return _chunk3WSWXPYMcjs.toFarmDocsMarkdownPage.call(void 0, page);
295
+ return _chunkQI7WQSMIcjs.toFarmDocsMarkdownPage.call(void 0, page);
296
296
  }
297
297
  _chunkS3JO3N4Hcjs.__name.call(void 0, toDocsLlmsPage, "toDocsLlmsPage");
298
298
  function getDocsLlmsOptions(context, request) {
@@ -386,7 +386,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, renderAgentsDocument, "renderAgentsDocumen
386
386
  function buildAgentSpec(context, request) {
387
387
  const url = new URL(request.url);
388
388
  const origin = url.origin;
389
- const pages = _chunk3WSWXPYMcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
389
+ const pages = _chunkQI7WQSMIcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
390
390
  const spec = _chunkIK6LVLKCcjs.docsEngine.call(void 0, ).buildDocsAgentDiscoverySpec(getDocsDiscoveryOptions(context, request));
391
391
  const title = getDocsTitle(context.docs);
392
392
  return {
@@ -428,7 +428,7 @@ function buildAgentSpec(context, request) {
428
428
  }
429
429
  _chunkS3JO3N4Hcjs.__name.call(void 0, buildAgentSpec, "buildAgentSpec");
430
430
  function buildDiagnostics(context) {
431
- const pages = _chunk3WSWXPYMcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
431
+ const pages = _chunkQI7WQSMIcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
432
432
  const diagnostics = _chunkIK6LVLKCcjs.docsEngine.call(void 0, ).buildDocsDiagnostics(context.docs.config, {
433
433
  entry: context.docs.entry,
434
434
  mcp: {
@@ -500,12 +500,12 @@ async function resolveAPIContext(options) {
500
500
  config: options.config,
501
501
  configPath: options.configPath
502
502
  }));
503
- const docs = isResolvedDocsConfig(docsInput) ? docsInput : await _chunkWFPRVVF2cjs.resolveDocsConfig.call(void 0, docsInput, { root, srcDir });
503
+ const docs = isResolvedDocsConfig(docsInput) ? docsInput : await _chunkKAERLFD3cjs.resolveDocsConfig.call(void 0, docsInput, { root, srcDir });
504
504
  return {
505
505
  root,
506
506
  srcDir,
507
507
  docs,
508
- contentDir: _chunk3WSWXPYMcjs.resolveFarmDocsContentDir.call(void 0, docs, { root, srcDir })
508
+ contentDir: _chunkQI7WQSMIcjs.resolveFarmDocsContentDir.call(void 0, docs, { root, srcDir })
509
509
  };
510
510
  }
511
511
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveAPIContext, "resolveAPIContext");
@@ -568,10 +568,10 @@ async function handleDocsAPIGet(request, context) {
568
568
  if (format === "markdown" || url.pathname.endsWith(".md")) {
569
569
  const pathParam = url.searchParams.get("path") || url.searchParams.get("slug");
570
570
  const slug = normalizeDocsApiSlug(_nullishCoalesce(_nullishCoalesce(pathParam, () => ( pathTarget.slug)), () => ( "")), context.docs);
571
- const page = _chunk3WSWXPYMcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, slug);
571
+ const page = _chunkQI7WQSMIcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, slug);
572
572
  if (!page) return text("Docs page not found\n", "text/plain; charset=utf-8", { status: 404 });
573
573
  return text(
574
- _chunkIK6LVLKCcjs.docsEngine.call(void 0, ).renderDocsMarkdownDocument(_chunk3WSWXPYMcjs.toFarmDocsMarkdownPage.call(void 0, page), {
574
+ _chunkIK6LVLKCcjs.docsEngine.call(void 0, ).renderDocsMarkdownDocument(_chunkQI7WQSMIcjs.toFarmDocsMarkdownPage.call(void 0, page), {
575
575
  origin: new URL(request.url).origin,
576
576
  llms: getDocsLlmsOptions(context, request),
577
577
  sitemap: context.docs.config.sitemap
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-IOEH4VWN.mjs";
7
7
  import {
8
8
  APIRouteConflictError
9
- } from "./chunk-QGG336NI.mjs";
9
+ } from "./chunk-Q4BHBO6V.mjs";
10
10
  import {
11
11
  findProgrammaticRouteFilesInDir
12
12
  } from "./chunk-YOYF2E4U.mjs";
@@ -19,7 +19,7 @@ import {
19
19
  invokeAPIRouteEndpoint,
20
20
  matchAPIRouteAtBasePath,
21
21
  resolveAPIRouteEndpoint
22
- } from "./chunk-GDUYXFIS.mjs";
22
+ } from "./chunk-6EG7U4NF.mjs";
23
23
  import {
24
24
  isProgrammaticRoutesFileName
25
25
  } from "./chunk-EA5K5BKU.mjs";
@@ -0,0 +1,53 @@
1
+ import {
2
+ resolveFarmAPICanonicalPathname,
3
+ resolveFarmAPIServerRoutePath
4
+ } from "./chunk-I6XDAKWQ.mjs";
5
+ import {
6
+ matchAPIRoute
7
+ } from "./chunk-O7BH5O46.mjs";
8
+ import {
9
+ __name
10
+ } from "./chunk-LPEX4YW6.mjs";
11
+
12
+ // src/mcp-catalog.ts
13
+ var CATALOGS = /* @__PURE__ */ Symbol.for("farm.mcp.catalogs");
14
+ function catalogs() {
15
+ const state = globalThis;
16
+ return state[CATALOGS] ?? (state[CATALOGS] = /* @__PURE__ */ new Map());
17
+ }
18
+ __name(catalogs, "catalogs");
19
+ function _publishFarmMCPCatalog(server, tools) {
20
+ const entry = { server, tools };
21
+ catalogs().set(server.path, entry);
22
+ return () => {
23
+ if (catalogs().get(server.path) === entry) catalogs().delete(server.path);
24
+ };
25
+ }
26
+ __name(_publishFarmMCPCatalog, "_publishFarmMCPCatalog");
27
+ function _findFarmMCPEndpointTool(method, pathname, serverBasePath) {
28
+ const upperMethod = method.toUpperCase();
29
+ for (const { server, tools } of catalogs().values()) {
30
+ const routes = /* @__PURE__ */ new Map();
31
+ for (const tool of tools) {
32
+ if (tool.kind === "endpoint" && tool.method === upperMethod) {
33
+ routes.set(tool.path, { path: tool.path, name: tool.name });
34
+ }
35
+ }
36
+ if (routes.size === 0) continue;
37
+ const canonical = serverBasePath ? resolveFarmAPICanonicalPathname(pathname, serverBasePath) : pathname;
38
+ const match = matchAPIRoute(routes, canonical);
39
+ if (match) {
40
+ return {
41
+ name: match.route.name,
42
+ endpoint: resolveFarmAPIServerRoutePath(server.path, serverBasePath)
43
+ };
44
+ }
45
+ }
46
+ return void 0;
47
+ }
48
+ __name(_findFarmMCPEndpointTool, "_findFarmMCPEndpointTool");
49
+
50
+ export {
51
+ _publishFarmMCPCatalog,
52
+ _findFarmMCPEndpointTool
53
+ };
@@ -27,7 +27,7 @@ import {
27
27
  renderFarmLocaleAlternateLinks,
28
28
  resolveDefaultErrorStatus,
29
29
  resolveFarmApiCatalogInput
30
- } from "./chunk-ARXCHQLX.mjs";
30
+ } from "./chunk-HG237IEY.mjs";
31
31
  import {
32
32
  isFarmPreviewDeploymentEnvironment
33
33
  } from "./chunk-BOYNDCZL.mjs";
@@ -107,7 +107,7 @@ import {
107
107
  resolveFarmLlmsTxtConfig,
108
108
  resolveFarmPerformanceConfig,
109
109
  resolveFarmSecurityConfig
110
- } from "./chunk-RAI7NULA.mjs";
110
+ } from "./chunk-JT25KHDI.mjs";
111
111
  import {
112
112
  getPublicFarmImageConfig,
113
113
  resolveFarmImageConfig
@@ -125,12 +125,12 @@ import {
125
125
  import {
126
126
  createFarmMarkdownRouteModuleFromFile,
127
127
  loadFarmMdxComponents
128
- } from "./chunk-74RZNRY6.mjs";
128
+ } from "./chunk-3PTVHMLD.mjs";
129
129
  import {
130
130
  createFarmMarkdownSourceResponse,
131
131
  isFarmMarkdownPageFile,
132
132
  normalizeFarmMarkdownRoutePath
133
- } from "./chunk-JM5GQL4H.mjs";
133
+ } from "./chunk-MBFURXAC.mjs";
134
134
  import {
135
135
  resolveFarmMdxComponentsModulePath,
136
136
  resolveMdxConfig
@@ -144,7 +144,7 @@ import {
144
144
  getFarmMarkdownMirrorPath,
145
145
  resolveMarkdownConfig,
146
146
  resolveMarkdownMirrorTarget
147
- } from "./chunk-OOIL3BWR.mjs";
147
+ } from "./chunk-POXI72VV.mjs";
148
148
  import {
149
149
  resolveWorkflowsConfig
150
150
  } from "./chunk-3ATMYLLJ.mjs";
@@ -185,7 +185,7 @@ import {
185
185
  } from "./chunk-IOEH4VWN.mjs";
186
186
  import {
187
187
  APIRouteManager
188
- } from "./chunk-QGG336NI.mjs";
188
+ } from "./chunk-Q4BHBO6V.mjs";
189
189
  import {
190
190
  findProgrammaticRouteFiles,
191
191
  loadProgrammaticRouteManifests
@@ -204,7 +204,7 @@ import {
204
204
  } from "./chunk-YOZYCI6Z.mjs";
205
205
  import {
206
206
  isFarmAPIPathname
207
- } from "./chunk-GDUYXFIS.mjs";
207
+ } from "./chunk-6EG7U4NF.mjs";
208
208
  import {
209
209
  resolveFarmAPIServerBasePath
210
210
  } from "./chunk-I6XDAKWQ.mjs";
@@ -274,7 +274,7 @@ import {
274
274
  } from "./chunk-Z2RZJZIZ.mjs";
275
275
  import {
276
276
  FARM_VERSION
277
- } from "./chunk-PPIW3MH6.mjs";
277
+ } from "./chunk-QQQNJS2E.mjs";
278
278
  import {
279
279
  resolveFarmTrailingSlashRedirect,
280
280
  setFarmTrailingSlashPreference
@@ -9518,7 +9518,7 @@ function loadFarmWorkflowsDevRuntime() {
9518
9518
  }
9519
9519
  __name(loadFarmWorkflowsDevRuntime, "loadFarmWorkflowsDevRuntime");
9520
9520
  function loadFarmDevtoolsSnapshotRuntime() {
9521
- return import("./devtools-5D4ZDRPR.mjs");
9521
+ return import("./devtools-6RN6KHTW.mjs");
9522
9522
  }
9523
9523
  __name(loadFarmDevtoolsSnapshotRuntime, "loadFarmDevtoolsSnapshotRuntime");
9524
9524
  function loadFarmDevtoolsUIRuntime() {
@@ -10886,7 +10886,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
10886
10886
  routeExists: /* @__PURE__ */ __name((pathname2) => Boolean(farmApp.getRouteManager().matchRoute(pathname2).route), "routeExists"),
10887
10887
  // Keep the page's own redirect (a sign-in gate, say) so the mirror
10888
10888
  // answers with it, as production does, instead of the target page.
10889
- renderPage: /* @__PURE__ */ __name(async (request2) => fetch(request2, { redirect: "manual" }), "renderPage")
10889
+ renderPage: /* @__PURE__ */ __name(async (request2) => fetch(request2, { redirect: "manual" }), "renderPage"),
10890
+ apiServerBasePath
10890
10891
  });
10891
10892
  if (markdownResponse) {
10892
10893
  if (await runAppMiddlewareForContentRoute()) return;
@@ -1,6 +1,12 @@
1
1
  import {
2
2
  emitFarmAgentRead
3
3
  } from "./chunk-MVL2RAJW.mjs";
4
+ import {
5
+ _findFarmMCPEndpointTool
6
+ } from "./chunk-O6XNAMBV.mjs";
7
+ import {
8
+ stripFarmBasePath
9
+ } from "./chunk-4RB44K6Z.mjs";
4
10
  import {
5
11
  __name
6
12
  } from "./chunk-LPEX4YW6.mjs";
@@ -392,6 +398,12 @@ async function createMarkdownMirrorResponse(options) {
392
398
  const html = await pageResponse.text();
393
399
  const markdownPath = target.pathname === "/" ? "/index.md" : `${target.pathname}.md`;
394
400
  const actions = extractFarmPageActions(html, pageUrl);
401
+ for (const form of actions) {
402
+ if (!form.action?.startsWith("/")) continue;
403
+ const pathname = new URL(form.action, pageUrl.origin).pathname;
404
+ const tool = _findFarmMCPEndpointTool(form.method, pathname, options.apiServerBasePath) ?? _findFarmMCPEndpointTool(form.method, stripFarmBasePath(pathname), options.apiServerBasePath);
405
+ if (tool) form.tool = tool;
406
+ }
395
407
  const markdown = htmlToMarkdown(html, {
396
408
  title: target.route?.title,
397
409
  includeMetadata: options.config?.includeMetadata ?? true,
@@ -17,7 +17,7 @@ import {
17
17
  matchAPIRouteAtBasePath,
18
18
  mergePluginAPIRoutes,
19
19
  resolveAPIRouteEndpoint
20
- } from "./chunk-GDUYXFIS.mjs";
20
+ } from "./chunk-6EG7U4NF.mjs";
21
21
  import {
22
22
  registerAPIRouteShape
23
23
  } from "./chunk-W3B4PKAW.mjs";
@@ -15,7 +15,7 @@ var _chunkIK6LVLKCcjs = require('./chunk-IK6LVLKC.cjs');
15
15
  var _chunkHREOKQWTcjs = require('./chunk-HREOKQWT.cjs');
16
16
 
17
17
 
18
- var _chunkQIH2HD6Hcjs = require('./chunk-QIH2HD6H.cjs');
18
+ var _chunkZSO5GWGDcjs = require('./chunk-ZSO5GWGD.cjs');
19
19
 
20
20
 
21
21
  var _chunkEM6SBQKMcjs = require('./chunk-EM6SBQKM.cjs');
@@ -1181,11 +1181,11 @@ function shouldReturnMarkdown(request) {
1181
1181
  if (url.pathname.endsWith(".md")) return true;
1182
1182
  const accept = request.headers.get("accept");
1183
1183
  const markdown = Math.max(
1184
- _chunkQIH2HD6Hcjs.farmAcceptQuality.call(void 0, accept, "text/markdown"),
1185
- _chunkQIH2HD6Hcjs.farmAcceptQuality.call(void 0, accept, "text/plain")
1184
+ _chunkZSO5GWGDcjs.farmAcceptQuality.call(void 0, accept, "text/markdown"),
1185
+ _chunkZSO5GWGDcjs.farmAcceptQuality.call(void 0, accept, "text/plain")
1186
1186
  );
1187
1187
  if (markdown <= 0) return false;
1188
- return markdown >= _chunkQIH2HD6Hcjs.farmAcceptQuality.call(void 0, accept, "text/html", { wildcards: true });
1188
+ return markdown >= _chunkZSO5GWGDcjs.farmAcceptQuality.call(void 0, accept, "text/html", { wildcards: true });
1189
1189
  }
1190
1190
  _chunkS3JO3N4Hcjs.__name.call(void 0, shouldReturnMarkdown, "shouldReturnMarkdown");
1191
1191
  function escapeAttribute(value) {
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.1.26";
2
+ var version = "0.1.27";
3
3
 
4
4
  // src/version.ts
5
5
  var FARM_VERSION = version;
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkRCYINC4Acjs = require('./chunk-RCYINC4A.cjs');
3
+ var _chunkHF5SIACKcjs = require('./chunk-HF5SIACK.cjs');
4
4
 
5
5
 
6
6
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -11,7 +11,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
11
11
  var _url = require('url');
12
12
  async function createFarmMarkdownRouteModuleFromFile(filePath, options = {}) {
13
13
  const source = await _promises.readFile.call(void 0, filePath, "utf8");
14
- return _chunkRCYINC4Acjs.createFarmMarkdownRouteModule.call(void 0, {
14
+ return _chunkHF5SIACKcjs.createFarmMarkdownRouteModule.call(void 0, {
15
15
  source,
16
16
  filePath,
17
17
  components: options.components,