@farm.js/core 0.1.25 → 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 (181) hide show
  1. package/dist/agent-runtime.d.mts +8 -10
  2. package/dist/agent-runtime.d.ts +8 -10
  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 +7 -9
  9. package/dist/api/route-manager.d.ts +7 -9
  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 +9 -11
  19. package/dist/api.d.ts +9 -11
  20. package/dist/api.mjs +9 -8
  21. package/dist/{app-ZuWrAMc_.d.mts → app-BfzZdjgX.d.mts} +3 -4
  22. package/dist/{app-BF-ctoxh.d.ts → app-CXK7Prrt.d.ts} +3 -4
  23. package/dist/app-markdown.cjs +12 -4
  24. package/dist/app-markdown.d.mts +9 -11
  25. package/dist/app-markdown.d.ts +9 -11
  26. package/dist/app-markdown.mjs +11 -3
  27. package/dist/{chunk-2BIJGZR3.mjs → chunk-3PTVHMLD.mjs} +1 -1
  28. package/dist/{chunk-XME4TCLB.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-E3RDL2DA.cjs → chunk-DQMTHWPI.cjs} +61 -31
  32. package/dist/{chunk-TTVHACQV.cjs → chunk-FOT7LZEO.cjs} +1 -1
  33. package/dist/{chunk-2KI3CL3N.mjs → chunk-FPW4W3VW.mjs} +1 -1
  34. package/dist/{chunk-6K4SPQWL.cjs → chunk-HF5SIACK.cjs} +3 -3
  35. package/dist/{chunk-T2OPSH6S.mjs → chunk-HG237IEY.mjs} +12 -5
  36. package/dist/chunk-J63ZH5OQ.cjs +62 -0
  37. package/dist/{chunk-BD2U4ZL6.cjs → chunk-JQGDQO2I.cjs} +8 -8
  38. package/dist/{chunk-RR6UGYUT.mjs → chunk-JT25KHDI.mjs} +39 -9
  39. package/dist/{chunk-O5DVPF3R.cjs → chunk-KAERLFD3.cjs} +16 -11
  40. package/dist/{chunk-H7CJRJ4L.cjs → chunk-LAHZ7LZA.cjs} +16 -16
  41. package/dist/{chunk-XM4ZDVD7.mjs → chunk-MBFURXAC.mjs} +1 -1
  42. package/dist/{chunk-6VEHUKZ2.mjs → chunk-MM5D6VLP.mjs} +4 -20
  43. package/dist/chunk-MVL2RAJW.mjs +62 -0
  44. package/dist/{chunk-YA6LLTIJ.cjs → chunk-ND224OE2.cjs} +4 -20
  45. package/dist/{chunk-RYDW7GPR.cjs → chunk-NPFGGBM5.cjs} +13 -13
  46. package/dist/{chunk-VZWO3XVL.mjs → chunk-O2LV5XDG.mjs} +2 -2
  47. package/dist/chunk-O6XNAMBV.mjs +53 -0
  48. package/dist/{chunk-N2Z4ZFDE.mjs → chunk-OGHTEYXS.mjs} +22 -14
  49. package/dist/{chunk-U4MP7XTD.mjs → chunk-POXI72VV.mjs} +180 -16
  50. package/dist/{chunk-QGG336NI.mjs → chunk-Q4BHBO6V.mjs} +1 -1
  51. package/dist/{chunk-AXYTGLF3.cjs → chunk-QI7WQSMI.cjs} +4 -4
  52. package/dist/{chunk-WOI2HOGA.mjs → chunk-QQQNJS2E.mjs} +1 -1
  53. package/dist/{chunk-CFNOGDUS.cjs → chunk-TDWFCC2T.cjs} +2 -2
  54. package/dist/{chunk-R7LCG3BT.cjs → chunk-UNSKL6BI.cjs} +89 -81
  55. package/dist/{chunk-WJYCI56T.mjs → chunk-UWTQTZFN.mjs} +52 -33
  56. package/dist/{chunk-5YYJ6Q2L.mjs → chunk-WIVTGKLY.mjs} +7 -2
  57. package/dist/{chunk-65P6OGYN.cjs → chunk-WJKVTJJR.cjs} +12 -5
  58. package/dist/{chunk-OAVTUMJP.cjs → chunk-YXM74XOW.cjs} +9 -9
  59. package/dist/{chunk-QYMRIVG6.cjs → chunk-YZBV7733.cjs} +120 -101
  60. package/dist/{chunk-2ITKVAIF.cjs → chunk-ZSO5GWGD.cjs} +203 -39
  61. package/dist/{client-plugins-DPG0NeZN.d.mts → client-plugins-1GS4zubE.d.mts} +1940 -1677
  62. package/dist/{client-plugins-Fgni-_25.d.ts → client-plugins-B1Za6F5x.d.ts} +1940 -1677
  63. package/dist/client-plugins.d.mts +8 -10
  64. package/dist/client-plugins.d.ts +8 -10
  65. package/dist/client.cjs +4 -4
  66. package/dist/client.d.mts +10 -12
  67. package/dist/client.d.ts +10 -12
  68. package/dist/client.mjs +3 -3
  69. package/dist/config.d.mts +8 -10
  70. package/dist/config.d.ts +8 -10
  71. package/dist/{devtools-I7TBFOKD.mjs → devtools-6RN6KHTW.mjs} +8 -3
  72. package/dist/{devtools-6OA7FEF6.cjs → devtools-CQJ3H6MX.cjs} +9 -4
  73. package/dist/docs.cjs +11 -6
  74. package/dist/docs.mjs +10 -5
  75. package/dist/{endpoint-1zA994xL.d.ts → endpoint-CA-TNX60.d.ts} +1 -1
  76. package/dist/{endpoint-DAc96i93.d.mts → endpoint-CCHFqyTE.d.mts} +1 -1
  77. package/dist/index.cjs +26 -21
  78. package/dist/index.d.mts +16 -18
  79. package/dist/index.d.ts +16 -18
  80. package/dist/index.mjs +26 -21
  81. package/dist/{integration-api-BbaiokCC.d.ts → integration-api-0y4FXJpC.d.mts} +128 -1
  82. package/dist/{integration-api-BbaiokCC.d.mts → integration-api-BPJo5oXb.d.ts} +128 -1
  83. package/dist/integrations.d.mts +8 -10
  84. package/dist/integrations.d.ts +8 -10
  85. package/dist/internal/app-markdown-runtime.cjs +11 -3
  86. package/dist/internal/app-markdown-runtime.d.mts +9 -10
  87. package/dist/internal/app-markdown-runtime.d.ts +9 -10
  88. package/dist/internal/app-markdown-runtime.mjs +10 -2
  89. package/dist/internal/build-runtime.cjs +19 -17
  90. package/dist/internal/build-runtime.d.mts +10 -12
  91. package/dist/internal/build-runtime.d.ts +10 -12
  92. package/dist/internal/build-runtime.mjs +18 -16
  93. package/dist/internal/cli-runtime.cjs +9 -5
  94. package/dist/internal/cli-runtime.mjs +8 -4
  95. package/dist/internal/client-error-overlay.cjs +4 -4
  96. package/dist/internal/client-error-overlay.mjs +1 -1
  97. package/dist/internal/compression-runtime.d.mts +8 -10
  98. package/dist/internal/compression-runtime.d.ts +8 -10
  99. package/dist/internal/config-runtime.cjs +9 -4
  100. package/dist/internal/config-runtime.d.mts +9 -11
  101. package/dist/internal/config-runtime.d.ts +9 -11
  102. package/dist/internal/config-runtime.mjs +8 -3
  103. package/dist/internal/infra-analytics-runtime.cjs +4 -3
  104. package/dist/internal/infra-analytics-runtime.mjs +2 -1
  105. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  106. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  107. package/dist/internal/production-runtime.cjs +8 -5
  108. package/dist/internal/production-runtime.d.mts +16 -16
  109. package/dist/internal/production-runtime.d.ts +16 -16
  110. package/dist/internal/production-runtime.mjs +7 -4
  111. package/dist/markdown.cjs +10 -2
  112. package/dist/markdown.d.mts +35 -153
  113. package/dist/markdown.d.ts +35 -153
  114. package/dist/markdown.mjs +9 -1
  115. package/dist/{metadata-CDnRHKVq.d.ts → metadata-7LKgQEWF.d.ts} +1 -1
  116. package/dist/{metadata-D0EF7esB.d.mts → metadata-B9mCxKgp.d.mts} +1 -1
  117. package/dist/middleware.d.mts +9 -11
  118. package/dist/middleware.d.ts +9 -11
  119. package/dist/navigation.d.mts +10 -12
  120. package/dist/navigation.d.ts +10 -12
  121. package/dist/{nitro-ZKLGOTVY.mjs → nitro-NAKCRVHX.mjs} +4 -3
  122. package/dist/{nitro-KQDU7CFE.cjs → nitro-VYDZGYFY.cjs} +4 -3
  123. package/dist/observability-BupkiN0m.d.mts +447 -0
  124. package/dist/observability-BupkiN0m.d.ts +447 -0
  125. package/dist/observability.d.mts +2 -417
  126. package/dist/observability.d.ts +2 -417
  127. package/dist/plugin.cjs +14 -12
  128. package/dist/plugin.d.mts +9 -11
  129. package/dist/plugin.d.ts +9 -11
  130. package/dist/plugin.mjs +13 -11
  131. package/dist/{production-runtime-DpCt0opU.d.ts → production-runtime-B3xnY6fI.d.ts} +1 -1
  132. package/dist/{production-runtime-x3W4wVqx.d.mts → production-runtime-DramhI0c.d.mts} +1 -1
  133. package/dist/{render-plan-D5oFRVBV.d.ts → render-plan-CpW32tOL.d.ts} +1 -1
  134. package/dist/{render-plan-tazUJalK.d.mts → render-plan-CtQB-zHS.d.mts} +1 -1
  135. package/dist/renderer-client.d.mts +6 -8
  136. package/dist/renderer-client.d.ts +6 -8
  137. package/dist/{request-CzZX0Aew.d.ts → request-BVGGeQv4.d.ts} +1 -1
  138. package/dist/{request-CXmQy5ks.d.mts → request-DlLVBKe3.d.mts} +1 -1
  139. package/dist/request.d.mts +9 -11
  140. package/dist/request.d.ts +9 -11
  141. package/dist/{route-rendering-Dw3C362T.d.ts → route-rendering-BdEldajn.d.ts} +1 -1
  142. package/dist/{route-rendering-B-qpe32B.d.mts → route-rendering-DChYLNdh.d.mts} +1 -1
  143. package/dist/{router-CLl3xHwl.d.ts → router-D0Az-1Nu.d.ts} +1 -1
  144. package/dist/{router-CafM2jlw.d.mts → router-D5htHn_M.d.mts} +1 -1
  145. package/dist/routes.d.mts +6 -8
  146. package/dist/routes.d.ts +6 -8
  147. package/dist/server-fn-client.d.mts +3 -4
  148. package/dist/server-fn-client.d.ts +3 -4
  149. package/dist/server-fn.d.mts +1 -1
  150. package/dist/server-fn.d.ts +1 -1
  151. package/dist/server-plugins.d.mts +8 -10
  152. package/dist/server-plugins.d.ts +8 -10
  153. package/dist/server-query-client.d.mts +1 -1
  154. package/dist/server-query-client.d.ts +1 -1
  155. package/dist/server-query.d.mts +1 -1
  156. package/dist/server-query.d.ts +1 -1
  157. package/dist/server.cjs +292 -141
  158. package/dist/server.d.mts +13 -15
  159. package/dist/server.d.ts +13 -15
  160. package/dist/server.mjs +278 -127
  161. package/dist/{spa-router-6sJfsMlQ.d.mts → spa-router-DVfSJZ5o.d.mts} +2 -2
  162. package/dist/{spa-router-DePr2aZ6.d.ts → spa-router-DmwP_7QL.d.ts} +2 -2
  163. package/dist/testing.cjs +6 -5
  164. package/dist/testing.d.mts +7 -9
  165. package/dist/testing.d.ts +7 -9
  166. package/dist/testing.mjs +5 -4
  167. package/dist/{utils-BPHr-1mP.d.mts → utils-B_Rmr0-n.d.mts} +1 -1
  168. package/dist/{utils-BBKC3cf3.d.ts → utils-Dv0OuLtF.d.ts} +1 -1
  169. package/dist/version.cjs +2 -2
  170. package/dist/version.mjs +1 -1
  171. package/dist/vite.cjs +14 -12
  172. package/dist/vite.d.mts +8 -10
  173. package/dist/vite.d.ts +8 -10
  174. package/dist/vite.mjs +13 -11
  175. package/package.json +1 -1
  176. package/dist/route-B0XrsrFk.d.mts +0 -128
  177. package/dist/route-DOEpbyWZ.d.ts +0 -128
  178. package/dist/{chunk-GDUYXFIS.mjs → chunk-6EG7U4NF.mjs} +3 -3
  179. package/dist/{chunk-YAOX43YI.cjs → chunk-C7OUJ6JI.cjs} +2 -2
  180. package/dist/{chunk-IXTFU4PL.cjs → chunk-NL3ZSMZB.cjs} +2 -2
  181. package/dist/{chunk-L6V3P73N.mjs → chunk-UOXGA6TO.mjs} +4 -4
