@aglyn/plugins-ai 1.16.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/jobs/ai-job-import-step.js +7 -4
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +7 -4
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +9 -0
- package/src/lib/jobs/ai-layout-stock-photos.js +4 -0
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
- package/src/lib/jobs/ai-site-import-actions.d.ts +35 -0
- package/src/lib/jobs/ai-site-import-actions.js +215 -0
- package/src/lib/jobs/ai-site-import-actions.js.map +1 -0
- package/src/lib/jobs/ai-site-import-compile.d.ts +7 -0
- package/src/lib/jobs/ai-site-import-compile.js +34 -4
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-improve.d.ts +13 -1
- package/src/lib/jobs/ai-site-import-improve.js +153 -12
- package/src/lib/jobs/ai-site-import-improve.js.map +1 -1
- package/src/lib/jobs/ai-site-import-pictures.js +4 -2
- package/src/lib/jobs/ai-site-import-pictures.js.map +1 -1
- package/src/lib/jobs/ai-site-import-plan.d.ts +67 -1
- package/src/lib/jobs/ai-site-import-plan.js +173 -4
- package/src/lib/jobs/ai-site-import-plan.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +13 -15
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +6 -0
- package/src/lib/model/ai-site-import-fidelity.js +88 -10
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-ledger.js +10 -2
- package/src/lib/model/ai-site-import-ledger.js.map +1 -1
- package/src/lib/model/ai-site-import-marks.d.ts +37 -0
- package/src/lib/model/ai-site-import-marks.js +53 -0
- package/src/lib/model/ai-site-import-marks.js.map +1 -0
- package/src/lib/model/ai-site-import.d.ts +11 -1
- package/src/lib/model/ai-site-import.js +14 -2
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +8 -0
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/site-import/site-import-images.js +9 -6
- package/src/lib/site-import/site-import-images.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-plan.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\n/*==========================================\n * IMPROVE IT, GENERATIVE: THE SITE PLANNED ONCE (AGL-4152).\n *\n * A page redesigned on its own cannot reorganize a site. So before anything of\n * it is built, one `submit_site_plan` answer reads what the first wave read and\n * says what the site is, how its menu and footer are organized, where the\n * header's main button goes, how the whole site is drawn, and at most one new\n * page. Every wave's pages are then drawn to it, by code:\n *\n * - the header and footer from `plan.nav`, with no model\n * (`aiSiteImportFrameSource`);\n * - each page's hero, groups, rhythm and closing band from `plan.design`\n * (`aiLayoutDesignChoices`), so the site reads as one design.\n *\n * The answer is held here: every page it names is a real page or the one it\n * proposes, its main button goes somewhere real, nothing the old menu reached\n * is left unreachable, and its words go through the honesty validator. An answer\n * that misses twice, or is refused, is no plan: the import's own frame and\n * design inputs stand, and its page says so.\n *\n * Nothing here runs with the flag off, or for Keep my site.\n *=========================================*/\n\nimport { fenceUntrustedText, UNTRUSTED_TEXT_RULE } from '@aglyn/shared-util-tools/untrusted-text'\nimport { aiLayoutGuardContacts } from '../layout-language/ai-layout-copy'\nimport { AI_SITE_IMPORT_PAGE_ROLES, AI_SITE_IMPORT_PROPOSED_PAGE, aiSiteImportPageIsLegal, type AiSiteImportPage, type AiSiteImportPageRole, type AiSiteImportPlan, type AiSiteImportPlanDesign, type AiSiteImportState } from '../model/ai-site-import'\nimport { AI_SITE_KINDS } from '../model/ai-site-kinds'\nimport type { AiSystemBlock, AiTool } from '../providers/contract'\nimport { AI_STEP_TIERS } from '../providers/catalog'\nimport type { AiGenerationCheck, AiValidatedGeneration } from '../runtime/ai-doctrine'\nimport { runValidatedGeneration } from '../runtime/ai-doctrine'\nimport type { AiDoctrineViolation } from '../runtime/ai-doctrine-validators'\nimport { aiGenerationMaxTokensWithin, aiJobStepBudget } from './ai-job-budget'\nimport { AI_LAYOUT_LANGUAGE_THINKING } from './ai-job-page-language'\nimport { AI_SITE_IMPORT_DROPPED_ITEM_CODE, AI_SITE_IMPORT_INVENTED_FACT_CODE, aiSiteImportHonestyFacts, aiSiteImportInventedIn } from './ai-site-import-honesty'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** The answer's kind of generation: the name its re-ask and its doctrine scope go by. */\nexport const AI_SITE_IMPORT_PLAN_KIND = 'site-import-plan'\n\n/** The heroes a plan may choose: those a page brought in can draw from one picture. */\nexport const AI_SITE_IMPORT_PLAN_HEROES = ['cover', 'poster', 'split', 'bleed', 'editorial', 'column', 'panel'] as const satisfies ReadonlyArray<AiSiteImportPlanDesign['hero']>\n\n/** The most top-level entries a planned menu holds: more reads as no plan at all. */\nexport const AI_SITE_IMPORT_PLAN_MAX_GROUPS = 6\n\n/** The most characters a menu's label holds, a heading of the footer, or the main button's. */\nexport const AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS = 28\n\n/** The most characters a proposed page's title holds: its search listing's ceiling. */\nexport const AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS = 60\n\nconst GROUP_SCHEMA = {\n type: 'object',\n additionalProperties: false,\n required: ['label', 'pages'],\n properties: { label: { type: 'string' }, pages: { type: 'array', items: { type: 'string' } } },\n} as const\n\n/** The plan's tool: strict, every field always written. */\nexport const AI_SITE_IMPORT_PLAN_TOOL: AiTool = {\n name: 'submit_site_plan',\n description: 'Submit the plan of the new site: what it is, its menu and footer, how it is drawn, and at most one new page.',\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['site', 'nav', 'design', 'proposed', 'roles'],\n properties: {\n site: {\n type: 'object',\n additionalProperties: false,\n required: ['what', 'audience', 'kind', 'voice'],\n properties: {\n what: { type: 'string' },\n audience: { type: 'string' },\n kind: { type: 'string', enum: AI_SITE_KINDS.map((kind) => kind.id) },\n voice: { type: 'string' },\n },\n },\n nav: {\n type: 'object',\n additionalProperties: false,\n required: ['groups', 'cta', 'footer'],\n properties: {\n groups: { type: 'array', items: GROUP_SCHEMA },\n cta: {\n type: 'object',\n additionalProperties: false,\n required: ['label', 'target'],\n properties: { label: { type: 'string' }, target: { type: 'string' } },\n },\n footer: { type: 'array', items: GROUP_SCHEMA },\n },\n },\n design: {\n type: 'object',\n additionalProperties: false,\n required: ['hero', 'group', 'rhythm', 'cta'],\n properties: {\n hero: { type: 'string', enum: [...AI_SITE_IMPORT_PLAN_HEROES] },\n group: { type: 'string', enum: ['cards', 'ruled', 'icons'] },\n rhythm: { type: 'string', enum: ['alternate', 'plain'] },\n cta: { type: 'string', enum: ['band', 'photo'] },\n },\n },\n proposed: {\n type: 'object',\n additionalProperties: false,\n required: ['title', 'slug', 'purpose'],\n properties: { title: { type: 'string' }, slug: { type: 'string' }, purpose: { type: 'string' } },\n },\n roles: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['page', 'role'],\n properties: { page: { type: 'string' }, role: { type: 'string', enum: [...AI_SITE_IMPORT_PAGE_ROLES] } },\n },\n },\n },\n },\n}\n\n/** What a plan is told, cached: every site shares these bytes. */\nexport const AI_SITE_IMPORT_PLAN_TEXT = [\n \"You plan the new website of a small business from what its existing website says. You are its information architect and art director: a visitor should find what they came for in one or two clicks, and the whole site should read as one confident design. The site's old menu is often just its pages in the order they were made. Reorganize it around what a visitor of this kind of business looks for. Answer with submit_site_plan.\",\n '',\n 'site: what is one plain sentence saying what the business does; audience is one short phrase saying who it serves; kind is the kind of site this is; voice is a few plain words on how its writing sounds.',\n '',\n 'nav: the menu, the header\\'s main button and the footer.',\n `- groups are the menu, at most ${AI_SITE_IMPORT_PLAN_MAX_GROUPS} top-level entries, in the order a visitor needs them. An entry with one page is a link under that label; an entry with several is a menu of them under the label. Pages are named by id, as the page list gives them. Group like pages under a clear label rather than listing them all; never put the home page in the menu, since the logo goes home.`,\n '- Every page the page list marks \"in the menu\" must stay reachable: in the menu or the footer. A policy page belongs in the footer.',\n '- cta is the header\\'s one filled button: the one thing a visitor of this business most wants to do. label is its words; target is a page by id, form for the page holding the site\\'s form, or phone for the phone number the site gives. Only what the page list says exists.',\n '- The page the main button goes to is never also a menu entry of its own: the button is its link. Put it in the footer.',\n '- footer is its columns, each a short heading over the pages it links: two to four where there are pages enough, and one where the site has two or three pages, so the footer is never empty.',\n `- Every label is short, at most ${AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS} characters, plain and in sentence case, so a capital reads as a name.`,\n '',\n 'design: how every page of the site is drawn, chosen once for the whole site from what it is and what it shows. hero: cover, a full-bleed photo with the words over it; poster, the same, taller and centered; split, the words beside a tall photo; bleed, half the band a photo; editorial, display type with a wide photo boxed under it; column, the words centered in a narrow column with a photo boxed under them; panel, the words on a card over a photo. Where the site opens on a wide photo of its work, its place or its people, lay the words over it (cover, poster, panel) or beside it (split, bleed); keep editorial and column for a site with no such photo. Choose a photo-led hero only where the site has photos worth it. group: how a set of services or reasons is drawn: cards, ruled columns, or icons. rhythm: alternate grounds between sections, or plain, one ground with space between. cta: the closing call to action on a strong band, or over a photo.',\n '',\n `roles: what each page of the list is for in the new site, by id, one of ${AI_SITE_IMPORT_PAGE_ROLES.join(', ')}: home for the home page; service for a page about what the business offers; contact for a page whose purpose is reaching it or booking; other where none fits. Every page redesigns to its role, so name each one.`,\n '',\n 'proposed: at most one new page the site lacks and a visitor of this kind of business looks for, such as common questions or how it works, named new in the menu or footer wherever it belongs. Propose one only where the request says there is room, and only what you can write without inventing a fact. title is at most 60 characters; slug is its address in lowercase words and hyphens; purpose is one sentence on what it tells a visitor. No page to propose: write all three as \"\".',\n '',\n 'Never write a name, number, price, date, testimonial, client, award, credential, address or guarantee the site does not give.',\n].join('\\n')\n\n/** A plan's system blocks: the platform's text, cached across sites. The site's own words ride the user turn. */\nexport function aiSiteImportPlanInstructions(): readonly AiSystemBlock[] {\n return [{ text: UNTRUSTED_TEXT_RULE }, { text: AI_SITE_IMPORT_PLAN_TEXT, cacheBreakpoint: true }]\n}\n\n/*------------------------------------------\n * What the answer is told\n *-----------------------------------------*/\n\n/** The most characters of a site's own words the answer is told, about the site and about its pages. */\nconst SITE_MAX_CHARS = 6_000\nconst PAGES_MAX_CHARS = 12_000\n/** The headings a page's line names. */\nconst HEADINGS_PER_PAGE = 8\n\n/** What one page tells the plan: its id, title, address, words and headings, and what it holds. */\nfunction pageLine(page: AiSiteImportPage, required: ReadonlySet<string>): string {\n const blocks = page.read?.blocks ?? []\n const headings = blocks.flatMap((block) => (block.kind === 'heading' && block.text.trim() ? [clean(block.text)] : [])).slice(0, HEADINGS_PER_PAGE)\n const marks = [\n ...(required.has(page.draftId) ? ['in the menu'] : []),\n ...(page.read?.forms?.length ? ['holds a form'] : []),\n ...(aiSiteImportPageIsLegal(page) ? ['a policy'] : []),\n ...(page.group !== 'main' ? [`in ${page.group}`] : []),\n ]\n return `${page.draftId} | ${page.slug === '/' ? 'home' : `/${page.slug}`} | ${clean(page.title)} | ${(page.read?.words ?? page.words).toLocaleString('en-US')} words${marks.length ? ` | ${marks.join(', ')}` : ''}${headings.length ? ` | headings: ${headings.join('; ')}` : ''}`\n}\n\n/** The pages a plan may name: every page the import brings in and can link. */\nexport function aiSiteImportPlanPages(state: Pick<AiSiteImportState, 'pages'>): AiSiteImportPage[] {\n return state.pages.filter((page) => !page.refused)\n}\n\n/** A plan's user turn: what the site says of itself and its pages, fenced as the owner's data, and whether there is room for a new page. */\nexport function aiSiteImportPlanPrompt(input: { state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName' | 'domain'>; required: readonly string[]; roomForPage: boolean }): string {\n const { state } = input\n const home = state.home ?? null\n const required = new Set(input.required)\n const phones = home?.facts.phones ?? []\n const said = [\n `Name: ${clean(home?.siteName) || clean(state.siteName)}`,\n home?.title ? `Title: ${clean(home.title)}` : '',\n home?.description ? `Description: ${clean(home.description)}` : '',\n ...(home?.facts.lines ?? []),\n phones.length ? `Phone: ${phones[0]}` : '',\n ].filter(Boolean)\n return [\n fenceUntrustedText(`What ${state.domain} says of itself`, said.join('\\n'), { maxChars: SITE_MAX_CHARS }),\n 'The page list, one a line: id | address | title | words | what it holds | headings.',\n fenceUntrustedText('The pages', aiSiteImportPlanPages(state).map((page) => pageLine(page, required)).join('\\n'), { maxChars: PAGES_MAX_CHARS }),\n input.roomForPage ? 'There is room for one new page.' : 'There is no room for a new page: write proposed as \"\".',\n phones.length ? 'The site gives a phone number.' : 'The site gives no phone number: target may not be phone.',\n ].join('\\n')\n}\n\n/*------------------------------------------\n * The answer held\n *-----------------------------------------*/\n\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\n\nconst invented = (message: string): AiDoctrineViolation => ({ rule: 14, code: AI_SITE_IMPORT_INVENTED_FACT_CODE, message })\nconst dropped = (message: string): AiDoctrineViolation => ({ rule: null, code: AI_SITE_IMPORT_DROPPED_ITEM_CODE, message })\nconst unusable = (message: string): AiDoctrineViolation => ({ rule: null, code: 'site-plan-unusable', message })\n\nconst record = (value: unknown): Record<string, unknown> => (value && typeof value === 'object' ? (value as Record<string, unknown>) : {})\n\n/** A list of groups, as an answer gives them. */\nfunction groupsOf(value: unknown): Array<{ label: string; pages: string[] }> {\n return (Array.isArray(value) ? value : []).map((entry) => {\n const group = record(entry)\n return { label: clean(group['label']), pages: (Array.isArray(group['pages']) ? group['pages'] : []).map(clean).filter(Boolean) }\n })\n}\n\n/** What a plan is held to. */\nexport interface AiSiteImportPlanScope {\n state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName'>\n /** Every line the import read of the site: what its words may say. */\n scope: readonly string[]\n /** The pages the old menu reached, which must stay reachable. */\n required: readonly string[]\n roomForPage: boolean\n}\n\n/** Every line of a site's first wave a plan's words are held to, with the page's own titles. */\nexport function aiSiteImportPlanScopeLines(state: Pick<AiSiteImportState, 'pages'>, siteLines: readonly string[]): string[] {\n const read = state.pages.flatMap((page) => [page.title, ...(page.read?.blocks ?? []).flatMap((block) => (block.kind === 'image' ? [] : block.text.trim() ? [block.text] : []))])\n return [...siteLines, ...read].map(clean).filter(Boolean)\n}\n\n/**\n * A plan's answer read and held (AGL-4152): a plan to store, or what it broke,\n * each named for the one re-ask. Its words are the honesty validator's: no name\n * or fact the site does not give, in any label or line.\n */\nexport function aiSiteImportPlanRead(raw: unknown, input: AiSiteImportPlanScope): { plan: AiSiteImportPlan | null; violations: AiDoctrineViolation[] } {\n const answer = record(raw)\n const site = record(answer['site'])\n const nav = record(answer['nav'])\n const cta = record(nav['cta'])\n const design = record(answer['design'])\n const proposedRaw = record(answer['proposed'])\n const groups = groupsOf(nav['groups'])\n const footer = groupsOf(nav['footer'])\n const out: AiDoctrineViolation[] = []\n const pages = aiSiteImportPlanPages(input.state)\n const ids = new Set(pages.map((page) => page.draftId))\n const homeIds = new Set(pages.filter((page) => page.slug === '/').map((page) => page.draftId))\n\n const title = clean(proposedRaw['title'])\n const slug = clean(proposedRaw['slug'])\n const purpose = clean(proposedRaw['purpose'])\n const proposes = !!(title || slug || purpose)\n if (proposes) {\n if (!input.roomForPage) out.push(unusable('proposed: there is no room for a new page on this plan. Write title, slug and purpose as \"\".'))\n if (!title || !purpose) out.push(unusable('proposed: a new page needs its title and its purpose, or all three written as \"\".'))\n if (title.length > AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS) out.push(unusable(`proposed: its title is over ${AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS} characters.`))\n if (!SLUG.test(slug)) out.push(unusable('proposed: its slug is lowercase words and hyphens only.'))\n else if (pages.some((page) => page.slug === slug || page.path.replace(/^\\/+|\\/+$/g, '') === slug)) out.push(unusable(`proposed: /${slug} is already a page of this site. Choose another address, or propose no page.`))\n if (pages.some((page) => clean(page.title).toLowerCase() === title.toLowerCase())) out.push(unusable(`proposed: \"${title.slice(0, 60)}\" is already a page of this site.`))\n }\n\n const entry = (name: string, page: string) => {\n if (page === AI_SITE_IMPORT_PROPOSED_PAGE) {\n if (!proposes) out.push(unusable(`${name}: it names the new page, and proposed is empty.`))\n } else if (!ids.has(page)) out.push(unusable(`${name}: \"${page.slice(0, 40)}\" is not a page of this site. Name pages by the ids the page list gives.`))\n }\n if (!groups.length) out.push(unusable('nav.groups: a menu needs at least one entry.'))\n if (groups.length > AI_SITE_IMPORT_PLAN_MAX_GROUPS) out.push(unusable(`nav.groups: at most ${AI_SITE_IMPORT_PLAN_MAX_GROUPS} top-level entries.`))\n for (const [where, list] of [['nav.groups', groups], ['nav.footer', footer]] as const) {\n list.forEach((group, index) => {\n const name = `${where}[${index}]`\n if (!group.label) out.push(unusable(`${name}: it needs a label.`))\n if (group.label.length > AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS) out.push(unusable(`${name}: \"${group.label.slice(0, 40)}\" is over ${AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS} characters.`))\n if (!group.pages.length) out.push(unusable(`${name}: it links no page.`))\n for (const page of group.pages) entry(name, page)\n })\n }\n groups.forEach((group, index) => {\n if (group.pages.some((page) => homeIds.has(page))) out.push(unusable(`nav.groups[${index}]: the home page is not in the menu: the logo goes home.`))\n })\n const placed = new Set([...groups, ...footer].flatMap((group) => group.pages))\n for (const page of input.required) {\n if (!placed.has(page) && !homeIds.has(page)) {\n const named = pages.find((other) => other.draftId === page)?.title ?? page\n out.push(dropped(`\"${named.slice(0, 60)}\" is in the old menu and nowhere in the new one. Put it in the menu or the footer.`))\n }\n }\n if (proposes && !placed.has(AI_SITE_IMPORT_PROPOSED_PAGE)) out.push(dropped('The new page is linked from nowhere. Put new in the menu or the footer.'))\n\n // The header's one filled button goes somewhere real.\n const ctaLabel = clean(cta['label'])\n const target = clean(cta['target'])\n let ctaPage: string | undefined\n if (!ctaLabel || !target) out.push(unusable('nav.cta: the header needs its main button, with its words and where it goes.'))\n else {\n if (ctaLabel.length > AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS) out.push(unusable(`nav.cta: \"${ctaLabel.slice(0, 40)}\" is over ${AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS} characters.`))\n if (target === 'form') {\n ctaPage = pages.find((page) => page.read?.forms?.some((form) => form.fields.length))?.draftId\n if (!ctaPage) out.push(unusable('nav.cta: no page of this site holds a form. Send the button to a page, or to phone.'))\n } else if (target === 'phone') {\n if (!input.state.home?.facts.phones.length) out.push(unusable('nav.cta: the site gives no phone number. Send the button to a page.'))\n } else if (target !== AI_SITE_IMPORT_PROPOSED_PAGE || !proposes) entry('nav.cta', target)\n }\n\n const kind = clean(site['kind'])\n if (!AI_SITE_KINDS.some((entry) => entry.id === kind)) out.push(unusable('site.kind: one of the kinds the tool lists.'))\n const what = clean(site['what'])\n const audience = clean(site['audience'])\n if (!what || !audience) out.push(unusable('site: what and audience are each a line, never empty.'))\n const hero = AI_SITE_IMPORT_PLAN_HEROES.find((value) => value === design['hero'])\n const group = (['cards', 'ruled', 'icons'] as const).find((value) => value === design['group'])\n const rhythm = (['alternate', 'plain'] as const).find((value) => value === design['rhythm'])\n const closing = (['band', 'photo'] as const).find((value) => value === design['cta'])\n if (!hero || !group || !rhythm || !closing) out.push(unusable('design: hero, group, rhythm and cta are each one of the values the tool lists.'))\n\n // Every word held to what the site says.\n const held = aiSiteImportHonestyFacts(input.scope)\n const contacts = input.scope.join(' \\n ')\n const lines = [\n ['site.what', what],\n ['site.audience', audience],\n ['site.voice', clean(site['voice'])],\n ['nav.cta', ctaLabel],\n ...groups.map((entry, index) => [`nav.groups[${index}]`, entry.label] as const),\n ...footer.map((entry, index) => [`nav.footer[${index}]`, entry.label] as const),\n ['proposed.title', title],\n ['proposed.purpose', purpose],\n ] as const\n for (const [where, text] of lines) {\n if (!text) continue\n const reason = aiSiteImportInventedIn(text, held)\n if (reason) out.push(invented(`${where}, \"${text.slice(0, 80)}\": ${reason}`))\n else if (aiLayoutGuardContacts(text, contacts) !== text) out.push(invented(`${where}, \"${text.slice(0, 80)}\": it gives a phone number or email the site does not.`))\n }\n if (out.length || !hero || !group || !rhythm || !closing) return { plan: null, violations: out }\n // What each page is for (AGL-4152): a role it does not know, or a page that is none of the site's, is left to the page.\n const roles: Record<string, AiSiteImportPageRole> = {}\n for (const entry of Array.isArray(answer['roles']) ? answer['roles'] : []) {\n const named = record(entry)\n const page = clean(named['page'])\n const role = AI_SITE_IMPORT_PAGE_ROLES.find((value) => value === named['role'])\n if (role && (ids.has(page) || (page === AI_SITE_IMPORT_PROPOSED_PAGE && proposes))) roles[page] = role\n }\n return {\n plan: {\n site: { what, audience, kind, voice: clean(site['voice']) },\n nav: { groups, primaryCta: { label: ctaLabel, target, ...(ctaPage ? { page: ctaPage } : {}) }, footer },\n design: { hero, group, rhythm, cta: closing },\n proposed: proposes ? { title, slug, purpose, on: true } : null,\n ...(Object.keys(roles).length ? { roles } : {}),\n },\n violations: [],\n }\n}\n\n/** A plan's check, answer by answer, for the one re-ask. */\nexport function aiSiteImportPlanCheck(input: AiSiteImportPlanScope): AiGenerationCheck<AiSiteImportPlan> {\n return (answer) => {\n const { plan, violations } = aiSiteImportPlanRead(answer, input)\n return plan ? { value: plan, violations: [] } : { value: null, violations }\n }\n}\n\n/*------------------------------------------\n * The answer asked\n *-----------------------------------------*/\n\n/** The most tokens a plan's answer asks, with its thinking. */\nexport const AI_SITE_IMPORT_PLAN_MOST_TOKENS = 4_000\n\n/** The least time a plan's pass needs: its answer and its one re-ask on the page step's tier. */\nexport const AI_SITE_IMPORT_PLAN_BUDGET = aiJobStepBudget({ tier: AI_STEP_TIERS['job.page'], maxTokens: AI_SITE_IMPORT_PLAN_MOST_TOKENS })\n\n/** The ceiling a plan is asked at on this model. */\nexport function aiSiteImportPlanMaxTokens(model: string): number {\n return aiGenerationMaxTokensWithin({ model, budgetMs: AI_SITE_IMPORT_PLAN_BUDGET.minimumMs, cap: AI_SITE_IMPORT_PLAN_MOST_TOKENS, lookups: 0 })\n}\n\n/** The one plan a generative Improve it asks for, on the page step's tier. */\nexport async function aiRunSiteImportPlan(input: AiSiteImportPlanScope & { state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName' | 'domain'>; model: string; signal?: AbortSignal }): Promise<AiValidatedGeneration<AiSiteImportPlan>> {\n return runValidatedGeneration<AiSiteImportPlan>(AI_SITE_IMPORT_PLAN_KIND, {\n step: 'job.page',\n model: input.model,\n instructions: aiSiteImportPlanInstructions(),\n messages: [{ role: 'user', content: aiSiteImportPlanPrompt({ state: input.state, required: input.required, roomForPage: input.roomForPage }) }],\n tool: AI_SITE_IMPORT_PLAN_TOOL,\n maxTokens: aiSiteImportPlanMaxTokens(input.model),\n cutOff: { noun: 'plan', smaller: 'Write shorter lines.' },\n ...AI_LAYOUT_LANGUAGE_THINKING,\n check: aiSiteImportPlanCheck(input),\n ...(input.signal ? { signal: input.signal } : {}),\n })\n}\n"],"names":["fenceUntrustedText","UNTRUSTED_TEXT_RULE","aiLayoutGuardContacts","AI_SITE_IMPORT_PAGE_ROLES","AI_SITE_IMPORT_PROPOSED_PAGE","aiSiteImportPageIsLegal","AI_SITE_KINDS","AI_STEP_TIERS","runValidatedGeneration","aiGenerationMaxTokensWithin","aiJobStepBudget","AI_LAYOUT_LANGUAGE_THINKING","AI_SITE_IMPORT_DROPPED_ITEM_CODE","AI_SITE_IMPORT_INVENTED_FACT_CODE","aiSiteImportHonestyFacts","aiSiteImportInventedIn","clean","text","replace","trim","AI_SITE_IMPORT_PLAN_KIND","AI_SITE_IMPORT_PLAN_HEROES","AI_SITE_IMPORT_PLAN_MAX_GROUPS","AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS","AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS","GROUP_SCHEMA","type","additionalProperties","required","properties","label","pages","items","AI_SITE_IMPORT_PLAN_TOOL","name","description","strict","inputSchema","site","what","audience","kind","enum","map","id","voice","nav","groups","cta","target","footer","design","hero","group","rhythm","proposed","title","slug","purpose","roles","page","role","AI_SITE_IMPORT_PLAN_TEXT","join","aiSiteImportPlanInstructions","cacheBreakpoint","SITE_MAX_CHARS","PAGES_MAX_CHARS","HEADINGS_PER_PAGE","pageLine","blocks","read","headings","flatMap","block","slice","marks","has","draftId","forms","length","words","toLocaleString","aiSiteImportPlanPages","state","filter","refused","aiSiteImportPlanPrompt","input","home","Set","phones","facts","said","siteName","lines","Boolean","domain","maxChars","roomForPage","SLUG","invented","message","rule","code","dropped","unusable","record","value","groupsOf","Array","isArray","entry","aiSiteImportPlanScopeLines","siteLines","aiSiteImportPlanRead","raw","answer","proposedRaw","out","ids","homeIds","proposes","push","test","some","path","toLowerCase","where","list","forEach","index","placed","named","find","other","ctaLabel","ctaPage","form","fields","closing","held","scope","contacts","reason","plan","violations","primaryCta","on","Object","keys","aiSiteImportPlanCheck","AI_SITE_IMPORT_PLAN_MOST_TOKENS","AI_SITE_IMPORT_PLAN_BUDGET","tier","maxTokens","aiSiteImportPlanMaxTokens","model","budgetMs","minimumMs","cap","lookups","aiRunSiteImportPlan","step","instructions","messages","content","tool","cutOff","noun","smaller","check","signal"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;2CAqB2C,GAE3C,SAASA,kBAAkB,EAAEC,mBAAmB,QAAQ,0CAAyC;AACjG,SAASC,qBAAqB,QAAQ,uCAAmC;AACzE,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IAAI;YAAEtC,OAAO;YAAMsC;QAAW;IAC5E;AACF;AAEA;;2CAE2C,GAE3C,6DAA6D,GAC7D,OAAO,MAAMM,kCAAkC,KAAK;AAEpD,+FAA+F,GAC/F,OAAO,MAAMC,6BAA6B/I,gBAAgB;IAAEgJ,MAAMnJ,aAAa,CAAC,WAAW;IAAEoJ,WAAWH;AAAgC,GAAE;AAE1I,kDAAkD,GAClD,OAAO,SAASI,0BAA0BC,KAAa;IACrD,OAAOpJ,4BAA4B;QAAEoJ;QAAOC,UAAUL,2BAA2BM,SAAS;QAAEC,KAAKR;QAAiCS,SAAS;IAAE;AAC/I;AAEA,4EAA4E,GAC5E,OAAO,eAAeC,oBAAoB1E,KAAgJ;IACxL,OAAOhF,uBAAyCY,0BAA0B;QACxE+I,MAAM;QACNN,OAAOrE,MAAMqE,KAAK;QAClBO,cAAcpG;QACdqG,UAAU;YAAC;gBAAExG,MAAM;gBAAQyG,SAAS/E,uBAAuB;oBAAEH,OAAOI,MAAMJ,KAAK;oBAAExD,UAAU4D,MAAM5D,QAAQ;oBAAEuE,aAAaX,MAAMW,WAAW;gBAAC;YAAG;SAAE;QAC/IoE,MAAMtI;QACN0H,WAAWC,0BAA0BpE,MAAMqE,KAAK;QAChDW,QAAQ;YAAEC,MAAM;YAAQC,SAAS;QAAuB;OACrD/J;QACHgK,OAAOpB,sBAAsB/D;OACzBA,MAAMoF,MAAM,GAAG;QAAEA,QAAQpF,MAAMoF,MAAM;IAAC,IAAI,CAAC;AAEnD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-plan.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\n/*==========================================\n * IMPROVE IT, GENERATIVE: THE SITE PLANNED ONCE (AGL-4152).\n *\n * A page redesigned on its own cannot reorganize a site. So before anything of\n * it is built, one `submit_site_plan` answer reads what the first wave read and\n * says what the site is, how its menu and footer are organized, where the\n * header's main button goes, how the whole site is drawn, and at most one new\n * page. Every wave's pages are then drawn to it, by code:\n *\n * - the header and footer from `plan.nav`, with no model\n * (`aiSiteImportFrameSource`);\n * - each page's hero, groups, rhythm and closing band from `plan.design`\n * (`aiLayoutDesignChoices`), so the site reads as one design.\n *\n * The answer is held here: every page it names is a real page or the one it\n * proposes, its main button goes somewhere real, nothing the old menu reached\n * is left unreachable, and its words go through the honesty validator. An answer\n * that misses twice, or is refused, is no plan: the import's own frame and\n * design inputs stand, and its page says so.\n *\n * Nothing here runs with the flag off, or for Keep my site.\n *=========================================*/\n\nimport { fenceUntrustedText, UNTRUSTED_TEXT_RULE } from '@aglyn/shared-util-tools/untrusted-text'\nimport { aiLayoutGuardContacts } from '../layout-language/ai-layout-copy'\nimport { AI_SITE_IMPORT_PAGE_ROLES, AI_SITE_IMPORT_PROPOSED_PAGE, aiSiteImportPageIsLegal, type AiSiteImportPage, type AiSiteImportPageRole, type AiSiteImportPlan, type AiSiteImportPlanDesign, type AiSiteImportState } from '../model/ai-site-import'\nimport { AI_SITE_KINDS } from '../model/ai-site-kinds'\nimport type { AiSystemBlock, AiTool } from '../providers/contract'\nimport { AI_STEP_TIERS } from '../providers/catalog'\nimport type { AiGenerationCheck, AiValidatedGeneration } from '../runtime/ai-doctrine'\nimport { runValidatedGeneration } from '../runtime/ai-doctrine'\nimport type { AiDoctrineViolation } from '../runtime/ai-doctrine-validators'\nimport { aiGenerationMaxTokensWithin, aiJobStepBudget } from './ai-job-budget'\nimport { AI_LAYOUT_LANGUAGE_THINKING } from './ai-job-page-language'\nimport { AI_SITE_IMPORT_DROPPED_ITEM_CODE, AI_SITE_IMPORT_INVENTED_FACT_CODE, aiSiteImportHonestyFacts, aiSiteImportInventedIn } from './ai-site-import-honesty'\nimport { aiSiteImportRedesignWhy } from './ai-site-import-improve'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** The answer's kind of generation: the name its re-ask and its doctrine scope go by. */\nexport const AI_SITE_IMPORT_PLAN_KIND = 'site-import-plan'\n\n/** The heroes a plan may choose: those a page brought in can draw from one picture. */\nexport const AI_SITE_IMPORT_PLAN_HEROES = ['cover', 'poster', 'split', 'bleed', 'editorial', 'column', 'panel'] as const satisfies ReadonlyArray<AiSiteImportPlanDesign['hero']>\n\n/** The most top-level entries a planned menu holds: more reads as no plan at all. */\nexport const AI_SITE_IMPORT_PLAN_MAX_GROUPS = 6\n\n/** The most characters a menu's label holds, a heading of the footer, or the main button's. */\nexport const AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS = 28\n\n/** The most characters a proposed page's title holds: its search listing's ceiling. */\nexport const AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS = 60\n\nconst GROUP_SCHEMA = {\n type: 'object',\n additionalProperties: false,\n required: ['label', 'pages'],\n properties: { label: { type: 'string' }, pages: { type: 'array', items: { type: 'string' } } },\n} as const\n\n/** The plan's tool: strict, every field always written. */\nexport const AI_SITE_IMPORT_PLAN_TOOL: AiTool = {\n name: 'submit_site_plan',\n description: 'Submit the plan of the new site: what it is, its menu and footer, how it is drawn, and at most one new page.',\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['site', 'nav', 'design', 'proposed', 'roles'],\n properties: {\n site: {\n type: 'object',\n additionalProperties: false,\n required: ['what', 'audience', 'kind', 'voice'],\n properties: {\n what: { type: 'string' },\n audience: { type: 'string' },\n kind: { type: 'string', enum: AI_SITE_KINDS.map((kind) => kind.id) },\n voice: { type: 'string' },\n },\n },\n nav: {\n type: 'object',\n additionalProperties: false,\n required: ['groups', 'cta', 'footer'],\n properties: {\n groups: { type: 'array', items: GROUP_SCHEMA },\n cta: {\n type: 'object',\n additionalProperties: false,\n required: ['label', 'target'],\n properties: { label: { type: 'string' }, target: { type: 'string' } },\n },\n footer: { type: 'array', items: GROUP_SCHEMA },\n },\n },\n design: {\n type: 'object',\n additionalProperties: false,\n required: ['hero', 'group', 'rhythm', 'cta'],\n properties: {\n hero: { type: 'string', enum: [...AI_SITE_IMPORT_PLAN_HEROES] },\n group: { type: 'string', enum: ['cards', 'ruled', 'icons'] },\n rhythm: { type: 'string', enum: ['alternate', 'plain'] },\n cta: { type: 'string', enum: ['band', 'photo'] },\n },\n },\n proposed: {\n type: 'object',\n additionalProperties: false,\n required: ['title', 'slug', 'purpose'],\n properties: { title: { type: 'string' }, slug: { type: 'string' }, purpose: { type: 'string' } },\n },\n roles: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['page', 'role'],\n properties: { page: { type: 'string' }, role: { type: 'string', enum: [...AI_SITE_IMPORT_PAGE_ROLES] } },\n },\n },\n },\n },\n}\n\n/** What a plan is told, cached: every site shares these bytes. */\nexport const AI_SITE_IMPORT_PLAN_TEXT = [\n \"You plan the new website of a small business from what its existing website says. You are its information architect and art director: a visitor should find what they came for in one or two clicks, and the whole site should read as one confident design. The site's old menu is often just its pages in the order they were made. Reorganize it around what a visitor of this kind of business looks for. Answer with submit_site_plan.\",\n '',\n 'site: what is one plain sentence saying what the business does; audience is one short phrase saying who it serves; kind is the kind of site this is; voice is a few plain words on how its writing sounds.',\n '',\n 'nav: the menu, the header\\'s main button and the footer.',\n `- groups are the menu, at most ${AI_SITE_IMPORT_PLAN_MAX_GROUPS} top-level entries, in the order a visitor needs them. An entry with one page is a link under that label; an entry with several is a menu of them under the label. Pages are named by id, as the page list gives them. Group like pages under a clear label rather than listing them all; never put the home page in the menu, since the logo goes home.`,\n '- Every page the page list marks \"in the menu\" must stay reachable: in the menu or the footer. A policy page belongs in the footer.',\n '- cta is the header\\'s one filled button: the one thing a visitor of this business most wants to do. label is its words; target is a page by id, form for the page holding the site\\'s form, or phone for the phone number the site gives. Only what the page list says exists.',\n '- The page the main button goes to is never also a menu entry of its own: the button is its link. Put it in the footer.',\n '- footer is its columns, each a short heading over the pages it links: two to four where there are pages enough, and one where the site has two or three pages, so the footer is never empty.',\n `- Every label is short, at most ${AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS} characters, plain and in sentence case, so a capital reads as a name.`,\n '',\n 'design: how every page of the site is drawn, chosen once for the whole site from what it is and what it shows. hero: cover, a full-bleed photo with the words over it; poster, the same, taller and centered; split, the words beside a tall photo; bleed, half the band a photo; editorial, display type with a wide photo boxed under it; column, the words centered in a narrow column with a photo boxed under them; panel, the words on a card over a photo. Where the site opens on a wide photo of its work, its place or its people, lay the words over it (cover, poster, panel) or beside it (split, bleed); keep editorial and column for a site with no such photo. Choose a photo-led hero only where the site has photos worth it. group: how a set of services or reasons is drawn: cards, ruled columns, or icons. rhythm: alternate grounds between sections, or plain, one ground with space between. cta: the closing call to action on a strong band, or over a photo.',\n '',\n `roles: what each page of the list is for in the new site, by id, one of ${AI_SITE_IMPORT_PAGE_ROLES.join(', ')}: home for the home page; service for a page about what the business offers; contact for a page whose purpose is reaching it or booking; other where none fits. Every page redesigns to its role, so name each one.`,\n '',\n 'proposed: at most one new page the site lacks and a visitor of this kind of business looks for, such as common questions or how it works, named new in the menu or footer wherever it belongs. Propose one only where the request says there is room, and only what you can write without inventing a fact. title is at most 60 characters; slug is its address in lowercase words and hyphens; purpose is one sentence on what it tells a visitor. No page to propose: write all three as \"\".',\n '',\n 'Never write a name, number, price, date, testimonial, client, award, credential, address or guarantee the site does not give.',\n].join('\\n')\n\n/** A plan's system blocks: the platform's text, cached across sites. The site's own words ride the user turn. */\nexport function aiSiteImportPlanInstructions(): readonly AiSystemBlock[] {\n return [{ text: UNTRUSTED_TEXT_RULE }, { text: AI_SITE_IMPORT_PLAN_TEXT, cacheBreakpoint: true }]\n}\n\n/*------------------------------------------\n * What the answer is told\n *-----------------------------------------*/\n\n/** The most characters of a site's own words the answer is told, about the site and about its pages. */\nconst SITE_MAX_CHARS = 6_000\nconst PAGES_MAX_CHARS = 12_000\n/** The headings a page's line names. */\nconst HEADINGS_PER_PAGE = 8\n\n/** What one page tells the plan: its id, title, address, words and headings, and what it holds. */\nfunction pageLine(page: AiSiteImportPage, required: ReadonlySet<string>): string {\n const blocks = page.read?.blocks ?? []\n const headings = blocks.flatMap((block) => (block.kind === 'heading' && block.text.trim() ? [clean(block.text)] : [])).slice(0, HEADINGS_PER_PAGE)\n const marks = [\n ...(required.has(page.draftId) ? ['in the menu'] : []),\n ...(page.read?.forms?.length ? ['holds a form'] : []),\n ...(aiSiteImportPageIsLegal(page) ? ['a policy'] : []),\n ...(page.group !== 'main' ? [`in ${page.group}`] : []),\n ]\n return `${page.draftId} | ${page.slug === '/' ? 'home' : `/${page.slug}`} | ${clean(page.title)} | ${(page.read?.words ?? page.words).toLocaleString('en-US')} words${marks.length ? ` | ${marks.join(', ')}` : ''}${headings.length ? ` | headings: ${headings.join('; ')}` : ''}`\n}\n\n/** The pages a plan may name: every page the import brings in and can link. */\nexport function aiSiteImportPlanPages(state: Pick<AiSiteImportState, 'pages'>): AiSiteImportPage[] {\n return state.pages.filter((page) => !page.refused)\n}\n\n/** A plan's user turn: what the site says of itself and its pages, fenced as the owner's data, and whether there is room for a new page. */\nexport function aiSiteImportPlanPrompt(input: { state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName' | 'domain'>; required: readonly string[]; roomForPage: boolean }): string {\n const { state } = input\n const home = state.home ?? null\n const required = new Set(input.required)\n const phones = home?.facts.phones ?? []\n const said = [\n `Name: ${clean(home?.siteName) || clean(state.siteName)}`,\n home?.title ? `Title: ${clean(home.title)}` : '',\n home?.description ? `Description: ${clean(home.description)}` : '',\n ...(home?.facts.lines ?? []),\n phones.length ? `Phone: ${phones[0]}` : '',\n ].filter(Boolean)\n return [\n fenceUntrustedText(`What ${state.domain} says of itself`, said.join('\\n'), { maxChars: SITE_MAX_CHARS }),\n 'The page list, one a line: id | address | title | words | what it holds | headings.',\n fenceUntrustedText('The pages', aiSiteImportPlanPages(state).map((page) => pageLine(page, required)).join('\\n'), { maxChars: PAGES_MAX_CHARS }),\n input.roomForPage ? 'There is room for one new page.' : 'There is no room for a new page: write proposed as \"\".',\n phones.length ? 'The site gives a phone number.' : 'The site gives no phone number: target may not be phone.',\n ].join('\\n')\n}\n\n/*------------------------------------------\n * The answer held\n *-----------------------------------------*/\n\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\n\nconst invented = (message: string): AiDoctrineViolation => ({ rule: 14, code: AI_SITE_IMPORT_INVENTED_FACT_CODE, message })\nconst dropped = (message: string): AiDoctrineViolation => ({ rule: null, code: AI_SITE_IMPORT_DROPPED_ITEM_CODE, message })\nconst unusable = (message: string): AiDoctrineViolation => ({ rule: null, code: 'site-plan-unusable', message })\n\nconst record = (value: unknown): Record<string, unknown> => (value && typeof value === 'object' ? (value as Record<string, unknown>) : {})\n\n/** A list of groups, as an answer gives them. */\nfunction groupsOf(value: unknown): Array<{ label: string; pages: string[] }> {\n return (Array.isArray(value) ? value : []).map((entry) => {\n const group = record(entry)\n return { label: clean(group['label']), pages: (Array.isArray(group['pages']) ? group['pages'] : []).map(clean).filter(Boolean) }\n })\n}\n\n/*------------------------------------------\n * The answer mended, where the mend is mechanical (AGL-4152)\n *-----------------------------------------*/\n\ntype AiSiteImportPlanGroup = { label: string; pages: string[] }\n\nconst trimSlashes = (path: string): string => path.replace(/^\\/+|\\/+$/g, '')\n\n/**\n * An entry as a page's id (AGL-4152): an id, or `new`, as written; else the\n * one page whose address or exact title it is. One that names no page, or\n * several, stays as written for the check to name.\n */\nexport function aiSiteImportPlanPageIdOf(pages: readonly AiSiteImportPage[]): (entry: string) => string {\n return (entry) => {\n if (entry === AI_SITE_IMPORT_PROPOSED_PAGE || pages.some((page) => page.draftId === entry)) return entry\n const address = trimSlashes(entry).toLowerCase()\n const title = entry.toLowerCase()\n const hits = pages.filter((page) => trimSlashes(page.slug).toLowerCase() === address || trimSlashes(page.path).toLowerCase() === address || clean(page.title).toLowerCase() === title)\n return hits.length === 1 && hits[0] ? hits[0].draftId : entry\n }\n}\n\n/** Whether a link of the old menu goes to this page: its host (www or not) and its path. */\nfunction linksTo(href: string | null | undefined, page: AiSiteImportPage): boolean {\n if (!href) return false\n try {\n const own = new URL(page.url)\n const url = new URL(href, own)\n const host = (value: string) => value.toLowerCase().replace(/^www\\./, '')\n return host(url.host) === host(own.host) && trimSlashes(decodeURIComponent(url.pathname)) === trimSlashes(page.path)\n } catch {\n return false\n }\n}\n\n/** The heading of the old menu's dropdown that held a page, in the site's own words, or `''`. */\nfunction oldMenuHeadingOf(page: AiSiteImportPage, home: AiSiteImportState['home']): string {\n const group = (home?.nav?.items ?? []).find((item) => item.items.length > 0 && item.items.some((entry) => linksTo(entry.href, page)))\n return clean(group?.label)\n}\n\n/** How alike two pages are, for the footer column a page joins: both policies, the same section of the site, the same group of the import. */\nfunction likeness(page: AiSiteImportPage, other: AiSiteImportPage | undefined): number {\n if (!other) return 0\n const section = (entry: AiSiteImportPage) => trimSlashes(entry.path).split('/')[0]?.toLowerCase() ?? ''\n return (\n (aiSiteImportPageIsLegal(page) && aiSiteImportPageIsLegal(other) ? 2 : 0) +\n (section(page) && section(page) === section(other) ? 2 : 0) +\n (page.group !== 'main' && page.group === other.group ? 1 : 0)\n )\n}\n\n/** What a plan's menu and footer are mended against. */\nexport interface AiSiteImportPlanMendScope {\n pages: readonly AiSiteImportPage[]\n /** The pages the old menu reached, which must stay reachable. */\n required: readonly string[]\n /** Whether the answer proposes a new page. */\n proposes: boolean\n home: AiSiteImportState['home']\n siteName: string\n}\n\n/**\n * A page the new menu left unreachable, put in the footer (AGL-4152): in the\n * column whose pages are most like it, else a new column under the heading the\n * old menu held it under, else the first column. A footer with no column takes\n * one headed by the site's name. Every heading is the site's own words; none\n * is made up, and one over the label's length is not taken.\n */\nfunction placeInFooter(footer: AiSiteImportPlanGroup[], page: string, input: AiSiteImportPlanMendScope): void {\n const of = (id: string) => input.pages.find((entry) => entry.draftId === id)\n const self = of(page)\n const heading = self ? oldMenuHeadingOf(self, input.home) : ''\n let best = -1\n let bestScore = 0\n footer.forEach((column, index) => {\n const score = (heading && column.label.toLowerCase() === heading.toLowerCase() ? 3 : 0) + (self ? column.pages.reduce((sum, other) => sum + likeness(self, of(other)), 0) : 0)\n if (score > bestScore) {\n best = index\n bestScore = score\n }\n })\n const fits = (label: string) => !!label && label.length <= AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS\n if (best >= 0) footer[best]?.pages.push(page)\n else if (fits(heading)) footer.push({ label: heading, pages: [page] })\n else if (footer[0]) footer[0].pages.push(page)\n else {\n const name = clean(input.home?.siteName) || clean(input.siteName)\n if (fits(name)) footer.push({ label: name, pages: [page] })\n }\n}\n\n/**\n * A plan's menu and footer mended where the mend is mechanical and cannot\n * change what the answer meant (AGL-4152), before it is held, so an answer\n * that needs only these costs no re-ask:\n *\n * - an entry written as a page's address or exact title reads as its id;\n * - a page named twice in one entry is named once;\n * - the home page leaves the menu (the logo goes home), and the new page\n * leaves every entry where none is proposed;\n * - an entry that then links no page is dropped;\n * - a page of the old menu, or the new page, that the answer left\n * unreachable joins the footer (`placeInFooter`).\n *\n * Nothing is mended in what the answer says: a label, a line, a button, or a\n * page that is none of the site's stands as written, for the check to name.\n */\nexport function aiSiteImportPlanMended(\n nav: { groups: readonly AiSiteImportPlanGroup[]; footer: readonly AiSiteImportPlanGroup[] },\n input: AiSiteImportPlanMendScope,\n): { groups: AiSiteImportPlanGroup[]; footer: AiSiteImportPlanGroup[] } {\n const ids = new Set(input.pages.map((page) => page.draftId))\n const homeIds = new Set(input.pages.filter((page) => page.slug === '/').map((page) => page.draftId))\n const idOf = aiSiteImportPlanPageIdOf(input.pages)\n const tidy = (list: readonly AiSiteImportPlanGroup[], menu: boolean) =>\n list\n .map((group) => ({\n label: group.label,\n pages: [...new Set(group.pages.map(idOf))].filter((page) => (page !== AI_SITE_IMPORT_PROPOSED_PAGE || input.proposes) && !(menu && homeIds.has(page))),\n }))\n .filter((group) => group.pages.length > 0)\n const groups = tidy(nav.groups, true)\n const footer = tidy(nav.footer, false)\n const placed = new Set([...groups, ...footer].flatMap((group) => group.pages))\n const missing = [\n ...new Set(input.required.filter((page) => ids.has(page) && !homeIds.has(page) && !placed.has(page))),\n ...(input.proposes && !placed.has(AI_SITE_IMPORT_PROPOSED_PAGE) ? [AI_SITE_IMPORT_PROPOSED_PAGE] : []),\n ]\n for (const page of missing) placeInFooter(footer, page, input)\n return { groups, footer }\n}\n\n/**\n * Why a plan did not pass, line by line (AGL-4152): each miss's code and the\n * line it names, as a redesign's (`aiSiteImportRedesignWhy`), for the job's\n * record (`planMissedWhy`). The log names its codes alone.\n */\nexport function aiSiteImportPlanWhy(violations: readonly AiDoctrineViolation[]): string[] {\n return aiSiteImportRedesignWhy(violations)\n}\n\n/** What the job's record says of a plan the model declined: there are no lines to name. */\nexport const AI_SITE_IMPORT_PLAN_REFUSED_WHY = 'refused: the model declined to plan the site.'\n\n/** What a plan is held to. */\nexport interface AiSiteImportPlanScope {\n state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName'>\n /** Every line the import read of the site: what its words may say. */\n scope: readonly string[]\n /** The pages the old menu reached, which must stay reachable. */\n required: readonly string[]\n roomForPage: boolean\n}\n\n/** Every line of a site's first wave a plan's words are held to, with the page's own titles. */\nexport function aiSiteImportPlanScopeLines(state: Pick<AiSiteImportState, 'pages'>, siteLines: readonly string[]): string[] {\n const read = state.pages.flatMap((page) => [page.title, ...(page.read?.blocks ?? []).flatMap((block) => (block.kind === 'image' ? [] : block.text.trim() ? [block.text] : []))])\n return [...siteLines, ...read].map(clean).filter(Boolean)\n}\n\n/**\n * A plan's answer read and held (AGL-4152): a plan to store, or what it broke,\n * each named for the one re-ask. Its words are the honesty validator's: no name\n * or fact the site does not give, in any label or line.\n */\nexport function aiSiteImportPlanRead(raw: unknown, input: AiSiteImportPlanScope): { plan: AiSiteImportPlan | null; violations: AiDoctrineViolation[] } {\n const answer = record(raw)\n const site = record(answer['site'])\n const nav = record(answer['nav'])\n const cta = record(nav['cta'])\n const design = record(answer['design'])\n const proposedRaw = record(answer['proposed'])\n const out: AiDoctrineViolation[] = []\n const pages = aiSiteImportPlanPages(input.state)\n const ids = new Set(pages.map((page) => page.draftId))\n const homeIds = new Set(pages.filter((page) => page.slug === '/').map((page) => page.draftId))\n\n const title = clean(proposedRaw['title'])\n const slug = clean(proposedRaw['slug'])\n const purpose = clean(proposedRaw['purpose'])\n const proposes = !!(title || slug || purpose)\n // Mended first, where the mend is mechanical: an answer that needs only that is no re-ask.\n const { groups, footer } = aiSiteImportPlanMended(\n { groups: groupsOf(nav['groups']), footer: groupsOf(nav['footer']) },\n { pages, required: input.required, proposes, home: input.state.home, siteName: input.state.siteName },\n )\n if (proposes) {\n if (!input.roomForPage) out.push(unusable('proposed: there is no room for a new page on this plan. Write title, slug and purpose as \"\".'))\n if (!title || !purpose) out.push(unusable('proposed: a new page needs its title and its purpose, or all three written as \"\".'))\n if (title.length > AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS) out.push(unusable(`proposed: its title is over ${AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS} characters.`))\n if (!SLUG.test(slug)) out.push(unusable('proposed: its slug is lowercase words and hyphens only.'))\n else if (pages.some((page) => page.slug === slug || page.path.replace(/^\\/+|\\/+$/g, '') === slug)) out.push(unusable(`proposed: /${slug} is already a page of this site. Choose another address, or propose no page.`))\n if (pages.some((page) => clean(page.title).toLowerCase() === title.toLowerCase())) out.push(unusable(`proposed: \"${title.slice(0, 60)}\" is already a page of this site.`))\n }\n\n const entry = (name: string, page: string) => {\n if (page === AI_SITE_IMPORT_PROPOSED_PAGE) {\n if (!proposes) out.push(unusable(`${name}: it names the new page, and proposed is empty.`))\n } else if (!ids.has(page)) out.push(unusable(`${name}: \"${page.slice(0, 40)}\" is not a page of this site. Name pages by the ids the page list gives.`))\n }\n if (!groups.length) out.push(unusable('nav.groups: a menu needs at least one entry.'))\n if (groups.length > AI_SITE_IMPORT_PLAN_MAX_GROUPS) out.push(unusable(`nav.groups: at most ${AI_SITE_IMPORT_PLAN_MAX_GROUPS} top-level entries.`))\n for (const [where, list] of [['nav.groups', groups], ['nav.footer', footer]] as const) {\n list.forEach((group, index) => {\n const name = `${where}[${index}]`\n if (!group.label) out.push(unusable(`${name}: it needs a label.`))\n if (group.label.length > AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS) out.push(unusable(`${name}: \"${group.label.slice(0, 40)}\" is over ${AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS} characters.`))\n if (!group.pages.length) out.push(unusable(`${name}: it links no page.`))\n for (const page of group.pages) entry(name, page)\n })\n }\n groups.forEach((group, index) => {\n if (group.pages.some((page) => homeIds.has(page))) out.push(unusable(`nav.groups[${index}]: the home page is not in the menu: the logo goes home.`))\n })\n const placed = new Set([...groups, ...footer].flatMap((group) => group.pages))\n for (const page of input.required) {\n if (!placed.has(page) && !homeIds.has(page)) {\n const named = pages.find((other) => other.draftId === page)?.title ?? page\n out.push(dropped(`\"${named.slice(0, 60)}\" is in the old menu and nowhere in the new one. Put it in the menu or the footer.`))\n }\n }\n if (proposes && !placed.has(AI_SITE_IMPORT_PROPOSED_PAGE)) out.push(dropped('The new page is linked from nowhere. Put new in the menu or the footer.'))\n\n // The header's one filled button goes somewhere real.\n const ctaLabel = clean(cta['label'])\n const written = clean(cta['target'])\n // A page written by its address or title is that page, as in the menu.\n const target = written === 'form' || written === 'phone' || !written ? written : aiSiteImportPlanPageIdOf(pages)(written)\n let ctaPage: string | undefined\n if (!ctaLabel || !target) out.push(unusable('nav.cta: the header needs its main button, with its words and where it goes.'))\n else {\n if (ctaLabel.length > AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS) out.push(unusable(`nav.cta: \"${ctaLabel.slice(0, 40)}\" is over ${AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS} characters.`))\n if (target === 'form') {\n ctaPage = pages.find((page) => page.read?.forms?.some((form) => form.fields.length))?.draftId\n if (!ctaPage) out.push(unusable('nav.cta: no page of this site holds a form. Send the button to a page, or to phone.'))\n } else if (target === 'phone') {\n if (!input.state.home?.facts.phones.length) out.push(unusable('nav.cta: the site gives no phone number. Send the button to a page.'))\n } else if (target !== AI_SITE_IMPORT_PROPOSED_PAGE || !proposes) entry('nav.cta', target)\n }\n\n const kind = clean(site['kind'])\n if (!AI_SITE_KINDS.some((entry) => entry.id === kind)) out.push(unusable('site.kind: one of the kinds the tool lists.'))\n const what = clean(site['what'])\n const audience = clean(site['audience'])\n if (!what || !audience) out.push(unusable('site: what and audience are each a line, never empty.'))\n const hero = AI_SITE_IMPORT_PLAN_HEROES.find((value) => value === design['hero'])\n const group = (['cards', 'ruled', 'icons'] as const).find((value) => value === design['group'])\n const rhythm = (['alternate', 'plain'] as const).find((value) => value === design['rhythm'])\n const closing = (['band', 'photo'] as const).find((value) => value === design['cta'])\n if (!hero || !group || !rhythm || !closing) out.push(unusable('design: hero, group, rhythm and cta are each one of the values the tool lists.'))\n\n // Every word held to what the site says.\n const held = aiSiteImportHonestyFacts(input.scope)\n const contacts = input.scope.join(' \\n ')\n const lines = [\n ['site.what', what],\n ['site.audience', audience],\n ['site.voice', clean(site['voice'])],\n ['nav.cta', ctaLabel],\n ...groups.map((entry, index) => [`nav.groups[${index}]`, entry.label] as const),\n ...footer.map((entry, index) => [`nav.footer[${index}]`, entry.label] as const),\n ['proposed.title', title],\n ['proposed.purpose', purpose],\n ] as const\n for (const [where, text] of lines) {\n if (!text) continue\n const reason = aiSiteImportInventedIn(text, held)\n if (reason) out.push(invented(`${where}, \"${text.slice(0, 80)}\": ${reason}`))\n else if (aiLayoutGuardContacts(text, contacts) !== text) out.push(invented(`${where}, \"${text.slice(0, 80)}\": it gives a phone number or email the site does not.`))\n }\n if (out.length || !hero || !group || !rhythm || !closing) return { plan: null, violations: out }\n // What each page is for (AGL-4152): a role it does not know, or a page that is none of the site's, is left to the page.\n const roles: Record<string, AiSiteImportPageRole> = {}\n for (const entry of Array.isArray(answer['roles']) ? answer['roles'] : []) {\n const named = record(entry)\n const page = clean(named['page'])\n const role = AI_SITE_IMPORT_PAGE_ROLES.find((value) => value === named['role'])\n if (role && (ids.has(page) || (page === AI_SITE_IMPORT_PROPOSED_PAGE && proposes))) roles[page] = role\n }\n // A button that asks to be contacted goes to the page for that, whatever page the answer named (AGL-4152).\n const ctaTarget = aiSiteImportCtaTarget({ label: ctaLabel, target }, roles)\n return {\n plan: {\n site: { what, audience, kind, voice: clean(site['voice']) },\n nav: { groups, primaryCta: { label: ctaLabel, target: ctaTarget, ...(ctaPage ? { page: ctaPage } : {}) }, footer },\n design: { hero, group, rhythm, cta: closing },\n proposed: proposes ? { title, slug, purpose, on: true } : null,\n ...(Object.keys(roles).length ? { roles } : {}),\n },\n violations: [],\n }\n}\n\n/**\n * Words on a button that ask a visitor to reach the business (AGL-4152):\n * contact, get in touch, a quote or estimate, a booking or appointment, a\n * call, a talk, a consultation, an enquiry, a message.\n */\nconst CONTACT_WORDS =\n /\\b(?:contact|get in touch|in touch|reach (?:us|out)|quotes?|estimates?|book(?:ing)?|schedule|appointments?|call|talk|consult(?:ation)?s?|enquir(?:e|y|ies)|inquir(?:e|y|ies)|message|write to us|email us)\\b/i\n\n/** Whether a button's words ask to be contacted. */\nexport function aiSiteImportAsksContact(label: string): boolean {\n return CONTACT_WORDS.test(label)\n}\n\n/**\n * Where the header's button goes (AGL-4152): where the answer sends it, except\n * that a button whose words ask to be contacted, sent to a page whose role is\n * not `contact` while a page of that role exists, goes to that page. A\n * \"Contact us\" to the About page took the visitor somewhere else than its\n * words said, and the menu, leaving a lone entry to the button's page, then\n * lost About altogether. The phone and the form are contact already.\n */\nexport function aiSiteImportCtaTarget(cta: { label: string; target: string }, roles: Readonly<Record<string, AiSiteImportPageRole>>): string {\n if (cta.target === 'phone' || cta.target === 'form' || !aiSiteImportAsksContact(cta.label)) return cta.target\n if (roles[cta.target] === 'contact') return cta.target\n const contact = Object.keys(roles).find((page) => roles[page] === 'contact')\n return contact ?? cta.target\n}\n\n/** A plan's check, answer by answer, for the one re-ask. */\nexport function aiSiteImportPlanCheck(input: AiSiteImportPlanScope): AiGenerationCheck<AiSiteImportPlan> {\n return (answer) => {\n const { plan, violations } = aiSiteImportPlanRead(answer, input)\n return plan ? { value: plan, violations: [] } : { value: null, violations }\n }\n}\n\n/*------------------------------------------\n * The answer asked\n *-----------------------------------------*/\n\n/** The most tokens a plan's answer asks, with its thinking. */\nexport const AI_SITE_IMPORT_PLAN_MOST_TOKENS = 4_000\n\n/** The least time a plan's pass needs: its answer and its one re-ask on the page step's tier. */\nexport const AI_SITE_IMPORT_PLAN_BUDGET = aiJobStepBudget({ tier: AI_STEP_TIERS['job.page'], maxTokens: AI_SITE_IMPORT_PLAN_MOST_TOKENS })\n\n/** The ceiling a plan is asked at on this model. */\nexport function aiSiteImportPlanMaxTokens(model: string): number {\n return aiGenerationMaxTokensWithin({ model, budgetMs: AI_SITE_IMPORT_PLAN_BUDGET.minimumMs, cap: AI_SITE_IMPORT_PLAN_MOST_TOKENS, lookups: 0 })\n}\n\n/** The one plan a generative Improve it asks for, on the page step's tier. */\nexport async function aiRunSiteImportPlan(input: AiSiteImportPlanScope & { state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName' | 'domain'>; model: string; signal?: AbortSignal }): Promise<AiValidatedGeneration<AiSiteImportPlan>> {\n return runValidatedGeneration<AiSiteImportPlan>(AI_SITE_IMPORT_PLAN_KIND, {\n step: 'job.page',\n model: input.model,\n instructions: aiSiteImportPlanInstructions(),\n messages: [{ role: 'user', content: aiSiteImportPlanPrompt({ state: input.state, required: input.required, roomForPage: input.roomForPage }) }],\n tool: AI_SITE_IMPORT_PLAN_TOOL,\n maxTokens: aiSiteImportPlanMaxTokens(input.model),\n cutOff: { noun: 'plan', smaller: 'Write shorter lines.' },\n ...AI_LAYOUT_LANGUAGE_THINKING,\n check: aiSiteImportPlanCheck(input),\n ...(input.signal ? { signal: input.signal } : {}),\n })\n}\n"],"names":["fenceUntrustedText","UNTRUSTED_TEXT_RULE","aiLayoutGuardContacts","AI_SITE_IMPORT_PAGE_ROLES","AI_SITE_IMPORT_PROPOSED_PAGE","aiSiteImportPageIsLegal","AI_SITE_KINDS","AI_STEP_TIERS","runValidatedGeneration","aiGenerationMaxTokensWithin","aiJobStepBudget","AI_LAYOUT_LANGUAGE_THINKING","AI_SITE_IMPORT_DROPPED_ITEM_CODE","AI_SITE_IMPORT_INVENTED_FACT_CODE","aiSiteImportHonestyFacts","aiSiteImportInventedIn","aiSiteImportRedesignWhy","clean","text","replace","trim","AI_SITE_IMPORT_PLAN_KIND","AI_SITE_IMPORT_PLAN_HEROES","AI_SITE_IMPORT_PLAN_MAX_GROUPS","AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS","AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS","GROUP_SCHEMA","type","additionalProperties","required","properties","label","pages","items","AI_SITE_IMPORT_PLAN_TOOL","name","description","strict","inputSchema","site","what","audience","kind","enum","map","id","voice","nav","groups","cta","target","footer","design","hero","group","rhythm","proposed","title","slug","purpose","roles","page","role","AI_SITE_IMPORT_PLAN_TEXT","join","aiSiteImportPlanInstructions","cacheBreakpoint","SITE_MAX_CHARS","PAGES_MAX_CHARS","HEADINGS_PER_PAGE","pageLine","blocks","read","headings","flatMap","block","slice","marks","has","draftId","forms","length","words","toLocaleString","aiSiteImportPlanPages","state","filter","refused","aiSiteImportPlanPrompt","input","home","Set","phones","facts","said","siteName","lines","Boolean","domain","maxChars","roomForPage","SLUG","invented","message","rule","code","dropped","unusable","record","value","groupsOf","Array","isArray","entry","trimSlashes","path","aiSiteImportPlanPageIdOf","some","address","toLowerCase","hits","linksTo","href","own","URL","url","host","decodeURIComponent","pathname","oldMenuHeadingOf","find","item","likeness","other","section","split","placeInFooter","of","self","heading","best","bestScore","forEach","column","index","score","reduce","sum","fits","push","aiSiteImportPlanMended","ids","homeIds","idOf","tidy","list","menu","proposes","placed","missing","aiSiteImportPlanWhy","violations","AI_SITE_IMPORT_PLAN_REFUSED_WHY","aiSiteImportPlanScopeLines","siteLines","aiSiteImportPlanRead","raw","answer","proposedRaw","out","test","where","named","ctaLabel","written","ctaPage","form","fields","closing","held","scope","contacts","reason","plan","ctaTarget","aiSiteImportCtaTarget","primaryCta","on","Object","keys","CONTACT_WORDS","aiSiteImportAsksContact","contact","aiSiteImportPlanCheck","AI_SITE_IMPORT_PLAN_MOST_TOKENS","AI_SITE_IMPORT_PLAN_BUDGET","tier","maxTokens","aiSiteImportPlanMaxTokens","model","budgetMs","minimumMs","cap","lookups","aiRunSiteImportPlan","step","instructions","messages","content","tool","cutOff","noun","smaller","check","signal"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;2CAqB2C,GAE3C,SAASA,kBAAkB,EAAEC,mBAAmB,QAAQ,0CAAyC;AACjG,SAASC,qBAAqB,QAAQ,uCAAmC;AACzE,SAASC,yBAAyB,EAAEC,4BAA4B,EAAEC,uBAAuB,QAAsI,6BAAyB;AACxP,SAASC,aAAa,QAAQ,4BAAwB;AAEtD,SAASC,aAAa,QAAQ,0BAAsB;AAEpD,SAASC,sBAAsB,QAAQ,4BAAwB;AAE/D,SAASC,2BAA2B,EAAEC,eAAe,QAAQ,qBAAiB;AAC9E,SAASC,2BAA2B,QAAQ,4BAAwB;AACpE,SAASC,gCAAgC,EAAEC,iCAAiC,EAAEC,wBAAwB,EAAEC,sBAAsB,QAAQ,8BAA0B;AAChK,SAASC,uBAAuB,QAAQ,8BAA0B;AAElE,MAAMC,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,uFAAuF,GACvF,OAAO,MAAMC,2BAA2B,mBAAkB;AAE1D,qFAAqF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BxG;OACzBA,MAAM6H,MAAM,GAAG;QAAEA,QAAQ7H,MAAM6H,MAAM;IAAC,IAAI,CAAC;AAEnD"}
|
|
@@ -16,6 +16,7 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/ import { REUSABLE_INSTANCE_COMPONENT_ID } from "@aglyn/aglyn/app-utils/reusable-component-keys";
|
|
19
|
+
import { ELEMENT_COLOR_SCHEME_VISITOR } from "@aglyn/aglyn/app-utils/element-color-scheme";
|
|
19
20
|
import { CANVAS_ROOT_ELEMENT_ID } from "@aglyn/aglyn/foundation/constants/canvas";
|
|
20
21
|
import { AI_ICON_COMPONENT_ID, aiIconOfWord, AI_ICON_LIBRARY } from "../runtime/ai-icon-library.js";
|
|
21
22
|
import { AI_INSTANCE_REF_PROP } from "../runtime/ai-node-tree.js";
|
|
@@ -1037,31 +1038,28 @@ function compileButton(scope, block) {
|
|
|
1037
1038
|
variant: 'contained',
|
|
1038
1039
|
color: onBrand ? 'secondary' : 'primary'
|
|
1039
1040
|
};
|
|
1040
|
-
// A filled button
|
|
1041
|
-
//
|
|
1042
|
-
// its header's button and every other
|
|
1043
|
-
const oneFill =
|
|
1044
|
-
// Sized to its words, never stretched across the column a Stack would
|
|
1045
|
-
// stretch it over (AGL-3660), and aligned with its section.
|
|
1046
|
-
const place = {
|
|
1047
|
-
alignSelf: scope.centered ? 'center' : 'flex-start'
|
|
1048
|
-
};
|
|
1041
|
+
// A filled button is the site's one primary (AGL-4152). A dark band and a cover photo pin the dark scheme, whose
|
|
1042
|
+
// primary is the light page's lighter twin; the button goes back to the scheme the visitor picked, so it wears
|
|
1043
|
+
// the primary its header's button and every other filled button wear, light or dark, and paints no ground.
|
|
1044
|
+
const oneFill = look.variant === 'contained' && look.color === 'primary' && (scope.band === 'dark' || !!scope.overPhoto);
|
|
1049
1045
|
const id = scope.page.tree.add('muiButton', _extends({
|
|
1050
1046
|
children: label
|
|
1051
1047
|
}, look, {
|
|
1052
1048
|
size: scope.index === 0 || block.style === 'large' ? 'large' : 'medium'
|
|
1053
|
-
}, destination ? destinationProps(destination) : {}
|
|
1049
|
+
}, destination ? destinationProps(destination) : {}, oneFill ? {
|
|
1050
|
+
colorScheme: ELEMENT_COLOR_SCHEME_VISITOR
|
|
1051
|
+
} : {}), // Sized to its words, never stretched across the column a Stack would
|
|
1052
|
+
// stretch it over (AGL-3660), and aligned with its section.
|
|
1053
|
+
{
|
|
1054
|
+
alignSelf: scope.centered ? 'center' : 'flex-start'
|
|
1055
|
+
}, null, 'button');
|
|
1054
1056
|
if (destination) linkTo(scope, id, destination);
|
|
1055
1057
|
if (film !== null) ((_plays = (_scope_page = scope.page).plays) != null ? _plays : _scope_page.plays = []).push({
|
|
1056
1058
|
id,
|
|
1057
1059
|
film,
|
|
1058
1060
|
label
|
|
1059
1061
|
});
|
|
1060
|
-
return
|
|
1061
|
-
colorScheme: 'light'
|
|
1062
|
-
}, place, [
|
|
1063
|
-
id
|
|
1064
|
-
], 'buttonScheme') : id;
|
|
1062
|
+
return id;
|
|
1065
1063
|
}
|
|
1066
1064
|
/** The film a button of a page brought in plays (AGL-4140), `video:<n>`, by its index; `null` for any other destination. */ export function aiLayoutImportedFilm(to) {
|
|
1067
1065
|
const match = /^video:(\d{1,3})$/.exec((to != null ? to : '').trim());
|