webcake-landing-mcp 1.13.2 → 1.13.3

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.
@@ -1,4 +1,11 @@
1
1
  [
2
+ {
3
+ "v": "1.13.3",
4
+ "d": "20/11/2026",
5
+ "type": "Fixed",
6
+ "en": "settings.thumbnail/settings.favicon no longer end up as a 404 sNaN resize URL after an MCP save followed by an editor publish: rehosting now skips…",
7
+ "vi": "settings.thumbnail/settings.favicon không còn bị thành URL resize sNaN lỗi 404 sau khi lưu qua MCP rồi publish lại từ editor: bước rehost nay bỏ qua…"
8
+ },
2
9
  {
3
10
  "v": "1.13.2",
4
11
  "d": "20/11/2026",
@@ -33,12 +40,5 @@
33
40
  "type": "Added",
34
41
  "en": "Three new tools, api_find, api_get, and api_call, expose the full landing_page_backend API surface the account's token can reach, beyond what the…",
35
42
  "vi": "Ba tool mới api_find, api_get, api_call cho phép gọi toàn bộ API của landing_page_backend mà token của tài khoản có quyền truy cập, vượt ra ngoài…"
36
- },
37
- {
38
- "v": "1.10.0",
39
- "d": "19/11/2026",
40
- "type": "Added",
41
- "en": "A new clone_page tool clones any web page (including JavaScript-rendered React/Vue/Next sites) by measuring it in a real headless-Chrome browser at…",
42
- "vi": "Tool mới clone_page clone bất kỳ trang web nào (kể cả trang render bằng JavaScript như React/Vue/Next) bằng cách đo trực tiếp trong trình duyệt…"
43
43
  }
44
44
  ]
@@ -24,6 +24,10 @@
24
24
  /** Hosts we never re-host: our own CDN + deliberate placeholders. */
25
25
  const SKIP_HOSTS = [
26
26
  "statics.pancake.vn",
27
+ // The editor's resize CDN (its publish writes settings.thumbnail/favicon as
28
+ // content.pancake.vn/<bucket>/s1200x650/…). Re-hosting it swapped a working
29
+ // editor URL for one without the -w:/-h: info the next editor publish needs (#5).
30
+ "content.pancake.vn",
27
31
  "placehold.co",
28
32
  "placeholder.com",
29
33
  "via.placeholder.com",
@@ -192,6 +196,18 @@ export function rewriteImageUrls(source, map) {
192
196
  };
193
197
  return recur(source);
194
198
  }