@@ -28,7 +28,7 @@ var _chunkPSV6XKPOcjs = require('./chunk-PSV6XKPO.cjs');
28
28
 
29
29
 
30
30
 
31
- var _chunkE3RDL2DAcjs = require('./chunk-E3RDL2DA.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 _chunk2ITKVAIFcjs = require('./chunk-2ITKVAIF.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: _chunkE3RDL2DAcjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.noindexPreviews])),
137
- llmsTxt: _chunkE3RDL2DAcjs.resolveFarmLlmsTxtConfig.call(void 0, _optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt])),
138
- crawlers: _chunkE3RDL2DAcjs.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 = _chunkE3RDL2DAcjs.resolveFarmSecurityConfig.call(void 0, userConfig.security);
684
- const securityHeader = _chunkE3RDL2DAcjs.getFarmSecurityHeader.call(void 0, security);
685
- if (_chunkE3RDL2DAcjs.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 = _chunk2ITKVAIFcjs.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: _chunkE3RDL2DAcjs.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-U4MP7XTD.mjs";
4
+ } from "./chunk-POXI72VV.mjs";
5
5
  import {
6
6
  __name
7
7
  } from "./chunk-LPEX4YW6.mjs";
@@ -1,3 +1,6 @@
1
+ import {
2
+ classifyFarmAgent
3
+ } from "./chunk-MVL2RAJW.mjs";
1
4
  import {
2
5
  onFarmEvent
3
6
  } from "./chunk-FUZEBRP3.mjs";
