milieu-cli 0.3.2 → 0.4.0
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/README.md +177 -76
- package/dist/bridges/context/agents-json.d.ts +0 -1
- package/dist/bridges/context/agents-json.js +21 -12
- package/dist/bridges/context/auth-clarity.d.ts +0 -1
- package/dist/bridges/context/auth-clarity.js +11 -9
- package/dist/bridges/context/auth-legibility.d.ts +2 -2
- package/dist/bridges/context/auth-legibility.js +67 -60
- package/dist/bridges/context/index.d.ts +1 -2
- package/dist/bridges/context/index.js +19 -40
- package/dist/bridges/context/oauth-metadata.d.ts +14 -0
- package/dist/bridges/context/oauth-metadata.js +127 -0
- package/dist/bridges/context/probe.d.ts +33 -0
- package/dist/bridges/context/probe.js +157 -0
- package/dist/bridges/context/rate-limits.d.ts +5 -2
- package/dist/bridges/context/rate-limits.js +27 -51
- package/dist/bridges/context/tos-contact.d.ts +13 -4
- package/dist/bridges/context/tos-contact.js +108 -46
- package/dist/bridges/context/versioning.d.ts +1 -2
- package/dist/bridges/context/versioning.js +42 -7
- package/dist/bridges/index.d.ts +0 -1
- package/dist/bridges/index.js +0 -1
- package/dist/bridges/reachability/crawler-policy.d.ts +30 -10
- package/dist/bridges/reachability/crawler-policy.js +41 -56
- package/dist/bridges/reachability/http-status.d.ts +3 -2
- package/dist/bridges/reachability/http-status.js +18 -3
- package/dist/bridges/reachability/https-check.d.ts +2 -2
- package/dist/bridges/reachability/https-check.js +6 -3
- package/dist/bridges/reachability/index.d.ts +1 -2
- package/dist/bridges/reachability/index.js +34 -43
- package/dist/bridges/reachability/meta-robots.d.ts +0 -13
- package/dist/bridges/reachability/meta-robots.js +89 -101
- package/dist/bridges/reachability/robots-parser.d.ts +7 -7
- package/dist/bridges/reachability/robots-parser.js +65 -15
- package/dist/bridges/reachability/robots-txt.d.ts +4 -2
- package/dist/bridges/reachability/robots-txt.js +33 -60
- package/dist/bridges/schema/descriptions.d.ts +2 -2
- package/dist/bridges/schema/descriptions.js +79 -44
- package/dist/bridges/schema/error-schemas.d.ts +2 -2
- package/dist/bridges/schema/error-schemas.js +31 -18
- package/dist/bridges/schema/index.d.ts +2 -2
- package/dist/bridges/schema/index.js +48 -30
- package/dist/bridges/schema/oas-types.d.ts +65 -26
- package/dist/bridges/schema/oas-types.js +37 -7
- package/dist/bridges/schema/operation-ids.d.ts +2 -2
- package/dist/bridges/schema/operation-ids.js +2 -3
- package/dist/bridges/schema/required-fields.d.ts +2 -2
- package/dist/bridges/schema/required-fields.js +12 -10
- package/dist/bridges/schema/schema-sources.d.ts +19 -0
- package/dist/bridges/schema/schema-sources.js +182 -0
- package/dist/bridges/schema/schema-types.d.ts +2 -2
- package/dist/bridges/schema/schema-types.js +20 -21
- package/dist/bridges/separation/api-presence.d.ts +3 -15
- package/dist/bridges/separation/api-presence.js +34 -85
- package/dist/bridges/separation/developer-docs.d.ts +6 -18
- package/dist/bridges/separation/developer-docs.js +100 -99
- package/dist/bridges/separation/docs-discovery.d.ts +28 -0
- package/dist/bridges/separation/docs-discovery.js +95 -0
- package/dist/bridges/separation/evidence-summary.d.ts +2 -0
- package/dist/bridges/separation/evidence-summary.js +67 -0
- package/dist/bridges/separation/index.d.ts +2 -19
- package/dist/bridges/separation/index.js +35 -39
- package/dist/bridges/separation/published-routes.d.ts +69 -0
- package/dist/bridges/separation/published-routes.js +271 -0
- package/dist/bridges/separation/sdk-references.d.ts +8 -3
- package/dist/bridges/separation/sdk-references.js +86 -61
- package/dist/bridges/separation/webhook-support.d.ts +3 -23
- package/dist/bridges/separation/webhook-support.js +61 -162
- package/dist/bridges/standards/a2a-agent-card.d.ts +0 -1
- package/dist/bridges/standards/a2a-agent-card.js +24 -9
- package/dist/bridges/standards/graphql.d.ts +3 -4
- package/dist/bridges/standards/graphql.js +70 -66
- package/dist/bridges/standards/index.d.ts +1 -2
- package/dist/bridges/standards/index.js +57 -47
- package/dist/bridges/standards/json-ld.d.ts +25 -11
- package/dist/bridges/standards/json-ld.js +114 -56
- package/dist/bridges/standards/llms-txt.d.ts +4 -2
- package/dist/bridges/standards/llms-txt.js +46 -32
- package/dist/bridges/standards/markdown-negotiation.d.ts +4 -1
- package/dist/bridges/standards/markdown-negotiation.js +16 -11
- package/dist/bridges/standards/mcp.d.ts +3 -12
- package/dist/bridges/standards/mcp.js +89 -132
- package/dist/bridges/standards/openapi.d.ts +7 -15
- package/dist/bridges/standards/openapi.js +657 -207
- package/dist/bridges/standards/probe-evidence.d.ts +30 -0
- package/dist/bridges/standards/probe-evidence.js +90 -0
- package/dist/bridges/standards/schema-org.d.ts +15 -9
- package/dist/bridges/standards/schema-org.js +38 -64
- package/dist/bridges/standards/sitemap.d.ts +2 -3
- package/dist/bridges/standards/sitemap.js +161 -169
- package/dist/bridges/standards/well-known.d.ts +3 -7
- package/dist/bridges/standards/well-known.js +28 -12
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +107 -22
- package/dist/cli/journey-commands.d.ts +3 -0
- package/dist/cli/journey-commands.js +35 -0
- package/dist/cli/read-report.d.ts +2 -0
- package/dist/cli/read-report.js +11 -0
- package/dist/core/bridge-output.d.ts +11 -0
- package/dist/core/bridge-output.js +86 -0
- package/dist/core/bridge-session.d.ts +28 -0
- package/dist/core/bridge-session.js +58 -0
- package/dist/core/bridge-worker.d.ts +1 -0
- package/dist/core/bridge-worker.js +66 -0
- package/dist/core/diff.d.ts +79 -0
- package/dist/core/diff.js +499 -0
- package/dist/core/explanations.d.ts +1 -3
- package/dist/core/explanations.js +36 -59
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +2 -3
- package/dist/core/scan-options.d.ts +0 -1
- package/dist/core/scan-options.js +14 -6
- package/dist/core/scan.d.ts +0 -1
- package/dist/core/scan.js +91 -41
- package/dist/core/scoring.d.ts +6 -0
- package/dist/core/scoring.js +27 -0
- package/dist/core/types.d.ts +97 -61
- package/dist/core/types.js +9 -3
- package/dist/core/validate-report.d.ts +5 -0
- package/dist/core/validate-report.js +95 -0
- package/dist/core/version.d.ts +0 -1
- package/dist/core/version.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/journey/body-worker.d.ts +27 -0
- package/dist/journey/body-worker.js +140 -0
- package/dist/journey/case.d.ts +74 -0
- package/dist/journey/case.js +187 -0
- package/dist/journey/cli.d.ts +14 -0
- package/dist/journey/cli.js +226 -0
- package/dist/journey/compare.d.ts +43 -0
- package/dist/journey/compare.js +83 -0
- package/dist/journey/contracts.d.ts +143 -0
- package/dist/journey/contracts.js +37 -0
- package/dist/journey/decision.d.ts +72 -0
- package/dist/journey/decision.js +121 -0
- package/dist/journey/demo.d.ts +36 -0
- package/dist/journey/demo.js +137 -0
- package/dist/journey/document.d.ts +8 -0
- package/dist/journey/document.js +113 -0
- package/dist/journey/excerpt.d.ts +6 -0
- package/dist/journey/excerpt.js +54 -0
- package/dist/journey/name-guidance.d.ts +2 -0
- package/dist/journey/name-guidance.js +41 -0
- package/dist/journey/providers.d.ts +34 -0
- package/dist/journey/providers.js +197 -0
- package/dist/journey/report-validation.d.ts +3 -0
- package/dist/journey/report-validation.js +457 -0
- package/dist/journey/runner.d.ts +12 -0
- package/dist/journey/runner.js +321 -0
- package/dist/journey/scope.d.ts +8 -0
- package/dist/journey/scope.js +50 -0
- package/dist/journey/transport.d.ts +3 -0
- package/dist/journey/transport.js +45 -0
- package/dist/journey/verify.d.ts +21 -0
- package/dist/journey/verify.js +213 -0
- package/dist/render/colors.d.ts +6 -7
- package/dist/render/colors.js +16 -25
- package/dist/render/discovery-guidance.d.ts +3 -0
- package/dist/render/discovery-guidance.js +66 -0
- package/dist/render/format-bridge.d.ts +1 -2
- package/dist/render/format-bridge.js +22 -17
- package/dist/render/format-diff.d.ts +2 -0
- package/dist/render/format-diff.js +169 -0
- package/dist/render/format-scan.d.ts +0 -1
- package/dist/render/format-scan.js +6 -4
- package/dist/render/format-verbose.d.ts +0 -1
- package/dist/render/format-verbose.js +7 -4
- package/dist/render/index.d.ts +0 -1
- package/dist/render/index.js +1 -2
- package/dist/render/oauth-observations.d.ts +4 -0
- package/dist/render/oauth-observations.js +27 -0
- package/dist/render/progress-bar.d.ts +1 -2
- package/dist/render/progress-bar.js +8 -6
- package/dist/render/robots-inventory.d.ts +3 -0
- package/dist/render/robots-inventory.js +38 -0
- package/dist/render/symbols.d.ts +4 -10
- package/dist/render/symbols.js +15 -17
- package/dist/render/terminal-text.d.ts +1 -3
- package/dist/render/terminal-text.js +1 -5
- package/dist/utils/analysis-worker-entry.d.ts +3 -0
- package/dist/utils/analysis-worker-entry.js +12 -0
- package/dist/utils/analysis-worker.d.ts +12 -0
- package/dist/utils/analysis-worker.js +54 -0
- package/dist/utils/html.d.ts +39 -0
- package/dist/utils/html.js +261 -0
- package/dist/utils/http-client.d.ts +24 -17
- package/dist/utils/http-client.js +166 -200
- package/dist/utils/http-types.d.ts +43 -0
- package/dist/utils/http-types.js +11 -0
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/package-registry.d.ts +11 -0
- package/dist/utils/package-registry.js +69 -0
- package/dist/utils/read-json-file.d.ts +3 -0
- package/dist/utils/read-json-file.js +41 -0
- package/dist/utils/record.d.ts +1 -0
- package/dist/utils/record.js +3 -0
- package/dist/utils/response-body.d.ts +7 -0
- package/dist/utils/response-body.js +71 -0
- package/dist/utils/ssrf.d.ts +11 -15
- package/dist/utils/ssrf.js +80 -44
- package/dist/utils/terminal-text.d.ts +2 -0
- package/dist/utils/terminal-text.js +4 -0
- package/dist/utils/url.d.ts +29 -1
- package/dist/utils/url.js +147 -17
- package/docs/examples/onboarding/account-claim.json +25 -0
- package/docs/examples/onboarding/pages/account-claim.html +3 -0
- package/docs/examples/onboarding/pages/production-activation.html +3 -0
- package/docs/examples/onboarding/pages/test-credential.html +3 -0
- package/docs/examples/onboarding/production-activation.json +25 -0
- package/docs/examples/onboarding/test-credential.json +25 -0
- package/docs/journey-qualification.md +46 -0
- package/docs/journeys.md +83 -0
- package/package.json +28 -8
- package/dist/bridges/context/agents-json.d.ts.map +0 -1
- package/dist/bridges/context/agents-json.js.map +0 -1
- package/dist/bridges/context/auth-clarity.d.ts.map +0 -1
- package/dist/bridges/context/auth-clarity.js.map +0 -1
- package/dist/bridges/context/auth-legibility.d.ts.map +0 -1
- package/dist/bridges/context/auth-legibility.js.map +0 -1
- package/dist/bridges/context/index.d.ts.map +0 -1
- package/dist/bridges/context/index.js.map +0 -1
- package/dist/bridges/context/rate-limits.d.ts.map +0 -1
- package/dist/bridges/context/rate-limits.js.map +0 -1
- package/dist/bridges/context/tos-contact.d.ts.map +0 -1
- package/dist/bridges/context/tos-contact.js.map +0 -1
- package/dist/bridges/context/versioning.d.ts.map +0 -1
- package/dist/bridges/context/versioning.js.map +0 -1
- package/dist/bridges/index.d.ts.map +0 -1
- package/dist/bridges/index.js.map +0 -1
- package/dist/bridges/reachability/crawler-policy.d.ts.map +0 -1
- package/dist/bridges/reachability/crawler-policy.js.map +0 -1
- package/dist/bridges/reachability/http-status.d.ts.map +0 -1
- package/dist/bridges/reachability/http-status.js.map +0 -1
- package/dist/bridges/reachability/https-check.d.ts.map +0 -1
- package/dist/bridges/reachability/https-check.js.map +0 -1
- package/dist/bridges/reachability/index.d.ts.map +0 -1
- package/dist/bridges/reachability/index.js.map +0 -1
- package/dist/bridges/reachability/meta-robots.d.ts.map +0 -1
- package/dist/bridges/reachability/meta-robots.js.map +0 -1
- package/dist/bridges/reachability/robots-parser.d.ts.map +0 -1
- package/dist/bridges/reachability/robots-parser.js.map +0 -1
- package/dist/bridges/reachability/robots-txt.d.ts.map +0 -1
- package/dist/bridges/reachability/robots-txt.js.map +0 -1
- package/dist/bridges/schema/descriptions.d.ts.map +0 -1
- package/dist/bridges/schema/descriptions.js.map +0 -1
- package/dist/bridges/schema/error-schemas.d.ts.map +0 -1
- package/dist/bridges/schema/error-schemas.js.map +0 -1
- package/dist/bridges/schema/index.d.ts.map +0 -1
- package/dist/bridges/schema/index.js.map +0 -1
- package/dist/bridges/schema/oas-types.d.ts.map +0 -1
- package/dist/bridges/schema/oas-types.js.map +0 -1
- package/dist/bridges/schema/operation-ids.d.ts.map +0 -1
- package/dist/bridges/schema/operation-ids.js.map +0 -1
- package/dist/bridges/schema/required-fields.d.ts.map +0 -1
- package/dist/bridges/schema/required-fields.js.map +0 -1
- package/dist/bridges/schema/schema-types.d.ts.map +0 -1
- package/dist/bridges/schema/schema-types.js.map +0 -1
- package/dist/bridges/separation/api-presence.d.ts.map +0 -1
- package/dist/bridges/separation/api-presence.js.map +0 -1
- package/dist/bridges/separation/developer-docs.d.ts.map +0 -1
- package/dist/bridges/separation/developer-docs.js.map +0 -1
- package/dist/bridges/separation/index.d.ts.map +0 -1
- package/dist/bridges/separation/index.js.map +0 -1
- package/dist/bridges/separation/sdk-references.d.ts.map +0 -1
- package/dist/bridges/separation/sdk-references.js.map +0 -1
- package/dist/bridges/separation/webhook-support.d.ts.map +0 -1
- package/dist/bridges/separation/webhook-support.js.map +0 -1
- package/dist/bridges/standards/a2a-agent-card.d.ts.map +0 -1
- package/dist/bridges/standards/a2a-agent-card.js.map +0 -1
- package/dist/bridges/standards/graphql.d.ts.map +0 -1
- package/dist/bridges/standards/graphql.js.map +0 -1
- package/dist/bridges/standards/index.d.ts.map +0 -1
- package/dist/bridges/standards/index.js.map +0 -1
- package/dist/bridges/standards/json-ld.d.ts.map +0 -1
- package/dist/bridges/standards/json-ld.js.map +0 -1
- package/dist/bridges/standards/llms-txt.d.ts.map +0 -1
- package/dist/bridges/standards/llms-txt.js.map +0 -1
- package/dist/bridges/standards/markdown-negotiation.d.ts.map +0 -1
- package/dist/bridges/standards/markdown-negotiation.js.map +0 -1
- package/dist/bridges/standards/mcp.d.ts.map +0 -1
- package/dist/bridges/standards/mcp.js.map +0 -1
- package/dist/bridges/standards/openapi.d.ts.map +0 -1
- package/dist/bridges/standards/openapi.js.map +0 -1
- package/dist/bridges/standards/schema-org.d.ts.map +0 -1
- package/dist/bridges/standards/schema-org.js.map +0 -1
- package/dist/bridges/standards/sitemap.d.ts.map +0 -1
- package/dist/bridges/standards/sitemap.js.map +0 -1
- package/dist/bridges/standards/well-known.d.ts.map +0 -1
- package/dist/bridges/standards/well-known.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/core/explanations.d.ts.map +0 -1
- package/dist/core/explanations.js.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/scan-options.d.ts.map +0 -1
- package/dist/core/scan-options.js.map +0 -1
- package/dist/core/scan.d.ts.map +0 -1
- package/dist/core/scan.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/core/version.d.ts.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/render/colors.d.ts.map +0 -1
- package/dist/render/colors.js.map +0 -1
- package/dist/render/format-bridge.d.ts.map +0 -1
- package/dist/render/format-bridge.js.map +0 -1
- package/dist/render/format-scan.d.ts.map +0 -1
- package/dist/render/format-scan.js.map +0 -1
- package/dist/render/format-verbose.d.ts.map +0 -1
- package/dist/render/format-verbose.js.map +0 -1
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/index.js.map +0 -1
- package/dist/render/progress-bar.d.ts.map +0 -1
- package/dist/render/progress-bar.js.map +0 -1
- package/dist/render/symbols.d.ts.map +0 -1
- package/dist/render/symbols.js.map +0 -1
- package/dist/render/terminal-text.d.ts.map +0 -1
- package/dist/render/terminal-text.js.map +0 -1
- package/dist/utils/http-client.d.ts.map +0 -1
- package/dist/utils/http-client.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/ssrf.d.ts.map +0 -1
- package/dist/utils/ssrf.js.map +0 -1
- package/dist/utils/url.d.ts.map +0 -1
- package/dist/utils/url.js.map +0 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { scoreChecks } from "../../core/scoring.js";
|
|
2
|
+
import { incompleteHomepage } from "./probe-evidence.js";
|
|
3
|
+
import { checkOpenApi, withRegistry } from "./openapi.js";
|
|
2
4
|
import { checkLlmsTxt, checkLlmsFullTxt } from "./llms-txt.js";
|
|
3
|
-
import { checkMcpEndpoint } from "./mcp.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { checkMcpEndpoint, MCP_PATH } from "./mcp.js";
|
|
6
|
+
import { HTML_LIMIT_DETAIL, htmlElements } from "../../utils/html.js";
|
|
7
|
+
import { checkJsonLd, extractJsonLdBlocks, jsonLdScripts } from "./json-ld.js";
|
|
8
|
+
import { checkSchemaOrg, itemtypes } from "./schema-org.js";
|
|
6
9
|
import { checkSecurityTxt } from "./well-known.js";
|
|
7
10
|
import { checkGraphql } from "./graphql.js";
|
|
8
11
|
import { checkSitemap } from "./sitemap.js";
|
|
9
12
|
import { checkMarkdownNegotiation } from "./markdown-negotiation.js";
|
|
10
13
|
import { checkA2aAgentCard } from "./a2a-agent-card.js";
|
|
14
|
+
import { extractTosUrlFromHtml, securityTxtContact } from "../context/tos-contact.js";
|
|
11
15
|
import { httpGet } from "../../utils/http-client.js";
|
|
12
16
|
/**
|
|
13
17
|
* Check weights by adoption maturity.
|
|
@@ -30,65 +34,71 @@ const CHECK_WEIGHTS = {
|
|
|
30
34
|
mcp_endpoint: 1,
|
|
31
35
|
standards_a2a_agent_card: 1,
|
|
32
36
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
points += weight * 0.5;
|
|
47
|
-
}
|
|
48
|
-
const score = maxPoints === 0 ? 0 : Math.round((points / maxPoints) * 100);
|
|
49
|
-
const scoreLabel = score >= 60 ? "pass" : score >= 30 ? "partial" : "fail";
|
|
50
|
-
return { score, scoreLabel };
|
|
37
|
+
/** What the homepage checks read from the page's tree. An element keeps the whole tree in memory, so none leaves here. */
|
|
38
|
+
function readHomepage(pageBody, pageUrl) {
|
|
39
|
+
const elements = [...htmlElements(pageBody)];
|
|
40
|
+
return { scripts: jsonLdScripts(elements), itemtypes: itemtypes(elements), termsUrl: extractTosUrlFromHtml(elements, pageUrl) };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The checks on the homepage's markup, and its Terms link. The page's tree can take half the bridge's heap and so
|
|
44
|
+
* can one JSON-LD block once it is parsed: the tree is let go before a block is parsed, and the blocks' text here.
|
|
45
|
+
*/
|
|
46
|
+
function checkHomepage(pageBody, pageUrl) {
|
|
47
|
+
const { scripts, itemtypes, termsUrl } = readHomepage(pageBody, pageUrl);
|
|
48
|
+
const jsonLdCheck = checkJsonLd(extractJsonLdBlocks(scripts));
|
|
49
|
+
return { jsonLdCheck, schemaOrgCheck: checkSchemaOrg(itemtypes, jsonLdCheck), termsUrl };
|
|
51
50
|
}
|
|
52
51
|
export async function runStandardsBridge(ctx) {
|
|
53
52
|
const start = performance.now();
|
|
54
53
|
const pageBody = ctx.shared.pageBody ?? "";
|
|
55
54
|
const robotsSitemaps = ctx.shared.robotsSitemaps ?? [];
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
checkOpenApi(
|
|
69
|
-
checkGraphql(
|
|
70
|
-
checkMcpEndpoint(ctx.baseUrl, ctx.options.timeout, pageBody, llmsTxtResult.body ?? undefined, mcpDiscoveryResponse),
|
|
55
|
+
const { baseUrl, options: { timeout, registryLookup } } = ctx;
|
|
56
|
+
const sitemap = checkSitemap(baseUrl, robotsSitemaps, timeout, ctx.shared.robotsSitemapsCut);
|
|
57
|
+
const llms = checkLlmsTxt(baseUrl, timeout);
|
|
58
|
+
// The declaration is requested here, among the first probes, and named only as the check that reads it: a
|
|
59
|
+
// response this function names is held, body and all, for as long as the bridge runs.
|
|
60
|
+
const mcp = Promise.all([llms, httpGet(new URL(MCP_PATH, baseUrl).href, { timeout, headers: { Accept: "application/json" } })])
|
|
61
|
+
.then(([index, response]) => checkMcpEndpoint(baseUrl, timeout, pageBody, index.body ?? undefined, response));
|
|
62
|
+
const probes = Promise.all([
|
|
63
|
+
sitemap, checkMarkdownNegotiation(baseUrl, timeout), llms, checkLlmsFullTxt(baseUrl, timeout),
|
|
64
|
+
// Context reports one Contact line of security.txt. It is read as the file arrives, and the file let go.
|
|
65
|
+
checkSecurityTxt(baseUrl, timeout).then(({ check, body }) => ({ check, contact: body ? securityTxtContact(body) : null })),
|
|
66
|
+
checkA2aAgentCard(baseUrl, timeout),
|
|
67
|
+
sitemap.then(result => checkOpenApi(baseUrl, timeout, result.apiRelevantUrls, false, ctx.shared.pageResponse)),
|
|
68
|
+
checkGraphql(baseUrl, timeout), mcp,
|
|
71
69
|
]);
|
|
72
|
-
//
|
|
73
|
-
const jsonLdCheck =
|
|
74
|
-
const
|
|
70
|
+
// The homepage is read while the answers are on their way, when the bridge holds the least.
|
|
71
|
+
const { jsonLdCheck, schemaOrgCheck, termsUrl } = checkHomepage(pageBody, ctx.shared.pageUrl ?? baseUrl);
|
|
72
|
+
const [sitemapResult, markdownResult, llmsTxtResult, llmsFullTxtCheck, securityTxtResult, a2aAgentCardCheck, localOpenApi, graphqlResult, mcpResult] = await probes;
|
|
73
|
+
const openApiResult = !localOpenApi.detected && registryLookup !== false
|
|
74
|
+
? await withRegistry(localOpenApi, baseUrl, timeout) : localOpenApi;
|
|
75
75
|
// Store results for downstream bridges
|
|
76
|
+
ctx.shared.openApiCheck = openApiResult.check;
|
|
77
|
+
ctx.shared.graphqlCheck = graphqlResult.check;
|
|
78
|
+
ctx.shared.openApiDocumentUrls = openApiResult.verifiedDocumentUrls ?? [];
|
|
76
79
|
ctx.shared.openApiDetected = openApiResult.detected;
|
|
77
|
-
ctx.shared.
|
|
80
|
+
ctx.shared.openApiSpecText = openApiResult.specText;
|
|
81
|
+
ctx.shared.openApiDiscoveryIncomplete = openApiResult.check.status === "error";
|
|
78
82
|
ctx.shared.openApiHasWebhooks = openApiResult.hasWebhooks;
|
|
79
83
|
ctx.shared.openApiHasCallbacks = openApiResult.hasCallbacks;
|
|
80
84
|
ctx.shared.graphqlDetected = graphqlResult.detected;
|
|
81
|
-
ctx.shared.mcpDetected = mcpResult.detected;
|
|
82
|
-
ctx.shared.sitemapUrls = sitemapResult.urls;
|
|
83
85
|
ctx.shared.llmsTxtBody = llmsTxtResult.body;
|
|
84
|
-
ctx.shared.
|
|
86
|
+
ctx.shared.rootLlmsResponse = llmsTxtResult.response;
|
|
87
|
+
ctx.shared.securityTxtContact = securityTxtResult.contact;
|
|
88
|
+
ctx.shared.securityTxtIncomplete = securityTxtResult.check.status === "error";
|
|
89
|
+
// Read here, where the page is parsed already. Context holds the parsed spec, and with a parsed page beside it
|
|
90
|
+
// the two could take more than its heap.
|
|
91
|
+
ctx.shared.pageTermsUrl = termsUrl;
|
|
92
|
+
const homepageCheck = (check) => incompleteHomepage(ctx.shared)
|
|
93
|
+
? { id: check.id, label: check.label, status: "error",
|
|
94
|
+
detail: ctx.shared.pageOverHtmlLimit ? "Homepage " + HTML_LIMIT_DETAIL : "Homepage could not be fully inspected" }
|
|
95
|
+
: check;
|
|
85
96
|
const checks = [
|
|
86
97
|
openApiResult.check, graphqlResult.check, sitemapResult.check,
|
|
87
98
|
markdownResult.check, llmsTxtResult.check, llmsFullTxtCheck,
|
|
88
|
-
mcpResult.check, jsonLdCheck, schemaOrgCheck, securityTxtResult.check,
|
|
99
|
+
mcpResult.check, homepageCheck(jsonLdCheck), homepageCheck(schemaOrgCheck), securityTxtResult.check,
|
|
89
100
|
a2aAgentCardCheck,
|
|
90
101
|
];
|
|
91
|
-
const { score, scoreLabel } =
|
|
102
|
+
const { score, scoreLabel } = scoreChecks(checks, CHECK_WEIGHTS, 60, 30);
|
|
92
103
|
return { id: 2, name: "Standards", status: "evaluated", score, scoreLabel, checks, durationMs: Math.round(performance.now() - start) };
|
|
93
104
|
}
|
|
94
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,16 +1,30 @@
|
|
|
1
|
+
import type { DefaultTreeAdapterTypes } from "parse5";
|
|
1
2
|
import type { Check } from "../../core/types.js";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
type Vocabulary = string | {
|
|
4
|
+
"@vocab": string;
|
|
5
|
+
} | null;
|
|
6
|
+
interface JsonLdBlock {
|
|
4
7
|
type: string | string[];
|
|
5
|
-
context:
|
|
8
|
+
context: Vocabulary;
|
|
6
9
|
}
|
|
10
|
+
type JsonLdEvidence = {
|
|
11
|
+
blockCount: number;
|
|
12
|
+
blocks: JsonLdBlock[];
|
|
13
|
+
truncated: boolean;
|
|
14
|
+
schemaOrgTypes: string[];
|
|
15
|
+
schemaOrgTypesTruncated: boolean;
|
|
16
|
+
/** A block was too large to parse, so the blocks and types found are not all the page holds. */
|
|
17
|
+
oversized?: true;
|
|
18
|
+
};
|
|
19
|
+
export declare function addTypeName(names: Set<string>, raw: string): boolean;
|
|
20
|
+
export declare function schemaOrgUrl(url: URL | null): boolean;
|
|
7
21
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Scans for <script type="application/ld+json"> tags via regex,
|
|
11
|
-
* parses JSON, and collects blocks with @type fields.
|
|
12
|
-
*
|
|
13
|
-
* Pure function -- no HTTP calls. Takes HTML string directly.
|
|
22
|
+
* The text of each JSON-LD script. A page's tree can take half a bridge's heap and so can one block once it is
|
|
23
|
+
* parsed, so the text is read apart from the parsing: a caller that holds the tree lets it go between the two.
|
|
14
24
|
*/
|
|
15
|
-
export declare function
|
|
16
|
-
|
|
25
|
+
export declare function jsonLdScripts(elements: Iterable<DefaultTreeAdapterTypes.Element>): string[];
|
|
26
|
+
export declare function extractJsonLdBlocks(scripts: Iterable<string>): JsonLdEvidence;
|
|
27
|
+
export declare function checkJsonLd(html: string | JsonLdEvidence): Check & {
|
|
28
|
+
data?: JsonLdEvidence;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -1,67 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { htmlElements } from "../../utils/html.js";
|
|
2
|
+
import { isRecord } from "../../utils/record.js";
|
|
3
|
+
import { OVERSIZED, readJson } from "./probe-evidence.js";
|
|
4
|
+
import { parseReference } from "../../utils/url.js";
|
|
5
|
+
const MAX_BLOCKS = 32;
|
|
6
|
+
const MAX_TYPES_PER_BLOCK = 8;
|
|
7
|
+
const MAX_TYPE_NAMES = 32;
|
|
8
|
+
const MAX_NAME_LENGTH = 160;
|
|
9
|
+
function diagnosticName(name) {
|
|
10
|
+
return name.length <= MAX_NAME_LENGTH ? name : name.slice(0, MAX_NAME_LENGTH - 1) + "…";
|
|
11
|
+
}
|
|
12
|
+
export function addTypeName(names, raw) {
|
|
13
|
+
const name = diagnosticName(raw);
|
|
14
|
+
if (names.size >= MAX_TYPE_NAMES && !names.has(name))
|
|
15
|
+
return false;
|
|
16
|
+
names.add(name);
|
|
17
|
+
return raw === name;
|
|
18
|
+
}
|
|
19
|
+
export function schemaOrgUrl(url) {
|
|
20
|
+
return (url?.protocol === "https:" || url?.protocol === "http:") && url.hostname === "schema.org";
|
|
21
|
+
}
|
|
22
|
+
const NO_CONTEXT = { vocabulary: null, schemaOrg: false };
|
|
23
|
+
/** Keep the relevant vocabulary as a short diagnostic. Graph children inherit this projection. */
|
|
24
|
+
function projectContext(raw) {
|
|
25
|
+
let first = NO_CONTEXT;
|
|
26
|
+
for (const entry of Array.isArray(raw) ? raw : [raw]) {
|
|
27
|
+
const value = isRecord(entry) ? entry["@vocab"] : entry;
|
|
28
|
+
if (typeof value !== "string")
|
|
29
|
+
continue;
|
|
30
|
+
const schemaOrg = schemaOrgUrl(parseReference(value));
|
|
31
|
+
if (!schemaOrg && first !== NO_CONTEXT)
|
|
32
|
+
continue;
|
|
33
|
+
const name = diagnosticName(value);
|
|
34
|
+
const vocabulary = typeof entry === "string" ? name : { "@vocab": name };
|
|
35
|
+
if (schemaOrg)
|
|
36
|
+
return { vocabulary, schemaOrg };
|
|
37
|
+
first = { vocabulary, schemaOrg };
|
|
38
|
+
}
|
|
39
|
+
return first;
|
|
7
40
|
}
|
|
8
41
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Scans for <script type="application/ld+json"> tags via regex,
|
|
12
|
-
* parses JSON, and collects blocks with @type fields.
|
|
13
|
-
*
|
|
14
|
-
* Pure function -- no HTTP calls. Takes HTML string directly.
|
|
42
|
+
* The text of each JSON-LD script. A page's tree can take half a bridge's heap and so can one block once it is
|
|
43
|
+
* parsed, so the text is read apart from the parsing: a caller that holds the tree lets it go between the two.
|
|
15
44
|
*/
|
|
16
|
-
export function
|
|
17
|
-
const
|
|
18
|
-
const
|
|
45
|
+
export function jsonLdScripts(elements) {
|
|
46
|
+
const scripts = [];
|
|
47
|
+
for (const element of elements) {
|
|
48
|
+
if (element.tagName !== "script")
|
|
49
|
+
continue;
|
|
50
|
+
const mime = element.attrs.find(attr => attr.name === "type")?.value.split(";")[0].trim().toLowerCase();
|
|
51
|
+
if (mime === "application/ld+json")
|
|
52
|
+
scripts.push(element.childNodes.map(node => "value" in node ? node.value : "").join(""));
|
|
53
|
+
}
|
|
54
|
+
return scripts;
|
|
55
|
+
}
|
|
56
|
+
export function extractJsonLdBlocks(scripts) {
|
|
19
57
|
const blocks = [];
|
|
20
|
-
const
|
|
21
|
-
let
|
|
22
|
-
|
|
58
|
+
const schemaOrgTypes = new Set();
|
|
59
|
+
let blockCount = 0;
|
|
60
|
+
let truncated = false;
|
|
61
|
+
let schemaOrgTypesTruncated = false;
|
|
62
|
+
let oversized = false;
|
|
63
|
+
for (const text of scripts) {
|
|
64
|
+
let value;
|
|
23
65
|
try {
|
|
24
|
-
|
|
25
|
-
// Handle both single objects and arrays of objects
|
|
26
|
-
const items = Array.isArray(parsed) ? parsed : [parsed];
|
|
27
|
-
for (const item of items) {
|
|
28
|
-
if (typeof item === "object" &&
|
|
29
|
-
item !== null &&
|
|
30
|
-
"@type" in item) {
|
|
31
|
-
const obj = item;
|
|
32
|
-
const type = obj["@type"];
|
|
33
|
-
if (!(typeof type === "string" && type.trim()) &&
|
|
34
|
-
!(Array.isArray(type) && type.length > 0 && type.every((t) => typeof t === "string" && t.trim())))
|
|
35
|
-
continue;
|
|
36
|
-
blocks.push({
|
|
37
|
-
type: type,
|
|
38
|
-
context: obj["@context"] ?? null,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
66
|
+
value = readJson(text.trimStart());
|
|
42
67
|
}
|
|
43
68
|
catch {
|
|
44
|
-
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (value === OVERSIZED) {
|
|
72
|
+
oversized = true;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const nodes = [{ value, context: NO_CONTEXT }];
|
|
76
|
+
while (nodes.length) {
|
|
77
|
+
const { value, context } = nodes.pop();
|
|
78
|
+
if (Array.isArray(value)) {
|
|
79
|
+
// Only what can hold a type is queued: a list of a million numbers would queue a million entries.
|
|
80
|
+
for (let i = value.length - 1; i >= 0; i--)
|
|
81
|
+
if (typeof value[i] === "object")
|
|
82
|
+
nodes.push({ value: value[i], context });
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!isRecord(value))
|
|
86
|
+
continue;
|
|
87
|
+
const active = Object.hasOwn(value, "@context") ? projectContext(value["@context"]) : context;
|
|
88
|
+
if (value["@graph"] !== undefined)
|
|
89
|
+
nodes.push({ value: value["@graph"], context: active });
|
|
90
|
+
const type = value["@type"];
|
|
91
|
+
const types = Array.isArray(type) ? type : [type];
|
|
92
|
+
if (!types.length || !types.every((t) => typeof t === "string" && !!t.trim()))
|
|
93
|
+
continue;
|
|
94
|
+
blockCount++;
|
|
95
|
+
if (active.schemaOrg) {
|
|
96
|
+
for (const name of types) {
|
|
97
|
+
if (!addTypeName(schemaOrgTypes, name))
|
|
98
|
+
schemaOrgTypesTruncated = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (blocks.length < MAX_BLOCKS) {
|
|
102
|
+
const sample = types.slice(0, MAX_TYPES_PER_BLOCK).map(diagnosticName);
|
|
103
|
+
truncated ||= types.length > sample.length || sample.some((name, i) => name !== types[i]);
|
|
104
|
+
blocks.push({ type: Array.isArray(type) ? sample : sample[0], context: active.vocabulary });
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
truncated = true;
|
|
108
|
+
}
|
|
45
109
|
}
|
|
46
110
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
111
|
+
return { blockCount, blocks, truncated: truncated || oversized, schemaOrgTypes: [...schemaOrgTypes], schemaOrgTypesTruncated, ...(oversized && { oversized }) };
|
|
112
|
+
}
|
|
113
|
+
export function checkJsonLd(html) {
|
|
114
|
+
const id = "json_ld";
|
|
115
|
+
const label = "JSON-LD Structured Data";
|
|
116
|
+
const data = typeof html === "string" ? extractJsonLdBlocks(jsonLdScripts(htmlElements(html))) : html;
|
|
117
|
+
if (!data.blockCount) {
|
|
118
|
+
return data.oversized ? { id, label, status: "error", detail: "JSON-LD block too large to inspect", data }
|
|
119
|
+
: { id, label, status: "fail", detail: "No JSON-LD structured data found" };
|
|
54
120
|
}
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
id,
|
|
61
|
-
label,
|
|
62
|
-
status: "pass",
|
|
63
|
-
detail,
|
|
64
|
-
data: { blocks },
|
|
65
|
-
};
|
|
121
|
+
const types = data.blocks.flatMap(block => block.type).join(", ");
|
|
122
|
+
const summary = types.length <= 1024 ? types : types.slice(0, 1023) + "…";
|
|
123
|
+
const detail = `${data.blockCount} JSON-LD block${data.blockCount === 1 ? "" : "s"} found: ${summary}${data.truncated ? " (sample)" : ""}`;
|
|
124
|
+
return { id, label, status: "pass", detail, data };
|
|
66
125
|
}
|
|
67
|
-
//# sourceMappingURL=json-ld.js.map
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { Check } from "../../core/types.js";
|
|
1
|
+
import type { Check, HttpResponse } from "../../core/types.js";
|
|
2
2
|
export interface LlmsTxtResult {
|
|
3
3
|
check: Check;
|
|
4
4
|
body: string | null;
|
|
5
|
+
response?: HttpResponse;
|
|
5
6
|
}
|
|
6
7
|
export interface LlmsContentQuality {
|
|
7
8
|
sectionCount: number;
|
|
8
9
|
linkCount: number;
|
|
9
10
|
hasApiReferences: boolean;
|
|
10
11
|
lineCount: number;
|
|
12
|
+
hasSummary: boolean;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Analyze llms.txt / llms-full.txt content for quality signals.
|
|
@@ -21,6 +23,7 @@ export declare function analyzeLlmsContent(body: string): LlmsContentQuality;
|
|
|
21
23
|
* but no H1 or lacks structured sections/links, fail if missing.
|
|
22
24
|
*/
|
|
23
25
|
export declare function checkLlmsTxt(baseUrl: string, timeout?: number): Promise<LlmsTxtResult>;
|
|
26
|
+
export declare function gradeLlmsIndex(result: HttpResponse): LlmsTxtResult;
|
|
24
27
|
/**
|
|
25
28
|
* Check for llms-full.txt at the domain root.
|
|
26
29
|
*
|
|
@@ -28,4 +31,3 @@ export declare function checkLlmsTxt(baseUrl: string, timeout?: number): Promise
|
|
|
28
31
|
* Returns partial if under 500 bytes (~100 words), indicating minimal content.
|
|
29
32
|
*/
|
|
30
33
|
export declare function checkLlmsFullTxt(baseUrl: string, timeout?: number): Promise<Check>;
|
|
31
|
-
//# sourceMappingURL=llms-txt.d.ts.map
|
|
@@ -1,13 +1,36 @@
|
|
|
1
|
+
import { looksLikeHtml } from "../../utils/html.js";
|
|
2
|
+
import { unmeasured } from "./probe-evidence.js";
|
|
1
3
|
import { httpGet } from "../../utils/http-client.js";
|
|
4
|
+
function failedFile(id, label, result) {
|
|
5
|
+
const statusCode = result.response?.status ?? result.error.statusCode;
|
|
6
|
+
const measured = result.error.kind === "http_error" && (statusCode === 404 || statusCode === 410);
|
|
7
|
+
const data = { statusCode, errorKind: result.error.kind, measured };
|
|
8
|
+
if (measured) {
|
|
9
|
+
return { id, label, status: "fail", detail: "No " + label + " found", data };
|
|
10
|
+
}
|
|
11
|
+
return { id, label, status: "error", data, detail: result.error.kind === "request_budget_exhausted"
|
|
12
|
+
? label + " probe skipped: scan request budget exhausted"
|
|
13
|
+
: label + " could not be measured (" + (statusCode ? "HTTP " + statusCode : result.error.kind) + ")" };
|
|
14
|
+
}
|
|
15
|
+
function rejectedBody(id, label, result) {
|
|
16
|
+
if (unmeasured(result))
|
|
17
|
+
return { id, label, status: "error", detail: label + " could not be fully read", data: { measured: false } };
|
|
18
|
+
if (!result.body.trim())
|
|
19
|
+
return { id, label, status: "fail", detail: "No " + label + " found", data: { statusCode: result.status, measured: true } };
|
|
20
|
+
if (result.headers["content-type"]?.toLowerCase().includes("html") || looksLikeHtml(result.body)) {
|
|
21
|
+
return { id, label, status: "fail", detail: "No " + label + " found (HTML response)", data: { statusCode: result.status, measured: true } };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
2
24
|
/**
|
|
3
25
|
* Analyze llms.txt / llms-full.txt content for quality signals.
|
|
4
26
|
*/
|
|
5
27
|
export function analyzeLlmsContent(body) {
|
|
6
|
-
const sectionCount = (body.match(
|
|
7
|
-
|
|
8
|
-
const
|
|
28
|
+
const sectionCount = (body.match(/^##[ \t]+/gm) ?? []).length;
|
|
29
|
+
// Each part excludes "[", so scans from different link starts never overlap.
|
|
30
|
+
const linkCount = (body.match(/\[[^\[\]\n]{1,512}\]\([ \t]*<?[^)\s>\[]{1,2048}>?(?:[ \t][^)\n\[]{0,256})?\)/g) ?? []).length;
|
|
31
|
+
const hasApiReferences = /\b(api|endpoint|sdk|developer|integration|webhook|oauth|graphql|rest[ \t]+api)\b/i.test(body);
|
|
9
32
|
const lineCount = body.split("\n").filter((l) => l.trim().length > 0).length;
|
|
10
|
-
return { sectionCount, linkCount, hasApiReferences, lineCount };
|
|
33
|
+
return { sectionCount, linkCount, hasApiReferences, lineCount, hasSummary: /^>[ \t]*\S/m.test(body) };
|
|
11
34
|
}
|
|
12
35
|
/**
|
|
13
36
|
* Check for llms.txt at the domain root.
|
|
@@ -17,28 +40,26 @@ export function analyzeLlmsContent(body) {
|
|
|
17
40
|
* but no H1 or lacks structured sections/links, fail if missing.
|
|
18
41
|
*/
|
|
19
42
|
export async function checkLlmsTxt(baseUrl, timeout) {
|
|
43
|
+
const response = await httpGet(`${baseUrl}/llms.txt`, { timeout });
|
|
44
|
+
return { ...gradeLlmsIndex(response), response };
|
|
45
|
+
}
|
|
46
|
+
export function gradeLlmsIndex(result) {
|
|
20
47
|
const id = "llms_txt";
|
|
21
48
|
const label = "llms.txt";
|
|
22
|
-
const result = await httpGet(`${baseUrl}/llms.txt`, { timeout });
|
|
23
49
|
if (!result.ok) {
|
|
24
|
-
|
|
25
|
-
return { check: { id, label, status: "error", detail: "llms.txt probe skipped: scan request budget exhausted" }, body: null };
|
|
26
|
-
}
|
|
27
|
-
return { check: { id, label, status: "fail", detail: "No llms.txt found" }, body: null };
|
|
28
|
-
}
|
|
29
|
-
if (result.body.trim().length === 0) {
|
|
30
|
-
return { check: { id, label, status: "fail", detail: "No llms.txt found" }, body: null };
|
|
31
|
-
}
|
|
32
|
-
// Reject soft 404s: servers returning HTML instead of the actual file
|
|
33
|
-
const contentType = (result.headers["content-type"] ?? "").toLowerCase();
|
|
34
|
-
if (contentType.includes("text/html")) {
|
|
35
|
-
return { check: { id, label, status: "fail", detail: "No llms.txt found (HTML response)" }, body: null };
|
|
50
|
+
return { check: failedFile(id, label, result), body: null };
|
|
36
51
|
}
|
|
52
|
+
const rejected = rejectedBody(id, label, result);
|
|
53
|
+
if (rejected)
|
|
54
|
+
return { check: rejected, body: null };
|
|
37
55
|
const sizeBytes = new TextEncoder().encode(result.body).byteLength;
|
|
38
|
-
const
|
|
39
|
-
|
|
56
|
+
const text = result.body.trimStart();
|
|
57
|
+
const newline = text.indexOf("\n");
|
|
58
|
+
const heading = (newline === -1 ? text : text.slice(0, newline)).trimEnd();
|
|
59
|
+
const firstLine = heading.length > 512 ? heading.slice(0, 511) + "…" : heading;
|
|
60
|
+
if (/^#\s+\S/.test(heading)) {
|
|
40
61
|
const quality = analyzeLlmsContent(result.body);
|
|
41
|
-
if (quality.sectionCount === 0
|
|
62
|
+
if (quality.sectionCount === 0 || quality.linkCount === 0) {
|
|
42
63
|
return {
|
|
43
64
|
check: {
|
|
44
65
|
id,
|
|
@@ -82,17 +103,11 @@ export async function checkLlmsFullTxt(baseUrl, timeout) {
|
|
|
82
103
|
const id = "llms_full_txt";
|
|
83
104
|
const label = "llms-full.txt";
|
|
84
105
|
const result = await httpGet(`${baseUrl}/llms-full.txt`, { timeout });
|
|
85
|
-
if (!result.ok
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
// Reject soft 404s: servers returning HTML instead of the actual file
|
|
92
|
-
const contentType = (result.headers["content-type"] ?? "").toLowerCase();
|
|
93
|
-
if (contentType.includes("text/html")) {
|
|
94
|
-
return { id, label, status: "fail", detail: "No llms-full.txt found (HTML response)" };
|
|
95
|
-
}
|
|
106
|
+
if (!result.ok)
|
|
107
|
+
return failedFile(id, label, result);
|
|
108
|
+
const rejected = rejectedBody(id, label, result);
|
|
109
|
+
if (rejected)
|
|
110
|
+
return rejected;
|
|
96
111
|
const sizeBytes = new TextEncoder().encode(result.body).byteLength;
|
|
97
112
|
const quality = analyzeLlmsContent(result.body);
|
|
98
113
|
if (sizeBytes < 500) {
|
|
@@ -112,4 +127,3 @@ export async function checkLlmsFullTxt(baseUrl, timeout) {
|
|
|
112
127
|
data: { sizeBytes, ...quality },
|
|
113
128
|
};
|
|
114
129
|
}
|
|
115
|
-
//# sourceMappingURL=llms-txt.js.map
|
|
@@ -4,6 +4,10 @@ export interface MarkdownNegotiationResult {
|
|
|
4
4
|
/** Whether the server supports markdown content negotiation */
|
|
5
5
|
supported: boolean;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Check if a Content-Type header indicates markdown.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isMarkdownContentType(headers: Record<string, string>): boolean;
|
|
7
11
|
/**
|
|
8
12
|
* Detect whether a site supports markdown content negotiation for AI agents.
|
|
9
13
|
*
|
|
@@ -22,4 +26,3 @@ export interface MarkdownNegotiationResult {
|
|
|
22
26
|
* - fail: No markdown support detected
|
|
23
27
|
*/
|
|
24
28
|
export declare function checkMarkdownNegotiation(baseUrl: string, timeout?: number): Promise<MarkdownNegotiationResult>;
|
|
25
|
-
//# sourceMappingURL=markdown-negotiation.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { isMarkdownMediaType, mediaType } from "../../utils/http-types.js";
|
|
2
|
+
import { looksLikeHtml } from "../../utils/html.js";
|
|
3
|
+
import { unmeasured } from "./probe-evidence.js";
|
|
1
4
|
import { httpGet } from "../../utils/http-client.js";
|
|
2
5
|
// ---------------------------------------------------------------------------
|
|
3
6
|
// Constants
|
|
@@ -27,9 +30,9 @@ function parseContentSignal(header) {
|
|
|
27
30
|
/**
|
|
28
31
|
* Check if a Content-Type header indicates markdown.
|
|
29
32
|
*/
|
|
30
|
-
function isMarkdownContentType(headers) {
|
|
31
|
-
const ct = (headers
|
|
32
|
-
return ct
|
|
33
|
+
export function isMarkdownContentType(headers) {
|
|
34
|
+
const ct = mediaType(headers);
|
|
35
|
+
return isMarkdownMediaType(ct);
|
|
33
36
|
}
|
|
34
37
|
// ---------------------------------------------------------------------------
|
|
35
38
|
// Public API
|
|
@@ -77,28 +80,30 @@ export async function checkMarkdownNegotiation(baseUrl, timeout) {
|
|
|
77
80
|
check: {
|
|
78
81
|
id,
|
|
79
82
|
label,
|
|
80
|
-
status: "
|
|
81
|
-
detail: "Could not reach product surface to test markdown negotiation",
|
|
83
|
+
status: "error",
|
|
84
|
+
detail: "Could not reach product surface to test markdown negotiation", data: { measured: false },
|
|
82
85
|
},
|
|
83
86
|
supported: false,
|
|
84
87
|
};
|
|
85
88
|
}
|
|
89
|
+
if (unmeasured(response))
|
|
90
|
+
return { check: { id, label, status: "error", detail: "Incomplete negotiation response" }, supported: false };
|
|
86
91
|
const signals = [];
|
|
87
92
|
// Signal 1: Does the response come back as markdown?
|
|
88
|
-
const markdownResponse = isMarkdownContentType(response.headers);
|
|
93
|
+
const markdownResponse = isMarkdownContentType(response.headers) && !!response.body.trim() && !looksLikeHtml(response.body);
|
|
89
94
|
if (markdownResponse) {
|
|
90
|
-
signals.push("
|
|
95
|
+
signals.push(mediaType(response.headers) + " response");
|
|
91
96
|
}
|
|
92
97
|
// Signal 2: x-markdown-tokens header
|
|
93
98
|
const tokenHeader = response.headers["x-markdown-tokens"];
|
|
94
|
-
if (tokenHeader !== undefined) {
|
|
99
|
+
if (tokenHeader !== undefined && /^\d+$/.test(tokenHeader.trim())) {
|
|
95
100
|
signals.push("x-markdown-tokens header");
|
|
96
101
|
}
|
|
97
102
|
// Signal 3: Content-Signal header with AI directives
|
|
98
103
|
const contentSignal = response.headers["content-signal"];
|
|
99
104
|
if (contentSignal) {
|
|
100
105
|
const directives = parseContentSignal(contentSignal);
|
|
101
|
-
const activeDirectives = AI_SIGNAL_KEYS.filter((key) => directives[key]
|
|
106
|
+
const activeDirectives = AI_SIGNAL_KEYS.filter((key) => directives[key] === "yes");
|
|
102
107
|
if (activeDirectives.length > 0) {
|
|
103
108
|
signals.push(`Content-Signal (${activeDirectives.join(", ")})`);
|
|
104
109
|
}
|
|
@@ -109,7 +114,7 @@ export async function checkMarkdownNegotiation(baseUrl, timeout) {
|
|
|
109
114
|
id,
|
|
110
115
|
label,
|
|
111
116
|
status: "fail",
|
|
112
|
-
detail: "No markdown content negotiation support detected",
|
|
117
|
+
detail: "No markdown content negotiation support detected", data: { measured: true },
|
|
113
118
|
},
|
|
114
119
|
supported: false,
|
|
115
120
|
};
|
|
@@ -127,6 +132,7 @@ export async function checkMarkdownNegotiation(baseUrl, timeout) {
|
|
|
127
132
|
detail,
|
|
128
133
|
data: {
|
|
129
134
|
signals,
|
|
135
|
+
varyAccept: response.headers.vary?.split(",").some(value => ["accept", "*"].includes(value.trim().toLowerCase())) ?? false,
|
|
130
136
|
markdownResponse,
|
|
131
137
|
hasTokenHeader: tokenHeader !== undefined,
|
|
132
138
|
contentSignal: contentSignal ?? null,
|
|
@@ -135,4 +141,3 @@ export async function checkMarkdownNegotiation(baseUrl, timeout) {
|
|
|
135
141
|
supported: markdownResponse,
|
|
136
142
|
};
|
|
137
143
|
}
|
|
138
|
-
//# sourceMappingURL=markdown-negotiation.js.map
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import type { Check, HttpResponse } from "../../core/types.js";
|
|
2
2
|
export interface McpResult {
|
|
3
3
|
check: Check;
|
|
4
|
-
/** Whether
|
|
4
|
+
/** Whether the probe returned a recognized MCP declaration */
|
|
5
5
|
detected: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* Detection tiers:
|
|
11
|
-
* 1. **pass**: `/.well-known/mcp.json` found with valid MCP structure
|
|
12
|
-
* 2. **partial**: No endpoint, but page content or llms.txt contains MCP signals
|
|
13
|
-
* 3. **fail**: Nothing found
|
|
14
|
-
*
|
|
15
|
-
* Endpoint probe takes priority — if it returns pass, content scan is skipped.
|
|
16
|
-
*/
|
|
7
|
+
export declare const MCP_PATH = "/.well-known/mcp.json";
|
|
8
|
+
/** The scored observation is a declaration at the checked path. No protocol session is initiated. */
|
|
17
9
|
export declare function checkMcpEndpoint(baseUrl: string, timeout?: number, pageBody?: string, llmsTxtBody?: string, endpointResponse?: HttpResponse): Promise<McpResult>;
|
|
18
|
-
//# sourceMappingURL=mcp.d.ts.map
|