@farm.js/core 0.1.26 → 0.1.28

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 (231) hide show
  1. package/dist/agent-runtime.d.mts +8 -9
  2. package/dist/agent-runtime.d.ts +8 -9
  3. package/dist/api/client.cjs +5 -7
  4. package/dist/api/client.d.mts +5 -5
  5. package/dist/api/client.d.ts +5 -5
  6. package/dist/api/client.mjs +4 -6
  7. package/dist/api/route-manager.cjs +12 -10
  8. package/dist/api/route-manager.d.mts +7 -8
  9. package/dist/api/route-manager.d.ts +7 -8
  10. package/dist/api/route-manager.mjs +11 -9
  11. package/dist/api/runtime.cjs +15 -8
  12. package/dist/api/runtime.d.mts +36 -3
  13. package/dist/api/runtime.d.ts +36 -3
  14. package/dist/api/runtime.mjs +14 -7
  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 +16 -14
  18. package/dist/api.d.mts +9 -10
  19. package/dist/api.d.ts +9 -10
  20. package/dist/api.mjs +16 -14
  21. package/dist/{app-29vG5tmY.d.mts → app-DSSq6wiN.d.mts} +3 -4
  22. package/dist/{app-Cx71s_PT.d.ts → app-M8nVWvNU.d.ts} +3 -4
  23. package/dist/app-markdown.cjs +10 -4
  24. package/dist/app-markdown.d.mts +9 -10
  25. package/dist/app-markdown.d.ts +9 -10
  26. package/dist/app-markdown.mjs +9 -3
  27. package/dist/cache-invalidation-BD0z_lfu.d.mts +4 -0
  28. package/dist/cache-invalidation-BD0z_lfu.d.ts +4 -0
  29. package/dist/cache.cjs +6 -4
  30. package/dist/cache.d.mts +11 -6
  31. package/dist/cache.d.ts +11 -6
  32. package/dist/cache.mjs +7 -5
  33. package/dist/{chunk-OFKG57MZ.mjs → chunk-2CNBR3EB.mjs} +2 -2
  34. package/dist/{chunk-JM5GQL4H.mjs → chunk-2DLN6HG4.mjs} +1 -1
  35. package/dist/{chunk-UUYF3CHN.mjs → chunk-2N5PX3LS.mjs} +2 -2
  36. package/dist/{chunk-H6G5INWM.cjs → chunk-2SDO73HK.cjs} +14 -156
  37. package/dist/{chunk-3TQWUUNP.cjs → chunk-3LUF2PE2.cjs} +10 -5
  38. package/dist/{chunk-SYGGPS4A.mjs → chunk-4IEPYMHF.mjs} +3 -3
  39. package/dist/{chunk-WD5PNSOB.mjs → chunk-4V7GIE2U.mjs} +6 -4
  40. package/dist/{chunk-2CT6XUNO.cjs → chunk-55ZY4ZA7.cjs} +4 -4
  41. package/dist/chunk-5MKEDGLD.cjs +53 -0
  42. package/dist/{chunk-I7PUUDGY.cjs → chunk-63H6BKXG.cjs} +2 -2
  43. package/dist/{chunk-FG5H2VCJ.mjs → chunk-6ZCMSZ5U.mjs} +2 -2
  44. package/dist/{chunk-ZMN3H73H.cjs → chunk-75DYEVXI.cjs} +13 -11
  45. package/dist/{chunk-QJ4D3UKJ.cjs → chunk-A672WZEG.cjs} +4 -4
  46. package/dist/{chunk-IXTFU4PL.cjs → chunk-BJPBQNIE.cjs} +14 -14
  47. package/dist/{chunk-QGG336NI.mjs → chunk-BXFWA23T.mjs} +2 -2
  48. package/dist/chunk-CNOQY6Z7.mjs +156 -0
  49. package/dist/{chunk-DW34V5SM.cjs → chunk-CTV2TTNP.cjs} +4 -4
  50. package/dist/{chunk-OAVTUMJP.cjs → chunk-D4JE5NNV.cjs} +12 -12
  51. package/dist/{chunk-KLSSO6YD.mjs → chunk-E76XC6ZG.mjs} +2 -2
  52. package/dist/{chunk-G3HRIVEY.cjs → chunk-ES4B2IXW.cjs} +2 -2
  53. package/dist/{chunk-W2HZKYES.cjs → chunk-EWZ3XHKQ.cjs} +2 -2
  54. package/dist/{chunk-BD2U4ZL6.cjs → chunk-EXLKRR4U.cjs} +10 -10
  55. package/dist/{chunk-SZ4LYNUX.cjs → chunk-F52CDFJM.cjs} +89 -83
  56. package/dist/{chunk-ARXCHQLX.mjs → chunk-FB3H4INL.mjs} +4 -4
  57. package/dist/{chunk-QPPQHB6X.mjs → chunk-FVCSLZWT.mjs} +19 -13
  58. package/dist/{chunk-WD4YXVLV.mjs → chunk-GZYH4OER.mjs} +1 -1
  59. package/dist/{chunk-DX4VKYAJ.cjs → chunk-I26CZYPV.cjs} +6 -4
  60. package/dist/{chunk-3TQG7CGC.cjs → chunk-ID6OVSLH.cjs} +164 -129
  61. package/dist/{chunk-F6SJAKFJ.mjs → chunk-IV6CQY7O.mjs} +12 -154
  62. package/dist/{chunk-6D242YGO.mjs → chunk-JATSG2ZO.mjs} +1 -1
  63. package/dist/{chunk-U74A3P2P.cjs → chunk-JLRDISQL.cjs} +7 -7
  64. package/dist/{chunk-H7CJRJ4L.cjs → chunk-JUFRXDTK.cjs} +18 -18
  65. package/dist/{chunk-OOIL3BWR.mjs → chunk-K3YEZLSY.mjs} +65 -8
  66. package/dist/{chunk-Y4YWHNKU.cjs → chunk-KH7BN726.cjs} +9 -9
  67. package/dist/{chunk-WFPRVVF2.cjs → chunk-KOQ555NR.cjs} +22 -14
  68. package/dist/{chunk-VZWO3XVL.mjs → chunk-KXGDXYUC.mjs} +3 -3
  69. package/dist/{chunk-3IL5UC5I.cjs → chunk-KZLND3D2.cjs} +2 -2
  70. package/dist/{chunk-QLXEYIAW.cjs → chunk-MH24QDVJ.cjs} +13 -13
  71. package/dist/{chunk-TKDY6AJP.mjs → chunk-MKMBQSNQ.mjs} +1 -1
  72. package/dist/{chunk-OCE65DDM.mjs → chunk-MNUGPHLN.mjs} +1 -1
  73. package/dist/{chunk-74RZNRY6.mjs → chunk-NVBS5WSZ.mjs} +1 -1
  74. package/dist/chunk-NYJMY3JA.cjs +156 -0
  75. package/dist/{chunk-VVJCWBIE.mjs → chunk-O3DTUAX2.mjs} +2 -2
  76. package/dist/chunk-O6XNAMBV.mjs +53 -0
  77. package/dist/{chunk-YAOX43YI.cjs → chunk-PZNCMPJF.cjs} +5 -5
  78. package/dist/{chunk-YMUH2BLR.mjs → chunk-PZPDGOU5.mjs} +14 -6
  79. package/dist/{chunk-52SH7TKB.mjs → chunk-QG5HNS7P.mjs} +2 -2
  80. package/dist/{chunk-CEYUWDWA.mjs → chunk-QZCT2CQ4.mjs} +10 -5
  81. package/dist/{chunk-RAI7NULA.mjs → chunk-REGFZJEJ.mjs} +1 -1
  82. package/dist/{chunk-QMV4QELL.mjs → chunk-S5GDHOE4.mjs} +4 -2
  83. package/dist/{chunk-CRQPYWLK.cjs → chunk-SORB3MAR.cjs} +14 -14
  84. package/dist/{chunk-DU2CASV6.mjs → chunk-T7HQ3I4C.mjs} +1 -1
  85. package/dist/{chunk-RCYINC4A.cjs → chunk-TII23GJC.cjs} +3 -3
  86. package/dist/{chunk-PPIW3MH6.mjs → chunk-UX2DD2VK.mjs} +1 -1
  87. package/dist/{chunk-I4J452B7.cjs → chunk-VHJGDMCG.cjs} +3 -3
  88. package/dist/{chunk-3WSWXPYM.cjs → chunk-VQXDC5UV.cjs} +4 -4
  89. package/dist/{chunk-B6ZCT36X.cjs → chunk-WNLBF77X.cjs} +4 -4
  90. package/dist/{chunk-GDUYXFIS.mjs → chunk-X7WVQMIB.mjs} +4 -4
  91. package/dist/{chunk-5SPPCN5J.mjs → chunk-XNPDONUH.mjs} +1 -1
  92. package/dist/{chunk-QIH2HD6H.cjs → chunk-XSPGWQWA.cjs} +86 -29
  93. package/dist/{chunk-ALIFMS4A.cjs → chunk-Y7GW7J46.cjs} +1 -1
  94. package/dist/{chunk-L6V3P73N.mjs → chunk-YDQZGSDS.mjs} +5 -5
  95. package/dist/{chunk-C3VRMB6H.cjs → chunk-ZCU4NZ3M.cjs} +6 -6
  96. package/dist/{chunk-UXQXGB5A.mjs → chunk-ZRIE4KMG.mjs} +63 -28
  97. package/dist/{client-plugins-B8RPJnot.d.mts → client-plugins-CgYNY7jF.d.mts} +1656 -1477
  98. package/dist/{client-plugins-bPBf4haK.d.ts → client-plugins-Fl9Og3yB.d.ts} +1656 -1477
  99. package/dist/client-plugins.d.mts +8 -9
  100. package/dist/client-plugins.d.ts +8 -9
  101. package/dist/client.cjs +12 -13
  102. package/dist/client.d.mts +10 -11
  103. package/dist/client.d.ts +10 -11
  104. package/dist/client.mjs +11 -12
  105. package/dist/config.d.mts +8 -9
  106. package/dist/config.d.ts +8 -9
  107. package/dist/{devtools-5D4ZDRPR.mjs → devtools-3E7ZANMZ.mjs} +7 -4
  108. package/dist/{devtools-QZJEUOJW.cjs → devtools-5AREISIA.cjs} +8 -5
  109. package/dist/docs.cjs +10 -7
  110. package/dist/docs.mjs +9 -6
  111. package/dist/{endpoint-1zA994xL.d.ts → endpoint-CA-TNX60.d.ts} +1 -1
  112. package/dist/{endpoint-DAc96i93.d.mts → endpoint-CCHFqyTE.d.mts} +1 -1
  113. package/dist/index.cjs +58 -55
  114. package/dist/index.d.mts +17 -18
  115. package/dist/index.d.ts +17 -18
  116. package/dist/index.mjs +69 -66
  117. package/dist/{integration-api-BbaiokCC.d.ts → integration-api-0y4FXJpC.d.mts} +128 -1
  118. package/dist/{integration-api-BbaiokCC.d.mts → integration-api-BPJo5oXb.d.ts} +128 -1
  119. package/dist/integrations.d.mts +8 -9
  120. package/dist/integrations.d.ts +8 -9
  121. package/dist/internal/app-markdown-runtime.cjs +9 -3
  122. package/dist/internal/app-markdown-runtime.d.mts +9 -9
  123. package/dist/internal/app-markdown-runtime.d.ts +9 -9
  124. package/dist/internal/app-markdown-runtime.mjs +8 -2
  125. package/dist/internal/build-runtime.cjs +26 -24
  126. package/dist/internal/build-runtime.d.mts +10 -11
  127. package/dist/internal/build-runtime.d.ts +10 -11
  128. package/dist/internal/build-runtime.mjs +25 -23
  129. package/dist/internal/cli-runtime.cjs +16 -12
  130. package/dist/internal/cli-runtime.mjs +15 -11
  131. package/dist/internal/client-error-overlay.cjs +4 -4
  132. package/dist/internal/client-error-overlay.mjs +1 -1
  133. package/dist/internal/client-runtime.cjs +5 -1
  134. package/dist/internal/client-runtime.d.mts +1 -0
  135. package/dist/internal/client-runtime.d.ts +1 -0
  136. package/dist/internal/client-runtime.mjs +4 -0
  137. package/dist/internal/compression-runtime.d.mts +8 -9
  138. package/dist/internal/compression-runtime.d.ts +8 -9
  139. package/dist/internal/config-runtime.cjs +8 -5
  140. package/dist/internal/config-runtime.d.mts +9 -10
  141. package/dist/internal/config-runtime.d.ts +9 -10
  142. package/dist/internal/config-runtime.mjs +7 -4
  143. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  144. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  145. package/dist/internal/production-runtime.cjs +20 -16
  146. package/dist/internal/production-runtime.d.mts +13 -14
  147. package/dist/internal/production-runtime.d.ts +13 -14
  148. package/dist/internal/production-runtime.mjs +20 -16
  149. package/dist/markdown.cjs +8 -2
  150. package/dist/markdown.d.mts +36 -153
  151. package/dist/markdown.d.ts +36 -153
  152. package/dist/markdown.mjs +7 -1
  153. package/dist/{metadata-C3na4CBj.d.mts → metadata-B0X-qtcQ.d.mts} +1 -1
  154. package/dist/{metadata-CzBP4Mfp.d.ts → metadata-BdDKgd7K.d.ts} +1 -1
  155. package/dist/middleware.cjs +4 -4
  156. package/dist/middleware.d.mts +9 -10
  157. package/dist/middleware.d.ts +9 -10
  158. package/dist/middleware.mjs +3 -3
  159. package/dist/navigation.cjs +5 -5
  160. package/dist/navigation.d.mts +10 -11
  161. package/dist/navigation.d.ts +10 -11
  162. package/dist/navigation.mjs +4 -4
  163. package/dist/{nitro-ZKLGOTVY.mjs → nitro-NAKCRVHX.mjs} +4 -3
  164. package/dist/{nitro-KQDU7CFE.cjs → nitro-VYDZGYFY.cjs} +4 -3
  165. package/dist/plugin.cjs +26 -21
  166. package/dist/plugin.d.mts +9 -10
  167. package/dist/plugin.d.ts +9 -10
  168. package/dist/plugin.mjs +26 -21
  169. package/dist/{production-runtime-DP94hPGe.d.mts → production-runtime-BjgFgDIg.d.mts} +1 -1
  170. package/dist/{production-runtime-CYg4wM4E.d.ts → production-runtime-Dx_qMA3t.d.ts} +1 -1
  171. package/dist/query/client.cjs +6 -6
  172. package/dist/query/client.mjs +2 -2
  173. package/dist/{render-plan-Bl6Fzg5z.d.ts → render-plan-B41EWmBb.d.ts} +1 -1
  174. package/dist/{render-plan-CKAJg0jC.d.mts → render-plan-_1TAWODt.d.mts} +1 -1
  175. package/dist/renderer-client.cjs +13 -14
  176. package/dist/renderer-client.d.mts +6 -7
  177. package/dist/renderer-client.d.ts +6 -7
  178. package/dist/renderer-client.mjs +6 -7
  179. package/dist/{request-CrBCcPZZ.d.mts → request-BhE4luLv.d.mts} +1 -1
  180. package/dist/{request-CR-Bp1Px.d.ts → request-Dbf3G0zM.d.ts} +1 -1
  181. package/dist/request.d.mts +9 -10
  182. package/dist/request.d.ts +9 -10
  183. package/dist/{route-rendering-CZH5FegB.d.ts → route-rendering-Z7PveTZE.d.ts} +1 -1
  184. package/dist/{route-rendering-C1NAHo-C.d.mts → route-rendering-zzfx_GHf.d.mts} +1 -1
  185. package/dist/{router-B57eDJ3u.d.mts → router-BatNMsa1.d.mts} +1 -1
  186. package/dist/{router-Cg_kD3Bd.d.ts → router-DtNRhQl3.d.ts} +1 -1
  187. package/dist/routes.cjs +6 -5
  188. package/dist/routes.d.mts +6 -7
  189. package/dist/routes.d.ts +6 -7
  190. package/dist/routes.mjs +5 -4
  191. package/dist/server-fn-client.d.mts +4 -4
  192. package/dist/server-fn-client.d.ts +4 -4
  193. package/dist/server-fn.cjs +6 -5
  194. package/dist/server-fn.d.mts +2 -1
  195. package/dist/server-fn.d.ts +2 -1
  196. package/dist/server-fn.mjs +5 -4
  197. package/dist/server-plugins.d.mts +8 -9
  198. package/dist/server-plugins.d.ts +8 -9
  199. package/dist/server-query-client.cjs +5 -7
  200. package/dist/server-query-client.d.mts +2 -1
  201. package/dist/server-query-client.d.ts +2 -1
  202. package/dist/server-query-client.mjs +4 -6
  203. package/dist/server-query.cjs +7 -6
  204. package/dist/server-query.d.mts +2 -1
  205. package/dist/server-query.d.ts +2 -1
  206. package/dist/server-query.mjs +6 -5
  207. package/dist/server.cjs +235 -131
  208. package/dist/server.d.mts +14 -15
  209. package/dist/server.d.ts +14 -15
  210. package/dist/server.mjs +222 -118
  211. package/dist/{spa-router-BstQUO6Q.d.ts → spa-router-BE3bwU-J.d.ts} +2 -2
  212. package/dist/{spa-router-DTdbuinx.d.mts → spa-router-DQOnHZVj.d.mts} +2 -2
  213. package/dist/testing.cjs +17 -15
  214. package/dist/testing.d.mts +7 -8
  215. package/dist/testing.d.ts +7 -8
  216. package/dist/testing.mjs +14 -12
  217. package/dist/{utils-CS3ZLnEJ.d.mts → utils-DLK1ERNl.d.mts} +1 -1
  218. package/dist/{utils-D3rdsIvM.d.ts → utils-u7ZBSWAK.d.ts} +1 -1
  219. package/dist/version.cjs +2 -2
  220. package/dist/version.mjs +1 -1
  221. package/dist/vite.cjs +22 -20
  222. package/dist/vite.d.mts +8 -9
  223. package/dist/vite.d.ts +8 -9
  224. package/dist/vite.mjs +21 -19
  225. package/package.json +1 -1
  226. package/dist/route-B0XrsrFk.d.mts +0 -128
  227. package/dist/route-DOEpbyWZ.d.ts +0 -128
  228. package/dist/{chunk-YOYF2E4U.mjs → chunk-LNZ7JZUS.mjs} +0 -0
  229. package/dist/{chunk-N4RLRSWW.cjs → chunk-SUIBNSNO.cjs} +0 -0
  230. package/dist/{chunk-TIKNUAU7.mjs → chunk-VUMAE7NC.mjs} +3 -3
  231. package/dist/{chunk-WM6HL7E7.cjs → chunk-ZHVYQL3H.cjs} +2 -2
@@ -1,13 +1,14 @@
1
1
  import { n as FarmClientPlugin } from './lifecycle-DK06VuKP.js';
2
- import { R as RouteMethod, g as PluginRoutes, P as PluginRoutesFactory } from './route-DOEpbyWZ.js';
3
- import { T as TypedEndpoint, d as EndpointMCPMetadata, R as RouteSchema, a as RouteSchemaOutput, c as RouteSchemaInput, Y as OpenAPISecurityMode } from './endpoint-1zA994xL.js';
2
+ import { F as FarmIntegrationAPI, e as FarmIntegrationAPIMethod, c as FarmIntegrationAPIBodyFormat, f as FarmIntegrationAPIOperation, g as FarmIntegrationAPIResponseFormat, h as FarmIntegrationRouteOperationCarrier, I as InferIntegrationAPIFromRoutes, p as PluginRoutes, P as PluginRoutesFactory, R as RouteMethod } from './integration-api-BPJo5oXb.js';
3
+ import { Y as OpenAPISecurityMode, T as TypedEndpoint, E as EndpointMCPMetadata, R as RouteSchema, b as RouteSchemaOutput, d as RouteSchemaInput } from './endpoint-CA-TNX60.js';
4
4
  import { FarmRenderer } from './renderer.js';
5
5
  import { IncomingMessage, ServerResponse } from 'http';
6
- import { FarmMarkdownResolvedConfig, FarmMarkdownUserConfig } from './markdown.js';
6
+ import { ServerFn } from './server-fn.js';
7
+ import { ServerQuery } from './server-query.js';
8
+ import { g as FarmI18nUserConfig, R as ResolvedFarmI18nConfig } from './types-Z0aotQ8w.js';
7
9
  import { d as FarmStorageUserConfig } from './types-Cc8l9IqS.js';
8
10
  import { FarmSchemaField, FarmSchema, FarmSchemaModel, FarmSchemaReference, FarmSchemaFieldType, FarmSchemaConstraint, FarmSchemaModelExtension, FarmSchemaModelOverride, defineSchema, FarmSchemaConfig } from './schema.js';
9
11
  import React__default, { ComponentType, ReactNode } from 'react';
10
- import { F as FarmIntegrationAPI, e as FarmIntegrationAPIMethod, c as FarmIntegrationAPIBodyFormat, f as FarmIntegrationAPIOperation, g as FarmIntegrationAPIResponseFormat, h as FarmIntegrationRouteOperationCarrier, I as InferIntegrationAPIFromRoutes } from './integration-api-BbaiokCC.js';
11
12
  import { OrmClient, SchemaDefinition, ModelDefinition, FieldBuilder, JsonValue, AnyModelDefinition, SchemaModels } from '@farming-labs/orm';
12
13
  import { a as FarmDocsUserConfig, F as FarmDocsResolvedConfig } from './types-DFbjpjXX.js';
13
14
  import { L as FarmObservabilityUserConfig } from './observability-BupkiN0m.js';
@@ -20,377 +21,281 @@ import { FarmServerActionsConfig, ResolvedFarmServerActionsConfig } from './serv
20
21
  import * as rolldown_utils from 'rolldown/utils';
21
22
  import { Plugin } from 'rolldown';
22
23
  import { F as FarmImageConfig, R as ResolvedFarmImageConfig } from './image-config-Duob7wER.js';
23
- import { g as FarmI18nUserConfig, R as ResolvedFarmI18nConfig } from './types-Z0aotQ8w.js';
24
24
  import { FarmCacheUserConfig } from './cache.js';
25
- import { ServerFn } from './server-fn.js';
26
- import { ServerQuery } from './server-query.js';
27
25
  import { R as ResolvedFarmThemeConfig, d as FarmThemeConfig } from './types-DQnyD3VD.js';
28
26
  import { FarmLayoutFonts } from './font.js';
29
27
  import { _withAfterNodeMiddleware } from './after.js';
30
28
  import { F as FarmIslandStrategy } from './island-CfGru1MO.js';
31
29
 
