sbuilder-mcp 0.100.4 → 0.100.6

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/CHANGELOG.md CHANGED
@@ -6,6 +6,31 @@ All notable changes to this project are documented in this file.
6
6
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7
7
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [0.100.6] - 2026-10-29
10
+
11
+ ### Added
12
+ - `sb_traits_for` and `sb_set` expose page-level controls on ROOT: `font_family`, `bg_color`, `bg_image`, `padding` and `class_css`.
13
+ - `sb_import_site` reports `links_unread` for pages whose links could not be read.
14
+
15
+ ### Changed
16
+ - The catalog is regenerated from the latest platform, so the starter theme text styles no longer carry a `fontFamily` of "Inter".
17
+
18
+ ### Fixed
19
+ - A theme text style with no font family now resolves to `inherit`, so elements take the page or site font instead of "Inter", and `default_font` no longer crashes or warns when a theme names no family.
20
+ - `sb_look` and `sb_import` no longer leak a Chrome that finishes launching after its deadline, and every page evaluation, settle and tab close now has a time limit.
21
+ - `sb_import` and `sb_import_site` replace a Chrome that hangs mid-capture once and re-read that page, and report the remaining pages as errors straight away if it hangs again.
22
+
23
+ ## [0.100.5] - 2026-10-29
24
+
25
+ ### Changed
26
+ - `sb_bind` returns `collapsed` with the replaced sources and a one-time note when it replaces a field's chain of several bindings with one.
27
+
28
+ ### Fixed
29
+ - `sb_look` measurements report `off_canvas` for a hidden absolute box, such as a closed dropdown panel, that still widens the page, and skip only hidden boxes inside a fixed layer, such as a closed drawer.
30
+ - `sb_look` no longer treats `aria-hidden` boxes as hidden, and hidden boxes still count for width but not for overlap or small text.
31
+ - `sb_look` turns off CSS transitions before measuring, so an overlay opened just before measuring is measured at its final position.
32
+ - `sb_review` reports `duplicate_binding_field` only when a binding is shadowed by a source that is always present, because a binding before a present-only source such as `product.summary`, `rating` or `record.*` is a fallback.
33
+
9
34
  ## [0.100.4] - 2026-10-29
10
35
 