@@ -74,27 +77,8 @@ function resolveFarmInfraAnalytics(env = processEnv()) {
74
77
  };
75
78
  }
76
79
  __name(resolveFarmInfraAnalytics, "resolveFarmInfraAnalytics");
77
- var AGENT_TOKENS = [
78
- ["ChatGPT-User", "openai", "agent"],
79
- ["OAI-SearchBot", "openai", "crawler"],
80
- ["GPTBot", "openai", "crawler"],
81
- ["Claude-User", "anthropic", "agent"],
82
- ["Claude-SearchBot", "anthropic", "crawler"],
83
- ["ClaudeBot", "anthropic", "crawler"]
84
- ];
85
- var AGENT_PATTERNS = AGENT_TOKENS.map(([token, family, category]) => ({
86
- pattern: new RegExp(`(?:^|[\\s;(])${token}(?=[/\\s;)]|$)`, "i"),
87
- family,
88
- category
89
- }));
90
80
  function classifyFarmInfraAgent(userAgent) {
91
- const value = (userAgent ?? "").slice(0, 2048);
92
- const matches = AGENT_PATTERNS.filter(({ pattern }) => pattern.test(value));
93
- if (matches.length === 1) {
94
- const { family, category } = matches[0];
95
- return { family, category, identity: "self-reported" };
96
- }
97
- return { family: "unknown", category: "unknown", identity: "unknown" };
81
+ return classifyFarmAgent(userAgent);
98
82
  }
