@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
@@ -34,6 +34,33 @@ async function loadFarmDevModule(server, id, environmentName = "ssr") {
34
34
  }
35
35
  }
36
36
  __name(loadFarmDevModule, "loadFarmDevModule");
37
+ function invalidateFarmDevDependents(server, file, targets, environmentName = "ssr") {
38
+ const environment = server.environments[environmentName];
39
+ const graph = environment?.moduleGraph;
40
+ if (!graph || targets.size === 0) return [];
41
+ const posix = /* @__PURE__ */ __name((filePath) => filePath.replace(/\\/g, "/"), "posix");
42
+ const byFile = new Map([...targets].map((target) => [posix(target), target]));
43
+ const reached = /* @__PURE__ */ new Set();
44
+ const seen = /* @__PURE__ */ new Set();
45
+ const queue = [...graph.getModulesByFile(posix(file)) ?? []];
46
+ while (queue.length > 0) {
47
+ const node = queue.pop();
48
+ if (seen.has(node)) continue;
49
+ seen.add(node);
50
+ const target = node.file ? byFile.get(posix(node.file)) : void 0;
51
+ if (target) reached.add(target);
52
+ queue.push(...node.importers);
53
+ }
54
+ if (reached.size === 0) return [];
55
+ const evaluatedModules = environment.runner?.evaluatedModules;
56
+ for (const node of seen) {
57
+ graph.invalidateModule(node);
58
+ const evaluated = node.id ? evaluatedModules?.getModuleById(node.id) : void 0;
59
+ if (evaluated) evaluatedModules.invalidateModule(evaluated);
60
+ }
61
+ return [...reached];
62
+ }
63
+ __name(invalidateFarmDevDependents, "invalidateFarmDevDependents");
37
64
  function invalidateFailedFarmDevModules(server) {
38
65
  for (const entry of Object.values(server.environments)) {
39
66
  const environment = entry;
@@ -62,6 +89,7 @@ __name(toFileModuleUrl, "toFileModuleUrl");
62
89
  export {
63
90
  FarmDevEnvironmentError,
64
91
  loadFarmDevModule,
92
+ invalidateFarmDevDependents,
65
93
  invalidateFailedFarmDevModules,
66
94
  toFileModuleUrl
67
95
  };
@@ -1,9 +1,12 @@
1
+ import {
2
+ FARM_DEFAULT_MCP_TOOLS
3
+ } from "./chunk-UH6QN5NL.mjs";
1
4
  import {
2
5
  DEFAULT_ERROR_STYLES
3
6
  } from "./chunk-XAXTTBUT.mjs";
4
7
  import {
5
8
  serializeFarmLlmsTxt
6
- } from "./chunk-UJD4PHYB.mjs";
9
+ } from "./chunk-DTSROJ5J.mjs";
7
10
  import {
8
11
  emitFarmAgentRead
9
12
  } from "./chunk-MVL2RAJW.mjs";
@@ -18,15 +21,16 @@ import {
18
21
  _listFarmRegisteredMCPServers
19
22
  } from "./chunk-ZLAT2CWY.mjs";
20
23
  import {
24
+ createFarmWeakETag,
21
25
  matchesFarmIfNoneMatch
22
- } from "./chunk-Y7RKTKYI.mjs";
26
+ } from "./chunk-ZMMBIVQM.mjs";
23
27
  import {
24
28
  resolveFarmAPIServerBasePath,
25
29
  resolveFarmAPIServerRoutePath
26
30
  } from "./chunk-BTHHUD7Q.mjs";
27
31
  import {
28
32
  FARM_VERSION
29
- } from "./chunk-3PXS2MHU.mjs";
33
+ } from "./chunk-OO7GXVSR.mjs";
30
34
  import {
31
35
  localizeFarmPathname
32
36
  } from "./chunk-L3KT7IXV.mjs";
@@ -153,7 +157,7 @@ function ensureFarmDocumentHead(markup) {
153
157
  }
154
158
  __name(ensureFarmDocumentHead, "ensureFarmDocumentHead");
