@cloudhal/mcp-server 0.6.0 → 0.6.1

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.
@@ -79,6 +79,9 @@ export async function listEntries(
79
79
  const orderBy = a.orderBy ;
80
80
  const limit = a.limit ;
81
81
  if (a.cursor !== undefined && limit === undefined) refuse("cursor", "a cursor needs limit");
82
+ // List fields belong to one collection; without it they would be silently ignored.
83
+ if (base.collection === undefined && (where !== undefined || orderBy !== undefined))
84
+ refuse("collection", "where and orderBy need the collection whose list fields they use");
82
85
  const offset = a.cursor === undefined ? 0 : decodeCursor(a.cursor );
83
86
  const { entries } = await queryContentEntries(ctx.store, siteId, {
84
87
  ...base,
@@ -42,11 +42,13 @@ const listEntriesTool = {
42
42
  name: "list_entries",
43
43
  title: "List articles",
44
44
  description:
45
- 'Content entries, newest first. `collection` defaults to posts (unless the filter names one). `filter` selects by terms (RFC-0002 grammar): clauses joined by "+" (AND), "[a,b]" = either, "-" = none of, "primary:category:x" = primary term, "category:x>*" = x or a sub-category, "collection:posts"; values are term slugs (old slugs work) or ids. Example: "category:news+tag:[ai,llm]+-tag:sponsored". `where`/`orderBy` filter and sort by the collection\'s list fields (RFC-0042; list_collections → listFields), e.g. upcoming events: where [{"field":"startsAt","op":"gte","value":"now"}], orderBy {"field":"startsAt","direction":"asc"}; `limit` pages the answer (total, nextCursor → cursor).',
45
+ 'Content entries, newest first. Without `collection` (or a "collection:" filter clause), entries of every collection; each entry carries its `collection`. `filter` selects by terms (RFC-0002 grammar): clauses joined by "+" (AND), "[a,b]" = either, "-" = none of, "primary:category:x" = primary term, "category:x>*" = x or a sub-category, "collection:posts"; values are term slugs (old slugs work) or ids. Example: "category:news+tag:[ai,llm]+-tag:sponsored". `where`/`orderBy` filter and sort by the collection\'s list fields (RFC-0042; list_collections → listFields), e.g. upcoming events: where [{"field":"startsAt","op":"gte","value":"now"}], orderBy {"field":"startsAt","direction":"asc"}; `limit` pages the answer (total, nextCursor → cursor).',
46
46
  inputSchema: obj(
47
47
  {
48
48
  siteId: id,
49
- collection: str("Collection slug", { default: "posts", pattern: SLUG_PATTERN }),
49
+ collection: str("Collection slug; leave out for every collection", {
50
+ pattern: SLUG_PATTERN,
51
+ }),
50
52
  filter: str("Filter over term assignments, e.g. category:news+tag:ai", {
51
53
  minLength: 1,
52
54
  maxLength: 512,
@@ -81,9 +83,8 @@ const listEntriesTool = {
81
83
  handler: async (a, ctx) => {
82
84
  await requireSite(ctx, a.siteId );
83
85
  const filter = a.filter ;
84
- const collection =
85
- (a.collection ) ??
86
- (filter && /(^|\+)-?collection:/.test(filter) ? undefined : "posts");
86
+ // Every collection by default: a site whose articles live in `blog` saw none under `posts`.
87
+ const collection = a.collection ;
87
88
  const query = {
88
89
  ...(collection !== undefined ? { collection } : {}),
89
90
  ...(filter !== undefined ? { filter } : {}),
@@ -1,4 +1,3 @@
1
- /** A minimal DevTools client over a browser-level socket (flat sessions), and base64 helpers. */
2
1
  import { type CdpSocket, type RenderSession } from "./types.js";
3
2
  /**
4
3
  * A minimal DevTools client over a browser-level socket (flat sessions). Enough for
@@ -1,4 +1,5 @@
1
1
  /** A minimal DevTools client over a browser-level socket (flat sessions), and base64 helpers. */
2
+ import { CSP_LISTENER } from "./checks/scripts.js";
2
3
  import { RenderError, } from "./types.js";
3
4
 
4
5
  /**
@@ -123,6 +124,8 @@ export async function cdpSession(
123
124
  },
124
125
  ],
125
126
  });
127
+ // Before the page's own scripts: keep the CSP violations it raises (`script-blocked`).
128
+ await s("Page.addScriptToEvaluateOnNewDocument", { source: CSP_LISTENER });
126
129
  const loaded = cdp.waitFor("Page.loadEventFired", sessionId, options.loadTimeoutMs ?? 12_000);
127
130
  const nav = await s("Page.navigate", { url });
128
131
  if (typeof nav.errorText === "string" && nav.errorText)
@@ -2,4 +2,4 @@
2
2
  * In-page checks, part of `RENDER_CHECK_SCRIPT`: empty-section, tap-target, input-label, chart-empty, long-line.
3
3
  * Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
4
4
  */
5
- export declare const CONTENT_CHECKS = " // empty-section\n for (const s of document.querySelectorAll(\"[data-section-id]\")) {\n if (getComputedStyle(s).display === \"none\") continue;\n const text = (s.innerText || \"\").trim();\n const media = s.querySelector(\"img,video,iframe,svg,canvas,input,select,textarea,picture\");\n const r = s.getBoundingClientRect();\n if (!text && !media) add(\"empty-section\", s, \"no text or media\");\n else if (r.height < 8) add(\"empty-section\", s, Math.round(r.height) + \" px tall\");\n }\n\n // tap-target: on small screens, controls under 24 \u00D7 24 px that sit too close to another one\n // (WCAG 2.5.8: a 24 px circle on each must not touch another target; links inside sentences are exempt).\n if (W < 768) {\n const targets = [...document.querySelectorAll(\"a[href],button,input:not([type=hidden]),select,textarea,summary,[role=button]\")]\n .filter(visible)\n .map((el) => ({ el, r: el.getBoundingClientRect() }))\n // screen-reader-only controls (1 \u00D7 1 px) are not tapped\n .filter((t) => t.r.width > 2 || t.r.height > 2);\n const small = (t) => t.r.width < 24 || t.r.height < 24;\n const centre = (r) => [r.left + r.width / 2, r.top + r.height / 2];\n const toRect = (p, r) => Math.hypot(Math.max(r.left - p[0], 0, p[0] - r.right), Math.max(r.top - p[1], 0, p[1] - r.bottom));\n for (const t of targets) {\n if (!small(t)) continue;\n if (t.el.tagName === \"A\" && getComputedStyle(t.el).display === \"inline\") {\n const block = t.el.closest(\"p,li,td,dd,blockquote,figcaption\");\n if (block && (block.innerText || \"\").trim().length > (t.el.innerText || \"\").trim().length + 20) continue;\n }\n const c = centre(t.r);\n const near = targets.find((o) => o !== t && !o.el.contains(t.el) && !t.el.contains(o.el) &&\n (toRect(c, o.r) < 12 || (small(o) && Math.hypot(c[0] - centre(o.r)[0], c[1] - centre(o.r)[1]) < 24)));\n if (near) add(\"tap-target\", t.el, Math.round(t.r.width) + \" \u00D7 \" + Math.round(t.r.height) + \" px, too close to \" + JSON.stringify(clip((near.el.innerText || near.el.getAttribute(\"aria-label\") || near.el.tagName.toLowerCase()).trim(), 24)));\n }\n }\n\n // input-label: form controls without an accessible name (a label, aria-label or aria-labelledby).\n for (const el of document.querySelectorAll(\"input:not([type=hidden]):not([type=submit]):not([type=button]),select,textarea\")) {\n if (!visible(el) && !(el.type === \"radio\" || el.type === \"checkbox\")) continue;\n const named = [...(el.labels || [])].some((l) => (l.innerText || l.textContent || \"\").trim()) ||\n (el.getAttribute(\"aria-label\") || \"\").trim() ||\n (el.getAttribute(\"aria-labelledby\") || \"\").split(/s+/).some((id) => id && (document.getElementById(id)?.textContent || \"\").trim());\n if (!named) add(\"input-label\", el, \"no label a screen reader can announce\");\n }\n\n // chart-empty: a chart whose data has no rows.\n for (const el of document.querySelectorAll(\"[data-ch-chart-empty]\")) add(\"chart-empty\", el, \"no rows in its data\");\n\n // long-line: paragraphs averaging more than 90 characters a line.\n for (const p of document.querySelectorAll(\"p,li,dd,blockquote\")) {\n if (!visible(p) || p.querySelector(\"p,li\")) continue;\n const text = (p.innerText || \"\").trim();\n if (text.length < 180) continue;\n const s = getComputedStyle(p);\n const lh = s.lineHeight === \"normal\" ? parseFloat(s.fontSize) * 1.2 : parseFloat(s.lineHeight);\n const lines = Math.round(p.getBoundingClientRect().height / lh);\n if (lines < 3) continue;\n const per = Math.round(text.length / lines);\n if (per > 90) add(\"long-line\", p, \"about \" + per + \" characters a line\");\n }\n";
5
+ export declare const CONTENT_CHECKS = " // empty-section\n for (const s of document.querySelectorAll(\"[data-section-id]\")) {\n if (getComputedStyle(s).display === \"none\") continue;\n const text = (s.innerText || \"\").trim();\n const media = s.querySelector(\"img,video,iframe,svg,canvas,input,select,textarea,picture\");\n const r = s.getBoundingClientRect();\n if (!text && !media) add(\"empty-section\", s, \"no text or media\");\n else if (r.height < 8) add(\"empty-section\", s, Math.round(r.height) + \" px tall\");\n }\n\n // tap-target: on small screens, controls under 24 \u00D7 24 px that sit too close to another one\n // (WCAG 2.5.8: a 24 px circle on each must not touch another target; links inside sentences are exempt).\n if (W < 768) {\n const targets = [...document.querySelectorAll(\"a[href],button,input:not([type=hidden]),select,textarea,summary,[role=button]\")]\n .filter(visible)\n .map((el) => ({ el, r: el.getBoundingClientRect() }))\n // screen-reader-only controls (1 \u00D7 1 px) are not tapped\n .filter((t) => t.r.width > 2 || t.r.height > 2);\n const small = (t) => t.r.width < 24 || t.r.height < 24;\n const centre = (r) => [r.left + r.width / 2, r.top + r.height / 2];\n const toRect = (p, r) => Math.hypot(Math.max(r.left - p[0], 0, p[0] - r.right), Math.max(r.top - p[1], 0, p[1] - r.bottom));\n for (const t of targets) {\n if (!small(t)) continue;\n if (t.el.tagName === \"A\" && getComputedStyle(t.el).display === \"inline\") {\n const block = t.el.closest(\"p,li,td,dd,blockquote,figcaption\");\n if (block && (block.innerText || \"\").trim().length > (t.el.innerText || \"\").trim().length + 20) continue;\n }\n const c = centre(t.r);\n const near = targets.find((o) => o !== t && !o.el.contains(t.el) && !t.el.contains(o.el) &&\n (toRect(c, o.r) < 12 || (small(o) && Math.hypot(c[0] - centre(o.r)[0], c[1] - centre(o.r)[1]) < 24)));\n if (near) add(\"tap-target\", t.el, Math.round(t.r.width) + \" \u00D7 \" + Math.round(t.r.height) + \" px, too close to \" + JSON.stringify(clip((near.el.innerText || near.el.getAttribute(\"aria-label\") || near.el.tagName.toLowerCase()).trim(), 24)));\n }\n }\n\n // input-label: form controls without an accessible name (a label, aria-label or aria-labelledby).\n for (const el of document.querySelectorAll(\"input:not([type=hidden]):not([type=submit]):not([type=button]),select,textarea\")) {\n if (!visible(el) && !(el.type === \"radio\" || el.type === \"checkbox\")) continue;\n const named = [...(el.labels || [])].some((l) => (l.innerText || l.textContent || \"\").trim()) ||\n (el.getAttribute(\"aria-label\") || \"\").trim() ||\n (el.getAttribute(\"aria-labelledby\") || \"\").split(/s+/).some((id) => id && (document.getElementById(id)?.textContent || \"\").trim());\n if (!named) add(\"input-label\", el, \"no label a screen reader can announce\");\n }\n\n // chart-empty: a chart whose data has no rows.\n for (const el of document.querySelectorAll(\"[data-ch-chart-empty]\")) add(\"chart-empty\", el, \"no rows in its data\");\n\n // long-line: text columns whose full lines hold more than 90 characters on average. Counted on\n // the rendered lines (each paragraph's last, partly filled one left out) and pooled over every\n // paragraph of the same width and font, so paragraphs of one column get one verdict.\n const range = document.createRange();\n const columns = new Map();\n let measured = 0;\n for (const p of document.querySelectorAll(\"p,li,dd,blockquote\")) {\n if (measured >= 80 || !visible(p) || p.querySelector(\"p,li\")) continue;\n if ((p.innerText || \"\").trim().length < 180) continue;\n measured++;\n // Characters by the line they are drawn on, in reading order: a character more than half a\n // line below the current line starts the next (inline code in another size stays on its line).\n // A run of spaces counts once, as it is shown.\n const s = getComputedStyle(p);\n const half = (s.lineHeight === \"normal\" ? parseFloat(s.fontSize) * 1.2 : parseFloat(s.lineHeight)) / 2;\n const rows = [];\n let top = -Infinity, seen = 0, space = true;\n const tw = document.createTreeWalker(p, NodeFilter.SHOW_TEXT);\n while (tw.nextNode() && seen < 800) {\n const n = tw.currentNode;\n for (let i = 0; i < n.length && seen < 800; i++) {\n const blank = /s/.test(n.data[i]);\n if (blank && space) continue;\n space = blank;\n seen++;\n range.setStart(n, i);\n range.setEnd(n, i + 1);\n const b = range.getClientRects()[0];\n if (!b) continue;\n if (b.top > top + half) { rows.push(0); top = b.top; }\n rows[rows.length - 1]++;\n }\n }\n // The last line seen may be partly filled (the paragraph's end, or where counting stopped).\n const full = rows.slice(0, -1);\n if (full.length < 2) continue;\n const width = Math.round(p.getBoundingClientRect().width);\n const key = width + \"|\" + s.fontSize + \"|\" + s.fontFamily;\n const col = columns.get(key) || { width, first: p, paragraphs: 0, lines: 0, chars: 0 };\n col.paragraphs++;\n col.lines += full.length;\n col.chars += full.reduce((a, b) => a + b, 0);\n columns.set(key, col);\n }\n for (const col of columns.values()) {\n const per = Math.round(col.chars / col.lines);\n if (per > 90)\n add(\"long-line\", col.first, \"about \" + per + \" characters a line in this \" + col.width + \" px column\" + (col.paragraphs > 1 ? \" (\" + col.paragraphs + \" paragraphs)\" : \"\"));\n }\n";
@@ -48,16 +48,53 @@ export const CONTENT_CHECKS = ` // empty-section
48
48
  // chart-empty: a chart whose data has no rows.
49
49
  for (const el of document.querySelectorAll("[data-ch-chart-empty]")) add("chart-empty", el, "no rows in its data");
50
50
 
51
- // long-line: paragraphs averaging more than 90 characters a line.
51
+ // long-line: text columns whose full lines hold more than 90 characters on average. Counted on
52
+ // the rendered lines (each paragraph's last, partly filled one left out) and pooled over every
53
+ // paragraph of the same width and font, so paragraphs of one column get one verdict.
54
+ const range = document.createRange();
55
+ const columns = new Map();
56
+ let measured = 0;
52
57
  for (const p of document.querySelectorAll("p,li,dd,blockquote")) {
53
- if (!visible(p) || p.querySelector("p,li")) continue;
54
- const text = (p.innerText || "").trim();
55
- if (text.length < 180) continue;
58
+ if (measured >= 80 || !visible(p) || p.querySelector("p,li")) continue;
59
+ if ((p.innerText || "").trim().length < 180) continue;
60
+ measured++;
61
+ // Characters by the line they are drawn on, in reading order: a character more than half a
62
+ // line below the current line starts the next (inline code in another size stays on its line).
63
+ // A run of spaces counts once, as it is shown.
56
64
  const s = getComputedStyle(p);
57
- const lh = s.lineHeight === "normal" ? parseFloat(s.fontSize) * 1.2 : parseFloat(s.lineHeight);
58
- const lines = Math.round(p.getBoundingClientRect().height / lh);
59
- if (lines < 3) continue;
60
- const per = Math.round(text.length / lines);
61
- if (per > 90) add("long-line", p, "about " + per + " characters a line");
65
+ const half = (s.lineHeight === "normal" ? parseFloat(s.fontSize) * 1.2 : parseFloat(s.lineHeight)) / 2;
66
+ const rows = [];
67
+ let top = -Infinity, seen = 0, space = true;
68
+ const tw = document.createTreeWalker(p, NodeFilter.SHOW_TEXT);
69
+ while (tw.nextNode() && seen < 800) {
70
+ const n = tw.currentNode;
71
+ for (let i = 0; i < n.length && seen < 800; i++) {
72
+ const blank = /\s/.test(n.data[i]);
73
+ if (blank && space) continue;
74
+ space = blank;
75
+ seen++;
76
+ range.setStart(n, i);
77
+ range.setEnd(n, i + 1);
78
+ const b = range.getClientRects()[0];
79
+ if (!b) continue;
80
+ if (b.top > top + half) { rows.push(0); top = b.top; }
81
+ rows[rows.length - 1]++;
82
+ }
83
+ }
84
+ // The last line seen may be partly filled (the paragraph's end, or where counting stopped).
85
+ const full = rows.slice(0, -1);
86
+ if (full.length < 2) continue;
87
+ const width = Math.round(p.getBoundingClientRect().width);
88
+ const key = width + "|" + s.fontSize + "|" + s.fontFamily;
89
+ const col = columns.get(key) || { width, first: p, paragraphs: 0, lines: 0, chars: 0 };
90
+ col.paragraphs++;
91
+ col.lines += full.length;
92
+ col.chars += full.reduce((a, b) => a + b, 0);
93
+ columns.set(key, col);
94
+ }
95
+ for (const col of columns.values()) {
96
+ const per = Math.round(col.chars / col.lines);
97
+ if (per > 90)
98
+ add("long-line", col.first, "about " + per + " characters a line in this " + col.width + " px column" + (col.paragraphs > 1 ? " (" + col.paragraphs + " paragraphs)" : ""));
62
99
  }
63
100
  `;
@@ -15,6 +15,7 @@ import { LAYOUT_CHECKS } from "./layout.js";
15
15
  import { MOTION_CHECKS } from "./motion.js";
16
16
  import { NAVIGATION_CHECKS } from "./navigation.js";
17
17
  import { PRELUDE } from "./prelude.js";
18
+ import { SCRIPT_CHECKS } from "./scripts.js";
18
19
 
19
20
  export const RENDER_CHECK_SCRIPT = [
20
21
  "(async () => {",
@@ -23,6 +24,7 @@ export const RENDER_CHECK_SCRIPT = [
23
24
  CONTRAST_CHECKS,
24
25
  CONTENT_CHECKS,
25
26
  FONT_CHECKS,
27
+ SCRIPT_CHECKS,
26
28
  MOTION_CHECKS,
27
29
  NAVIGATION_CHECKS,
28
30
  COMPONENT_CHECKS,
@@ -0,0 +1,11 @@
1
+ /**
2
+ * In-page checks, part of `RENDER_CHECK_SCRIPT`: surface-broken, script-blocked.
3
+ * Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
4
+ */
5
+ /**
6
+ * Runs in the page before any of its own scripts (`Page.addScriptToEvaluateOnNewDocument`):
7
+ * keeps the Content-Security-Policy violations the page raises while it loads, which the
8
+ * `script-blocked` check reads. Report-only ones (`cloudhal dev`) are kept too.
9
+ */
10
+ export declare const CSP_LISTENER = "(() => {\n const seen = (window.__chCsp = []);\n window.addEventListener(\"securitypolicyviolation\", (e) => {\n if (seen.length < 50)\n seen.push({ directive: e.effectiveDirective || e.violatedDirective || \"\", blocked: e.blockedURI || \"\", sample: e.sample || \"\", line: e.lineNumber || 0, report: e.disposition === \"report\", el: e.target instanceof Element ? e.target : null });\n }, true);\n})();";
11
+ export declare const SCRIPT_CHECKS = " // surface-broken: a body surface the preview could not draw (RFC-0020 \u00A75), or a component in one\n // with an unknown block type or props that do not fit it. Theme blocks the preview leaves to the\n // site are fine.\n for (const el of document.querySelectorAll(\".ch-surface-problem\")) {\n const why = [...el.querySelectorAll(\"li\")].map((li) => (li.textContent || \"\").trim()).filter(Boolean);\n add(\"surface-broken\", el, why.length ? why.slice(0, 3).join(\"; \") : \"this interactive block cannot be shown\");\n }\n for (const el of document.querySelectorAll(\".ch-block--missing\")) {\n const text = (el.textContent || \"\").trim();\n if (!/shown by the theme on the site$/.test(text)) add(\"surface-broken\", el, text);\n }\n\n // script-blocked: scripts the page's Content-Security-Policy refused (the Site Worker sends\n // script-src 'self', so an inline <script> never runs there). A static preview runs none on\n // purpose (its own CSP), so it is not asked.\n const runsScripts = !document.querySelector('meta[name=\"generator\"][content=\"Cloudhal preview\"]');\n for (const v of runsScripts ? window.__chCsp || [] : []) {\n if (!/^(script-src|script-src-elem|script-src-attr|worker-src)$/.test(v.directive)) continue;\n const inline = v.blocked === \"inline\" || v.blocked === \"eval\" || !v.blocked;\n const what = inline\n ? (v.blocked === \"eval\" ? \"eval\" : \"an inline script\") + (v.sample ? \" \" + JSON.stringify(clip(v.sample.trim(), 40)) : \"\") + (v.line ? \" at line \" + v.line : \"\")\n : \"the script \" + v.blocked;\n const fix = inline ? \"; ship it as a file (a .js under /_astro or public/)\" : \"\";\n const el = v.el && v.el.isConnected ? v.el : document.body;\n add(\"script-blocked\", el, what + (v.report ? \" would be blocked on the site\" : \" was blocked\") + \" by \" + v.directive + fix);\n }\n";
@@ -0,0 +1,45 @@
1
+ /**
2
+ * In-page checks, part of `RENDER_CHECK_SCRIPT`: surface-broken, script-blocked.
3
+ * Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
4
+ */
5
+
6
+ /**
7
+ * Runs in the page before any of its own scripts (`Page.addScriptToEvaluateOnNewDocument`):
8
+ * keeps the Content-Security-Policy violations the page raises while it loads, which the
9
+ * `script-blocked` check reads. Report-only ones (`cloudhal dev`) are kept too.
10
+ */
11
+ export const CSP_LISTENER = `(() => {
12
+ const seen = (window.__chCsp = []);
13
+ window.addEventListener("securitypolicyviolation", (e) => {
14
+ if (seen.length < 50)
15
+ seen.push({ directive: e.effectiveDirective || e.violatedDirective || "", blocked: e.blockedURI || "", sample: e.sample || "", line: e.lineNumber || 0, report: e.disposition === "report", el: e.target instanceof Element ? e.target : null });
16
+ }, true);
17
+ })();`;
18
+
19
+ export const SCRIPT_CHECKS = ` // surface-broken: a body surface the preview could not draw (RFC-0020 §5), or a component in one
20
+ // with an unknown block type or props that do not fit it. Theme blocks the preview leaves to the
21
+ // site are fine.
22
+ for (const el of document.querySelectorAll(".ch-surface-problem")) {
23
+ const why = [...el.querySelectorAll("li")].map((li) => (li.textContent || "").trim()).filter(Boolean);
24
+ add("surface-broken", el, why.length ? why.slice(0, 3).join("; ") : "this interactive block cannot be shown");
25
+ }
26
+ for (const el of document.querySelectorAll(".ch-block--missing")) {
27
+ const text = (el.textContent || "").trim();
28
+ if (!/shown by the theme on the site$/.test(text)) add("surface-broken", el, text);
29
+ }
30
+
31
+ // script-blocked: scripts the page's Content-Security-Policy refused (the Site Worker sends
32
+ // script-src 'self', so an inline <script> never runs there). A static preview runs none on
33
+ // purpose (its own CSP), so it is not asked.
34
+ const runsScripts = !document.querySelector('meta[name="generator"][content="Cloudhal preview"]');
35
+ for (const v of runsScripts ? window.__chCsp || [] : []) {
36
+ if (!/^(script-src|script-src-elem|script-src-attr|worker-src)$/.test(v.directive)) continue;
37
+ const inline = v.blocked === "inline" || v.blocked === "eval" || !v.blocked;
38
+ const what = inline
39
+ ? (v.blocked === "eval" ? "eval" : "an inline script") + (v.sample ? " " + JSON.stringify(clip(v.sample.trim(), 40)) : "") + (v.line ? " at line " + v.line : "")
40
+ : "the script " + v.blocked;
41
+ const fix = inline ? "; ship it as a file (a .js under /_astro or public/)" : "";
42
+ const el = v.el && v.el.isConnected ? v.el : document.body;
43
+ add("script-blocked", el, what + (v.report ? " would be blocked on the site" : " was blocked") + " by " + v.directive + fix);
44
+ }
45
+ `;
@@ -41,7 +41,7 @@ export interface RenderCheck {
41
41
  /** The widths it failed at. */
42
42
  widths: number[];
43
43
  }
44
- export declare const RENDER_CHECK_IDS: readonly ["overflow-x", "img-alt", "img-broken", "heading-order", "contrast", "empty-section", "tap-target", "long-line", "input-label", "chart-empty", "reduced-motion", "motion-cls", "motion-budget", "flash", "skip-link", "landmarks", "header-contrast", "focus-obscured", "overlay-open", "carousel-label", "carousel-lcp", "carousel-focus", "carousel-autoplay", "image-fit", "font-fallback"];
44
+ export declare const RENDER_CHECK_IDS: readonly ["overflow-x", "img-alt", "img-broken", "heading-order", "contrast", "empty-section", "tap-target", "long-line", "input-label", "chart-empty", "reduced-motion", "motion-cls", "motion-budget", "flash", "skip-link", "landmarks", "header-contrast", "focus-obscured", "overlay-open", "carousel-label", "carousel-lcp", "carousel-focus", "carousel-autoplay", "image-fit", "font-fallback", "surface-broken", "script-blocked"];
45
45
  export type RenderCheckId = (typeof RENDER_CHECK_IDS)[number];
46
46
  export interface RenderShot {
47
47
  width: number;
@@ -89,6 +89,10 @@ export const RENDER_CHECK_IDS = [
89
89
  "image-fit",
90
90
  // RFC-0023 §2: a web font with no metric-matched fallback, so its text moves when it loads.
91
91
  "font-fallback",
92
+ // RFC-0020 §5: a body surface the page could not draw (an unknown component, props that do not fit).
93
+ "surface-broken",
94
+ // A script the page's Content-Security-Policy refused (the Site Worker's is script-src 'self').
95
+ "script-blocked",
92
96
  ] ;
93
97
 
94
98
 
@@ -73,6 +73,8 @@ const WHAT = {
73
73
  "carousel-autoplay": "carousel autoplay",
74
74
  "image-fit": "image crops",
75
75
  "font-fallback": "font swap shift",
76
+ "surface-broken": "interactive blocks that cannot be shown",
77
+ "script-blocked": "scripts blocked by the CSP",
76
78
  };
77
79
 
78
80
  function summary(r ) {
@@ -130,7 +132,7 @@ export function renderTools(previewDoc ) {
130
132
  name: "render_page",
131
133
  title: "Render a page in a browser",
132
134
  description:
133
- "Look at a page's draft as people will see it: renders it in a real browser at desktop (1440), tablet (768) and phone (390) widths and returns screenshots plus automatic checks (sideways scrolling, alt text, broken images, heading order, text contrast, empty sections, tap targets, line length, motion under reduced motion, layout shift) that name the section and component behind each problem. Use it after building or changing a page and before asking a person to publish; fix what it finds and render again. Read-only. Rate-limited (about 10 a minute); when no browser is available, use preview_page.",
135
+ "Look at a page's draft as people will see it: renders it in a real browser at desktop (1440), tablet (768) and phone (390) widths and returns screenshots plus automatic checks (sideways scrolling, alt text, broken images, heading order, text contrast, empty sections, tap targets, line length, motion under reduced motion, layout shift, interactive blocks that cannot be shown, scripts the site's Content-Security-Policy blocks) that name the section and component behind each problem. Use it after building or changing a page and before asking a person to publish; fix what it finds and render again. Read-only. Rate-limited (about 10 a minute); when no browser is available, use preview_page.",
134
136
  inputSchema: obj(
135
137
  {
136
138
  siteId: id,
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Sight for agents (RFC-0021 §4): renders a page in a real browser at a few widths and returns
3
3
  * screenshots plus automatic checks (overflow, alt text, broken images, heading order, contrast,
4
- * empty sections, tap targets, line length). The browser is a DevTools socket: local Chrome under
5
- * Node (`@cloudhal/cli`), Cloudflare Browser Rendering on Workers (`@cloudhal/cloudflare`). One
6
- * small DevTools client serves both, so there is no browser library to bundle.
4
+ * empty sections, tap targets, line length, broken surfaces, blocked scripts, …). The browser is a
5
+ * DevTools socket: local Chrome under Node (`@cloudhal/cli`), Cloudflare Browser Rendering on
6
+ * Workers (`@cloudhal/cloudflare`). One small DevTools client serves both, so there is no browser
7
+ * library to bundle.
7
8
  *
8
9
  * Worker-safe: no Node imports.
9
10
  */
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Sight for agents (RFC-0021 §4): renders a page in a real browser at a few widths and returns
3
3
  * screenshots plus automatic checks (overflow, alt text, broken images, heading order, contrast,
4
- * empty sections, tap targets, line length). The browser is a DevTools socket: local Chrome under
5
- * Node (`@cloudhal/cli`), Cloudflare Browser Rendering on Workers (`@cloudhal/cloudflare`). One
6
- * small DevTools client serves both, so there is no browser library to bundle.
4
+ * empty sections, tap targets, line length, broken surfaces, blocked scripts, …). The browser is a
5
+ * DevTools socket: local Chrome under Node (`@cloudhal/cli`), Cloudflare Browser Rendering on
6
+ * Workers (`@cloudhal/cloudflare`). One small DevTools client serves both, so there is no browser
7
+ * library to bundle.
7
8
  *
8
9
  * Worker-safe: no Node imports.
9
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudhal/mcp-server",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Cloudhal MCP server: semantic site tools (pages, articles, snapshots, preview, publish) governed by the policy engine",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://cloudhal.dev",
@@ -56,15 +56,15 @@
56
56
  "README.md"
57
57
  ],
58
58
  "dependencies": {
59
- "@cloudhal/analytics": "0.6.0",
60
- "@cloudhal/agent-runtime": "0.6.0",
61
- "@cloudhal/astro-renderer": "0.6.0",
62
- "@cloudhal/comments": "0.6.0",
63
- "@cloudhal/core-contracts": "0.6.0",
64
- "@cloudhal/core-ts": "0.6.0",
65
- "@cloudhal/storage": "0.6.0",
59
+ "@cloudhal/analytics": "0.6.1",
60
+ "@cloudhal/agent-runtime": "0.6.1",
61
+ "@cloudhal/astro-renderer": "0.6.1",
62
+ "@cloudhal/comments": "0.6.1",
63
+ "@cloudhal/core-contracts": "0.6.1",
64
+ "@cloudhal/core-ts": "0.6.1",
65
+ "@cloudhal/storage": "0.6.1",
66
66
  "@modelcontextprotocol/server": "2.3.1",
67
- "@cloudhal/schedules": "0.6.0"
67
+ "@cloudhal/schedules": "0.6.1"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@cloudflare/workers-types": "^5.20261007.1",