@farm.js/plugin 0.1.27 → 0.1.29

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.
package/dist/index.d.ts CHANGED
@@ -39,5 +39,5 @@
39
39
  * })
40
40
  * ```
41
41
  */
42
- export declare const version = "0.1.27";
42
+ export declare const version = "0.1.29";
43
43
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@
39
39
  * })
40
40
  * ```
41
41
  */
42
- export const version = "0.1.27";
42
+ export const version = "0.1.29";
43
43
  // Note: Import plugins from their respective subpaths:
44
44
  // - @farm.js/plugin/rsc
45
45
  // - @farm.js/plugin/middleware
@@ -63,7 +63,7 @@ import {
63
63
  `;
64
64
  if (ctx.actionsEnabled) {
65
65
  imports += `import { setServerCallback, encodeReply, createTemporaryReferenceSet } from '@vitejs/plugin-rsc/browser';
66
- import { applyFarmCacheInvalidations } from '@farm.js/core/cache';
66
+ import { applyFarmCacheInvalidations } from '@farm.js/core/internal/client-runtime';
67
67
  import {
68
68
  beginFarmServerQueryAction,
69
69
  completeFarmServerQueryAction,
@@ -1 +1 @@
1
- {"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/rsc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAe5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAy+B1D"}
1
+ {"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/rsc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAe5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAquC1D"}
@@ -1,3 +1,10 @@
1
+ import { createRequire } from "node:module";
2
+ const require_ = createRequire(import.meta.url);
3
+ /** Core's production source for the \`mcp\` plugin, so both servers merge config the same way. */
4
+ function generateMCPPluginSource() {
5
+ const { generateNativeMCPPluginSource } = require_("@farm.js/core/internal/production-runtime");
6
+ return generateNativeMCPPluginSource({ enabled: true });
7
+ }
1
8
  /**
2
9
  * Generates the terminal middleware-result handling shared by the RSC entry
3
10
  * and its executable contract tests.
@@ -46,11 +53,17 @@ export function generateRscEntry(ctx) {
46
53
  const middlewareConfigImports = (ctx.middlewareConfigPaths ?? [])
47
54
  .map((configPath, index) => `import * as FarmMiddlewareConfigModule${index} from ${JSON.stringify(configPath.replace(/\\/g, "/"))};`)
48
55
  .join("\n");
56
+ const mcpConfigImports = (ctx.mcpConfigPaths ?? [])
57
+ .map((configPath, index) => `import * as FarmMCPConfigModule${index} from ${JSON.stringify(configPath.replace(/\\/g, "/"))};`)
58
+ .join("\n");
59
+ const mcpSource = ctx.mcpConfigPaths?.length ? generateMCPPluginSource() : null;
49
60
  const middlewareConfigValues = (ctx.middlewareConfigPaths ?? []).map((_configPath, index) => `(FarmMiddlewareConfigModule${index}.default || FarmMiddlewareConfigModule${index})`);
50
61
  let code = `
51
62
  import React from 'react';
52
63
  import ServerErrorFallback from '/.farm/rsc-entries/error-fallback.tsx';
53
64
  ${middlewareConfigImports}
65
+ ${mcpConfigImports}
66
+ ${mcpSource ? `${mcpSource.importSource}\nimport { mergePluginAPIRoutes } from '@farm.js/core/api/runtime';` : ""}
54
67
  import { registerAPIRouteShape } from '@farm.js/core/api/runtime';
55
68
  import {
56
69
  renderToReadableStream,
@@ -92,9 +105,32 @@ import {
92
105
  getRoutePatternSpecificity,
93
106
  } from '@farm.js/core/internal/production-runtime';
94
107
 
108
+ import {
109
+ FARM_MARKDOWN_CONTENT_TYPE,
110
+ applyMarkdownNegotiationHeaders,
111
+ createFarmMarkdownErrorBody,
112
+ createMarkdownMirrorResponse,
113
+ farmRequestWantsMarkdown,
114
+ } from '@farm.js/core/markdown';
115
+
95
116
  const farmDeploymentId = ${JSON.stringify(ctx.deploymentId)};
96
117
  const farmApiBasePath = ${JSON.stringify(ctx.apiBasePath ?? "/api")};
118
+ const farmMarkdownConfig = ${JSON.stringify(ctx.markdown ?? { enabled: false, expose: [], cache: false, includeMetadata: true })};
97
119
  `;
120
+ if (ctx.llmsTxt?.enabled) {
121
+ code += `import {
122
+ collectFarmLlmsTxtPages,
123
+ createFarmDefaultLlmsTxt,
124
+ createFarmLlmsFullRenderer,
125
+ createFarmLlmsMarkdownReader,
126
+ createFarmMetadataRouteResponse,
127
+ renderFarmLlmsFullTxt,
128
+ } from '@farm.js/core/internal/production-runtime';
129
+
130
+ const farmLlmsTxtConfig = ${JSON.stringify(ctx.llmsTxt)};
131
+ const farmLlmsFullRenderer = createFarmLlmsFullRenderer({ revalidate: farmLlmsTxtConfig.revalidate });
132
+ `;
133
+ }
98
134
  if (ctx.actionsEnabled) {
99
135
  code += `import {
100
136
  createServerActionRequestErrorResponse,
@@ -106,6 +142,56 @@ const farmApiBasePath = ${JSON.stringify(ctx.apiBasePath ?? "/api")};
106
142
  } from '@farm.js/core/server-action-security';
107
143
 
108
144
  const serverActionSecurity = ${JSON.stringify(ctx.serverActions)};
145
+ `;
146
+ }
147
+ // In development, a page, layout, loading or error file that fails to load
148
+ // fails only the routes that use it. Eager globs would fail the whole entry,
149
+ // so every route returned the same error until the file was fixed. The
150
+ // modules still load once, in order, before the first request. Middleware
151
+ // and API routes stay eager: skipping a broken auth middleware would leave
152
+ // its routes unprotected. Production keeps eager globs, where a broken
153
+ // import already fails the build.
154
+ const isolateRouteModules = ctx.development === true;
155
+ const uiRouteGlob = (pattern) => isolateRouteModules
156
+ ? `await loadFarmDevRouteModules(import.meta.glob(${JSON.stringify(pattern)}))`
157
+ : `import.meta.glob(${JSON.stringify(pattern)}, { eager: true })`;
158
+ if (isolateRouteModules) {
159
+ code += `
160
+ const farmRouteLoadErrors = new Map();
161
+
162
+ async function loadFarmDevRouteModules(loaders) {
163
+ const modules = {};
164
+ for (const [filePath, load] of Object.entries(loaders)) {
165
+ try {
166
+ modules[filePath] = await load();
167
+ } catch (error) {
168
+ console.error('[Farm.js] Could not load ' + filePath + ':', error);
169
+ const failed = {
170
+ default: function FarmRouteLoadFailure() {
171
+ throw error;
172
+ },
173
+ };
174
+ farmRouteLoadErrors.set(failed, error);
175
+ modules[filePath] = failed;
176
+ }
177
+ }
178
+ return modules;
179
+ }
180
+
181
+ /** The load error of a module the matched route renders with, if any. */
182
+ function findFarmRouteLoadError(matched) {
183
+ if (farmRouteLoadErrors.size === 0) return undefined;
184
+ const routeModules = [
185
+ pages[matched.pattern],
186
+ ...getRouteModules(matched.pattern, layouts, 'layout'),
187
+ ...getRouteModules(matched.pattern, loadings, 'loading'),
188
+ ...getRouteModules(matched.pattern, errors, 'error'),
189
+ ];
190
+ for (const module of routeModules) {
191
+ if (farmRouteLoadErrors.has(module)) return farmRouteLoadErrors.get(module);
192
+ }
193
+ return undefined;
194
+ }
109
195
  `;
110
196
  }
111
197
  // Auto-discover pages, layouts, and middleware using Vite's glob import
@@ -136,10 +222,10 @@ function applyActionResponseHeaders(headers, request) {
136
222
 
137
223
  // Auto-discover all route modules. Every glob remains a literal so Vite can analyze it.
138
224
  ${routeSourceRoots
139
- .map((root, index) => `const pages${index} = import.meta.glob(${JSON.stringify(`${root.glob}/**/page.{tsx,jsx,ts,js}`)}, { eager: true });
140
- const layouts${index} = import.meta.glob(${JSON.stringify(`${root.glob}/**/layout.{tsx,jsx,ts,js}`)}, { eager: true });
141
- const loadings${index} = import.meta.glob(${JSON.stringify(`${root.glob}/**/loading.{tsx,jsx,ts,js}`)}, { eager: true });
142
- const errors${index} = import.meta.glob(${JSON.stringify(`${root.glob}/**/error.{tsx,jsx,ts,js}`)}, { eager: true });
225
+ .map((root, index) => `const pages${index} = ${uiRouteGlob(`${root.glob}/**/page.{tsx,jsx,ts,js}`)};
226
+ const layouts${index} = ${uiRouteGlob(`${root.glob}/**/layout.{tsx,jsx,ts,js}`)};
227
+ const loadings${index} = ${uiRouteGlob(`${root.glob}/**/loading.{tsx,jsx,ts,js}`)};
228
+ const errors${index} = ${uiRouteGlob(`${root.glob}/**/error.{tsx,jsx,ts,js}`)};
143
229
  const middlewares${index} = import.meta.glob(${JSON.stringify(`${root.glob}/**/middleware.{tsx,jsx,ts,js}`)}, { eager: true });
144
230
  const apiRouteModules${index} = import.meta.glob(${JSON.stringify(`${root.glob}/api/**/route.{tsx,jsx,ts,js}`)}, { eager: true });
145
231
  const routeDefinitionModules${index} = import.meta.glob(${JSON.stringify(root.sourceGlob === root.glob
@@ -283,7 +369,39 @@ function registerApiRouteSources(fileModules, definitionModules, sourceCount) {
283
369
  }
284
370
 
285
371
  registerApiRouteSources(apiRouteModules, routeDefinitionModules, ${routeSourceRoots.length});
286
-
372
+ ${mcpSource
373
+ ? `
374
+ // mcp: the same plugin core's production server mounts, built from the mcp
375
+ // config read from each config file, layers first.
376
+ const farmNativeMCPPlugin = (() => {
377
+ const farmRuntimeConfigs = [${(ctx.mcpConfigPaths ?? [])
378
+ .map((_path, index) => `(FarmMCPConfigModule${index}.default || FarmMCPConfigModule${index})`)
379
+ .join(", ")}];
380
+ ${mcpSource.registerSource}
381
+ return farmNativeMCPPlugin;
382
+ })();
383
+ if (farmNativeMCPPlugin) {
384
+ const mountedRoutes = [...apiRouteMap.values()].map((route) => ({
385
+ path: route.path,
386
+ methods: [...route.methods],
387
+ endpoints: { ...route.handlers },
388
+ }));
389
+ // Rejects a plugin route that would replace an app endpoint.
390
+ for (const route of mergePluginAPIRoutes(mountedRoutes, [farmNativeMCPPlugin])) {
391
+ for (const method of route.pluginMethods ?? []) {
392
+ let target = apiRouteMap.get(route.path);
393
+ if (!target) {
394
+ target = { path: route.path, methods: [], handlers: {}, files: {}, sources: {} };
395
+ apiRouteMap.set(route.path, target);
396
+ }
397
+ target.methods.push(method);
398
+ target.handlers[method] = route.endpoints[method];
399
+ target.files[method] = 'plugin:' + farmNativeMCPPlugin.name;
400
+ }
401
+ }
402
+ }
403
+ `
404
+ : ""}
287
405
  async function handleAPIRequest(request) {
288
406
  const url = new URL(request.url);
289
407
  const match = matchAPIRouteAtBasePath(apiRouteMap, url.pathname, farmApiBasePath);
@@ -576,7 +694,12 @@ async function handleFarmRequest(request, context) {
576
694
  if (apiResponse) {
577
695
  return applyProductionMiddlewareHeaders(apiResponse, middlewareHeaders);
578
696
  }
579
- if (isFarmAPIPathname(url.pathname, farmApiBasePath) || isFarmAPIPathname(url.pathname)) {
697
+ ${ctx.llmsTxt?.enabled
698
+ ? `// agent.llmsTxt: answered after middleware, so its redirects and headers apply.
699
+ const llmsResponse = await handleFarmLlmsTxtRequest(request, context);
700
+ if (llmsResponse) return applyProductionMiddlewareHeaders(llmsResponse, middlewareHeaders);
701
+ `
702
+ : ""}if (isFarmAPIPathname(url.pathname, farmApiBasePath) || isFarmAPIPathname(url.pathname)) {
580
703
  return applyProductionMiddlewareHeaders(new Response(
581
704
  JSON.stringify({ error: 'API route not found', pathname: url.pathname }),
582
705
  { status: 404, headers: { 'Content-Type': 'application/json' } },
@@ -731,11 +854,26 @@ async function handleFarmRequest(request, context) {
731
854
 
732
855
  if (!matched) {
733
856
  debug('404 - No route found for:', url.pathname);
857
+ // Agents that read in Markdown get a Markdown 404, as in core's server.
858
+ if (farmMarkdownConfig.enabled && farmRequestWantsMarkdown(url.pathname, request.headers.get('accept'))) {
859
+ return new Response(createFarmMarkdownErrorBody(404, url.pathname), {
860
+ status: 404,
861
+ headers: {
862
+ 'Content-Type': FARM_MARKDOWN_CONTENT_TYPE,
863
+ 'X-Farm-Markdown-Error': '404',
864
+ 'Cache-Control': 'no-store',
865
+ },
866
+ });
867
+ }
734
868
  return new Response('Not Found', { status: 404 });
735
869
  }
736
870
 
737
871
  const { Page, pattern, params, pageMetadata } = matched;
738
- const LayoutModules = getLayoutModules(pattern);
872
+ ${isolateRouteModules
873
+ ? `const routeLoadError = findFarmRouteLoadError(matched);
874
+ if (routeLoadError) throw routeLoadError;
875
+ `
876
+ : ""}const LayoutModules = getLayoutModules(pattern);
739
877
  const metadata = mergeDocumentMetadata(
740
878
  ...LayoutModules.map((layoutModule) => layoutModule.metadata),
741
879
  pageMetadata,
@@ -894,7 +1032,11 @@ async function handleFarmRequest(request, context) {
894
1032
  )
895
1033
  );
896
1034
  } catch (err) {
897
- const redirect = getFarmRedirectError(err);
1035
+ ${isolateRouteModules
1036
+ ? `// A file that failed to load: show the dev error page, not error.tsx.
1037
+ if ([...farmRouteLoadErrors.values()].includes(err)) throw err;
1038
+ `
1039
+ : ""}const redirect = getFarmRedirectError(err);
898
1040
  if (redirect) return new Response(null, { status: redirect.status, headers: { location: redirect.url, 'cache-control': 'no-store' } });
899
1041
  if (isFarmNotFoundError(err)) return new Response('Not Found', { status: 404, headers: { 'cache-control': 'no-store' } });
900
1042
  console.error('[RSC] Handler error:', err);
@@ -980,13 +1122,116 @@ async function handleFarmRequest(request, context) {
980
1122
  }
981
1123
  }
982
1124
 
1125
+ ${ctx.llmsTxt?.enabled
1126
+ ? `/**
1127
+ * agent.llmsTxt, built the same way as core's production server: /llms.txt
1128
+ * lists the app's static pages and links to their Markdown mirrors, and
1129
+ * /llms-full.txt inlines each mirror.
1130
+ */
1131
+ function createFarmLlmsTxtContext(request, context, full) {
1132
+ const origin = new URL(request.url).origin;
1133
+ const pages = collectFarmLlmsTxtPages(
1134
+ pageRoutes.map(({ module, segments }) => ({
1135
+ // Dynamic routes have no single URL, so the collector skips them.
1136
+ pattern: '/' + segments
1137
+ .map((part) => (part.isDynamic ? '[' + part.segment + ']' : part.segment))
1138
+ .join('/'),
1139
+ metadata: module && module.metadata,
1140
+ })),
1141
+ {
1142
+ origin,
1143
+ markdown: farmMarkdownConfig,
1144
+ include: farmLlmsTxtConfig.include,
1145
+ exclude: farmLlmsTxtConfig.exclude,
1146
+ },
1147
+ );
1148
+ const rootLayout = getRouteModules('/page.tsx', layouts, 'layout')[0];
1149
+ return {
1150
+ defaults: createFarmDefaultLlmsTxt({
1151
+ origin,
1152
+ pages,
1153
+ config: farmLlmsTxtConfig,
1154
+ rootMetadata: rootLayout && rootLayout.metadata,
1155
+ }),
1156
+ // Pages are read in-process through the full handler with a fresh request,
1157
+ // so the caller's cookies never shape the file. HEAD reads nothing.
1158
+ markdown: full && request.method.toUpperCase() !== 'HEAD'
1159
+ ? createFarmLlmsMarkdownReader((page) => handler(page, context))
1160
+ : async () => null,
1161
+ };
1162
+ }
1163
+
1164
+ async function handleFarmLlmsTxtRequest(request, context) {
1165
+ const { origin, pathname } = new URL(request.url);
1166
+ const kind = pathname === '/llms.txt'
1167
+ ? 'llms'
1168
+ : farmLlmsTxtConfig.full && pathname === '/llms-full.txt' ? 'llms-full' : null;
1169
+ if (!kind) return null;
1170
+ const method = request.method.toUpperCase();
1171
+ if (method !== 'GET' && method !== 'HEAD') {
1172
+ return new Response(null, { status: 405, headers: { Allow: 'GET, HEAD' } });
1173
+ }
1174
+ const llmsContext = createFarmLlmsTxtContext(request, context, kind === 'llms-full');
1175
+ // A page that times out is left out, and that response is neither reused nor cached.
1176
+ let complete = true;
1177
+ const renderFull = (shared) =>
1178
+ renderFarmLlmsFullTxt(llmsContext.defaults, {
1179
+ origin,
1180
+ readMarkdown: llmsContext.markdown,
1181
+ onIncomplete: () => {
1182
+ complete = false;
1183
+ if (shared) shared.incomplete();
1184
+ },
1185
+ });
1186
+ // HEAD reads no pages, so it neither waits for nor fills the shared render.
1187
+ const body = kind === 'llms'
1188
+ ? llmsContext.defaults
1189
+ : method === 'HEAD'
1190
+ ? await renderFull()
1191
+ : await farmLlmsFullRenderer(origin, renderFull, (settled) => {
1192
+ complete = settled;
1193
+ });
1194
+ const response = createFarmMetadataRouteResponse(
1195
+ kind,
1196
+ body,
1197
+ { revalidate: complete ? farmLlmsTxtConfig.revalidate : 0 },
1198
+ { method, request },
1199
+ );
1200
+ if (!complete) response.headers.set('cache-control', 'no-store');
1201
+ return response;
1202
+ }
1203
+
1204
+ `
1205
+ : ""}/**
1206
+ * Serves a page's Markdown mirror (\`/page.md\` or \`Accept: text/markdown\`) by
1207
+ * rendering the page through the normal request path, so middleware and sign-in
1208
+ * gates apply; every other request renders as usual, and HTML pages advertise
1209
+ * their mirror with a Link header.
1210
+ */
1211
+ async function handleFarmPageOrMarkdown(request, context) {
1212
+ if (!farmMarkdownConfig.enabled) return handleFarmRequest(request, context);
1213
+ const markdown = await createMarkdownMirrorResponse({
1214
+ request,
1215
+ config: farmMarkdownConfig,
1216
+ routeExists: (pathname) => Boolean(matchRoute(pathname)),
1217
+ renderPage: (pageRequest) => handleFarmRequest(pageRequest, context),
1218
+ apiServerBasePath: farmApiBasePath,
1219
+ });
1220
+ if (markdown) return markdown;
1221
+ const response = await handleFarmRequest(request, context);
1222
+ return applyMarkdownNegotiationHeaders(response, {
1223
+ config: farmMarkdownConfig,
1224
+ pathname: new URL(request.url).pathname,
1225
+ });
1226
+ }
1227
+
983
1228
  async function handler(request, context) {
984
1229
  return _runWithAPIRequestRuntime({
985
1230
  basePath: farmApiBasePath,
986
1231
  dispatch: async (localRequest) =>
987
1232
  (await handleAPIRequest(localRequest)) ?? Response.json({ error: 'Not Found' }, { status: 404 }),
988
1233
  }, () => _runWithCurrentRequest(request, () =>
989
- _runWithAfterRequest(request, () => handleFarmRequest(request, context), context)
1234
+ _runWithAfterRequest(request, () => handleFarmPageOrMarkdown(request, context), context)
990
1235
  ));
991
1236
  }
992
1237
 
@@ -28,6 +28,9 @@ import type { FarmAPIConfig } from "@farm.js/core/api";
28
28
  import type { FarmMiddlewareConfig } from "@farm.js/core/middleware";
29
29
  import type { FarmServerConfig } from "@farm.js/core/internal/production-runtime";
30
30
  import type { FarmLayerEntry, ResolvedFarmLayer } from "@farm.js/core/server";
31
+ import { type FarmMarkdownUserConfig } from "@farm.js/core/markdown";
32
+ import type { FarmLlmsTxtUserConfig } from "@farm.js/core/internal/production-runtime";
33
+ import type { FarmMCPUserConfig } from "@farm.js/core/server";
31
34
  export type { FarmRscPluginOptions, EntryContext };
32
35
  export { buildRscNitro, waitForRscManifest, waitForRscOutputs } from "./nitro-build.js";
33
36
  export type { BuildRscNitroOptions } from "./nitro-build.js";
@@ -77,6 +80,29 @@ export interface FarmRscConfig {
77
80
  };
78
81
  /** Extra Vite plugins (e.g. rsc() with entries so client build resolves virtual:vite-rsc/client-references). */
79
82
  plugins?: any[];
83
+ /**
84
+ * Markdown mirrors for agents: `/page.md` and `Accept: text/markdown`, with
85
+ * `?outline`, `?section`, `?max_tokens`, and `?actions`. Same options as core's `md`.
86
+ * @default true
87
+ */
88
+ md?: FarmMarkdownUserConfig | boolean;
89
+ /**
90
+ * Agent-facing files. `llmsTxt` serves `/llms.txt`, an index of the app's
91
+ * static pages that links to their Markdown mirrors, and with `full: true`
92
+ * also `/llms-full.txt`, which inlines them. Same options as core's
93
+ * `agent.llmsTxt`; `false` turns it off.
94
+ * @default { llmsTxt: { full: false } }
95
+ */
96
+ agent?: {
97
+ llmsTxt?: boolean | FarmLlmsTxtUserConfig;
98
+ };
99
+ /**
100
+ * An MCP endpoint for agents, with the same options as core's top-level
101
+ * `mcp`. Requires `@farm.js/mcp`. Declare it directly in this config object:
102
+ * the server reads it, and only the bindings it uses, from this file.
103
+ * `oauth` is not supported in RSC apps yet.
104
+ */
105
+ mcp?: FarmMCPUserConfig;
80
106
  }
81
107
  /**
82
108
  * Define a Farm.js RSC configuration
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rsc/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,E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AAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,gHAAgH;IAChH,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB;;;;OAIG;IACH,EAAE,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC;IACtC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAA;KAAE,CAAC;IACtD;;;;;OAKG;IACH,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,aAAkB,GAAG,UAAU,CA0DnE;AA2ZD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAikC5E"}
package/dist/rsc/index.js CHANGED
@@ -27,6 +27,7 @@ import { init as initModuleLexer, parse as parseModuleImports } from "es-module-
27
27
  import { farmEnvironmentFunctionsPlugin } from "@farm.js/core/environment/vite";
28
28
  import { generateClientCachePersistenceCode, resolveFarmClientCacheAdapterEntry, } from "@farm.js/core/vite";
29
29
  import { generateRscEntry } from "./entries/rsc.js";
30
+ import { resolveMarkdownConfig } from "@farm.js/core/markdown";
30
31
  import { generateSsrEntry } from "./entries/ssr.js";
31
32
  import { generateErrorFallbackEntry } from "./entries/error-fallback.js";
32
33
  import { generateClientEntry, serverFnTransportErrorClientRuntime } from "./entries/client.js";
@@ -36,7 +37,7 @@ import { transformAutomaticOptimizedBoundaries } from "./automatic-optimized-bou
36
37
  import { resolveRscBuildOutputPath } from "./build-paths.js";
37
38
  import { assertRscPackageCompatibility } from "./compatibility.js";
38
39
  import { sendRscDevelopmentResponse } from "./dev-response.js";
39
- import { loadRscMiddlewareConfigModule } from "./middleware-config-module.js";
40
+ import { loadRscConfigPropertyModule, loadRscMiddlewareConfigModule, } from "./middleware-config-module.js";
40
41
  import fs from "fs/promises";
41
42
  import path from "path";
42
43
  import { devServableFileExists } from "../dev-static.js";
@@ -46,11 +47,12 @@ import { createRequire } from "node:module";
46
47
  // Use API and middleware plugins from @farm.js/core (require so CJS build resolves when ESM .mjs is missing)
47
48
  const require_ = createRequire(import.meta.url);
48
49
  const { farmApiPlugin } = require_("@farm.js/core");
50
+ const { FARM_VERSION } = require_("@farm.js/core/version");
49
51
  const { farmMiddlewarePlugin } = require_("@farm.js/core/middleware");
50
52
  const { resolveServerActionsConfig, validateServerActionRequest, createServerActionRequestErrorResponse, } = require_("@farm.js/core/server-action-security");
51
53
  const { normalizeFarmDeploymentId } = require_("@farm.js/core/deployment");
52
- const { getFarmLayerAliases, getFarmSourceRoots, resolveFarmLayers } = require_("@farm.js/core/server");
53
- const { searchParamsToObject, readNodeRequestBody, resolveFarmServerConfig, resolveFarmI18nConfig, createFarmRequestBodyErrorResponse, } = require_("@farm.js/core/internal/production-runtime");
54
+ const { getFarmLayerAliases, getFarmSourceRoots, resolveFarmLayers, resolveFarmMCPConfig, resolveFarmMCPPlugin, } = require_("@farm.js/core/server");
55
+ const { readNodeRequestBody, resolveFarmServerConfig, resolveFarmI18nConfig, createFarmRequestBodyErrorResponse, createDefaultErrorMarkup, resolveFarmLlmsTxtConfig, } = require_("@farm.js/core/internal/production-runtime");
54
56
  const { isFarmAPIPathname } = require_("@farm.js/core/api/runtime");
55
57
  const { resolveFarmAPIConfig, resolveFarmAPIServerBasePath } = require_("@farm.js/core/api");
56
58
  const { getResolvedEnv } = require_("@farm.js/core/env");
@@ -80,6 +82,9 @@ export function defineConfig(config = {}) {
80
82
  serverActions: config.serverActions,
81
83
  deploymentId: config.deploymentId,
82
84
  generateBuildId: config.generateBuildId,
85
+ md: config.md,
86
+ agent: config.agent,
87
+ mcp: config.mcp,
83
88
  // Vite server configuration
84
89
  server: {
85
90
  ...config.server,
@@ -88,11 +93,6 @@ export function defineConfig(config = {}) {
88
93
  },
89
94
  // Custom logger to hide Vite's default startup banner
90
95
  customLogger: createFarmLogger(port, debug),
91
- // Configure esbuild for JSX transformation
92
- esbuild: {
93
- jsx: "automatic",
94
- jsxImportSource: "react",
95
- },
96
96
  plugins: [
97
97
  farmMiddlewarePlugin({
98
98
  srcDir: config.srcDir ?? "src",
@@ -103,6 +103,8 @@ export function defineConfig(config = {}) {
103
103
  srcDir: config.srcDir ?? "src",
104
104
  debug,
105
105
  bodySizeLimit: config.server?.bodySizeLimit,
106
+ // The dev API server mounts the MCP endpoint, as core's does.
107
+ ...(config.mcp ? { plugins: ({ root }) => resolveRscMCPPlugins(config.mcp, root) } : {}),
106
108
  }),
107
109
  farmRsc({
108
110
  debug,
@@ -184,6 +186,7 @@ const VIRTUAL_HYDRATE_ENTRY = "virtual:@farm.js/rsc/hydrate";
184
186
  const OPTIMIZED_BOUNDARY_ADAPTER = "@farm.js/plugin/rsc/optimized-boundary";
185
187
  const STRATA_PACKAGE = "@farming-labs/strata";
186
188
  const RSC_MIDDLEWARE_CONFIG_QUERY = "?farm-rsc-middleware";
189
+ const RSC_MCP_CONFIG_QUERY = "?farm-rsc-mcp";
187
190
  const FARM_CORE_PACKAGE_ROOT = path.resolve(path.dirname(require_.resolve("@farm.js/core")), "..");
188
191
  const FARM_CONFIG_FILENAMES = [
189
192
  "farm.config.ts",
@@ -228,6 +231,19 @@ async function findFarmConfigPath(root) {
228
231
  }
229
232
  return null;
230
233
  }
234
+ /** Resolves `mcp` for an RSC app, rejecting what the RSC server cannot serve yet. */
235
+ function resolveRscMCPConfig(input) {
236
+ const config = resolveFarmMCPConfig(input);
237
+ if (config.enabled && config.oauth) {
238
+ throw new Error("[Farm.js] mcp.oauth is not supported in RSC apps yet: the RSC server does not serve " +
239
+ "the protected-resource metadata. Remove oauth, or validate tokens in mcp.authorize.");
240
+ }
241
+ return config;
242
+ }
243
+ async function resolveRscMCPPlugins(input, root) {
244
+ const plugin = await resolveFarmMCPPlugin(resolveRscMCPConfig(input), { root });
245
+ return plugin ? [plugin] : [];
246
+ }
231
247
  async function resolveMiddlewareConfigPaths(root, layers) {
232
248
  const paths = (layers ?? []).flatMap((layer) => layer.configFile ? [path.resolve(layer.configFile)] : []);
233
249
  const projectConfigPath = await findFarmConfigPath(root);
@@ -240,6 +256,23 @@ function isOptimizedBoundaryModule(id) {
240
256
  id === STRATA_PACKAGE ||
241
257
  id.startsWith(`${STRATA_PACKAGE}/`));
242
258
  }
259
+ /** The development error page for a failed RSC render: core's error page, with the real error. */
260
+ function createRscDevErrorDocument(error, method, pathname) {
261
+ const failure = error instanceof Error ? error : new Error(String(error));
262
+ const markup = createDefaultErrorMarkup({
263
+ statusCode: 500,
264
+ requestPath: pathname,
265
+ method,
266
+ message: failure.message,
267
+ errorName: failure.name,
268
+ stack: failure.stack,
269
+ development: true,
270
+ mode: "development",
271
+ farmVersion: FARM_VERSION,
272
+ nodeVersion: process.version,
273
+ });
274
+ return `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>500 · Farm.js</title></head><body>${markup}</body></html>`;
275
+ }
243
276
  function resolveOptimizedBoundaryRuntimeRoot() {
244
277
  try {
245
278
  return path.dirname(require_.resolve(`${STRATA_PACKAGE}/package.json`));
@@ -451,6 +484,7 @@ export default function farmRsc(options = {}) {
451
484
  let entryContext;
452
485
  let rscBuildRoot;
453
486
  const middlewareConfigModules = new Map();
487
+ let mcpConfigCandidates = null;
454
488
  // Store for debugging
455
489
  const debug = options.debug ?? false;
456
490
  const automaticDeploymentId = `build-${Date.now()}`;
@@ -544,10 +578,38 @@ export default function farmRsc(options = {}) {
544
578
  name: "@farm.js/plugin/rsc:middleware-config",
545
579
  enforce: "pre",
546
580
  resolveId(id) {
547
- if (!id.endsWith(RSC_MIDDLEWARE_CONFIG_QUERY))
581
+ if (!id.endsWith(RSC_MIDDLEWARE_CONFIG_QUERY) && !id.endsWith(RSC_MCP_CONFIG_QUERY)) {
548
582
  return null;
583
+ }
549
584
  return id.replace(/\\/g, "/");
550
585
  },
586
+ // The MCP config is read from the Vite config file too, whose path is
587
+ // only known here. Entries are generated on load, after this runs.
588
+ async configResolved(resolved) {
589
+ if (!mcpConfigCandidates || !entryContext)
590
+ return;
591
+ const configPaths = [...mcpConfigCandidates];
592
+ if (resolved.configFile)
593
+ configPaths.push(path.resolve(resolved.configFile));
594
+ const mcpConfigPaths = [];
595
+ for (const configPath of new Set(configPaths)) {
596
+ const extracted = await loadRscConfigPropertyModule(configPath, "mcp");
597
+ if (extracted.kind === "unsupported") {
598
+ throw new Error(`[Farm.js] Cannot read mcp for the RSC server from ${configPath}: ${extracted.reason}. ` +
599
+ "Declare mcp directly in defineConfig({ mcp: ... }).");
600
+ }
601
+ if (extracted.kind === "absent")
602
+ continue;
603
+ const moduleId = `${configPath.replace(/\\/g, "/")}${RSC_MCP_CONFIG_QUERY}`;
604
+ middlewareConfigModules.set(moduleId, extracted.code);
605
+ mcpConfigPaths.push(moduleId);
606
+ }
607
+ if (mcpConfigPaths.length === 0) {
608
+ throw new Error("[Farm.js] The RSC server could not find the mcp config. " +
609
+ "Declare mcp directly in defineConfig({ mcp: ... }) in your Vite or Farm config file.");
610
+ }
611
+ entryContext.mcpConfigPaths = mcpConfigPaths;
612
+ },
551
613
  load(id) {
552
614
  return middlewareConfigModules.get(id.replace(/\\/g, "/")) ?? null;
553
615
  },
@@ -612,6 +674,11 @@ export default function farmRsc(options = {}) {
612
674
  Object.assign(c, layerResolution.config);
613
675
  }
614
676
  middlewareConfigModules.clear();
677
+ // The config files mcp is read from at runtime; the Vite config file is
678
+ // added once it is known, in configResolved.
679
+ mcpConfigCandidates = resolveRscMCPConfig(c.mcp).enabled
680
+ ? await resolveMiddlewareConfigPaths(root, c.layers)
681
+ : null;
615
682
  const middlewareConfigPaths = [];
616
683
  if (hasFarmMiddlewareConfig(c.middleware)) {
617
684
  const configPaths = await resolveMiddlewareConfigPaths(root, c.layers);
@@ -693,6 +760,9 @@ export default function farmRsc(options = {}) {
693
760
  allowedOrigins: options.serverActions?.allowedOrigins ?? c.serverActions?.allowedOrigins,
694
761
  }),
695
762
  deploymentId,
763
+ markdown: resolveMarkdownConfig(c.md),
764
+ // Core's default for an app without docs: llms.txt on, llms-full.txt off.
765
+ llmsTxt: resolveFarmLlmsTxtConfig(c.agent?.llmsTxt ?? { full: false }),
696
766
  // Resolved the same way core resolves it for the config, so RSC and
697
767
  // non-RSC apps match middleware against the same pathname.
698
768
  i18n: resolveFarmI18nConfig(c.i18n, {
@@ -809,10 +879,11 @@ export default function farmRsc(options = {}) {
809
879
  : []),
810
880
  ],
811
881
  },
812
- esbuild: {
813
- jsx: "automatic",
814
- jsxImportSource: "react",
815
- },
882
+ // Vite 8 compiles with oxc, which already uses the automatic runtime;
883
+ // setting esbuild there only prints a "both options were set" warning.
884
+ ...(this?.meta?.rolldownVersion
885
+ ? {}
886
+ : { esbuild: { jsx: "automatic", jsxImportSource: "react" } }),
816
887
  ...(c.layers?.length
817
888
  ? {
818
889
  server: {
@@ -829,7 +900,14 @@ export default function farmRsc(options = {}) {
829
900
  copyPublicDir: false,
830
901
  rollupOptions: { input: { index: entryRsc } },
831
902
  },
832
- resolve: { conditions: ["react-server", "node", "import"] },
903
+ resolve: {
904
+ conditions: ["react-server", "node", "import"],
905
+ // Strata is a native CommonJS loader: Node must load it, not Vite's
906
+ // module runner. ssr.external does not reach this environment.
907
+ ...(optimizedBoundaryEnabled
908
+ ? { external: [STRATA_PACKAGE, `${STRATA_PACKAGE}/react-server`] }
909
+ : {}),
910
+ },
833
911
  },
834
912
  ssr: {
835
913
  build: {
@@ -845,6 +923,19 @@ export default function farmRsc(options = {}) {
845
923
  rollupOptions: { input: { index: entryClient } },
846
924
  },
847
925
  resolve: { conditions: ["browser", "import"] },
926
+ // Optimize what the browser entry needs up front. A dependency first
927
+ // found on page load makes Vite re-optimize and reload, and until the
928
+ // reload client components can see two React copies ("Invalid hook call").
929
+ optimizeDeps: {
930
+ include: [
931
+ "react",
932
+ "react/jsx-runtime",
933
+ "react/jsx-dev-runtime",
934
+ "react-dom",
935
+ "react-dom/client",
936
+ "rsc-html-stream/client",
937
+ ],
938
+ },
848
939
  },
849
940
  },
850
941
  };
@@ -1109,7 +1200,6 @@ if (document.readyState === 'loading') {
1109
1200
  logInfo("Dev server middleware ready");
1110
1201
  const serverStartTime = Date.now();
1111
1202
  let bannerPrinted = false;
1112
- const pageCache = new Map();
1113
1203
  server.httpServer?.once("listening", () => {
1114
1204
  if (bannerPrinted)
1115
1205
  return;
@@ -1119,7 +1209,7 @@ if (document.readyState === 'loading') {
1119
1209
  const port = typeof address === "object" && address ? address.port : 3000;
1120
1210
  const colors = getColors();
1121
1211
  console.log("");
1122
- console.log(` ${colors.bold(colors.green("Farm.js"))} ${colors.dim("v1.0.0")} ${colors.dim(`ready in ${elapsed}ms`)}`);
1212
+ console.log(` ${colors.bold(colors.green("Farm.js"))} ${colors.dim(`v${FARM_VERSION}`)} ${colors.dim(`ready in ${elapsed}ms`)}`);
1123
1213
  console.log("");
1124
1214
  console.log(` ${colors.dim("➜")} ${colors.bold("Local:")} ${colors.cyan(`http://localhost:${port}/`)}`);
1125
1215
  console.log(` ${colors.dim("➜")} ${colors.bold("Network:")} ${colors.dim("use --host to expose")}`);
@@ -1229,276 +1319,15 @@ if (document.readyState === 'loading') {
1229
1319
  res.destroy(rscError instanceof Error ? rscError : new Error(String(rscError)));
1230
1320
  return;
1231
1321
  }
1232
- // RSC pipeline failed; fall back to legacy SSR for GET only
1233
- if (method !== "GET" || rscError instanceof FarmDevEnvironmentError) {
1234
- const duration = Date.now() - startTime;
1235
- logResponse(method, pathname, 500, duration);
1236
- console.error("[Farm.js] RSC dev handler error:", rscError);
1237
- res.statusCode = 500;
1238
- res.setHeader("Content-Type", "text/html");
1239
- res.end(`<!DOCTYPE html><html><head><title>Error</title></head><body><pre>${rscError.message}</pre></body></html>`);
1240
- return;
1241
- }
1242
- }
1243
- try {
1244
- if (method !== "GET")
1245
- return next();
1246
- // Get middleware data from standalone middleware plugin
1247
- const middlewareData = req.__FARM_MIDDLEWARE_DATA__ || {};
1248
- // Build the glob pattern for discovering routes (Farm convention: src/app when routesDir unset)
1249
- const srcDir = entryContext.srcDir;
1250
- const appSegment = entryContext.routesDir === undefined ? "app" : entryContext.routesDir.trim();
1251
- const glob = appSegment ? `/${srcDir}/${appSegment}` : `/${srcDir}`;
1252
- // Find matching page file
1253
- const normalized = pathname.replace(/\/$/, "") || "/";
1254
- // Common page file patterns
1255
- const possiblePaths = [
1256
- `${glob}${normalized === "/" ? "" : normalized}/page.tsx`,
1257
- `${glob}${normalized === "/" ? "" : normalized}/page.jsx`,
1258
- `${glob}/page.tsx`,
1259
- `${glob}/page.jsx`,
1260
- ];
1261
- // Also check for dynamic routes by walking up the path
1262
- const parts = normalized.split("/").filter(Boolean);
1263
- for (let i = parts.length; i >= 0; i--) {
1264
- const base = parts.slice(0, i).join("/");
1265
- possiblePaths.push(base ? `${glob}/${base}/page.tsx` : `${glob}/page.tsx`);
1266
- possiblePaths.push(base ? `${glob}/${base}/page.jsx` : `${glob}/page.jsx`);
1267
- }
1268
- let pageModule = null;
1269
- let matchedPath = "";
1270
- let layoutModule = null;
1271
- // Try to find and load the page
1272
- for (const pagePath of possiblePaths) {
1273
- try {
1274
- // Convert glob path to actual file path
1275
- const actualPath = pagePath.startsWith("/") ? `.${pagePath}` : pagePath;
1276
- if (pageCache.has(pagePath)) {
1277
- pageModule = pageCache.get(pagePath);
1278
- matchedPath = pagePath;
1279
- break;
1280
- }
1281
- pageModule = await loadFarmDevModule(server, actualPath);
1282
- if (pageModule?.default) {
1283
- pageCache.set(pagePath, pageModule);
1284
- matchedPath = pagePath;
1285
- // Page loaded successfully
1286
- break;
1287
- }
1288
- }
1289
- catch (e) {
1290
- // Page not found at this path, continue
1291
- }
1292
- }
1293
- if (!pageModule?.default) {
1294
- return next();
1295
- }
1296
- try {
1297
- const layoutPath = `./${srcDir}${appSegment ? `/${appSegment}` : ""}/layout.tsx`;
1298
- layoutModule = await loadFarmDevModule(server, layoutPath);
1299
- }
1300
- catch { }
1301
- const React = await import("react");
1302
- const ReactDOMServer = await import("react-dom/server");
1303
- const Page = pageModule.default;
1304
- const metadata = {
1305
- title: typeof pageModule.metadata?.title === "string"
1306
- ? pageModule.metadata.title
1307
- : layoutModule?.metadata?.title,
1308
- description: typeof pageModule.metadata?.description === "string"
1309
- ? pageModule.metadata.description
1310
- : layoutModule?.metadata?.description,
1311
- };
1312
- const Layout = layoutModule?.default;
1313
- // Parse URL params (basic dynamic route support)
1314
- const params = {};
1315
- const searchParams = searchParamsToObject(resolveDevRequestURL(req).searchParams);
1316
- // Render the page with middleware data
1317
- const pageProps = {
1318
- params,
1319
- searchParams,
1320
- // Middleware shared data is available to pages
1321
- middlewareData,
1322
- };
1323
- // Helper to check if a function is async or returns a Promise
1324
- // We need to actually call the function to detect this reliably
1325
- // since transpiled async functions may not be detectable by constructor
1326
- const isAsyncFunction = (fn) => {
1327
- if (!fn)
1328
- return false;
1329
- // Check if it's an AsyncFunction
1330
- if (fn.constructor?.name === "AsyncFunction")
1331
- return true;
1332
- // Check if function.toString() contains async
1333
- try {
1334
- const str = fn.toString();
1335
- // Check for "async function" or "async (" patterns
1336
- if (/^async\s/.test(str) || /^async\s*\(/.test(str))
1337
- return true;
1338
- }
1339
- catch { }
1340
- return false;
1341
- };
1342
- // Try to render the page - if it returns a Promise, it's async
1343
- let pageContent;
1344
- let isAsyncPage = isAsyncFunction(Page);
1345
- try {
1346
- const result = Page(pageProps);
1347
- // Check if result is a Promise (thenable)
1348
- if (result && typeof result.then === "function") {
1349
- isAsyncPage = true;
1350
- pageContent = await result;
1351
- }
1352
- else {
1353
- // If it's not a Promise, it's a React element or we need to use createElement
1354
- if (React.default.isValidElement(result)) {
1355
- pageContent = result;
1356
- }
1357
- else {
1358
- pageContent = React.default.createElement(Page, pageProps);
1359
- }
1360
- }
1361
- }
1362
- catch (e) {
1363
- // If calling directly failed, use createElement
1364
- pageContent = React.default.createElement(Page, pageProps);
1365
- }
1366
- // Check if Layout is async
1367
- let isAsyncLayout = isAsyncFunction(Layout);
1368
- // Wrap in layout if available
1369
- let content = pageContent;
1370
- if (Layout) {
1371
- try {
1372
- const layoutResult = Layout({ children: pageContent });
1373
- if (layoutResult && typeof layoutResult.then === "function") {
1374
- isAsyncLayout = true;
1375
- content = await layoutResult;
1376
- }
1377
- else if (React.default.isValidElement(layoutResult)) {
1378
- content = layoutResult;
1379
- }
1380
- else {
1381
- content = React.default.createElement(Layout, null, pageContent);
1382
- }
1383
- }
1384
- catch (e) {
1385
- content = React.default.createElement(Layout, null, pageContent);
1386
- }
1387
- }
1388
- // Create full HTML page
1389
- const h = React.default.createElement;
1390
- const isSyncPage = !isAsyncPage && !isAsyncLayout;
1391
- // For sync pages we load preamble + vite client + hydrate in one script below; do not load vite-client in head so order is guaranteed.
1392
- const routesDir = entryContext.routesDir === undefined ? "app" : entryContext.routesDir.trim();
1393
- const routesPath = routesDir ? `/${routesDir}` : "";
1394
- const headElements = [
1395
- h("meta", { key: "charset", charSet: "utf-8" }),
1396
- h("meta", {
1397
- key: "viewport",
1398
- name: "viewport",
1399
- content: "width=device-width, initial-scale=1",
1400
- }),
1401
- metadata.title
1402
- ? h("title", { key: "title" }, metadata.title)
1403
- : h("title", { key: "title" }, "Farm.js"),
1404
- metadata.description
1405
- ? h("meta", {
1406
- key: "description",
1407
- name: "description",
1408
- content: metadata.description,
1409
- })
1410
- : null,
1411
- h("link", {
1412
- key: "globals-css",
1413
- rel: "stylesheet",
1414
- href: `/${srcDir}${routesPath}/globals.css`,
1415
- }),
1416
- ...(isSyncPage
1417
- ? []
1418
- : [
1419
- h("script", {
1420
- key: "vite-client",
1421
- type: "module",
1422
- src: "/@vite/client",
1423
- }),
1424
- ]),
1425
- ].filter(Boolean);
1426
- // Create body elements
1427
- // For async (server) pages, we don't hydrate the page itself - only client components within
1428
- // For sync pages, we can hydrate the whole thing
1429
- const bodyElements = [h("div", { key: "root", id: "root" }, content)];
1430
- // Only add hydration script for sync pages (non-async)
1431
- // When server actions are enabled, set __viteRscCallServer first so form submission works.
1432
- if (actionsEnabled) {
1433
- bodyElements.push(h("script", {
1434
- key: "rsc-call-server",
1435
- dangerouslySetInnerHTML: {
1436
- __html: `(function(){if(typeof globalThis.__viteRscCallServer!=='function'){globalThis.__viteRscCallServer=function(){return Promise.reject(new Error('Farm.js: server actions not ready'));}}})();`,
1437
- },
1438
- }));
1439
- }
1440
- // Set React refresh preamble synchronously first so "use client" components don't throw when they load.
1441
- if (!isAsyncPage && !isAsyncLayout) {
1442
- bodyElements.push(h("script", {
1443
- key: "preamble-sync",
1444
- dangerouslySetInnerHTML: {
1445
- __html: `window.__vite_plugin_react_preamble_installed__=true;window.$RefreshReg$=function(){};window.$RefreshSig$=function(){return function(t){return t;}};`,
1446
- },
1447
- }), h("script", {
1448
- key: "page-props",
1449
- dangerouslySetInnerHTML: {
1450
- __html: `window.__PAGE_PROPS__ = ${JSON.stringify(pageProps)};`,
1451
- },
1452
- }), h("script", {
1453
- key: "hydrate",
1454
- type: "module",
1455
- dangerouslySetInnerHTML: {
1456
- __html: `import("/@react-refresh").then(m=>{m.default.injectIntoGlobalHook(window);return import("/@vite/client");}).then(()=>import(${JSON.stringify(`/@rsc-hydrate${normalized}`)}));`,
1457
- },
1458
- }));
1459
- }
1460
- else {
1461
- // For async pages, we need to hydrate client component islands
1462
- // Load a minimal script that finds and hydrates "use client" components
1463
- bodyElements.push(h("script", {
1464
- key: "client-islands",
1465
- type: "module",
1466
- dangerouslySetInnerHTML: {
1467
- __html: `
1468
- // Hydrate client component islands
1469
- import '/@vite/client';
1470
-
1471
- // Find all client components and hydrate them
1472
- // The actual hydration is handled by @vitejs/plugin-rsc transforms
1473
- `,
1474
- },
1475
- }));
1476
- }
1477
- const fullPage = h("html", { lang: "en" }, h("head", null, ...headElements), h("body", null, ...bodyElements));
1478
- const html = "<!DOCTYPE html>" + ReactDOMServer.renderToString(fullPage);
1479
- res.statusCode = 200;
1480
- res.setHeader("Content-Type", "text/html");
1481
- res.end(html);
1482
- const duration = Date.now() - startTime;
1483
- logResponse("GET", pathname, 200, duration);
1484
- }
1485
- catch (error) {
1322
+ // Show the failure. Rendering another page instead (the old legacy
1323
+ // SSR fallback) served the wrong page and hid the error.
1486
1324
  const duration = Date.now() - startTime;
1487
- logResponse("GET", pathname, 500, duration);
1488
- console.error(error);
1489
- // Return error page
1325
+ logResponse(method, pathname, 500, duration);
1326
+ console.error(`[Farm.js] RSC render failed for ${method} ${pathname}:`, rscError);
1490
1327
  res.statusCode = 500;
1491
- res.setHeader("Content-Type", "text/html");
1492
- res.end(`
1493
- <!DOCTYPE html>
1494
- <html>
1495
- <head><title>Error</title></head>
1496
- <body style="font-family: system-ui; padding: 2rem; background: #1a1a2e; color: #eee;">
1497
- <h1 style="color: #ff6b6b;">Error</h1>
1498
- <pre style="background: #16213e; padding: 1rem; border-radius: 8px; overflow: auto;">${error.stack || error.message}</pre>
1499
- </body>
1500
- </html>
1501
- `);
1328
+ res.setHeader("Content-Type", "text/html; charset=utf-8");
1329
+ res.setHeader("Cache-Control", "no-store");
1330
+ res.end(createRscDevErrorDocument(rscError, method, pathname));
1502
1331
  }
1503
1332
  });
1504
1333
  };
@@ -14,6 +14,9 @@ type ExtractionResult = {
14
14
  reason: string;
15
15
  };
16
16
  export declare function extractRscMiddlewareConfigModule(source: string, program: AstNode): ExtractionResult;
17
+ /** Extracts `key` from the default-exported config, as a module that exports `{ [key] }`. */
18
+ export declare function extractRscConfigPropertyModule(source: string, program: AstNode, key: "middleware" | "mcp"): ExtractionResult;
17
19
  export declare function loadRscMiddlewareConfigModule(configPath: string): Promise<ExtractionResult>;
20
+ export declare function loadRscConfigPropertyModule(configPath: string, key: "middleware" | "mcp"): Promise<ExtractionResult>;
18
21
  export {};
19
22
  //# sourceMappingURL=middleware-config-module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware-config-module.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware-config-module.ts"],"names":[],"mappings":"AAQA,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AASF,KAAK,gBAAgB,GACjB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA4P5C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACf,gBAAgB,CA+IlB;AAiBD,wBAAsB,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsBjG"}
1
+ {"version":3,"file":"middleware-config-module.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware-config-module.ts"],"names":[],"mappings":"AAQA,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AASF,KAAK,gBAAgB,GACjB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAgQ5C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACf,gBAAgB,CAElB;AAED,6FAA6F;AAC7F,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,YAAY,GAAG,KAAK,GACxB,gBAAgB,CA+IlB;AAiBD,wBAAsB,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEjG;AAED,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,YAAY,GAAG,KAAK,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAuB3B"}
@@ -202,7 +202,7 @@ function resolveConfigObject(node, variableInitializers, configHelpers, seen = n
202
202
  * leave the guard with a different matcher than the config it came from. Fail
203
203
  * on those instead of producing a module that disagrees with the config.
204
204
  */
205
- function unsupportedStatementReason(statement, source) {
205
+ function unsupportedStatementReason(statement, source, key) {
206
206
  switch (statement.type) {
207
207
  case "ImportDeclaration":
208
208
  if ((statement.specifiers ?? []).length > 0)
@@ -224,10 +224,14 @@ function unsupportedStatementReason(statement, source) {
224
224
  const text = source.slice(statement.start, statement.end).replace(/\s+/g, " ").trim();
225
225
  const snippet = text.length > 80 ? `${text.slice(0, 77)}...` : text;
226
226
  return statement.type === "ImportDeclaration"
227
- ? `the side-effect import \`${snippet}\` would not run with the extracted middleware`
228
- : `the top-level statement \`${snippet}\` would not run with the extracted middleware`;
227
+ ? `the side-effect import \`${snippet}\` would not run with the extracted ${key}`
228
+ : `the top-level statement \`${snippet}\` would not run with the extracted ${key}`;
229
229
  }
230
230
  export function extractRscMiddlewareConfigModule(source, program) {
231
+ return extractRscConfigPropertyModule(source, program, "middleware");
232
+ }
233
+ /** Extracts `key` from the default-exported config, as a module that exports `{ [key] }`. */
234
+ export function extractRscConfigPropertyModule(source, program, key) {
231
235
  const body = program.body ?? [];
232
236
  const bindings = new Map();
233
237
  const variableInitializers = new Map();
@@ -235,7 +239,7 @@ export function extractRscMiddlewareConfigModule(source, program) {
235
239
  let defaultExport = null;
236
240
  let order = 0;
237
241
  for (const statement of body) {
238
- const unsupported = unsupportedStatementReason(statement, source);
242
+ const unsupported = unsupportedStatementReason(statement, source, key);
239
243
  if (unsupported)
240
244
  return { kind: "unsupported", reason: unsupported };
241
245
  if (statement.type === "ImportDeclaration") {
@@ -313,33 +317,33 @@ export function extractRscMiddlewareConfigModule(source, program) {
313
317
  };
314
318
  }
315
319
  const properties = configObject.properties ?? [];
316
- let middlewareProperty = null;
317
- let middlewareIndex = -1;
320
+ let keyProperty = null;
321
+ let keyIndex = -1;
318
322
  for (const [index, property] of properties.entries()) {
319
- if (property.type === "Property" && propertyName(property) === "middleware") {
320
- middlewareProperty = property;
321
- middlewareIndex = index;
323
+ if (property.type === "Property" && propertyName(property) === key) {
324
+ keyProperty = property;
325
+ keyIndex = index;
322
326
  }
323
327
  }
324
- if (!middlewareProperty) {
328
+ if (!keyProperty) {
325
329
  if (properties.some((property) => property.type === "SpreadElement")) {
326
330
  return {
327
331
  kind: "unsupported",
328
- reason: "middleware may be supplied through a config spread",
332
+ reason: `${key} may be supplied through a config spread`,
329
333
  };
330
334
  }
331
335
  return { kind: "absent" };
332
336
  }
333
- if (properties.slice(middlewareIndex + 1).some((property) => property.type === "SpreadElement")) {
337
+ if (properties.slice(keyIndex + 1).some((property) => property.type === "SpreadElement")) {
334
338
  return {
335
339
  kind: "unsupported",
336
- reason: "a config spread after middleware may override it",
340
+ reason: `a config spread after ${key} may override it`,
337
341
  };
338
342
  }
339
- const middlewareValue = middlewareProperty.value;
343
+ const keyValue = keyProperty.value;
340
344
  const candidateNames = new Set(bindings.keys());
341
345
  const selectedBindings = new Set();
342
- const pending = [...referencedTopLevelNames(middlewareValue, candidateNames)];
346
+ const pending = [...referencedTopLevelNames(keyValue, candidateNames)];
343
347
  while (pending.length > 0) {
344
348
  const name = pending.pop();
345
349
  const binding = bindings.get(name);
@@ -355,10 +359,10 @@ export function extractRscMiddlewareConfigModule(source, program) {
355
359
  const declarations = [...selectedBindings]
356
360
  .sort((a, b) => a.order - b.order)
357
361
  .map((binding) => binding.render());
358
- const middlewareSource = source.slice(middlewareValue.start, middlewareValue.end);
362
+ const valueSource = source.slice(keyValue.start, keyValue.end);
359
363
  return {
360
364
  kind: "module",
361
- code: `${declarations.join("\n")}${declarations.length ? "\n" : ""}export default { middleware: ${middlewareSource} };\n`,
365
+ code: `${declarations.join("\n")}${declarations.length ? "\n" : ""}export default { ${key}: ${valueSource} };\n`,
362
366
  };
363
367
  }
364
368
  function sourceLang(file) {
@@ -376,6 +380,9 @@ function sourceLang(file) {
376
380
  }
377
381
  }
378
382
  export async function loadRscMiddlewareConfigModule(configPath) {
383
+ return loadRscConfigPropertyModule(configPath, "middleware");
384
+ }
385
+ export async function loadRscConfigPropertyModule(configPath, key) {
379
386
  const [{ readFile }, vite] = await Promise.all([import("node:fs/promises"), import("vite")]);
380
387
  const source = await readFile(configPath, "utf8");
381
388
  const lang = sourceLang(configPath);
@@ -392,5 +399,5 @@ export async function loadRscMiddlewareConfigModule(configPath) {
392
399
  jsx: "automatic",
393
400
  loader: lang,
394
401
  });
395
- return extractRscMiddlewareConfigModule(transformed.code, vite.parseAst(transformed.code));
402
+ return extractRscConfigPropertyModule(transformed.code, vite.parseAst(transformed.code), key);
396
403
  }
@@ -1,3 +1,5 @@
1
+ import type { FarmMarkdownResolvedConfig } from "@farm.js/core/markdown";
2
+ import type { ResolvedFarmLlmsTxtConfig } from "@farm.js/core/internal/production-runtime";
1
3
  import type { ResolvedFarmI18nConfig } from "@farm.js/core/i18n";
2
4
  import type { FarmServerActionsConfig, ResolvedFarmServerActionsConfig } from "@farm.js/core/server-action-security";
3
5
  /**
@@ -92,6 +94,12 @@ export interface EntryContext {
92
94
  * Farm's normal config merge order.
93
95
  */
94
96
  middlewareConfigPaths?: string[];
97
+ /** Modules that export `{ mcp }`, read from the app's config files, in layer order. */
98
+ mcpConfigPaths?: string[];
99
+ /** Resolved Markdown mirror settings (core's `md`): `.md` pages and `Accept: text/markdown`. */
100
+ markdown?: FarmMarkdownResolvedConfig;
101
+ /** Resolved `agent.llmsTxt`: the generated `/llms.txt` and `/llms-full.txt`. */
102
+ llmsTxt?: ResolvedFarmLlmsTxtConfig;
95
103
  /** Whether debug mode is enabled */
96
104
  debug: boolean;
97
105
  /** True only for the Vite serve command, never for a production build. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/rsc/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EACV,uBAAuB,EACvB,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,aAAa,CAAC,EAAE,uBAAuB,CAAC;IAExC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,OAAO,CAAC,EAAE;QACR,wCAAwC;QACxC,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,wCAAwC;QACxC,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,2CAA2C;QAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IAEf,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IAEf,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IAEjB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CA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,CAAC,MAAM,CAAC,CAAC;SAC5D,CAAC;KACH;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/plugin",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Official plugins for Farm.js framework",
5
5
  "license": "MIT",
6
6
  "author": "Farm.js Team",
@@ -62,7 +62,7 @@
62
62
  "nitro": "3.0.260903-beta",
63
63
  "picocolors": "^1.0.0",
64
64
  "rsc-html-stream": "^0.0.4",
65
- "@farm.js/core": "0.1.27"
65
+ "@farm.js/core": "0.1.29"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/node": "^22.20.5",
@@ -83,7 +83,7 @@
83
83
  "react-dom": "19.2.8",
84
84
  "react-server-dom-webpack": "19.2.8",
85
85
  "vite": ">=6.0.0",
86
- "@farm.js/core": "0.1.27"
86
+ "@farm.js/core": "0.1.29"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@vitejs/plugin-rsc": {