@aglyn/plugins-ai 1.14.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-site-build-page.component.js +5 -3
  3. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  4. package/src/lib/components/ai-site-import-finish.component.d.ts +3 -1
  5. package/src/lib/components/ai-site-import-finish.component.js +3 -3
  6. package/src/lib/components/ai-site-import-finish.component.js.map +1 -1
  7. package/src/lib/components/ai-site-import-job.component.d.ts +4 -3
  8. package/src/lib/components/ai-site-import-job.component.js +141 -43
  9. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  10. package/src/lib/components/ai-site-import-plan.component.d.ts +42 -0
  11. package/src/lib/components/ai-site-import-plan.component.js +246 -0
  12. package/src/lib/components/ai-site-import-plan.component.js.map +1 -0
  13. package/src/lib/components/ai-site-import-start.component.d.ts +3 -1
  14. package/src/lib/components/ai-site-import-start.component.js +3 -2
  15. package/src/lib/components/ai-site-import-start.component.js.map +1 -1
  16. package/src/lib/components/ai-site-start-card.component.js +6 -2
  17. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  18. package/src/lib/components/ai-site-start-steps.component.d.ts +3 -2
  19. package/src/lib/components/ai-site-start-steps.component.js +12 -5
  20. package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
  21. package/src/lib/jobs/ai-job-import-step.d.ts +47 -2
  22. package/src/lib/jobs/ai-job-import-step.js +356 -22
  23. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  24. package/src/lib/jobs/ai-job-layout-language.js +4 -1
  25. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  26. package/src/lib/jobs/ai-job-page-language.d.ts +21 -2
  27. package/src/lib/jobs/ai-job-page-language.js +217 -5
  28. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  29. package/src/lib/jobs/ai-job-page-step.d.ts +7 -0
  30. package/src/lib/jobs/ai-job-page-step.js +73 -12
  31. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  32. package/src/lib/jobs/ai-job-plan-step.js +4 -2
  33. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  34. package/src/lib/jobs/ai-job-site-look.js +14 -5
  35. package/src/lib/jobs/ai-job-site-look.js.map +1 -1
  36. package/src/lib/jobs/ai-job-text-step.d.ts +10 -2
  37. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  38. package/src/lib/jobs/ai-jobs.js +2 -1
  39. package/src/lib/jobs/ai-jobs.js.map +1 -1
  40. package/src/lib/jobs/ai-site-import-compile.d.ts +43 -2
  41. package/src/lib/jobs/ai-site-import-compile.js +105 -62
  42. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  43. package/src/lib/jobs/ai-site-import-document.d.ts +25 -1
  44. package/src/lib/jobs/ai-site-import-document.js +26 -7
  45. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  46. package/src/lib/jobs/ai-site-import-honesty.d.ts +65 -0
  47. package/src/lib/jobs/ai-site-import-honesty.js +271 -0
  48. package/src/lib/jobs/ai-site-import-honesty.js.map +1 -0
  49. package/src/lib/jobs/ai-site-import-improve.d.ts +233 -0
  50. package/src/lib/jobs/ai-site-import-improve.js +1151 -0
  51. package/src/lib/jobs/ai-site-import-improve.js.map +1 -0
  52. package/src/lib/jobs/ai-site-import-look.d.ts +4 -0
  53. package/src/lib/jobs/ai-site-import-look.js +16 -6
  54. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  55. package/src/lib/jobs/ai-site-import-pictures.d.ts +83 -0
  56. package/src/lib/jobs/ai-site-import-pictures.js +261 -0
  57. package/src/lib/jobs/ai-site-import-pictures.js.map +1 -0
  58. package/src/lib/jobs/ai-site-import-plan.d.ts +78 -0
  59. package/src/lib/jobs/ai-site-import-plan.js +627 -0
  60. package/src/lib/jobs/ai-site-import-plan.js.map +1 -0
  61. package/src/lib/jobs/ai-site-import-wording.js +2 -5
  62. package/src/lib/jobs/ai-site-import-wording.js.map +1 -1
  63. package/src/lib/layout-language/ai-layout-compiler.d.ts +6 -0
  64. package/src/lib/layout-language/ai-layout-compiler.js +10 -6
  65. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  66. package/src/lib/layout-language/ai-layout-design.d.ts +9 -0
  67. package/src/lib/layout-language/ai-layout-design.js +29 -3
  68. package/src/lib/layout-language/ai-layout-design.js.map +1 -1
  69. package/src/lib/layout-language/ai-layout-frame-source.d.ts +5 -0
  70. package/src/lib/layout-language/ai-layout-frame-source.js +4 -2
  71. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
  72. package/src/lib/layout-language/ai-layout-frame.d.ts +2 -0
  73. package/src/lib/layout-language/ai-layout-frame.js +20 -12
  74. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  75. package/src/lib/layout-language/ai-layout-language.d.ts +8 -0
  76. package/src/lib/layout-language/ai-layout-language.js +7 -3
  77. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  78. package/src/lib/model/ai-site-import-fidelity.d.ts +62 -0
  79. package/src/lib/model/ai-site-import-fidelity.js +374 -0
  80. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  81. package/src/lib/model/ai-site-import-ledger.d.ts +82 -0
  82. package/src/lib/model/ai-site-import-ledger.js +254 -0
  83. package/src/lib/model/ai-site-import-ledger.js.map +1 -0
  84. package/src/lib/model/ai-site-import-view.d.ts +110 -6
  85. package/src/lib/model/ai-site-import-view.js +166 -13
  86. package/src/lib/model/ai-site-import-view.js.map +1 -1
  87. package/src/lib/model/ai-site-import.d.ts +227 -2
  88. package/src/lib/model/ai-site-import.js +312 -15
  89. package/src/lib/model/ai-site-import.js.map +1 -1
  90. package/src/lib/model/ai-site-job.js +4 -0
  91. package/src/lib/model/ai-site-job.js.map +1 -1
  92. package/src/lib/model/ai-site-kinds.d.ts +2 -0
  93. package/src/lib/model/ai-site-kinds.js +7 -0
  94. package/src/lib/model/ai-site-kinds.js.map +1 -1
  95. package/src/lib/model/ai-site-look.d.ts +14 -5
  96. package/src/lib/model/ai-site-look.js +22 -16
  97. package/src/lib/model/ai-site-look.js.map +1 -1
  98. package/src/lib/model/ai-site-start.d.ts +37 -7
  99. package/src/lib/model/ai-site-start.js +54 -10
  100. package/src/lib/model/ai-site-start.js.map +1 -1
  101. package/src/lib/model/ai-site-starter-look.d.ts +69 -0
  102. package/src/lib/model/ai-site-starter-look.js +90 -0
  103. package/src/lib/model/ai-site-starter-look.js.map +1 -0
  104. package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -0
  105. package/src/lib/runtime/ai-doctrine-validators.js +3 -2
  106. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  107. package/src/lib/runtime/ai-doctrine.d.ts +10 -0
  108. package/src/lib/runtime/ai-doctrine.js +16 -2
  109. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  110. package/src/lib/server/ai-jobs-resume.js +12 -3
  111. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  112. package/src/lib/server/ai-jobs-route.js +5 -1
  113. package/src/lib/server/ai-jobs-route.js.map +1 -1
  114. package/src/lib/server/ai-site-import-route.d.ts +6 -0
  115. package/src/lib/server/ai-site-import-route.js +8 -1
  116. package/src/lib/server/ai-site-import-route.js.map +1 -1
  117. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +46 -7
  118. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +260 -14
  119. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  120. package/src/lib/site-import/fixtures/site-import-improve-answers.d.ts +33 -0
  121. package/src/lib/site-import/fixtures/site-import-improve-answers.js +457 -0
  122. package/src/lib/site-import/fixtures/site-import-improve-answers.js.map +1 -0
  123. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +29 -0
  124. package/src/lib/site-import/fixtures/site-layout-recordings.js +26 -0
  125. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  126. package/src/lib/site-import/site-import-flag.d.ts +17 -0
  127. package/src/lib/site-import/site-import-flag.js +15 -0
  128. package/src/lib/site-import/site-import-flag.js.map +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-pictures.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: A REDESIGNED PAGE'S PICTURES (AGL-4152).\n *\n * A redesign may ask for a picture where its own do not fit: a slot, which\n * `aiResolveLayoutPictures` fills or drops. This is the order it fills from,\n * first to last:\n *\n * 1. the page's own photos no `keep` placed;\n * 2. the source photos the site's earlier pages left off;\n * 3. what the site's own photo links hold, then the stock library\n * (`aiLayoutSitePhotoSource`): no credits, copied into the library, its\n * photographer kept, its brand-tag refusal held;\n * 4. only where the owner switched them on, and it is quoted, a generated\n * picture: a hero or a section's lead, never a person or a product, at most\n * `AI_SITE_IMPORT_GENERATED_PICTURES_PER_PAGE` a page.\n *\n * A slot nothing fills is dropped, and the row around it redraws without a gap\n * (`aiLayoutDropEmptyPictures`). The tally is what the page's row says.\n *=========================================*/\n\nimport type { PluginMediaIngest } from '@aglyn/aglyn/plugin-manager/plugin-media-ingest'\nimport { aiLayoutPictureBandCells, type AiLayoutPicturePhoto, type AiLayoutPictureSlot, type AiLayoutPictureSource } from '../layout-language/ai-layout-pictures'\nimport { AI_SITE_IMPORT_GENERATED_PICTURES_PER_PAGE, type AiSiteImportPagePictures, type AiSiteImportPhoto } from '../model/ai-site-import'\nimport { aiMediaCreditsPerPicture } from '../model/ai-media-credits'\nimport { estimateAiBilledUsd } from '../providers/catalog'\nimport { AiImageSafetyRefusal, type AiImageAspectRatio, type AiImageProvider } from '../providers/image-contract'\nimport { aiImageAltText, aiImageFileName } from '../server/ai-media-image'\nimport { aiMediaRasterPrompt } from '../server/ai-media-raster-prompt'\nimport { recordAssistCost } from '../usage/assist-usage'\nimport { aiAssignOwnerPhotos } from './ai-layout-owner-photos'\n\ntype NodesMap = Parameters<typeof aiLayoutPictureBandCells>[0]\n\n/** How long one generated picture is waited on: a picture is decoration, and a page never fails over one. */\nexport const AI_SITE_IMPORT_GENERATED_PICTURE_MS = 40_000\n\n/** What a slot's picture came from, as the page's row tells it. */\nexport interface AiSiteImportPictureTally {\n source: number\n stock: number\n generated: number\n /** What the generated pictures cost at the billed rates. */\n generatedUsd: number\n /** The addresses of the source's photos a slot took. */\n placed: string[]\n}\n\nexport function aiSiteImportPictureTally(): AiSiteImportPictureTally {\n return { source: 0, stock: 0, generated: 0, generatedUsd: 0, placed: [] }\n}\n\n/** A generated picture for a slot, stored and metered; `null` where it could not be made or kept. */\nexport type AiSiteImportPictureMaker = (slot: AiLayoutPictureSlot, tally: AiSiteImportPictureTally) => Promise<AiLayoutPicturePhoto | null>\n\n/** The words that say a picture shows a person: a generated one would show someone who does not exist as if they did. */\nconst SHOWS_PEOPLE = /\\b(?:team|staff|crew|owner|owners|founder|founders|person|people|portrait|headshot|family|families|customer|customers|client|clients|patient|patients|doctor|dentist|stylist|therapist|attorney|lawyer|accountant)\\b/i\n\n/**\n * Which slots may take a generated picture (AGL-4152): the page's hero, or the\n * first picture of a section that is no cell of a band, and none that shows a\n * person, a product or a record's own thing.\n */\nexport function aiSiteImportGeneratedSlots(nodes: NodesMap, slots: readonly AiLayoutPictureSlot[]): boolean[] {\n const cells = aiLayoutPictureBandCells(nodes, slots)\n const seen = new Set<number>()\n return slots.map((slot, index) => {\n const lead = !seen.has(slot.sectionIndex)\n seen.add(slot.sectionIndex)\n return lead && !cells[index] && !slot.product && !slot.people && !slot.record && !SHOWS_PEOPLE.test(slot.alt)\n })\n}\n\n/**\n * The source a redesigned page's slots fill from, in the order above. `next`\n * answers the slots the source's own photos leave and tallies its own stock\n * photos; a slot it leaves empty takes a generated picture where one is allowed.\n */\nexport function aiSiteImportPictureSource(input: {\n photos: readonly AiSiteImportPhoto[]\n next: AiLayoutPictureSource | null\n make?: AiSiteImportPictureMaker | null\n nodes: NodesMap\n tally: AiSiteImportPictureTally\n /** The most generated pictures this page may take. */\n cap?: number\n}): AiLayoutPictureSource | null {\n const { next, make, tally } = input\n // A photo the library holds no size for cannot be framed.\n const photos = input.photos.filter((photo) => photo.width && photo.height)\n if (!photos.length && !next && !make) return null\n const froms = new Map(photos.map((photo) => [photo.src, photo.from ?? '']))\n const cap = input.cap ?? AI_SITE_IMPORT_GENERATED_PICTURES_PER_PAGE\n return async (slots, report) => {\n const own = aiAssignOwnerPhotos(slots, photos)\n own.forEach((photo) => {\n if (!photo) return\n tally.source += 1\n const from = froms.get(photo.src)\n if (from) tally.placed.push(from)\n })\n const open = slots.filter((_slot, index) => !own[index])\n const found = next && open.length ? await next(open, report) : []\n let at = 0\n const answers = own.map((photo) => photo ?? found[at++] ?? null)\n if (!make) return answers\n const allowed = aiSiteImportGeneratedSlots(input.nodes, slots)\n let left = Math.max(0, cap)\n const out: Array<AiLayoutPicturePhoto | null> = [...answers]\n // One at a time, so the cap holds whatever each comes to: the hero first, the biggest seen first.\n const order = slots.map((slot, index) => ({ slot, index })).sort((a, b) => Number(b.slot.role === 'hero') - Number(a.slot.role === 'hero') || a.index - b.index)\n for (const { slot, index } of order) {\n if (left <= 0) break\n if (answers[index]?.src || !allowed[index]) continue\n const made = await make(slot, tally)\n if (made) {\n out[index] = made\n left -= 1\n }\n }\n return out\n }\n}\n\n/** The nearest shape the image models draw to a slot's frame. */\nexport function aiSiteImportPictureShape(aspect: number): AiImageAspectRatio {\n const shapes: ReadonlyArray<readonly [AiImageAspectRatio, number]> = [['16:9', 16 / 9], ['4:3', 4 / 3], ['1:1', 1], ['3:4', 3 / 4], ['9:16', 9 / 16]]\n const wanted = aspect > 0 && Number.isFinite(aspect) ? aspect : 4 / 3\n return [...shapes].sort((a, b) => Math.abs(a[1] - wanted) - Math.abs(b[1] - wanted))[0]?.[0] ?? '4:3'\n}\n\n/** What a generated picture is made through, and whether the workspace's meter has room for it. */\nexport interface AiSiteImportPictureMakerInput {\n provider: AiImageProvider | null\n ingest: PluginMediaIngest | null\n firestore: FirebaseFirestore.Firestore\n orgId: string\n hostId: string\n uid: string\n /** What the site is, which a picture's own words are read with. */\n about: string\n /** Whether the workspace's meter has room for a picture now. */\n roomFor?: (credits: number) => boolean\n record?: typeof recordAssistCost\n}\n\n/**\n * A generated picture through the Media door's own parts (AGL-4152): the image\n * provider at a paid plan's size, the fixed style wording, the media library's\n * ingest as an upload this member made, the same provenance on the asset, and the\n * same meter, charged only once it is stored. `null` where it cannot run here.\n */\nexport function aiSiteImportPictureMaker(input: AiSiteImportPictureMakerInput): AiSiteImportPictureMaker | null {\n const { provider, ingest } = input\n if (!provider?.configured() || !ingest) return null\n const size = '1K' as const\n return async (slot, tally) => {\n const model = provider.defaultModel()\n if (input.roomFor && !input.roomFor(aiMediaCreditsPerPicture('photo', model, size))) return null\n const words = `${slot.alt}. For a website about: ${input.about}`.replace(/\\s+/g, ' ').trim()\n const timeout = new Promise<null>((resolve) => setTimeout(() => resolve(null), AI_SITE_IMPORT_GENERATED_PICTURE_MS))\n try {\n const result = await Promise.race([\n provider.generate({ model, prompt: aiMediaRasterPrompt(words, 'natural'), aspectRatio: aiSiteImportPictureShape(slot.aspect), size, count: 1 }),\n timeout,\n ])\n const image = result?.images[0]\n if (!result || !image) return null\n const alt = aiImageAltText(slot.alt)\n const stored = await ingest.ingest({\n hostId: input.hostId,\n uid: input.uid,\n fileName: aiImageFileName(slot.alt, 0, image.mimeType),\n contentType: image.mimeType,\n bytes: Buffer.from(image.base64, 'base64'),\n alt,\n description: 'Created with AI from a description.',\n })\n if (!stored.ok) return null\n const usage = { ...result.usage, images: 1, imageSize: size }\n let signalId: string | null = null\n try {\n signalId = await (input.record ?? recordAssistCost)(input.firestore, input.orgId, {\n route: 'ai/jobs',\n hostId: input.hostId,\n model,\n tier: 'entitled',\n usage,\n docsPaths: [],\n stopReason: 'end_turn',\n free: null,\n uid: input.uid,\n kind: 'image',\n })\n } catch (error) {\n console.error('ai site import: a generated picture’s usage was not recorded', { orgId: input.orgId, error })\n }\n await input.firestore\n .collection('hosts')\n .doc(input.hostId)\n .collection('media')\n .doc(stored.mediaId)\n .update({ aiGenerated: { model, prompt: slot.alt, mode: 'photo', style: 'natural', aspectRatio: aiSiteImportPictureShape(slot.aspect), signalId, generatedBy: input.uid, createdAt: new Date() } })\n .catch((error: unknown) => console.error('ai site import: a generated picture’s record was not written', { mediaId: stored.mediaId, error }))\n tally.generated += 1\n tally.generatedUsd += estimateAiBilledUsd(usage, model)\n return { src: stored.src, width: stored.width ?? 1024, height: stored.height ?? 1024, alt }\n } catch (error) {\n if (!(error instanceof AiImageSafetyRefusal)) console.warn('ai site import: a generated picture failed; its slot is dropped', { error })\n return null\n }\n }\n}\n\n/** A page's pictures, as its row reads them once its slots are filled. */\nexport function aiSiteImportPagePicturesOf(pictures: AiSiteImportPagePictures, tally: AiSiteImportPictureTally): AiSiteImportPagePictures {\n const taken = new Set(tally.placed)\n return { source: pictures.source + tally.source, stock: tally.stock, generated: tally.generated, slots: 0, unplaced: pictures.unplaced.filter((url) => !taken.has(url)) }\n}\n"],"names":["aiLayoutPictureBandCells","AI_SITE_IMPORT_GENERATED_PICTURES_PER_PAGE","aiMediaCreditsPerPicture","estimateAiBilledUsd","AiImageSafetyRefusal","aiImageAltText","aiImageFileName","aiMediaRasterPrompt","recordAssistCost","aiAssignOwnerPhotos","AI_SITE_IMPORT_GENERATED_PICTURE_MS","aiSiteImportPictureTally","source","stock","generated","generatedUsd","placed","SHOWS_PEOPLE","aiSiteImportGeneratedSlots","nodes","slots","cells","seen","Set","map","slot","index","lead","has","sectionIndex","add","product","people","record","test","alt","aiSiteImportPictureSource","input","next","make","tally","photos","filter","photo","width","height","length","froms","Map","src","from","cap","report","own","forEach","get","push","open","_slot","found","at","answers","allowed","left","Math","max","out","order","sort","a","b","Number","role","made","aiSiteImportPictureShape","aspect","shapes","wanted","isFinite","abs","aiSiteImportPictureMaker","provider","ingest","configured","size","model","defaultModel","roomFor","words","about","replace","trim","timeout","Promise","resolve","setTimeout","stored","result","race","generate","prompt","aspectRatio","count","image","images","hostId","uid","fileName","mimeType","contentType","bytes","Buffer","base64","description","ok","usage","imageSize","signalId","firestore","orgId","route","tier","docsPaths","stopReason","free","kind","error","console","collection","doc","mediaId","update","aiGenerated","mode","style","generatedBy","createdAt","Date","catch","warn","aiSiteImportPagePicturesOf","pictures","taken","unplaced","url"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;2CAkB2C;AAG3C,SAASA,wBAAwB,QAAyF,2CAAuC;AACjK,SAASC,0CAA0C,QAA+D,6BAAyB;AAC3I,SAASC,wBAAwB,QAAQ,+BAA2B;AACpE,SAASC,mBAAmB,QAAQ,0BAAsB;AAC1D,SAASC,oBAAoB,QAAuD,iCAA6B;AACjH,SAASC,cAAc,EAAEC,eAAe,QAAQ,8BAA0B;AAC1E,SAASC,mBAAmB,QAAQ,sCAAkC;AACtE,SAASC,gBAAgB,QAAQ,2BAAuB;AACxD,SAASC,mBAAmB,QAAQ,8BAA0B;AAI9D,2GAA2G,GAC3G,OAAO,MAAMC,sCAAsC,MAAM;AAazD,OAAO,SAASC;IACd,OAAO;QAAEC,QAAQ;QAAGC,OAAO;QAAGC,WAAW;QAAGC,cAAc;QAAGC,QAAQ,EAAE;IAAC;AAC1E;AAKA,uHAAuH,GACvH,MAAMC,eAAe;AAErB;;;;CAIC,GACD,OAAO,SAASC,2BAA2BC,KAAe,EAAEC,KAAqC;IAC/F,MAAMC,QAAQrB,yBAAyBmB,OAAOC;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AMqE,GAAG;oBAAE8B,WAAW,IAAIC;gBAAO;YAAE,GAChMC,KAAK,CAAC,CAACZ,QAAmBC,QAAQD,KAAK,CAAC,gEAAgE;oBAAEI,SAASlC,OAAOkC,OAAO;oBAAEJ;gBAAM;YAC5ItF,MAAM1B,SAAS,IAAI;YACnB0B,MAAMzB,YAAY,IAAIZ,oBAAoBgH,OAAO9B;YACjD,OAAO;gBAAEpC,KAAK+C,OAAO/C,GAAG;gBAAEL,KAAK,GAAEoD,gBAAAA,OAAOpD,KAAK,YAAZoD,gBAAgB;gBAAMnD,MAAM,GAAEmD,iBAAAA,OAAOnD,MAAM,YAAbmD,iBAAiB;gBAAM7D;YAAI;QAC5F,EAAE,OAAO2F,OAAO;YACd,IAAI,CAAEA,CAAAA,iBAAiB1H,oBAAmB,GAAI2H,QAAQY,IAAI,CAAC,mEAAmE;gBAAEb;YAAM;YACtI,OAAO;QACT;IACF;AACF;AAEA,wEAAwE,GACxE,OAAO,SAASc,2BAA2BC,QAAkC,EAAErG,KAA+B;IAC5G,MAAMsG,QAAQ,IAAIvH,IAAIiB,MAAMxB,MAAM;IAClC,OAAO;QAAEJ,QAAQiI,SAASjI,MAAM,GAAG4B,MAAM5B,MAAM;QAAEC,OAAO2B,MAAM3B,KAAK;QAAEC,WAAW0B,MAAM1B,SAAS;QAAEM,OAAO;QAAG2H,UAAUF,SAASE,QAAQ,CAACrG,MAAM,CAAC,CAACsG,MAAQ,CAACF,MAAMlH,GAAG,CAACoH;IAAM;AAC1K"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type AiSiteImportPage, type AiSiteImportPlan, type AiSiteImportState } from '../model/ai-site-import';
18
+ import type { AiSystemBlock, AiTool } from '../providers/contract';
19
+ import type { AiGenerationCheck, AiValidatedGeneration } from '../runtime/ai-doctrine';
20
+ import type { AiDoctrineViolation } from '../runtime/ai-doctrine-validators';
21
+ /** The answer's kind of generation: the name its re-ask and its doctrine scope go by. */
22
+ export declare const AI_SITE_IMPORT_PLAN_KIND = "site-import-plan";
23
+ /** The heroes a plan may choose: those a page brought in can draw from one picture. */
24
+ export declare const AI_SITE_IMPORT_PLAN_HEROES: readonly ["cover", "poster", "split", "bleed", "editorial", "column", "panel"];
25
+ /** The most top-level entries a planned menu holds: more reads as no plan at all. */
26
+ export declare const AI_SITE_IMPORT_PLAN_MAX_GROUPS = 6;
27
+ /** The most characters a menu's label holds, a heading of the footer, or the main button's. */
28
+ export declare const AI_SITE_IMPORT_PLAN_LABEL_MAX_CHARS = 28;
29
+ /** The most characters a proposed page's title holds: its search listing's ceiling. */
30
+ export declare const AI_SITE_IMPORT_PLAN_TITLE_MAX_CHARS = 60;
31
+ /** The plan's tool: strict, every field always written. */
32
+ export declare const AI_SITE_IMPORT_PLAN_TOOL: AiTool;
33
+ /** What a plan is told, cached: every site shares these bytes. */
34
+ export declare const AI_SITE_IMPORT_PLAN_TEXT: string;
35
+ /** A plan's system blocks: the platform's text, cached across sites. The site's own words ride the user turn. */
36
+ export declare function aiSiteImportPlanInstructions(): readonly AiSystemBlock[];
37
+ /** The pages a plan may name: every page the import brings in and can link. */
38
+ export declare function aiSiteImportPlanPages(state: Pick<AiSiteImportState, 'pages'>): AiSiteImportPage[];
39
+ /** 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. */
40
+ export declare function aiSiteImportPlanPrompt(input: {
41
+ state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName' | 'domain'>;
42
+ required: readonly string[];
43
+ roomForPage: boolean;
44
+ }): string;
45
+ /** What a plan is held to. */
46
+ export interface AiSiteImportPlanScope {
47
+ state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName'>;
48
+ /** Every line the import read of the site: what its words may say. */
49
+ scope: readonly string[];
50
+ /** The pages the old menu reached, which must stay reachable. */
51
+ required: readonly string[];
52
+ roomForPage: boolean;
53
+ }
54
+ /** Every line of a site's first wave a plan's words are held to, with the page's own titles. */
55
+ export declare function aiSiteImportPlanScopeLines(state: Pick<AiSiteImportState, 'pages'>, siteLines: readonly string[]): string[];
56
+ /**
57
+ * A plan's answer read and held (AGL-4152): a plan to store, or what it broke,
58
+ * each named for the one re-ask. Its words are the honesty validator's: no name
59
+ * or fact the site does not give, in any label or line.
60
+ */
61
+ export declare function aiSiteImportPlanRead(raw: unknown, input: AiSiteImportPlanScope): {
62
+ plan: AiSiteImportPlan | null;
63
+ violations: AiDoctrineViolation[];
64
+ };
65
+ /** A plan's check, answer by answer, for the one re-ask. */
66
+ export declare function aiSiteImportPlanCheck(input: AiSiteImportPlanScope): AiGenerationCheck<AiSiteImportPlan>;
67
+ /** The most tokens a plan's answer asks, with its thinking. */
68
+ export declare const AI_SITE_IMPORT_PLAN_MOST_TOKENS = 4000;
69
+ /** The least time a plan's pass needs: its answer and its one re-ask on the page step's tier. */
70
+ export declare const AI_SITE_IMPORT_PLAN_BUDGET: import("./ai-job-budget").AiJobStepBudget;
71
+ /** The ceiling a plan is asked at on this model. */
72
+ export declare function aiSiteImportPlanMaxTokens(model: string): number;
73
+ /** The one plan a generative Improve it asks for, on the page step's tier. */
74
+ export declare function aiRunSiteImportPlan(input: AiSiteImportPlanScope & {
75
+ state: Pick<AiSiteImportState, 'pages' | 'home' | 'siteName' | 'domain'>;
76
+ model: string;
77
+ signal?: AbortSignal;
78
+ }): Promise<AiValidatedGeneration<AiSiteImportPlan>>;