11
36
  ### Fixed
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,31 @@ Mọi thay đổi đáng chú ý của dự án được ghi lại trong file n
6
6
  Định dạng dựa trên [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7
7
  và dự án tuân theo [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [0.100.6] - 2026-10-29
10
+
11
+ ### Added
12
+ - `sb_traits_for` và `sb_set` cung cấp các control cấp trang trên ROOT: `font_family`, `bg_color`, `bg_image`, `padding` và `class_css`.
13
+ - `sb_import_site` báo `links_unread` cho các trang không đọc được liên kết.
14
+
15
+ ### Changed
16
+ - Catalog được tái sinh theo platform mới nhất, nên text style của theme khởi đầu không còn `fontFamily` là "Inter".
17
+
18
+ ### Fixed
19
+ - Text style của theme không có font family nay được đọc là `inherit`, nên element kế thừa font của trang hoặc site thay vì "Inter", và `default_font` không còn crash hay báo nhầm khi theme không nêu family.
20
+ - `sb_look` và `sb_import` không còn để mồ côi một Chrome khởi động xong sau hạn, và mọi bước evaluate, settle và đóng tab của trang đều có hạn thời gian.
21
+ - `sb_import` và `sb_import_site` thay một lần Chrome bị treo giữa chừng khi chụp rồi đọc lại trang đó, và nếu treo lần nữa thì báo lỗi ngay cho các trang còn lại.
22
+
23
+ ## [0.100.5] - 2026-10-29
24
+
25
+ ### Changed
26
+ - `sb_bind` trả về `collapsed` cùng các nguồn bị thay và một ghi chú một lần khi thay chuỗi nhiều binding của một field bằng một binding duy nhất.
27
+
28
+ ### Fixed
29
+ - Phép đo của `sb_look` báo `off_canvas` cho hộp ẩn dạng absolute, như panel dropdown đang đóng, mà vẫn làm trang rộng ra, và chỉ bỏ qua hộp ẩn nằm trong lớp fixed, như drawer đang đóng.
30
+ - `sb_look` không còn coi hộp `aria-hidden` là ẩn, và hộp ẩn vẫn được tính vào bề rộng nhưng không tính vào overlap hay chữ nhỏ.
31
+ - `sb_look` tắt CSS transition trước khi đo, nên overlay vừa mở được đo ở vị trí cuối.
32
+ - `sb_review` chỉ báo `duplicate_binding_field` khi binding bị che bởi một nguồn luôn có, vì binding đứng trước nguồn present-only như `product.summary`, `rating` hay `record.*` là dự phòng.
33
+
9
34
  ## [0.100.4] - 2026-10-29
10
35
 
11
36
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  export const DEAD_KEY_SOURCE = {
2
- "files": 6041,
3
- "identifiers": 111016,
2
+ "files": 6051,
3
+ "identifiers": 111271,
4
4
  "seededKeys": 460,
5
5
  "dead": 0
6
6
  };
@@ -13,8 +13,54 @@ export const ELEMENTS = {
13
13
  "hideInLayer": false,
14
14
  "childAllows": [],
15
15
  "defaults": {},
16
- "inspector": [],
17
- "controls": [],
16
+ "inspector": [
17
+ {
18
+ "tab": "general",
19
+ "groups": [
20
+ {
21
+ "key": "typography",
22
+ "label": "Typography",
23
+ "controls": [
24
+ "font_family"
25
+ ]
26
+ },
27
+ {
28
+ "key": "background",
29
+ "label": "Background",
30
+ "controls": [
31
+ "bg_color",
32
+ "bg_image"
33
+ ]
34
+ }
35
+ ]
36
+ },
37
+ {
38
+ "tab": "advanced",
39
+ "groups": [
40
+ {
41
+ "key": "spacing",
42
+ "label": "Spacing",
43
+ "controls": [
44
+ "padding"
45
+ ]
46
+ },
47
+ {
48
+ "key": "class_css",
49
+ "label": "Class",
50
+ "controls": [
51
+ "class_css"
52
+ ]
53
+ }
54
+ ]
55
+ }
56
+ ],
57
+ "controls": [
58
+ "font_family",
59
+ "bg_color",
60
+ "bg_image",
61
+ "padding",
62
+ "class_css"
63
+ ],
18
64
  "description": "The invisible page root that wraps all top-level sections.",
19
65
  "useWhen": [
20
66
  "Always present as the single root of every page document"
@@ -36400,6 +36446,40 @@ export const BINDING_SOURCES = [
36400
36446
  "site.timezone",
36401
36447
  "site.youtube"
36402
36448
  ];
36449
+ /** Sources a context holds only when the entity has one (scripts/gen-catalog.ts readPresentOnlySources). */
36450
+ export const PRESENT_ONLY_SOURCES = [
36451
+ "course.ratingAverage",
36452
+ "course.ratingCount",
36453
+ "product.attributes",
36454
+ "product.brandLogo",
36455
+ "product.brandUrl",
36456
+ "product.bundleItems",
36457
+ "product.id",
36458
+ "product.model",
36459
+ "product.ratingAverage",
36460
+ "product.ratingCount",
36461
+ "product.summary",
36462
+ "product.tags",
36463
+ "product.variations",
36464
+ "site.addressLine",
36465
+ "site.country",
36466
+ "site.description",
36467
+ "site.facebook",
36468
+ "site.instagram",
36469
+ "site.localeSwitch",
36470
+ "site.money",
36471
+ "site.moneySwitch",
36472
+ "site.postalCode",
36473
+ "site.privacyPolicy",
36474
+ "site.province",
36475
+ "site.returnPolicy",
36476
+ "site.shippingPolicy",
36477
+ "site.supportEmail",
36478
+ "site.supportPhone",
36479
+ "site.tiktok",
36480
+ "site.timezone",
36481
+ "site.youtube"
36482
+ ];
36403
36483
  export const BOUND_SPECIALS = {
36404
36484
  "bundle-items": [
36405
36485
  "boundBundleItems"
@@ -4,7 +4,7 @@ export const SHAPE_SOURCE = {
4
4
  "fromHandlers": 334,
5
5
  "fromSwaggerOnly": 10,
6
6
  "withReadOnly": 29,
7
- "structsRead": 3469
7
+ "structsRead": 3482
8
8
  };
9
9
  export const REQUEST_SHAPES = {
10
10
  "post:/api/sites/{id}/ai-credits/purchase": {
@@ -1,7 +1,7 @@
1
1
  // GENERATED by scripts/gen-catalog.ts — do not edit by hand.
2
2
  // The platform commit every other generated file here describes.
3
3
  export const PLATFORM_SOURCE = {
4
- "commit": "ab273ce14722dcc17f81176e01415a1892e5d878",
5
- "committedAt": "2026-10-29T18:33:35+07:00",
4
+ "commit": "8243d518032505f7f494c89313bc82ae35e513ea",
5
+ "committedAt": "2026-10-29T22:22:20+07:00",
6
6
  "dirty": false
7
7
  };
@@ -74,7 +74,6 @@ export const STARTER_THEME = {
74
74
  "slug": "heading-1",
75
75
  "name": "Heading 1",
76
76
  "base": {
77
- "fontFamily": "Inter",
78
77
  "fontSize": "48px",
79
78
  "fontWeight": "700",
80
79
  "fontStyle": "normal",
@@ -94,7 +93,6 @@ export const STARTER_THEME = {
94
93
  "slug": "heading-2",
95
94
  "name": "Heading 2",
96
95
  "base": {
97
- "fontFamily": "Inter",
98
96
  "fontSize": "36px",
99
97
  "fontWeight": "700",
100
98
  "fontStyle": "normal",
@@ -114,7 +112,6 @@ export const STARTER_THEME = {
114
112
  "slug": "heading-3",
115
113
  "name": "Heading 3",
116
114
  "base": {
117
- "fontFamily": "Inter",
118
115
  "fontSize": "28px",
119
116
  "fontWeight": "600",
120
117
  "fontStyle": "normal",
@@ -134,7 +131,6 @@ export const STARTER_THEME = {
134
131
  "slug": "heading-4",
135
132
  "name": "Heading 4",
136
133
  "base": {
137
- "fontFamily": "Inter",
138
134
  "fontSize": "22px",
139
135
  "fontWeight": "600",
140
136
  "fontStyle": "normal",
@@ -149,7 +145,6 @@ export const STARTER_THEME = {
149
145
  "slug": "heading-5",
150
146
  "name": "Heading 5",
151
147
  "base": {
152
- "fontFamily": "Inter",
153
148
  "fontSize": "18px",
154
149
  "fontWeight": "600",
155
150
  "fontStyle": "normal",
@@ -164,7 +159,6 @@ export const STARTER_THEME = {
164
159
  "slug": "heading-6",
165
160
  "name": "Heading 6",
166
161
  "base": {
167
- "fontFamily": "Inter",
168
162
  "fontSize": "16px",
169
163
  "fontWeight": "600",
170
164
  "fontStyle": "normal",
@@ -179,7 +173,6 @@ export const STARTER_THEME = {
179
173
  "slug": "text-1",
180
174
  "name": "Text 1",
181
175
  "base": {
182
- "fontFamily": "Inter",
183
176
  "fontSize": "16px",
184
177
  "fontWeight": "400",
185
178
  "fontStyle": "normal",
@@ -194,7 +187,6 @@ export const STARTER_THEME = {
194
187
  "slug": "text-2",
195
188
  "name": "Text 2",
196
189
  "base": {
197
- "fontFamily": "Inter",
198
190
  "fontSize": "14px",
199
191
  "fontWeight": "400",
200
192
  "fontStyle": "normal",
@@ -209,7 +201,6 @@ export const STARTER_THEME = {
209
201
  "slug": "text-3",
210
202
  "name": "Text 3",
211
203
  "base": {
212
- "fontFamily": "Inter",
213
204
  "fontSize": "12px",
214
205
  "fontWeight": "400",
215
206
  "fontStyle": "normal",
@@ -5,7 +5,7 @@ import { bandOf, isGlobal } from './traps.js';
5
5
  import { exampleCopy } from './examplecopy.js';
6
6
  import { SEED_COPY_VI, langOf } from './seedcopy.js';
7
7
  import { HOVER_STATE, hoverHome } from './hover.js';
8
- import { ELEMENTS, BINDING_SOURCES, BOUND_SPECIALS, FIRST_CHILD_ONLY, SATELLITE_RULES, ELEMENT_SEEDS } from '../../catalog/elements.generated.js';
8
+ import { ELEMENTS, BINDING_SOURCES, PRESENT_ONLY_SOURCES, BOUND_SPECIALS, FIRST_CHILD_ONLY, SATELLITE_RULES, ELEMENT_SEEDS } from '../../catalog/elements.generated.js';
9
9
  import { fill } from './findings.js';
10
10
  import { hrefParamProblems, isRecordSource, isSameSitePath, parseRecordRefAxis, readRecordAggregates, recordAggKeyOf, recordAggregateParams, RECORD_FIELD_ID, RECORD_HTML_SOURCE, RECORD_SOURCE, RECORD_TILES, recordScope, } from './record.js';
11
11
  import { formFieldFindings, isFormDocument } from './formdoc.js';
@@ -1541,26 +1541,36 @@ opts = {}) {
1541
1541
  }
1542
1542
  }
1543
1543
  // TWO BINDINGS ON ONE FIELD (TTG gap #62). ApplyBindings
1544
- // (render/scope/scope.go) walks them IN ORDER and each resolved source
1545
- // overwrites the special, so the LAST renders and the rest are dead weight
1546
- // that a reorder silently swaps. The purchase binding is not a field binding.
1544
+ // (render/scope/scope.go) walks them IN ORDER, SKIPS a source the context
1545
+ // does not hold, and each resolved one overwrites the special — so the last
1546
+ // source THE CONTEXT RESOLVES wins. An earlier binding is dead only under a
1547
+ // later source that is ALWAYS there: same context (namespace) and not
1548
+ // present-only. Under `product.tags`, `product.summary`, a rating or a
1549
+ // `record.*` field it is the fallback for an entity without one, and a
1550
+ // source from another context may be outside this node's scope altogether.
1551
+ // The purchase binding is not a field binding.
1547
1552
  const byField = new Map();
1548
1553
  for (const b of bindings) {
1549
1554
  if (!b.field || !b.source || b.id === PRODUCT_ACTION_BINDING_ID)
1550
1555
  continue;
1551
1556
  byField.set(b.field, [...(byField.get(b.field) ?? []), b.source]);
1552
1557
  }
1558
+ const ns = (s) => s.split('.')[0];
1559
+ const always = (s) => ns(s) !== 'record' && !PRESENT_ONLY_SOURCES.includes(s);
1553
1560
  for (const [field, sources] of byField) {
1554
- if (sources.length < 2)
1561
+ const shadow = (i) => sources.slice(i + 1).filter((t) => ns(t) === ns(sources[i]) && always(t)).pop();
1562
+ const deadAt = sources.map((_, i) => i).filter((i) => shadow(i));
1563
+ if (!deadAt.length)
1555
1564
  continue;
1556
- const wins = sources[sources.length - 1];
1565
+ const dead = deadAt.map((i) => sources[i]);
1557
1566
  out.push({
1558
1567
  code: 'duplicate_binding_field',
1559
1568
  nodeId: id,
1560
1569
  type,
1561
1570
  key: field,
1562
- problem: `${sources.length} bindings write ${field} (${sources.join(', ')}); the renderer applies them in ` +
1563
- `order, so ${wins} renders and the others are dead weight.`,
1571
+ problem: `${sources.length} bindings write ${field} (${sources.join(', ')}); the renderer applies them in order ` +
1572
+ `and the last source the context resolves wins, so ${dead.join(', ')} never renders — ` +
1573
+ `${shadow(deadAt[0])} always resolves after it.`,
1564
1574
  fix: fill('duplicate_binding_field', { id, key: field }),
1565
1575
  });
1566
1576
  }
@@ -31,6 +31,16 @@ export function findPreset(theme, id) {
31
31
  * was deleted, or the theme is older than the preset) and inventing a colour for
32
32
  * it would be the exact failure this module exists to prevent.
33
33
  */
34
+ /** `--wb-ts-<slug>-<suffix>` → the text-style prop it carries (schema theme.ts textStyleDecls). */
35
+ const TS_PROP = {
36
+ family: 'fontFamily',
37
+ size: 'fontSize',
38
+ weight: 'fontWeight',
39
+ style: 'fontStyle',
40
+ 'line-height': 'lineHeight',
41
+ 'letter-spacing': 'letterSpacing',
42
+ transform: 'textTransform',
43
+ };
34
44
  export function resolveVars(theme, value, depth = 0) {
35
45
  if (depth > 6 || !value.includes('var('))
36
46
  return value;
@@ -40,6 +50,21 @@ export function resolveVars(theme, value, depth = 0) {
40
50
  const [, name, fallback] = m;
41
51
  const scheme = theme.schemes.find((s) => s.id === theme.lightSchemeId) ?? theme.schemes[0] ?? null;
42
52
  let next;
53
+ if (name.startsWith('--wb-ts-')) {
54
+ // A text style DECLARES every prop, empty when unset (schema theme.ts
55
+ // textStyleDecls), so for a slug the theme carries the fallback never applies:
56
+ // an empty var is invalid at computed time and the element INHERITS. The
57
+ // starter's styles name no family since web_builder 81d036721 — reporting the
58
+ // `Inter` fallback there would tell an agent to write the very literal that
59
+ // commit removed. `color` is composed (role/ref) and keeps the old reading.
60
+ const rest = name.slice('--wb-ts-'.length);
61
+ const ts = theme.textStyles.find((t) => rest.startsWith(`${t.slug}-`));
62
+ const key = ts && TS_PROP[rest.slice(ts.slug.length + 1)];
63
+ if (ts && key) {
64
+ const v = ts.base?.[key];
65
+ return typeof v === 'string' && v ? resolveVars(theme, v, depth + 1) : 'inherit';
66
+ }
67
+ }
43
68
  if (name.startsWith('--wb-sc-'))
44
69
  next = scheme?.roles?.[name.slice('--wb-sc-'.length)];
45
70
  else if (name.startsWith('--wb-color-')) {
@@ -169,7 +169,15 @@ async function discoverSite(ctx, entry, opts) {
169
169
  seen.add(real);
170
170
  urls.push({ url: real, from: real === entry ? 'entry' : 'links' });
171
171
  }
172
- return { source: 'links', urls, titles: crawled.titles, visited: crawled.visited, robots, aliases };
172
+ return {
173
+ source: 'links',
174
+ urls,
175
+ titles: crawled.titles,
176
+ visited: crawled.visited,
177
+ robots,
178
+ aliases,
179
+ ...(crawled.unread.length ? { unread: crawled.unread } : {}),
180
+ };
173
181
  }
174
182
  /**
175
183
  * A built subtree as the document a GLOBAL SECTION stores.
@@ -489,6 +497,7 @@ export function registerImportTools(server, ctx, session) {
489
497
  entry,
490
498
  discovered_by: found.source,
491
499
  ...(found.visited ? { pages_read_to_find_them: found.visited } : {}),
500
+ ...(found.unread ? { links_unread: found.unread } : {}),
492
501
  pages: plan.pages.map((p) => ({ url: p.url, slug: p.slug, name: p.name, ...lands(p) })),
493
502
  ...(Object.keys(plan.skipped).length || found.aliases
494
503
  ? { skipped: { ...plan.skipped, ...(found.aliases ? { 'canonical-alias': found.aliases } : {}) } }
@@ -882,11 +882,27 @@ export function registerLiveTools(server, ctx, session) {
882
882
  }
883
883
  }
884
884
  const forced = guard.forced.length ? { forced: guard.forced } : {};
885
+ // A FALLBACK CHAIN COLLAPSED. ApplyBindings skips a source the context
886
+ // lacks, so earlier bindings under a present-only one (product.summary,
887
+ // tags, rating, record.*) render when it is absent. Replacing them all is
888
+ // what a rebind asks for — and is said, since it can lose a fallback.
889
+ const prior = action === undefined
890
+ ? (d.node(id).bindings ?? [])
891
+ .filter((b) => b?.field === field && b.id !== PRODUCT_ACTION_BINDING_ID)
892
+ .map((b) => b.source ?? '')
893
+ : [];
894
+ const collapsed = prior.length > 1
895
+ ? {
896
+ collapsed: prior,
897
+ collapsed_note: (dry_run !== false ? ctx.notices.peek : ctx.notices.once).call(ctx.notices, 'bind:collapsed', `${field} held a chain; the renderer shows the last source the context resolves, so an earlier one was ` +
898
+ 'a fallback for an entity without the later one. Now one binding — rebind each if the chain was wanted.'),
899
+ }
900
+ : {};
885
901
  if (dry_run !== false) {
886
902
  const refuse = session.wouldRefuse(patches);
887
- return text({ dry_run: true, patches, ...(refuse ? { would_refuse: refuse } : {}), ...forced });
903
+ return text({ dry_run: true, patches, ...(refuse ? { would_refuse: refuse } : {}), ...collapsed, ...forced });
888
904
  }
889
905
  await session.applyAndSave(patches);
890
- return text({ bound: id, source, field, ...(action ? { action } : {}), rev: d.rev, ...forced });
906
+ return text({ bound: id, source, field, ...(action ? { action } : {}), ...collapsed, rev: d.rev, ...forced });
891
907
  });
892
908
  }
@@ -2041,8 +2041,10 @@ export function registerPageTools(server, ctx) {
2041
2041
  catch {
2042
2042
  // Readiness is additional information, never the reason a review fails.
2043
2043
  }
2044
- // The site's font per text style, for `default_font` — a SITE theme only: the
2045
- // starter is set in Inter, so it can never disagree with an old literal Inter.
2044
+ // The site's font per text style, for `default_font` — a SITE theme only, and
2045
+ // only a style that NAMES a family. Since web_builder 81d036721 the starter's
2046
+ // styles name none (they inherit the page/site font), and an inherited family
2047
+ // is not known here, so such a slug is left out and the rule stays silent.
2046
2048
  const fonts = {};
2047
2049
  try {
2048
2050
  const { theme, from } = await siteTheme(ctx, session.site());
@@ -1446,10 +1446,13 @@ async function readPage(browser, url, width, work, navMs = NAV_TIMEOUT_MS, settl
1446
1446
  // question actually being asked (has the page stopped changing) and answers
1447
1447
  // when it becomes true, bounded so a page that never settles is still read.
1448
1448
  await settleDom(page, settleMs);
1449
- return await work(page);
1449
+ // Bounded by the page's own budget: a dense page reads in seconds, and an
1450
+ // evaluate on a Chrome wedged after the tab opened never answers at all.
1451
+ return await deadline(work(page), 'read the page', navMs);
1450
1452
  }
1451
1453
  finally {
1452
- await page?.close().catch(() => undefined);
1454
+ if (page)
1455
+ await deadline(page.close(), 'close a tab').catch(() => undefined);
1453
1456
  }
1454
1457
  }
1455
1458
  function limitsFrom(opts) {
@@ -1515,22 +1518,39 @@ export async function capture(url, opts = {}) {
1515
1518
  */
1516
1519
  export async function captureMany(urls, opts = {}) {
1517
1520
  const limits = limitsFrom(opts);
1518
- return withBrowser(async (browser) => {
1519
- const out = [];
1520
- for (const url of urls) {
1521
- try {
1522
- const result = (await readPage(browser, url, opts.width ?? 1440, (page) => page.evaluate(capturePage, limits), opts.navTimeoutMs, opts.settleMs));
1523
- out.push({ url, ok: true, result });
1524
- }
1525
- catch (e) {
1526
- // ponytail: a wedged Chrome (`ChromeStalled`) fails this page AND each later
1527
- // one after its own 15s deadline, rather than hanging the run; relaunch
1528
- // mid-loop if a site import is ever seen doing that.
1529
- out.push({ url, ok: false, why: readFailure(e) });
1530
- }
1521
+ const out = [];
1522
+ let i = 0;
1523
+ // A WEDGED CHROME IS REPLACED ONCE, MID-RUN, and the page it wedged on is read
1524
+ // again on the fresh one. If that one wedges too the machine is the problem,
1525
+ // and every remaining page fails AT ONCE with the reason — not after a
1526
+ // deadline each, which on a twelve-page import was three silent minutes.
1527
+ for (let attempt = 0; i < urls.length; attempt++) {
1528
+ try {
1529
+ await withBrowser(async (browser) => {
1530
+ for (; i < urls.length; i++) {
1531
+ try {
1532
+ const result = (await readPage(browser, urls[i], opts.width ?? 1440, (page) => page.evaluate(capturePage, limits), opts.navTimeoutMs, opts.settleMs));
1533
+ out.push({ url: urls[i], ok: true, result });
1534
+ }
1535
+ catch (e) {
1536
+ if (e instanceof ChromeStalled)
1537
+ throw e;
1538
+ out.push({ url: urls[i], ok: false, why: readFailure(e) });
1539
+ }
1540
+ }
1541
+ });
1531
1542
  }
1532
- return out;
1533
- });
1543
+ catch (e) {
1544
+ // The first browser not starting at all is no run to report on.
1545
+ if (attempt === 0 && !(e instanceof ChromeStalled))
1546
+ throw e;
1547
+ if (attempt === 0)
1548
+ continue;
1549
+ for (; i < urls.length; i++)
1550
+ out.push({ url: urls[i], ok: false, why: readFailure(e) });
1551
+ }
1552
+ }
1553
+ return out;
1534
1554
  }
1535
1555
  /**
1536
1556
  * Every link on a page, absolute.
@@ -1591,6 +1611,7 @@ export async function crawlLinks(entry, opts) {
1591
1611
  const titles = new Map();
1592
1612
  const canonical = new Map();
1593
1613
  let visited = 0;
1614
+ const unread = [];
1594
1615
  await withBrowser(async (browser) => {
1595
1616
  let frontier = [entry];
1596
1617
  // NAVIGATE ONLY WHILE THE LINKS CAN STILL BE USED. `depth` is how far from
@@ -1626,12 +1647,14 @@ export async function crawlLinks(entry, opts) {
1626
1647
  next.push(url2);
1627
1648
  }
1628
1649
  }
1629
- catch {
1630
- // A page that will not open contributes nothing and ends nothing.
1650
+ catch (e) {
1651
+ // A page that will not open ends nothing, but it is SAID: its links
1652
+ // were never followed, so a thin plan has a reason a caller can read.
1653
+ unread.push({ url, why: readFailure(e) });
1631
1654
  }
1632
1655
  }
1633
1656
  frontier = next;
1634
1657
  }
1635
1658
  });
1636
- return { urls: [...found], titles, canonical, visited };
1659
+ return { urls: [...found], titles, canonical, visited, unread };
1637
1660
  }
@@ -1,5 +1,4 @@
1
- import { chromium } from 'playwright-core';
2
- import { release } from './shoot.js';
1
+ import { launchChrome, release } from './shoot.js';
3
2
  /**
4
3
  * ITS OWN BROWSER, not `shoot.ts`'s pooled one.
5
4
  *
@@ -11,8 +10,10 @@ import { release } from './shoot.js';
11
10
  */
12
11
  let shared = null;
13
12
  async function browser() {
13
+ // Through shoot's launcher: no Playwright signal handlers (src/index.ts owns
14
+ // them), a launch deadline, and a pid noted so `release` can kill a stuck close.
14
15
  if (!shared)
15
- shared = await chromium.launch({ channel: 'chrome' });
16
+ shared = await launchChrome();
16
17
  return shared;
17
18
  }
18
19
  /** MUST be called by any script that diffs, or the process never exits. */
@@ -33,16 +33,21 @@ export function measureShot(shot, skip = new Set(), doc) {
33
33
  // that is two dozen false positives long is a list nobody reads.
34
34
  if (skip.has(b.id))
35
35
  continue;
36
- // A box the browser does not show (a CLOSED drawer is `visibility:hidden`
37
- // and translated off-screen by its own static CSS) is not a visitor's
38
- // problem; the same drawer OPENED is (TTG gap #60).
39
- if (b.hidden)
36
+ // A CLOSED DRAWER is `visibility:hidden` AND fixed, translated off-screen by
37
+ // its own static CSS: nothing a visitor sees or scrolls to (TTG gap #60).
38
+ // Hidden is PAINT only, though — a hidden ABSOLUTE panel (a closed dropdown,
39
+ // a reveal-on-hover child) still lays out and still widens the page:
40
+ // measured, a 320px `.wb-dropdown-panel` at x=200 made a 390 phone scroll
41
+ // to 520 (review of v0.100.4). So only hidden-in-a-fixed-layer is skipped.
42
+ if (b.hidden && (b.inFixed || b.position === 'fixed'))
40
43
  continue;
41
44
  // A FLOATING BOX PAST THE VIEWPORT (TTG gap #60). A fixed drawer 400px wide
42
45
  // on a 390px phone overhangs by 10px with no scrollbar to show it — headless
43
46
  // has none, and a 24px padding hides most of it in the picture. Out of the
44
- // flow nothing shrinks it, so the fix is a cap, said with the widths.
45
- if ((b.position === 'fixed' || b.position === 'sticky' || b.position === 'absolute') &&
47
+ // flow nothing shrinks it, so the fix is a cap, said with the widths. A
48
+ // HIDDEN one is not seen at all; what it costs is the scroll (off_canvas).
49
+ if (!b.hidden &&
50
+ (b.position === 'fixed' || b.position === 'sticky' || b.position === 'absolute') &&
46
51
  (b.x < -1 || b.x + b.w > shot.width + 1)) {
47
52
  out.push({
48
53
  code: 'wider_than_viewport',
@@ -60,13 +65,14 @@ export function measureShot(shot, skip = new Set(), doc) {
60
65
  code: 'off_canvas',
61
66
  nodeId: b.id,
62
67
  width: shot.width,
63
- problem: `Extends past the ${shot.width}px viewport (${b.x} → ${b.x + b.w}).`,
68
+ problem: (b.hidden ? 'Hidden, yet still laid out — it widens the page: ' : '') +
69
+ `Extends past the ${shot.width}px viewport (${b.x} → ${b.x + b.w}).`,
64
70
  fix: fill('off_canvas', { id: b.id }),
65
71
  });
66
72
  }
67
73
  // TEXT TOO SMALL. Only where text actually renders: a container inherits a
68
74
  // font size it never shows, and reporting that would be noise.
69
- if (b.hasText && b.fontPx && b.fontPx < MIN_BODY_PX) {
75
+ if (!b.hidden && b.hasText && b.fontPx && b.fontPx < MIN_BODY_PX) {
70
76
  out.push({
71
77
  code: 'text_too_small',
72
78
  nodeId: b.id,
@@ -59,9 +59,19 @@ export function setLauncherForTest(fn) {
59
59
  * one test seam) serves both, while each keeps a browser of its own.
60
60
  */
61
61
  export async function launchChrome() {
62
- const b = await deadline(launcher(), 'start');
63
- void pidOf(b);
64
- return b;
62
+ const launching = launcher();
63
+ try {
64
+ const b = await deadline(launching, 'start', stallMs * 2);
65
+ void pidOf(b);
66
+ return b;
67
+ }
68
+ catch (e) {
69
+ // The deadline lost the race, not the launch: a Chrome that answers late is
70
+ // still a process nobody holds. Release it when it arrives (review of v0.100.5).
71
+ if (e instanceof ChromeStalled)
72
+ void launching.then((late) => release(late), () => { });
73
+ throw e;
74
+ }
65
75
  }
66
76
  /**
67
77
  * A CHROME STEP THAT NEVER ANSWERS MEANS A WEDGED CHROME, and nothing else bounds it.
@@ -74,6 +84,12 @@ export async function launchChrome() {
74
84
  * handle, and in the server every later tool call, because calls run one at a
75
85
  * time. Healthy, the same steps took ≤3.7s at a load average of 47; the deadline
76
86
  * is four times that, and missing it costs a relaunch, not a failure.
87
+ *
88
+ * A LAUNCH GETS TWICE THAT (30s). It is the heaviest step under CPU contention
89
+ * (process spawn, profile, CDP handshake) and the review of v0.100.5 saw 15s
90
+ * expire on a launch that was merely slow — and a missed launch deadline spends
91
+ * a SECOND launch on the same overloaded machine, the opposite of relief. A tab
92
+ * or an evaluate is cheap, so it keeps 15s: there a miss really means a wedge.
77
93
  */
78
94
  let stallMs = 15_000;
79
95
  /** Tests only: shorten the stall deadline. Pass nothing to restore it. */
@@ -93,6 +109,19 @@ export function deadline(step, what, ms = stallMs) {
93
109
  }),
94
110
  ]);
95
111
  }
112
+ /**
113
+ * A BEST-EFFORT page step: its own failure is swallowed (a page that refuses a
114
+ * stylesheet is still worth photographing), a STALL is not — a wedged Chrome
115
+ * answers no later step either, and swallowing it here would only move the
116
+ * hang to the next unbounded call.
117
+ */
118
+ function soft(step, what, fallback, ms) {
119
+ return deadline(step, what, ms).catch((e) => {
120
+ if (e instanceof ChromeStalled)
121
+ throw e;
122
+ return fallback;
123
+ });
124
+ }
96
125
  /**
97
126
  * ONE Chrome per process, launched on first use and kept.
98
127
  *
@@ -175,7 +204,9 @@ export async function release(b, graceMs = 3_000) {
175
204
  const closing = b.close().catch(() => { });
176
205
  const stalled = await Promise.race([closing.then(() => false), sleep(graceMs, true, { ref: false })]);
177
206
  // No pid, no kill: Chrome's own watchdog still ends it, just not on our clock.
178
- if (!stalled || !pid)
207
+ // `pid > 1` before `kill(-pid)`: -1 is EVERY process this user may signal.
208
+ // CDP only ever answers a real pid; this guards the day it does not.
209
+ if (!stalled || !pid || pid <= 1)
179
210
  return;
180
211
  for (const target of [-pid, pid]) {
181
212
  try {
@@ -234,6 +265,10 @@ export async function shoot(url, opts = {}) {
234
265
  if (!(e instanceof ChromeStalled))
235
266
  throw e;
236
267
  // The pool would hand every later call this same wedged handle: replace it, once.
268
+ // CAVEAT: this closes the SHARED Chrome, so a second shoot() running at the same
269
+ // moment loses its tabs mid-shot. In the server sb_look is the only caller and
270
+ // runs on the serial queue (src/mcp/serial.ts — it is not in SESSION_FREE), so
271
+ // two shots never overlap; a script calling shoot() in parallel owns that risk.
237
272
  await closeBrowser();
238
273
  return shootWith(await browser(), url, opts);
239
274
  }
@@ -251,7 +286,10 @@ async function shootWith(b, url, opts) {
251
286
  return await shootOne(page, url, width, format, opts);
252
287
  }
253
288
  finally {
254
- await page.close().catch(() => { });
289
+ // Bounded: a wedged Chrome does not answer a close either, and an
290
+ // unbounded one here would hang the stall it is unwinding from. Swallowed
291
+ // whole, so the error that brought us here is the one reported.
292
+ await deadline(page.close(), 'close a tab').catch(() => undefined);
255
293
  }
256
294
  }));
257
295
  }
@@ -279,8 +317,7 @@ async function shootWith(b, url, opts) {
279
317
  * photographed anyway — a late picture beats none.
280
318
  */
281
319
  export async function settleDom(page, capMs = 2_000) {
282
- await page
283
- .evaluate(({ quiet, cap }) => new Promise((resolve) => {
320
+ await soft(page.evaluate(({ quiet, cap }) => new Promise((resolve) => {
284
321
  const start = Date.now();
285
322
  let last = Date.now();
286
323
  const mo = new MutationObserver(() => {
@@ -307,8 +344,10 @@ export async function settleDom(page, capMs = 2_000) {
307
344
  // a page that holds 2,396 — 4.8% — and reported NO error, because
308
345
  // settling is not failing. A silent thin import is worse than a refused
309
346
  // one, and the shoot path keeps the default it was tuned for.
310
- { quiet: 250, cap: capMs })
311
- .catch(() => { });
347
+ { quiet: 250, cap: capMs }), 'settle', undefined,
348
+ // The in-page cap bounds a page that keeps changing; this bounds a Chrome
349
+ // that stopped answering altogether.
350
+ capMs + stallMs);
312
351
  }
313
352
  /**
314
353
  * WALK THE PAGE so its lazy images load, then come back to the top.
@@ -330,13 +369,10 @@ async function settleLazyImages(page) {
330
369
  // A page with nothing lazy has nothing to walk for, and the walk is 60 ms a
331
370
  // screen. Checked rather than assumed: the renderer marks images below the
332
371
  // first screen lazy, so a short page legitimately has none.
333
- const lazy = await page
334
- .evaluate(() => document.querySelectorAll('img[loading="lazy"]').length)
335
- .catch(() => 1);
372
+ const lazy = await soft(page.evaluate(() => document.querySelectorAll('img[loading="lazy"]').length), 'count images', 1);
336
373
  if (!lazy)
337
374
  return;
338
- await page
339
- .evaluate(async () => {
375
+ await soft(page.evaluate(async () => {
340
376
  const step = window.innerHeight || 900;
341
377
  const end = document.body.scrollHeight;
342
378
  // A very long page is walked in bigger strides rather than not at all.
@@ -346,15 +382,12 @@ async function settleLazyImages(page) {
346
382
  await new Promise((r) => setTimeout(() => r(undefined), 60));
347
383
  }
348
384
  window.scrollTo(0, 0);
349
- })
350
- .catch(() => { });
385
+ }), 'walk the page', undefined);
351
386
  // Give what the walk started a chance to arrive. `complete` is false while a
352
387
  // fetch is in flight; a decoded-but-broken image reports complete with a zero
353
388
  // natural width, and that is a REAL defect the shot should show, so it is not
354
389
  // waited on.
355
- await page
356
- .waitForFunction(() => [...document.querySelectorAll('img')].every((i) => i.complete === true), undefined, { timeout: 3_000 })
357
- .catch(() => { });
390
+ await soft(page.waitForFunction(() => [...document.querySelectorAll('img')].every((i) => i.complete === true), undefined, { timeout: 3_000 }), 'load images', undefined);
358
391
  }
359
392
  /**
360
393
  * SETTLE EVERY ENTRANCE ANIMATION, or photograph a band that is not there.
@@ -388,9 +421,13 @@ async function settleLazyImages(page) {
388
421
  * Best-effort: a page that refuses a stylesheet is still worth photographing.
389
422
  */
390
423
  async function settleAnimations(page) {
391
- await page
392
- .addStyleTag({ content: '*,*::before,*::after{animation:none !important}' })
393
- .catch(() => { });
424
+ // TRANSITION TOO: an overlay opened just before measuring slides in under
425
+ // its own transition (cart drawer `transform .25s`), and a shot mid-slide
426
+ // measures a box that is not where it ends. `none` jumps to the end value.
427
+ // KNOWN GAP: a reveal chained to ANOTHER element's `transitionend` stays at its
428
+ // start — with no transition, `transitioncancel` fires instead. web_builder's
429
+ // own runtime never listens for `transitionend`; hand-written custom-code can.
430
+ await soft(page.addStyleTag({ content: '*,*::before,*::after{animation:none !important;transition:none !important}' }), 'settle animations', undefined);
394
431
  }
395
432
  async function shootOne(page, url, width, format, opts) {
396
433
  // LOAD, then a BOUNDED settle — never `networkidle` alone.
@@ -417,7 +454,7 @@ async function shootOne(page, url, width, format, opts) {
417
454
  // plus `visibility:visible`. The scrim takes it too, so the shot matches what
418
455
  // a shopper sees rather than a panel floating over bare page.
419
456
  if (opts.open) {
420
- await page.evaluate((id) => {
457
+ await deadline(page.evaluate((id) => {
421
458
  // The narrow `document` shim this file declares is for the MEASUREMENT
422
459
  // pass; here the real DOM is what runs, so reach it through the cast
423
460
  // rather than widening a shim that exists to keep that pass honest.
@@ -425,7 +462,7 @@ async function shootOne(page, url, width, format, opts) {
425
462
  d.getElementById(id)?.classList.add('is-open');
426
463
  for (const s of d.querySelectorAll('.wb-cart-scrim'))
427
464
  s.classList.add('is-open');
428
- }, opts.open);
465
+ }, opts.open), 'open the overlay');
429
466
  }
430
467
  await settleDom(page);
431
468
  await settleLazyImages(page);
@@ -442,7 +479,7 @@ async function shootOne(page, url, width, format, opts) {
442
479
  // node. `type` is read off the leading `wb-` class, which is the only type
443
480
  // signal the render emits; the caller already knows the real types from
444
481
  // sb_outline, so this is a convenience, not a contract.
445
- const boxes = (await page.evaluate(() => {
482
+ const boxes = (await deadline(page.evaluate(() => {
446
483
  // No named inner function: a transpiler's `__name` wrapper would not exist
447
484
  // in the page (the vision skill's evaluate trap).
448
485
  const anon = new Map();
@@ -456,8 +493,11 @@ async function shootOne(page, url, width, format, opts) {
456
493
  const cs = getComputedStyle(el);
457
494
  const own = (el.textContent ?? '').trim();
458
495
  let layer;
459
- for (let e = el; e && layer === undefined; e = e.parentElement) {
460
- if (!['absolute', 'fixed', 'sticky'].includes(getComputedStyle(e).position))
496
+ let inFixed = false;
497
+ for (let e = el; e && !inFixed; e = e.parentElement) {
498
+ const p = getComputedStyle(e).position;
499
+ inFixed = p === 'fixed';
500
+ if (layer !== undefined || !['absolute', 'fixed', 'sticky'].includes(p))
461
501
  continue;
462
502
  if (!e.id && !anon.has(e))
463
503
  anon.set(e, `@${anon.size}`);
@@ -474,10 +514,11 @@ async function shootOne(page, url, width, format, opts) {
474
514
  hasText: own.length > 0,
475
515
  position: cs.position,
476
516
  ...(layer ? { layer } : {}),
477
- ...(cs.visibility !== 'visible' || el.closest('[aria-hidden="true"]') ? { hidden: true } : {}),
517
+ ...(cs.visibility !== 'visible' ? { hidden: true } : {}),
518
+ ...(inFixed ? { inFixed: true } : {}),
478
519
  };
479
520
  });
480
- }));
521
+ }), 'measure the page'));
481
522
  // ZOOM. A designer does not judge a card by looking at the whole page, and
482
523
  // a full-page shot of a long storefront makes one card a few pixels tall.
483
524
  // The clip comes from the SAME measurement pass the boxes do, so what is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.100.4",
3
+ "version": "0.100.6",
4
4
  "description": "MCP server that designs and operates a Store Builder site — pages, data, theme and publish — through the platform's own API and live-edit protocol.",
5
5
  "mcpName": "io.github.vuluu2k/sbuilder-mcp",
6
6
  "type": "module",