@farming-labs/docs 0.2.52 → 0.2.53

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.
Files changed (44) hide show
  1. package/dist/agent-2t4kZLGo.mjs +10 -0
  2. package/dist/{agent-CaOBIVFy.mjs → agent-BMxMpEa0.mjs} +194 -22
  3. package/dist/agent-contract-b0akaPcg.mjs +573 -0
  4. package/dist/agent-export--X9Go-wj.mjs +853 -0
  5. package/dist/{agents-DjhjZaNP.mjs → agents-CW-zTNKP.mjs} +6 -5
  6. package/dist/cli/index.mjs +43 -28
  7. package/dist/client/react.d.mts +1 -1
  8. package/dist/{cloud-ask-ai-DcMe6xOf.d.mts → cloud-ask-ai-CMzYVzVX.d.mts} +1 -1
  9. package/dist/{cloud-C_Ok9rC5.mjs → cloud-zs0qAnKJ.mjs} +3 -3
  10. package/dist/{codeblocks-z9iT794h.mjs → codeblocks-DWM4IJPL.mjs} +9 -12
  11. package/dist/{dev-Tm9Ss4D6.mjs → dev-DFeVU2Ui.mjs} +2 -2
  12. package/dist/docs-cloud-server.d.mts +2 -2
  13. package/dist/docs-cloud-server.mjs +1 -1
  14. package/dist/{doctor-O9o9kjN8.mjs → doctor-CkM5tKdD.mjs} +36 -24
  15. package/dist/{downgrade-CYEaOctn.mjs → downgrade-Dj_KXV11.mjs} +2 -2
  16. package/dist/i18n-CAlj1ADU.mjs +40 -0
  17. package/dist/index.d.mts +139 -3
  18. package/dist/index.mjs +7 -5
  19. package/dist/{init-Ch5On0zm.mjs → init-Cmz-oqnp.mjs} +3 -3
  20. package/dist/{mcp-DuCPNHS-.mjs → mcp-B4Q1PN93.mjs} +9 -5
  21. package/dist/mcp.d.mts +102 -4
  22. package/dist/mcp.mjs +1446 -66
  23. package/dist/{package-version-C8PigBZk.mjs → package-version-DxnTZH4m.mjs} +1 -1
  24. package/dist/{reading-time-CPAy1SWO.mjs → reading-time-BuK2YL23.mjs} +278 -33
  25. package/dist/{review-lm3dt7yy.mjs → review-BEsbm0l2.mjs} +38 -3
  26. package/dist/{robots-DV7u4Ire.mjs → robots-BOwkq9du.mjs} +5 -4
  27. package/dist/{robots-XVPs9lVz.mjs → robots-C6uQG-fS.mjs} +1 -1
  28. package/dist/{search-BWuU70B0.mjs → search-CJNLkdjX.mjs} +174 -79
  29. package/dist/{search-DFEhf9-s.d.mts → search-CTu6Bvq-.d.mts} +3 -1
  30. package/dist/{search-B6nEkx86.mjs → search-CtAXkk_J.mjs} +5 -4
  31. package/dist/server.d.mts +5 -5
  32. package/dist/server.mjs +8 -7
  33. package/dist/{sitemap-BEiKy4Iy.mjs → sitemap-OPb8EdNe.mjs} +6 -5
  34. package/dist/{sitemap-server-xEHtDUDB.mjs → sitemap-server-DnilMEiZ.mjs} +1 -1
  35. package/dist/{templates-uaauJcTO.mjs → templates-Bty9M6lA.mjs} +11 -5
  36. package/dist/{types-XqGLsmOD.d.mts → types-CdKu8KmO.d.mts} +118 -2
  37. package/dist/{upgrade-DzQtpgJM.mjs → upgrade-BNdBB9tQ.mjs} +2 -2
  38. package/package.json +1 -1
  39. package/dist/agent-DXDOMJBw.mjs +0 -9
  40. /package/dist/{cloud-ask-ai-Cl-xaV8j.mjs → cloud-ask-ai-BFlx8VMO.mjs} +0 -0
  41. /package/dist/{config-tiQCZ46q.mjs → config-DhIyFsy9.mjs} +0 -0
  42. /package/dist/{errors-CW1LnxaQ.mjs → errors-BxfYhp1L.mjs} +0 -0
  43. /package/dist/{review-B7goPYUb.mjs → review-BHdy75TE.mjs} +0 -0
  44. /package/dist/{utils-D-xTRNuh.mjs → utils-CMZTjRQT.mjs} +0 -0
