@aglyn/plugins-ai 1.0.0-beta.292 → 1.0.0-beta.296

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 (203) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-job-links.d.ts +15 -2
  3. package/src/lib/components/ai-job-links.js +24 -3
  4. package/src/lib/components/ai-job-links.js.map +1 -1
  5. package/src/lib/components/ai-job-requests.d.ts +9 -0
  6. package/src/lib/components/ai-job-requests.js +34 -0
  7. package/src/lib/components/ai-job-requests.js.map +1 -1
  8. package/src/lib/components/ai-site-build-page.component.js +28 -2
  9. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  10. package/src/lib/components/ai-site-import-job.component.js +5 -4
  11. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  12. package/src/lib/components/ai-site-import-start.component.js +3 -3
  13. package/src/lib/components/ai-site-import-start.component.js.map +1 -1
  14. package/src/lib/components/ai-site-start-card.component.d.ts +1 -1
  15. package/src/lib/components/ai-site-start-card.component.js +129 -29
  16. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  17. package/src/lib/components/ai-site-start-steps.component.d.ts +15 -3
  18. package/src/lib/components/ai-site-start-steps.component.js +42 -25
  19. package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
  20. package/src/lib/components/ai-site-style-previews.d.ts +17 -0
  21. package/src/lib/components/ai-site-style-previews.js +26 -95
  22. package/src/lib/components/ai-site-style-previews.js.map +1 -1
  23. package/src/lib/components/assist-jobs-drawer.component.d.ts +7 -1
  24. package/src/lib/components/assist-jobs-drawer.component.js +20 -6
  25. package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
  26. package/src/lib/components/assist-page-change-card.component.d.ts +44 -0
  27. package/src/lib/components/assist-page-change-card.component.js +166 -0
  28. package/src/lib/components/assist-page-change-card.component.js.map +1 -0
  29. package/src/lib/components/assist-panel.component.d.ts +105 -1
  30. package/src/lib/components/assist-panel.component.js +224 -29
  31. package/src/lib/components/assist-panel.component.js.map +1 -1
  32. package/src/lib/declarations.server.js +22 -0
  33. package/src/lib/declarations.server.js.map +1 -1
  34. package/src/lib/jobs/ai-job-edit-step.d.ts +62 -16
  35. package/src/lib/jobs/ai-job-edit-step.js +172 -61
  36. package/src/lib/jobs/ai-job-edit-step.js.map +1 -1
  37. package/src/lib/jobs/ai-job-import-step.d.ts +21 -2
  38. package/src/lib/jobs/ai-job-import-step.js +179 -49
  39. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  40. package/src/lib/jobs/ai-job-layout-language.d.ts +27 -3
  41. package/src/lib/jobs/ai-job-layout-language.js +156 -113
  42. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  43. package/src/lib/jobs/ai-job-layout-step.js +56 -17
  44. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  45. package/src/lib/jobs/ai-job-navigation-step.js +4 -2
  46. package/src/lib/jobs/ai-job-navigation-step.js.map +1 -1
  47. package/src/lib/jobs/ai-job-page-language.d.ts +25 -15
  48. package/src/lib/jobs/ai-job-page-language.js +120 -66
  49. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  50. package/src/lib/jobs/ai-job-page-step.js +27 -7
  51. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  52. package/src/lib/jobs/ai-job-site-datasets.d.ts +12 -4
  53. package/src/lib/jobs/ai-job-site-datasets.js +36 -16
  54. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  55. package/src/lib/jobs/ai-jobs.js +6 -2
  56. package/src/lib/jobs/ai-jobs.js.map +1 -1
  57. package/src/lib/jobs/ai-layout-stock-photos.d.ts +50 -1
  58. package/src/lib/jobs/ai-layout-stock-photos.js +586 -35
  59. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  60. package/src/lib/jobs/ai-site-import-compile.d.ts +147 -0
  61. package/src/lib/jobs/ai-site-import-compile.js +1143 -0
  62. package/src/lib/jobs/ai-site-import-compile.js.map +1 -0
  63. package/src/lib/jobs/ai-site-import-document.d.ts +9 -36
  64. package/src/lib/jobs/ai-site-import-document.js +23 -489
  65. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  66. package/src/lib/jobs/ai-site-import-look.d.ts +54 -7
  67. package/src/lib/jobs/ai-site-import-look.js +163 -52
  68. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  69. package/src/lib/jobs/ai-site-import-publish.d.ts +7 -1
  70. package/src/lib/jobs/ai-site-import-publish.js +19 -5
  71. package/src/lib/jobs/ai-site-import-publish.js.map +1 -1
  72. package/src/lib/jobs/ai-site-late-photos.js +4 -2
  73. package/src/lib/jobs/ai-site-late-photos.js.map +1 -1
  74. package/src/lib/jobs/ai-site-publish.d.ts +10 -1
  75. package/src/lib/jobs/ai-site-publish.js +8 -3
  76. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  77. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.d.ts +23 -0
  78. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.js +677 -0
  79. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.js.map +1 -0
  80. package/src/lib/layout-language/ai-layout-compiler.d.ts +26 -0
  81. package/src/lib/layout-language/ai-layout-compiler.js +677 -33
  82. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  83. package/src/lib/layout-language/ai-layout-frame-hollows.js +5 -1
  84. package/src/lib/layout-language/ai-layout-frame-hollows.js.map +1 -1
  85. package/src/lib/layout-language/ai-layout-frame-source.d.ts +196 -0
  86. package/src/lib/layout-language/ai-layout-frame-source.js +726 -0
  87. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -0
  88. package/src/lib/layout-language/ai-layout-frame.d.ts +22 -0
  89. package/src/lib/layout-language/ai-layout-frame.js +121 -29
  90. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  91. package/src/lib/layout-language/ai-layout-language.d.ts +103 -37
  92. package/src/lib/layout-language/ai-layout-language.js +85 -120
  93. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  94. package/src/lib/model/ai-credit-estimate.d.ts +11 -7
  95. package/src/lib/model/ai-credit-estimate.js +11 -7
  96. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  97. package/src/lib/model/ai-edit-job.d.ts +33 -16
  98. package/src/lib/model/ai-edit-job.js +50 -34
  99. package/src/lib/model/ai-edit-job.js.map +1 -1
  100. package/src/lib/model/ai-job-activity.d.ts +6 -11
  101. package/src/lib/model/ai-job-activity.js +8 -15
  102. package/src/lib/model/ai-job-activity.js.map +1 -1
  103. package/src/lib/model/ai-jobs.types.d.ts +6 -0
  104. package/src/lib/model/ai-jobs.types.js.map +1 -1
  105. package/src/lib/model/ai-site-import.d.ts +307 -13
  106. package/src/lib/model/ai-site-import.js +227 -19
  107. package/src/lib/model/ai-site-import.js.map +1 -1
  108. package/src/lib/model/ai-site-inventory.d.ts +6 -0
  109. package/src/lib/model/ai-site-inventory.js.map +1 -1
  110. package/src/lib/model/ai-site-look.d.ts +65 -1
  111. package/src/lib/model/ai-site-look.js +141 -23
  112. package/src/lib/model/ai-site-look.js.map +1 -1
  113. package/src/lib/model/ai-site-photos.d.ts +2 -0
  114. package/src/lib/model/ai-site-photos.js.map +1 -1
  115. package/src/lib/model/ai-site-start-steps.d.ts +4 -3
  116. package/src/lib/model/ai-site-start-steps.js +11 -3
  117. package/src/lib/model/ai-site-start-steps.js.map +1 -1
  118. package/src/lib/model/ai-site-start.d.ts +23 -2
  119. package/src/lib/model/ai-site-start.js +25 -3
  120. package/src/lib/model/ai-site-start.js.map +1 -1
  121. package/src/lib/model/assist-edit.d.ts +18 -1
  122. package/src/lib/model/assist-edit.js +7 -0
  123. package/src/lib/model/assist-edit.js.map +1 -1
  124. package/src/lib/model/assist-page-change.d.ts +86 -0
  125. package/src/lib/model/assist-page-change.js +86 -0
  126. package/src/lib/model/assist-page-change.js.map +1 -0
  127. package/src/lib/providers/routing.d.ts +11 -0
  128. package/src/lib/providers/routing.js +23 -0
  129. package/src/lib/providers/routing.js.map +1 -1
  130. package/src/lib/runtime/ai-doctrine-validators.d.ts +4 -2
  131. package/src/lib/runtime/ai-doctrine-validators.js +7 -2
  132. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  133. package/src/lib/runtime/ai-eval.js +3 -1
  134. package/src/lib/runtime/ai-eval.js.map +1 -1
  135. package/src/lib/runtime/ai-icon-library.d.ts +4 -0
  136. package/src/lib/runtime/ai-icon-library.js +4 -0
  137. package/src/lib/runtime/ai-icon-library.js.map +1 -1
  138. package/src/lib/runtime/ai-node-tree.d.ts +5 -0
  139. package/src/lib/runtime/ai-node-tree.js +23 -4
  140. package/src/lib/runtime/ai-node-tree.js.map +1 -1
  141. package/src/lib/runtime/ai-palette.d.ts +2 -0
  142. package/src/lib/runtime/ai-palette.generated.js +19 -3
  143. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  144. package/src/lib/runtime/ai-palette.js +2 -1
  145. package/src/lib/runtime/ai-palette.js.map +1 -1
  146. package/src/lib/runtime/site-inventory.d.ts +8 -1
  147. package/src/lib/runtime/site-inventory.js +18 -0
  148. package/src/lib/runtime/site-inventory.js.map +1 -1
  149. package/src/lib/server/assist-build.js +2 -0
  150. package/src/lib/server/assist-build.js.map +1 -1
  151. package/src/lib/server/assist-chat.js +51 -2
  152. package/src/lib/server/assist-chat.js.map +1 -1
  153. package/src/lib/server/assist-edit.d.ts +54 -2
  154. package/src/lib/server/assist-edit.js +219 -30
  155. package/src/lib/server/assist-edit.js.map +1 -1
  156. package/src/lib/server/assist-page-change.d.ts +62 -0
  157. package/src/lib/server/assist-page-change.js +140 -0
  158. package/src/lib/server/assist-page-change.js.map +1 -0
  159. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +50 -0
  160. package/src/lib/site-import/fixtures/site-layout-recordings.js +86 -0
  161. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -0
  162. package/src/lib/site-import/site-import-crawl.d.ts +18 -1
  163. package/src/lib/site-import/site-import-crawl.js +70 -10
  164. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  165. package/src/lib/site-import/site-import-css.d.ts +110 -0
  166. package/src/lib/site-import/site-import-css.js +826 -0
  167. package/src/lib/site-import/site-import-css.js.map +1 -0
  168. package/src/lib/site-import/site-import-html.d.ts +116 -1
  169. package/src/lib/site-import/site-import-html.js +538 -46
  170. package/src/lib/site-import/site-import-html.js.map +1 -1
  171. package/src/lib/site-import/site-import-layout.d.ts +79 -0
  172. package/src/lib/site-import/site-import-layout.js +1608 -0
  173. package/src/lib/site-import/site-import-layout.js.map +1 -0
  174. package/src/lib/site-import/site-import-nav.d.ts +40 -0
  175. package/src/lib/site-import/site-import-nav.js +437 -0
  176. package/src/lib/site-import/site-import-nav.js.map +1 -0
  177. package/src/lib/site-import/site-import-page.d.ts +8 -1
  178. package/src/lib/site-import/site-import-page.js +24 -2
  179. package/src/lib/site-import/site-import-page.js.map +1 -1
  180. package/src/lib/assets/site-styles/beauty.webp +0 -0
  181. package/src/lib/assets/site-styles/blog.webp +0 -0
  182. package/src/lib/assets/site-styles/business.webp +0 -0
  183. package/src/lib/assets/site-styles/coming-soon.webp +0 -0
  184. package/src/lib/assets/site-styles/education.webp +0 -0
  185. package/src/lib/assets/site-styles/events.webp +0 -0
  186. package/src/lib/assets/site-styles/fitness.webp +0 -0
  187. package/src/lib/assets/site-styles/landing.webp +0 -0
  188. package/src/lib/assets/site-styles/music.webp +0 -0
  189. package/src/lib/assets/site-styles/nonprofit.webp +0 -0
  190. package/src/lib/assets/site-styles/personal.webp +0 -0
  191. package/src/lib/assets/site-styles/photography.webp +0 -0
  192. package/src/lib/assets/site-styles/portfolio.webp +0 -0
  193. package/src/lib/assets/site-styles/professional.webp +0 -0
  194. package/src/lib/assets/site-styles/realestate.webp +0 -0
  195. package/src/lib/assets/site-styles/restaurant.webp +0 -0
  196. package/src/lib/assets/site-styles/store.webp +0 -0
  197. package/src/lib/assets/site-styles/studio.webp +0 -0
  198. package/src/lib/assets/site-styles/trades.webp +0 -0
  199. package/src/lib/assets/site-styles/wellness.webp +0 -0
  200. package/src/lib/assets/site-styles/yoga.webp +0 -0
  201. package/src/lib/site-import/site-import-review.d.ts +0 -40
  202. package/src/lib/site-import/site-import-review.js +0 -149
  203. package/src/lib/site-import/site-import-review.js.map +0 -1
