seo-supervisor 1.2.0 → 2.0.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.
Files changed (207) hide show
  1. package/.claude-plugin/icon.png +0 -0
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/.claude-plugin/plugin.json +16 -3
  4. package/CHANGELOG.md +430 -0
  5. package/NOTICE +7 -0
  6. package/README.md +230 -25
  7. package/agents/seo-auditor.md +16 -0
  8. package/agents/seo-reviewer.md +16 -0
  9. package/bin/agents.mjs +194 -29
  10. package/bin/extras.mjs +422 -0
  11. package/bin/prompt.mjs +34 -14
  12. package/bin/seo-supervisor.mjs +386 -53
  13. package/commands/seo-audit.md +29 -3
  14. package/commands/seo-brief.md +28 -0
  15. package/commands/seo-connect.md +27 -0
  16. package/commands/seo-fix.md +24 -3
  17. package/commands/seo-grow.md +26 -0
  18. package/commands/seo-launch.md +17 -3
  19. package/commands/seo-review.md +13 -1
  20. package/commands/seo-rewrite.md +25 -0
  21. package/commands/seo-setup.md +17 -1
  22. package/commands/seo-watch.md +28 -0
  23. package/hooks/hooks.json +117 -0
  24. package/package.json +20 -7
  25. package/skills/seo-supervisor/NOTICE +7 -0
  26. package/skills/seo-supervisor/SKILL.md +302 -21
  27. package/skills/seo-supervisor/audience.md +61 -0
  28. package/skills/seo-supervisor/examples/drafts/security.md +41 -0
  29. package/skills/seo-supervisor/examples/hooks/README.md +28 -0
  30. package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
  31. package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
  32. package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
  33. package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
  34. package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
  35. package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
  36. package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
  37. package/skills/seo-supervisor/examples/sample-audit.json +94 -2
  38. package/skills/seo-supervisor/examples/sample-report.html +111 -61
  39. package/skills/seo-supervisor/examples/sample-report.md +147 -44
  40. package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
  41. package/skills/seo-supervisor/examples/snippets.md +648 -1
  42. package/skills/seo-supervisor/grow.md +342 -0
  43. package/skills/seo-supervisor/og-images.md +85 -0
  44. package/skills/seo-supervisor/page-types.md +124 -0
  45. package/skills/seo-supervisor/planning.md +19 -7
  46. package/skills/seo-supervisor/profile-template.md +41 -0
  47. package/skills/seo-supervisor/report-format.md +177 -10
  48. package/skills/seo-supervisor/rewrite.md +59 -0
  49. package/skills/seo-supervisor/rules/ai-search.md +65 -12
  50. package/skills/seo-supervisor/rules/content.md +33 -9
  51. package/skills/seo-supervisor/rules/crawl-index.md +33 -6
  52. package/skills/seo-supervisor/rules/internal-linking.md +49 -6
  53. package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
  54. package/skills/seo-supervisor/rules/media.md +13 -1
  55. package/skills/seo-supervisor/rules/metadata.md +41 -9
  56. package/skills/seo-supervisor/rules/performance.md +50 -5
  57. package/skills/seo-supervisor/rules/rendering.md +39 -2
  58. package/skills/seo-supervisor/rules/search-intent.md +32 -0
  59. package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
  60. package/skills/seo-supervisor/rules/structured-data.md +37 -14
  61. package/skills/seo-supervisor/rules/trust-security.md +25 -2
  62. package/skills/seo-supervisor/rules/urls.md +10 -2
  63. package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
  64. package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
  65. package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
  66. package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
  67. package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
  68. package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
  69. package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
  70. package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
  71. package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
  72. package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
  73. package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
  74. package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
  75. package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
  76. package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
  77. package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
  78. package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
  79. package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
  80. package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
  81. package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
  82. package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
  83. package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
  84. package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
  85. package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
  86. package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
  87. package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
  88. package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
  89. package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
  90. package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
  91. package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
  92. package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
  93. package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
  94. package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
  95. package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
  96. package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
  97. package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
  98. package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
  99. package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
  100. package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
  101. package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
  102. package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
  103. package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
  104. package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
  105. package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
  106. package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
  107. package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
  108. package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
  109. package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
  110. package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
  111. package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
  112. package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
  113. package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
  114. package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
  115. package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
  116. package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
  117. package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
  118. package/skills/seo-supervisor/scripts/google.mjs +1341 -0
  119. package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
  120. package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
  121. package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
  122. package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
  123. package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
  124. package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
  125. package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
  126. package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
  127. package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
  128. package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
  129. package/skills/seo-supervisor/scripts/guard.mjs +74 -0
  130. package/skills/seo-supervisor/scripts/images.mjs +408 -0
  131. package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
  132. package/skills/seo-supervisor/scripts/issues.mjs +217 -0
  133. package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
  134. package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
  135. package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
  136. package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
  137. package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
  138. package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
  139. package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
  140. package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
  141. package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
  142. package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
  143. package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
  144. package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
  145. package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
  146. package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
  147. package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
  148. package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
  149. package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
  150. package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
  151. package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
  152. package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
  153. package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
  154. package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
  155. package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
  156. package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
  157. package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
  158. package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
  159. package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
  160. package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
  161. package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
  162. package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
  163. package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
  164. package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
  165. package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
  166. package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
  167. package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
  168. package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
  169. package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
  170. package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
  171. package/skills/seo-supervisor/scripts/osm.mjs +359 -0
  172. package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
  173. package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
  174. package/skills/seo-supervisor/scripts/report/client.js +37 -0
  175. package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
  176. package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
  177. package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
  178. package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
  179. package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
  180. package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
  181. package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
  182. package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
  183. package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
  184. package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
  185. package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
  186. package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
  187. package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
  188. package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
  189. package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
  190. package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
  191. package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
  192. package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
  193. package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
  194. package/skills/seo-supervisor/scripts/report/styles.css +223 -0
  195. package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
  196. package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
  197. package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
  198. package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
  199. package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
  200. package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
  201. package/skills/seo-supervisor/site-types/content.md +34 -1
  202. package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
  203. package/skills/seo-supervisor/site-types/local-business.md +96 -6
  204. package/skills/seo-supervisor/site-types/services.md +46 -0
  205. package/skills/seo-supervisor/site-types/tools.md +3 -3
  206. package/skills/seo-supervisor/strategy.md +232 -0
  207. package/skills/seo-supervisor/troubleshooting.md +56 -0
