@farm.js/core 0.1.35 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{metadata-WGpBYcGn.d.mts → agent-mcp-BVExL8rZ.d.mts} +45 -2
- package/dist/agent-mcp-handler-LPJ2CADR.mjs +19 -0
- package/dist/agent-mcp-handler-SJAHFSPI.cjs +19 -0
- package/dist/{metadata-BnLDsUOS.d.ts → agent-mcp-luzfXK-P.d.ts} +45 -2
- package/dist/agent-runtime.cjs +5 -3
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/agent-runtime.mjs +4 -2
- package/dist/api/route-manager.cjs +6 -6
- package/dist/api/route-manager.d.mts +10 -4
- package/dist/api/route-manager.d.ts +10 -4
- package/dist/api/route-manager.mjs +5 -5
- package/dist/api/runtime.cjs +4 -4
- package/dist/api/runtime.d.mts +4 -62
- package/dist/api/runtime.d.ts +4 -62
- package/dist/api/runtime.mjs +3 -3
- package/dist/api.cjs +8 -8
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/api.mjs +7 -7
- package/dist/{app-D_j9AAVL.d.mts → app-BukwkFIu.d.mts} +17 -3
- package/dist/{app-BXB3JZYc.d.ts → app-Yfa2dsFy.d.ts} +17 -3
- package/dist/app-markdown.cjs +4 -4
- package/dist/app-markdown.d.mts +2 -2
- package/dist/app-markdown.d.ts +2 -2
- package/dist/app-markdown.mjs +3 -3
- package/dist/{chunk-4KU5Q7C2.mjs → chunk-276VJSM6.mjs} +221 -48
- package/dist/{chunk-PFQKNERH.cjs → chunk-2YTDKNH3.cjs} +364 -197
- package/dist/{chunk-UAORZ7QA.mjs → chunk-35GKZR22.mjs} +2 -2
- package/dist/{chunk-QAU5JD57.mjs → chunk-35WV46VL.mjs} +203 -36
- package/dist/{chunk-EFCQPQMG.cjs → chunk-42NHY7HW.cjs} +54 -4
- package/dist/{chunk-SOMHP6GF.mjs → chunk-4E5AEDKY.mjs} +2 -2
- package/dist/{chunk-UJD4PHYB.mjs → chunk-4E5WBPEG.mjs} +72 -354
- package/dist/{chunk-2G2NNLE2.mjs → chunk-4GLOOWKE.mjs} +4 -4
- package/dist/{chunk-62XKI4Z3.cjs → chunk-4NU4GGTC.cjs} +2 -2
- package/dist/{chunk-4JHOT46A.mjs → chunk-4WCZJQUO.mjs} +54 -4
- package/dist/chunk-4WQ6PGSJ.cjs +367 -0
- package/dist/{chunk-SMHH4VDG.mjs → chunk-4WVJLURN.mjs} +1 -1
- package/dist/chunk-6SJ2KJTA.mjs +314 -0
- package/dist/{chunk-IPXLADVO.cjs → chunk-ADEA7PN3.cjs} +122 -61
- package/dist/{chunk-CP6X4AEU.mjs → chunk-AJQTP4OO.mjs} +1 -1
- package/dist/{chunk-4MMGO7YW.cjs → chunk-AO6RYU5N.cjs} +31 -28
- package/dist/{chunk-GFHLGIYC.cjs → chunk-BO36SELV.cjs} +6 -6
- package/dist/{chunk-6TJOML4E.mjs → chunk-BPOF5U4N.mjs} +4 -4
- package/dist/{chunk-JHWOVJ3M.mjs → chunk-BUGNQIHC.mjs} +5 -0
- package/dist/{chunk-FTFYRMQQ.cjs → chunk-CBJJH36A.cjs} +50 -25
- package/dist/{chunk-7GLPRTTF.cjs → chunk-CGBDNNSM.cjs} +2 -2
- package/dist/chunk-CI6E3UOH.cjs +314 -0
- package/dist/{chunk-X6W5FFH6.cjs → chunk-D2BB47NB.cjs} +8 -8
- package/dist/chunk-DTSROJ5J.mjs +367 -0
- package/dist/{chunk-YC6V7PWE.cjs → chunk-DZ5ZVB2K.cjs} +1 -1
- package/dist/{chunk-DBNKI4NF.cjs → chunk-ECKF2BAM.cjs} +6 -2
- package/dist/{chunk-Q3VLETLE.mjs → chunk-EWET4D2Y.mjs} +1 -1
- package/dist/{chunk-HUMR6LSU.mjs → chunk-F5QO4FNE.mjs} +1 -1
- package/dist/{chunk-XBML5KMG.cjs → chunk-FO427P6I.cjs} +22 -12
- package/dist/{chunk-SAZVVAJH.mjs → chunk-GQRWBCWK.mjs} +8 -5
- package/dist/{chunk-F6Z3Y5KL.mjs → chunk-HOXTWRGB.mjs} +1 -1
- package/dist/{chunk-3BHT4WMP.cjs → chunk-JNUWCDTF.cjs} +6 -6
- package/dist/{chunk-73MC7ZL6.cjs → chunk-JZVADIOD.cjs} +2 -2
- package/dist/{chunk-OMVAU7NT.cjs → chunk-KIIMAWOJ.cjs} +11 -1
- package/dist/{chunk-43FMW62B.mjs → chunk-KMTGADN3.mjs} +28 -0
- package/dist/{chunk-6ETPZTJI.mjs → chunk-LSZAVSGY.mjs} +116 -55
- package/dist/{chunk-HMIJDL7S.mjs → chunk-MKYBIIAQ.mjs} +30 -5
- package/dist/{chunk-RU3M2FIK.cjs → chunk-MRMI32SN.cjs} +87 -369
- package/dist/{chunk-7L5V3KQO.cjs → chunk-N2NAS2AM.cjs} +2 -2
- package/dist/{chunk-ICUQICNC.cjs → chunk-NMHWYWDR.cjs} +654 -481
- package/dist/{chunk-G5RT7EXW.mjs → chunk-O6I6VWKK.mjs} +20 -5
- package/dist/{chunk-PDOCJ6RY.mjs → chunk-O6WAEAX3.mjs} +1 -1
- package/dist/{chunk-6DU6UFUE.mjs → chunk-OHLSEQ57.mjs} +16 -8
- package/dist/{chunk-3PXS2MHU.mjs → chunk-OO7GXVSR.mjs} +1 -1
- package/dist/chunk-PTZ2TVNE.cjs +178 -0
- package/dist/{chunk-6WCPV6G2.mjs → chunk-Q2KB32T4.mjs} +1 -1
- package/dist/{chunk-XCACDAZZ.cjs → chunk-S6VYG6XU.cjs} +23 -8
- package/dist/{chunk-VFQT3LAO.cjs → chunk-SDOTRX3V.cjs} +5 -5
- package/dist/{chunk-BMWDEBXO.cjs → chunk-SHLXACIO.cjs} +31 -3
- package/dist/{chunk-22LTEMGQ.mjs → chunk-T4OGRVNS.mjs} +13 -3
- package/dist/{chunk-ZXGAFZDO.cjs → chunk-T5OJPTVN.cjs} +2 -2
- package/dist/{chunk-VZJR7UTG.cjs → chunk-TE2G5ION.cjs} +2 -2
- package/dist/chunk-UH6QN5NL.mjs +178 -0
- package/dist/{chunk-F7JZENPF.cjs → chunk-UVW64BCB.cjs} +38 -30
- package/dist/{chunk-OKZUAXHF.mjs → chunk-VILIPRS6.mjs} +1 -1
- package/dist/{chunk-3UH7MRCP.cjs → chunk-VQLJWDVW.cjs} +13 -13
- package/dist/{chunk-VPTDD5XF.cjs → chunk-WBKEZXWE.cjs} +5 -0
- package/dist/{chunk-EJQT6KZN.cjs → chunk-WC5UV2HQ.cjs} +2 -2
- package/dist/{chunk-YULD7ICZ.mjs → chunk-WZ77PUAM.mjs} +1 -1
- package/dist/{chunk-C35ZBVRD.mjs → chunk-YWMZUGIS.mjs} +6 -2
- package/dist/{chunk-Y7RKTKYI.mjs → chunk-ZMMBIVQM.mjs} +10 -0
- package/dist/{chunk-ULAWS2PA.cjs → chunk-ZWM5KGAA.cjs} +6 -6
- package/dist/{client-plugins-CvIslxWi.d.mts → client-plugins-C3mK9Pol.d.mts} +98 -5
- package/dist/{client-plugins-HIyulDym.d.ts → client-plugins-r1mOtSC1.d.ts} +98 -5
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{devtools-EE5RIBTH.mjs → devtools-ERIKFEXX.mjs} +9 -8
- package/dist/{devtools-EAUY43BS.cjs → devtools-JZJJY5CK.cjs} +10 -9
- package/dist/docs.cjs +12 -11
- package/dist/docs.d.mts +2 -2
- package/dist/docs.d.ts +2 -2
- package/dist/docs.mjs +11 -10
- package/dist/image/server.cjs +3 -3
- package/dist/image/server.mjs +2 -2
- package/dist/image/sharp.cjs +10 -10
- package/dist/image/sharp.mjs +2 -2
- package/dist/index.cjs +39 -35
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +38 -34
- package/dist/integrations.cjs +7 -3
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.mjs +6 -2
- package/dist/internal/app-markdown-runtime.cjs +3 -3
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +27 -25
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +26 -24
- package/dist/internal/cli-runtime.cjs +14 -13
- package/dist/internal/cli-runtime.mjs +13 -12
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +10 -9
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +9 -8
- package/dist/internal/isolated-boundary.cjs +2 -2
- package/dist/internal/isolated-boundary.d.mts +0 -1
- package/dist/internal/isolated-boundary.d.ts +0 -1
- package/dist/internal/isolated-boundary.mjs +1 -1
- package/dist/internal/metadata-image-runtime.cjs +3 -3
- package/dist/internal/metadata-image-runtime.mjs +2 -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 +23 -9
- package/dist/internal/production-runtime.d.mts +67 -27
- package/dist/internal/production-runtime.d.ts +67 -27
- package/dist/internal/production-runtime.mjs +26 -12
- package/dist/{layers-BRQF5ETU.mjs → layers-UTB43B7A.mjs} +1 -1
- package/dist/layers-VUWIOFEO.cjs +18 -0
- package/dist/markdown.cjs +1 -1
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/middleware.cjs +6 -6
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/middleware.mjs +5 -5
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/{nitro-OVPLKPE2.cjs → nitro-7F65EZZS.cjs} +3 -3
- package/dist/{nitro-MXRDCXWZ.mjs → nitro-MPZJGPXK.mjs} +2 -2
- package/dist/plugin.cjs +23 -21
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +22 -20
- package/dist/{production-runtime-0sRnuYc-.d.mts → production-runtime-CCeVZXst.d.mts} +1 -1
- package/dist/{production-runtime-Crq6CJ-2.d.ts → production-runtime-DPnsggY3.d.ts} +1 -1
- package/dist/{render-plan-gs9GGPzw.d.mts → render-plan-BuGaPFe6.d.mts} +1 -1
- package/dist/{render-plan-8ozZh2Qv.d.ts → render-plan-Cw4f5E_R.d.ts} +1 -1
- package/dist/renderer/react/server.cjs +3 -3
- package/dist/renderer/react/server.mjs +1 -1
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/{request-B5G8rLBH.d.ts → request-Bkg-hERy.d.ts} +1 -1
- package/dist/{request-fkhiynXe.d.mts → request-CsGARcAw.d.mts} +1 -1
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/{route-rendering-lS5nUMua.d.ts → route-rendering-BUZMH_64.d.ts} +1 -1
- package/dist/{route-rendering-CLnS7AZj.d.mts → route-rendering-f11yh5dp.d.mts} +1 -1
- package/dist/{router-4iuiYnOW.d.ts → router-B8CR9GbD.d.ts} +1 -1
- package/dist/{router-ifU8Dui1.d.mts → router-Cp6yRE8A.d.mts} +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/runtime-CAEv36S_.d.mts +69 -0
- package/dist/runtime-CQVsT330.d.ts +69 -0
- package/dist/server-action-security.cjs +3 -3
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn.cjs +4 -4
- package/dist/server-fn.mjs +3 -3
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-query.cjs +5 -5
- package/dist/server-query.mjs +4 -4
- package/dist/server.cjs +42 -40
- package/dist/server.d.mts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.mjs +25 -23
- package/dist/{spa-router-DaJk5Re4.d.ts → spa-router-BuciWGCZ.d.ts} +2 -2
- package/dist/{spa-router-Bq7VCOwx.d.mts → spa-router-DwbqGkGj.d.mts} +2 -2
- package/dist/testing.cjs +8 -8
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +6 -6
- package/dist/{utils-XJn0c9bj.d.mts → utils-B9V0S_yL.d.mts} +1 -1
- package/dist/{utils-BXLmFsVR.d.ts → utils-CaoWKtYM.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +23 -21
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +22 -20
- package/dist/workflows.cjs +3 -3
- package/dist/workflows.mjs +2 -2
- package/package.json +1 -1
- package/dist/layers-4PNE2HOY.cjs +0 -18
- package/dist/{chunk-2F2ER724.cjs → chunk-BPMATOP2.cjs} +2 -2
- package/dist/{chunk-IHNMMXHV.mjs → chunk-OTC5BDGO.mjs} +3 -3
|
@@ -34,6 +34,33 @@ async function loadFarmDevModule(server, id, environmentName = "ssr") {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
__name(loadFarmDevModule, "loadFarmDevModule");
|
|
37
|
+
function invalidateFarmDevDependents(server, file, targets, environmentName = "ssr") {
|
|
38
|
+
const environment = server.environments[environmentName];
|
|
39
|
+
const graph = environment?.moduleGraph;
|
|
40
|
+
if (!graph || targets.size === 0) return [];
|
|
41
|
+
const posix = /* @__PURE__ */ __name((filePath) => filePath.replace(/\\/g, "/"), "posix");
|
|
42
|
+
const byFile = new Map([...targets].map((target) => [posix(target), target]));
|
|
43
|
+
const reached = /* @__PURE__ */ new Set();
|
|
44
|
+
const seen = /* @__PURE__ */ new Set();
|
|
45
|
+
const queue = [...graph.getModulesByFile(posix(file)) ?? []];
|
|
46
|
+
while (queue.length > 0) {
|
|
47
|
+
const node = queue.pop();
|
|
48
|
+
if (seen.has(node)) continue;
|
|
49
|
+
seen.add(node);
|
|
50
|
+
const target = node.file ? byFile.get(posix(node.file)) : void 0;
|
|
51
|
+
if (target) reached.add(target);
|
|
52
|
+
queue.push(...node.importers);
|
|
53
|
+
}
|
|
54
|
+
if (reached.size === 0) return [];
|
|
55
|
+
const evaluatedModules = environment.runner?.evaluatedModules;
|
|
56
|
+
for (const node of seen) {
|
|
57
|
+
graph.invalidateModule(node);
|
|
58
|
+
const evaluated = node.id ? evaluatedModules?.getModuleById(node.id) : void 0;
|
|
59
|
+
if (evaluated) evaluatedModules.invalidateModule(evaluated);
|
|
60
|
+
}
|
|
61
|
+
return [...reached];
|
|
62
|
+
}
|
|
63
|
+
__name(invalidateFarmDevDependents, "invalidateFarmDevDependents");
|
|
37
64
|
function invalidateFailedFarmDevModules(server) {
|
|
38
65
|
for (const entry of Object.values(server.environments)) {
|
|
39
66
|
const environment = entry;
|
|
@@ -62,6 +89,7 @@ __name(toFileModuleUrl, "toFileModuleUrl");
|
|
|
62
89
|
export {
|
|
63
90
|
FarmDevEnvironmentError,
|
|
64
91
|
loadFarmDevModule,
|
|
92
|
+
invalidateFarmDevDependents,
|
|
65
93
|
invalidateFailedFarmDevModules,
|
|
66
94
|
toFileModuleUrl
|
|
67
95
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FARM_DEFAULT_MCP_TOOLS
|
|
3
|
+
} from "./chunk-UH6QN5NL.mjs";
|
|
1
4
|
import {
|
|
2
5
|
DEFAULT_ERROR_STYLES
|
|
3
6
|
} from "./chunk-XAXTTBUT.mjs";
|
|
4
7
|
import {
|
|
5
8
|
serializeFarmLlmsTxt
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DTSROJ5J.mjs";
|
|
7
10
|
import {
|
|
8
11
|
emitFarmAgentRead
|
|
9
12
|
} from "./chunk-MVL2RAJW.mjs";
|
|
@@ -18,15 +21,16 @@ import {
|
|
|
18
21
|
_listFarmRegisteredMCPServers
|
|
19
22
|
} from "./chunk-ZLAT2CWY.mjs";
|
|
20
23
|
import {
|
|
24
|
+
createFarmWeakETag,
|
|
21
25
|
matchesFarmIfNoneMatch
|
|
22
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-ZMMBIVQM.mjs";
|
|
23
27
|
import {
|
|
24
28
|
resolveFarmAPIServerBasePath,
|
|
25
29
|
resolveFarmAPIServerRoutePath
|
|
26
30
|
} from "./chunk-BTHHUD7Q.mjs";
|
|
27
31
|
import {
|
|
28
32
|
FARM_VERSION
|
|
29
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-OO7GXVSR.mjs";
|
|
30
34
|
import {
|
|
31
35
|
localizeFarmPathname
|
|
32
36
|
} from "./chunk-L3KT7IXV.mjs";
|
|
@@ -153,7 +157,7 @@ function ensureFarmDocumentHead(markup) {
|
|
|
153
157
|
}
|
|
154
158
|
__name(ensureFarmDocumentHead, "ensureFarmDocumentHead");
|
|
155
159
|
function ensureFarmDocumentRoot(markup) {
|
|
156
|
-
if (
|
|
160
|
+
if (/<body\b[^>]*>\s*<div\b[^>]*\sid=["']root["']/i.test(markup)) return markup;
|
|
157
161
|
return markup.replace(
|
|
158
162
|
/<body\b([^>]*)>/i,
|
|
159
163
|
(_match, attributes) => `<body${attributes}><div id="root">`
|
|
@@ -436,6 +440,13 @@ function listFarmMCPServerSources(input) {
|
|
|
436
440
|
if (sources.has(endpoint)) continue;
|
|
437
441
|
sources.set(endpoint, { ...server, endpoint, local: Boolean(server.path) });
|
|
438
442
|
}
|
|
443
|
+
if (sources.size === 0 && input.defaultMCP) {
|
|
444
|
+
const server = input.defaultMCP();
|
|
445
|
+
if (server) {
|
|
446
|
+
const endpoint = applyFarmBasePath(server.path, input.basePath);
|
|
447
|
+
sources.set(endpoint, { ...server, endpoint, local: true });
|
|
448
|
+
}
|
|
449
|
+
}
|
|
439
450
|
return [...sources.values()];
|
|
440
451
|
}
|
|
441
452
|
__name(listFarmMCPServerSources, "listFarmMCPServerSources");
|
|
@@ -526,7 +537,7 @@ function createFarmAiCatalogResponse(request, input = {}, requestUrl) {
|
|
|
526
537
|
const body = JSON.stringify(
|
|
527
538
|
card ? card.card : { specVersion: "1.0", entries: servers.map(({ entry }) => entry) }
|
|
528
539
|
);
|
|
529
|
-
const etag =
|
|
540
|
+
const etag = createFarmWeakETag(body);
|
|
530
541
|
const headers = {
|
|
531
542
|
...corsHeaders(),
|
|
532
543
|
"Content-Type": card ? `${SERVER_CARD_TYPE}; charset=utf-8` : ard ? "application/json; charset=utf-8" : `${AI_CATALOG_TYPE}; charset=utf-8`,
|
|
@@ -565,15 +576,6 @@ function truncate(text) {
|
|
|
565
576
|
return text.length <= CARD_DESCRIPTION_MAX ? text : `${text.slice(0, CARD_DESCRIPTION_MAX - 1).trimEnd()}\u2026`;
|
|
566
577
|
}
|
|
567
578
|
__name(truncate, "truncate");
|
|
568
|
-
function fnv1a(value) {
|
|
569
|
-
let hash = 2166136261;
|
|
570
|
-
for (let index = 0; index < value.length; index++) {
|
|
571
|
-
hash ^= value.charCodeAt(index);
|
|
572
|
-
hash = Math.imul(hash, 16777619);
|
|
573
|
-
}
|
|
574
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
575
|
-
}
|
|
576
|
-
__name(fnv1a, "fnv1a");
|
|
577
579
|
|
|
578
580
|
// src/components/error-page.ts
|
|
579
581
|
var ERROR_STATUS_TEXT = {
|
|
@@ -868,7 +870,12 @@ function createFarmApiCatalogResponse(method, input, request) {
|
|
|
868
870
|
__name(createFarmApiCatalogResponse, "createFarmApiCatalogResponse");
|
|
869
871
|
|
|
870
872
|
// src/app-manifest.ts
|
|
871
|
-
var FARM_APP_MANIFEST_PATH = "/.well-known/farmjs";
|
|
873
|
+
var FARM_APP_MANIFEST_PATH = "/.well-known/farmjs.json";
|
|
874
|
+
var FARM_APP_MANIFEST_LEGACY_PATH = "/.well-known/farmjs";
|
|
875
|
+
function isFarmAppManifestPath(pathname) {
|
|
876
|
+
return pathname === FARM_APP_MANIFEST_PATH || pathname === FARM_APP_MANIFEST_LEGACY_PATH;
|
|
877
|
+
}
|
|
878
|
+
__name(isFarmAppManifestPath, "isFarmAppManifestPath");
|
|
872
879
|
var FARM_INFRA_SIGNATURE_HEADER = "farmjs-infra-signature";
|
|
873
880
|
var SIGNED_PURPOSE = "farmjs-manifest-v1";
|
|
874
881
|
var SIGNATURE_WINDOW_SECONDS = 300;
|
|
@@ -901,8 +908,8 @@ var SOURCES = {
|
|
|
901
908
|
standalone: "defineTool",
|
|
902
909
|
serverFunction: "serverFunction"
|
|
903
910
|
};
|
|
904
|
-
function createFarmAppManifest(input) {
|
|
905
|
-
|
|
911
|
+
function createFarmAppManifest(input, { full = false } = {}) {
|
|
912
|
+
const manifest = {
|
|
906
913
|
schemaVersion: 1,
|
|
907
914
|
app: {
|
|
908
915
|
farm: FARM_VERSION,
|
|
@@ -912,37 +919,69 @@ function createFarmAppManifest(input) {
|
|
|
912
919
|
},
|
|
913
920
|
packages: input.packages,
|
|
914
921
|
mcp: {
|
|
915
|
-
servers: _listFarmMCPCatalogs().map(({ server, tools, details }) =>
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
922
|
+
servers: _listFarmMCPCatalogs().map(({ server, tools, details }) => {
|
|
923
|
+
const listed = full || details?.public === true;
|
|
924
|
+
return {
|
|
925
|
+
name: server.name,
|
|
926
|
+
version: server.version,
|
|
927
|
+
path: server.path,
|
|
928
|
+
authorization: details?.public === true ? "none" : "required",
|
|
929
|
+
resources: listed ? [...details?.resources ?? []] : [],
|
|
930
|
+
prompts: listed ? [...details?.prompts ?? []] : [],
|
|
931
|
+
tools: (listed ? tools : []).map((tool) => {
|
|
932
|
+
const schemas = details?.schemas?.[tool.name];
|
|
933
|
+
const hints = Object.fromEntries(
|
|
934
|
+
["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"].filter((hint) => typeof tool[hint] === "boolean").map((hint) => [hint, tool[hint]])
|
|
935
|
+
);
|
|
936
|
+
return {
|
|
937
|
+
name: tool.name,
|
|
938
|
+
...tool.title ? { title: tool.title } : {},
|
|
939
|
+
...tool.description ? { description: tool.description } : {},
|
|
940
|
+
source: SOURCES[tool.kind],
|
|
941
|
+
// MCP clients never see the route behind a tool; only Infra's view names it.
|
|
942
|
+
...full && tool.kind === "endpoint" ? { method: tool.method, path: tool.path } : {},
|
|
943
|
+
...hints,
|
|
944
|
+
...schemas ? { inputSchema: schemas.input } : {},
|
|
945
|
+
...schemas?.output ? { outputSchema: schemas.output } : {}
|
|
946
|
+
};
|
|
947
|
+
})
|
|
948
|
+
};
|
|
949
|
+
})
|
|
938
950
|
},
|
|
939
951
|
webmcp: input.webmcp,
|
|
940
952
|
integrations: input.integrations,
|
|
941
953
|
agent: input.agent,
|
|
942
954
|
plugins: input.plugins
|
|
943
955
|
};
|
|
956
|
+
manifest.mcp.servers.push(...listDefaultServer(input));
|
|
957
|
+
return manifest;
|
|
944
958
|
}
|
|
945
959
|
__name(createFarmAppManifest, "createFarmAppManifest");
|
|
960
|
+
function listDefaultServer(input) {
|
|
961
|
+
const server = input.defaultMCP?.();
|
|
962
|
+
if (!server) return [];
|
|
963
|
+
return [
|
|
964
|
+
{
|
|
965
|
+
name: server.name,
|
|
966
|
+
version: server.version,
|
|
967
|
+
path: server.path,
|
|
968
|
+
authorization: "none",
|
|
969
|
+
resources: [],
|
|
970
|
+
prompts: [],
|
|
971
|
+
tools: FARM_DEFAULT_MCP_TOOLS.map((tool) => ({
|
|
972
|
+
name: tool.name,
|
|
973
|
+
title: tool.title,
|
|
974
|
+
description: tool.description,
|
|
975
|
+
// Standalone tools with no endpoint behind them, like defineTool's.
|
|
976
|
+
source: "defineTool",
|
|
977
|
+
...tool.annotations,
|
|
978
|
+
inputSchema: tool.inputSchema,
|
|
979
|
+
..."outputSchema" in tool ? { outputSchema: tool.outputSchema } : {}
|
|
980
|
+
}))
|
|
981
|
+
}
|
|
982
|
+
];
|
|
983
|
+
}
|
|
984
|
+
__name(listDefaultServer, "listDefaultServer");
|
|
946
985
|
var encoder = new TextEncoder();
|
|
947
986
|
var hex = /* @__PURE__ */ __name((bytes) => [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join(""), "hex");
|
|
948
987
|
async function sha256Hex(value) {
|
|
@@ -987,22 +1026,41 @@ function processEnv() {
|
|
|
987
1026
|
return globalThis.process?.env ?? {};
|
|
988
1027
|
}
|
|
989
1028
|
__name(processEnv, "processEnv");
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1029
|
+
var CORS_HEADERS = {
|
|
1030
|
+
"access-control-allow-origin": "*",
|
|
1031
|
+
"access-control-allow-methods": "GET, HEAD, OPTIONS",
|
|
1032
|
+
"access-control-allow-headers": `If-None-Match, ${FARM_INFRA_SIGNATURE_HEADER}`,
|
|
1033
|
+
"access-control-expose-headers": "ETag"
|
|
1034
|
+
};
|
|
1035
|
+
async function createFarmAppManifestResponse(request, input, options = {}) {
|
|
1036
|
+
const method = request.method.toUpperCase();
|
|
1037
|
+
if (method === "OPTIONS") return new Response(null, { status: 204, headers: CORS_HEADERS });
|
|
1038
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
1039
|
+
return new Response("Method Not Allowed", {
|
|
1040
|
+
status: 405,
|
|
1041
|
+
headers: { ...CORS_HEADERS, allow: "GET, HEAD, OPTIONS", "content-type": "text/plain" }
|
|
1042
|
+
});
|
|
1001
1043
|
}
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1044
|
+
const signature = request.headers.get(FARM_INFRA_SIGNATURE_HEADER);
|
|
1045
|
+
const key = input.analytics ? (options.env ?? processEnv()).FARMJS_API_KEY?.trim() : void 0;
|
|
1046
|
+
const full = Boolean(
|
|
1047
|
+
signature && key && await verifyFarmInfraManifestSignature(signature, key)
|
|
1048
|
+
);
|
|
1049
|
+
const body = JSON.stringify(createFarmAppManifest(input, { full }));
|
|
1050
|
+
const etag = createFarmWeakETag(body);
|
|
1051
|
+
const headers = {
|
|
1052
|
+
...CORS_HEADERS,
|
|
1053
|
+
"content-type": "application/json; charset=utf-8",
|
|
1054
|
+
// The full view is for Infra alone; shared caches keep the two views apart.
|
|
1055
|
+
"cache-control": full ? "private, no-store" : "public, max-age=0, must-revalidate",
|
|
1056
|
+
vary: FARM_INFRA_SIGNATURE_HEADER,
|
|
1057
|
+
etag,
|
|
1058
|
+
"x-content-type-options": "nosniff"
|
|
1059
|
+
};
|
|
1060
|
+
if (!full && matchesFarmIfNoneMatch(request.headers.get("if-none-match"), etag)) {
|
|
1061
|
+
return new Response(null, { status: 304, headers });
|
|
1062
|
+
}
|
|
1063
|
+
return new Response(method === "HEAD" ? null : body, { status: 200, headers });
|
|
1006
1064
|
}
|
|
1007
1065
|
__name(createFarmAppManifestResponse, "createFarmAppManifestResponse");
|
|
1008
1066
|
|
|
@@ -1035,6 +1093,9 @@ export {
|
|
|
1035
1093
|
resolveFarmApiCatalogInput,
|
|
1036
1094
|
createFarmApiCatalogResponse,
|
|
1037
1095
|
FARM_APP_MANIFEST_PATH,
|
|
1096
|
+
FARM_APP_MANIFEST_LEGACY_PATH,
|
|
1097
|
+
isFarmAppManifestPath,
|
|
1098
|
+
FARM_INFRA_SIGNATURE_HEADER,
|
|
1038
1099
|
resolveFarmAppManifestInput,
|
|
1039
1100
|
createFarmAppManifestResponse
|
|
1040
1101
|
};
|
|
@@ -16,11 +16,15 @@ import {
|
|
|
16
16
|
readNodeRequestBody,
|
|
17
17
|
resolveFarmServerConfig,
|
|
18
18
|
setRequestContext
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-ZMMBIVQM.mjs";
|
|
20
20
|
import {
|
|
21
21
|
applyWebResponseHeaders,
|
|
22
22
|
sendWebResponse
|
|
23
23
|
} from "./chunk-Z2RZJZIZ.mjs";
|
|
24
|
+
import {
|
|
25
|
+
createFarmAPIMiddlewarePathnames,
|
|
26
|
+
resolveFarmAPIServerBasePath
|
|
27
|
+
} from "./chunk-BTHHUD7Q.mjs";
|
|
24
28
|
import {
|
|
25
29
|
api,
|
|
26
30
|
defineIntegrationAPIOperation
|
|
@@ -1577,10 +1581,12 @@ async function dispatchIntegrationRequest(runtime, request, options = {}) {
|
|
|
1577
1581
|
const middleware = [...integration.middleware || []];
|
|
1578
1582
|
const forwardedSetCookies = [];
|
|
1579
1583
|
for (const entry of middleware) {
|
|
1584
|
+
if (options.ranMiddleware?.has(entry)) continue;
|
|
1580
1585
|
const params = resolveIntegrationMiddlewareParams(entry, pathname, runtime.config);
|
|
1581
1586
|
if (!params) {
|
|
1582
1587
|
continue;
|
|
1583
1588
|
}
|
|
1589
|
+
options.ranMiddleware?.add(entry);
|
|
1584
1590
|
const handlerContext = createServerIntegrationHandlerContext({
|
|
1585
1591
|
runtime,
|
|
1586
1592
|
route: {
|
|
@@ -1845,6 +1851,7 @@ async function dispatchIntegrationRequests(integrations, runtime, request, optio
|
|
|
1845
1851
|
request.clone(),
|
|
1846
1852
|
{
|
|
1847
1853
|
currentRequest: options.currentRequest,
|
|
1854
|
+
ranMiddleware: options.ranMiddleware,
|
|
1848
1855
|
onForwardedCookies: /* @__PURE__ */ __name((cookies) => setCookies.push(...cookies), "onForwardedCookies")
|
|
1849
1856
|
}
|
|
1850
1857
|
);
|
|
@@ -2006,8 +2013,10 @@ function resolveIntegrationMiddlewareParams(entry, pathname, config) {
|
|
|
2006
2013
|
const params = resolveMatcherParams(entry.matcher, pathname);
|
|
2007
2014
|
if (params || !entry.matcher) return params;
|
|
2008
2015
|
const routePathname = resolveIntegrationRoutePathname(pathname, config);
|
|
2009
|
-
|
|
2010
|
-
|
|
2016
|
+
const candidates = [.../* @__PURE__ */ new Set([pathname, ...getIntegrationAPIPathnames(config)(routePathname)])];
|
|
2017
|
+
for (const candidate of candidates) {
|
|
2018
|
+
if (candidate === pathname) continue;
|
|
2019
|
+
const routeParams = resolveMatcherParams(entry.matcher, candidate);
|
|
2011
2020
|
if (routeParams) return routeParams;
|
|
2012
2021
|
}
|
|
2013
2022
|
let compiled = compiledIntegrationGuards.get(entry);
|
|
@@ -2017,13 +2026,28 @@ function resolveIntegrationMiddlewareParams(entry, pathname, config) {
|
|
|
2017
2026
|
});
|
|
2018
2027
|
compiledIntegrationGuards.set(entry, compiled);
|
|
2019
2028
|
}
|
|
2020
|
-
for (const candidate of
|
|
2029
|
+
for (const candidate of candidates) {
|
|
2021
2030
|
const result = matchesCompiledMiddlewareConfig(candidate, compiled, noMiddlewareContext);
|
|
2022
2031
|
if (result.matched) return result.params ?? {};
|
|
2023
2032
|
}
|
|
2024
2033
|
return null;
|
|
2025
2034
|
}
|
|
2026
2035
|
__name(resolveIntegrationMiddlewareParams, "resolveIntegrationMiddlewareParams");
|
|
2036
|
+
var FARM_INTEGRATION_API_BASE_PATH_KEY = "__farmAPIServerBasePath";
|
|
2037
|
+
var integrationAPIPathnames = /* @__PURE__ */ new WeakMap();
|
|
2038
|
+
function getIntegrationAPIPathnames(config) {
|
|
2039
|
+
if (!config) return (pathname) => [pathname];
|
|
2040
|
+
let toPathnames = integrationAPIPathnames.get(config);
|
|
2041
|
+
if (!toPathnames) {
|
|
2042
|
+
const recorded = config[FARM_INTEGRATION_API_BASE_PATH_KEY];
|
|
2043
|
+
const api2 = config.api;
|
|
2044
|
+
const serverBasePath = typeof recorded === "string" ? recorded : typeof api2?.baseURL === "string" && typeof api2.basePath === "string" ? resolveFarmAPIServerBasePath(api2) : void 0;
|
|
2045
|
+
toPathnames = createFarmAPIMiddlewarePathnames(serverBasePath);
|
|
2046
|
+
integrationAPIPathnames.set(config, toPathnames);
|
|
2047
|
+
}
|
|
2048
|
+
return toPathnames;
|
|
2049
|
+
}
|
|
2050
|
+
__name(getIntegrationAPIPathnames, "getIntegrationAPIPathnames");
|
|
2027
2051
|
function resolveIntegrationRoutePathname(pathname, config) {
|
|
2028
2052
|
const basePath = typeof config?.basePath === "string" ? config.basePath : void 0;
|
|
2029
2053
|
let routePathname = basePath ? stripFarmBasePath(pathname, basePath) : pathname;
|
|
@@ -2158,5 +2182,6 @@ export {
|
|
|
2158
2182
|
matchRegisteredIntegrationRoute,
|
|
2159
2183
|
getRegisteredIntegrationAPIManifest,
|
|
2160
2184
|
dispatchIntegrationRequest,
|
|
2161
|
-
dispatchIntegrationRequests
|
|
2185
|
+
dispatchIntegrationRequests,
|
|
2186
|
+
FARM_INTEGRATION_API_BASE_PATH_KEY
|
|
2162
2187
|
};
|