@aglyn/plugins-ai 1.0.0-beta.272 → 1.0.0-beta.274

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 (52) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-site-start-card.component.js +237 -234
  3. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  4. package/src/lib/jobs/ai-empty-site-sweep.d.ts +12 -1
  5. package/src/lib/jobs/ai-empty-site-sweep.js +15 -3
  6. package/src/lib/jobs/ai-empty-site-sweep.js.map +1 -1
  7. package/src/lib/jobs/ai-job-page-step.js +21 -2
  8. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  9. package/src/lib/jobs/ai-job-seo-step.js +8 -4
  10. package/src/lib/jobs/ai-job-seo-step.js.map +1 -1
  11. package/src/lib/jobs/ai-job-site-datasets.d.ts +39 -1
  12. package/src/lib/jobs/ai-job-site-datasets.js +111 -15
  13. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  14. package/src/lib/jobs/ai-job-site-step.d.ts +12 -3
  15. package/src/lib/jobs/ai-job-site-step.js +85 -11
  16. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  17. package/src/lib/jobs/ai-job-text-step.d.ts +8 -0
  18. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  19. package/src/lib/jobs/ai-jobs.d.ts +3 -0
  20. package/src/lib/jobs/ai-jobs.js +4 -0
  21. package/src/lib/jobs/ai-jobs.js.map +1 -1
  22. package/src/lib/jobs/ai-layout-owner-photos.js +4 -4
  23. package/src/lib/jobs/ai-layout-owner-photos.js.map +1 -1
  24. package/src/lib/jobs/ai-layout-stock-photos.d.ts +35 -0
  25. package/src/lib/jobs/ai-layout-stock-photos.js +114 -43
  26. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  27. package/src/lib/jobs/ai-site-late-photos.d.ts +143 -0
  28. package/src/lib/jobs/ai-site-late-photos.js +486 -0
  29. package/src/lib/jobs/ai-site-late-photos.js.map +1 -0
  30. package/src/lib/jobs/ai-site-publish.d.ts +18 -0
  31. package/src/lib/jobs/ai-site-publish.js +123 -5
  32. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  33. package/src/lib/jobs/fixtures/ai-site-late-photos-laurel-fork.d.ts +83 -0
  34. package/src/lib/jobs/fixtures/ai-site-late-photos-laurel-fork.js +1553 -0
  35. package/src/lib/jobs/fixtures/ai-site-late-photos-laurel-fork.js.map +1 -0
  36. package/src/lib/layout-language/ai-layout-pictures.d.ts +50 -13
  37. package/src/lib/layout-language/ai-layout-pictures.js +81 -19
  38. package/src/lib/layout-language/ai-layout-pictures.js.map +1 -1
  39. package/src/lib/model/ai-jobs.types.d.ts +10 -0
  40. package/src/lib/model/ai-jobs.types.js.map +1 -1
  41. package/src/lib/model/ai-site-photos.d.ts +119 -0
  42. package/src/lib/model/ai-site-photos.js +128 -0
  43. package/src/lib/model/ai-site-photos.js.map +1 -0
  44. package/src/lib/runtime/ai-doctrine-validators.d.ts +3 -1
  45. package/src/lib/runtime/ai-doctrine-validators.js +3 -1
  46. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  47. package/src/lib/runtime/seo-fields.d.ts +29 -4
  48. package/src/lib/runtime/seo-fields.js +58 -11
  49. package/src/lib/runtime/seo-fields.js.map +1 -1
  50. package/src/lib/tools/ai-seo-tool.d.ts +25 -1
  51. package/src/lib/tools/ai-seo-tool.js +61 -0
  52. package/src/lib/tools/ai-seo-tool.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-publish.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isFirstPublishedRoute } from '@aglyn/aglyn/app-utils/analytics-events'\nimport { createResourceUid } from '@aglyn/aglyn/app-utils/create-resource-uid'\nimport { hostPublicOrigin } from '@aglyn/aglyn/app-utils/host-naming'\nimport {\n blockingRouteOwner,\n normalizeScreenSlug,\n SCREEN_ROOT_PATH,\n screenRoutePathToUrl,\n} from '@aglyn/aglyn/app-utils/screen-route'\nimport { resolvePageLocale, siteLanguageCode } from '@aglyn/aglyn/app-utils/seo-locale'\nimport { decodeStoredNodes, encodeStoredNodes } from '@aglyn/aglyn/app-utils/stored-nodes'\nimport { dropPluginSiteCache } from '@aglyn/aglyn/plugin-manager/plugin-site-cache'\nimport type { NodesMap } from '@aglyn/aglyn/types/nodes'\nimport { sendGa4SitePublished } from '@aglyn/tenant-data-admin/server/ga4-measurement-protocol'\nimport { FieldValue, type Firestore } from 'firebase-admin/firestore'\nimport {\n aiLayoutFrameHollows,\n aiLayoutFrameHollowsSaid,\n aiLayoutFrameIsHollow,\n aiLayoutRepairFrameHollows,\n aiLayoutWithoutFrameHollows,\n} from '../layout-language/ai-layout-frame-hollows'\nimport type { AiJob, AiJobOutput, AiJobSitePublish } from '../model/ai-jobs.types'\nimport { AI_SITE_BLOG_SLUGS } from '../model/ai-site-job'\nimport { aiSiteEntityUpdates, aiSiteEntityValues, aiSiteListingUpdates } from '../model/ai-site-entity'\nimport { aiSiteSeoProposalForInputs } from '../model/ai-site-start-seo'\nimport { aiLayoutWithStoreLinks, type AiStoreLayoutLinks } from '../model/ai-layout-store-links'\nimport { aiLayoutWithMenuChanges, aiNoMenuChanges } from '../model/ai-layout-menus'\nimport { AI_STORE_LINKS_SOURCE_FIELD as STORE_LINKS_SOURCE_FIELD } from './ai-job-store-links-layout'\nimport { updateAiDraftNodes } from './ai-job-drafts'\n\n/**\n * A store's links a build drafted into the site's own layout (AGL-3676): the\n * draft version, the links in it, and the site's page addresses they were\n * checked against. Its publish makes that version the live one, or — where\n * the layout changed since the draft was made — adds the same links to the\n * version that is live now.\n */\nexport interface AiSitePublishStoreLinks {\n layoutId: string\n versionId: string\n links: AiStoreLayoutLinks\n screenPaths?: Readonly<Record<string, string>>\n}\n\n/**\n * A guided site start publishes what it built (AGL-3596).\n *\n * A person who asked for \"a website\" in the guided start and watched it build\n * was then handed drafts: a site whose address still answered with the\n * starter, or with nothing. A `site` job started from the guided start (its\n * plan confirmed on the person's behalf, `inputs.autoConfirm`) therefore ends\n * by putting every page it built on the site, through the same writes a\n * person's Publish makes:\n *\n * - each page's address in the host's routing map, `publishedAt` on the page,\n * in ONE batch with the publish outbox entry that drops the live site's\n * cached pages (AGL-2575), the drop itself attempted at once;\n * - the home page takes `/` from the starter home page the site was created\n * with (AGL-3408), and an untouched starter goes to the trash rather than\n * staying beside it as a second \"Home\";\n * - the navigation entries the pages proposed are added to the header of\n * the layout they render inside, as a new live version of that layout;\n * - `site_published` once, server-side, as the scheduled publish sends it.\n *\n * A page that cannot be published — deleted meanwhile, no address, an address\n * another page holds — stays a draft and is reported with the plain sentence\n * for why. It never fails the job: the site is still built, and the person\n * fixes that one page in Pages. Every other job kind keeps producing drafts.\n *\n * The allowance is respected by construction: a draft is counted against the\n * plan's pages when it is written (`aiDraftBandRefusal`), so publishing\n * drafts adds none, and retiring the starter frees the one it held.\n */\n\nexport interface AiSitePublishDeps {\n sendSitePublished?: typeof sendGa4SitePublished\n dropCache?: typeof dropPluginSiteCache\n}\n\n/**\n * Whether a build puts its pages live (AGL-3616): only where its request\n * asked to (`publish`, set by Assist's proposal) AND the member ticked the\n * plan card's box when confirming (`publishConfirmed`, set by the resume\n * door). Every other build leaves drafts.\n */\nexport function aiJobPublishesBuild(job: Pick<AiJob, 'kind' | 'inputs'>): boolean {\n return job.kind === 'build' && job.inputs?.['publish'] === true && job.inputs?.['publishConfirmed'] === true\n}\n\n/**\n * The host fields a guided start writes for its plan's language (AGL-3750),\n * as the Languages card saves one language: `locales` of that one and\n * `defaultLocale` the same. `null` — nothing written — where the plan said no\n * valid language, where it is the language the site already publishes in\n * (English for a new site), and on a site with more than one language, whose\n * languages are the owner's decision. Nothing is translated: the pages were\n * written in the brief's language, and this says so to the reader.\n */\nexport function aiSiteLanguageUpdates(\n host: { locales?: unknown; defaultLocale?: unknown },\n language: string | null | undefined,\n): { locales: string[]; defaultLocale: string } | null {\n const code = siteLanguageCode(language)\n if (!code) return null\n const locales = Array.isArray(host.locales)\n ? host.locales.filter((one): one is string => typeof one === 'string' && one.trim() !== '')\n : []\n if (locales.length > 1) return null\n const current = resolvePageLocale({\n host: {\n ...(typeof host.defaultLocale === 'string' ? { defaultLocale: host.defaultLocale } : {}),\n locales,\n },\n })\n if (current === code) return null\n return { locales: [code], defaultLocale: code }\n}\n\n/** Whether a finished job of this shape publishes what it built. */\nexport function aiJobPublishesSite(job: Pick<AiJob, 'kind' | 'inputs'>): boolean {\n return job.kind === 'site' && job.inputs?.['autoConfirm'] === true\n}\n\n/**\n * Where a site answers: its custom domain, else its subdomain under the\n * deployment's tenant apex — never a hard-coded platform host, so a\n * self-hosted deployment links to its own sites.\n */\nexport function aiSiteLiveUrl(host: { cname?: unknown; subdomain?: unknown }): string | null {\n const text = (value: unknown) => (typeof value === 'string' ? value.trim() : '')\n const origin = hostPublicOrigin({ cname: text(host.cname) || null, subdomain: text(host.subdomain) || null })\n return origin ? `${origin}/` : null\n}\n\n/** The sentences a page that stayed a draft is reported with. */\nexport const AI_SITE_PUBLISH_DELETED = 'It was deleted before it could be published.'\nexport const AI_SITE_PUBLISH_NO_ADDRESS = 'It has no address yet. Give it one in Pages and publish it.'\nexport const aiSitePublishTakenCopy = (path: string): string =>\n `Another page is already published at ${screenRoutePathToUrl(path)}. Give this one another address in Pages and publish it.`\nexport const AI_SITE_PUBLISH_FAILED = 'It could not be published just now. Publish it from Pages.'\n\n/** A navigation entry a page proposed, as the page step reports it. */\ninterface NavEntry {\n screenId: string\n label: string\n}\n\nfunction navEntriesOf(outputs: readonly AiJobOutput[]): NavEntry[] {\n const entries: NavEntry[] = []\n for (const output of outputs) {\n if (output.resource !== 'screen') continue\n const navigation = output.proposal?.['navigation'] as { label?: unknown } | undefined\n const label = typeof navigation?.label === 'string' ? navigation.label.trim() : ''\n if (label && !entries.some((entry) => entry.screenId === output.id)) {\n entries.push({ screenId: output.id, label })\n }\n }\n return entries\n}\n\ntype MutableNode = {\n $id: string\n componentId?: string\n parentId?: string\n props?: Record<string, unknown>\n nodes?: string[]\n [key: string]: unknown\n}\n\n/**\n * The blog paths a start's layout links and must not publish (AGL-3660): its\n * header, phone menu and footer link the blog by path while the posts part is\n * still owed, so a start whose posts part then failed or was skipped drops\n * every address the blog could have taken. None while the blog was written.\n */\nexport function aiSiteUnwrittenBlogHrefs(blogUnwritten: boolean | undefined): string[] {\n return blogUnwritten ? AI_SITE_BLOG_SLUGS.map((slug) => `/${slug}`) : []\n}\n\n/**\n * The layout's nodes with its links to the retired starter home pointed at\n * the new home, its links to pages the start did not write taken out, and a\n * link for each proposed entry the header does not already carry, added by\n * the navigation op's `aiLayoutWithMenuChanges` (AGL-3747): to the header's\n * menu and its phone menu, after their items, or after the brand in a\n * starter's Toolbar. `null` when nothing changes, or when the layout has no\n * header to hold an entry and no link to repoint or take out.\n */\nexport function aiLayoutWithNavigation(\n nodes: NodesMap,\n input: {\n entries: readonly NavEntry[]\n retiredHomeId?: string | null\n homeId?: string | null\n /** Paths whose links come out: a blog the start linked and never wrote (AGL-3660). */\n droppedHrefs?: readonly string[]\n /** Pages whose links come out: a page the start planned and did not put live (AGL-3988). */\n droppedScreenIds?: readonly string[]\n },\n): NodesMap | null {\n const map: Record<string, MutableNode> = {}\n for (const [id, node] of Object.entries(nodes as unknown as Record<string, MutableNode>)) {\n map[id] = { ...node, ...(node.props ? { props: { ...node.props } } : {}), ...(node.nodes ? { nodes: [...node.nodes] } : {}) }\n }\n let changed = false\n // The header, the phone menu and the footer link a blog by its path before\n // its posts are written (AGL-3660); a start whose posts were not written\n // publishes none of those links to a page that does not exist. Nor does a\n // start link a page it planned and did not put live (AGL-3988): the\n // beta.270 Sugar Hollow header linked its refused Galleries page.\n const dropped = new Set(input.droppedHrefs ?? [])\n const unbuilt = new Set(input.droppedScreenIds ?? [])\n if (dropped.size || unbuilt.size) {\n const gone = new Set(\n Object.entries(map)\n .filter(\n ([, node]) =>\n node.componentId === 'muiScreenLink' &&\n (dropped.has(String(node.props?.['href'] ?? '')) || unbuilt.has(String(node.props?.['screenId'] ?? ''))),\n )\n .map(([id]) => id),\n )\n if (gone.size) {\n for (const id of gone) delete map[id]\n for (const node of Object.values(map)) {\n if (node.nodes?.some((child) => gone.has(child))) node.nodes = node.nodes.filter((child) => !gone.has(child))\n }\n // A footer heading whose links all went goes with them, and its column\n // when that leaves it only the heading (AGL-3735).\n aiLayoutRepairFrameHollows(map as unknown as Record<string, unknown>)\n changed = true\n }\n }\n const links = Object.values(map).filter((node) => node.componentId === 'muiScreenLink')\n if (input.retiredHomeId && input.homeId) {\n for (const link of links) {\n if (link.props?.['screenId'] === input.retiredHomeId) {\n link.props = { ...link.props, screenId: input.homeId }\n changed = true\n }\n }\n }\n // The entries go into the header through the navigation op's own code\n // (AGL-3747): the bar's menu and the phone menu's, after the items already\n // there, each looking like its neighbours. A page some link already opens,\n // or an item of the same name, is not added again.\n const linked = new Set(links.map((link) => link.props?.['screenId']).filter(Boolean))\n const missing = input.entries.filter((entry) => !linked.has(entry.screenId))\n if (missing.length) {\n const added = aiLayoutWithMenuChanges(\n map,\n ['header'],\n { ...aiNoMenuChanges(), add: missing.map((entry) => ({ parent: null, label: entry.label, to: { screenId: entry.screenId } })) },\n { newId: () => `ai_nav_${createResourceUid()}` },\n )\n if (added.nodes) return added.nodes as unknown as NodesMap\n }\n return changed ? (map as unknown as NodesMap) : null\n}\n\n/** Elements that only frame what they hold, which go once a link taken out leaves them nothing. */\nconst LINK_FRAMES = new Set(['muiStack', 'muiBox', 'muiGrid', 'muiButtonGroup', 'muiCardActions'])\n\n/**\n * A page's nodes with every link to a page the start did not put live taken\n * out (AGL-3988), and every frame that held only such links with them, up to\n * its section: a published site never links to a 404. The beta.270 Sugar\n * Hollow home page linked its refused Galleries page from \"See the\n * galleries\" and the dataset band's \"View all galleries\". A link is a Page\n * Link to one of `screenIds`; anything else that opens one (a picture) keeps\n * its place and loses the link. `null` when nothing links one. Pure.\n */\nexport function aiPageWithoutLinksTo(nodes: NodesMap, screenIds: readonly string[]): NodesMap | null {\n const missing = new Set(screenIds.filter(Boolean))\n if (!missing.size) return null\n const map: Record<string, MutableNode> = {}\n for (const [id, node] of Object.entries(nodes as unknown as Record<string, MutableNode>)) {\n map[id] = { ...node, ...(node.props ? { props: { ...node.props } } : {}), ...(node.nodes ? { nodes: [...node.nodes] } : {}) }\n }\n const opensMissing = (node: MutableNode | undefined) => missing.has(String(node?.props?.['screenId'] ?? ''))\n const ids = Object.keys(map).filter((id) => opensMissing(map[id]))\n if (!ids.length) return null\n const parentOf = (id: string) => Object.keys(map).find((key) => map[key]?.nodes?.includes(id)) ?? null\n const removeTree = (id: string) => {\n for (const child of [...(map[id]?.nodes ?? [])]) removeTree(child)\n delete map[id]\n }\n for (const id of ids) {\n const node = map[id]\n if (!node) continue\n if (node.componentId !== 'muiScreenLink') {\n const props = { ...(node.props ?? {}) }\n delete props['screenId']\n node.props = props\n continue\n }\n let parent = parentOf(id)\n if (parent) map[parent] = { ...(map[parent] as MutableNode), nodes: (map[parent]?.nodes ?? []).filter((child) => child !== id) }\n removeTree(id)\n // The frames it leaves empty, never a section nor the page's root.\n while (parent && map[parent] && !(map[parent]?.nodes ?? []).length && LINK_FRAMES.has(String(map[parent]?.componentId))) {\n const above = parentOf(parent)\n if (!above) break\n map[above] = { ...(map[above] as MutableNode), nodes: (map[above]?.nodes ?? []).filter((child) => child !== parent) }\n delete map[parent]\n parent = above\n }\n }\n return map as unknown as NodesMap\n}\n\n/** The blog a start writes, as its header entry links it (`aiSiteBlogNavPage`). */\nexport interface AiSiteBlogEntry {\n label: string\n href: string\n}\n\n/**\n * The layout's nodes with the blog's header entry put back (AGL-3747): a\n * start whose posts part failed published with every link to the blog taken\n * out (AGL-3660), and Try again's posts went live with none to reach them.\n * Added by the navigation op's `aiLayoutWithMenuChanges`, as the start's\n * other entries are — the bar's menu and the phone menu — second after the\n * home page's item, as the start first linked it (AGL-3676), else last.\n * `null` where some link already opens the blog, or the layout has no header\n * menu to hold it.\n */\nexport function aiLayoutWithBlogEntry(\n nodes: NodesMap,\n input: { blog: AiSiteBlogEntry; homeId?: string | null },\n): NodesMap | null {\n const blogHrefs = new Set([input.blog.href, ...AI_SITE_BLOG_SLUGS.map((slug) => `/${slug}`)])\n const linked = Object.values(nodes as unknown as Record<string, MutableNode>).some(\n (node) => node?.componentId === 'muiScreenLink' && blogHrefs.has(String(node.props?.['href'] ?? '')),\n )\n if (linked) return null\n const home = [...(input.homeId ? [{ screenId: input.homeId }] : []), { href: '/' }]\n const added = aiLayoutWithMenuChanges(\n nodes as unknown as Record<string, unknown>,\n ['header'],\n { ...aiNoMenuChanges(), add: [{ parent: null, label: input.blog.label, to: { href: input.blog.href }, after: home }] },\n { newId: () => `ai_nav_${createResourceUid()}` },\n )\n return (added.nodes as unknown as NodesMap | null) ?? null\n}\n\n/**\n * Puts the blog's header entry back on a live start whose posts Try again\n * wrote (AGL-3747), as a new live version of the layout its published pages\n * render inside, in one batch with the publish outbox entry that drops the\n * live site's cached pages, the drop itself attempted at once. Returns\n * whether the entry went live; never throws for a layout it cannot change.\n */\nexport async function aiRestoreGuidedBlogEntry(\n firestore: Firestore,\n input: {\n job: Pick<AiJob, '$id' | 'hostId'>\n /** The start's published pages: the layout they share is the one changed. */\n pageIds: readonly string[]\n /** The published home page, which the blog's entry follows. */\n homeId?: string | null\n blog: AiSiteBlogEntry\n now: Date\n },\n deps: Pick<AiSitePublishDeps, 'dropCache'> = {},\n): Promise<boolean> {\n const dropCache = deps.dropCache ?? dropPluginSiteCache\n const hostId = input.job.hostId ?? ''\n if (!hostId || !input.pageIds.length) return false\n const layoutId = await aiPagesLayoutId(firestore, hostId, input.pageIds)\n if (!layoutId) return false\n const write = await aiLayoutVersionWrite(firestore, {\n hostId,\n layoutId,\n transform: (nodes) => aiLayoutWithBlogEntry(nodes, { blog: input.blog, homeId: input.homeId ?? null }),\n storeLinks: null,\n jobId: input.job.$id,\n now: input.now,\n displayName: 'Navigation for the blog',\n })\n if (!write?.version) return false\n const batch = firestore.batch()\n batch.create(write.versionRef, write.version)\n batch.set(write.layoutRef, { versionId: write.versionRef.id, updatedAt: input.now }, { merge: true })\n // A layout change reaches every page, so the announce asks for the whole site.\n const outboxRef = firestore.collection('publishOutbox').doc(createResourceUid())\n batch.set(outboxRef, {\n hostId,\n paths: [SCREEN_ROOT_PATH],\n createdAt: FieldValue.serverTimestamp(),\n attempts: 0,\n entireHost: true,\n })\n await batch.commit()\n const dropped = await dropCache({ hostIds: [hostId], reason: 'guided AI site start linked its blog' })\n if (dropped.complete) await outboxRef.delete().catch(() => undefined)\n return true\n}\n\n/**\n * A retry's publish merged into the start's first (AGL-3730): the pages it\n * put live join the published list, a page it published leaves the drafts,\n * and a page it left a draft is reported with its newest reason.\n */\nexport function aiMergeSitePublish(previous: AiJobSitePublish, retried: AiJobSitePublish): AiJobSitePublish {\n const now = new Set([...retried.published, ...retried.drafts].map((page) => page.id))\n return {\n liveUrl: retried.liveUrl ?? previous.liveUrl,\n published: [...previous.published.filter((page) => !now.has(page.id)), ...retried.published],\n drafts: [...previous.drafts.filter((page) => !now.has(page.id)), ...retried.drafts],\n }\n}\n\n/**\n * Publishes the pages a guided site start built. Never throws for a page; a\n * Firestore failure of the publish write itself reports every page as a\n * draft, for the same reason, and is logged.\n */\nexport async function aiPublishGuidedSite(\n firestore: Firestore,\n input: {\n job: Pick<AiJob, '$id' | 'orgId' | 'hostId'> & Partial<Pick<AiJob, 'inputs'>>\n outputs: readonly AiJobOutput[]\n now: Date\n /** The start owed its blog's posts and wrote none (AGL-3660): its links to the blog come out. */\n blogUnwritten?: boolean\n /** Paths the layout links that the start did not write, such as a store page (AGL-3676): their links come out. */\n unwrittenHrefs?: readonly string[]\n /**\n * The pages the start planned and did not build (AGL-3988): a page its\n * checks refused. Every link to one — the header's, the footer's, a\n * button's on a page going live — comes out, and so does every link to\n * a page this publish leaves a draft.\n */\n unbuiltScreenIds?: readonly string[]\n /**\n * The start's pages in the order the site lists them (AGL-3988): a page\n * going live with no place of its own in Pages takes its place there, so\n * the 404 page's links follow the site's order, never the alphabet.\n */\n siteOrder?: readonly string[]\n /** A store's links a build drafted into the site's own layout (AGL-3676), which go live with its pages. */\n storeLinks?: AiSitePublishStoreLinks | null\n /**\n * The start published once already, and Try again rebuilt what failed\n * (AGL-3730): only `outputs` go live, beside what is. The home address is\n * never taken from the starter here, the starter is never retired, and\n * `site_published` is not sent again; a retried page at `/` that the\n * starter still holds stays a draft and says so.\n */\n retry?: boolean\n /**\n * The language the plan says the brief and copy are in (AGL-3750): the\n * site publishes in it, where `aiSiteLanguageUpdates` says so.\n */\n language?: string | null\n },\n deps: AiSitePublishDeps = {},\n): Promise<AiJobSitePublish> {\n const sendSitePublished = deps.sendSitePublished ?? sendGa4SitePublished\n const dropCache = deps.dropCache ?? dropPluginSiteCache\n const { job, now } = input\n const hostId = job.hostId ?? ''\n const pages = input.outputs.filter(\n (output, index, all) =>\n output.resource === 'screen' &&\n (output.hostId ?? hostId) === hostId &&\n all.findIndex((other) => other.resource === 'screen' && other.id === output.id) === index,\n )\n const hostRef = firestore.collection('hosts').doc(hostId)\n const host = await hostRef.get()\n const result: AiJobSitePublish = {\n liveUrl: aiSiteLiveUrl({ cname: host.get('cname'), subdomain: host.get('subdomain') }),\n published: [],\n drafts: [],\n }\n if (!host.exists || !pages.length) return result\n\n const before = { ...((host.get('screens') ?? {}) as Record<string, string>) }\n const starter = (host.get('defaultHomeScreenId') as string | undefined) || null\n // A retry never takes `/` from the starter (AGL-3730): it holds it like any page.\n const placeholder = input.retry ? null : starter\n const routing = { ...before }\n const entries: Record<string, string> = {}\n const accepted: Array<{ id: string; label: string; path: string; slug: string; order?: number }> = []\n const siteOrder = input.siteOrder ?? []\n for (const page of pages) {\n const snapshot = await hostRef.collection('screens').doc(page.id).get()\n const label = String(snapshot.get('displayName') ?? page.label ?? '') || page.label\n if (!snapshot.exists || snapshot.get('deletedAt') != null) {\n result.drafts.push({ id: page.id, label, reason: AI_SITE_PUBLISH_DELETED })\n continue\n }\n const slug = normalizeScreenSlug(String(snapshot.get('slug') ?? ''))\n if (!slug) {\n result.drafts.push({ id: page.id, label, reason: AI_SITE_PUBLISH_NO_ADDRESS })\n continue\n }\n const owner = blockingRouteOwner(routing, slug, placeholder)\n if (owner && owner !== page.id) {\n result.drafts.push({ id: page.id, label, reason: aiSitePublishTakenCopy(slug) })\n continue\n }\n routing[page.id] = slug\n entries[page.id] = slug\n // Its place in Pages, where the owner has not given it one (AGL-3988).\n const place = siteOrder.indexOf(page.id)\n const placed = typeof snapshot.get('order') === 'number'\n accepted.push({ id: page.id, label, path: slug, slug, ...(place >= 0 && !placed ? { order: place } : {}) })\n }\n if (!accepted.length) return result\n\n // A page that is not live once this publish is done — planned and never\n // built, or left a draft just now — is linked from nowhere (AGL-3988).\n const live = new Set([...accepted.map((page) => page.id), ...Object.keys(before)])\n const notLive = [...new Set([...(input.unbuiltScreenIds ?? []), ...result.drafts.map((page) => page.id)])].filter(\n (id) => id && !live.has(id),\n )\n if (notLive.length) {\n for (const page of accepted) {\n await updateAiDraftNodes(firestore, {\n kind: 'screen',\n hostId,\n id: page.id,\n now,\n update: (nodes) => aiPageWithoutLinksTo(nodes, notLive),\n }).catch((error: unknown) => {\n console.error('ai site publish: links to an unbuilt page not taken out', { hostId, jobId: job.$id, pageId: page.id, error })\n })\n }\n }\n\n // The first real home page replaces the placeholder in the same write.\n const home = accepted.find((page) => page.path === SCREEN_ROOT_PATH) ?? null\n const releases =\n home && placeholder && placeholder !== home.id && before[placeholder] === SCREEN_ROOT_PATH\n ? placeholder\n : null\n // An untouched starter home (still its one first version) is retired to the\n // trash; one its owner edited stays in Pages as their draft.\n const retire = releases\n ? (await hostRef.collection('screens').doc(releases).collection('versions').limit(2).get()).size <= 1\n : false\n\n // The header of the layout the pages render inside learns their entries.\n const layoutWrite = await aiNavigationLayoutWrite(firestore, {\n hostId,\n pageIds: accepted.map((page) => page.id),\n entries: navEntriesOf(pages).filter((entry) => entries[entry.screenId]),\n droppedHrefs: [...aiSiteUnwrittenBlogHrefs(input.blogUnwritten), ...(input.unwrittenHrefs ?? [])],\n droppedScreenIds: notLive,\n retiredHomeId: releases,\n homeId: home?.id ?? null,\n jobId: job.$id,\n now,\n storeLinks: input.storeLinks ?? null,\n }).catch((error: unknown) => {\n console.error('ai site publish: navigation not applied', { hostId, jobId: job.$id, error })\n return null\n })\n // A store's links drafted into a layout the pages' navigation did not touch go live on their own.\n const storeLinks = input.storeLinks ?? null\n const storeLinksWrite =\n storeLinks && layoutWrite?.layoutRef.id !== storeLinks.layoutId\n ? await aiLayoutVersionWrite(firestore, {\n hostId,\n layoutId: storeLinks.layoutId,\n transform: () => null,\n storeLinks,\n jobId: job.$id,\n now,\n }).catch((error: unknown) => {\n console.error('ai site publish: store links not applied', { hostId, jobId: job.$id, error })\n return null\n })\n : null\n const layoutWrites = [layoutWrite, storeLinksWrite].filter((write): write is LayoutWrite => Boolean(write))\n\n const paths = [\n ...new Set(\n [\n ...Object.values(entries),\n ...(releases ? [SCREEN_ROOT_PATH] : []),\n ].map((path) => screenRoutePathToUrl(path)),\n ),\n ]\n const batch = firestore.batch()\n const hostUpdates: Record<string, unknown> = { updatedAt: now }\n for (const [id, path] of Object.entries(entries)) hostUpdates[`screens.${id}`] = path\n if (releases) {\n hostUpdates[`screens.${releases}`] = FieldValue.delete()\n hostUpdates['defaultHomeScreenId'] = FieldValue.delete()\n batch.set(\n hostRef.collection('screens').doc(releases),\n { publishedAt: FieldValue.delete(), ...(retire ? { deletedAt: now } : {}) },\n { merge: true },\n )\n } else if (placeholder && entries[placeholder]) {\n hostUpdates['defaultHomeScreenId'] = FieldValue.delete()\n }\n // The site's language, from its plan (AGL-3750): every page's `<html lang>`\n // reads it, so the announce below asks for the whole site.\n const language = aiSiteLanguageUpdates(\n { locales: host.get('locales'), defaultLocale: host.get('defaultLocale') },\n input.language,\n )\n if (language) Object.assign(hostUpdates, language)\n // Who publishes the site, from the start's answers (AGL-3979): its Setup ->\n // SEO -> Entity and AI agents fields and its Business details, each only\n // where empty, so every page's structured data and the site's /llms.txt\n // name its business type, phone, email, address, hours, areas, profiles and\n // logo. Every page carries the entity, so the announce asks for the whole\n // site when any of it changes.\n const siteName = typeof host.get('displayName') === 'string' ? (host.get('displayName') as string) : null\n const entity = aiSiteEntityUpdates(\n host.get('seo'),\n aiSiteEntityValues(job.inputs, { language: input.language ?? null, siteName }),\n { logoUrl: host.get('logoUrl'), business: host.get('business') },\n )\n Object.assign(hostUpdates, entity)\n // The site's own listing (AGL-3979): the start's, with the site's name,\n // over the title and description its creation seeded and nowhere else. A\n // listing the owner changed keeps their words, and the SEO section still\n // offers the start's beside them. Every page falls back to it, and\n // `og:site_name` and /llms.txt read it, so it asks for the whole site too.\n const listing = aiSiteListingUpdates(\n host.get('seo'),\n siteName,\n aiSiteSeoProposalForInputs(job.inputs, input.language ?? null, siteName),\n )\n Object.assign(hostUpdates, listing)\n const entireHost =\n layoutWrites.length > 0 || language !== null || Object.keys(entity).length > 0 || Object.keys(listing).length > 0\n batch.update(hostRef, hostUpdates)\n for (const page of accepted) {\n batch.set(\n hostRef.collection('screens').doc(page.id),\n { slug: page.slug, publishedAt: now, ...(page.order !== undefined ? { order: page.order } : {}) },\n { merge: true },\n )\n }\n for (const write of layoutWrites) {\n if (write.version) batch.create(write.versionRef, write.version)\n batch.set(write.layoutRef, { versionId: write.versionRef.id, updatedAt: now }, { merge: true })\n }\n // The announce, written down in the publish's own batch (AGL-2575): a\n // layout change reaches every page, so it asks for the whole site.\n const outboxRef = firestore.collection('publishOutbox').doc(createResourceUid())\n batch.set(outboxRef, {\n hostId,\n paths: paths.length ? paths : [SCREEN_ROOT_PATH],\n createdAt: FieldValue.serverTimestamp(),\n attempts: 0,\n ...(entireHost ? { entireHost: true } : {}),\n })\n try {\n await batch.commit()\n } catch (error) {\n console.error('ai site publish failed', { hostId, jobId: job.$id, error })\n for (const page of accepted) result.drafts.push({ id: page.id, label: page.label, reason: AI_SITE_PUBLISH_FAILED })\n return result\n }\n result.published = accepted.map(({ id, label, path }) => ({ id, label, path: screenRoutePathToUrl(path) }))\n\n // The live site's cached pages go now; the outbox entry stays for the\n // drain unless the drop certainly happened.\n const dropped = await dropCache({\n hostIds: [hostId],\n reason: 'guided AI site start published',\n ...(entireHost ? {} : { paths: { [hostId]: paths } }),\n })\n if (dropped.complete) await outboxRef.delete().catch(() => undefined)\n // A site that came alive with nobody's browser on the publish (AGL-1589),\n // announced once: a retry's pages join a site already announced (AGL-3730).\n if (!input.retry) await sendSitePublished({ hostId, firstPublish: isFirstPublishedRoute(before, placeholder) })\n return result\n}\n\ninterface LayoutWrite {\n layoutRef: FirebaseFirestore.DocumentReference\n versionRef: FirebaseFirestore.DocumentReference\n /** The new version to create; `null` where the live version becomes one already written (a store's links draft). */\n version: Record<string, unknown> | null\n}\n\n/**\n * The new live version of the layout the published pages render inside, with\n * their navigation entries and the home link moved off a retired starter;\n * `null` when there is nothing to change or no one layout to change.\n */\nasync function aiNavigationLayoutWrite(\n firestore: Firestore,\n input: {\n hostId: string\n pageIds: readonly string[]\n entries: readonly NavEntry[]\n droppedHrefs: readonly string[]\n droppedScreenIds: readonly string[]\n retiredHomeId: string | null\n homeId: string | null\n jobId: string\n now: Date\n storeLinks?: AiSitePublishStoreLinks | null\n },\n): Promise<LayoutWrite | null> {\n if (!input.entries.length && !input.retiredHomeId && !input.droppedHrefs.length && !input.droppedScreenIds.length && !input.storeLinks) return null\n const layoutId = await aiPagesLayoutId(firestore, input.hostId, input.pageIds)\n if (!layoutId) return null\n return aiLayoutVersionWrite(firestore, {\n hostId: input.hostId,\n layoutId,\n transform: (nodes) => aiLayoutWithNavigation(nodes, input),\n storeLinks: input.storeLinks ?? null,\n jobId: input.jobId,\n now: input.now,\n })\n}\n\n/** The one layout the pages render inside, by their current versions; `null` where they do not share one. */\nasync function aiPagesLayoutId(firestore: Firestore, hostId: string, pageIds: readonly string[]): Promise<string | null> {\n const hostRef = firestore.collection('hosts').doc(hostId)\n const layoutIds = new Set<string>()\n for (const id of pageIds) {\n const screen = await hostRef.collection('screens').doc(id).get()\n const versionId = screen.get('versionId')\n const version =\n typeof versionId === 'string' && versionId\n ? await hostRef.collection('screens').doc(id).collection('versions').doc(versionId).get()\n : null\n const layoutId = version?.get('layoutId') ?? screen.get('layoutId')\n if (typeof layoutId === 'string' && layoutId) layoutIds.add(layoutId)\n }\n return layoutIds.size === 1 ? [...layoutIds][0] : null\n}\n\n/**\n * The new live version of one layout: `transform` applied to the version\n * live now. A store's links drafted into this layout (AGL-3676) start it from\n * that draft while the draft was made from the live version, and are added\n * to the live version otherwise; a draft with nothing more to add becomes\n * the live version as it is. `null` when nothing changes.\n */\nasync function aiLayoutVersionWrite(\n firestore: Firestore,\n input: {\n hostId: string\n layoutId: string\n transform: (nodes: NodesMap) => NodesMap | null\n storeLinks: AiSitePublishStoreLinks | null\n jobId: string\n now: Date\n /** The new version's name in the layout's versions. */\n displayName?: string\n },\n): Promise<LayoutWrite | null> {\n const { layoutId } = input\n const layoutRef = firestore.collection('hosts').doc(input.hostId).collection('layouts').doc(layoutId)\n const layout = await layoutRef.get()\n const currentVersionId = layout.get('versionId')\n if (!layout.exists || layout.get('deletedAt') != null || typeof currentVersionId !== 'string') return null\n const current = await layoutRef.collection('versions').doc(currentVersionId).get()\n const links = input.storeLinks?.layoutId === layoutId ? input.storeLinks : null\n const draftRef = links ? layoutRef.collection('versions').doc(links.versionId) : null\n const draft = draftRef ? await draftRef.get() : null\n const fromDraft = Boolean(draft?.exists && draft.get(STORE_LINKS_SOURCE_FIELD) === currentVersionId)\n const base = fromDraft && draft ? draft : current\n const nodes = base.exists ? decodeStoredNodes<NodesMap>(base.get('nodes')) : null\n if (!nodes) return null\n let next = input.transform(nodes)\n if (links && !fromDraft) {\n const added = aiLayoutWithStoreLinks((next ?? nodes) as never, links.links, links.screenPaths)\n next = (added.nodes as NodesMap | null) ?? next\n }\n // What a publish puts live has no hollow heading, column or menu (AGL-3735).\n next = (aiLayoutWithoutFrameHollows((next ?? nodes) as unknown as Record<string, unknown>) as NodesMap | null) ?? next\n const hollow = aiLayoutFrameHollows((next ?? nodes) as unknown as Record<string, unknown>)\n if (aiLayoutFrameIsHollow(hollow)) {\n console.error('ai site publish: a layout is still hollow after its repair', { layoutId, hollow: aiLayoutFrameHollowsSaid(hollow) })\n }\n if (!next) return fromDraft && draftRef ? { layoutRef, versionRef: draftRef, version: null } : null\n const packed = encodeStoredNodes(next)\n if (!packed) return null\n const versionRef = layoutRef.collection('versions').doc(createResourceUid())\n return {\n layoutRef,\n versionRef,\n version: {\n layoutId,\n hostId: input.hostId,\n displayName: input.displayName ?? 'Navigation for the new pages',\n nodes: Buffer.from(packed),\n createdAt: input.now,\n updatedAt: input.now,\n aiJobId: input.jobId,\n },\n }\n}\n"],"names":["isFirstPublishedRoute","createResourceUid","hostPublicOrigin","blockingRouteOwner","normalizeScreenSlug","SCREEN_ROOT_PATH","screenRoutePathToUrl","resolvePageLocale","siteLanguageCode","decodeStoredNodes","encodeStoredNodes","dropPluginSiteCache","sendGa4SitePublished","FieldValue","aiLayoutFrameHollows","aiLayoutFrameHollowsSaid","aiLayoutFrameIsHollow","aiLayoutRepairFrameHollows","aiLayoutWithoutFrameHollows","AI_SITE_BLOG_SLUGS","aiSiteEntityUpdates","aiSiteEntityValues","aiSiteListingUpdates","aiSiteSeoProposalForInputs","aiLayoutWithStoreLinks","aiLayoutWithMenuChanges","aiNoMenuChanges","AI_STORE_LINKS_SOURCE_FIELD","STORE_LINKS_SOURCE_FIELD","updateAiDraftNodes","aiJobPublishesBuild","job","kind","inputs","aiSiteLanguageUpdates","host","language","code","locales","Array","isArray","filter","one","trim","length","current","defaultLocale","aiJobPublishesSite","aiSiteLiveUrl","text","value","origin","cname","subdomain","AI_SITE_PUBLISH_DELETED","AI_SITE_PUBLISH_NO_ADDRESS","aiSitePublishTakenCopy","path","AI_SITE_PUBLISH_FAILED","navEntriesOf","outputs","entries","output","resource","navigation","proposal","label","some","entry","screenId","id","push","aiSiteUnwrittenBlogHrefs","blogUnwritten","map","slug","aiLayoutWithNavigation","nodes","input","node","Object","props","changed","dropped","Set","droppedHrefs","unbuilt","droppedScreenIds","size","gone","componentId","has","String","values","child","links","retiredHomeId","homeId","link","linked","Boolean","missing","added","add","parent","to","newId","LINK_FRAMES","aiPageWithoutLinksTo","screenIds","opensMissing","ids","keys","parentOf","find","key","includes","removeTree","above","aiLayoutWithBlogEntry","blogHrefs","blog","href","home","after","aiRestoreGuidedBlogEntry","firestore","deps","dropCache","hostId","pageIds","layoutId","aiPagesLayoutId","write","aiLayoutVersionWrite","transform","storeLinks","jobId","$id","now","displayName","version","batch","create","versionRef","set","layoutRef","versionId","updatedAt","merge","outboxRef","collection","doc","paths","createdAt","serverTimestamp","attempts","entireHost","commit","hostIds","reason","complete","delete","catch","undefined","aiMergeSitePublish","previous","retried","published","drafts","page","liveUrl","aiPublishGuidedSite","accepted","sendSitePublished","pages","index","all","findIndex","other","hostRef","get","result","exists","before","starter","placeholder","retry","routing","siteOrder","snapshot","owner","place","indexOf","placed","order","live","notLive","unbuiltScreenIds","update","error","console","pageId","releases","retire","limit","layoutWrite","aiNavigationLayoutWrite","unwrittenHrefs","storeLinksWrite","layoutWrites","hostUpdates","publishedAt","deletedAt","assign","siteName","entity","logoUrl","business","listing","firstPublish","layoutIds","screen","layout","currentVersionId","draftRef","draft","fromDraft","base","next","screenPaths","hollow","packed","Buffer","from","aiJobId"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,q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WAAWtE,MAAM6D,GAAG;YACpBgG,SAAS7J,MAAM2D,KAAK;QACtB;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-publish.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isFirstPublishedRoute } from '@aglyn/aglyn/app-utils/analytics-events'\nimport { createResourceUid } from '@aglyn/aglyn/app-utils/create-resource-uid'\nimport { hostPublicOrigin } from '@aglyn/aglyn/app-utils/host-naming'\nimport {\n blockingRouteOwner,\n normalizeScreenSlug,\n SCREEN_ROOT_PATH,\n screenRoutePathToUrl,\n} from '@aglyn/aglyn/app-utils/screen-route'\nimport { resolvePageLocale, siteLanguageCode } from '@aglyn/aglyn/app-utils/seo-locale'\nimport { decodeStoredNodes, encodeStoredNodes } from '@aglyn/aglyn/app-utils/stored-nodes'\nimport { dropPluginSiteCache } from '@aglyn/aglyn/plugin-manager/plugin-site-cache'\nimport { CANVAS_ROOT_ELEMENT_ID } from '@aglyn/aglyn/foundation/constants/canvas'\nimport type { NodesMap } from '@aglyn/aglyn/types/nodes'\nimport { sendGa4SitePublished } from '@aglyn/tenant-data-admin/server/ga4-measurement-protocol'\nimport { FieldValue, type Firestore } from 'firebase-admin/firestore'\nimport {\n aiLayoutFrameHollows,\n aiLayoutFrameHollowsSaid,\n aiLayoutFrameIsHollow,\n aiLayoutRepairFrameHollows,\n aiLayoutWithoutFrameHollows,\n} from '../layout-language/ai-layout-frame-hollows'\nimport type { AiJob, AiJobOutput, AiJobSitePublish } from '../model/ai-jobs.types'\nimport { AI_SITE_BLOG_SLUGS } from '../model/ai-site-job'\nimport { aiSiteEntityUpdates, aiSiteEntityValues, aiSiteListingUpdates } from '../model/ai-site-entity'\nimport { aiSiteSeoProposalForInputs } from '../model/ai-site-start-seo'\nimport { aiLayoutWithStoreLinks, type AiStoreLayoutLinks } from '../model/ai-layout-store-links'\nimport { aiLayoutWithMenuChanges, aiNoMenuChanges } from '../model/ai-layout-menus'\nimport { AI_STORE_LINKS_SOURCE_FIELD as STORE_LINKS_SOURCE_FIELD } from './ai-job-store-links-layout'\nimport { readAiDraftNodes, updateAiDraftNodes } from './ai-job-drafts'\nimport { aiSiteIsStarterSrc } from '../model/ai-site-photos'\nimport type { AiLayoutPicturePhoto } from '../layout-language/ai-layout-pictures'\n\n/**\n * A store's links a build drafted into the site's own layout (AGL-3676): the\n * draft version, the links in it, and the site's page addresses they were\n * checked against. Its publish makes that version the live one, or — where\n * the layout changed since the draft was made — adds the same links to the\n * version that is live now.\n */\nexport interface AiSitePublishStoreLinks {\n layoutId: string\n versionId: string\n links: AiStoreLayoutLinks\n screenPaths?: Readonly<Record<string, string>>\n}\n\n/**\n * A guided site start publishes what it built (AGL-3596).\n *\n * A person who asked for \"a website\" in the guided start and watched it build\n * was then handed drafts: a site whose address still answered with the\n * starter, or with nothing. A `site` job started from the guided start (its\n * plan confirmed on the person's behalf, `inputs.autoConfirm`) therefore ends\n * by putting every page it built on the site, through the same writes a\n * person's Publish makes:\n *\n * - each page's address in the host's routing map, `publishedAt` on the page,\n * in ONE batch with the publish outbox entry that drops the live site's\n * cached pages (AGL-2575), the drop itself attempted at once;\n * - the home page takes `/` from the starter home page the site was created\n * with (AGL-3408), and an untouched starter goes to the trash rather than\n * staying beside it as a second \"Home\";\n * - the navigation entries the pages proposed are added to the header of\n * the layout they render inside, as a new live version of that layout;\n * - `site_published` once, server-side, as the scheduled publish sends it.\n *\n * A page that cannot be published — deleted meanwhile, no address, an address\n * another page holds — stays a draft and is reported with the plain sentence\n * for why. It never fails the job: the site is still built, and the person\n * fixes that one page in Pages. Every other job kind keeps producing drafts.\n *\n * The allowance is respected by construction: a draft is counted against the\n * plan's pages when it is written (`aiDraftBandRefusal`), so publishing\n * drafts adds none, and retiring the starter frees the one it held.\n */\n\nexport interface AiSitePublishDeps {\n sendSitePublished?: typeof sendGa4SitePublished\n dropCache?: typeof dropPluginSiteCache\n}\n\n/**\n * Whether a build puts its pages live (AGL-3616): only where its request\n * asked to (`publish`, set by Assist's proposal) AND the member ticked the\n * plan card's box when confirming (`publishConfirmed`, set by the resume\n * door). Every other build leaves drafts.\n */\nexport function aiJobPublishesBuild(job: Pick<AiJob, 'kind' | 'inputs'>): boolean {\n return job.kind === 'build' && job.inputs?.['publish'] === true && job.inputs?.['publishConfirmed'] === true\n}\n\n/**\n * The host fields a guided start writes for its plan's language (AGL-3750),\n * as the Languages card saves one language: `locales` of that one and\n * `defaultLocale` the same. `null` — nothing written — where the plan said no\n * valid language, where it is the language the site already publishes in\n * (English for a new site), and on a site with more than one language, whose\n * languages are the owner's decision. Nothing is translated: the pages were\n * written in the brief's language, and this says so to the reader.\n */\nexport function aiSiteLanguageUpdates(\n host: { locales?: unknown; defaultLocale?: unknown },\n language: string | null | undefined,\n): { locales: string[]; defaultLocale: string } | null {\n const code = siteLanguageCode(language)\n if (!code) return null\n const locales = Array.isArray(host.locales)\n ? host.locales.filter((one): one is string => typeof one === 'string' && one.trim() !== '')\n : []\n if (locales.length > 1) return null\n const current = resolvePageLocale({\n host: {\n ...(typeof host.defaultLocale === 'string' ? { defaultLocale: host.defaultLocale } : {}),\n locales,\n },\n })\n if (current === code) return null\n return { locales: [code], defaultLocale: code }\n}\n\n/** Whether a finished job of this shape publishes what it built. */\nexport function aiJobPublishesSite(job: Pick<AiJob, 'kind' | 'inputs'>): boolean {\n return job.kind === 'site' && job.inputs?.['autoConfirm'] === true\n}\n\n/**\n * Where a site answers: its custom domain, else its subdomain under the\n * deployment's tenant apex — never a hard-coded platform host, so a\n * self-hosted deployment links to its own sites.\n */\nexport function aiSiteLiveUrl(host: { cname?: unknown; subdomain?: unknown }): string | null {\n const text = (value: unknown) => (typeof value === 'string' ? value.trim() : '')\n const origin = hostPublicOrigin({ cname: text(host.cname) || null, subdomain: text(host.subdomain) || null })\n return origin ? `${origin}/` : null\n}\n\n/** The sentences a page that stayed a draft is reported with. */\nexport const AI_SITE_PUBLISH_DELETED = 'It was deleted before it could be published.'\nexport const AI_SITE_PUBLISH_NO_ADDRESS = 'It has no address yet. Give it one in Pages and publish it.'\nexport const aiSitePublishTakenCopy = (path: string): string =>\n `Another page is already published at ${screenRoutePathToUrl(path)}. Give this one another address in Pages and publish it.`\nexport const AI_SITE_PUBLISH_FAILED = 'It could not be published just now. Publish it from Pages.'\n\n/** A navigation entry a page proposed, as the page step reports it. */\ninterface NavEntry {\n screenId: string\n label: string\n}\n\nfunction navEntriesOf(outputs: readonly AiJobOutput[]): NavEntry[] {\n const entries: NavEntry[] = []\n for (const output of outputs) {\n if (output.resource !== 'screen') continue\n const navigation = output.proposal?.['navigation'] as { label?: unknown } | undefined\n const label = typeof navigation?.label === 'string' ? navigation.label.trim() : ''\n if (label && !entries.some((entry) => entry.screenId === output.id)) {\n entries.push({ screenId: output.id, label })\n }\n }\n return entries\n}\n\ntype MutableNode = {\n $id: string\n componentId?: string\n parentId?: string\n props?: Record<string, unknown>\n nodes?: string[]\n [key: string]: unknown\n}\n\n/**\n * The blog paths a start's layout links and must not publish (AGL-3660): its\n * header, phone menu and footer link the blog by path while the posts part is\n * still owed, so a start whose posts part then failed or was skipped drops\n * every address the blog could have taken. None while the blog was written.\n */\nexport function aiSiteUnwrittenBlogHrefs(blogUnwritten: boolean | undefined): string[] {\n return blogUnwritten ? AI_SITE_BLOG_SLUGS.map((slug) => `/${slug}`) : []\n}\n\n/**\n * The layout's nodes with its links to the retired starter home pointed at\n * the new home, its links to pages the start did not write taken out, and a\n * link for each proposed entry the header does not already carry, added by\n * the navigation op's `aiLayoutWithMenuChanges` (AGL-3747): to the header's\n * menu and its phone menu, after their items, or after the brand in a\n * starter's Toolbar. `null` when nothing changes, or when the layout has no\n * header to hold an entry and no link to repoint or take out.\n */\nexport function aiLayoutWithNavigation(\n nodes: NodesMap,\n input: {\n entries: readonly NavEntry[]\n retiredHomeId?: string | null\n homeId?: string | null\n /** Paths whose links come out: a blog the start linked and never wrote (AGL-3660). */\n droppedHrefs?: readonly string[]\n /** Pages whose links come out: a page the start planned and did not put live (AGL-3988). */\n droppedScreenIds?: readonly string[]\n },\n): NodesMap | null {\n const map: Record<string, MutableNode> = {}\n for (const [id, node] of Object.entries(nodes as unknown as Record<string, MutableNode>)) {\n map[id] = { ...node, ...(node.props ? { props: { ...node.props } } : {}), ...(node.nodes ? { nodes: [...node.nodes] } : {}) }\n }\n let changed = false\n // The header, the phone menu and the footer link a blog by its path before\n // its posts are written (AGL-3660); a start whose posts were not written\n // publishes none of those links to a page that does not exist. Nor does a\n // start link a page it planned and did not put live (AGL-3988): the\n // beta.270 Sugar Hollow header linked its refused Galleries page.\n const dropped = new Set(input.droppedHrefs ?? [])\n const unbuilt = new Set(input.droppedScreenIds ?? [])\n if (dropped.size || unbuilt.size) {\n const gone = new Set(\n Object.entries(map)\n .filter(\n ([, node]) =>\n node.componentId === 'muiScreenLink' &&\n (dropped.has(String(node.props?.['href'] ?? '')) || unbuilt.has(String(node.props?.['screenId'] ?? ''))),\n )\n .map(([id]) => id),\n )\n if (gone.size) {\n for (const id of gone) delete map[id]\n for (const node of Object.values(map)) {\n if (node.nodes?.some((child) => gone.has(child))) node.nodes = node.nodes.filter((child) => !gone.has(child))\n }\n // A footer heading whose links all went goes with them, and its column\n // when that leaves it only the heading (AGL-3735).\n aiLayoutRepairFrameHollows(map as unknown as Record<string, unknown>)\n changed = true\n }\n }\n const links = Object.values(map).filter((node) => node.componentId === 'muiScreenLink')\n if (input.retiredHomeId && input.homeId) {\n for (const link of links) {\n if (link.props?.['screenId'] === input.retiredHomeId) {\n link.props = { ...link.props, screenId: input.homeId }\n changed = true\n }\n }\n }\n // The entries go into the header through the navigation op's own code\n // (AGL-3747): the bar's menu and the phone menu's, after the items already\n // there, each looking like its neighbours. A page some link already opens,\n // or an item of the same name, is not added again.\n const linked = new Set(links.map((link) => link.props?.['screenId']).filter(Boolean))\n const missing = input.entries.filter((entry) => !linked.has(entry.screenId))\n if (missing.length) {\n const added = aiLayoutWithMenuChanges(\n map,\n ['header'],\n { ...aiNoMenuChanges(), add: missing.map((entry) => ({ parent: null, label: entry.label, to: { screenId: entry.screenId } })) },\n { newId: () => `ai_nav_${createResourceUid()}` },\n )\n if (added.nodes) return added.nodes as unknown as NodesMap\n }\n return changed ? (map as unknown as NodesMap) : null\n}\n\n/** Elements that only frame what they hold, which go once a link taken out leaves them nothing. */\nconst LINK_FRAMES = new Set(['muiStack', 'muiBox', 'muiGrid', 'muiButtonGroup', 'muiCardActions'])\n\n/**\n * A page's nodes with every link to a page the start did not put live taken\n * out (AGL-3988), and every frame that held only such links with them, up to\n * its section: a published site never links to a 404. The beta.270 Sugar\n * Hollow home page linked its refused Galleries page from \"See the\n * galleries\" and the dataset band's \"View all galleries\". A link is a Page\n * Link to one of `screenIds`; anything else that opens one (a picture) keeps\n * its place and loses the link. `null` when nothing links one. Pure.\n */\nexport function aiPageWithoutLinksTo(nodes: NodesMap, screenIds: readonly string[]): NodesMap | null {\n const missing = new Set(screenIds.filter(Boolean))\n if (!missing.size) return null\n const map: Record<string, MutableNode> = {}\n for (const [id, node] of Object.entries(nodes as unknown as Record<string, MutableNode>)) {\n map[id] = { ...node, ...(node.props ? { props: { ...node.props } } : {}), ...(node.nodes ? { nodes: [...node.nodes] } : {}) }\n }\n const opensMissing = (node: MutableNode | undefined) => missing.has(String(node?.props?.['screenId'] ?? ''))\n const ids = Object.keys(map).filter((id) => opensMissing(map[id]))\n if (!ids.length) return null\n const parentOf = (id: string) => Object.keys(map).find((key) => map[key]?.nodes?.includes(id)) ?? null\n const removeTree = (id: string) => {\n for (const child of [...(map[id]?.nodes ?? [])]) removeTree(child)\n delete map[id]\n }\n for (const id of ids) {\n const node = map[id]\n if (!node) continue\n if (node.componentId !== 'muiScreenLink') {\n const props = { ...(node.props ?? {}) }\n delete props['screenId']\n node.props = props\n continue\n }\n let parent = parentOf(id)\n if (parent) map[parent] = { ...(map[parent] as MutableNode), nodes: (map[parent]?.nodes ?? []).filter((child) => child !== id) }\n removeTree(id)\n // The frames it leaves empty, never a section nor the page's root.\n while (parent && map[parent] && !(map[parent]?.nodes ?? []).length && LINK_FRAMES.has(String(map[parent]?.componentId))) {\n const above = parentOf(parent)\n if (!above) break\n map[above] = { ...(map[above] as MutableNode), nodes: (map[above]?.nodes ?? []).filter((child) => child !== parent) }\n delete map[parent]\n parent = above\n }\n }\n return map as unknown as NodesMap\n}\n\n/** The blog a start writes, as its header entry links it (`aiSiteBlogNavPage`). */\nexport interface AiSiteBlogEntry {\n label: string\n href: string\n}\n\n/**\n * The layout's nodes with the blog's header entry put back (AGL-3747): a\n * start whose posts part failed published with every link to the blog taken\n * out (AGL-3660), and Try again's posts went live with none to reach them.\n * Added by the navigation op's `aiLayoutWithMenuChanges`, as the start's\n * other entries are — the bar's menu and the phone menu — second after the\n * home page's item, as the start first linked it (AGL-3676), else last.\n * `null` where some link already opens the blog, or the layout has no header\n * menu to hold it.\n */\nexport function aiLayoutWithBlogEntry(\n nodes: NodesMap,\n input: { blog: AiSiteBlogEntry; homeId?: string | null },\n): NodesMap | null {\n const blogHrefs = new Set([input.blog.href, ...AI_SITE_BLOG_SLUGS.map((slug) => `/${slug}`)])\n const linked = Object.values(nodes as unknown as Record<string, MutableNode>).some(\n (node) => node?.componentId === 'muiScreenLink' && blogHrefs.has(String(node.props?.['href'] ?? '')),\n )\n if (linked) return null\n const home = [...(input.homeId ? [{ screenId: input.homeId }] : []), { href: '/' }]\n const added = aiLayoutWithMenuChanges(\n nodes as unknown as Record<string, unknown>,\n ['header'],\n { ...aiNoMenuChanges(), add: [{ parent: null, label: input.blog.label, to: { href: input.blog.href }, after: home }] },\n { newId: () => `ai_nav_${createResourceUid()}` },\n )\n return (added.nodes as unknown as NodesMap | null) ?? null\n}\n\n/**\n * Puts the blog's header entry back on a live start whose posts Try again\n * wrote (AGL-3747), as a new live version of the layout its published pages\n * render inside, in one batch with the publish outbox entry that drops the\n * live site's cached pages, the drop itself attempted at once. Returns\n * whether the entry went live; never throws for a layout it cannot change.\n */\nexport async function aiRestoreGuidedBlogEntry(\n firestore: Firestore,\n input: {\n job: Pick<AiJob, '$id' | 'hostId'>\n /** The start's published pages: the layout they share is the one changed. */\n pageIds: readonly string[]\n /** The published home page, which the blog's entry follows. */\n homeId?: string | null\n blog: AiSiteBlogEntry\n now: Date\n },\n deps: Pick<AiSitePublishDeps, 'dropCache'> = {},\n): Promise<boolean> {\n const dropCache = deps.dropCache ?? dropPluginSiteCache\n const hostId = input.job.hostId ?? ''\n if (!hostId || !input.pageIds.length) return false\n const layoutId = await aiPagesLayoutId(firestore, hostId, input.pageIds)\n if (!layoutId) return false\n const write = await aiLayoutVersionWrite(firestore, {\n hostId,\n layoutId,\n transform: (nodes) => aiLayoutWithBlogEntry(nodes, { blog: input.blog, homeId: input.homeId ?? null }),\n storeLinks: null,\n jobId: input.job.$id,\n now: input.now,\n displayName: 'Navigation for the blog',\n })\n if (!write?.version) return false\n const batch = firestore.batch()\n batch.create(write.versionRef, write.version)\n batch.set(write.layoutRef, { versionId: write.versionRef.id, updatedAt: input.now }, { merge: true })\n // A layout change reaches every page, so the announce asks for the whole site.\n const outboxRef = firestore.collection('publishOutbox').doc(createResourceUid())\n batch.set(outboxRef, {\n hostId,\n paths: [SCREEN_ROOT_PATH],\n createdAt: FieldValue.serverTimestamp(),\n attempts: 0,\n entireHost: true,\n })\n await batch.commit()\n const dropped = await dropCache({ hostIds: [hostId], reason: 'guided AI site start linked its blog' })\n if (dropped.complete) await outboxRef.delete().catch(() => undefined)\n return true\n}\n\n/**\n * Whether a site's share image is the publish's to set (AGL-3988): it has\n * none, or still the starter photo every new site is created with. An image\n * its owner picked is theirs, whatever it is.\n */\nexport function aiSiteShareImageOpen(seo: unknown): boolean {\n const image = (seo as { image?: unknown } | null | undefined)?.image\n if (image === undefined || image === null) return true\n return typeof image === 'string' && (!image.trim() || aiSiteIsStarterSrc(image))\n}\n\n/** The library photos a stored page shows, in document order, each once, with whether it sits in the page's first section. */\nfunction libraryPhotosOf(nodes: NodesMap | null): Array<AiLayoutPicturePhoto & { lead: boolean }> {\n if (!nodes) return []\n const map = nodes as unknown as Record<string, { componentId?: string; props?: Record<string, unknown>; nodes?: string[] }>\n const firstSection = map[CANVAS_ROOT_ELEMENT_ID]?.nodes?.[0] ?? null\n const out: Array<AiLayoutPicturePhoto & { lead: boolean }> = []\n const seen = new Set<string>()\n const visit = (id: string, lead: boolean) => {\n if (seen.has(id)) return\n seen.add(id)\n const node = map[id]\n if (!node) return\n if (node.componentId === 'image') {\n const src = node.props?.['src']\n const width = Number(node.props?.['intrinsicWidth'])\n const height = Number(node.props?.['intrinsicHeight'])\n if (typeof src === 'string' && src.startsWith('media:') && width > 0 && height > 0) {\n const alt = typeof node.props?.['alt'] === 'string' ? (node.props['alt'] as string).trim() : ''\n out.push({ src, width, height, ...(alt ? { alt } : {}), lead })\n }\n }\n for (const child of node.nodes ?? []) visit(child, lead || child === firstSection)\n }\n visit(CANVAS_ROOT_ELEMENT_ID, false)\n return out\n}\n\n/**\n * The photo a published site's share image is set from (AGL-3988): its home\n * page's hero — the first library photo of its first section — else the\n * widest photo its pages show, a wide one first. `null` where they show no\n * library photo. The beta.271 Laurel Fork start shared an office team on a\n * wedding photographer's every link: nothing set the share image from what\n * the start built, so it kept the starter the site was created with. Pure.\n */\nexport function aiSiteSharePhoto(home: NodesMap | null, pages: ReadonlyArray<NodesMap | null>): AiLayoutPicturePhoto | null {\n const hero = libraryPhotosOf(home).find((photo) => photo.lead)\n const pick = (photo: AiLayoutPicturePhoto & { lead?: boolean }): AiLayoutPicturePhoto => ({\n src: photo.src,\n width: photo.width,\n height: photo.height,\n ...(photo.alt ? { alt: photo.alt } : {}),\n })\n if (hero) return pick(hero)\n const all = [home, ...pages].flatMap(libraryPhotosOf)\n const wide = (photo: AiLayoutPicturePhoto) => photo.width / photo.height >= 1.3\n const [best] = [...all].sort((a, b) => Number(wide(b)) - Number(wide(a)) || b.width - a.width)\n return best ? pick(best) : null\n}\n\n/** The host fields the share image is written in, as the Social image card writes them (AGL-3988). */\nexport function aiSiteShareImageUpdates(photo: AiLayoutPicturePhoto): Record<string, unknown> {\n return {\n 'seo.image': photo.src,\n 'seo.imageWidth': photo.width,\n 'seo.imageHeight': photo.height,\n 'seo.imageAlt': photo.alt?.trim() ?? '',\n }\n}\n\n/**\n * A retry's publish merged into the start's first (AGL-3730): the pages it\n * put live join the published list, a page it published leaves the drafts,\n * and a page it left a draft is reported with its newest reason.\n */\nexport function aiMergeSitePublish(previous: AiJobSitePublish, retried: AiJobSitePublish): AiJobSitePublish {\n const now = new Set([...retried.published, ...retried.drafts].map((page) => page.id))\n return {\n liveUrl: retried.liveUrl ?? previous.liveUrl,\n published: [...previous.published.filter((page) => !now.has(page.id)), ...retried.published],\n drafts: [...previous.drafts.filter((page) => !now.has(page.id)), ...retried.drafts],\n }\n}\n\n/**\n * Publishes the pages a guided site start built. Never throws for a page; a\n * Firestore failure of the publish write itself reports every page as a\n * draft, for the same reason, and is logged.\n */\nexport async function aiPublishGuidedSite(\n firestore: Firestore,\n input: {\n job: Pick<AiJob, '$id' | 'orgId' | 'hostId'> & Partial<Pick<AiJob, 'inputs'>>\n outputs: readonly AiJobOutput[]\n now: Date\n /** The start owed its blog's posts and wrote none (AGL-3660): its links to the blog come out. */\n blogUnwritten?: boolean\n /** Paths the layout links that the start did not write, such as a store page (AGL-3676): their links come out. */\n unwrittenHrefs?: readonly string[]\n /**\n * The pages the start planned and did not build (AGL-3988): a page its\n * checks refused. Every link to one — the header's, the footer's, a\n * button's on a page going live — comes out, and so does every link to\n * a page this publish leaves a draft.\n */\n unbuiltScreenIds?: readonly string[]\n /**\n * The start's pages in the order the site lists them (AGL-3988): a page\n * going live with no place of its own in Pages takes its place there, so\n * the 404 page's links follow the site's order, never the alphabet.\n */\n siteOrder?: readonly string[]\n /** A store's links a build drafted into the site's own layout (AGL-3676), which go live with its pages. */\n storeLinks?: AiSitePublishStoreLinks | null\n /**\n * The start published once already, and Try again rebuilt what failed\n * (AGL-3730): only `outputs` go live, beside what is. The home address is\n * never taken from the starter here, the starter is never retired, and\n * `site_published` is not sent again; a retried page at `/` that the\n * starter still holds stays a draft and says so.\n */\n retry?: boolean\n /**\n * The language the plan says the brief and copy are in (AGL-3750): the\n * site publishes in it, where `aiSiteLanguageUpdates` says so.\n */\n language?: string | null\n },\n deps: AiSitePublishDeps = {},\n): Promise<AiJobSitePublish> {\n const sendSitePublished = deps.sendSitePublished ?? sendGa4SitePublished\n const dropCache = deps.dropCache ?? dropPluginSiteCache\n const { job, now } = input\n const hostId = job.hostId ?? ''\n const pages = input.outputs.filter(\n (output, index, all) =>\n output.resource === 'screen' &&\n (output.hostId ?? hostId) === hostId &&\n all.findIndex((other) => other.resource === 'screen' && other.id === output.id) === index,\n )\n const hostRef = firestore.collection('hosts').doc(hostId)\n const host = await hostRef.get()\n const result: AiJobSitePublish = {\n liveUrl: aiSiteLiveUrl({ cname: host.get('cname'), subdomain: host.get('subdomain') }),\n published: [],\n drafts: [],\n }\n if (!host.exists || !pages.length) return result\n\n const before = { ...((host.get('screens') ?? {}) as Record<string, string>) }\n const starter = (host.get('defaultHomeScreenId') as string | undefined) || null\n // A retry never takes `/` from the starter (AGL-3730): it holds it like any page.\n const placeholder = input.retry ? null : starter\n const routing = { ...before }\n const entries: Record<string, string> = {}\n const accepted: Array<{ id: string; label: string; path: string; slug: string; order?: number }> = []\n const siteOrder = input.siteOrder ?? []\n for (const page of pages) {\n const snapshot = await hostRef.collection('screens').doc(page.id).get()\n const label = String(snapshot.get('displayName') ?? page.label ?? '') || page.label\n if (!snapshot.exists || snapshot.get('deletedAt') != null) {\n result.drafts.push({ id: page.id, label, reason: AI_SITE_PUBLISH_DELETED })\n continue\n }\n const slug = normalizeScreenSlug(String(snapshot.get('slug') ?? ''))\n if (!slug) {\n result.drafts.push({ id: page.id, label, reason: AI_SITE_PUBLISH_NO_ADDRESS })\n continue\n }\n const owner = blockingRouteOwner(routing, slug, placeholder)\n if (owner && owner !== page.id) {\n result.drafts.push({ id: page.id, label, reason: aiSitePublishTakenCopy(slug) })\n continue\n }\n routing[page.id] = slug\n entries[page.id] = slug\n // Its place in Pages, where the owner has not given it one (AGL-3988).\n const place = siteOrder.indexOf(page.id)\n const placed = typeof snapshot.get('order') === 'number'\n accepted.push({ id: page.id, label, path: slug, slug, ...(place >= 0 && !placed ? { order: place } : {}) })\n }\n if (!accepted.length) return result\n\n // A page that is not live once this publish is done — planned and never\n // built, or left a draft just now — is linked from nowhere (AGL-3988).\n const live = new Set([...accepted.map((page) => page.id), ...Object.keys(before)])\n const notLive = [...new Set([...(input.unbuiltScreenIds ?? []), ...result.drafts.map((page) => page.id)])].filter(\n (id) => id && !live.has(id),\n )\n if (notLive.length) {\n for (const page of accepted) {\n await updateAiDraftNodes(firestore, {\n kind: 'screen',\n hostId,\n id: page.id,\n now,\n update: (nodes) => aiPageWithoutLinksTo(nodes, notLive),\n }).catch((error: unknown) => {\n console.error('ai site publish: links to an unbuilt page not taken out', { hostId, jobId: job.$id, pageId: page.id, error })\n })\n }\n }\n\n // The first real home page replaces the placeholder in the same write.\n const home = accepted.find((page) => page.path === SCREEN_ROOT_PATH) ?? null\n const releases =\n home && placeholder && placeholder !== home.id && before[placeholder] === SCREEN_ROOT_PATH\n ? placeholder\n : null\n // An untouched starter home (still its one first version) is retired to the\n // trash; one its owner edited stays in Pages as their draft.\n const retire = releases\n ? (await hostRef.collection('screens').doc(releases).collection('versions').limit(2).get()).size <= 1\n : false\n\n // The header of the layout the pages render inside learns their entries.\n const layoutWrite = await aiNavigationLayoutWrite(firestore, {\n hostId,\n pageIds: accepted.map((page) => page.id),\n entries: navEntriesOf(pages).filter((entry) => entries[entry.screenId]),\n droppedHrefs: [...aiSiteUnwrittenBlogHrefs(input.blogUnwritten), ...(input.unwrittenHrefs ?? [])],\n droppedScreenIds: notLive,\n retiredHomeId: releases,\n homeId: home?.id ?? null,\n jobId: job.$id,\n now,\n storeLinks: input.storeLinks ?? null,\n }).catch((error: unknown) => {\n console.error('ai site publish: navigation not applied', { hostId, jobId: job.$id, error })\n return null\n })\n // A store's links drafted into a layout the pages' navigation did not touch go live on their own.\n const storeLinks = input.storeLinks ?? null\n const storeLinksWrite =\n storeLinks && layoutWrite?.layoutRef.id !== storeLinks.layoutId\n ? await aiLayoutVersionWrite(firestore, {\n hostId,\n layoutId: storeLinks.layoutId,\n transform: () => null,\n storeLinks,\n jobId: job.$id,\n now,\n }).catch((error: unknown) => {\n console.error('ai site publish: store links not applied', { hostId, jobId: job.$id, error })\n return null\n })\n : null\n const layoutWrites = [layoutWrite, storeLinksWrite].filter((write): write is LayoutWrite => Boolean(write))\n\n const paths = [\n ...new Set(\n [\n ...Object.values(entries),\n ...(releases ? [SCREEN_ROOT_PATH] : []),\n ].map((path) => screenRoutePathToUrl(path)),\n ),\n ]\n const batch = firestore.batch()\n const hostUpdates: Record<string, unknown> = { updatedAt: now }\n for (const [id, path] of Object.entries(entries)) hostUpdates[`screens.${id}`] = path\n if (releases) {\n hostUpdates[`screens.${releases}`] = FieldValue.delete()\n hostUpdates['defaultHomeScreenId'] = FieldValue.delete()\n batch.set(\n hostRef.collection('screens').doc(releases),\n { publishedAt: FieldValue.delete(), ...(retire ? { deletedAt: now } : {}) },\n { merge: true },\n )\n } else if (placeholder && entries[placeholder]) {\n hostUpdates['defaultHomeScreenId'] = FieldValue.delete()\n }\n // The site's language, from its plan (AGL-3750): every page's `<html lang>`\n // reads it, so the announce below asks for the whole site.\n const language = aiSiteLanguageUpdates(\n { locales: host.get('locales'), defaultLocale: host.get('defaultLocale') },\n input.language,\n )\n if (language) Object.assign(hostUpdates, language)\n // Who publishes the site, from the start's answers (AGL-3979): its Setup ->\n // SEO -> Entity and AI agents fields and its Business details, each only\n // where empty, so every page's structured data and the site's /llms.txt\n // name its business type, phone, email, address, hours, areas, profiles and\n // logo. Every page carries the entity, so the announce asks for the whole\n // site when any of it changes.\n const siteName = typeof host.get('displayName') === 'string' ? (host.get('displayName') as string) : null\n const entity = aiSiteEntityUpdates(\n host.get('seo'),\n aiSiteEntityValues(job.inputs, { language: input.language ?? null, siteName }),\n { logoUrl: host.get('logoUrl'), business: host.get('business') },\n )\n Object.assign(hostUpdates, entity)\n // The site's own listing (AGL-3979): the start's, with the site's name,\n // over the title and description its creation seeded and nowhere else. A\n // listing the owner changed keeps their words, and the SEO section still\n // offers the start's beside them. Every page falls back to it, and\n // `og:site_name` and /llms.txt read it, so it asks for the whole site too.\n const listing = aiSiteListingUpdates(\n host.get('seo'),\n siteName,\n aiSiteSeoProposalForInputs(job.inputs, input.language ?? null, siteName),\n )\n Object.assign(hostUpdates, listing)\n // The site's share image (AGL-3988), where it has none or the starter it\n // was created with: its home hero's photo, else its widest. Every page's\n // `og:image` falls back to it, so it asks for the whole site too.\n // A retry's home page is the one already live at the site's address.\n const homeId = home?.id ?? Object.entries(before).find(([id, path]) => path === SCREEN_ROOT_PATH && id !== starter)?.[0] ?? null\n const share = aiSiteShareImageOpen(host.get('seo'))\n ? await aiSiteSharePhotoOf(firestore, hostId, accepted, homeId).catch((error: unknown) => {\n console.error('ai site publish: the share image could not be read', { hostId, jobId: job.$id, error })\n return null\n })\n : null\n const shareImage = share ? aiSiteShareImageUpdates(share) : {}\n Object.assign(hostUpdates, shareImage)\n const entireHost =\n layoutWrites.length > 0 ||\n language !== null ||\n Object.keys(entity).length > 0 ||\n Object.keys(listing).length > 0 ||\n Object.keys(shareImage).length > 0\n batch.update(hostRef, hostUpdates)\n for (const page of accepted) {\n batch.set(\n hostRef.collection('screens').doc(page.id),\n { slug: page.slug, publishedAt: now, ...(page.order !== undefined ? { order: page.order } : {}) },\n { merge: true },\n )\n }\n for (const write of layoutWrites) {\n if (write.version) batch.create(write.versionRef, write.version)\n batch.set(write.layoutRef, { versionId: write.versionRef.id, updatedAt: now }, { merge: true })\n }\n // The announce, written down in the publish's own batch (AGL-2575): a\n // layout change reaches every page, so it asks for the whole site.\n const outboxRef = firestore.collection('publishOutbox').doc(createResourceUid())\n batch.set(outboxRef, {\n hostId,\n paths: paths.length ? paths : [SCREEN_ROOT_PATH],\n createdAt: FieldValue.serverTimestamp(),\n attempts: 0,\n ...(entireHost ? { entireHost: true } : {}),\n })\n try {\n await batch.commit()\n } catch (error) {\n console.error('ai site publish failed', { hostId, jobId: job.$id, error })\n for (const page of accepted) result.drafts.push({ id: page.id, label: page.label, reason: AI_SITE_PUBLISH_FAILED })\n return result\n }\n result.published = accepted.map(({ id, label, path }) => ({ id, label, path: screenRoutePathToUrl(path) }))\n\n // The live site's cached pages go now; the outbox entry stays for the\n // drain unless the drop certainly happened.\n const dropped = await dropCache({\n hostIds: [hostId],\n reason: 'guided AI site start published',\n ...(entireHost ? {} : { paths: { [hostId]: paths } }),\n })\n if (dropped.complete) await outboxRef.delete().catch(() => undefined)\n // A site that came alive with nobody's browser on the publish (AGL-1589),\n // announced once: a retry's pages join a site already announced (AGL-3730).\n if (!input.retry) await sendSitePublished({ hostId, firstPublish: isFirstPublishedRoute(before, placeholder) })\n return result\n}\n\n/** The share image's photo, read off the pages going live (AGL-3988). */\nasync function aiSiteSharePhotoOf(\n firestore: Firestore,\n hostId: string,\n pages: ReadonlyArray<{ id: string }>,\n homeId: string | null,\n): Promise<AiLayoutPicturePhoto | null> {\n const read = async (id: string) => (await readAiDraftNodes(firestore, { kind: 'screen', hostId, id }))?.nodes ?? null\n const [home, ...others] = await Promise.all([\n homeId ? read(homeId) : Promise.resolve(null),\n ...pages.filter((page) => page.id !== homeId).map((page) => read(page.id)),\n ])\n return aiSiteSharePhoto(home ?? null, others)\n}\n\ninterface LayoutWrite {\n layoutRef: FirebaseFirestore.DocumentReference\n versionRef: FirebaseFirestore.DocumentReference\n /** The new version to create; `null` where the live version becomes one already written (a store's links draft). */\n version: Record<string, unknown> | null\n}\n\n/**\n * The new live version of the layout the published pages render inside, with\n * their navigation entries and the home link moved off a retired starter;\n * `null` when there is nothing to change or no one layout to change.\n */\nasync function aiNavigationLayoutWrite(\n firestore: Firestore,\n input: {\n hostId: string\n pageIds: readonly string[]\n entries: readonly NavEntry[]\n droppedHrefs: readonly string[]\n droppedScreenIds: readonly string[]\n retiredHomeId: string | null\n homeId: string | null\n jobId: string\n now: Date\n storeLinks?: AiSitePublishStoreLinks | null\n },\n): Promise<LayoutWrite | null> {\n if (!input.entries.length && !input.retiredHomeId && !input.droppedHrefs.length && !input.droppedScreenIds.length && !input.storeLinks) return null\n const layoutId = await aiPagesLayoutId(firestore, input.hostId, input.pageIds)\n if (!layoutId) return null\n return aiLayoutVersionWrite(firestore, {\n hostId: input.hostId,\n layoutId,\n transform: (nodes) => aiLayoutWithNavigation(nodes, input),\n storeLinks: input.storeLinks ?? null,\n jobId: input.jobId,\n now: input.now,\n })\n}\n\n/** The one layout the pages render inside, by their current versions; `null` where they do not share one. */\nasync function aiPagesLayoutId(firestore: Firestore, hostId: string, pageIds: readonly string[]): Promise<string | null> {\n const hostRef = firestore.collection('hosts').doc(hostId)\n const layoutIds = new Set<string>()\n for (const id of pageIds) {\n const screen = await hostRef.collection('screens').doc(id).get()\n const versionId = screen.get('versionId')\n const version =\n typeof versionId === 'string' && versionId\n ? await hostRef.collection('screens').doc(id).collection('versions').doc(versionId).get()\n : null\n const layoutId = version?.get('layoutId') ?? screen.get('layoutId')\n if (typeof layoutId === 'string' && layoutId) layoutIds.add(layoutId)\n }\n return layoutIds.size === 1 ? [...layoutIds][0] : null\n}\n\n/**\n * The new live version of one layout: `transform` applied to the version\n * live now. A store's links drafted into this layout (AGL-3676) start it from\n * that draft while the draft was made from the live version, and are added\n * to the live version otherwise; a draft with nothing more to add becomes\n * the live version as it is. `null` when nothing changes.\n */\nasync function aiLayoutVersionWrite(\n firestore: Firestore,\n input: {\n hostId: string\n layoutId: string\n transform: (nodes: NodesMap) => NodesMap | null\n storeLinks: AiSitePublishStoreLinks | null\n jobId: string\n now: Date\n /** The new version's name in the layout's versions. */\n displayName?: string\n },\n): Promise<LayoutWrite | null> {\n const { layoutId } = input\n const layoutRef = firestore.collection('hosts').doc(input.hostId).collection('layouts').doc(layoutId)\n const layout = await layoutRef.get()\n const currentVersionId = layout.get('versionId')\n if (!layout.exists || layout.get('deletedAt') != null || typeof currentVersionId !== 'string') return null\n const current = await layoutRef.collection('versions').doc(currentVersionId).get()\n const links = input.storeLinks?.layoutId === layoutId ? input.storeLinks : null\n const draftRef = links ? layoutRef.collection('versions').doc(links.versionId) : null\n const draft = draftRef ? await draftRef.get() : null\n const fromDraft = Boolean(draft?.exists && draft.get(STORE_LINKS_SOURCE_FIELD) === currentVersionId)\n const base = fromDraft && draft ? draft : current\n const nodes = base.exists ? decodeStoredNodes<NodesMap>(base.get('nodes')) : null\n if (!nodes) return null\n let next = input.transform(nodes)\n if (links && !fromDraft) {\n const added = aiLayoutWithStoreLinks((next ?? nodes) as never, links.links, links.screenPaths)\n next = (added.nodes as NodesMap | null) ?? next\n }\n // What a publish puts live has no hollow heading, column or menu (AGL-3735).\n next = (aiLayoutWithoutFrameHollows((next ?? nodes) as unknown as Record<string, unknown>) as NodesMap | null) ?? next\n const hollow = aiLayoutFrameHollows((next ?? nodes) as unknown as Record<string, unknown>)\n if (aiLayoutFrameIsHollow(hollow)) {\n console.error('ai site publish: a layout is still hollow after its repair', { layoutId, hollow: aiLayoutFrameHollowsSaid(hollow) })\n }\n if (!next) return fromDraft && draftRef ? { layoutRef, versionRef: draftRef, version: null } : null\n const packed = encodeStoredNodes(next)\n if (!packed) return null\n const versionRef = layoutRef.collection('versions').doc(createResourceUid())\n return {\n layoutRef,\n versionRef,\n version: {\n layoutId,\n hostId: input.hostId,\n displayName: input.displayName ?? 'Navigation for the new pages',\n nodes: Buffer.from(packed),\n createdAt: input.now,\n updatedAt: input.now,\n aiJobId: input.jobId,\n },\n }\n}\n"],"names":["isFirstPublishedRoute","createResourceUid","hostPublicOrigin","blockingRouteOwner","normalizeScreenSlug","SCREEN_ROOT_PATH","screenRoutePathToUrl","resolvePageLocale","siteLanguageCode","decodeStoredNodes","encodeStoredNodes","dropPluginSiteCache","CANVAS_ROOT_ELEMENT_ID","sendGa4SitePublished","FieldValue","aiLayoutFrameHollows","aiLayoutFrameHollowsSaid","aiLayoutFrameIsHollow","aiLayoutRepairFrameHollows","aiLayoutWithoutFrameHollows","AI_SITE_BLOG_SLUGS","aiSiteEntityUpdates","aiSiteEntityValues","aiSiteListingUpdates","aiSiteSeoProposalForInputs","aiLayoutWithStoreLinks","aiLayoutWithMenuChanges","aiNoMenuChanges","AI_STORE_LINKS_SOURCE_FIELD","STORE_LINKS_SOURCE_FIELD","readAiDraftNodes","updateAiDraftNodes","aiSiteIsStarterSrc","aiJobPublishesBuild","job","kind","inputs","aiSiteLanguageUpdates","host","language","code","locales","Array","isArray","filter","one","trim","length","current","defaultLocale","aiJobPublishesSite","aiSiteLiveUrl","text","value","origin","cname","subdomain","AI_SITE_PUBLISH_DELETED","AI_SITE_PUBLISH_NO_ADDRESS","aiSitePublishTakenCopy","path","AI_SITE_PUBLISH_FAILED","navEntriesOf","outputs","entries","output","resource","navigation","proposal","label","some","entry","screenId","id","push","aiSiteUnwrittenBlogHrefs","blogUnwritten","map","slug","aiLayoutWithNavigation","nodes","input","node","Object","props","changed","dropped","Set","droppedHrefs","unbuilt","droppedScreenIds","size","gone","componentId","has","String","values","child","links","retiredHomeId","homeId","link","linked","Boolean","missing","added","add","parent","to","newId","LINK_FRAMES","aiPageWithoutLinksTo","screenIds","opensMissing","ids","keys","parentOf","find","key","includes","removeTree","above","aiLayoutWithBlogEntry","blogHrefs","blog","href","home","after","aiRestoreGuidedBlogEntry","firestore","deps","dropCache","hostId","pageIds","layoutId","aiPagesLayoutId","write","aiLayoutVersionWrite","transform","storeLinks","jobId","$id","now","displayName","version","batch","create","versionRef","set","layoutRef","versionId","updatedAt","merge","outboxRef","collection","doc","paths","createdAt","serverTimestamp","attempts","entireHost","commit","hostIds","reason","complete","delete","catch","undefined","aiSiteShareImageOpen","seo","image","libraryPhotosOf","firstSection","out","seen","visit","lead","src","width","Number","height","startsWith","alt","aiSiteSharePhoto","pages","hero","photo","pick","all","flatMap","wide","best","sort","a","b","aiSiteShareImageUpdates","aiMergeSitePublish","previous","retried","published","drafts","page","liveUrl","aiPublishGuidedSite","accepted","sendSitePublished","index","findIndex","other","hostRef","get","result","exists","before","starter","placeholder","retry","routing","siteOrder","snapshot","owner","place","indexOf","placed","order","live","notLive","unbuiltScreenIds","update","error","console","pageId","releases","retire","limit","layoutWrite","aiNavigationLayoutWrite","unwrittenHrefs","storeLinksWrite","layoutWrites","hostUpdates","publishedAt","deletedAt","assign","siteName","entity","logoUrl","business","listing","share","aiSiteSharePhotoOf","shareImage","firstPublish","read","others","Promise","resolve","layoutIds","screen","layout","currentVersionId","draftRef","draft","fromDraft","base","next","screenPaths","hollow","packed","Buffer","from","aiJobId"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,qBAAqB,QAAQ,0CAAyC;AAC/E,SAASC,iBAAiB,QAAQ,6CAA4C;AAC9E,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,gBAAgB,EAChBC,oBAAoB,QACf,sCAAqC;AAC5C,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,oCAAmC;AACvF,SAASC,iBAAiB,EAAEC,iBAAiB,QAAQ,sCAAqC;AAC1F,SAASC,mBAAmB,QAAQ,gDAA+C;AACnF,SAASC,sBAAsB,QAAQ,2CAA0C;AAEjF,SAASC,oBAAoB,QAAQ,2DAA0D;AAC/F,SAASC,UAAU,QAAwB,2BAA0B;AACrE,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,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kB,SAAS,CAACqK,WAAW;YAEf9J;QADR,MAAMA,QAAQhF,uBAAwBgP,eAAAA,OAAQzL,OAAiBkB,MAAMA,KAAK,EAAEA,MAAMwK,WAAW;QAC7FD,QAAQhK,eAAAA,MAAMzB,KAAK,YAAXyB,eAAmCgK;IAC7C;IACA,6EAA6E;IAC7EA,QAAQtP,+BAAAA,4BAA6BsP,eAAAA,OAAQzL,kBAArC7D,+BAA0GsP;IAClH,MAAME,SAAS5P,qBAAsB0P,eAAAA,OAAQzL;IAC7C,IAAI/D,sBAAsB0P,SAAS;QACjCrC,QAAQD,KAAK,CAAC,8DAA8D;YAAE/F;YAAUqI,QAAQ3P,yBAAyB2P;QAAQ;IACnI;IACA,IAAI,CAACF,MAAM,OAAOF,aAAaF,WAAW;QAAEhH;QAAWF,YAAYkH;QAAUrH,SAAS;IAAK,IAAI;IAC/F,MAAM4H,SAASlQ,kBAAkB+P;IACjC,IAAI,CAACG,QAAQ,OAAO;IACpB,MAAMzH,aAAaE,UAAUK,UAAU,CAAC,YAAYC,GAAG,CAAC1J;IACxD,OAAO;QACLoJ;QACAF;QACAH,SAAS;YACPV;YACAF,QAAQnD,MAAMmD,MAAM;YACpBW,WAAW,GAAE9D,qBAAAA,MAAM8D,WAAW,YAAjB9D,qBAAqB;YAClCD,OAAO6L,OAAOC,IAAI,CAACF;YACnB/G,WAAW5E,MAAM6D,GAAG;YACpBS,WAAWtE,MAAM6D,GAAG;YACpBiI,SAAS9L,MAAM2D,KAAK;QACtB;IACF;AACF"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { NodesMap } from '@aglyn/aglyn/types/nodes';
18
+ /**
19
+ * THE V1.0.0-BETA.271 LAUREL FORK PHOTOGRAPHY GUIDED START (AGL-3988), as
20
+ * production left it: workspace jWmGooWE3L, host zVfToa7iIQ
21
+ * (laurel-fork-photography.aglyn.app), job yZUqIPmjIZ, 2026-10-19 23:05Z,
22
+ * "a wedding and family photographer in the Blue Ridge Mountains who books
23
+ * sessions and elopements". Read back read-only from production's job and
24
+ * host documents after the job finished.
25
+ *
26
+ * - `LAUREL_FORK_PAGES`: each published page's tree, cut to its sections,
27
+ * its pictures and every node between them (frames keep their shape), in
28
+ * document order. Copy and styling are left out; nothing else is changed.
29
+ * - `LAUREL_FORK_PHOTOS`: the ten stock photos the job copied into the
30
+ * site's library (23:08:29 to 23:13:30), with the query that found each.
31
+ * - `LAUREL_FORK_COVERS`: the twelve "Gallery collections" records, in
32
+ * order, every one on a starter (the office team and the desk in turn).
33
+ * - `LAUREL_FORK_REFUSALS`: the Pixabay ids whose downloads the console's
34
+ * request logs show pixabay.com's Cloudflare refusing with 429 (after four
35
+ * tries each), by the beat that sent them. The logs name the photo, not
36
+ * the slot: the covers' beat built the datasets (23:07:09), the next beat
37
+ * the home page (23:08:11).
38
+ */
39
+ /** The site's share image the publish left: the starter the site was created with. */
40
+ export declare const LAUREL_FORK_SHARE_IMAGE: {
41
+ readonly image: "/_static/starter/hero-team.jpg";
42
+ readonly imageWidth: 1600;
43
+ readonly imageHeight: 1067;
44
+ readonly imageAlt: "A small team working together around a table in a bright office";
45
+ };
46
+ /** The pages the start put live, in the site's order, each cut to its pictures. */
47
+ export declare const LAUREL_FORK_PAGES: ReadonlyArray<{
48
+ id: string;
49
+ title: string;
50
+ slug: string;
51
+ nodes: NodesMap;
52
+ }>;
53
+ /** The photos the job copied into the site's library, in the order it copied them. */
54
+ export declare const LAUREL_FORK_PHOTOS: ReadonlyArray<{
55
+ mediaId: string;
56
+ key: string;
57
+ width: number;
58
+ height: number;
59
+ alt: string;
60
+ query: string;
61
+ at: string;
62
+ }>;
63
+ /** The "Gallery collections" records production wrote (dataset WX2B9IcAnF), in order. */
64
+ export declare const LAUREL_FORK_COVERS: ReadonlyArray<{
65
+ order: number;
66
+ title: string;
67
+ category: string;
68
+ image: string;
69
+ imageDescription: string;
70
+ }>;
71
+ /** The downloads the image hosts refused, by the beat that sent them (its request's start, from the console's logs). */
72
+ export declare const LAUREL_FORK_REFUSALS: {
73
+ /** The beat that built the site layout, the datasets and the form: every one of them a "Gallery collections" cover's pick. */
74
+ readonly covers: {
75
+ readonly at: "2026-10-19T23:07:09.140Z";
76
+ readonly ids: readonly ["8028185", "2179256", "7612157", "1837148", "5693164", "6935359", "6704262", "7103290", "2191391", "7162791", "6230410", "1576456", "621634", "4610864", "2592704", "868394", "5401602", "7843738", "3717770", "6883668", "515532", "6935341"];
77
+ };
78
+ /** The beat that built the home page: its hero's and its about split's picks among them. */
79
+ readonly home: {
80
+ readonly at: "2026-10-19T23:08:11.813Z";
81
+ readonly ids: readonly ["1846114", "5061887", "7302669", "7315389", "1837148", "3997967", "7103290", "621634", "5582980", "9981742", "9034408"];
82
+ };
83
+ };