@@ -0,0 +1,488 @@
1
+ // @ts-check
2
+ // Agent readiness: what AI agents can use on a page, Bing's AI rules, AI crawler rules, and the AI bot list.
3
+ import { readFileSync } from "node:fs";
4
+ import { attrs } from "../lib/html.mjs";
5
+ import { bodyUpTo } from "../lib/http.mjs";
6
+ import { parseRobots } from "../lib/robots.mjs";
7
+
8
+ export const CHECKS = {
9
+ "click-only-elements": [
10
+ "AI-05",
11
+ "low",
12
+ n => `${n} page(s) have elements that only a mouse click works on`,
13
+ "A `<div>`, `<span>` or table row with an `onclick` and no role is clickable with a mouse, but nothing tells a screen reader or an AI agent that browses the site for someone that it does anything: it isn't in the page's list of buttons and links, and the Tab key skips it. Agents act on what the accessibility tree calls a button or a link.",
14
+ 'Use a real `<button type="button">` for an action and an `<a href>` for a link to another page. If the element must stay a `<div>`, give it `role="button"`, `tabindex="0"` and a key handler for Enter and Space.',
15
+ ],
16
+ "content-signal-placement": [
17
+ "MAP-06",
18
+ "low",
19
+ n => `robots.txt has ${n} Content-Signal line(s) or group(s) that crawlers won't read a signal from`,
20
+ "A Content-Signal line applies to the user-agent group it sits in, as every example on contentsignals.org places it. One above the first `User-agent:` line belongs to no group. A crawler reads only the group that names it (or the `*` group when none does), so a group without its own Content-Signal line gives its crawlers no signal.",
21
+ "Put a Content-Signal line in each group that lets crawlers in, right under its `User-agent:` lines, for example `User-agent: *` then `Content-Signal: search=yes, ai-train=no` then `Allow: /`. A group that blocks its crawlers with `Disallow: /` needs none.",
22
+ ],
23
+ // WAF custom rules can't skip Bot Fight Mode, but an IP Access rule matches before it, and Super Bot Fight Mode
24
+ // allows Skip rules. Perplexity warns it can still challenge their bots.
25
+ // https://developers.cloudflare.com/bots/get-started/bot-fight-mode/
26
+ // https://docs.perplexity.ai/guides/bots
27
+ "ai-bot-refused": [
28
+ "MAP-06",
29
+ "needs-decision",
30
+ n => `${n} page(s) turn away requests that claim to be an AI search crawler`,
31
+ "Asked with the user agent of OAI-SearchBot, Claude-SearchBot or PerplexityBot, these pages answered with an error or a bot challenge, while the same request as a visitor got the page. A firewall, CDN bot setting or security plugin usually does this, and robots.txt doesn't show it, so the site can be left out of ChatGPT, Claude or Perplexity answers without anyone deciding that. A firewall that checks the vendor's IP addresses is right to refuse this test, which doesn't come from them, so the test can't tell the two apart.",
32
+ "Decide whether these crawlers should reach the site, and record it in the profile (MAP-06). To let them in, allow the vendors' published IP ranges (openai.com/searchbot.json, claude.com/crawling/bots.json, perplexity.ai/perplexitybot.json) or the CDN's verified-bots list in the firewall rules, not the user agent alone. Then run log-scan.mjs with --verify-ips on the server logs to see what the real crawlers get. When the evidence names Cloudflare's Bot Fight Mode: custom firewall rules can't skip it, so let the vendors' IP ranges in with an IP Access rule, which Cloudflare checks first, or use Super Bot Fight Mode, which allows Skip rules.",
33
+ ],
34
+ // needs-decision, not low: either line may be a deliberate exception (one vendor licensed to train), which the
35
+ // crawl can't tell.
36
+ "ai-robots-conflict": [
37
+ "MAP-06",
38
+ "needs-decision",
39
+ n => `robots.txt has ${n} AI crawler rule(s) that contradict each other`,
40
+ "Some robots.txt lines for AI crawlers say opposite things: a vendor's AI search crawler let in while its fetcher for pages a person asks about is kept out (or the reverse), a Content-Signal line that says the opposite of its group's Allow and Disallow lines, or the shared AI-training opt-out set while a training crawler's own group lets it in. Each crawler follows the group that names it, so the site may not get the policy the owner meant. Blocking training crawlers while letting AI search in is a valid policy and isn't flagged.",
41
+ "Decide what each AI crawler should do, record it in the profile (MAP-06) and make the lines agree: give a vendor's search crawler and its fetcher the same rule unless they should differ, keep each Content-Signal line in step with its group's Allow and Disallow lines, and with the shared training opt-out set, remove the Allow lines for training crawlers that shouldn't train on the site.",
42
+ ],
43
+ // Bing's new AI directives and its noarchive cut-over dates; Amazon reads noarchive as a training opt-out.
44
+ // https://blogs.bing.com/search/2026/10/your-content-your-choice-clearer-preferences-for-training-and-grounding/
45
+ // https://developer.amazon.com/amazonbot
46
+ "ai-legacy-noarchive": [
47
+ "AI-03",
48
+ "needs-decision",
49
+ n => `${n} page(s) still use noarchive or nocache, which Bing stops reading as AI controls on 1 Mar 2027`,
50
+ "Bing reads noarchive and nocache as AI controls today: noarchive keeps a page out of Copilot's answers and out of training. That ends soon. Bing honours its new `ai-grounding` and `ai-training` directives from 1 Feb 2027, and from 1 Mar 2027 noarchive and nocache no longer control training or grounding, so a page kept out of Copilot today goes back in unless it gets the new directive. Bing search itself isn't affected either way. Amazon reads noarchive as \"don't use this page to train AI models\".",
51
+ 'Decide what these pages should allow. To keep a page out of AI answers and training, add `<meta name="bingbot" content="ai-grounding:disallow, ai-training:disallow">` (or the same in an `X-Robots-Tag: bingbot:` header); `ai-grounding:disallowextended` keeps it in Microsoft\'s own Copilot but out of grounding services Microsoft sells to other companies. If noarchive was never meant to keep the page out of AI answers, remove it. From 15 Dec 2026, sites that use noarchive or nocache can set a temporary preference in Bing Webmaster Tools, which expires on 30 Sep 2027.',
52
+ ],
53
+ "ai-preference-invalid": [
54
+ "AI-03",
55
+ "low",
56
+ n => `${n} page(s) give Bing an ai-grounding or ai-training value it doesn't list`,
57
+ "Bing lists `allow`, `disallow` and `disallowextended` for ai-grounding, and `allow` and `disallow` for ai-training. A value outside those isn't one Bing documents, so the page may not get the setting the owner meant.",
58
+ "Use one of Bing's values: `ai-grounding:disallow` (or `disallowextended`, or `allow`) and `ai-training:disallow` (or `allow`).",
59
+ ],
60
+ // Links with no name are LINK-05's link-no-text, so they aren't counted here.
61
+ "controls-no-name": [
62
+ "AI-05",
63
+ "low",
64
+ n => `${n} page(s) have form fields or buttons with no name`,
65
+ "A form field needs a name that tells people what to type, and a button one that says what it does: a label, an `aria-label`, a title or, for a button, its text. Screen readers read these names out, and AI agents that browse the site for someone use the same names to fill in forms and press buttons. Without one, a search box or an icon-only button is a guess for both.",
66
+ 'Give each field a `<label for>` that points at its `id` (or wrap the field in its `<label>`), and each icon-only button an `aria-label`, for example `<button aria-label="Open menu">`. A visible label works better than placeholder text, which disappears as people type.',
67
+ ],
68
+ };
69
+
70
+ const filled = v => typeof v === "string" && v.trim() !== "";
71
+ const named = a => ["aria-label", "aria-labelledby", "title"].some(k => filled(a[k]));
72
+ const unseen = a => /^(none|presentation)$/i.test(a.role || "");
73
+ // Hidden from everyone, along with everything inside it.
74
+ const gone = a =>
75
+ "hidden" in a ||
76
+ a["aria-hidden"]?.trim().toLowerCase() === "true" ||
77
+ /(?:^|;)\s*(?:display\s*:\s*none|visibility\s*:\s*hidden)\b/i.test(a.style || "");
78
+ // A signup form's spam trap: a text field the Tab key skips, inside a box moved far off screen.
79
+ const offScreen = a => /(?:^|;)\s*(?:left|top)\s*:\s*-\d{3,}px/i.test(a.style || "");
80
+ const trap = t => {
81
+ const a = attrs(t);
82
+ return a.tabindex?.trim() === "-1" && TEXTLIKE.test((a.type || "text").trim().toLowerCase()) ? " " : t;
83
+ };
84
+ const VOID = /^(area|br|col|embed|hr|img|input|source|track|wbr)$/i;
85
+ // Replaces each element pick(attrs) chooses, contents included, with what(element). An element with no balancing
86
+ // close tag (an <input>, a <p> left open) is just its tag. hint skips parsing tags that can't match.
87
+ const swap = (html, pick, what, hint) => {
88
+ const open = /<([a-z][\w-]*)\b[^>]*>/gi;
89
+ let out = "",
90
+ from = 0;
91
+ for (let m; (m = open.exec(html));) {
92
+ if (!hint.test(m[0]) || !pick(attrs(m[0]))) continue;
93
+ let end = open.lastIndex;
94
+ if (!VOID.test(m[1]) && !m[0].endsWith("/>")) {
95
+ const tag = new RegExp(`<(/?)${m[1]}(?=[\\s/>])[^>]*>`, "gi");
96
+ tag.lastIndex = end;
97
+ for (let d = 1, t; (t = tag.exec(html));)
98
+ if (!(d += t[1] ? -1 : 1)) {
99
+ end = tag.lastIndex;
100
+ break;
101
+ }
102
+ }
103
+ out += html.slice(from, m.index) + what(html.slice(m.index, end));
104
+ from = open.lastIndex = end;
105
+ }
106
+ return out + html.slice(from);
107
+ };
108
+ // A control as the evidence shows it: tag, type and the first identifying attribute.
109
+ const describe = (tag, a) => {
110
+ const k = ["name", "id", "class", "src"].find(x => filled(a[x]));
111
+ return `<${tag}${a.type ? ` type="${a.type}"` : ""}${k ? ` ${k}="${a[k].replace(/[`"]/g, "").slice(0, 40)}"` : ""}>`;
112
+ };
113
+ // The first object literal in s without its nested objects, so a tool's name can't come from its input schema or
114
+ // from code after the call. Braces inside strings throw the count off; tokenize the script if that matters.
115
+ const topLevel = s => {
116
+ let d = 0,
117
+ out = "";
118
+ for (const c of s) {
119
+ if (c === "{") d++;
120
+ if (d === 1) out += c;
121
+ if (c === "}" && --d === 0) break;
122
+ }
123
+ return out;
124
+ };
125
+ // Inputs a placeholder can name (HTML-AAM 4.1.1); other fields need a label, aria or title (4.1.7).
126
+ // https://www.w3.org/TR/html-aam-1.0/
127
+ const TEXTLIKE = /^(text|password|number|search|tel|email|url)$/;
128
+
129
+ export function agentFeatures(html) {
130
+ const scripts = [...html.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)]
131
+ .filter(m => !/\ssrc\s*=/i.test(" " + m[1]))
132
+ .map(m => m[2])
133
+ .join("\n");
134
+ // Only what renders; a textarea's contents are text, not markup.
135
+ const doc = html
136
+ .replace(/<(script|style|template|noscript)\b[\s\S]*?<\/\1>|<!--[\s\S]*?-->/gi, " ")
137
+ .replace(/(<textarea\b[^>]*>)[\s\S]*?<\/textarea>/gi, "$1</textarea>");
138
+ const labelFor = new Set([...doc.matchAll(/<label\b[^>]*>/gi)].map(m => attrs(m[0]).for).filter(filled));
139
+ // Hidden elements and spam-trap fields are out of visitors' reach, so they're dropped.
140
+ const shown = swap(
141
+ swap(doc, gone, () => " ", /hidden|style/i),
142
+ offScreen,
143
+ el => el.replace(/<input\b[^>]*>/gi, trap),
144
+ /style/i,
145
+ );
146
+ // A field inside a <label> is named by it, so only fields outside labels are checked one by one.
147
+ const wrapped =
148
+ (shown.match(/<label\b[\s\S]*?<\/label>/gi) || []).join(" ").match(/<(input|select|textarea)\b/gi)?.length || 0;
149
+ const loose = shown.replace(/<label\b[\s\S]*?<\/label>/gi, " ");
150
+ const unnamedFields = [],
151
+ unnamedButtons = [];
152
+ let controls = wrapped;
153
+ for (const m of loose.matchAll(/<(input|select|textarea)\b[^>]*>/gi)) {
154
+ const tag = m[1].toLowerCase(),
155
+ a = attrs(m[0]),
156
+ type = (a.type || "").trim().toLowerCase();
157
+ if (unseen(a) || (tag === "input" && type === "hidden")) continue;
158
+ controls++;
159
+ if (named(a)) continue;
160
+ // Submit and reset have a default name unless value is set empty; an image button needs alt (HTML-AAM 4.1.2-3).
161
+ if (tag === "input" && /^(submit|reset)$/.test(type)) {
162
+ if ("value" in a && !filled(a.value)) unnamedButtons.push(describe(tag, a));
163
+ continue;
164
+ }
165
+ if (tag === "input" && type === "button") {
166
+ if (!filled(a.value)) unnamedButtons.push(describe(tag, a));
167
+ continue;
168
+ }
169
+ if (tag === "input" && type === "image") {
170
+ if (!filled(a.alt) && !filled(a.value)) unnamedButtons.push(describe(tag, a));
171
+ continue;
172
+ }
173
+ const placeholder = tag === "textarea" || (tag === "input" && TEXTLIKE.test(type || "text"));
174
+ if (!(filled(a.id) && labelFor.has(a.id)) && !(placeholder && filled(a.placeholder)))
175
+ unnamedFields.push(describe(tag, a));
176
+ }
177
+ // A button is named by its text (an SVG <title> counts), an alt or label inside it, or its own aria-label or title.
178
+ for (const m of shown.matchAll(/<button\b([^>]*)>([\s\S]*?)<\/button>/gi)) {
179
+ const a = attrs("<button " + m[1] + ">");
180
+ if (unseen(a)) continue;
181
+ controls++;
182
+ const text = m[2]
183
+ .replace(/<[^>]+>/g, " ")
184
+ .replace(/&nbsp;|&#160;/gi, " ")
185
+ .trim();
186
+ if (!named(a) && !text && !/\s(alt|aria-label|aria-labelledby|title)\s*=\s*["']?\s*[^\s"'>]/i.test(m[2]))
187
+ unnamedButtons.push(describe("button", a));
188
+ }
189
+ // WebMCP tools: forms with toolname and tooldescription, then registerTool() calls in inline scripts (external
190
+ // scripts aren't fetched). navigator.modelContext is the older name for document.modelContext.
191
+ // https://webmachinelearning.github.io/webmcp/
192
+ // https://developer.chrome.com/docs/ai/webmcp/declarative-api
193
+ const tools = [...doc.matchAll(/<form\b[^>]*>/gi)]
194
+ .map(m => attrs(m[0]))
195
+ .filter(a => filled(a.toolname) && filled(a.tooldescription))
196
+ .map(a => a.toolname.trim());
197
+ if (/\bmodelContext\b/.test(scripts))
198
+ for (const call of scripts.split(/\bregisterTool\s*\(/).slice(1)) {
199
+ const own = /^\s*\{/.test(call) && /["']?\bname["']?\s*:\s*(["'`])([^"'`\n]{1,100})\1/.exec(topLevel(call));
200
+ tools.push(own ? own[2] : "a tool set up by a script");
201
+ }
202
+ // Click-only: an onclick on a non-interactive tag with no role. A landmark counts as its tag or its ARIA role.
203
+ const clickOnly = [...shown.matchAll(/<([a-z][\w-]*)\b[^>]*>/gi)]
204
+ .filter(m => /onclick/i.test(m[0]))
205
+ .map(m => /** @type {[string, Record<string, string>]} */ ([m[1].toLowerCase(), attrs(m[0])]))
206
+ .filter(([tag, a]) => "onclick" in a && !("role" in a) && !INTERACTIVE.test(tag))
207
+ .map(([tag, a]) => describe(tag, a));
208
+ const landmarksMissing = Object.entries(LANDMARKS)
209
+ .filter(([tag, role]) => !new RegExp(`<${tag}(?=[\\s>/])|\\srole\\s*=\\s*["']?${role}\\b`, "i").test(doc))
210
+ .map(([tag]) => tag);
211
+ return { unnamedFields, unnamedButtons, webmcpTools: [...new Set(tools)], controls, clickOnly, landmarksMissing };
212
+ }
213
+ const INTERACTIVE = /^(a|area|button|input|select|textarea|summary|label|option|details)$/;
214
+ const LANDMARKS = { main: "main", nav: "navigation", header: "banner", footer: "contentinfo" };
215
+
216
+ // The bots in data/ai-bots.json: the one list behind the robots table, ai-bots-blocked, log-scan and the AI crawler
217
+ // probe. Fields beyond name (the vendor's robots.txt token) and vendor:
218
+ // - kind (robots table): search, training, user (fetches a page a person asked for) or other; mayIgnore: the vendor
219
+ // says robots.txt may not apply; alias: a second accepted name; fallback: the group it follows when unnamed;
220
+ // ownGroupOnly: it never follows `User-agent: *`.
221
+ // - group and purpose (log-scan, for bots with their own user agent); ips: published IP lists; ipsAt: where the
222
+ // vendor publishes them in a form log-scan can't read; probeUa: the user agent --ai-bot-probe sends.
223
+ // Each row follows the vendor's own page. Anthropic names three bots, so anthropic-ai and Claude-Web aren't rows, and
224
+ // Claude-Agent is log-scan only since its page doesn't say how robots.txt applies. Google-NotebookLM (supported until
225
+ // Aug 2026) and GoogleMessages are log-scan only. Cohere runs no crawler, so it isn't listed.
226
+ // https://developers.openai.com/api/docs/bots
227
+ // https://docs.perplexity.ai/guides/bots
228
+ // https://support.claude.com/en/articles/8896518
229
+ // https://support.claude.com/en/articles/18234133
230
+ // https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers
231
+ // https://developers.google.com/search/docs/crawling-indexing/google-user-triggered-fetchers
232
+ // https://docs.mistral.ai/robots
233
+ // https://duckduckgo.com/duckduckgo-help-pages/results/duckassistbot
234
+ // https://developer.amazon.com/amazonbot
235
+ // https://yandex.com/support/webmaster/en/robot-workings/check-yandex-robots
236
+ // https://developers.facebook.com/docs/sharing/webmasters/web-crawlers
237
+ // https://support.apple.com/en-us/119829
238
+ // https://docs.cohere.com/docs/cohere-web-crawlers
239
+ /** @type {{ name: string, vendor: string, kind?: string, mayIgnore?: boolean, alias?: string, fallback?: string, ownGroupOnly?: boolean, group?: string, purpose?: string, ips?: string[], ipsAt?: string, probeUa?: string }[]} */
240
+ export const BOTS = JSON.parse(readFileSync(new URL("../data/ai-bots.json", import.meta.url), "utf8"));
241
+ // The robots table's rows, in file order.
242
+ /** @type {[string, string, string, boolean?, { alias?: string, fallback?: string, ownGroupOnly?: boolean }?][]} */
243
+ export const AI_BOTS = BOTS.filter(b => b.kind).map(b => [
244
+ b.name,
245
+ b.vendor,
246
+ b.kind,
247
+ b.mayIgnore,
248
+ { alias: b.alias, fallback: b.fallback, ownGroupOnly: b.ownGroupOnly },
249
+ ]);
250
+
251
+ // Bing's AI rules from robots meta contents and X-Robots-Tag lines. A "<crawler>:" prefix holds for the rules after
252
+ // it; VALUED names take a value after the colon, so they aren't prefixes. legacy holds noarchive and nocache, which
253
+ // Bing reads as AI controls until 1 Mar 2027.
254
+ // https://blogs.bing.com/search/2026/10/your-content-your-choice-clearer-preferences-for-training-and-grounding/
255
+ export const VALUED = /^(max-snippet|max-image-preview|max-video-preview|unavailable_after|ai-grounding|ai-training)$/;
256
+ export const BING_PREFS = {
257
+ "ai-grounding": ["allow", "disallow", "disallowextended"],
258
+ "ai-training": ["allow", "disallow"],
259
+ };
260
+ /** @param {string[]} metas @param {string[]} headerLines */
261
+ export function bingAiRules(metas, headerLines) {
262
+ const legacy = [],
263
+ prefs = [];
264
+ const read = (s, where) => {
265
+ let agent = null;
266
+ for (let t of String(s || "")
267
+ .toLowerCase()
268
+ .split(",")) {
269
+ const m = /^\s*([a-z][\w-]*)\s*:\s*(.*)$/.exec(t);
270
+ if (m && !VALUED.test(m[1])) [, agent, t] = m;
271
+ t = t.trim().replace(/\s*:\s*/, ":");
272
+ if (!t || (agent && agent !== "bingbot")) continue;
273
+ if (t === "noarchive" || t === "nocache") legacy.push({ rule: t, where });
274
+ const p = /^(ai-grounding|ai-training):(.*)$/.exec(t);
275
+ if (p) prefs.push({ name: p[1], value: p[2] });
276
+ }
277
+ };
278
+ metas.forEach(s => read(s, "meta"));
279
+ headerLines.forEach(s => read(s, "header"));
280
+ return { legacy, prefs };
281
+ }
282
+
283
+ // Content-Signal lines crawlers won't read: one above the first User-agent line and, once any group has a signal,
284
+ // each group without one that still lets crawlers in. blocksAll gets a group as { rules: [{ allow, path }] }.
285
+ // https://contentsignals.org
286
+ export function signalPlacement(txt, blocksAll) {
287
+ const { groups, loose } = robotsGroups(txt);
288
+ const out = loose
289
+ .filter(l => l.k === "content-signal")
290
+ .map(l => `line ${l.line}: Content-Signal comes before any User-agent line, so it belongs to no group`);
291
+ // A crawler reads every group naming it as one, and Cloudflare's managed block often sits in front of the site's
292
+ // own `User-agent: *` group, so groups are merged per crawler first.
293
+ // https://www.rfc-editor.org/rfc/rfc9309#section-2.2.1
294
+ const byAgent = new Map();
295
+ for (const g of groups)
296
+ for (const a of g.agents) {
297
+ const k = agentKey(a),
298
+ m = byAgent.get(k) || byAgent.set(k, { agents: [a], rules: [], signal: false }).get(k);
299
+ m.rules.push(...g.rules);
300
+ m.signal ||= g.signals.length > 0;
301
+ }
302
+ const unsignalled = a => {
303
+ const m = byAgent.get(agentKey(a));
304
+ return !m.signal && !blocksAll(m);
305
+ },
306
+ told = new Set();
307
+ if (groups.some(g => g.signals.length))
308
+ for (const g of groups) {
309
+ const names = g.agents.filter(a => unsignalled(a) && !told.has(agentKey(a)));
310
+ names.forEach(a => told.add(agentKey(a)));
311
+ if (names.length)
312
+ out.push(`the User-agent: ${names.join(", ")} group has no Content-Signal line, though other groups do`);
313
+ }
314
+ return out;
315
+ }
316
+
317
+ // The crawler name parseRobots matches on: the leading letters, "_" and "-", lowercased.
318
+ const agentKey = a => (a.startsWith("*") ? "*" : (/^[A-Za-z_-]+/.exec(a)?.[0] || a).toLowerCase());
319
+ const robotsGroups = txt => {
320
+ const { groups, loose } = parseRobots(txt);
321
+ return { groups: groups.map(g => ({ ...g, agents: g.names })), loose };
322
+ };
323
+
324
+ // AI crawler rules in one robots.txt that contradict each other, as sentences, and aipref Content-Usage lines as
325
+ // written: the aipref drafts aren't final, so those are shown, not judged. Groups naming the same crawler read as one.
326
+ // Blocking training while letting search in is a policy, not a contradiction, and is never flagged.
327
+ // https://datatracker.ietf.org/doc/draft-ietf-aipref-attach/
328
+ // https://datatracker.ietf.org/doc/draft-ietf-aipref-vocab/
329
+ /** @param {string} txt @param {(group: { rules: { allow: boolean, path: string }[] }, path: string) => boolean} allowed */
330
+ export function aiRobots(txt, allowed) {
331
+ const { groups, loose } = robotsGroups(txt),
332
+ out = [];
333
+ const merged = key => {
334
+ const gs = groups.filter(g => g.agents.some(a => agentKey(a) === key));
335
+ return gs.length ? { rules: gs.flatMap(g => g.rules) } : null;
336
+ };
337
+ const list = a => (a.length > 1 ? `${a.slice(0, -1).join(", ")} and ${a.at(-1)}` : a[0]);
338
+ // 1. A vendor's search crawler against its user fetchers.
339
+ const star = merged("*"),
340
+ status = bot => {
341
+ const own = merged(bot.toLowerCase()),
342
+ g = own || star;
343
+ return !g || allowed(g, "/") ? "" : own ? "its own group" : "the `User-agent: *` group";
344
+ };
345
+ for (const [s, vendor] of AI_BOTS.filter(b => b[2] === "search"))
346
+ for (const [u] of AI_BOTS.filter(b => b[1] === vendor && b[2] === "user")) {
347
+ const [bs, bu] = [status(s), status(u)],
348
+ S = `${s}, ${vendor}'s AI search crawler,`,
349
+ U = `${u}, which fetches pages a person asks ${vendor}'s assistant for,`;
350
+ if (!bs !== !bu)
351
+ out.push(
352
+ bu ? `${S} is allowed, but ${U} is blocked by ${bu}.` : `${U} is allowed, but ${S} is blocked by ${bs}.`,
353
+ );
354
+ }
355
+ // 2. Content-Signal lines against their group, per set of crawlers sharing the same groups: a yes where Disallow
356
+ // keeps them out, a no to the one use a search-only or training-only group exists for, or two lines disagreeing.
357
+ // In a training-only group only ai-train counts; a copied search=yes says nothing about those crawlers.
358
+ const shared = merged("__usage_ai-training"),
359
+ optOut = !shared
360
+ ? ""
361
+ : !allowed(shared, "/")
362
+ ? "blocked"
363
+ : shared.rules.some(x => !x.allow && x.path)
364
+ ? ""
365
+ : "allowed";
366
+ const kindOf = key =>
367
+ AI_BOTS.find(([n, , , , { alias } = {}]) => n.toLowerCase() === key || alias?.toLowerCase() === key)?.[2];
368
+ const sets = new Map();
369
+ for (const key of new Set(groups.flatMap(g => g.agents.map(agentKey)))) {
370
+ if (key === "__usage_ai-training") continue;
371
+ const idx = groups.flatMap((g, i) => (g.agents.some(a => agentKey(a) === key) ? [i] : [])),
372
+ id = idx.join();
373
+ const set =
374
+ sets.get(id) ||
375
+ sets
376
+ .set(id, {
377
+ names: [],
378
+ kinds: new Set(),
379
+ rules: idx.flatMap(i => groups[i].rules),
380
+ signals: idx.flatMap(i => groups[i].signals),
381
+ })
382
+ .get(id);
383
+ set.names.push(groups[idx[0]].agents.find(a => agentKey(a) === key).replace(/`/g, ""));
384
+ set.kinds.add(kindOf(key));
385
+ }
386
+ for (const { names, kinds, rules, signals } of sets.values()) {
387
+ const g = { rules },
388
+ label = `\`User-agent: ${names.join(", ")}\``,
389
+ kind = kinds.size === 1 ? [...kinds][0] : undefined,
390
+ seen = new Map();
391
+ for (const { v } of signals) {
392
+ const m = /^(\/\S*)\s+(.*)$/.exec(v),
393
+ path = m ? m[1] : "/",
394
+ at = path === "/" ? "" : ` for ${path}`,
395
+ open = allowed(g, path);
396
+ const pairs = Object.fromEntries(
397
+ (m ? m[2] : v)
398
+ .split(",")
399
+ .map(p => p.split("=").map(x => x.trim().toLowerCase()))
400
+ .filter(([k, x]) => /^(search|ai-input|ai-train)$/.test(k) && /^(yes|no)$/.test(x)),
401
+ );
402
+ const yes = Object.keys(pairs).filter(k => pairs[k] === "yes" && (kind !== "training" || k === "ai-train"));
403
+ if (!open && yes.length)
404
+ out.push(
405
+ `The ${label} group's Content-Signal line says ${yes.map(k => `${k}=yes`).join(", ")}${at}, but its Disallow lines keep those crawlers out of ${at ? path : "the whole site"}.`,
406
+ );
407
+ const own = { search: "search", training: "ai-train" }[kind];
408
+ if (open && own && pairs[own] === "no")
409
+ out.push(
410
+ `The ${label} group lets its crawlers in${at}, but its Content-Signal line says ${own}=no${at}, though these are AI ${kind} crawlers.`,
411
+ );
412
+ for (const [k, x] of Object.entries(pairs)) {
413
+ const was = seen.get(path + " " + k);
414
+ if (was === undefined) seen.set(path + " " + k, x);
415
+ else if (was !== x && was !== "told") {
416
+ out.push(`The ${label} group says ${k}=${was} in one Content-Signal line and ${k}=${x} in another${at}.`);
417
+ seen.set(path + " " + k, "told");
418
+ }
419
+ }
420
+ if (open && !at && optOut && pairs["ai-train"] === (optOut === "blocked" ? "yes" : "no"))
421
+ out.push(
422
+ `The shared AI-training opt-out (\`User-agent: __usage_ai-training\`) ${optOut === "blocked" ? "refuses" : "allows"} training for the whole site, but the Content-Signal line in the ${label} group says ai-train=${pairs["ai-train"]}.`,
423
+ );
424
+ }
425
+ }
426
+ // 3. The shared opt-out against training crawlers their own group lets in: the draft lets specific rules win
427
+ // (section 4.5), and Anthropic follows a group that names ClaudeBot.
428
+ // https://datatracker.ietf.org/doc/draft-kelley-aipref-training-preference-signal/
429
+ // https://support.claude.com/en/articles/8896518
430
+ const open =
431
+ optOut === "blocked"
432
+ ? AI_BOTS.filter(
433
+ b => b[2] === "training" && merged(b[0].toLowerCase()) && allowed(merged(b[0].toLowerCase()), "/"),
434
+ ).map(b => b[0])
435
+ : [];
436
+ if (open.length)
437
+ out.push(
438
+ `The shared AI-training opt-out (\`User-agent: __usage_ai-training\`) refuses training for the whole site, but ${list(open)} ${open.length > 1 ? "have their own groups that let them" : "has its own group that lets it"} in. A crawler's own group can win over the shared one: Anthropic says it follows rules that name ClaudeBot first.`,
439
+ );
440
+ const usage = [
441
+ ...loose.filter(l => l.k === "content-usage").map(l => ({ agents: null, rule: l.v })),
442
+ ...groups.flatMap(g => g.usage.map(l => ({ agents: g.agents.join(", "), rule: l.v }))),
443
+ ];
444
+ return {
445
+ conflicts: out,
446
+ usage: usage
447
+ .filter(u => u.rule)
448
+ .slice(0, 20)
449
+ .map(u => ({ agents: u.agents?.slice(0, 200) ?? null, rule: u.rule.slice(0, 200) })),
450
+ };
451
+ }
452
+
453
+ // An RFC 9727 API catalog (a linkset), an A2A Agent Card (A2A 1.0.0 section 8.2), and OAuth metadata, whose required
454
+ // members are `resource` (RFC 9728) and `issuer` (RFC 8414).
455
+ // https://www.rfc-editor.org/rfc/rfc9727
456
+ // https://www.rfc-editor.org/rfc/rfc9728
457
+ // https://www.rfc-editor.org/rfc/rfc8414
458
+ /** @type {[string, (j: any) => boolean][]} */
459
+ const AGENT_FILES = [
460
+ ["/.well-known/api-catalog", j => Array.isArray(j?.linkset)],
461
+ ["/.well-known/agent-card.json", j => filled(j?.name)],
462
+ ["/.well-known/oauth-protected-resource", j => filled(j?.resource)],
463
+ ["/.well-known/oauth-authorization-server", j => filled(j?.issuer)],
464
+ ];
465
+ // Only /.well-known/ paths on the origin are asked for. A file counts only when it parses as what it should be, so a
466
+ // soft 404 doesn't, and each is capped at 1 MB unpacked against huge files and gzip bombs.
467
+ export async function agentFiles(fetchFn, origin) {
468
+ const read = async path => {
469
+ try {
470
+ const r = await fetchFn(origin + path);
471
+ if (r.status !== 200) {
472
+ await r.body?.cancel();
473
+ return null;
474
+ }
475
+ const b = await bodyUpTo(r, 1 << 20);
476
+ return b && JSON.parse(new TextDecoder().decode(b));
477
+ } catch {
478
+ return null;
479
+ }
480
+ };
481
+ const [ucp, ...files] = await Promise.all(["/.well-known/ucp", ...AGENT_FILES.map(([p]) => p)].map(read));
482
+ // A UCP business profile is a JSON object with a `ucp` member. https://ucp.dev/latest/specification/overview
483
+ const profile = ucp && typeof ucp.ucp === "object" && ucp.ucp;
484
+ return {
485
+ ucp: profile ? (filled(profile.version) ? profile.version : "unknown") : null,
486
+ wellKnown: AGENT_FILES.filter(([, ok], i) => ok(files[i])).map(([p]) => p),
487
+ };
488
+ }