99
83
  __name(classifyFarmInfraAgent, "classifyFarmInfraAgent");
100
84
  function routeTemplate(pattern) {
@@ -0,0 +1,62 @@
1
+ import {
2
+ emitFarmEvent
3
+ } from "./chunk-FUZEBRP3.mjs";
4
+ import {
5
+ __name
6
+ } from "./chunk-LPEX4YW6.mjs";
7
+
8
+ // src/agent-identity.ts
9
+ var AGENT_TOKENS = [
10
+ ["ChatGPT-User", "openai", "agent"],
11
+ ["OAI-SearchBot", "openai", "crawler"],
12
+ ["GPTBot", "openai", "crawler"],
13
+ ["Claude-User", "anthropic", "agent"],
14
+ ["Claude-SearchBot", "anthropic", "crawler"],
15
+ ["ClaudeBot", "anthropic", "crawler"],
16
+ ["Perplexity-User", "perplexity", "agent"],
17
+ ["PerplexityBot", "perplexity", "crawler"],
18
+ ["CCBot", "other", "crawler"],
19
+ ["Bytespider", "other", "crawler"],
20
+ ["Meta-ExternalAgent", "other", "crawler"]
21
+ ];
22
+ var AGENT_PATTERNS = AGENT_TOKENS.map(([token, family, category]) => ({
23
+ pattern: new RegExp(`(?:^|[\\s;(])${token}(?=[/\\s;)]|$)`, "i"),
24
+ family,
25
+ category
26
+ }));
27
+ var UNKNOWN = { family: "unknown", category: "unknown", identity: "unknown" };
28
+ function classifyFarmAgent(userAgent) {
29
+ const value = (userAgent ?? "").slice(0, 2048);
30
+ const matches = AGENT_PATTERNS.filter(({ pattern }) => pattern.test(value));
31
+ if (matches.length === 1) {
32
+ const { family, category } = matches[0];
33
+ return { family, category, identity: "self-reported" };
34
+ }
35
+ return { ...UNKNOWN };
36
+ }
37
+ __name(classifyFarmAgent, "classifyFarmAgent");
38
+ var FARM_INTERNAL_READ_HEADER = "x-farm-internal-read";
39
+ function emitFarmAgentRead(request, surface, status, view) {
40
+ if (request.headers.has(FARM_INTERNAL_READ_HEADER)) return;
41
+ let route;
42
+ try {
43
+ route = new URL(request.url).pathname;
44
+ } catch {
45
+ return;
46
+ }
47
+ emitFarmEvent({
48
+ type: "agent.read",
49
+ surface,
50
+ route,
51
+ ...view ? { view } : {},
52
+ status,
53
+ agent: classifyFarmAgent(request.headers.get("user-agent"))
54
+ });
55
+ }
56
+ __name(emitFarmAgentRead, "emitFarmAgentRead");
57
+
58
+ export {
59
+ classifyFarmAgent,
60
+ FARM_INTERNAL_READ_HEADER,
61
+ emitFarmAgentRead
62
+ };
@@ -1,5 +1,8 @@
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 _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
4
+
5
+
3
6
  var _chunkE3UK5IIBcjs = require('./chunk-E3UK5IIB.cjs');
4
7
 
5
8
 
@@ -74,27 +77,8 @@ function resolveFarmInfraAnalytics(env = processEnv()) {
74
77
  };
75
78
  }
