@nextblock-cms/cortex 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/client.cjs.js +1 -1
  2. package/client.es.js +3 -7
  3. package/index.cjs.js +1 -1
  4. package/index.es.js +24 -277
  5. package/lib/ai-block-generation.cjs.js +3 -4
  6. package/lib/ai-block-generation.es.js +143 -182
  7. package/lib/ai-client.cjs.js +1 -1
  8. package/lib/ai-client.d.ts +1 -1
  9. package/lib/ai-client.es.js +101 -135
  10. package/lib/ai-config.cjs.js +1 -1
  11. package/lib/ai-config.es.js +89 -108
  12. package/lib/ai-cortex-widget-builder.cjs.js +1 -1
  13. package/lib/ai-cortex-widget-builder.es.js +56 -70
  14. package/lib/ai-global-agent-content-ops-tools.cjs.js +1 -1
  15. package/lib/ai-global-agent-content-ops-tools.d.ts +1943 -68
  16. package/lib/ai-global-agent-content-ops-tools.es.js +185 -199
  17. package/lib/ai-global-agent-custom-block-tools.cjs.js +1 -1
  18. package/lib/ai-global-agent-custom-block-tools.d.ts +2160 -95
  19. package/lib/ai-global-agent-custom-block-tools.es.js +226 -223
  20. package/lib/ai-global-agent-db-tools.cjs.js +1 -1
  21. package/lib/ai-global-agent-db-tools.d.ts +2708 -98
  22. package/lib/ai-global-agent-db-tools.es.js +1013 -986
  23. package/lib/ai-global-agent-ecommerce.cjs.js +1 -1
  24. package/lib/ai-global-agent-ecommerce.es.js +3 -7
  25. package/lib/ai-global-agent-site-tools.cjs.js +2 -3
  26. package/lib/ai-global-agent-site-tools.d.ts +10695 -500
  27. package/lib/ai-global-agent-site-tools.es.js +750 -757
  28. package/lib/ai-global-agent-theming-tools.cjs.js +1 -3
  29. package/lib/ai-global-agent-theming-tools.d.ts +2905 -105
  30. package/lib/ai-global-agent-theming-tools.es.js +326 -396
  31. package/lib/ai-global-agent-tools.cjs.js +2 -2
  32. package/lib/ai-global-agent-tools.d.ts +4 -2230
  33. package/lib/ai-global-agent-tools.es.js +3899 -4328
  34. package/lib/ai-key-crypto.cjs.js +1 -1
  35. package/lib/ai-key-crypto.es.js +63 -82
  36. package/lib/ai-key-verification.cjs.js +1 -1
  37. package/lib/ai-key-verification.es.js +74 -63
  38. package/lib/ai-model-catalog.cjs.js +1 -1
  39. package/lib/ai-model-catalog.es.js +18 -22
  40. package/lib/ai-model-registry.cjs.js +2 -2
  41. package/lib/ai-model-registry.es.js +246 -309
  42. package/lib/ai-seo-metadata.cjs.js +2 -3
  43. package/lib/ai-seo-metadata.es.js +143 -185
  44. package/lib/ai-vision.cjs.js +2 -2
  45. package/lib/ai-vision.d.ts +6 -6
  46. package/lib/ai-vision.es.js +161 -215
  47. package/lib/block-content-schemas.cjs.js +1 -1
  48. package/lib/block-content-schemas.es.js +324 -254
  49. package/lib/cortex-widget-registry.cjs.js +1 -1
  50. package/lib/cortex-widget-registry.es.js +35 -43
  51. package/lib/cortex-widget-schema.cjs.js +2 -3
  52. package/lib/cortex-widget-schema.es.js +280 -309
  53. package/lib/editor-document-from-html.cjs.js +1 -1
  54. package/lib/editor-document-from-html.es.js +334 -278
  55. package/lib/fetch-host-guard.cjs.js +1 -0
  56. package/lib/fetch-host-guard.d.ts +2 -0
  57. package/lib/fetch-host-guard.es.js +30 -0
  58. package/lib/mcp-server.cjs.js +1 -1
  59. package/lib/mcp-server.es.js +155 -173
  60. package/lib/mcp-tokens.cjs.js +1 -1
  61. package/lib/mcp-tokens.es.js +95 -107
  62. package/lib/mcp-tool-registry.cjs.js +5 -6
  63. package/lib/mcp-tool-registry.es.js +533 -411
  64. package/lib/site-brief.cjs.js +2 -2
  65. package/lib/site-brief.es.js +102 -108
  66. package/lib/vision-image-download.cjs.js +1 -0
  67. package/lib/vision-image-download.d.ts +43 -0
  68. package/lib/vision-image-download.es.js +120 -0
  69. package/lib/zod-config.cjs.js +1 -1
  70. package/lib/zod-config.es.js +5 -6
  71. package/package.json +8 -8
@@ -1,794 +1,787 @@
1
- import { tool as O } from "ai";
2
- import { parseSiteSocialImageSetting as ke, SITE_SOCIAL_IMAGE_SETTING_KEY as H } from "@nextblock-cms/utils/seo";
3
- import { findOriginalUploadVariant as ve, pickOriginalUploadObjectKey as $e } from "@nextblock-cms/utils/media-variants";
4
- import { requireActorRole as se } from "./ai-global-agent-theming-tools.es.js";
5
- import { cortexSiteBriefInputSchema as de, safeParseCortexSiteBrief as ue, CORTEX_AI_SITE_BRIEF_SETTING_KEY as Q, cortexBuildSessionSchema as ce, CORTEX_AI_BUILD_SESSION_SETTING_KEY as F, cortexSiteBriefSchema as Te, isCortexBuildSessionUsable as Ee } from "./site-brief.es.js";
6
- import "./zod-config.es.js";
7
- import { z as u } from "zod";
8
- const ie = /* @__PURE__ */ new Set([
9
- // pages: home, articles, contact, privacy policy, terms of service
10
- "0098e4f0-e5f3-4e28-acfc-bb9fdb3a4a6b",
11
- "50adeea5-5040-4ae7-bacd-992647920982",
12
- "e3b28669-7e38-47bd-9189-7db2353b52dc",
13
- "8cd91839-518d-4b57-87db-441e59a71a95",
14
- "b5eb82c7-95d6-4308-82d8-3ac2816f5d46",
15
- // posts: architecture, setup, commerce, cortex guide, updating, MCP guide (+ FR)
16
- "de8b8593-1ef6-4e66-8d1f-8b3e7ffb811d",
17
- "461cde55-74cb-4112-8c3d-a25882eeedce",
18
- "23773a34-e54b-40c6-89b5-b09ead17ae60",
19
- "669489e7-5900-496e-8b73-2aba7514a71b",
20
- "c0d3f1a2-8b47-4e19-9a52-7f6b1d4e8c30",
21
- "a7c4e2d1-3b58-4f96-9e0a-6d2c8b1f5a73",
22
- "dbe2a06f-1a9d-48ba-bc35-0f6ef4869156"
23
- ]), V = /* @__PURE__ */ new Set([
24
- "images/NBcover.webp",
25
- "images/commerce-plan.webp",
26
- "images/commerce-wide.webp",
27
- "images/cortex-ai.webp",
28
- "images/cortex_post.webp",
29
- "images/extensibility.webp",
30
- "images/included.webp",
31
- "images/nextblock-logo-button-tiny.png",
32
- "images/nextblock-logo-small.webp",
33
- "images/programmer-upscaled.webp",
34
- "images/update_nextblock.webp"
35
- ]), Ce = "NextBlock™ CMS", Ie = "nextblock cms", A = "home", xe = [
36
- "active_logo_id",
37
- "footer_copyright",
38
- "footer_show_attribution",
39
- "site_description",
40
- "site_keywords",
41
- "site_title",
42
- H
1
+ import { z as e } from "./zod-config.es.js";
2
+ import { CORTEX_AI_BUILD_SESSION_SETTING_KEY as t, CORTEX_AI_SITE_BRIEF_SETTING_KEY as n, cortexBuildSessionSchema as r, cortexSiteBriefInputSchema as i, cortexSiteBriefSchema as a, isCortexBuildSessionUsable as o, safeParseCortexSiteBrief as s } from "./site-brief.es.js";
3
+ import { requireActorRole as c } from "./ai-global-agent-theming-tools.es.js";
4
+ import { tool as l } from "ai";
5
+ import { revalidatePath as u } from "next/cache";
6
+ import { SITE_SOCIAL_IMAGE_SETTING_KEY as d, parseSiteSocialImageSetting as f } from "@nextblock-cms/utils/seo";
7
+ import { findOriginalUploadVariant as p, pickOriginalUploadObjectKey as m } from "@nextblock-cms/utils/media-variants";
8
+ //#region libs/cortex/src/lib/ai-global-agent-site-tools.ts
9
+ var h = /* @__PURE__ */ new Set([
10
+ "0098e4f0-e5f3-4e28-acfc-bb9fdb3a4a6b",
11
+ "50adeea5-5040-4ae7-bacd-992647920982",
12
+ "e3b28669-7e38-47bd-9189-7db2353b52dc",
13
+ "8cd91839-518d-4b57-87db-441e59a71a95",
14
+ "b5eb82c7-95d6-4308-82d8-3ac2816f5d46",
15
+ "de8b8593-1ef6-4e66-8d1f-8b3e7ffb811d",
16
+ "461cde55-74cb-4112-8c3d-a25882eeedce",
17
+ "23773a34-e54b-40c6-89b5-b09ead17ae60",
18
+ "669489e7-5900-496e-8b73-2aba7514a71b",
19
+ "c0d3f1a2-8b47-4e19-9a52-7f6b1d4e8c30",
20
+ "a7c4e2d1-3b58-4f96-9e0a-6d2c8b1f5a73",
21
+ "dbe2a06f-1a9d-48ba-bc35-0f6ef4869156"
22
+ ]), g = /* @__PURE__ */ new Set([
23
+ "images/NBcover.webp",
24
+ "images/commerce-plan.webp",
25
+ "images/commerce-wide.webp",
26
+ "images/cortex-ai.webp",
27
+ "images/cortex_post.webp",
28
+ "images/extensibility.webp",
29
+ "images/included.webp",
30
+ "images/nextblock-logo-button-tiny.png",
31
+ "images/nextblock-logo-small.webp",
32
+ "images/programmer-upscaled.webp",
33
+ "images/update_nextblock.webp"
34
+ ]), _ = "NextBlock™ CMS", v = "nextblock cms", y = "home", b = [
35
+ "active_logo_id",
36
+ "footer_copyright",
37
+ "footer_show_attribution",
38
+ "site_description",
39
+ "site_keywords",
40
+ "site_title",
41
+ d
43
42
  ];
44
- function L(e) {
45
- if (!e?.supabase)
46
- throw new Error("No database connection is available for this tool.");
47
- return e.supabase;
43
+ function x(e) {
44
+ if (!e?.supabase) throw Error("No database connection is available for this tool.");
45
+ return e.supabase;
48
46
  }
49
- function y(e) {
50
- return e ? e instanceof Error ? e.message : typeof e == "object" && "message" in e ? String(e.message) : String(e) : "unknown error";
47
+ function S(e) {
48
+ return e ? e instanceof Error ? e.message : typeof e == "object" && "message" in e ? String(e.message) : String(e) : "unknown error";
51
49
  }
52
- function ae(e) {
53
- return e === null || typeof e != "object" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map((t) => ae(t)).join(",")}]` : `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${ae(e[t])}`).join(",")}}`;
50
+ function C(e) {
51
+ return typeof e != "object" || !e ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map((e) => C(e)).join(",")}]` : `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${C(e[t])}`).join(",")}}`;
54
52
  }