155
159
  function ensureFarmDocumentRoot(markup) {
156
- if (/\sid=["']root["']/i.test(markup)) return markup;
160
+ if (/<body\b[^>]*>\s*<div\b[^>]*\sid=["']root["']/i.test(markup)) return markup;
157
161
  return markup.replace(
158
162
  /<body\b([^>]*)>/i,
159
163
  (_match, attributes) => `<body${attributes}><div id="root">`
@@ -436,6 +440,13 @@ function listFarmMCPServerSources(input) {
436
440
  if (sources.has(endpoint)) continue;
437
441
  sources.set(endpoint, { ...server, endpoint, local: Boolean(server.path) });
438
442
  }
443
+ if (sources.size === 0 && input.defaultMCP) {
444
+ const server = input.defaultMCP();
445
+ if (server) {
446
+ const endpoint = applyFarmBasePath(server.path, input.basePath);
447
+ sources.set(endpoint, { ...server, endpoint, local: true });
448
+ }
449
+ }
439
450
  return [...sources.values()];
440
451
  }
441
452
  __name(listFarmMCPServerSources, "listFarmMCPServerSources");
@@ -526,7 +537,7 @@ function createFarmAiCatalogResponse(request, input = {}, requestUrl) {
526
537
  const body = JSON.stringify(
527
538
  card ? card.card : { specVersion: "1.0", entries: servers.map(({ entry }) => entry) }
528
539
  );
529
- const etag = `W/"${fnv1a(body)}"`;
540
+ const etag = createFarmWeakETag(body);
530
541
  const headers = {
531
542
  ...corsHeaders(),
532
543
  "Content-Type": card ? `${SERVER_CARD_TYPE}; charset=utf-8` : ard ? "application/json; charset=utf-8" : `${AI_CATALOG_TYPE}; charset=utf-8`,
@@ -565,15 +576,6 @@ function truncate(text) {
565
576
  return text.length <= CARD_DESCRIPTION_MAX ? text : `${text.slice(0, CARD_DESCRIPTION_MAX - 1).trimEnd()}\u2026`;
566
577
  }
567
578
  __name(truncate, "truncate");
568
- function fnv1a(value) {
569
- let hash = 2166136261;
570
- for (let index = 0; index < value.length; index++) {
571
- hash ^= value.charCodeAt(index);
572
- hash = Math.imul(hash, 16777619);
573
- }
574
- return (hash >>> 0).toString(16).padStart(8, "0");
575
- }
576
- __name(fnv1a, "fnv1a");
577
579
 
578
580
  // src/components/error-page.ts
579
581
  var ERROR_STATUS_TEXT = {
@@ -868,7 +870,12 @@ function createFarmApiCatalogResponse(method, input, request) {
868
870
  __name(createFarmApiCatalogResponse, "createFarmApiCatalogResponse");
869
871
 
870
872
  // src/app-manifest.ts
871
- var FARM_APP_MANIFEST_PATH = "/.well-known/farmjs";
873
+ var FARM_APP_MANIFEST_PATH = "/.well-known/farmjs.json";
874
+ var FARM_APP_MANIFEST_LEGACY_PATH = "/.well-known/farmjs";
875
+ function isFarmAppManifestPath(pathname) {
876
+ return pathname === FARM_APP_MANIFEST_PATH || pathname === FARM_APP_MANIFEST_LEGACY_PATH;
877
+ }
878
+ __name(isFarmAppManifestPath, "isFarmAppManifestPath");
872
879
  var FARM_INFRA_SIGNATURE_HEADER = "farmjs-infra-signature";
873
880
  var SIGNED_PURPOSE = "farmjs-manifest-v1";
874
881
  var SIGNATURE_WINDOW_SECONDS = 300;
@@ -901,8 +908,8 @@ var SOURCES = {
901
908
  standalone: "defineTool",
902
909
  serverFunction: "serverFunction"
903
910
  };
904
- function createFarmAppManifest(input) {
905
- return {
911
+ function createFarmAppManifest(input, { full = false } = {}) {
912
+ const manifest = {
906
913
  schemaVersion: 1,
907
914
  app: {
908
915
  farm: FARM_VERSION,
@@ -912,37 +919,69 @@ function createFarmAppManifest(input) {
912
919
  },
913
920
  packages: input.packages,
914
921
  mcp: {
915
- servers: _listFarmMCPCatalogs().map(({ server, tools, details }) => ({
916
- name: server.name,
917
- version: server.version,
918
- path: server.path,
919
- resources: [...details?.resources ?? []],
920
- prompts: [...details?.prompts ?? []],
921
- tools: tools.map((tool) => {
922
- const schemas = details?.schemas?.[tool.name];
923
- const hints = Object.fromEntries(
924
- ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"].filter((hint) => typeof tool[hint] === "boolean").map((hint) => [hint, tool[hint]])
925
- );
926
- return {
927
- name: tool.name,
928
- ...tool.title ? { title: tool.title } : {},
929
- ...tool.description ? { description: tool.description } : {},
930
- source: SOURCES[tool.kind],
931
- ...tool.kind === "endpoint" ? { method: tool.method, path: tool.path } : {},
932
- ...hints,
933
- ...schemas ? { inputSchema: schemas.input } : {},
934
- ...schemas?.output ? { outputSchema: schemas.output } : {}
935
- };
936
- })
937
- }))
922
+ servers: _listFarmMCPCatalogs().map(({ server, tools, details }) => {
923
+ const listed = full || details?.public === true;
924
+ return {
925
+ name: server.name,
926
+ version: server.version,
927
+ path: server.path,
928
+ authorization: details?.public === true ? "none" : "required",
929
+ resources: listed ? [...details?.resources ?? []] : [],
930
+ prompts: listed ? [...details?.prompts ?? []] : [],
931
+ tools: (listed ? tools : []).map((tool) => {
932
+ const schemas = details?.schemas?.[tool.name];
933
+ const hints = Object.fromEntries(
934
+ ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"].filter((hint) => typeof tool[hint] === "boolean").map((hint) => [hint, tool[hint]])
935
+ );
936
+ return {
937
+ name: tool.name,
938
+ ...tool.title ? { title: tool.title } : {},
939
+ ...tool.description ? { description: tool.description } : {},
940
+ source: SOURCES[tool.kind],
941
+ // MCP clients never see the route behind a tool; only Infra's view names it.
942
+ ...full && tool.kind === "endpoint" ? { method: tool.method, path: tool.path } : {},
943
+ ...hints,
944
+ ...schemas ? { inputSchema: schemas.input } : {},
945
+ ...schemas?.output ? { outputSchema: schemas.output } : {}
946
+ };
947
+ })
948
+ };
949
+ })
938
950
  },
939
951
  webmcp: input.webmcp,
940
952
  integrations: input.integrations,
941
953
  agent: input.agent,
942
954
  plugins: input.plugins
943
955
  };
956
+ manifest.mcp.servers.push(...listDefaultServer(input));
957
+ return manifest;
944
958
  }
945
959
  __name(createFarmAppManifest, "createFarmAppManifest");
960
+ function listDefaultServer(input) {
961
+ const server = input.defaultMCP?.();
962
+ if (!server) return [];
963
+ return [
964
+ {
965
+ name: server.name,
966
+ version: server.version,
967
+ path: server.path,
968
+ authorization: "none",
969
+ resources: [],
970
+ prompts: [],
971
+ tools: FARM_DEFAULT_MCP_TOOLS.map((tool) => ({
972
+ name: tool.name,
973
+ title: tool.title,
974
+ description: tool.description,
975
+ // Standalone tools with no endpoint behind them, like defineTool's.
976
+ source: "defineTool",
977
+ ...tool.annotations,
978
+ inputSchema: tool.inputSchema,
979
+ ..."outputSchema" in tool ? { outputSchema: tool.outputSchema } : {}
980
+ }))
981
+ }
982
+ ];
983
+ }
984
+ __name(listDefaultServer, "listDefaultServer");
946
985
  var encoder = new TextEncoder();
947
986
  var hex = /* @__PURE__ */ __name((bytes) => [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join(""), "hex");
948
987
  async function sha256Hex(value) {
@@ -987,22 +1026,41 @@ function processEnv() {
987
1026
  return globalThis.process?.env ?? {};
988
1027
  }
989
1028
  __name(processEnv, "processEnv");
990
- async function createFarmAppManifestResponse(request, input, options) {
991
- if (request.method !== "GET" && request.method !== "HEAD") return null;
992
- if (!options.development) {
993
- const key = (options.env ?? processEnv()).FARMJS_API_KEY?.trim();
994
- if (!input.analytics || !key) return null;
995
- const signed = await verifyFarmInfraManifestSignature(
996
- request.headers.get(FARM_INFRA_SIGNATURE_HEADER),
997
- key
998
- );
999
- if (!signed)
1000
- return new Response(null, { status: 404, headers: { "cache-control": "no-store" } });
1029
+ var CORS_HEADERS = {
1030
+ "access-control-allow-origin": "*",
1031
+ "access-control-allow-methods": "GET, HEAD, OPTIONS",
1032
+ "access-control-allow-headers": `If-None-Match, ${FARM_INFRA_SIGNATURE_HEADER}`,
1033
+ "access-control-expose-headers": "ETag"
1034
+ };
1035
+ async function createFarmAppManifestResponse(request, input, options = {}) {
1036
+ const method = request.method.toUpperCase();
1037
+ if (method === "OPTIONS") return new Response(null, { status: 204, headers: CORS_HEADERS });
1038
+ if (method !== "GET" && method !== "HEAD") {
1039
+ return new Response("Method Not Allowed", {
1040
+ status: 405,
1041
+ headers: { ...CORS_HEADERS, allow: "GET, HEAD, OPTIONS", "content-type": "text/plain" }
1042
+ });
1001
1043
  }
1002
- const body = JSON.stringify(createFarmAppManifest(input));
1003
- return new Response(request.method === "HEAD" ? null : body, {
1004
- headers: { "content-type": "application/json", "cache-control": "private, no-store" }
1005
- });
1044
+ const signature = request.headers.get(FARM_INFRA_SIGNATURE_HEADER);
1045
+ const key = input.analytics ? (options.env ?? processEnv()).FARMJS_API_KEY?.trim() : void 0;
1046
+ const full = Boolean(
1047
+ signature && key && await verifyFarmInfraManifestSignature(signature, key)
1048
+ );
1049
+ const body = JSON.stringify(createFarmAppManifest(input, { full }));
1050
+ const etag = createFarmWeakETag(body);
1051
+ const headers = {
1052
+ ...CORS_HEADERS,
1053
+ "content-type": "application/json; charset=utf-8",
1054
+ // The full view is for Infra alone; shared caches keep the two views apart.
1055
+ "cache-control": full ? "private, no-store" : "public, max-age=0, must-revalidate",
1056
+ vary: FARM_INFRA_SIGNATURE_HEADER,
1057
+ etag,
1058
+ "x-content-type-options": "nosniff"
1059
+ };
1060
+ if (!full && matchesFarmIfNoneMatch(request.headers.get("if-none-match"), etag)) {
1061
+ return new Response(null, { status: 304, headers });
1062
+ }
1063
+ return new Response(method === "HEAD" ? null : body, { status: 200, headers });
1006
1064
  }
1007
1065
  __name(createFarmAppManifestResponse, "createFarmAppManifestResponse");
1008
1066
 
@@ -1035,6 +1093,9 @@ export {
1035
1093
  resolveFarmApiCatalogInput,
1036
1094
  createFarmApiCatalogResponse,
1037
1095
  FARM_APP_MANIFEST_PATH,
1096
+ FARM_APP_MANIFEST_LEGACY_PATH,
1097
+ isFarmAppManifestPath,
1098
+ FARM_INFRA_SIGNATURE_HEADER,
1038
1099
  resolveFarmAppManifestInput,
1039
1100
  createFarmAppManifestResponse
1040
1101
  };
@@ -16,11 +16,15 @@ import {
16
16
  readNodeRequestBody,
17
17
  resolveFarmServerConfig,
18
18
  setRequestContext
19
- } from "./chunk-Y7RKTKYI.mjs";
19
+ } from "./chunk-ZMMBIVQM.mjs";
20
20
  import {
21
21
  applyWebResponseHeaders,
22
22
  sendWebResponse
23
23
  } from "./chunk-Z2RZJZIZ.mjs";
24
+ import {
25
+ createFarmAPIMiddlewarePathnames,
26
+ resolveFarmAPIServerBasePath
27
+ } from "./chunk-BTHHUD7Q.mjs";
24
28
  import {
25
29
  api,
26
30
  defineIntegrationAPIOperation
@@ -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 (options.ranMiddleware?.has(entry)) continue;
1580
1585
  const params = resolveIntegrationMiddlewareParams(entry, pathname, runtime.config);
1581
1586
  if (!params) {
1582
1587
  continue;
1583
1588
  }
1589
+ options.ranMiddleware?.add(entry);
1584
1590
  const handlerContext = createServerIntegrationHandlerContext({
1585
1591
  runtime,
1586
1592
  route: {
@@ -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__ */ __name((cookies) => setCookies.push(...cookies), "onForwardedCookies")
1849
1856
  }
1850
1857
  );
@@ -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,13 +2026,28 @@ 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 = matchesCompiledMiddlewareConfig(candidate, compiled, noMiddlewareContext);
2022
2031
  if (result.matched) return result.params ?? {};
2023
2032
  }
2024
2033
  return null;
2025
2034
  }
2026
2035
  __name(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 api2?.baseURL === "string" && typeof api2.basePath === "string" ? resolveFarmAPIServerBasePath(api2) : void 0;
2045
+ toPathnames = createFarmAPIMiddlewarePathnames(serverBasePath);
2046
+ integrationAPIPathnames.set(config, toPathnames);
2047
+ }
2048
+ return toPathnames;
2049
+ }
2050
+ __name(getIntegrationAPIPathnames, "getIntegrationAPIPathnames");
2027
2051
  function resolveIntegrationRoutePathname(pathname, config) {
2028
2052
  const basePath = typeof config?.basePath === "string" ? config.basePath : void 0;
2029
2053
  let routePathname = basePath ? stripFarmBasePath(pathname, basePath) : pathname;
@@ -2158,5 +2182,6 @@ export {
2158
2182
  matchRegisteredIntegrationRoute,
2159
2183
  getRegisteredIntegrationAPIManifest,
2160
2184
  dispatchIntegrationRequest,
2161
- dispatchIntegrationRequests
2185
+ dispatchIntegrationRequests,
2186
+ FARM_INTEGRATION_API_BASE_PATH_KEY
2162
2187
  };