@farming-labs/docs 0.1.90 → 0.1.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-ByVfHy7k.mjs → agent-DV2Qc7qh.mjs} +2 -2
- package/dist/cli/index.mjs +9 -9
- package/dist/{doctor-Zn6h4wkZ.mjs → doctor-DjLUv0Dq.mjs} +154 -12
- package/dist/index.d.mts +5 -2
- package/dist/index.mjs +2 -2
- package/dist/{mcp-OuciCVEf.mjs → mcp-B7x8mPrj.mjs} +1 -1
- package/dist/mcp.mjs +11 -36
- package/dist/{robots-BHEIUAYm.mjs → robots-CbylLz5o.mjs} +1 -1
- package/dist/{robots-DR-Gy1Hs.mjs → robots-D7dvjbuN.mjs} +8 -1
- package/dist/{search-B5ze-heM.mjs → search-BL7o2rXk.mjs} +3 -4
- package/dist/{search-CHiEEXZI.mjs → search-o8jXDckl.mjs} +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{sitemap-Bk9HqW_J.mjs → sitemap-DFVo9yr0.mjs} +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./reading-time-CbbHNg9V.mjs";
|
|
2
|
-
import { _ as parseGeneratedAgentDocument, h as hashGeneratedAgentContent, m as GENERATED_AGENT_PROVENANCE_VERSION, v as serializeGeneratedAgentDocument } from "./search-
|
|
3
|
-
import { B as renderDocsMarkdownDocument, O as findDocsMarkdownPage } from "./robots-
|
|
2
|
+
import { _ as parseGeneratedAgentDocument, h as hashGeneratedAgentContent, m as GENERATED_AGENT_PROVENANCE_VERSION, v as serializeGeneratedAgentDocument } from "./search-BL7o2rXk.mjs";
|
|
3
|
+
import { B as renderDocsMarkdownDocument, O as findDocsMarkdownPage } from "./robots-D7dvjbuN.mjs";
|
|
4
4
|
import "./index.mjs";
|
|
5
5
|
import "./sitemap-server-DwEPfk13.mjs";
|
|
6
6
|
import { createFilesystemDocsMcpSource } from "./mcp.mjs";
|
package/dist/cli/index.mjs
CHANGED
|
@@ -83,10 +83,10 @@ async function main() {
|
|
|
83
83
|
const { dev } = await import("../dev-B5L7k3b6.mjs");
|
|
84
84
|
await dev(devOptions);
|
|
85
85
|
} else if (parsedCommand.command === "mcp") {
|
|
86
|
-
const { runMcp } = await import("../mcp-
|
|
86
|
+
const { runMcp } = await import("../mcp-B7x8mPrj.mjs");
|
|
87
87
|
await runMcp(mcpOptions);
|
|
88
88
|
} else if (parsedCommand.command === "agent" && subcommand === "compact") {
|
|
89
|
-
const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-
|
|
89
|
+
const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-DV2Qc7qh.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-
|
|
99
|
+
const { printAgentCompactHelp } = await import("../agent-DV2Qc7qh.mjs");
|
|
100
100
|
printAgentCompactHelp();
|
|
101
101
|
process.exit(1);
|
|
102
102
|
} else if (parsedCommand.command === "doctor") {
|
|
103
|
-
const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-
|
|
103
|
+
const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-DjLUv0Dq.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-
|
|
111
|
+
const { syncSearch } = await import("../search-o8jXDckl.mjs");
|
|
112
112
|
await syncSearch(searchSyncOptions);
|
|
113
113
|
} else if (parsedCommand.command === "search") {
|
|
114
114
|
console.error(pc.red(`Unknown search subcommand: ${subcommand ?? "(missing)"}`));
|
|
@@ -116,7 +116,7 @@ async function main() {
|
|
|
116
116
|
printHelp();
|
|
117
117
|
process.exit(1);
|
|
118
118
|
} else if (parsedCommand.command === "sitemap" && subcommand === "generate") {
|
|
119
|
-
const { generateSitemap, parseSitemapGenerateArgs, printSitemapGenerateHelp } = await import("../sitemap-
|
|
119
|
+
const { generateSitemap, parseSitemapGenerateArgs, printSitemapGenerateHelp } = await import("../sitemap-DFVo9yr0.mjs");
|
|
120
120
|
const sitemapOptions = parseSitemapGenerateArgs(args.slice(2));
|
|
121
121
|
if (sitemapOptions.help) {
|
|
122
122
|
printSitemapGenerateHelp();
|
|
@@ -126,11 +126,11 @@ async function main() {
|
|
|
126
126
|
} else if (parsedCommand.command === "sitemap") {
|
|
127
127
|
console.error(pc.red(`Unknown sitemap subcommand: ${subcommand ?? "(missing)"}`));
|
|
128
128
|
console.error();
|
|
129
|
-
const { printSitemapGenerateHelp } = await import("../sitemap-
|
|
129
|
+
const { printSitemapGenerateHelp } = await import("../sitemap-DFVo9yr0.mjs");
|
|
130
130
|
printSitemapGenerateHelp();
|
|
131
131
|
process.exit(1);
|
|
132
132
|
} else if (parsedCommand.command === "robots" && subcommand === "generate") {
|
|
133
|
-
const { generateRobots, parseRobotsGenerateArgs, printRobotsGenerateHelp } = await import("../robots-
|
|
133
|
+
const { generateRobots, parseRobotsGenerateArgs, printRobotsGenerateHelp } = await import("../robots-CbylLz5o.mjs");
|
|
134
134
|
const robotsOptions = parseRobotsGenerateArgs(args.slice(2));
|
|
135
135
|
if (robotsOptions.help) {
|
|
136
136
|
printRobotsGenerateHelp();
|
|
@@ -140,7 +140,7 @@ async function main() {
|
|
|
140
140
|
} else if (parsedCommand.command === "robots") {
|
|
141
141
|
console.error(pc.red(`Unknown robots subcommand: ${subcommand ?? "(missing)"}`));
|
|
142
142
|
console.error();
|
|
143
|
-
const { printRobotsGenerateHelp } = await import("../robots-
|
|
143
|
+
const { printRobotsGenerateHelp } = await import("../robots-CbylLz5o.mjs");
|
|
144
144
|
printRobotsGenerateHelp();
|
|
145
145
|
process.exit(1);
|
|
146
146
|
} else if (parsedCommand.command === "upgrade") {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "./reading-time-CbbHNg9V.mjs";
|
|
2
|
-
import "./search-
|
|
2
|
+
import "./search-BL7o2rXk.mjs";
|
|
3
3
|
import { i as DEFAULT_SITEMAP_XML_ROUTE, n as DEFAULT_SITEMAP_MD_ROUTE, r as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, u as resolveDocsSitemapConfig } from "./sitemap-BIQIYMKe.mjs";
|
|
4
|
-
import { C as DEFAULT_MCP_WELL_KNOWN_ROUTE, T as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, a as analyzeDocsRobotsTxt, d as DEFAULT_AGENT_FEEDBACK_ROUTE, g as DEFAULT_LLMS_FULL_TXT_ROUTE, l as resolveDocsRobotsConfig, m as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, n as DEFAULT_ROBOTS_TXT_ROUTE, p as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, w as DEFAULT_SKILL_MD_ROUTE, x as DEFAULT_MCP_PUBLIC_ROUTE, y as DEFAULT_LLMS_TXT_ROUTE } from "./robots-
|
|
4
|
+
import { C as DEFAULT_MCP_WELL_KNOWN_ROUTE, T as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, a as analyzeDocsRobotsTxt, d as DEFAULT_AGENT_FEEDBACK_ROUTE, g as DEFAULT_LLMS_FULL_TXT_ROUTE, l as resolveDocsRobotsConfig, m as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, n as DEFAULT_ROBOTS_TXT_ROUTE, p as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, w as DEFAULT_SKILL_MD_ROUTE, x as DEFAULT_MCP_PUBLIC_ROUTE, y as DEFAULT_LLMS_TXT_ROUTE } from "./robots-D7dvjbuN.mjs";
|
|
5
5
|
import "./sitemap-server-DwEPfk13.mjs";
|
|
6
6
|
import { createFilesystemDocsMcpSource, resolveDocsMcpConfig } from "./mcp.mjs";
|
|
7
7
|
import "./server.mjs";
|
|
8
8
|
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-UI31_wlO.mjs";
|
|
9
|
-
import { inspectAgentCompactionState, scanDocsPageTargets } from "./agent-
|
|
9
|
+
import { inspectAgentCompactionState, scanDocsPageTargets } from "./agent-DV2Qc7qh.mjs";
|
|
10
10
|
import { t as detectFramework } from "./utils-AmYxHDoz.mjs";
|
|
11
11
|
import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
@@ -736,7 +736,8 @@ async function probeTextRoute(baseUrl, route) {
|
|
|
736
736
|
return {
|
|
737
737
|
ok: true,
|
|
738
738
|
status: response.status,
|
|
739
|
-
detail: `${route} returned HTTP ${response.status} with ${body.length} characters
|
|
739
|
+
detail: `${route} returned HTTP ${response.status} with ${body.length} characters.`,
|
|
740
|
+
body
|
|
740
741
|
};
|
|
741
742
|
} catch (error) {
|
|
742
743
|
return {
|
|
@@ -745,6 +746,56 @@ async function probeTextRoute(baseUrl, route) {
|
|
|
745
746
|
};
|
|
746
747
|
}
|
|
747
748
|
}
|
|
749
|
+
function decodeHtmlEntity(value) {
|
|
750
|
+
const named = {
|
|
751
|
+
amp: "&",
|
|
752
|
+
apos: "'",
|
|
753
|
+
gt: ">",
|
|
754
|
+
lt: "<",
|
|
755
|
+
quot: "\""
|
|
756
|
+
};
|
|
757
|
+
return value.replace(/&(#x[\da-f]+|#\d+|[a-z]+);/gi, (entity, raw) => {
|
|
758
|
+
const lower = raw.toLowerCase();
|
|
759
|
+
if (lower.startsWith("#x")) {
|
|
760
|
+
const codePoint = Number.parseInt(lower.slice(2), 16);
|
|
761
|
+
return Number.isFinite(codePoint) && codePoint >= 0 && codePoint <= 1114111 ? String.fromCodePoint(codePoint) : entity;
|
|
762
|
+
}
|
|
763
|
+
if (lower.startsWith("#")) {
|
|
764
|
+
const codePoint = Number.parseInt(lower.slice(1), 10);
|
|
765
|
+
return Number.isFinite(codePoint) && codePoint >= 0 && codePoint <= 1114111 ? String.fromCodePoint(codePoint) : entity;
|
|
766
|
+
}
|
|
767
|
+
return named[lower] ?? entity;
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
function htmlAttribute(tag, name) {
|
|
771
|
+
for (const match of tag.matchAll(/([^\s"'<>/=]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/g)) {
|
|
772
|
+
if (match[1]?.toLowerCase() !== name.toLowerCase()) continue;
|
|
773
|
+
return decodeHtmlEntity(match[2] ?? match[3] ?? match[4] ?? "");
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
function hasJsonLdScript(html) {
|
|
777
|
+
return /<script\b(?=[^>]*\btype\s*=\s*["']application\/ld\+json["'])[^>]*>/i.test(html);
|
|
778
|
+
}
|
|
779
|
+
function markdownAlternateHref(html) {
|
|
780
|
+
for (const match of html.matchAll(/<link\b[^>]*>/gi)) {
|
|
781
|
+
const tag = match[0];
|
|
782
|
+
const rel = htmlAttribute(tag, "rel") ?? "";
|
|
783
|
+
const type = htmlAttribute(tag, "type") ?? "";
|
|
784
|
+
const href = htmlAttribute(tag, "href");
|
|
785
|
+
const relTokens = rel.toLowerCase().split(/\s+/).filter(Boolean);
|
|
786
|
+
if (href && relTokens.includes("alternate") && /^text\/markdown(?:\s*;|$)/i.test(type.trim())) return href;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
function resolveMarkdownAlternateUrl(href, pageUrl) {
|
|
790
|
+
if (!href) return void 0;
|
|
791
|
+
try {
|
|
792
|
+
const url = new URL(href, pageUrl);
|
|
793
|
+
const page = new URL(pageUrl);
|
|
794
|
+
return url.origin === page.origin && url.pathname.endsWith(".md") ? url : void 0;
|
|
795
|
+
} catch {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
748
799
|
async function probeRobotsRoute(baseUrl, route = DEFAULT_ROBOTS_TXT_ROUTE) {
|
|
749
800
|
const url = joinDoctorUrl(baseUrl, route);
|
|
750
801
|
try {
|
|
@@ -845,12 +896,8 @@ async function probeMcpRoute(baseUrl, route) {
|
|
|
845
896
|
ok: false,
|
|
846
897
|
detail: `${route} initialize returned HTTP ${initializeResponse.status}: ${String(initializePayload.error?.message ?? "unknown MCP error")}.`
|
|
847
898
|
};
|
|
848
|
-
const sessionId = initializeResponse.headers.get("mcp-session-id");
|
|
849
|
-
if (
|
|
850
|
-
ok: false,
|
|
851
|
-
detail: `${route} initialize did not return mcp-session-id.`
|
|
852
|
-
};
|
|
853
|
-
await postMcpJson(baseUrl, route, {
|
|
899
|
+
const sessionId = initializeResponse.headers.get("mcp-session-id") ?? void 0;
|
|
900
|
+
if (sessionId) await postMcpJson(baseUrl, route, {
|
|
854
901
|
jsonrpc: "2.0",
|
|
855
902
|
method: "notifications/initialized",
|
|
856
903
|
params: {}
|
|
@@ -862,7 +909,7 @@ async function probeMcpRoute(baseUrl, route) {
|
|
|
862
909
|
params: {}
|
|
863
910
|
}, sessionId);
|
|
864
911
|
const toolsPayload = await parseMcpResponse(toolsResponse);
|
|
865
|
-
await fetchWithTimeout(joinDoctorUrl(baseUrl, route), {
|
|
912
|
+
if (sessionId) await fetchWithTimeout(joinDoctorUrl(baseUrl, route), {
|
|
866
913
|
method: "DELETE",
|
|
867
914
|
headers: {
|
|
868
915
|
"mcp-protocol-version": LATEST_PROTOCOL_VERSION,
|
|
@@ -887,7 +934,7 @@ async function probeMcpRoute(baseUrl, route) {
|
|
|
887
934
|
};
|
|
888
935
|
return {
|
|
889
936
|
ok: true,
|
|
890
|
-
detail: `${route} initialized and exposed ${toolNames.length} MCP tool${toolNames.length === 1 ? "" : "s"}.`
|
|
937
|
+
detail: `${route} initialized ${sessionId ? "with a session" : "statelessly"} and exposed ${toolNames.length} MCP tool${toolNames.length === 1 ? "" : "s"}.`
|
|
891
938
|
};
|
|
892
939
|
} catch (error) {
|
|
893
940
|
return {
|
|
@@ -927,6 +974,93 @@ function hostedRobotsRoute(discoveryBody) {
|
|
|
927
974
|
route: readDiscoveryRoute(robots?.route) ?? DEFAULT_ROBOTS_TXT_ROUTE
|
|
928
975
|
};
|
|
929
976
|
}
|
|
977
|
+
function hostedCapability(discoveryBody, key) {
|
|
978
|
+
const root = asRecord(discoveryBody);
|
|
979
|
+
const capability = asRecord(root?.capabilities)?.[key];
|
|
980
|
+
if (typeof capability === "boolean") return capability;
|
|
981
|
+
const enabled = asRecord(root?.[key])?.enabled;
|
|
982
|
+
return typeof enabled === "boolean" ? enabled : void 0;
|
|
983
|
+
}
|
|
984
|
+
function hostedRootDocsRoute(discoveryBody) {
|
|
985
|
+
const site = asRecord(asRecord(discoveryBody)?.site);
|
|
986
|
+
return `/${(typeof site?.entry === "string" && site.entry.trim() ? site.entry.trim() : "docs").replace(/^\/+|\/+$/g, "") || "docs"}`;
|
|
987
|
+
}
|
|
988
|
+
function hostedPageUrl(baseUrl, pageRoute) {
|
|
989
|
+
try {
|
|
990
|
+
const base = new URL(baseUrl);
|
|
991
|
+
const parsed = new URL(pageRoute, base.origin);
|
|
992
|
+
if (parsed.origin !== base.origin) return void 0;
|
|
993
|
+
parsed.hash = "";
|
|
994
|
+
parsed.search = "";
|
|
995
|
+
const basePath = base.pathname.replace(/\/+$/, "");
|
|
996
|
+
const pagePath = parsed.pathname.replace(/\/+$/, "") || "/";
|
|
997
|
+
const pathname = !basePath || pagePath === basePath || pagePath.startsWith(`${basePath}/`) ? pagePath : `${basePath}${pagePath}`;
|
|
998
|
+
return new URL(pathname || "/", base.origin).toString().replace(/\/+$/, "");
|
|
999
|
+
} catch {
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
function sampleHostedPageUrls(baseUrl, discoveryBody, pages, limit = 10) {
|
|
1004
|
+
const pageRoutes = pages.map((page) => page.url).filter((route) => route.startsWith("/") && !route.endsWith(".md"));
|
|
1005
|
+
const fallback = hostedRootDocsRoute(discoveryBody);
|
|
1006
|
+
const unique = Array.from(new Set(pageRoutes.length > 0 ? pageRoutes : [fallback])).sort();
|
|
1007
|
+
return (unique.length <= limit ? unique : Array.from({ length: limit }, (_, index) => unique[Math.floor(index * (unique.length / limit))])).map((route) => hostedPageUrl(baseUrl, route)).filter((url) => typeof url === "string");
|
|
1008
|
+
}
|
|
1009
|
+
async function probeHostedHtmlPage(url) {
|
|
1010
|
+
try {
|
|
1011
|
+
const response = await fetchWithTimeout(url, { headers: { Accept: "text/html, */*" } });
|
|
1012
|
+
const body = await response.text().catch(() => "");
|
|
1013
|
+
const pathname = new URL(url).pathname;
|
|
1014
|
+
if (!response.ok) return {
|
|
1015
|
+
ok: false,
|
|
1016
|
+
detail: `${pathname} returned HTTP ${response.status}.`,
|
|
1017
|
+
hasJsonLd: false,
|
|
1018
|
+
hasMarkdownAlternate: false
|
|
1019
|
+
};
|
|
1020
|
+
const alternateUrl = resolveMarkdownAlternateUrl(markdownAlternateHref(body), url);
|
|
1021
|
+
return {
|
|
1022
|
+
ok: true,
|
|
1023
|
+
detail: `${pathname} returned HTML with ${body.length} characters.`,
|
|
1024
|
+
hasJsonLd: hasJsonLdScript(body),
|
|
1025
|
+
hasMarkdownAlternate: Boolean(alternateUrl)
|
|
1026
|
+
};
|
|
1027
|
+
} catch (error) {
|
|
1028
|
+
return {
|
|
1029
|
+
ok: false,
|
|
1030
|
+
detail: `${url} failed: ${error instanceof Error ? error.message : String(error)}.`,
|
|
1031
|
+
hasJsonLd: false,
|
|
1032
|
+
hasMarkdownAlternate: false
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
function hostedSurfaceScore(probes, predicate) {
|
|
1037
|
+
const total = probes.length;
|
|
1038
|
+
const passed = probes.filter((probe) => probe.ok && predicate(probe)).length;
|
|
1039
|
+
if (total === 0) return {
|
|
1040
|
+
status: "warn",
|
|
1041
|
+
score: 0,
|
|
1042
|
+
passed: 0,
|
|
1043
|
+
total
|
|
1044
|
+
};
|
|
1045
|
+
if (passed === total) return {
|
|
1046
|
+
status: "pass",
|
|
1047
|
+
score: 5,
|
|
1048
|
+
passed,
|
|
1049
|
+
total
|
|
1050
|
+
};
|
|
1051
|
+
if (passed > 0) return {
|
|
1052
|
+
status: "warn",
|
|
1053
|
+
score: Math.round(passed / total * 5),
|
|
1054
|
+
passed,
|
|
1055
|
+
total
|
|
1056
|
+
};
|
|
1057
|
+
return {
|
|
1058
|
+
status: "fail",
|
|
1059
|
+
score: 0,
|
|
1060
|
+
passed,
|
|
1061
|
+
total
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
930
1064
|
async function buildHostedAgentChecks(url, pages) {
|
|
931
1065
|
let baseUrl;
|
|
932
1066
|
try {
|
|
@@ -963,6 +1097,14 @@ async function buildHostedAgentChecks(url, pages) {
|
|
|
963
1097
|
const markdown = await probeTextRoute(baseUrl, markdownRoute);
|
|
964
1098
|
checks.push(makeCheck("hosted-markdown", "Hosted markdown route", markdown.ok ? "pass" : "fail", markdown.ok ? 5 : 0, 5, markdown.detail, markdown.ok ? void 0 : `Verify deployed markdown routes are forwarded, starting with ${markdownRoute}.`));
|
|
965
1099
|
} else checks.push(makeCheck("hosted-markdown", "Hosted markdown route", "warn", 0, 5, "No local docs page was available to choose a sample .md route.", "Add docs pages so the hosted doctor can probe a representative .md route."));
|
|
1100
|
+
const htmlPageUrls = sampleHostedPageUrls(baseUrl, discovery.body, pages);
|
|
1101
|
+
const htmlPageProbes = await Promise.all(htmlPageUrls.map((pageUrl) => probeHostedHtmlPage(pageUrl)));
|
|
1102
|
+
const structuredDataScore = hostedSurfaceScore(htmlPageProbes, (probe) => probe.hasJsonLd);
|
|
1103
|
+
const structuredDataEnabled = hostedCapability(discovery.body, "structuredData");
|
|
1104
|
+
checks.push(makeCheck("hosted-structured-data", "Hosted structured data", structuredDataEnabled === false ? "warn" : structuredDataScore.status, structuredDataEnabled === false ? 0 : structuredDataScore.score, 5, structuredDataEnabled === false ? "The hosted discovery spec reports structured data as disabled." : structuredDataScore.total > 0 ? `${structuredDataScore.passed}/${structuredDataScore.total} sampled hosted docs pages include application/ld+json structured data.` : "No hosted docs pages were available to verify application/ld+json structured data.", structuredDataEnabled === false || structuredDataScore.status === "pass" ? void 0 : "Keep JSON-LD enabled on every docs page so agents can read canonical title, description, URL, breadcrumbs, and freshness hints."));
|
|
1105
|
+
const markdownAlternateScore = hostedSurfaceScore(htmlPageProbes, (probe) => probe.hasMarkdownAlternate);
|
|
1106
|
+
const markdownRoutesEnabled = hostedCapability(discovery.body, "markdownRoutes");
|
|
1107
|
+
checks.push(makeCheck("hosted-markdown-alternate", "Hosted markdown alternate links", markdownRoutesEnabled === false ? "warn" : markdownAlternateScore.status, markdownRoutesEnabled === false ? 0 : markdownAlternateScore.score, 5, markdownRoutesEnabled === false ? "The hosted discovery spec reports markdown routes as disabled." : markdownAlternateScore.total > 0 ? `${markdownAlternateScore.passed}/${markdownAlternateScore.total} sampled hosted docs pages include <link rel="alternate" type="text/markdown"> pointing to .md routes.` : "No hosted docs pages were available to verify markdown alternate links.", markdownRoutesEnabled === false || markdownAlternateScore.status === "pass" ? void 0 : "Add a text/markdown alternate link in each docs page head, usually through `alternates.types['text/markdown']`, so agents can discover the page markdown URL from HTML."));
|
|
966
1108
|
const mcp = await Promise.all([probeMcpRoute(baseUrl, DEFAULT_MCP_PUBLIC_ROUTE), probeMcpRoute(baseUrl, DEFAULT_MCP_WELL_KNOWN_ROUTE)]);
|
|
967
1109
|
const mcpPassed = mcp.filter((result) => result.ok).length;
|
|
968
1110
|
checks.push(makeCheck("hosted-mcp", "Hosted MCP handshake", mcpPassed === mcp.length ? "pass" : mcpPassed > 0 ? "warn" : "fail", mcpPassed === mcp.length ? 10 : mcpPassed > 0 ? 5 : 0, 10, mcp.map((result) => result.detail).join(" "), mcpPassed === mcp.length ? void 0 : `Verify deployed ${DEFAULT_MCP_PUBLIC_ROUTE} and ${DEFAULT_MCP_WELL_KNOWN_ROUTE} support Streamable HTTP initialize and tools/list.`));
|
package/dist/index.d.mts
CHANGED
|
@@ -315,6 +315,9 @@ interface DocsMarkdownPage {
|
|
|
315
315
|
agentFallbackContent?: string;
|
|
316
316
|
agentFallbackRawContent?: string;
|
|
317
317
|
}
|
|
318
|
+
interface DocsMarkdownDocumentOptions {
|
|
319
|
+
llms?: boolean | DocsLlmsDiscoveryConfig | LlmsTxtConfig;
|
|
320
|
+
}
|
|
318
321
|
interface DocsMarkdownNotFoundOptions {
|
|
319
322
|
entry?: string;
|
|
320
323
|
requestedPath: string;
|
|
@@ -351,8 +354,8 @@ declare function renderDocsMarkdownNotFound({
|
|
|
351
354
|
sitemap
|
|
352
355
|
}: DocsMarkdownNotFoundOptions): string;
|
|
353
356
|
declare function findDocsMarkdownPage<T extends DocsMarkdownPage>(entry: string, pages: T[], requestedPath: string): T | null;
|
|
354
|
-
declare function renderDocsMarkdownDocument(page: DocsMcpPage | DocsSearchSourcePage): string;
|
|
355
|
-
declare function renderDocsMarkdownDocument(page: DocsMarkdownPage): string;
|
|
357
|
+
declare function renderDocsMarkdownDocument(page: DocsMcpPage | DocsSearchSourcePage, options?: DocsMarkdownDocumentOptions): string;
|
|
358
|
+
declare function renderDocsMarkdownDocument(page: DocsMarkdownPage, options?: DocsMarkdownDocumentOptions): string;
|
|
356
359
|
declare function renderDocsSkillDocument({
|
|
357
360
|
origin,
|
|
358
361
|
entry,
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as extendTheme, a as resolveReadingTimeOptions, b as defineDocs, c as buildPageTwitter, d as resolveOGImage, f as resolveTitle, g as createTheme, h as resolveDocsPath, i as resolveReadingTimeFromSource, l as renderDocsPageStructuredDataJson, m as resolveDocsLocale, n as resolvePageReadingTime, o as buildDocsPageStructuredData, p as resolveDocsI18n, r as resolveReadingTimeFromContent, s as buildPageOpenGraph, t as estimateReadingTimeMinutes, u as resolveDocsMetadataBaseUrl, v as deepMerge, y as resolveChangelogConfig } from "./reading-time-CbbHNg9V.mjs";
|
|
2
|
-
import { A as resolveDocsAnalyticsConfig, C as resolveSidebarFolderIndexBehaviorForPath, D as emitDocsAgentTraceEvent, E as createDocsAgentTraceId, M as createDocsCloudAnalytics, O as emitDocsAnalyticsEvent, S as resolveSidebarFolderIndexBehavior, T as createDocsAgentTraceContext, _ as parseGeneratedAgentDocument, a as createMcpSearchAdapter, b as applySidebarFolderIndexBehavior, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, f as resolveSearchRequestConfig, g as normalizeGeneratedAgentContent, h as hashGeneratedAgentContent, i as createCustomSearchAdapter, j as resolveDocsObservabilityConfig, k as emitDocsObservabilityEvent, l as inferDocsAskAIPackageHints, m as GENERATED_AGENT_PROVENANCE_VERSION, n as buildDocsSearchDocuments, o as createSimpleSearchAdapter, p as GENERATED_AGENT_PROVENANCE_MARKER, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, u as performDocsSearch, v as serializeGeneratedAgentDocument, w as DOCS_AGENT_TRACE_EVENT_TYPES, x as resolvePageSidebarFolderIndexBehavior, y as stripGeneratedAgentProvenance } from "./search-
|
|
2
|
+
import { A as resolveDocsAnalyticsConfig, C as resolveSidebarFolderIndexBehaviorForPath, D as emitDocsAgentTraceEvent, E as createDocsAgentTraceId, M as createDocsCloudAnalytics, O as emitDocsAnalyticsEvent, S as resolveSidebarFolderIndexBehavior, T as createDocsAgentTraceContext, _ as parseGeneratedAgentDocument, a as createMcpSearchAdapter, b as applySidebarFolderIndexBehavior, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, f as resolveSearchRequestConfig, g as normalizeGeneratedAgentContent, h as hashGeneratedAgentContent, i as createCustomSearchAdapter, j as resolveDocsObservabilityConfig, k as emitDocsObservabilityEvent, l as inferDocsAskAIPackageHints, m as GENERATED_AGENT_PROVENANCE_VERSION, n as buildDocsSearchDocuments, o as createSimpleSearchAdapter, p as GENERATED_AGENT_PROVENANCE_MARKER, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, u as performDocsSearch, v as serializeGeneratedAgentDocument, w as DOCS_AGENT_TRACE_EVENT_TYPES, x as resolvePageSidebarFolderIndexBehavior, y as stripGeneratedAgentProvenance } from "./search-BL7o2rXk.mjs";
|
|
3
3
|
import { n as renderDocsRelatedMarkdownLines, t as normalizeDocsRelated } from "./related-BNj_NdHq.mjs";
|
|
4
4
|
import { a as buildDocsSitemapManifest, c as renderDocsSitemapMarkdown, d as resolveDocsSitemapPageLastmod, f as resolveDocsSitemapRequest, i as DEFAULT_SITEMAP_XML_ROUTE, l as renderDocsSitemapXml, n as DEFAULT_SITEMAP_MD_ROUTE, o as createDocsSitemapResponse, p as toDocsSitemapMarkdownUrl, r as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, s as readDocsSitemapManifestFromContentMap, t as DEFAULT_SITEMAP_MANIFEST_PATH, u as resolveDocsSitemapConfig } from "./sitemap-BIQIYMKe.mjs";
|
|
5
|
-
import { A as getDocsMarkdownVaryHeader, B as renderDocsMarkdownDocument, C as DEFAULT_MCP_WELL_KNOWN_ROUTE, D as buildDocsAgentDiscoverySpec, E as DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER, F as isDocsSkillRequest, G as resolveDocsLlmsTxtRequest, H as renderDocsSkillDocument, I as matchesDocsLlmsTxtSection, J as resolveDocsSkillFormat, K as resolveDocsLlmsTxtSections, L as normalizeDocsPathSegment, M as isDocsAgentDiscoveryRequest, N as isDocsMcpRequest, O as findDocsMarkdownPage, P as isDocsPublicGetRequest, R as normalizeDocsUrlPath, S as DEFAULT_MCP_ROUTE, T as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, U as resolveDocsAgentMdxContent, V as renderDocsMarkdownNotFound, W as resolveDocsLlmsTxtFormat, X as toDocsMarkdownUrl, Y as selectDocsLlmsTxtContent, _ as DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, a as analyzeDocsRobotsTxt, b as DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, c as renderDocsRobotsTxt, d as DEFAULT_AGENT_FEEDBACK_ROUTE, f as DEFAULT_AGENT_SPEC_ROUTE, g as DEFAULT_LLMS_FULL_TXT_ROUTE, h as DEFAULT_DOCS_API_ROUTE, i as DOCS_ROBOTS_GENERATED_BLOCK_START, j as hasDocsMarkdownSignatureAgent, k as getDocsLlmsTxtMaxCharsIssue, l as resolveDocsRobotsConfig, m as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, n as DEFAULT_ROBOTS_TXT_ROUTE, o as getDocsRobotsAllowRoutes, p as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, q as resolveDocsMarkdownRequest, r as DOCS_ROBOTS_GENERATED_BLOCK_END, s as renderDocsRobotsGeneratedBlock, t as DEFAULT_DOCS_AI_ROBOTS_USER_AGENTS, u as upsertDocsRobotsGeneratedBlock, v as DEFAULT_LLMS_TXT_MAX_CHARS, w as DEFAULT_SKILL_MD_ROUTE, x as DEFAULT_MCP_PUBLIC_ROUTE, y as DEFAULT_LLMS_TXT_ROUTE, z as renderDocsLlmsTxt } from "./robots-
|
|
5
|
+
import { A as getDocsMarkdownVaryHeader, B as renderDocsMarkdownDocument, C as DEFAULT_MCP_WELL_KNOWN_ROUTE, D as buildDocsAgentDiscoverySpec, E as DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER, F as isDocsSkillRequest, G as resolveDocsLlmsTxtRequest, H as renderDocsSkillDocument, I as matchesDocsLlmsTxtSection, J as resolveDocsSkillFormat, K as resolveDocsLlmsTxtSections, L as normalizeDocsPathSegment, M as isDocsAgentDiscoveryRequest, N as isDocsMcpRequest, O as findDocsMarkdownPage, P as isDocsPublicGetRequest, R as normalizeDocsUrlPath, S as DEFAULT_MCP_ROUTE, T as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, U as resolveDocsAgentMdxContent, V as renderDocsMarkdownNotFound, W as resolveDocsLlmsTxtFormat, X as toDocsMarkdownUrl, Y as selectDocsLlmsTxtContent, _ as DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, a as analyzeDocsRobotsTxt, b as DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, c as renderDocsRobotsTxt, d as DEFAULT_AGENT_FEEDBACK_ROUTE, f as DEFAULT_AGENT_SPEC_ROUTE, g as DEFAULT_LLMS_FULL_TXT_ROUTE, h as DEFAULT_DOCS_API_ROUTE, i as DOCS_ROBOTS_GENERATED_BLOCK_START, j as hasDocsMarkdownSignatureAgent, k as getDocsLlmsTxtMaxCharsIssue, l as resolveDocsRobotsConfig, m as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, n as DEFAULT_ROBOTS_TXT_ROUTE, o as getDocsRobotsAllowRoutes, p as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, q as resolveDocsMarkdownRequest, r as DOCS_ROBOTS_GENERATED_BLOCK_END, s as renderDocsRobotsGeneratedBlock, t as DEFAULT_DOCS_AI_ROBOTS_USER_AGENTS, u as upsertDocsRobotsGeneratedBlock, v as DEFAULT_LLMS_TXT_MAX_CHARS, w as DEFAULT_SKILL_MD_ROUTE, x as DEFAULT_MCP_PUBLIC_ROUTE, y as DEFAULT_LLMS_TXT_ROUTE, z as renderDocsLlmsTxt } from "./robots-D7dvjbuN.mjs";
|
|
6
6
|
|
|
7
7
|
export { DEFAULT_AGENT_FEEDBACK_ROUTE, DEFAULT_AGENT_SPEC_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, DEFAULT_DOCS_AI_ROBOTS_USER_AGENTS, DEFAULT_DOCS_API_ROUTE, DEFAULT_LLMS_FULL_TXT_ROUTE, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, DEFAULT_LLMS_TXT_MAX_CHARS, DEFAULT_LLMS_TXT_ROUTE, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE, DEFAULT_MCP_PUBLIC_ROUTE, DEFAULT_MCP_ROUTE, DEFAULT_MCP_WELL_KNOWN_ROUTE, DEFAULT_ROBOTS_TXT_ROUTE, DEFAULT_SITEMAP_MANIFEST_PATH, DEFAULT_SITEMAP_MD_ROUTE, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, DEFAULT_SITEMAP_XML_ROUTE, DEFAULT_SKILL_MD_ROUTE, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, DOCS_AGENT_TRACE_EVENT_TYPES, DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER, DOCS_ROBOTS_GENERATED_BLOCK_END, DOCS_ROBOTS_GENERATED_BLOCK_START, GENERATED_AGENT_PROVENANCE_MARKER, GENERATED_AGENT_PROVENANCE_VERSION, analyzeDocsRobotsTxt, applySidebarFolderIndexBehavior, buildDocsAgentDiscoverySpec, buildDocsAskAIContext, buildDocsPageStructuredData, buildDocsSearchDocuments, buildDocsSitemapManifest, buildPageOpenGraph, buildPageTwitter, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAnalytics, createDocsSitemapResponse, createMcpSearchAdapter, createSimpleSearchAdapter, createTheme, createTypesenseSearchAdapter, deepMerge, defineDocs, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, estimateReadingTimeMinutes, extendTheme, findDocsMarkdownPage, formatDocsAskAIPackageHints, getDocsLlmsTxtMaxCharsIssue, getDocsMarkdownVaryHeader, getDocsRobotsAllowRoutes, hasDocsMarkdownSignatureAgent, hashGeneratedAgentContent, inferDocsAskAIPackageHints, isDocsAgentDiscoveryRequest, isDocsMcpRequest, isDocsPublicGetRequest, isDocsSkillRequest, matchesDocsLlmsTxtSection, normalizeDocsPathSegment, normalizeDocsRelated, normalizeDocsUrlPath, normalizeGeneratedAgentContent, parseGeneratedAgentDocument, performDocsSearch, readDocsSitemapManifestFromContentMap, renderDocsLlmsTxt, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, renderDocsPageStructuredDataJson, renderDocsRelatedMarkdownLines, renderDocsRobotsGeneratedBlock, renderDocsRobotsTxt, renderDocsSitemapMarkdown, renderDocsSitemapXml, renderDocsSkillDocument, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsAgentMdxContent, resolveDocsAnalyticsConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsObservabilityConfig, resolveDocsPath, resolveDocsRobotsConfig, resolveDocsSitemapConfig, resolveDocsSitemapPageLastmod, resolveDocsSitemapRequest, resolveDocsSkillFormat, resolveOGImage, resolvePageReadingTime, resolvePageSidebarFolderIndexBehavior, resolveReadingTimeFromContent, resolveReadingTimeFromSource, resolveReadingTimeOptions, resolveSearchRequestConfig, resolveSidebarFolderIndexBehavior, resolveSidebarFolderIndexBehaviorForPath, resolveTitle, selectDocsLlmsTxtContent, serializeGeneratedAgentDocument, stripGeneratedAgentProvenance, toDocsMarkdownUrl, toDocsSitemapMarkdownUrl, upsertDocsRobotsGeneratedBlock };
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { D as emitDocsAgentTraceEvent, E as createDocsAgentTraceId, O as emitDocsAnalyticsEvent, T as createDocsAgentTraceContext, u as performDocsSearch, x as resolvePageSidebarFolderIndexBehavior, y as stripGeneratedAgentProvenance } from "./search-
|
|
1
|
+
import { D as emitDocsAgentTraceEvent, E as createDocsAgentTraceId, O as emitDocsAnalyticsEvent, T as createDocsAgentTraceContext, u as performDocsSearch, x as resolvePageSidebarFolderIndexBehavior, y as stripGeneratedAgentProvenance } from "./search-BL7o2rXk.mjs";
|
|
2
2
|
import { n as renderDocsRelatedMarkdownLines, t as normalizeDocsRelated } from "./related-BNj_NdHq.mjs";
|
|
3
3
|
import matter from "gray-matter";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import { randomUUID } from "node:crypto";
|
|
7
6
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
8
|
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
@@ -522,23 +521,9 @@ function createDocsMcpHttpHandler(options) {
|
|
|
522
521
|
}),
|
|
523
522
|
DELETE: async () => createJsonErrorResponse(404, disabledMessage)
|
|
524
523
|
};
|
|
525
|
-
|
|
526
|
-
async function createSession() {
|
|
524
|
+
async function createStatelessTransport() {
|
|
527
525
|
const server = await createDocsMcpServer(options);
|
|
528
|
-
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
529
|
-
sessionIdGenerator: () => randomUUID(),
|
|
530
|
-
onsessioninitialized(sessionId) {
|
|
531
|
-
sessions.set(sessionId, {
|
|
532
|
-
server,
|
|
533
|
-
transport
|
|
534
|
-
});
|
|
535
|
-
},
|
|
536
|
-
async onsessionclosed(sessionId) {
|
|
537
|
-
const session = sessions.get(sessionId);
|
|
538
|
-
sessions.delete(sessionId);
|
|
539
|
-
await session?.server.close().catch(() => void 0);
|
|
540
|
-
}
|
|
541
|
-
});
|
|
526
|
+
const transport = new WebStandardStreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
|
|
542
527
|
await server.connect(transport);
|
|
543
528
|
return {
|
|
544
529
|
server,
|
|
@@ -549,7 +534,6 @@ function createDocsMcpHttpHandler(options) {
|
|
|
549
534
|
const url = new URL(request.url);
|
|
550
535
|
const method = request.method.toUpperCase();
|
|
551
536
|
const sessionId = request.headers.get("mcp-session-id") ?? request.headers.get("Mcp-Session-Id");
|
|
552
|
-
const existing = sessionId ? sessions.get(sessionId) : void 0;
|
|
553
537
|
let parsedBody;
|
|
554
538
|
let bodyParseFailed = false;
|
|
555
539
|
if (method === "POST") try {
|
|
@@ -566,26 +550,17 @@ function createDocsMcpHttpHandler(options) {
|
|
|
566
550
|
path: url.pathname,
|
|
567
551
|
properties: {
|
|
568
552
|
method,
|
|
569
|
-
hasSession: Boolean(
|
|
553
|
+
hasSession: Boolean(sessionId),
|
|
554
|
+
stateless: true,
|
|
570
555
|
initialize: Boolean(initializeRequest)
|
|
571
556
|
}
|
|
572
557
|
});
|
|
573
|
-
if (
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if (!initializeRequest) return createJsonRpcErrorResponse({
|
|
580
|
-
status: sessionId || method === "DELETE" ? 404 : 400,
|
|
581
|
-
code: sessionId ? -32001 : -32e3,
|
|
582
|
-
message: sessionId ? "Session not found. Reinitialize the MCP client before calling docs tools." : "MCP session not initialized. Start with an initialize request against this endpoint.",
|
|
583
|
-
id: readJsonRpcId(parsedBody),
|
|
584
|
-
data: { reason: sessionId ? "session_not_found" : "session_not_initialized" }
|
|
585
|
-
});
|
|
586
|
-
return (await createSession()).transport.handleRequest(request, parsedBody === void 0 ? void 0 : { parsedBody });
|
|
587
|
-
}
|
|
588
|
-
return existing.transport.handleRequest(request, parsedBody === void 0 ? void 0 : { parsedBody });
|
|
558
|
+
if (method === "POST" && bodyParseFailed) return createJsonRpcErrorResponse({
|
|
559
|
+
status: 400,
|
|
560
|
+
code: -32700,
|
|
561
|
+
message: "Parse error: Invalid JSON"
|
|
562
|
+
});
|
|
563
|
+
return (await createStatelessTransport()).transport.handleRequest(request, parsedBody === void 0 ? void 0 : { parsedBody });
|
|
589
564
|
}
|
|
590
565
|
return {
|
|
591
566
|
GET: async ({ request }) => handle(request),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as DOCS_ROBOTS_GENERATED_BLOCK_START, l as resolveDocsRobotsConfig, r as DOCS_ROBOTS_GENERATED_BLOCK_END, s as renderDocsRobotsGeneratedBlock, u as upsertDocsRobotsGeneratedBlock } from "./robots-
|
|
1
|
+
import { i as DOCS_ROBOTS_GENERATED_BLOCK_START, l as resolveDocsRobotsConfig, r as DOCS_ROBOTS_GENERATED_BLOCK_END, s as renderDocsRobotsGeneratedBlock, u as upsertDocsRobotsGeneratedBlock } from "./robots-D7dvjbuN.mjs";
|
|
2
2
|
import { d as readTopLevelStringProperty, f as resolveDocsConfigPath, i as loadDocsConfigModule, o as readBooleanProperty, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-UI31_wlO.mjs";
|
|
3
3
|
import { t as detectFramework } from "./utils-AmYxHDoz.mjs";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -19,6 +19,7 @@ const DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE = "/.well-known/skill.md";
|
|
|
19
19
|
const DEFAULT_AGENT_DISCOVERY_ROBOTS_TXT_ROUTE = "/robots.txt";
|
|
20
20
|
const DEFAULT_AGENT_FEEDBACK_ROUTE = "/api/docs/agent/feedback";
|
|
21
21
|
const DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER = "Signature-Agent";
|
|
22
|
+
const DOCS_LLMS_TXT_DIRECTIVE_LINE = "LLM index: /llms.txt";
|
|
22
23
|
function normalizeDocsPathSegment(value) {
|
|
23
24
|
return value.replace(/^\/+|\/+$/g, "");
|
|
24
25
|
}
|
|
@@ -328,10 +329,16 @@ function findDocsMarkdownPage(entry, pages, requestedPath) {
|
|
|
328
329
|
for (const page of pages) if (page.slug !== void 0 && normalizeDocsPathSegment(page.slug) === normalizedSlug) return page;
|
|
329
330
|
return null;
|
|
330
331
|
}
|
|
331
|
-
function
|
|
332
|
+
function shouldRenderLlmsDirective(options) {
|
|
333
|
+
if (options?.llms === false) return false;
|
|
334
|
+
if (options?.llms && typeof options.llms === "object" && options.llms.enabled === false) return false;
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
function renderDocsMarkdownDocument(page, options) {
|
|
332
338
|
if (page.agentRawContent !== void 0) return page.agentRawContent;
|
|
333
339
|
const relatedLines = renderDocsRelatedMarkdownLines(page.related);
|
|
334
340
|
const lines = [`# ${page.title}`, `URL: ${page.url}`];
|
|
341
|
+
if (shouldRenderLlmsDirective(options)) lines.push(DOCS_LLMS_TXT_DIRECTIVE_LINE);
|
|
335
342
|
if (page.description) lines.push(`Description: ${page.description}`);
|
|
336
343
|
lines.push(...relatedLines);
|
|
337
344
|
lines.push("", page.agentFallbackRawContent ?? page.rawContent ?? page.content);
|
|
@@ -1112,8 +1112,7 @@ function createMcpSearchAdapter(config) {
|
|
|
1112
1112
|
const initializePayload = await readMcpResponsePayload(initializeResponse);
|
|
1113
1113
|
ensureOk(initializeResponse, "MCP search initialization failed");
|
|
1114
1114
|
ensureJsonRpcOk(initializePayload, "MCP search initialization failed");
|
|
1115
|
-
const sessionId = initializeResponse.headers.get("mcp-session-id");
|
|
1116
|
-
if (!sessionId) throw new Error("MCP search endpoint did not return an mcp-session-id header.");
|
|
1115
|
+
const sessionId = initializeResponse.headers.get("mcp-session-id") ?? void 0;
|
|
1117
1116
|
try {
|
|
1118
1117
|
const searchResponse = await fetch(endpoint, {
|
|
1119
1118
|
method: "POST",
|
|
@@ -1122,7 +1121,7 @@ function createMcpSearchAdapter(config) {
|
|
|
1122
1121
|
"Content-Type": "application/json",
|
|
1123
1122
|
accept: "application/json, text/event-stream",
|
|
1124
1123
|
"mcp-protocol-version": protocolVersion,
|
|
1125
|
-
"mcp-session-id": sessionId
|
|
1124
|
+
...sessionId ? { "mcp-session-id": sessionId } : {}
|
|
1126
1125
|
},
|
|
1127
1126
|
body: JSON.stringify({
|
|
1128
1127
|
jsonrpc: "2.0",
|
|
@@ -1146,7 +1145,7 @@ function createMcpSearchAdapter(config) {
|
|
|
1146
1145
|
const parsed = JSON.parse(resultText);
|
|
1147
1146
|
return (Array.isArray(parsed) ? parsed : Array.isArray(parsed.results) ? parsed.results : Array.isArray(parsed.pages) ? parsed.pages : []).map(mapMcpSearchResult).filter((result) => Boolean(result));
|
|
1148
1147
|
} finally {
|
|
1149
|
-
await fetch(endpoint, {
|
|
1148
|
+
if (sessionId) await fetch(endpoint, {
|
|
1150
1149
|
method: "DELETE",
|
|
1151
1150
|
headers: {
|
|
1152
1151
|
...baseHeaders,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as buildDocsSearchDocuments, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter } from "./search-
|
|
1
|
+
import { n as buildDocsSearchDocuments, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter } from "./search-BL7o2rXk.mjs";
|
|
2
2
|
import "./sitemap-server-DwEPfk13.mjs";
|
|
3
3
|
import { createFilesystemDocsMcpSource } from "./mcp.mjs";
|
|
4
4
|
import "./server.mjs";
|
package/dist/server.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as resolveDocsAnalyticsConfig, D as emitDocsAgentTraceEvent, E as createDocsAgentTraceId, M as createDocsCloudAnalytics, O as emitDocsAnalyticsEvent, T as createDocsAgentTraceContext, a as createMcpSearchAdapter, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, f as resolveSearchRequestConfig, i as createCustomSearchAdapter, j as resolveDocsObservabilityConfig, k as emitDocsObservabilityEvent, l as inferDocsAskAIPackageHints, n as buildDocsSearchDocuments, o as createSimpleSearchAdapter, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, u as performDocsSearch, w as DOCS_AGENT_TRACE_EVENT_TYPES } from "./search-
|
|
1
|
+
import { A as resolveDocsAnalyticsConfig, D as emitDocsAgentTraceEvent, E as createDocsAgentTraceId, M as createDocsCloudAnalytics, O as emitDocsAnalyticsEvent, T as createDocsAgentTraceContext, a as createMcpSearchAdapter, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, f as resolveSearchRequestConfig, i as createCustomSearchAdapter, j as resolveDocsObservabilityConfig, k as emitDocsObservabilityEvent, l as inferDocsAskAIPackageHints, n as buildDocsSearchDocuments, o as createSimpleSearchAdapter, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, u as performDocsSearch, w as DOCS_AGENT_TRACE_EVENT_TYPES } from "./search-BL7o2rXk.mjs";
|
|
2
2
|
import { a as buildDocsSitemapManifest, c as renderDocsSitemapMarkdown, d as resolveDocsSitemapPageLastmod, f as resolveDocsSitemapRequest, i as DEFAULT_SITEMAP_XML_ROUTE, l as renderDocsSitemapXml, n as DEFAULT_SITEMAP_MD_ROUTE, o as createDocsSitemapResponse, p as toDocsSitemapMarkdownUrl, r as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, s as readDocsSitemapManifestFromContentMap, t as DEFAULT_SITEMAP_MANIFEST_PATH, u as resolveDocsSitemapConfig } from "./sitemap-BIQIYMKe.mjs";
|
|
3
3
|
import { _ as resolveApiReferenceRenderer, a as resolvePromptProviderChoices, c as serializeDocsIconRegistry, d as buildApiReferenceHtmlDocumentAsync, f as buildApiReferenceOpenApiDocument, g as resolveApiReferenceConfig, h as buildApiReferenceScalarCss, i as parsePromptStringArray, l as serializeOpenDocsProviders, m as buildApiReferencePageTitle, n as DEFAULT_PROMPT_PROVIDER_TEMPLATES, o as sanitizePromptText, p as buildApiReferenceOpenApiDocumentAsync, r as normalizePromptProviderName, s as serializeDocsIcon, t as readDocsSitemapManifest, u as buildApiReferenceHtmlDocument } from "./sitemap-server-DwEPfk13.mjs";
|
|
4
4
|
import { createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./search-
|
|
1
|
+
import "./search-BL7o2rXk.mjs";
|
|
2
2
|
import { a as buildDocsSitemapManifest, c as renderDocsSitemapMarkdown, l as renderDocsSitemapXml, u as resolveDocsSitemapConfig } from "./sitemap-BIQIYMKe.mjs";
|
|
3
3
|
import "./sitemap-server-DwEPfk13.mjs";
|
|
4
4
|
import { createFilesystemDocsMcpSource } from "./mcp.mjs";
|