webcake-landing-mcp 1.13.4 → 1.13.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.
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "v": "1.13.6",
4
+ "d": "20/11/2026",
5
+ "type": "Fixed",
6
+ "en": "update_page/patch_page no longer compute a sections-only diff against a page that has two elements sharing the same id (something the Webcake editor…",
7
+ "vi": "update_page/patch_page nay không còn tính diff theo từng section với một trang có hai element dùng chung id (điều mà chính editor Webcake vẫn cho…"
8
+ },
9
+ {
10
+ "v": "1.13.5",
11
+ "d": "20/11/2026",
12
+ "type": "Fixed",
13
+ "en": "update_page/patch_page no longer block on a click event the Webcake editor itself saved with action:null (an event added via the editor's EventTrait…",
14
+ "vi": "update_page/patch_page không còn bị chặn bởi một event click mà chính editor Webcake đã lưu với action:null (một event được thêm qua picker…"
15
+ },
2
16
  {
3
17
  "v": "1.13.4",
4
18
  "d": "20/11/2026",
@@ -26,19 +40,5 @@
26
40
  "type": "Fixed",
27
41
  "en": "update_page, patch_page, add_section (legacy fallback path), and completing a cached draft via create_page/patch_page/update_page with a draft_id…",
28
42
  "vi": "update_page, patch_page, add_section (đường fallback cho backend cũ), và việc hoàn tất một draft đã cache qua create_page/patch_page/update_page với…"
29
- },
30
- {
31
- "v": "1.13.0",
32
- "d": "19/11/2026",
33
- "type": "Added",
34
- "en": "new_element and the get_element/list_elements skeletons now return the exact node the Webcake editor drops for a type — its default colors, font,…",
35
- "vi": "new_element và skeleton của get_element/list_elements nay trả về đúng node mà editor Webcake thả ra cho type đó — màu, font, viền, kích thước mặc…"
36
- },
37
- {
38
- "v": "1.12.0",
39
- "d": "19/11/2026",
40
- "type": "Added",
41
- "en": "get_element/list_elements now return keys (one line per specials/config/styles key the published renderer actually reads, with meaning, value type,…",
42
- "vi": "get_element/list_elements nay trả thêm keys (mỗi dòng là một key specials/config/styles mà renderer thật có đọc, kèm ý nghĩa, kiểu giá trị, enum,…"
43
43
  }
44
44
  ]
@@ -210,8 +210,8 @@
210
210
  "description": "Trigger. Matches the editor's own dropdown: click/hover on any element, success/error on a form, delay on anything (plus the legacy \"unset\")."
211
211
  },