32
- interface FarmLlmsTxtLink {
33
- title: string;
34
- url: string;
35
- description?: string;
30
+ /** @internal The environment registry is owned and closed by Vite. */
31
+ interface FarmDevModuleServer {
32
+ environments: Record<string, unknown>;
36
33
  }
37
- interface FarmLlmsTxtSection {
38
- title: string;
39
- links: FarmLlmsTxtLink[];
34
+ /** @internal Distinguishes an unsupported runtime from a module evaluation error. */
35
+ declare class FarmDevEnvironmentError extends Error {
40
36
  }
41
- interface FarmLlmsTxt {
42
- /** Site or project name, rendered as the `# H1`. Required by the format. */
43
- title: string;
44
- /** One-sentence summary, rendered as a `> blockquote`. */
45
- summary?: string;
46
- /** Free-form Markdown placed after the summary. */
47
- details?: string;
48
- /** `## H2` sections of links. A section titled "Optional" marks skippable links. */
49
- sections?: FarmLlmsTxtSection[];
37
+ /** @internal Load in the selected environment without sharing SSR/RSC module state. */
38
+ declare function loadFarmDevModule<T = Record<string, any>>(server: FarmDevModuleServer, id: string, environmentName?: "ssr" | "rsc"): Promise<T>;
39
+
40
+ declare const DEFAULT_FARM_DEVTOOLS_SHORTCUT = "mod+shift+.";
41
+ declare const FARM_DEVTOOLS_PATH = "/__farm/devtools";
42
+ declare const FARM_DEVTOOLS_LAUNCH_PARAM = "__farm_devtools";
43
+ /**
44
+ * Configuration for the built-in DevTools dashboard. The dashboard is deprecated in favor
45
+ * of the `@farm.js/devtools` plugin, which reuses this configuration for enablement and
46
+ * the keyboard shortcut. Both options keep working while the built-in UI remains available.
47
+ */
48
+ interface FarmDevtoolsConfig {
49
+ /** Enable the development-only DevTools UI and runtime endpoints. */
50
+ enabled?: boolean;
51
+ /** Keyboard shortcut used to toggle DevTools, or false to disable the shortcut. */
52
+ shortcut?: string | false;
50
53
  }
51
- /** A static page of the app, ready to use as an llms.txt link. */
52
- interface FarmLlmsTxtPage extends FarmLlmsTxtLink {
53
- /** The page's route path, such as `/docs/install`. */
54
- path: string;
54
+ type FarmDevtoolsUserConfig = boolean | FarmDevtoolsConfig;
55
+ interface ResolvedFarmDevtoolsConfig {
56
+ enabled: boolean;
57
+ shortcut: string | false;
55
58
  }
56
- interface FarmLlmsTxtUserConfig {
57
- /** Set to `false` to turn llms.txt off while keeping these options. */
58
- enabled?: boolean;
59
- /** Site name for the `# H1`. Defaults to the root layout's metadata title. */
60
- title?: string;
61
- /** Summary for the `> blockquote`. Defaults to the root layout's metadata description. */
62
- summary?: string;
63
- /** Markdown placed after the summary. */
64
- details?: string;
65
- /**
66
- * Route patterns to list, using the same syntax as `md.expose`
67
- * (`/docs/[...slug]`). Defaults to every static page.
68
- */
69
- include?: string[];
70
- /** Route patterns to leave out, such as `/admin/[...path]`. */
71
- exclude?: string[];
59
+ declare function resolveFarmDevtoolsConfig(config: FarmDevtoolsUserConfig | ResolvedFarmDevtoolsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevtoolsConfig;
60
+
61
+ type ResolvedSchemaField = FarmSchemaField & {
62
+ name: string;
63
+ };
64
+ type ResolvedSchemaModel = Omit<FarmSchemaModel, "fields"> & {
65
+ name: string;
66
+ fields: Record<string, ResolvedSchemaField>;
67
+ };
68
+ /**
69
+ * Resolve a schema's extensions, overrides, and name mappings.
70
+ *
71
+ * Table and column names fall back to the schema's own keys, which is what the
72
+ * runtime ORM uses. Any other default would generate artifacts describing
73
+ * tables the app cannot actually read.
74
+ */
75
+ declare function resolveSchemaModels(ownerKey: string, schema: FarmSchema): Record<string, ResolvedSchemaModel>;
76
+
77
+ type FarmSqlDialect = "postgres" | "mysql" | "sqlite";
78
+ type CollectedSchemaModel = {
79
+ /** Namespace that owns the model: an integration key or a plugin name. */
80
+ ownerKey: string;
81
+ modelKey: string;
82
+ modelName: string;
83
+ exportName: string;
84
+ prismaModelName: string;
85
+ model: ResolvedSchemaModel;
72
86
  /**
73
- * Also serve `/llms-full.txt`, the index with each page's Markdown mirror inlined.
74
- *
75
- * @default true
87
+ * Real table and column for references to models this owner describes but
88
+ * does not create (external, or outside its `models`), keyed by field. Only
89
+ * shown in comments: Farm never creates a foreign key to them.
76
90
  */
77
- full?: boolean;
91
+ referenceTargets?: Record<string, {
92
+ table: string;
93
+ column: string;
94
+ }>;
78
95
  /**
79
- * Seconds a CDN may cache the generated files, and the production server may
80
- * reuse an llms-full.txt render, which renders every listed page. Defaults to
81
- * no caching; concurrent llms-full.txt requests still share one render.
96
+ * References to tables other owners create that may carry a real foreign
97
+ * key, keyed by field. Set by migrate after checking the database; only a
98
+ * table created now gets one inline.
82
99
  */
83
- revalidate?: number;
84
- }
85
- interface ResolvedFarmLlmsTxtConfig {
86
- enabled: boolean;
87
- title?: string;
88
- summary?: string;
89
- details?: string;
90
- include: string[];
91
- exclude: string[];
92
- full: boolean;
93
- revalidate?: number;
94
- }
95
- interface FarmLlmsTxtPageSource {
96
- pattern: string;
97
- metadata?: unknown;
98
- }
99
- declare function collectFarmLlmsTxtPages(sources: Iterable<FarmLlmsTxtPageSource>, options: {
100
- origin: string;
101
- basePath?: string;
102
- markdown?: FarmMarkdownResolvedConfig;
103
- include?: string[];
104
- exclude?: string[];
105
- }): FarmLlmsTxtPage[];
106
- declare function createFarmDefaultLlmsTxt(options: {
107
- origin: string;
108
- pages: FarmLlmsTxtPage[];
109
- config: ResolvedFarmLlmsTxtConfig;
110
- rootMetadata?: unknown;
111
- }): FarmLlmsTxt;
100
+ foreignKeys?: Record<string, {
101
+ table: string;
102
+ column: string;
103
+ onDelete: NonNullable<FarmSchemaReference["onDelete"]>;
104
+ }>;
105
+ };
106
+ /** `table.column` a field's reference points at, using real names when known. */
107
+ declare function describeSchemaReference(model: CollectedSchemaModel, fieldKey: string): string;
112
108
  /**
113
- * Reads a page's Markdown the way an agent would: a fresh `.md` request with no
114
- * cookies or credentials, so a page behind auth answers 401 and is left out of
115
- * a file that CDNs may cache, instead of leaking into it.
109
+ * Flatten owners' schemas into one list, rejecting two models that would
110
+ * resolve to the same table.
111
+ *
112
+ * `only` narrows an owner to the models it actually controls; an owner handed a
113
+ * schema it shares with the rest of the app should not claim all of it.
116
114
  */
117
- declare function createFarmLlmsMarkdownReader(fetchMarkdown: (request: Request) => Promise<Response>): (url: string) => Promise<string | null>;
115
+ declare function collectSchemaModels(entries: ReadonlyArray<readonly [string, FarmSchema, (readonly string[])?]>): CollectedSchemaModel[];
116
+ type FarmSqlStatement = {
117
+ kind: "table" | "index" | "column";
118
+ /** The object this statement creates, for drift reporting. */
119
+ target: string;
120
+ sql: string;
121
+ };
118
122
  /**
119
- * Renders llms-full.txt: the llms.txt header, then one block per linked page with
120
- * its Markdown inlined, in the layout the docs engine uses. A string passes
121
- * through unchanged. Only same-origin links are fetched.
123
+ * Emit create statements for a set of models.
124
+ *
125
+ * Everything here is derivable from the schema: nothing is inferred from a live
126
+ * database, so the output is stable and reviewable before it is applied.
122
127
  */
123
- declare function renderFarmLlmsFullTxt(value: unknown, options: {
124
- origin: string;
125
- readMarkdown: (url: string) => Promise<string | null>;
126
- concurrency?: number;
127
- /** Milliseconds to wait for one page's Markdown before leaving it out. */
128
- pageTimeout?: number;
129
- /** Called when a page is left out because it did not answer in time. */
130
- onIncomplete?: () => void;
131
- }): Promise<string>;
128
+ declare function generateSqlStatements(models: readonly CollectedSchemaModel[], dialect: FarmSqlDialect): FarmSqlStatement[];
129
+ /** Render models as a standalone `.sql` file. */
130
+ declare function renderSqlSchemaFile(models: readonly CollectedSchemaModel[], dialect: FarmSqlDialect): string;
131
+ declare function getSqlColumnType(field: ResolvedSchemaField, dialect: FarmSqlDialect): "BOOLEAN" | "INTEGER" | "DOUBLE PRECISION" | "TIMESTAMPTZ" | "JSONB" | "TEXT" | "INT" | "DOUBLE" | "DATETIME" | "JSON" | "VARCHAR(255)" | "REAL";
132
+ declare function getSqlDefaultExpression(field: ResolvedSchemaField, dialect: FarmSqlDialect): string | null;
133
+ declare function isNullableField(field: ResolvedSchemaField): boolean;
134
+ declare function quoteSqlIdentifier(dialect: FarmSqlDialect, value: string): string;
135
+ declare function toSnakeCase(value: string): string;
136
+ declare function toPascalCase(value: string): string;
137
+ declare function toCamelCase(value: string): string;
138
+ declare function escapeSqlString(value: string, dialect?: FarmSqlDialect): string;
139
+
132
140
  /**
133
- * Shares llms-full.txt renders, which read every listed page. Requests for the
134
- * same origin while a render runs, or within `revalidate` seconds after it, get
135
- * that result; renders run one at a time, so a burst of requests, even with
136
- * varied Host headers, cannot multiply page renders. The content is the same for
137
- * every caller: pages are read with fresh requests that carry no credentials.
138
- * A render that calls `incomplete()`, because a page timed out, is answered but
139
- * not reused, so the next request tries that page again.
141
+ * An ordered change a plugin release makes to its own tables that Farm will
142
+ * not infer: a rename looks exactly like a removal plus an addition. Each step
143
+ * runs once per database, in the order listed.
144
+ *
145
+ * Names are the plugin's own: `model` and `to` are keys in the current
146
+ * schema, so the app's renames apply; `from` is the old name in the database.
140
147
  */
141
- declare function createFarmLlmsFullRenderer(options?: {
142
- revalidate?: number;
143
- now?: () => number;
144
- maxEntries?: number;
145
- }): (origin: string, render: (shared: {
146
- incomplete: () => void;
147
- }) => Promise<string>, onSettled?: (complete: boolean) => void) => Promise<string>;
148
+ type FarmSchemaMigrationStep = {
149
+ id: string;
150
+ description?: string;
151
+ } & ({
152
+ renameColumn: {
153
+ model: string;
154
+ from: string;
155
+ to: string;
156
+ };
157
+ } | {
158
+ renameTable: {
159
+ from: string;
160
+ to: string;
161
+ };
162
+ }
163
+ /**
164
+ * Deletes data, so it runs only with `--allow-destructive`, and only on a
165
+ * column or table Farm recorded this plugin creating.
166
+ */
167
+ | {
168
+ dropColumn: {
169
+ model: string;
170
+ column: string;
171
+ };
172
+ } | {
173
+ dropTable: {
174
+ table: string;
175
+ };
176
+ } | {
177
+ /** Per dialect; a dialect without SQL cannot run the step. */
178
+ sql: Partial<Record<FarmSqlDialect, string | readonly string[]>>;
179
+ /**
180
+ * Custom SQL runs after this release's new tables and columns exist, so
181
+ * a backfill can fill them. Set `before` to run it with the renames.
182
+ */
183
+ before?: boolean;
184
+ });
148
185
 
149
- type ApplicationMetadataRouteKind = "sitemap" | "robots" | "manifest" | "llms" | "llms-full";
150
- declare namespace MetadataRoute {
151
- type SitemapChangeFrequency = "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
152
- interface SitemapEntry {
153
- url: string;
154
- lastModified?: string | Date;
155
- changeFrequency?: SitemapChangeFrequency;
156
- priority?: number;
157
- alternates?: {
158
- languages?: Record<string, string>;
159
- };
160
- }
161
- type Sitemap = SitemapEntry[];
162
- interface RobotsRule {
163
- userAgent: string | string[];
164
- allow?: string | string[];
165
- disallow?: string | string[];
166
- crawlDelay?: number;
167
- }
168
- interface Robots {
169
- rules: RobotsRule | RobotsRule[];
170
- sitemap?: string | string[];
171
- host?: string;
172
- }
173
- interface ManifestIcon {
174
- src: string;
175
- sizes?: string;
176
- type?: string;
177
- purpose?: string;
178
- }
179
- interface Manifest {
180
- name?: string;
181
- short_name?: string;
182
- description?: string;
183
- id?: string;
184
- start_url?: string;
185
- scope?: string;
186
- display?: "fullscreen" | "standalone" | "minimal-ui" | "browser" | string;
187
- orientation?: string;
188
- background_color?: string;
189
- theme_color?: string;
190
- lang?: string;
191
- dir?: "ltr" | "rtl" | "auto";
192
- categories?: string[];
193
- icons?: ManifestIcon[];
194
- [key: string]: unknown;
195
- }
196
- /**
197
- * The object an `llms.ts` metadata route returns, rendered as llms.txt. An
198
- * `llms.ts` can also return the complete file as a string, or a `Response`.
199
- */
200
- type LlmsTxt = FarmLlmsTxt;
201
- type LlmsTxtSection = FarmLlmsTxtSection;
202
- type LlmsTxtLink = FarmLlmsTxtLink;
203
- /** A static page of the app, usable directly as an llms.txt link. */
204
- type LlmsTxtPage = FarmLlmsTxtPage;
205
- /** What an `llms.ts` default-export function receives. */
206
- interface LlmsTxtContext extends MetadataRouteContext {
207
- /** The app's static pages, linking to their Markdown mirrors when exposed. */
208
- pages: LlmsTxtPage[];
209
- /** The llms.txt that `agent.llmsTxt` would serve, to extend instead of replace. */
210
- defaults: LlmsTxt;
211
- }
212
- /**
213
- * What an `llms-full.ts` default-export function receives. Returning an
214
- * `LlmsTxt` object inlines each same-origin link's Markdown; returning a string
215
- * serves it as the complete file.
216
- */
217
- interface LlmsFullTxtContext extends LlmsTxtContext {
218
- /** A page's Markdown mirror, read without the request's cookies; `null` if unavailable. */
219
- markdown(url: string): Promise<string | null>;
220
- }
221
- }
222
- interface MetadataRouteContext {
223
- request: Request;
224
- params: Record<string, string>;
225
- searchParams: URLSearchParams;
226
- /** The concrete route-segment path that owns the metadata file. */
227
- path: string;
186
+ /**
187
+ * Typed, validated plugin options.
188
+ *
189
+ * A plugin factory takes one options object. Describing it with a Standard
190
+ * Schema (Zod, Valibot, ArkType, ...) gives the call site its input type for
191
+ * autocomplete, gives the plugin the parsed type with defaults applied, and
192
+ * rejects bad options while the config loads instead of deep inside a hook.
193
+ */
194
+ type MaybePromise$2<T> = T | Promise<T>;
195
+ type FarmPluginOptionsIssuePathSegment = PropertyKey | {
196
+ readonly key: PropertyKey;
197
+ };
198
+ interface FarmPluginOptionsIssue {
199
+ readonly message: string;
200
+ readonly path?: ReadonlyArray<FarmPluginOptionsIssuePathSegment> | undefined;
228
201
  }
229
- interface FarmMetadataRouteModule {
230
- revalidate?: number | false;
202
+ type FarmPluginOptionsResult<TOutput> = {
203
+ readonly value: TOutput;
204
+ readonly issues?: undefined;
205
+ } | {
206
+ readonly issues: ReadonlyArray<FarmPluginOptionsIssue>;
207
+ };
208
+ /** The part of the Standard Schema interface plugin options need. */
209
+ interface FarmPluginOptionsSchema<TInput = unknown, TOutput = TInput> {
210
+ readonly "~standard": {
211
+ readonly version: 1;
212
+ readonly vendor: string;
213
+ readonly validate: (value: unknown) => MaybePromise$2<FarmPluginOptionsResult<TOutput>>;
214
+ readonly types?: {
215
+ readonly input: TInput;
216
+ readonly output: TOutput;
217
+ } | undefined;
218
+ };
231
219
  }
232
- interface FarmMetadataRouteResponseOptions {
233
- method?: string;
234
- /** The request being answered, so llms.txt reads can be reported as agent traffic. */
235
- request?: Request;
220
+ /** What the app passes to the plugin factory. */
221
+ type InferPluginOptionsInput<TSchema> = TSchema extends FarmPluginOptionsSchema<infer TInput, any> ? TInput : never;
222
+ /** What the plugin receives, after parsing and defaults. */
223
+ type InferPluginOptionsOutput<TSchema> = TSchema extends FarmPluginOptionsSchema<any, infer TOutput> ? TOutput : never;
224
+ /**
225
+ * The factory a plugin exports. Options can be left out when every option is
226
+ * optional, so `plugin()` and `plugin({})` mean the same thing.
227
+ */
228
+ type FarmPluginFactory<TInput, TPlugin> = {} extends TInput ? (options?: TInput) => TPlugin : (options: TInput) => TPlugin;
229
+ /** Thrown when an app passes options its plugin's schema rejects. */
230
+ declare class FarmPluginOptionsError extends TypeError {
231
+ readonly issues: ReadonlyArray<FarmPluginOptionsIssue>;
232
+ constructor(issues: ReadonlyArray<FarmPluginOptionsIssue>);
236
233
  }
237
- /** @internal */
238
- declare function createFarmMetadataRouteResponse(kind: ApplicationMetadataRouteKind, value: unknown, routeModule?: FarmMetadataRouteModule, options?: FarmMetadataRouteResponseOptions): Response;
239
234
 
240
- type FarmCrawlerPolicy = "allow" | "block";
241
- interface FarmAgentCrawlers {
242
- /** Set to `false` to stop serving the generated robots.txt while keeping these options. */
243
- enabled?: boolean;
244
- /**
245
- * AI search and user-triggered agents such as OAI-SearchBot, Claude-SearchBot,
246
- * and PerplexityBot. Left unset, they follow the `User-agent: *` rules.
247
- */
248
- search?: FarmCrawlerPolicy;
249
- /**
250
- * AI training crawlers such as GPTBot, ClaudeBot, Google-Extended, and CCBot.
251
- * Left unset, they follow the `User-agent: *` rules.
252
- */
253
- training?: FarmCrawlerPolicy;
254
- /**
255
- * More robots.txt groups, written after the generated ones. Crawlers combine
256
- * groups that name the same agent. A rule for `*` replaces the default
257
- * `User-agent: *` / `Allow: /` group.
258
- */
259
- rules?: MetadataRoute.RobotsRule[];
260
- /**
261
- * Absolute sitemap URLs. Defaults to the app's `sitemap.ts` route, resolved
262
- * against the root layout's `metadataBase`; with neither, no `Sitemap:` line.
263
- */
264
- sitemap?: string | string[];
235
+ interface ResolvedClientCacheAdapterEntry {
236
+ /** Absolute adapter module path with forward slashes, ready for codegen. */
237
+ importPath: string;
238
+ options: {
239
+ version?: string;
240
+ flushDelayMs?: number;
241
+ };
265
242
  }
266
- interface ResolvedFarmAgentCrawlers {
267
- enabled: boolean;
268
- search?: FarmCrawlerPolicy;
269
- training?: FarmCrawlerPolicy;
270
- rules: MetadataRoute.RobotsRule[];
271
- sitemap?: string[];
243
+ interface ClientCachePersistenceEntryCode {
244
+ imports: string;
245
+ init: string;
272
246
  }
273
- interface FarmAgentRobotsOptions {
274
- crawlers: ResolvedFarmAgentCrawlers;
275
- /** The app's root sitemap route, such as `/sitemap.xml`, when it has one. */
276
- sitemapPath?: string;
277
- /** The root layout's `metadataBase`, which makes the sitemap URL absolute. */
278
- metadataBase?: unknown;
279
- basePath?: string;
247
+ /**
248
+ * Resolve `cache.client.adapter` from configuration to an absolute module
249
+ * path for the generated client entries. Fails the build with an actionable
250
+ * error when the option is set but the module cannot be found.
251
+ */
252
+ declare function resolveFarmClientCacheAdapterEntry(root: string, cache: FarmCacheUserConfig | undefined): ResolvedClientCacheAdapterEntry | undefined;
253
+ /**
254
+ * Code fragments for the generated client entries: an import of the user's
255
+ * adapter module and an init call that runs before hydration starts. Empty
256
+ * strings when persistence is not configured, so entries stay unchanged.
257
+ */
258
+ declare function generateClientCachePersistenceCode(entry: ResolvedClientCacheAdapterEntry | undefined): ClientCachePersistenceEntryCode;
259
+
260
+ type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
261
+ interface FarmRedirectSignal {
262
+ url: string;
263
+ status: FarmRedirectStatus;
280
264
  }
281
- /** The robots.txt `agent.crawlers` serves. */
282
- declare function createFarmAgentRobots(options: FarmAgentRobotsOptions): MetadataRoute.Robots;
265
+ declare function redirect(url: string, status?: FarmRedirectStatus): never;
266
+ declare function permanentRedirect(url: string): never;
267
+ declare function notFound(): never;
268
+ declare function isFarmRedirectError(error: unknown): boolean;
269
+ declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
270
+ declare function isFarmNotFoundError(error: unknown): boolean;
283
271
 
284
272
  /**
285
- * Agent-readiness configuration: opt-in primitives that make a Farm site easier
286
- * for AI agents and crawlers to discover, resolve, and use. Off by default so
287
- * sites that do not want agent exposure (internal tools, private dashboards) are
288
- * unaffected.
273
+ * Integration auth routes accept ordinary form posts, which browsers send
274
+ * cross-site without a CORS preflight. Without an origin check, a third-party
275
+ * page can submit credentials to an app's own sign-in route and plant an
276
+ * attacker-controlled session in the victim's browser (login CSRF), or drive a
277
+ * forced sign-out. This mirrors the server-action origin contract so both
278
+ * entry points reject the same requests.
289
279
  */
290
-
291
- /** schema.org JSON-LD emitted in the document head to identify the site. */
292
- interface FarmAgentJsonLd {
280
+ type IntegrationOriginRejection = "missing-origin" | "opaque-origin" | "invalid-origin" | "cross-site";
281
+ type IntegrationOriginResult = {
282
+ ok: true;
283
+ } | {
284
+ ok: false;
285
+ reason: IntegrationOriginRejection;
286
+ };
287
+ interface IntegrationOriginPolicy {
288
+ /** Extra trusted origins, using the `serverActions.allowedOrigins` pattern syntax. */
289
+ allowedOrigins?: readonly string[];
293
290
  /**
294
- * schema.org `@type`. Common values: `"Organization"` for a company or
295
- * project, `"SoftwareApplication"` for a product, `"WebSite"`, `"Person"`.
291
+ * Whether a request carrying no origin metadata at all must be rejected.
296
292
  *
297
- * @default "Organization"
293
+ * Form posts always carry an Origin header in supported browsers, so
294
+ * state-changing POSTs default to rejecting (`true`). Top-level GET
295
+ * navigations legitimately arrive with no Origin and no Referer — a typed
296
+ * URL or a bookmark — so GET callers pass `false` to avoid breaking them.
298
297
  */
299
- type?: string;
300
- /** Entity name. Defaults to the site's Open Graph site name or page title. */
301
- name?: string;
302
- /** Canonical URL for the entity. Defaults to the configured `metadataBase`. */
303
- url?: string;
304
- /** Short description. Defaults to the page/site metadata description. */
305
- description?: string;
306
- /** Logo URL. */
307
- logo?: string;
308
- /** URLs that also represent this entity (social profiles, repos) — schema.org `sameAs`. */
309
- sameAs?: string[];
310
- /** Additional schema.org properties merged into the emitted object. */
311
- properties?: Record<string, unknown>;
312
- }
313
- interface FarmAgentUserConfig {
314
- /**
315
- * Emit schema.org JSON-LD in the document head so agents and crawlers can
316
- * resolve the site's identity. `true` emits an `Organization` built from the
317
- * site's metadata; an object customizes the type and fields.
318
- *
319
- * @default false
320
- */
321
- jsonLd?: boolean | FarmAgentJsonLd;
322
- /**
323
- * On a preview deployment, send `X-Robots-Tag: noindex, nofollow` with every
324
- * response from Farm's server. Previews are detected from `FARM_PREVIEW`,
325
- * `VERCEL_ENV=preview`, Netlify's deploy-preview and branch-deploy contexts,
326
- * and Render pull request previews. Production is unaffected.
327
- *
328
- * @default false
329
- */
330
- noindexPreviews?: boolean;
331
- /**
332
- * Serve `/llms.txt` (https://llmstxt.org): a Markdown index of the app's static
333
- * pages, linking to their Markdown mirrors. `true` builds it from page metadata;
334
- * an object sets the title, summary, details, and which routes to list. A
335
- * `src/app/llms.ts` metadata route replaces the generated file.
336
- *
337
- * @default false
338
- */
339
- llmsTxt?: boolean | FarmLlmsTxtUserConfig;
340
- /**
341
- * Serve a generated `/robots.txt` that allows or blocks AI search agents
342
- * (`search`) and AI training crawlers (`training`), plus your own `rules`.
343
- * `true` serves only `User-agent: *` / `Allow: /` and the sitemap. A
344
- * `public/robots.txt` or `src/app/robots.ts` replaces the generated file.
345
- *
346
- * @default false
347
- */
348
- crawlers?: boolean | FarmAgentCrawlers;
349
- /**
350
- * Serve `/.well-known/api-catalog` (RFC 9727): a Linkset listing the app's
351
- * OpenAPI description and reference (when `openapi` is enabled) and its MCP
352
- * endpoint (when the top-level `mcp` is enabled), so agents can find them
353
- * from the origin alone.
354
- *
355
- * @default false
356
- */
357
- apiCatalog?: boolean;
358
- }
359
- interface ResolvedFarmAgentConfig {
360
- jsonLd: FarmAgentJsonLd | false;
361
- noindexPreviews: boolean;
362
- llmsTxt: ResolvedFarmLlmsTxtConfig;
363
- crawlers: ResolvedFarmAgentCrawlers;
364
- apiCatalog: boolean;
365
- }
366
-
367
- /**
368
- * Integration auth routes accept ordinary form posts, which browsers send
369
- * cross-site without a CORS preflight. Without an origin check, a third-party
370
- * page can submit credentials to an app's own sign-in route and plant an
371
- * attacker-controlled session in the victim's browser (login CSRF), or drive a
372
- * forced sign-out. This mirrors the server-action origin contract so both
373
- * entry points reject the same requests.
374
- */
375
- type IntegrationOriginRejection = "missing-origin" | "opaque-origin" | "invalid-origin" | "cross-site";
376
- type IntegrationOriginResult = {
377
- ok: true;
378
- } | {
379
- ok: false;
380
- reason: IntegrationOriginRejection;
381
- };
382
- interface IntegrationOriginPolicy {
383
- /** Extra trusted origins, using the `serverActions.allowedOrigins` pattern syntax. */
384
- allowedOrigins?: readonly string[];
385
- /**
386
- * Whether a request carrying no origin metadata at all must be rejected.
387
- *
388
- * Form posts always carry an Origin header in supported browsers, so
389
- * state-changing POSTs default to rejecting (`true`). Top-level GET
390
- * navigations legitimately arrive with no Origin and no Referer — a typed
391
- * URL or a bookmark — so GET callers pass `false` to avoid breaking them.
392
- */
393
- requireOriginMetadata?: boolean;
298
+ requireOriginMetadata?: boolean;
394
299
  }
395
300
  /**
396
301
  * Resolve configured origin patterns once, at integration construction, so an
@@ -455,499 +360,755 @@ declare function resolveIntegrationOrmRuntimeClient<TClient = unknown>(options:
455
360
  declare function farmIntegrationSchemaToOrmSchema(schema: FarmIntegrationSchema): Promise<FarmIntegrationOrmSchema>;
456
361
  type IntegrationOrmModelNames<TSchema extends FarmIntegrationOrmSchema> = keyof SchemaModels<TSchema> & string;
457
362
 
458
- /** @internal The environment registry is owned and closed by Vite. */
459
- interface FarmDevModuleServer {
460
- environments: Record<string, unknown>;
363
+ type FarmIntegrationCategory = "auth" | "payment" | "monitoring" | "logging" | (string & {});
364
+ /** @deprecated Use FarmIntegrationCategory instead. */
365
+ type FarmIntegrationSlot = FarmIntegrationCategory;
366
+ type FarmIntegrationRouteParamValue = string | string[];
367
+ type FarmIntegrationRouteParams = Record<string, FarmIntegrationRouteParamValue>;
368
+ type FarmIntegrationRouteMethod = FarmIntegrationAPIMethod | Lowercase<FarmIntegrationAPIMethod> | "ALL" | "all";
369
+ type FarmIntegrationRouteInputSource = "body" | "query";
370
+ type MaybePromise$1<T> = T | Promise<T>;
371
+ type FarmIntegrationValidationPathSegment = PropertyKey | {
372
+ readonly key: PropertyKey;
373
+ };
374
+ interface FarmIntegrationRouteInput<TBody = unknown, TQuery = unknown> {
375
+ body?: TBody;
376
+ query?: TQuery;
461
377
  }
462
- /** @internal Distinguishes an unsupported runtime from a module evaluation error. */
463
- declare class FarmDevEnvironmentError extends Error {
378
+ interface FarmIntegrationValidationIssue {
379
+ source: FarmIntegrationRouteInputSource;
380
+ path?: readonly (string | number)[];
381
+ code?: string;
382
+ message: string;
464
383
  }
465
- /** @internal Load in the selected environment without sharing SSR/RSC module state. */
466
- declare function loadFarmDevModule<T = Record<string, any>>(server: FarmDevModuleServer, id: string, environmentName?: "ssr" | "rsc"): Promise<T>;
467
-
468
- type ResolvedSchemaField = FarmSchemaField & {
469
- name: string;
384
+ interface FarmIntegrationValidationErrorLike {
385
+ issues?: readonly {
386
+ path?: readonly FarmIntegrationValidationPathSegment[];
387
+ code?: string;
388
+ message?: string;
389
+ }[];
390
+ message?: string;
391
+ }
392
+ type FarmIntegrationValidationResult<TValue> = {
393
+ success: true;
394
+ data: TValue;
395
+ } | {
396
+ success: false;
397
+ error: FarmIntegrationValidationErrorLike;
470
398
  };
471
- type ResolvedSchemaModel = Omit<FarmSchemaModel, "fields"> & {
472
- name: string;
473
- fields: Record<string, ResolvedSchemaField>;
399
+ type FarmIntegrationStandardValidationResult<TValue> = {
400
+ value: TValue;
401
+ } | {
402
+ issues: readonly {
403
+ path?: readonly FarmIntegrationValidationPathSegment[];
404
+ code?: string;
405
+ message: string;
406
+ }[];
474
407
  };
408
+ interface FarmIntegrationInputSchema<TValue = unknown> {
409
+ _output?: TValue;
410
+ parse?(value: unknown): MaybePromise$1<TValue>;
411
+ safeParse?(value: unknown): MaybePromise$1<FarmIntegrationValidationResult<TValue>>;
412
+ safeParseAsync?(value: unknown): Promise<FarmIntegrationValidationResult<TValue>>;
413
+ "~standard"?: {
414
+ validate(value: unknown): MaybePromise$1<FarmIntegrationStandardValidationResult<TValue>>;
415
+ types?: {
416
+ output: TValue;
417
+ };
418
+ };
419
+ }
420
+ interface FarmIntegrationRouteInputSchemas<TBody = unknown, TQuery = unknown> {
421
+ body?: FarmIntegrationInputSchema<TBody>;
422
+ query?: FarmIntegrationInputSchema<TQuery>;
423
+ }
424
+ /** @deprecated Use `FarmRequestStore` and access it through `ctx.req`. */
425
+ type FarmIntegrationRequestContextStore = FarmRequestStore;
426
+ declare const FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
475
427
  /**
476
- * Resolve a schema's extensions, overrides, and name mappings.
477
- *
478
- * Table and column names fall back to the schema's own keys, which is what the
479
- * runtime ORM uses. Any other default would generate artifacts describing
480
- * tables the app cannot actually read.
428
+ * Request-context key under which an integration middleware can hand
429
+ * `Set-Cookie` values to the runtime when it returns `void` (i.e. lets the
430
+ * request continue to the downstream route/page handler). The runtime reads
431
+ * this key back after a `void` middleware return and forwards the cookies onto
432
+ * the response it ultimately sends, so a server-side session refresh (or any
433
+ * other cookie rotation) reaches the browser instead of being dropped.
481
434
  */
482
- declare function resolveSchemaModels(ownerKey: string, schema: FarmSchema): Record<string, ResolvedSchemaModel>;
483
-
484
- type FarmSqlDialect = "postgres" | "mysql" | "sqlite";
485
- type CollectedSchemaModel = {
486
- /** Namespace that owns the model: an integration key or a plugin name. */
487
- ownerKey: string;
488
- modelKey: string;
489
- modelName: string;
490
- exportName: string;
491
- prismaModelName: string;
492
- model: ResolvedSchemaModel;
493
- /**
494
- * Real table and column for references to models this owner describes but
495
- * does not create (external, or outside its `models`), keyed by field. Only
496
- * shown in comments: Farm never creates a foreign key to them.
497
- */
498
- referenceTargets?: Record<string, {
499
- table: string;
500
- column: string;
501
- }>;
502
- /**
503
- * References to tables other owners create that may carry a real foreign
504
- * key, keyed by field. Set by migrate after checking the database; only a
505
- * table created now gets one inline.
506
- */
507
- foreignKeys?: Record<string, {
508
- table: string;
509
- column: string;
510
- onDelete: NonNullable<FarmSchemaReference["onDelete"]>;
511
- }>;
512
- };
513
- /** `table.column` a field's reference points at, using real names when known. */
514
- declare function describeSchemaReference(model: CollectedSchemaModel, fieldKey: string): string;
435
+ declare const FARM_INTEGRATION_SET_COOKIES_KEY = "farm:integration:set-cookies";
515
436
  /**
516
- * Flatten owners' schemas into one list, rejecting two models that would
517
- * resolve to the same table.
518
- *
519
- * `only` narrows an owner to the models it actually controls; an owner handed a
520
- * schema it shares with the rest of the app should not claim all of it.
437
+ * Forward `Set-Cookie` values from an integration middleware that returns
438
+ * `void` (the authenticated/passthrough branch) to the runtime, so they are
439
+ * merged onto the response the runtime sends for the matched route. This is
440
+ * the passthrough counterpart to appending `Set-Cookie` to a `Response` the
441
+ * middleware returns directly (e.g. a failure redirect): both paths can rotate
442
+ * auth cookies, and both must be able to reach the browser.
521
443
  */
522
- declare function collectSchemaModels(entries: ReadonlyArray<readonly [string, FarmSchema, (readonly string[])?]>): CollectedSchemaModel[];
523
- type FarmSqlStatement = {
524
- kind: "table" | "index" | "column";
525
- /** The object this statement creates, for drift reporting. */
526
- target: string;
527
- sql: string;
528
- };
444
+ declare function forwardIntegrationSetCookies(context: Pick<FarmIntegrationHandlerContext, "req">, cookies: string[]): void;
445
+ type FarmIntegrationRouteDb<TSchema extends FarmIntegrationSchema | undefined> = InferFarmIntegrationOrmClient<TSchema>;
446
+ interface FarmIntegrationRouteStorageArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
447
+ getClient(): Promise<unknown | undefined>;
448
+ getOrm(): Promise<FarmIntegrationRouteDb<TSchema>>;
449
+ }
450
+ interface FarmIntegrationRouteArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
451
+ db: FarmIntegrationRouteDb<TSchema>;
452
+ getDb(): Promise<FarmIntegrationRouteDb<TSchema>>;
453
+ storage: FarmIntegrationRouteStorageArgs<TSchema>;
454
+ }
455
+ interface FarmIntegrationConfigContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
456
+ key: string;
457
+ integration: FarmIntegration<TSchema, any>;
458
+ appConfig: FarmPluginContext["config"];
459
+ /** Alias for appConfig. */
460
+ config: FarmPluginContext["config"];
461
+ args: FarmIntegrationRouteArgs<TSchema>;
462
+ env: Record<string, string | undefined>;
463
+ isDev: boolean;
464
+ isProd: boolean;
465
+ }
466
+ interface FarmIntegrationConfigDefinition<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
467
+ schema?: FarmIntegrationInputSchema<TConfig>;
468
+ env?: Record<string, string | readonly string[]>;
469
+ defaults?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise$1<Partial<TConfig>>);
470
+ input?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise$1<Partial<TConfig>>);
471
+ resolve?(context: FarmIntegrationConfigContext<TSchema>): MaybePromise$1<TConfig | Partial<TConfig> | undefined>;
472
+ }
473
+ type FarmIntegrationConfigInput<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationInputSchema<TConfig> | FarmIntegrationConfigDefinition<TConfig, TSchema>;
474
+ type FarmIntegrationLifecycleLogLevel = "info" | "warn" | "error";
475
+ interface FarmIntegrationLifecycleLogger {
476
+ info(message: string, meta?: Record<string, unknown>): void;
477
+ warn(message: string, meta?: Record<string, unknown>): void;
478
+ error(message: string, meta?: Record<string, unknown>): void;
479
+ }
480
+ interface FarmIntegrationLifecycleContext<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationConfigContext<TSchema> {
481
+ integration: FarmIntegration<TSchema, TConfig>;
482
+ integrationConfig: TConfig;
483
+ log: FarmIntegrationLifecycleLogger;
484
+ reason?: string;
485
+ cleanup(callback?: () => MaybePromise$1<void>): Promise<void>;
486
+ }
487
+ type FarmIntegrationLifecycleHook<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationLifecycleContext<TConfig, TSchema>) => MaybePromise$1<void>;
529
488
  /**
530
- * Emit create statements for a set of models.
531
- *
532
- * Everything here is derivable from the schema: nothing is inferred from a live
533
- * database, so the output is stable and reviewable before it is applied.
489
+ * Small per-call integration metadata. Values received over HTTP are
490
+ * client-controlled and should be validated before authorization decisions.
534
491
  */
535
- declare function generateSqlStatements(models: readonly CollectedSchemaModel[], dialect: FarmSqlDialect): FarmSqlStatement[];
536
- /** Render models as a standalone `.sql` file. */
537
- declare function renderSqlSchemaFile(models: readonly CollectedSchemaModel[], dialect: FarmSqlDialect): string;
538
- declare function getSqlColumnType(field: ResolvedSchemaField, dialect: FarmSqlDialect): "BOOLEAN" | "INTEGER" | "DOUBLE PRECISION" | "TIMESTAMPTZ" | "JSONB" | "TEXT" | "INT" | "DOUBLE" | "DATETIME" | "JSON" | "VARCHAR(255)" | "REAL";
539
- declare function getSqlDefaultExpression(field: ResolvedSchemaField, dialect: FarmSqlDialect): string | null;
540
- declare function isNullableField(field: ResolvedSchemaField): boolean;
541
- declare function quoteSqlIdentifier(dialect: FarmSqlDialect, value: string): string;
542
- declare function toSnakeCase(value: string): string;
543
- declare function toPascalCase(value: string): string;
544
- declare function toCamelCase(value: string): string;
545
- declare function escapeSqlString(value: string, dialect?: FarmSqlDialect): string;
546
-
547
- /**
548
- * An ordered change a plugin release makes to its own tables that Farm will
549
- * not infer: a rename looks exactly like a removal plus an addition. Each step
550
- * runs once per database, in the order listed.
551
- *
552
- * Names are the plugin's own: `model` and `to` are keys in the current
553
- * schema, so the app's renames apply; `from` is the old name in the database.
554
- */
555
- type FarmSchemaMigrationStep = {
556
- id: string;
557
- description?: string;
558
- } & ({
559
- renameColumn: {
560
- model: string;
561
- from: string;
562
- to: string;
492
+ type FarmIntegrationData = Record<string, unknown>;
493
+ interface FarmIntegrationHandlerContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
494
+ request: Request;
495
+ requestId: string;
496
+ url: URL;
497
+ pathname: string;
498
+ method: string;
499
+ params: FarmIntegrationRouteParams;
500
+ input: FarmIntegrationRouteInput<TBody, TQuery>;
501
+ args: FarmIntegrationRouteArgs<TSchema>;
502
+ data: FarmIntegrationData;
503
+ integration: {
504
+ category: FarmIntegrationCategory;
505
+ /** @deprecated Use category instead. */
506
+ slot: FarmIntegrationCategory;
507
+ type: string;
508
+ instance: unknown;
563
509
  };
564
- } | {
565
- renameTable: {
566
- from: string;
567
- to: string;
510
+ route: {
511
+ kind: "route" | "middleware";
512
+ path: string;
513
+ methods: readonly string[];
568
514
  };
515
+ req: FarmRequestStore;
516
+ /** @deprecated Use `req` instead. */
517
+ requestContext: FarmRequestStore;
518
+ config: FarmPluginContext["config"];
519
+ isDev: boolean;
520
+ isProd: boolean;
569
521
  }
570
- /**
571
- * Deletes data, so it runs only with `--allow-destructive`, and only on a
572
- * column or table Farm recorded this plugin creating.
573
- */
574
- | {
575
- dropColumn: {
576
- model: string;
577
- column: string;
578
- };
579
- } | {
580
- dropTable: {
581
- table: string;
582
- };
583
- } | {
584
- /** Per dialect; a dialect without SQL cannot run the step. */
585
- sql: Partial<Record<FarmSqlDialect, string | readonly string[]>>;
586
- /**
587
- * Custom SQL runs after this release's new tables and columns exist, so
588
- * a backfill can fill them. Set `before` to run it with the renames.
589
- */
590
- before?: boolean;
591
- });
592
-
593
- /**
594
- * Typed, validated plugin options.
595
- *
596
- * A plugin factory takes one options object. Describing it with a Standard
597
- * Schema (Zod, Valibot, ArkType, ...) gives the call site its input type for
598
- * autocomplete, gives the plugin the parsed type with defaults applied, and
599
- * rejects bad options while the config loads instead of deep inside a hook.
600
- */
601
- type MaybePromise$2<T> = T | Promise<T>;
602
- type FarmPluginOptionsIssuePathSegment = PropertyKey | {
603
- readonly key: PropertyKey;
604
- };
605
- interface FarmPluginOptionsIssue {
606
- readonly message: string;
607
- readonly path?: ReadonlyArray<FarmPluginOptionsIssuePathSegment> | undefined;
522
+ interface FarmIntegrationRouteHookContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationHandlerContext<TBody, TQuery, TSchema> {
523
+ response?: Response;
608
524
  }
609
- type FarmPluginOptionsResult<TOutput> = {
610
- readonly value: TOutput;
611
- readonly issues?: undefined;
612
- } | {
613
- readonly issues: ReadonlyArray<FarmPluginOptionsIssue>;
614
- };
615
- /** The part of the Standard Schema interface plugin options need. */
616
- interface FarmPluginOptionsSchema<TInput = unknown, TOutput = TInput> {
617
- readonly "~standard": {
618
- readonly version: 1;
619
- readonly vendor: string;
620
- readonly validate: (value: unknown) => MaybePromise$2<FarmPluginOptionsResult<TOutput>>;
621
- readonly types?: {
622
- readonly input: TInput;
623
- readonly output: TOutput;
624
- } | undefined;
625
- };
525
+ type FarmIntegrationRouteHook<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
526
+ bivarianceHack(request: Request, context: FarmIntegrationRouteHookContext<TBody, TQuery, TSchema>): Promise<Response | void> | Response | void;
527
+ }["bivarianceHack"];
528
+ interface FarmIntegrationRoute<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
529
+ path: string;
530
+ method?: FarmIntegrationRouteMethod;
531
+ methods?: readonly FarmIntegrationRouteMethod[];
532
+ middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
533
+ before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
534
+ after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
535
+ rawBody?: boolean;
536
+ bodyFormat?: FarmIntegrationAPIBodyFormat;
537
+ body?: FarmIntegrationInputSchema<TBody>;
538
+ query?: FarmIntegrationInputSchema<TQuery>;
539
+ input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
540
+ handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
626
541
  }
627
- /** What the app passes to the plugin factory. */
628
- type InferPluginOptionsInput<TSchema> = TSchema extends FarmPluginOptionsSchema<infer TInput, any> ? TInput : never;
629
- /** What the plugin receives, after parsing and defaults. */
630
- type InferPluginOptionsOutput<TSchema> = TSchema extends FarmPluginOptionsSchema<any, infer TOutput> ? TOutput : never;
631
- /**
632
- * The factory a plugin exports. Options can be left out when every option is
633
- * optional, so `plugin()` and `plugin({})` mean the same thing.
634
- */
635
- type FarmPluginFactory<TInput, TPlugin> = {} extends TInput ? (options?: TInput) => TPlugin : (options: TInput) => TPlugin;
636
- /** Thrown when an app passes options its plugin's schema rejects. */
637
- declare class FarmPluginOptionsError extends TypeError {
638
- readonly issues: ReadonlyArray<FarmPluginOptionsIssue>;
639
- constructor(issues: ReadonlyArray<FarmPluginOptionsIssue>);
542
+ interface FarmTypedIntegrationRoute<TPath extends string = string, TBody = never, TQuery = never, TResponse = unknown, TServer extends boolean = false, TMethod extends FarmIntegrationAPIMethod = FarmIntegrationAPIMethod, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoute<TBody, TQuery, TSchema> {
543
+ path: TPath;
544
+ method: TMethod;
545
+ __operation: FarmIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>;
640
546
  }
641
-
642
- interface ResolvedClientCacheAdapterEntry {
643
- /** Absolute adapter module path with forward slashes, ready for codegen. */
644
- importPath: string;
645
- options: {
646
- version?: string;
647
- flushDelayMs?: number;
648
- };
547
+ interface FarmIntegrationRouteMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
548
+ handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
649
549
  }
650
- interface ClientCachePersistenceEntryCode {
651
- imports: string;
652
- init: string;
550
+ interface FarmIntegrationMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
551
+ matcher?: string | string[];
552
+ handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
653
553
  }
654
- /**
655
- * Resolve `cache.client.adapter` from configuration to an absolute module
656
- * path for the generated client entries. Fails the build with an actionable
657
- * error when the option is set but the module cannot be found.
658
- */
659
- declare function resolveFarmClientCacheAdapterEntry(root: string, cache: FarmCacheUserConfig | undefined): ResolvedClientCacheAdapterEntry | undefined;
660
- /**
661
- * Code fragments for the generated client entries: an import of the user's
662
- * adapter module and an init call that runs before hydration starts. Empty
663
- * strings when persistence is not configured, so entries stay unchanged.
664
- */
665
- declare function generateClientCachePersistenceCode(entry: ResolvedClientCacheAdapterEntry | undefined): ClientCachePersistenceEntryCode;
666
-
667
- type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
668
- interface FarmRedirectSignal {
669
- url: string;
670
- status: FarmRedirectStatus;
554
+ interface FarmIntegrationProviderProps {
555
+ children: ReactNode;
671
556
  }
672
- declare function redirect(url: string, status?: FarmRedirectStatus): never;
673
- declare function permanentRedirect(url: string): never;
674
- declare function notFound(): never;
675
- declare function isFarmRedirectError(error: unknown): boolean;
676
- declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
677
- declare function isFarmNotFoundError(error: unknown): boolean;
678
-
679
- /**
680
- * Farm.js Middleware System
681
- *
682
- * Type definitions for the middleware system
683
- */
684
-
685
- /**
686
- * Next function type for middleware chain
687
- */
688
- type MiddlewareResult = void | Response;
689
- type NextFunction = () => Promise<MiddlewareResult>;
690
- type MiddlewareStoreKey<TValues extends Record<string, any>> = Extract<keyof TValues, string>;
691
- /**
692
- * A typed view over the request-scoped maps used by middleware.
693
- */
694
- interface ReadonlyMiddlewareStore<TValues extends Record<string, any> = Record<string, any>> {
695
- readonly size: number;
696
- get<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): TValues[TKey] | undefined;
697
- has<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
698
- entries(): IterableIterator<[MiddlewareStoreKey<TValues>, TValues[MiddlewareStoreKey<TValues>]]>;
699
- keys(): IterableIterator<MiddlewareStoreKey<TValues>>;
700
- values(): IterableIterator<TValues[MiddlewareStoreKey<TValues>]>;
701
- forEach(callback: (value: TValues[MiddlewareStoreKey<TValues>], key: MiddlewareStoreKey<TValues>, store: ReadonlyMiddlewareStore<TValues>) => void, thisArg?: any): void;
702
- [Symbol.iterator](): IterableIterator<[
703
- MiddlewareStoreKey<TValues>,
704
- TValues[MiddlewareStoreKey<TValues>]
705
- ]>;
557
+ interface FarmIntegrationProviderComponentReference {
558
+ /** Client-safe module specifier using `@/`, a path relative to the app root, or a package. */
559
+ module: string;
560
+ /** Named export to use. Defaults to the module's default export. */
561
+ export?: string;
706
562
  }
707
- interface MiddlewareStore<TValues extends Record<string, any> = Record<string, any>> extends ReadonlyMiddlewareStore<TValues> {
708
- clear(): void;
709
- delete<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
710
- set<TKey extends MiddlewareStoreKey<TValues>>(key: TKey, value: TValues[TKey]): this;
563
+ interface FarmIntegrationProvider {
564
+ name: string;
565
+ type: string;
566
+ props?: Record<string, unknown>;
567
+ /**
568
+ * The provider can be instantiated independently around each isolated
569
+ * client root without relying on context or state owned by the route root.
570
+ * Providers are treated as route-wide unless they explicitly opt in.
571
+ */
572
+ supportsIsolatedHydration?: boolean;
573
+ component?: ComponentType<FarmIntegrationProviderProps> | FarmIntegrationProviderComponentReference;
711
574
  }
712
- /**
713
- * Middleware function signature
714
- */
715
- type MiddlewareFunction = (ctx: MiddlewareContext, next: NextFunction) => MiddlewareResult | Promise<MiddlewareResult>;
716
- /**
717
- * Context passed to a named, request-first middleware export.
718
- * `locals` and the get/set helpers stay on the server. `data` can be exposed
719
- * through page props and should contain only serializable, client-safe values.
720
- */
721
- interface RequestMiddlewareContext<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> {
722
- readonly url: URL;
723
- readonly pathname: string;
724
- readonly searchParams: URLSearchParams;
725
- readonly method: string;
726
- readonly params: Record<string, string>;
727
- readonly route: string;
728
- readonly locals: MiddlewareStore<TLocals>;
729
- readonly data: MiddlewareStore<TData>;
730
- readonly headers: Map<string, string>;
731
- readonly cookies: CookieJar;
732
- get<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): TLocals[TKey] | undefined;
733
- has<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
734
- set<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey, value: TLocals[TKey]): void;
735
- delete<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
736
- redirect(url: string, status?: number): void;
737
- rewrite(url: string): void;
738
- json(data: any, status?: number): void;
739
- text(content: string, status?: number): void;
740
- html(content: string, status?: number): void;
575
+ interface FarmIntegrationDocumentNavigation {
576
+ matcher: string | readonly string[];
741
577
  }
742
- type RequestMiddleware<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> = (request: Request, context: RequestMiddlewareContext<TLocals, TData>) => MiddlewareResult | Promise<MiddlewareResult>;
743
- /**
744
- * Cookie options
745
- */
746
- interface CookieOptions {
747
- maxAge?: number;
748
- expires?: Date;
749
- path?: string;
750
- domain?: string;
751
- secure?: boolean;
752
- httpOnly?: boolean;
753
- sameSite?: "strict" | "lax" | "none";
754
- }
755
- /**
756
- * Cookie management interface
757
- */
758
- interface CookieJar {
759
- get(name: string): string | undefined;
760
- set(name: string, value: string, options?: CookieOptions): void;
761
- /**
762
- * Remove a cookie. Pass the `path`/`domain` it was set with; a tombstone only
763
- * matches a cookie with the same scope.
764
- */
765
- delete(name: string, options?: CookieOptions): void;
766
- getAll(): Record<string, string>;
767
- }
768
- interface RateLimitIncrementResult {
769
- count: number;
770
- /** Unix epoch timestamp in milliseconds when the fixed window resets. */
771
- resetAt: number;
772
- }
773
- interface RateLimitStorage {
774
- /** Atomically increment a key and create or retain its fixed expiry window. */
775
- increment(key: string, windowMs: number): Promise<RateLimitIncrementResult> | RateLimitIncrementResult;
776
- /** Optional inspection support used by getRateLimitStatus(). */
777
- get?(key: string): Promise<RateLimitIncrementResult | null> | RateLimitIncrementResult | null;
778
- }
779
- interface MemoryRateLimitStorageOptions {
780
- /** Maximum number of active keys retained by this process. */
781
- maxEntries?: number;
782
- }
783
- interface RateLimitConfig {
784
- requests: number;
785
- window: string;
786
- keyGenerator?: (ctx: MiddlewareContext) => string;
787
- onLimit?: (ctx: MiddlewareContext) => void | Response | Promise<void | Response>;
788
- storage?: RateLimitStorage;
789
- }
790
- interface RateLimitStatus {
791
- requests: number;
792
- limit: number;
793
- remaining: number;
794
- resetIn: number | null;
795
- resetAt: Date | null;
796
- isLimited: boolean;
578
+ /** @deprecated Use `FarmSchemaFieldType`. */
579
+ type FarmIntegrationSchemaFieldType = FarmSchemaFieldType;
580
+ /** @deprecated Use `FarmSchemaReference`. */
581
+ type FarmIntegrationSchemaReference = FarmSchemaReference;
582
+ /** @deprecated Use `FarmSchemaField`. */
583
+ type FarmIntegrationSchemaField = FarmSchemaField;
584
+ /** @deprecated Use `FarmSchemaConstraint`. */
585
+ type FarmIntegrationSchemaConstraint = FarmSchemaConstraint;
586
+ /** @deprecated Use `FarmSchemaModel`. */
587
+ type FarmIntegrationSchemaModel = FarmSchemaModel;
588
+ /** @deprecated Use `FarmSchemaModelExtension`. */
589
+ type FarmIntegrationSchemaModelExtension = FarmSchemaModelExtension;
590
+ /** @deprecated Use `FarmSchemaModelOverride`. */
591
+ type FarmIntegrationSchemaModelOverride = FarmSchemaModelOverride;
592
+ /** @deprecated Use `FarmSchema`. */
593
+ type FarmIntegrationSchema = FarmSchema;
594
+ /** @deprecated Use `defineSchema`. This is an exact alias, not a wrapper. */
595
+ declare const defineIntegrationSchema: typeof defineSchema;
596
+ type FarmIntegrationLogPhase = "registered" | "validate" | "setup" | "ready" | "dispose" | "request:start" | "request:end" | "request:error";
597
+ interface FarmIntegrationLogEvent {
598
+ category: FarmIntegrationCategory;
599
+ /** @deprecated Use category instead. */
600
+ slot: FarmIntegrationCategory;
601
+ type: string;
602
+ phase: FarmIntegrationLogPhase;
603
+ route?: {
604
+ kind: "route" | "middleware";
605
+ path: string;
606
+ methods: readonly string[];
607
+ };
608
+ requestId?: string;
609
+ request?: Request;
610
+ response?: Response;
611
+ error?: unknown;
612
+ durationMs?: number;
613
+ level?: FarmIntegrationLifecycleLogLevel;
614
+ message?: string;
615
+ meta?: Record<string, unknown>;
616
+ context: Map<string, unknown>;
797
617
  }
798
- /**
799
- * Middleware configuration
800
- */
801
- type MiddlewareMatcher = string | RegExp | ((ctx: MiddlewareContext) => boolean);
802
- interface MiddlewareConfig$1 {
803
- matcher?: MiddlewareMatcher | MiddlewareMatcher[];
804
- exclude?: (string | RegExp)[];
805
- runtime?: "nodejs" | "edge";
618
+ type FarmIntegrationLogger = (event: FarmIntegrationLogEvent) => void | Promise<void>;
619
+ interface FarmIntegrationPluginOwner {
620
+ key: string;
621
+ category: FarmIntegrationCategory;
622
+ type: string;
623
+ source: "lifecycle" | "contribution";
624
+ serverRuntime: boolean;
806
625
  }
807
- interface MiddlewareConfigEntry extends MiddlewareConfig$1 {
808
- handler?: MiddlewareFunction;
809
- handlers?: MiddlewareFunction[];
626
+ /** A normal plugin or an integration-bound plugin compatible with the shared instance. */
627
+ type FarmIntegrationContributedPlugin<TInstance = unknown> = FarmPlugin<any, any, any, any, unknown, false> | FarmPlugin<any, any, any, any, TInstance, true>;
628
+ interface FarmIntegration<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> {
629
+ readonly kind: "farm-integration";
630
+ category: FarmIntegrationCategory;
631
+ /** @deprecated Use category instead. */
632
+ slot?: FarmIntegrationCategory;
633
+ type: string;
634
+ instance: TInstance;
635
+ /** Set to false when a platform adapter owns this integration's production routes. */
636
+ serverRuntime?: boolean;
637
+ api?: FarmIntegrationAPI;
638
+ schema?: TSchema;
639
+ config?: FarmIntegrationConfigInput<TConfig, TSchema>;
640
+ validate?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
641
+ setup?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
642
+ ready?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
643
+ dispose?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
644
+ log?: FarmIntegrationLogger;
645
+ routes?: readonly FarmIntegrationRoute<any, any, TSchema>[];
646
+ endpoints?: FarmIntegrationEndpoints<TSchema>;
647
+ middleware?: readonly FarmIntegrationMiddleware<TSchema>[];
648
+ providers?: readonly FarmIntegrationProvider[];
649
+ documentNavigations?: readonly FarmIntegrationDocumentNavigation[];
650
+ /** Additional Farm plugins owned and configured by this integration. */
651
+ plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
810
652
  }
811
- type FarmMiddlewareConfig = MiddlewareConfig$1 | MiddlewareConfigEntry | MiddlewareConfigEntry[];
812
- /**
813
- * Middleware context - the main object passed to middleware functions
814
- */
815
- interface MiddlewareContext {
816
- request: IncomingMessage;
817
- response: ServerResponse;
818
- url: URL;
819
- pathname: string;
820
- searchParams: URLSearchParams;
821
- method: string;
822
- params: Record<string, string>;
823
- route: string;
824
- parent?: {
825
- data: Map<string, any>;
826
- locals?: Map<string, any>;
827
- headers: Record<string, string>;
828
- };
829
- vite: {
830
- isDev: boolean;
831
- hmr: boolean;
832
- server?: ViteDevServer;
833
- };
834
- data: Map<string, any>;
835
- locals: Map<string, any>;
836
- headers: Map<string, string>;
837
- cookies: CookieJar;
838
- _handled: boolean;
839
- _redirectUrl?: string;
840
- _rewriteUrl?: string;
841
- redirect(url: string, status?: number): void;
842
- rewrite(url: string): void;
843
- json(data: any, status?: number): void;
844
- text(content: string, status?: number): void;
845
- html(content: string, status?: number): void;
653
+ type FarmIntegrationsUserConfig = Record<string, FarmIntegration<any, any, any> | undefined>;
654
+ /** @internal Identifies plugins owned by platform-managed integrations. */
655
+ declare function getFarmIntegrationPluginServerRuntime(plugin: FarmPlugin): boolean | undefined;
656
+ /** Returns the integration that contributed a normalized plugin, when applicable. */
657
+ declare function getFarmIntegrationPluginOwner(plugin: FarmPlugin): Readonly<FarmIntegrationPluginOwner> | undefined;
658
+ type IntegrationRouteBuilderOptions<TBody, TQuery, TServer extends boolean, TSchema extends FarmIntegrationSchema | undefined> = {
659
+ middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
660
+ before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
661
+ after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
662
+ rawBody?: boolean;
663
+ headers?: Record<string, string>;
664
+ credentials?: RequestCredentials;
665
+ bodyFormat?: FarmIntegrationAPIBodyFormat;
666
+ responseFormat?: FarmIntegrationAPIResponseFormat;
667
+ isServer?: TServer;
668
+ body?: FarmIntegrationInputSchema<TBody>;
669
+ query?: FarmIntegrationInputSchema<TQuery>;
670
+ input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
671
+ handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
672
+ };
673
+ interface FarmIntegrationRouteFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
674
+ get<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "GET", TSchema>;
675
+ post<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "POST", TSchema>;
676
+ query<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "QUERY", TSchema>;
677
+ put<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PUT", TSchema>;
678
+ patch<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PATCH", TSchema>;
679
+ delete<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "DELETE", TSchema>;
680
+ options<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "OPTIONS", TSchema>;
681
+ head<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "HEAD", TSchema>;
846
682
  }
847
- /**
848
- * Middleware chain interface
849
- */
850
- interface MiddlewareChain {
851
- use(fn: MiddlewareFunction): MiddlewareChain;
852
- /**
853
- * Conditionally run middleware based on a condition.
854
- * Supports boolean values or functions that evaluate to boolean.
855
- *
856
- * @example
857
- * .when(true, (ctx, next) => { ... }) // Always run
858
- * .when((ctx) => ctx.data.get('flag'), (ctx, next) => { ... }) // Conditional
859
- */
860
- when(condition: boolean | ((ctx: MiddlewareContext) => boolean), fn: MiddlewareFunction | ((chain: MiddlewareChain) => void)): MiddlewareChain;
861
- rateLimit(config: RateLimitConfig): MiddlewareChain;
862
- redirect(source: string, destination: string, permanent?: boolean): MiddlewareChain;
863
- /**
864
- * Rewrite the current route to a new destination.
865
- * In route-specific middleware, this rewrites the middleware's route.
866
- *
867
- * @param destination - The destination path to rewrite to
868
- * @param condition - Optional boolean or function that evaluates to boolean. If false, rewrite is skipped.
869
- *
870
- * @example
871
- * // In /contact/middleware.ts
872
- * .rewrite('/about') // Always rewrites /contact to /about
873
- * .rewrite('/about', true) // Always rewrites
874
- * .rewrite('/about', false) // Never rewrites
875
- * .rewrite('/about', (ctx) => ctx.data.get('shouldRewrite')) // Conditional rewrite
876
- */
877
- rewrite(destination: string, condition?: boolean | ((ctx: MiddlewareContext) => boolean)): MiddlewareChain;
878
- build(): {
879
- handlers: MiddlewareFunction[];
880
- config?: MiddlewareConfig$1;
881
- };
683
+ interface FarmIntegrationRoutesFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
684
+ route: FarmIntegrationRouteFactory<TSchema>;
685
+ integrationRoute: FarmIntegrationRouteFactory<TSchema>;
882
686
  }
883
- /**
884
- * Middleware module export
885
- */
886
- interface MiddlewareModule {
887
- default?: MiddlewareChain | MiddlewareFunction;
888
- middleware?: RequestMiddleware;
889
- config?: MiddlewareConfig$1;
687
+ type FarmIntegrationRoutesFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationRoutesFactoryContext<TSchema>) => readonly FarmIntegrationRoute<any, any, TSchema>[];
688
+ type FarmIntegrationEndpointValue<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationRoute<any, any, TSchema> | readonly FarmIntegrationEndpointValue<TSchema>[] | {
689
+ readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
690
+ };
691
+ type FarmIntegrationEndpoints<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
692
+ readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
693
+ };
694
+ interface FarmIntegrationEndpointsFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoutesFactoryContext<TSchema> {
695
+ endpoint: FarmIntegrationRouteFactory<TSchema>;
890
696
  }
891
-
892
- type FarmMdxComponent = React__default.ComponentType<any> | keyof React__default.JSX.IntrinsicElements;
893
- type FarmMdxComponents = Record<string, FarmMdxComponent>;
894
- interface FarmMdxUserConfig {
895
- /**
896
- * Component map or module path that exports `components` or a default component map.
897
- * Relative paths resolve from the project root.
898
- */
899
- components?: string | FarmMdxComponents;
697
+ type FarmIntegrationEndpointsFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationEndpointsFactoryContext<TSchema>) => FarmIntegrationEndpoints<TSchema>;
698
+ declare function createIntegrationRoute<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined>(_schema?: TSchema): FarmIntegrationRouteFactory<TSchema>;
699
+ declare const integrationRoute: FarmIntegrationRouteFactory<undefined>;
700
+ type RegisteredIntegrationRuntime = {
701
+ integration: FarmIntegration;
702
+ config: FarmPluginContext["config"];
703
+ isDev: boolean;
704
+ isProd: boolean;
705
+ };
706
+ type FarmIntegrationRoutesInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = readonly FarmIntegrationRoute<any, any, TSchema>[] | FarmIntegrationRoutesFactory<TSchema>;
707
+ type FarmIntegrationEndpointsInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationEndpoints<TSchema> | FarmIntegrationEndpointsFactory<TSchema>;
708
+ type FarmIntegrationInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> = Omit<FarmIntegration<TSchema, TConfig, TInstance>, "kind" | "category" | "slot" | "instance" | "config" | "routes" | "endpoints" | "plugins"> & {
709
+ instance: TInstance;
710
+ config?: FarmIntegrationConfigInput<TConfig, TSchema>;
711
+ routes?: FarmIntegrationRoutesInput<TSchema>;
712
+ endpoints?: FarmIntegrationEndpointsInput<TSchema>;
713
+ plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
714
+ } & ({
715
+ category: FarmIntegrationCategory;
716
+ slot?: FarmIntegrationCategory;
717
+ } | {
718
+ category?: FarmIntegrationCategory;
719
+ slot: FarmIntegrationCategory;
720
+ });
721
+ type FarmIntegrationCategoryInput = {
722
+ category: FarmIntegrationCategory;
723
+ slot?: FarmIntegrationCategory;
724
+ } | {
725
+ category?: FarmIntegrationCategory;
726
+ slot: FarmIntegrationCategory;
727
+ };
728
+ type FarmIntegrationShapeForInference = FarmIntegrationCategoryInput & {
729
+ api?: FarmIntegrationAPI;
730
+ schema?: FarmIntegrationSchema;
731
+ config?: unknown;
732
+ routes?: unknown;
733
+ endpoints?: unknown;
734
+ };
735
+ type ExtractIntegrationSchema<TIntegration> = TIntegration extends {
736
+ schema: infer TSchema extends FarmIntegrationSchema;
737
+ } ? TSchema : undefined;
738
+ type ResolveIntegrationRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = TRoutes extends FarmIntegrationRoutesFactory<TSchema> ? ReturnType<TRoutes> : TRoutes;
739
+ type ResolveIntegrationEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = TEndpoints extends FarmIntegrationEndpointsFactory<TSchema> ? ReturnType<TEndpoints> : TEndpoints;
740
+ type ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = ResolveIntegrationRoutesInput<TRoutes, TSchema> extends readonly (infer TRoute)[] ? TRoute : never;
741
+ type ExtractIntegrationRoutesFromEndpointValue<TValue> = TValue extends FarmIntegrationRouteOperationCarrier<string, any> ? TValue : TValue extends readonly (infer TItem)[] ? ExtractIntegrationRoutesFromEndpointValue<TItem> : TValue extends object ? ExtractIntegrationRoutesFromEndpointValue<TValue[keyof TValue]> : never;
742
+ type ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = ExtractIntegrationRoutesFromEndpointValue<ResolveIntegrationEndpointsInput<TEndpoints, TSchema>>;
743
+ type ExtractIntegrationRouteUnion<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = (TIntegration extends {
744
+ routes: infer TRoutes;
745
+ } ? ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema> : never) | (TIntegration extends {
746
+ endpoints: infer TEndpoints;
747
+ } ? ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema> : never);
748
+ type ExtractDefinedIntegrationRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = [ExtractIntegrationRouteUnion<TIntegration, TSchema>] extends [never] ? undefined : readonly ExtractIntegrationRouteUnion<TIntegration, TSchema>[];
749
+ type ExtractDefinedIntegrationEndpoints<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = TIntegration extends {
750
+ endpoints: infer TEndpoints;
751
+ } ? ResolveIntegrationEndpointsInput<TEndpoints, TSchema> : undefined;
752
+ type ExtractIntegrationAPIRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = Extract<ExtractIntegrationRouteUnion<TIntegration, TSchema>, FarmIntegrationRouteOperationCarrier<string, any>>;
753
+ type ExtractIntegrationCategory<TIntegration extends FarmIntegrationCategoryInput> = TIntegration extends {
754
+ category: infer TCategory extends FarmIntegrationCategory;
755
+ } ? TCategory : TIntegration extends {
756
+ slot: infer TSlot extends FarmIntegrationCategory;
757
+ } ? TSlot : FarmIntegrationCategory;
758
+ type ExtractDerivedIntegrationAPI<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = TIntegration extends {
759
+ api: infer TAPI extends FarmIntegrationAPI;
760
+ } ? TAPI : [ExtractIntegrationAPIRoutes<TIntegration, TSchema>] extends [never] ? FarmIntegrationAPI | undefined : InferIntegrationAPIFromRoutes<readonly ExtractIntegrationAPIRoutes<TIntegration, TSchema>[]>;
761
+ type DefinedIntegration<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = Omit<TIntegration, "kind" | "category" | "slot" | "api" | "routes" | "endpoints"> & {
762
+ readonly kind: "farm-integration";
763
+ category: ExtractIntegrationCategory<TIntegration>;
764
+ slot: ExtractIntegrationCategory<TIntegration>;
765
+ routes: ExtractDefinedIntegrationRoutes<TIntegration, TSchema>;
766
+ endpoints: ExtractDefinedIntegrationEndpoints<TIntegration, TSchema>;
767
+ api: ExtractDerivedIntegrationAPI<TIntegration, TSchema>;
768
+ };
769
+ declare function defineIntegration<const TSchema extends FarmIntegrationSchema | undefined, const TConfig, TIntegration extends FarmIntegrationInput<TSchema, TConfig, any>>(integration: TIntegration & FarmIntegrationInput<TSchema, TConfig, NoInfer<TIntegration["instance"]>>): DefinedIntegration<TIntegration, TSchema>;
770
+ declare function isFarmIntegration(value: unknown): value is FarmIntegration;
771
+ declare function resolveIntegrationPlugins(integrations: FarmIntegrationsUserConfig | undefined): FarmPlugin[];
772
+ declare function getIntegrationProviders(integrations: FarmIntegrationsUserConfig | undefined): FarmIntegrationProvider[];
773
+ declare function isFarmIntegrationProviderComponentReference(value: FarmIntegrationProvider["component"]): value is FarmIntegrationProviderComponentReference;
774
+ declare function getIntegrationDocumentNavigationMatchers(integrations: FarmIntegrationsUserConfig | undefined): string[];
775
+ declare function getIntegrationSchemas(integrations: FarmIntegrationsUserConfig | undefined): Record<string, FarmIntegrationSchema>;
776
+ declare function getRegisteredIntegrationRuntime(key: string): RegisteredIntegrationRuntime | undefined;
777
+ declare function getRegisteredIntegrations(): Record<string, FarmIntegration>;
778
+ declare function getRegisteredIntegrationSchemas(): Record<string, FarmIntegrationSchema>;
779
+ declare function matchIntegrationRoute(integrations: FarmIntegrationsUserConfig | undefined, input: {
780
+ pathname: string;
781
+ method?: string;
782
+ }): {
783
+ key: string;
784
+ integration: FarmIntegration;
785
+ route: {
786
+ path: string;
787
+ methods: readonly string[];
788
+ };
789
+ params: FarmIntegrationRouteParams;
790
+ } | null;
791
+ declare function matchRegisteredIntegrationRoute(input: {
792
+ pathname: string;
793
+ method?: string;
794
+ }): {
795
+ key: string;
796
+ integration: FarmIntegration;
797
+ route: {
798
+ path: string;
799
+ methods: readonly string[];
800
+ };
801
+ params: FarmIntegrationRouteParams;
802
+ } | null;
803
+ declare function getRegisteredIntegrationAPIManifest(): Record<string, FarmIntegrationAPI>;
804
+ declare function dispatchIntegrationRequest(runtime: RegisteredIntegrationRuntime, request: Request, options?: {
805
+ currentRequest?: Request;
806
+ data?: FarmIntegrationData;
807
+ internal?: boolean;
900
808
  /**
901
- * Serve source-authored markdown pages at `/route.md`.
902
- * Enabled by default for `page.md` and `page.mdx`.
809
+ * Receives `Set-Cookie` values that a middleware forwarded via
810
+ * forwardIntegrationSetCookies while returning `void`, when this dispatch
811
+ * ends without a Response of its own. The request continues downstream, so
812
+ * the caller owns merging them onto whatever response it finally produces.
813
+ * Only called on the `null` return path: a Response returned from here has
814
+ * already had the forwarded cookies appended.
903
815
  */
904
- markdownRoutes?: boolean;
905
- /** Class name used for the wrapper around rendered markdown content. */
906
- className?: string;
907
- }
908
- interface FarmMdxResolvedConfig {
909
- components?: string | FarmMdxComponents;
910
- markdownRoutes: boolean;
911
- className: string;
912
- }
913
- declare function resolveMdxConfig(config: FarmMdxUserConfig | undefined): FarmMdxResolvedConfig;
816
+ onForwardedCookies?: (cookies: string[]) => void;
817
+ }): Promise<Response | null>;
914
818
  /**
915
- * The MDX components module a Markdown page renders from, as an absolute path. Undefined when
916
- * the components are an inline object, which cannot be analyzed for client components.
819
+ * Run every configured integration's middleware and routes for one request.
820
+ *
821
+ * Integration middleware is not route scoped: it is the mechanism behind
822
+ * `protectedRoutes` guards and provider session refresh, so it has to run for
823
+ * ordinary page and API requests that match no integration route at all. That
824
+ * makes this, not `matchIntegrationRoute`, the correct entry point for a
825
+ * runtime dispatching integrations for every request.
826
+ *
827
+ * The first integration that produces a Response short-circuits the rest.
828
+ * `Set-Cookie` values forwarded by middleware that returned `void` are
829
+ * collected: they ride the short-circuiting Response when there is one, and are
830
+ * otherwise handed back so the caller can merge them onto the downstream
831
+ * response.
917
832
  */
918
- declare function resolveFarmMdxComponentsModulePath(config: FarmMdxResolvedConfig | undefined, root: string): string | undefined;
833
+ declare function dispatchIntegrationRequests(integrations: FarmIntegrationsUserConfig | undefined, runtime: Omit<RegisteredIntegrationRuntime, "integration">, request: Request, options?: {
834
+ currentRequest?: Request;
835
+ }): Promise<{
836
+ response: Response | null;
837
+ setCookies: string[];
838
+ }>;
919
839
 
920
- type FarmRouteRuntime = "auto" | "node" | "edge";
921
- type FarmRouteRegions = "auto" | readonly string[];
922
- type FarmRouteMaxDuration = "auto" | number;
923
- /** Portable execution controls shared by file, programmatic, and config routes. */
924
- interface FarmRouteRuntimeConfig {
925
- runtime?: FarmRouteRuntime;
926
- regions?: FarmRouteRegions;
927
- maxDuration?: FarmRouteMaxDuration;
840
+ /**
841
+ * Farm.js Middleware System
842
+ *
843
+ * Type definitions for the middleware system
844
+ */
845
+
846
+ /**
847
+ * Next function type for middleware chain
848
+ */
849
+ type MiddlewareResult = void | Response;
850
+ type NextFunction = () => Promise<MiddlewareResult>;
851
+ type MiddlewareStoreKey<TValues extends Record<string, any>> = Extract<keyof TValues, string>;
852
+ /**
853
+ * A typed view over the request-scoped maps used by middleware.
854
+ */
855
+ interface ReadonlyMiddlewareStore<TValues extends Record<string, any> = Record<string, any>> {
856
+ readonly size: number;
857
+ get<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): TValues[TKey] | undefined;
858
+ has<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
859
+ entries(): IterableIterator<[MiddlewareStoreKey<TValues>, TValues[MiddlewareStoreKey<TValues>]]>;
860
+ keys(): IterableIterator<MiddlewareStoreKey<TValues>>;
861
+ values(): IterableIterator<TValues[MiddlewareStoreKey<TValues>]>;
862
+ forEach(callback: (value: TValues[MiddlewareStoreKey<TValues>], key: MiddlewareStoreKey<TValues>, store: ReadonlyMiddlewareStore<TValues>) => void, thisArg?: any): void;
863
+ [Symbol.iterator](): IterableIterator<[
864
+ MiddlewareStoreKey<TValues>,
865
+ TValues[MiddlewareStoreKey<TValues>]
866
+ ]>;
928
867
  }
929
- interface ResolvedFarmRouteRuntimeConfig {
930
- runtime: FarmRouteRuntime;
931
- regions?: string[];
932
- maxDuration?: number;
868
+ interface MiddlewareStore<TValues extends Record<string, any> = Record<string, any>> extends ReadonlyMiddlewareStore<TValues> {
869
+ clear(): void;
870
+ delete<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
871
+ set<TKey extends MiddlewareStoreKey<TValues>>(key: TKey, value: TValues[TKey]): this;
933
872
  }
934
- type FarmRouteRuntimeEntryKind = "page" | "api" | "metadata" | "rule";
935
- type FarmRouteRenderingMode = "static" | "dynamic";
936
- interface FarmRouteRuntimeManifestEntry extends ResolvedFarmRouteRuntimeConfig {
937
- kind: FarmRouteRuntimeEntryKind;
938
- pattern: string;
939
- rendering: FarmRouteRenderingMode;
940
- source?: string;
873
+ /**
874
+ * Middleware function signature
875
+ */
876
+ type MiddlewareFunction = (ctx: MiddlewareContext, next: NextFunction) => MiddlewareResult | Promise<MiddlewareResult>;
877
+ /**
878
+ * Context passed to a named, request-first middleware export.
879
+ * `locals` and the get/set helpers stay on the server. `data` can be exposed
880
+ * through page props and should contain only serializable, client-safe values.
881
+ */
882
+ interface RequestMiddlewareContext<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> {
883
+ readonly url: URL;
884
+ readonly pathname: string;
885
+ readonly searchParams: URLSearchParams;
886
+ readonly method: string;
887
+ readonly params: Record<string, string>;
888
+ readonly route: string;
889
+ readonly locals: MiddlewareStore<TLocals>;
890
+ readonly data: MiddlewareStore<TData>;
891
+ readonly headers: Map<string, string>;
892
+ readonly cookies: CookieJar;
893
+ get<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): TLocals[TKey] | undefined;
894
+ has<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
895
+ set<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey, value: TLocals[TKey]): void;
896
+ delete<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
897
+ redirect(url: string, status?: number): void;
898
+ rewrite(url: string): void;
899
+ json(data: any, status?: number): void;
900
+ text(content: string, status?: number): void;
901
+ html(content: string, status?: number): void;
941
902
  }
942
- interface FarmRouteRuntimeManifest {
943
- version: 1;
944
- routes: FarmRouteRuntimeManifestEntry[];
903
+ type RequestMiddleware<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> = (request: Request, context: RequestMiddlewareContext<TLocals, TData>) => MiddlewareResult | Promise<MiddlewareResult>;
904
+ /**
905
+ * Cookie options
906
+ */
907
+ interface CookieOptions {
908
+ maxAge?: number;
909
+ expires?: Date;
910
+ path?: string;
911
+ domain?: string;
912
+ secure?: boolean;
913
+ httpOnly?: boolean;
914
+ sameSite?: "strict" | "lax" | "none";
945
915
  }
946
- declare function normalizeFarmRouteRuntimeConfig(value: FarmRouteRuntimeConfig | null | undefined, source?: string): FarmRouteRuntimeConfig;
947
- /** Merge from lowest to highest precedence. Explicit "auto" values reset inherited hints. */
948
- declare function mergeFarmRouteRuntimeConfigs(...configs: Array<FarmRouteRuntimeConfig | null | undefined>): FarmRouteRuntimeConfig;
949
- declare function resolveFarmRouteRuntimeConfig(config: FarmRouteRuntimeConfig | null | undefined, source?: string): ResolvedFarmRouteRuntimeConfig;
950
- declare function hasFarmRouteRuntimeControls(config: FarmRouteRuntimeConfig | null | undefined): boolean;
916
+ /**
917
+ * Cookie management interface
918
+ */
919
+ interface CookieJar {
920
+ get(name: string): string | undefined;
921
+ set(name: string, value: string, options?: CookieOptions): void;
922
+ /**
923
+ * Remove a cookie. Pass the `path`/`domain` it was set with; a tombstone only
924
+ * matches a cookie with the same scope.
925
+ */
926
+ delete(name: string, options?: CookieOptions): void;
927
+ getAll(): Record<string, string>;
928
+ }
929
+ interface RateLimitIncrementResult {
930
+ count: number;
931
+ /** Unix epoch timestamp in milliseconds when the fixed window resets. */
932
+ resetAt: number;
933
+ }
934
+ interface RateLimitStorage {
935
+ /** Atomically increment a key and create or retain its fixed expiry window. */
936
+ increment(key: string, windowMs: number): Promise<RateLimitIncrementResult> | RateLimitIncrementResult;
937
+ /** Optional inspection support used by getRateLimitStatus(). */
938
+ get?(key: string): Promise<RateLimitIncrementResult | null> | RateLimitIncrementResult | null;
939
+ }
940
+ interface MemoryRateLimitStorageOptions {
941
+ /** Maximum number of active keys retained by this process. */
942
+ maxEntries?: number;
943
+ }
944
+ interface RateLimitConfig {
945
+ requests: number;
946
+ window: string;
947
+ keyGenerator?: (ctx: MiddlewareContext) => string;
948
+ onLimit?: (ctx: MiddlewareContext) => void | Response | Promise<void | Response>;
949
+ storage?: RateLimitStorage;
950
+ }
951
+ interface RateLimitStatus {
952
+ requests: number;
953
+ limit: number;
954
+ remaining: number;
955
+ resetIn: number | null;
956
+ resetAt: Date | null;
957
+ isLimited: boolean;
958
+ }
959
+ /**
960
+ * Middleware configuration
961
+ */
962
+ type MiddlewareMatcher = string | RegExp | ((ctx: MiddlewareContext) => boolean);
963
+ interface MiddlewareConfig$1 {
964
+ matcher?: MiddlewareMatcher | MiddlewareMatcher[];
965
+ exclude?: (string | RegExp)[];
966
+ runtime?: "nodejs" | "edge";
967
+ }
968
+ interface MiddlewareConfigEntry extends MiddlewareConfig$1 {
969
+ handler?: MiddlewareFunction;
970
+ handlers?: MiddlewareFunction[];
971
+ }
972
+ type FarmMiddlewareConfig = MiddlewareConfig$1 | MiddlewareConfigEntry | MiddlewareConfigEntry[];
973
+ /**
974
+ * Middleware context - the main object passed to middleware functions
975
+ */
976
+ interface MiddlewareContext {
977
+ request: IncomingMessage;
978
+ response: ServerResponse;
979
+ url: URL;
980
+ pathname: string;
981
+ searchParams: URLSearchParams;
982
+ method: string;
983
+ params: Record<string, string>;
984
+ route: string;
985
+ parent?: {
986
+ data: Map<string, any>;
987
+ locals?: Map<string, any>;
988
+ headers: Record<string, string>;
989
+ };
990
+ vite: {
991
+ isDev: boolean;
992
+ hmr: boolean;
993
+ server?: ViteDevServer;
994
+ };
995
+ data: Map<string, any>;
996
+ locals: Map<string, any>;
997
+ headers: Map<string, string>;
998
+ cookies: CookieJar;
999
+ _handled: boolean;
1000
+ _redirectUrl?: string;
1001
+ _rewriteUrl?: string;
1002
+ redirect(url: string, status?: number): void;
1003
+ rewrite(url: string): void;
1004
+ json(data: any, status?: number): void;
1005
+ text(content: string, status?: number): void;
1006
+ html(content: string, status?: number): void;
1007
+ }
1008
+ /**
1009
+ * Middleware chain interface
1010
+ */
1011
+ interface MiddlewareChain {
1012
+ use(fn: MiddlewareFunction): MiddlewareChain;
1013
+ /**
1014
+ * Conditionally run middleware based on a condition.
1015
+ * Supports boolean values or functions that evaluate to boolean.
1016
+ *
1017
+ * @example
1018
+ * .when(true, (ctx, next) => { ... }) // Always run
1019
+ * .when((ctx) => ctx.data.get('flag'), (ctx, next) => { ... }) // Conditional
1020
+ */
1021
+ when(condition: boolean | ((ctx: MiddlewareContext) => boolean), fn: MiddlewareFunction | ((chain: MiddlewareChain) => void)): MiddlewareChain;
1022
+ rateLimit(config: RateLimitConfig): MiddlewareChain;
1023
+ redirect(source: string, destination: string, permanent?: boolean): MiddlewareChain;
1024
+ /**
1025
+ * Rewrite the current route to a new destination.
1026
+ * In route-specific middleware, this rewrites the middleware's route.
1027
+ *
1028
+ * @param destination - The destination path to rewrite to
1029
+ * @param condition - Optional boolean or function that evaluates to boolean. If false, rewrite is skipped.
1030
+ *
1031
+ * @example
1032
+ * // In /contact/middleware.ts
1033
+ * .rewrite('/about') // Always rewrites /contact to /about
1034
+ * .rewrite('/about', true) // Always rewrites
1035
+ * .rewrite('/about', false) // Never rewrites
1036
+ * .rewrite('/about', (ctx) => ctx.data.get('shouldRewrite')) // Conditional rewrite
1037
+ */
1038
+ rewrite(destination: string, condition?: boolean | ((ctx: MiddlewareContext) => boolean)): MiddlewareChain;
1039
+ build(): {
1040
+ handlers: MiddlewareFunction[];
1041
+ config?: MiddlewareConfig$1;
1042
+ };
1043
+ }
1044
+ /**
1045
+ * Middleware module export
1046
+ */
1047
+ interface MiddlewareModule {
1048
+ default?: MiddlewareChain | MiddlewareFunction;
1049
+ middleware?: RequestMiddleware;
1050
+ config?: MiddlewareConfig$1;
1051
+ }
1052
+
1053
+ type FarmMdxComponent = React__default.ComponentType<any> | keyof React__default.JSX.IntrinsicElements;
1054
+ type FarmMdxComponents = Record<string, FarmMdxComponent>;
1055
+ interface FarmMdxUserConfig {
1056
+ /**
1057
+ * Component map or module path that exports `components` or a default component map.
1058
+ * Relative paths resolve from the project root.
1059
+ */
1060
+ components?: string | FarmMdxComponents;
1061
+ /**
1062
+ * Serve source-authored markdown pages at `/route.md`.
1063
+ * Enabled by default for `page.md` and `page.mdx`.
1064
+ */
1065
+ markdownRoutes?: boolean;
1066
+ /** Class name used for the wrapper around rendered markdown content. */
1067
+ className?: string;
1068
+ }
1069
+ interface FarmMdxResolvedConfig {
1070
+ components?: string | FarmMdxComponents;
1071
+ markdownRoutes: boolean;
1072
+ className: string;
1073
+ }
1074
+ declare function resolveMdxConfig(config: FarmMdxUserConfig | undefined): FarmMdxResolvedConfig;
1075
+ /**
1076
+ * The MDX components module a Markdown page renders from, as an absolute path. Undefined when
1077
+ * the components are an inline object, which cannot be analyzed for client components.
1078
+ */
1079
+ declare function resolveFarmMdxComponentsModulePath(config: FarmMdxResolvedConfig | undefined, root: string): string | undefined;
1080
+
1081
+ type FarmRouteRuntime = "auto" | "node" | "edge";
1082
+ type FarmRouteRegions = "auto" | readonly string[];
1083
+ type FarmRouteMaxDuration = "auto" | number;
1084
+ /** Portable execution controls shared by file, programmatic, and config routes. */
1085
+ interface FarmRouteRuntimeConfig {
1086
+ runtime?: FarmRouteRuntime;
1087
+ regions?: FarmRouteRegions;
1088
+ maxDuration?: FarmRouteMaxDuration;
1089
+ }
1090
+ interface ResolvedFarmRouteRuntimeConfig {
1091
+ runtime: FarmRouteRuntime;
1092
+ regions?: string[];
1093
+ maxDuration?: number;
1094
+ }
1095
+ type FarmRouteRuntimeEntryKind = "page" | "api" | "metadata" | "rule";
1096
+ type FarmRouteRenderingMode = "static" | "dynamic";
1097
+ interface FarmRouteRuntimeManifestEntry extends ResolvedFarmRouteRuntimeConfig {
1098
+ kind: FarmRouteRuntimeEntryKind;
1099
+ pattern: string;
1100
+ rendering: FarmRouteRenderingMode;
1101
+ source?: string;
1102
+ }
1103
+ interface FarmRouteRuntimeManifest {
1104
+ version: 1;
1105
+ routes: FarmRouteRuntimeManifestEntry[];
1106
+ }
1107
+ declare function normalizeFarmRouteRuntimeConfig(value: FarmRouteRuntimeConfig | null | undefined, source?: string): FarmRouteRuntimeConfig;
1108
+ /** Merge from lowest to highest precedence. Explicit "auto" values reset inherited hints. */
1109
+ declare function mergeFarmRouteRuntimeConfigs(...configs: Array<FarmRouteRuntimeConfig | null | undefined>): FarmRouteRuntimeConfig;
1110
+ declare function resolveFarmRouteRuntimeConfig(config: FarmRouteRuntimeConfig | null | undefined, source?: string): ResolvedFarmRouteRuntimeConfig;
1111
+ declare function hasFarmRouteRuntimeControls(config: FarmRouteRuntimeConfig | null | undefined): boolean;
951
1112
  declare function getFarmRouteRuntimeConfig(value: unknown): FarmRouteRuntimeConfig;
952
1113
  declare function createFarmRouteRuntimeKey(config: ResolvedFarmRouteRuntimeConfig): string;
953
1114
  /** Resolve matching route rules from broadest to most specific. */
@@ -1032,27 +1193,6 @@ declare function loadFarmConfigFile<TConfig = Record<string, any>>(configPath: s
1032
1193
  cacheRoot?: string;
1033
1194
  }): Promise<TConfig>;
1034
1195
 
1035
- declare const DEFAULT_FARM_DEVTOOLS_SHORTCUT = "mod+shift+.";
1036
- declare const FARM_DEVTOOLS_PATH = "/__farm/devtools";
1037
- declare const FARM_DEVTOOLS_LAUNCH_PARAM = "__farm_devtools";
1038
- /**
1039
- * Configuration for the built-in DevTools dashboard. The dashboard is deprecated in favor
1040
- * of the `@farm.js/devtools` plugin, which reuses this configuration for enablement and
1041
- * the keyboard shortcut. Both options keep working while the built-in UI remains available.
1042
- */
1043
- interface FarmDevtoolsConfig {
1044
- /** Enable the development-only DevTools UI and runtime endpoints. */
1045
- enabled?: boolean;
1046
- /** Keyboard shortcut used to toggle DevTools, or false to disable the shortcut. */
1047
- shortcut?: string | false;
1048
- }
1049
- type FarmDevtoolsUserConfig = boolean | FarmDevtoolsConfig;
1050
- interface ResolvedFarmDevtoolsConfig {
1051
- enabled: boolean;
1052
- shortcut: string | false;
1053
- }
1054
- declare function resolveFarmDevtoolsConfig(config: FarmDevtoolsUserConfig | ResolvedFarmDevtoolsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevtoolsConfig;
1055
-
1056
1196
  type FarmBuildActivityPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
1057
1197
  interface FarmDevIndicatorsConfig {
1058
1198
  /** Show build and HMR activity in the browser during development. */
@@ -1129,199 +1269,19 @@ interface ResolvedFarmAuthConfig {
1129
1269
  };
1130
1270
  }
1131
1271
 
1132
- /** A server-only endpoint reference. Config references must declare an explicit /api path. */
1133
- type FarmMCPEndpoint = TypedEndpoint<any, any, any, any, any, any, any, any>;
1134
- interface FarmMCPExecuteContext {
1135
- /** The principal returned by authorize, or { subject: "anonymous" } for public servers. */
1136
- readonly authorization: Readonly<FarmMCPAuthorization>;
1137
- readonly request: Request;
1138
- /** Observe this signal in cancellable work. Cancellation cannot undo side effects. */
1139
- readonly signal: AbortSignal;
1272
+ type FarmPreloadMode = "warn" | "enforce";
1273
+ interface FarmPreloadUserConfig {
1274
+ /** Report excess hints or remove the lower-priority hints. @default "enforce" */
1275
+ mode?: FarmPreloadMode;
1276
+ /** Maximum image preload hints per document. @default 1 */
1277
+ maxImages?: number;
1278
+ /** Maximum font preload hints per document. @default 2 */
1279
+ maxFonts?: number;
1140
1280
  }
1141
- /** A server-only tool with no corresponding HTTP endpoint. */
1142
- interface FarmMCPStandaloneTool<Schema extends RouteSchema = RouteSchema, Result = unknown, OutputSchema extends RouteSchema | undefined = undefined> extends EndpointMCPMetadata {
1143
- name: string;
1144
- /** Must describe an object and support input JSON Schema conversion. */
1145
- inputSchema: Schema;
1146
- /** Validate/transform returned data and advertise its output shape inside MCP's result envelope. */
1147
- outputSchema?: OutputSchema;
1148
- /** Return JSON-serializable data, not a Response or an MCP protocol envelope. */
1149
- execute(input: RouteSchemaOutput<Schema>, context: FarmMCPExecuteContext): OutputSchema extends RouteSchema ? NoInfer<RouteSchemaInput<OutputSchema>> | Promise<NoInfer<RouteSchemaInput<OutputSchema>>> : Result | Promise<Result>;
1150
- endpoint?: never;
1151
- }
1152
- /**
1153
- * A createServerFn or createServerQuery function with `mcp` metadata. It runs through its own
1154
- * input schema, middleware and output schema, with the MCP request as its request.
1155
- */
1156
- type FarmMCPServerFunction = ServerFn<any, any, any> | ServerQuery<any, any>;
1157
- /** Compose endpoint references, server functions and standalone tools. */
1158
- type FarmMCPToolDefinition = FarmMCPEndpoint | FarmMCPServerFunction | (EndpointMCPMetadata & {
1159
- endpoint: FarmMCPEndpoint;
1160
- execute?: never;
1161
- }) | FarmMCPStandaloneTool<any, unknown, any>;
1162
- /** Resolved tool identity, without handlers, validators, or a way to bypass authorization. */
1163
- type FarmMCPTool = Readonly<EndpointMCPMetadata> & {
1164
- readonly name: string;
1165
- } & ({
1166
- readonly kind: "endpoint";
1167
- readonly method: RouteMethod;
1168
- readonly path: string;
1169
- } | {
1170
- readonly kind: "standalone";
1171
- readonly method?: never;
1172
- readonly path?: never;
1173
- } | {
1174
- readonly kind: "serverFunction";
1175
- readonly method?: never;
1176
- readonly path?: never;
1177
- });
1178
- /** What a resource's `read` receives: the URI asked for, its template variables, and the caller. */
1179
- interface FarmMCPResourceContext extends FarmMCPExecuteContext {
1180
- readonly uri: URL;
1181
- /** Values matched by `uriTemplate`; empty for a fixed `uri`. */
1182
- readonly variables: Readonly<Record<string, string | string[]>>;
1183
- }
1184
- /**
1185
- * One piece of resource content: a string (sent as `mimeType`, or text/plain),
1186
- * text with its own type, JSON data, or binary data.
1187
- */
1188
- type FarmMCPResourceContent = string | {
1189
- text: string;
1190
- mimeType?: string;
1191
- } | {
1192
- json: unknown;
1193
- } | {
1194
- blob: Uint8Array | ArrayBuffer;
1195
- mimeType?: string;
1196
- };
1197
- /** One concrete URI a templated resource lists. */
1198
- interface FarmMCPResourceListing {
1199
- uri: string;
1200
- name?: string;
1201
- title?: string;
1202
- description?: string;
1203
- mimeType?: string;
1204
- }
1205
- /**
1206
- * A server-only MCP resource: read-only context an agent can load, at a fixed
1207
- * `uri` or at every URI matching an RFC 6570 `uriTemplate`.
1208
- */
1209
- interface FarmMCPResource {
1210
- /** Stable name, used in authorization and in `authorize`'s `resources` allowlist. */
1211
- name: string;
1212
- title?: string;
1213
- description?: string;
1214
- mimeType?: string;
1215
- /** A fixed absolute URI, such as `docs://handbook`. Set this or `uriTemplate`. */
1216
- uri?: string;
1217
- /** An RFC 6570 template, such as `notes://{id}`. Set this or `uri`. */
1218
- uriTemplate?: string;
1219
- /** For a template: the concrete resources to list. Omit to list none. */
1220
- list?(context: FarmMCPExecuteContext): readonly FarmMCPResourceListing[] | Promise<readonly FarmMCPResourceListing[]>;
1221
- /** Return the content, or null when the URI names nothing. */
1222
- read(context: FarmMCPResourceContext): FarmMCPResourceContent | readonly FarmMCPResourceContent[] | null | Promise<FarmMCPResourceContent | readonly FarmMCPResourceContent[] | null>;
1223
- }
1224
- interface FarmMCPPromptMessage {
1225
- role: "user" | "assistant";
1226
- text: string;
1227
- }
1228
- /**
1229
- * A server-only MCP prompt: a reusable message template a client offers its
1230
- * user. Arguments arrive as strings, as MCP sends them, and are validated by
1231
- * `arguments` before `render` runs.
1232
- */
1233
- interface FarmMCPPrompt<Schema extends RouteSchema | undefined = RouteSchema | undefined> {
1234
- /** Stable name: 1-128 letters, numbers, dots, underscores, or hyphens. */
1235
- name: string;
1236
- title?: string;
1237
- description?: string;
1238
- /** An object schema of string arguments. */
1239
- arguments?: Schema;
1240
- /** Return the prompt text, sent as one user message, or a list of messages. */
1241
- render(args: Schema extends RouteSchema ? RouteSchemaOutput<Schema> : Record<string, never>, context: FarmMCPExecuteContext): string | readonly FarmMCPPromptMessage[] | Promise<string | readonly FarmMCPPromptMessage[]>;
1242
- }
1243
- interface FarmMCPServer {
1244
- readonly name: string;
1245
- readonly version: string;
1246
- readonly path: `/api/${string}`;
1247
- }
1248
- interface FarmMCPAuthorization extends Record<string, unknown> {
1249
- /** Stable application principal identifier. Never written to a response or log by Farm. */
1250
- subject: string;
1251
- scopes?: string[];
1252
- /** Allowed tool names for this request. Omit for all configured tools; [] denies all tools. */
1253
- tools?: readonly string[];
1254
- /** Allowed resource names. Omit for all configured resources; [] denies all resources. */
1255
- resources?: readonly string[];
1256
- /** Allowed prompt names. Omit for all configured prompts; [] denies all prompts. */
1257
- prompts?: readonly string[];
1258
- }
1259
- interface FarmMCPAuthorizeContext {
1260
- request: Request;
1261
- /** Untrusted requested name for a tools/call; authorization runs separately for every JSON-RPC batch item. */
1262
- tool?: string;
1263
- /** Untrusted requested URI for a resources/read. */
1264
- resource?: string;
1265
- /** Untrusted requested name for a prompts/get. */
1266
- prompt?: string;
1267
- /** Complete configured catalog, before applying this caller's permissions. */
1268
- tools: readonly FarmMCPTool[];
1269
- /** Resolved transport identity, for policies shared by multiple MCP endpoints. */
1270
- server: FarmMCPServer;
1271
- }
1272
- interface FarmMCPConfig {
1273
- /** Set false to disable MCP without removing its configuration. @default true */
1274
- enabled?: boolean;
1275
- /** Canonical Farm API path for the Streamable HTTP endpoint. @default "/api/mcp" */
1276
- path?: `/api/${string}`;
1277
- /** MCP server identity. @default "farm-api" */
1278
- name?: string;
1279
- /** MCP server version. @default "1.0.0" */
1280
- version?: string;
1281
- /** Explicit endpoint/standalone tool allowlist. Omit to discover route-owned MCP metadata. */
1282
- tools?: readonly FarmMCPToolDefinition[];
1283
- /** Read-only context for agents, from `defineResource()`. */
1284
- resources?: readonly FarmMCPResource[];
1285
- /** Reusable prompt templates, from `definePrompt()`. */
1286
- prompts?: readonly FarmMCPPrompt<any>[];
1287
- /** Authorize every MCP request. Returning false responds with 401 before protocol handling. */
1288
- authorize?: (context: FarmMCPAuthorizeContext) => FarmMCPAuthorization | false | Promise<FarmMCPAuthorization | false>;
1289
- /** Deliberate escape hatch for public servers. Authentication is required by default. */
1290
- allowUnauthenticated?: boolean;
1291
- /**
1292
- * OAuth discovery for MCP clients. When set, a rejected request's 401 points at
1293
- * RFC 9728 Protected Resource Metadata naming these authorization servers, which
1294
- * Farm serves at `/.well-known/oauth-protected-resource/<endpoint path>`.
1295
- * Validating tokens stays in `authorize`.
1296
- */
1297
- oauth?: FarmMCPOAuthConfig;
1298
- }
1299
- interface FarmMCPOAuthConfig {
1300
- /** Issuer URLs of the OAuth authorization servers that issue tokens for this endpoint. */
1301
- authorizationServers: readonly string[];
1302
- /** Scopes clients may request, advertised as `scopes_supported` and in the 401 challenge. */
1303
- scopes?: readonly string[];
1304
- /** Human-readable name for consent screens. @default the MCP server name */
1305
- resourceName?: string;
1306
- }
1307
- type FarmMCPUserConfig = FarmMCPConfig | false;
1308
- interface ResolvedFarmMCPConfig extends FarmMCPConfig {
1309
- enabled: boolean;
1310
- }
1311
-
1312
- type FarmPreloadMode = "warn" | "enforce";
1313
- interface FarmPreloadUserConfig {
1314
- /** Report excess hints or remove the lower-priority hints. @default "enforce" */
1315
- mode?: FarmPreloadMode;
1316
- /** Maximum image preload hints per document. @default 1 */
1317
- maxImages?: number;
1318
- /** Maximum font preload hints per document. @default 2 */
1319
- maxFonts?: number;
1320
- }
1321
- interface ResolvedFarmPreloadConfig {
1322
- mode: FarmPreloadMode;
1323
- maxImages: number;
1324
- maxFonts: number;
1281
+ interface ResolvedFarmPreloadConfig {
1282
+ mode: FarmPreloadMode;
1283
+ maxImages: number;
1284
+ maxFonts: number;
1325
1285
  }
1326
1286
  interface FarmPerformanceConfig {
1327
1287
  preload?: FarmPreloadUserConfig;
@@ -1678,7 +1638,7 @@ declare function shouldEmitFarmClientRootHmr(renderer?: FarmRenderer): boolean;
1678
1638
  declare function farmPlugin(options?: FarmVitePluginOptions, initialPluginManager?: PluginManager): Plugin$1;
1679
1639
  declare function defineConfig(config?: FarmVitePluginOptions): Promise<UserConfig>;
1680
1640
 
1681
- type MaybePromise$1<T> = T | Promise<T>;
1641
+ type MaybePromise<T> = T | Promise<T>;
1682
1642
  /** @internal Marks a Node response whose intercepted end is awaiting response hooks. */
1683
1643
  declare const FARM_NODE_RESPONSE_END_PENDING: unique symbol;
1684
1644
  declare const FARM_PLUGIN_INTEGRATION_INSTANCE: unique symbol;
@@ -1845,7 +1805,7 @@ interface FarmPluginRuntimeEndpointEvent<TState = unknown, TIntegrationInstance
1845
1805
  interface FarmPluginRuntimeEndpoint<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1846
1806
  /** Exact application-relative pathname, before Farm's configured basePath. */
1847
1807
  path: string;
1848
- handler(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeEndpointEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<Response>;
1808
+ handler(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeEndpointEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<Response>;
1849
1809
  }
1850
1810
  interface FarmPluginRuntimeBeforeEvent<TState = unknown, TRequestContext extends object = Record<string, unknown>, TIntegrationInstance = unknown> extends FarmPluginRuntimeBaseEvent<TState, TIntegrationInstance> {
1851
1811
  ctx: Readonly<TRequestContext>;
@@ -1869,19 +1829,19 @@ type FarmPluginRuntimeEventFor<TEvent, TIntegrationInstance, TIntegrationBound e
1869
1829
  interface FarmPluginRuntimeHooks<TState = unknown, TRequestContext extends object = Record<string, unknown>, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1870
1830
  /** Exact request endpoints owned by this plugin. */
1871
1831
  endpoints?: readonly FarmPluginRuntimeEndpoint<TState, TIntegrationInstance, TIntegrationBound>[];
1872
- start?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeStartEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1873
- context?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeContextEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<TRequestContext>;
1874
- before?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeBeforeEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<Request | Response | void>;
1875
- after?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeAfterEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<Response | void>;
1876
- error?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeErrorEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1877
- close?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeCloseEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1832
+ start?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeStartEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1833
+ context?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeContextEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<TRequestContext>;
1834
+ before?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeBeforeEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<Request | Response | void>;
1835
+ after?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeAfterEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<Response | void>;
1836
+ error?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeErrorEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1837
+ close?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeCloseEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1878
1838
  }
1879
1839
  interface FarmPluginRuntimeRequestOptions {
1880
1840
  kind?: FarmPluginRuntimeKind;
1881
1841
  route?: FarmPluginRouteRuntimePayload;
1882
1842
  waitUntil?: (promise: Promise<unknown>) => void;
1883
1843
  }
1884
- type FarmPluginRuntimeRequestHandler = (request: Request) => MaybePromise$1<Response>;
1844
+ type FarmPluginRuntimeRequestHandler = (request: Request) => MaybePromise<Response>;
1885
1845
  interface FarmPluginRuntimeSession {
1886
1846
  request: Request;
1887
1847
  response?: Response;
@@ -1896,23 +1856,23 @@ type FarmPluginDiscoveredRoute = RouteDiscoveredPayload | ({
1896
1856
  kind: "api";
1897
1857
  } & APIRouteDiscoveredPayload);
1898
1858
  interface FarmPluginRouterHooks<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1899
- discovered?(route: FarmPluginDiscoveredRoute, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1900
- generated?(routes: RoutesGeneratedPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1901
- before?(route: RouteMatchPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1902
- after?(result: RouteMatchResultPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1859
+ discovered?(route: FarmPluginDiscoveredRoute, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1860
+ generated?(routes: RoutesGeneratedPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1861
+ before?(route: RouteMatchPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1862
+ after?(result: RouteMatchResultPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1903
1863
  }
1904
1864
  interface FarmPluginRenderHooks<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1905
- before?(render: RenderLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1906
- html?(html: string, render: RenderLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<string | void>;
1865
+ before?(render: RenderLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1866
+ html?(html: string, render: RenderLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<string | void>;
1907
1867
  }
1908
1868
  interface FarmPluginBuildHooks<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1909
- before?(bundle: BundleLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1910
- configure?(buildConfig: any, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<any>;
1911
- after?(result: BundleResultPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1869
+ before?(bundle: BundleLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1870
+ configure?(buildConfig: any, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<any>;
1871
+ after?(result: BundleResultPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1912
1872
  }
1913
1873
  interface FarmPluginDevHooks<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1914
- server?(viteServer: ViteDevServer, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1915
- update?(update: HMRUpdatePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1874
+ server?(viteServer: ViteDevServer, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1875
+ update?(update: HMRUpdatePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1916
1876
  }
1917
1877
  interface FarmPluginClientConfig<TState = unknown, TPublic = undefined> extends FarmClientPlugin<TState, TPublic> {
1918
1878
  /** Explicitly public, JSON-safe data embedded in the browser bundle. */
@@ -1925,9 +1885,9 @@ interface FarmPlugin<TState = any, TRequestContext extends object = Record<strin
1925
1885
  /** Declarative API routes, mounted through the normal dev and production API pipeline. */
1926
1886
  routes?: PluginRoutesFactory<TRoutes>;
1927
1887
  /** Transform Farm config before the development or production pipeline is created. */
1928
- configure?: (config: FarmConfig, context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>) => MaybePromise$1<FarmConfig | void>;
1888
+ configure?: (config: FarmConfig, context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>) => MaybePromise<FarmConfig | void>;
1929
1889
  /** Initialize private plugin state once for this plugin manager. */
1930
- setup?: (context: FarmPluginSetupContextFor<TIntegrationInstance, TIntegrationBound>) => MaybePromise$1<TState>;
1890
+ setup?: (context: FarmPluginSetupContextFor<TIntegrationInstance, TIntegrationBound>) => MaybePromise<TState>;
1931
1891
  runtime?: FarmPluginRuntimeHooks<TState, TRequestContext, TIntegrationInstance, TIntegrationBound>;
1932
1892
  router?: FarmPluginRouterHooks<TState, TIntegrationInstance, TIntegrationBound>;
1933
1893
  render?: FarmPluginRenderHooks<TState, TIntegrationInstance, TIntegrationBound>;
@@ -2087,9 +2047,9 @@ type FarmPluginDefinition<TState = undefined, TRequestContext extends object = R
2087
2047
  */
2088
2048
  options?: TSchema;
2089
2049
  /** Transform Farm config before the development or production pipeline is created. */
2090
- configure?: (config: FarmConfig, context: WithPluginOptions<FarmPluginContextFor<TIntegrationInstance, false>, TSchema>) => MaybePromise$1<FarmConfig | void>;
2050
+ configure?: (config: FarmConfig, context: WithPluginOptions<FarmPluginContextFor<TIntegrationInstance, false>, TSchema>) => MaybePromise<FarmConfig | void>;
2091
2051
  /** Initialize private plugin state once for this plugin manager. */
2092
- setup?: (context: WithPluginOptions<FarmPluginSetupContextFor<TIntegrationInstance, false>, TSchema>) => MaybePromise$1<TState>;
2052
+ setup?: (context: WithPluginOptions<FarmPluginSetupContextFor<TIntegrationInstance, false>, TSchema>) => MaybePromise<TState>;
2093
2053
  };
2094
2054
  type DefinedPlugin<TState, TRequestContext extends object, TClientState, TClientPublic, TIntegrationInstance, TRoutes extends PluginRoutes, TSchema> = FarmPlugin<ResolvedPluginState<TState, TSchema>, TRequestContext, TClientState, TClientPublic, TIntegrationInstance, false, TRoutes>;
2095
2055
  /** The database a plugin's `schema` tables live in, when not `storage.client`. */
@@ -2128,482 +2088,701 @@ declare namespace definePlugin {
2128
2088
  function forIntegration<TIntegrationInstance>(): <TState = undefined, TRequestContext extends object = Record<string, never>, TClientState = unknown, TClientPublic = undefined>(plugin: FarmPlugin<TState, TRequestContext, TClientState, TClientPublic, TIntegrationInstance, true>) => FarmPlugin<TState, TRequestContext, TClientState, TClientPublic, TIntegrationInstance, true>;
2129
2089
  }
2130
2090
 
2131
- type FarmIntegrationCategory = "auth" | "payment" | "monitoring" | "logging" | (string & {});
2132
- /** @deprecated Use FarmIntegrationCategory instead. */
2133
- type FarmIntegrationSlot = FarmIntegrationCategory;
2134
- type FarmIntegrationRouteParamValue = string | string[];
2135
- type FarmIntegrationRouteParams = Record<string, FarmIntegrationRouteParamValue>;
2136
- type FarmIntegrationRouteMethod = FarmIntegrationAPIMethod | Lowercase<FarmIntegrationAPIMethod> | "ALL" | "all";
2137
- type FarmIntegrationRouteInputSource = "body" | "query";
2138
- type MaybePromise<T> = T | Promise<T>;
2139
- type FarmIntegrationValidationPathSegment = PropertyKey | {
2140
- readonly key: PropertyKey;
2141
- };
2142
- interface FarmIntegrationRouteInput<TBody = unknown, TQuery = unknown> {
2143
- body?: TBody;
2144
- query?: TQuery;
2145
- }
2146
- interface FarmIntegrationValidationIssue {
2147
- source: FarmIntegrationRouteInputSource;
2148
- path?: readonly (string | number)[];
2149
- code?: string;
2150
- message: string;
2151
- }
2152
- interface FarmIntegrationValidationErrorLike {
2153
- issues?: readonly {
2154
- path?: readonly FarmIntegrationValidationPathSegment[];
2155
- code?: string;
2156
- message?: string;
2157
- }[];
2158
- message?: string;
2159
- }
2160
- type FarmIntegrationValidationResult<TValue> = {
2161
- success: true;
2162
- data: TValue;
2163
- } | {
2164
- success: false;
2165
- error: FarmIntegrationValidationErrorLike;
2166
- };
2167
- type FarmIntegrationStandardValidationResult<TValue> = {
2168
- value: TValue;
2169
- } | {
2170
- issues: readonly {
2171
- path?: readonly FarmIntegrationValidationPathSegment[];
2172
- code?: string;
2173
- message: string;
2174
- }[];
2175
- };
2176
- interface FarmIntegrationInputSchema<TValue = unknown> {
2177
- _output?: TValue;
2178
- parse?(value: unknown): MaybePromise<TValue>;
2179
- safeParse?(value: unknown): MaybePromise<FarmIntegrationValidationResult<TValue>>;
2180
- safeParseAsync?(value: unknown): Promise<FarmIntegrationValidationResult<TValue>>;
2181
- "~standard"?: {
2182
- validate(value: unknown): MaybePromise<FarmIntegrationStandardValidationResult<TValue>>;
2183
- types?: {
2184
- output: TValue;
2185
- };
2186
- };
2091
+ /** A server-only endpoint reference. Config references must declare an explicit /api path. */
2092
+ type FarmMCPEndpoint = TypedEndpoint<any, any, any, any, any, any, any, any>;
2093
+ interface FarmMCPExecuteContext {
2094
+ /** The principal returned by authorize, or { subject: "anonymous" } for public servers. */
2095
+ readonly authorization: Readonly<FarmMCPAuthorization>;
2096
+ readonly request: Request;
2097
+ /** Observe this signal in cancellable work. Cancellation cannot undo side effects. */
2098
+ readonly signal: AbortSignal;
2187
2099
  }
2188
- interface FarmIntegrationRouteInputSchemas<TBody = unknown, TQuery = unknown> {
2189
- body?: FarmIntegrationInputSchema<TBody>;
2190
- query?: FarmIntegrationInputSchema<TQuery>;
2100
+ /** A server-only tool with no corresponding HTTP endpoint. */
2101
+ interface FarmMCPStandaloneTool<Schema extends RouteSchema = RouteSchema, Result = unknown, OutputSchema extends RouteSchema | undefined = undefined> extends EndpointMCPMetadata {
2102
+ name: string;
2103
+ /** Must describe an object and support input JSON Schema conversion. */
2104
+ inputSchema: Schema;
2105
+ /** Validate/transform returned data and advertise its output shape inside MCP's result envelope. */
2106
+ outputSchema?: OutputSchema;
2107
+ /** Return JSON-serializable data, not a Response or an MCP protocol envelope. */
2108
+ execute(input: RouteSchemaOutput<Schema>, context: FarmMCPExecuteContext): OutputSchema extends RouteSchema ? NoInfer<RouteSchemaInput<OutputSchema>> | Promise<NoInfer<RouteSchemaInput<OutputSchema>>> : Result | Promise<Result>;
2109
+ endpoint?: never;
2191
2110
  }
2192
- /** @deprecated Use `FarmRequestStore` and access it through `ctx.req`. */
2193
- type FarmIntegrationRequestContextStore = FarmRequestStore;
2194
- declare const FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
2195
2111
  /**
2196
- * Request-context key under which an integration middleware can hand
2197
- * `Set-Cookie` values to the runtime when it returns `void` (i.e. lets the
2198
- * request continue to the downstream route/page handler). The runtime reads
2199
- * this key back after a `void` middleware return and forwards the cookies onto
2200
- * the response it ultimately sends, so a server-side session refresh (or any
2201
- * other cookie rotation) reaches the browser instead of being dropped.
2112
+ * A createServerFn or createServerQuery function with `mcp` metadata. It runs through its own
2113
+ * input schema, middleware and output schema, with the MCP request as its request.
2202
2114
  */
2203
- declare const FARM_INTEGRATION_SET_COOKIES_KEY = "farm:integration:set-cookies";
2204
- /**
2205
- * Forward `Set-Cookie` values from an integration middleware that returns
2206
- * `void` (the authenticated/passthrough branch) to the runtime, so they are
2207
- * merged onto the response the runtime sends for the matched route. This is
2208
- * the passthrough counterpart to appending `Set-Cookie` to a `Response` the
2209
- * middleware returns directly (e.g. a failure redirect): both paths can rotate
2210
- * auth cookies, and both must be able to reach the browser.
2211
- */
2212
- declare function forwardIntegrationSetCookies(context: Pick<FarmIntegrationHandlerContext, "req">, cookies: string[]): void;
2213
- type FarmIntegrationRouteDb<TSchema extends FarmIntegrationSchema | undefined> = InferFarmIntegrationOrmClient<TSchema>;
2214
- interface FarmIntegrationRouteStorageArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2215
- getClient(): Promise<unknown | undefined>;
2216
- getOrm(): Promise<FarmIntegrationRouteDb<TSchema>>;
2217
- }
2218
- interface FarmIntegrationRouteArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2219
- db: FarmIntegrationRouteDb<TSchema>;
2220
- getDb(): Promise<FarmIntegrationRouteDb<TSchema>>;
2221
- storage: FarmIntegrationRouteStorageArgs<TSchema>;
2222
- }
2223
- interface FarmIntegrationConfigContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2224
- key: string;
2225
- integration: FarmIntegration<TSchema, any>;
2226
- appConfig: FarmPluginContext["config"];
2227
- /** Alias for appConfig. */
2228
- config: FarmPluginContext["config"];
2229
- args: FarmIntegrationRouteArgs<TSchema>;
2230
- env: Record<string, string | undefined>;
2231
- isDev: boolean;
2232
- isProd: boolean;
2115
+ type FarmMCPServerFunction = ServerFn<any, any, any> | ServerQuery<any, any>;
2116
+ /** Compose endpoint references, server functions and standalone tools. */
2117
+ type FarmMCPToolDefinition = FarmMCPEndpoint | FarmMCPServerFunction | (EndpointMCPMetadata & {
2118
+ endpoint: FarmMCPEndpoint;
2119
+ execute?: never;
2120
+ }) | FarmMCPStandaloneTool<any, unknown, any>;
2121
+ /** Resolved tool identity, without handlers, validators, or a way to bypass authorization. */
2122
+ type FarmMCPTool = Readonly<EndpointMCPMetadata> & {
2123
+ readonly name: string;
2124
+ } & ({
2125
+ readonly kind: "endpoint";
2126
+ readonly method: RouteMethod;
2127
+ readonly path: string;
2128
+ } | {
2129
+ readonly kind: "standalone";
2130
+ readonly method?: never;
2131
+ readonly path?: never;
2132
+ } | {
2133
+ readonly kind: "serverFunction";
2134
+ readonly method?: never;
2135
+ readonly path?: never;
2136
+ });
2137
+ /** What a resource's `read` receives: the URI asked for, its template variables, and the caller. */
2138
+ interface FarmMCPResourceContext extends FarmMCPExecuteContext {
2139
+ readonly uri: URL;
2140
+ /** Values matched by `uriTemplate`; empty for a fixed `uri`. */
2141
+ readonly variables: Readonly<Record<string, string | string[]>>;
2233
2142
  }
2234
- interface FarmIntegrationConfigDefinition<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2235
- schema?: FarmIntegrationInputSchema<TConfig>;
2236
- env?: Record<string, string | readonly string[]>;
2237
- defaults?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
2238
- input?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
2239
- resolve?(context: FarmIntegrationConfigContext<TSchema>): MaybePromise<TConfig | Partial<TConfig> | undefined>;
2143
+ /**
2144
+ * One piece of resource content: a string (sent as `mimeType`, or text/plain),
2145
+ * text with its own type, JSON data, or binary data.
2146
+ */
2147
+ type FarmMCPResourceContent = string | {
2148
+ text: string;
2149
+ mimeType?: string;
2150
+ } | {
2151
+ json: unknown;
2152
+ } | {
2153
+ blob: Uint8Array | ArrayBuffer;
2154
+ mimeType?: string;
2155
+ };
2156
+ /** One concrete URI a templated resource lists. */
2157
+ interface FarmMCPResourceListing {
2158
+ uri: string;
2159
+ name?: string;
2160
+ title?: string;
2161
+ description?: string;
2162
+ mimeType?: string;
2240
2163
  }
2241
- type FarmIntegrationConfigInput<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationInputSchema<TConfig> | FarmIntegrationConfigDefinition<TConfig, TSchema>;
2242
- type FarmIntegrationLifecycleLogLevel = "info" | "warn" | "error";
2243
- interface FarmIntegrationLifecycleLogger {
2244
- info(message: string, meta?: Record<string, unknown>): void;
2245
- warn(message: string, meta?: Record<string, unknown>): void;
2246
- error(message: string, meta?: Record<string, unknown>): void;
2164
+ /**
2165
+ * A server-only MCP resource: read-only context an agent can load, at a fixed
2166
+ * `uri` or at every URI matching an RFC 6570 `uriTemplate`.
2167
+ */
2168
+ interface FarmMCPResource {
2169
+ /** Stable name, used in authorization and in `authorize`'s `resources` allowlist. */
2170
+ name: string;
2171
+ title?: string;
2172
+ description?: string;
2173
+ mimeType?: string;
2174
+ /** A fixed absolute URI, such as `docs://handbook`. Set this or `uriTemplate`. */
2175
+ uri?: string;
2176
+ /** An RFC 6570 template, such as `notes://{id}`. Set this or `uri`. */
2177
+ uriTemplate?: string;
2178
+ /** For a template: the concrete resources to list. Omit to list none. */
2179
+ list?(context: FarmMCPExecuteContext): readonly FarmMCPResourceListing[] | Promise<readonly FarmMCPResourceListing[]>;
2180
+ /** Return the content, or null when the URI names nothing. */
2181
+ read(context: FarmMCPResourceContext): FarmMCPResourceContent | readonly FarmMCPResourceContent[] | null | Promise<FarmMCPResourceContent | readonly FarmMCPResourceContent[] | null>;
2247
2182
  }
2248
- interface FarmIntegrationLifecycleContext<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationConfigContext<TSchema> {
2249
- integration: FarmIntegration<TSchema, TConfig>;
2250
- integrationConfig: TConfig;
2251
- log: FarmIntegrationLifecycleLogger;
2252
- reason?: string;
2253
- cleanup(callback?: () => MaybePromise<void>): Promise<void>;
2183
+ interface FarmMCPPromptMessage {
2184
+ role: "user" | "assistant";
2185
+ text: string;
2254
2186
  }
2255
- type FarmIntegrationLifecycleHook<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationLifecycleContext<TConfig, TSchema>) => MaybePromise<void>;
2256
2187
  /**
2257
- * Small per-call integration metadata. Values received over HTTP are
2258
- * client-controlled and should be validated before authorization decisions.
2188
+ * A server-only MCP prompt: a reusable message template a client offers its
2189
+ * user. Arguments arrive as strings, as MCP sends them, and are validated by
2190
+ * `arguments` before `render` runs.
2259
2191
  */
2260
- type FarmIntegrationData = Record<string, unknown>;
2261
- interface FarmIntegrationHandlerContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2262
- request: Request;
2263
- requestId: string;
2264
- url: URL;
2265
- pathname: string;
2266
- method: string;
2267
- params: FarmIntegrationRouteParams;
2268
- input: FarmIntegrationRouteInput<TBody, TQuery>;
2269
- args: FarmIntegrationRouteArgs<TSchema>;
2270
- data: FarmIntegrationData;
2271
- integration: {
2272
- category: FarmIntegrationCategory;
2273
- /** @deprecated Use category instead. */
2274
- slot: FarmIntegrationCategory;
2275
- type: string;
2276
- instance: unknown;
2277
- };
2278
- route: {
2279
- kind: "route" | "middleware";
2280
- path: string;
2281
- methods: readonly string[];
2282
- };
2283
- req: FarmRequestStore;
2284
- /** @deprecated Use `req` instead. */
2285
- requestContext: FarmRequestStore;
2286
- config: FarmPluginContext["config"];
2287
- isDev: boolean;
2288
- isProd: boolean;
2289
- }
2290
- interface FarmIntegrationRouteHookContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationHandlerContext<TBody, TQuery, TSchema> {
2291
- response?: Response;
2192
+ interface FarmMCPPrompt<Schema extends RouteSchema | undefined = RouteSchema | undefined> {
2193
+ /** Stable name: 1-128 letters, numbers, dots, underscores, or hyphens. */
2194
+ name: string;
2195
+ title?: string;
2196
+ description?: string;
2197
+ /** An object schema of string arguments. */
2198
+ arguments?: Schema;
2199
+ /** Return the prompt text, sent as one user message, or a list of messages. */
2200
+ render(args: Schema extends RouteSchema ? RouteSchemaOutput<Schema> : Record<string, never>, context: FarmMCPExecuteContext): string | readonly FarmMCPPromptMessage[] | Promise<string | readonly FarmMCPPromptMessage[]>;
2292
2201
  }
2293
- type FarmIntegrationRouteHook<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
2294
- bivarianceHack(request: Request, context: FarmIntegrationRouteHookContext<TBody, TQuery, TSchema>): Promise<Response | void> | Response | void;
2295
- }["bivarianceHack"];
2296
- interface FarmIntegrationRoute<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2297
- path: string;
2298
- method?: FarmIntegrationRouteMethod;
2299
- methods?: readonly FarmIntegrationRouteMethod[];
2300
- middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
2301
- before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2302
- after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2303
- rawBody?: boolean;
2304
- bodyFormat?: FarmIntegrationAPIBodyFormat;
2305
- body?: FarmIntegrationInputSchema<TBody>;
2306
- query?: FarmIntegrationInputSchema<TQuery>;
2307
- input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
2308
- handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
2202
+ interface FarmMCPServer {
2203
+ readonly name: string;
2204
+ readonly version: string;
2205
+ readonly path: `/api/${string}`;
2309
2206
  }
2310
- interface FarmTypedIntegrationRoute<TPath extends string = string, TBody = never, TQuery = never, TResponse = unknown, TServer extends boolean = false, TMethod extends FarmIntegrationAPIMethod = FarmIntegrationAPIMethod, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoute<TBody, TQuery, TSchema> {
2311
- path: TPath;
2312
- method: TMethod;
2313
- __operation: FarmIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>;
2207
+ interface FarmMCPAuthorization extends Record<string, unknown> {
2208
+ /** Stable application principal identifier. Never written to a response or log by Farm. */
2209
+ subject: string;
2210
+ scopes?: string[];
2211
+ /** Allowed tool names for this request. Omit for all configured tools; [] denies all tools. */
2212
+ tools?: readonly string[];
2213
+ /** Allowed resource names. Omit for all configured resources; [] denies all resources. */
2214
+ resources?: readonly string[];
2215
+ /** Allowed prompt names. Omit for all configured prompts; [] denies all prompts. */
2216
+ prompts?: readonly string[];
2314
2217
  }
2315
- interface FarmIntegrationRouteMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2316
- handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
2218
+ interface FarmMCPAuthorizeContext {
2219
+ request: Request;
2220
+ /** Untrusted requested name for a tools/call; authorization runs separately for every JSON-RPC batch item. */
2221
+ tool?: string;
2222
+ /** Untrusted requested URI for a resources/read. */
2223
+ resource?: string;
2224
+ /** Untrusted requested name for a prompts/get. */
2225
+ prompt?: string;
2226
+ /** Complete configured catalog, before applying this caller's permissions. */
2227
+ tools: readonly FarmMCPTool[];
2228
+ /** Resolved transport identity, for policies shared by multiple MCP endpoints. */
2229
+ server: FarmMCPServer;
2317
2230
  }
2318
- interface FarmIntegrationMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2319
- matcher?: string | string[];
2320
- handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
2231
+ interface FarmMCPConfig {
2232
+ /** Set false to disable MCP without removing its configuration. @default true */
2233
+ enabled?: boolean;
2234
+ /** Canonical Farm API path for the Streamable HTTP endpoint. @default "/api/mcp" */
2235
+ path?: `/api/${string}`;
2236
+ /** MCP server identity. @default "farm-api" */
2237
+ name?: string;
2238
+ /** MCP server version. @default "1.0.0" */
2239
+ version?: string;
2240
+ /** Explicit endpoint/standalone tool allowlist. Omit to discover route-owned MCP metadata. */
2241
+ tools?: readonly FarmMCPToolDefinition[];
2242
+ /** Read-only context for agents, from `defineResource()`. */
2243
+ resources?: readonly FarmMCPResource[];
2244
+ /** Reusable prompt templates, from `definePrompt()`. */
2245
+ prompts?: readonly FarmMCPPrompt<any>[];
2246
+ /** Authorize every MCP request. Returning false responds with 401 before protocol handling. */
2247
+ authorize?: (context: FarmMCPAuthorizeContext) => FarmMCPAuthorization | false | Promise<FarmMCPAuthorization | false>;
2248
+ /** Deliberate escape hatch for public servers. Authentication is required by default. */
2249
+ allowUnauthenticated?: boolean;
2250
+ /**
2251
+ * OAuth discovery for MCP clients. When set, a rejected request's 401 points at
2252
+ * RFC 9728 Protected Resource Metadata naming these authorization servers, which
2253
+ * Farm serves at `/.well-known/oauth-protected-resource/<endpoint path>`.
2254
+ * Validating tokens stays in `authorize`.
2255
+ */
2256
+ oauth?: FarmMCPOAuthConfig;
2321
2257
  }
2322
- interface FarmIntegrationProviderProps {
2323
- children: ReactNode;
2258
+ interface FarmMCPOAuthConfig {
2259
+ /** Issuer URLs of the OAuth authorization servers that issue tokens for this endpoint. */
2260
+ authorizationServers: readonly string[];
2261
+ /** Scopes clients may request, advertised as `scopes_supported` and in the 401 challenge. */
2262
+ scopes?: readonly string[];
2263
+ /** Human-readable name for consent screens. @default the MCP server name */
2264
+ resourceName?: string;
2324
2265
  }
2325
- interface FarmIntegrationProviderComponentReference {
2326
- /** Client-safe module specifier using `@/`, a path relative to the app root, or a package. */
2327
- module: string;
2328
- /** Named export to use. Defaults to the module's default export. */
2329
- export?: string;
2266
+ type FarmMCPUserConfig = FarmMCPConfig | false;
2267
+ interface ResolvedFarmMCPConfig extends FarmMCPConfig {
2268
+ enabled: boolean;
2330
2269
  }
2331
- interface FarmIntegrationProvider {
2270
+
2271
+ /**
2272
+ * @internal Publishes one MCP server's tools, replacing an earlier catalog for
2273
+ * the same endpoint. Returns a function that removes it.
2274
+ */
2275
+ declare function _publishFarmMCPCatalog(server: FarmMCPServer, tools: readonly FarmMCPTool[]): () => void;
2276
+ interface FarmMCPEndpointTool {
2277
+ /** The MCP tool name. */
2332
2278
  name: string;
2333
- type: string;
2334
- props?: Record<string, unknown>;
2335
- /**
2336
- * The provider can be instantiated independently around each isolated
2337
- * client root without relying on context or state owned by the route root.
2338
- * Providers are treated as route-wide unless they explicitly opt in.
2279
+ /** The public path of the MCP endpoint that serves the tool. */
2280
+ endpoint: string;
2281
+ }
2282
+ /**
2283
+ * @internal Finds the MCP tool that runs the API endpoint a request to
2284
+ * `method pathname` reaches, if a published catalog exposes one.
2285
+ * `serverBasePath` is the app's public API path, which maps to `/api`.
2286
+ */
2287
+ declare function _findFarmMCPEndpointTool(method: string, pathname: string, serverBasePath?: string): FarmMCPEndpointTool | undefined;
2288
+
2289
+ /** Content type for Markdown responses, including agent-facing error bodies. */
2290
+ declare const FARM_MARKDOWN_CONTENT_TYPE = "text/markdown; charset=utf-8";
2291
+ declare function farmRequestWantsMarkdown(pathname: string, accept: string | null | undefined): boolean;
2292
+ declare function createFarmMarkdownErrorBody(status: number, pathname: string, homeHref?: string): string;
2293
+ type FarmMarkdownRouteInput = string | {
2294
+ route: string;
2295
+ title?: string;
2296
+ cache?: number | false;
2297
+ };
2298
+ interface FarmMarkdownUserConfig {
2299
+ /**
2300
+ * Enable generated markdown representations for React pages.
2301
+ * @default true
2339
2302
  */
2340
- supportsIsolatedHydration?: boolean;
2341
- component?: ComponentType<FarmIntegrationProviderProps> | FarmIntegrationProviderComponentReference;
2303
+ enabled?: boolean;
2304
+ /**
2305
+ * Routes that may expose generated markdown. Every page is exposed by default.
2306
+ */
2307
+ expose?: boolean | FarmMarkdownRouteInput[];
2308
+ /** @deprecated Use `expose`. */
2309
+ routes?: FarmMarkdownRouteInput[];
2310
+ cache?: number | false;
2311
+ includeMetadata?: boolean;
2342
2312
  }
2343
- interface FarmIntegrationDocumentNavigation {
2344
- matcher: string | readonly string[];
2313
+ interface FarmMarkdownResolvedRoute {
2314
+ route: string;
2315
+ title?: string;
2316
+ cache?: number | false;
2345
2317
  }
2346
- /** @deprecated Use `FarmSchemaFieldType`. */
2347
- type FarmIntegrationSchemaFieldType = FarmSchemaFieldType;
2348
- /** @deprecated Use `FarmSchemaReference`. */
2349
- type FarmIntegrationSchemaReference = FarmSchemaReference;
2350
- /** @deprecated Use `FarmSchemaField`. */
2351
- type FarmIntegrationSchemaField = FarmSchemaField;
2352
- /** @deprecated Use `FarmSchemaConstraint`. */
2353
- type FarmIntegrationSchemaConstraint = FarmSchemaConstraint;
2354
- /** @deprecated Use `FarmSchemaModel`. */
2355
- type FarmIntegrationSchemaModel = FarmSchemaModel;
2356
- /** @deprecated Use `FarmSchemaModelExtension`. */
2357
- type FarmIntegrationSchemaModelExtension = FarmSchemaModelExtension;
2358
- /** @deprecated Use `FarmSchemaModelOverride`. */
2359
- type FarmIntegrationSchemaModelOverride = FarmSchemaModelOverride;
2360
- /** @deprecated Use `FarmSchema`. */
2361
- type FarmIntegrationSchema = FarmSchema;
2362
- /** @deprecated Use `defineSchema`. This is an exact alias, not a wrapper. */
2363
- declare const defineIntegrationSchema: typeof defineSchema;
2364
- type FarmIntegrationLogPhase = "registered" | "validate" | "setup" | "ready" | "dispose" | "request:start" | "request:end" | "request:error";
2365
- interface FarmIntegrationLogEvent {
2366
- category: FarmIntegrationCategory;
2367
- /** @deprecated Use category instead. */
2368
- slot: FarmIntegrationCategory;
2318
+ interface FarmMarkdownResolvedConfig {
2319
+ enabled: boolean;
2320
+ expose: true | FarmMarkdownResolvedRoute[];
2321
+ cache: number | false;
2322
+ includeMetadata: boolean;
2323
+ }
2324
+ interface FarmMarkdownMirrorTarget {
2325
+ pathname: string;
2326
+ route: FarmMarkdownResolvedRoute | null;
2327
+ }
2328
+ interface ResolveMarkdownMirrorTargetOptions {
2329
+ accept?: string | null;
2330
+ }
2331
+ interface CreateMarkdownMirrorResponseOptions {
2332
+ request: Request;
2333
+ /** @internal Reuse a parse only while its href still matches this request. */
2334
+ requestUrl?: URL;
2335
+ config?: FarmMarkdownResolvedConfig;
2336
+ routeExists?: (pathname: string) => boolean;
2337
+ renderPage: (request: Request) => Response | Promise<Response>;
2338
+ /** The app's public API path, so a form posting to an API route can be matched to its MCP tool. */
2339
+ apiServerBasePath?: string;
2340
+ }
2341
+ interface ApplyMarkdownNegotiationHeadersOptions {
2342
+ config?: FarmMarkdownResolvedConfig;
2343
+ pathname: string;
2344
+ }
2345
+ declare function resolveMarkdownConfig(config: FarmMarkdownUserConfig | boolean | undefined): FarmMarkdownResolvedConfig;
2346
+ declare function resolveMarkdownMirrorTarget(config: FarmMarkdownResolvedConfig | undefined, pathname: string, options?: ResolveMarkdownMirrorTargetOptions): FarmMarkdownMirrorTarget | null;
2347
+ declare function createMarkdownMirrorResponse(options: CreateMarkdownMirrorResponseOptions): Promise<Response | null>;
2348
+ declare function applyMarkdownNegotiationHeaders(response: Response, options: ApplyMarkdownNegotiationHeadersOptions): Response;
2349
+ declare function htmlToMarkdown(html: string, options?: {
2350
+ title?: string;
2351
+ sourcePath?: string;
2352
+ includeMetadata?: boolean;
2353
+ /** Where the page's forms are described, listed when the page has any. */
2354
+ actionsPath?: string;
2355
+ }): string;
2356
+ /**
2357
+ * Quality value an `Accept` header assigns a media type, or 0 when the client
2358
+ * will not take it.
2359
+ *
2360
+ * `q=0` means "not acceptable" per RFC 9110, so it has to be distinguished from
2361
+ * an absent entry rather than treated as a match. Wildcards are opt-in: a client
2362
+ * sending `*&#47;*` will take anything, which says nothing about whether it would
2363
+ * rather have Markdown than HTML, so callers negotiating between two concrete
2364
+ * types should ask for exact entries only.
2365
+ */
2366
+ declare function farmAcceptQuality(accept: string | null | undefined, mediaType: string, options?: {
2367
+ wildcards?: boolean;
2368
+ }): number;
2369
+ declare function requestAcceptsMarkdown(accept: string | null | undefined): boolean;
2370
+ /** @internal The `.md` URL that serves a page's Markdown mirror. */
2371
+ declare function getFarmMarkdownMirrorPath(pathname: string): string;
2372
+ /**
2373
+ * @internal The `.md` URL to advertise for the HTML page at `pathname`, or
2374
+ * null when it has no Markdown mirror. Both the `Link` response header and the
2375
+ * `<link rel="alternate">` in the document head come from this.
2376
+ */
2377
+ declare function getFarmMarkdownAlternatePath(config: FarmMarkdownResolvedConfig | undefined, pathname: string): string | null;
2378
+ /** @internal Whether `pathname` has a Markdown mirror under `config`. */
2379
+ declare function isFarmMarkdownMirrorExposed(config: FarmMarkdownResolvedConfig | undefined, pathname: string): boolean;
2380
+ /** @internal Matches a page pathname against a route pattern such as `/docs/[...slug]`. */
2381
+ declare function matchesFarmMarkdownRoutePattern(pattern: string, pathname: string): boolean;
2382
+ interface FarmPageFormOption {
2383
+ value: string;
2384
+ label?: string;
2385
+ selected?: true;
2386
+ }
2387
+ interface FarmPageFormField {
2388
+ name: string;
2389
+ /** The input type, or `select`, `textarea`, `radio`, or `checkbox` for a group. */
2369
2390
  type: string;
2370
- phase: FarmIntegrationLogPhase;
2371
- route?: {
2372
- kind: "route" | "middleware";
2373
- path: string;
2374
- methods: readonly string[];
2391
+ label?: string;
2392
+ required?: true;
2393
+ multiple?: true;
2394
+ /** A preset value: always present for hidden fields. */
2395
+ value?: string;
2396
+ checked?: true;
2397
+ /** Choices of a select, or of radio buttons and checkboxes sharing a name. */
2398
+ options?: FarmPageFormOption[];
2399
+ placeholder?: string;
2400
+ pattern?: string;
2401
+ min?: string;
2402
+ max?: string;
2403
+ step?: string;
2404
+ minLength?: number;
2405
+ maxLength?: number;
2406
+ accept?: string;
2407
+ }
2408
+ interface FarmPageFormSubmit {
2409
+ label: string;
2410
+ name?: string;
2411
+ value?: string;
2412
+ /** Set when the button submits somewhere other than its form (`formaction`). */
2413
+ action?: string;
2414
+ method?: string;
2415
+ }
2416
+ interface FarmPageFormAction {
2417
+ type: "form";
2418
+ name?: string;
2419
+ method: "GET" | "POST";
2420
+ /**
2421
+ * Where the form submits: a root-relative URL on the page's origin, or an
2422
+ * absolute URL elsewhere. Absent when the form only submits with JavaScript.
2423
+ */
2424
+ action?: string;
2425
+ /** Present for POST forms. */
2426
+ enctype?: string;
2427
+ requiresJavaScript?: true;
2428
+ fields: FarmPageFormField[];
2429
+ submit: FarmPageFormSubmit[];
2430
+ /** A React server action form: the id React put in its hidden `$ACTION_` fields. */
2431
+ serverAction?: {
2432
+ id: string;
2375
2433
  };
2376
- requestId?: string;
2377
- request?: Request;
2378
- response?: Response;
2379
- error?: unknown;
2380
- durationMs?: number;
2381
- level?: FarmIntegrationLifecycleLogLevel;
2382
- message?: string;
2383
- meta?: Record<string, unknown>;
2384
- context: Map<string, unknown>;
2434
+ /**
2435
+ * The MCP tool that runs the same API endpoint, when `@farm.js/mcp` exposes
2436
+ * it: the tool `name` and the MCP `endpoint` to call it at. The caller's
2437
+ * `authorize` policy still decides whether that tool is available to it.
2438
+ */
2439
+ tool?: FarmMCPEndpointTool;
2385
2440
  }
2386
- type FarmIntegrationLogger = (event: FarmIntegrationLogEvent) => void | Promise<void>;
2387
- interface FarmIntegrationPluginOwner {
2388
- key: string;
2389
- category: FarmIntegrationCategory;
2390
- type: string;
2391
- source: "lifecycle" | "contribution";
2392
- serverRuntime: boolean;
2441
+ /**
2442
+ * Describes the forms in the part of the page the mirror reads, so an agent can
2443
+ * see what it can submit: where, how, and with which fields. Controls that are
2444
+ * disabled are left out, since a browser would not submit them; hidden fields
2445
+ * keep their values, so a submission without JavaScript can be replayed.
2446
+ */
2447
+ declare function extractFarmPageActions(html: string, pageUrl: URL): FarmPageFormAction[];
2448
+
2449
+ interface FarmLlmsTxtLink {
2450
+ title: string;
2451
+ url: string;
2452
+ description?: string;
2393
2453
  }
2394
- /** A normal plugin or an integration-bound plugin compatible with the shared instance. */
2395
- type FarmIntegrationContributedPlugin<TInstance = unknown> = FarmPlugin<any, any, any, any, unknown, false> | FarmPlugin<any, any, any, any, TInstance, true>;
2396
- interface FarmIntegration<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> {
2397
- readonly kind: "farm-integration";
2398
- category: FarmIntegrationCategory;
2399
- /** @deprecated Use category instead. */
2400
- slot?: FarmIntegrationCategory;
2401
- type: string;
2402
- instance: TInstance;
2403
- /** Set to false when a platform adapter owns this integration's production routes. */
2404
- serverRuntime?: boolean;
2405
- api?: FarmIntegrationAPI;
2406
- schema?: TSchema;
2407
- config?: FarmIntegrationConfigInput<TConfig, TSchema>;
2408
- validate?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2409
- setup?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2410
- ready?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2411
- dispose?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2412
- log?: FarmIntegrationLogger;
2413
- routes?: readonly FarmIntegrationRoute<any, any, TSchema>[];
2414
- endpoints?: FarmIntegrationEndpoints<TSchema>;
2415
- middleware?: readonly FarmIntegrationMiddleware<TSchema>[];
2416
- providers?: readonly FarmIntegrationProvider[];
2417
- documentNavigations?: readonly FarmIntegrationDocumentNavigation[];
2418
- /** Additional Farm plugins owned and configured by this integration. */
2419
- plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
2454
+ interface FarmLlmsTxtSection {
2455
+ title: string;
2456
+ links: FarmLlmsTxtLink[];
2420
2457
  }
2421
- type FarmIntegrationsUserConfig = Record<string, FarmIntegration<any, any, any> | undefined>;
2422
- /** @internal Identifies plugins owned by platform-managed integrations. */
2423
- declare function getFarmIntegrationPluginServerRuntime(plugin: FarmPlugin): boolean | undefined;
2424
- /** Returns the integration that contributed a normalized plugin, when applicable. */
2425
- declare function getFarmIntegrationPluginOwner(plugin: FarmPlugin): Readonly<FarmIntegrationPluginOwner> | undefined;
2426
- type IntegrationRouteBuilderOptions<TBody, TQuery, TServer extends boolean, TSchema extends FarmIntegrationSchema | undefined> = {
2427
- middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
2428
- before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2429
- after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2430
- rawBody?: boolean;
2431
- headers?: Record<string, string>;
2432
- credentials?: RequestCredentials;
2433
- bodyFormat?: FarmIntegrationAPIBodyFormat;
2434
- responseFormat?: FarmIntegrationAPIResponseFormat;
2435
- isServer?: TServer;
2436
- body?: FarmIntegrationInputSchema<TBody>;
2437
- query?: FarmIntegrationInputSchema<TQuery>;
2438
- input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
2439
- handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
2440
- };
2441
- interface FarmIntegrationRouteFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2442
- get<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "GET", TSchema>;
2443
- post<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "POST", TSchema>;
2444
- query<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "QUERY", TSchema>;
2445
- put<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PUT", TSchema>;
2446
- patch<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PATCH", TSchema>;
2447
- delete<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "DELETE", TSchema>;
2448
- options<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "OPTIONS", TSchema>;
2449
- head<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "HEAD", TSchema>;
2458
+ interface FarmLlmsTxt {
2459
+ /** Site or project name, rendered as the `# H1`. Required by the format. */
2460
+ title: string;
2461
+ /** One-sentence summary, rendered as a `> blockquote`. */
2462
+ summary?: string;
2463
+ /** Free-form Markdown placed after the summary. */
2464
+ details?: string;
2465
+ /** `## H2` sections of links. A section titled "Optional" marks skippable links. */
2466
+ sections?: FarmLlmsTxtSection[];
2450
2467
  }
2451
- interface FarmIntegrationRoutesFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2452
- route: FarmIntegrationRouteFactory<TSchema>;
2453
- integrationRoute: FarmIntegrationRouteFactory<TSchema>;
2468
+ /** A static page of the app, ready to use as an llms.txt link. */
2469
+ interface FarmLlmsTxtPage extends FarmLlmsTxtLink {
2470
+ /** The page's route path, such as `/docs/install`. */
2471
+ path: string;
2454
2472
  }
2455
- type FarmIntegrationRoutesFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationRoutesFactoryContext<TSchema>) => readonly FarmIntegrationRoute<any, any, TSchema>[];
2456
- type FarmIntegrationEndpointValue<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationRoute<any, any, TSchema> | readonly FarmIntegrationEndpointValue<TSchema>[] | {
2457
- readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
2458
- };
2459
- type FarmIntegrationEndpoints<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
2460
- readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
2461
- };
2462
- interface FarmIntegrationEndpointsFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoutesFactoryContext<TSchema> {
2463
- endpoint: FarmIntegrationRouteFactory<TSchema>;
2473
+ interface FarmLlmsTxtUserConfig {
2474
+ /** Set to `false` to turn llms.txt off while keeping these options. */
2475
+ enabled?: boolean;
2476
+ /** Site name for the `# H1`. Defaults to the root layout's metadata title. */
2477
+ title?: string;
2478
+ /** Summary for the `> blockquote`. Defaults to the root layout's metadata description. */
2479
+ summary?: string;
2480
+ /** Markdown placed after the summary. */
2481
+ details?: string;
2482
+ /**
2483
+ * Route patterns to list, using the same syntax as `md.expose`
2484
+ * (`/docs/[...slug]`). Defaults to every static page.
2485
+ */
2486
+ include?: string[];
2487
+ /** Route patterns to leave out, such as `/admin/[...path]`. */
2488
+ exclude?: string[];
2489
+ /**
2490
+ * Also serve `/llms-full.txt`, the index with each page's Markdown mirror inlined.
2491
+ *
2492
+ * @default true
2493
+ */
2494
+ full?: boolean;
2495
+ /**
2496
+ * Seconds a CDN may cache the generated files, and the production server may
2497
+ * reuse an llms-full.txt render, which renders every listed page. Defaults to
2498
+ * no caching; concurrent llms-full.txt requests still share one render.
2499
+ */
2500
+ revalidate?: number;
2501
+ }
2502
+ interface ResolvedFarmLlmsTxtConfig {
2503
+ enabled: boolean;
2504
+ title?: string;
2505
+ summary?: string;
2506
+ details?: string;
2507
+ include: string[];
2508
+ exclude: string[];
2509
+ full: boolean;
2510
+ revalidate?: number;
2511
+ }
2512
+ interface FarmLlmsTxtPageSource {
2513
+ pattern: string;
2514
+ metadata?: unknown;
2515
+ }
2516
+ declare function collectFarmLlmsTxtPages(sources: Iterable<FarmLlmsTxtPageSource>, options: {
2517
+ origin: string;
2518
+ basePath?: string;
2519
+ markdown?: FarmMarkdownResolvedConfig;
2520
+ include?: string[];
2521
+ exclude?: string[];
2522
+ }): FarmLlmsTxtPage[];
2523
+ declare function createFarmDefaultLlmsTxt(options: {
2524
+ origin: string;
2525
+ pages: FarmLlmsTxtPage[];
2526
+ config: ResolvedFarmLlmsTxtConfig;
2527
+ rootMetadata?: unknown;
2528
+ }): FarmLlmsTxt;
2529
+ /**
2530
+ * Reads a page's Markdown the way an agent would: a fresh `.md` request with no
2531
+ * cookies or credentials, so a page behind auth answers 401 and is left out of
2532
+ * a file that CDNs may cache, instead of leaking into it.
2533
+ */
2534
+ declare function createFarmLlmsMarkdownReader(fetchMarkdown: (request: Request) => Promise<Response>): (url: string) => Promise<string | null>;
2535
+ /**
2536
+ * Renders llms-full.txt: the llms.txt header, then one block per linked page with
2537
+ * its Markdown inlined, in the layout the docs engine uses. A string passes
2538
+ * through unchanged. Only same-origin links are fetched.
2539
+ */
2540
+ declare function renderFarmLlmsFullTxt(value: unknown, options: {
2541
+ origin: string;
2542
+ readMarkdown: (url: string) => Promise<string | null>;
2543
+ concurrency?: number;
2544
+ /** Milliseconds to wait for one page's Markdown before leaving it out. */
2545
+ pageTimeout?: number;
2546
+ /** Called when a page is left out because it did not answer in time. */
2547
+ onIncomplete?: () => void;
2548
+ }): Promise<string>;
2549
+ /**
2550
+ * Shares llms-full.txt renders, which read every listed page. Requests for the
2551
+ * same origin while a render runs, or within `revalidate` seconds after it, get
2552
+ * that result; renders run one at a time, so a burst of requests, even with
2553
+ * varied Host headers, cannot multiply page renders. The content is the same for
2554
+ * every caller: pages are read with fresh requests that carry no credentials.
2555
+ * A render that calls `incomplete()`, because a page timed out, is answered but
2556
+ * not reused, so the next request tries that page again.
2557
+ */
2558
+ declare function createFarmLlmsFullRenderer(options?: {
2559
+ revalidate?: number;
2560
+ now?: () => number;
2561
+ maxEntries?: number;
2562
+ }): (origin: string, render: (shared: {
2563
+ incomplete: () => void;
2564
+ }) => Promise<string>, onSettled?: (complete: boolean) => void) => Promise<string>;
2565
+
2566
+ type ApplicationMetadataRouteKind = "sitemap" | "robots" | "manifest" | "llms" | "llms-full";
2567
+ declare namespace MetadataRoute {
2568
+ type SitemapChangeFrequency = "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
2569
+ interface SitemapEntry {
2570
+ url: string;
2571
+ lastModified?: string | Date;
2572
+ changeFrequency?: SitemapChangeFrequency;
2573
+ priority?: number;
2574
+ alternates?: {
2575
+ languages?: Record<string, string>;
2576
+ };
2577
+ }
2578
+ type Sitemap = SitemapEntry[];
2579
+ interface RobotsRule {
2580
+ userAgent: string | string[];
2581
+ allow?: string | string[];
2582
+ disallow?: string | string[];
2583
+ crawlDelay?: number;
2584
+ }
2585
+ interface Robots {
2586
+ rules: RobotsRule | RobotsRule[];
2587
+ sitemap?: string | string[];
2588
+ host?: string;
2589
+ }
2590
+ interface ManifestIcon {
2591
+ src: string;
2592
+ sizes?: string;
2593
+ type?: string;
2594
+ purpose?: string;
2595
+ }
2596
+ interface Manifest {
2597
+ name?: string;
2598
+ short_name?: string;
2599
+ description?: string;
2600
+ id?: string;
2601
+ start_url?: string;
2602
+ scope?: string;
2603
+ display?: "fullscreen" | "standalone" | "minimal-ui" | "browser" | string;
2604
+ orientation?: string;
2605
+ background_color?: string;
2606
+ theme_color?: string;
2607
+ lang?: string;
2608
+ dir?: "ltr" | "rtl" | "auto";
2609
+ categories?: string[];
2610
+ icons?: ManifestIcon[];
2611
+ [key: string]: unknown;
2612
+ }
2613
+ /**
2614
+ * The object an `llms.ts` metadata route returns, rendered as llms.txt. An
2615
+ * `llms.ts` can also return the complete file as a string, or a `Response`.
2616
+ */
2617
+ type LlmsTxt = FarmLlmsTxt;
2618
+ type LlmsTxtSection = FarmLlmsTxtSection;
2619
+ type LlmsTxtLink = FarmLlmsTxtLink;
2620
+ /** A static page of the app, usable directly as an llms.txt link. */
2621
+ type LlmsTxtPage = FarmLlmsTxtPage;
2622
+ /** What an `llms.ts` default-export function receives. */
2623
+ interface LlmsTxtContext extends MetadataRouteContext {
2624
+ /** The app's static pages, linking to their Markdown mirrors when exposed. */
2625
+ pages: LlmsTxtPage[];
2626
+ /** The llms.txt that `agent.llmsTxt` would serve, to extend instead of replace. */
2627
+ defaults: LlmsTxt;
2628
+ }
2629
+ /**
2630
+ * What an `llms-full.ts` default-export function receives. Returning an
2631
+ * `LlmsTxt` object inlines each same-origin link's Markdown; returning a string
2632
+ * serves it as the complete file.
2633
+ */
2634
+ interface LlmsFullTxtContext extends LlmsTxtContext {
2635
+ /** A page's Markdown mirror, read without the request's cookies; `null` if unavailable. */
2636
+ markdown(url: string): Promise<string | null>;
2637
+ }
2638
+ }
2639
+ interface MetadataRouteContext {
2640
+ request: Request;
2641
+ params: Record<string, string>;
2642
+ searchParams: URLSearchParams;
2643
+ /** The concrete route-segment path that owns the metadata file. */
2644
+ path: string;
2645
+ }
2646
+ interface FarmMetadataRouteModule {
2647
+ revalidate?: number | false;
2464
2648
  }
2465
- type FarmIntegrationEndpointsFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationEndpointsFactoryContext<TSchema>) => FarmIntegrationEndpoints<TSchema>;
2466
- declare function createIntegrationRoute<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined>(_schema?: TSchema): FarmIntegrationRouteFactory<TSchema>;
2467
- declare const integrationRoute: FarmIntegrationRouteFactory<undefined>;
2468
- type RegisteredIntegrationRuntime = {
2469
- integration: FarmIntegration;
2470
- config: FarmPluginContext["config"];
2471
- isDev: boolean;
2472
- isProd: boolean;
2473
- };
2474
- type FarmIntegrationRoutesInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = readonly FarmIntegrationRoute<any, any, TSchema>[] | FarmIntegrationRoutesFactory<TSchema>;
2475
- type FarmIntegrationEndpointsInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationEndpoints<TSchema> | FarmIntegrationEndpointsFactory<TSchema>;
2476
- type FarmIntegrationInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> = Omit<FarmIntegration<TSchema, TConfig, TInstance>, "kind" | "category" | "slot" | "instance" | "config" | "routes" | "endpoints" | "plugins"> & {
2477
- instance: TInstance;
2478
- config?: FarmIntegrationConfigInput<TConfig, TSchema>;
2479
- routes?: FarmIntegrationRoutesInput<TSchema>;
2480
- endpoints?: FarmIntegrationEndpointsInput<TSchema>;
2481
- plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
2482
- } & ({
2483
- category: FarmIntegrationCategory;
2484
- slot?: FarmIntegrationCategory;
2485
- } | {
2486
- category?: FarmIntegrationCategory;
2487
- slot: FarmIntegrationCategory;
2488
- });
2489
- type FarmIntegrationCategoryInput = {
2490
- category: FarmIntegrationCategory;
2491
- slot?: FarmIntegrationCategory;
2492
- } | {
2493
- category?: FarmIntegrationCategory;
2494
- slot: FarmIntegrationCategory;
2495
- };
2496
- type FarmIntegrationShapeForInference = FarmIntegrationCategoryInput & {
2497
- api?: FarmIntegrationAPI;
2498
- schema?: FarmIntegrationSchema;
2499
- config?: unknown;
2500
- routes?: unknown;
2501
- endpoints?: unknown;
2502
- };
2503
- type ExtractIntegrationSchema<TIntegration> = TIntegration extends {
2504
- schema: infer TSchema extends FarmIntegrationSchema;
2505
- } ? TSchema : undefined;
2506
- type ResolveIntegrationRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = TRoutes extends FarmIntegrationRoutesFactory<TSchema> ? ReturnType<TRoutes> : TRoutes;
2507
- type ResolveIntegrationEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = TEndpoints extends FarmIntegrationEndpointsFactory<TSchema> ? ReturnType<TEndpoints> : TEndpoints;
2508
- type ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = ResolveIntegrationRoutesInput<TRoutes, TSchema> extends readonly (infer TRoute)[] ? TRoute : never;
2509
- type ExtractIntegrationRoutesFromEndpointValue<TValue> = TValue extends FarmIntegrationRouteOperationCarrier<string, any> ? TValue : TValue extends readonly (infer TItem)[] ? ExtractIntegrationRoutesFromEndpointValue<TItem> : TValue extends object ? ExtractIntegrationRoutesFromEndpointValue<TValue[keyof TValue]> : never;
2510
- type ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = ExtractIntegrationRoutesFromEndpointValue<ResolveIntegrationEndpointsInput<TEndpoints, TSchema>>;
2511
- type ExtractIntegrationRouteUnion<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = (TIntegration extends {
2512
- routes: infer TRoutes;
2513
- } ? ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema> : never) | (TIntegration extends {
2514
- endpoints: infer TEndpoints;
2515
- } ? ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema> : never);
2516
- type ExtractDefinedIntegrationRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = [ExtractIntegrationRouteUnion<TIntegration, TSchema>] extends [never] ? undefined : readonly ExtractIntegrationRouteUnion<TIntegration, TSchema>[];
2517
- type ExtractDefinedIntegrationEndpoints<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = TIntegration extends {
2518
- endpoints: infer TEndpoints;
2519
- } ? ResolveIntegrationEndpointsInput<TEndpoints, TSchema> : undefined;
2520
- type ExtractIntegrationAPIRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = Extract<ExtractIntegrationRouteUnion<TIntegration, TSchema>, FarmIntegrationRouteOperationCarrier<string, any>>;
2521
- type ExtractIntegrationCategory<TIntegration extends FarmIntegrationCategoryInput> = TIntegration extends {
2522
- category: infer TCategory extends FarmIntegrationCategory;
2523
- } ? TCategory : TIntegration extends {
2524
- slot: infer TSlot extends FarmIntegrationCategory;
2525
- } ? TSlot : FarmIntegrationCategory;
2526
- type ExtractDerivedIntegrationAPI<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = TIntegration extends {
2527
- api: infer TAPI extends FarmIntegrationAPI;
2528
- } ? TAPI : [ExtractIntegrationAPIRoutes<TIntegration, TSchema>] extends [never] ? FarmIntegrationAPI | undefined : InferIntegrationAPIFromRoutes<readonly ExtractIntegrationAPIRoutes<TIntegration, TSchema>[]>;
2529
- type DefinedIntegration<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = Omit<TIntegration, "kind" | "category" | "slot" | "api" | "routes" | "endpoints"> & {
2530
- readonly kind: "farm-integration";
2531
- category: ExtractIntegrationCategory<TIntegration>;
2532
- slot: ExtractIntegrationCategory<TIntegration>;
2533
- routes: ExtractDefinedIntegrationRoutes<TIntegration, TSchema>;
2534
- endpoints: ExtractDefinedIntegrationEndpoints<TIntegration, TSchema>;
2535
- api: ExtractDerivedIntegrationAPI<TIntegration, TSchema>;
2536
- };
2537
- declare function defineIntegration<const TSchema extends FarmIntegrationSchema | undefined, const TConfig, TIntegration extends FarmIntegrationInput<TSchema, TConfig, any>>(integration: TIntegration & FarmIntegrationInput<TSchema, TConfig, NoInfer<TIntegration["instance"]>>): DefinedIntegration<TIntegration, TSchema>;
2538
- declare function isFarmIntegration(value: unknown): value is FarmIntegration;
2539
- declare function resolveIntegrationPlugins(integrations: FarmIntegrationsUserConfig | undefined): FarmPlugin[];
2540
- declare function getIntegrationProviders(integrations: FarmIntegrationsUserConfig | undefined): FarmIntegrationProvider[];
2541
- declare function isFarmIntegrationProviderComponentReference(value: FarmIntegrationProvider["component"]): value is FarmIntegrationProviderComponentReference;
2542
- declare function getIntegrationDocumentNavigationMatchers(integrations: FarmIntegrationsUserConfig | undefined): string[];
2543
- declare function getIntegrationSchemas(integrations: FarmIntegrationsUserConfig | undefined): Record<string, FarmIntegrationSchema>;
2544
- declare function getRegisteredIntegrationRuntime(key: string): RegisteredIntegrationRuntime | undefined;
2545
- declare function getRegisteredIntegrations(): Record<string, FarmIntegration>;
2546
- declare function getRegisteredIntegrationSchemas(): Record<string, FarmIntegrationSchema>;
2547
- declare function matchIntegrationRoute(integrations: FarmIntegrationsUserConfig | undefined, input: {
2548
- pathname: string;
2549
- method?: string;
2550
- }): {
2551
- key: string;
2552
- integration: FarmIntegration;
2553
- route: {
2554
- path: string;
2555
- methods: readonly string[];
2556
- };
2557
- params: FarmIntegrationRouteParams;
2558
- } | null;
2559
- declare function matchRegisteredIntegrationRoute(input: {
2560
- pathname: string;
2649
+ interface FarmMetadataRouteResponseOptions {
2561
2650
  method?: string;
2562
- }): {
2563
- key: string;
2564
- integration: FarmIntegration;
2565
- route: {
2566
- path: string;
2567
- methods: readonly string[];
2568
- };
2569
- params: FarmIntegrationRouteParams;
2570
- } | null;
2571
- declare function getRegisteredIntegrationAPIManifest(): Record<string, FarmIntegrationAPI>;
2572
- declare function dispatchIntegrationRequest(runtime: RegisteredIntegrationRuntime, request: Request, options?: {
2573
- currentRequest?: Request;
2574
- data?: FarmIntegrationData;
2575
- internal?: boolean;
2651
+ /** The request being answered, so llms.txt reads can be reported as agent traffic. */
2652
+ request?: Request;
2653
+ }
2654
+ /** @internal */
2655
+ declare function createFarmMetadataRouteResponse(kind: ApplicationMetadataRouteKind, value: unknown, routeModule?: FarmMetadataRouteModule, options?: FarmMetadataRouteResponseOptions): Response;
2656
+
2657
+ type FarmCrawlerPolicy = "allow" | "block";
2658
+ interface FarmAgentCrawlers {
2659
+ /** Set to `false` to stop serving the generated robots.txt while keeping these options. */
2660
+ enabled?: boolean;
2576
2661
  /**
2577
- * Receives `Set-Cookie` values that a middleware forwarded via
2578
- * forwardIntegrationSetCookies while returning `void`, when this dispatch
2579
- * ends without a Response of its own. The request continues downstream, so
2580
- * the caller owns merging them onto whatever response it finally produces.
2581
- * Only called on the `null` return path: a Response returned from here has
2582
- * already had the forwarded cookies appended.
2662
+ * AI search and user-triggered agents such as OAI-SearchBot, Claude-SearchBot,
2663
+ * and PerplexityBot. Left unset, they follow the `User-agent: *` rules.
2583
2664
  */
2584
- onForwardedCookies?: (cookies: string[]) => void;
2585
- }): Promise<Response | null>;
2665
+ search?: FarmCrawlerPolicy;
2666
+ /**
2667
+ * AI training crawlers such as GPTBot, ClaudeBot, Google-Extended, and CCBot.
2668
+ * Left unset, they follow the `User-agent: *` rules.
2669
+ */
2670
+ training?: FarmCrawlerPolicy;
2671
+ /**
2672
+ * More robots.txt groups, written after the generated ones. Crawlers combine
2673
+ * groups that name the same agent. A rule for `*` replaces the default
2674
+ * `User-agent: *` / `Allow: /` group.
2675
+ */
2676
+ rules?: MetadataRoute.RobotsRule[];
2677
+ /**
2678
+ * Absolute sitemap URLs. Defaults to the app's `sitemap.ts` route, resolved
2679
+ * against the root layout's `metadataBase`; with neither, no `Sitemap:` line.
2680
+ */
2681
+ sitemap?: string | string[];
2682
+ }
2683
+ interface ResolvedFarmAgentCrawlers {
2684
+ enabled: boolean;
2685
+ search?: FarmCrawlerPolicy;
2686
+ training?: FarmCrawlerPolicy;
2687
+ rules: MetadataRoute.RobotsRule[];
2688
+ sitemap?: string[];
2689
+ }
2690
+ interface FarmAgentRobotsOptions {
2691
+ crawlers: ResolvedFarmAgentCrawlers;
2692
+ /** The app's root sitemap route, such as `/sitemap.xml`, when it has one. */
2693
+ sitemapPath?: string;
2694
+ /** The root layout's `metadataBase`, which makes the sitemap URL absolute. */
2695
+ metadataBase?: unknown;
2696
+ basePath?: string;
2697
+ }
2698
+ /** The robots.txt `agent.crawlers` serves. */
2699
+ declare function createFarmAgentRobots(options: FarmAgentRobotsOptions): MetadataRoute.Robots;
2700
+
2586
2701
  /**
2587
- * Run every configured integration's middleware and routes for one request.
2588
- *
2589
- * Integration middleware is not route scoped: it is the mechanism behind
2590
- * `protectedRoutes` guards and provider session refresh, so it has to run for
2591
- * ordinary page and API requests that match no integration route at all. That
2592
- * makes this, not `matchIntegrationRoute`, the correct entry point for a
2593
- * runtime dispatching integrations for every request.
2594
- *
2595
- * The first integration that produces a Response short-circuits the rest.
2596
- * `Set-Cookie` values forwarded by middleware that returned `void` are
2597
- * collected: they ride the short-circuiting Response when there is one, and are
2598
- * otherwise handed back so the caller can merge them onto the downstream
2599
- * response.
2702
+ * Agent-readiness configuration: primitives that make a Farm site easier for AI agents and
2703
+ * crawlers to discover, resolve, and use. The ones that only describe the site agents can
2704
+ * already read (JSON-LD, llms.txt) are on by default; the ones that expose more
2705
+ * (crawler rules, an API catalog) are opt-in. Each one turns off with `false`.
2600
2706
  */
2601
- declare function dispatchIntegrationRequests(integrations: FarmIntegrationsUserConfig | undefined, runtime: Omit<RegisteredIntegrationRuntime, "integration">, request: Request, options?: {
2602
- currentRequest?: Request;
2603
- }): Promise<{
2604
- response: Response | null;
2605
- setCookies: string[];
2606
- }>;
2707
+
2708
+ /** schema.org JSON-LD emitted in the document head to identify the site. */
2709
+ interface FarmAgentJsonLd {
2710
+ /**
2711
+ * schema.org `@type`. Common values: `"Organization"` for a company or
2712
+ * project, `"SoftwareApplication"` for a product, `"WebSite"`, `"Person"`.
2713
+ *
2714
+ * @default "Organization"
2715
+ */
2716
+ type?: string;
2717
+ /** Entity name. Defaults to the site's Open Graph site name or page title. */
2718
+ name?: string;
2719
+ /** Canonical URL for the entity. Defaults to the configured `metadataBase`. */
2720
+ url?: string;
2721
+ /** Short description. Defaults to the page/site metadata description. */
2722
+ description?: string;
2723
+ /** Logo URL. */
2724
+ logo?: string;
2725
+ /** URLs that also represent this entity (social profiles, repos) — schema.org `sameAs`. */
2726
+ sameAs?: string[];
2727
+ /** Additional schema.org properties merged into the emitted object. */
2728
+ properties?: Record<string, unknown>;
2729
+ }
2730
+ interface FarmAgentUserConfig {
2731
+ /**
2732
+ * Emit schema.org JSON-LD in the document head so agents and crawlers can
2733
+ * resolve the site's identity. Left unset, it emits a `WebSite` built from the
2734
+ * site's metadata; `true` emits an `Organization`; an object customizes the type
2735
+ * and fields; `false` turns it off.
2736
+ *
2737
+ * @default { type: "WebSite" }
2738
+ */
2739
+ jsonLd?: boolean | FarmAgentJsonLd;
2740
+ /**
2741
+ * On a preview deployment, send `X-Robots-Tag: noindex, nofollow` with every
2742
+ * response from Farm's server. Previews are detected from `FARM_PREVIEW`,
2743
+ * `VERCEL_ENV=preview`, Netlify's deploy-preview and branch-deploy contexts,
2744
+ * and Render pull request previews. Production is unaffected.
2745
+ *
2746
+ * @default false
2747
+ */
2748
+ noindexPreviews?: boolean;
2749
+ /**
2750
+ * Serve `/llms.txt` (https://llmstxt.org): a Markdown index of the app's static
2751
+ * pages, linking to their Markdown mirrors. `true` builds it from page metadata
2752
+ * and also serves `/llms-full.txt`; an object sets the title, summary, details,
2753
+ * and which routes to list. A `src/app/llms.ts` metadata route or a
2754
+ * `public/llms.txt` replaces the generated file. Left unset, `/llms.txt` is served
2755
+ * (without `/llms-full.txt`) unless the docs engine is enabled, which serves its own.
2756
+ *
2757
+ * @default { full: false } without docs, false with docs
2758
+ */
2759
+ llmsTxt?: boolean | FarmLlmsTxtUserConfig;
2760
+ /**
2761
+ * Serve a generated `/robots.txt` that allows or blocks AI search agents
2762
+ * (`search`) and AI training crawlers (`training`), plus your own `rules`.
2763
+ * `true` serves only `User-agent: *` / `Allow: /` and the sitemap. A
2764
+ * `public/robots.txt` or `src/app/robots.ts` replaces the generated file.
2765
+ *
2766
+ * @default false
2767
+ */
2768
+ crawlers?: boolean | FarmAgentCrawlers;
2769
+ /**
2770
+ * Serve `/.well-known/api-catalog` (RFC 9727): a Linkset listing the app's
2771
+ * OpenAPI description and reference (when `openapi` is enabled) and its MCP
2772
+ * endpoint (when the top-level `mcp` is enabled), so agents can find them
2773
+ * from the origin alone.
2774
+ *
2775
+ * @default false
2776
+ */
2777
+ apiCatalog?: boolean;
2778
+ }
2779
+ interface ResolvedFarmAgentConfig {
2780
+ jsonLd: FarmAgentJsonLd | false;
2781
+ noindexPreviews: boolean;
2782
+ llmsTxt: ResolvedFarmLlmsTxtConfig;
2783
+ crawlers: ResolvedFarmAgentCrawlers;
2784
+ apiCatalog: boolean;
2785
+ }
2607
2786
 
2608
2787
  declare global {
2609
2788
  namespace FarmJS {
@@ -3260,4 +3439,4 @@ interface MetadataRobots extends MetadataRobotsDirectives {
3260
3439
  googleBot?: string | MetadataRobotsDirectives;
3261
3440
  }
3262
3441
 
3263
- export { type LayoutMetadataProps as $, type FarmAgentJsonLd as A, type FarmContextFactory as B, type MiddlewareProps as C, type BundleResultPayload as D, type FarmIntegration as E, type FarmRouteRuntimeConfig as F, type FarmConfig as G, farmPlugin as H, defineConfig as I, type FarmComponentType as J, type AppRoutePattern as K, type LayoutProps as L, type Metadata as M, type PageRouteParams as N, type NitroPreset as O, type ParsedRoute as P, type FarmMigrationCommand as Q, type RouteSegment as R, type FarmMigrationsConfig as S, type FarmMigrationsUserConfig as T, type ResolvedFarmMigrationsConfig as U, type FarmContextFactoryInput as V, type FarmIsolatedClientHydrationMode as W, type LoadingProps as X, type ErrorProps as Y, type PagePropsWithMiddleware as Z, type MetadataProps as _, type FarmPlugin as a, definePlugin as a$, type Page as a0, type Layout as a1, type Loading as a2, type ErrorBoundary as a3, type StaticPathPrimitive as a4, type StaticPathParams as a5, type StaticRouteParams as a6, type GenerateStaticParams as a7, type LayoutModule as a8, type MetadataJsonLd as a9, type ResolvedFarmDevIndicatorsConfig as aA, type ResolvedFarmAuthConfig as aB, type ResolvedFarmPerformanceConfig as aC, type ResolvedFarmSecurityConfig as aD, type APIRequestRuntime as aE, createFarmMetadataRouteResponse as aF, createFarmAgentRobots as aG, collectFarmLlmsTxtPages as aH, createFarmDefaultLlmsTxt as aI, createFarmLlmsMarkdownReader as aJ, renderFarmLlmsFullTxt as aK, createFarmLlmsFullRenderer as aL, manageFarmDocumentPreloads as aM, manageFarmHtmlPreloads as aN, manageFarmLinkHeaderPreloads as aO, reportFarmPreloadWarnings as aP, applyFarmCspNonceToResponse as aQ, resolveFarmSecurityConfig as aR, type ResolvedSchemaField as aS, type FarmSqlDialect as aT, type FarmSqlStatement as aU, type CollectedSchemaModel as aV, type FarmSchemaMigrationStep as aW, type OpenAPIConfig as aX, type FarmAgentUserConfig as aY, type FarmAgentCrawlers as aZ, type FarmCrawlerPolicy as a_, type ServerAction as aa, type BuildOptions as ab, type SSGPage as ac, type SSGCollectionResult as ad, type MetadataRobotsDirectives as ae, type MetadataRobots as af, type FarmLayerEntry as ag, type ResolvedFarmLayer as ah, type FarmSourceRoot as ai, type ResolveFarmLayersOptions as aj, type FarmLayerResolution as ak, resolveFarmLayers as al, getFarmSourceRoots as am, getFarmAppDirectories as an, getFarmLayerAliases as ao, createFarmConfigResolutionPlugin as ap, loadFarmConfigFile as aq, type ReadonlyMiddlewareStore as ar, type FarmMiddlewareConfig as as, type MiddlewareModule as at, type MiddlewareConfig$1 as au, type MiddlewareContext as av, type ResolvedFarmRouteRuntimeConfig as aw, type ApplicationMetadataRouteKind as ax, type ResolvedFarmAPIConfig as ay, type ResolvedFarmDevtoolsConfig as az, isFarmRedirectError as b, type FarmPluginStateContext as b$, FarmRuntimeShutdownError as b0, PluginManager as b1, type FarmPluginDatabase as b2, type FarmPluginDefinition as b3, FarmPluginOptionsError as b4, type FarmPluginFactory as b5, type FarmPluginOptionsIssue as b6, type FarmPluginOptionsSchema as b7, type InferPluginOptionsInput as b8, type InferPluginOptionsOutput as b9, type FarmMCPAuthorization as bA, type FarmMCPEndpoint as bB, type FarmMCPServerFunction as bC, type FarmMCPToolDefinition as bD, type FarmMCPStandaloneTool as bE, type FarmMCPExecuteContext as bF, type FarmMCPTool as bG, type FarmMCPServer as bH, type FarmMCPAuthorizeContext as bI, type FarmMCPConfig as bJ, type FarmMCPOAuthConfig as bK, type FarmMCPPrompt as bL, type FarmMCPPromptMessage as bM, type FarmMCPResource as bN, type FarmMCPResourceContent as bO, type FarmMCPResourceContext as bP, type FarmMCPResourceListing as bQ, type FarmMCPUserConfig as bR, type ResolvedFarmMCPConfig as bS, type PluginRequestContext as bT, type FarmPluginIntegrationContext as bU, type FarmPluginLifecycle as bV, type FarmRequestPluginContext as bW, type FarmRequestStore as bX, type FarmPluginRuntimeKind as bY, type FarmPluginRouteRuntimePayload as bZ, type FarmPluginSetupContext as b_, resolveConfig as ba, loadConfig as bb, resolveDeployConfig as bc, resolveMigrationsConfig as bd, resolveDeployOutputPath as be, normalizeDeployTarget as bf, getDeployTargetForPreset as bg, getPresetForDeployTarget as bh, type FarmLayerConfig as bi, type FarmPerformanceConfig as bj, type FarmPreloadMode as bk, type FarmPreloadUserConfig as bl, type ResolvedFarmPreloadConfig as bm, type FarmCspConfig as bn, type FarmCspDirectives as bo, type FarmCspDirectiveValue as bp, type FarmCspOptions as bq, type FarmSecurityConfig as br, type ResolvedFarmCspConfig as bs, MetadataRoute as bt, type MetadataRouteContext as bu, type FarmAuthConfig as bv, type FarmAuthDatabaseConfig as bw, type FarmAuthEmailAndPasswordConfig as bx, type FarmAuthSessionConfig as by, type FarmAuthUserConfig as bz, type FarmRedirectSignal as c, type FarmIntegrationRouteInput as c$, type FarmPluginRuntimeBaseEvent as c0, type FarmPluginRuntimeContextEvent as c1, type FarmPluginRuntimeEndpoint as c2, type FarmPluginRuntimeEndpointEvent as c3, type FarmPluginRuntimeBeforeEvent as c4, type FarmPluginRuntimeAfterEvent as c5, type FarmPluginRuntimeErrorEvent as c6, type FarmPluginRuntimeStartEvent as c7, type FarmPluginRuntimeCloseEvent as c8, type FarmPluginRuntimeHooks as c9, type ImageConfig as cA, type I18nConfig as cB, type MiddlewareConfig as cC, type FarmDeployConfig as cD, type ResolvedFarmDeployConfig as cE, type FarmDeployTarget as cF, describeSchemaReference as cG, collectSchemaModels as cH, generateSqlStatements as cI, renderSqlSchemaFile as cJ, getSqlColumnType as cK, getSqlDefaultExpression as cL, isNullableField as cM, quoteSqlIdentifier as cN, toSnakeCase as cO, toPascalCase as cP, toCamelCase as cQ, escapeSqlString as cR, resolveSchemaModels as cS, type ResolvedSchemaModel as cT, type FarmIntegrationCategory as cU, type FarmIntegrationSlot as cV, type FarmIntegrationRouteParamValue as cW, type FarmIntegrationRouteParams as cX, type FarmIntegrationRouteMethod as cY, type FarmIntegrationRouteInputSource as cZ, type FarmIntegrationValidationPathSegment as c_, type FarmPluginRuntimeRequestOptions as ca, type FarmPluginRuntimeRequestHandler as cb, type FarmPluginRuntimeSession as cc, type FarmPluginDiscoveredRoute as cd, type FarmPluginRouterHooks as ce, type FarmPluginRenderHooks as cf, type FarmPluginBuildHooks as cg, type FarmPluginDevHooks as ch, type FarmPluginClientConfig as ci, type RouteDiscoveredPayload as cj, type RoutesGeneratedPayload as ck, type MiddlewareDiscoveredPayload as cl, type APIRouteDiscoveredPayload as cm, type RouteMatchPayload as cn, type RouteMatchResultPayload as co, type RenderLifecyclePayload as cp, type APIHandlerLifecyclePayload as cq, type ErrorLifecyclePayload as cr, type HMRUpdatePayload as cs, type BundleLifecyclePayload as ct, type NitroBuildLifecyclePayload as cu, type ShutdownPayload as cv, type ResolvedFarmConfig as cw, type RedirectConfig as cx, type HeaderConfig as cy, type RewriteConfig as cz, type FarmRedirectStatus as d, getIntegrationProviders as d$, type FarmIntegrationValidationIssue as d0, type FarmIntegrationValidationErrorLike as d1, type FarmIntegrationValidationResult as d2, type FarmIntegrationStandardValidationResult as d3, type FarmIntegrationInputSchema as d4, type FarmIntegrationRouteInputSchemas as d5, type FarmIntegrationRequestContextStore as d6, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as d7, FARM_INTEGRATION_SET_COOKIES_KEY as d8, forwardIntegrationSetCookies as d9, type FarmIntegrationSchemaConstraint as dA, type FarmIntegrationSchemaModel as dB, type FarmIntegrationSchemaModelExtension as dC, type FarmIntegrationSchemaModelOverride as dD, type FarmIntegrationSchema as dE, defineIntegrationSchema as dF, type FarmIntegrationLogPhase as dG, type FarmIntegrationLogEvent as dH, type FarmIntegrationLogger as dI, type FarmIntegrationPluginOwner as dJ, type FarmIntegrationContributedPlugin as dK, type FarmIntegrationsUserConfig as dL, getFarmIntegrationPluginServerRuntime as dM, getFarmIntegrationPluginOwner as dN, type FarmIntegrationRouteFactory as dO, type FarmIntegrationRoutesFactoryContext as dP, type FarmIntegrationRoutesFactory as dQ, type FarmIntegrationEndpointValue as dR, type FarmIntegrationEndpoints as dS, type FarmIntegrationEndpointsFactoryContext as dT, type FarmIntegrationEndpointsFactory as dU, createIntegrationRoute as dV, integrationRoute as dW, type DefinedIntegration as dX, defineIntegration as dY, isFarmIntegration as dZ, resolveIntegrationPlugins as d_, type FarmIntegrationRouteDb as da, type FarmIntegrationRouteStorageArgs as db, type FarmIntegrationRouteArgs as dc, type FarmIntegrationConfigContext as dd, type FarmIntegrationConfigDefinition as de, type FarmIntegrationConfigInput as df, type FarmIntegrationLifecycleLogLevel as dg, type FarmIntegrationLifecycleLogger as dh, type FarmIntegrationLifecycleContext as di, type FarmIntegrationLifecycleHook as dj, type FarmIntegrationData as dk, type FarmIntegrationHandlerContext as dl, type FarmIntegrationRouteHookContext as dm, type FarmIntegrationRouteHook as dn, type FarmIntegrationRoute as dp, type FarmTypedIntegrationRoute as dq, type FarmIntegrationRouteMiddleware as dr, type FarmIntegrationMiddleware as ds, type FarmIntegrationProviderProps as dt, type FarmIntegrationProviderComponentReference as du, type FarmIntegrationProvider as dv, type FarmIntegrationDocumentNavigation as dw, type FarmIntegrationSchemaFieldType as dx, type FarmIntegrationSchemaReference as dy, type FarmIntegrationSchemaField as dz, type FarmRequest as e, type FarmRouteRuntimeManifest as e$, isFarmIntegrationProviderComponentReference as e0, getIntegrationDocumentNavigationMatchers as e1, getIntegrationSchemas as e2, getRegisteredIntegrationRuntime as e3, getRegisteredIntegrations as e4, getRegisteredIntegrationSchemas as e5, matchIntegrationRoute as e6, matchRegisteredIntegrationRoute as e7, getRegisteredIntegrationAPIManifest as e8, dispatchIntegrationRequest as e9, resolveFarmAPIRequestURL as eA, type MiddlewareFunction as eB, type RequestMiddleware as eC, type RequestMiddlewareContext as eD, type MiddlewareStore as eE, type MiddlewareChain as eF, type CookieJar as eG, type CookieOptions as eH, type RateLimitConfig as eI, type RateLimitIncrementResult as eJ, type RateLimitStorage as eK, type RateLimitStatus as eL, type MemoryRateLimitStorageOptions as eM, type NextFunction as eN, type MiddlewareResult as eO, type FarmRouteRuleRenderMode as eP, type FarmRouteRuleRedirect as eQ, type FarmRouteRuleCors as eR, type FarmRouteRule as eS, type FarmRouteRules as eT, normalizeRouteRules as eU, routeRulesToRedirects as eV, routeRulesToHeaders as eW, routeRulesToNitroRouteRules as eX, type FarmRouteRuntimeEntryKind as eY, type FarmRouteRenderingMode as eZ, type FarmRouteRuntimeManifestEntry as e_, dispatchIntegrationRequests as ea, describeIntegrationOriginRejection as eb, resolveIntegrationAllowedOrigins as ec, validateIntegrationRequestOrigin as ed, type IntegrationOriginPolicy as ee, type IntegrationOriginRejection as ef, type IntegrationOriginResult as eg, type FarmIntegrationOrmSchema as eh, type FarmIntegrationOrmClient as ei, type InferFarmIntegrationOrmField as ej, type InferFarmIntegrationOrmFields as ek, type InferFarmIntegrationOrmSchema as el, type InferFarmIntegrationOrmClient as em, type CreateIntegrationOrmOptions as en, createIntegrationOrm as eo, resolveIntegrationOrmRuntimeClient as ep, farmIntegrationSchemaToOrmSchema as eq, type IntegrationOrmModelNames as er, DEFAULT_FARM_API_BASE_PATH as es, type FarmAPIConfigResolverContext as et, type FarmAPIConfigValue as eu, type FarmAPIConfig as ev, resolveFarmAPIConfig as ew, normalizeFarmAPIConfig as ex, normalizeFarmAPIBasePath as ey, getFarmAPIBaseURL as ez, type FarmResponse as f, normalizeFarmRouteRuntimeConfig as f0, mergeFarmRouteRuntimeConfigs as f1, resolveFarmRouteRuntimeConfig as f2, hasFarmRouteRuntimeControls as f3, getFarmRouteRuntimeConfig as f4, createFarmRouteRuntimeKey as f5, resolveFarmRouteRuleRuntimeConfig as f6, farmRouteRuleMatches as f7, DEFAULT_FARM_DEVTOOLS_SHORTCUT as f8, FARM_DEVTOOLS_PATH as f9, FARM_DEVTOOLS_LAUNCH_PARAM as fa, type FarmDevtoolsConfig as fb, type FarmDevtoolsUserConfig as fc, resolveFarmDevtoolsConfig as fd, type FarmBuildActivityPosition as fe, type FarmDevIndicatorsConfig as ff, resolveFarmDevIndicatorsConfig as fg, generateFarmDevIndicatorsClientRuntime as fh, farmI18nClientBridgePlugin as fi, farmServerOnlyEntriesPlugin as fj, withFarmRequestTracing as fk, rewriteEarlySsrRelativeImports as fl, transformIsolatedClientBoundaryModule as fm, shouldEmitFarmClientRootHmr as fn, generateClientCachePersistenceCode as fo, resolveFarmClientCacheAdapterEntry as fp, type ClientCachePersistenceEntryCode as fq, FARM_NODE_RESPONSE_END_PENDING as fr, loadFarmDevModule as fs, FarmDevEnvironmentError as ft, type FarmDevModuleServer as fu, getFarmRedirectError as g, type FarmPluginContext as h, isFarmNotFoundError as i, type FarmRouteRuntime as j, type FarmRouteRegions as k, type FarmRouteMaxDuration as l, type FarmAppContext as m, notFound as n, type PageProps as o, permanentRedirect as p, type PluginContextProps as q, redirect as r, type RouteModule as s, type FarmMdxComponents as t, type FarmMdxResolvedConfig as u, resolveFarmMdxComponentsModulePath as v, resolveMdxConfig as w, type FarmMdxComponent as x, type FarmMdxUserConfig as y, type FarmUserConfig as z };
3442
+ export { type ErrorProps as $, createFarmMarkdownErrorBody as A, farmRequestWantsMarkdown as B, type FarmUserConfig as C, type FarmAgentJsonLd as D, type FarmContextFactory as E, type FarmRouteRuntimeConfig as F, type MiddlewareProps as G, type BundleResultPayload as H, type FarmIntegration as I, type FarmConfig as J, farmPlugin as K, type LayoutProps as L, type Metadata as M, defineConfig as N, type FarmComponentType as O, type ParsedRoute as P, type AppRoutePattern as Q, type RouteSegment as R, type PageRouteParams as S, type NitroPreset as T, type FarmMigrationCommand as U, type FarmMigrationsConfig as V, type FarmMigrationsUserConfig as W, type ResolvedFarmMigrationsConfig as X, type FarmContextFactoryInput as Y, type FarmIsolatedClientHydrationMode as Z, type LoadingProps as _, type FarmPlugin as a, type CollectedSchemaModel as a$, type PagePropsWithMiddleware as a0, type MetadataProps as a1, type LayoutMetadataProps as a2, type Page as a3, type Layout as a4, type Loading as a5, type ErrorBoundary as a6, type StaticPathPrimitive as a7, type StaticPathParams as a8, type StaticRouteParams as a9, _publishFarmMCPCatalog as aA, type ResolvedFarmRouteRuntimeConfig as aB, type ApplicationMetadataRouteKind as aC, type ResolvedFarmAPIConfig as aD, type FarmMarkdownResolvedConfig as aE, type ResolvedFarmDevtoolsConfig as aF, type ResolvedFarmDevIndicatorsConfig as aG, type ResolvedFarmAuthConfig as aH, type ResolvedFarmPerformanceConfig as aI, type ResolvedFarmSecurityConfig as aJ, type APIRequestRuntime as aK, createFarmMetadataRouteResponse as aL, createFarmAgentRobots as aM, collectFarmLlmsTxtPages as aN, createFarmDefaultLlmsTxt as aO, createFarmLlmsMarkdownReader as aP, renderFarmLlmsFullTxt as aQ, createFarmLlmsFullRenderer as aR, manageFarmDocumentPreloads as aS, manageFarmHtmlPreloads as aT, manageFarmLinkHeaderPreloads as aU, reportFarmPreloadWarnings as aV, applyFarmCspNonceToResponse as aW, resolveFarmSecurityConfig as aX, type ResolvedSchemaField as aY, type FarmSqlDialect as aZ, type FarmSqlStatement as a_, type GenerateStaticParams as aa, type LayoutModule as ab, type MetadataJsonLd as ac, type ServerAction as ad, type BuildOptions as ae, type SSGPage as af, type SSGCollectionResult as ag, type MetadataRobotsDirectives as ah, type MetadataRobots as ai, type FarmLayerEntry as aj, type ResolvedFarmLayer as ak, type FarmSourceRoot as al, type ResolveFarmLayersOptions as am, type FarmLayerResolution as an, resolveFarmLayers as ao, getFarmSourceRoots as ap, getFarmAppDirectories as aq, getFarmLayerAliases as ar, createFarmConfigResolutionPlugin as as, loadFarmConfigFile as at, type ReadonlyMiddlewareStore as au, type FarmMiddlewareConfig as av, type MiddlewareModule as aw, type MiddlewareConfig$1 as ax, type MiddlewareContext as ay, _findFarmMCPEndpointTool as az, isFarmRedirectError as b, type FarmPluginIntegrationContext as b$, type FarmSchemaMigrationStep as b0, type OpenAPIConfig as b1, type FarmAgentUserConfig as b2, type FarmAgentCrawlers as b3, type FarmCrawlerPolicy as b4, definePlugin as b5, FarmRuntimeShutdownError as b6, PluginManager as b7, type FarmPluginDatabase as b8, type FarmPluginDefinition as b9, type MetadataRouteContext as bA, type FarmMCPEndpointTool as bB, type FarmAuthConfig as bC, type FarmAuthDatabaseConfig as bD, type FarmAuthEmailAndPasswordConfig as bE, type FarmAuthSessionConfig as bF, type FarmAuthUserConfig as bG, type FarmMCPAuthorization as bH, type FarmMCPEndpoint as bI, type FarmMCPServerFunction as bJ, type FarmMCPToolDefinition as bK, type FarmMCPStandaloneTool as bL, type FarmMCPExecuteContext as bM, type FarmMCPTool as bN, type FarmMCPServer as bO, type FarmMCPAuthorizeContext as bP, type FarmMCPConfig as bQ, type FarmMCPOAuthConfig as bR, type FarmMCPPrompt as bS, type FarmMCPPromptMessage as bT, type FarmMCPResource as bU, type FarmMCPResourceContent as bV, type FarmMCPResourceContext as bW, type FarmMCPResourceListing as bX, type FarmMCPUserConfig as bY, type ResolvedFarmMCPConfig as bZ, type PluginRequestContext as b_, FarmPluginOptionsError as ba, type FarmPluginFactory as bb, type FarmPluginOptionsIssue as bc, type FarmPluginOptionsSchema as bd, type InferPluginOptionsInput as be, type InferPluginOptionsOutput as bf, resolveConfig as bg, loadConfig as bh, resolveDeployConfig as bi, resolveMigrationsConfig as bj, resolveDeployOutputPath as bk, normalizeDeployTarget as bl, getDeployTargetForPreset as bm, getPresetForDeployTarget as bn, type FarmLayerConfig as bo, type FarmPerformanceConfig as bp, type FarmPreloadMode as bq, type FarmPreloadUserConfig as br, type ResolvedFarmPreloadConfig as bs, type FarmCspConfig as bt, type FarmCspDirectives as bu, type FarmCspDirectiveValue as bv, type FarmCspOptions as bw, type FarmSecurityConfig as bx, type ResolvedFarmCspConfig as by, MetadataRoute as bz, type FarmRedirectSignal as c, type ResolvedSchemaModel as c$, type FarmPluginLifecycle as c0, type FarmRequestPluginContext as c1, type FarmRequestStore as c2, type FarmPluginRuntimeKind as c3, type FarmPluginRouteRuntimePayload as c4, type FarmPluginSetupContext as c5, type FarmPluginStateContext as c6, type FarmPluginRuntimeBaseEvent as c7, type FarmPluginRuntimeContextEvent as c8, type FarmPluginRuntimeEndpoint as c9, type BundleLifecyclePayload as cA, type NitroBuildLifecyclePayload as cB, type ShutdownPayload as cC, type ResolvedFarmConfig as cD, type RedirectConfig as cE, type HeaderConfig as cF, type RewriteConfig as cG, type ImageConfig as cH, type I18nConfig as cI, type MiddlewareConfig as cJ, type FarmDeployConfig as cK, type ResolvedFarmDeployConfig as cL, type FarmDeployTarget as cM, type FarmMarkdownUserConfig as cN, describeSchemaReference as cO, collectSchemaModels as cP, generateSqlStatements as cQ, renderSqlSchemaFile as cR, getSqlColumnType as cS, getSqlDefaultExpression as cT, isNullableField as cU, quoteSqlIdentifier as cV, toSnakeCase as cW, toPascalCase as cX, toCamelCase as cY, escapeSqlString as cZ, resolveSchemaModels as c_, type FarmPluginRuntimeEndpointEvent as ca, type FarmPluginRuntimeBeforeEvent as cb, type FarmPluginRuntimeAfterEvent as cc, type FarmPluginRuntimeErrorEvent as cd, type FarmPluginRuntimeStartEvent as ce, type FarmPluginRuntimeCloseEvent as cf, type FarmPluginRuntimeHooks as cg, type FarmPluginRuntimeRequestOptions as ch, type FarmPluginRuntimeRequestHandler as ci, type FarmPluginRuntimeSession as cj, type FarmPluginDiscoveredRoute as ck, type FarmPluginRouterHooks as cl, type FarmPluginRenderHooks as cm, type FarmPluginBuildHooks as cn, type FarmPluginDevHooks as co, type FarmPluginClientConfig as cp, type RouteDiscoveredPayload as cq, type RoutesGeneratedPayload as cr, type MiddlewareDiscoveredPayload as cs, type APIRouteDiscoveredPayload as ct, type RouteMatchPayload as cu, type RouteMatchResultPayload as cv, type RenderLifecyclePayload as cw, type APIHandlerLifecyclePayload as cx, type ErrorLifecyclePayload as cy, type HMRUpdatePayload as cz, type FarmRedirectStatus as d, type FarmIntegrationEndpointsFactoryContext as d$, type FarmIntegrationCategory as d0, type FarmIntegrationSlot as d1, type FarmIntegrationRouteParamValue as d2, type FarmIntegrationRouteParams as d3, type FarmIntegrationRouteMethod as d4, type FarmIntegrationRouteInputSource as d5, type FarmIntegrationValidationPathSegment as d6, type FarmIntegrationRouteInput as d7, type FarmIntegrationValidationIssue as d8, type FarmIntegrationValidationErrorLike as d9, type FarmIntegrationMiddleware as dA, type FarmIntegrationProviderProps as dB, type FarmIntegrationProviderComponentReference as dC, type FarmIntegrationProvider as dD, type FarmIntegrationDocumentNavigation as dE, type FarmIntegrationSchemaFieldType as dF, type FarmIntegrationSchemaReference as dG, type FarmIntegrationSchemaField as dH, type FarmIntegrationSchemaConstraint as dI, type FarmIntegrationSchemaModel as dJ, type FarmIntegrationSchemaModelExtension as dK, type FarmIntegrationSchemaModelOverride as dL, type FarmIntegrationSchema as dM, defineIntegrationSchema as dN, type FarmIntegrationLogPhase as dO, type FarmIntegrationLogEvent as dP, type FarmIntegrationLogger as dQ, type FarmIntegrationPluginOwner as dR, type FarmIntegrationContributedPlugin as dS, type FarmIntegrationsUserConfig as dT, getFarmIntegrationPluginServerRuntime as dU, getFarmIntegrationPluginOwner as dV, type FarmIntegrationRouteFactory as dW, type FarmIntegrationRoutesFactoryContext as dX, type FarmIntegrationRoutesFactory as dY, type FarmIntegrationEndpointValue as dZ, type FarmIntegrationEndpoints as d_, type FarmIntegrationValidationResult as da, type FarmIntegrationStandardValidationResult as db, type FarmIntegrationInputSchema as dc, type FarmIntegrationRouteInputSchemas as dd, type FarmIntegrationRequestContextStore as de, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as df, FARM_INTEGRATION_SET_COOKIES_KEY as dg, forwardIntegrationSetCookies as dh, type FarmIntegrationRouteDb as di, type FarmIntegrationRouteStorageArgs as dj, type FarmIntegrationRouteArgs as dk, type FarmIntegrationConfigContext as dl, type FarmIntegrationConfigDefinition as dm, type FarmIntegrationConfigInput as dn, type FarmIntegrationLifecycleLogLevel as dp, type FarmIntegrationLifecycleLogger as dq, type FarmIntegrationLifecycleContext as dr, type FarmIntegrationLifecycleHook as ds, type FarmIntegrationData as dt, type FarmIntegrationHandlerContext as du, type FarmIntegrationRouteHookContext as dv, type FarmIntegrationRouteHook as dw, type FarmIntegrationRoute as dx, type FarmTypedIntegrationRoute as dy, type FarmIntegrationRouteMiddleware as dz, type FarmRequest as e, type FarmRouteRules as e$, type FarmIntegrationEndpointsFactory as e0, createIntegrationRoute as e1, integrationRoute as e2, type DefinedIntegration as e3, defineIntegration as e4, isFarmIntegration as e5, resolveIntegrationPlugins as e6, getIntegrationProviders as e7, isFarmIntegrationProviderComponentReference as e8, getIntegrationDocumentNavigationMatchers as e9, DEFAULT_FARM_API_BASE_PATH as eA, type FarmAPIConfigResolverContext as eB, type FarmAPIConfigValue as eC, type FarmAPIConfig as eD, resolveFarmAPIConfig as eE, normalizeFarmAPIConfig as eF, normalizeFarmAPIBasePath as eG, getFarmAPIBaseURL as eH, resolveFarmAPIRequestURL as eI, type MiddlewareFunction as eJ, type RequestMiddleware as eK, type RequestMiddlewareContext as eL, type MiddlewareStore as eM, type MiddlewareChain as eN, type CookieJar as eO, type CookieOptions as eP, type RateLimitConfig as eQ, type RateLimitIncrementResult as eR, type RateLimitStorage as eS, type RateLimitStatus as eT, type MemoryRateLimitStorageOptions as eU, type NextFunction as eV, type MiddlewareResult as eW, type FarmRouteRuleRenderMode as eX, type FarmRouteRuleRedirect as eY, type FarmRouteRuleCors as eZ, type FarmRouteRule as e_, getIntegrationSchemas as ea, getRegisteredIntegrationRuntime as eb, getRegisteredIntegrations as ec, getRegisteredIntegrationSchemas as ed, matchIntegrationRoute as ee, matchRegisteredIntegrationRoute as ef, getRegisteredIntegrationAPIManifest as eg, dispatchIntegrationRequest as eh, dispatchIntegrationRequests as ei, describeIntegrationOriginRejection as ej, resolveIntegrationAllowedOrigins as ek, validateIntegrationRequestOrigin as el, type IntegrationOriginPolicy as em, type IntegrationOriginRejection as en, type IntegrationOriginResult as eo, type FarmIntegrationOrmSchema as ep, type FarmIntegrationOrmClient as eq, type InferFarmIntegrationOrmField as er, type InferFarmIntegrationOrmFields as es, type InferFarmIntegrationOrmSchema as et, type InferFarmIntegrationOrmClient as eu, type CreateIntegrationOrmOptions as ev, createIntegrationOrm as ew, resolveIntegrationOrmRuntimeClient as ex, farmIntegrationSchemaToOrmSchema as ey, type IntegrationOrmModelNames as ez, type FarmResponse as f, normalizeRouteRules as f0, routeRulesToRedirects as f1, routeRulesToHeaders as f2, routeRulesToNitroRouteRules as f3, type FarmRouteRuntimeEntryKind as f4, type FarmRouteRenderingMode as f5, type FarmRouteRuntimeManifestEntry as f6, type FarmRouteRuntimeManifest as f7, normalizeFarmRouteRuntimeConfig as f8, mergeFarmRouteRuntimeConfigs as f9, type FarmPageFormAction as fA, extractFarmPageActions as fB, DEFAULT_FARM_DEVTOOLS_SHORTCUT as fC, FARM_DEVTOOLS_PATH as fD, FARM_DEVTOOLS_LAUNCH_PARAM as fE, type FarmDevtoolsConfig as fF, type FarmDevtoolsUserConfig as fG, resolveFarmDevtoolsConfig as fH, type FarmBuildActivityPosition as fI, type FarmDevIndicatorsConfig as fJ, resolveFarmDevIndicatorsConfig as fK, generateFarmDevIndicatorsClientRuntime as fL, farmI18nClientBridgePlugin as fM, farmServerOnlyEntriesPlugin as fN, withFarmRequestTracing as fO, rewriteEarlySsrRelativeImports as fP, transformIsolatedClientBoundaryModule as fQ, shouldEmitFarmClientRootHmr as fR, generateClientCachePersistenceCode as fS, resolveFarmClientCacheAdapterEntry as fT, type ClientCachePersistenceEntryCode as fU, FARM_NODE_RESPONSE_END_PENDING as fV, loadFarmDevModule as fW, FarmDevEnvironmentError as fX, type FarmDevModuleServer as fY, resolveFarmRouteRuntimeConfig as fa, hasFarmRouteRuntimeControls as fb, getFarmRouteRuntimeConfig as fc, createFarmRouteRuntimeKey as fd, resolveFarmRouteRuleRuntimeConfig as fe, farmRouteRuleMatches as ff, type FarmMarkdownRouteInput as fg, type FarmMarkdownResolvedRoute as fh, type FarmMarkdownMirrorTarget as fi, type ResolveMarkdownMirrorTargetOptions as fj, type CreateMarkdownMirrorResponseOptions as fk, type ApplyMarkdownNegotiationHeadersOptions as fl, resolveMarkdownConfig as fm, resolveMarkdownMirrorTarget as fn, createMarkdownMirrorResponse as fo, applyMarkdownNegotiationHeaders as fp, htmlToMarkdown as fq, farmAcceptQuality as fr, requestAcceptsMarkdown as fs, getFarmMarkdownMirrorPath as ft, getFarmMarkdownAlternatePath as fu, isFarmMarkdownMirrorExposed as fv, matchesFarmMarkdownRoutePattern as fw, type FarmPageFormOption as fx, type FarmPageFormField as fy, type FarmPageFormSubmit as fz, getFarmRedirectError as g, type FarmPluginContext as h, isFarmNotFoundError as i, type FarmRouteRuntime as j, type FarmRouteRegions as k, type FarmRouteMaxDuration as l, type FarmAppContext as m, notFound as n, type PageProps as o, permanentRedirect as p, type PluginContextProps as q, redirect as r, type RouteModule as s, type FarmMdxComponents as t, type FarmMdxResolvedConfig as u, resolveFarmMdxComponentsModulePath as v, resolveMdxConfig as w, type FarmMdxComponent as x, type FarmMdxUserConfig as y, FARM_MARKDOWN_CONTENT_TYPE as z };