@farm.js/core 0.1.41 → 0.1.43
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/{agent-mcp-BOqIxJLI.d.mts → agent-mcp-3KDz4hr9.d.mts} +1 -1
- package/dist/{agent-mcp-D0eZKfci.d.ts → agent-mcp-6yRebHk7.d.ts} +1 -1
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/api/route-manager.d.mts +3 -3
- package/dist/api/route-manager.d.ts +3 -3
- package/dist/api/runtime.d.mts +2 -2
- package/dist/api/runtime.d.ts +2 -2
- package/dist/api.cjs +2 -2
- package/dist/api.d.mts +8 -3
- package/dist/api.d.ts +8 -3
- package/dist/api.mjs +1 -1
- package/dist/{app-DM8e1z3G.d.ts → app-8Db1zR-2.d.ts} +8 -4
- package/dist/{app-CzTSMJaf.d.mts → app-DlTWv4cn.d.mts} +8 -4
- package/dist/app-manifest-TRzS7ZZ9.d.mts +120 -0
- package/dist/app-manifest-cO2jkG1F.d.ts +120 -0
- package/dist/app-markdown.d.mts +2 -2
- package/dist/app-markdown.d.ts +2 -2
- package/dist/{chunk-ECKF2BAM.cjs → chunk-2GVF3C2F.cjs} +255 -42
- package/dist/chunk-2NXO5SBY.mjs +57 -0
- package/dist/chunk-3BROEWFY.cjs +39 -0
- package/dist/{chunk-ENOBPDKZ.mjs → chunk-4MRQ5OKQ.mjs} +14 -9
- package/dist/{chunk-R65GCA6A.mjs → chunk-4OCEMK72.mjs} +260 -49
- package/dist/{chunk-6PKXK4TY.mjs → chunk-53ZV6K65.mjs} +1 -1
- package/dist/{chunk-LYIZHJTK.cjs → chunk-5LPHJZSI.cjs} +14 -14
- package/dist/chunk-5NIWBWDD.mjs +97 -0
- package/dist/{chunk-NRDBW4MP.mjs → chunk-7IQQIPRZ.mjs} +10 -0
- package/dist/{chunk-FJGIVDA5.mjs → chunk-7SCCY6SI.mjs} +80 -177
- package/dist/chunk-APDGOKKE.cjs +148 -0
- package/dist/chunk-AZBSVLRM.cjs +132 -0
- package/dist/{chunk-PN676AZF.cjs → chunk-BKPXWRTT.cjs} +6 -6
- package/dist/chunk-CEDPEDNW.cjs +98 -0
- package/dist/chunk-D5RFPV2H.mjs +148 -0
- package/dist/{chunk-BYQVROIP.mjs → chunk-DMRPN25V.mjs} +69 -0
- package/dist/{chunk-724JLMS4.mjs → chunk-F646BZ4Y.mjs} +4 -2
- package/dist/{chunk-C5KVWHIH.cjs → chunk-G2Z5DGMS.cjs} +5 -3
- package/dist/{chunk-L6HYACBE.cjs → chunk-GVNCWSQV.cjs} +145 -127
- package/dist/{chunk-24SP5TGU.mjs → chunk-H4LXPWI2.mjs} +2 -2
- package/dist/chunk-H7BLEEAE.cjs +57 -0
- package/dist/{chunk-JOTUZIM4.cjs → chunk-HUMEHX24.cjs} +2 -2
- package/dist/{chunk-BD3D7EZV.cjs → chunk-IXFOBGLQ.cjs} +9 -3
- package/dist/{chunk-3TB5QGUW.cjs → chunk-JAXDRRRC.cjs} +70 -1
- package/dist/{chunk-32TZ3QTP.cjs → chunk-JDJAPCR2.cjs} +421 -210
- package/dist/{chunk-MHN4UR5U.cjs → chunk-KFZZFZ7J.cjs} +7 -7
- package/dist/chunk-LRJRXXQZ.cjs +109 -0
- package/dist/{chunk-EX4MKHXN.cjs → chunk-LVABUXLA.cjs} +22 -17
- package/dist/{chunk-HCSVR4YZ.mjs → chunk-M3BXTWJM.mjs} +18 -0
- package/dist/{chunk-PYHPXPSW.mjs → chunk-NXO75WY4.mjs} +1 -1
- package/dist/{chunk-BGGWKZ2V.mjs → chunk-OYSGGV6O.mjs} +137 -167
- package/dist/{chunk-JR4QCLJY.cjs → chunk-PDU4P2IC.cjs} +19 -1
- package/dist/chunk-PJEHUSHA.mjs +229 -0
- package/dist/chunk-QGH2RQVF.mjs +132 -0
- package/dist/{chunk-YWMZUGIS.mjs → chunk-R3ZFQJEF.mjs} +247 -34
- package/dist/{chunk-ROQ4C4LJ.cjs → chunk-RACQTC7K.cjs} +274 -371
- package/dist/{chunk-WSOBCAYO.cjs → chunk-RQYTOFQM.cjs} +23 -23
- package/dist/chunk-S34OBRMZ.mjs +109 -0
- package/dist/{chunk-TS4JHGUJ.mjs → chunk-S3ZEMCE6.mjs} +9 -3
- package/dist/{chunk-WWFTAUFG.cjs → chunk-SBH2JLLF.cjs} +12 -2
- package/dist/{chunk-YSLWRWWP.cjs → chunk-SKK6UF5P.cjs} +200 -46
- package/dist/chunk-T7J7E63D.cjs +144 -0
- package/dist/{chunk-SVPGWJZF.mjs → chunk-TESO7EFU.mjs} +125 -107
- package/dist/{chunk-OQ4YXWH4.cjs → chunk-VIVQERJ5.cjs} +320 -351
- package/dist/{chunk-JIYYX7WU.mjs → chunk-VLXNGUKO.mjs} +1 -1
- package/dist/{chunk-OFZUJMCU.mjs → chunk-WPJQN64R.mjs} +195 -41
- package/dist/chunk-XARSG2TG.mjs +144 -0
- package/dist/chunk-XUGFRFD2.mjs +39 -0
- package/dist/{chunk-EH3464KF.cjs → chunk-YBDSTNMH.cjs} +1 -1
- package/dist/{chunk-VLPII2JJ.mjs → chunk-YGZH4T2X.mjs} +1 -1
- package/dist/chunk-YKUEJ3MG.cjs +229 -0
- package/dist/{chunk-4C7KTKX7.mjs → chunk-ZYWJIPKQ.mjs} +1 -1
- package/dist/{client-plugins-CkYwvDJ0.d.mts → client-plugins-Cv0OJtnM.d.mts} +98 -7
- package/dist/{client-plugins-DfeKd0sD.d.ts → client-plugins-kwQuZcWq.d.ts} +98 -7
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +4 -3
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +3 -2
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{devtools-N3QLRIQU.mjs → devtools-M22FEFPK.mjs} +4 -4
- package/dist/{devtools-2YHAJYH6.cjs → devtools-MLB3JJMC.cjs} +5 -5
- package/dist/docs.cjs +6 -6
- package/dist/docs.d.mts +2 -2
- package/dist/docs.d.ts +2 -2
- package/dist/docs.mjs +5 -5
- package/dist/index-CQOp8EmB.d.mts +48 -0
- package/dist/index-DAl0QTZS.d.ts +48 -0
- package/dist/index.cjs +41 -24
- package/dist/index.d.mts +15 -14
- package/dist/index.d.ts +15 -14
- package/dist/index.mjs +46 -29
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/build-runtime.cjs +29 -15
- package/dist/internal/build-runtime.d.mts +12 -16
- package/dist/internal/build-runtime.d.ts +12 -16
- package/dist/internal/build-runtime.mjs +28 -14
- package/dist/internal/cli-runtime.cjs +23 -11
- package/dist/internal/cli-runtime.mjs +23 -11
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +5 -1
- package/dist/internal/client-runtime.d.mts +1 -0
- package/dist/internal/client-runtime.d.ts +1 -0
- package/dist/internal/client-runtime.mjs +4 -0
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +5 -5
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +4 -4
- package/dist/internal/form-actions-client.cjs +18 -0
- package/dist/internal/form-actions-client.d.mts +5 -0
- package/dist/internal/form-actions-client.d.ts +5 -0
- package/dist/internal/form-actions-client.mjs +18 -0
- package/dist/internal/form-actions.cjs +18 -0
- package/dist/internal/form-actions.d.mts +14 -0
- package/dist/internal/form-actions.d.ts +14 -0
- package/dist/internal/form-actions.mjs +18 -0
- package/dist/internal/island-codec.cjs +22 -0
- package/dist/internal/island-codec.d.mts +29 -0
- package/dist/internal/island-codec.d.ts +29 -0
- package/dist/internal/island-codec.mjs +22 -0
- package/dist/internal/island-value-store.cjs +13 -0
- package/dist/internal/island-value-store.d.mts +6 -0
- package/dist/internal/island-value-store.d.ts +6 -0
- package/dist/internal/island-value-store.mjs +13 -0
- package/dist/internal/islands-runtime.cjs +77 -0
- package/dist/internal/islands-runtime.d.mts +57 -0
- package/dist/internal/islands-runtime.d.ts +57 -0
- package/dist/internal/islands-runtime.mjs +77 -0
- package/dist/internal/islands-server.cjs +19 -0
- package/dist/internal/islands-server.d.mts +3 -0
- package/dist/internal/islands-server.d.ts +3 -0
- package/dist/internal/islands-server.mjs +19 -0
- package/dist/internal/islx-client.cjs +5 -0
- package/dist/internal/islx-client.d.mts +2 -0
- package/dist/internal/islx-client.d.ts +2 -0
- package/dist/internal/islx-client.mjs +3 -0
- package/dist/internal/islx-react.cjs +4 -0
- package/dist/internal/islx-react.d.mts +1 -0
- package/dist/internal/islx-react.d.ts +1 -0
- package/dist/internal/islx-react.mjs +2 -0
- package/dist/internal/islx-server.cjs +5 -0
- package/dist/internal/islx-server.d.mts +2 -0
- package/dist/internal/islx-server.d.ts +2 -0
- package/dist/internal/islx-server.mjs +3 -0
- package/dist/internal/isolated-boundary.cjs +4 -3
- package/dist/internal/isolated-boundary.d.mts +13 -1
- package/dist/internal/isolated-boundary.d.ts +13 -1
- package/dist/internal/isolated-boundary.mjs +3 -2
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +24 -7
- package/dist/internal/production-runtime.d.mts +20 -127
- package/dist/internal/production-runtime.d.ts +20 -127
- package/dist/internal/production-runtime.mjs +24 -7
- package/dist/internal/server-tree.cjs +6 -3
- package/dist/internal/server-tree.d.mts +25 -2
- package/dist/internal/server-tree.d.ts +25 -2
- package/dist/internal/server-tree.mjs +7 -4
- package/dist/island-value-protocol-BRayRghM.d.mts +12 -0
- package/dist/island-value-protocol-BRayRghM.d.ts +12 -0
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/navigation.cjs +5 -4
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.mjs +4 -3
- package/dist/og.d.mts +5 -0
- package/dist/og.d.ts +5 -0
- package/dist/plugin.cjs +18 -12
- package/dist/plugin.d.mts +3 -3
- package/dist/plugin.d.ts +3 -3
- package/dist/plugin.mjs +17 -11
- package/dist/{production-runtime-DFC7pgbp.d.ts → production-runtime-5nArjFpn.d.ts} +1 -1
- package/dist/{production-runtime-BTkXQdYy.d.mts → production-runtime-BzsF2z5F.d.mts} +1 -1
- package/dist/query/client.cjs +6 -5
- package/dist/query/client.mjs +2 -1
- package/dist/{render-plan-5rFeWmk7.d.mts → render-plan-B9yQorV4.d.mts} +4 -2
- package/dist/{render-plan-BoAK9xFC.d.ts → render-plan-fg6E_HvL.d.ts} +4 -2
- package/dist/renderer/react/server.cjs +7 -6
- package/dist/renderer/react/server.d.mts +3 -1
- package/dist/renderer/react/server.d.ts +3 -1
- package/dist/renderer/react/server.mjs +5 -4
- package/dist/renderer-client.cjs +5 -4
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/renderer-client.mjs +2 -1
- package/dist/renderer.d.mts +3 -1
- package/dist/renderer.d.ts +3 -1
- package/dist/{request-BxBWigtl.d.mts → request-C4j_g-BH.d.mts} +1 -1
- package/dist/{request-fciwmd3n.d.ts → request-gz8vFK0n.d.ts} +1 -1
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/{route-rendering-BLZT0IP0.d.ts → route-rendering-DamyKVi3.d.ts} +1 -1
- package/dist/{route-rendering-BCM1QzEf.d.mts → route-rendering-iTTOwz1f.d.mts} +1 -1
- package/dist/{router-DyZJWc1_.d.mts → router-EoSzHlos.d.mts} +1 -1
- package/dist/{router-CkheNX3-.d.ts → router-OVjDqVo8.d.ts} +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/rsc-pipeline-LK4K5JFK.mjs +77 -0
- package/dist/rsc-pipeline-YCDRJME4.cjs +77 -0
- package/dist/{runtime-DfU4sKa5.d.ts → runtime-CwiuozLd.d.ts} +1 -1
- package/dist/{runtime-wexvUN5J.d.mts → runtime-DDH4tiuF.d.mts} +1 -1
- package/dist/{schema-dev-notice-5JPE67AI.cjs → schema-dev-notice-77ZL23PL.cjs} +4 -4
- package/dist/{schema-dev-notice-WLPZ6WKU.mjs → schema-dev-notice-BLXOS6U2.mjs} +2 -2
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server.cjs +56 -38
- package/dist/server.d.mts +15 -10
- package/dist/server.d.ts +15 -10
- package/dist/server.mjs +36 -18
- package/dist/{spa-router-DgsMXqfX.d.mts → spa-router-Br4qFCWf.d.mts} +8 -3
- package/dist/{spa-router-CcejECnG.d.ts → spa-router-BsWUKH73.d.ts} +8 -3
- package/dist/{ssg-1FGaFISl.d.ts → ssg-Csy2vwpi.d.ts} +2 -2
- package/dist/{ssg-Bg4bMMhM.d.mts → ssg-Donyfcxy.d.mts} +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{utils-Dxbh6Hgj.d.ts → utils-Luk72LXC.d.ts} +1 -1
- package/dist/{utils-8wtTYiH4.d.mts → utils-d_k1ZZw0.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +18 -12
- package/dist/vite.d.mts +6 -4
- package/dist/vite.d.ts +6 -4
- package/dist/vite.mjs +17 -11
- package/package.json +53 -1
- package/dist/{chunk-35WS7P2V.mjs → chunk-26CXZR6L.mjs} +3 -3
- package/dist/{chunk-QEILRWVV.cjs → chunk-3XEMGDBF.cjs} +2 -2
- package/dist/{chunk-BPOTSHDO.cjs → chunk-IOAUK4OI.cjs} +2 -2
- package/dist/{chunk-BYR3RQPB.mjs → chunk-T76H22WI.mjs} +4 -4
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_ERROR_STYLES
|
|
6
6
|
} from "./chunk-XAXTTBUT.mjs";
|
|
7
|
+
import {
|
|
8
|
+
resolveFarmAppManifestConfig
|
|
9
|
+
} from "./chunk-DMRPN25V.mjs";
|
|
7
10
|
import {
|
|
8
11
|
serializeFarmLlmsTxt
|
|
9
12
|
} from "./chunk-ETPEZLS3.mjs";
|
|
@@ -42,7 +45,7 @@ import {
|
|
|
42
45
|
} from "./chunk-ZZGQD7A4.mjs";
|
|
43
46
|
import {
|
|
44
47
|
FARM_VERSION
|
|
45
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-YGZH4T2X.mjs";
|
|
46
49
|
import {
|
|
47
50
|
localizeFarmPathname
|
|
48
51
|
} from "./chunk-L3KT7IXV.mjs";
|
|
@@ -53,6 +56,56 @@ import {
|
|
|
53
56
|
__name
|
|
54
57
|
} from "./chunk-LPEX4YW6.mjs";
|
|
55
58
|
|
|
59
|
+
// src/navigation/render-plan.ts
|
|
60
|
+
function createFarmRouteRenderPlan(input = {}) {
|
|
61
|
+
const pageShouldHydrate = input.pageShouldHydrate === true;
|
|
62
|
+
const layoutShouldHydrate = input.layoutShouldHydrate === true;
|
|
63
|
+
const hydration = pageShouldHydrate ? layoutShouldHydrate ? "route-and-layout-islands" : "route-island" : layoutShouldHydrate ? "layout-island" : "none";
|
|
64
|
+
const rendering = input.rendering;
|
|
65
|
+
const cache = rendering?.ssg ? typeof rendering.revalidate === "number" && rendering.revalidate > 0 ? { mode: "revalidate", revalidate: rendering.revalidate } : { mode: "static" } : { mode: "dynamic" };
|
|
66
|
+
return {
|
|
67
|
+
version: 1,
|
|
68
|
+
output: "html",
|
|
69
|
+
navigation: "html-fragment",
|
|
70
|
+
hydration,
|
|
71
|
+
islandStrategy: hydration === "none" ? null : input.islandStrategy ?? "load",
|
|
72
|
+
cache
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
__name(createFarmRouteRenderPlan, "createFarmRouteRenderPlan");
|
|
76
|
+
function getFarmFragmentCacheControl(plan) {
|
|
77
|
+
if (plan.cache.mode === "static") {
|
|
78
|
+
return "public, max-age=0, s-maxage=31536000, immutable";
|
|
79
|
+
}
|
|
80
|
+
if (plan.cache.mode === "revalidate") {
|
|
81
|
+
const seconds = Math.max(1, plan.cache.revalidate ?? 1);
|
|
82
|
+
return `public, max-age=0, s-maxage=${seconds}, stale-while-revalidate=${seconds}`;
|
|
83
|
+
}
|
|
84
|
+
return "private, max-age=0";
|
|
85
|
+
}
|
|
86
|
+
__name(getFarmFragmentCacheControl, "getFarmFragmentCacheControl");
|
|
87
|
+
function parseFarmLayoutChainHeader(value) {
|
|
88
|
+
if (!value || value.length > 8192) return [];
|
|
89
|
+
try {
|
|
90
|
+
const parsed = JSON.parse(value);
|
|
91
|
+
if (!Array.isArray(parsed) || parsed.length > 64) return [];
|
|
92
|
+
return parsed.filter(
|
|
93
|
+
(pattern) => typeof pattern === "string" && pattern.startsWith("/") && pattern.length <= 512
|
|
94
|
+
);
|
|
95
|
+
} catch {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
__name(parseFarmLayoutChainHeader, "parseFarmLayoutChainHeader");
|
|
100
|
+
function getSharedLayoutPrefixLength(current, next) {
|
|
101
|
+
let index = 0;
|
|
102
|
+
while (index < current.length && index < next.length && current[index] === next[index]) {
|
|
103
|
+
index++;
|
|
104
|
+
}
|
|
105
|
+
return index;
|
|
106
|
+
}
|
|
107
|
+
__name(getSharedLayoutPrefixLength, "getSharedLayoutPrefixLength");
|
|
108
|
+
|
|
56
109
|
// src/routing/route-groups.ts
|
|
57
110
|
function isRouteGroupSegment(part) {
|
|
58
111
|
return part.startsWith("(") && part.endsWith(")");
|
|
@@ -961,13 +1014,11 @@ function isFarmAppManifestPath(pathname) {
|
|
|
961
1014
|
return pathname === FARM_APP_MANIFEST_PATH || pathname === FARM_APP_MANIFEST_LEGACY_PATH;
|
|
962
1015
|
}
|
|
963
1016
|
__name(isFarmAppManifestPath, "isFarmAppManifestPath");
|
|
964
|
-
var FARM_INFRA_SIGNATURE_HEADER = "farmjs-infra-signature";
|
|
965
|
-
var SIGNED_PURPOSE = "farmjs-manifest-v1";
|
|
966
|
-
var SIGNATURE_WINDOW_SECONDS = 300;
|
|
967
1017
|
function resolveFarmAppManifestInput(config, extra) {
|
|
968
1018
|
const llms = config.agent?.llmsTxt;
|
|
969
1019
|
const plugins = (config.plugins ?? []).map(({ name }) => name);
|
|
970
1020
|
const webmcp = plugins.includes("farm:webmcp");
|
|
1021
|
+
const sections = resolveFarmAppManifestConfig(config.agent?.manifest);
|
|
971
1022
|
return {
|
|
972
1023
|
renderer: config.renderer?.name ?? "react",
|
|
973
1024
|
basePath: config.basePath || "/",
|
|
@@ -984,7 +1035,7 @@ function resolveFarmAppManifestInput(config, extra) {
|
|
|
984
1035
|
openapi: config.openapi?.enabled && config.openapi.specRoute ? config.openapi.specRoute : null
|
|
985
1036
|
},
|
|
986
1037
|
plugins,
|
|
987
|
-
|
|
1038
|
+
...sections ? { sections } : {}
|
|
988
1039
|
};
|
|
989
1040
|
}
|
|
990
1041
|
__name(resolveFarmAppManifestInput, "resolveFarmAppManifestInput");
|
|
@@ -993,56 +1044,71 @@ var SOURCES = {
|
|
|
993
1044
|
standalone: "defineTool",
|
|
994
1045
|
serverFunction: "serverFunction"
|
|
995
1046
|
};
|
|
996
|
-
|
|
997
|
-
|
|
1047
|
+
var DEFAULT_SECTIONS = resolveFarmAppManifestConfig(void 0);
|
|
1048
|
+
function createFarmAppManifest(input) {
|
|
1049
|
+
const sections = input.sections ?? DEFAULT_SECTIONS;
|
|
1050
|
+
const { app, mcp, webmcp } = sections;
|
|
1051
|
+
return {
|
|
998
1052
|
schemaVersion: 1,
|
|
999
|
-
app: {
|
|
1000
|
-
farm: FARM_VERSION,
|
|
1001
|
-
renderer: input.renderer,
|
|
1053
|
+
app: app ? {
|
|
1054
|
+
...app.version ? { farm: FARM_VERSION } : {},
|
|
1055
|
+
...app.renderer ? { renderer: input.renderer } : {},
|
|
1002
1056
|
basePath: input.basePath,
|
|
1003
|
-
build: input.build
|
|
1004
|
-
},
|
|
1005
|
-
packages: input.packages,
|
|
1006
|
-
mcp: {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
authorization: open ? "none" : "required",
|
|
1015
|
-
resources: listed ? [...details?.resources ?? []] : [],
|
|
1016
|
-
prompts: listed ? [...details?.prompts ?? []] : [],
|
|
1017
|
-
tools: (listed ? tools : []).map((tool) => {
|
|
1018
|
-
const schemas = details?.schemas?.[tool.name];
|
|
1019
|
-
const hints = Object.fromEntries(
|
|
1020
|
-
["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"].filter((hint) => typeof tool[hint] === "boolean").map((hint) => [hint, tool[hint]])
|
|
1021
|
-
);
|
|
1022
|
-
return {
|
|
1023
|
-
name: tool.name,
|
|
1024
|
-
...tool.title ? { title: tool.title } : {},
|
|
1025
|
-
...tool.description ? { description: tool.description } : {},
|
|
1026
|
-
source: SOURCES[tool.kind],
|
|
1027
|
-
// MCP clients never see the route behind a tool; only Infra's view names it.
|
|
1028
|
-
...full && tool.kind === "endpoint" ? { method: tool.method, path: tool.path } : {},
|
|
1029
|
-
...hints,
|
|
1030
|
-
...schemas ? { inputSchema: schemas.input } : {},
|
|
1031
|
-
...schemas?.output ? { outputSchema: schemas.output } : {}
|
|
1032
|
-
};
|
|
1033
|
-
})
|
|
1034
|
-
};
|
|
1035
|
-
})
|
|
1036
|
-
},
|
|
1037
|
-
webmcp: input.webmcp,
|
|
1038
|
-
integrations: input.integrations,
|
|
1039
|
-
agent: input.agent,
|
|
1040
|
-
plugins: input.plugins
|
|
1057
|
+
...app.build ? { build: input.build } : {}
|
|
1058
|
+
} : null,
|
|
1059
|
+
packages: sections.packages === "names" ? Object.fromEntries(Object.keys(input.packages).map((name) => [name, null])) : sections.packages ? input.packages : null,
|
|
1060
|
+
mcp: mcp ? { servers: listServers(input, mcp) } : null,
|
|
1061
|
+
webmcp: webmcp ? {
|
|
1062
|
+
enabled: input.webmcp.enabled,
|
|
1063
|
+
tools: input.webmcp.tools.filter((tool) => !webmcp.hide.includes(tool.name))
|
|
1064
|
+
} : null,
|
|
1065
|
+
integrations: sections.integrations ? input.integrations : null,
|
|
1066
|
+
agent: sections.agent ? input.agent : null,
|
|
1067
|
+
plugins: sections.plugins ? input.plugins : null
|
|
1041
1068
|
};
|
|
1042
|
-
manifest.mcp.servers.push(...listDefaultServer(input));
|
|
1043
|
-
return manifest;
|
|
1044
1069
|
}
|
|
1045
1070
|
__name(createFarmAppManifest, "createFarmAppManifest");
|
|
1071
|
+
function listServers(input, mcp) {
|
|
1072
|
+
const servers = _listFarmMCPCatalogs().map(({ server, tools, details }) => {
|
|
1073
|
+
const open = details?.public === true && !input.guardCoversPath?.(server.path);
|
|
1074
|
+
return {
|
|
1075
|
+
name: server.name,
|
|
1076
|
+
version: server.version,
|
|
1077
|
+
path: server.path,
|
|
1078
|
+
authorization: open ? "none" : "required",
|
|
1079
|
+
resources: open ? [...details?.resources ?? []] : [],
|
|
1080
|
+
prompts: open ? [...details?.prompts ?? []] : [],
|
|
1081
|
+
tools: (open ? tools : []).map((tool) => {
|
|
1082
|
+
const schemas = details?.schemas?.[tool.name];
|
|
1083
|
+
const hints = Object.fromEntries(
|
|
1084
|
+
["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"].filter((hint) => typeof tool[hint] === "boolean").map((hint) => [hint, tool[hint]])
|
|
1085
|
+
);
|
|
1086
|
+
return {
|
|
1087
|
+
name: tool.name,
|
|
1088
|
+
...tool.title ? { title: tool.title } : {},
|
|
1089
|
+
...tool.description ? { description: tool.description } : {},
|
|
1090
|
+
source: SOURCES[tool.kind],
|
|
1091
|
+
...hints,
|
|
1092
|
+
...schemas ? { inputSchema: schemas.input } : {},
|
|
1093
|
+
...schemas?.output ? { outputSchema: schemas.output } : {}
|
|
1094
|
+
};
|
|
1095
|
+
})
|
|
1096
|
+
};
|
|
1097
|
+
});
|
|
1098
|
+
return [...servers, ...listDefaultServer(input)].filter((server) => !mcp.hide.includes(server.name)).map((server) => ({
|
|
1099
|
+
...server,
|
|
1100
|
+
tools: server.tools.filter((tool) => !mcp.hide.includes(`${server.name}/${tool.name}`)).map((tool) => mcp.schemas ? tool : withoutSchemas(tool))
|
|
1101
|
+
}));
|
|
1102
|
+
}
|
|
1103
|
+
__name(listServers, "listServers");
|
|
1104
|
+
function withoutSchemas({
|
|
1105
|
+
inputSchema: _input,
|
|
1106
|
+
outputSchema: _output,
|
|
1107
|
+
...tool
|
|
1108
|
+
}) {
|
|
1109
|
+
return tool;
|
|
1110
|
+
}
|
|
1111
|
+
__name(withoutSchemas, "withoutSchemas");
|
|
1046
1112
|
function listDefaultServer(input) {
|
|
1047
1113
|
const server = input.defaultMCP?.();
|
|
1048
1114
|
if (!server) return [];
|
|
@@ -1068,57 +1134,13 @@ function listDefaultServer(input) {
|
|
|
1068
1134
|
];
|
|
1069
1135
|
}
|
|
1070
1136
|
__name(listDefaultServer, "listDefaultServer");
|
|
1071
|
-
var encoder = new TextEncoder();
|
|
1072
|
-
var hex = /* @__PURE__ */ __name((bytes) => [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join(""), "hex");
|
|
1073
|
-
async function sha256Hex(value) {
|
|
1074
|
-
return hex(await crypto.subtle.digest("SHA-256", encoder.encode(value)));
|
|
1075
|
-
}
|
|
1076
|
-
__name(sha256Hex, "sha256Hex");
|
|
1077
|
-
async function hmacHex(secret, message) {
|
|
1078
|
-
const key = await crypto.subtle.importKey(
|
|
1079
|
-
"raw",
|
|
1080
|
-
encoder.encode(secret),
|
|
1081
|
-
{ name: "HMAC", hash: "SHA-256" },
|
|
1082
|
-
false,
|
|
1083
|
-
["sign"]
|
|
1084
|
-
);
|
|
1085
|
-
return hex(await crypto.subtle.sign("HMAC", key, encoder.encode(message)));
|
|
1086
|
-
}
|
|
1087
|
-
__name(hmacHex, "hmacHex");
|
|
1088
|
-
function sameHex(a, b) {
|
|
1089
|
-
if (a.length !== b.length) return false;
|
|
1090
|
-
let difference = 0;
|
|
1091
|
-
for (let index = 0; index < a.length; index++)
|
|
1092
|
-
difference |= a.charCodeAt(index) ^ b.charCodeAt(index);
|
|
1093
|
-
return difference === 0;
|
|
1094
|
-
}
|
|
1095
|
-
__name(sameHex, "sameHex");
|
|
1096
|
-
async function verifyFarmInfraManifestSignature(header, key, now = Date.now()) {
|
|
1097
|
-
if (!header || header.length > 2048) return false;
|
|
1098
|
-
const parts = header.split(",").map((part) => part.trim());
|
|
1099
|
-
const timestamp = Number(
|
|
1100
|
-
/^t=(\d{1,12})$/.exec(parts.find((part) => part.startsWith("t=")) ?? "")?.[1]
|
|
1101
|
-
);
|
|
1102
|
-
if (!Number.isSafeInteger(timestamp)) return false;
|
|
1103
|
-
if (Math.abs(now / 1e3 - timestamp) > SIGNATURE_WINDOW_SECONDS) return false;
|
|
1104
|
-
const signatures = parts.filter((part) => part.startsWith("v1=")).map((part) => part.slice(3)).filter((value) => /^[0-9a-f]{64}$/.test(value));
|
|
1105
|
-
if (!signatures.length || signatures.length > 8) return false;
|
|
1106
|
-
const expected = await hmacHex(await sha256Hex(key), `${SIGNED_PURPOSE}
|
|
1107
|
-
${timestamp}`);
|
|
1108
|
-
return signatures.some((signature) => sameHex(signature, expected));
|
|
1109
|
-
}
|
|
1110
|
-
__name(verifyFarmInfraManifestSignature, "verifyFarmInfraManifestSignature");
|
|
1111
|
-
function processEnv() {
|
|
1112
|
-
return globalThis.process?.env ?? {};
|
|
1113
|
-
}
|
|
1114
|
-
__name(processEnv, "processEnv");
|
|
1115
1137
|
var CORS_HEADERS = {
|
|
1116
1138
|
"access-control-allow-origin": "*",
|
|
1117
1139
|
"access-control-allow-methods": "GET, HEAD, OPTIONS",
|
|
1118
|
-
"access-control-allow-headers":
|
|
1140
|
+
"access-control-allow-headers": "If-None-Match",
|
|
1119
1141
|
"access-control-expose-headers": "ETag"
|
|
1120
1142
|
};
|
|
1121
|
-
async function createFarmAppManifestResponse(request, input
|
|
1143
|
+
async function createFarmAppManifestResponse(request, input) {
|
|
1122
1144
|
const method = request.method.toUpperCase();
|
|
1123
1145
|
if (method === "OPTIONS") return new Response(null, { status: 204, headers: CORS_HEADERS });
|
|
1124
1146
|
if (method !== "GET" && method !== "HEAD") {
|
|
@@ -1127,23 +1149,16 @@ async function createFarmAppManifestResponse(request, input, options = {}) {
|
|
|
1127
1149
|
headers: { ...CORS_HEADERS, allow: "GET, HEAD, OPTIONS", "content-type": "text/plain" }
|
|
1128
1150
|
});
|
|
1129
1151
|
}
|
|
1130
|
-
const
|
|
1131
|
-
const key = input.analytics ? (options.env ?? processEnv()).FARMJS_API_KEY?.trim() : void 0;
|
|
1132
|
-
const full = Boolean(
|
|
1133
|
-
signature && key && await verifyFarmInfraManifestSignature(signature, key)
|
|
1134
|
-
);
|
|
1135
|
-
const body = JSON.stringify(createFarmAppManifest(input, { full }));
|
|
1152
|
+
const body = JSON.stringify(createFarmAppManifest(input));
|
|
1136
1153
|
const etag = createFarmWeakETag(body);
|
|
1137
1154
|
const headers = {
|
|
1138
1155
|
...CORS_HEADERS,
|
|
1139
1156
|
"content-type": "application/json; charset=utf-8",
|
|
1140
|
-
|
|
1141
|
-
"cache-control": full ? "private, no-store" : "public, max-age=0, must-revalidate",
|
|
1142
|
-
vary: FARM_INFRA_SIGNATURE_HEADER,
|
|
1157
|
+
"cache-control": "public, max-age=0, must-revalidate",
|
|
1143
1158
|
etag,
|
|
1144
1159
|
"x-content-type-options": "nosniff"
|
|
1145
1160
|
};
|
|
1146
|
-
if (
|
|
1161
|
+
if (matchesFarmIfNoneMatch(request.headers.get("if-none-match"), etag)) {
|
|
1147
1162
|
return new Response(null, { status: 304, headers });
|
|
1148
1163
|
}
|
|
1149
1164
|
return new Response(method === "HEAD" ? null : body, { status: 200, headers });
|
|
@@ -1151,6 +1166,10 @@ async function createFarmAppManifestResponse(request, input, options = {}) {
|
|
|
1151
1166
|
__name(createFarmAppManifestResponse, "createFarmAppManifestResponse");
|
|
1152
1167
|
|
|
1153
1168
|
export {
|
|
1169
|
+
createFarmRouteRenderPlan,
|
|
1170
|
+
getFarmFragmentCacheControl,
|
|
1171
|
+
parseFarmLayoutChainHeader,
|
|
1172
|
+
getSharedLayoutPrefixLength,
|
|
1154
1173
|
formatRouteSegment,
|
|
1155
1174
|
createRouteDirectoryPattern,
|
|
1156
1175
|
stripRouteGroups,
|
|
@@ -1186,7 +1205,6 @@ export {
|
|
|
1186
1205
|
FARM_APP_MANIFEST_PATH,
|
|
1187
1206
|
FARM_APP_MANIFEST_LEGACY_PATH,
|
|
1188
1207
|
isFarmAppManifestPath,
|
|
1189
|
-
FARM_INFRA_SIGNATURE_HEADER,
|
|
1190
1208
|
resolveFarmAppManifestInput,
|
|
1191
1209
|
createFarmAppManifestResponse
|
|
1192
1210
|
};
|