199
+ /**
200
+ * Repair `content.pancake.vn/<bucket>/sNaNx<h>[/fwebp<q>]/…` URLs (always 404).
201
+ * The editor's publish resizes settings.thumbnail/favicon from the `-w:…-h:…`
202
+ * info in the file name; a URL without it (the public upload route mints those)
203
+ * gets width NaN, and the editor stores that broken link in the source (#5).
204
+ * Dropping the size segment leaves the original image, which the CDN serves.
205
+ */
206
+ const NAN_RESIZE_RE = /(https:\/\/content\.pancake\.vn\/[^/"\s]+)\/sNaNx\d+(?:\/fwebp\d*)?\//g;
207
+ export function healBrokenResizeUrls(source) {
208
+ const json = JSON.stringify(source);
209
+ return json?.includes("/sNaNx") ? JSON.parse(json.replace(NAN_RESIZE_RE, "$1/")) : source;
210
+ }
195
211
  /** Hard cap on uploads per save — a runaway-safety backstop, far above a real page's image count.
196
212
  * The {original → hosted} dedup cache itself lives in ./rehost-cache.ts (Redis-or-memory),
197
213
  * kept OUT of this module so rehost.ts stays PURE (no network/IO → no webcake-client cycle). */
@@ -565,7 +565,7 @@ function writeFailure(status, json, text) {
565
565
  */
566
566
  export async function appendSection(config, pageId, sections, opts = {}) {
567
567
  const url = `${config.base}${APPEND_ENDPOINT}`;
568
- const { source: hostedSections, report: rehost } = await rehostSourceImages(config, sections);
568
+ const { source: hostedSections, report: rehost } = await rehostSourceImages(config, sections, pageId);
569
569
  let res;
570
570
  try {
571
571
  res = await fetch(url, {
@@ -626,7 +626,7 @@ function fontWeightNotice(sections) {
626
626
  /** Overwrite an existing page's source (source-only). */
627
627
  export async function updatePageSource(config, pageId, source, opts = {}) {
628
628
  let url = `${config.base}${UPDATE_ENDPOINT}`;
629
- const { source: hostedSource, report: rehost } = await rehostSourceImages(config, withGoogleWeightLinks(source));
629
+ const { source: hostedSource, report: rehost } = await rehostSourceImages(config, withGoogleWeightLinks(source), pageId);
630
630
  // Against a known version: send only the changed sections (patch_page_source) when that is smaller.
631
631
  let body = JSON.stringify({ page_id: pageId, source: hostedSource, ...baseField(opts.base) });
632
632
  let via = "update";
@@ -1253,7 +1253,7 @@ function rehostFilename(src, ext) {
1253
1253
  * row is per-org, so a shared key would let org B reuse org A's URL and never get
1254
1254
  * the image filed into its own collection.
1255
1255
  */
1256
- export async function rehostSourceImages(config, source) {
1256
+ export async function rehostSourceImages(config, source, pageId) {
1257
1257
  const candidates = collectExternalImageUrls(source);
1258
1258
  if (candidates.length === 0)
1259
1259
  return { source };
@@ -1265,7 +1265,16 @@ export async function rehostSourceImages(config, source) {
1265
1265
  // collection. This never blocks the save: a page's images are not worth
1266
1266
  // failing a write over, and create_page already refuses to save at all when
1267
1267
  // the org is ambiguous, so by this point an org is normally settled.
1268
- const orgId = config.jwt ? await resolveCollectionOrgId(config) : undefined;
1268
+ let orgId = config.jwt ? await resolveCollectionOrgId(config) : undefined;
1269
+ // An edit (update/append) on a multi-org account: file into the PAGE's org.
1270
+ // The public fallback mints URLs without the -w:/-h: info, which the editor's
1271
+ // publish turns into a 404 `sNaN` thumbnail/favicon (#5).
1272
+ if (!orgId && config.jwt && pageId) {
1273
+ const found = await searchPages(config, { id: pageId, limit: 1 });
1274
+ const org = found.pages?.find((p) => `${p.id}` === `${pageId}`)?.organization_id;
1275
+ if (org != null && `${org}` !== "")
1276
+ orgId = `${org}`;
1277
+ }
1269
1278
  if (orgId)
1270
1279
  config = { ...config, orgId };
1271
1280
  const scope = config.jwt && orgId ? `org:${orgId}` : "public";
package/dist/smoke.js CHANGED
@@ -26,7 +26,7 @@ import { isLocalPath, resolveLocalPath, sniffMime, localContentType } from "./to
26
26
  import { buildMicrolinkUrl } from "./persistence/screenshot-client.js";
27
27
  import { isPrivateHost, isAllowedScreenshotUrl, acquireSlot, releaseSlot, slotStats } from "./persistence/screenshot-playwright.js";
28
28
  import { iconifyCandidates } from "./persistence/icon-client.js";
29
- import { collectExternalImageUrls, rewriteImageUrls, isRehostableImageUrl, isInlineBase64Image, parseInlineBase64Image } from "./persistence/rehost.js";
29
+ import { collectExternalImageUrls, rewriteImageUrls, isRehostableImageUrl, isInlineBase64Image, parseInlineBase64Image, healBrokenResizeUrls } from "./persistence/rehost.js";
30
30
  import { key as rehostCacheKey } from "./persistence/rehost-cache.js";
31
31
  import { sourceFingerprint, collectElementIds, decideOverwrite, rememberPageVersion, forgetPageVersion, lastKnownPageVersion, resetPageVersions, sourceCacheKey, cachePageSource, cachedPageSource, cachedPageSourceVersion, dropCachedPageSource, resetPageSourceCache, } from "./persistence/page-version.js";
32
32
  let failures = 0;
@@ -2128,6 +2128,13 @@ console.log("== rehost: external-image URL collect + rewrite (pure, offline) =="
2128
2128
  check("rehost: data: URI not rehostable", !isRehostableImageUrl("data:image/svg+xml;utf8,<svg>"));
2129
2129
  check("rehost: extension-less URL not rehostable as a plain field", !isRehostableImageUrl("https://w.ladicdn.com/x/noext"));
2130
2130
  check("rehost: .jpg URL rehostable", isRehostableImageUrl("https://w.ladicdn.com/x/p.jpg"));
2131
+ // #5: the editor's resize CDN is ours — never re-host it; heal its NaN-width (404) links.
2132
+ check("rehost: content.pancake.vn (editor resize CDN) not rehostable", !isRehostableImageUrl("https://content.pancake.vn/web-media-264/s1200x650/fwebp90/1a/67/x-w:1200-h:630.png"));
2133
+ {
2134
+ const ok = "https://content.pancake.vn/web-media-264/s50x50/fwebp/1a/67/x.png";
2135
+ const healed = healBrokenResizeUrls({ settings: { favicon: "https://content.pancake.vn/web-media-264/sNaNx50/fwebp/1a/67/x.png", thumbnail: "https://content.pancake.vn/web-media-264/sNaNx650/1a/67/y.png", ok } });
2136
+ check("heal: sNaN favicon/thumbnail → original image, valid resize URL untouched", healed.settings.favicon === "https://content.pancake.vn/web-media-264/1a/67/x.png" && healed.settings.thumbnail === "https://content.pancake.vn/web-media-264/1a/67/y.png" && healed.settings.ok === ok, healed);
2137
+ }
2131
2138
  check("rehost: ?query after ext still rehostable", isRehostableImageUrl("https://cdn.x/p.png?v=2"));
2132
2139
  // Stitch ↔ webcake bridge: Google Stitch images live on googleusercontent with
2133
2140
  // NO extension — host-recognized so a Stitch clone's specials.src auto-hosts.
@@ -15,6 +15,7 @@ import { objectOrJson, objectsOrJson } from "../mcp/params.js";
15
15
  import { readConfig, configFromHeaders } from "../persistence/config.js";
16
16
  import { applyOps, buildRequestRedacted, buildUpdateRequestRedacted, buildAppendRequestRedacted, buildPublishRequestRedacted, buildPageApp, createPage, listOrganizations, listPages, searchPages, listVerifiedDomains, getPageSource, getPageVersion, updatePageSource, appendSection, publishPage, toPreviewUrl, } from "../persistence/webcake-client.js";
17
17
  import { matchAccountDomain, normalizeDomain } from "../persistence/domain-match.js";
18
+ import { healBrokenResizeUrls } from "../persistence/rehost.js";
18
19
  import { putDraft, getDraft, updateDraft, deleteDraft } from "../persistence/draft-cache.js";
19
20
  import { sourceFingerprint, decideOverwrite, rememberPageVersion, forgetPageVersion, lastKnownPageVersion, sourceCacheKey, cachePageSource, cachedPageSource, cachedPageSourceVersion, dropCachedPageSource, } from "../persistence/page-version.js";
20
21
  import { locate as locateNode, outline as pageOutline, selectIds, matchProblem, dropStaleMeasure, dropStaleAgainst, moveNode, duplicateNode, refsTo, subtreeIds, } from "../domains/landing/tree.js";
@@ -1699,6 +1700,8 @@ export function registerPersistenceTools(server, domain) {
1699
1700
  if (!res.ok || res.source == null) {
1700
1701
  return text({ published: false, reason: "page_not_found", status: res.status, error: res.error ?? "No source on this page." });
1701
1702
  }
1703
+ // An editor publish may have stored a 404 `sNaN` thumbnail/favicon — don't republish it (#5).
1704
+ const source = healBrokenResizeUrls(res.source);
1702
1705
  // Resolve the domain to publish to the way the editor's publish modal does:
1703
1706
  // an explicit arg wins, otherwise reuse the page's CURRENTLY-ATTACHED domain
1704
1707
  // so a plain publish_page({ page_id }) keeps the page live at the same URL
@@ -1780,7 +1783,7 @@ export function registerPersistenceTools(server, domain) {
1780
1783
  : { would_run: false, note: "No build host configured — publish will fall back to the LEGACY source-only route (nothing goes live). Set WEBCAKE_BUILD_BASE env or x-webcake-build-base header (prod preset: https://build.webcake.io) to publish for real." },
1781
1784
  ...(previewExpiryNote ? { note: previewExpiryNote } : {}),
1782
1785
  ...(domainNote ? { domain_note: domainNote } : {}),
1783
- request: buildPublishRequestRedacted(config, page_id, res.source, opts, !!buildBase),
1786
+ request: buildPublishRequestRedacted(config, page_id, source, opts, !!buildBase),
1784
1787
  hint: "Re-run with dry_run=false to actually publish.",
1785
1788
  });
1786
1789
  }
@@ -1793,7 +1796,7 @@ export function registerPersistenceTools(server, domain) {
1793
1796
  let buildWarning;
1794
1797
  if (buildBase) {
1795
1798
  console.error(`[publish_page] calling build host ${buildBase} for page ${page_id}`);
1796
- const buildResult = await buildPageApp(buildBase, page_id, res.source);
1799
+ const buildResult = await buildPageApp(buildBase, page_id, source);
1797
1800
  if (buildResult.ok) {
1798
1801
  app = buildResult.app;
1799
1802
  app_css = buildResult.app_css;
@@ -1809,7 +1812,7 @@ export function registerPersistenceTools(server, domain) {
1809
1812
  buildWarning = "No build host configured (WEBCAKE_BUILD_BASE env / x-webcake-build-base header; prod preset has https://build.webcake.io automatically). Fell back to the legacy source-only publish: a version was saved but NOTHING WENT LIVE (the live publish_html route needs the rendered app).";
1810
1813
  }
1811
1814
  const publishOpts = { ...opts, app, app_css };
1812
- const outcome = await publishPage(config, page_id, res.source, publishOpts);
1815
+ const outcome = await publishPage(config, page_id, source, publishOpts);
1813
1816
  return text({
1814
1817
  published: outcome.ok,
1815
1818
  // live = the PagePublishedV2 record public serving reads was written
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcake-landing-mcp",
3
- "version": "1.13.2",
3
+ "version": "1.13.3",
4
4
  "description": "MCP server exposing Webcake landing-page element schemas + AI usage hints, and persisting LLM-generated page sources to a Webcake backend.",
5
5
  "mcpName": "io.github.vuluu2k/webcake-landing-mcp",
6
6
  "type": "module",