@farming-labs/docs 0.2.54 → 0.2.56

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 (28) hide show
  1. package/dist/{agent-BXvi0uhS.mjs → agent-3IpxY9F6.mjs} +3 -2
  2. package/dist/{agent-DXkXi-pS.mjs → agent-CxDzPqtl.mjs} +1121 -53
  3. package/dist/{agent-export-n-a0GbeU.mjs → agent-export-BtlITzt3.mjs} +10 -5
  4. package/dist/{agent-surface-drift-LS8zQgbq.mjs → agent-surface-drift-rGFS38Ak.mjs} +61 -63
  5. package/dist/{agents-BJaRQimo.mjs → agents-BguzxLhO.mjs} +3 -3
  6. package/dist/cli/index.mjs +14 -14
  7. package/dist/client/react.d.mts +1 -1
  8. package/dist/{cloud-ask-ai-466g6uAi.d.mts → cloud-ask-ai-CvRVnwdK.d.mts} +1 -1
  9. package/dist/docs-cloud-server.d.mts +2 -2
  10. package/dist/{doctor-CQpQ2zZm.mjs → doctor-Cra5qEEi.mjs} +11 -11
  11. package/dist/index.d.mts +12 -4
  12. package/dist/index.mjs +5 -5
  13. package/dist/{mcp-DnxZZWpY.mjs → mcp-BwYAu9DJ.mjs} +3 -3
  14. package/dist/mcp.d.mts +1 -1
  15. package/dist/mcp.mjs +17 -59
  16. package/dist/{reading-time-BrTd3DIh.mjs → reading-time-W_Id2ayC.mjs} +2 -2
  17. package/dist/{review-B6gyEFkD.mjs → review-x3zV5jZp.mjs} +14 -6
  18. package/dist/{robots-4BUJxlvV.mjs → robots-BSPfXA3J.mjs} +2 -2
  19. package/dist/{robots-DAptQnkx.mjs → robots-DRpoiYAV.mjs} +1 -1
  20. package/dist/{search-CfWvmVYA.d.mts → search-9uEaC23e.d.mts} +29 -4
  21. package/dist/{search-CJIC1Cqo.mjs → search-OHp36znm.mjs} +102 -42
  22. package/dist/{search-CbPm2x5g.mjs → search-vG59kGqo.mjs} +3 -3
  23. package/dist/server.d.mts +3 -3
  24. package/dist/server.mjs +3 -3
  25. package/dist/{sitemap-D6nP3J1Q.mjs → sitemap-DqxsKlvI.mjs} +3 -3
  26. package/dist/{sitemap-server-wsNLyVkb.mjs → sitemap-server-zFYctvCa.mjs} +1 -1
  27. package/dist/{types-BVgucdVm.d.mts → types-R-DN23yw.d.mts} +2 -1
  28. package/package.json +3 -2
@@ -1,6 +1,6 @@
1
- import "./agent-DXkXi-pS.mjs";
2
- import "./search-CJIC1Cqo.mjs";
3
- import "./sitemap-server-wsNLyVkb.mjs";
1
+ import "./agent-CxDzPqtl.mjs";
2
+ import "./search-OHp36znm.mjs";
3
+ import "./sitemap-server-zFYctvCa.mjs";
4
4
  import "./agent-evals-BD17jOqL.mjs";
5
5
  import { createFilesystemDocsMcpSource, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
6
6
  import "./code-blocks-C9awWzEQ.mjs";
package/dist/mcp.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Ft as DocsSearchSourcePage, Rt as DocsTelemetryConfig, T as DocsAnalyticsConfig, Ut as DocsTelemetryFramework, fn as PageAgentFrontmatter, kt as DocsSearchConfig, nt as DocsMcpAuthPrincipal, ot as DocsMcpConfig, pt as DocsObservabilityConfig, rt as DocsMcpAuthenticate, sn as OrderingItem, tt as DocsMcpAllowedOrigins } from "./types-BVgucdVm.mjs";
1
+ import { Ft as DocsSearchSourcePage, Rt as DocsTelemetryConfig, T as DocsAnalyticsConfig, Ut as DocsTelemetryFramework, fn as PageAgentFrontmatter, kt as DocsSearchConfig, nt as DocsMcpAuthPrincipal, ot as DocsMcpConfig, pt as DocsObservabilityConfig, rt as DocsMcpAuthenticate, sn as OrderingItem, tt as DocsMcpAllowedOrigins } from "./types-R-DN23yw.mjs";
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
 
4
4
  //#region src/mcp.d.ts
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as emitDocsAnalyticsEvent, i as emitDocsAgentTraceEvent, n as createDocsAgentTraceContext, r as createDocsAgentTraceId } from "./analytics-Bx44lg6d.mjs";
2
- import { Gt as hasStructuredPageAgentContract, Kt as normalizePageAgentFrontmatter, Lt as normalizeDocsRelated, Rt as renderDocsRelatedMarkdownLines, Xt as upsertPageAgentContractMarkdown } from "./agent-DXkXi-pS.mjs";
3
- import { C as resolvePageSidebarFolderIndexBehavior, E as emitDocsTelemetryAgentSurfaceEvent, O as emitDocsTelemetryMcpToolEvent, k as emitDocsTelemetryProjectEvent, m as parseDocsMarkdownSections, p as findDocsMarkdownSection, u as performDocsSearch, x as stripGeneratedAgentProvenance } from "./search-CJIC1Cqo.mjs";
2
+ import { Et as resolveDocsAudienceMdxContent, Ht as renderDocsRelatedMarkdownLines, Vt as normalizeDocsRelated, Xt as normalizePageAgentFrontmatter, Yt as hasStructuredPageAgentContract, en as upsertPageAgentContractMarkdown } from "./agent-CxDzPqtl.mjs";
3
+ import { C as resolvePageSidebarFolderIndexBehavior, E as emitDocsTelemetryAgentSurfaceEvent, O as emitDocsTelemetryMcpToolEvent, k as emitDocsTelemetryProjectEvent, m as parseDocsMarkdownSections, p as findDocsMarkdownSection, u as performDocsSearch, x as stripGeneratedAgentProvenance } from "./search-OHp36znm.mjs";
4
4
  import { a as normalizeAgentScopeValues, i as normalizeAgentLocale, n as agentVersionConstraintsOverlap, r as normalizeAgentFramework, t as agentVersionConstraintMatches } from "./agent-scope-B8lptqCd.mjs";
5
5
  import matter from "gray-matter";
6
6
  import fs from "node:fs";
