@farm.js/core 0.1.25 → 0.1.26
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-runtime.d.mts +2 -2
- package/dist/agent-runtime.d.ts +2 -2
- package/dist/api/route-manager.d.mts +2 -2
- package/dist/api/route-manager.d.ts +2 -2
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/{app-ZuWrAMc_.d.mts → app-29vG5tmY.d.mts} +3 -3
- package/dist/{app-BF-ctoxh.d.ts → app-Cx71s_PT.d.ts} +3 -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-E3RDL2DA.cjs → chunk-2CT6XUNO.cjs} +61 -31
- package/dist/{chunk-R7LCG3BT.cjs → chunk-3TQG7CGC.cjs} +84 -77
- package/dist/{chunk-AXYTGLF3.cjs → chunk-3WSWXPYM.cjs} +4 -4
- package/dist/{chunk-2BIJGZR3.mjs → chunk-74RZNRY6.mjs} +1 -1
- package/dist/{chunk-TTVHACQV.cjs → chunk-ALIFMS4A.cjs} +1 -1
- package/dist/{chunk-T2OPSH6S.mjs → chunk-ARXCHQLX.mjs} +9 -2
- package/dist/{chunk-2KI3CL3N.mjs → chunk-DU2CASV6.mjs} +1 -1
- package/dist/chunk-J63ZH5OQ.cjs +62 -0
- package/dist/{chunk-XM4ZDVD7.mjs → chunk-JM5GQL4H.mjs} +1 -1
- package/dist/{chunk-6VEHUKZ2.mjs → chunk-MM5D6VLP.mjs} +4 -20
- package/dist/chunk-MVL2RAJW.mjs +62 -0
- package/dist/{chunk-YA6LLTIJ.cjs → chunk-ND224OE2.cjs} +4 -20
- package/dist/{chunk-XME4TCLB.mjs → chunk-OFKG57MZ.mjs} +2 -2
- package/dist/{chunk-U4MP7XTD.mjs → chunk-OOIL3BWR.mjs} +168 -16
- package/dist/{chunk-WOI2HOGA.mjs → chunk-PPIW3MH6.mjs} +1 -1
- package/dist/{chunk-2ITKVAIF.cjs → chunk-QIH2HD6H.cjs} +191 -39
- package/dist/{chunk-65P6OGYN.cjs → chunk-QJ4D3UKJ.cjs} +10 -3
- package/dist/{chunk-RYDW7GPR.cjs → chunk-QLXEYIAW.cjs} +13 -13
- package/dist/{chunk-WJYCI56T.mjs → chunk-QPPQHB6X.mjs} +43 -30
- package/dist/{chunk-RR6UGYUT.mjs → chunk-RAI7NULA.mjs} +39 -9
- package/dist/{chunk-6K4SPQWL.cjs → chunk-RCYINC4A.cjs} +3 -3
- package/dist/{chunk-QYMRIVG6.cjs → chunk-SZ4LYNUX.cjs} +110 -97
- package/dist/{chunk-N2Z4ZFDE.mjs → chunk-UXQXGB5A.mjs} +19 -12
- package/dist/{chunk-CFNOGDUS.cjs → chunk-W2HZKYES.cjs} +2 -2
- package/dist/{chunk-O5DVPF3R.cjs → chunk-WFPRVVF2.cjs} +10 -10
- package/dist/{chunk-5YYJ6Q2L.mjs → chunk-YMUH2BLR.mjs} +2 -2
- package/dist/{client-plugins-DPG0NeZN.d.mts → client-plugins-B8RPJnot.d.mts} +90 -3
- package/dist/{client-plugins-Fgni-_25.d.ts → client-plugins-bPBf4haK.d.ts} +90 -3
- package/dist/client-plugins.d.mts +2 -2
- package/dist/client-plugins.d.ts +2 -2
- package/dist/client.d.mts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/config.d.mts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/{devtools-I7TBFOKD.mjs → devtools-5D4ZDRPR.mjs} +5 -3
- package/dist/{devtools-6OA7FEF6.cjs → devtools-QZJEUOJW.cjs} +6 -4
- package/dist/docs.cjs +8 -6
- package/dist/docs.mjs +7 -5
- package/dist/index.cjs +17 -13
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +16 -12
- package/dist/integrations.d.mts +2 -2
- package/dist/integrations.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.cjs +5 -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 +4 -2
- package/dist/internal/build-runtime.cjs +14 -13
- package/dist/internal/build-runtime.d.mts +4 -4
- package/dist/internal/build-runtime.d.ts +4 -4
- package/dist/internal/build-runtime.mjs +13 -12
- package/dist/internal/cli-runtime.cjs +6 -5
- package/dist/internal/cli-runtime.mjs +5 -4
- 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 +2 -2
- package/dist/internal/compression-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.cjs +6 -4
- package/dist/internal/config-runtime.d.mts +3 -3
- package/dist/internal/config-runtime.d.ts +3 -3
- package/dist/internal/config-runtime.mjs +5 -3
- package/dist/internal/infra-analytics-runtime.cjs +4 -3
- package/dist/internal/infra-analytics-runtime.mjs +2 -1
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +5 -4
- package/dist/internal/production-runtime.d.mts +11 -9
- package/dist/internal/production-runtime.d.ts +11 -9
- package/dist/internal/production-runtime.mjs +4 -3
- package/dist/markdown.cjs +4 -2
- package/dist/markdown.mjs +3 -1
- package/dist/{metadata-D0EF7esB.d.mts → metadata-C3na4CBj.d.mts} +1 -1
- package/dist/{metadata-CDnRHKVq.d.ts → metadata-CzBP4Mfp.d.ts} +1 -1
- package/dist/middleware.d.mts +4 -4
- package/dist/middleware.d.ts +4 -4
- package/dist/navigation.d.mts +5 -5
- package/dist/navigation.d.ts +5 -5
- package/dist/observability-BupkiN0m.d.mts +447 -0
- package/dist/observability-BupkiN0m.d.ts +447 -0
- package/dist/observability.d.mts +2 -417
- package/dist/observability.d.ts +2 -417
- package/dist/plugin.cjs +9 -8
- package/dist/plugin.d.mts +2 -2
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.mjs +8 -7
- package/dist/{production-runtime-DpCt0opU.d.ts → production-runtime-CYg4wM4E.d.ts} +1 -1
- package/dist/{production-runtime-x3W4wVqx.d.mts → production-runtime-DP94hPGe.d.mts} +1 -1
- package/dist/{render-plan-D5oFRVBV.d.ts → render-plan-Bl6Fzg5z.d.ts} +1 -1
- package/dist/{render-plan-tazUJalK.d.mts → render-plan-CKAJg0jC.d.mts} +1 -1
- package/dist/renderer-client.d.mts +4 -4
- package/dist/renderer-client.d.ts +4 -4
- package/dist/{request-CzZX0Aew.d.ts → request-CR-Bp1Px.d.ts} +1 -1
- package/dist/{request-CXmQy5ks.d.mts → request-CrBCcPZZ.d.mts} +1 -1
- package/dist/request.d.mts +3 -3
- package/dist/request.d.ts +3 -3
- package/dist/{route-rendering-B-qpe32B.d.mts → route-rendering-C1NAHo-C.d.mts} +1 -1
- package/dist/{route-rendering-Dw3C362T.d.ts → route-rendering-CZH5FegB.d.ts} +1 -1
- package/dist/{router-CafM2jlw.d.mts → router-B57eDJ3u.d.mts} +1 -1
- package/dist/{router-CLl3xHwl.d.ts → router-Cg_kD3Bd.d.ts} +1 -1
- package/dist/routes.d.mts +2 -2
- package/dist/routes.d.ts +2 -2
- package/dist/server-plugins.d.mts +3 -3
- package/dist/server-plugins.d.ts +3 -3
- package/dist/server.cjs +159 -102
- package/dist/server.d.mts +8 -8
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +140 -83
- package/dist/{spa-router-DePr2aZ6.d.ts → spa-router-BstQUO6Q.d.ts} +2 -2
- package/dist/{spa-router-6sJfsMlQ.d.mts → spa-router-DTdbuinx.d.mts} +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/{utils-BPHr-1mP.d.mts → utils-CS3ZLnEJ.d.mts} +1 -1
- package/dist/{utils-BBKC3cf3.d.ts → utils-D3rdsIvM.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +9 -8
- package/dist/vite.d.mts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.mjs +8 -7
- package/package.json +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
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
2
|
|
|
3
|
+
var _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
4
7
|
|
|
5
8
|
// src/markdown-view.ts
|
|
@@ -39,10 +42,12 @@ function parseFarmMarkdownHeadings(markdown) {
|
|
|
39
42
|
end: lines.length
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const open = [];
|
|
46
|
+
for (const heading of headings) {
|
|
47
|
+
while (open.length > 0 && open[open.length - 1].level >= heading.level) {
|
|
48
|
+
open.pop().end = heading.start;
|
|
49
|
+
}
|
|
50
|
+
open.push(heading);
|
|
46
51
|
}
|
|
47
52
|
return headings;
|
|
48
53
|
}
|
|
@@ -55,23 +60,49 @@ function estimateFarmMarkdownTokens(text) {
|
|
|
55
60
|
return Math.ceil(text.length / 4);
|
|
56
61
|
}
|
|
57
62
|
_chunkS3JO3N4Hcjs.__name.call(void 0, estimateFarmMarkdownTokens, "estimateFarmMarkdownTokens");
|
|
63
|
+
var FARM_MARKDOWN_MIN_TOKEN_BUDGET = 100;
|
|
64
|
+
var FARM_MARKDOWN_VIEW_PARAMS = [
|
|
65
|
+
"outline",
|
|
66
|
+
"section",
|
|
67
|
+
"actions",
|
|
68
|
+
"max_tokens",
|
|
69
|
+
"cursor"
|
|
70
|
+
];
|
|
58
71
|
function selectFarmMarkdownView(markdown, searchParams, markdownPath) {
|
|
59
72
|
const wantsOutline = searchParams.has("outline");
|
|
60
73
|
const sectionId = searchParams.get("section");
|
|
61
|
-
|
|
74
|
+
const budget = searchParams.get("max_tokens");
|
|
75
|
+
if (!wantsOutline && sectionId === null && budget === null)
|
|
76
|
+
return { status: 200, body: markdown };
|
|
77
|
+
const viewUrl = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (view) => {
|
|
78
|
+
const query = new URLSearchParams(searchParams);
|
|
79
|
+
for (const name of FARM_MARKDOWN_VIEW_PARAMS) query.delete(name);
|
|
80
|
+
for (const [name, value] of Object.entries(view)) {
|
|
81
|
+
if (value !== null && value !== void 0) query.set(name, value);
|
|
82
|
+
}
|
|
83
|
+
const search = query.toString();
|
|
84
|
+
return search ? `${markdownPath}?${search}` : markdownPath;
|
|
85
|
+
}, "viewUrl");
|
|
86
|
+
const withinBudget = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (document) => budget === null ? { status: 200, body: document } : selectFarmMarkdownPart(
|
|
87
|
+
document,
|
|
88
|
+
budget,
|
|
89
|
+
searchParams.get("cursor"),
|
|
90
|
+
(cursor) => viewUrl({ section: sectionId, max_tokens: budget, cursor })
|
|
91
|
+
), "withinBudget");
|
|
92
|
+
if (!wantsOutline && sectionId === null) return withinBudget(markdown);
|
|
62
93
|
const lines = markdown.split("\n");
|
|
63
94
|
const headings = parseFarmMarkdownHeadings(markdown);
|
|
64
95
|
const sectionText = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (heading) => lines.slice(heading.start, heading.end).join("\n").trim(), "sectionText");
|
|
65
96
|
if (sectionId !== null) {
|
|
66
97
|
const heading = headings.find((candidate) => candidate.id === sectionId);
|
|
67
|
-
if (heading) return
|
|
68
|
-
`
|
|
98
|
+
if (heading) return withinBudget(`${sectionText(heading)}
|
|
99
|
+
`);
|
|
69
100
|
const available = headings.map((candidate) => `- \`${candidate.id}\``).join("\n");
|
|
70
101
|
return {
|
|
71
102
|
status: 404,
|
|
72
103
|
body: `# Section not found
|
|
73
104
|
|
|
74
|
-
|
|
105
|
+
${markdownCodeSpan(sectionId)} is not a section of ${markdownPath}.
|
|
75
106
|
|
|
76
107
|
` + (available ? `Available sections:
|
|
77
108
|
|
|
@@ -79,23 +110,31 @@ ${available}
|
|
|
79
110
|
` : "This page has no sections.\n")
|
|
80
111
|
};
|
|
81
112
|
}
|
|
82
|
-
const minLevel =
|
|
113
|
+
const minLevel = headings.reduce((min, heading) => Math.min(min, heading.level), 6);
|
|
83
114
|
const entries = headings.map((heading) => {
|
|
84
115
|
const indent = " ".repeat(heading.level - minLevel);
|
|
85
116
|
const tokens = estimateFarmMarkdownTokens(sectionText(heading));
|
|
86
|
-
return `${indent}- [${heading.text}](${
|
|
117
|
+
return `${indent}- [${heading.text}](${viewUrl({ section: heading.id })}) ~${tokens} tokens`;
|
|
87
118
|
});
|
|
88
119
|
return {
|
|
89
120
|
status: 200,
|
|
90
121
|
body: `# Outline of ${markdownPath}
|
|
91
122
|
|
|
92
|
-
About ${estimateFarmMarkdownTokens(markdown)} tokens in total. Request one section with \`?section=<id>\`.
|
|
123
|
+
About ${estimateFarmMarkdownTokens(markdown)} tokens in total. Request one section with \`?section=<id>\`, or read in parts with \`?max_tokens=<n>\`.
|
|
93
124
|
|
|
94
125
|
` + (entries.length > 0 ? `${entries.join("\n")}
|
|
95
126
|
` : "This page has no headings.\n")
|
|
96
127
|
};
|
|
97
128
|
}
|
|
98
129
|
_chunkS3JO3N4Hcjs.__name.call(void 0, selectFarmMarkdownView, "selectFarmMarkdownView");
|
|
130
|
+
function markdownCodeSpan(value) {
|
|
131
|
+
const text = value.replace(/[\p{Cc}\u2028\u2029]+/gu, " ");
|
|
132
|
+
const longestRun = (_nullishCoalesce(text.match(/`+/g), () => ( []))).reduce((max, run) => Math.max(max, run.length), 0);
|
|
133
|
+
const fence = "`".repeat(longestRun + 1);
|
|
134
|
+
const pad = text.startsWith("`") || text.endsWith("`") ? " " : "";
|
|
135
|
+
return `${fence}${pad}${text}${pad}${fence}`;
|
|
136
|
+
}
|
|
137
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, markdownCodeSpan, "markdownCodeSpan");
|
|
99
138
|
function selectFarmPageActionsView(markdownPath, actions, headers) {
|
|
100
139
|
headers.set("Content-Type", "application/json; charset=utf-8");
|
|
101
140
|
const page = markdownPath === "/index.md" ? "/" : markdownPath.replace(/\.md$/, "");
|
|
@@ -106,7 +145,117 @@ function selectFarmPageActionsView(markdownPath, actions, headers) {
|
|
|
106
145
|
};
|
|
107
146
|
}
|
|
108
147
|
_chunkS3JO3N4Hcjs.__name.call(void 0, selectFarmPageActionsView, "selectFarmPageActionsView");
|
|
148
|
+
function selectFarmMarkdownPart(document, rawBudget, rawCursor, partUrl) {
|
|
149
|
+
const budget = /^\d{1,9}$/.test(rawBudget) ? Number(rawBudget) : Number.NaN;
|
|
150
|
+
if (!(budget >= FARM_MARKDOWN_MIN_TOKEN_BUDGET)) {
|
|
151
|
+
return {
|
|
152
|
+
status: 400,
|
|
153
|
+
body: `# Invalid max_tokens
|
|
154
|
+
|
|
155
|
+
\`max_tokens\` must be a whole number of at least ${FARM_MARKDOWN_MIN_TOKEN_BUDGET}.
|
|
156
|
+
`
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const lines = document.replace(/\n$/, "").split("\n");
|
|
160
|
+
const version = hashFarmMarkdown(document).slice(0, 8);
|
|
161
|
+
let start = 0;
|
|
162
|
+
if (rawCursor !== null) {
|
|
163
|
+
const match = /^(\d{1,9})\.([0-9a-z]+)$/.exec(rawCursor);
|
|
164
|
+
if (!match || Number(match[1]) <= 0 || Number(match[1]) >= lines.length) {
|
|
165
|
+
return {
|
|
166
|
+
status: 400,
|
|
167
|
+
body: `# Invalid cursor
|
|
168
|
+
|
|
169
|
+
Start again at ${partUrl()}.
|
|
170
|
+
`
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (match[2] !== version) {
|
|
174
|
+
return {
|
|
175
|
+
status: 409,
|
|
176
|
+
body: `# Page changed
|
|
177
|
+
|
|
178
|
+
The page changed after this cursor was issued. Start again at ${partUrl()}.
|
|
179
|
+
`
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
start = Number(match[1]);
|
|
183
|
+
}
|
|
184
|
+
const fences = readOpenFences(lines);
|
|
185
|
+
const reopen = fences[start];
|
|
186
|
+
const room = budget * 4 - 200;
|
|
187
|
+
let size = reopen ? reopen.opener.length + 1 : 0;
|
|
188
|
+
let end = start;
|
|
189
|
+
let lastBreak = -1;
|
|
190
|
+
while (end < lines.length) {
|
|
191
|
+
const length = lines[end].length + 1;
|
|
192
|
+
if (end > start && size + length > room) break;
|
|
193
|
+
size += length;
|
|
194
|
+
end++;
|
|
195
|
+
if (end < lines.length && isPartBreak(lines, fences, end)) lastBreak = end;
|
|
196
|
+
}
|
|
197
|
+
const head = reopen ? `${reopen.opener}
|
|
198
|
+
` : "";
|
|
199
|
+
if (end >= lines.length) {
|
|
200
|
+
return { status: 200, body: `${head}${lines.slice(start).join("\n")}
|
|
201
|
+
` };
|
|
202
|
+
}
|
|
203
|
+
if (lastBreak > start) end = lastBreak;
|
|
204
|
+
const open = fences[end];
|
|
205
|
+
const part = `${head}${lines.slice(start, end).join("\n").replace(/\n+$/, "")}${open ? `
|
|
206
|
+
${open.closer}` : ""}`;
|
|
207
|
+
const next = partUrl(`${end}.${version}`);
|
|
208
|
+
const remaining = estimateFarmMarkdownTokens(lines.slice(end).join("\n"));
|
|
209
|
+
return {
|
|
210
|
+
status: 200,
|
|
211
|
+
body: `${part}
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
Continue: ${next} (about ${remaining} more tokens)
|
|
216
|
+
`,
|
|
217
|
+
headers: { Link: `<${next}>; rel="next"` }
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, selectFarmMarkdownPart, "selectFarmMarkdownPart");
|
|
221
|
+
function readOpenFences(lines) {
|
|
222
|
+
const open = [];
|
|
223
|
+
let fence;
|
|
224
|
+
let frontMatter = _optionalChain([lines, 'access', _5 => _5[0], 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]) === "---";
|
|
225
|
+
for (let index = 0; index < lines.length; index++) {
|
|
226
|
+
open.push(frontMatter && index > 0 ? { opener: "", closer: "" } : fence);
|
|
227
|
+
const line = lines[index];
|
|
228
|
+
if (frontMatter) {
|
|
229
|
+
if (index > 0 && line.trim() === "---") frontMatter = false;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const match = FENCE.exec(line);
|
|
233
|
+
if (!match) continue;
|
|
234
|
+
const marker = match[1];
|
|
235
|
+
if (!fence) fence = { opener: line.trim(), closer: marker, marker };
|
|
236
|
+
else if (marker[0] === fence.marker[0] && marker.length >= fence.marker.length)
|
|
237
|
+
fence = void 0;
|
|
238
|
+
}
|
|
239
|
+
return open;
|
|
240
|
+
}
|
|
241
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readOpenFences, "readOpenFences");
|
|
242
|
+
function isPartBreak(lines, fences, index) {
|
|
243
|
+
if (fences[index]) return false;
|
|
244
|
+
return lines[index - 1].trim() === "" || ATX_HEADING.test(lines[index]);
|
|
245
|
+
}
|
|
246
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isPartBreak, "isPartBreak");
|
|
247
|
+
function readMarkdownViewName(searchParams) {
|
|
248
|
+
if (searchParams.has("actions")) return "actions";
|
|
249
|
+
if (searchParams.has("outline")) return "outline";
|
|
250
|
+
if (searchParams.has("max_tokens")) return "parts";
|
|
251
|
+
return searchParams.has("section") ? "section" : void 0;
|
|
252
|
+
}
|
|
253
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readMarkdownViewName, "readMarkdownViewName");
|
|
109
254
|
function createFarmMarkdownETag(body) {
|
|
255
|
+
return `W/"${hashFarmMarkdown(body)}-${body.length.toString(36)}"`;
|
|
256
|
+
}
|
|
257
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmMarkdownETag, "createFarmMarkdownETag");
|
|
258
|
+
function hashFarmMarkdown(body) {
|
|
110
259
|
let h1 = 3735928559;
|
|
111
260
|
let h2 = 1103547991;
|
|
112
261
|
for (let index = 0; index < body.length; index++) {
|
|
@@ -116,10 +265,9 @@ function createFarmMarkdownETag(body) {
|
|
|
116
265
|
}
|
|
117
266
|
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
118
267
|
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
119
|
-
|
|
120
|
-
return `W/"${hash}-${body.length.toString(36)}"`;
|
|
268
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36);
|
|
121
269
|
}
|
|
122
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0,
|
|
270
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, hashFarmMarkdown, "hashFarmMarkdown");
|
|
123
271
|
function ifNoneMatchIncludes(header, etag) {
|
|
124
272
|
if (!header) return false;
|
|
125
273
|
const opaque = etag.replace(/^W\//, "");
|
|
@@ -130,6 +278,9 @@ function createFarmMarkdownViewResponse(options) {
|
|
|
130
278
|
const url = _nullishCoalesce(options.requestUrl, () => ( new URL(options.request.url)));
|
|
131
279
|
const view = url.searchParams.has("actions") ? selectFarmPageActionsView(options.markdownPath, _nullishCoalesce(options.actions, () => ( [])), options.headers) : selectFarmMarkdownView(options.markdown, url.searchParams, options.markdownPath);
|
|
132
280
|
const status = view.status === 200 ? options.status : view.status;
|
|
281
|
+
_chunkJ63ZH5OQcjs.emitFarmAgentRead.call(void 0, options.request, "markdown", status, readMarkdownViewName(url.searchParams));
|
|
282
|
+
for (const [name, value] of Object.entries(_nullishCoalesce(view.headers, () => ( {}))))
|
|
283
|
+
options.headers.append(name, value);
|
|
133
284
|
const etag = createFarmMarkdownETag(view.body);
|
|
134
285
|
options.headers.set("ETag", etag);
|
|
135
286
|
if (status === 200 && ifNoneMatchIncludes(options.request.headers.get("if-none-match"), etag)) {
|
|
@@ -187,7 +338,7 @@ function resolveMarkdownConfig(config) {
|
|
|
187
338
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveMarkdownConfig, "resolveMarkdownConfig");
|
|
188
339
|
function resolveMarkdownMirrorTarget(config, pathname, options = {}) {
|
|
189
340
|
const hasMarkdownExtension = pathname.toLowerCase().endsWith(".md");
|
|
190
|
-
if (!_optionalChain([config, 'optionalAccess',
|
|
341
|
+
if (!_optionalChain([config, 'optionalAccess', _8 => _8.enabled]) || !hasMarkdownExtension && !requestAcceptsMarkdown(options.accept)) {
|
|
191
342
|
return null;
|
|
192
343
|
}
|
|
193
344
|
const targetPathname = normalizeMarkdownRoute(
|
|
@@ -207,7 +358,7 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
207
358
|
if (options.request.method !== "GET" && options.request.method !== "HEAD") {
|
|
208
359
|
return null;
|
|
209
360
|
}
|
|
210
|
-
const requestUrl = _optionalChain([options, 'access',
|
|
361
|
+
const requestUrl = _optionalChain([options, 'access', _9 => _9.requestUrl, 'optionalAccess', _10 => _10.href]) === options.request.url ? options.requestUrl : new URL(options.request.url);
|
|
211
362
|
const hasMarkdownExtension = requestUrl.pathname.toLowerCase().endsWith(".md");
|
|
212
363
|
const target = resolveMarkdownMirrorTarget(options.config, requestUrl.pathname, {
|
|
213
364
|
accept: options.request.headers.get("accept")
|
|
@@ -220,7 +371,7 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
220
371
|
}
|
|
221
372
|
const pageUrl = new URL(options.request.url);
|
|
222
373
|
pageUrl.pathname = target.pathname;
|
|
223
|
-
for (const name of
|
|
374
|
+
for (const name of FARM_MARKDOWN_VIEW_PARAMS) pageUrl.searchParams.delete(name);
|
|
224
375
|
const headers = new Headers(options.request.headers);
|
|
225
376
|
headers.set("accept", "text/html");
|
|
226
377
|
const pageResponse = await options.renderPage(
|
|
@@ -229,7 +380,8 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
229
380
|
headers
|
|
230
381
|
})
|
|
231
382
|
);
|
|
232
|
-
|
|
383
|
+
const redirects = pageResponse.status >= 300 && pageResponse.status < 400 && pageResponse.headers.has("location");
|
|
384
|
+
if (redirects || !isHtmlResponse(pageResponse)) {
|
|
233
385
|
return createMarkdownAccessResponse(
|
|
234
386
|
pageResponse,
|
|
235
387
|
target.pathname,
|
|
@@ -241,8 +393,8 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
241
393
|
const markdownPath = target.pathname === "/" ? "/index.md" : `${target.pathname}.md`;
|
|
242
394
|
const actions = extractFarmPageActions(html, pageUrl);
|
|
243
395
|
const markdown = htmlToMarkdown(html, {
|
|
244
|
-
title: _optionalChain([target, 'access',
|
|
245
|
-
includeMetadata: _nullishCoalesce(_optionalChain([options, 'access',
|
|
396
|
+
title: _optionalChain([target, 'access', _11 => _11.route, 'optionalAccess', _12 => _12.title]),
|
|
397
|
+
includeMetadata: _nullishCoalesce(_optionalChain([options, 'access', _13 => _13.config, 'optionalAccess', _14 => _14.includeMetadata]), () => ( true)),
|
|
246
398
|
sourcePath: target.pathname,
|
|
247
399
|
actionsPath: actions.length > 0 ? `${markdownPath}?actions` : void 0
|
|
248
400
|
});
|
|
@@ -254,17 +406,17 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
254
406
|
if (!hasMarkdownExtension) {
|
|
255
407
|
headersOut.set("Vary", "Accept");
|
|
256
408
|
}
|
|
257
|
-
for (const token of _nullishCoalesce(_optionalChain([pageResponse, 'access',
|
|
409
|
+
for (const token of _nullishCoalesce(_optionalChain([pageResponse, 'access', _15 => _15.headers, 'access', _16 => _16.get, 'call', _17 => _17("vary"), 'optionalAccess', _18 => _18.split, 'call', _19 => _19(",")]), () => ( []))) {
|
|
258
410
|
const name = token.trim();
|
|
259
411
|
if (name && name.toLowerCase() !== "accept") appendHeaderToken(headersOut, "Vary", name);
|
|
260
412
|
}
|
|
261
413
|
const pageCacheControl = pageResponse.headers.get("cache-control");
|
|
262
|
-
const cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([target, 'access',
|
|
414
|
+
const cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([target, 'access', _20 => _20.route, 'optionalAccess', _21 => _21.cache]), () => ( _optionalChain([options, 'access', _22 => _22.config, 'optionalAccess', _23 => _23.cache]))), () => ( false));
|
|
263
415
|
headersOut.set(
|
|
264
416
|
"Cache-Control",
|
|
265
417
|
pageCacheControl && isPrivateCacheControl(pageCacheControl) ? pageCacheControl : createMarkdownCacheHeader(cache)
|
|
266
418
|
);
|
|
267
|
-
const robots = [pageResponse.headers.get("x-robots-tag"), readHtmlMetaContent(html, "robots")].filter((value) => Boolean(_optionalChain([value, 'optionalAccess',
|
|
419
|
+
const robots = [pageResponse.headers.get("x-robots-tag"), readHtmlMetaContent(html, "robots")].filter((value) => Boolean(_optionalChain([value, 'optionalAccess', _24 => _24.trim, 'call', _25 => _25()]))).join(", ");
|
|
268
420
|
if (robots) headersOut.set("X-Robots-Tag", robots);
|
|
269
421
|
const canonical = readHtmlCanonicalHref(html);
|
|
270
422
|
if (canonical) {
|
|
@@ -521,7 +673,7 @@ function getFarmMarkdownAlternatePath(config, pathname) {
|
|
|
521
673
|
}
|
|
522
674
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmMarkdownAlternatePath, "getFarmMarkdownAlternatePath");
|
|
523
675
|
function isFarmMarkdownMirrorExposed(config, pathname) {
|
|
524
|
-
if (!_optionalChain([config, 'optionalAccess',
|
|
676
|
+
if (!_optionalChain([config, 'optionalAccess', _26 => _26.enabled])) return false;
|
|
525
677
|
return config.expose === true || findExposedMarkdownRoute(config, pathname) !== null;
|
|
526
678
|
}
|
|
527
679
|
_chunkS3JO3N4Hcjs.__name.call(void 0, isFarmMarkdownMirrorExposed, "isFarmMarkdownMirrorExposed");
|
|
@@ -614,7 +766,7 @@ function extractHtmlBody(html) {
|
|
|
614
766
|
const body = rootMatch ? rootMatch[1] : bodyMatch ? bodyMatch[1] : html;
|
|
615
767
|
const main = extractFirstElementContent(body, ["main"]);
|
|
616
768
|
if (main !== void 0) return main;
|
|
617
|
-
const articles = _nullishCoalesce(_optionalChain([body, 'access',
|
|
769
|
+
const articles = _nullishCoalesce(_optionalChain([body, 'access', _27 => _27.match, 'call', _28 => _28(/<article\b/gi), 'optionalAccess', _29 => _29.length]), () => ( 0));
|
|
618
770
|
return articles === 1 ? _nullishCoalesce(extractFirstElementContent(body, ["article"]), () => ( body)) : body;
|
|
619
771
|
}
|
|
620
772
|
_chunkS3JO3N4Hcjs.__name.call(void 0, extractHtmlBody, "extractHtmlBody");
|
|
@@ -630,7 +782,7 @@ function extractFirstElementContent(html, tagNames) {
|
|
|
630
782
|
_chunkS3JO3N4Hcjs.__name.call(void 0, extractFirstElementContent, "extractFirstElementContent");
|
|
631
783
|
function readHtmlMetaContent(html, name) {
|
|
632
784
|
for (const match of html.matchAll(/<meta\b([^>]*)>/gi)) {
|
|
633
|
-
if (_optionalChain([readHtmlAttribute, 'call',
|
|
785
|
+
if (_optionalChain([readHtmlAttribute, 'call', _30 => _30(match[1], "name"), 'optionalAccess', _31 => _31.toLowerCase, 'call', _32 => _32()]) === name) {
|
|
634
786
|
return readHtmlAttribute(match[1], "content");
|
|
635
787
|
}
|
|
636
788
|
}
|
|
@@ -639,8 +791,8 @@ function readHtmlMetaContent(html, name) {
|
|
|
639
791
|
_chunkS3JO3N4Hcjs.__name.call(void 0, readHtmlMetaContent, "readHtmlMetaContent");
|
|
640
792
|
function readHtmlCanonicalHref(html) {
|
|
641
793
|
for (const match of html.matchAll(/<link\b([^>]*)>/gi)) {
|
|
642
|
-
const rel = _optionalChain([readHtmlAttribute, 'call',
|
|
643
|
-
if (_optionalChain([rel, 'optionalAccess',
|
|
794
|
+
const rel = _optionalChain([readHtmlAttribute, 'call', _33 => _33(match[1], "rel"), 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35(), 'access', _36 => _36.split, 'call', _37 => _37(/\s+/)]);
|
|
795
|
+
if (_optionalChain([rel, 'optionalAccess', _38 => _38.includes, 'call', _39 => _39("canonical")])) return readHtmlAttribute(match[1], "href");
|
|
644
796
|
}
|
|
645
797
|
return void 0;
|
|
646
798
|
}
|
|
@@ -667,7 +819,7 @@ function extractFarmPageActions(html, pageUrl) {
|
|
|
667
819
|
}
|
|
668
820
|
_chunkS3JO3N4Hcjs.__name.call(void 0, extractFarmPageActions, "extractFarmPageActions");
|
|
669
821
|
function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
670
|
-
const method = _optionalChain([readDecodedAttribute, 'call',
|
|
822
|
+
const method = _optionalChain([readDecodedAttribute, 'call', _40 => _40(attributes, "method"), 'optionalAccess', _41 => _41.trim, 'call', _42 => _42(), 'access', _43 => _43.toLowerCase, 'call', _44 => _44()]);
|
|
671
823
|
if (method === "dialog") return void 0;
|
|
672
824
|
const target = resolveFormTarget(readDecodedAttribute(attributes, "action"), pageUrl);
|
|
673
825
|
const form = {
|
|
@@ -677,11 +829,11 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
677
829
|
submit: []
|
|
678
830
|
};
|
|
679
831
|
const name = _nullishCoalesce(_nullishCoalesce(readDecodedAttribute(attributes, "aria-label"), () => ( readDecodedAttribute(attributes, "name"))), () => ( readDecodedAttribute(attributes, "id")));
|
|
680
|
-
if (_optionalChain([name, 'optionalAccess',
|
|
832
|
+
if (_optionalChain([name, 'optionalAccess', _45 => _45.trim, 'call', _46 => _46()])) form.name = name.trim();
|
|
681
833
|
if (target) form.action = target;
|
|
682
834
|
else form.requiresJavaScript = true;
|
|
683
835
|
if (form.method === "POST") {
|
|
684
|
-
const enctype = _optionalChain([readDecodedAttribute, 'call',
|
|
836
|
+
const enctype = _optionalChain([readDecodedAttribute, 'call', _47 => _47(attributes, "enctype"), 'optionalAccess', _48 => _48.trim, 'call', _49 => _49(), 'access', _50 => _50.toLowerCase, 'call', _51 => _51()]);
|
|
685
837
|
form.enctype = enctype && FORM_ENCTYPES.has(enctype) ? enctype : "application/x-www-form-urlencoded";
|
|
686
838
|
}
|
|
687
839
|
const wrappingLabels = [...content.matchAll(/<label\b[^>]*>([\s\S]*?)<\/label>/gi)].map(
|
|
@@ -692,13 +844,13 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
692
844
|
})
|
|
693
845
|
);
|
|
694
846
|
const labelOf = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (controlAttributes, index) => {
|
|
695
|
-
const aria = _optionalChain([readDecodedAttribute, 'call',
|
|
847
|
+
const aria = _optionalChain([readDecodedAttribute, 'call', _52 => _52(controlAttributes, "aria-label"), 'optionalAccess', _53 => _53.trim, 'call', _54 => _54()]);
|
|
696
848
|
if (aria) return aria;
|
|
697
849
|
const id = readDecodedAttribute(controlAttributes, "id");
|
|
698
850
|
const forLabel = id ? labelsFor.get(id) : void 0;
|
|
699
851
|
if (forLabel) return forLabel;
|
|
700
852
|
const wrapping = wrappingLabels.find((label) => label.start < index && index < label.end);
|
|
701
|
-
return _optionalChain([wrapping, 'optionalAccess',
|
|
853
|
+
return _optionalChain([wrapping, 'optionalAccess', _55 => _55.text]) || void 0;
|
|
702
854
|
}, "labelOf");
|
|
703
855
|
const groups = /* @__PURE__ */ new Map();
|
|
704
856
|
const controls = /<(input)\b([^>]*)>|<(select|textarea|button)\b([^>]*)>([\s\S]*?)<\/\3>/gi;
|
|
@@ -709,7 +861,7 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
709
861
|
if (hasHtmlAttribute(controlAttributes, "disabled")) continue;
|
|
710
862
|
const label = labelOf(controlAttributes, match.index);
|
|
711
863
|
const fieldName = readDecodedAttribute(controlAttributes, "name");
|
|
712
|
-
const typeAttribute = _optionalChain([readDecodedAttribute, 'call',
|
|
864
|
+
const typeAttribute = _optionalChain([readDecodedAttribute, 'call', _56 => _56(controlAttributes, "type"), 'optionalAccess', _57 => _57.trim, 'call', _58 => _58(), 'access', _59 => _59.toLowerCase, 'call', _60 => _60()]);
|
|
713
865
|
const type = tag === "input" ? _nullishCoalesce(typeAttribute, () => ( "text")) : tag === "button" ? _nullishCoalesce(typeAttribute, () => ( "submit")) : tag;
|
|
714
866
|
if (tag === "button" && !["button", "reset"].includes(type) || tag === "input" && (type === "submit" || type === "image")) {
|
|
715
867
|
const submit = {
|
|
@@ -723,7 +875,7 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
723
875
|
const resolved = resolveFormTarget(formAction, pageUrl);
|
|
724
876
|
if (resolved) submit.action = resolved;
|
|
725
877
|
}
|
|
726
|
-
const formMethod = _optionalChain([readDecodedAttribute, 'call',
|
|
878
|
+
const formMethod = _optionalChain([readDecodedAttribute, 'call', _61 => _61(controlAttributes, "formmethod"), 'optionalAccess', _62 => _62.toLowerCase, 'call', _63 => _63()]);
|
|
727
879
|
if (formMethod === "get" || formMethod === "post") submit.method = formMethod.toUpperCase();
|
|
728
880
|
form.submit.push(submit);
|
|
729
881
|
continue;
|
|
@@ -802,7 +954,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, readPageForm, "readPageForm");
|
|
|
802
954
|
function resolveFormTarget(action, pageUrl) {
|
|
803
955
|
let target;
|
|
804
956
|
try {
|
|
805
|
-
target = new URL(_optionalChain([action, 'optionalAccess',
|
|
957
|
+
target = new URL(_optionalChain([action, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]) || pageUrl.href, pageUrl);
|
|
806
958
|
} catch (e4) {
|
|
807
959
|
return void 0;
|
|
808
960
|
}
|
|
@@ -834,7 +986,7 @@ function readHtmlAttribute(attributes, name) {
|
|
|
834
986
|
_chunkS3JO3N4Hcjs.__name.call(void 0, readHtmlAttribute, "readHtmlAttribute");
|
|
835
987
|
function readCodeLanguage(attributesList) {
|
|
836
988
|
for (const attributes of attributesList) {
|
|
837
|
-
const language = _nullishCoalesce(_nullishCoalesce(readHtmlAttribute(attributes, "data-language"), () => ( readHtmlAttribute(attributes, "data-lang"))), () => ( _optionalChain([readHtmlAttribute, 'call',
|
|
989
|
+
const language = _nullishCoalesce(_nullishCoalesce(readHtmlAttribute(attributes, "data-language"), () => ( readHtmlAttribute(attributes, "data-lang"))), () => ( _optionalChain([readHtmlAttribute, 'call', _66 => _66(attributes, "class"), 'optionalAccess', _67 => _67.match, 'call', _68 => _68(/(?:^|\s)lang(?:uage)?-(\S+)/), 'optionalAccess', _69 => _69[1]])));
|
|
838
990
|
if (language && /^[\w#+.-]+$/.test(language)) return language;
|
|
839
991
|
}
|
|
840
992
|
return void 0;
|
|
@@ -947,7 +1099,7 @@ function matchClosingTags(html) {
|
|
|
947
1099
|
while (match = tags.exec(html)) {
|
|
948
1100
|
const name = match[2].toLowerCase();
|
|
949
1101
|
if (match[1]) {
|
|
950
|
-
const start = _optionalChain([open, 'access',
|
|
1102
|
+
const start = _optionalChain([open, 'access', _70 => _70.get, 'call', _71 => _71(name), 'optionalAccess', _72 => _72.pop, 'call', _73 => _73()]);
|
|
951
1103
|
if (start !== void 0) closes.set(start, match.index + match[0].length);
|
|
952
1104
|
} else if (!VOID_TAGS.has(name) && !isSelfClosingTag(match[0])) {
|
|
953
1105
|
let starts = open.get(name);
|
|
@@ -982,7 +1134,7 @@ function resolveStreamedBoundaries(html, { boundaries, placeholders }) {
|
|
|
982
1134
|
let cursor = 0;
|
|
983
1135
|
let match;
|
|
984
1136
|
while (match = openingTag.exec(html)) {
|
|
985
|
-
const id = _optionalChain([/\sid="([^"]*)"/, 'access',
|
|
1137
|
+
const id = _optionalChain([/\sid="([^"]*)"/, 'access', _74 => _74.exec, 'call', _75 => _75(match[2]), 'optionalAccess', _76 => _76[1]]);
|
|
986
1138
|
if (!id || !wanted.has(id) || segments.has(id)) continue;
|
|
987
1139
|
const close = closingTags.get(match.index);
|
|
988
1140
|
if (close === void 0) continue;
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
var _chunkOWOUTKIJcjs = require('./chunk-OWOUTKIJ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk2CT6XUNOcjs = require('./chunk-2CT6XUNO.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
var _chunkOI6CMLWXcjs = require('./chunk-OI6CMLWX.cjs');
|
|
@@ -201,10 +204,13 @@ function createFarmMetadataRouteResponse(kind, value, routeModule = {}, options
|
|
|
201
204
|
if (method !== "GET" && method !== "HEAD") {
|
|
202
205
|
return new Response(null, { status: 405, headers: { Allow: "GET, HEAD" } });
|
|
203
206
|
}
|
|
207
|
+
if ((kind === "llms" || kind === "llms-full") && options.request) {
|
|
208
|
+
_chunkJ63ZH5OQcjs.emitFarmAgentRead.call(void 0, options.request, kind, isResponse(value) ? value.status : 200);
|
|
209
|
+
}
|
|
204
210
|
if (isResponse(value)) {
|
|
205
211
|
return method === "HEAD" ? _chunkTKJZFIMLcjs.omitFarmResponseBody.call(void 0, value) : value;
|
|
206
212
|
}
|
|
207
|
-
const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ?
|
|
213
|
+
const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ? _chunk2CT6XUNOcjs.serializeFarmLlmsTxt.call(void 0, value) : serializeManifest(value);
|
|
208
214
|
const contentType = kind === "sitemap" ? "application/xml; charset=utf-8" : kind === "robots" || kind === "llms" || kind === "llms-full" ? "text/plain; charset=utf-8" : "application/manifest+json; charset=utf-8";
|
|
209
215
|
return new Response(method === "HEAD" ? null : body, {
|
|
210
216
|
headers: {
|
|
@@ -486,7 +492,7 @@ function createFarmApiCatalog(input) {
|
|
|
486
492
|
};
|
|
487
493
|
}
|
|
488
494
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmApiCatalog, "createFarmApiCatalog");
|
|
489
|
-
function createFarmApiCatalogResponse(method, input) {
|
|
495
|
+
function createFarmApiCatalogResponse(method, input, request) {
|
|
490
496
|
const upperMethod = method.toUpperCase();
|
|
491
497
|
if (upperMethod !== "GET" && upperMethod !== "HEAD") {
|
|
492
498
|
return new Response("Method Not Allowed", {
|
|
@@ -494,6 +500,7 @@ function createFarmApiCatalogResponse(method, input) {
|
|
|
494
500
|
headers: { Allow: "GET, HEAD", "Content-Type": "text/plain; charset=utf-8" }
|
|
495
501
|
});
|
|
496
502
|
}
|
|
503
|
+
if (request) _chunkJ63ZH5OQcjs.emitFarmAgentRead.call(void 0, request, "api-catalog", 200);
|
|
497
504
|
const catalog = createFarmApiCatalog(input);
|
|
498
505
|
return new Response(upperMethod === "HEAD" ? null : JSON.stringify(catalog), {
|
|
499
506
|
status: 200,
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk3WSWXPYMcjs = require('./chunk-3WSWXPYM.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkIK6LVLKCcjs = require('./chunk-IK6LVLKC.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkWFPRVVF2cjs = require('./chunk-WFPRVVF2.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
var _chunk75WGQVQAcjs = require('./chunk-75WGQVQA.cjs');
|
|
@@ -39,7 +39,7 @@ function createFarmDocsAdapterRuntimeConfig(docs, options, moduleConfig) {
|
|
|
39
39
|
...moduleConfig ? { ...moduleConfig, ...docs.configOverrides } : _nullishCoalesce(docs.runtimeConfig, () => ( docs.config)),
|
|
40
40
|
entry: docs.config.entry || docs.entry.replace(/^\/+|\/+$/g, "") || "docs",
|
|
41
41
|
docsPath: docs.entry,
|
|
42
|
-
contentDir:
|
|
42
|
+
contentDir: _chunk3WSWXPYMcjs.resolveFarmDocsContentDir.call(void 0, docs, options)
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmDocsAdapterRuntimeConfig, "createFarmDocsAdapterRuntimeConfig");
|
|
@@ -274,25 +274,25 @@ function getDocsDescription(docs) {
|
|
|
274
274
|
}
|
|
275
275
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getDocsDescription, "getDocsDescription");
|
|
276
276
|
function getLoadedDocsPages(context) {
|
|
277
|
-
return
|
|
277
|
+
return _chunk3WSWXPYMcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs).map((page) => _chunk3WSWXPYMcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, page.slug)).filter((page) => Boolean(page));
|
|
278
278
|
}
|
|
279
279
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getLoadedDocsPages, "getLoadedDocsPages");
|
|
280
280
|
function toDocsSourcePage(page) {
|
|
281
281
|
return {
|
|
282
|
-
...
|
|
282
|
+
..._chunk3WSWXPYMcjs.toFarmDocsMarkdownPage.call(void 0, page),
|
|
283
283
|
sourcePath: page.sourcePath
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
286
|
_chunkS3JO3N4Hcjs.__name.call(void 0, toDocsSourcePage, "toDocsSourcePage");
|
|
287
287
|
function toDocsSitemapPage(page) {
|
|
288
288
|
return {
|
|
289
|
-
...
|
|
289
|
+
..._chunk3WSWXPYMcjs.toFarmDocsMarkdownPage.call(void 0, page),
|
|
290
290
|
sourcePath: page.sourcePath
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
_chunkS3JO3N4Hcjs.__name.call(void 0, toDocsSitemapPage, "toDocsSitemapPage");
|
|
294
294
|
function toDocsLlmsPage(page) {
|
|
295
|
-
return
|
|
295
|
+
return _chunk3WSWXPYMcjs.toFarmDocsMarkdownPage.call(void 0, page);
|
|
296
296
|
}
|
|
297
297
|
_chunkS3JO3N4Hcjs.__name.call(void 0, toDocsLlmsPage, "toDocsLlmsPage");
|
|
298
298
|
function getDocsLlmsOptions(context, request) {
|
|
@@ -386,7 +386,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, renderAgentsDocument, "renderAgentsDocumen
|
|
|
386
386
|
function buildAgentSpec(context, request) {
|
|
387
387
|
const url = new URL(request.url);
|
|
388
388
|
const origin = url.origin;
|
|
389
|
-
const pages =
|
|
389
|
+
const pages = _chunk3WSWXPYMcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
|
|
390
390
|
const spec = _chunkIK6LVLKCcjs.docsEngine.call(void 0, ).buildDocsAgentDiscoverySpec(getDocsDiscoveryOptions(context, request));
|
|
391
391
|
const title = getDocsTitle(context.docs);
|
|
392
392
|
return {
|
|
@@ -428,7 +428,7 @@ function buildAgentSpec(context, request) {
|
|
|
428
428
|
}
|
|
429
429
|
_chunkS3JO3N4Hcjs.__name.call(void 0, buildAgentSpec, "buildAgentSpec");
|
|
430
430
|
function buildDiagnostics(context) {
|
|
431
|
-
const pages =
|
|
431
|
+
const pages = _chunk3WSWXPYMcjs.discoverFarmDocsPages.call(void 0, context.contentDir, context.docs);
|
|
432
432
|
const diagnostics = _chunkIK6LVLKCcjs.docsEngine.call(void 0, ).buildDocsDiagnostics(context.docs.config, {
|
|
433
433
|
entry: context.docs.entry,
|
|
434
434
|
mcp: {
|
|
@@ -500,12 +500,12 @@ async function resolveAPIContext(options) {
|
|
|
500
500
|
config: options.config,
|
|
501
501
|
configPath: options.configPath
|
|
502
502
|
}));
|
|
503
|
-
const docs = isResolvedDocsConfig(docsInput) ? docsInput : await
|
|
503
|
+
const docs = isResolvedDocsConfig(docsInput) ? docsInput : await _chunkWFPRVVF2cjs.resolveDocsConfig.call(void 0, docsInput, { root, srcDir });
|
|
504
504
|
return {
|
|
505
505
|
root,
|
|
506
506
|
srcDir,
|
|
507
507
|
docs,
|
|
508
|
-
contentDir:
|
|
508
|
+
contentDir: _chunk3WSWXPYMcjs.resolveFarmDocsContentDir.call(void 0, docs, { root, srcDir })
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
511
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveAPIContext, "resolveAPIContext");
|
|
@@ -568,10 +568,10 @@ async function handleDocsAPIGet(request, context) {
|
|
|
568
568
|
if (format === "markdown" || url.pathname.endsWith(".md")) {
|
|
569
569
|
const pathParam = url.searchParams.get("path") || url.searchParams.get("slug");
|
|
570
570
|
const slug = normalizeDocsApiSlug(_nullishCoalesce(_nullishCoalesce(pathParam, () => ( pathTarget.slug)), () => ( "")), context.docs);
|
|
571
|
-
const page =
|
|
571
|
+
const page = _chunk3WSWXPYMcjs.loadFarmDocsPage.call(void 0, context.contentDir, context.docs, slug);
|
|
572
572
|
if (!page) return text("Docs page not found\n", "text/plain; charset=utf-8", { status: 404 });
|
|
573
573
|
return text(
|
|
574
|
-
_chunkIK6LVLKCcjs.docsEngine.call(void 0, ).renderDocsMarkdownDocument(
|
|
574
|
+
_chunkIK6LVLKCcjs.docsEngine.call(void 0, ).renderDocsMarkdownDocument(_chunk3WSWXPYMcjs.toFarmDocsMarkdownPage.call(void 0, page), {
|
|
575
575
|
origin: new URL(request.url).origin,
|
|
576
576
|
llms: getDocsLlmsOptions(context, request),
|
|
577
577
|
sitemap: context.docs.config.sitemap
|