@@ -21,7 +21,7 @@ import { aiHomeScreenIds } from "../model/ai-site-inventory.js";
21
21
  import { AI_LAYOUT_POST_ADDRESS_TOKENS, aiCompileLayoutPage } from "../layout-language/ai-layout-compiler.js";
22
22
  import { aiSiteMotionStyle, aiWithSiteMotion } from "../layout-language/ai-layout-motion.js";
23
23
  import { aiLayoutListingAt, aiLayoutListingsOf, aiLayoutRecordHref } from "../layout-language/ai-layout-listings.js";
24
- import { AI_LAYOUT_ARRANGE_TOOL, AI_LAYOUT_LANGUAGE_TEXT, AI_LAYOUT_PAGE_TOOL, aiReadLayoutArrangement, aiReadLayoutPage } from "../layout-language/ai-layout-language.js";
24
+ import { AI_LAYOUT_DESIGN_TOOL, AI_LAYOUT_LANGUAGE_TEXT, AI_LAYOUT_PAGE_TOOL, aiReadLayoutDesign, aiReadLayoutPage } from "../layout-language/ai-layout-language.js";
25
25
  import { aiLayoutCopyCheck, aiLayoutWithoutSections } from "../layout-language/ai-layout-gaps.js";
26
26
  import { aiLayoutPromisedCopyViolations, aiLayoutPromisedSections } from "../layout-language/ai-layout-promised-copy.js";