212
212
  "action": {
213
- "type": "string",
214
- "description": "Behavior. Common click actions and what target holds: none(-), open_link(URL), open_popup(popup id), close_popup(popup id), scroll_to(element/section id), show_section/hide_section(section id), show_hide_element(element id), change_tab(id), lightbox(image id/url), copy(text), collapse(id), set_field_value(field_name + set_value), back_to/back_home(url), share(url), play_audio/stop_audio(id), open_cart/add_to_cart(product id), open_app(provider: botcake|whatsapp|mess_prefill|tiktok_prefill|line_prefill), change_color, custom_js. Hover actions: change_color, change_background, change_text_color, change_underline, change_overline, change_image, animation_hover, show_hide_element.",
213
+ "type": ["string", "null"],
214
+ "description": "null = an event the editor added but no action was picked yet (EventTrait.vue add()); the renderer ignores it and create_page's repair drops it. Behavior. Common click actions and what target holds: none(-), open_link(URL), open_popup(popup id), close_popup(popup id), scroll_to(element/section id), show_section/hide_section(section id), show_hide_element(element id), change_tab(id), lightbox(image id/url), copy(text), collapse(id), set_field_value(field_name + set_value), back_to/back_home(url), share(url), play_audio/stop_audio(id), open_cart/add_to_cart(product id), open_app(provider: botcake|whatsapp|mess_prefill|tiktok_prefill|line_prefill), change_color, custom_js. Hover actions: change_color, change_background, change_text_color, change_underline, change_overline, change_image, animation_hover, show_hide_element.",
215
215
  "examples": [
216
216
  "none", "open_link", "open_popup", "close_popup", "scroll_to",
217
217
  "show_section", "hide_section", "show_hide_element", "copy",
@@ -99,6 +99,9 @@ const TOP_KEYS = ["settings", "options", "cartConfigs"];
99
99
  export function sourceOps(before, after) {
100
100
  if (!isPlainObj(before) || !isPlainObj(after))
101
101
  return undefined;
102
+ // an id held by two nodes: the backend edits the FIRST one it meets, which may not be the one meant
103
+ if (hasDuplicateIds(before) || hasDuplicateIds(after))
104
+ return undefined;
102
105
  const acc = { removes: [], sets: [], inserts: [] };
103
106
  for (const root of ["page", "popup"])
104
107
  if (!listOps(Array.isArray(before[root]) ? before[root] : [], Array.isArray(after[root]) ? after[root] : [], { root }, acc))
@@ -113,6 +116,11 @@ export function sourceOps(before, after) {
113
116
  }
114
117
  return [...acc.removes, ...acc.sets, ...acc.inserts, ...tops];
115
118
  }
119
+ function hasDuplicateIds(src) {
120
+ const seen = new Set();
121
+ const walk = (list) => Array.isArray(list) && list.some((n) => isPlainObj(n) && ((typeof n.id === "string" && (seen.has(n.id) || !seen.add(n.id))) || walk(n.children)));
122
+ return ["page", "popup", "dynamic_pages"].some((r) => walk(src[r]));
123
+ }
116
124
  /** Ops for one child list (false: not expressible as list edits — reordered, or a node without an id). */
117
125
  function listOps(a, b, where, acc) {
118
126
  if ([...a, ...b].some((n) => !isPlainObj(n) || typeof n.id !== "string"))
@@ -154,37 +162,52 @@ function nodeOps(old, n, acc) {
154
162
  * so the tree a patch leaves behind can be cached without downloading it again. Throws on an op it cannot apply. */
155
163
  export function applyOps(source, ops) {
156
164
  const out = structuredClone(source);
165
+ // depth-first pre-order, page then popup — the order LandingPage.Ai.SourcePatch walks
157
166
  const find = (id) => {
158
- for (const root of ["page", "popup"]) {
159
- const stack = [Array.isArray(out[root]) ? out[root] : []];
160
- while (stack.length) {
161
- const list = stack.pop();
162
- for (let i = 0; i < list.length; i++) {
163
- if (list[i]?.id === id)
164
- return { list, i };
165
- if (Array.isArray(list[i]?.children))
166
- stack.push(list[i].children);
167
- }
167
+ const walk = (list) => {
168
+ if (!Array.isArray(list))
169
+ return undefined;
170
+ for (let i = 0; i < list.length; i++) {
171
+ if (!isPlainObj(list[i]))
172
+ continue;
173
+ if (list[i].id === id)
174
+ return { list, i };
175
+ const hit = walk(list[i].children);
176
+ if (hit)
177
+ return hit;
168
178
  }
169
- }
170
- return undefined;
179
+ return undefined;
180
+ };
181
+ return walk(out.page) ?? walk(out.popup);
171
182
  };
172
183
  const at = (list, index, node) => (index == null ? list.push(node) : list.splice(index, 0, node));
184
+ const ROOT_TYPE = { page: "section", popup: "popup" };
173
185
  for (const op of ops) {
174
186
  if (op.op === "top")
175
187
  out[op.key] = structuredClone(op.value);
176
- else if (op.op === "insert" && !op.parent_id)
177
- at((out[op.root ?? "page"] ??= []), op.index, structuredClone(op.node));
188
+ else if (op.op === "insert" && !op.parent_id) {
189
+ const root = op.root ?? "page";
190
+ if (op.node?.type !== ROOT_TYPE[root])
191
+ throw new Error(`applyOps: a top-level ${root} node must be a ${ROOT_TYPE[root]}`);
192
+ at((out[root] ??= []), op.index, structuredClone(op.node));
193
+ }
178
194
  else {
179
195
  const hit = find(op.op === "insert" ? op.parent_id : op.id);
180
196
  if (!hit)
181
197
  throw new Error(`applyOps: ${op.op} ${op.id ?? op.parent_id} not found`);
198
+ const node = hit.list[hit.i];
182
199
  if (op.op === "remove")
183
200
  hit.list.splice(hit.i, 1);
184
- else if (op.op === "set")
201
+ else if (op.op === "set") {
202
+ if ((node.type === "section" || node.type === "popup") && op.node?.type !== node.type)
203
+ throw new Error(`applyOps: cannot turn ${node.type} ${op.id} into ${op.node?.type}`);
185
204
  hit.list[hit.i] = { ...structuredClone(op.node), id: op.id };
186
- else if (op.op === "insert")
187
- at((hit.list[hit.i].children ??= []), op.index, structuredClone(op.node));
205
+ }
206
+ else if (op.op === "insert") {
207
+ if (!Array.isArray(node.children))
208
+ throw new Error(`applyOps: ${op.parent_id} has no children list`);
209
+ at(node.children, op.index, structuredClone(op.node));
210
+ }
188
211
  }
189
212
  }
190
213
  return out;
@@ -393,6 +416,7 @@ export async function createPage(config, name, source, orgId) {
393
416
  editor_url: toEditorLoginUrl(config, editorPath),
394
417
  preview_url: toPreviewUrl(config, previewPath),
395
418
  organization_id: (orgId ?? config.orgId) ?? null,
419
+ version: versionOf(data),
396
420
  raw: data,
397
421
  ...(rehost ? { rehost } : {}),
398
422
  // Also when only the Google weight links changed it — publish must build what was stored.
@@ -632,7 +656,14 @@ export async function updatePageSource(config, pageId, source, opts = {}) {
632
656
  let via = "update";
633
657
  let nOps = 0;
634
658
  const ops = opts.base && opts.before != null ? sourceOps(opts.before, hostedSource) : undefined;
635
- // the tree equals the version it was read at: nothing to write (fonts still synced — a sync can fail and be retried)
659
+ // the tree equals the version it was read at: nothing to write (fonts still synced — a sync can fail and be retried).
660
+ // `before` taken from the cache without asking (verified:false) may be stale: then confirm the
661
+ // version first — an empty diff never reaches the backend's own check.
662
+ if (ops && ops.length === 0 && opts.verified === false) {
663
+ const v = await getPageVersion(config, pageId);
664
+ if (v.ok && v.version !== opts.base)
665
+ return { ok: false, status: 409, page_changed: true, live_version: v.version, error: "page_changed: the cached copy is older than the stored page — nothing was written" };
666
+ }
636
667
  if (ops && ops.length === 0)
637
668
  return {
638
669
  ok: true, status: 200, page_id: pageId, version: opts.base, via: "patch", patch_ops: 0, unchanged: true, raw: { unchanged: true },
@@ -670,7 +701,8 @@ export async function updatePageSource(config, pageId, source, opts = {}) {
670
701
  }
671
702
  }
672
703
  catch (e) {
673
- return timeoutOrNetworkError(url, e);
704
+ // a timed-out save may still land: the draft must hold what it would have stored
705
+ return { ...timeoutOrNetworkError(url, e), rehosted_source: hostedSource };
674
706
  }
675
707
  const text = await res.text();
676
708
  let json = null;
@@ -683,7 +715,7 @@ export async function updatePageSource(config, pageId, source, opts = {}) {
683
715
  const data = json?.data ?? json;
684
716
  const pageIdOut = data?.page_id;
685
717
  if (!res.ok || !pageIdOut)
686
- return writeFailure(res.status, json, text);
718
+ return { ...writeFailure(res.status, json, text), rehosted_source: hostedSource };
687
719
  return {
688
720
  ok: true,
689
721
  status: res.status,
package/dist/smoke.js CHANGED
@@ -189,6 +189,17 @@ console.log("== expand: relocates misplaced responsive.<bp>.animation into confi
189
189
  const kept = landingDomain.expand(both).page[0].children[0].responsive.desktop;
190
190
  check("explicit config.animation wins over the stray key", kept.config.animation.name === "zoomIn" && kept.animation === undefined, kept.config);
191
191
  }
192
+ console.log("== editor-saved values: looping animation + empty click event (#4) ==");
193
+ {
194
+ // A page saved by the editor carries repeat:"infinite" on looping animations and
195
+ // action:null on an event added but never configured — a whole-tree patch must not choke on them.
196
+ const ed = structuredClone(good);
197
+ const el = ed.page[0].children[0];
198
+ el.responsive.desktop.config.animation = { name: "pulse", delay: 0, duration: 1, repeat: "infinite" };
199
+ el.events = [{ id: "ev_null", type: "click", action: null, target: null }];
200
+ const r = validatePage(landingDomain.expand(ed));
201
+ check("editor repeat:'infinite' + action:null validate", r.valid, r.errors);
202
+ }
192
203
  console.log("== form fields: field_default follows the system field_name; alias names warn ==");
193
204
  {
194
205
  // The editor locks a field's ID when properties.field_default is true and
@@ -9,11 +9,13 @@
9
9
  * headers (extra.requestInfo.headers) carry the client's own Webcake JWT, so a
10
10
  * hosted server is multi-user; in stdio/single-user mode they come from env.
11
11
  */
12
+ import { createHash } from "node:crypto";
13
+ import { withGoogleWeightLinks } from "../persistence/html-ingest.js";
12
14
  import { z } from "zod";
13
15
  import { text, warningsField, autoFixedField } from "../mcp/response.js";
14
16
  import { objectOrJson, objectsOrJson } from "../mcp/params.js";
15
17
  import { readConfig, configFromHeaders } from "../persistence/config.js";
16
- import { applyOps, buildRequestRedacted, buildUpdateRequestRedacted, buildAppendRequestRedacted, buildPublishRequestRedacted, buildPageApp, createPage, listOrganizations, listPages, searchPages, listVerifiedDomains, getPageSource, getPageVersion, updatePageSource, appendSection, publishPage, toPreviewUrl, } from "../persistence/webcake-client.js";
18
+ import { sourceOps, applyOps, buildRequestRedacted, buildUpdateRequestRedacted, buildAppendRequestRedacted, buildPublishRequestRedacted, buildPageApp, createPage, listOrganizations, listPages, searchPages, listVerifiedDomains, getPageSource, getPageVersion, updatePageSource, appendSection, publishPage, toPreviewUrl, } from "../persistence/webcake-client.js";
17
19
  import { matchAccountDomain, normalizeDomain } from "../persistence/domain-match.js";
18
20
  import { healBrokenResizeUrls } from "../persistence/rehost.js";
19
21
  import { putDraft, getDraft, updateDraft, deleteDraft } from "../persistence/draft-cache.js";
@@ -83,10 +85,11 @@ export function registerPersistenceTools(server, domain) {
83
85
  const readLiveSource = async (config, pageId, opts = {}) => {
84
86
  const key = sourceCacheKey(pageId, config.jwt);
85
87
  const cv = cachedPageSourceVersion(key);
86
- if (cv && opts.trust && (opts.trust === true || opts.trust === cv)) {
88
+ // only an exact (md5) version is trusted: updated_at has 1 s precision
89
+ if (cv && /^[0-9a-f]{32}$/.test(cv) && opts.trust && (opts.trust === true || opts.trust === cv)) {
87
90
  const hit = cachedPageSource(key, cv);
88
91
  if (hit)
89
- return { ...hit, source: structuredClone(hit.source), from_cache: true };
92
+ return { ...hit, source: structuredClone(hit.source), from_cache: true, trusted: true };
90
93
  }
91
94
  if (cachedPageSourceVersion(key)) {
92
95
  const probe = await getPageVersion(config, pageId);
@@ -122,6 +125,25 @@ export function registerPersistenceTools(server, domain) {
122
125
  if (served.size > 500)
123
126
  served.delete(served.keys().next().value); // ponytail: oldest-first cap
124
127
  };
128
+ /** Both publish routes store `JSON.stringify(source)` byte for byte: its md5 is the version a publish leaves. */
129
+ const publishedVersion = (source) => createHash("md5").update(JSON.stringify(source)).digest("hex");
130
+ /** A version probe after a re-save is only trusted when it is EXACTLY the bytes we stored — anything
131
+ * else means another save landed in between, so forget instead of re-labelling a stale tree. */
132
+ const probeIs = async (config, pageId, expected) => {
133
+ const v = await getPageVersion(config, pageId).catch(() => null);
134
+ return !!v?.ok && v.version === expected;
135
+ };
136
+ /** A page the model just created: its tree IS the stored version — the create's own (exact, from
137
+ * the response), or the auto-publish re-save's when that ran and the probe proves nothing else landed. */
138
+ const servedAfterCreate = async (config, pageId, created, published) => {
139
+ if (!pageId)
140
+ return;
141
+ if (published === undefined)
142
+ return rememberServed(config, pageId, created.version);
143
+ const expected = publishedVersion(published);
144
+ if (await probeIs(config, pageId, expected))
145
+ rememberServed(config, pageId, expected);
146
+ };
125
147
  const isServerToken = (v) => !!v && (/^[0-9a-f]{32}$/.test(v) || /^\d{4}-\d\d-\d\dT/.test(v));
126
148
  /** After a write the backend versioned (source_hash / updated_at): the stored tree IS what we sent,
127
149
  * so cache it under that version — the next read is a version probe, not a download. */
@@ -140,6 +162,9 @@ export function registerPersistenceTools(server, domain) {
140
162
  catch {
141
163
  stored = undefined;
142
164
  }
165
+ // a patch result is only as exact as its version: never cache one under a 1 s updated_at
166
+ if (outcome.via === "patch" && !/^[0-9a-f]{32}$/.test(outcome.version ?? ""))
167
+ stored = undefined;
143
168
  if (outcome.version && stored != null && meta?.ok)
144
169
  cachePageSource(sourceCacheKey(pageId, config.jwt), outcome.version, { ...meta, version: outcome.version, source: structuredClone(stored), from_cache: undefined });
145
170
  else
@@ -178,8 +203,14 @@ export function registerPersistenceTools(server, domain) {
178
203
  return { ok: true };
179
204
  // A server version token (from get_page): exact. The write carries it, the backend re-checks it under its lock.
180
205
  if (tokenBase && live.version) {
206
+ const before = domain.expand(structuredClone(live.source));
181
207
  if (live.version === tokenBase)
182
- return { ok: true, liveVersion: live.version, base: { base: tokenBase, before: domain.expand(structuredClone(live.source)) }, live };
208
+ return { ok: true, liveVersion: live.version, base: { base: tokenBase, before, verified: !live.trusted }, live };
209
+ // the page moved on but already holds exactly this tree (a timed-out save that did land): done
210
+ // (the save adds the Google weight links itself — compare what it would have stored)
211
+ const landed = sourceOps(before, withGoogleWeightLinks(incoming));
212
+ if (landed && landed.length === 0)
213
+ return { ok: true, liveVersion: live.version, base: { base: live.version, before, verified: true }, live };
183
214
  return {
184
215
  ok: false,
185
216
  payload: {
@@ -193,6 +224,20 @@ export function registerPersistenceTools(server, domain) {
193
224
  },
194
225
  };
195
226
  }
227
+ // The backend versions sources exactly, yet nothing says which version this tree was built
228
+ // from (no base_version, no get_page / create_page in this session): an overwrite cannot be
229
+ // checked, so it is refused rather than allowed when it happens to drop no ids.
230
+ if (!opts.baseVersion && /^[0-9a-f]{32}$/.test(live.version ?? ""))
231
+ return {
232
+ ok: false,
233
+ payload: {
234
+ reason: "unverified_overwrite",
235
+ page_id: pageId,
236
+ live_version: live.version,
237
+ hint: "Nothing ties this source to a version of the page (no get_page of the whole tree in this session, no base_version), so the save cannot be checked against edits made since — it could revert them. " +
238
+ `Do ONE of these: (a) patch_page({ page_id, patches:[…] }) for element edits — it merges into the live tree; (b) get_page({ page_id }) (the whole tree), apply your edit to it, then update_page({ page_id, source }) — or pass that get_page's source_version as update_page's base_version; (c) to overwrite regardless, re-run ${opts.retryHint} with force:true.`,
239
+ },
240
+ };
196
241
  // An explicit base_version comes from get_page's source_version — a real read.
197
242
  const baseline = opts.baseVersion
198
243
  ? { fp: opts.baseVersion, origin: "read" }
@@ -516,6 +561,7 @@ export function registerPersistenceTools(server, domain) {
516
561
  const publishOutcome = publish === false
517
562
  ? { published: false, skipped: true, note: "publish:false — created source-only; the preview stays blank until publish_page runs." }
518
563
  : await autoPublish(config, outcome.page_id, outcome.rehosted_source ?? parsed);
564
+ await servedAfterCreate(config, outcome.page_id, outcome, publishOutcome?.published ? outcome.rehosted_source ?? parsed : undefined);
519
565
  return text({
520
566
  created: true,
521
567
  ...outcome,
@@ -652,9 +698,10 @@ export function registerPersistenceTools(server, domain) {
652
698
  // editor after this point cannot be silently overwritten.
653
699
  const source_version = res.version ?? sourceFingerprint(res.source);
654
700
  rememberPageVersion(page_id, sourceFingerprint(res.source), "read");
655
- rememberServed(config, page_id, res.version);
656
701
  if (outline || element_id)
657
702
  return narrow(res.source, { page_id, name: res.name, source_version });
703
+ // only a WHOLE tree handed to the model is a base an update_page tree can come from
704
+ rememberServed(config, page_id, res.version);
658
705
  if (compact === false)
659
706
  return text({ ...res, source_version });
660
707
  return text({
@@ -732,7 +779,7 @@ export function registerPersistenceTools(server, domain) {
732
779
  // loses its stale measured height, and only errors this overwrite ADDS refuse it.
733
780
  const cfg0 = cfgFor(extra).config;
734
781
  // no explicit base: the version of the tree get_page last handed the model
735
- if (!resolvedBaseVersion && cfg0)
782
+ if (!resolvedBaseVersion && cfg0 && !draft_id)
736
783
  resolvedBaseVersion = servedOf(cfg0, resolvedPageId);
737
784
  let liveSrc = null;
738
785
  if (cfg0 && !draft_id) {
@@ -822,7 +869,9 @@ export function registerPersistenceTools(server, domain) {
822
869
  rememberServed(config, resolvedPageId, outcome.version);
823
870
  return text({ updated: true, ...outcome, ...warningsField(result.warnings), ...(guard.notice ? { stale_check: guard.notice } : {}) });
824
871
  }
825
- await updateDraft(existingDraftId, expanded);
872
+ // what the save would have stored (images re-hosted, font links) — a retry after a save that
873
+ // did land then matches the live tree
874
+ await updateDraft(existingDraftId, outcome.rehosted_source ?? expanded);
826
875
  return text({
827
876
  updated: false,
828
877
  ...outcome,
@@ -1573,6 +1622,8 @@ export function registerPersistenceTools(server, domain) {
1573
1622
  // A page created via the fix-after-error path gets the same auto-publish
1574
1623
  // as a direct create_page (build + publish_html so the preview renders).
1575
1624
  const publishOutcome = outcome.ok ? await autoPublish(config, outcome.page_id, outcome.rehosted_source ?? parsed) : undefined;
1625
+ if (outcome.ok)
1626
+ await servedAfterCreate(config, outcome.page_id, outcome, publishOutcome?.published ? outcome.rehosted_source ?? parsed : undefined);
1576
1627
  return text({
1577
1628
  patched: outcome.ok,
1578
1629
  created: outcome.ok,
@@ -1627,7 +1678,7 @@ export function registerPersistenceTools(server, domain) {
1627
1678
  }
1628
1679
  // against the version just read: only the changed sections travel, and an editor save that
1629
1680
  // landed in between is refused by the backend instead of being overwritten
1630
- const outcome = await updatePageSource(config, page_id, parsed, { base: liveRead?.version, before: before && domain.expand(before) });
1681
+ const outcome = await updatePageSource(config, page_id, parsed, { base: liveRead?.version, before: before && domain.expand(before), verified: !liveRead?.trusted });
1631
1682
  if (outcome.page_changed) {
1632
1683
  await deleteDraft(liveDraftId);
1633
1684
  invalidateSource(config, page_id);
@@ -1650,8 +1701,8 @@ export function registerPersistenceTools(server, domain) {
1650
1701
  ...warningsField(result.warnings),
1651
1702
  });
1652
1703
  }
1653
- // Network failure / timeout: keep the update draft for retry.
1654
- await updateDraft(liveDraftId, expanded);
1704
+ // Network failure / timeout: keep the update draft for retry — as it would have been stored.
1705
+ await updateDraft(liveDraftId, outcome.rehosted_source ?? expanded);
1655
1706
  return text({
1656
1707
  patched: false,
1657
1708
  patches_applied: applied, ...integrity,
@@ -1813,6 +1864,18 @@ export function registerPersistenceTools(server, domain) {
1813
1864
  }
1814
1865
  const publishOpts = { ...opts, app, app_css };
1815
1866
  const outcome = await publishPage(config, page_id, source, publishOpts);
1867
+ // publish_html re-saves the source it was given (same content, the backend's own bytes → a new md5):
1868
+ // carry the model's base and the cache over to that version, or an update_page that follows is refused
1869
+ if (outcome.ok && res.version) {
1870
+ const expected = publishedVersion(source);
1871
+ if (expected !== res.version && (await probeIs(config, page_id, expected))) {
1872
+ if (servedOf(config, page_id) === res.version)
1873
+ rememberServed(config, page_id, expected);
1874
+ cachePageSource(sourceCacheKey(page_id, config.jwt), expected, { ...res, version: expected, source: structuredClone(source), from_cache: undefined, trusted: undefined });
1875
+ }
1876
+ else if (expected !== res.version)
1877
+ invalidateSource(config, page_id);
1878
+ }
1816
1879
  return text({
1817
1880
  published: outcome.ok,
1818
1881
  // 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.4",
3
+ "version": "1.13.6",
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",