@farm.js/core 0.1.35 → 0.1.37
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-BnLDsUOS.d.ts → agent-mcp-BC0bAGVF.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-WGpBYcGn.d.mts → agent-mcp-jyDHbQKe.d.ts} +45 -2
- package/dist/agent-runtime.cjs +6 -4
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/agent-runtime.mjs +5 -3
- package/dist/api/client.cjs +3 -3
- package/dist/api/client.mjs +2 -2
- package/dist/api/route-manager.cjs +9 -9
- package/dist/api/route-manager.d.mts +10 -4
- package/dist/api/route-manager.d.ts +10 -4
- package/dist/api/route-manager.mjs +8 -8
- package/dist/api/runtime.cjs +6 -6
- package/dist/api/runtime.d.mts +4 -62
- package/dist/api/runtime.d.ts +4 -62
- package/dist/api/runtime.mjs +5 -5
- package/dist/api.cjs +13 -12
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/api.mjs +12 -11
- package/dist/{app-BXB3JZYc.d.ts → app-CKO3iN1c.d.ts} +17 -3
- package/dist/{app-D_j9AAVL.d.mts → app-Cbkj9ufe.d.mts} +17 -3
- package/dist/app-markdown.cjs +6 -4
- package/dist/app-markdown.d.mts +3 -3
- package/dist/app-markdown.d.ts +3 -3
- package/dist/app-markdown.mjs +5 -3
- package/dist/{chunk-F7JZENPF.cjs → chunk-3A4KGQYI.cjs} +38 -30
- package/dist/{chunk-4MMGO7YW.cjs → chunk-3IP27TCG.cjs} +43 -32
- package/dist/{chunk-FDR64H6B.mjs → chunk-3KGDJLJK.mjs} +41 -2
- package/dist/{chunk-UJD4PHYB.mjs → chunk-4E5WBPEG.mjs} +72 -354
- package/dist/{chunk-KXWRO25S.cjs → chunk-4GPOC4LN.cjs} +3 -3
- package/dist/{chunk-Z2HLU4IX.cjs → chunk-4GWRFP22.cjs} +23 -2
- package/dist/{chunk-4KU5Q7C2.mjs → chunk-4P6ULFMD.mjs} +253 -67
- package/dist/chunk-4WQ6PGSJ.cjs +367 -0
- package/dist/{chunk-SMHH4VDG.mjs → chunk-4WVJLURN.mjs} +1 -1
- package/dist/{chunk-2F2ER724.cjs → chunk-5BXGGEC7.cjs} +27 -22
- package/dist/{chunk-3BHT4WMP.cjs → chunk-5D2JIPLH.cjs} +8 -8
- package/dist/{chunk-AHGECQEW.mjs → chunk-666CKENS.mjs} +1 -1
- package/dist/{chunk-GFHLGIYC.cjs → chunk-6LGFV2CQ.cjs} +8 -8
- package/dist/chunk-6SJ2KJTA.mjs +314 -0
- package/dist/{chunk-PFQKNERH.cjs → chunk-6TJITR2B.cjs} +457 -218
- package/dist/{chunk-73MC7ZL6.cjs → chunk-75X755YZ.cjs} +2 -2
- package/dist/{chunk-3UH7MRCP.cjs → chunk-7DWNJI73.cjs} +13 -13
- package/dist/{chunk-7L5V3KQO.cjs → chunk-7O5M4UKW.cjs} +2 -2
- package/dist/{chunk-BJPBQNIE.cjs → chunk-7SQ5SGYZ.cjs} +2 -2
- package/dist/{chunk-27ZWSI3W.cjs → chunk-ADOAUDQ6.cjs} +2 -2
- package/dist/{chunk-CP6X4AEU.mjs → chunk-AJQTP4OO.mjs} +1 -1
- package/dist/{chunk-YKX5BK66.cjs → chunk-ATWHHSY2.cjs} +7 -7
- package/dist/{chunk-EFCQPQMG.cjs → chunk-B5PFZLKV.cjs} +89 -8
- package/dist/{chunk-FNO7A7CM.cjs → chunk-BHY547NB.cjs} +34 -16
- package/dist/{chunk-JHWOVJ3M.mjs → chunk-BUGNQIHC.mjs} +5 -0
- package/dist/{chunk-7GLPRTTF.cjs → chunk-CGBDNNSM.cjs} +2 -2
- package/dist/chunk-CI6E3UOH.cjs +314 -0
- package/dist/{chunk-2G2NNLE2.mjs → chunk-CQMVIOYP.mjs} +5 -5
- package/dist/{chunk-X6W5FFH6.cjs → chunk-CVH2BXPY.cjs} +8 -8
- package/dist/{chunk-TKSCR644.cjs → chunk-D3C5LBQY.cjs} +2 -2
- package/dist/{chunk-PZNL3WEG.mjs → chunk-DMEPTZTI.mjs} +22 -11
- package/dist/chunk-DTSROJ5J.mjs +367 -0
- package/dist/{chunk-DBNKI4NF.cjs → chunk-ECKF2BAM.cjs} +6 -2
- package/dist/{chunk-GQ3Z3IZI.cjs → chunk-EMMQ64QW.cjs} +18 -18
- package/dist/{chunk-6DU6UFUE.mjs → chunk-EXG5LD6B.mjs} +16 -8
- package/dist/{chunk-HUMR6LSU.mjs → chunk-F5QO4FNE.mjs} +1 -1
- package/dist/{chunk-YULD7ICZ.mjs → chunk-FBOJ55OM.mjs} +1 -1
- package/dist/{chunk-IHNMMXHV.mjs → chunk-FGRYBX5X.mjs} +15 -10
- package/dist/{chunk-D227TIEN.cjs → chunk-FWE7LEQC.cjs} +13 -13
- package/dist/{chunk-3BU22U3M.cjs → chunk-G2TEB74S.cjs} +5 -2
- package/dist/{chunk-G5RT7EXW.mjs → chunk-HEVMCTSR.mjs} +21 -6
- package/dist/{chunk-W7LF2J2S.mjs → chunk-HMRSWN47.mjs} +1 -1
- package/dist/{chunk-JG6DJF5A.mjs → chunk-HZFM2LWQ.mjs} +22 -1
- package/dist/{chunk-UAORZ7QA.mjs → chunk-IAIYV4RZ.mjs} +2 -2
- package/dist/{chunk-F2SE2VDO.mjs → chunk-IHQIOZLC.mjs} +1 -1
- package/dist/{chunk-2NNMOPDN.mjs → chunk-J3ANCZKA.mjs} +4 -1
- package/dist/{chunk-C4SPBWFM.cjs → chunk-JEZO6VUR.cjs} +10 -1
- package/dist/{chunk-SC2WYWPF.mjs → chunk-JPNFPAZ4.mjs} +3 -3
- package/dist/{chunk-F6Z3Y5KL.mjs → chunk-K3SAEIM3.mjs} +5 -2
- package/dist/{chunk-QAU5JD57.mjs → chunk-K4I4O5TS.mjs} +289 -50
- package/dist/{chunk-KN7K4VQN.mjs → chunk-KDTBF3UU.mjs} +1 -1
- package/dist/{chunk-OMVAU7NT.cjs → chunk-KIIMAWOJ.cjs} +11 -1
- package/dist/{chunk-43FMW62B.mjs → chunk-KMTGADN3.mjs} +28 -0
- package/dist/{chunk-QORUJDIV.mjs → chunk-KPFKMDM7.mjs} +2 -2
- package/dist/{chunk-YSCV4SJF.cjs → chunk-L5H2GSUC.cjs} +4 -4
- package/dist/{chunk-YDQZGSDS.mjs → chunk-LBDP3YT3.mjs} +1 -1
- package/dist/{chunk-6ETPZTJI.mjs → chunk-LBGILORX.mjs} +116 -55
- package/dist/{chunk-IPXLADVO.cjs → chunk-LOFKRKO7.cjs} +122 -61
- package/dist/{chunk-ULAWS2PA.cjs → chunk-LPFV45AY.cjs} +29 -26
- package/dist/{chunk-3KZS4SUS.mjs → chunk-MCIZVNOQ.mjs} +1 -1
- package/dist/{chunk-RU3M2FIK.cjs → chunk-MRMI32SN.cjs} +87 -369
- package/dist/{chunk-XCMCS4DA.mjs → chunk-ND2CWPOD.mjs} +2 -2
- package/dist/{chunk-XCACDAZZ.cjs → chunk-NDILNQ4L.cjs} +25 -10
- package/dist/{chunk-6TJOML4E.mjs → chunk-NFMDCAOS.mjs} +14 -11
- package/dist/{chunk-UXFQ3UDA.cjs → chunk-NICDYKBS.cjs} +42 -3
- package/dist/{chunk-EZDQRNQ7.mjs → chunk-NNSAQX3U.mjs} +23 -5
- package/dist/{chunk-YC6V7PWE.cjs → chunk-NQ6QFZWD.cjs} +1 -1
- package/dist/{chunk-PDOCJ6RY.mjs → chunk-O6WAEAX3.mjs} +1 -1
- package/dist/{chunk-U4KT7QP3.cjs → chunk-OW67PDDS.cjs} +14 -1
- package/dist/{chunk-77GNHH2Z.cjs → chunk-PMQHMWZU.cjs} +3 -3
- package/dist/chunk-PTZ2TVNE.cjs +178 -0
- package/dist/{chunk-6WCPV6G2.mjs → chunk-Q2KB32T4.mjs} +1 -1
- package/dist/{chunk-ICUQICNC.cjs → chunk-Q5FYSK45.cjs} +718 -532
- package/dist/{chunk-5SJWVY6R.mjs → chunk-QHSH7IH4.mjs} +9 -0
- package/dist/{chunk-Q3VLETLE.mjs → chunk-RRMVL6CJ.mjs} +4 -4
- package/dist/{chunk-IZY3V5XW.mjs → chunk-S3VWVTVA.mjs} +14 -1
- package/dist/{chunk-FFFW3OQ7.cjs → chunk-S6FJO323.cjs} +2 -2
- package/dist/{chunk-VFQT3LAO.cjs → chunk-SDOTRX3V.cjs} +5 -5
- package/dist/chunk-SGBZPZUW.mjs +75 -0
- package/dist/{chunk-BMWDEBXO.cjs → chunk-SHLXACIO.cjs} +31 -3
- package/dist/{chunk-ZXGAFZDO.cjs → chunk-T5OJPTVN.cjs} +2 -2
- package/dist/{chunk-2ELDTQRN.mjs → chunk-TDNWPAVR.mjs} +1 -1
- package/dist/{chunk-VZJR7UTG.cjs → chunk-TE2G5ION.cjs} +2 -2
- package/dist/{chunk-IHNIDL6H.cjs → chunk-TO4GJ56K.cjs} +22 -11
- package/dist/{chunk-4JHOT46A.mjs → chunk-TPLJVC7E.mjs} +86 -5
- package/dist/{chunk-NRSN7G7E.mjs → chunk-TW4GYDBJ.mjs} +1 -1
- package/dist/{chunk-XBML5KMG.cjs → chunk-U6MPZ35Q.cjs} +24 -14
- package/dist/chunk-UH6QN5NL.mjs +178 -0
- package/dist/{chunk-FTFYRMQQ.cjs → chunk-UJZLSXUB.cjs} +53 -28
- package/dist/chunk-UXHS27O6.cjs +75 -0
- package/dist/{chunk-DQQOKWYA.cjs → chunk-VR4GD5I3.cjs} +3 -3
- package/dist/{chunk-22LTEMGQ.mjs → chunk-VXAWRDK7.mjs} +14 -4
- package/dist/{chunk-62XKI4Z3.cjs → chunk-W2YDNK66.cjs} +6 -3
- package/dist/{chunk-VPTDD5XF.cjs → chunk-WBKEZXWE.cjs} +5 -0
- package/dist/{chunk-EJQT6KZN.cjs → chunk-WC5UV2HQ.cjs} +2 -2
- package/dist/{chunk-SAZVVAJH.mjs → chunk-WQ7T2263.mjs} +18 -7
- package/dist/chunk-WRPHYQVY.mjs +109 -0
- package/dist/chunk-WT4TGLXT.cjs +109 -0
- package/dist/{chunk-SOMHP6GF.mjs → chunk-XOPOIFTJ.mjs} +2 -2
- package/dist/{chunk-3PXS2MHU.mjs → chunk-YCKO6FRS.mjs} +1 -1
- package/dist/{chunk-C35ZBVRD.mjs → chunk-YWMZUGIS.mjs} +6 -2
- package/dist/{chunk-HMIJDL7S.mjs → chunk-Z5BEWYVO.mjs} +31 -6
- package/dist/{chunk-OKZUAXHF.mjs → chunk-Z7LA7MHQ.mjs} +1 -1
- package/dist/{chunk-Y7RKTKYI.mjs → chunk-ZMMBIVQM.mjs} +10 -0
- package/dist/{client-plugins-HIyulDym.d.ts → client-plugins-C8DjftDF.d.ts} +112 -5
- package/dist/{client-plugins-CvIslxWi.d.mts → client-plugins-CV4eJ9De.d.mts} +112 -5
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +8 -8
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +7 -7
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{devtools-EAUY43BS.cjs → devtools-JXFQNWSH.cjs} +11 -10
- package/dist/{devtools-EE5RIBTH.mjs → devtools-KVOY2TCZ.mjs} +10 -9
- package/dist/docs.cjs +13 -12
- package/dist/docs.d.mts +2 -2
- package/dist/docs.d.ts +2 -2
- package/dist/docs.mjs +12 -11
- package/dist/headers.cjs +4 -4
- package/dist/headers.mjs +3 -3
- package/dist/i18n/client.cjs +11 -11
- package/dist/i18n/client.mjs +3 -3
- 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 +61 -54
- package/dist/index.d.mts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.mjs +60 -53
- package/dist/integrations.cjs +8 -4
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.mjs +7 -3
- package/dist/internal/app-markdown-runtime.cjs +5 -3
- package/dist/internal/app-markdown-runtime.d.mts +19 -5
- package/dist/internal/app-markdown-runtime.d.ts +19 -5
- package/dist/internal/app-markdown-runtime.mjs +4 -2
- package/dist/internal/build-runtime.cjs +38 -34
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +37 -33
- package/dist/internal/cli-runtime.cjs +17 -16
- package/dist/internal/cli-runtime.mjs +16 -15
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +2 -2
- package/dist/internal/client-runtime.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 +11 -10
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +10 -9
- package/dist/internal/infra-analytics-runtime.cjs +5 -5
- package/dist/internal/infra-analytics-runtime.mjs +3 -3
- 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 +27 -48
- package/dist/internal/production-runtime.d.mts +67 -27
- package/dist/internal/production-runtime.d.ts +67 -27
- package/dist/internal/production-runtime.mjs +34 -55
- 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 +10 -10
- package/dist/middleware.d.mts +6 -4
- package/dist/middleware.d.ts +6 -4
- package/dist/middleware.mjs +9 -9
- package/dist/navigation.cjs +7 -7
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.mjs +6 -6
- package/dist/{nitro-OVPLKPE2.cjs → nitro-7F65EZZS.cjs} +3 -3
- package/dist/{nitro-MXRDCXWZ.mjs → nitro-MPZJGPXK.mjs} +2 -2
- package/dist/plugin.cjs +31 -28
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +30 -27
- package/dist/{production-runtime-Crq6CJ-2.d.ts → production-runtime-C2kkrPVZ.d.ts} +1 -1
- package/dist/{production-runtime-0sRnuYc-.d.mts → production-runtime-Du_FHb2-.d.mts} +1 -1
- package/dist/query/client.cjs +9 -9
- package/dist/query/client.mjs +4 -4
- package/dist/{render-plan-8ozZh2Qv.d.ts → render-plan-BnnPTpus.d.ts} +1 -1
- package/dist/{render-plan-gs9GGPzw.d.mts → render-plan-Cgx7v8tJ.d.mts} +1 -1
- package/dist/renderer/react/server.cjs +3 -3
- package/dist/renderer/react/server.mjs +1 -1
- package/dist/renderer-client.cjs +12 -12
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/renderer-client.mjs +4 -4
- package/dist/{request-B5G8rLBH.d.ts → request-BNWr7r5e.d.ts} +1 -1
- package/dist/{request-fkhiynXe.d.mts → request-sKayKcop.d.mts} +1 -1
- package/dist/request.cjs +3 -3
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/request.mjs +2 -2
- package/dist/{route-rendering-lS5nUMua.d.ts → route-rendering-Bx4Auw6Q.d.ts} +1 -1
- package/dist/{route-rendering-CLnS7AZj.d.mts → route-rendering-DWFp3Yq4.d.mts} +1 -1
- package/dist/{router-ifU8Dui1.d.mts → router-BK6K42Ij.d.mts} +1 -1
- package/dist/{router-4iuiYnOW.d.ts → router-DnW_2tQi.d.ts} +1 -1
- package/dist/routes.cjs +2 -2
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.mjs +1 -1
- package/dist/runtime-CA3Ei5k_.d.ts +69 -0
- package/dist/runtime-DJDaCMd_.d.mts +69 -0
- package/dist/server-action-security.cjs +3 -3
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn.cjs +5 -5
- package/dist/server-fn.mjs +4 -4
- package/dist/server-plugins.cjs +5 -5
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-plugins.mjs +4 -4
- package/dist/server-query.cjs +6 -6
- package/dist/server-query.mjs +5 -5
- package/dist/server.cjs +57 -54
- package/dist/server.d.mts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.mjs +35 -32
- package/dist/{spa-router-Bq7VCOwx.d.mts → spa-router-D6fUA4Rn.d.mts} +2 -2
- package/dist/{spa-router-DaJk5Re4.d.ts → spa-router-Mwbd7g2L.d.ts} +2 -2
- package/dist/testing.cjs +13 -13
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +10 -10
- package/dist/theme/server.cjs +4 -4
- package/dist/theme/server.mjs +3 -3
- package/dist/{utils-BXLmFsVR.d.ts → utils-BwVcAfUR.d.ts} +1 -1
- package/dist/{utils-XJn0c9bj.d.mts → utils-p9Hs-jCc.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +31 -28
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +30 -27
- package/dist/workflows.cjs +3 -3
- package/dist/workflows.mjs +2 -2
- package/package.json +1 -1
- package/types/middleware.d.ts +5 -1
- package/dist/chunk-FXEF4PPL.mjs +0 -47
- package/dist/chunk-XD32KALF.cjs +0 -47
- package/dist/layers-4PNE2HOY.cjs +0 -18
- /package/dist/{chunk-SJNMVDDF.cjs → chunk-FUCSUGDM.cjs} +0 -0
- /package/dist/{chunk-UDNPLXW7.mjs → chunk-MYIZXDZA.mjs} +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkPTZ2TVNEcjs = require('./chunk-PTZ2TVNE.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
12
|
+
|
|
13
|
+
// src/agent-mcp-handler.ts
|
|
14
|
+
var INSTRUCTIONS = "This server reads the site's public pages. Call list_pages or search_pages to find a page, then read_page with its path to get the page as Markdown. It cannot change anything.";
|
|
15
|
+
var MAX_BODY_BYTES = 64 * 1024;
|
|
16
|
+
var MAX_BATCH = 16;
|
|
17
|
+
var READ_TIMEOUT_MS = 3e4;
|
|
18
|
+
var _FarmMCPRequestError = class _FarmMCPRequestError extends Error {
|
|
19
|
+
constructor(code, message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _FarmMCPRequestError, "FarmMCPRequestError");
|
|
25
|
+
var FarmMCPRequestError = _FarmMCPRequestError;
|
|
26
|
+
var PARSE_ERROR = -32700;
|
|
27
|
+
var INVALID_REQUEST = -32600;
|
|
28
|
+
var METHOD_NOT_FOUND = -32601;
|
|
29
|
+
var INVALID_PARAMS = -32602;
|
|
30
|
+
var INTERNAL_ERROR = -32603;
|
|
31
|
+
var TRANSPORT_ERROR = -32e3;
|
|
32
|
+
async function handleFarmDefaultMCPRequest(request, context) {
|
|
33
|
+
const method = request.method.toUpperCase();
|
|
34
|
+
if (method !== "POST") {
|
|
35
|
+
return transportError(405, "Method not allowed. Send MCP requests with POST.", {
|
|
36
|
+
Allow: "POST"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const origin = request.headers.get("origin");
|
|
40
|
+
if (origin && !isSameOrigin(origin, request.url)) {
|
|
41
|
+
return transportError(403, "Cross-origin requests are not allowed.");
|
|
42
|
+
}
|
|
43
|
+
const protocolHeader = request.headers.get("mcp-protocol-version");
|
|
44
|
+
if (protocolHeader && !_chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.includes(protocolHeader.trim())) {
|
|
45
|
+
return transportError(
|
|
46
|
+
400,
|
|
47
|
+
`Unsupported MCP-Protocol-Version: ${protocolHeader.slice(0, 32)}. Supported: ${_chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.join(", ")}.`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const contentType = _nullishCoalesce(request.headers.get("content-type"), () => ( ""));
|
|
51
|
+
if (!/^application\/json\s*(?:;|$)/i.test(contentType.trim())) {
|
|
52
|
+
return transportError(415, "Content-Type must be application/json.");
|
|
53
|
+
}
|
|
54
|
+
const text = await readBody(request);
|
|
55
|
+
if (text === null) return transportError(413, "The request body is too large.");
|
|
56
|
+
let message;
|
|
57
|
+
try {
|
|
58
|
+
message = JSON.parse(text);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return json(400, rpcError(null, { code: PARSE_ERROR, message: "Parse error." }));
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(message)) {
|
|
63
|
+
if (message.length === 0 || message.length > MAX_BATCH) {
|
|
64
|
+
return json(
|
|
65
|
+
400,
|
|
66
|
+
rpcError(null, { code: INVALID_REQUEST, message: "Invalid batch of JSON-RPC messages." })
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const replies = (await Promise.all(message.map((item) => answerMessage(item, request, context)))).filter((reply2) => reply2 !== void 0);
|
|
70
|
+
return replies.length ? json(200, replies) : new Response(null, { status: 202 });
|
|
71
|
+
}
|
|
72
|
+
const reply = await answerMessage(message, request, context);
|
|
73
|
+
return reply === void 0 ? new Response(null, { status: 202 }) : json(200, reply);
|
|
74
|
+
}
|
|
75
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, handleFarmDefaultMCPRequest, "handleFarmDefaultMCPRequest");
|
|
76
|
+
async function answerMessage(message, request, context) {
|
|
77
|
+
if (!isRecord(message) || message.jsonrpc !== "2.0") {
|
|
78
|
+
return rpcError(readId(message), { code: INVALID_REQUEST, message: "Invalid Request." });
|
|
79
|
+
}
|
|
80
|
+
const hasId = "id" in message;
|
|
81
|
+
if (typeof message.method !== "string") {
|
|
82
|
+
if (hasId && ("result" in message || "error" in message)) return void 0;
|
|
83
|
+
return rpcError(readId(message), { code: INVALID_REQUEST, message: "Invalid Request." });
|
|
84
|
+
}
|
|
85
|
+
if (!hasId) return void 0;
|
|
86
|
+
const id = readId(message);
|
|
87
|
+
if (id === void 0) {
|
|
88
|
+
return rpcError(null, { code: INVALID_REQUEST, message: "Invalid Request id." });
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const result = await dispatch(message.method, message.params, request, context);
|
|
92
|
+
return { jsonrpc: "2.0", id, result };
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (error instanceof FarmMCPRequestError) {
|
|
95
|
+
return rpcError(id, { code: error.code, message: error.message });
|
|
96
|
+
}
|
|
97
|
+
return rpcError(id, { code: INTERNAL_ERROR, message: "Internal error." });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, answerMessage, "answerMessage");
|
|
101
|
+
async function dispatch(method, params, request, context) {
|
|
102
|
+
switch (method) {
|
|
103
|
+
case "initialize": {
|
|
104
|
+
const requested = isRecord(params) ? params.protocolVersion : void 0;
|
|
105
|
+
const protocolVersion = typeof requested === "string" && _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS.includes(requested) ? requested : _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PROTOCOL_VERSIONS[0];
|
|
106
|
+
return {
|
|
107
|
+
protocolVersion,
|
|
108
|
+
capabilities: { tools: { listChanged: false } },
|
|
109
|
+
serverInfo: {
|
|
110
|
+
name: context.server.name,
|
|
111
|
+
version: context.server.version,
|
|
112
|
+
...context.server.title ? { title: context.server.title } : {},
|
|
113
|
+
description: _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_DESCRIPTION
|
|
114
|
+
},
|
|
115
|
+
instructions: INSTRUCTIONS
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
case "ping":
|
|
119
|
+
return {};
|
|
120
|
+
case "tools/list":
|
|
121
|
+
return { tools: _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_TOOLS };
|
|
122
|
+
case "tools/call":
|
|
123
|
+
return callTool(params, request, context);
|
|
124
|
+
default:
|
|
125
|
+
throw new FarmMCPRequestError(METHOD_NOT_FOUND, `Method not found: ${method.slice(0, 64)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, dispatch, "dispatch");
|
|
129
|
+
async function callTool(params, request, context) {
|
|
130
|
+
if (!isRecord(params) || typeof params.name !== "string") {
|
|
131
|
+
throw new FarmMCPRequestError(INVALID_PARAMS, "tools/call needs a tool name.");
|
|
132
|
+
}
|
|
133
|
+
const tool = _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_TOOLS.find(({ name }) => name === params.name);
|
|
134
|
+
if (!tool) {
|
|
135
|
+
throw new FarmMCPRequestError(INVALID_PARAMS, `Unknown tool: ${params.name.slice(0, 64)}`);
|
|
136
|
+
}
|
|
137
|
+
const args = _nullishCoalesce(params.arguments, () => ( {}));
|
|
138
|
+
if (!isRecord(args)) return toolError("Arguments must be an object.");
|
|
139
|
+
const allowed = new Set(Object.keys(tool.inputSchema.properties));
|
|
140
|
+
const unknown = Object.keys(args).find((key) => !allowed.has(key));
|
|
141
|
+
if (unknown) return toolError(`Unknown argument: ${unknown.slice(0, 64)}.`);
|
|
142
|
+
if (tool.name === "list_pages") return pagesResult(await context.listPages());
|
|
143
|
+
if (tool.name === "search_pages") {
|
|
144
|
+
const query = args.query;
|
|
145
|
+
if (typeof query !== "string" || !query.trim() || query.length > 200) {
|
|
146
|
+
return toolError("query must be a non-empty string of at most 200 characters.");
|
|
147
|
+
}
|
|
148
|
+
const limit = _nullishCoalesce(args.limit, () => ( 10));
|
|
149
|
+
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1 || limit > 50) {
|
|
150
|
+
return toolError("limit must be a whole number from 1 to 50.");
|
|
151
|
+
}
|
|
152
|
+
return pagesResult(searchPages(await context.listPages(), query, limit));
|
|
153
|
+
}
|
|
154
|
+
const path = args.path;
|
|
155
|
+
if (typeof path !== "string" || !path.trim() || path.length > 2048) {
|
|
156
|
+
return toolError('path must be a page path such as "/about".');
|
|
157
|
+
}
|
|
158
|
+
const pagePath = toPagePath(path, request.url, context.basePath);
|
|
159
|
+
const pages = await context.listPages();
|
|
160
|
+
const page = pagePath ? pages.find((candidate) => candidate.path === pagePath) : void 0;
|
|
161
|
+
if (!page) {
|
|
162
|
+
return toolError(
|
|
163
|
+
`No public page at ${JSON.stringify(path.slice(0, 200))}. Call list_pages for the pages this server can read.`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
const markdown = await readWithTimeout(context.readMarkdown, page.markdownUrl);
|
|
167
|
+
if (markdown === null) {
|
|
168
|
+
return toolError(`${page.path} did not answer with Markdown. Try again later.`);
|
|
169
|
+
}
|
|
170
|
+
return { content: [{ type: "text", text: markdown }] };
|
|
171
|
+
}
|
|
172
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, callTool, "callTool");
|
|
173
|
+
function pagesResult(pages) {
|
|
174
|
+
const structured = {
|
|
175
|
+
pages: pages.map(({ path, title, url, description }) => ({
|
|
176
|
+
path,
|
|
177
|
+
title,
|
|
178
|
+
url,
|
|
179
|
+
...description ? { description } : {}
|
|
180
|
+
}))
|
|
181
|
+
};
|
|
182
|
+
return {
|
|
183
|
+
content: [{ type: "text", text: JSON.stringify(structured) }],
|
|
184
|
+
structuredContent: structured
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, pagesResult, "pagesResult");
|
|
188
|
+
function toolError(text) {
|
|
189
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
190
|
+
}
|
|
191
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, toolError, "toolError");
|
|
192
|
+
function searchPages(pages, query, limit) {
|
|
193
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean).slice(0, 16);
|
|
194
|
+
return pages.map((page) => {
|
|
195
|
+
const title = page.title.toLowerCase();
|
|
196
|
+
const rest = `${_nullishCoalesce(page.description, () => ( ""))} ${page.path}`.toLowerCase();
|
|
197
|
+
let score = 0;
|
|
198
|
+
for (const term of terms) {
|
|
199
|
+
if (title.includes(term)) score += 2;
|
|
200
|
+
else if (rest.includes(term)) score += 1;
|
|
201
|
+
else return null;
|
|
202
|
+
}
|
|
203
|
+
return { page, score };
|
|
204
|
+
}).filter((match) => match !== null).sort(
|
|
205
|
+
(left, right) => right.score - left.score || left.page.path.localeCompare(right.page.path)
|
|
206
|
+
).slice(0, limit).map(({ page }) => page);
|
|
207
|
+
}
|
|
208
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, searchPages, "searchPages");
|
|
209
|
+
function toPagePath(input, requestUrl, basePath) {
|
|
210
|
+
let url;
|
|
211
|
+
try {
|
|
212
|
+
url = new URL(input.trim(), requestUrl);
|
|
213
|
+
} catch (e2) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
if (url.origin !== new URL(requestUrl).origin) return null;
|
|
217
|
+
let path = url.pathname;
|
|
218
|
+
try {
|
|
219
|
+
path = decodeURI(path);
|
|
220
|
+
} catch (e3) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
path = _chunkI57LW5VZcjs.stripFarmBasePath.call(void 0, path, basePath);
|
|
224
|
+
if (path === "/index.md") return "/";
|
|
225
|
+
if (path.toLowerCase().endsWith(".md")) path = path.slice(0, -3) || "/";
|
|
226
|
+
return path.length > 1 ? path.replace(/\/+$/, "") || "/" : path;
|
|
227
|
+
}
|
|
228
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, toPagePath, "toPagePath");
|
|
229
|
+
async function readWithTimeout(read, url) {
|
|
230
|
+
let timer;
|
|
231
|
+
const timedOut = new Promise((resolve) => {
|
|
232
|
+
timer = setTimeout(resolve, READ_TIMEOUT_MS, null);
|
|
233
|
+
});
|
|
234
|
+
try {
|
|
235
|
+
return await Promise.race([read(url), timedOut]);
|
|
236
|
+
} finally {
|
|
237
|
+
clearTimeout(timer);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readWithTimeout, "readWithTimeout");
|
|
241
|
+
async function readBody(request) {
|
|
242
|
+
const declared = Number(request.headers.get("content-length"));
|
|
243
|
+
if (Number.isFinite(declared) && declared > MAX_BODY_BYTES) {
|
|
244
|
+
await _optionalChain([request, 'access', _ => _.body, 'optionalAccess', _2 => _2.cancel, 'call', _3 => _3(), 'access', _4 => _4.catch, 'call', _5 => _5(() => {
|
|
245
|
+
})]);
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
if (!request.body) return "";
|
|
249
|
+
const reader = request.body.getReader();
|
|
250
|
+
const chunks = [];
|
|
251
|
+
let size = 0;
|
|
252
|
+
for (; ; ) {
|
|
253
|
+
const { done, value } = await reader.read();
|
|
254
|
+
if (done) break;
|
|
255
|
+
size += value.byteLength;
|
|
256
|
+
if (size > MAX_BODY_BYTES) {
|
|
257
|
+
await reader.cancel().catch(() => {
|
|
258
|
+
});
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
chunks.push(value);
|
|
262
|
+
}
|
|
263
|
+
const body = new Uint8Array(size);
|
|
264
|
+
let offset = 0;
|
|
265
|
+
for (const chunk of chunks) {
|
|
266
|
+
body.set(chunk, offset);
|
|
267
|
+
offset += chunk.byteLength;
|
|
268
|
+
}
|
|
269
|
+
return new TextDecoder().decode(body);
|
|
270
|
+
}
|
|
271
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readBody, "readBody");
|
|
272
|
+
function isSameOrigin(origin, requestUrl) {
|
|
273
|
+
try {
|
|
274
|
+
return new URL(origin).host === new URL(requestUrl).host;
|
|
275
|
+
} catch (e4) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isSameOrigin, "isSameOrigin");
|
|
280
|
+
function readId(message) {
|
|
281
|
+
if (!isRecord(message)) return null;
|
|
282
|
+
const { id } = message;
|
|
283
|
+
return typeof id === "string" || typeof id === "number" && Number.isFinite(id) || id === null ? id : void 0;
|
|
284
|
+
}
|
|
285
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readId, "readId");
|
|
286
|
+
function rpcError(id, error) {
|
|
287
|
+
return { jsonrpc: "2.0", id: _nullishCoalesce(id, () => ( null)), error };
|
|
288
|
+
}
|
|
289
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, rpcError, "rpcError");
|
|
290
|
+
function json(status, body) {
|
|
291
|
+
return new Response(JSON.stringify(body), {
|
|
292
|
+
status,
|
|
293
|
+
headers: {
|
|
294
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
295
|
+
"Cache-Control": "no-store",
|
|
296
|
+
"X-Content-Type-Options": "nosniff"
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, json, "json");
|
|
301
|
+
function transportError(status, message, headers = {}) {
|
|
302
|
+
const response = json(status, rpcError(null, { code: TRANSPORT_ERROR, message }));
|
|
303
|
+
for (const [name, value] of Object.entries(headers)) response.headers.set(name, value);
|
|
304
|
+
return response;
|
|
305
|
+
}
|
|
306
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, transportError, "transportError");
|
|
307
|
+
function isRecord(value) {
|
|
308
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
309
|
+
}
|
|
310
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isRecord, "isRecord");
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
exports.handleFarmDefaultMCPRequest = handleFarmDefaultMCPRequest;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
APITypeGenerator
|
|
3
|
+
} from "./chunk-F3VB7ONA.mjs";
|
|
1
4
|
import {
|
|
2
5
|
readSchemaTables
|
|
3
6
|
} from "./chunk-HALDNTIV.mjs";
|
|
4
7
|
import {
|
|
5
8
|
resolveSchemaModels
|
|
6
9
|
} from "./chunk-ZMSZZXOR.mjs";
|
|
7
|
-
import {
|
|
8
|
-
APITypeGenerator
|
|
9
|
-
} from "./chunk-F3VB7ONA.mjs";
|
|
10
10
|
import {
|
|
11
11
|
mergeRouteRenderingDirectiveConfig
|
|
12
12
|
} from "./chunk-DAO7JGTS.mjs";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
getFarmAppDirectories,
|
|
22
22
|
getFarmSourceRoots
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-BUGNQIHC.mjs";
|
|
24
24
|
import {
|
|
25
25
|
resolveFarmComponentExtensions
|
|
26
26
|
} from "./chunk-DAATZTKJ.mjs";
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
} from "./chunk-RHAZ22ZN.mjs";
|
|
30
30
|
import {
|
|
31
31
|
discoverProgrammaticRoutePaths
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-MYIZXDZA.mjs";
|
|
33
33
|
import {
|
|
34
34
|
readFarmI18nCatalogs
|
|
35
35
|
} from "./chunk-QCFBDFRS.mjs";
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk6LGFV2CQcjs = require('./chunk-6LGFV2CQ.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkSK35NQKKcjs = require('./chunk-SK35NQKK.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkT5OJPTVNcjs = require('./chunk-T5OJPTVN.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ function createServerQuery(options) {
|
|
|
35
35
|
throw new TypeError("createServerQuery requires a key function");
|
|
36
36
|
}
|
|
37
37
|
const staleTime = normalizeServerQueryStaleTime(options.staleTime);
|
|
38
|
-
const execute =
|
|
38
|
+
const execute = _chunk6LGFV2CQcjs.createServerFn.call(void 0, {
|
|
39
39
|
input: options.input,
|
|
40
40
|
middleware: options.middleware,
|
|
41
41
|
handler: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (context) => {
|
|
@@ -45,7 +45,7 @@ function createServerQuery(options) {
|
|
|
45
45
|
const cacheKey = _chunkNYJMY3JAcjs.createFarmCacheKey.call(void 0, ["route-data", routeKey]);
|
|
46
46
|
const producer = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
|
|
47
47
|
const value = await options.handler(context);
|
|
48
|
-
return
|
|
48
|
+
return _chunk6LGFV2CQcjs._parseServerFnSchema.call(void 0, options.output, value, "output", "createServerQuery");
|
|
49
49
|
}, "producer");
|
|
50
50
|
let data;
|
|
51
51
|
let updatedAt;
|
|
@@ -70,7 +70,7 @@ function createServerQuery(options) {
|
|
|
70
70
|
});
|
|
71
71
|
const query = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (input) => {
|
|
72
72
|
const result = await execute(input);
|
|
73
|
-
return
|
|
73
|
+
return _chunkT5OJPTVNcjs.getServerActionExecutionContext.call(void 0, ) ? result : result.data;
|
|
74
74
|
}, "query");
|
|
75
75
|
Object.defineProperties(query, {
|
|
76
76
|
[FARM_SERVER_QUERY_SYMBOL]: {
|
|
@@ -90,10 +90,10 @@ function createServerQuery(options) {
|
|
|
90
90
|
enumerable: false
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
-
|
|
93
|
+
_chunk6LGFV2CQcjs._attachServerFunctionDescriptor.call(void 0,
|
|
94
94
|
query,
|
|
95
|
-
|
|
96
|
-
const result = await
|
|
95
|
+
_chunk6LGFV2CQcjs.createServerFunctionDescriptor.call(void 0, "query", options, async (value) => {
|
|
96
|
+
const result = await _chunk6LGFV2CQcjs._runServerFunctionForCaller.call(void 0,
|
|
97
97
|
execute,
|
|
98
98
|
value
|
|
99
99
|
);
|
|
@@ -6,7 +6,7 @@ var _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
|
|
|
6
6
|
var _chunkE3UK5IIBcjs = require('./chunk-E3UK5IIB.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkNICDYKBScjs = require('./chunk-NICDYKBS.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
@@ -299,7 +299,7 @@ function farmInfraAnalyticsPlugin(options, send) {
|
|
|
299
299
|
context.state.unsubscribe = _chunkE3UK5IIBcjs.onFarmEvent.call(void 0,
|
|
300
300
|
(event) => {
|
|
301
301
|
if (!isToolEvent(event)) return;
|
|
302
|
-
const request =
|
|
302
|
+
const request = _chunkNICDYKBScjs.getCurrentRequestOrNull.call(void 0, );
|
|
303
303
|
if (!request) return;
|
|
304
304
|
const metadata = context.requestContext.get(request, contextKey);
|
|
305
305
|
if (!metadata) return;
|
|
@@ -569,6 +569,10 @@ async function resolveProgrammaticRouteData(route, dataHooks, context) {
|
|
|
569
569
|
if (routeDataKey == null) {
|
|
570
570
|
return dataHooks.main(context);
|
|
571
571
|
}
|
|
572
|
+
const revalidate = normalizeProgrammaticRouteStaleTime(dataHooks.staleTime, route.path);
|
|
573
|
+
if (revalidate === 0) {
|
|
574
|
+
return dataHooks.main(context);
|
|
575
|
+
}
|
|
572
576
|
const cacheKey = createFarmCacheKey(["route-data", routeDataKey]);
|
|
573
577
|
const cacheOptions = {
|
|
574
578
|
tags: [
|
|
@@ -579,7 +583,7 @@ async function resolveProgrammaticRouteData(route, dataHooks, context) {
|
|
|
579
583
|
...typeof context.path === "string" ? [context.path] : [],
|
|
580
584
|
...await resolveProgrammaticRouteDataKeys(dataHooks.paths, context)
|
|
581
585
|
],
|
|
582
|
-
revalidate
|
|
586
|
+
revalidate
|
|
583
587
|
};
|
|
584
588
|
return getFarmDataCache().getOrSet(cacheKey, () => dataHooks.main(context), cacheOptions);
|
|
585
589
|
}
|
|
@@ -590,20 +594,26 @@ async function resolveProgrammaticRouteDataKeys(input, context) {
|
|
|
590
594
|
return value.filter((item) => typeof item === "string" && item.trim().length > 0);
|
|
591
595
|
}
|
|
592
596
|
__name(resolveProgrammaticRouteDataKeys, "resolveProgrammaticRouteDataKeys");
|
|
593
|
-
function normalizeProgrammaticRouteStaleTime(staleTime) {
|
|
597
|
+
function normalizeProgrammaticRouteStaleTime(staleTime, routePath) {
|
|
594
598
|
if (staleTime === void 0) return void 0;
|
|
595
599
|
if (staleTime === false) return false;
|
|
600
|
+
let milliseconds;
|
|
596
601
|
if (typeof staleTime === "number") {
|
|
597
|
-
|
|
598
|
-
|
|
602
|
+
milliseconds = staleTime;
|
|
603
|
+
} else {
|
|
604
|
+
const match = typeof staleTime === "string" && staleTime.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)$/);
|
|
605
|
+
if (!match) {
|
|
606
|
+
throw new TypeError(
|
|
607
|
+
`Route "${routePath}" data.staleTime must be milliseconds or a duration like "250ms", "30s", "5m", or "1h".`
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
const unit = match[2];
|
|
611
|
+
milliseconds = Number(match[1]) * (unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : 36e5);
|
|
612
|
+
}
|
|
613
|
+
if (!Number.isFinite(milliseconds) || milliseconds < 0) {
|
|
614
|
+
throw new TypeError(`Route "${routePath}" data.staleTime must be a non-negative duration.`);
|
|
599
615
|
}
|
|
600
|
-
|
|
601
|
-
if (!match) return void 0;
|
|
602
|
-
const value = Number(match[1]);
|
|
603
|
-
if (!Number.isFinite(value) || value <= 0) return void 0;
|
|
604
|
-
const unit = match[2];
|
|
605
|
-
const milliseconds = unit === "ms" ? value : unit === "s" ? value * 1e3 : unit === "m" ? value * 6e4 : value * 36e5;
|
|
606
|
-
return Math.max(1, Math.ceil(milliseconds / 1e3));
|
|
616
|
+
return milliseconds === 0 ? 0 : Math.max(1, Math.ceil(milliseconds / 1e3));
|
|
607
617
|
}
|
|
608
618
|
__name(normalizeProgrammaticRouteStaleTime, "normalizeProgrammaticRouteStaleTime");
|
|
609
619
|
function isProgrammaticRoutePropsResolved(value) {
|
|
@@ -662,6 +672,7 @@ function normalizeProgrammaticRoute(route) {
|
|
|
662
672
|
};
|
|
663
673
|
}
|
|
664
674
|
const routeActions = route.kind === "page" ? normalizeProgrammaticRouteActions(route) : void 0;
|
|
675
|
+
normalizeProgrammaticRouteStaleTime(route.data?.staleTime, route.path);
|
|
665
676
|
return {
|
|
666
677
|
...route,
|
|
667
678
|
...routeActions,
|