27
27
  import { aiLayoutStoredTree } from "../layout-language/ai-layout-store.js";
@@ -38,7 +38,8 @@ import { aiJobBriefLine, aiPlanReferenceLines } from "./ai-job-generation.js";
38
38
  import { aiLayoutIsHomeSlug, aiLayoutSiteAliases, aiLayoutSitePages } from "./ai-job-layout-site-pages.js";
39
39
  import { aiLayoutInventedContactViolations } from "./ai-layout-site-facts.js";
40
40
  import { aiSiteContactOf } from "../model/ai-site-details.js";
41
- import { AI_SITE_IMPORT_ARRANGE_MAX_CHARS, aiCompileImportedDocument, aiSiteImportArrangeText, aiSiteImportDocLines, aiSiteImportDocumentOf } from "./ai-site-import-document.js";
41
+ import { aiSiteImportDocumentOf } from "./ai-site-import-document.js";
42
+ import { AI_SITE_IMPORT_DESIGN_MAX_CHARS, aiCompileImportedPage, aiSiteImportDesignText, aiSiteImportSectionNames } from "./ai-site-import-compile.js";
42
43
  /**
43
44
  * A page built in the compact layout language (AGL-3660): the page step's
44
45
  * pass for a site's page units — a guided start's and a build's — in place of
@@ -861,68 +862,89 @@ export const AI_JOB_PAGE_LANGUAGE_BUDGET = aiJobStepBudget({
861
862
  return _extends({}, second, spentTogether(first, second));
862
863
  }
863
864
  /*------------------------------------------
864
- * A page brought in: copied, or arranged (AGL-4084)
865
+ * A page brought in: built by the site compiler (AGL-4084, AGL-4107)
865
866
  *-----------------------------------------*/ /**
866
- * What an arranged page's answer is told (AGL-4084), cached: the page's words
867
- * are the source's and fixed, and the answer only lays them out. The tool has
868
- * no field for a word of copy, so a rewording has nowhere to go.
869
- */ export const AI_LAYOUT_ARRANGE_TEXT = [
870
- "You arrange a page brought in from its owner's own website. Arrange; keep every line as written; add nothing; reword nothing. Its words are fixed: every line of the page is shown numbered, and the platform places each line you name exactly as its source wrote it, in the site's theme. You never write a word of copy.",
867
+ * What a main page's design answer is told (AGL-4107), cached: the page's
868
+ * words and structure are the source's and fixed, read by code, and the
869
+ * answer only chooses how its sections are drawn. The tool has no field for
870
+ * a word of copy, a line or a block, so nothing it says can reword or move
871
+ * one.
872
+ */ export const AI_LAYOUT_DESIGN_TEXT = [
873
+ "You design how a page brought in from its owner's own website is drawn. Its words, its sections and what each section shows are fixed: the platform reads them from the source and places every line exactly as written, in the site's theme. You choose only the design; you never write a word.",
871
874
  '',
872
- 'Answer with submit_arrangement: one entry in sections for each section of the page, in order. A section has:',
873
- '- band: plain (the page background), soft (a light band) or dark. Vary the bands down the page so neighboring sections read apart, and keep dark to one or two sections a page.',
874
- '- cols: [] for one column, or relative column widths for a row, such as [1, 1] or [7, 5]; at most 4.',
875
- '- align: start or center.',
876
- '- blocks: top to bottom. A block has kind, col (-1 to span the section, or the column of the row it sits in, 0 first), from (the numbers of the lines it shows, in order), style (primary, secondary or quiet for a button, none otherwise) and items.',
877
- '',
878
- 'Block kinds: heading, eyebrow, lede, text and note show their lines one under another; list shows each of its lines as an item; cards, steps, stats and faq show items, each item\'s from its title line first and then its text lines (from is then []); button is a line that is a link; image is a line that is a picture.',
879
- "Every line goes in exactly one block of its own section. Name no line twice and no line of another section. A line you leave out is still shown, at the end of its section, so leave none out on purpose. The page's first section opens with its heading line."
875
+ 'Answer with submit_design: one entry in sections for each section listed, in order. A section has:',
876
+ '- hero: for the first section, where it opens the page with a picture: split or bleed (the words beside the picture), cover or poster (the words over the picture, dimmed), panel (the words on a card over the picture), column or editorial (the words above a wide picture). Choose the one closest to how the source places its picture unless another reads better for this site; none keeps the source\'s own arrangement. Every other section: none.',
877
+ "- band: source keeps the section's own background. Only a section with no band of its own may take plain, soft or dark, so neighboring sections read apart; every other section: source.",
878
+ '- align: source, start or center.',
879
+ "- groups: one entry for each of the section's groups, in the order they are numbered. kind: source, or cards, steps, stats or list where the group plainly is one (numbered items are steps, a figure over its label is stats). style: cards (the theme's cards), ruled (open columns under a thin rule), icons (open columns led by their icons, only where each item has one), pictures (each item's picture over its words, open) or articles (the same, in cards), pictures and articles only where each item has a picture.",
880
+ 'Draw the page at least as well as its source: keep its boxes where it boxes its items, its icons where it draws them and its pictures where it shows them.'
880
881
  ].join('\n');
881
- /** The arranged page's cached instructions, and the rule that fenced text is data. */ export const AI_JOB_PAGE_ARRANGE_INSTRUCTIONS = [
882
+ /** The design answer's cached instructions, and the rule that fenced text is data. */ export const AI_JOB_PAGE_DESIGN_INSTRUCTIONS = [
882
883
  {
883
- text: AI_LAYOUT_ARRANGE_TEXT,
884
+ text: AI_LAYOUT_DESIGN_TEXT,
884
885
  cacheBreakpoint: true
885
886
  },
886
887
  {
887
888
  text: UNTRUSTED_TEXT_RULE
888
889
  }
889
890
  ];
890
- /** An arranged page's user turn: the page, the kind of site it is, and its numbered lines, fenced. */ export function aiLayoutArrangePrompt(input) {
891
- const { sections } = aiSiteImportDocLines(input.doc.blocks, input.doc.title);
891
+ /** A design answer's user turn: the page, the kind of site it is, and its structure, the sections' names fenced. */ export function aiLayoutDesignPrompt(input) {
892
+ const count = aiSiteImportSectionNames(input.doc).length;
892
893
  return [
893
894
  `Page: "${input.screen.title}" at ${input.screen.slug}`,
894
895
  ...aiSiteKindDesignLines(input.job.inputs),
895
- `Its ${sections.length === 1 ? 'one section' : `${sections.length} sections`}, each with its numbered lines:`,
896
- fenceUntrustedText(`The owner's page ${input.doc.url}`, aiSiteImportArrangeText(input.doc), {
897
- maxChars: AI_SITE_IMPORT_ARRANGE_MAX_CHARS
896
+ `Its ${count === 1 ? 'one section' : `${count} sections`}, each with what it shows:`,
897
+ fenceUntrustedText(`The structure of the owner's page ${input.doc.url}`, aiSiteImportDesignText(input.doc), {
898
+ maxChars: AI_SITE_IMPORT_DESIGN_MAX_CHARS
898
899
  }),
899
900
  `Design seed: ${input.job.$id.slice(-6)}.`
900
901
  ].join('\n');
901
902
  }
903
+ /** The site a page brought in is drawn for: its design, else the page's own, so its hero has a home to open (AGL-4107). */ function importedDesign(design, screen) {
904
+ return design != null ? design : {
905
+ kind: 'business',
906
+ seed: 0,
907
+ home: aiLayoutIsHomeSlug(screen.slug)
908
+ };
909
+ }
902
910
  /**
903
- * The check a page brought in is held to (AGL-4084): the arrangement read
904
- * (or none, for a page copied as it is), the source's lines substituted
905
- * into it, the page stored and checked whole as a page of the owner's own
906
- * words. Nothing in an answer can change a word.
911
+ * The check a page brought in is held to (AGL-4084, AGL-4107): its layout
912
+ * compiled by the site compiler with every word as written — with the design
913
+ * answer where one is given — stored, and checked whole as a page of its
914
+ * owner's own words. An answer whose design cannot be drawn is set aside and
915
+ * the page is drawn as its source lays it out, so no answer is asked again
916
+ * for what code decides. Nothing in an answer can change a word.
907
917
  */ export function aiImportedPageCheck(input) {
908
918
  const context = _extends({}, aiLayoutListingContext(input.context, input.targets), {
909
919
  ownWords: true
910
920
  });
911
- return (answer)=>{
921
+ const plan = {
922
+ title: input.screen.title,
923
+ sections: input.screen.sections.map((section)=>({
924
+ name: section.name,
925
+ uses: [],
926
+ items: 0
927
+ }))
928
+ };
929
+ const build = (design)=>{
912
930
  var _ref, _input_motion;
913
- const arrangement = answer && input.doc.build === 'arranged' ? aiReadLayoutArrangement(answer, input.sectionIds.length) : null;
914
- const compiled = aiCompileImportedDocument({
931
+ const compiled = aiCompileImportedPage(_extends({
915
932
  doc: input.doc,
916
933
  sectionIds: input.sectionIds,
917
- pages: input.targets.pages,
918
- arrangement
919
- });
934
+ plan,
935
+ targets: input.targets,
936
+ design: importedDesign(input.design, input.screen),
937
+ answer: design
938
+ }, input.language ? {
939
+ language: input.language
940
+ } : {}));
920
941
  const stored = aiLayoutStoredTree(compiled.tree, 'screen', context, input.sectionIds);
921
942
  if (stored.ok === false) {
922
943
  console.error('ai imported page: a compiled page did not store', {
923
944
  error: stored.error
924
945
  });
925
946
  return {
947
+ compiled,
926
948
  value: null,
927
949
  violations: [
928
950
  {
@@ -942,10 +964,12 @@ export const AI_JOB_PAGE_LANGUAGE_BUDGET = aiJobStepBudget({
942
964
  repeatsCompiled: true
943
965
  }));
944
966
  if (report.violations.length) return {
967
+ compiled,
945
968
  value: null,
946
969
  violations: report.violations
947
970
  };
948
971
  return {
972
+ compiled,
949
973
  value: {
950
974
  nodes: aiWithSiteMotion(stored.nodes, (_ref = (_input_motion = input.motion) != null ? _input_motion : input.design) != null ? _ref : {
951
975
  seed: 0
@@ -953,15 +977,39 @@ export const AI_JOB_PAGE_LANGUAGE_BUDGET = aiJobStepBudget({
953
977
  sectionIds: input.sectionIds
954
978
  }),
955
979
  load: report.load,
956
- settled: [],
980
+ settled: compiled.settled,
957
981
  dropped: [],
958
- items: input.sectionIds.map(()=>0)
982
+ items: compiled.sectionRoots.map(()=>0)
959
983
  },
960
984
  violations: []
961
985
  };
962
986
  };
987
+ return (answer)=>{
988
+ var _ref;
989
+ var _designed_violations_;
990
+ const design = answer ? aiReadLayoutDesign(answer, input.sectionIds.length) : null;
991
+ const designed = build(design);
992
+ if (designed.value || !design) return {
993
+ value: designed.value,
994
+ violations: designed.violations
995
+ };
996
+ // The answer's design could not be drawn: the page as its source lays it out.
997
+ const plain = build(null);
998
+ if (plain.value) plain.value.settled.push({
999
+ at: 'design',
1000
+ what: `the design answer set aside: ${(_ref = (_designed_violations_ = designed.violations[0]) == null ? void 0 : _designed_violations_.code) != null ? _ref : 'not drawn'}`
1001
+ });
1002
+ return {
1003
+ value: plain.value,
1004
+ violations: plain.violations
1005
+ };
1006
+ };
963
1007
  }
964
- /** The most an arrangement answer runs to: a few hundred tokens of line numbers, inside a page's ceiling. */ export const AI_LAYOUT_ARRANGE_KIND = AI_LAYOUT_PAGE_KIND;
1008
+ /** The design answer's kind of generation, which shares the page's ceilings. */ export const AI_LAYOUT_DESIGN_KIND = AI_LAYOUT_PAGE_KIND;
1009
+ /**
1010
+ * The most a design answer runs to (AGL-4107): a few tokens a section and a
1011
+ * group, with room to think, inside a page's ceiling on the balanced tier.
1012
+ */ export const AI_LAYOUT_DESIGN_MAX_TOKENS = 3000;
965
1013
  const NO_USAGE = {
966
1014
  inputTokens: 0,
967
1015
  outputTokens: 0,
@@ -969,62 +1017,68 @@ const NO_USAGE = {
969
1017
  cacheWriteTokens: 0
970
1018
  };
971
1019
  /**
972
- * A page brought in (AGL-4084). Copied as it is: compiled by code, no model
973
- * at all, nothing spent. Arranged: one answer on the page step's tier that
974
- * lays the numbered lines out, every word still the source's.
1020
+ * A page brought in (AGL-4084, AGL-4107). Its layout is compiled first with
1021
+ * no model: a page of a collection is that page, nothing spent; a page that
1022
+ * cannot be built so is reviewed before anything is spent on it. A main page
1023
+ * then asks one design answer on the page step's balanced tier and is drawn
1024
+ * with it, every word still the source's.
975
1025
  */ async function aiRunImportedPage(input, doc) {
976
1026
  var _input_observe;
977
- const check = aiImportedPageCheck({
1027
+ const check = aiImportedPageCheck(_extends({
978
1028
  screen: input.screen,
979
1029
  sectionIds: input.sectionIds,
980
1030
  targets: input.targets,
981
1031
  context: input.context,
982
1032
  design: aiLayoutDesignOf(input.job, input.screen.slug),
983
- motion: aiLayoutMotionSiteOf(input.job, input.screen.slug),
1033
+ motion: aiLayoutMotionSiteOf(input.job, input.screen.slug)
1034
+ }, input.plan.language ? {
1035
+ language: input.plan.language
1036
+ } : {}, {
984
1037
  doc
985
- });
986
- if (doc.build === 'copied') {
987
- const spend = {
988
- attempts: 0,
989
- usage: NO_USAGE,
990
- estCostUsd: 0,
991
- model: input.model,
992
- stopReason: null,
993
- effort: null
994
- };
995
- const result = check(null);
996
- return result.value ? _extends({}, spend, {
997
- status: 'ok',
998
- value: result.value
999
- }) : _extends({}, spend, {
1038
+ }));
1039
+ const spend = {
1040
+ attempts: 0,
1041
+ usage: NO_USAGE,
1042
+ estCostUsd: 0,
1043
+ model: input.model,
1044
+ stopReason: null,
1045
+ effort: null
1046
+ };
1047
+ const plain = check(null);
1048
+ if (!plain.value) {
1049
+ return _extends({}, spend, {
1000
1050
  status: 'needs_input',
1001
- violations: result.violations,
1002
- message: aiDoctrineNeedsInputMessage(result.violations),
1051
+ violations: plain.violations,
1052
+ message: aiDoctrineNeedsInputMessage(plain.violations),
1003
1053
  answer: null
1004
1054
  });
1005
1055
  }
1056
+ if (doc.build === 'copied') return _extends({}, spend, {
1057
+ status: 'ok',
1058
+ value: plain.value
1059
+ });
1006
1060
  const observe = (_input_observe = input.observe) != null ? _input_observe : (inner)=>inner;
1007
- return runValidatedGeneration(AI_LAYOUT_ARRANGE_KIND, _extends({
1061
+ return runValidatedGeneration(AI_LAYOUT_DESIGN_KIND, _extends({
1008
1062
  step: 'job.page',
1009
1063
  model: input.model,
1010
- instructions: AI_JOB_PAGE_ARRANGE_INSTRUCTIONS,
1011
- // The lines are the whole question: no lookup of the site is offered.
1064
+ instructions: AI_JOB_PAGE_DESIGN_INSTRUCTIONS,
1065
+ // The structure is the whole question: no lookup of the site is offered.
1012
1066
  inventory: null,
1013
1067
  messages: [
1014
1068
  {
1015
1069
  role: 'user',
1016
- content: aiLayoutArrangePrompt({
1070
+ content: aiLayoutDesignPrompt({
1017
1071
  job: input.job,
1018
1072
  screen: input.screen,
1019
1073
  doc
1020
1074
  })
1021
1075
  }
1022
1076
  ],
1023
- tool: AI_LAYOUT_ARRANGE_TOOL,
1024
- maxTokens: AI_JOB_PAGE_LANGUAGE_BUDGET.maxTokens(input.model),
1077
+ tool: AI_LAYOUT_DESIGN_TOOL,
1078
+ maxTokens: Math.min(AI_LAYOUT_DESIGN_MAX_TOKENS, AI_JOB_PAGE_LANGUAGE_BUDGET.maxTokens(input.model)),
1025
1079
  cutOff: {
1026
- noun: 'page',
1027
- smaller: 'Use fewer blocks: give each block more of its lines.'
1080
+ noun: 'design',
1081
+ smaller: 'Answer with the choices alone.'
1028
1082
  }
1029
1083
  }, AI_LAYOUT_LANGUAGE_THINKING, {
1030
1084
  check: observe((answer)=>check(answer))