@@ -0,0 +1,10 @@
1
+ import "./reading-time-BuK2YL23.mjs";
2
+ import "./agent-contract-b0akaPcg.mjs";
3
+ import "./agent-BMxMpEa0.mjs";
4
+ import "./search-CJNLkdjX.mjs";
5
+ import "./robots-C6uQG-fS.mjs";
6
+ import "./sitemap-server-DnilMEiZ.mjs";
7
+ import "./config-DhIyFsy9.mjs";
8
+ import { a as readPageTokenBudget, i as printAgentCompactHelp, n as inspectAgentCompactionState, o as scanDocsPageTargets, r as parseAgentCompactArgs, t as compactAgentDocs } from "./codeblocks-DWM4IJPL.mjs";
9
+
10
+ export { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp };
@@ -1,3 +1,5 @@
1
+ import { l as upsertPageAgentContractMarkdown, s as renderPageAgentFrontmatterYamlLines } from "./agent-contract-b0akaPcg.mjs";
2
+
1
3
  //#region src/related.ts
2
4
  function normalizeDocsRelated(value) {
3
5
  if (!Array.isArray(value)) return [];
@@ -181,7 +183,7 @@ function buildDocsSitemapManifest(options) {
181
183
  pages.push({
182
184
  url,
183
185
  absoluteUrl: absolutizeUrl(baseUrl, url),
184
- markdownUrl: toDocsSitemapMarkdownUrl(url),
186
+ markdownUrl: page.markdownUrl ?? toDocsSitemapMarkdownUrl(url),
185
187
  title: page.title,
186
188
  description: page.description,
187
189
  sourcePath: page.sourcePath,
@@ -371,10 +373,13 @@ const DEFAULT_DOCS_DIAGNOSTICS_MCP_TOOLS = {
371
373
  listDocs: true,
372
374
  listPages: true,
373
375
  readPage: true,
376
+ listTasks: true,
377
+ readTask: true,
374
378
  searchDocs: true,
375
379
  getNavigation: true,
376
380
  getCodeExamples: true,
377
- getConfigSchema: true
381
+ getConfigSchema: true,
382
+ getContext: true
378
383
  };
379
384
  const DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER = "Signature-Agent";
380
385
  const DOCS_AI_AGENT_USER_AGENT_PATTERNS = [
@@ -927,10 +932,13 @@ function resolveDocsDiagnosticsMcp(mcp) {
927
932
  listDocs: tools.listDocs !== false,
928
933
  listPages: tools.listPages !== false,
929
934
  readPage: tools.readPage !== false,
935
+ listTasks: tools.listTasks !== false,
936
+ readTask: tools.readTask !== false,
930
937
  searchDocs: tools.searchDocs !== false,
931
938
  getNavigation: tools.getNavigation !== false,
932
939
  getCodeExamples: tools.getCodeExamples !== false,
933
- getConfigSchema: tools.getConfigSchema !== false
940
+ getConfigSchema: tools.getConfigSchema !== false,
941
+ getContext: tools.getContext !== false
934
942
  }
935
943
  };
936
944
  }
@@ -1262,7 +1270,7 @@ function resolveDocsLlmsTxtRequest(url, llms, basePath) {
1262
1270
  function renderLlmsTxtPageList(pages, baseUrl) {
1263
1271
  let content = "";
1264
1272
  for (const page of pages) {
1265
- content += `- [${page.title}](${baseUrl}${toDocsMarkdownUrl(page.url)})`;
1273
+ content += `- [${page.title}](${baseUrl}${page.markdownUrl ?? toDocsMarkdownUrl(page.url)})`;
1266
1274
  if (page.description) content += `: ${page.description}`;
1267
1275
  content += "\n";
1268
1276
  }
@@ -1498,7 +1506,7 @@ function resolveDocsMarkdownRequest(entry, url, request) {
1498
1506
  if (pathname === `${normalizedEntry}.md`) return { requestedPath: "" };
1499
1507
  const slugPrefix = `${normalizedEntry}/`;
1500
1508
  if (pathname.startsWith(slugPrefix) && pathname.endsWith(".md")) return { requestedPath: pathname.slice(slugPrefix.length, -3) };
1501
- if (acceptsMarkdown(request) || hasDocsMarkdownSignatureAgent(request) || detectDocsMarkdownAgentRequest(request).detected) {
1509
+ if (acceptsDocsMarkdown(request) || hasDocsMarkdownSignatureAgent(request) || detectDocsMarkdownAgentRequest(request).detected) {
1502
1510
  if (pathname === normalizedEntry) return { requestedPath: "" };
1503
1511
  if (pathname.startsWith(slugPrefix)) return { requestedPath: pathname.slice(slugPrefix.length) };
1504
1512
  }
@@ -1534,7 +1542,7 @@ function detectDocsMarkdownAgentRequest(request) {
1534
1542
  }
1535
1543
  function getDocsMarkdownVaryHeader(request) {
1536
1544
  const values = /* @__PURE__ */ new Set();
1537
- if (acceptsMarkdown(request)) values.add("Accept");
1545
+ if (acceptsDocsMarkdown(request)) values.add("Accept");
1538
1546
  if (hasDocsMarkdownSignatureAgent(request)) {
1539
1547
  values.add("Accept");
1540
1548
  values.add(DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER);
@@ -1680,7 +1688,7 @@ function resolveDocsMarkdownMetadataUrl(value, origin) {
1680
1688
  return value;
1681
1689
  }
1682
1690
  }
1683
- function renderDocsMarkdownFrontmatter({ title, description, canonicalUrl, markdownUrl, lastUpdated }) {
1691
+ function renderDocsMarkdownFrontmatter({ title, description, canonicalUrl, markdownUrl, lastUpdated, agent }) {
1684
1692
  return [
1685
1693
  "---",
1686
1694
  `title: ${toYamlString(title)}`,
@@ -1688,6 +1696,7 @@ function renderDocsMarkdownFrontmatter({ title, description, canonicalUrl, markd
1688
1696
  `canonical_url: ${toYamlString(canonicalUrl)}`,
1689
1697
  `markdown_url: ${toYamlString(markdownUrl)}`,
1690
1698
  ...lastUpdated ? [`last_updated: ${toYamlString(lastUpdated)}`] : [],
1699
+ ...renderPageAgentFrontmatterYamlLines(agent),
1691
1700
  "---"
1692
1701
  ].join("\n");
1693
1702
  }
@@ -1703,8 +1712,9 @@ function resolveDocsMarkdownPageMetadata(page, options) {
1703
1712
  title: page.title,
1704
1713
  description: page.description,
1705
1714
  canonicalUrl: resolveDocsMarkdownMetadataUrl(page.url, options?.origin),
1706
- markdownUrl: resolveDocsMarkdownMetadataUrl(toDocsMarkdownUrl(page.url), options?.origin),
1707
- lastUpdated: normalizeDocsMarkdownLastUpdated(page.lastmod ?? page.lastModified)
1715
+ markdownUrl: resolveDocsMarkdownMetadataUrl(page.markdownUrl ?? toDocsMarkdownUrl(page.url), options?.origin),
1716
+ lastUpdated: normalizeDocsMarkdownLastUpdated(page.lastmod ?? page.lastModified),
1717
+ agent: page.agent
1708
1718
  };
1709
1719
  }
1710
1720
  function renderDocsMarkdownNotFound({ entry = "docs", requestedPath, origin, pages, sitemap }) {
@@ -1750,6 +1760,121 @@ function renderDocsMarkdownNotFound({ entry = "docs", requestedPath, origin, pag
1750
1760
  markdownUrl: resolveDocsMarkdownMetadataUrl(requestedMarkdownRoute, origin)
1751
1761
  }), sitemap);
1752
1762
  }
1763
+ function hashDocsMarkdownRepresentation(value) {
1764
+ let hash = 2166136261;
1765
+ for (let index = 0; index < value.length; index += 1) {
1766
+ hash ^= value.charCodeAt(index);
1767
+ hash = Math.imul(hash, 16777619);
1768
+ }
1769
+ return (hash >>> 0).toString(16).padStart(8, "0");
1770
+ }
1771
+ function createDocsMarkdownEtag(document) {
1772
+ return `W/"${document.length.toString(16)}-${hashDocsMarkdownRepresentation(document)}"`;
1773
+ }
1774
+ function normalizeDocsMarkdownEtag(value) {
1775
+ return value.trim().replace(/^W\//i, "");
1776
+ }
1777
+ function requestMatchesDocsMarkdownEtag(request, etag) {
1778
+ const header = request.headers.get("if-none-match");
1779
+ if (!header) return false;
1780
+ if (header.trim() === "*") return true;
1781
+ const expected = normalizeDocsMarkdownEtag(etag);
1782
+ return header.split(",").some((candidate) => normalizeDocsMarkdownEtag(candidate) === expected);
1783
+ }
1784
+ function resolveDocsMarkdownHttpDate(value) {
1785
+ if (!value) return void 0;
1786
+ if (typeof value === "string" && !/(?:T|\s)\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?/.test(value.trim())) return;
1787
+ const date = value instanceof Date ? value : new Date(value);
1788
+ if (Number.isNaN(date.getTime())) return void 0;
1789
+ return date.toUTCString();
1790
+ }
1791
+ function extractDocsMarkdownLastModified(document) {
1792
+ const frontmatter = document.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1];
1793
+ if (!frontmatter) return void 0;
1794
+ const raw = frontmatter.match(/^last_updated:\s*(.+?)\s*$/m)?.[1]?.trim();
1795
+ if (!raw) return void 0;
1796
+ if (raw.startsWith("\"") && raw.endsWith("\"") || raw.startsWith("'") && raw.endsWith("'")) return raw.slice(1, -1);
1797
+ return raw;
1798
+ }
1799
+ function requestHasFreshDocsMarkdownDate(request, lastModified) {
1800
+ if (!lastModified || request.headers.has("if-none-match")) return false;
1801
+ const ifModifiedSince = request.headers.get("if-modified-since");
1802
+ if (!ifModifiedSince) return false;
1803
+ const resourceTime = Date.parse(lastModified);
1804
+ const requestTime = Date.parse(ifModifiedSince);
1805
+ return Number.isFinite(resourceTime) && Number.isFinite(requestTime) && Math.floor(resourceTime / 1e3) <= Math.floor(requestTime / 1e3);
1806
+ }
1807
+ function resolveDocsMarkdownContentLocation(canonicalUrl) {
1808
+ const url = new URL(canonicalUrl);
1809
+ url.pathname = toDocsMarkdownUrl(url.pathname);
1810
+ return url.toString();
1811
+ }
1812
+ /** Build one standards-aware Markdown response for every framework adapter. */
1813
+ function createDocsMarkdownResponse(options) {
1814
+ const { request, document, entry = "docs", requestedPath, origin = new URL(request.url).origin, pages, sitemap, locale } = options;
1815
+ const canonicalUrl = options.canonicalUrl ?? resolveDocsMarkdownCanonicalUrl({
1816
+ origin,
1817
+ entry,
1818
+ requestedPath,
1819
+ locale
1820
+ });
1821
+ const contentLocation = options.contentLocation ?? resolveDocsMarkdownContentLocation(canonicalUrl);
1822
+ const varyHeader = getDocsMarkdownVaryHeader(request);
1823
+ const sharedHeaders = {
1824
+ "Content-Location": contentLocation,
1825
+ Link: `<${canonicalUrl}>; rel="canonical"`,
1826
+ "X-Robots-Tag": "noindex",
1827
+ ...locale ? { "Content-Language": locale } : {},
1828
+ ...varyHeader ? { Vary: varyHeader } : {}
1829
+ };
1830
+ if (!document) {
1831
+ const recovery = resolveDocsMarkdownRecovery({
1832
+ entry,
1833
+ requestedPath,
1834
+ pages,
1835
+ sitemap
1836
+ });
1837
+ if (recovery.redirect) return new Response(null, {
1838
+ status: 307,
1839
+ headers: {
1840
+ ...sharedHeaders,
1841
+ "Cache-Control": "no-store",
1842
+ Location: new URL(recovery.redirect.markdownUrl, request.url).toString()
1843
+ }
1844
+ });
1845
+ return new Response(renderDocsMarkdownNotFound({
1846
+ entry,
1847
+ requestedPath,
1848
+ origin,
1849
+ pages,
1850
+ sitemap
1851
+ }), {
1852
+ status: 404,
1853
+ headers: {
1854
+ ...sharedHeaders,
1855
+ "Cache-Control": "no-store",
1856
+ "Content-Type": "text/markdown; charset=utf-8"
1857
+ }
1858
+ });
1859
+ }
1860
+ const etag = createDocsMarkdownEtag(document);
1861
+ const lastModified = resolveDocsMarkdownHttpDate(options.lastModified ?? extractDocsMarkdownLastModified(document));
1862
+ const responseHeaders = {
1863
+ ...sharedHeaders,
1864
+ "Cache-Control": options.cacheControl ?? "public, max-age=0, s-maxage=3600",
1865
+ "Content-Type": "text/markdown; charset=utf-8",
1866
+ ETag: etag,
1867
+ ...lastModified ? { "Last-Modified": lastModified } : {}
1868
+ };
1869
+ if (requestMatchesDocsMarkdownEtag(request, etag) || requestHasFreshDocsMarkdownDate(request, lastModified)) {
1870
+ const { "Content-Type": _contentType, ...notModifiedHeaders } = responseHeaders;
1871
+ return new Response(null, {
1872
+ status: 304,
1873
+ headers: notModifiedHeaders
1874
+ });
1875
+ }
1876
+ return new Response(document, { headers: responseHeaders });
1877
+ }
1753
1878
  function findDocsMarkdownPage(entry, pages, requestedPath) {
1754
1879
  const normalizedRequest = normalizeRequestedMarkdownPath(entry, requestedPath);
1755
1880
  for (const page of pages) if (normalizeDocsUrlPath(page.url) === normalizedRequest) return page;
@@ -1883,13 +2008,13 @@ function appendDocsAgentPublicRouteLines(lines, context, variant) {
1883
2008
  appendDocsMcpRouteLines(lines, context);
1884
2009
  }
1885
2010
  function renderDocsMarkdownDocument(page, options) {
1886
- if (page.agentRawContent !== void 0) return appendDocsMarkdownSitemapFooter(prependDocsMarkdownFrontmatter(page.agentRawContent, resolveDocsMarkdownPageMetadata(page, options)), options?.sitemap);
2011
+ if (page.agentRawContent !== void 0) return appendDocsMarkdownSitemapFooter(prependDocsMarkdownFrontmatter(upsertPageAgentContractMarkdown(page.agentRawContent, page.agent), resolveDocsMarkdownPageMetadata(page, options)), options?.sitemap);
1887
2012
  const relatedLines = renderDocsRelatedMarkdownLines(page.related);
1888
2013
  const lines = [`# ${page.title}`, `URL: ${page.url}`];
1889
2014
  if (shouldRenderLlmsDirective(options)) lines.push(DOCS_LLMS_TXT_DIRECTIVE_LINE);
1890
2015
  if (page.description) lines.push(`Description: ${page.description}`);
1891
2016
  lines.push(...relatedLines);
1892
- lines.push("", page.agentFallbackRawContent ?? page.rawContent ?? page.content);
2017
+ lines.push("", upsertPageAgentContractMarkdown(page.agentFallbackRawContent ?? page.rawContent ?? page.content, page.agent));
1893
2018
  return appendDocsMarkdownSitemapFooter(prependDocsMarkdownFrontmatter(lines.join("\n"), resolveDocsMarkdownPageMetadata(page, options)), options?.sitemap);
1894
2019
  }
1895
2020
  function renderDocsSkillDocument(options) {
@@ -1977,6 +2102,14 @@ function resolveDocsAgentMdxContent(content, audience) {
1977
2102
  }
1978
2103
  return output.join("\n").replace(/\n{3,}/g, "\n\n").trim();
1979
2104
  }
2105
+ /** Resolve only the task tools that the advertised MCP endpoint actually exposes. */
2106
+ function resolveDocsAgentContractMcpTools(mcp) {
2107
+ if (!mcp.enabled) return void 0;
2108
+ const tools = {};
2109
+ if (mcp.tools.listTasks !== false) tools.list = "list_tasks";
2110
+ if (mcp.tools.readTask !== false) tools.read = "read_task";
2111
+ return tools.list || tools.read ? tools : void 0;
2112
+ }
1980
2113
  function buildDocsAgentDiscoverySpec({ origin, entry = "docs", i18n = null, search, mcp, feedback, llms, sitemap, robots, openapi, markdown }) {
1981
2114
  const normalizedEntry = normalizeDocsPathSegment(entry) || "docs";
1982
2115
  const localesEnabled = i18n !== null;
@@ -1988,6 +2121,7 @@ function buildDocsAgentDiscoverySpec({ origin, entry = "docs", i18n = null, sear
1988
2121
  const sitemapConfig = resolveDocsSitemapConfig(sitemap, { baseUrl: llms?.baseUrl });
1989
2122
  const robotsEnabled = isRobotsDiscoveryEnabled(robots);
1990
2123
  const openapiConfig = resolveDocsOpenApiDiscoveryConfig(openapi);
2124
+ const agentContractMcpTools = resolveDocsAgentContractMcpTools(mcp);
1991
2125
  return {
1992
2126
  version: "1",
1993
2127
  name: "@farming-labs/docs",
@@ -2009,6 +2143,7 @@ function buildDocsAgentDiscoverySpec({ origin, entry = "docs", i18n = null, sear
2009
2143
  markdownRoutes: true,
2010
2144
  agentMdOverrides: true,
2011
2145
  agentBlocks: true,
2146
+ structuredAgentContracts: true,
2012
2147
  agents: true,
2013
2148
  llms: llmsEnabled,
2014
2149
  skills: true,
@@ -2052,6 +2187,33 @@ function buildDocsAgentDiscoverySpec({ origin, entry = "docs", i18n = null, sear
2052
2187
  "page markdown"
2053
2188
  ]
2054
2189
  },
2190
+ agentContract: {
2191
+ enabled: true,
2192
+ schemaVersion: "page-agent-contract.v1",
2193
+ source: "page-frontmatter",
2194
+ frontmatterPath: "agent",
2195
+ markdownSection: "Agent Contract",
2196
+ mcpField: "agent",
2197
+ ...agentContractMcpTools ? { mcpTools: agentContractMcpTools } : {},
2198
+ usefulContractFields: ["task", "outcome"],
2199
+ fields: {
2200
+ tokenBudget: "number",
2201
+ task: "string",
2202
+ outcome: "string",
2203
+ appliesTo: {
2204
+ framework: "string|string[]",
2205
+ version: "string|string[]",
2206
+ package: "string|string[]"
2207
+ },
2208
+ prerequisites: "string[]",
2209
+ files: "string[]",
2210
+ commands: "Array<string|{run,cwd?,description?}>",
2211
+ sideEffects: "string[]",
2212
+ verification: "Array<string|{description?,run?,expect?}>",
2213
+ rollback: "string[]",
2214
+ failureModes: "Array<string|{symptom,resolution?}>"
2215
+ }
2216
+ },
2055
2217
  llms: {
2056
2218
  enabled: llmsEnabled,
2057
2219
  defaultTxt: DEFAULT_LLMS_TXT_ROUTE,
@@ -2103,10 +2265,12 @@ function buildDocsAgentDiscoverySpec({ origin, entry = "docs", i18n = null, sear
2103
2265
  "description",
2104
2266
  "url",
2105
2267
  "dateModified",
2106
- "breadcrumb"
2268
+ "breadcrumb",
2269
+ "mainEntity"
2107
2270
  ],
2108
2271
  canonicalUrlField: "url",
2109
- breadcrumbType: "BreadcrumbList"
2272
+ breadcrumbType: "BreadcrumbList",
2273
+ agentContractType: "HowTo"
2110
2274
  },
2111
2275
  openapi: {
2112
2276
  enabled: openapiConfig.enabled,
@@ -2174,18 +2338,26 @@ function buildDocsAgentDiscoverySpec({ origin, entry = "docs", i18n = null, sear
2174
2338
  }
2175
2339
  };
2176
2340
  }
2177
- function acceptsMarkdown(request) {
2341
+ function acceptsDocsMarkdown(request) {
2178
2342
  const accept = request.headers.get("accept");
2179
2343
  if (!accept) return false;
2180
- return accept.split(",").map((value) => value.trim()).some((value) => {
2181
- const [mediaType, ...params] = value.split(";").map((part) => part.trim().toLowerCase());
2182
- if (mediaType !== "text/markdown") return false;
2344
+ const ranges = accept.split(",").map((value) => {
2345
+ const [rawMediaType = "", ...params] = value.split(";").map((part) => part.trim().toLowerCase());
2183
2346
  const qualityParam = params.find((param) => param.split("=", 1)[0]?.trim() === "q");
2184
- if (!qualityParam) return true;
2185
- const qualityValue = qualityParam.slice(qualityParam.indexOf("=") + 1).trim();
2186
- const quality = Number.parseFloat(qualityValue);
2187
- return Number.isFinite(quality) ? quality > 0 : true;
2347
+ const parsedQuality = qualityParam ? Number.parseFloat(qualityParam.slice(qualityParam.indexOf("=") + 1).trim()) : 1;
2348
+ return {
2349
+ mediaType: rawMediaType,
2350
+ quality: Number.isFinite(parsedQuality) ? Math.min(1, Math.max(0, parsedQuality)) : 0
2351
+ };
2188
2352
  });
2353
+ const qualityFor = (mediaType) => {
2354
+ const matches = ranges.filter((range) => range.mediaType === mediaType);
2355
+ return matches.length > 0 ? Math.max(...matches.map((range) => range.quality)) : void 0;
2356
+ };
2357
+ const markdownQuality = qualityFor("text/markdown");
2358
+ if (!markdownQuality || markdownQuality <= 0) return false;
2359
+ const htmlQuality = qualityFor("text/html") ?? qualityFor("text/*") ?? qualityFor("*/*");
2360
+ return htmlQuality === void 0 || htmlQuality <= markdownQuality;
2189
2361
  }
2190
2362
  function buildDocsUserAgentHeaderPattern(patterns) {
2191
2363
  return `.*(?:${patterns.map(toCaseInsensitiveHeaderPattern).join("|")}).*`;
@@ -2247,4 +2419,4 @@ function toYamlString(value) {
2247
2419
  }
2248
2420
 
2249
2421
  //#endregion
2250
- export { renderDocsAgentsDocument as $, buildDocsAgentDiscoverySpec as A, resolveDocsSitemapPageLastmod as At, hasDocsMarkdownSignatureAgent as B, DEFAULT_OPENAPI_SCHEMA_ROUTE as C, DEFAULT_SITEMAP_XML_ROUTE as Ct, DOCS_BOT_LIKE_USER_AGENT_HEADER_PATTERN as D, renderDocsSitemapMarkdown as Dt, DOCS_AI_AGENT_USER_AGENT_HEADER_PATTERN as E, readDocsSitemapManifestFromContentMap as Et, detectDocsMarkdownAgentRequest as F, isDocsLlmsTxtPublicRequest as G, isDocsAgentsRequest as H, findDocsMarkdownPage as I, isDocsSkillRequest as J, isDocsMcpRequest as K, getDocsLlmsTxtMaxCharsIssue as L, buildDocsConfigMap as M, toDocsSitemapMarkdownUrl as Mt, buildDocsDiagnostics as N, normalizeDocsRelated as Nt, DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER as O, renderDocsSitemapXml as Ot, buildDocsMcpEndpointCandidates as P, renderDocsRelatedMarkdownLines as Pt, parseDocsAgentFeedbackData as Q, getDocsMarkdownCanonicalLinkHeader as R, DEFAULT_MCP_WELL_KNOWN_ROUTE as S, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE as St, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE as T, createDocsSitemapResponse as Tt, isDocsConfigRequest as U, isDocsAgentDiscoveryRequest as V, isDocsDiagnosticsRequest as W, normalizeDocsPathSegment as X, matchesDocsLlmsTxtSection as Y, normalizeDocsUrlPath as Z, DEFAULT_LLMS_TXT_MAX_CHARS as _, toDocsMarkdownUrl as _t, DEFAULT_AGENT_MD_ROUTE as a, resolveDocsAgentFeedbackRequest as at, DEFAULT_MCP_PUBLIC_ROUTE as b, DEFAULT_SITEMAP_MD_DOCS_ROUTE as bt, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE as c, resolveDocsLlmsTxtFormat as ct, DEFAULT_DOCS_CONFIG_FORMAT as d, resolveDocsMarkdownCanonicalUrl as dt, renderDocsLlmsTxt as et, DEFAULT_DOCS_CONFIG_ROUTE as f, resolveDocsMarkdownRecovery as ft, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE as g, selectDocsLlmsTxtContent as gt, DEFAULT_LLMS_FULL_TXT_ROUTE as h, resolveDocsSkillFormat as ht, DEFAULT_AGENT_FEEDBACK_ROUTE as i, resolveDocsAgentFeedbackConfig as it, buildDocsAgentFeedbackSchema as j, resolveDocsSitemapRequest as jt, DOCS_TRADITIONAL_BOT_USER_AGENT_HEADER_PATTERN as k, resolveDocsSitemapConfig as kt, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE as l, resolveDocsLlmsTxtRequest as lt, DEFAULT_DOCS_DIAGNOSTICS_ROUTE as m, resolveDocsOpenApiDiscoveryConfig as mt, DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE as n, renderDocsMarkdownNotFound as nt, DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE as o, resolveDocsAgentMdxContent as ot, DEFAULT_DOCS_DIAGNOSTICS_FORMAT as p, resolveDocsMarkdownRequest as pt, isDocsPublicGetRequest as q, DEFAULT_AGENT_FEEDBACK_PAYLOAD_SCHEMA as r, renderDocsSkillDocument as rt, DEFAULT_AGENT_SPEC_ROUTE as s, resolveDocsAgentsFormat as st, DEFAULT_AGENTS_MD_ROUTE as t, renderDocsMarkdownDocument as tt, DEFAULT_DOCS_API_ROUTE as u, resolveDocsLlmsTxtSections as ut, DEFAULT_LLMS_TXT_ROUTE as v, validateDocsAgentFeedbackPayload as vt, DEFAULT_SKILL_MD_ROUTE as w, buildDocsSitemapManifest as wt, DEFAULT_MCP_ROUTE as x, DEFAULT_SITEMAP_MD_ROUTE as xt, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE as y, DEFAULT_SITEMAP_MANIFEST_PATH as yt, getDocsMarkdownVaryHeader as z };
2422
+ export { normalizeDocsUrlPath as $, acceptsDocsMarkdown as A, renderDocsSitemapMarkdown as At, getDocsMarkdownCanonicalLinkHeader as B, DEFAULT_OPENAPI_SCHEMA_ROUTE as C, DEFAULT_SITEMAP_MD_DOCS_ROUTE as Ct, DOCS_BOT_LIKE_USER_AGENT_HEADER_PATTERN as D, buildDocsSitemapManifest as Dt, DOCS_AI_AGENT_USER_AGENT_HEADER_PATTERN as E, DEFAULT_SITEMAP_XML_ROUTE as Et, buildDocsMcpEndpointCandidates as F, toDocsSitemapMarkdownUrl as Ft, isDocsConfigRequest as G, hasDocsMarkdownSignatureAgent as H, createDocsMarkdownResponse as I, normalizeDocsRelated as It, isDocsMcpRequest as J, isDocsDiagnosticsRequest as K, detectDocsMarkdownAgentRequest as L, renderDocsRelatedMarkdownLines as Lt, buildDocsAgentFeedbackSchema as M, resolveDocsSitemapConfig as Mt, buildDocsConfigMap as N, resolveDocsSitemapPageLastmod as Nt, DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER as O, createDocsSitemapResponse as Ot, buildDocsDiagnostics as P, resolveDocsSitemapRequest as Pt, normalizeDocsPathSegment as Q, findDocsMarkdownPage as R, DEFAULT_MCP_WELL_KNOWN_ROUTE as S, DEFAULT_SITEMAP_MANIFEST_PATH as St, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE as T, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE as Tt, isDocsAgentDiscoveryRequest as U, getDocsMarkdownVaryHeader as V, isDocsAgentsRequest as W, isDocsSkillRequest as X, isDocsPublicGetRequest as Y, matchesDocsLlmsTxtSection as Z, DEFAULT_LLMS_TXT_MAX_CHARS as _, resolveDocsOpenApiDiscoveryConfig as _t, DEFAULT_AGENT_MD_ROUTE as a, renderDocsSkillDocument as at, DEFAULT_MCP_PUBLIC_ROUTE as b, toDocsMarkdownUrl as bt, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE as c, resolveDocsAgentFeedbackRequest as ct, DEFAULT_DOCS_CONFIG_FORMAT as d, resolveDocsLlmsTxtFormat as dt, parseDocsAgentFeedbackData as et, DEFAULT_DOCS_CONFIG_ROUTE as f, resolveDocsLlmsTxtRequest as ft, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE as g, resolveDocsMarkdownRequest as gt, DEFAULT_LLMS_FULL_TXT_ROUTE as h, resolveDocsMarkdownRecovery as ht, DEFAULT_AGENT_FEEDBACK_ROUTE as i, renderDocsMarkdownNotFound as it, buildDocsAgentDiscoverySpec as j, renderDocsSitemapXml as jt, DOCS_TRADITIONAL_BOT_USER_AGENT_HEADER_PATTERN as k, readDocsSitemapManifestFromContentMap as kt, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE as l, resolveDocsAgentMdxContent as lt, DEFAULT_DOCS_DIAGNOSTICS_ROUTE as m, resolveDocsMarkdownCanonicalUrl as mt, DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE as n, renderDocsLlmsTxt as nt, DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE as o, resolveDocsAgentContractMcpTools as ot, DEFAULT_DOCS_DIAGNOSTICS_FORMAT as p, resolveDocsLlmsTxtSections as pt, isDocsLlmsTxtPublicRequest as q, DEFAULT_AGENT_FEEDBACK_PAYLOAD_SCHEMA as r, renderDocsMarkdownDocument as rt, DEFAULT_AGENT_SPEC_ROUTE as s, resolveDocsAgentFeedbackConfig as st, DEFAULT_AGENTS_MD_ROUTE as t, renderDocsAgentsDocument as tt, DEFAULT_DOCS_API_ROUTE as u, resolveDocsAgentsFormat as ut, DEFAULT_LLMS_TXT_ROUTE as v, resolveDocsSkillFormat as vt, DEFAULT_SKILL_MD_ROUTE as w, DEFAULT_SITEMAP_MD_ROUTE as wt, DEFAULT_MCP_ROUTE as x, validateDocsAgentFeedbackPayload as xt, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE as y, selectDocsLlmsTxtContent as yt, getDocsLlmsTxtMaxCharsIssue as z };