76
79
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmInfraAnalytics, "resolveFarmInfraAnalytics");
77
- var AGENT_TOKENS = [
78
- ["ChatGPT-User", "openai", "agent"],
79
- ["OAI-SearchBot", "openai", "crawler"],
80
- ["GPTBot", "openai", "crawler"],
81
- ["Claude-User", "anthropic", "agent"],
82
- ["Claude-SearchBot", "anthropic", "crawler"],
83
- ["ClaudeBot", "anthropic", "crawler"]
84
- ];
85
- var AGENT_PATTERNS = AGENT_TOKENS.map(([token, family, category]) => ({
86
- pattern: new RegExp(`(?:^|[\\s;(])${token}(?=[/\\s;)]|$)`, "i"),
87
- family,
88
- category
89
- }));
90
80
  function classifyFarmInfraAgent(userAgent) {
91
- const value = (_nullishCoalesce(userAgent, () => ( ""))).slice(0, 2048);
92
- const matches = AGENT_PATTERNS.filter(({ pattern }) => pattern.test(value));
93
- if (matches.length === 1) {
94
- const { family, category } = matches[0];
95
- return { family, category, identity: "self-reported" };
96
- }
97
- return { family: "unknown", category: "unknown", identity: "unknown" };
81
+ return _chunkJ63ZH5OQcjs.classifyFarmAgent.call(void 0, userAgent);
98
82
  }
99
83
  _chunkS3JO3N4Hcjs.__name.call(void 0, classifyFarmInfraAgent, "classifyFarmInfraAgent");
100
84
  function routeTemplate(pattern) {
@@ -3,14 +3,14 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkAXYTGLF3cjs = require('./chunk-AXYTGLF3.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 _chunkO5DVPF3Rcjs = require('./chunk-O5DVPF3R.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: _chunkAXYTGLF3cjs.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 _chunkAXYTGLF3cjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs).map((page) => _chunkAXYTGLF3cjs.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
- ..._chunkAXYTGLF3cjs.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
- ..._chunkAXYTGLF3cjs.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 _chunkAXYTGLF3cjs.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 = _chunkAXYTGLF3cjs.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 = _chunkAXYTGLF3cjs.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 _chunkO5DVPF3Rcjs.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: _chunkAXYTGLF3cjs.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 = _chunkAXYTGLF3cjs.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(_chunkAXYTGLF3cjs.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
+ };