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,106 +1,107 @@
|
|
|
1
|
+
import { isMarkdownMediaType, mediaType } from "../../utils/http-types.js";
|
|
2
|
+
import { classifyDoc, completeRepresentation, DOC_PATHS, docFetchFor, docPathMatches, isDeveloperDocsLink, HOME_LINKS_SIZE, MAX_RECORDED_URL, readDocument, relatedHost, safeUrl, urlSample } from "./published-routes.js";
|
|
3
|
+
import { boundedDocGet, DOCS_BODY_LIMIT, discoverDocsFormats, inspectableDoc } from "./docs-discovery.js";
|
|
1
4
|
import { httpGet } from "../../utils/http-client.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"/api/docs",
|
|
10
|
-
"/documentation",
|
|
11
|
-
];
|
|
12
|
-
/**
|
|
13
|
-
* Scan homepage HTML for links pointing to documentation paths.
|
|
14
|
-
* Returns matched paths (deduplicated).
|
|
15
|
-
*/
|
|
16
|
-
function scanDocLinks(html, baseUrl) {
|
|
17
|
-
const found = new Set();
|
|
18
|
-
const anchors = /<a(?=\s)(?:[^<>"']|"[^"]*"|'[^']*')*>/gi;
|
|
19
|
-
const attributes = /([^\s=/<>"']+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s<>"'=`]+)))?/g;
|
|
20
|
-
for (const [tag] of html.matchAll(anchors)) {
|
|
21
|
-
for (const [, name, doubleQuoted, singleQuoted, unquoted] of tag.matchAll(attributes)) {
|
|
22
|
-
if (name.toLowerCase() !== "href")
|
|
23
|
-
continue;
|
|
24
|
-
const href = doubleQuoted ?? singleQuoted ?? unquoted;
|
|
25
|
-
const url = href ? URL.parse(href, baseUrl) : null;
|
|
26
|
-
if (url?.protocol === "http:" || url?.protocol === "https:") {
|
|
27
|
-
// Match whole path segments, including nested and off-site docs.
|
|
28
|
-
const pathname = url.pathname.toLowerCase() + "/";
|
|
29
|
-
for (const path of DOC_PATHS) {
|
|
30
|
-
if (pathname.includes(path + "/"))
|
|
31
|
-
found.add(path);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return DOC_PATHS.filter((path) => found.has(path));
|
|
5
|
+
import { effectiveOrigin } from "../../utils/url.js";
|
|
6
|
+
function displayUrl(raw) {
|
|
7
|
+
const url = new URL(raw);
|
|
8
|
+
return url.origin + url.pathname;
|
|
9
|
+
}
|
|
10
|
+
function displayed(url) {
|
|
11
|
+
return url.length > MAX_RECORDED_URL ? " (URL exceeds display limit)" : ": " + url;
|
|
38
12
|
}
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
13
|
+
/** Keep the published inventory, observed fetches, and verified documentation independently attributable. */
|
|
14
|
+
export async function checkDeveloperDocs(baseUrl, html, timeout, homepage = baseUrl, rootIndex) {
|
|
15
|
+
const baseOrigin = new URL(baseUrl).origin;
|
|
16
|
+
const pageUrl = typeof homepage === "string" ? homepage : homepage?.url;
|
|
17
|
+
// Only an observed same-site redirect moves the docs origin; a supplied page URL is just a link base.
|
|
18
|
+
const origin = homepage && typeof homepage !== "string" ? effectiveOrigin(baseUrl, homepage.url) : baseOrigin;
|
|
19
|
+
// After such a redirect the site answers on both origins.
|
|
20
|
+
const own = [origin, baseOrigin];
|
|
21
|
+
const linksMeasured = typeof homepage === "string" || (homepage !== null && completeRepresentation(homepage));
|
|
22
|
+
const homeDocument = readDocument(html, pageUrl ?? baseUrl, HOME_LINKS_SIZE);
|
|
23
|
+
const homeLinks = homeDocument.links;
|
|
24
|
+
const site = new URL(pageUrl ?? baseUrl);
|
|
25
|
+
const candidates = homeLinks.filter(isDeveloperDocsLink);
|
|
26
|
+
const linkedDocs = candidates.filter(url => relatedHost(url, site) && !url.username && !url.password);
|
|
27
|
+
const linkedUrls = [...new Set(linkedDocs.map(url => displayUrl(url.href)))];
|
|
28
|
+
const externalOrigins = [...new Set(candidates.filter(url => safeUrl(url) && !own.includes(url.origin)).map(url => url.origin))];
|
|
29
|
+
const linked = (target) => linkedDocs.find(url => safeUrl(url) && url.origin === target);
|
|
30
|
+
const first = linked(origin) ?? linked(baseOrigin);
|
|
31
|
+
const docs = await Promise.all(DOC_PATHS.map(async (path) => {
|
|
32
|
+
const requestedUrl = new URL(path, baseUrl).href;
|
|
33
|
+
return { requestedUrl, response: inspectableDoc(await httpGet(requestedUrl, { timeout, maxBodyBytes: DOCS_BODY_LIMIT })) };
|
|
34
|
+
}));
|
|
35
|
+
// A docs origin can present its genuine documentation at its own observed homepage.
|
|
36
|
+
let ownHome;
|
|
37
|
+
if (homepage && typeof homepage !== "string" && safeUrl(new URL(homepage.url)) &&
|
|
38
|
+
new URL(homepage.url).origin === origin && isDeveloperDocsLink(new URL(homepage.url))) {
|
|
39
|
+
ownHome = { requestedUrl: homepage.url, response: homepage, document: homeDocument };
|
|
40
|
+
ownHome.state = classifyDoc(ownHome, undefined, undefined, true);
|
|
41
|
+
if (ownHome.state === "verified")
|
|
42
|
+
docs.unshift(ownHome);
|
|
43
|
+
}
|
|
44
|
+
let selected = first ? docFetchFor(first, docs) : undefined;
|
|
45
|
+
if (first && !selected && linksMeasured) {
|
|
46
|
+
selected = { requestedUrl: first.href, response: await boundedDocGet(first, timeout) };
|
|
47
|
+
docs.push(selected);
|
|
48
|
+
}
|
|
49
|
+
const cache = new Map();
|
|
50
|
+
if (rootIndex)
|
|
51
|
+
cache.set(new URL("/llms.txt", baseOrigin).href, rootIndex);
|
|
52
|
+
// Bridge 2 followed the same-site redirect, so the landed index is already read.
|
|
53
|
+
if (rootIndex?.ok && safeUrl(new URL(rootIndex.url)))
|
|
54
|
+
cache.set(rootIndex.url, rootIndex);
|
|
59
55
|
const pages = [];
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const fetchedUrls = new Set();
|
|
57
|
+
const verifiedUrls = new Set();
|
|
58
|
+
const verifiedPaths = new Set();
|
|
59
|
+
const observations = docs.map(doc => {
|
|
60
|
+
const response = doc.response;
|
|
61
|
+
const state = doc.state ??= classifyDoc(doc, pageUrl, html);
|
|
62
|
+
const requestedUrl = displayUrl(doc.requestedUrl);
|
|
63
|
+
cache.set(doc.requestedUrl, response);
|
|
64
|
+
const finalUrl = displayUrl(response.ok ? response.url : response.error.url);
|
|
65
|
+
const status = response.ok ? response.status : response.response?.status ?? response.error.statusCode;
|
|
62
66
|
if (response.ok) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
id,
|
|
78
|
-
label,
|
|
79
|
-
status: "error",
|
|
80
|
-
detail: "Developer documentation probes skipped: scan request budget exhausted",
|
|
81
|
-
},
|
|
82
|
-
pages: [],
|
|
83
|
-
};
|
|
67
|
+
fetchedUrls.add(finalUrl);
|
|
68
|
+
if (safeUrl(new URL(response.url)))
|
|
69
|
+
cache.set(response.url, response);
|
|
70
|
+
if (state === "verified") {
|
|
71
|
+
verifiedPaths.add(new URL(doc.requestedUrl).pathname);
|
|
72
|
+
if (!verifiedUrls.has(finalUrl)) {
|
|
73
|
+
const final = new URL(finalUrl);
|
|
74
|
+
// Both of the site's origins can serve one path: the first copy takes the path label, the other its full URL.
|
|
75
|
+
const byPath = own.includes(final.origin) && !pages.some(page => page.source === final.pathname);
|
|
76
|
+
pages.push({ content: response.body, url: response.url, document: doc.document,
|
|
77
|
+
markdown: isMarkdownMediaType(mediaType(response.headers)), source: byPath ? final.pathname : finalUrl });
|
|
78
|
+
}
|
|
79
|
+
verifiedUrls.add(finalUrl);
|
|
80
|
+
}
|
|
84
81
|
}
|
|
85
|
-
return {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
pages,
|
|
82
|
+
return { requestedUrl, finalUrl, status, state, ...(!response.ok && { errorKind: response.error.kind }) };
|
|
83
|
+
});
|
|
84
|
+
const fetchesComplete = !observations.some(item => item.state === "incomplete");
|
|
85
|
+
const paths = [...new Set([...verifiedPaths, ...DOC_PATHS.filter(path => linkedDocs.some(url => docPathMatches(url, path)))])];
|
|
86
|
+
const supplementary = linksMeasured && selected?.state === "verified" && selected.response.ok &&
|
|
87
|
+
[...selected.response.redirects, selected.response.url].every(raw => own.includes(new URL(raw).origin))
|
|
88
|
+
? await discoverDocsFormats({ ...selected, response: selected.response }, own, cache, timeout) : undefined;
|
|
89
|
+
// Each link kept from a cut inventory is one the page has and is followed as such; the inventory is not every link.
|
|
90
|
+
const data = { paths, ...urlSample("linkedUrls", linkedUrls), fetchedUrls: [...fetchedUrls], verifiedUrls: [...verifiedUrls],
|
|
91
|
+
linksMeasured: linksMeasured && !homeDocument.linksCut,
|
|
92
|
+
fetchesComplete, observations, ...urlSample("externalOrigins", externalOrigins), ...(supplementary && { supplementary }) };
|
|
93
|
+
const status = verifiedUrls.size || linkedUrls.length ? "pass" : !fetchesComplete || !data.linksMeasured ? "error" : "fail";
|
|
94
|
+
const destination = selected ?? docs.find(doc => doc.state && doc.state !== "absent");
|
|
95
|
+
const destinationDetail = {
|
|
96
|
+
"homepage-fallback": "returned the homepage", "login-interstitial": "returned a sign-in page",
|
|
97
|
+
unverified: "returned a page with unverified documentation", absent: "returned a missing document",
|
|
98
|
+
incomplete: "could not be fully measured",
|
|
104
99
|
};
|
|
100
|
+
const destinationNote = destination?.state && destinationDetail[destination.state];
|
|
101
|
+
const detail = verifiedUrls.size ? "Verified developer documentation at " + [...verifiedUrls][0] :
|
|
102
|
+
linkedUrls.length ? "Published documentation link" + displayed(first ? displayUrl(first.href) : linkedUrls[0]) +
|
|
103
|
+
(selected && destinationNote ? " (" + destinationNote + ")" : "") :
|
|
104
|
+
destinationNote && destination ? displayUrl(destination.requestedUrl) + " " + destinationNote :
|
|
105
|
+
status === "error" ? "Developer documentation could not be fully measured" : "No document at the checked documentation paths";
|
|
106
|
+
return { check: { id: "developer_docs", label: "Developer Documentation", status, detail, data }, pages, routeSources: { homeDocument, homeLinks, docs } };
|
|
105
107
|
}
|
|
106
|
-
//# sourceMappingURL=developer-docs.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HttpResponse, HttpSuccess } from "../../core/types.js";
|
|
2
|
+
import { type DocFetch } from "./published-routes.js";
|
|
3
|
+
export declare const DOCS_BODY_LIMIT = 1048576;
|
|
4
|
+
/** A docs response is parsed only when it is served as HTML; Markdown and other bodies keep their content. */
|
|
5
|
+
export declare function inspectableDoc<T extends HttpResponse>(response: T): T;
|
|
6
|
+
export declare function boundedDocGet(url: URL, timeout?: number): Promise<HttpResponse>;
|
|
7
|
+
/**
|
|
8
|
+
* Only the first eligible published docs page contributes supplementary reads. They stay on that page's origin;
|
|
9
|
+
* `siteOrigins` are the origins a cached response may have crossed on its way there.
|
|
10
|
+
*/
|
|
11
|
+
export declare function discoverDocsFormats(doc: DocFetch & {
|
|
12
|
+
response: HttpSuccess;
|
|
13
|
+
}, siteOrigins: string[], cache: Map<string, HttpResponse>, timeout?: number): Promise<{
|
|
14
|
+
markdown?: {
|
|
15
|
+
url: string;
|
|
16
|
+
source: string;
|
|
17
|
+
state: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
pageUrl: string;
|
|
20
|
+
index: {
|
|
21
|
+
errorKind?: import("../../utils/http-types.js").HttpErrorKind | undefined;
|
|
22
|
+
linksTruncated?: boolean | undefined;
|
|
23
|
+
url: string;
|
|
24
|
+
source: string;
|
|
25
|
+
state: string;
|
|
26
|
+
links: string[];
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { parseReference } from "../../utils/url.js";
|
|
2
|
+
import { inspectableHtml, looksLikeHtml } from "../../utils/html.js";
|
|
3
|
+
import { isHtmlMediaType, mediaType } from "../../utils/http-types.js";
|
|
4
|
+
import { httpGet } from "../../utils/http-client.js";
|
|
5
|
+
import { gradeLlmsIndex } from "../standards/llms-txt.js";
|
|
6
|
+
import { isMarkdownContentType } from "../standards/markdown-negotiation.js";
|
|
7
|
+
import { completeRepresentation, MAX_RECORDED_URL, safeUrl } from "./published-routes.js";
|
|
8
|
+
export const DOCS_BODY_LIMIT = 1_048_576;
|
|
9
|
+
function docGet(url, timeout) {
|
|
10
|
+
return httpGet(url.href, { timeout, retry: false, maxRedirects: 0, maxBodyBytes: DOCS_BODY_LIMIT });
|
|
11
|
+
}
|
|
12
|
+
/** A docs response is parsed only when it is served as HTML; Markdown and other bodies keep their content. */
|
|
13
|
+
export function inspectableDoc(response) {
|
|
14
|
+
return isHtmlMediaType(mediaType(response.ok ? response.headers : undefined)) ? inspectableHtml(response) : response;
|
|
15
|
+
}
|
|
16
|
+
export async function boundedDocGet(url, timeout) {
|
|
17
|
+
return inspectableDoc(await docGet(url, timeout));
|
|
18
|
+
}
|
|
19
|
+
function stateOf(response) {
|
|
20
|
+
if (response.ok)
|
|
21
|
+
return completeRepresentation(response) ? "complete" : "incomplete";
|
|
22
|
+
const status = response.response?.status ?? response.error.statusCode;
|
|
23
|
+
return response.error.kind === "http_error" && (status === 404 || status === 410) ? "absent" : "incomplete";
|
|
24
|
+
}
|
|
25
|
+
const MAX_INDEX_LINKS = 32;
|
|
26
|
+
/** The first distinct guide links of an index, and whether any link was left out of them. */
|
|
27
|
+
function markdownLinks(body, base) {
|
|
28
|
+
const links = new Set();
|
|
29
|
+
let truncated = false;
|
|
30
|
+
// llms.txt section entries are Markdown list items containing a link.
|
|
31
|
+
for (const match of body.matchAll(/^[ \t]*[-*+][ \t]+\[[^\]\r\n]*\]\([ \t]*(?:<([^>\r\n]+)>|([^\s)]+))(?:[ \t][^)\r\n]*)?\)/gm)) {
|
|
32
|
+
const url = parseReference(match[1] ?? match[2], base);
|
|
33
|
+
if (!url || !safeUrl(url))
|
|
34
|
+
continue;
|
|
35
|
+
const link = url.origin + url.pathname;
|
|
36
|
+
if (link.length > MAX_RECORDED_URL) {
|
|
37
|
+
truncated = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (links.has(link))
|
|
41
|
+
continue;
|
|
42
|
+
// A true total would hold every distinct link of a body of up to 5 MiB in memory.
|
|
43
|
+
if (links.size === MAX_INDEX_LINKS)
|
|
44
|
+
return { links: [...links], truncated: true };
|
|
45
|
+
links.add(link);
|
|
46
|
+
}
|
|
47
|
+
return { links: [...links], truncated };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Only the first eligible published docs page contributes supplementary reads. They stay on that page's origin;
|
|
51
|
+
* `siteOrigins` are the origins a cached response may have crossed on its way there.
|
|
52
|
+
*/
|
|
53
|
+
export async function discoverDocsFormats(doc, siteOrigins, cache, timeout) {
|
|
54
|
+
const page = new URL(doc.response.url);
|
|
55
|
+
const origin = page.origin;
|
|
56
|
+
const pageMarkdown = isMarkdownContentType(doc.response.headers) && !looksLikeHtml(doc.response.body);
|
|
57
|
+
const anchors = doc.document?.links ?? [];
|
|
58
|
+
const explicit = anchors.find(url => safeUrl(url) && url.origin === origin && /\/llms\.txt$/i.test(url.pathname));
|
|
59
|
+
const directory = page.pathname.endsWith("/") || /\.[^/]+$/.test(page.pathname) ? page.href : page.href + "/";
|
|
60
|
+
const indexUrl = explicit ?? new URL("llms.txt", directory);
|
|
61
|
+
async function read(url) {
|
|
62
|
+
let result = cache.get(url.href);
|
|
63
|
+
if (!result) {
|
|
64
|
+
// llms.txt and Markdown alternates are never parsed as HTML.
|
|
65
|
+
result = await docGet(url, timeout);
|
|
66
|
+
cache.set(url.href, result);
|
|
67
|
+
}
|
|
68
|
+
const state = result.ok && [...result.redirects, result.url].some(address => {
|
|
69
|
+
const hop = new URL(address);
|
|
70
|
+
return !siteOrigins.includes(hop.origin) || !safeUrl(hop);
|
|
71
|
+
}) ? "incomplete" : stateOf(result);
|
|
72
|
+
return { result, state };
|
|
73
|
+
}
|
|
74
|
+
const index = await read(indexUrl);
|
|
75
|
+
const indexResult = index.result;
|
|
76
|
+
const graded = indexResult.ok && index.state === "complete" && !looksLikeHtml(indexResult.body)
|
|
77
|
+
? gradeLlmsIndex(indexResult) : undefined;
|
|
78
|
+
const { links, truncated } = graded?.body && indexResult.ok ? markdownLinks(graded.body, indexResult.url) : { links: [], truncated: false };
|
|
79
|
+
const hasHeading = graded?.body && /^#\s+\S/.test(graded.body.trim());
|
|
80
|
+
// A link left out of the stored list was still found.
|
|
81
|
+
const indexVerified = Boolean(hasHeading && (graded?.check.status === "pass" || links.length || truncated));
|
|
82
|
+
const indexState = index.state === "complete" ? (indexVerified ? "verified" : "unverified") : index.state;
|
|
83
|
+
const alternate = doc.document?.markdownAlternates.find(url => url.origin === origin && safeUrl(url));
|
|
84
|
+
let markdown;
|
|
85
|
+
if (pageMarkdown) {
|
|
86
|
+
markdown = { url: page.href, source: "docs-page", state: "verified" };
|
|
87
|
+
}
|
|
88
|
+
else if (alternate) {
|
|
89
|
+
const { result, state } = await read(alternate);
|
|
90
|
+
const verified = result.ok && isMarkdownContentType(result.headers) && !!result.body.trim() && !looksLikeHtml(result.body);
|
|
91
|
+
markdown = { url: alternate.href, source: "published-alternate", state: state === "complete" ? (verified ? "verified" : "unverified") : state };
|
|
92
|
+
}
|
|
93
|
+
return { pageUrl: page.href, index: { url: indexUrl.href, source: explicit ? "published-link" : "docs-path",
|
|
94
|
+
state: indexState, links, ...(truncated && { linksTruncated: true }), ...(!indexResult.ok && { errorKind: indexResult.error.kind }) }, ...(markdown && { markdown }) };
|
|
95
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
function apiSummary(api, contract, graphql) {
|
|
2
|
+
if (contract?.status === "pass") {
|
|
3
|
+
return contract.data?.specType === "swagger" ? "API described in Swagger 2.0" : "API described in OpenAPI";
|
|
4
|
+
}
|
|
5
|
+
if (contract?.data?.registry === "apis.guru")
|
|
6
|
+
return "OpenAPI listed in APIs.guru";
|
|
7
|
+
if (contract?.data?.protected === true)
|
|
8
|
+
return "API inferred from a protected spec path";
|
|
9
|
+
if (graphql?.status === "pass")
|
|
10
|
+
return "GraphQL schema inspected";
|
|
11
|
+
if (graphql?.data?.protected === true)
|
|
12
|
+
return "API inferred from a protected GraphQL path";
|
|
13
|
+
if (graphql?.data?.introspectionEnabled === false)
|
|
14
|
+
return "GraphQL introspection disabled";
|
|
15
|
+
if (api?.status === "pass")
|
|
16
|
+
return "API inferred from discovery signals";
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
// A stored sample can omit links that were counted.
|
|
20
|
+
function recorded(sample, total) {
|
|
21
|
+
return sample.length > 0 || typeof total === "number" && total > 0;
|
|
22
|
+
}
|
|
23
|
+
export function summarizeSeparation(checks, contract, graphql) {
|
|
24
|
+
const byId = new Map(checks.map(check => [check.id, check]));
|
|
25
|
+
const parts = [];
|
|
26
|
+
const api = apiSummary(byId.get("api_presence"), contract, graphql);
|
|
27
|
+
if (api)
|
|
28
|
+
parts.push(api);
|
|
29
|
+
const docs = byId.get("developer_docs");
|
|
30
|
+
if (docs?.data?.linkedAndFetched === true) {
|
|
31
|
+
parts.push("Developer docs linked and fetched");
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (Array.isArray(docs?.data?.linkedUrls) && recorded(docs.data.linkedUrls, docs.data.linkedUrlsTotal))
|
|
35
|
+
parts.push("Developer docs linked");
|
|
36
|
+
if (Array.isArray(docs?.data?.verifiedUrls)) {
|
|
37
|
+
if (docs.data.verifiedUrls.length)
|
|
38
|
+
parts.push("Developer docs verified");
|
|
39
|
+
else if (Array.isArray(docs.data.observations) && docs.data.observations.some(o => o?.state === "homepage-fallback")) {
|
|
40
|
+
parts.push("Docs path returned the homepage");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const sdk = byId.get("sdk_references");
|
|
45
|
+
if (sdk?.status === "pass") {
|
|
46
|
+
const links = sdk.data?.packageLinks;
|
|
47
|
+
parts.push(Array.isArray(links) && recorded(links, sdk.data?.packageLinksTotal) ? "Package registry linked" : "SDK/package reference found");
|
|
48
|
+
}
|
|
49
|
+
const webhook = byId.get("webhook_support");
|
|
50
|
+
if (webhook?.status === "pass") {
|
|
51
|
+
const signals = webhook.data?.signals;
|
|
52
|
+
if (Array.isArray(signals) && signals.some(s => s === "openapi webhooks" || s === "openapi callbacks")) {
|
|
53
|
+
parts.push("Webhook declared in OpenAPI");
|
|
54
|
+
}
|
|
55
|
+
else if (Array.isArray(signals) && signals.includes("websub hub")) {
|
|
56
|
+
parts.push("WebSub hub advertised");
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
parts.push("Webhook support inferred");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (docs?.status === "error")
|
|
63
|
+
parts.push("Docs discovery incomplete");
|
|
64
|
+
if (contract?.status === "error" && !api)
|
|
65
|
+
parts.push("OpenAPI discovery incomplete");
|
|
66
|
+
return parts.join(" · ") || "No integration evidence found in the checked sources";
|
|
67
|
+
}
|
|
@@ -1,20 +1,3 @@
|
|
|
1
1
|
import type { BridgeResult, ScanContext } from "../../core/types.js";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Runs 4 checks to detect API/developer separation signals:
|
|
6
|
-
* - 1 async HTTP probe (developer docs) fired first (non-blocking)
|
|
7
|
-
* - 3 synchronous pure-function checks (api presence, SDK references, webhook support)
|
|
8
|
-
*
|
|
9
|
-
* Unlike Bridges 1-2, Bridge 3 is a detection inventory with NO scoring.
|
|
10
|
-
* Returns score: null and scoreLabel: null.
|
|
11
|
-
*
|
|
12
|
-
* Reads from ctx.shared (openApiDetected, pageBody, pageHeaders, llmsTxtBody)
|
|
13
|
-
* set by Bridges 1 and 2. Writes ctx.shared.devDocsBodies with fetched
|
|
14
|
-
* developer documentation page bodies.
|
|
15
|
-
*
|
|
16
|
-
* Assembles ContentSource[] from homepage body, llms.txt body, and developer
|
|
17
|
-
* docs page bodies, then passes to all three pure-function checks.
|
|
18
|
-
*/
|
|
19
|
-
export declare function runSeparationBridge(ctx: ScanContext): Promise<BridgeResult>;
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
2
|
+
/** Gather integration evidence from the homepage, llms.txt, and verified documentation. */
|
|
3
|
+
export declare function runSeparationBridge(ctx: ScanContext): Promise<BridgeResult<3>>;
|
|
@@ -1,61 +1,57 @@
|
|
|
1
|
+
import { HTML_LIMIT_DETAIL } from "../../utils/html.js";
|
|
2
|
+
import { incompleteHomepage, unmeasured } from "../standards/probe-evidence.js";
|
|
1
3
|
import { checkApiPresence } from "./api-presence.js";
|
|
4
|
+
import { contractRoutes, linkedDocWasFetched } from "./published-routes.js";
|
|
5
|
+
import { summarizeSeparation } from "./evidence-summary.js";
|
|
2
6
|
import { checkDeveloperDocs } from "./developer-docs.js";
|
|
3
7
|
import { checkSdkReferences } from "./sdk-references.js";
|
|
4
8
|
import { checkWebhookSupport } from "./webhook-support.js";
|
|
5
|
-
/**
|
|
6
|
-
* Run Bridge 3: Separation.
|
|
7
|
-
*
|
|
8
|
-
* Runs 4 checks to detect API/developer separation signals:
|
|
9
|
-
* - 1 async HTTP probe (developer docs) fired first (non-blocking)
|
|
10
|
-
* - 3 synchronous pure-function checks (api presence, SDK references, webhook support)
|
|
11
|
-
*
|
|
12
|
-
* Unlike Bridges 1-2, Bridge 3 is a detection inventory with NO scoring.
|
|
13
|
-
* Returns score: null and scoreLabel: null.
|
|
14
|
-
*
|
|
15
|
-
* Reads from ctx.shared (openApiDetected, pageBody, pageHeaders, llmsTxtBody)
|
|
16
|
-
* set by Bridges 1 and 2. Writes ctx.shared.devDocsBodies with fetched
|
|
17
|
-
* developer documentation page bodies.
|
|
18
|
-
*
|
|
19
|
-
* Assembles ContentSource[] from homepage body, llms.txt body, and developer
|
|
20
|
-
* docs page bodies, then passes to all three pure-function checks.
|
|
21
|
-
*/
|
|
9
|
+
/** Gather integration evidence from the homepage, llms.txt, and verified documentation. */
|
|
22
10
|
export async function runSeparationBridge(ctx) {
|
|
23
11
|
const start = performance.now();
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const openApiDetected = ctx.shared.openApiDetected ?? false;
|
|
28
|
-
const openApiHasWebhooks = ctx.shared.openApiHasWebhooks ?? false;
|
|
29
|
-
const openApiHasCallbacks = ctx.shared.openApiHasCallbacks ?? false;
|
|
30
|
-
const graphqlDetected = ctx.shared.graphqlDetected ?? false;
|
|
31
|
-
const llmsTxtBody = ctx.shared.llmsTxtBody ?? null;
|
|
32
|
-
// Fire async developer docs probe first (non-blocking)
|
|
33
|
-
const devDocsPromise = checkDeveloperDocs(ctx.baseUrl, pageBody, ctx.options.timeout);
|
|
34
|
-
// Await async check (need pages for content sources)
|
|
35
|
-
const devDocsResult = await devDocsPromise;
|
|
36
|
-
// Store dev docs pages in shared context for downstream bridges
|
|
37
|
-
ctx.shared.devDocsBodies = devDocsResult.pages;
|
|
12
|
+
const { pageBody = "", pageHeaders = {}, openApiDetected = false, openApiHasWebhooks = false, openApiHasCallbacks = false, graphqlDetected = false, llmsTxtBody, pageResponse: homepage, openApiCheck, graphqlCheck, rootLlmsResponse, } = ctx.shared;
|
|
13
|
+
const pageUrl = homepage?.url ?? ctx.shared.pageUrl ?? (ctx.shared.pageBody !== undefined ? ctx.baseUrl : null);
|
|
14
|
+
const devDocsResult = await checkDeveloperDocs(ctx.baseUrl, pageBody, ctx.options.timeout, homepage ?? pageUrl, rootLlmsResponse);
|
|
38
15
|
// Assemble content sources from all available bodies
|
|
39
16
|
const contentSources = [];
|
|
40
17
|
if (pageBody)
|
|
41
|
-
contentSources.push({ content: pageBody, source: "homepage"
|
|
18
|
+
contentSources.push({ content: pageBody, source: "homepage",
|
|
19
|
+
url: pageUrl ?? ctx.baseUrl, document: devDocsResult.routeSources?.homeDocument });
|
|
42
20
|
if (llmsTxtBody)
|
|
43
|
-
contentSources.push({ content: llmsTxtBody, source: "llms.txt"
|
|
21
|
+
contentSources.push({ content: llmsTxtBody, source: "llms.txt", markdown: true,
|
|
22
|
+
url: rootLlmsResponse?.ok ? rootLlmsResponse.url : new URL("/llms.txt", ctx.baseUrl).href });
|
|
44
23
|
contentSources.push(...devDocsResult.pages);
|
|
45
24
|
// Run 3 synchronous pure-function checks with assembled content sources
|
|
46
|
-
const apiPresenceCheck = checkApiPresence(openApiDetected, contentSources, pageHeaders, graphqlDetected);
|
|
47
|
-
const
|
|
25
|
+
const apiPresenceCheck = checkApiPresence(openApiDetected, contentSources, pageHeaders, graphqlDetected, pageUrl ?? ctx.baseUrl);
|
|
26
|
+
const routeEvidence = contractRoutes(openApiCheck, ctx.shared.openApiDocumentUrls ?? [], homepage, devDocsResult.routeSources);
|
|
27
|
+
apiPresenceCheck.data = {
|
|
28
|
+
...apiPresenceCheck.data, routeEvidence,
|
|
29
|
+
...(routeEvidence.capabilities.length ? { descriptionSource: openApiCheck?.data?.documentUrl } : {}),
|
|
30
|
+
};
|
|
31
|
+
if (homepage && devDocsResult.routeSources) {
|
|
32
|
+
devDocsResult.check.data = { ...devDocsResult.check.data,
|
|
33
|
+
linkedAndFetched: linkedDocWasFetched(devDocsResult.routeSources, homepage) };
|
|
34
|
+
}
|
|
35
|
+
const sdkRefsCheck = checkSdkReferences(contentSources, { homepage, docs: devDocsResult.routeSources });
|
|
48
36
|
const webhookCheck = checkWebhookSupport(contentSources, {
|
|
49
37
|
pageHeaders,
|
|
50
38
|
openApiHasWebhooks,
|
|
51
39
|
openApiHasCallbacks,
|
|
52
40
|
});
|
|
41
|
+
// A rejected Content-Length and a truncated stream both leave a known source unread.
|
|
42
|
+
const unread = incompleteHomepage(ctx.shared) || !!devDocsResult.routeSources?.docs.some(doc => doc.response.ok ? unmeasured(doc.response) : doc.response.error.kind === "body_too_large");
|
|
43
|
+
// So does a link inventory that left links out, for the checks that read links.
|
|
44
|
+
const linksCut = contentSources.some(source => source.document?.linksCut);
|
|
45
|
+
const evidence = (check, incomplete = unread) => incomplete && check.status === "fail"
|
|
46
|
+
? { ...check, status: "error", detail: ctx.shared.pageOverHtmlLimit
|
|
47
|
+
? "Homepage " + HTML_LIMIT_DETAIL : "One or more sources for this check could not be fully inspected." }
|
|
48
|
+
: check;
|
|
53
49
|
// Assemble checks array in order
|
|
54
50
|
const checks = [
|
|
55
|
-
apiPresenceCheck,
|
|
51
|
+
evidence(apiPresenceCheck, unread || linksCut),
|
|
56
52
|
devDocsResult.check,
|
|
57
|
-
sdkRefsCheck,
|
|
58
|
-
webhookCheck,
|
|
53
|
+
evidence(sdkRefsCheck, unread || linksCut),
|
|
54
|
+
evidence(webhookCheck),
|
|
59
55
|
];
|
|
60
56
|
return {
|
|
61
57
|
id: 3,
|
|
@@ -64,7 +60,7 @@ export async function runSeparationBridge(ctx) {
|
|
|
64
60
|
score: null,
|
|
65
61
|
scoreLabel: null,
|
|
66
62
|
checks,
|
|
63
|
+
message: summarizeSeparation(checks, openApiCheck, graphqlCheck),
|
|
67
64
|
durationMs: Math.round(performance.now() - start),
|
|
68
65
|
};
|
|
69
66
|
}
|
|
70
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Check, ContentSource, HttpResponse, HttpSuccess } from "../../core/types.js";
|
|
2
|
+
/** Well-known paths for developer documentation */
|
|
3
|
+
export declare const DOC_PATHS: readonly ["/docs", "/developers", "/developer", "/api/docs", "/documentation"];
|
|
4
|
+
export declare function docPathMatches(url: URL, path: string): boolean;
|
|
5
|
+
export declare function isDeveloperDocsLink(url: URL): boolean;
|
|
6
|
+
export declare function relatedHost(url: URL, site: URL): boolean;
|
|
7
|
+
export declare const MAX_RECORDED_URL = 2048;
|
|
8
|
+
/** Report fields for a deduplicated inventory: a bounded sample under `field`, its total, and a flag when cut. */
|
|
9
|
+
export declare function urlSample(field: string, urls: Iterable<string>): Record<string, unknown>;
|
|
10
|
+
export interface DiscoverySource extends ContentSource {
|
|
11
|
+
url?: string;
|
|
12
|
+
document?: ReturnType<typeof readDocument>;
|
|
13
|
+
markdown?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function sourceDocument(source: DiscoverySource): {
|
|
16
|
+
links: URL[];
|
|
17
|
+
markdownAlternates: URL[];
|
|
18
|
+
linksCut: boolean;
|
|
19
|
+
headings: string;
|
|
20
|
+
text: string;
|
|
21
|
+
webhookSignals: Set<string>;
|
|
22
|
+
passwordForm: boolean;
|
|
23
|
+
hasForm: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare function isMarkdownSource(source: DiscoverySource): boolean;
|
|
26
|
+
export declare function markdownLinks(text: string): RegExpStringIterator<RegExpExecArray>;
|
|
27
|
+
export type DocState = "verified" | "homepage-fallback" | "login-interstitial" | "unverified" | "absent" | "incomplete";
|
|
28
|
+
export interface DocFetch {
|
|
29
|
+
requestedUrl: string;
|
|
30
|
+
response: HttpResponse;
|
|
31
|
+
state?: DocState;
|
|
32
|
+
document?: ReturnType<typeof readDocument>;
|
|
33
|
+
}
|
|
34
|
+
export interface PublishedSources {
|
|
35
|
+
homeLinks: URL[];
|
|
36
|
+
homeDocument?: ReturnType<typeof readDocument>;
|
|
37
|
+
docs: DocFetch[];
|
|
38
|
+
}
|
|
39
|
+
export declare function safeUrl(url: URL): boolean;
|
|
40
|
+
/** The homepage's links are the ones the report counts, and its body may be five times a docs page's. */
|
|
41
|
+
export declare const HOME_LINKS_SIZE: number;
|
|
42
|
+
export declare function readDocument(body: string, documentUrl?: string, linksSize?: number): {
|
|
43
|
+
links: URL[];
|
|
44
|
+
markdownAlternates: URL[];
|
|
45
|
+
linksCut: boolean;
|
|
46
|
+
headings: string;
|
|
47
|
+
text: string;
|
|
48
|
+
webhookSignals: Set<string>;
|
|
49
|
+
passwordForm: boolean;
|
|
50
|
+
hasForm: boolean;
|
|
51
|
+
};
|
|
52
|
+
export declare function htmlLinks(body: string, documentUrl?: string): URL[];
|
|
53
|
+
export declare function completeRepresentation(response: HttpSuccess): boolean;
|
|
54
|
+
export declare function classifyDoc(doc: DocFetch, homeUrl?: string, homeBody?: string, ownHomepage?: boolean): DocState;
|
|
55
|
+
export declare function docFetchFor(link: URL, docs: PublishedSources["docs"]): DocFetch | undefined;
|
|
56
|
+
export declare function linkedDocWasFetched(sources: PublishedSources, homepage: HttpSuccess): boolean;
|
|
57
|
+
/** Entry paths from the homepage, homepage-linked docs, and a catalog used to verify this contract. */
|
|
58
|
+
export declare function contractRoutes(spec: Check | undefined, verifiedUrls: string[], homepage: HttpSuccess | undefined, sources: PublishedSources | undefined): {
|
|
59
|
+
capabilities: {
|
|
60
|
+
id: string;
|
|
61
|
+
label: string;
|
|
62
|
+
routes: {
|
|
63
|
+
source: string;
|
|
64
|
+
target: string;
|
|
65
|
+
}[];
|
|
66
|
+
}[];
|
|
67
|
+
complete: boolean;
|
|
68
|
+
catalogVerified: boolean;
|
|
69
|
+
};
|