@farming-labs/docs 0.1.70 → 0.1.72

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.
@@ -1,4 +1,4 @@
1
- import { _ as renderDocsRelatedMarkdownLines } from "./search-BhXicuww.mjs";
1
+ import { x as renderDocsRelatedMarkdownLines } from "./search-Bk7rg-AY.mjs";
2
2
  import matter from "gray-matter";
3
3
 
4
4
  //#region src/define-docs.ts
@@ -18,6 +18,7 @@ function defineDocs(config) {
18
18
  sidebar: config.sidebar,
19
19
  components: config.components,
20
20
  analytics: config.analytics,
21
+ observability: config.observability,
21
22
  onCopyClick: config.onCopyClick,
22
23
  feedback: config.feedback,
23
24
  search: config.search,
@@ -309,78 +310,6 @@ function resolveReadingTimeFromSource(source, wordsPerMinute) {
309
310
  return resolveReadingTimeFromContent(data, content, wordsPerMinute);
310
311
  }
311
312
 
312
- //#endregion
313
- //#region src/sidebar.ts
314
- function resolvePageSidebarFolderIndexBehavior(sidebar) {
315
- if (!sidebar || typeof sidebar !== "object") return void 0;
316
- const value = sidebar.folderIndexBehavior;
317
- return value === "link" || value === "toggle" || value === "hidden" ? value : void 0;
318
- }
319
- function normalizeSidebarFolderBehaviorPath(path) {
320
- if (!path) return void 0;
321
- let value = path.trim();
322
- if (!value) return void 0;
323
- if (/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(value)) try {
324
- value = new URL(value).pathname;
325
- } catch {
326
- return;
327
- }
328
- else value = value.split("#", 1)[0]?.split("?", 1)[0] ?? value;
329
- if (!value.startsWith("/")) value = `/${value}`;
330
- return value.replace(/\/$/, "") || "/";
331
- }
332
- function resolveSidebarFolderIndexBehavior(sidebar, defaultBehavior = "link") {
333
- if (sidebar === void 0 || sidebar === true || sidebar === false) return defaultBehavior;
334
- if (sidebar.folderIndexBehavior === "toggle") return "toggle";
335
- if (sidebar.folderIndexBehavior === "hidden") return "hidden";
336
- if (sidebar.folderIndexBehavior === "link") return "link";
337
- return defaultBehavior;
338
- }
339
- function resolveSidebarFolderIndexBehaviorForPath(sidebar, folderPath, defaultBehavior = "link") {
340
- const fallback = resolveSidebarFolderIndexBehavior(sidebar, defaultBehavior);
341
- if (!sidebar || typeof sidebar !== "object") return fallback;
342
- const normalizedPath = normalizeSidebarFolderBehaviorPath(folderPath);
343
- if (!normalizedPath) return fallback;
344
- for (const [rawPath, override] of Object.entries(sidebar.folderIndexBehaviorOverrides ?? {})) if (normalizeSidebarFolderBehaviorPath(rawPath) === normalizedPath) return override === "link" || override === "toggle" || override === "hidden" ? override : fallback;
345
- return fallback;
346
- }
347
- function applySidebarFolderIndexBehavior(tree, behaviorOrOptions) {
348
- const resolveBehavior = typeof behaviorOrOptions === "string" ? () => behaviorOrOptions : (folderPath) => resolveSidebarFolderIndexBehaviorForPath(behaviorOrOptions.sidebar, folderPath, behaviorOrOptions.defaultBehavior);
349
- function mapNode(node) {
350
- if (!node || typeof node !== "object") return node;
351
- const candidate = node;
352
- if (candidate.type !== "folder" || !Array.isArray(candidate.children)) return node;
353
- const children = candidate.children.map(mapNode);
354
- const index = candidate.index ? mapNode(candidate.index) : void 0;
355
- const folderPath = (typeof candidate.url === "string" ? candidate.url : void 0) || (candidate.index && typeof candidate.index === "object" && "url" in candidate.index && typeof candidate.index.url === "string" ? candidate.index.url ?? void 0 : void 0);
356
- const behavior = (candidate.folderIndexBehavior === "link" || candidate.folderIndexBehavior === "toggle" || candidate.folderIndexBehavior === "hidden" ? candidate.folderIndexBehavior : void 0) ?? resolveBehavior(folderPath);
357
- if (behavior === "link") return {
358
- ...candidate,
359
- folderIndexBehavior: void 0,
360
- index,
361
- children
362
- };
363
- if (behavior === "hidden") return {
364
- ...candidate,
365
- folderIndexBehavior: void 0,
366
- index: void 0,
367
- url: void 0,
368
- children
369
- };
370
- return {
371
- ...candidate,
372
- folderIndexBehavior: void 0,
373
- index: void 0,
374
- url: void 0,
375
- children: index ? [index, ...children] : children
376
- };
377
- }
378
- return {
379
- ...tree,
380
- children: tree.children.map(mapNode)
381
- };
382
- }
383
-
384
313
  //#endregion
385
314
  //#region src/agent.ts
386
315
  const DEFAULT_DOCS_API_ROUTE = "/api/docs";
@@ -700,4 +629,4 @@ function toYamlString(value) {
700
629
  }
701
630
 
702
631
  //#endregion
703
- export { resolvePageSidebarFolderIndexBehavior as A, resolveOGImage as B, renderDocsMarkdownDocument as C, resolveDocsMarkdownRequest as D, resolveDocsLlmsTxtFormat as E, resolveReadingTimeFromContent as F, createTheme as G, resolveDocsI18n as H, resolveReadingTimeFromSource as I, resolveChangelogConfig as J, extendTheme as K, resolveReadingTimeOptions as L, resolveSidebarFolderIndexBehaviorForPath as M, estimateReadingTimeMinutes as N, resolveDocsSkillFormat as O, resolvePageReadingTime as P, buildPageOpenGraph as R, normalizeDocsUrlPath as S, resolveDocsAgentMdxContent as T, resolveDocsLocale as U, resolveTitle as V, resolveDocsPath as W, defineDocs as Y, isDocsAgentDiscoveryRequest as _, DEFAULT_DOCS_API_ROUTE as a, isDocsSkillRequest as b, DEFAULT_LLMS_TXT_ROUTE as c, DEFAULT_MCP_ROUTE as d, DEFAULT_MCP_WELL_KNOWN_ROUTE as f, findDocsMarkdownPage as g, buildDocsAgentDiscoverySpec as h, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE as i, resolveSidebarFolderIndexBehavior as j, applySidebarFolderIndexBehavior as k, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE as l, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE as m, DEFAULT_AGENT_SPEC_ROUTE as n, DEFAULT_LLMS_FULL_TXT_ROUTE as o, DEFAULT_SKILL_MD_ROUTE as p, deepMerge as q, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE as r, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE as s, DEFAULT_AGENT_FEEDBACK_ROUTE as t, DEFAULT_MCP_PUBLIC_ROUTE as u, isDocsMcpRequest as v, renderDocsSkillDocument as w, normalizeDocsPathSegment as x, isDocsPublicGetRequest as y, buildPageTwitter as z };
632
+ export { resolvePageReadingTime as A, resolveDocsPath as B, renderDocsMarkdownDocument as C, resolveDocsMarkdownRequest as D, resolveDocsLlmsTxtFormat as E, buildPageTwitter as F, defineDocs as G, extendTheme as H, resolveOGImage as I, resolveTitle as L, resolveReadingTimeFromSource as M, resolveReadingTimeOptions as N, resolveDocsSkillFormat as O, buildPageOpenGraph as P, resolveDocsI18n as R, normalizeDocsUrlPath as S, resolveDocsAgentMdxContent as T, deepMerge as U, createTheme as V, resolveChangelogConfig as W, isDocsAgentDiscoveryRequest as _, DEFAULT_DOCS_API_ROUTE as a, isDocsSkillRequest as b, DEFAULT_LLMS_TXT_ROUTE as c, DEFAULT_MCP_ROUTE as d, DEFAULT_MCP_WELL_KNOWN_ROUTE as f, findDocsMarkdownPage as g, buildDocsAgentDiscoverySpec as h, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE as i, resolveReadingTimeFromContent as j, estimateReadingTimeMinutes as k, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE as l, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE as m, DEFAULT_AGENT_SPEC_ROUTE as n, DEFAULT_LLMS_FULL_TXT_ROUTE as o, DEFAULT_SKILL_MD_ROUTE as p, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE as r, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE as s, DEFAULT_AGENT_FEEDBACK_ROUTE as t, DEFAULT_MCP_PUBLIC_ROUTE as u, isDocsMcpRequest as v, renderDocsSkillDocument as w, normalizeDocsPathSegment as x, isDocsPublicGetRequest as y, resolveDocsLocale as z };
@@ -1,5 +1,5 @@
1
- import { C as renderDocsMarkdownDocument, g as findDocsMarkdownPage } from "./agent-BMOtZLMC.mjs";
2
- import { d as hashGeneratedAgentContent, m as serializeGeneratedAgentDocument, p as parseGeneratedAgentDocument, u as GENERATED_AGENT_PROVENANCE_VERSION } from "./search-BhXicuww.mjs";
1
+ import { C as renderDocsMarkdownDocument, g as findDocsMarkdownPage } from "./agent-D87B57Wv.mjs";
2
+ import { d as hashGeneratedAgentContent, m as serializeGeneratedAgentDocument, p as parseGeneratedAgentDocument, u as GENERATED_AGENT_PROVENANCE_VERSION } from "./search-Bk7rg-AY.mjs";
3
3
  import "./index.mjs";
4
4
  import "./prompt-utils-8nmFLQVH.mjs";
5
5
  import { createFilesystemDocsMcpSource } from "./mcp.mjs";
@@ -83,10 +83,10 @@ async function main() {
83
83
  const { dev } = await import("../dev-BQIDeAoL.mjs");
84
84
  await dev(devOptions);
85
85
  } else if (parsedCommand.command === "mcp") {
86
- const { runMcp } = await import("../mcp-vNQt0NUC.mjs");
86
+ const { runMcp } = await import("../mcp-obMYAPqu.mjs");
87
87
  await runMcp(mcpOptions);
88
88
  } else if (parsedCommand.command === "agent" && subcommand === "compact") {
89
- const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-Pbf5iqr6.mjs");
89
+ const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-beh4aVYP.mjs");
90
90
  const agentCompactOptions = parseAgentCompactArgs(args.slice(2));
91
91
  if (agentCompactOptions.help) {
92
92
  printAgentCompactHelp();
@@ -96,11 +96,11 @@ async function main() {
96
96
  } else if (parsedCommand.command === "agent") {
97
97
  console.error(pc.red(`Unknown agent subcommand: ${subcommand ?? "(missing)"}`));
98
98
  console.error();
99
- const { printAgentCompactHelp } = await import("../agent-Pbf5iqr6.mjs");
99
+ const { printAgentCompactHelp } = await import("../agent-beh4aVYP.mjs");
100
100
  printAgentCompactHelp();
101
101
  process.exit(1);
102
102
  } else if (parsedCommand.command === "doctor") {
103
- const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-CndGrKwy.mjs");
103
+ const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-BUI3LchV.mjs");
104
104
  const doctorOptions = parseDoctorArgs(args.slice(1));
105
105
  if (doctorOptions.help) {
106
106
  printDoctorHelp();
@@ -108,7 +108,7 @@ async function main() {
108
108
  }
109
109
  await runDoctor(doctorOptions);
110
110
  } else if (parsedCommand.command === "search" && subcommand === "sync") {
111
- const { syncSearch } = await import("../search-DcXwu_8y.mjs");
111
+ const { syncSearch } = await import("../search-BzMf2w0H.mjs");
112
112
  await syncSearch(searchSyncOptions);
113
113
  } else if (parsedCommand.command === "search") {
114
114
  console.error(pc.red(`Unknown search subcommand: ${subcommand ?? "(missing)"}`));
@@ -1,10 +1,10 @@
1
- import { c as DEFAULT_LLMS_TXT_ROUTE, f as DEFAULT_MCP_WELL_KNOWN_ROUTE, i as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, m as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, o as DEFAULT_LLMS_FULL_TXT_ROUTE, p as DEFAULT_SKILL_MD_ROUTE, r as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, t as DEFAULT_AGENT_FEEDBACK_ROUTE, u as DEFAULT_MCP_PUBLIC_ROUTE } from "./agent-BMOtZLMC.mjs";
2
- import "./search-BhXicuww.mjs";
1
+ import { c as DEFAULT_LLMS_TXT_ROUTE, f as DEFAULT_MCP_WELL_KNOWN_ROUTE, i as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, m as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, o as DEFAULT_LLMS_FULL_TXT_ROUTE, p as DEFAULT_SKILL_MD_ROUTE, r as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, t as DEFAULT_AGENT_FEEDBACK_ROUTE, u as DEFAULT_MCP_PUBLIC_ROUTE } from "./agent-D87B57Wv.mjs";
2
+ import "./search-Bk7rg-AY.mjs";
3
3
  import "./prompt-utils-8nmFLQVH.mjs";
4
4
  import { createFilesystemDocsMcpSource, resolveDocsMcpConfig } from "./mcp.mjs";
5
5
  import "./server.mjs";
6
6
  import { a as loadProjectEnv, c as readNavTitle, d as readTopLevelStringProperty, f as resolveDocsConfigPath, i as loadDocsConfigModule, o as readBooleanProperty, p as resolveDocsContentDir, r as extractTopLevelConfigObject, t as extractNestedObjectLiteral } from "./config-Si-yUfM_.mjs";
7
- import { inspectAgentCompactionState, scanDocsPageTargets } from "./agent-Pbf5iqr6.mjs";
7
+ import { inspectAgentCompactionState, scanDocsPageTargets } from "./agent-beh4aVYP.mjs";
8
8
  import { t as detectFramework } from "./utils-DSMXVnEu.mjs";
9
9
  import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
10
10
  import path from "node:path";
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as PageFrontmatter, A as DocsSearchAdapterContext, B as DocsTheme, C as DocsI18nConfig, D as DocsNav, E as DocsMetadata, F as DocsSearchEmbeddingsConfig, G as LlmsTxtConfig, H as FontStyle, I as DocsSearchQuery, J as OpenDocsConfig, K as McpDocsSearchConfig, L as DocsSearchResult, M as DocsSearchChunkingConfig, N as DocsSearchConfig, O as DocsRelatedItem, P as DocsSearchDocument, Q as PageActionsConfig, R as DocsSearchResultType, S as DocsFeedbackValue, T as DocsMcpToolsConfig, U as GithubConfig, V as FeedbackConfig, W as LastUpdatedConfig, X as OpenGraphImage, Y as OpenDocsProvider, Z as OrderingItem, _ as DocsAnalyticsEventType, a as ApiReferenceRenderer, at as SidebarComponentProps, b as DocsConfig, c as ChangelogFrontmatter, ct as SidebarFolderNode, d as CustomDocsSearchConfig, dt as SidebarTree, et as PageOpenGraph, f as DocsAgentFeedbackContext, ft as SimpleDocsSearchConfig, g as DocsAnalyticsEventInput, gt as UIConfig, h as DocsAnalyticsEvent, ht as TypographyConfig, i as ApiReferenceConfig, it as ResolvedDocsRelatedLink, j as DocsSearchAdapterFactory, k as DocsSearchAdapter, l as CodeBlockCopyData, lt as SidebarNode, m as DocsAnalyticsConfig, mt as TypesenseDocsSearchConfig, n as AgentFeedbackConfig, nt as PageTwitter, o as BreadcrumbConfig, ot as SidebarConfig, p as DocsAgentFeedbackData, pt as ThemeToggleConfig, q as OGConfig, r as AlgoliaDocsSearchConfig, rt as ReadingTimeConfig, s as ChangelogConfig, st as SidebarFolderIndexBehavior, t as AIConfig, tt as PageSidebarFrontmatter, u as CopyMarkdownConfig, ut as SidebarPageNode, v as DocsAnalyticsInput, w as DocsMcpConfig, x as DocsFeedbackData, y as DocsAnalyticsSource, z as DocsSearchSourcePage } from "./types-BXgTvFFE.mjs";
2
- import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, d as resolveDocsAnalyticsConfig, f as DocsCloudAnalyticsOptions, i as createMcpSearchAdapter, l as ResolvedDocsAnalyticsConfig, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, p as createDocsCloudAnalytics, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments, u as emitDocsAnalyticsEvent } from "./search-Gvi81BSo.mjs";
1
+ import { $ as OGConfig, A as DocsNav, B as DocsSearchDocument, C as DocsConfig, D as DocsMcpConfig, E as DocsI18nConfig, F as DocsSearchAdapter, G as DocsSearchSourcePage, H as DocsSearchQuery, I as DocsSearchAdapterContext, J as FontStyle, K as DocsTheme, L as DocsSearchAdapterFactory, M as DocsObservabilityEvent, N as DocsObservabilityEventInput, O as DocsMcpToolsConfig, P as DocsRelatedItem, Q as McpDocsSearchConfig, R as DocsSearchChunkingConfig, S as DocsAnalyticsSource, St as UIConfig, T as DocsFeedbackValue, U as DocsSearchResult, V as DocsSearchEmbeddingsConfig, W as DocsSearchResultType, X as LastUpdatedConfig, Y as GithubConfig, Z as LlmsTxtConfig, _ as DocsAnalyticsConfig, _t as SidebarTree, a as ApiReferenceRenderer, at as PageFrontmatter, b as DocsAnalyticsEventType, bt as TypesenseDocsSearchConfig, c as ChangelogFrontmatter, ct as PageTwitter, d as CustomDocsSearchConfig, dt as SidebarComponentProps, et as OpenDocsConfig, f as DocsAgentFeedbackContext, ft as SidebarConfig, g as DocsAgentTraceStatus, gt as SidebarPageNode, h as DocsAgentTraceEventType, ht as SidebarNode, i as ApiReferenceConfig, it as PageActionsConfig, j as DocsObservabilityConfig, k as DocsMetadata, l as CodeBlockCopyData, lt as ReadingTimeConfig, m as DocsAgentTraceEventInput, mt as SidebarFolderNode, n as AgentFeedbackConfig, nt as OpenGraphImage, o as BreadcrumbConfig, ot as PageOpenGraph, p as DocsAgentFeedbackData, pt as SidebarFolderIndexBehavior, q as FeedbackConfig, r as AlgoliaDocsSearchConfig, rt as OrderingItem, s as ChangelogConfig, st as PageSidebarFrontmatter, t as AIConfig, tt as OpenDocsProvider, u as CopyMarkdownConfig, ut as ResolvedDocsRelatedLink, v as DocsAnalyticsEvent, vt as SimpleDocsSearchConfig, w as DocsFeedbackData, x as DocsAnalyticsInput, xt as TypographyConfig, y as DocsAnalyticsEventInput, yt as ThemeToggleConfig, z as DocsSearchConfig } from "./types-CgBlM_yI.mjs";
2
+ import { _ as emitDocsObservabilityEvent, a as createSimpleSearchAdapter, b as DocsCloudAnalyticsOptions, c as resolveSearchRequestConfig, d as ResolvedDocsAnalyticsConfig, f as ResolvedDocsObservabilityConfig, g as emitDocsAnalyticsEvent, h as emitDocsAgentTraceEvent, i as createMcpSearchAdapter, l as DOCS_AGENT_TRACE_EVENT_TYPES, m as createDocsAgentTraceId, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, p as createDocsAgentTraceContext, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments, u as DocsAgentTraceContext, v as resolveDocsAnalyticsConfig, x as createDocsCloudAnalytics, y as resolveDocsObservabilityConfig } from "./search-COyfvf6H.mjs";
3
3
  import { DocsMcpPage, DocsMcpResolvedConfig } from "./mcp.mjs";
4
4
 
5
5
  //#region src/define-docs.d.ts
@@ -372,4 +372,4 @@ declare function buildDocsAgentDiscoverySpec({
372
372
  };
373
373
  };
374
374
  //#endregion
375
- export { type AIConfig, type AgentFeedbackConfig, type AlgoliaDocsSearchConfig, type ApiReferenceConfig, type ApiReferenceRenderer, type BreadcrumbConfig, type ChangelogConfig, type ChangelogEntrySummary, type ChangelogFrontmatter, type CodeBlockCopyData, type CopyMarkdownConfig, type CustomDocsSearchConfig, DEFAULT_AGENT_FEEDBACK_ROUTE, DEFAULT_AGENT_SPEC_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, DEFAULT_DOCS_API_ROUTE, DEFAULT_LLMS_FULL_TXT_ROUTE, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, DEFAULT_LLMS_TXT_ROUTE, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, DEFAULT_MCP_PUBLIC_ROUTE, DEFAULT_MCP_ROUTE, DEFAULT_MCP_WELL_KNOWN_ROUTE, DEFAULT_SKILL_MD_ROUTE, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, type DocsAgentDiscoverySpecOptions, type DocsAgentFeedbackContext, type DocsAgentFeedbackData, type DocsAgentFeedbackDiscoveryConfig, type DocsAnalyticsConfig, type DocsAnalyticsEvent, type DocsAnalyticsEventInput, type DocsAnalyticsEventType, type DocsAnalyticsInput, type DocsAnalyticsSource, type DocsCloudAnalyticsOptions, type DocsConfig, type DocsFeedbackData, type DocsFeedbackValue, type DocsI18nConfig, type DocsLlmsDiscoveryConfig, type DocsMarkdownPage, type DocsMcpConfig, type DocsMcpToolsConfig, type DocsMetadata, type DocsNav, type DocsPathMatch, type DocsRelatedItem, type DocsSearchAdapter, type DocsSearchAdapterContext, type DocsSearchAdapterFactory, type DocsSearchChunkingConfig, type DocsSearchConfig, type DocsSearchDocument, type DocsSearchEmbeddingsConfig, type DocsSearchQuery, type DocsSearchResult, type DocsSearchResultType, type DocsSearchSourcePage, type DocsSkillDocumentOptions, type DocsTheme, type FeedbackConfig, type FontStyle, GENERATED_AGENT_PROVENANCE_MARKER, GENERATED_AGENT_PROVENANCE_VERSION, type GeneratedAgentProvenance, type GeneratedAgentSourceKind, type GithubConfig, type LastUpdatedConfig, type LlmsTxtConfig, type McpDocsSearchConfig, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, type OpenGraphImage, type OrderingItem, type PageActionsConfig, type PageFrontmatter, type PageOpenGraph, type PageSidebarFrontmatter, type PageTwitter, type ReadingTimeConfig, type ResolvedChangelogConfig, type ResolvedDocsAnalyticsConfig, type ResolvedDocsI18n, type ResolvedDocsRelatedLink, type SidebarComponentProps, type SidebarConfig, type SidebarFolderIndexBehavior, type SidebarFolderNode, type SidebarNode, type SidebarPageNode, type SidebarTree, type SimpleDocsSearchConfig, type ThemeToggleConfig, type TypesenseDocsSearchConfig, type TypographyConfig, type UIConfig, applySidebarFolderIndexBehavior, buildDocsAgentDiscoverySpec, buildDocsSearchDocuments, buildPageOpenGraph, buildPageTwitter, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsCloudAnalytics, createMcpSearchAdapter, createSimpleSearchAdapter, createTheme, createTypesenseSearchAdapter, deepMerge, defineDocs, emitDocsAnalyticsEvent, estimateReadingTimeMinutes, extendTheme, findDocsMarkdownPage, hashGeneratedAgentContent, isDocsAgentDiscoveryRequest, isDocsMcpRequest, isDocsPublicGetRequest, isDocsSkillRequest, normalizeDocsPathSegment, normalizeDocsRelated, normalizeDocsUrlPath, normalizeGeneratedAgentContent, parseGeneratedAgentDocument, performDocsSearch, renderDocsMarkdownDocument, renderDocsRelatedMarkdownLines, renderDocsSkillDocument, resolveChangelogConfig, resolveDocsAgentMdxContent, resolveDocsAnalyticsConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsPath, resolveDocsSkillFormat, resolveOGImage, resolvePageReadingTime, resolvePageSidebarFolderIndexBehavior, resolveReadingTimeFromContent, resolveReadingTimeFromSource, resolveReadingTimeOptions, resolveSearchRequestConfig, resolveSidebarFolderIndexBehavior, resolveSidebarFolderIndexBehaviorForPath, resolveTitle, serializeGeneratedAgentDocument, stripGeneratedAgentProvenance };
375
+ export { type AIConfig, type AgentFeedbackConfig, type AlgoliaDocsSearchConfig, type ApiReferenceConfig, type ApiReferenceRenderer, type BreadcrumbConfig, type ChangelogConfig, type ChangelogEntrySummary, type ChangelogFrontmatter, type CodeBlockCopyData, type CopyMarkdownConfig, type CustomDocsSearchConfig, DEFAULT_AGENT_FEEDBACK_ROUTE, DEFAULT_AGENT_SPEC_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, DEFAULT_DOCS_API_ROUTE, DEFAULT_LLMS_FULL_TXT_ROUTE, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, DEFAULT_LLMS_TXT_ROUTE, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, DEFAULT_MCP_PUBLIC_ROUTE, DEFAULT_MCP_ROUTE, DEFAULT_MCP_WELL_KNOWN_ROUTE, DEFAULT_SKILL_MD_ROUTE, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, DOCS_AGENT_TRACE_EVENT_TYPES, type DocsAgentDiscoverySpecOptions, type DocsAgentFeedbackContext, type DocsAgentFeedbackData, type DocsAgentFeedbackDiscoveryConfig, type DocsAgentTraceContext, type DocsAgentTraceEventInput, type DocsAgentTraceEventType, type DocsAgentTraceStatus, type DocsAnalyticsConfig, type DocsAnalyticsEvent, type DocsAnalyticsEventInput, type DocsAnalyticsEventType, type DocsAnalyticsInput, type DocsAnalyticsSource, type DocsCloudAnalyticsOptions, type DocsConfig, type DocsFeedbackData, type DocsFeedbackValue, type DocsI18nConfig, type DocsLlmsDiscoveryConfig, type DocsMarkdownPage, type DocsMcpConfig, type DocsMcpToolsConfig, type DocsMetadata, type DocsNav, type DocsObservabilityConfig, type DocsObservabilityEvent, type DocsObservabilityEventInput, type DocsPathMatch, type DocsRelatedItem, type DocsSearchAdapter, type DocsSearchAdapterContext, type DocsSearchAdapterFactory, type DocsSearchChunkingConfig, type DocsSearchConfig, type DocsSearchDocument, type DocsSearchEmbeddingsConfig, type DocsSearchQuery, type DocsSearchResult, type DocsSearchResultType, type DocsSearchSourcePage, type DocsSkillDocumentOptions, type DocsTheme, type FeedbackConfig, type FontStyle, GENERATED_AGENT_PROVENANCE_MARKER, GENERATED_AGENT_PROVENANCE_VERSION, type GeneratedAgentProvenance, type GeneratedAgentSourceKind, type GithubConfig, type LastUpdatedConfig, type LlmsTxtConfig, type McpDocsSearchConfig, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, type OpenGraphImage, type OrderingItem, type PageActionsConfig, type PageFrontmatter, type PageOpenGraph, type PageSidebarFrontmatter, type PageTwitter, type ReadingTimeConfig, type ResolvedChangelogConfig, type ResolvedDocsAnalyticsConfig, type ResolvedDocsI18n, type ResolvedDocsObservabilityConfig, type ResolvedDocsRelatedLink, type SidebarComponentProps, type SidebarConfig, type SidebarFolderIndexBehavior, type SidebarFolderNode, type SidebarNode, type SidebarPageNode, type SidebarTree, type SimpleDocsSearchConfig, type ThemeToggleConfig, type TypesenseDocsSearchConfig, type TypographyConfig, type UIConfig, applySidebarFolderIndexBehavior, buildDocsAgentDiscoverySpec, buildDocsSearchDocuments, buildPageOpenGraph, buildPageTwitter, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAnalytics, createMcpSearchAdapter, createSimpleSearchAdapter, createTheme, createTypesenseSearchAdapter, deepMerge, defineDocs, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, estimateReadingTimeMinutes, extendTheme, findDocsMarkdownPage, hashGeneratedAgentContent, isDocsAgentDiscoveryRequest, isDocsMcpRequest, isDocsPublicGetRequest, isDocsSkillRequest, normalizeDocsPathSegment, normalizeDocsRelated, normalizeDocsUrlPath, normalizeGeneratedAgentContent, parseGeneratedAgentDocument, performDocsSearch, renderDocsMarkdownDocument, renderDocsRelatedMarkdownLines, renderDocsSkillDocument, resolveChangelogConfig, resolveDocsAgentMdxContent, resolveDocsAnalyticsConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsObservabilityConfig, resolveDocsPath, resolveDocsSkillFormat, resolveOGImage, resolvePageReadingTime, resolvePageSidebarFolderIndexBehavior, resolveReadingTimeFromContent, resolveReadingTimeFromSource, resolveReadingTimeOptions, resolveSearchRequestConfig, resolveSidebarFolderIndexBehavior, resolveSidebarFolderIndexBehaviorForPath, resolveTitle, serializeGeneratedAgentDocument, stripGeneratedAgentProvenance };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as resolvePageSidebarFolderIndexBehavior, B as resolveOGImage, C as renderDocsMarkdownDocument, D as resolveDocsMarkdownRequest, E as resolveDocsLlmsTxtFormat, F as resolveReadingTimeFromContent, G as createTheme, H as resolveDocsI18n, I as resolveReadingTimeFromSource, J as resolveChangelogConfig, K as extendTheme, L as resolveReadingTimeOptions, M as resolveSidebarFolderIndexBehaviorForPath, N as estimateReadingTimeMinutes, O as resolveDocsSkillFormat, P as resolvePageReadingTime, R as buildPageOpenGraph, S as normalizeDocsUrlPath, T as resolveDocsAgentMdxContent, U as resolveDocsLocale, V as resolveTitle, W as resolveDocsPath, Y as defineDocs, _ as isDocsAgentDiscoveryRequest, a as DEFAULT_DOCS_API_ROUTE, b as isDocsSkillRequest, c as DEFAULT_LLMS_TXT_ROUTE, d as DEFAULT_MCP_ROUTE, f as DEFAULT_MCP_WELL_KNOWN_ROUTE, g as findDocsMarkdownPage, h as buildDocsAgentDiscoverySpec, i as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, j as resolveSidebarFolderIndexBehavior, k as applySidebarFolderIndexBehavior, l as DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, m as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, n as DEFAULT_AGENT_SPEC_ROUTE, o as DEFAULT_LLMS_FULL_TXT_ROUTE, p as DEFAULT_SKILL_MD_ROUTE, q as deepMerge, r as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, s as DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, t as DEFAULT_AGENT_FEEDBACK_ROUTE, u as DEFAULT_MCP_PUBLIC_ROUTE, v as isDocsMcpRequest, w as renderDocsSkillDocument, x as normalizeDocsPathSegment, y as isDocsPublicGetRequest, z as buildPageTwitter } from "./agent-BMOtZLMC.mjs";
2
- import { _ as renderDocsRelatedMarkdownLines, a as createSimpleSearchAdapter, b as createDocsCloudAnalytics, c as resolveSearchRequestConfig, d as hashGeneratedAgentContent, f as normalizeGeneratedAgentContent, g as normalizeDocsRelated, h as stripGeneratedAgentProvenance, i as createMcpSearchAdapter, l as GENERATED_AGENT_PROVENANCE_MARKER, m as serializeGeneratedAgentDocument, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, p as parseGeneratedAgentDocument, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments, u as GENERATED_AGENT_PROVENANCE_VERSION, v as emitDocsAnalyticsEvent, y as resolveDocsAnalyticsConfig } from "./search-BhXicuww.mjs";
1
+ import { A as resolvePageReadingTime, B as resolveDocsPath, C as renderDocsMarkdownDocument, D as resolveDocsMarkdownRequest, E as resolveDocsLlmsTxtFormat, F as buildPageTwitter, G as defineDocs, H as extendTheme, I as resolveOGImage, L as resolveTitle, M as resolveReadingTimeFromSource, N as resolveReadingTimeOptions, O as resolveDocsSkillFormat, P as buildPageOpenGraph, R as resolveDocsI18n, S as normalizeDocsUrlPath, T as resolveDocsAgentMdxContent, U as deepMerge, V as createTheme, W as resolveChangelogConfig, _ as isDocsAgentDiscoveryRequest, a as DEFAULT_DOCS_API_ROUTE, b as isDocsSkillRequest, c as DEFAULT_LLMS_TXT_ROUTE, d as DEFAULT_MCP_ROUTE, f as DEFAULT_MCP_WELL_KNOWN_ROUTE, g as findDocsMarkdownPage, h as buildDocsAgentDiscoverySpec, i as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, j as resolveReadingTimeFromContent, k as estimateReadingTimeMinutes, l as DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, m as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, n as DEFAULT_AGENT_SPEC_ROUTE, o as DEFAULT_LLMS_FULL_TXT_ROUTE, p as DEFAULT_SKILL_MD_ROUTE, r as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, s as DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, t as DEFAULT_AGENT_FEEDBACK_ROUTE, u as DEFAULT_MCP_PUBLIC_ROUTE, v as isDocsMcpRequest, w as renderDocsSkillDocument, x as normalizeDocsPathSegment, y as isDocsPublicGetRequest, z as resolveDocsLocale } from "./agent-D87B57Wv.mjs";
2
+ import { A as createDocsCloudAnalytics, C as createDocsAgentTraceContext, D as emitDocsObservabilityEvent, E as emitDocsAnalyticsEvent, O as resolveDocsAnalyticsConfig, S as DOCS_AGENT_TRACE_EVENT_TYPES, T as emitDocsAgentTraceEvent, _ as resolvePageSidebarFolderIndexBehavior, a as createSimpleSearchAdapter, b as normalizeDocsRelated, c as resolveSearchRequestConfig, d as hashGeneratedAgentContent, f as normalizeGeneratedAgentContent, g as applySidebarFolderIndexBehavior, h as stripGeneratedAgentProvenance, i as createMcpSearchAdapter, k as resolveDocsObservabilityConfig, l as GENERATED_AGENT_PROVENANCE_MARKER, m as serializeGeneratedAgentDocument, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, p as parseGeneratedAgentDocument, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments, u as GENERATED_AGENT_PROVENANCE_VERSION, v as resolveSidebarFolderIndexBehavior, w as createDocsAgentTraceId, x as renderDocsRelatedMarkdownLines, y as resolveSidebarFolderIndexBehaviorForPath } from "./search-Bk7rg-AY.mjs";
3
3
 
4
- export { DEFAULT_AGENT_FEEDBACK_ROUTE, DEFAULT_AGENT_SPEC_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, DEFAULT_DOCS_API_ROUTE, DEFAULT_LLMS_FULL_TXT_ROUTE, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, DEFAULT_LLMS_TXT_ROUTE, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, DEFAULT_MCP_PUBLIC_ROUTE, DEFAULT_MCP_ROUTE, DEFAULT_MCP_WELL_KNOWN_ROUTE, DEFAULT_SKILL_MD_ROUTE, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, GENERATED_AGENT_PROVENANCE_MARKER, GENERATED_AGENT_PROVENANCE_VERSION, applySidebarFolderIndexBehavior, buildDocsAgentDiscoverySpec, buildDocsSearchDocuments, buildPageOpenGraph, buildPageTwitter, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsCloudAnalytics, createMcpSearchAdapter, createSimpleSearchAdapter, createTheme, createTypesenseSearchAdapter, deepMerge, defineDocs, emitDocsAnalyticsEvent, estimateReadingTimeMinutes, extendTheme, findDocsMarkdownPage, hashGeneratedAgentContent, isDocsAgentDiscoveryRequest, isDocsMcpRequest, isDocsPublicGetRequest, isDocsSkillRequest, normalizeDocsPathSegment, normalizeDocsRelated, normalizeDocsUrlPath, normalizeGeneratedAgentContent, parseGeneratedAgentDocument, performDocsSearch, renderDocsMarkdownDocument, renderDocsRelatedMarkdownLines, renderDocsSkillDocument, resolveChangelogConfig, resolveDocsAgentMdxContent, resolveDocsAnalyticsConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsPath, resolveDocsSkillFormat, resolveOGImage, resolvePageReadingTime, resolvePageSidebarFolderIndexBehavior, resolveReadingTimeFromContent, resolveReadingTimeFromSource, resolveReadingTimeOptions, resolveSearchRequestConfig, resolveSidebarFolderIndexBehavior, resolveSidebarFolderIndexBehaviorForPath, resolveTitle, serializeGeneratedAgentDocument, stripGeneratedAgentProvenance };
4
+ export { DEFAULT_AGENT_FEEDBACK_ROUTE, DEFAULT_AGENT_SPEC_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, DEFAULT_DOCS_API_ROUTE, DEFAULT_LLMS_FULL_TXT_ROUTE, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, DEFAULT_LLMS_TXT_ROUTE, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, DEFAULT_MCP_PUBLIC_ROUTE, DEFAULT_MCP_ROUTE, DEFAULT_MCP_WELL_KNOWN_ROUTE, DEFAULT_SKILL_MD_ROUTE, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, DOCS_AGENT_TRACE_EVENT_TYPES, GENERATED_AGENT_PROVENANCE_MARKER, GENERATED_AGENT_PROVENANCE_VERSION, applySidebarFolderIndexBehavior, buildDocsAgentDiscoverySpec, buildDocsSearchDocuments, buildPageOpenGraph, buildPageTwitter, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAnalytics, createMcpSearchAdapter, createSimpleSearchAdapter, createTheme, createTypesenseSearchAdapter, deepMerge, defineDocs, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, estimateReadingTimeMinutes, extendTheme, findDocsMarkdownPage, hashGeneratedAgentContent, isDocsAgentDiscoveryRequest, isDocsMcpRequest, isDocsPublicGetRequest, isDocsSkillRequest, normalizeDocsPathSegment, normalizeDocsRelated, normalizeDocsUrlPath, normalizeGeneratedAgentContent, parseGeneratedAgentDocument, performDocsSearch, renderDocsMarkdownDocument, renderDocsRelatedMarkdownLines, renderDocsSkillDocument, resolveChangelogConfig, resolveDocsAgentMdxContent, resolveDocsAnalyticsConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsObservabilityConfig, resolveDocsPath, resolveDocsSkillFormat, resolveOGImage, resolvePageReadingTime, resolvePageSidebarFolderIndexBehavior, resolveReadingTimeFromContent, resolveReadingTimeFromSource, resolveReadingTimeOptions, resolveSearchRequestConfig, resolveSidebarFolderIndexBehavior, resolveSidebarFolderIndexBehaviorForPath, resolveTitle, serializeGeneratedAgentDocument, stripGeneratedAgentProvenance };
@@ -1,4 +1,4 @@
1
- import "./search-BhXicuww.mjs";
1
+ import "./search-Bk7rg-AY.mjs";
2
2
  import "./prompt-utils-8nmFLQVH.mjs";
3
3
  import { createFilesystemDocsMcpSource, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
4
4
  import "./server.mjs";
package/dist/mcp.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as DocsSearchConfig, Z as OrderingItem, m as DocsAnalyticsConfig, w as DocsMcpConfig, z as DocsSearchSourcePage } from "./types-BXgTvFFE.mjs";
1
+ import { D as DocsMcpConfig, G as DocsSearchSourcePage, _ as DocsAnalyticsConfig, j as DocsObservabilityConfig, rt as OrderingItem, z as DocsSearchConfig } from "./types-CgBlM_yI.mjs";
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
 
4
4
  //#region src/mcp.d.ts
@@ -69,6 +69,7 @@ interface CreateDocsMcpServerOptions {
69
69
  mcp?: boolean | DocsMcpConfig;
70
70
  search?: boolean | DocsSearchConfig;
71
71
  analytics?: boolean | DocsAnalyticsConfig;
72
+ observability?: boolean | DocsObservabilityConfig;
72
73
  defaultName?: string;
73
74
  defaultVersion?: string;
74
75
  }
package/dist/mcp.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as renderDocsRelatedMarkdownLines, g as normalizeDocsRelated, h as stripGeneratedAgentProvenance, s as performDocsSearch, v as emitDocsAnalyticsEvent } from "./search-BhXicuww.mjs";
1
+ import { C as createDocsAgentTraceContext, E as emitDocsAnalyticsEvent, T as emitDocsAgentTraceEvent, _ as resolvePageSidebarFolderIndexBehavior, b as normalizeDocsRelated, h as stripGeneratedAgentProvenance, s as performDocsSearch, w as createDocsAgentTraceId, x as renderDocsRelatedMarkdownLines } from "./search-Bk7rg-AY.mjs";
2
2
  import matter from "gray-matter";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
@@ -130,21 +130,69 @@ async function createDocsMcpServer(options) {
130
130
  annotations: { readOnlyHint: true }
131
131
  }, async ({ locale }) => {
132
132
  const startedAt = nowMs();
133
- const pages = toPageSummaries(dedupePages(await options.source.getPages(locale)));
134
- await emitDocsAnalyticsEvent(options.analytics, {
135
- type: "mcp_tool",
133
+ const trace = createDocsAgentTraceContext("mcp.tool.list_pages");
134
+ const callSpanId = createDocsAgentTraceId("span");
135
+ await emitDocsAgentTraceEvent(options.observability, {
136
+ type: "tool.call",
136
137
  source: "mcp",
138
+ traceId: trace.traceId,
139
+ spanId: callSpanId,
140
+ name: "list_pages",
141
+ startedAt: trace.startedAt,
142
+ status: "started",
137
143
  locale,
138
- properties: {
139
- tool: "list_pages",
140
- resultCount: pages.length,
141
- durationMs: durationMs(startedAt)
142
- }
144
+ inputPreview: { locale },
145
+ metadata: { tool: "list_pages" }
143
146
  });
144
- return { content: [{
145
- type: "text",
146
- text: JSON.stringify({ pages }, null, 2)
147
- }] };
147
+ try {
148
+ const pages = toPageSummaries(dedupePages(await options.source.getPages(locale)));
149
+ const elapsed = durationMs(startedAt);
150
+ await emitDocsAnalyticsEvent(options.analytics, {
151
+ type: "mcp_tool",
152
+ source: "mcp",
153
+ locale,
154
+ properties: {
155
+ tool: "list_pages",
156
+ resultCount: pages.length,
157
+ durationMs: elapsed
158
+ }
159
+ });
160
+ await emitDocsAgentTraceEvent(options.observability, {
161
+ type: "tool.result",
162
+ source: "mcp",
163
+ traceId: trace.traceId,
164
+ parentSpanId: callSpanId,
165
+ name: "list_pages",
166
+ startedAt: trace.startedAt,
167
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
168
+ durationMs: elapsed,
169
+ status: "success",
170
+ locale,
171
+ outputPreview: { resultCount: pages.length },
172
+ metadata: { tool: "list_pages" }
173
+ });
174
+ return { content: [{
175
+ type: "text",
176
+ text: JSON.stringify({ pages }, null, 2)
177
+ }] };
178
+ } catch (error) {
179
+ const elapsed = durationMs(startedAt);
180
+ await emitDocsAgentTraceEvent(options.observability, {
181
+ type: "tool.error",
182
+ source: "mcp",
183
+ traceId: trace.traceId,
184
+ parentSpanId: callSpanId,
185
+ name: "list_pages",
186
+ startedAt: trace.startedAt,
187
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
188
+ durationMs: elapsed,
189
+ status: "error",
190
+ locale,
191
+ outputPreview: { message: error instanceof Error ? error.message : "Unknown error" },
192
+ metadata: { tool: "list_pages" }
193
+ });
194
+ throw error;
195
+ }
148
196
  });
149
197
  if (resolved.tools.getNavigation) server.registerTool("get_navigation", {
150
198
  title: "Get docs navigation",
@@ -153,20 +201,68 @@ async function createDocsMcpServer(options) {
153
201
  annotations: { readOnlyHint: true }
154
202
  }, async ({ locale }) => {
155
203
  const startedAt = nowMs();
156
- const tree = await options.source.getNavigation(locale);
157
- await emitDocsAnalyticsEvent(options.analytics, {
158
- type: "mcp_tool",
204
+ const trace = createDocsAgentTraceContext("mcp.tool.get_navigation");
205
+ const callSpanId = createDocsAgentTraceId("span");
206
+ await emitDocsAgentTraceEvent(options.observability, {
207
+ type: "tool.call",
159
208
  source: "mcp",
209
+ traceId: trace.traceId,
210
+ spanId: callSpanId,
211
+ name: "get_navigation",
212
+ startedAt: trace.startedAt,
213
+ status: "started",
160
214
  locale,
161
- properties: {
162
- tool: "get_navigation",
163
- durationMs: durationMs(startedAt)
164
- }
215
+ inputPreview: { locale },
216
+ metadata: { tool: "get_navigation" }
165
217
  });
166
- return { content: [{
167
- type: "text",
168
- text: renderNavigationTree(tree)
169
- }] };
218
+ try {
219
+ const text = renderNavigationTree(await options.source.getNavigation(locale));
220
+ const elapsed = durationMs(startedAt);
221
+ await emitDocsAnalyticsEvent(options.analytics, {
222
+ type: "mcp_tool",
223
+ source: "mcp",
224
+ locale,
225
+ properties: {
226
+ tool: "get_navigation",
227
+ durationMs: elapsed
228
+ }
229
+ });
230
+ await emitDocsAgentTraceEvent(options.observability, {
231
+ type: "tool.result",
232
+ source: "mcp",
233
+ traceId: trace.traceId,
234
+ parentSpanId: callSpanId,
235
+ name: "get_navigation",
236
+ startedAt: trace.startedAt,
237
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
238
+ durationMs: elapsed,
239
+ status: "success",
240
+ locale,
241
+ outputPreview: { chars: text.length },
242
+ metadata: { tool: "get_navigation" }
243
+ });
244
+ return { content: [{
245
+ type: "text",
246
+ text
247
+ }] };
248
+ } catch (error) {
249
+ const elapsed = durationMs(startedAt);
250
+ await emitDocsAgentTraceEvent(options.observability, {
251
+ type: "tool.error",
252
+ source: "mcp",
253
+ traceId: trace.traceId,
254
+ parentSpanId: callSpanId,
255
+ name: "get_navigation",
256
+ startedAt: trace.startedAt,
257
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
258
+ durationMs: elapsed,
259
+ status: "error",
260
+ locale,
261
+ outputPreview: { message: error instanceof Error ? error.message : "Unknown error" },
262
+ metadata: { tool: "get_navigation" }
263
+ });
264
+ throw error;
265
+ }
170
266
  });
171
267
  if (resolved.tools.searchDocs) server.registerTool("search_docs", {
172
268
  title: "Search documentation",
@@ -175,31 +271,84 @@ async function createDocsMcpServer(options) {
175
271
  annotations: { readOnlyHint: true }
176
272
  }, async ({ query, limit, locale }) => {
177
273
  const startedAt = nowMs();
178
- const results = await performDocsSearch({
179
- pages: toSearchSourcePages(dedupePages(await options.source.getPages(locale))),
180
- query,
181
- search: toolSearchConfig ?? true,
182
- locale,
183
- siteTitle: options.source.siteTitle,
184
- limit: limit ?? 10
185
- });
186
- await emitDocsAnalyticsEvent(options.analytics, {
187
- type: "mcp_tool",
274
+ const resolvedLimit = limit ?? 10;
275
+ const trace = createDocsAgentTraceContext("mcp.tool.search_docs");
276
+ const callSpanId = createDocsAgentTraceId("span");
277
+ await emitDocsAgentTraceEvent(options.observability, {
278
+ type: "tool.call",
188
279
  source: "mcp",
280
+ traceId: trace.traceId,
281
+ spanId: callSpanId,
282
+ name: "search_docs",
283
+ startedAt: trace.startedAt,
284
+ status: "started",
189
285
  locale,
190
- input: { query },
191
- properties: {
192
- tool: "search_docs",
286
+ inputPreview: {
193
287
  queryLength: query.length,
194
- limit: limit ?? 10,
195
- resultCount: results.length,
196
- durationMs: durationMs(startedAt)
197
- }
288
+ limit: resolvedLimit,
289
+ locale
290
+ },
291
+ metadata: { tool: "search_docs" }
198
292
  });
199
- return { content: [{
200
- type: "text",
201
- text: JSON.stringify({ results }, null, 2)
202
- }] };
293
+ try {
294
+ const results = await performDocsSearch({
295
+ pages: toSearchSourcePages(dedupePages(await options.source.getPages(locale))),
296
+ query,
297
+ search: toolSearchConfig ?? true,
298
+ locale,
299
+ siteTitle: options.source.siteTitle,
300
+ limit: resolvedLimit
301
+ });
302
+ const elapsed = durationMs(startedAt);
303
+ await emitDocsAnalyticsEvent(options.analytics, {
304
+ type: "mcp_tool",
305
+ source: "mcp",
306
+ locale,
307
+ input: { query },
308
+ properties: {
309
+ tool: "search_docs",
310
+ queryLength: query.length,
311
+ limit: resolvedLimit,
312
+ resultCount: results.length,
313
+ durationMs: elapsed
314
+ }
315
+ });
316
+ await emitDocsAgentTraceEvent(options.observability, {
317
+ type: "tool.result",
318
+ source: "mcp",
319
+ traceId: trace.traceId,
320
+ parentSpanId: callSpanId,
321
+ name: "search_docs",
322
+ startedAt: trace.startedAt,
323
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
324
+ durationMs: elapsed,
325
+ status: "success",
326
+ locale,
327
+ outputPreview: { resultCount: results.length },
328
+ metadata: { tool: "search_docs" }
329
+ });
330
+ return { content: [{
331
+ type: "text",
332
+ text: JSON.stringify({ results }, null, 2)
333
+ }] };
334
+ } catch (error) {
335
+ const elapsed = durationMs(startedAt);
336
+ await emitDocsAgentTraceEvent(options.observability, {
337
+ type: "tool.error",
338
+ source: "mcp",
339
+ traceId: trace.traceId,
340
+ parentSpanId: callSpanId,
341
+ name: "search_docs",
342
+ startedAt: trace.startedAt,
343
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
344
+ durationMs: elapsed,
345
+ status: "error",
346
+ locale,
347
+ outputPreview: { message: error instanceof Error ? error.message : "Unknown error" },
348
+ metadata: { tool: "search_docs" }
349
+ });
350
+ throw error;
351
+ }
203
352
  });
204
353
  if (resolved.tools.readPage) server.registerTool("read_page", {
205
354
  title: "Read a docs page",
@@ -208,73 +357,150 @@ async function createDocsMcpServer(options) {
208
357
  annotations: { readOnlyHint: true }
209
358
  }, async ({ path: requestedPath, locale }) => {
210
359
  const startedAt = nowMs();
211
- const page = findDocsPage(dedupePages(await options.source.getPages(locale)), requestedPath, options.source.entry);
212
- if (!page) {
360
+ const trace = createDocsAgentTraceContext("mcp.tool.read_page");
361
+ const callSpanId = createDocsAgentTraceId("span");
362
+ await emitDocsAgentTraceEvent(options.observability, {
363
+ type: "tool.call",
364
+ source: "mcp",
365
+ traceId: trace.traceId,
366
+ spanId: callSpanId,
367
+ name: "read_page",
368
+ startedAt: trace.startedAt,
369
+ status: "started",
370
+ locale,
371
+ inputPreview: {
372
+ path: requestedPath,
373
+ locale
374
+ },
375
+ metadata: { tool: "read_page" }
376
+ });
377
+ try {
378
+ const page = findDocsPage(dedupePages(await options.source.getPages(locale)), requestedPath, options.source.entry);
379
+ if (!page) {
380
+ const elapsed = durationMs(startedAt);
381
+ await emitDocsAnalyticsEvent(options.analytics, {
382
+ type: "agent_read",
383
+ source: "mcp",
384
+ locale,
385
+ properties: {
386
+ delivery: "mcp_tool",
387
+ tool: "read_page",
388
+ requestedPath,
389
+ found: false,
390
+ durationMs: elapsed
391
+ }
392
+ });
393
+ await emitDocsAnalyticsEvent(options.analytics, {
394
+ type: "mcp_tool",
395
+ source: "mcp",
396
+ locale,
397
+ properties: {
398
+ tool: "read_page",
399
+ path: requestedPath,
400
+ found: false,
401
+ durationMs: elapsed
402
+ }
403
+ });
404
+ await emitDocsAgentTraceEvent(options.observability, {
405
+ type: "tool.error",
406
+ source: "mcp",
407
+ traceId: trace.traceId,
408
+ parentSpanId: callSpanId,
409
+ name: "read_page",
410
+ startedAt: trace.startedAt,
411
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
412
+ durationMs: elapsed,
413
+ status: "error",
414
+ locale,
415
+ outputPreview: {
416
+ found: false,
417
+ path: requestedPath
418
+ },
419
+ metadata: {
420
+ tool: "read_page",
421
+ reason: "not_found"
422
+ }
423
+ });
424
+ return {
425
+ content: [{
426
+ type: "text",
427
+ text: JSON.stringify({ error: `No docs page matched "${requestedPath}".` }, null, 2)
428
+ }],
429
+ isError: true
430
+ };
431
+ }
432
+ const document = renderPageDocument(page);
433
+ const elapsed = durationMs(startedAt);
213
434
  await emitDocsAnalyticsEvent(options.analytics, {
214
435
  type: "agent_read",
215
436
  source: "mcp",
216
437
  locale,
438
+ path: page.url,
217
439
  properties: {
218
440
  delivery: "mcp_tool",
219
441
  tool: "read_page",
220
442
  requestedPath,
221
- found: false,
222
- durationMs: durationMs(startedAt)
443
+ slug: page.slug,
444
+ found: true,
445
+ contentLength: document.length,
446
+ durationMs: elapsed
223
447
  }
224
448
  });
225
449
  await emitDocsAnalyticsEvent(options.analytics, {
226
450
  type: "mcp_tool",
227
451
  source: "mcp",
228
452
  locale,
453
+ path: page.url,
229
454
  properties: {
230
455
  tool: "read_page",
231
- path: requestedPath,
232
- found: false,
233
- durationMs: durationMs(startedAt)
456
+ requestedPath,
457
+ slug: page.slug,
458
+ found: true,
459
+ contentLength: document.length,
460
+ durationMs: elapsed
234
461
  }
235
462
  });
236
- return {
237
- content: [{
238
- type: "text",
239
- text: JSON.stringify({ error: `No docs page matched "${requestedPath}".` }, null, 2)
240
- }],
241
- isError: true
242
- };
463
+ await emitDocsAgentTraceEvent(options.observability, {
464
+ type: "tool.result",
465
+ source: "mcp",
466
+ traceId: trace.traceId,
467
+ parentSpanId: callSpanId,
468
+ name: "read_page",
469
+ startedAt: trace.startedAt,
470
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
471
+ durationMs: elapsed,
472
+ status: "success",
473
+ locale,
474
+ path: page.url,
475
+ outputPreview: {
476
+ found: true,
477
+ chars: document.length,
478
+ slug: page.slug
479
+ },
480
+ metadata: { tool: "read_page" }
481
+ });
482
+ return { content: [{
483
+ type: "text",
484
+ text: document
485
+ }] };
486
+ } catch (error) {
487
+ const elapsed = durationMs(startedAt);
488
+ await emitDocsAgentTraceEvent(options.observability, {
489
+ type: "tool.error",
490
+ source: "mcp",
491
+ traceId: trace.traceId,
492
+ parentSpanId: callSpanId,
493
+ name: "read_page",
494
+ startedAt: trace.startedAt,
495
+ endedAt: (/* @__PURE__ */ new Date()).toISOString(),
496
+ durationMs: elapsed,
497
+ status: "error",
498
+ locale,
499
+ outputPreview: { message: error instanceof Error ? error.message : "Unknown error" },
500
+ metadata: { tool: "read_page" }
501
+ });
502
+ throw error;
243
503
  }
244
- const document = renderPageDocument(page);
245
- await emitDocsAnalyticsEvent(options.analytics, {
246
- type: "agent_read",
247
- source: "mcp",
248
- locale,
249
- path: page.url,
250
- properties: {
251
- delivery: "mcp_tool",
252
- tool: "read_page",
253
- requestedPath,
254
- slug: page.slug,
255
- found: true,
256
- contentLength: document.length,
257
- durationMs: durationMs(startedAt)
258
- }
259
- });
260
- await emitDocsAnalyticsEvent(options.analytics, {
261
- type: "mcp_tool",
262
- source: "mcp",
263
- locale,
264
- path: page.url,
265
- properties: {
266
- tool: "read_page",
267
- requestedPath,
268
- slug: page.slug,
269
- found: true,
270
- contentLength: document.length,
271
- durationMs: durationMs(startedAt)
272
- }
273
- });
274
- return { content: [{
275
- type: "text",
276
- text: document
277
- }] };
278
504
  });
279
505
  return server;
280
506
  }
@@ -462,6 +688,39 @@ function resolveAgentMdxContent(content, audience) {
462
688
  function stripMarkdownForMcp(content) {
463
689
  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();
464
690
  }
691
+ function resolveFilesystemDocsPageSource(dir) {
692
+ return [
693
+ "page.mdx",
694
+ "page.md",
695
+ "page.svx"
696
+ ].map((fileName) => path.join(dir, fileName)).find((candidate) => fs.existsSync(candidate));
697
+ }
698
+ function hasVisibleDescendantFilesystemDocsPage(dir) {
699
+ let entries;
700
+ try {
701
+ entries = fs.readdirSync(dir);
702
+ } catch {
703
+ return false;
704
+ }
705
+ for (const name of entries.sort()) {
706
+ const full = path.join(dir, name);
707
+ try {
708
+ if (!fs.statSync(full).isDirectory()) continue;
709
+ } catch {
710
+ continue;
711
+ }
712
+ const pageSource = resolveFilesystemDocsPageSource(full);
713
+ if (pageSource) try {
714
+ const data = matter(fs.readFileSync(pageSource, "utf-8")).data;
715
+ const hiddenFolderIndex = resolvePageSidebarFolderIndexBehavior(data.sidebar) === "hidden";
716
+ if (data.hidden !== true && !hiddenFolderIndex) return true;
717
+ } catch {
718
+ return true;
719
+ }
720
+ if (hasVisibleDescendantFilesystemDocsPage(full)) return true;
721
+ }
722
+ return false;
723
+ }
465
724
  function scanFilesystemDocsPages(contentDirAbs, entry) {
466
725
  const pages = [];
467
726
  function scan(dir, slugParts) {
@@ -476,11 +735,12 @@ function scanFilesystemDocsPages(contentDirAbs, entry) {
476
735
  if (name === "agent.md") continue;
477
736
  if (!name.endsWith(".md") && !name.endsWith(".mdx") && !name.endsWith(".svx")) continue;
478
737
  const { data, content } = matter(fs.readFileSync(full, "utf-8"));
738
+ const baseName = name.replace(/\.(md|mdx|svx)$/, "");
739
+ const isIndex = baseName === "index" || baseName === "page" || baseName === "+page";
740
+ if (isIndex && resolvePageSidebarFolderIndexBehavior(data.sidebar) === "hidden" && hasVisibleDescendantFilesystemDocsPage(dir)) continue;
479
741
  const humanRawContent = resolveAgentMdxContent(content, "human");
480
742
  const pageAgentRawContent = resolveAgentMdxContent(content, "agent");
481
743
  const pageAgentContent = pageAgentRawContent !== humanRawContent ? stripMarkdownForMcp(pageAgentRawContent) : void 0;
482
- const baseName = name.replace(/\.(md|mdx|svx)$/, "");
483
- const isIndex = baseName === "index" || baseName === "page" || baseName === "+page";
484
744
  const slug = isIndex ? slugParts.join("/") : [...slugParts, baseName].join("/");
485
745
  const url = slug ? `/${entry}/${slug}` : `/${entry}`;
486
746
  const agentDoc = isIndex ? readFilesystemAgentDoc(dir) : void 0;
@@ -54,6 +54,29 @@ function createDocsCloudAnalytics(options = {}) {
54
54
 
55
55
  //#endregion
56
56
  //#region src/analytics.ts
57
+ const ANALYTICS_LOG_PREFIX = "[@farming-labs/docs:analytics]";
58
+ const OBSERVABILITY_LOG_PREFIX = "[@farming-labs/docs:observability]";
59
+ const DOCS_AGENT_TRACE_EVENT_TYPES = [
60
+ "run.start",
61
+ "run.end",
62
+ "run.error",
63
+ "user.input",
64
+ "prompt.build",
65
+ "retrieval.query",
66
+ "retrieval.result",
67
+ "retrieval.error",
68
+ "model.call",
69
+ "model.response",
70
+ "model.stream",
71
+ "model.error",
72
+ "tool.call",
73
+ "tool.result",
74
+ "tool.error",
75
+ "retry",
76
+ "timeout",
77
+ "error",
78
+ "agent.final"
79
+ ];
57
80
  function composeAnalyticsHandlers(userOnEvent, cloudOnEvent) {
58
81
  if (typeof userOnEvent !== "function" && !cloudOnEvent) return;
59
82
  return async (event) => {
@@ -75,6 +98,17 @@ function resolveConsoleLevel(value, hasEventHandler) {
75
98
  if (value === "log" || value === "info" || value === "debug") return value;
76
99
  return hasEventHandler ? false : "info";
77
100
  }
101
+ function createDocsAgentTraceId(prefix = "trace") {
102
+ return `${prefix.replace(/[^a-zA-Z0-9_-]/g, "_") || "trace"}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
103
+ }
104
+ function createDocsAgentTraceContext(name = "agent.run") {
105
+ return {
106
+ traceId: createDocsAgentTraceId("run"),
107
+ name,
108
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
109
+ startedMs: Date.now()
110
+ };
111
+ }
78
112
  function resolveDocsAnalyticsConfig(analytics) {
79
113
  const cloudOptions = resolveDocsCloudAnalyticsOptions(analytics);
80
114
  const cloudOnEvent = cloudOptions ? async (event) => {
@@ -109,6 +143,25 @@ function resolveDocsAnalyticsConfig(analytics) {
109
143
  onEvent
110
144
  };
111
145
  }
146
+ function resolveDocsObservabilityConfig(observability) {
147
+ if (!observability) return {
148
+ enabled: false,
149
+ console: false,
150
+ includeInputs: false
151
+ };
152
+ if (observability === true) return {
153
+ enabled: true,
154
+ console: "info",
155
+ includeInputs: false
156
+ };
157
+ const hasEventHandler = typeof observability.onEvent === "function";
158
+ return {
159
+ enabled: observability.enabled !== false,
160
+ console: resolveConsoleLevel(observability.console, hasEventHandler),
161
+ includeInputs: observability.includeInputs === true,
162
+ onEvent: observability.onEvent
163
+ };
164
+ }
112
165
  function normalizeAnalyticsEvent(event, config) {
113
166
  const normalized = {
114
167
  ...event,
@@ -118,18 +171,51 @@ function normalizeAnalyticsEvent(event, config) {
118
171
  if (!config.includeInputs && normalized.input) delete normalized.input;
119
172
  return normalized;
120
173
  }
174
+ function normalizeObservabilityEvent(event, config) {
175
+ const normalized = {
176
+ ...event,
177
+ source: event.source ?? "server",
178
+ timestamp: event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
179
+ };
180
+ if (!config.includeInputs && normalized.input) delete normalized.input;
181
+ return normalized;
182
+ }
121
183
  async function emitDocsAnalyticsEvent(analytics, event) {
122
184
  const resolved = resolveDocsAnalyticsConfig(analytics);
123
185
  if (!resolved.enabled) return;
124
186
  const normalized = normalizeAnalyticsEvent(event, resolved);
125
- if (resolved.console) (console[resolved.console] ?? console.info).call(console, "[farming-labs:analytics]", normalized);
187
+ if (resolved.console) (console[resolved.console] ?? console.info).call(console, ANALYTICS_LOG_PREFIX, normalized);
188
+ if (!resolved.onEvent) return;
189
+ try {
190
+ await resolved.onEvent(normalized);
191
+ } catch (error) {
192
+ if (resolved.console !== false) console.warn(`${ANALYTICS_LOG_PREFIX} onEvent failed`, error);
193
+ }
194
+ }
195
+ async function emitDocsObservabilityEvent(observability, event) {
196
+ const resolved = resolveDocsObservabilityConfig(observability);
197
+ if (!resolved.enabled) return;
198
+ const normalized = normalizeObservabilityEvent(event, resolved);
199
+ if (resolved.console) (console[resolved.console] ?? console.info).call(console, OBSERVABILITY_LOG_PREFIX, normalized);
126
200
  if (!resolved.onEvent) return;
127
201
  try {
128
202
  await resolved.onEvent(normalized);
129
203
  } catch (error) {
130
- if (resolved.console !== false) console.warn("[farming-labs:analytics] onEvent failed", error);
204
+ if (resolved.console !== false) console.warn(`${OBSERVABILITY_LOG_PREFIX} onEvent failed`, error);
131
205
  }
132
206
  }
207
+ async function emitDocsAgentTraceEvent(observability, event) {
208
+ const timestamp = event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
209
+ await emitDocsObservabilityEvent(observability, {
210
+ ...event,
211
+ timestamp,
212
+ source: event.source ?? "server",
213
+ traceId: event.traceId ?? createDocsAgentTraceId("run"),
214
+ spanId: event.spanId ?? createDocsAgentTraceId("span"),
215
+ startedAt: event.startedAt ?? timestamp,
216
+ status: event.status ?? "success"
217
+ });
218
+ }
133
219
 
134
220
  //#endregion
135
221
  //#region src/related.ts
@@ -180,6 +266,78 @@ function normalizeInlineText(value) {
180
266
  return value.replace(/\s+/g, " ").trim();
181
267
  }
182
268
 
269
+ //#endregion
270
+ //#region src/sidebar.ts
271
+ function resolvePageSidebarFolderIndexBehavior(sidebar) {
272
+ if (!sidebar || typeof sidebar !== "object") return void 0;
273
+ const value = sidebar.folderIndexBehavior;
274
+ return value === "link" || value === "toggle" || value === "hidden" ? value : void 0;
275
+ }
276
+ function normalizeSidebarFolderBehaviorPath(path) {
277
+ if (!path) return void 0;
278
+ let value = path.trim();
279
+ if (!value) return void 0;
280
+ if (/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(value)) try {
281
+ value = new URL(value).pathname;
282
+ } catch {
283
+ return;
284
+ }
285
+ else value = value.split("#", 1)[0]?.split("?", 1)[0] ?? value;
286
+ if (!value.startsWith("/")) value = `/${value}`;
287
+ return value.replace(/\/$/, "") || "/";
288
+ }
289
+ function resolveSidebarFolderIndexBehavior(sidebar, defaultBehavior = "link") {
290
+ if (sidebar === void 0 || sidebar === true || sidebar === false) return defaultBehavior;
291
+ if (sidebar.folderIndexBehavior === "toggle") return "toggle";
292
+ if (sidebar.folderIndexBehavior === "hidden") return "hidden";
293
+ if (sidebar.folderIndexBehavior === "link") return "link";
294
+ return defaultBehavior;
295
+ }
296
+ function resolveSidebarFolderIndexBehaviorForPath(sidebar, folderPath, defaultBehavior = "link") {
297
+ const fallback = resolveSidebarFolderIndexBehavior(sidebar, defaultBehavior);
298
+ if (!sidebar || typeof sidebar !== "object") return fallback;
299
+ const normalizedPath = normalizeSidebarFolderBehaviorPath(folderPath);
300
+ if (!normalizedPath) return fallback;
301
+ for (const [rawPath, override] of Object.entries(sidebar.folderIndexBehaviorOverrides ?? {})) if (normalizeSidebarFolderBehaviorPath(rawPath) === normalizedPath) return override === "link" || override === "toggle" || override === "hidden" ? override : fallback;
302
+ return fallback;
303
+ }
304
+ function applySidebarFolderIndexBehavior(tree, behaviorOrOptions) {
305
+ const resolveBehavior = typeof behaviorOrOptions === "string" ? () => behaviorOrOptions : (folderPath) => resolveSidebarFolderIndexBehaviorForPath(behaviorOrOptions.sidebar, folderPath, behaviorOrOptions.defaultBehavior);
306
+ function mapNode(node) {
307
+ if (!node || typeof node !== "object") return node;
308
+ const candidate = node;
309
+ if (candidate.type !== "folder" || !Array.isArray(candidate.children)) return node;
310
+ const children = candidate.children.map(mapNode);
311
+ const index = candidate.index ? mapNode(candidate.index) : void 0;
312
+ const folderPath = (typeof candidate.url === "string" ? candidate.url : void 0) || (candidate.index && typeof candidate.index === "object" && "url" in candidate.index && typeof candidate.index.url === "string" ? candidate.index.url ?? void 0 : void 0);
313
+ const behavior = (candidate.folderIndexBehavior === "link" || candidate.folderIndexBehavior === "toggle" || candidate.folderIndexBehavior === "hidden" ? candidate.folderIndexBehavior : void 0) ?? resolveBehavior(folderPath);
314
+ if (behavior === "link") return {
315
+ ...candidate,
316
+ folderIndexBehavior: void 0,
317
+ index,
318
+ children
319
+ };
320
+ if (behavior === "hidden") return {
321
+ ...candidate,
322
+ folderIndexBehavior: void 0,
323
+ index: void 0,
324
+ url: void 0,
325
+ children
326
+ };
327
+ return {
328
+ ...candidate,
329
+ folderIndexBehavior: void 0,
330
+ index: void 0,
331
+ url: void 0,
332
+ children: index ? [index, ...children] : children
333
+ };
334
+ }
335
+ return {
336
+ ...tree,
337
+ children: tree.children.map(mapNode)
338
+ };
339
+ }
340
+
183
341
  //#endregion
184
342
  //#region src/agent-provenance.ts
185
343
  const GENERATED_AGENT_PROVENANCE_MARKER = "@farming-labs/docs:generated";
@@ -927,4 +1085,4 @@ function createCustomSearchAdapter(adapter) {
927
1085
  }
928
1086
 
929
1087
  //#endregion
930
- export { renderDocsRelatedMarkdownLines as _, createSimpleSearchAdapter as a, createDocsCloudAnalytics as b, resolveSearchRequestConfig as c, hashGeneratedAgentContent as d, normalizeGeneratedAgentContent as f, normalizeDocsRelated as g, stripGeneratedAgentProvenance as h, createMcpSearchAdapter as i, GENERATED_AGENT_PROVENANCE_MARKER as l, serializeGeneratedAgentDocument as m, createAlgoliaSearchAdapter as n, createTypesenseSearchAdapter as o, parseGeneratedAgentDocument as p, createCustomSearchAdapter as r, performDocsSearch as s, buildDocsSearchDocuments as t, GENERATED_AGENT_PROVENANCE_VERSION as u, emitDocsAnalyticsEvent as v, resolveDocsAnalyticsConfig as y };
1088
+ export { createDocsCloudAnalytics as A, createDocsAgentTraceContext as C, emitDocsObservabilityEvent as D, emitDocsAnalyticsEvent as E, resolveDocsAnalyticsConfig as O, DOCS_AGENT_TRACE_EVENT_TYPES as S, emitDocsAgentTraceEvent as T, resolvePageSidebarFolderIndexBehavior as _, createSimpleSearchAdapter as a, normalizeDocsRelated as b, resolveSearchRequestConfig as c, hashGeneratedAgentContent as d, normalizeGeneratedAgentContent as f, applySidebarFolderIndexBehavior as g, stripGeneratedAgentProvenance as h, createMcpSearchAdapter as i, resolveDocsObservabilityConfig as k, GENERATED_AGENT_PROVENANCE_MARKER as l, serializeGeneratedAgentDocument as m, createAlgoliaSearchAdapter as n, createTypesenseSearchAdapter as o, parseGeneratedAgentDocument as p, createCustomSearchAdapter as r, performDocsSearch as s, buildDocsSearchDocuments as t, GENERATED_AGENT_PROVENANCE_VERSION as u, resolveSidebarFolderIndexBehavior as v, createDocsAgentTraceId as w, renderDocsRelatedMarkdownLines as x, resolveSidebarFolderIndexBehaviorForPath as y };
@@ -1,4 +1,4 @@
1
- import { n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, t as buildDocsSearchDocuments } from "./search-BhXicuww.mjs";
1
+ import { n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, t as buildDocsSearchDocuments } from "./search-Bk7rg-AY.mjs";
2
2
  import "./prompt-utils-8nmFLQVH.mjs";
3
3
  import { createFilesystemDocsMcpSource } from "./mcp.mjs";
4
4
  import "./server.mjs";
@@ -0,0 +1,59 @@
1
+ import { B as DocsSearchDocument, F as DocsSearchAdapter, G as DocsSearchSourcePage, L as DocsSearchAdapterFactory, M as DocsObservabilityEvent, N as DocsObservabilityEventInput, Q as McpDocsSearchConfig, R as DocsSearchChunkingConfig, U as DocsSearchResult, _ as DocsAnalyticsConfig, bt as TypesenseDocsSearchConfig, d as CustomDocsSearchConfig, j as DocsObservabilityConfig, m as DocsAgentTraceEventInput, r as AlgoliaDocsSearchConfig, v as DocsAnalyticsEvent, y as DocsAnalyticsEventInput, z as DocsSearchConfig } from "./types-CgBlM_yI.mjs";
2
+
3
+ //#region src/cloud-analytics.d.ts
4
+ interface DocsCloudAnalyticsOptions {
5
+ enabled?: boolean;
6
+ console?: DocsAnalyticsConfig["console"];
7
+ includeInputs?: boolean;
8
+ projectId?: string;
9
+ apiKey?: string;
10
+ }
11
+ declare function createDocsCloudAnalytics(options?: DocsCloudAnalyticsOptions): DocsAnalyticsConfig;
12
+ //#endregion
13
+ //#region src/analytics.d.ts
14
+ 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"];
15
+ interface DocsAgentTraceContext {
16
+ traceId: string;
17
+ name: string;
18
+ startedAt: string;
19
+ startedMs: number;
20
+ }
21
+ interface ResolvedDocsAnalyticsConfig {
22
+ enabled: boolean;
23
+ console: false | "log" | "info" | "debug";
24
+ includeInputs: boolean;
25
+ onEvent?: (event: DocsAnalyticsEvent) => void | Promise<void>;
26
+ }
27
+ interface ResolvedDocsObservabilityConfig {
28
+ enabled: boolean;
29
+ console: false | "log" | "info" | "debug";
30
+ includeInputs: boolean;
31
+ onEvent?: (event: DocsObservabilityEvent) => void | Promise<void>;
32
+ }
33
+ declare function createDocsAgentTraceId(prefix?: string): string;
34
+ declare function createDocsAgentTraceContext(name?: string): DocsAgentTraceContext;
35
+ declare function resolveDocsAnalyticsConfig(analytics?: boolean | DocsAnalyticsConfig): ResolvedDocsAnalyticsConfig;
36
+ declare function resolveDocsObservabilityConfig(observability?: boolean | DocsObservabilityConfig): ResolvedDocsObservabilityConfig;
37
+ declare function emitDocsAnalyticsEvent(analytics: boolean | DocsAnalyticsConfig | undefined, event: DocsAnalyticsEventInput): Promise<void>;
38
+ declare function emitDocsObservabilityEvent(observability: boolean | DocsObservabilityConfig | undefined, event: DocsObservabilityEventInput): Promise<void>;
39
+ declare function emitDocsAgentTraceEvent(observability: boolean | DocsObservabilityConfig | undefined, event: DocsAgentTraceEventInput): Promise<void>;
40
+ //#endregion
41
+ //#region src/search.d.ts
42
+ declare function buildDocsSearchDocuments(pages: DocsSearchSourcePage[], chunking?: DocsSearchChunkingConfig): DocsSearchDocument[];
43
+ declare function createSimpleSearchAdapter(): DocsSearchAdapter;
44
+ declare function createTypesenseSearchAdapter(config: TypesenseDocsSearchConfig): DocsSearchAdapter;
45
+ declare function resolveSearchRequestConfig(search: boolean | DocsSearchConfig | undefined, requestUrl?: string): boolean | DocsSearchConfig | undefined;
46
+ declare function createMcpSearchAdapter(config: McpDocsSearchConfig): DocsSearchAdapter;
47
+ declare function createAlgoliaSearchAdapter(config: AlgoliaDocsSearchConfig): DocsSearchAdapter;
48
+ declare function performDocsSearch(options: {
49
+ pages: DocsSearchSourcePage[];
50
+ query: string;
51
+ search?: boolean | DocsSearchConfig;
52
+ locale?: string;
53
+ pathname?: string;
54
+ siteTitle?: string;
55
+ limit?: number;
56
+ }): Promise<DocsSearchResult[]>;
57
+ declare function createCustomSearchAdapter(adapter: DocsSearchAdapter | DocsSearchAdapterFactory): CustomDocsSearchConfig;
58
+ //#endregion
59
+ export { emitDocsObservabilityEvent as _, createSimpleSearchAdapter as a, DocsCloudAnalyticsOptions as b, resolveSearchRequestConfig as c, ResolvedDocsAnalyticsConfig as d, ResolvedDocsObservabilityConfig as f, emitDocsAnalyticsEvent as g, emitDocsAgentTraceEvent as h, createMcpSearchAdapter as i, DOCS_AGENT_TRACE_EVENT_TYPES as l, createDocsAgentTraceId as m, createAlgoliaSearchAdapter as n, createTypesenseSearchAdapter as o, createDocsAgentTraceContext as p, createCustomSearchAdapter as r, performDocsSearch as s, buildDocsSearchDocuments as t, DocsAgentTraceContext as u, resolveDocsAnalyticsConfig as v, createDocsCloudAnalytics as x, resolveDocsObservabilityConfig as y };
package/dist/server.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as DocsSearchAdapterContext, I as DocsSearchQuery, K as McpDocsSearchConfig, L as DocsSearchResult, N as DocsSearchConfig, P as DocsSearchDocument, Y as OpenDocsProvider, a as ApiReferenceRenderer, b as DocsConfig, g as DocsAnalyticsEventInput, h as DocsAnalyticsEvent, j as DocsSearchAdapterFactory, k as DocsSearchAdapter, m as DocsAnalyticsConfig, z as DocsSearchSourcePage } from "./types-BXgTvFFE.mjs";
2
- import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, d as resolveDocsAnalyticsConfig, f as DocsCloudAnalyticsOptions, i as createMcpSearchAdapter, l as ResolvedDocsAnalyticsConfig, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, p as createDocsCloudAnalytics, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments, u as emitDocsAnalyticsEvent } from "./search-Gvi81BSo.mjs";
1
+ import { B as DocsSearchDocument, C as DocsConfig, F as DocsSearchAdapter, G as DocsSearchSourcePage, H as DocsSearchQuery, I as DocsSearchAdapterContext, L as DocsSearchAdapterFactory, M as DocsObservabilityEvent, N as DocsObservabilityEventInput, Q as McpDocsSearchConfig, U as DocsSearchResult, _ as DocsAnalyticsConfig, a as ApiReferenceRenderer, g as DocsAgentTraceStatus, h as DocsAgentTraceEventType, j as DocsObservabilityConfig, m as DocsAgentTraceEventInput, tt as OpenDocsProvider, v as DocsAnalyticsEvent, y as DocsAnalyticsEventInput, z as DocsSearchConfig } from "./types-CgBlM_yI.mjs";
2
+ import { _ as emitDocsObservabilityEvent, a as createSimpleSearchAdapter, b as DocsCloudAnalyticsOptions, c as resolveSearchRequestConfig, d as ResolvedDocsAnalyticsConfig, f as ResolvedDocsObservabilityConfig, g as emitDocsAnalyticsEvent, h as emitDocsAgentTraceEvent, i as createMcpSearchAdapter, l as DOCS_AGENT_TRACE_EVENT_TYPES, m as createDocsAgentTraceId, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, p as createDocsAgentTraceContext, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments, u as DocsAgentTraceContext, v as resolveDocsAnalyticsConfig, x as createDocsCloudAnalytics, y as resolveDocsObservabilityConfig } from "./search-COyfvf6H.mjs";
3
3
  import { DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpResolvedConfig, DocsMcpSource, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
4
4
 
5
5
  //#region src/api-reference.d.ts
@@ -63,4 +63,4 @@ declare function parsePromptStringArray(value: unknown): string[] | undefined;
63
63
  declare function resolvePromptProviderChoices(availableProviders?: PromptProviderInput[], preferredNames?: string[]): PromptProviderChoice[];
64
64
  declare function sanitizePromptText(text: string): string;
65
65
  //#endregion
66
- export { type ApiReferenceFramework, type ApiReferenceRenderer, type ApiReferenceRoute, DEFAULT_PROMPT_PROVIDER_TEMPLATES, type DocsAnalyticsConfig, type DocsAnalyticsEvent, type DocsAnalyticsEventInput, type DocsCloudAnalyticsOptions, type DocsMcpHttpHandlers, type DocsMcpNavigationNode, type DocsMcpNavigationTree, type DocsMcpPage, type DocsMcpResolvedConfig, type DocsMcpSource, type DocsSearchAdapter, type DocsSearchAdapterContext, type DocsSearchAdapterFactory, type DocsSearchConfig, type DocsSearchDocument, type DocsSearchQuery, type DocsSearchResult, type DocsSearchSourcePage, type McpDocsSearchConfig, type PromptAction, type PromptProviderChoice, type ResolvedApiReferenceConfig, type ResolvedDocsAnalyticsConfig, type SerializedOpenDocsProvider, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsSearchDocuments, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsCloudAnalytics, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, emitDocsAnalyticsEvent, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, resolveApiReferenceConfig, resolveApiReferenceRenderer, resolveDocsAnalyticsConfig, resolveDocsMcpConfig, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProviders };
66
+ export { type ApiReferenceFramework, type ApiReferenceRenderer, type ApiReferenceRoute, DEFAULT_PROMPT_PROVIDER_TEMPLATES, DOCS_AGENT_TRACE_EVENT_TYPES, type DocsAgentTraceContext, type DocsAgentTraceEventInput, type DocsAgentTraceEventType, type DocsAgentTraceStatus, type DocsAnalyticsConfig, type DocsAnalyticsEvent, type DocsAnalyticsEventInput, type DocsCloudAnalyticsOptions, type DocsMcpHttpHandlers, type DocsMcpNavigationNode, type DocsMcpNavigationTree, type DocsMcpPage, type DocsMcpResolvedConfig, type DocsMcpSource, type DocsObservabilityConfig, type DocsObservabilityEvent, type DocsObservabilityEventInput, type DocsSearchAdapter, type DocsSearchAdapterContext, type DocsSearchAdapterFactory, type DocsSearchConfig, type DocsSearchDocument, type DocsSearchQuery, type DocsSearchResult, type DocsSearchSourcePage, type McpDocsSearchConfig, type PromptAction, type PromptProviderChoice, type ResolvedApiReferenceConfig, type ResolvedDocsAnalyticsConfig, type ResolvedDocsObservabilityConfig, type SerializedOpenDocsProvider, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsSearchDocuments, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAnalytics, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, resolveApiReferenceConfig, resolveApiReferenceRenderer, resolveDocsAnalyticsConfig, resolveDocsMcpConfig, resolveDocsObservabilityConfig, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProviders };
package/dist/server.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as createSimpleSearchAdapter, b as createDocsCloudAnalytics, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments, v as emitDocsAnalyticsEvent, y as resolveDocsAnalyticsConfig } from "./search-BhXicuww.mjs";
1
+ import { A as createDocsCloudAnalytics, C as createDocsAgentTraceContext, D as emitDocsObservabilityEvent, E as emitDocsAnalyticsEvent, O as resolveDocsAnalyticsConfig, S as DOCS_AGENT_TRACE_EVENT_TYPES, T as emitDocsAgentTraceEvent, a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, k as resolveDocsObservabilityConfig, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments, w as createDocsAgentTraceId } from "./search-Bk7rg-AY.mjs";
2
2
  import { a as sanitizePromptText, c as serializeOpenDocsProviders, d as buildApiReferenceOpenApiDocument, f as buildApiReferenceOpenApiDocumentAsync, g as resolveApiReferenceRenderer, h as resolveApiReferenceConfig, i as resolvePromptProviderChoices, l as buildApiReferenceHtmlDocument, m as buildApiReferenceScalarCss, n as normalizePromptProviderName, o as serializeDocsIcon, p as buildApiReferencePageTitle, r as parsePromptStringArray, s as serializeDocsIconRegistry, t as DEFAULT_PROMPT_PROVIDER_TEMPLATES, u as buildApiReferenceHtmlDocumentAsync } from "./prompt-utils-8nmFLQVH.mjs";
3
3
  import { createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
4
4
 
5
- export { DEFAULT_PROMPT_PROVIDER_TEMPLATES, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsSearchDocuments, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsCloudAnalytics, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, emitDocsAnalyticsEvent, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, resolveApiReferenceConfig, resolveApiReferenceRenderer, resolveDocsAnalyticsConfig, resolveDocsMcpConfig, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProviders };
5
+ export { DEFAULT_PROMPT_PROVIDER_TEMPLATES, DOCS_AGENT_TRACE_EVENT_TYPES, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsSearchDocuments, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAnalytics, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, resolveApiReferenceConfig, resolveApiReferenceRenderer, resolveDocsAnalyticsConfig, resolveDocsMcpConfig, resolveDocsObservabilityConfig, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProviders };
@@ -633,6 +633,8 @@ interface PageActionsConfig {
633
633
  alignment?: "left" | "right";
634
634
  }
635
635
  type DocsAnalyticsSource = "client" | "server" | "mcp";
636
+ type DocsAgentTraceStatus = "started" | "success" | "error" | "retry" | "timeout";
637
+ type DocsAgentTraceEventType = "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";
636
638
  type DocsAnalyticsEventType = "page_view" | "search_open" | "search_close" | "search_query" | "search_result_click" | "search_error" | "ai_open" | "ai_close" | "ai_question" | "ai_response" | "ai_error" | "ai_clear" | "page_action_copy_markdown" | "page_action_open_docs_menu" | "page_action_open_docs" | "code_block_copy" | "feedback_select" | "feedback_submit" | "feedback_error" | "agent_read" | "agent_spec_request" | "agent_feedback_schema" | "agent_feedback_submit" | "agent_feedback_error" | "markdown_request" | "llms_request" | "skill_request" | "api_search" | "api_ai_request" | "api_ai_response" | "api_ai_error" | "mcp_request" | "mcp_tool";
637
639
  interface DocsAnalyticsInput {
638
640
  query?: string;
@@ -640,8 +642,7 @@ interface DocsAnalyticsInput {
640
642
  feedbackComment?: string;
641
643
  content?: string;
642
644
  }
643
- interface DocsAnalyticsEvent {
644
- type: DocsAnalyticsEventType | (string & {});
645
+ interface DocsEventBase {
645
646
  timestamp: string;
646
647
  source: DocsAnalyticsSource;
647
648
  url?: string;
@@ -649,17 +650,42 @@ interface DocsAnalyticsEvent {
649
650
  referrer?: string;
650
651
  locale?: string;
651
652
  input?: DocsAnalyticsInput;
653
+ metadata?: Record<string, unknown>;
652
654
  properties?: Record<string, unknown>;
653
655
  }
656
+ interface DocsAnalyticsEvent extends DocsEventBase {
657
+ type: DocsAnalyticsEventType | (string & {});
658
+ }
654
659
  type DocsAnalyticsEventInput = Omit<DocsAnalyticsEvent, "timestamp" | "source"> & {
655
660
  timestamp?: string;
656
661
  source?: DocsAnalyticsSource;
657
662
  };
663
+ interface DocsObservabilityEvent extends DocsEventBase {
664
+ type: DocsAgentTraceEventType | (string & {});
665
+ traceId?: string;
666
+ spanId?: string;
667
+ parentSpanId?: string;
668
+ name?: string;
669
+ startedAt?: string;
670
+ endedAt?: string;
671
+ durationMs?: number;
672
+ status?: DocsAgentTraceStatus;
673
+ inputPreview?: Record<string, unknown>;
674
+ outputPreview?: Record<string, unknown>;
675
+ }
676
+ type DocsObservabilityEventInput = Omit<DocsObservabilityEvent, "timestamp" | "source"> & {
677
+ timestamp?: string;
678
+ source?: DocsAnalyticsSource;
679
+ };
680
+ type DocsAgentTraceEventInput = Omit<DocsObservabilityEventInput, "type"> & {
681
+ type: DocsAgentTraceEventType;
682
+ name: string;
683
+ };
658
684
  interface DocsAnalyticsConfig {
659
- /** Enable analytics event emission. Defaults to `true` when this object is provided. */
685
+ /** Enable event emission. Defaults to `true` when this object is provided. */
660
686
  enabled?: boolean;
661
687
  /**
662
- * Log analytics events to the console.
688
+ * Log events to the console.
663
689
  *
664
690
  * `analytics: true` logs with `console.info`. When `onEvent` is provided,
665
691
  * console logging is disabled unless this is set.
@@ -673,9 +699,30 @@ interface DocsAnalyticsConfig {
673
699
  * counts, routes, status, and duration.
674
700
  */
675
701
  includeInputs?: boolean;
676
- /** Callback fired for every analytics event. */
702
+ /** Callback fired for every emitted event. */
677
703
  onEvent?: (event: DocsAnalyticsEvent) => void | Promise<void>;
678
704
  }
705
+ interface DocsObservabilityConfig {
706
+ /** Enable trace emission. Defaults to `true` when this object is provided. */
707
+ enabled?: boolean;
708
+ /**
709
+ * Log trace events to the console.
710
+ *
711
+ * `observability: true` logs with `console.info`. When `onEvent` is provided,
712
+ * console logging is disabled unless this is set.
713
+ */
714
+ console?: boolean | "log" | "info" | "debug";
715
+ /**
716
+ * Include raw `input` fields on observability events.
717
+ *
718
+ * Defaults to `false`; events still include safe metadata such as lengths,
719
+ * counts, routes, status, and duration. Built-in trace events use previews
720
+ * instead of raw user-authored text.
721
+ */
722
+ includeInputs?: boolean;
723
+ /** Callback fired for every emitted trace event. */
724
+ onEvent?: (event: DocsObservabilityEvent) => void | Promise<void>;
725
+ }
679
726
  /**
680
727
  * Configuration for the "Last updated" date display.
681
728
  *
@@ -1674,13 +1721,27 @@ interface DocsConfig {
1674
1721
  * Built-in analytics event stream for docs interactions.
1675
1722
  *
1676
1723
  * - `false` or omitted -> analytics disabled (default)
1677
- * - `true` -> log all framework events to the console
1724
+ * - `true` -> log product/usage events to the console
1678
1725
  * - `{ onEvent(event) { ... } }` -> send events to your analytics sink
1679
1726
  *
1680
1727
  * Raw queries, AI questions, feedback comments, and copied content are not
1681
1728
  * included unless `includeInputs: true` is set.
1682
1729
  */
1683
1730
  analytics?: boolean | DocsAnalyticsConfig;
1731
+ /**
1732
+ * Built-in observability stream for agent traces, timing, errors, and runtime debugging.
1733
+ * This is separate from `analytics`; it emits span-like Ask AI and MCP trace events.
1734
+ *
1735
+ * ```ts
1736
+ * observability: {
1737
+ * console: "debug",
1738
+ * onEvent(event) {
1739
+ * console.info(event.type, event.traceId, event.durationMs)
1740
+ * },
1741
+ * }
1742
+ * ```
1743
+ */
1744
+ observability?: boolean | DocsObservabilityConfig;
1684
1745
  /**
1685
1746
  * GitHub repository URL or config. Enables "Edit on GitHub" links
1686
1747
  * on each docs page footer, pointing to the source `.mdx` file.
@@ -2046,4 +2107,4 @@ interface DocsConfig {
2046
2107
  og?: OGConfig;
2047
2108
  }
2048
2109
  //#endregion
2049
- export { PageFrontmatter as $, DocsSearchAdapterContext as A, DocsTheme as B, DocsI18nConfig as C, DocsNav as D, DocsMetadata as E, DocsSearchEmbeddingsConfig as F, LlmsTxtConfig as G, FontStyle as H, DocsSearchQuery as I, OpenDocsConfig as J, McpDocsSearchConfig as K, DocsSearchResult as L, DocsSearchChunkingConfig as M, DocsSearchConfig as N, DocsRelatedItem as O, DocsSearchDocument as P, PageActionsConfig as Q, DocsSearchResultType as R, DocsFeedbackValue as S, DocsMcpToolsConfig as T, GithubConfig as U, FeedbackConfig as V, LastUpdatedConfig as W, OpenGraphImage as X, OpenDocsProvider as Y, OrderingItem as Z, DocsAnalyticsEventType as _, ApiReferenceRenderer as a, SidebarComponentProps as at, DocsConfig as b, ChangelogFrontmatter as c, SidebarFolderNode as ct, CustomDocsSearchConfig as d, SidebarTree as dt, PageOpenGraph as et, DocsAgentFeedbackContext as f, SimpleDocsSearchConfig as ft, DocsAnalyticsEventInput as g, UIConfig as gt, DocsAnalyticsEvent as h, TypographyConfig as ht, ApiReferenceConfig as i, ResolvedDocsRelatedLink as it, DocsSearchAdapterFactory as j, DocsSearchAdapter as k, CodeBlockCopyData as l, SidebarNode as lt, DocsAnalyticsConfig as m, TypesenseDocsSearchConfig as mt, AgentFeedbackConfig as n, PageTwitter as nt, BreadcrumbConfig as o, SidebarConfig as ot, DocsAgentFeedbackData as p, ThemeToggleConfig as pt, OGConfig as q, AlgoliaDocsSearchConfig as r, ReadingTimeConfig as rt, ChangelogConfig as s, SidebarFolderIndexBehavior as st, AIConfig as t, PageSidebarFrontmatter as tt, CopyMarkdownConfig as u, SidebarPageNode as ut, DocsAnalyticsInput as v, DocsMcpConfig as w, DocsFeedbackData as x, DocsAnalyticsSource as y, DocsSearchSourcePage as z };
2110
+ export { OGConfig as $, DocsNav as A, DocsSearchDocument as B, DocsConfig as C, DocsMcpConfig as D, DocsI18nConfig as E, DocsSearchAdapter as F, DocsSearchSourcePage as G, DocsSearchQuery as H, DocsSearchAdapterContext as I, FontStyle as J, DocsTheme as K, DocsSearchAdapterFactory as L, DocsObservabilityEvent as M, DocsObservabilityEventInput as N, DocsMcpToolsConfig as O, DocsRelatedItem as P, McpDocsSearchConfig as Q, DocsSearchChunkingConfig as R, DocsAnalyticsSource as S, UIConfig as St, DocsFeedbackValue as T, DocsSearchResult as U, DocsSearchEmbeddingsConfig as V, DocsSearchResultType as W, LastUpdatedConfig as X, GithubConfig as Y, LlmsTxtConfig as Z, DocsAnalyticsConfig as _, SidebarTree as _t, ApiReferenceRenderer as a, PageFrontmatter as at, DocsAnalyticsEventType as b, TypesenseDocsSearchConfig as bt, ChangelogFrontmatter as c, PageTwitter as ct, CustomDocsSearchConfig as d, SidebarComponentProps as dt, OpenDocsConfig as et, DocsAgentFeedbackContext as f, SidebarConfig as ft, DocsAgentTraceStatus as g, SidebarPageNode as gt, DocsAgentTraceEventType as h, SidebarNode as ht, ApiReferenceConfig as i, PageActionsConfig as it, DocsObservabilityConfig as j, DocsMetadata as k, CodeBlockCopyData as l, ReadingTimeConfig as lt, DocsAgentTraceEventInput as m, SidebarFolderNode as mt, AgentFeedbackConfig as n, OpenGraphImage as nt, BreadcrumbConfig as o, PageOpenGraph as ot, DocsAgentFeedbackData as p, SidebarFolderIndexBehavior as pt, FeedbackConfig as q, AlgoliaDocsSearchConfig as r, OrderingItem as rt, ChangelogConfig as s, PageSidebarFrontmatter as st, AIConfig as t, OpenDocsProvider as tt, CopyMarkdownConfig as u, ResolvedDocsRelatedLink as ut, DocsAnalyticsEvent as v, SimpleDocsSearchConfig as vt, DocsFeedbackData as w, DocsAnalyticsInput as x, TypographyConfig as xt, DocsAnalyticsEventInput as y, ThemeToggleConfig as yt, DocsSearchConfig as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/docs",
3
- "version": "0.1.70",
3
+ "version": "0.1.72",
4
4
  "description": "Modern, flexible MDX-based docs framework — core types, config, and CLI",
5
5
  "keywords": [
6
6
  "docs",
@@ -1,41 +0,0 @@
1
- import { K as McpDocsSearchConfig, L as DocsSearchResult, M as DocsSearchChunkingConfig, N as DocsSearchConfig, P as DocsSearchDocument, d as CustomDocsSearchConfig, g as DocsAnalyticsEventInput, h as DocsAnalyticsEvent, j as DocsSearchAdapterFactory, k as DocsSearchAdapter, m as DocsAnalyticsConfig, mt as TypesenseDocsSearchConfig, r as AlgoliaDocsSearchConfig, z as DocsSearchSourcePage } from "./types-BXgTvFFE.mjs";
2
-
3
- //#region src/cloud-analytics.d.ts
4
- interface DocsCloudAnalyticsOptions {
5
- enabled?: boolean;
6
- console?: DocsAnalyticsConfig["console"];
7
- includeInputs?: boolean;
8
- projectId?: string;
9
- apiKey?: string;
10
- }
11
- declare function createDocsCloudAnalytics(options?: DocsCloudAnalyticsOptions): DocsAnalyticsConfig;
12
- //#endregion
13
- //#region src/analytics.d.ts
14
- interface ResolvedDocsAnalyticsConfig {
15
- enabled: boolean;
16
- console: false | "log" | "info" | "debug";
17
- includeInputs: boolean;
18
- onEvent?: (event: DocsAnalyticsEvent) => void | Promise<void>;
19
- }
20
- declare function resolveDocsAnalyticsConfig(analytics?: boolean | DocsAnalyticsConfig): ResolvedDocsAnalyticsConfig;
21
- declare function emitDocsAnalyticsEvent(analytics: boolean | DocsAnalyticsConfig | undefined, event: DocsAnalyticsEventInput): Promise<void>;
22
- //#endregion
23
- //#region src/search.d.ts
24
- declare function buildDocsSearchDocuments(pages: DocsSearchSourcePage[], chunking?: DocsSearchChunkingConfig): DocsSearchDocument[];
25
- declare function createSimpleSearchAdapter(): DocsSearchAdapter;
26
- declare function createTypesenseSearchAdapter(config: TypesenseDocsSearchConfig): DocsSearchAdapter;
27
- declare function resolveSearchRequestConfig(search: boolean | DocsSearchConfig | undefined, requestUrl?: string): boolean | DocsSearchConfig | undefined;
28
- declare function createMcpSearchAdapter(config: McpDocsSearchConfig): DocsSearchAdapter;
29
- declare function createAlgoliaSearchAdapter(config: AlgoliaDocsSearchConfig): DocsSearchAdapter;
30
- declare function performDocsSearch(options: {
31
- pages: DocsSearchSourcePage[];
32
- query: string;
33
- search?: boolean | DocsSearchConfig;
34
- locale?: string;
35
- pathname?: string;
36
- siteTitle?: string;
37
- limit?: number;
38
- }): Promise<DocsSearchResult[]>;
39
- declare function createCustomSearchAdapter(adapter: DocsSearchAdapter | DocsSearchAdapterFactory): CustomDocsSearchConfig;
40
- //#endregion
41
- export { createSimpleSearchAdapter as a, resolveSearchRequestConfig as c, resolveDocsAnalyticsConfig as d, DocsCloudAnalyticsOptions as f, createMcpSearchAdapter as i, ResolvedDocsAnalyticsConfig as l, createAlgoliaSearchAdapter as n, createTypesenseSearchAdapter as o, createDocsCloudAnalytics as p, createCustomSearchAdapter as r, performDocsSearch as s, buildDocsSearchDocuments as t, emitDocsAnalyticsEvent as u };