@@ -1522,6 +1522,7 @@ async function createDocsMcpServer(options) {
1522
1522
  function trackMcpTool(tool, values) {
1523
1523
  emitDocsTelemetryMcpToolEvent(telemetryConfig, {
1524
1524
  framework: telemetryFramework,
1525
+ request: options.requestContext?.request,
1525
1526
  tool,
1526
1527
  locale: values?.locale,
1527
1528
  resultCount: values?.resultCount
@@ -2133,6 +2134,7 @@ async function createDocsMcpServer(options) {
2133
2134
  pages: toSearchSourcePages(dedupePages(await getSourcePages(locale))),
2134
2135
  query,
2135
2136
  search: toolSearchConfig ?? true,
2137
+ audience: "agent",
2136
2138
  locale,
2137
2139
  siteTitle: options.source.siteTitle,
2138
2140
  limit: resolvedLimit
@@ -2973,53 +2975,6 @@ function normalizePathSegment(value) {
2973
2975
  function titleize(value) {
2974
2976
  return value.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
2975
2977
  }
2976
- function resolveAgentMdxContent(content, audience) {
2977
- const lines = content.split("\n");
2978
- const output = [];
2979
- let fenceMarker = null;
2980
- let agentDepth = 0;
2981
- for (const line of lines) {
2982
- const trimmed = line.trim();
2983
- const fenceMatch = trimmed.match(/^(`{3,}|~{3,})/);
2984
- if (fenceMatch) {
2985
- if (!fenceMarker) fenceMarker = fenceMatch[1];
2986
- else if (trimmed.startsWith(fenceMarker)) fenceMarker = null;
2987
- if (audience === "agent" || agentDepth === 0) output.push(line);
2988
- continue;
2989
- }
2990
- if (!fenceMarker) {
2991
- if (/^<Agent(?:\s[^>]*)?\/>$/.test(trimmed)) continue;
2992
- const singleLineMatch = line.match(/^(\s*)<Agent(?:\s[^>]*)?>([\s\S]*?)<\/Agent>\s*$/);
2993
- if (singleLineMatch) {
2994
- if (audience === "agent" && singleLineMatch[2]) output.push(`${singleLineMatch[1]}${singleLineMatch[2]}`);
2995
- continue;
2996
- }
2997
- if (line.match(/^(\s*)<Agent(?:\s[^>]*)?>\s*$/)) {
2998
- agentDepth += 1;
2999
- continue;
3000
- }
3001
- const openWithContentMatch = line.match(/^(\s*)<Agent(?:\s[^>]*)?>(.*)$/);
3002
- if (openWithContentMatch) {
3003
- agentDepth += 1;
3004
- if (audience === "agent" && openWithContentMatch[2]) output.push(`${openWithContentMatch[1]}${openWithContentMatch[2]}`);
3005
- continue;
3006
- }
3007
- const closeWithContentMatch = line.match(/^(.*)<\/Agent>\s*$/);
3008
- if (closeWithContentMatch && agentDepth > 0) {
3009
- if (audience === "agent" && closeWithContentMatch[1]) output.push(closeWithContentMatch[1]);
3010
- agentDepth = Math.max(0, agentDepth - 1);
3011
- continue;
3012
- }
3013
- if (/^<\/Agent>\s*$/.test(trimmed) && agentDepth > 0) {
3014
- agentDepth = Math.max(0, agentDepth - 1);
3015
- continue;
3016
- }
3017
- }
3018
- if (agentDepth > 0 && audience === "human") continue;
3019
- output.push(line);
3020
- }
3021
- return output.join("\n").replace(/\n{3,}/g, "\n\n").trim();
3022
- }
3023
2978
  function stripMarkdownForMcp(content) {
3024
2979
  return content.replace(/^(import|export)\s.*$/gm, "").replace(/<[^>]+\/>/g, "").replace(/<\/?[A-Z][^>]*>/g, "").replace(/<\/?[a-z][^>]*>/g, "").replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/^#{1,6}\s+/gm, "").replace(/(\*{1,3}|_{1,3})(.*?)\1/g, "$2").replace(/```[\s\S]*?```/g, "").replace(/`([^`]+)`/g, "$1").replace(/^>\s+/gm, "").replace(/^[-*_]{3,}\s*$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
3025
2980
  }
@@ -3074,8 +3029,8 @@ function scanFilesystemDocsPages(contentDirAbs, entry, rootDir) {
3074
3029
  const baseName = name.replace(/\.(md|mdx|svx)$/, "");
3075
3030
  const isIndex = baseName === "index" || baseName === "page" || baseName === "+page";
3076
3031
  if (isIndex && resolvePageSidebarFolderIndexBehavior(data.sidebar) === "hidden" && hasVisibleDescendantFilesystemDocsPage(dir)) continue;
3077
- const humanRawContent = resolveAgentMdxContent(content, "human");
3078
- const pageAgentRawContent = resolveAgentMdxContent(content, "agent");
3032
+ const humanRawContent = resolveDocsAudienceMdxContent(content, "human");
3033
+ const pageAgentRawContent = resolveDocsAudienceMdxContent(content, "agent");
3079
3034
  const pageAgentContent = pageAgentRawContent !== humanRawContent ? stripMarkdownForMcp(pageAgentRawContent) : void 0;
3080
3035
  const slug = isIndex ? slugParts.join("/") : [...slugParts, baseName].join("/");
3081
3036
  const url = slug ? `/${entry}/${slug}` : `/${entry}`;
@@ -3111,9 +3066,10 @@ function readFilesystemAgentDoc(dir) {
3111
3066
  const agentPath = path.join(dir, "agent.md");
3112
3067
  if (!fs.existsSync(agentPath)) return void 0;
3113
3068
  const { content } = matter(stripGeneratedAgentProvenance(fs.readFileSync(agentPath, "utf-8")));
3069
+ const agentContent = resolveDocsAudienceMdxContent(content, "agent");
3114
3070
  return {
3115
- agentContent: stripMarkdownForMcp(content),
3116
- agentRawContent: content
3071
+ agentContent: stripMarkdownForMcp(agentContent),
3072
+ agentRawContent: agentContent
3117
3073
  };
3118
3074
  }
3119
3075
  function resolveRelatedForMcpPages(pages) {
@@ -3232,8 +3188,8 @@ function toSearchSourcePages(pages) {
3232
3188
  return pages.map((page) => ({
3233
3189
  title: page.title,
3234
3190
  url: page.url,
3235
- content: page.agentContent ?? page.agentFallbackContent ?? page.content,
3236
- rawContent: page.agentRawContent ?? page.agentFallbackRawContent ?? page.rawContent,
3191
+ content: page.content,
3192
+ rawContent: page.rawContent,
3237
3193
  sourcePath: page.sourcePath,
3238
3194
  lastModified: page.lastModified,
3239
3195
  locale: page.locale,
@@ -3572,7 +3528,7 @@ function countDocsSections(sections) {
3572
3528
  return sections.reduce((total, section) => total + 1 + countDocsSections(section.sections), 0);
3573
3529
  }
3574
3530
  function extractDocsMcpCodeExamples(page) {
3575
- const source = page.agentRawContent ?? page.agentFallbackRawContent ?? page.rawContent;
3531
+ const source = page.agentRawContent ?? page.agentFallbackRawContent ?? page.agentContent ?? page.agentFallbackContent ?? page.rawContent ?? page.content;
3576
3532
  if (!source) return [];
3577
3533
  const examples = [];
3578
3534
  const lines = source.split("\n");
@@ -3795,7 +3751,7 @@ function toStructuredDocsMcpPage(page) {
3795
3751
  };
3796
3752
  }
3797
3753
  function getDocsMcpSourceMarkdown(page) {
3798
- return page.agentRawContent ?? page.agentFallbackRawContent ?? page.rawContent ?? page.agentContent ?? page.agentFallbackContent ?? page.content;
3754
+ return page.agentRawContent ?? page.agentFallbackRawContent ?? page.agentContent ?? page.agentFallbackContent ?? page.rawContent ?? page.content;
3799
3755
  }
3800
3756
  function resolveDocsMcpScopeField(pageValue, contractValue, filter, overlaps, matchesFilter) {
3801
3757
  const pageValues = normalizeAgentScopeValues(pageValue);
@@ -3859,6 +3815,7 @@ async function buildDocsMcpContext(options) {
3859
3815
  maxResults: 50,
3860
3816
  chunking: { strategy: "section" }
3861
3817
  },
3818
+ audience: "agent",
3862
3819
  locale: options.locale,
3863
3820
  siteTitle: options.siteTitle,
3864
3821
  limit: 50
@@ -3998,12 +3955,13 @@ function normalizeUrlPath(value) {
3998
3955
  return normalized.replace(/\/+$/, "");
3999
3956
  }
4000
3957
  function renderPageDocument(page) {
4001
- if (page.agentRawContent !== void 0) return upsertPageAgentContractMarkdown(page.agentRawContent, page.agent);
3958
+ const explicitAgentContent = page.agentRawContent ?? page.agentContent;
3959
+ if (explicitAgentContent !== void 0) return upsertPageAgentContractMarkdown(explicitAgentContent, page.agent);
4002
3960
  const relatedLines = renderDocsRelatedMarkdownLines(page.related);
4003
3961
  const lines = [`# ${page.title}`, `URL: ${page.url}`];
4004
3962
  if (page.description) lines.push(`Description: ${page.description}`);
4005
3963
  lines.push(...relatedLines);
4006
- lines.push("", upsertPageAgentContractMarkdown(page.agentFallbackRawContent ?? page.rawContent ?? page.content, page.agent));
3964
+ lines.push("", upsertPageAgentContractMarkdown(page.agentFallbackRawContent ?? page.agentFallbackContent ?? page.rawContent ?? page.content, page.agent));
4007
3965
  return lines.join("\n");
4008
3966
  }
4009
3967
  function renderNavigationTree(tree) {
@@ -1,5 +1,5 @@
1
- import { Dt as DEFAULT_SITEMAP_XML_ROUTE, Gt as hasStructuredPageAgentContract, Kt as normalizePageAgentFrontmatter, S as DEFAULT_MCP_WELL_KNOWN_ROUTE, Tt as DEFAULT_SITEMAP_MD_ROUTE, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, f as DEFAULT_DOCS_CONFIG_ROUTE, h as DEFAULT_LLMS_FULL_TXT_ROUTE, i as DEFAULT_AGENT_FEEDBACK_ROUTE, m as DEFAULT_DOCS_DIAGNOSTICS_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, w as DEFAULT_SKILL_MD_ROUTE } from "./agent-DXkXi-pS.mjs";
2
- import { n as DEFAULT_ROBOTS_TXT_ROUTE } from "./robots-DAptQnkx.mjs";
1
+ import { S as DEFAULT_MCP_WELL_KNOWN_ROUTE, Xt as normalizePageAgentFrontmatter, Yt as hasStructuredPageAgentContract, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, f as DEFAULT_DOCS_CONFIG_ROUTE, h as DEFAULT_LLMS_FULL_TXT_ROUTE, i as DEFAULT_AGENT_FEEDBACK_ROUTE, jt as DEFAULT_SITEMAP_XML_ROUTE, kt as DEFAULT_SITEMAP_MD_ROUTE, m as DEFAULT_DOCS_DIAGNOSTICS_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, w as DEFAULT_SKILL_MD_ROUTE } from "./agent-CxDzPqtl.mjs";
2
+ import { n as DEFAULT_ROBOTS_TXT_ROUTE } from "./robots-DRpoiYAV.mjs";
3
3
  import matter from "gray-matter";
4
4
 
5
5
  //#region src/define-docs.ts
@@ -1,11 +1,11 @@
1
- import { Bt as PAGE_AGENT_CONTRACT_FIELDS, Gt as hasStructuredPageAgentContract, Kt as normalizePageAgentFrontmatter, M as buildDocsAgentDiscoverySpec, O as DOCS_CONFIG_MAP_TOP_LEVEL_KEYS, P as buildDocsConfigMap, Wt as getPageAgentFrontmatterIssues, f as DEFAULT_DOCS_CONFIG_ROUTE, u as DEFAULT_DOCS_API_ROUTE } from "./agent-DXkXi-pS.mjs";
2
- import "./search-CJIC1Cqo.mjs";
1
+ import { Jt as getPageAgentFrontmatterIssues, M as buildDocsAgentDiscoverySpec, O as DOCS_CONFIG_MAP_TOP_LEVEL_KEYS, P as buildDocsConfigMap, St as findDocsAudienceMdxIssues, Wt as PAGE_AGENT_CONTRACT_FIELDS, Xt as normalizePageAgentFrontmatter, Yt as hasStructuredPageAgentContract, f as DEFAULT_DOCS_CONFIG_ROUTE, u as DEFAULT_DOCS_API_ROUTE } from "./agent-CxDzPqtl.mjs";
2
+ import "./search-OHp36znm.mjs";
3
3
  import { c as resolveDocsReviewConfig, o as ensureDocsReviewWorkflow, s as readDocsReviewConfigFromSource, t as runDocsGoldenTasks } from "./agent-evals-BD17jOqL.mjs";
4
4
  import { createFilesystemDocsMcpSource, getDocsConfigSchema, resolveDocsMcpConfig } from "./mcp.mjs";
5
5
  import "./code-blocks-C9awWzEQ.mjs";
6
6
  import { a as loadDocsConfigModuleResultWithProjectEnv, h as resolveDocsContentDir, m as resolveDocsConfigPath, p as readTopLevelStringProperty } from "./config-CydaZ5PB.mjs";
7
7
  import { t as detectFramework } from "./utils-DBCCkkJS.mjs";
8
- import { n as analyzeAgentUsefulness, r as createAgentUsefulnessPagesFromMcp, t as analyzeAgentSurfaceDrift } from "./agent-surface-drift-LS8zQgbq.mjs";
8
+ import { i as extractAgentBlocks, n as analyzeAgentUsefulness, r as createAgentUsefulnessPagesFromMcp, t as analyzeAgentSurfaceDrift } from "./agent-surface-drift-rGFS38Ak.mjs";
9
9
  import matter from "gray-matter";
10
10
  import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
11
11
  import path from "node:path";
@@ -415,6 +415,14 @@ function checkCodeFences(findings, review, options) {
415
415
  }
416
416
  }
417
417
  function checkAgentContext(findings, review, options) {
418
+ for (const issue of findDocsAudienceMdxIssues(options.source)) pushFinding(findings, review, {
419
+ rule: "agentContext",
420
+ code: `audience-${issue.code}`,
421
+ severity: issue.code === "dynamic-only" ? "error" : "warn",
422
+ file: options.file,
423
+ line: lineForIndex(options.source, issue.index),
424
+ message: issue.message
425
+ });
418
426
  for (const issue of getPageAgentFrontmatterIssues(options.agent)) pushFinding(findings, review, {
419
427
  rule: "agentContext",
420
428
  severity: "warn",
@@ -448,7 +456,7 @@ function checkAgentContext(findings, review, options) {
448
456
  });
449
457
  if (agent?.task && agent.outcome) return;
450
458
  }
451
- if (options.source.includes("<Agent>") || options.source.includes("</Agent>")) return;
459
+ if (extractAgentBlocks(options.source, { sourcePath: options.file }).length > 0) return;
452
460
  if (existsSync(path.join(path.dirname(path.join(options.rootDir, options.file)), "agent.md"))) return;
453
461
  if (!/\b(install|configure|setup|implement|defineDocs|docs\.config|MCP|agent)\b/i.test(options.source)) return;
454
462
  pushFinding(findings, review, {
@@ -456,7 +464,7 @@ function checkAgentContext(findings, review, options) {
456
464
  severity: "suggestion",
457
465
  file: options.file,
458
466
  line: 1,
459
- message: "Implementation-heavy docs page could use an <Agent> block or sibling agent.md."
467
+ message: "Implementation-heavy docs page could use an <Agent> block, <Audience only=\"agent\"> block, or sibling agent.md."
460
468
  });
461
469
  }
462
470
  function pushFinding(findings, review, finding) {
@@ -486,7 +494,7 @@ function printReviewReport(report) {
486
494
  console.log(`Changed files: ${report.changedFiles.length}`);
487
495
  console.log(`Reviewed docs files: ${report.reviewedFiles.length}`);
488
496
  console.log(`Findings: ${counts.error} error${counts.error === 1 ? "" : "s"}, ${counts.warn} warning${counts.warn === 1 ? "" : "s"}, ${counts.suggestion} suggestion${counts.suggestion === 1 ? "" : "s"}`);
489
- if (report.usefulness) console.log(`Useful Agent blocks: ${report.usefulness.agentBlocks.useful}/${report.usefulness.agentBlocks.total}; task-complete pages: ${report.usefulness.taskCompleteness.completePages}/${report.usefulness.actionablePages}`);
497
+ if (report.usefulness) console.log(`Useful agent-only blocks: ${report.usefulness.agentBlocks.useful}/${report.usefulness.agentBlocks.total}; task-complete pages: ${report.usefulness.taskCompleteness.completePages}/${report.usefulness.actionablePages}`);
490
498
  if (report.evaluations) console.log(`Golden tasks: ${report.evaluations.status === "unmeasured" ? "unmeasured" : `${report.evaluations.passedTaskCount}/${report.evaluations.taskCount} passed (${report.evaluations.score}/100)`}`);
491
499
  if (report.reviewedFiles.length === 0 && report.findings.length === 0) {
492
500
  console.log("");
@@ -1,5 +1,5 @@
1
- import "./agent-DXkXi-pS.mjs";
2
- import { c as renderDocsRobotsGeneratedBlock, f as upsertDocsRobotsGeneratedBlock, i as DOCS_ROBOTS_GENERATED_BLOCK_START, r as DOCS_ROBOTS_GENERATED_BLOCK_END, u as resolveDocsRobotsConfig } from "./robots-DAptQnkx.mjs";
1
+ import "./agent-CxDzPqtl.mjs";
2
+ import { c as renderDocsRobotsGeneratedBlock, f as upsertDocsRobotsGeneratedBlock, i as DOCS_ROBOTS_GENERATED_BLOCK_START, r as DOCS_ROBOTS_GENERATED_BLOCK_END, u as resolveDocsRobotsConfig } from "./robots-DRpoiYAV.mjs";
3
3
  import { d as readStringProperty, i as loadDocsConfigModule, m as resolveDocsConfigPath, p as readTopLevelStringProperty, s as readBooleanProperty, t as extractNestedObjectLiteral } from "./config-CydaZ5PB.mjs";
4
4
  import { t as detectFramework } from "./utils-DBCCkkJS.mjs";
5
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { $ as normalizeDocsPathSegment, Nt as resolveDocsSitemapConfig, S as DEFAULT_MCP_WELL_KNOWN_ROUTE, T as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, a as DEFAULT_AGENT_MD_ROUTE, b as DEFAULT_MCP_PUBLIC_ROUTE, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, g as DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, h as DEFAULT_LLMS_FULL_TXT_ROUTE, l as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, w as DEFAULT_SKILL_MD_ROUTE, y as DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE } from "./agent-DXkXi-pS.mjs";
1
+ import { $ as normalizeDocsPathSegment, Lt as resolveDocsSitemapConfig, S as DEFAULT_MCP_WELL_KNOWN_ROUTE, T as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, a as DEFAULT_AGENT_MD_ROUTE, b as DEFAULT_MCP_PUBLIC_ROUTE, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, g as DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, h as DEFAULT_LLMS_FULL_TXT_ROUTE, l as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, w as DEFAULT_SKILL_MD_ROUTE, y as DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE } from "./agent-CxDzPqtl.mjs";
2
2
 
3
3
  //#region src/robots.ts
4
4
  const DEFAULT_ROBOTS_TXT_ROUTE = "/robots.txt";
@@ -1,4 +1,4 @@
1
- import { $t as McpDocsSearchConfig, An as TypesenseDocsSearchConfig, At as DocsSearchDocument, D as DocsAnalyticsEventInput, Dt as DocsSearchAdapterFactory, E as DocsAnalyticsEvent, Ft as DocsSearchSourcePage, It as DocsSitemapConfig, L as DocsAskAIMcpConfig, Nt as DocsSearchResult, Ot as DocsSearchChunkingConfig, S as DocsAgentTraceEventInput, T as DocsAnalyticsConfig, Tt as DocsSearchAdapter, an as OpenDocsTarget, bn as ResolvedDocsRelatedLink, f as CustomDocsSearchConfig, ht as DocsObservabilityEventInput, kt as DocsSearchConfig, mt as DocsObservabilityEvent, nn as OpenDocsProvider, pt as DocsObservabilityConfig, r as AlgoliaDocsSearchConfig } from "./types-BVgucdVm.mjs";
1
+ import { $t as McpDocsSearchConfig, An as TypesenseDocsSearchConfig, At as DocsSearchDocument, D as DocsAnalyticsEventInput, Dt as DocsSearchAdapterFactory, E as DocsAnalyticsEvent, Ft as DocsSearchSourcePage, It as DocsSitemapConfig, L as DocsAskAIMcpConfig, Nt as DocsSearchResult, Ot as DocsSearchChunkingConfig, S as DocsAgentTraceEventInput, T as DocsAnalyticsConfig, Tt as DocsSearchAdapter, an as OpenDocsTarget, bn as ResolvedDocsRelatedLink, f as CustomDocsSearchConfig, ht as DocsObservabilityEventInput, kt as DocsSearchConfig, mt as DocsObservabilityEvent, nn as OpenDocsProvider, pt as DocsObservabilityConfig, r as AlgoliaDocsSearchConfig } from "./types-R-DN23yw.mjs";
2
2
 
3
3
  //#region src/analytics.d.ts
4
4
  declare const DOCS_AGENT_TRACE_EVENT_TYPES: readonly ["run.start", "run.end", "run.error", "user.input", "prompt.build", "retrieval.query", "retrieval.result", "retrieval.error", "model.call", "model.response", "model.stream", "model.error", "tool.call", "tool.result", "tool.error", "retry", "timeout", "error", "agent.final"];
@@ -29,6 +29,30 @@ declare function emitDocsAnalyticsEvent(analytics: boolean | DocsAnalyticsConfig
29
29
  declare function emitDocsObservabilityEvent(observability: boolean | DocsObservabilityConfig | undefined, event: DocsObservabilityEventInput): Promise<void>;
30
30
  declare function emitDocsAgentTraceEvent(observability: boolean | DocsObservabilityConfig | undefined, event: DocsAgentTraceEventInput): Promise<void>;
31
31
  //#endregion
32
+ //#region src/audience.d.ts
33
+ /** The two content projections emitted by the docs framework. */
34
+ type DocsContentAudience = "human" | "agent";
35
+ /** Resolve whether content with an optional audience restriction is visible. */
36
+ declare function resolveDocsAudienceExposure(only: unknown, audience: DocsContentAudience): boolean;
37
+ interface DocsAudienceMdxIssue {
38
+ code: "missing-only" | "invalid-only" | "dynamic-only" | "ignored-agent-only" | "ignored-human-only";
39
+ index: number;
40
+ message: string;
41
+ }
42
+ /** Find audience declarations that cannot be projected consistently at build time. */
43
+ declare function findDocsAudienceMdxIssues(content: string): DocsAudienceMdxIssue[];
44
+ /**
45
+ * Resolve MDX into its human or agent projection.
46
+ *
47
+ * `<Agent>` is shorthand for `<Audience only="agent">`, while `<Human>` is
48
+ * shorthand for `<Audience only="human">`. Unknown `Audience.only` values are
49
+ * treated as shared content so an authoring typo never silently deletes content.
50
+ * These primitives shape content for each surface; they are not an access-control boundary.
51
+ */
52
+ declare function resolveDocsAudienceMdxContent(content: string, audience: DocsContentAudience): string;
53
+ /** Backwards-compatible name retained for existing integrations. */
54
+ declare function resolveDocsAgentMdxContent(content: string, audience: DocsContentAudience): string;
55
+ //#endregion
32
56
  //#region src/prompt-utils.d.ts
33
57
  type PromptAction = "copy" | "open";
34
58
  interface SerializedOpenDocsProvider {
@@ -185,7 +209,7 @@ interface DocsAskAIPackageHints {
185
209
  }
186
210
  declare function inferDocsAskAIPackageHints(content: string): DocsAskAIPackageHints;
187
211
  declare function formatDocsAskAIPackageHints(hints: DocsAskAIPackageHints, packageName?: string): string | undefined;
188
- declare function buildDocsSearchDocuments(pages: DocsSearchSourcePage[], chunking?: DocsSearchChunkingConfig): DocsSearchDocument[];
212
+ declare function buildDocsSearchDocuments(pages: DocsSearchSourcePage[], chunking?: DocsSearchChunkingConfig, audience?: DocsContentAudience): DocsSearchDocument[];
189
213
  declare function createSimpleSearchAdapter(): DocsSearchAdapter;
190
214
  declare function createTypesenseSearchAdapter(config: TypesenseDocsSearchConfig): DocsSearchAdapter;
191
215
  declare function resolveSearchRequestConfig(search: boolean | DocsSearchConfig | undefined, requestUrl?: string): boolean | DocsSearchConfig | undefined;
@@ -202,7 +226,8 @@ declare function createAlgoliaSearchAdapter(config: AlgoliaDocsSearchConfig): Do
202
226
  declare function performDocsSearch(options: {
203
227
  pages: DocsSearchSourcePage[];
204
228
  query: string;
205
- search?: boolean | DocsSearchConfig;
229
+ search?: boolean | DocsSearchConfig; /** Selects which audience projection is searchable. Public site search defaults to human. */
230
+ audience?: DocsContentAudience;
206
231
  locale?: string;
207
232
  pathname?: string;
208
233
  siteTitle?: string;
@@ -222,4 +247,4 @@ declare function buildDocsAskAIContext(options: {
222
247
  }): Promise<DocsAskAIContext>;
223
248
  declare function createCustomSearchAdapter(adapter: DocsSearchAdapter | DocsSearchAdapterFactory): CustomDocsSearchConfig;
224
249
  //#endregion
225
- export { createDocsAgentTraceId as $, resolveDocsSitemapRequest as A, normalizePromptProviderName as B, buildDocsSitemapManifest as C, renderDocsSitemapXml as D, renderDocsSitemapMarkdown as E, DEFAULT_PROMPT_PROVIDER_TEMPLATES as F, serializeDocsIconRegistry as G, resolvePromptProviderChoices as H, PromptAction as I, DOCS_AGENT_TRACE_EVENT_TYPES as J, serializeOpenDocsProvider as K, PromptProviderChoice as L, DEFAULT_OPEN_DOCS_PROMPT as M, DEFAULT_OPEN_DOCS_PROVIDER_IDS as N, resolveDocsSitemapConfig as O, DEFAULT_OPEN_DOCS_TARGET as P, createDocsAgentTraceContext as Q, SerializeOpenDocsProviderOptions as R, DocsSitemapResolvedConfig as S, readDocsSitemapManifestFromContentMap as T, sanitizePromptText as U, parsePromptStringArray as V, serializeDocsIcon as W, ResolvedDocsAnalyticsConfig as X, DocsAgentTraceContext as Y, ResolvedDocsObservabilityConfig as Z, DEFAULT_SITEMAP_XML_ROUTE as _, createMcpSearchAdapter as a, resolveDocsObservabilityConfig as at, DocsSitemapManifestPage as b, formatDocsAskAIPackageHints as c, resolveAskAISearchRequestConfig as d, emitDocsAgentTraceEvent as et, resolveSearchRequestConfig as f, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE as g, DEFAULT_SITEMAP_MD_ROUTE as h, createCustomSearchAdapter as i, resolveDocsAnalyticsConfig as it, toDocsSitemapMarkdownUrl as j, resolveDocsSitemapPageLastmod as k, inferDocsAskAIPackageHints as l, DEFAULT_SITEMAP_MD_DOCS_ROUTE as m, buildDocsSearchDocuments as n, emitDocsObservabilityEvent as nt, createSimpleSearchAdapter as o, DEFAULT_SITEMAP_MANIFEST_PATH as p, serializeOpenDocsProviders as q, createAlgoliaSearchAdapter as r, getDocsRequestAnalyticsProperties as rt, createTypesenseSearchAdapter as s, buildDocsAskAIContext as t, emitDocsAnalyticsEvent as tt, performDocsSearch as u, DocsSitemapFormat as v, createDocsSitemapResponse as w, DocsSitemapPageInput as x, DocsSitemapManifest as y, SerializedOpenDocsProvider as z };
250
+ export { resolveDocsAudienceMdxContent as $, resolveDocsSitemapRequest as A, normalizePromptProviderName as B, buildDocsSitemapManifest as C, renderDocsSitemapXml as D, renderDocsSitemapMarkdown as E, DEFAULT_PROMPT_PROVIDER_TEMPLATES as F, serializeDocsIconRegistry as G, resolvePromptProviderChoices as H, PromptAction as I, DocsAudienceMdxIssue as J, serializeOpenDocsProvider as K, PromptProviderChoice as L, DEFAULT_OPEN_DOCS_PROMPT as M, DEFAULT_OPEN_DOCS_PROVIDER_IDS as N, resolveDocsSitemapConfig as O, DEFAULT_OPEN_DOCS_TARGET as P, resolveDocsAudienceExposure as Q, SerializeOpenDocsProviderOptions as R, DocsSitemapResolvedConfig as S, readDocsSitemapManifestFromContentMap as T, sanitizePromptText as U, parsePromptStringArray as V, serializeDocsIcon as W, findDocsAudienceMdxIssues as X, DocsContentAudience as Y, resolveDocsAgentMdxContent as Z, DEFAULT_SITEMAP_XML_ROUTE as _, createMcpSearchAdapter as a, createDocsAgentTraceId as at, DocsSitemapManifestPage as b, formatDocsAskAIPackageHints as c, emitDocsObservabilityEvent as ct, resolveAskAISearchRequestConfig as d, resolveDocsObservabilityConfig as dt, DOCS_AGENT_TRACE_EVENT_TYPES as et, resolveSearchRequestConfig as f, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE as g, DEFAULT_SITEMAP_MD_ROUTE as h, createCustomSearchAdapter as i, createDocsAgentTraceContext as it, toDocsSitemapMarkdownUrl as j, resolveDocsSitemapPageLastmod as k, inferDocsAskAIPackageHints as l, getDocsRequestAnalyticsProperties as lt, DEFAULT_SITEMAP_MD_DOCS_ROUTE as m, buildDocsSearchDocuments as n, ResolvedDocsAnalyticsConfig as nt, createSimpleSearchAdapter as o, emitDocsAgentTraceEvent as ot, DEFAULT_SITEMAP_MANIFEST_PATH as p, serializeOpenDocsProviders as q, createAlgoliaSearchAdapter as r, ResolvedDocsObservabilityConfig as rt, createTypesenseSearchAdapter as s, emitDocsAnalyticsEvent as st, buildDocsAskAIContext as t, DocsAgentTraceContext as tt, performDocsSearch as u, resolveDocsAnalyticsConfig as ut, DocsSitemapFormat as v, createDocsSitemapResponse as w, DocsSitemapPageInput as x, DocsSitemapManifest as y, SerializedOpenDocsProvider as z };
@@ -1,4 +1,4 @@
1
- import { G as isDocsAgentsRequest, Ht as PAGE_AGENT_CONTRACT_START_MARKER, W as isDocsAgentDiscoveryRequest, Xt as upsertPageAgentContractMarkdown, Z as isDocsSkillRequest, _t as resolveDocsMarkdownRequest, ct as resolveDocsAgentFeedbackConfig, dt as resolveDocsAgentsFormat, lt as resolveDocsAgentFeedbackRequest, pt as resolveDocsLlmsTxtRequest, qt as renderPageAgentContractMarkdown, yt as resolveDocsSkillFormat, zt as PAGE_AGENT_CONTRACT_END_MARKER } from "./agent-DXkXi-pS.mjs";
1
+ import { G as isDocsAgentsRequest, Kt as PAGE_AGENT_CONTRACT_START_MARKER, Ut as PAGE_AGENT_CONTRACT_END_MARKER, W as isDocsAgentDiscoveryRequest, Z as isDocsSkillRequest, Zt as renderPageAgentContractMarkdown, ct as resolveDocsAgentFeedbackConfig, en as upsertPageAgentContractMarkdown, ft as resolveDocsLlmsTxtRequest, gt as resolveDocsMarkdownRequest, lt as resolveDocsAgentFeedbackRequest, ut as resolveDocsAgentsFormat, vt as resolveDocsSkillFormat } from "./agent-CxDzPqtl.mjs";
2
2
 
3
3
  //#region src/telemetry.ts
4
4
  const DOCS_PACKAGE_NAME = "@farming-labs/docs";
@@ -53,15 +53,42 @@ function readRequestOrigin(request) {
53
53
  return;
54
54
  }
55
55
  }
56
- function normalizeTelemetryOrigin(candidate) {
57
- if (!candidate) return void 0;
56
+ /** Normalize an HTTP(S) telemetry site value to its origin. */
57
+ function normalizeDocsTelemetryOrigin(candidate) {
58
+ if (typeof candidate !== "string") return void 0;
59
+ const trimmed = candidate.trim();
60
+ if (!trimmed) return void 0;
58
61
  try {
59
- const withProtocol = /^https?:\/\//i.test(candidate) ? candidate : `https://${candidate}`;
60
- return new URL(withProtocol).origin;
62
+ const hasScheme = /^[a-z][a-z\d+.-]*:(?!\d)/i.test(trimmed);
63
+ const url = new URL(hasScheme ? trimmed : `https://${trimmed}`);
64
+ if (url.protocol !== "http:" && url.protocol !== "https:") return void 0;
65
+ return url.origin;
61
66
  } catch {
62
67
  return;
63
68
  }
64
69
  }
70
+ /** Return whether a telemetry origin points at a local development server. */
71
+ function isLocalDocsTelemetryOrigin(candidate) {
72
+ const origin = normalizeDocsTelemetryOrigin(candidate);
73
+ if (!origin) return false;
74
+ const hostname = new URL(origin).hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.+$/, "");
75
+ if ([
76
+ "localhost",
77
+ "localhost.localdomain",
78
+ "localhost6",
79
+ "localhost6.localdomain6",
80
+ "ip6-localhost",
81
+ "ip6-loopback"
82
+ ].includes(hostname) || hostname.endsWith(".localhost")) return true;
83
+ if (hostname === "::" || hostname === "::1") return true;
84
+ const ipv4 = hostname.split(".").map((part) => Number(part));
85
+ if (ipv4.length === 4 && ipv4.every((part) => Number.isInteger(part) && part >= 0 && part <= 255)) return ipv4[0] === 127 || ipv4.every((part) => part === 0);
86
+ return /^::ffff:7f[0-9a-f]{2}:/.test(hostname) || hostname === "::ffff:0:0";
87
+ }
88
+ function isBlockedDocsTelemetryOrigin(candidate) {
89
+ if (candidate === void 0) return false;
90
+ return !normalizeDocsTelemetryOrigin(candidate) || isLocalDocsTelemetryOrigin(candidate);
91
+ }
65
92
  function readDeploymentOrigin() {
66
93
  const candidates = [
67
94
  readRuntimeEnv("DOCS_SITE_URL"),
@@ -75,7 +102,7 @@ function readDeploymentOrigin() {
75
102
  readRuntimeEnv("DEPLOY_PRIME_URL")
76
103
  ];
77
104
  for (const candidate of candidates) {
78
- const origin = normalizeTelemetryOrigin(candidate);
105
+ const origin = normalizeDocsTelemetryOrigin(candidate);
79
106
  if (origin) return origin;
80
107
  }
81
108
  }
@@ -158,7 +185,15 @@ function getDocsTelemetryFeatures(config) {
158
185
  }
159
186
  function createDocsTelemetryEvent(config, input, context = {}) {
160
187
  const telemetryConfig = config.telemetry && typeof config.telemetry === "object" ? config.telemetry : void 0;
161
- const siteOrigin = context.siteOrigin ?? input.site?.origin ?? normalizeTelemetryOrigin(telemetryConfig?.siteOrigin) ?? readRequestOrigin(context.request) ?? readDeploymentOrigin();
188
+ const siteOriginCandidates = [
189
+ context.siteOrigin,
190
+ input.site?.origin,
191
+ telemetryConfig?.siteOrigin,
192
+ readRequestOrigin(context.request),
193
+ readDeploymentOrigin()
194
+ ];
195
+ if (siteOriginCandidates.some(isBlockedDocsTelemetryOrigin)) return void 0;
196
+ const siteOrigin = siteOriginCandidates.map(normalizeDocsTelemetryOrigin).find((origin) => Boolean(origin));
162
197
  const deployment = input.deployment ?? detectDeployment();
163
198
  const properties = context.properties || input.properties ? {
164
199
  ...input.properties,
@@ -206,7 +241,13 @@ function pruneSentProjectKeys(sent, now) {
206
241
  }
207
242
  async function emitDocsTelemetryEvent(telemetry, event) {
208
243
  const resolved = resolveDocsTelemetryConfig(telemetry);
209
- if (!resolved.enabled || !resolved.endpoint || typeof fetch !== "function") return;
244
+ const eventSiteOrigin = event.site?.origin;
245
+ const normalizedSiteOrigin = normalizeDocsTelemetryOrigin(eventSiteOrigin);
246
+ if (!resolved.enabled || !resolved.endpoint || typeof fetch !== "function" || eventSiteOrigin !== void 0 && (!normalizedSiteOrigin || isLocalDocsTelemetryOrigin(eventSiteOrigin))) return;
247
+ const eventToSend = normalizedSiteOrigin ? {
248
+ ...event,
249
+ site: { origin: normalizedSiteOrigin }
250
+ } : event;
210
251
  try {
211
252
  const ingestKey = readRuntimeEnv("DOCS_TELEMETRY_INGEST_KEY");
212
253
  const headers = { "content-type": "application/json" };
@@ -214,13 +255,14 @@ async function emitDocsTelemetryEvent(telemetry, event) {
214
255
  await fetch(resolved.endpoint, {
215
256
  method: "POST",
216
257
  headers,
217
- body: JSON.stringify({ event }),
258
+ body: JSON.stringify({ event: eventToSend }),
218
259
  keepalive: true
219
260
  });
220
261
  } catch {}
221
262
  }
222
263
  function emitDocsTelemetryProjectEvent(config, context = {}) {
223
264
  const event = createDocsTelemetryEvent(config, { type: "project_detected" }, context);
265
+ if (!event) return;
224
266
  const key = projectEventKey(event);
225
267
  const sent = getSentProjectKeys();
226
268
  const now = Date.now();
@@ -236,6 +278,7 @@ function emitDocsTelemetryAgentSurfaceEvent(config, context) {
236
278
  type: context.surface === "mcp" ? "mcp_request" : "agent_surface_used",
237
279
  properties: { surface: context.surface }
238
280
  }, context);
281
+ if (!event) return;
239
282
  emitDocsTelemetryEvent(config.telemetry, event);
240
283
  }
241
284
  function emitDocsTelemetryMcpToolEvent(config, context) {
@@ -247,6 +290,7 @@ function emitDocsTelemetryMcpToolEvent(config, context) {
247
290
  resultCount: context.resultCount
248
291
  }
249
292
  }, context);
293
+ if (!event) return;
250
294
  emitDocsTelemetryEvent(config.telemetry, event);
251
295
  }
252
296
  function inferDocsTelemetryAgentSurface(request, options) {
@@ -662,7 +706,7 @@ function resolveAskAIContextUrl(value, baseUrl) {
662
706
  }
663
707
  }
664
708
  function getAskAIPageContent(page) {
665
- return upsertPageAgentContractMarkdown(page.agentRawContent ?? page.agentFallbackRawContent ?? page.rawContent ?? page.content, page.agent).replace(PAGE_AGENT_CONTRACT_START_MARKER, "").replace(PAGE_AGENT_CONTRACT_END_MARKER, "").replace(/^\r?\n+/, "");
709
+ return upsertPageAgentContractMarkdown(page.agentRawContent ?? page.agentFallbackRawContent ?? page.agentContent ?? page.agentFallbackContent ?? page.rawContent ?? page.content, page.agent).replace(PAGE_AGENT_CONTRACT_START_MARKER, "").replace(PAGE_AGENT_CONTRACT_END_MARKER, "").replace(/^\r?\n+/, "");
666
710
  }
667
711
  function getPageAgentContractSearchText(page) {
668
712
  return stripMarkdownText(renderPageAgentContractMarkdown(page.agent).replace(PAGE_AGENT_CONTRACT_START_MARKER, "").replace(PAGE_AGENT_CONTRACT_END_MARKER, ""));
@@ -794,12 +838,37 @@ function mergeSearchResults(...groups) {
794
838
  }
795
839
  return results;
796
840
  }
797
- function pageToSearchDocument(page) {
841
+ function sanitizeExternalAgentSearchResults(results, localAgentResults, preserveUnmatched) {
842
+ const localByKey = new Map(localAgentResults.map((result) => [getSearchResultKey(result), result]));
843
+ const localPageResults = /* @__PURE__ */ new Map();
844
+ for (const result of localAgentResults) {
845
+ const pageUrl = normalizeUrlPathname(result.url);
846
+ if (!localPageResults.get(pageUrl) || result.type === "page") localPageResults.set(pageUrl, result);
847
+ }
848
+ return results.flatMap((result) => {
849
+ const local = localByKey.get(getSearchResultKey(result)) ?? localPageResults.get(normalizeUrlPathname(result.url));
850
+ if (!local) return preserveUnmatched?.(result) ? [result] : [];
851
+ return [{
852
+ ...local,
853
+ id: result.id,
854
+ score: result.score ?? local.score
855
+ }];
856
+ });
857
+ }
858
+ function getPageAudienceRawContent(page, audience) {
859
+ if (audience === "agent") return page.agentRawContent ?? page.agentFallbackRawContent ?? page.agentContent ?? page.agentFallbackContent ?? page.rawContent ?? page.content;
860
+ return page.rawContent ?? page.content;
861
+ }
862
+ function getPageAudienceSearchText(page, audience) {
863
+ if (audience === "agent") return page.agentContent ?? page.agentFallbackContent ?? stripMarkdownText(getPageAudienceRawContent(page, audience));
864
+ return page.content || stripMarkdownText(getPageAudienceRawContent(page, audience));
865
+ }
866
+ function pageToSearchDocument(page, audience = "human") {
798
867
  return {
799
868
  id: makeDocumentId(page.url, "page"),
800
869
  url: page.url,
801
870
  title: page.title,
802
- content: normalizeWhitespace([page.content, getPageAgentContractSearchText(page)].join(" ")),
871
+ content: normalizeWhitespace([getPageAudienceSearchText(page, audience), getPageAgentContractSearchText(page)].join(" ")),
803
872
  description: page.description,
804
873
  type: "page",
805
874
  locale: page.locale,
@@ -808,12 +877,12 @@ function pageToSearchDocument(page) {
808
877
  tags: page.tags
809
878
  };
810
879
  }
811
- function buildExactPageSearchResults(query, pages) {
880
+ function buildExactPageSearchResults(query, pages, audience = "human") {
812
881
  const normalizedQuery = normalizeSearchPhrase(query);
813
882
  if (!normalizedQuery) return [];
814
883
  const results = [];
815
884
  for (const page of pages) {
816
- const document = pageToSearchDocument(page);
885
+ const document = pageToSearchDocument(page, audience);
817
886
  const title = normalizeSearchPhrase(page.title);
818
887
  const urlSegments = getUrlSearchSegments(page.url);
819
888
  if (!(title === normalizedQuery || urlSegments.includes(normalizedQuery))) continue;
@@ -846,9 +915,6 @@ function prioritizeLiteralInsideResults(query, results) {
846
915
  return 0;
847
916
  });
848
917
  }
849
- function shouldSupplementAskAIWithSimpleSearch(search) {
850
- return search.enabled && search.provider !== "simple";
851
- }
852
918
  function rankAskAIContextResult(query, result) {
853
919
  return scoreDocument(query, {
854
920
  id: result.id,
@@ -870,8 +936,8 @@ function buildAskAIContextBlock(result) {
870
936
  function makeDocumentId(url, suffix) {
871
937
  return `${url}#${suffix}`;
872
938
  }
873
- function splitPageIntoSections(page) {
874
- return parseDocsMarkdownSections(page.rawContent ?? page.content).flatMap((section, index) => {
939
+ function splitPageIntoSections(page, audience = "human") {
940
+ return parseDocsMarkdownSections(getPageAudienceRawContent(page, audience)).flatMap((section, index) => {
875
941
  const content = normalizeWhitespace(stripMarkdownText(section.content));
876
942
  if (!content) return [];
877
943
  return [{
@@ -889,12 +955,12 @@ function splitPageIntoSections(page) {
889
955
  }];
890
956
  });
891
957
  }
892
- function buildDocsSearchDocuments(pages, chunking = {}) {
958
+ function buildDocsSearchDocuments(pages, chunking = {}, audience = "human") {
893
959
  const strategy = chunking.strategy ?? "section";
894
960
  return pages.flatMap((page) => {
895
- const base = pageToSearchDocument(page);
961
+ const base = pageToSearchDocument(page, audience);
896
962
  if (strategy === "page") return [base];
897
- const sections = splitPageIntoSections(page);
963
+ const sections = splitPageIntoSections(page, audience);
898
964
  if (sections.length === 0) return [base];
899
965
  return [...base.content ? [base] : [], ...sections];
900
966
  });
@@ -1478,7 +1544,8 @@ async function maybeSyncSearchIndex(adapter, search, context) {
1478
1544
  async function performDocsSearch(options) {
1479
1545
  const search = normalizeDocsSearchConfig(options.search);
1480
1546
  if (!search.enabled) return [];
1481
- const documents = buildDocsSearchDocuments(options.pages, search.chunking);
1547
+ const audience = options.audience ?? "human";
1548
+ const documents = buildDocsSearchDocuments(options.pages, search.chunking, audience);
1482
1549
  const context = {
1483
1550
  pages: options.pages,
1484
1551
  documents,
@@ -1494,10 +1561,16 @@ async function performDocsSearch(options) {
1494
1561
  };
1495
1562
  try {
1496
1563
  const adapter = await resolveSearchAdapter(search, context);
1497
- await maybeSyncSearchIndex(adapter, search, context);
1564
+ await maybeSyncSearchIndex(adapter, search, audience === "agent" ? {
1565
+ ...context,
1566
+ documents: buildDocsSearchDocuments(options.pages, search.chunking, "human")
1567
+ } : context);
1498
1568
  const results = await adapter.search(query, context);
1499
1569
  if (search.provider === "simple") return results;
1500
- return prioritizeLiteralInsideResults(options.query, mergeSearchResults(buildExactPageSearchResults(options.query, options.pages), results)).slice(0, query.limit ?? search.maxResults ?? DEFAULT_SEARCH_LIMIT);
1570
+ const localAudienceResults = audience === "agent" ? await createSimpleSearchAdapter().search(query, context) : [];
1571
+ const localPagePaths = new Set(options.pages.map((page) => normalizeUrlPathname(page.url)));
1572
+ const safeAdapterResults = audience !== "agent" ? results : sanitizeExternalAgentSearchResults(results, localAudienceResults, search.provider === "mcp" ? (result) => !localPagePaths.has(normalizeUrlPathname(result.url)) : void 0);
1573
+ return prioritizeLiteralInsideResults(options.query, mergeSearchResults(buildExactPageSearchResults(options.query, options.pages, audience), safeAdapterResults, localAudienceResults)).slice(0, query.limit ?? search.maxResults ?? DEFAULT_SEARCH_LIMIT);
1501
1574
  } catch {
1502
1575
  return createSimpleSearchAdapter().search(query, context);
1503
1576
  }
@@ -1507,29 +1580,16 @@ async function buildDocsAskAIContext(options) {
1507
1580
  const searchLimit = Math.max(limit * 2, limit);
1508
1581
  const initialSearch = options.search === false ? true : options.search;
1509
1582
  const primarySearch = normalizeDocsSearchConfig(initialSearch).enabled ? initialSearch : true;
1510
- const primarySearchConfig = normalizeDocsSearchConfig(primarySearch);
1511
- const searchResults = mergeSearchResults(await performDocsSearch({
1583
+ const searchResults = await performDocsSearch({
1512
1584
  pages: options.pages,
1513
1585
  query: options.query,
1514
1586
  search: primarySearch,
1587
+ audience: "agent",
1515
1588
  locale: options.locale,
1516
1589
  pathname: options.pathname,
1517
1590
  siteTitle: options.siteTitle,
1518
1591
  limit: searchLimit
1519
- }), shouldSupplementAskAIWithSimpleSearch(primarySearchConfig) ? await performDocsSearch({
1520
- pages: options.pages,
1521
- query: options.query,
1522
- search: {
1523
- provider: "simple",
1524
- enabled: true,
1525
- chunking: primarySearchConfig.chunking,
1526
- maxResults: searchLimit
1527
- },
1528
- locale: options.locale,
1529
- pathname: options.pathname,
1530
- siteTitle: options.siteTitle,
1531
- limit: searchLimit
1532
- }) : []);
1592
+ });
1533
1593
  const seen = /* @__PURE__ */ new Set();
1534
1594
  const maxResultChars = options.maxResultChars ?? DEFAULT_ASK_AI_RESULT_CHARS;
1535
1595
  const rankedResults = searchResults.map((result, index) => {
@@ -1584,4 +1644,4 @@ function createCustomSearchAdapter(adapter) {
1584
1644
  }
1585
1645
 
1586
1646
  //#endregion
1587
- export { getDocsTelemetryFeatures as A, resolvePageSidebarFolderIndexBehavior as C, emitDocsTelemetryEvent as D, emitDocsTelemetryAgentSurfaceEvent as E, resolveDocsTelemetryConfig as M, emitDocsTelemetryMcpToolEvent as O, applySidebarFolderIndexBehavior as S, resolveSidebarFolderIndexBehaviorForPath as T, hashGeneratedAgentContent as _, createMcpSearchAdapter as a, serializeGeneratedAgentDocument as b, formatDocsAskAIPackageHints as c, resolveAskAISearchRequestConfig as d, resolveSearchRequestConfig as f, GENERATED_AGENT_PROVENANCE_VERSION as g, GENERATED_AGENT_PROVENANCE_MARKER as h, createCustomSearchAdapter as i, inferDocsTelemetryAgentSurface as j, emitDocsTelemetryProjectEvent as k, inferDocsAskAIPackageHints as l, parseDocsMarkdownSections as m, buildDocsSearchDocuments as n, createSimpleSearchAdapter as o, findDocsMarkdownSection as p, createAlgoliaSearchAdapter as r, createTypesenseSearchAdapter as s, buildDocsAskAIContext as t, performDocsSearch as u, normalizeGeneratedAgentContent as v, resolveSidebarFolderIndexBehavior as w, stripGeneratedAgentProvenance as x, parseGeneratedAgentDocument as y };
1647
+ export { getDocsTelemetryFeatures as A, resolvePageSidebarFolderIndexBehavior as C, emitDocsTelemetryEvent as D, emitDocsTelemetryAgentSurfaceEvent as E, isLocalDocsTelemetryOrigin as M, normalizeDocsTelemetryOrigin as N, emitDocsTelemetryMcpToolEvent as O, resolveDocsTelemetryConfig as P, applySidebarFolderIndexBehavior as S, resolveSidebarFolderIndexBehaviorForPath as T, hashGeneratedAgentContent as _, createMcpSearchAdapter as a, serializeGeneratedAgentDocument as b, formatDocsAskAIPackageHints as c, resolveAskAISearchRequestConfig as d, resolveSearchRequestConfig as f, GENERATED_AGENT_PROVENANCE_VERSION as g, GENERATED_AGENT_PROVENANCE_MARKER as h, createCustomSearchAdapter as i, inferDocsTelemetryAgentSurface as j, emitDocsTelemetryProjectEvent as k, inferDocsAskAIPackageHints as l, parseDocsMarkdownSections as m, buildDocsSearchDocuments as n, createSimpleSearchAdapter as o, findDocsMarkdownSection as p, createAlgoliaSearchAdapter as r, createTypesenseSearchAdapter as s, buildDocsAskAIContext as t, performDocsSearch as u, normalizeGeneratedAgentContent as v, resolveSidebarFolderIndexBehavior as w, stripGeneratedAgentProvenance as x, parseGeneratedAgentDocument as y };
@@ -1,6 +1,6 @@
1
- import "./agent-DXkXi-pS.mjs";
2
- import { n as buildDocsSearchDocuments, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter } from "./search-CJIC1Cqo.mjs";
3
- import "./sitemap-server-wsNLyVkb.mjs";
1
+ import "./agent-CxDzPqtl.mjs";
2
+ import { n as buildDocsSearchDocuments, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter } from "./search-OHp36znm.mjs";
3
+ import "./sitemap-server-zFYctvCa.mjs";
4
4
  import "./agent-evals-BD17jOqL.mjs";
5
5
  import { createFilesystemDocsMcpSource } from "./mcp.mjs";
6
6
  import "./code-blocks-C9awWzEQ.mjs";