55
- function Ne(e) {
56
- let t = 2166136261;
57
- const a = ae(e);
58
- for (let i = 0; i < a.length; i++)
59
- t ^= a.charCodeAt(i), t = Math.imul(t, 16777619);
60
- return (t >>> 0).toString(16).padStart(8, "0");
53
+ function w(e) {
54
+ let t = 2166136261, n = C(e);
55
+ for (let e = 0; e < n.length; e++) t ^= n.charCodeAt(e), t = Math.imul(t, 16777619);
56
+ return (t >>> 0).toString(16).padStart(8, "0");
61
57
  }
62
- function te(e) {
63
- return e.replace(/\s+/g, " ").trim().toUpperCase();
58
+ function T(e) {
59
+ return e.replace(/\s+/g, " ").trim().toUpperCase();
64
60
  }
65
- function oe(e) {
66
- if (e.context?.skipConfirmation)
67
- return null;
68
- const t = `${te(
69
- `CONFIRM ${e.action} ${e.subject}`
70
- )} #${Ne(e.payload)}`;
71
- return te(e.context?.latestUserMessage || "").includes(te(t)) ? null : {
72
- confirmationPhrase: t,
73
- mutationExecuted: !1,
74
- preview: e.preview,
75
- requiresConfirmation: !0,
76
- success: !0
77
- };
61
+ function E(e) {
62
+ if (e.context?.skipConfirmation) return null;
63
+ let t = `${T(`CONFIRM ${e.action} ${e.subject}`)} #${w(e.payload)}`;
64
+ return T(e.context?.latestUserMessage || "").includes(T(t)) ? null : {
65
+ confirmationPhrase: t,
66
+ mutationExecuted: !1,
67
+ preview: e.preview,
68
+ requiresConfirmation: !0,
69
+ success: !0
70
+ };
78
71
  }
79
- function Ae() {
80
- return globalThis.crypto?.randomUUID?.() || `id-${Date.now()}-${Math.random().toString(36).slice(2)}`;
72
+ function D() {
73
+ return globalThis.crypto?.randomUUID?.() || `id-${Date.now()}-${Math.random().toString(36).slice(2)}`;
81
74
  }
82
- function ge(e, t = 200) {
83
- const a = [];
84
- for (let i = 0; i < e.length; i += t)
85
- a.push(e.slice(i, i + t));
86
- return a;
75
+ function O(e, t = 200) {
76
+ let n = [];
77
+ for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
78
+ return n;
87
79
  }
88
- function ne(e, t = []) {
89
- let a = e?.revalidatePath;
90
- if (!a)
91
- try {
92
- a = require("next/cache").revalidatePath;
93
- } catch {
94
- return;
95
- }
96
- try {
97
- a("/", "layout");
98
- for (const i of t)
99
- a(i);
100
- } catch {
101
- }
80
+ function k(e, t = []) {
81
+ let n = e?.revalidatePath;
82
+ n ||= u;
83
+ try {
84
+ n("/", "layout");
85
+ for (let e of t) n(e);
86
+ } catch {}
102
87
  }
103
- async function De(e, t) {
104
- const { data: a, error: i } = await e.from("site_settings").select("key, value").in("key", [...t]);
105
- if (i)
106
- throw new Error(`Could not read the site settings: ${y(i)}`);
107
- return new Map((Array.isArray(a) ? a : []).map((r) => [r.key, r.value]));
88
+ async function ee(e, t) {
89
+ let { data: n, error: r } = await e.from("site_settings").select("key, value").in("key", [...t]);
90
+ if (r) throw Error(`Could not read the site settings: ${S(r)}`);
91
+ return new Map((Array.isArray(n) ? n : []).map((e) => [e.key, e.value]));
108
92
  }
109
- async function k(e, t, a) {
110
- const { error: i } = await e.from("site_settings").upsert({ key: t, value: a });
111
- if (i)
112
- throw new Error(`Could not save the "${t}" setting: ${y(i)}`);
93
+ async function A(e, t, n) {
94
+ let { error: r } = await e.from("site_settings").upsert({
95
+ key: t,
96
+ value: n
97
+ });
98
+ if (r) throw Error(`Could not save the "${t}" setting: ${S(r)}`);
113
99
  }
114
- async function N(e, t, a, i) {
115
- let r = 0;
116
- for (const o of ge(i)) {
117
- const { error: l } = await e.from(t).delete().in(a, o);
118
- if (l)
119
- throw new Error(`Could not delete from ${t}: ${y(l)}`);
120
- r += o.length;
121
- }
122
- return r;
100
+ async function j(e, t, n, r) {
101
+ let i = 0;
102
+ for (let a of O(r)) {
103
+ let { error: r } = await e.from(t).delete().in(n, a);
104
+ if (r) throw Error(`Could not delete from ${t}: ${S(r)}`);
105
+ i += a.length;
106
+ }
107
+ return i;
123
108
  }
124
- function Be(e) {
125
- return !e || typeof e != "object" ? !1 : Object.values(e).some(
126
- (t) => typeof t == "string" && t.toLowerCase().includes(Ie)
127
- );
109
+ function te(e) {
110
+ return !e || typeof e != "object" ? !1 : Object.values(e).some((e) => typeof e == "string" && e.toLowerCase().includes(v));
128
111
  }
129
- async function re(e) {
130
- const { data: t, error: a } = await e.from("site_settings").select("value").eq("key", Q).maybeSingle();
131
- return a ? null : ue(t?.value);
112
+ async function M(e) {
113
+ let { data: t, error: r } = await e.from("site_settings").select("value").eq("key", n).maybeSingle();
114
+ return r ? null : s(t?.value);
132
115
  }
133
- const me = u.strictObject({
134
- brief: de.describe(
135
- 'The fields you learned. With mode "merge" (default) they are layered over the saved brief, so you can save after every answer.'
136
- ),
137
- mode: u.enum(["merge", "replace"]).default("merge")
116
+ var N = e.strictObject({
117
+ brief: i.describe("The fields you learned. With mode \"merge\" (default) they are layered over the saved brief, so you can save after every answer."),
118
+ mode: e.enum(["merge", "replace"]).default("merge")
138
119
  });
139
- async function Z(e, t) {
140
- const a = me.parse(e), i = L(t), r = a.mode === "merge" ? await re(i) : null, o = new Set(Object.keys(e.brief ?? {})), l = Object.fromEntries(
141
- Object.entries(a.brief).filter(([m]) => o.has(m))
142
- ), d = Te.parse({
143
- ...r ?? {},
144
- ...l,
145
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
146
- });
147
- return await k(i, Q, d), {
148
- brief: d,
149
- created: !r,
150
- mutationExecuted: !0,
151
- success: !0
152
- };
120
+ async function P(e, t) {
121
+ let r = N.parse(e), i = x(t), o = r.mode === "merge" ? await M(i) : null, s = new Set(Object.keys(e.brief ?? {})), c = Object.fromEntries(Object.entries(r.brief).filter(([e]) => s.has(e))), l = a.parse({
122
+ ...o ?? {},
123
+ ...c,
124
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
125
+ });
126
+ return await A(i, n, l), {
127
+ brief: l,
128
+ created: !o,
129
+ mutationExecuted: !0,
130
+ success: !0
131
+ };
153
132
  }
154
- async function pe(e) {
155
- const { data: t, error: a } = await e.from("site_settings").select("value").eq("key", F).maybeSingle();
156
- if (a)
157
- return null;
158
- const i = ce.safeParse(t?.value);
159
- return i.success ? i.data : null;
133
+ async function F(e) {
134
+ let { data: n, error: i } = await e.from("site_settings").select("value").eq("key", t).maybeSingle();
135
+ if (i) return null;
136
+ let a = r.safeParse(n?.value);
137
+ return a.success ? a.data : null;
160
138
  }
161
- async function Ze(e, t) {
162
- const a = await pe(e);
163
- return Ee(a, { actorUserId: t }) ? a : null;
139
+ async function I(e, t) {
140
+ let n = await F(e);
141
+ return o(n, { actorUserId: t }) ? n : null;
164
142
  }
165
- async function Re(e) {
166
- const { error: t } = await e.from("site_settings").delete().eq("key", F);
167
- if (t)
168
- throw new Error(`Could not close the build session: ${y(t)}`);
143
+ async function L(e) {
144
+ let { error: n } = await e.from("site_settings").delete().eq("key", t);
145
+ if (n) throw Error(`Could not close the build session: ${S(n)}`);
169
146
  }
170
- const fe = u.strictObject({
171
- includeMedia: u.boolean().default(!1).describe("Also list the most recent media library entries (id, file name, alt text)."),
172
- includeNavigation: u.boolean().default(!0),
173
- limit: u.number().int().min(10).max(300).default(120).describe("Maximum pages, posts, and products to list.")
147
+ var R = e.strictObject({
148
+ includeMedia: e.boolean().default(!1).describe("Also list the most recent media library entries (id, file name, alt text)."),
149
+ includeNavigation: e.boolean().default(!0),
150
+ limit: e.number().int().min(10).max(300).default(120).describe("Maximum pages, posts, and products to list.")
174
151
  });
175
- function Oe(e, t) {
176
- const a = { footer: {}, header: {} }, i = /* @__PURE__ */ new Map();
177
- for (const o of e) {
178
- const l = String(o.menu_key).toUpperCase() === "FOOTER" ? "footer" : "header";
179
- i.set(Number(o.id), {
180
- children: [],
181
- id: Number(o.id),
182
- label: String(o.label ?? ""),
183
- languageCode: t.get(Number(o.language_id)) ?? String(o.language_id),
184
- menu: l,
185
- order: Number(o.order ?? 0),
186
- parentId: o.parent_id === null || o.parent_id === void 0 ? null : Number(o.parent_id),
187
- url: String(o.url ?? "")
188
- });
189
- }
190
- const r = [...i.values()].sort((o, l) => o.order - l.order);
191
- for (const o of r) {
192
- const l = o.parentId === null ? null : i.get(o.parentId);
193
- if (l) {
194
- l.children.push({ children: o.children, id: o.id, label: o.label, url: o.url });
195
- continue;
196
- }
197
- (a[o.menu][o.languageCode] ??= []).push({ children: o.children, id: o.id, label: o.label, url: o.url });
198
- }
199
- return a;
152
+ function ne(e, t) {
153
+ let n = {
154
+ footer: {},
155
+ header: {}
156
+ }, r = /* @__PURE__ */ new Map();
157
+ for (let n of e) {
158
+ let e = String(n.menu_key).toUpperCase() === "FOOTER" ? "footer" : "header";
159
+ r.set(Number(n.id), {
160
+ children: [],
161
+ id: Number(n.id),
162
+ label: String(n.label ?? ""),
163
+ languageCode: t.get(Number(n.language_id)) ?? String(n.language_id),
164
+ menu: e,
165
+ order: Number(n.order ?? 0),
166
+ parentId: n.parent_id === null || n.parent_id === void 0 ? null : Number(n.parent_id),
167
+ url: String(n.url ?? "")
168
+ });
169
+ }
170
+ let i = [...r.values()].sort((e, t) => e.order - t.order);
171
+ for (let e of i) {
172
+ let t = e.parentId === null ? null : r.get(e.parentId);
173
+ if (t) {
174
+ t.children.push({
175
+ children: e.children,
176
+ id: e.id,
177
+ label: e.label,
178
+ url: e.url
179
+ });
180
+ continue;
181
+ }
182
+ (n[e.menu][e.languageCode] ??= []).push({
183
+ children: e.children,
184
+ id: e.id,
185
+ label: e.label,
186
+ url: e.url
187
+ });
188
+ }
189
+ return n;
200
190
  }
201
- async function Le(e, t) {
202
- const a = fe.parse(e), i = L(t), [r, o, l, d, m, c, p] = await Promise.all([
203
- i.from("languages").select("id, code, name, is_default, is_active").order("id"),
204
- De(i, [...xe, Q, F]),
205
- // `count: 'exact'` so the totals are the site's, not the capped list's.
206
- i.from("pages").select("id, slug, title, status, language_id, translation_group_id, author_id, updated_at", { count: "exact" }).order("id").limit(a.limit),
207
- i.from("posts").select("id, slug, title, status, language_id, translation_group_id, author_id, published_at", { count: "exact" }).order("id").limit(a.limit),
208
- i.from("site_themes").select("slug, name, is_default, is_active, color_scheme").order("sort_order"),
209
- i.from("custom_block_definitions").select("slug, name, fields").order("name"),
210
- i.from("content_drafts").select("parent_type, parent_id, updated_at")
211
- ]);
212
- for (const [s, h] of [
213
- ["languages", r],
214
- ["pages", l],
215
- ["posts", d],
216
- ["themes", m],
217
- ["custom blocks", c],
218
- ["drafts", p]
219
- ])
220
- if (h?.error)
221
- throw new Error(`Could not read the ${s}: ${y(h.error)}`);
222
- const f = r.data ?? [], S = new Map(f.map((s) => [Number(s.id), String(s.code)])), P = f.find((s) => s.is_default) ?? f[0] ?? null;
223
- let T = [];
224
- try {
225
- const { data: s } = await i.from("products").select("id, slug, title, status, language_id").order("created_at", { ascending: !1 }).limit(a.limit);
226
- T = Array.isArray(s) ? s : [];
227
- } catch {
228
- T = [];
229
- }
230
- const E = /* @__PURE__ */ new Map();
231
- {
232
- const { data: s } = await i.from("blocks").select("page_id, post_id").limit(5e3);
233
- for (const h of Array.isArray(s) ? s : []) {
234
- const _ = h.page_id ? `page:${h.page_id}` : h.post_id ? `post:${h.post_id}` : null;
235
- _ && E.set(_, (E.get(_) ?? 0) + 1);
236
- }
237
- }
238
- let Y = null;
239
- if (a.includeNavigation) {
240
- const { data: s, error: h } = await i.from("navigation_items").select("id, label, url, menu_key, language_id, parent_id, order, page_id").order("order");
241
- if (h)
242
- throw new Error(`Could not read the navigation: ${y(h)}`);
243
- Y = Oe(Array.isArray(s) ? s : [], S);
244
- }
245
- const { data: W } = await i.from("media").select("id, object_key, file_name, description, created_at").order("created_at", { ascending: !1 }).limit(500), w = Array.isArray(W) ? W : [], C = w.filter((s) => V.has(String(s.object_key))).length, { data: I } = await i.from("logos").select("id, name, media_id, created_at").order("created_at", { ascending: !1 }), j = Array.isArray(I) ? I : [], M = typeof o.get("active_logo_id") == "string" ? o.get("active_logo_id") : null, v = (M ? j.find((s) => s.id === M) : null) ?? j[0] ?? null, D = v ? w.find((s) => s.id === v.media_id) ?? null : null, B = D ? String(D.object_key) : null, R = ke(o.get(H)), X = R ? { mediaId: R.media_id, objectKey: R.object_key, url: R.url } : null, x = (l.data ?? []).map((s) => ({
246
- blockCount: E.get(`page:${s.id}`) ?? 0,
247
- id: Number(s.id),
248
- isHome: s.slug === A && (!P || Number(s.language_id) === Number(P.id)),
249
- isSeeded: ie.has(String(s.translation_group_id)),
250
- languageCode: S.get(Number(s.language_id)) ?? String(s.language_id),
251
- slug: String(s.slug),
252
- status: String(s.status),
253
- title: String(s.title ?? ""),
254
- translationGroupId: s.translation_group_id ? String(s.translation_group_id) : null
255
- })), K = (d.data ?? []).map((s) => ({
256
- blockCount: E.get(`post:${s.id}`) ?? 0,
257
- id: Number(s.id),
258
- isSeeded: ie.has(String(s.translation_group_id)),
259
- languageCode: S.get(Number(s.language_id)) ?? String(s.language_id),
260
- publishedAt: s.published_at ?? null,
261
- slug: String(s.slug),
262
- status: String(s.status),
263
- title: String(s.title ?? ""),
264
- translationGroupId: s.translation_group_id ? String(s.translation_group_id) : null
265
- })), U = typeof o.get("site_title") == "string" ? o.get("site_title") : "", z = o.get("footer_copyright"), b = {
266
- copyright: Be(z),
267
- logo: !!(B && V.has(B)),
268
- media: C,
269
- pages: x.filter((s) => s.isSeeded).length,
270
- posts: K.filter((s) => s.isSeeded).length,
271
- siteTitle: U.trim() === Ce
272
- }, J = b.copyright || b.logo || b.media > 0 || b.pages > 0 || b.posts > 0 || b.siteTitle, q = ue(o.get(Q)), G = ce.safeParse(o.get(F)), $ = G.success ? G.data : null, n = x.find((s) => s.isHome) ?? null, g = [];
273
- return n ? n.blockCount === 0 && g.push("The home page exists but has no blocks. Fill it with rewrite_page_draft then publish_content_draft.") : g.push(
274
- `There is no "${A}" page in the default language, so "/" returns 404. Create one with create_cms_page (slug "${A}", status "published").`
275
- ), J && g.push(
276
- `NextBlock demo content is still present (${b.pages} seeded pages, ${b.posts} seeded posts, ${b.media} bundled images${b.logo ? ", the NextBlock logo" : ""}${b.siteTitle ? ", the default site title" : ""}${b.copyright ? ", the default copyright" : ""}). Remove it with reset_site_content, or pass reset to start_site_build.`
277
- ), q || g.push("No site brief is saved yet. Interview the client and record the answers with save_site_brief."), {
278
- brief: q,
279
- buildSession: $ ? { expiresAt: $.expiresAt, id: $.id, summary: $.summary } : null,
280
- counts: {
281
- customBlocks: (c.data ?? []).length,
282
- drafts: (p.data ?? []).length,
283
- media: w.length,
284
- pages: typeof l.count == "number" ? l.count : x.length,
285
- posts: typeof d.count == "number" ? d.count : K.length,
286
- products: T.length
287
- },
288
- customBlocks: (c.data ?? []).map((s) => ({
289
- fieldCount: Array.isArray(s.fields) ? s.fields.length : 0,
290
- fields: Array.isArray(s.fields) ? s.fields.map((h) => ({ key: h?.key, required: h?.required === !0, type: h?.type })) : [],
291
- name: String(s.name ?? ""),
292
- slug: String(s.slug)
293
- })),
294
- drafts: (p.data ?? []).map((s) => ({
295
- parentId: Number(s.parent_id),
296
- parentType: String(s.parent_type)
297
- })),
298
- homePage: n,
299
- identity: {
300
- activeLogo: v ? {
301
- id: String(v.id),
302
- isSeeded: b.logo,
303
- name: String(v.name ?? ""),
304
- objectKey: B
305
- } : null,
306
- footerCopyright: z ?? null,
307
- footerShowAttribution: o.get("footer_show_attribution") !== !1,
308
- siteDescription: typeof o.get("site_description") == "string" ? o.get("site_description") : "",
309
- siteKeywords: typeof o.get("site_keywords") == "string" ? o.get("site_keywords") : "",
310
- siteTitle: U,
311
- socialImage: X
312
- },
313
- languages: f.map((s) => ({
314
- code: String(s.code),
315
- id: Number(s.id),
316
- isActive: s.is_active !== !1,
317
- isDefault: s.is_default === !0,
318
- name: String(s.name ?? "")
319
- })),
320
- media: {
321
- count: w.length,
322
- sample: a.includeMedia ? w.slice(0, 40).map((s) => ({
323
- altText: s.description ?? null,
324
- fileName: s.file_name ?? null,
325
- id: String(s.id),
326
- isSeeded: V.has(String(s.object_key))
327
- })) : void 0,
328
- seededCount: C
329
- },
330
- navigation: Y,
331
- nextSteps: g,
332
- pages: x,
333
- posts: K,
334
- products: T.map((s) => ({
335
- id: String(s.id),
336
- languageCode: S.get(Number(s.language_id)) ?? String(s.language_id),
337
- slug: String(s.slug),
338
- status: String(s.status),
339
- title: String(s.title ?? "")
340
- })),
341
- seeded: { ...b, anyPresent: J },
342
- success: !0,
343
- themes: (m.data ?? []).map((s) => ({
344
- colorScheme: String(s.color_scheme ?? "light"),
345
- isActive: s.is_active !== !1,
346
- isDefault: s.is_default === !0,
347
- name: String(s.name ?? ""),
348
- slug: String(s.slug)
349
- }))
350
- };
191
+ async function z(e, i) {
192
+ let a = R.parse(e), o = x(i), [c, l, u, p, m, v, C] = await Promise.all([
193
+ o.from("languages").select("id, code, name, is_default, is_active").order("id"),
194
+ ee(o, [
195
+ ...b,
196
+ n,
197
+ t
198
+ ]),
199
+ o.from("pages").select("id, slug, title, status, language_id, translation_group_id, author_id, updated_at", { count: "exact" }).order("id").limit(a.limit),
200
+ o.from("posts").select("id, slug, title, status, language_id, translation_group_id, author_id, published_at", { count: "exact" }).order("id").limit(a.limit),
201
+ o.from("site_themes").select("slug, name, is_default, is_active, color_scheme").order("sort_order"),
202
+ o.from("custom_block_definitions").select("slug, name, fields").order("name"),
203
+ o.from("content_drafts").select("parent_type, parent_id, updated_at")
204
+ ]);
205
+ for (let [e, t] of [
206
+ ["languages", c],
207
+ ["pages", u],
208
+ ["posts", p],
209
+ ["themes", m],
210
+ ["custom blocks", v],
211
+ ["drafts", C]
212
+ ]) if (t?.error) throw Error(`Could not read the ${e}: ${S(t.error)}`);
213
+ let w = c.data ?? [], T = new Map(w.map((e) => [Number(e.id), String(e.code)])), E = w.find((e) => e.is_default) ?? w[0] ?? null, D = [];
214
+ try {
215
+ let { data: e } = await o.from("products").select("id, slug, title, status, language_id").order("created_at", { ascending: !1 }).limit(a.limit);
216
+ D = Array.isArray(e) ? e : [];
217
+ } catch {
218
+ D = [];
219
+ }
220
+ let O = /* @__PURE__ */ new Map();
221
+ {
222
+ let { data: e } = await o.from("blocks").select("page_id, post_id").limit(5e3);
223
+ for (let t of Array.isArray(e) ? e : []) {
224
+ let e = t.page_id ? `page:${t.page_id}` : t.post_id ? `post:${t.post_id}` : null;
225
+ e && O.set(e, (O.get(e) ?? 0) + 1);
226
+ }
227
+ }
228
+ let k = null;
229
+ if (a.includeNavigation) {
230
+ let { data: e, error: t } = await o.from("navigation_items").select("id, label, url, menu_key, language_id, parent_id, order, page_id").order("order");
231
+ if (t) throw Error(`Could not read the navigation: ${S(t)}`);
232
+ k = ne(Array.isArray(e) ? e : [], T);
233
+ }
234
+ let { data: A } = await o.from("media").select("id, object_key, file_name, description, created_at").order("created_at", { ascending: !1 }).limit(500), j = Array.isArray(A) ? A : [], M = j.filter((e) => g.has(String(e.object_key))).length, { data: N } = await o.from("logos").select("id, name, media_id, created_at").order("created_at", { ascending: !1 }), P = Array.isArray(N) ? N : [], F = typeof l.get("active_logo_id") == "string" ? l.get("active_logo_id") : null, I = (F ? P.find((e) => e.id === F) : null) ?? P[0] ?? null, L = I ? j.find((e) => e.id === I.media_id) ?? null : null, z = L ? String(L.object_key) : null, B = f(l.get(d)), re = B ? {
235
+ mediaId: B.media_id,
236
+ objectKey: B.object_key,
237
+ url: B.url
238
+ } : null, V = (u.data ?? []).map((e) => ({
239
+ blockCount: O.get(`page:${e.id}`) ?? 0,
240
+ id: Number(e.id),
241
+ isHome: e.slug === y && (!E || Number(e.language_id) === Number(E.id)),
242
+ isSeeded: h.has(String(e.translation_group_id)),
243
+ languageCode: T.get(Number(e.language_id)) ?? String(e.language_id),
244
+ slug: String(e.slug),
245
+ status: String(e.status),
246
+ title: String(e.title ?? ""),
247
+ translationGroupId: e.translation_group_id ? String(e.translation_group_id) : null
248
+ })), H = (p.data ?? []).map((e) => ({
249
+ blockCount: O.get(`post:${e.id}`) ?? 0,
250
+ id: Number(e.id),
251
+ isSeeded: h.has(String(e.translation_group_id)),
252
+ languageCode: T.get(Number(e.language_id)) ?? String(e.language_id),
253
+ publishedAt: e.published_at ?? null,
254
+ slug: String(e.slug),
255
+ status: String(e.status),
256
+ title: String(e.title ?? ""),
257
+ translationGroupId: e.translation_group_id ? String(e.translation_group_id) : null
258
+ })), U = typeof l.get("site_title") == "string" ? l.get("site_title") : "", W = l.get("footer_copyright"), G = {
259
+ copyright: te(W),
260
+ logo: !!(z && g.has(z)),
261
+ media: M,
262
+ pages: V.filter((e) => e.isSeeded).length,
263
+ posts: H.filter((e) => e.isSeeded).length,
264
+ siteTitle: U.trim() === _
265
+ }, K = G.copyright || G.logo || G.media > 0 || G.pages > 0 || G.posts > 0 || G.siteTitle, q = s(l.get(n)), J = r.safeParse(l.get(t)), Y = J.success ? J.data : null, X = V.find((e) => e.isHome) ?? null, Z = [];
266
+ return X ? X.blockCount === 0 && Z.push("The home page exists but has no blocks. Fill it with rewrite_page_draft then publish_content_draft.") : Z.push(`There is no "${y}" page in the default language, so "/" returns 404. Create one with create_cms_page (slug "${y}", status "published").`), K && Z.push(`NextBlock demo content is still present (${G.pages} seeded pages, ${G.posts} seeded posts, ${G.media} bundled images${G.logo ? ", the NextBlock logo" : ""}${G.siteTitle ? ", the default site title" : ""}${G.copyright ? ", the default copyright" : ""}). Remove it with reset_site_content, or pass reset to start_site_build.`), q || Z.push("No site brief is saved yet. Interview the client and record the answers with save_site_brief."), {
267
+ brief: q,
268
+ buildSession: Y ? {
269
+ expiresAt: Y.expiresAt,
270
+ id: Y.id,
271
+ summary: Y.summary
272
+ } : null,
273
+ counts: {
274
+ customBlocks: (v.data ?? []).length,
275
+ drafts: (C.data ?? []).length,
276
+ media: j.length,
277
+ pages: typeof u.count == "number" ? u.count : V.length,
278
+ posts: typeof p.count == "number" ? p.count : H.length,
279
+ products: D.length
280
+ },
281
+ customBlocks: (v.data ?? []).map((e) => ({
282
+ fieldCount: Array.isArray(e.fields) ? e.fields.length : 0,
283
+ fields: Array.isArray(e.fields) ? e.fields.map((e) => ({
284
+ key: e?.key,
285
+ required: e?.required === !0,
286
+ type: e?.type
287
+ })) : [],
288
+ name: String(e.name ?? ""),
289
+ slug: String(e.slug)
290
+ })),
291
+ drafts: (C.data ?? []).map((e) => ({
292
+ parentId: Number(e.parent_id),
293
+ parentType: String(e.parent_type)
294
+ })),
295
+ homePage: X,
296
+ identity: {
297
+ activeLogo: I ? {
298
+ id: String(I.id),
299
+ isSeeded: G.logo,
300
+ name: String(I.name ?? ""),
301
+ objectKey: z
302
+ } : null,
303
+ footerCopyright: W ?? null,
304
+ footerShowAttribution: l.get("footer_show_attribution") !== !1,
305
+ siteDescription: typeof l.get("site_description") == "string" ? l.get("site_description") : "",
306
+ siteKeywords: typeof l.get("site_keywords") == "string" ? l.get("site_keywords") : "",
307
+ siteTitle: U,
308
+ socialImage: re
309
+ },
310
+ languages: w.map((e) => ({
311
+ code: String(e.code),
312
+ id: Number(e.id),
313
+ isActive: e.is_active !== !1,
314
+ isDefault: e.is_default === !0,
315
+ name: String(e.name ?? "")
316
+ })),
317
+ media: {
318
+ count: j.length,
319
+ sample: a.includeMedia ? j.slice(0, 40).map((e) => ({
320
+ altText: e.description ?? null,
321
+ fileName: e.file_name ?? null,
322
+ id: String(e.id),
323
+ isSeeded: g.has(String(e.object_key))
324
+ })) : void 0,
325
+ seededCount: M
326
+ },
327
+ navigation: k,
328
+ nextSteps: Z,
329
+ pages: V,
330
+ posts: H,
331
+ products: D.map((e) => ({
332
+ id: String(e.id),
333
+ languageCode: T.get(Number(e.language_id)) ?? String(e.language_id),
334
+ slug: String(e.slug),
335
+ status: String(e.status),
336
+ title: String(e.title ?? "")
337
+ })),
338
+ seeded: {
339
+ ...G,
340
+ anyPresent: K
341
+ },
342
+ success: !0,
343
+ themes: (m.data ?? []).map((e) => ({
344
+ colorScheme: String(e.color_scheme ?? "light"),
345
+ isActive: e.is_active !== !1,
346
+ isDefault: e.is_default === !0,
347
+ name: String(e.name ?? ""),
348
+ slug: String(e.slug)
349
+ }))
350
+ };
351
351
  }
352
- const Pe = 30;
353
- function et(e) {
354
- const { counts: t, seeded: a } = e, i = [];
355
- i.push(
356
- `Counts: ${t.pages} pages, ${t.posts} posts, ${t.products} products, ${t.media} media, ${t.customBlocks} custom blocks, ${t.drafts} drafts.`
357
- );
358
- const r = e.languages.filter((c) => c.isActive), o = (r.length > 0 ? r : e.languages).map((c) => `${c.code}${c.isDefault ? " (default)" : ""}`).join(", ");
359
- if (i.push(`Languages: ${o || "none"}.`), a.anyPresent) {
360
- const c = [
361
- a.pages > 0 ? `${a.pages} demo pages` : null,
362
- a.posts > 0 ? `${a.posts} demo posts` : null,
363
- a.media > 0 ? `${a.media} bundled images` : null,
364
- a.logo ? "the NextBlock logo" : null,
365
- a.siteTitle ? "the default site title" : null,
366
- a.copyright ? "the default copyright" : null
367
- ].filter((p) => !!p);
368
- i.push(`NextBlock demo content: present (${c.join(", ")}).`);
369
- } else
370
- i.push("NextBlock demo content: none detected.");
371
- const l = e.homePage;
372
- i.push(
373
- l ? `Home page: "${l.title}" (/${l.slug}) ${l.status}, ${l.blockCount} blocks${l.isSeeded ? ", seeded demo content" : ""}.` : 'Home page: missing in the default language ("/" returns 404).'
374
- );
375
- const d = e.identity, m = d.activeLogo ? `logo "${d.activeLogo.name || d.activeLogo.id}"${d.activeLogo.isSeeded ? " (NextBlock demo logo)" : ""}` : "no logo";
376
- if (i.push(`Site title: ${d.siteTitle ? `"${d.siteTitle}"` : "not set"}; ${m}.`), i.push(
377
- d.socialImage ? "Social preview image: set." : "Social preview image: not set (link previews show the NextBlock banner; set one with update_site_identity social_image)."
378
- ), e.themes.length > 0 && i.push(
379
- `Themes: ${e.themes.map(
380
- (c) => `${c.name || c.slug} (${c.colorScheme}${c.isDefault ? ", default" : ""}${c.isActive ? "" : ", inactive"})`
381
- ).join("; ")}.`
382
- ), i.push(e.brief ? `Site brief: saved (status ${e.brief.status}).` : "Site brief: none saved."), i.push(
383
- e.buildSession ? `Build session: active until ${e.buildSession.expiresAt}.` : "Build session: none."
384
- ), e.pages.length > 0) {
385
- const c = e.pages.slice(0, Pe), p = Math.max(t.pages, e.pages.length) - c.length;
386
- i.push(
387
- `Pages: ${c.map((f) => `${f.title || f.slug} (/${f.slug}) [${f.languageCode}]`).join(", ")}${p > 0 ? `, +${p} more` : ""}.`
388
- );
389
- } else
390
- i.push("Pages: none.");
391
- return i.join(`
392
- `);
352
+ var B = 30;
353
+ function re(e) {
354
+ let { counts: t, seeded: n } = e, r = [];
355
+ r.push(`Counts: ${t.pages} pages, ${t.posts} posts, ${t.products} products, ${t.media} media, ${t.customBlocks} custom blocks, ${t.drafts} drafts.`);
356
+ let i = e.languages.filter((e) => e.isActive), a = (i.length > 0 ? i : e.languages).map((e) => `${e.code}${e.isDefault ? " (default)" : ""}`).join(", ");
357
+ if (r.push(`Languages: ${a || "none"}.`), n.anyPresent) {
358
+ let e = [
359
+ n.pages > 0 ? `${n.pages} demo pages` : null,
360
+ n.posts > 0 ? `${n.posts} demo posts` : null,
361
+ n.media > 0 ? `${n.media} bundled images` : null,
362
+ n.logo ? "the NextBlock logo" : null,
363
+ n.siteTitle ? "the default site title" : null,
364
+ n.copyright ? "the default copyright" : null
365
+ ].filter((e) => !!e);
366
+ r.push(`NextBlock demo content: present (${e.join(", ")}).`);
367
+ } else r.push("NextBlock demo content: none detected.");
368
+ let o = e.homePage;
369
+ r.push(o ? `Home page: "${o.title}" (/${o.slug}) ${o.status}, ${o.blockCount} blocks${o.isSeeded ? ", seeded demo content" : ""}.` : "Home page: missing in the default language (\"/\" returns 404).");
370
+ let s = e.identity, c = s.activeLogo ? `logo "${s.activeLogo.name || s.activeLogo.id}"${s.activeLogo.isSeeded ? " (NextBlock demo logo)" : ""}` : "no logo";
371
+ if (r.push(`Site title: ${s.siteTitle ? `"${s.siteTitle}"` : "not set"}; ${c}.`), r.push(s.socialImage ? "Social preview image: set." : "Social preview image: not set (link previews show the NextBlock banner; set one with update_site_identity social_image)."), e.themes.length > 0 && r.push(`Themes: ${e.themes.map((e) => `${e.name || e.slug} (${e.colorScheme}${e.isDefault ? ", default" : ""}${e.isActive ? "" : ", inactive"})`).join("; ")}.`), r.push(e.brief ? `Site brief: saved (status ${e.brief.status}).` : "Site brief: none saved."), r.push(e.buildSession ? `Build session: active until ${e.buildSession.expiresAt}.` : "Build session: none."), e.pages.length > 0) {
372
+ let n = e.pages.slice(0, B), i = Math.max(t.pages, e.pages.length) - n.length;
373
+ r.push(`Pages: ${n.map((e) => `${e.title || e.slug} (/${e.slug}) [${e.languageCode}]`).join(", ")}${i > 0 ? `, +${i} more` : ""}.`);
374
+ } else r.push("Pages: none.");
375
+ return r.join("\n");
393
376
  }
394
- const he = u.strictObject({
395
- active_logo_id: u.string().uuid().nullable().optional().describe("Pin a logos.id as the active logo, or null to fall back to the newest logo."),
396
- footer_copyright: u.record(u.string().trim().min(2).max(12), u.string().trim().min(1).max(500)).optional().describe('Copyright line per locale code; "{year}" is replaced with the current year. Example: { "en": "© {year} Acme Bakery", "fr": "© {year} Boulangerie Acme" }.'),
397
- footer_show_attribution: u.boolean().optional().describe('Whether the "Published with NextBlock" credit shows in the footer. Set false when the client wants no NextBlock mention.'),
398
- site_description: u.string().trim().max(500).optional().describe("Default meta description and header tagline."),
399
- site_keywords: u.string().trim().max(500).optional().describe("Comma-separated SEO keywords."),
400
- site_title: u.string().trim().min(1).max(160).optional().describe("The brand name shown in the header and <title>."),
401
- social_image: u.string().trim().min(1).max(2048).nullable().optional().describe(
402
- "The site-wide social preview image (Open Graph / Twitter card) for every page, post or product without a feature image of its own — the home page above all, which must NOT get a feature image (on a page that renders a full-width title banner above the hero). A media library id (from list_media or upload_media) or an https image URL, hotlinked as-is (a search_stock_photos `url` works). Use a wide landscape image, ideally 1200×630. Null clears it and the NextBlock banner is used."
403
- )
404
- }).refine((e) => Object.values(e).some((t) => t !== void 0), {
405
- message: "Provide at least one identity field to update."
406
- });
407
- async function je(e, t) {
408
- const a = he.parse(e);
409
- await se(t, ["ADMIN", "WRITER"], "Updating the site identity");
410
- const i = L(t), r = Object.entries(a).filter(([, d]) => d !== void 0), o = oe({
411
- action: "UPDATE SITE IDENTITY",
412
- context: t,
413
- payload: { input: a, tool: "update_site_identity" },
414
- preview: {
415
- changes: Object.fromEntries(r),
416
- summary: `Update ${r.map(([d]) => d).join(", ")} for the whole site.`
417
- },
418
- subject: r.map(([d]) => d).join(" ")
419
- });
420
- if (o)
421
- return o;
422
- const l = [];
423
- for (const [d, m] of r)
424
- l.push(
425
- d === "social_image" ? [H, await Ke(i, m)] : [d, m]
426
- );
427
- for (const [d, m] of l)
428
- await k(i, d, m);
429
- return ne(t, ["/cms/settings/logos", "/cms/settings/copyright"]), {
430
- mutationExecuted: !0,
431
- success: !0,
432
- updatedKeys: l.map(([d]) => d)
433
- };
377
+ var V = e.strictObject({
378
+ active_logo_id: e.string().uuid().nullable().optional().describe("Pin a logos.id as the active logo, or null to fall back to the newest logo."),
379
+ footer_copyright: e.record(e.string().trim().min(2).max(12), e.string().trim().min(1).max(500)).optional().describe("Copyright line per locale code; \"{year}\" is replaced with the current year. Example: { \"en\": \"© {year} Acme Bakery\", \"fr\": \"© {year} Boulangerie Acme\" }."),
380
+ footer_show_attribution: e.boolean().optional().describe("Whether the \"Published with NextBlock\" credit shows in the footer. Set false when the client wants no NextBlock mention."),
381
+ site_description: e.string().trim().max(500).optional().describe("Default meta description and header tagline."),
382
+ site_keywords: e.string().trim().max(500).optional().describe("Comma-separated SEO keywords."),
383
+ site_title: e.string().trim().min(1).max(160).optional().describe("The brand name shown in the header and <title>."),
384
+ social_image: e.string().trim().min(1).max(2048).nullable().optional().describe("The site-wide social preview image (Open Graph / Twitter card) for every page, post or product without a feature image of its own — the home page above all, which must NOT get a feature image (on a page that renders a full-width title banner above the hero). A media library id (from list_media or upload_media) or an https image URL, hotlinked as-is (a search_stock_photos `url` works). Use a wide landscape image, ideally 1200×630. Null clears it and the NextBlock banner is used.")
385
+ }).refine((e) => Object.values(e).some((e) => e !== void 0), { message: "Provide at least one identity field to update." });
386
+ async function H(e, t) {
387
+ let n = V.parse(e);
388
+ await c(t, ["ADMIN", "WRITER"], "Updating the site identity");
389
+ let r = x(t), i = Object.entries(n).filter(([, e]) => e !== void 0), a = E({
390
+ action: "UPDATE SITE IDENTITY",
391
+ context: t,
392
+ payload: {
393
+ input: n,
394
+ tool: "update_site_identity"
395
+ },
396
+ preview: {
397
+ changes: Object.fromEntries(i),
398
+ summary: `Update ${i.map(([e]) => e).join(", ")} for the whole site.`
399
+ },
400
+ subject: i.map(([e]) => e).join(" ")
401
+ });
402
+ if (a) return a;
403
+ let o = [];
404
+ for (let [e, t] of i) o.push(e === "social_image" ? [d, await W(r, t)] : [e, t]);
405
+ for (let [e, t] of o) await A(r, e, t);
406
+ return k(t, ["/cms/settings/logos", "/cms/settings/copyright"]), {
407
+ mutationExecuted: !0,
408
+ success: !0,
409
+ updatedKeys: o.map(([e]) => e)
410
+ };
434
411
  }
435
- const Me = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
436
- async function Ke(e, t) {
437
- if (t === null)
438
- return null;
439
- const a = t.trim();
440
- if (/^https?:\/\//i.test(a))
441
- return { alt: null, height: null, media_id: null, object_key: null, url: a, width: null };
442
- if (!Me.test(a))
443
- throw new Error(`"${a}" is not a usable social image — provide an https:// image URL or a media library id.`);
444
- const { data: i, error: r } = await e.from("media").select("id, object_key, file_path, width, height, description, variants").eq("id", a).maybeSingle();
445
- if (r)
446
- throw new Error(`Could not read media ${a}: ${y(r)}`);
447
- if (!i)
448
- throw new Error(`No media library item has the id ${a}. Call list_media to find one, or upload_media to import an image first.`);
449
- const o = ve(i), l = $e(i);
450
- if (!l)
451
- throw new Error(`Media ${a} has no usable file to serve as the social image.`);
452
- return {
453
- alt: typeof i.description == "string" && i.description.trim() ? i.description.trim() : null,
454
- height: o?.height ?? (typeof i.height == "number" ? i.height : null),
455
- media_id: String(i.id),
456
- object_key: l,
457
- url: null,
458
- width: o?.width ?? (typeof i.width == "number" ? i.width : null)
459
- };
412
+ var U = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
413
+ async function W(e, t) {
414
+ if (t === null) return null;
415
+ let n = t.trim();
416
+ if (/^https?:\/\//i.test(n)) return {
417
+ alt: null,
418
+ height: null,
419
+ media_id: null,
420
+ object_key: null,
421
+ url: n,
422
+ width: null
423
+ };
424
+ if (!U.test(n)) throw Error(`"${n}" is not a usable social image — provide an https:// image URL or a media library id.`);
425
+ let { data: r, error: i } = await e.from("media").select("id, object_key, file_path, width, height, description, variants").eq("id", n).maybeSingle();
426
+ if (i) throw Error(`Could not read media ${n}: ${S(i)}`);
427
+ if (!r) throw Error(`No media library item has the id ${n}. Call list_media to find one, or upload_media to import an image first.`);
428
+ let a = p(r), o = m(r);
429
+ if (!o) throw Error(`Media ${n} has no usable file to serve as the social image.`);
430
+ return {
431
+ alt: typeof r.description == "string" && r.description.trim() ? r.description.trim() : null,
432
+ height: a?.height ?? (typeof r.height == "number" ? r.height : null),
433
+ media_id: String(r.id),
434
+ object_key: o,
435
+ url: null,
436
+ width: a?.width ?? (typeof r.width == "number" ? r.width : null)
437
+ };
460
438
  }
461
- const Ue = u.strictObject({
462
- customBlocks: u.boolean().default(!1).describe("Delete every custom block definition."),
463
- identity: u.boolean().default(!0).describe("Clear the NextBlock site title, description, keywords, copyright line, social preview image, and the seeded logo."),
464
- navigation: u.boolean().default(!0).describe("Delete every header and footer navigation item."),
465
- pages: u.boolean().default(!0).describe("Delete pages (all languages) except keepPageSlugs."),
466
- posts: u.boolean().default(!0).describe("Delete every blog post."),
467
- products: u.boolean().default(!1).describe("Delete every product, with its variants, images, and drafts."),
468
- seededMedia: u.boolean().default(!0).describe("Delete the bundled NextBlock demo images from the media library.")
469
- }).partial(), ee = u.strictObject({
470
- clearKeptPageBlocks: u.boolean().default(!0).describe('Empty the blocks of the kept pages (usually "home") so they can be rebuilt. Set false to leave their content untouched.'),
471
- dryRun: u.boolean().default(!1).describe("Report what would be removed without changing anything. No confirmation needed."),
472
- keepLanguages: u.array(u.string().trim().min(2).max(10)).max(10).optional().describe("Locale codes the site should keep. Other languages are deactivated (never deleted) and their pages and posts removed. Omit to keep every language as it is."),
473
- keepPageSlugs: u.array(u.string().trim().min(1).max(300)).max(50).default([A]).describe('Pages to keep, by slug in any language; every translation of a kept page is kept. Defaults to ["home"] because "/" must always resolve.'),
474
- onlySeeded: u.boolean().default(!1).describe("Remove only rows that match the NextBlock demo seed (fixed translation groups, bundled images). Use when the site already has real content next to the demo content."),
475
- scope: Ue.default({})
439
+ var G = e.strictObject({
440
+ customBlocks: e.boolean().default(!1).describe("Delete every custom block definition."),
441
+ identity: e.boolean().default(!0).describe("Clear the NextBlock site title, description, keywords, copyright line, social preview image, and the seeded logo."),
442
+ navigation: e.boolean().default(!0).describe("Delete every header and footer navigation item."),
443
+ pages: e.boolean().default(!0).describe("Delete pages (all languages) except keepPageSlugs."),
444
+ posts: e.boolean().default(!0).describe("Delete every blog post."),
445
+ products: e.boolean().default(!1).describe("Delete every product, with its variants, images, and drafts."),
446
+ seededMedia: e.boolean().default(!0).describe("Delete the bundled NextBlock demo images from the media library.")
447
+ }).partial(), K = e.strictObject({
448
+ clearKeptPageBlocks: e.boolean().default(!0).describe("Empty the blocks of the kept pages (usually \"home\") so they can be rebuilt. Set false to leave their content untouched."),
449
+ dryRun: e.boolean().default(!1).describe("Report what would be removed without changing anything. No confirmation needed."),
450
+ keepLanguages: e.array(e.string().trim().min(2).max(10)).max(10).optional().describe("Locale codes the site should keep. Other languages are deactivated (never deleted) and their pages and posts removed. Omit to keep every language as it is."),
451
+ keepPageSlugs: e.array(e.string().trim().min(1).max(300)).max(50).default([y]).describe("Pages to keep, by slug in any language; every translation of a kept page is kept. Defaults to [\"home\"] because \"/\" must always resolve."),
452
+ onlySeeded: e.boolean().default(!1).describe("Remove only rows that match the NextBlock demo seed (fixed translation groups, bundled images). Use when the site already has real content next to the demo content."),
453
+ scope: G.default({})
476
454
  });
477
- async function be(e, t) {
478
- const a = {
479
- customBlocks: e.scope.customBlocks ?? !1,
480
- identity: e.scope.identity ?? !0,
481
- navigation: e.scope.navigation ?? !0,
482
- pages: e.scope.pages ?? !0,
483
- posts: e.scope.posts ?? !0,
484
- products: e.scope.products ?? !1,
485
- seededMedia: e.scope.seededMedia ?? !0
486
- }, { data: i, error: r } = await t.from("languages").select("id, code, name, is_default, is_active");
487
- if (r)
488
- throw new Error(`Could not read the languages: ${y(r)}`);
489
- const o = Array.isArray(i) ? i : [], l = new Map(o.map((n) => [Number(n.id), String(n.code).toLowerCase()])), d = e.keepLanguages ? new Set(e.keepLanguages.map((n) => n.toLowerCase())) : null;
490
- if (d) {
491
- const n = new Set(l.values()), g = [...d].filter((s) => !n.has(s));
492
- if (g.length > 0)
493
- throw new Error(`Unknown language code(s) in keepLanguages: ${g.join(", ")}. Existing: ${[...n].join(", ")}.`);
494
- }
495
- const m = new Set(
496
- o.filter((n) => !d || d.has(String(n.code).toLowerCase())).map((n) => Number(n.id))
497
- ), c = o.filter((n) => d && !d.has(String(n.code).toLowerCase()) && n.is_active !== !1).map((n) => ({ code: String(n.code), id: Number(n.id) })), p = o.find((n) => n.is_default === !0), f = d && p && !d.has(String(p.code).toLowerCase()) ? (() => {
498
- const n = o.find((g) => d.has(String(g.code).toLowerCase()));
499
- return n ? { code: String(n.code), id: Number(n.id) } : null;
500
- })() : null, S = (n) => ie.has(String(n.translation_group_id)), { data: P, error: T } = await t.from("pages").select("id, slug, language_id, translation_group_id, author_id");
501
- if (T)
502
- throw new Error(`Could not read the pages: ${y(T)}`);
503
- const E = Array.isArray(P) ? P : [], Y = new Set(e.keepPageSlugs.map((n) => n.toLowerCase())), W = new Set(
504
- E.filter((n) => Y.has(String(n.slug).toLowerCase())).map((n) => String(n.translation_group_id))
505
- ), w = (n) => ({
506
- id: Number(n.id),
507
- languageCode: l.get(Number(n.language_id)) ?? String(n.language_id),
508
- slug: String(n.slug)
509
- }), C = [], I = [];
510
- for (const n of E) {
511
- const g = W.has(String(n.translation_group_id)), s = m.has(Number(n.language_id)), h = !e.onlySeeded || S(n);
512
- g && s ? I.push(w(n)) : a.pages && h || !s ? C.push(w(n)) : I.push(w(n));
513
- }
514
- const { data: j, error: M } = await t.from("posts").select("id, slug, language_id, translation_group_id, author_id");
515
- if (M)
516
- throw new Error(`Could not read the posts: ${y(M)}`);
517
- const v = (Array.isArray(j) ? j : []).filter((n) => {
518
- const g = m.has(Number(n.language_id)), s = !e.onlySeeded || S(n);
519
- return a.posts && s || !g;
520
- }).map(w);
521
- let D = [];
522
- if (a.products)
523
- try {
524
- const { data: n } = await t.from("products").select("id");
525
- D = (Array.isArray(n) ? n : []).map((g) => String(g.id));
526
- } catch {
527
- D = [];
528
- }
529
- const B = new Set(C.map((n) => n.id)), R = new Set(C.map((n) => `/${n.slug}`)), { data: X, error: x } = await t.from("navigation_items").select("id, url, page_id");
530
- if (x)
531
- throw new Error(`Could not read the navigation: ${y(x)}`);
532
- const K = (Array.isArray(X) ? X : []).filter(
533
- (n) => a.navigation || n.page_id !== null && n.page_id !== void 0 && B.has(Number(n.page_id)) || R.has(String(n.url))
534
- ).map((n) => Number(n.id)), U = I.map((n) => n.id), z = new Set(v.map((n) => n.id)), { data: b } = await t.from("content_drafts").select("id, parent_type, parent_id"), J = (Array.isArray(b) ? b : []).filter((n) => {
535
- const g = Number(n.parent_id);
536
- return n.parent_type === "page" ? B.has(g) || e.clearKeptPageBlocks && U.includes(g) : n.parent_type === "post" && z.has(g);
537
- }).map((n) => ({ parentId: Number(n.parent_id), parentType: String(n.parent_type) }));
538
- let q = [];
539
- if (a.customBlocks) {
540
- const { data: n } = await t.from("custom_block_definitions").select("slug");
541
- q = (Array.isArray(n) ? n : []).map((g) => String(g.slug));
542
- }
543
- let G = [], $ = [];
544
- if (a.seededMedia || a.identity) {
545
- const { data: n } = await t.from("media").select("id, object_key"), g = (Array.isArray(n) ? n : []).filter(
546
- (_) => V.has(String(_.object_key))
547
- ), s = new Set(g.map((_) => String(_.id))), { data: h } = await t.from("logos").select("id, media_id");
548
- $ = (Array.isArray(h) ? h : []).filter((_) => s.has(String(_.media_id))).map((_) => String(_.id)), G = a.seededMedia ? [...s] : [], a.identity || ($ = []);
549
- }
550
- return {
551
- blocksToClearPageIds: e.clearKeptPageBlocks ? U : [],
552
- customBlockSlugs: q,
553
- draftsToDelete: J,
554
- identityKeys: a.identity ? ["site_title", "site_description", "site_keywords", "footer_copyright", H] : [],
555
- languagesToDeactivate: c,
556
- logosToDelete: $,
557
- mediaToDelete: G,
558
- navigationToDelete: K,
559
- newDefaultLanguage: f,
560
- pagesToDelete: C,
561
- pagesToKeep: I,
562
- postsToDelete: v,
563
- productsToDelete: D
564
- };
455
+ async function q(e, t) {
456
+ let n = {
457
+ customBlocks: e.scope.customBlocks ?? !1,
458
+ identity: e.scope.identity ?? !0,
459
+ navigation: e.scope.navigation ?? !0,
460
+ pages: e.scope.pages ?? !0,
461
+ posts: e.scope.posts ?? !0,
462
+ products: e.scope.products ?? !1,
463
+ seededMedia: e.scope.seededMedia ?? !0
464
+ }, { data: r, error: i } = await t.from("languages").select("id, code, name, is_default, is_active");
465
+ if (i) throw Error(`Could not read the languages: ${S(i)}`);
466
+ let a = Array.isArray(r) ? r : [], o = new Map(a.map((e) => [Number(e.id), String(e.code).toLowerCase()])), s = e.keepLanguages ? new Set(e.keepLanguages.map((e) => e.toLowerCase())) : null;
467
+ if (s) {
468
+ let e = new Set(o.values()), t = [...s].filter((t) => !e.has(t));
469
+ if (t.length > 0) throw Error(`Unknown language code(s) in keepLanguages: ${t.join(", ")}. Existing: ${[...e].join(", ")}.`);
470
+ }
471
+ let c = new Set(a.filter((e) => !s || s.has(String(e.code).toLowerCase())).map((e) => Number(e.id))), l = a.filter((e) => s && !s.has(String(e.code).toLowerCase()) && e.is_active !== !1).map((e) => ({
472
+ code: String(e.code),
473
+ id: Number(e.id)
474
+ })), u = a.find((e) => e.is_default === !0), f = s && u && !s.has(String(u.code).toLowerCase()) ? (() => {
475
+ let e = a.find((e) => s.has(String(e.code).toLowerCase()));
476
+ return e ? {
477
+ code: String(e.code),
478
+ id: Number(e.id)
479
+ } : null;
480
+ })() : null, p = (e) => h.has(String(e.translation_group_id)), { data: m, error: _ } = await t.from("pages").select("id, slug, language_id, translation_group_id, author_id");
481
+ if (_) throw Error(`Could not read the pages: ${S(_)}`);
482
+ let v = Array.isArray(m) ? m : [], y = new Set(e.keepPageSlugs.map((e) => e.toLowerCase())), b = new Set(v.filter((e) => y.has(String(e.slug).toLowerCase())).map((e) => String(e.translation_group_id))), x = (e) => ({
483
+ id: Number(e.id),
484
+ languageCode: o.get(Number(e.language_id)) ?? String(e.language_id),
485
+ slug: String(e.slug)
486
+ }), C = [], w = [];
487
+ for (let t of v) {
488
+ let r = b.has(String(t.translation_group_id)), i = c.has(Number(t.language_id)), a = !e.onlySeeded || p(t);
489
+ r && i ? w.push(x(t)) : n.pages && a || !i ? C.push(x(t)) : w.push(x(t));
490
+ }
491
+ let { data: T, error: E } = await t.from("posts").select("id, slug, language_id, translation_group_id, author_id");
492
+ if (E) throw Error(`Could not read the posts: ${S(E)}`);
493
+ let D = (Array.isArray(T) ? T : []).filter((t) => {
494
+ let r = c.has(Number(t.language_id)), i = !e.onlySeeded || p(t);
495
+ return n.posts && i || !r;
496
+ }).map(x), O = [];
497
+ if (n.products) try {
498
+ let { data: e } = await t.from("products").select("id");
499
+ O = (Array.isArray(e) ? e : []).map((e) => String(e.id));
500
+ } catch {
501
+ O = [];
502
+ }
503
+ let k = new Set(C.map((e) => e.id)), ee = new Set(C.map((e) => `/${e.slug}`)), { data: A, error: j } = await t.from("navigation_items").select("id, url, page_id");
504
+ if (j) throw Error(`Could not read the navigation: ${S(j)}`);
505
+ let te = (Array.isArray(A) ? A : []).filter((e) => n.navigation || e.page_id !== null && e.page_id !== void 0 && k.has(Number(e.page_id)) || ee.has(String(e.url))).map((e) => Number(e.id)), M = w.map((e) => e.id), N = new Set(D.map((e) => e.id)), { data: P } = await t.from("content_drafts").select("id, parent_type, parent_id"), F = (Array.isArray(P) ? P : []).filter((t) => {
506
+ let n = Number(t.parent_id);
507
+ return t.parent_type === "page" ? k.has(n) || e.clearKeptPageBlocks && M.includes(n) : t.parent_type === "post" && N.has(n);
508
+ }).map((e) => ({
509
+ parentId: Number(e.parent_id),
510
+ parentType: String(e.parent_type)
511
+ })), I = [];
512
+ if (n.customBlocks) {
513
+ let { data: e } = await t.from("custom_block_definitions").select("slug");
514
+ I = (Array.isArray(e) ? e : []).map((e) => String(e.slug));
515
+ }
516
+ let L = [], R = [];
517
+ if (n.seededMedia || n.identity) {
518
+ let { data: e } = await t.from("media").select("id, object_key"), r = (Array.isArray(e) ? e : []).filter((e) => g.has(String(e.object_key))), i = new Set(r.map((e) => String(e.id))), { data: a } = await t.from("logos").select("id, media_id");
519
+ R = (Array.isArray(a) ? a : []).filter((e) => i.has(String(e.media_id))).map((e) => String(e.id)), L = n.seededMedia ? [...i] : [], n.identity || (R = []);
520
+ }
521
+ return {
522
+ blocksToClearPageIds: e.clearKeptPageBlocks ? M : [],
523
+ customBlockSlugs: I,
524
+ draftsToDelete: F,
525
+ identityKeys: n.identity ? [
526
+ "site_title",
527
+ "site_description",
528
+ "site_keywords",
529
+ "footer_copyright",
530
+ d
531
+ ] : [],
532
+ languagesToDeactivate: l,
533
+ logosToDelete: R,
534
+ mediaToDelete: L,
535
+ navigationToDelete: te,
536
+ newDefaultLanguage: f,
537
+ pagesToDelete: C,
538
+ pagesToKeep: w,
539
+ postsToDelete: D,
540
+ productsToDelete: O
541
+ };
565
542
  }
566
- function ye(e) {
567
- return {
568
- blocksClearedOnPages: e.blocksToClearPageIds.length,
569
- customBlocks: e.customBlockSlugs.length,
570
- drafts: e.draftsToDelete.length,
571
- identityCleared: e.identityKeys.length > 0,
572
- languagesDeactivated: e.languagesToDeactivate.map((t) => t.code),
573
- logos: e.logosToDelete.length,
574
- media: e.mediaToDelete.length,
575
- navigationItems: e.navigationToDelete.length,
576
- pages: e.pagesToDelete.length,
577
- pagesKept: e.pagesToKeep.map((t) => `${t.slug} (${t.languageCode})`),
578
- posts: e.postsToDelete.length,
579
- products: e.productsToDelete.length
580
- };
543
+ function J(e) {
544
+ return {
545
+ blocksClearedOnPages: e.blocksToClearPageIds.length,
546
+ customBlocks: e.customBlockSlugs.length,
547
+ drafts: e.draftsToDelete.length,
548
+ identityCleared: e.identityKeys.length > 0,
549
+ languagesDeactivated: e.languagesToDeactivate.map((e) => e.code),
550
+ logos: e.logosToDelete.length,
551
+ media: e.mediaToDelete.length,
552
+ navigationItems: e.navigationToDelete.length,
553
+ pages: e.pagesToDelete.length,
554
+ pagesKept: e.pagesToKeep.map((e) => `${e.slug} (${e.languageCode})`),
555
+ posts: e.postsToDelete.length,
556
+ products: e.productsToDelete.length
557
+ };
581
558
  }
582
- async function qe(e, t, a) {
583
- for (const i of e.draftsToDelete) {
584
- const { error: r } = await t.from("content_drafts").delete().eq("parent_type", i.parentType).eq("parent_id", i.parentId);
585
- if (r)
586
- throw new Error(`Could not delete a draft: ${y(r)}`);
587
- }
588
- if (await N(t, "navigation_items", "id", e.navigationToDelete), e.blocksToClearPageIds.length > 0)
589
- for (const i of ge(e.blocksToClearPageIds)) {
590
- const { error: r } = await t.from("blocks").delete().in("page_id", i);
591
- if (r)
592
- throw new Error(`Could not clear the kept pages: ${y(r)}`);
593
- }
594
- if (await N(t, "pages", "id", e.pagesToDelete.map((i) => i.id)), await N(t, "posts", "id", e.postsToDelete.map((i) => i.id)), await N(t, "products", "id", e.productsToDelete), await N(t, "custom_block_definitions", "slug", e.customBlockSlugs), await N(t, "logos", "id", e.logosToDelete), await N(t, "media", "id", e.mediaToDelete), e.identityKeys.length > 0 && (await k(t, "site_title", ""), await k(t, "site_description", ""), await k(t, "site_keywords", ""), await k(t, H, null), await k(
595
- t,
596
- "footer_copyright",
597
- Object.fromEntries(a.map((i) => [i, "© {year}"]))
598
- )), e.logosToDelete.length > 0) {
599
- const { data: i } = await t.from("site_settings").select("value").eq("key", "active_logo_id").maybeSingle();
600
- typeof i?.value == "string" && e.logosToDelete.includes(i.value) && await k(t, "active_logo_id", null);
601
- }
602
- for (const i of e.languagesToDeactivate) {
603
- const { error: r } = await t.from("languages").update({ is_active: !1, is_default: !1 }).eq("id", i.id);
604
- if (r)
605
- throw new Error(`Could not deactivate the "${i.code}" language: ${y(r)}`);
606
- }
607
- if (e.newDefaultLanguage) {
608
- const { error: i } = await t.from("languages").update({ is_default: !1 }).neq("id", e.newDefaultLanguage.id);
609
- if (i)
610
- throw new Error(`Could not change the default language: ${y(i)}`);
611
- const { error: r } = await t.from("languages").update({ is_active: !0, is_default: !0 }).eq("id", e.newDefaultLanguage.id);
612
- if (r)
613
- throw new Error(`Could not change the default language: ${y(r)}`);
614
- }
559
+ async function Y(e, t, n) {
560
+ for (let n of e.draftsToDelete) {
561
+ let { error: e } = await t.from("content_drafts").delete().eq("parent_type", n.parentType).eq("parent_id", n.parentId);
562
+ if (e) throw Error(`Could not delete a draft: ${S(e)}`);
563
+ }
564
+ if (await j(t, "navigation_items", "id", e.navigationToDelete), e.blocksToClearPageIds.length > 0) for (let n of O(e.blocksToClearPageIds)) {
565
+ let { error: e } = await t.from("blocks").delete().in("page_id", n);
566
+ if (e) throw Error(`Could not clear the kept pages: ${S(e)}`);
567
+ }
568
+ if (await j(t, "pages", "id", e.pagesToDelete.map((e) => e.id)), await j(t, "posts", "id", e.postsToDelete.map((e) => e.id)), await j(t, "products", "id", e.productsToDelete), await j(t, "custom_block_definitions", "slug", e.customBlockSlugs), await j(t, "logos", "id", e.logosToDelete), await j(t, "media", "id", e.mediaToDelete), e.identityKeys.length > 0 && (await A(t, "site_title", ""), await A(t, "site_description", ""), await A(t, "site_keywords", ""), await A(t, d, null), await A(t, "footer_copyright", Object.fromEntries(n.map((e) => [e, "© {year}"])))), e.logosToDelete.length > 0) {
569
+ let { data: n } = await t.from("site_settings").select("value").eq("key", "active_logo_id").maybeSingle();
570
+ typeof n?.value == "string" && e.logosToDelete.includes(n.value) && await A(t, "active_logo_id", null);
571
+ }
572
+ for (let n of e.languagesToDeactivate) {
573
+ let { error: e } = await t.from("languages").update({
574
+ is_active: !1,
575
+ is_default: !1
576
+ }).eq("id", n.id);
577
+ if (e) throw Error(`Could not deactivate the "${n.code}" language: ${S(e)}`);
578
+ }
579
+ if (e.newDefaultLanguage) {
580
+ let { error: n } = await t.from("languages").update({ is_default: !1 }).neq("id", e.newDefaultLanguage.id);
581
+ if (n) throw Error(`Could not change the default language: ${S(n)}`);
582
+ let { error: r } = await t.from("languages").update({
583
+ is_active: !0,
584
+ is_default: !0
585
+ }).eq("id", e.newDefaultLanguage.id);
586
+ if (r) throw Error(`Could not change the default language: ${S(r)}`);
587
+ }
615
588
  }
616
- function le(e) {
617
- const t = [], a = e.pagesToKeep.some((i) => i.slug === A);
618
- return a && e.blocksToClearPageIds.length > 0 ? t.push('The home page was kept but is now empty: rebuild it with rewrite_page_draft (contentType "page", slug "home") and then publish_content_draft.') : a || t.push(`No "${A}" page remains, so "/" is a 404 until you create_cms_page with slug "${A}" and status "published".`), e.navigationToDelete.length > 0 && t.push('The header and footer menus are empty: rebuild them with update_navigation_bar (mode "replace") and update_footer for every active language.'), e.identityKeys.length > 0 && t.push("Site title, description, keywords, and copyright are blank: set them with update_site_identity."), t.push('The "Published with NextBlock" footer credit is unchanged; set footer_show_attribution to false with update_site_identity if the client wants no NextBlock mention.'), t;
589
+ function X(e) {
590
+ let t = [], n = e.pagesToKeep.some((e) => e.slug === y);
591
+ return n && e.blocksToClearPageIds.length > 0 ? t.push("The home page was kept but is now empty: rebuild it with rewrite_page_draft (contentType \"page\", slug \"home\") and then publish_content_draft.") : n || t.push(`No "${y}" page remains, so "/" is a 404 until you create_cms_page with slug "${y}" and status "published".`), e.navigationToDelete.length > 0 && t.push("The header and footer menus are empty: rebuild them with update_navigation_bar (mode \"replace\") and update_footer for every active language."), e.identityKeys.length > 0 && t.push("Site title, description, keywords, and copyright are blank: set them with update_site_identity."), t.push("The \"Published with NextBlock\" footer credit is unchanged; set footer_show_attribution to false with update_site_identity if the client wants no NextBlock mention."), t;
619
592
  }
620
- async function _e(e, t) {
621
- const a = ee.parse(e);
622
- await se(t, ["ADMIN"], "Resetting the site content");
623
- const i = L(t), r = await be(a, i), o = ye(r), l = o.pages + o.posts + o.products + o.navigationItems + o.customBlocks + o.media + o.logos;
624
- if (a.dryRun)
625
- return {
626
- dryRun: !0,
627
- mutationExecuted: !1,
628
- nextSteps: le(r),
629
- success: !0,
630
- summary: o,
631
- wouldDelete: {
632
- pages: r.pagesToDelete,
633
- posts: r.postsToDelete
634
- }
635
- };
636
- const d = oe({
637
- action: "RESET SITE CONTENT",
638
- context: t,
639
- payload: { input: a, summary: o, tool: "reset_site_content" },
640
- preview: {
641
- irreversible: !0,
642
- summary: `Permanently delete ${o.pages} page(s), ${o.posts} post(s), ${o.products} product(s), ${o.navigationItems} navigation item(s), ${o.customBlocks} custom block definition(s), ${o.media} demo image(s) and ${o.logos} logo(s)${o.identityCleared ? ", clear the site identity" : ""}${o.languagesDeactivated.length ? `, deactivate ${o.languagesDeactivated.join(", ")}` : ""}. Kept: ${o.pagesKept.join(", ") || "nothing"}. This cannot be undone — take a backup first at /cms/settings/backup-restore if the content matters.`,
643
- ...o
644
- },
645
- subject: `${l} items`
646
- });
647
- if (d)
648
- return d;
649
- const m = a.keepLanguages?.map((p) => p.toLowerCase()) ?? [], c = m.length > 0 ? m : await (async () => {
650
- const { data: p } = await i.from("languages").select("code, is_active");
651
- return (Array.isArray(p) ? p : []).filter((f) => f.is_active !== !1).map((f) => String(f.code).toLowerCase());
652
- })();
653
- return await qe(r, i, c), ne(t, ["/cms/pages", "/cms/posts", "/cms/navigation", "/cms/media", "/cms/custom-blocks", "/cms/products"]), {
654
- deleted: o,
655
- mutationExecuted: !0,
656
- nextSteps: le(r),
657
- success: !0
658
- };
593
+ async function Z(e, t) {
594
+ let n = K.parse(e);
595
+ await c(t, ["ADMIN"], "Resetting the site content");
596
+ let r = x(t), i = await q(n, r), a = J(i), o = a.pages + a.posts + a.products + a.navigationItems + a.customBlocks + a.media + a.logos;
597
+ if (n.dryRun) return {
598
+ dryRun: !0,
599
+ mutationExecuted: !1,
600
+ nextSteps: X(i),
601
+ success: !0,
602
+ summary: a,
603
+ wouldDelete: {
604
+ pages: i.pagesToDelete,
605
+ posts: i.postsToDelete
606
+ }
607
+ };
608
+ let s = E({
609
+ action: "RESET SITE CONTENT",
610
+ context: t,
611
+ payload: {
612
+ input: n,
613
+ summary: a,
614
+ tool: "reset_site_content"
615
+ },
616
+ preview: {
617
+ irreversible: !0,
618
+ summary: `Permanently delete ${a.pages} page(s), ${a.posts} post(s), ${a.products} product(s), ${a.navigationItems} navigation item(s), ${a.customBlocks} custom block definition(s), ${a.media} demo image(s) and ${a.logos} logo(s)${a.identityCleared ? ", clear the site identity" : ""}${a.languagesDeactivated.length ? `, deactivate ${a.languagesDeactivated.join(", ")}` : ""}. Kept: ${a.pagesKept.join(", ") || "nothing"}. This cannot be undone — take a backup first at /cms/settings/backup-restore if the content matters.`,
619
+ ...a
620
+ },
621
+ subject: `${o} items`
622
+ });
623
+ if (s) return s;
624
+ let l = n.keepLanguages?.map((e) => e.toLowerCase()) ?? [];
625
+ return await Y(i, r, l.length > 0 ? l : await (async () => {
626
+ let { data: e } = await r.from("languages").select("code, is_active");
627
+ return (Array.isArray(e) ? e : []).filter((e) => e.is_active !== !1).map((e) => String(e.code).toLowerCase());
628
+ })()), k(t, [
629
+ "/cms/pages",
630
+ "/cms/posts",
631
+ "/cms/navigation",
632
+ "/cms/media",
633
+ "/cms/custom-blocks",
634
+ "/cms/products"
635
+ ]), {
636
+ deleted: a,
637
+ mutationExecuted: !0,
638
+ nextSteps: X(i),
639
+ success: !0
640
+ };
659
641
  }
660
- const Ge = 60, we = u.strictObject({
661
- brief: de.optional().describe("The brief as agreed with the client. Merged over the saved brief and marked confirmed."),
662
- durationMinutes: u.number().int().min(15).max(180).default(Ge).describe("How long the unattended build session stays open."),
663
- reset: ee.optional().describe("Remove the seeded NextBlock demo content as the first step of the build. Omit when the client keeps existing content."),
664
- summary: u.string().trim().min(20).max(4e3).describe("The plan the operator is approving, in plain language: what is removed, every page and its sections, navigation, footer, theme, languages.")
642
+ var Q = e.strictObject({
643
+ brief: i.optional().describe("The brief as agreed with the client. Merged over the saved brief and marked confirmed."),
644
+ durationMinutes: e.number().int().min(15).max(180).default(60).describe("How long the unattended build session stays open."),
645
+ reset: K.optional().describe("Remove the seeded NextBlock demo content as the first step of the build. Omit when the client keeps existing content."),
646
+ summary: e.string().trim().min(20).max(4e3).describe("The plan the operator is approving, in plain language: what is removed, every page and its sections, navigation, footer, theme, languages.")
665
647
  });
666
- async function Fe(e, t) {
667
- const a = we.parse(e);
668
- await se(t, ["ADMIN"], "Starting a site build");
669
- const i = L(t), r = t?.actorUserId;
670
- let o = null, l = null;
671
- a.reset && (l = ee.parse({ ...a.reset, dryRun: !1 }), o = ye(await be(l, i)));
672
- const d = oe({
673
- action: "START SITE BUILD",
674
- context: t,
675
- payload: { brief: a.brief ?? null, durationMinutes: a.durationMinutes, reset: l, summary: a.summary, tool: "start_site_build" },
676
- preview: {
677
- durationMinutes: a.durationMinutes,
678
- plan: a.summary,
679
- reset: o,
680
- summary: `${a.summary}${o ? ` First, permanently delete ${o.pages} page(s), ${o.posts} post(s), ${o.navigationItems} navigation item(s), ${o.media} demo image(s)${o.identityCleared ? " and the NextBlock site identity" : ""} (kept: ${o.pagesKept.join(", ") || "nothing"}).` : ""} After you confirm, Cortex applies every step of this plan without asking again, for up to ${a.durationMinutes} minutes. You can stop it at any time.`
681
- },
682
- subject: "plan"
683
- });
684
- if (d)
685
- return d;
686
- let m = null;
687
- a.brief ? m = (await Z(
688
- { brief: { ...a.brief, status: "confirmed" }, mode: "merge" },
689
- { ...t }
690
- )).brief : await re(i) && (m = (await Z({ brief: { status: "confirmed" }, mode: "merge" }, { ...t })).brief);
691
- let c = null;
692
- l && (c = await _e(l, { ...t, skipConfirmation: !0 }));
693
- const p = /* @__PURE__ */ new Date(), f = {
694
- actorUserId: r,
695
- createdAt: p.toISOString(),
696
- expiresAt: new Date(p.getTime() + a.durationMinutes * 6e4).toISOString(),
697
- id: Ae(),
698
- summary: a.summary
699
- };
700
- return await k(i, F, f), {
701
- brief: m,
702
- buildSession: { expiresAt: f.expiresAt, id: f.id },
703
- continuePrompt: "The build session is active and the plan is approved. Continue the site build now, step by step, without asking for confirmation: identity, languages, theme, pages (rewrite home, create the others), publish every draft, navigation, footer, translations, then call finish_site_build and summarize what was built with links.",
704
- mutationExecuted: !0,
705
- resetResult: c,
706
- success: !0
707
- };
648
+ async function ie(e, n) {
649
+ let r = Q.parse(e);
650
+ await c(n, ["ADMIN"], "Starting a site build");
651
+ let i = x(n), a = n?.actorUserId, o = null, s = null;
652
+ r.reset && (s = K.parse({
653
+ ...r.reset,
654
+ dryRun: !1
655
+ }), o = J(await q(s, i)));
656
+ let l = E({
657
+ action: "START SITE BUILD",
658
+ context: n,
659
+ payload: {
660
+ brief: r.brief ?? null,
661
+ durationMinutes: r.durationMinutes,
662
+ reset: s,
663
+ summary: r.summary,
664
+ tool: "start_site_build"
665
+ },
666
+ preview: {
667
+ durationMinutes: r.durationMinutes,
668
+ plan: r.summary,
669
+ reset: o,
670
+ summary: `${r.summary}${o ? ` First, permanently delete ${o.pages} page(s), ${o.posts} post(s), ${o.navigationItems} navigation item(s), ${o.media} demo image(s)${o.identityCleared ? " and the NextBlock site identity" : ""} (kept: ${o.pagesKept.join(", ") || "nothing"}).` : ""} After you confirm, Cortex applies every step of this plan without asking again, for up to ${r.durationMinutes} minutes. You can stop it at any time.`
671
+ },
672
+ subject: "plan"
673
+ });
674
+ if (l) return l;
675
+ let u = null;
676
+ r.brief ? u = (await P({
677
+ brief: {
678
+ ...r.brief,
679
+ status: "confirmed"
680
+ },
681
+ mode: "merge"
682
+ }, {
683
+ ...n,
684
+ skipConfirmation: !0
685
+ })).brief : await M(i) && (u = (await P({
686
+ brief: { status: "confirmed" },
687
+ mode: "merge"
688
+ }, {
689
+ ...n,
690
+ skipConfirmation: !0
691
+ })).brief);
692
+ let d = null;
693
+ s && (d = await Z(s, {
694
+ ...n,
695
+ skipConfirmation: !0
696
+ }));
697
+ let f = /* @__PURE__ */ new Date(), p = {
698
+ actorUserId: a,
699
+ createdAt: f.toISOString(),
700
+ expiresAt: new Date(f.getTime() + r.durationMinutes * 6e4).toISOString(),
701
+ id: D(),
702
+ summary: r.summary
703
+ };
704
+ return await A(i, t, p), {
705
+ brief: u,
706
+ buildSession: {
707
+ expiresAt: p.expiresAt,
708
+ id: p.id
709
+ },
710
+ continuePrompt: "The build session is active and the plan is approved. Continue the site build now, step by step, without asking for confirmation: identity, languages, theme, pages (rewrite home, create the others), publish every draft, navigation, footer, translations, then call finish_site_build and summarize what was built with links.",
711
+ mutationExecuted: !0,
712
+ resetResult: d,
713
+ success: !0
714
+ };
708
715
  }
709
- const Se = u.strictObject({
710
- outcome: u.enum(["built", "stopped"]).default("built").describe('"built" when the plan was completed; "stopped" when the operator interrupted it.'),
711
- summary: u.string().trim().max(4e3).optional().describe("What was built, for the record.")
716
+ var $ = e.strictObject({
717
+ outcome: e.enum(["built", "stopped"]).default("built").describe("\"built\" when the plan was completed; \"stopped\" when the operator interrupted it."),
718
+ summary: e.string().trim().max(4e3).optional().describe("What was built, for the record.")
712
719
  });
713
- async function He(e, t) {
714
- const a = Se.parse(e), i = L(t), r = await pe(i);
715
- await Re(i);
716
- let o = null;
717
- if (a.outcome === "built") {
718
- const l = await re(i);
719
- l && (o = (await Z(
720
- { brief: { status: "built", ...a.summary ? { notes: `${l.notes ? `${l.notes}
721
- ` : ""}Built: ${a.summary}` } : {} }, mode: "merge" },
722
- { ...t }
723
- )).brief);
724
- }
725
- return ne(t, ["/cms/dashboard"]), {
726
- brief: o,
727
- buildSessionEnded: !0,
728
- hadSession: !!r,
729
- mutationExecuted: !0,
730
- outcome: a.outcome,
731
- success: !0
732
- };
720
+ async function ae(e, t) {
721
+ let n = $.parse(e), r = x(t), i = await F(r);
722
+ await L(r);
723
+ let a = null;
724
+ if (n.outcome === "built") {
725
+ let e = await M(r);
726
+ e && (a = (await P({
727
+ brief: {
728
+ status: "built",
729
+ ...n.summary ? { notes: `${e.notes ? `${e.notes}\n` : ""}Built: ${n.summary}` } : {}
730
+ },
731
+ mode: "merge"
732
+ }, {
733
+ ...t,
734
+ skipConfirmation: !0
735
+ })).brief);
736
+ }
737
+ return k(t, ["/cms/dashboard"]), {
738
+ brief: a,
739
+ buildSessionEnded: !0,
740
+ hadSession: !!i,
741
+ mutationExecuted: !0,
742
+ outcome: n.outcome,
743
+ success: !0
744
+ };
733
745
  }
734
- function tt(e) {
735
- return {
736
- get_site_overview: O({
737
- description: 'Read the WHOLE site in one call: languages, site identity (title, description, copyright, active logo), every page, post, and product with status and language, the header and footer menus per language, themes, custom block definitions, media counts, pending Live Drafts, the saved site brief, and whether NextBlock demo content is still present. Read-only. Call this FIRST for any request about the site as a whole ("build my site", "update the whole website", "what do I have?") instead of several narrower reads.',
738
- execute: (t) => Le(t, e),
739
- inputSchema: fe,
740
- strict: !0
741
- }),
742
- update_site_identity: O({
743
- description: 'Set the site-wide identity: site_title (brand name in the header and <title>), site_description, site_keywords, footer_copyright per locale ("{year}" is substituted), footer_show_attribution (the "Published with NextBlock" credit), the pinned active_logo_id, and social_image — the site-wide Open Graph / share preview image (a media id or an https URL) used by every page without a feature image, the home page above all, which must never get a feature image of its own. Use it right after a reset and whenever the client renames or re-describes their business. Mutating: first returns a confirmation phrase; only executes after exact confirmation.',
744
- execute: (t) => je(t, e),
745
- inputSchema: he,
746
- strict: !0
747
- }),
748
- save_site_brief: O({
749
- description: 'Record what the client wants their website to be — business, audience, goals, site type (a one-page landing site is fine), pages and their sections, languages, brand colours and tone, contact details, whether existing content is kept. Saved site-wide and shown to you at the start of every later conversation, so save it as soon as you learn something (mode "merge" adds to what is saved). Runs immediately, no confirmation.',
750
- execute: (t) => Z(t, e),
751
- inputSchema: me,
752
- strict: !0
753
- }),
754
- reset_site_content: O({
755
- description: 'Remove the NextBlock demo content that ships with a fresh install — or, by scope, everything: pages (all languages, except keepPageSlugs, default ["home"] which is kept but emptied), posts, navigation, the bundled demo images and logo, the default site title and copyright; optionally products and custom block definitions. keepLanguages deactivates every other language and removes its content, so a client who only wants English gets an English-only site. Pass dryRun true to see the counts first. ADMIN only, irreversible; take a backup at /cms/settings/backup-restore if in doubt. Mutating: first returns a confirmation phrase; only executes after exact confirmation. Prefer start_site_build with `reset` when you are about to rebuild the site, so one confirmation covers both.',
756
- execute: (t) => _e(t, e),
757
- inputSchema: ee,
758
- strict: !0
759
- }),
760
- start_site_build: O({
761
- description: "Approve a whole-site plan with ONE confirmation. Pass the plain-language plan in `summary`, the agreed `brief`, and (usually) `reset` so the demo content is removed first. On confirmation it saves the brief, runs the reset, and opens a time-boxed build session: until it expires, every later tool call in this chat executes without asking for confirmation, so you can create pages, publish drafts, set navigation, footer, theme, and translations in one unattended run. Call it only after the client has seen the plan and agreed. After it succeeds, keep working through the plan immediately and finish with finish_site_build. ADMIN only.",
762
- execute: (t) => Fe(t, e),
763
- inputSchema: we,
764
- strict: !0
765
- }),
766
- finish_site_build: O({
767
- description: 'Close the current build session (opened by start_site_build) and mark the brief as built. Call it as the LAST step of a site build, or with outcome "stopped" if the operator interrupted. Runs immediately, no confirmation.',
768
- execute: (t) => He(t, e),
769
- inputSchema: Se,
770
- strict: !0
771
- })
772
- };
746
+ function oe(e) {
747
+ return {
748
+ get_site_overview: l({
749
+ description: "Read the WHOLE site in one call: languages, site identity (title, description, copyright, active logo), every page, post, and product with status and language, the header and footer menus per language, themes, custom block definitions, media counts, pending Live Drafts, the saved site brief, and whether NextBlock demo content is still present. Read-only. Call this FIRST for any request about the site as a whole (\"build my site\", \"update the whole website\", \"what do I have?\") instead of several narrower reads.",
750
+ execute: (t) => z(t, e),
751
+ inputSchema: R,
752
+ strict: !0
753
+ }),
754
+ update_site_identity: l({
755
+ description: "Set the site-wide identity: site_title (brand name in the header and <title>), site_description, site_keywords, footer_copyright per locale (\"{year}\" is substituted), footer_show_attribution (the \"Published with NextBlock\" credit), the pinned active_logo_id, and social_image — the site-wide Open Graph / share preview image (a media id or an https URL) used by every page without a feature image, the home page above all, which must never get a feature image of its own. Use it right after a reset and whenever the client renames or re-describes their business. Mutating: first returns a confirmation phrase; only executes after exact confirmation.",
756
+ execute: (t) => H(t, e),
757
+ inputSchema: V,
758
+ strict: !0
759
+ }),
760
+ save_site_brief: l({
761
+ description: "Record what the client wants their website to be — business, audience, goals, site type (a one-page landing site is fine), pages and their sections, languages, brand colours and tone, contact details, whether existing content is kept. Saved site-wide and shown to you at the start of every later conversation, so save it as soon as you learn something (mode \"merge\" adds to what is saved). Runs immediately, no confirmation.",
762
+ execute: (t) => P(t, e),
763
+ inputSchema: N,
764
+ strict: !0
765
+ }),
766
+ reset_site_content: l({
767
+ description: "Remove the NextBlock demo content that ships with a fresh install — or, by scope, everything: pages (all languages, except keepPageSlugs, default [\"home\"] which is kept but emptied), posts, navigation, the bundled demo images and logo, the default site title and copyright; optionally products and custom block definitions. keepLanguages deactivates every other language and removes its content, so a client who only wants English gets an English-only site. Pass dryRun true to see the counts first. ADMIN only, irreversible; take a backup at /cms/settings/backup-restore if in doubt. Mutating: first returns a confirmation phrase; only executes after exact confirmation. Prefer start_site_build with `reset` when you are about to rebuild the site, so one confirmation covers both.",
768
+ execute: (t) => Z(t, e),
769
+ inputSchema: K,
770
+ strict: !0
771
+ }),
772
+ start_site_build: l({
773
+ description: "Approve a whole-site plan with ONE confirmation. Pass the plain-language plan in `summary`, the agreed `brief`, and (usually) `reset` so the demo content is removed first. On confirmation it saves the brief, runs the reset, and opens a time-boxed build session: until it expires, every later tool call in this chat executes without asking for confirmation, so you can create pages, publish drafts, set navigation, footer, theme, and translations in one unattended run. Call it only after the client has seen the plan and agreed. After it succeeds, keep working through the plan immediately and finish with finish_site_build. ADMIN only.",
774
+ execute: (t) => ie(t, e),
775
+ inputSchema: Q,
776
+ strict: !0
777
+ }),
778
+ finish_site_build: l({
779
+ description: "Close the current build session (opened by start_site_build) and mark the brief as built. Call it as the LAST step of a site build, or with outcome \"stopped\" if the operator interrupted. Runs immediately, no confirmation.",
780
+ execute: (t) => ae(t, e),
781
+ inputSchema: $,
782
+ strict: !0
783
+ })
784
+ };
773
785
  }
774
- export {
775
- V as NEXTBLOCK_SEED_MEDIA_OBJECT_KEYS,
776
- ie as NEXTBLOCK_SEED_TRANSLATION_GROUP_IDS,
777
- tt as createCortexSiteTools,
778
- He as executeFinishSiteBuild,
779
- Le as executeGetSiteOverview,
780
- _e as executeResetSiteContent,
781
- Z as executeSaveSiteBrief,
782
- Fe as executeStartSiteBuild,
783
- je as executeUpdateSiteIdentity,
784
- Se as finishSiteBuildInputSchema,
785
- et as formatCortexSiteOverviewForPrompt,
786
- fe as getSiteOverviewInputSchema,
787
- pe as readCortexBuildSession,
788
- re as readCortexSiteBrief,
789
- ee as resetSiteContentInputSchema,
790
- Ze as resolveCortexBuildSession,
791
- me as saveSiteBriefInputSchema,
792
- we as startSiteBuildInputSchema,
793
- he as updateSiteIdentityInputSchema
794
- };
786
+ //#endregion
787
+ export { g as NEXTBLOCK_SEED_MEDIA_OBJECT_KEYS, h as NEXTBLOCK_SEED_TRANSLATION_GROUP_IDS, oe as createCortexSiteTools, ae as executeFinishSiteBuild, z as executeGetSiteOverview, Z as executeResetSiteContent, P as executeSaveSiteBrief, ie as executeStartSiteBuild, H as executeUpdateSiteIdentity, $ as finishSiteBuildInputSchema, re as formatCortexSiteOverviewForPrompt, R as getSiteOverviewInputSchema, F as readCortexBuildSession, M as readCortexSiteBrief, K as resetSiteContentInputSchema, I as resolveCortexBuildSession, N as saveSiteBriefInputSchema, Q as startSiteBuildInputSchema, V as updateSiteIdentityInputSchema };