@aglyn/plugins-ai 1.0.0-beta.229 → 1.0.0-beta.230

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 (248) hide show
  1. package/README.md +3 -3
  2. package/package.json +17 -17
  3. package/src/lib/activity/ai-activity-actions.js +7 -1
  4. package/src/lib/activity/ai-activity-actions.js.map +1 -1
  5. package/src/lib/components/ai-automation-zones.d.ts +38 -0
  6. package/src/lib/components/ai-automation-zones.js +5 -1
  7. package/src/lib/components/ai-automation-zones.js.map +1 -1
  8. package/src/lib/components/ai-brief-dialog.component.d.ts +20 -2
  9. package/src/lib/components/ai-brief-dialog.component.js +87 -8
  10. package/src/lib/components/ai-brief-dialog.component.js.map +1 -1
  11. package/src/lib/components/ai-campaign-create.component.d.ts +54 -0
  12. package/src/lib/components/ai-campaign-create.component.js +270 -0
  13. package/src/lib/components/ai-campaign-create.component.js.map +1 -0
  14. package/src/lib/components/ai-describe-automation.component.d.ts +8 -3
  15. package/src/lib/components/ai-describe-automation.component.js +15 -6
  16. package/src/lib/components/ai-describe-automation.component.js.map +1 -1
  17. package/src/lib/components/ai-describe-button.component.d.ts +20 -8
  18. package/src/lib/components/ai-describe-button.component.js +19 -36
  19. package/src/lib/components/ai-describe-button.component.js.map +1 -1
  20. package/src/lib/components/ai-describe-email.component.d.ts +31 -0
  21. package/src/lib/components/ai-describe-email.component.js +22 -0
  22. package/src/lib/components/ai-describe-email.component.js.map +1 -0
  23. package/src/lib/components/ai-describe-org-automation.component.d.ts +36 -0
  24. package/src/lib/components/ai-describe-org-automation.component.js +238 -0
  25. package/src/lib/components/ai-describe-org-automation.component.js.map +1 -0
  26. package/src/lib/components/ai-experiment-cards.component.d.ts +9 -1
  27. package/src/lib/components/ai-experiment-cards.component.js +104 -18
  28. package/src/lib/components/ai-experiment-cards.component.js.map +1 -1
  29. package/src/lib/components/ai-explain-automation.component.js +1 -5
  30. package/src/lib/components/ai-explain-automation.component.js.map +1 -1
  31. package/src/lib/components/ai-funnel-zones.component.d.ts +61 -0
  32. package/src/lib/components/ai-funnel-zones.component.js +178 -0
  33. package/src/lib/components/ai-funnel-zones.component.js.map +1 -0
  34. package/src/lib/components/ai-insight-card.component.d.ts +42 -0
  35. package/src/lib/components/ai-insight-card.component.js +137 -0
  36. package/src/lib/components/ai-insight-card.component.js.map +1 -0
  37. package/src/lib/components/ai-insight-dialog.component.d.ts +6 -0
  38. package/src/lib/components/ai-insight-dialog.component.js +9 -3
  39. package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
  40. package/src/lib/components/ai-job-plan.component.d.ts +7 -2
  41. package/src/lib/components/ai-job-plan.component.js +35 -5
  42. package/src/lib/components/ai-job-plan.component.js.map +1 -1
  43. package/src/lib/components/ai-job-requests.d.ts +17 -1
  44. package/src/lib/components/ai-job-requests.js +39 -3
  45. package/src/lib/components/ai-job-requests.js.map +1 -1
  46. package/src/lib/components/ai-logic-zones.d.ts +64 -0
  47. package/src/lib/components/ai-logic-zones.js +18 -0
  48. package/src/lib/components/ai-logic-zones.js.map +1 -0
  49. package/src/lib/components/ai-logic.component.d.ts +77 -0
  50. package/src/lib/components/ai-logic.component.js +553 -0
  51. package/src/lib/components/ai-logic.component.js.map +1 -0
  52. package/src/lib/components/ai-marketing-insight.component.d.ts +30 -0
  53. package/src/lib/components/ai-marketing-insight.component.js +80 -0
  54. package/src/lib/components/ai-marketing-insight.component.js.map +1 -0
  55. package/src/lib/components/ai-media-create.component.d.ts +55 -0
  56. package/src/lib/components/ai-media-create.component.js +433 -0
  57. package/src/lib/components/ai-media-create.component.js.map +1 -0
  58. package/src/lib/components/ai-overlay-cards.component.d.ts +83 -0
  59. package/src/lib/components/ai-overlay-cards.component.js +505 -0
  60. package/src/lib/components/ai-overlay-cards.component.js.map +1 -0
  61. package/src/lib/components/ai-product-zones.d.ts +5 -0
  62. package/src/lib/components/ai-product-zones.js +1 -1
  63. package/src/lib/components/ai-product-zones.js.map +1 -1
  64. package/src/lib/components/ai-products-create-button.component.d.ts +42 -0
  65. package/src/lib/components/ai-products-create-button.component.js +67 -0
  66. package/src/lib/components/ai-products-create-button.component.js.map +1 -0
  67. package/src/lib/components/ai-products-hub-card.component.js +100 -81
  68. package/src/lib/components/ai-products-hub-card.component.js.map +1 -1
  69. package/src/lib/components/ai-revise-automation.component.d.ts +16 -0
  70. package/src/lib/components/ai-revise-automation.component.js +207 -0
  71. package/src/lib/components/ai-revise-automation.component.js.map +1 -0
  72. package/src/lib/components/ai-site-build-page.component.js +140 -16
  73. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  74. package/src/lib/components/ai-upsell-dialog.component.d.ts +53 -0
  75. package/src/lib/components/ai-upsell-dialog.component.js +177 -0
  76. package/src/lib/components/ai-upsell-dialog.component.js.map +1 -0
  77. package/src/lib/components/assist-build-card.component.d.ts +42 -0
  78. package/src/lib/components/assist-build-card.component.js +183 -0
  79. package/src/lib/components/assist-build-card.component.js.map +1 -0
  80. package/src/lib/components/assist-edit-canvas.d.ts +2 -0
  81. package/src/lib/components/assist-edit-canvas.js +56 -1
  82. package/src/lib/components/assist-edit-canvas.js.map +1 -1
  83. package/src/lib/components/assist-jobs-drawer.component.js +48 -3
  84. package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
  85. package/src/lib/components/assist-panel.component.js +51 -2
  86. package/src/lib/components/assist-panel.component.js.map +1 -1
  87. package/src/lib/components/use-ai-job-run.d.ts +3 -14
  88. package/src/lib/components/use-ai-job-run.js +0 -50
  89. package/src/lib/components/use-ai-job-run.js.map +1 -1
  90. package/src/lib/jobs/ai-build-capabilities.d.ts +58 -0
  91. package/src/lib/jobs/ai-build-capabilities.js +256 -0
  92. package/src/lib/jobs/ai-build-capabilities.js.map +1 -0
  93. package/src/lib/jobs/ai-build-unit-outcome.d.ts +52 -0
  94. package/src/lib/jobs/ai-build-unit-outcome.js +138 -0
  95. package/src/lib/jobs/ai-build-unit-outcome.js.map +1 -0
  96. package/src/lib/jobs/ai-job-build-step.d.ts +144 -0
  97. package/src/lib/jobs/ai-job-build-step.js +657 -0
  98. package/src/lib/jobs/ai-job-build-step.js.map +1 -0
  99. package/src/lib/jobs/ai-job-draft-ids.js +9 -1
  100. package/src/lib/jobs/ai-job-draft-ids.js.map +1 -1
  101. package/src/lib/jobs/ai-job-drafts.d.ts +14 -4
  102. package/src/lib/jobs/ai-job-drafts.js +25 -4
  103. package/src/lib/jobs/ai-job-drafts.js.map +1 -1
  104. package/src/lib/jobs/ai-job-logic-step.d.ts +107 -0
  105. package/src/lib/jobs/ai-job-logic-step.js +395 -0
  106. package/src/lib/jobs/ai-job-logic-step.js.map +1 -0
  107. package/src/lib/jobs/ai-job-overlay-copy.d.ts +70 -0
  108. package/src/lib/jobs/ai-job-overlay-copy.js +178 -0
  109. package/src/lib/jobs/ai-job-overlay-copy.js.map +1 -0
  110. package/src/lib/jobs/ai-job-page-step.js +6 -6
  111. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  112. package/src/lib/jobs/ai-job-plan-step.d.ts +26 -1
  113. package/src/lib/jobs/ai-job-plan-step.js +79 -11
  114. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  115. package/src/lib/jobs/ai-job-site-step.d.ts +15 -1
  116. package/src/lib/jobs/ai-job-site-step.js +200 -58
  117. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  118. package/src/lib/jobs/ai-job-text-step.d.ts +22 -1
  119. package/src/lib/jobs/ai-job-text-step.js +12 -0
  120. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  121. package/src/lib/jobs/ai-job-workflow-step.d.ts +54 -4
  122. package/src/lib/jobs/ai-job-workflow-step.js +318 -13
  123. package/src/lib/jobs/ai-job-workflow-step.js.map +1 -1
  124. package/src/lib/jobs/ai-jobs.d.ts +80 -2
  125. package/src/lib/jobs/ai-jobs.js +377 -13
  126. package/src/lib/jobs/ai-jobs.js.map +1 -1
  127. package/src/lib/jobs/ai-logic-records.d.ts +40 -0
  128. package/src/lib/jobs/ai-logic-records.js +55 -0
  129. package/src/lib/jobs/ai-logic-records.js.map +1 -0
  130. package/src/lib/jobs/ai-site-publish.d.ts +7 -0
  131. package/src/lib/jobs/ai-site-publish.js +9 -0
  132. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  133. package/src/lib/jobs/ai-workflow-records.d.ts +4 -0
  134. package/src/lib/jobs/ai-workflow-records.js +40 -1
  135. package/src/lib/jobs/ai-workflow-records.js.map +1 -1
  136. package/src/lib/model/ai-automation-draft.d.ts +18 -0
  137. package/src/lib/model/ai-automation-draft.js +86 -0
  138. package/src/lib/model/ai-automation-draft.js.map +1 -1
  139. package/src/lib/model/ai-build-job.d.ts +201 -0
  140. package/src/lib/model/ai-build-job.js +471 -0
  141. package/src/lib/model/ai-build-job.js.map +1 -0
  142. package/src/lib/model/ai-build-plan.d.ts +61 -0
  143. package/src/lib/model/ai-build-plan.js +154 -9
  144. package/src/lib/model/ai-build-plan.js.map +1 -1
  145. package/src/lib/model/ai-build-progress.d.ts +56 -0
  146. package/src/lib/model/ai-build-progress.js +128 -0
  147. package/src/lib/model/ai-build-progress.js.map +1 -0
  148. package/src/lib/model/ai-insight.d.ts +20 -10
  149. package/src/lib/model/ai-insight.js +72 -9
  150. package/src/lib/model/ai-insight.js.map +1 -1
  151. package/src/lib/model/ai-job-activity.js +3 -1
  152. package/src/lib/model/ai-job-activity.js.map +1 -1
  153. package/src/lib/model/ai-jobs.types.d.ts +80 -2
  154. package/src/lib/model/ai-jobs.types.js +3 -1
  155. package/src/lib/model/ai-jobs.types.js.map +1 -1
  156. package/src/lib/model/ai-logic-job.d.ts +108 -0
  157. package/src/lib/model/ai-logic-job.js +327 -0
  158. package/src/lib/model/ai-logic-job.js.map +1 -0
  159. package/src/lib/model/ai-media-credits.d.ts +52 -0
  160. package/src/lib/model/ai-media-credits.js +61 -0
  161. package/src/lib/model/ai-media-credits.js.map +1 -0
  162. package/src/lib/model/ai-overlay-copy.d.ts +114 -0
  163. package/src/lib/model/ai-overlay-copy.js +175 -0
  164. package/src/lib/model/ai-overlay-copy.js.map +1 -0
  165. package/src/lib/model/ai-site-build-progress.d.ts +20 -3
  166. package/src/lib/model/ai-site-build-progress.js +170 -10
  167. package/src/lib/model/ai-site-build-progress.js.map +1 -1
  168. package/src/lib/model/ai-svg.d.ts +69 -0
  169. package/src/lib/model/ai-svg.js +265 -0
  170. package/src/lib/model/ai-svg.js.map +1 -0
  171. package/src/lib/model/ai-usage-by-user.d.ts +3 -2
  172. package/src/lib/model/ai-usage-by-user.js.map +1 -1
  173. package/src/lib/model/ai-workflow-job.d.ts +92 -4
  174. package/src/lib/model/ai-workflow-job.js +124 -7
  175. package/src/lib/model/ai-workflow-job.js.map +1 -1
  176. package/src/lib/model/assist-build.d.ts +58 -0
  177. package/src/lib/model/assist-build.js +52 -0
  178. package/src/lib/model/assist-build.js.map +1 -0
  179. package/src/lib/model/assist-edit.d.ts +48 -3
  180. package/src/lib/model/assist-edit.js +48 -4
  181. package/src/lib/model/assist-edit.js.map +1 -1
  182. package/src/lib/plugin-config.js +2 -0
  183. package/src/lib/plugin-config.js.map +1 -1
  184. package/src/lib/plugin.js +240 -11
  185. package/src/lib/plugin.js.map +1 -1
  186. package/src/lib/providers/catalog.d.ts +81 -4
  187. package/src/lib/providers/catalog.js +80 -9
  188. package/src/lib/providers/catalog.js.map +1 -1
  189. package/src/lib/providers/image-contract.d.ts +116 -0
  190. package/src/lib/providers/image-contract.js +74 -0
  191. package/src/lib/providers/image-contract.js.map +1 -0
  192. package/src/lib/providers/model-choice.js +11 -0
  193. package/src/lib/providers/model-choice.js.map +1 -1
  194. package/src/lib/providers/routing.js +18 -0
  195. package/src/lib/providers/routing.js.map +1 -1
  196. package/src/lib/providers/vertex-image.d.ts +121 -0
  197. package/src/lib/providers/vertex-image.js +312 -0
  198. package/src/lib/providers/vertex-image.js.map +1 -0
  199. package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
  200. package/src/lib/runtime/ai-doctrine-validators.js +89 -0
  201. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  202. package/src/lib/runtime/ai-doctrine.js +11 -5
  203. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  204. package/src/lib/runtime/ai-eval-live.js +4 -0
  205. package/src/lib/runtime/ai-eval-live.js.map +1 -1
  206. package/src/lib/runtime/ai-eval.d.ts +15 -1
  207. package/src/lib/runtime/ai-eval.js +52 -1
  208. package/src/lib/runtime/ai-eval.js.map +1 -1
  209. package/src/lib/runtime/experiment-variant-copy.d.ts +34 -0
  210. package/src/lib/runtime/experiment-variant-copy.js +102 -0
  211. package/src/lib/runtime/experiment-variant-copy.js.map +1 -0
  212. package/src/lib/server/ai-experiment-versions.d.ts +51 -0
  213. package/src/lib/server/ai-experiment-versions.js +270 -0
  214. package/src/lib/server/ai-experiment-versions.js.map +1 -0
  215. package/src/lib/server/ai-jobs-resume.js +74 -4
  216. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  217. package/src/lib/server/ai-media-image.d.ts +66 -0
  218. package/src/lib/server/ai-media-image.js +521 -0
  219. package/src/lib/server/ai-media-image.js.map +1 -0
  220. package/src/lib/server/ai-media-svg.d.ts +91 -0
  221. package/src/lib/server/ai-media-svg.js +186 -0
  222. package/src/lib/server/ai-media-svg.js.map +1 -0
  223. package/src/lib/server/assist-build.d.ts +54 -0
  224. package/src/lib/server/assist-build.js +121 -0
  225. package/src/lib/server/assist-build.js.map +1 -0
  226. package/src/lib/server/assist-chat.js +108 -12
  227. package/src/lib/server/assist-chat.js.map +1 -1
  228. package/src/lib/server/assist-edit.js +213 -3
  229. package/src/lib/server/assist-edit.js.map +1 -1
  230. package/src/lib/server/assist-view-context.js +242 -4
  231. package/src/lib/server/assist-view-context.js.map +1 -1
  232. package/src/lib/server.js +26 -0
  233. package/src/lib/server.js.map +1 -1
  234. package/src/lib/tools/ai-logic-tool.d.ts +27 -0
  235. package/src/lib/tools/ai-logic-tool.js +207 -0
  236. package/src/lib/tools/ai-logic-tool.js.map +1 -0
  237. package/src/lib/tools/ai-overlay-tool.d.ts +35 -0
  238. package/src/lib/tools/ai-overlay-tool.js +107 -0
  239. package/src/lib/tools/ai-overlay-tool.js.map +1 -0
  240. package/src/lib/tools/ai-workflow-tool.d.ts +11 -0
  241. package/src/lib/tools/ai-workflow-tool.js +31 -0
  242. package/src/lib/tools/ai-workflow-tool.js.map +1 -1
  243. package/src/lib/usage/assist-job-refund.d.ts +28 -1
  244. package/src/lib/usage/assist-job-refund.js +44 -9
  245. package/src/lib/usage/assist-job-refund.js.map +1 -1
  246. package/src/lib/usage/assist-usage.d.ts +5 -0
  247. package/src/lib/usage/assist-usage.js +2 -0
  248. package/src/lib/usage/assist-usage.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-build-page.component.tsx"],"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'use client'\n\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn'\nimport { PageHeaderRecord } from '@aglyn/aglyn/app-utils/page-header-record-context'\nimport type { ConsolePluginPageProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport {\n mdiAlertCircle,\n mdiCheckCircle,\n mdiChevronDown,\n mdiClockOutline,\n} from '@aglyn/shared-data-mdi'\nimport { AppLink, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport type { MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Alert,\n Box,\n Button,\n Card,\n CircularProgress,\n Container,\n LinearProgress,\n Stack,\n Typography,\n} from '@mui/material'\nimport { type ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n aiJobPageCopy,\n aiSiteBuildCreditsLine,\n aiSiteBuildPhase,\n aiSiteBuildRows,\n type AiSiteBuildRowState,\n} from '../model/ai-site-build-progress'\nimport { aiJobRefundCopy, aiSiteStarterFallbackOffered } from '../model/ai-job-failure-copy'\nimport { aiSiteStartAnswersFromInputs } from '../model/ai-site-start'\nimport { AiSiteStartCard } from './ai-site-start-card.component'\nimport { AI_JOB_TERMINAL_STATUSES, type AiJobSummary } from '../model/ai-jobs.types'\nimport { followAiJobEvents } from './ai-job-events'\nimport { aiSiteBuildDoneLinks } from './ai-job-links'\nimport { resumeAiJobRequest } from './ai-job-requests'\nimport { useAiJobSite } from './ai-job-site'\nimport { AiSiteStarterFallback } from './ai-site-starter-fallback.component'\n\n/**\n * \"Building your site\" (AGL-3594): one job's page, at `/ai-jobs/{jobId}`\n * under its site — where the guided start sends a person the moment they\n * plan a site, and where a notification about that job opens.\n *\n * A guided site start confirms its own plan (`autoConfirm`), so there is no\n * approval to make here: the page says what is happening, step by step, live\n * from the job's events route; shows what is being built; and, when the job\n * ends, leads with the next thing to do — the live site and the pages to\n * edit, or, where it stopped, the plain sentence for why and what to do\n * about it. It is linkable and survives a reload, because it reads the job by\n * the id in its own address under the site's own route.\n *\n * Every wait ends (AGL-3596): a site that cannot be read, a job the route\n * does not know, a route that fails, and a first state that never arrives\n * each end on a sentence instead of a spinner.\n *\n * Mounted by `AiJobsPage`, the plugin's unlisted `/ai-jobs` route: no tab on\n * the site's strip, an address under it.\n */\n\n/** How long the job's first state may take before the page says it could not be loaded. */\nexport const AI_JOB_FIRST_STATE_TIMEOUT_MS = 20_000\n\n/**\n * One job, followed by id: its latest summary; `null` while the first state\n * is out; `'missing'` when the route says there is no such job for this\n * reader; `'error'` when the route failed or no state arrived in time.\n */\nexport type AiJobByIdState = AiJobSummary | 'missing' | 'error' | null\n\n/** Follows one job by id. `retry` follows it again after a `'missing'` or `'error'`. */\nexport function useAiJobById(\n user: MaybeTokenSource,\n orgId: string | null,\n jobId: string | null,\n): [AiJobByIdState, (job: AiJobSummary) => void, () => void] {\n const userRef = useRef(user)\n userRef.current = user\n const [job, setJob] = useState<AiJobByIdState>(null)\n const [attempt, setAttempt] = useState(0)\n const status = job && typeof job === 'object' ? job.status : null\n // Followed until the job ENDS (AGL-3596), not until it first stops: a guided\n // start parks on its plan for the instant it takes to confirm it, and a page\n // that stopped following there showed that park — the plan's 13 credits and\n // \"the plan is ready\" — after the job had built, spent and failed.\n const moving = status === null || !AI_JOB_TERMINAL_STATUSES.includes(status)\n useEffect(() => {\n if (!orgId || !jobId || !moving) return undefined\n const controller = new AbortController()\n let heard = false\n const timer = setTimeout(() => {\n if (!heard) setJob((current) => current ?? 'error')\n }, AI_JOB_FIRST_STATE_TIMEOUT_MS)\n void followAiJobEvents(() => userRef.current, orgId, jobId, controller.signal, (next) => {\n heard = true\n setJob(next)\n }).then((end) => {\n if (heard || controller.signal.aborted) return\n const unheard: AiJobByIdState = end === 'not-found' ? 'missing' : 'error'\n setJob((current) => (current && typeof current === 'object' ? current : unheard))\n })\n return () => {\n clearTimeout(timer)\n controller.abort()\n }\n }, [orgId, jobId, moving, attempt])\n const retry = useCallback(() => {\n setJob(null)\n setAttempt((count) => count + 1)\n }, [])\n return [job, setJob, retry]\n}\n\nconst ROW_ICON: Readonly<Record<Exclude<AiSiteBuildRowState, 'active'>, { path: string; color: string; label: string }>> = {\n done: { path: mdiCheckCircle.path, color: 'success.main', label: 'Done' },\n waiting: { path: mdiClockOutline.path, color: 'text.disabled', label: 'Waiting' },\n failed: { path: mdiAlertCircle.path, color: 'error.main', label: 'Stopped' },\n}\n\nfunction RowIcon({ state }: { state: AiSiteBuildRowState }) {\n if (state === 'active') {\n return <CircularProgress size={20} aria-label=\"In progress\" />\n }\n const icon = ROW_ICON[state]\n return (\n <Box component=\"span\" role=\"img\" aria-label={icon.label} sx={{ color: icon.color, display: 'inline-flex', fontSize: (theme) => theme.spacing(2.5) }}>\n <MdiIcon path={icon.path} aria-hidden />\n </Box>\n )\n}\n\n/** The page's frame: the site's name over the heading and its sentence. */\nfunction Frame({\n siteName,\n heading,\n lede,\n children,\n}: {\n siteName?: string\n heading: string\n lede?: string\n children?: ReactNode\n}) {\n return (\n <Container maxWidth=\"sm\" sx={{ py: { xs: 3, sm: 5 }, px: { xs: 2, sm: 3 } }}>\n <Stack spacing={4}>\n <Stack spacing={1}>\n {siteName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {siteName}\n </Typography>\n ) : null}\n <Typography variant=\"h4\" component=\"h1\">\n {heading}\n </Typography>\n {lede ? (\n <Typography variant=\"body1\" color=\"text.secondary\">\n {lede}\n </Typography>\n ) : null}\n </Stack>\n {children}\n </Stack>\n </Container>\n )\n}\n\nexport function AiSiteBuildPage({ hostId, segments, basePath }: ConsolePluginPageProps) {\n const { data: user } = useUser()\n const jobId = segments?.[0] ? decodeURIComponent(String(segments[0])) : null\n const orgSlug = (basePath ?? '').split('/')[1] ?? ''\n // `/{orgSlug}/hosts/{subdomain}/ai-jobs`: the site's subdomain, which a console URL names it by.\n const hostSubdomain = (basePath ?? '').split('/')[3] || null\n const site = useAiJobSite(hostId)\n const orgId = site.status === 'ready' ? site.orgId : null\n const siteName = site.status === 'ready' ? site.name : undefined\n\n const [job, setJob, retry] = useAiJobById(user, orgId, jobId)\n const [busy, setBusy] = useState(false)\n const [notice, setNotice] = useState<string | null>(null)\n // A failed guided start's Try again reopens its questions, filled in (AGL-3596);\n // `?retry=1` — what the AI jobs drawer links — opens them on arrival.\n const [retrying, setRetrying] = useState(\n () => typeof window !== 'undefined' && new URLSearchParams(window.location.search).get('retry') === '1',\n )\n const tryAgain = useCallback(async () => {\n if (!orgId || !job || typeof job !== 'object') return\n setBusy(true)\n setNotice(null)\n const decision = await resumeAiJobRequest(user, orgId, job)\n if (decision.job) setJob(decision.job)\n if (decision.error) setNotice(decision.error)\n setBusy(false)\n }, [orgId, job, user, setJob])\n\n const ready = job && typeof job === 'object' ? job : null\n const copy = ready ? aiJobPageCopy(ready, PLATFORM_BRAND_NAME) : null\n // The shell's header names the job's page as the page does, and its trail\n // walks back to the site's AI jobs.\n const record = <PageHeaderRecord title={copy?.heading} />\n\n if (site.status === 'error') {\n return (\n <Frame heading=\"This site could not be read\">\n <Alert severity=\"warning\">\n {'The site this job belongs to could not be loaded. Check your connection and reload the page.'}\n </Alert>\n </Frame>\n )\n }\n if (job === 'missing') {\n return (\n <Frame siteName={siteName} heading=\"This job could not be found\">\n <Alert severity=\"info\">{'It may belong to another workspace, or it may have expired.'}</Alert>\n {basePath ? (\n <Box>\n <Button variant=\"outlined\" component={AppLink} href={basePath}>\n {'See this site’s AI jobs'}\n </Button>\n </Box>\n ) : null}\n </Frame>\n )\n }\n if (job === 'error') {\n return (\n <Frame siteName={siteName} heading=\"This job could not be loaded\">\n <Alert\n severity=\"warning\"\n action={\n <Button color=\"inherit\" size=\"small\" onClick={retry}>\n {'Try again'}\n </Button>\n }\n >\n {'Something went wrong reading it. It may still be running: try again in a moment.'}\n </Alert>\n </Frame>\n )\n }\n if (!ready || !copy) {\n return (\n <Frame siteName={siteName} heading=\"Building your site\">\n <Stack sx={{ alignItems: 'center', py: 4 }}>\n <CircularProgress aria-label=\"Loading the job\" />\n </Stack>\n </Frame>\n )\n }\n\n const phase = aiSiteBuildPhase(ready)\n const rows = aiSiteBuildRows(ready)\n const credits = aiSiteBuildCreditsLine(ready)\n const links = phase === 'done' ? aiSiteBuildDoneLinks(ready, orgSlug) : { view: null, pages: null }\n const sitePublish = ready.kind === 'site' && phase === 'done' ? (ready.sitePublish ?? null) : null\n const liveUrl = sitePublish && sitePublish.published.length > 0 ? sitePublish.liveUrl : null\n const retryRefusal = ready.review?.retryRefusal\n const canRetry = phase === 'stopped' && ready.review?.reason === 'doctrine'\n // A guided start that ended without building its site starts over from its\n // own answers, as a fresh job: the questions reopen filled in.\n const restartAnswers =\n ready.kind === 'site' && (phase === 'failed' || phase === 'canceled')\n ? aiSiteStartAnswersFromInputs(ready.siteInputs)\n : null\n const refund = phase === 'failed' || phase === 'stopped' || phase === 'canceled' ? aiJobRefundCopy(ready) : null\n\n return (\n <Frame siteName={siteName} heading={copy.heading} lede={copy.lede}>\n {record}\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n {phase === 'working' && <LinearProgress aria-label=\"Building\" />}\n <Box component=\"ol\" aria-label=\"Progress\" sx={{ listStyle: 'none', m: 0, p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n {rows.map((row) => (\n <Stack component=\"li\" key={row.id} direction=\"row\" spacing={2} sx={{ alignItems: 'center' }}>\n <Box sx={{ width: (theme) => theme.spacing(3), display: 'flex', justifyContent: 'center' }}>\n <RowIcon state={row.state} />\n </Box>\n <Typography\n variant=\"body1\"\n color={row.state === 'waiting' ? 'text.secondary' : 'text.primary'}\n >\n {row.label}\n </Typography>\n </Stack>\n ))}\n </Stack>\n </Box>\n </Card>\n {refund && (ready.refundedCredits ?? 0) > 0 ? (\n <Alert severity=\"info\">{refund}</Alert>\n ) : credits ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {credits}\n </Typography>\n ) : null}\n {retrying && restartAnswers && hostId ? (\n <AiSiteStartCard\n hostId={hostId}\n orgId={orgId ?? undefined}\n orgSlug={orgSlug}\n host={hostSubdomain}\n initialAnswers={restartAnswers}\n startBlank={() => setRetrying(false)}\n leave={() => setRetrying(false)}\n />\n ) : null}\n {sitePublish && sitePublish.drafts.length > 0 && (\n // The pages the publish left as drafts, each with its plain reason;\n // Edit your pages is where they are fixed and published.\n <Alert severity=\"warning\">\n <Typography variant=\"body2\" sx={{ mb: 1 }}>\n {sitePublish.drafts.length === 1 ? 'This page stayed a draft:' : 'These pages stayed drafts:'}\n </Typography>\n <Box component=\"ul\" sx={{ m: 0, pl: 2.5 }}>\n {sitePublish.drafts.map((draft) => (\n <li key={draft.id}>\n <Typography variant=\"body2\">{`${draft.label}: ${draft.reason}`}</Typography>\n </li>\n ))}\n </Box>\n <Typography variant=\"body2\" sx={{ mt: 1 }}>\n {'Open Edit your pages to fix and publish them.'}\n </Typography>\n </Alert>\n )}\n {phase === 'done' && (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n {liveUrl ? (\n // The live site, in a tab of its own: the console stays where it is.\n <Button\n variant=\"contained\"\n size=\"large\"\n component=\"a\"\n href={liveUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {'View your site'}\n </Button>\n ) : links.view ? (\n <Button variant=\"contained\" size=\"large\" component={AppLink} href={links.view}>\n {'View your site'}\n </Button>\n ) : null}\n {links.pages && (\n <Button variant=\"outlined\" size=\"large\" component={AppLink} href={links.pages}>\n {'Edit your pages'}\n </Button>\n )}\n </Stack>\n )}\n {(phase === 'stopped' || phase === 'failed' || phase === 'canceled') && (\n <Stack spacing={1}>\n {retryRefusal && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {retryRefusal}\n </Typography>\n )}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'center' } }}>\n {restartAnswers && hostId && (\n <Button variant=\"contained\" onClick={() => setRetrying(true)}>\n {'Try again'}\n </Button>\n )}\n {canRetry && (\n <Button\n variant=\"contained\"\n disabled={busy || Boolean(retryRefusal)}\n onClick={() => void tryAgain()}\n >\n {'Try again'}\n </Button>\n )}\n {aiSiteStarterFallbackOffered(ready) && user ? <AiSiteStarterFallback job={ready} user={user} /> : null}\n </Stack>\n </Stack>\n )}\n {ready.plan && ready.plan.screens.length > 0 && (\n <Accordion variant=\"outlined\" disableGutters sx={{ borderRadius: 2, '&::before': { display: 'none' } }}>\n <AccordionSummary expandIcon={<MdiIcon path={mdiChevronDown.path} />}>\n <Typography variant=\"subtitle1\">{'What we’re building'}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Stack component=\"ul\" spacing={1.5} sx={{ m: 0, pl: 2.5 }}>\n {ready.plan.screens.map((screen, index) => (\n <Box component=\"li\" key={`${screen.slug}-${index}`}>\n <Typography variant=\"body1\">{`${screen.title} — ${screen.slug}`}</Typography>\n {screen.sections.length > 0 && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {screen.sections.map((section) => section.name).join(', ')}\n </Typography>\n )}\n </Box>\n ))}\n </Stack>\n </AccordionDetails>\n </Accordion>\n )}\n </Frame>\n )\n}\n\nexport default AiSiteBuildPage\n"],"names":["PLATFORM_BRAND_NAME","PageHeaderRecord","mdiAlertCircle","mdiCheckCircle","mdiChevronDown","mdiClockOutline","AppLink","MdiIcon","useUser","Accordion","AccordionDetails","AccordionSummary","Alert","Box","Button","Card","CircularProgress","Container","LinearProgress","Stack","Typography","useCallback","useEffect","useRef","useState","aiJobPageCopy","aiSiteBuildCreditsLine","aiSiteBuildPhase","aiSiteBuildRows","aiJobRefundCopy","aiSiteStarterFallbackOffered","aiSiteStartAnswersFromInputs","AiSiteStartCard","AI_JOB_TERMINAL_STATUSES","followAiJobEvents","aiSiteBuildDoneLinks","resumeAiJobRequest","useAiJobSite","AiSiteStarterFallback","AI_JOB_FIRST_STATE_TIMEOUT_MS","useAiJobById","user","orgId","jobId","userRef","current","job","setJob","attempt","setAttempt","status","moving","includes","undefined","controller","AbortController","heard","timer","setTimeout","signal","next","then","end","aborted","unheard","clearTimeout","abort","retry","count","ROW_ICON","done","path","color","label","waiting","failed","RowIcon","state","size","aria-label","icon","component","role","sx","display","fontSize","theme","spacing","aria-hidden","Frame","siteName","heading","lede","children","maxWidth","py","xs","sm","px","variant","AiSiteBuildPage","hostId","segments","basePath","ready","data","decodeURIComponent","String","orgSlug","split","hostSubdomain","site","name","busy","setBusy","notice","setNotice","retrying","setRetrying","window","URLSearchParams","location","search","get","tryAgain","decision","error","copy","record","title","severity","href","action","onClick","alignItems","phase","rows","credits","links","view","pages","sitePublish","kind","liveUrl","published","length","retryRefusal","review","canRetry","reason","restartAnswers","siteInputs","refund","borderRadius","listStyle","m","p","map","row","direction","width","justifyContent","id","refundedCredits","host","initialAnswers","startBlank","leave","drafts","mb","pl","draft","li","mt","target","rel","disabled","Boolean","plan","screens","disableGutters","expandIcon","screen","index","slug","sections","section","join"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,SAASA,mBAAmB,QAAQ,eAAc;AAClD,SAASC,gBAAgB,QAAQ,oDAAmD;AAEpF,SACEC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,eAAe,QACV,yBAAwB;AAC/B,SAASC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AAEvD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,SAAS,EACTC,cAAc,EACdC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAAyBC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChF,SACEC,aAAa,EACbC,sBAAsB,EACtBC,gBAAgB,EAChBC,eAAe,QAEV,qCAAiC;AACxC,SAASC,eAAe,EAAEC,4BAA4B,QAAQ,kCAA8B;AAC5F,SAASC,4BAA4B,QAAQ,4BAAwB;AACrE,SAASC,eAAe,QAAQ,oCAAgC;AAChE,SAASC,wBAAwB,QAA2B,4BAAwB;AACpF,SAASC,iBAAiB,QAAQ,qBAAiB;AACnD,SAASC,oBAAoB,QAAQ,oBAAgB;AACrD,SAASC,kBAAkB,QAAQ,uBAAmB;AACtD,SAASC,YAAY,QAAQ,mBAAe;AAC5C,SAASC,qBAAqB,QAAQ,0CAAsC;AAE5E;;;;;;;;;;;;;;;;;;;CAmBC,GAED,yFAAyF,GACzF,OAAO,MAAMC,gCAAgC,MAAM;AASnD,sFAAsF,GACtF,OAAO,SAASC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G,aAAa;wBAAErE,SAAS;oBAAO;gBAAE;;kCACnG,KAACzE;wBAAiB0K,0BAAY,KAAC9K;4BAAQgE,MAAMnE,eAAemE,IAAI;;kCAC9D,cAAA,KAACnD;4BAAW+E,SAAQ;sCAAa;;;kCAEnC,KAACzF;kCACC,cAAA,KAACS;4BAAM8D,WAAU;4BAAKM,SAAS;4BAAKJ,IAAI;gCAAEwE,GAAG;gCAAGe,IAAI;4BAAI;sCACrDlE,MAAM0E,IAAI,CAACC,OAAO,CAACtB,GAAG,CAAC,CAACyB,QAAQC,sBAC/B,MAAC1K;oCAAIoE,WAAU;;sDACb,KAAC7D;4CAAW+E,SAAQ;sDAAS,GAAGmF,OAAOrD,KAAK,CAAC,GAAG,EAAEqD,OAAOE,IAAI,EAAE;;wCAC9DF,OAAOG,QAAQ,CAACxC,MAAM,GAAG,mBACxB,KAAC7H;4CAAW+E,SAAQ;4CAAQ3B,OAAM;sDAC/B8G,OAAOG,QAAQ,CAAC5B,GAAG,CAAC,CAAC6B,UAAYA,QAAQ1E,IAAI,EAAE2E,IAAI,CAAC;;;mCAJlC,GAAGL,OAAOE,IAAI,CAAC,CAAC,EAAED,OAAO;;;;;;;AAelE;AAEA,eAAenF,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-build-page.component.tsx"],"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'use client'\n\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn'\nimport { PageHeaderRecord } from '@aglyn/aglyn/app-utils/page-header-record-context'\nimport type { ConsolePluginPageProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport {\n mdiAlertCircle,\n mdiCheckCircle,\n mdiChevronDown,\n mdiClockOutline,\n mdiMinusCircleOutline,\n} from '@aglyn/shared-data-mdi'\nimport { AppLink, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport type { MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Alert,\n Box,\n Button,\n Card,\n CircularProgress,\n Container,\n LinearProgress,\n Stack,\n Typography,\n} from '@mui/material'\nimport { type ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n aiJobPageCopy,\n aiSiteBuildCreditsLine,\n aiSiteBuildFraction,\n aiSiteBuildPhase,\n aiSiteBuildRows,\n type AiSiteBuildRowState,\n} from '../model/ai-site-build-progress'\nimport { aiJobRefundCopy, aiSiteStarterFallbackOffered } from '../model/ai-job-failure-copy'\nimport { aiSiteStartAnswersFromInputs } from '../model/ai-site-start'\nimport { AiSiteStartCard } from './ai-site-start-card.component'\nimport { AI_JOB_TERMINAL_STATUSES, type AiJobSummary } from '../model/ai-jobs.types'\nimport { followAiJobEvents } from './ai-job-events'\nimport { aiSiteBuildDoneLinks } from './ai-job-links'\nimport { AiJobPlan } from './ai-job-plan.component'\nimport { aiBuildCanRetry } from '../model/ai-build-progress'\nimport { resumeAiJobRequest } from './ai-job-requests'\nimport { useAiJobSite } from './ai-job-site'\nimport { AiSiteStarterFallback } from './ai-site-starter-fallback.component'\n\n/**\n * \"Building your site\" (AGL-3594): one job's page, at `/ai-jobs/{jobId}`\n * under its site — where the guided start sends a person the moment they\n * plan a site, and where a notification about that job opens.\n *\n * A guided site start confirms its own plan (`autoConfirm`), so there is no\n * approval to make here: the page says what is happening, step by step, live\n * from the job's events route; shows what is being built; and, when the job\n * ends, leads with the next thing to do — the live site and the pages to\n * edit, or, where it stopped, the plain sentence for why and what to do\n * about it. It is linkable and survives a reload, because it reads the job by\n * the id in its own address under the site's own route.\n *\n * Every wait ends (AGL-3596): a site that cannot be read, a job the route\n * does not know, a route that fails, and a first state that never arrives\n * each end on a sentence instead of a spinner.\n *\n * Mounted by `AiJobsPage`, the plugin's unlisted `/ai-jobs` route: no tab on\n * the site's strip, an address under it.\n */\n\n/** How long the job's first state may take before the page says it could not be loaded. */\nexport const AI_JOB_FIRST_STATE_TIMEOUT_MS = 20_000\n\n/**\n * One job, followed by id: its latest summary; `null` while the first state\n * is out; `'missing'` when the route says there is no such job for this\n * reader; `'error'` when the route failed or no state arrived in time.\n */\nexport type AiJobByIdState = AiJobSummary | 'missing' | 'error' | null\n\n/** Follows one job by id. `retry` follows it again after a `'missing'` or `'error'`. */\nexport function useAiJobById(\n user: MaybeTokenSource,\n orgId: string | null,\n jobId: string | null,\n): [AiJobByIdState, (job: AiJobSummary) => void, () => void] {\n const userRef = useRef(user)\n userRef.current = user\n const [job, setJob] = useState<AiJobByIdState>(null)\n const [attempt, setAttempt] = useState(0)\n const status = job && typeof job === 'object' ? job.status : null\n // Followed until the job ENDS (AGL-3596), not until it first stops: a guided\n // start parks on its plan for the instant it takes to confirm it, and a page\n // that stopped following there showed that park — the plan's 13 credits and\n // \"the plan is ready\" — after the job had built, spent and failed.\n const moving = status === null || !AI_JOB_TERMINAL_STATUSES.includes(status)\n useEffect(() => {\n if (!orgId || !jobId || !moving) return undefined\n const controller = new AbortController()\n let heard = false\n const timer = setTimeout(() => {\n if (!heard) setJob((current) => current ?? 'error')\n }, AI_JOB_FIRST_STATE_TIMEOUT_MS)\n void followAiJobEvents(() => userRef.current, orgId, jobId, controller.signal, (next) => {\n heard = true\n setJob(next)\n }).then((end) => {\n if (heard || controller.signal.aborted) return\n const unheard: AiJobByIdState = end === 'not-found' ? 'missing' : 'error'\n setJob((current) => (current && typeof current === 'object' ? current : unheard))\n })\n return () => {\n clearTimeout(timer)\n controller.abort()\n }\n }, [orgId, jobId, moving, attempt])\n const retry = useCallback(() => {\n setJob(null)\n setAttempt((count) => count + 1)\n }, [])\n return [job, setJob, retry]\n}\n\nconst ROW_ICON: Readonly<Record<Exclude<AiSiteBuildRowState, 'active'>, { path: string; color: string; label: string }>> = {\n done: { path: mdiCheckCircle.path, color: 'success.main', label: 'Done' },\n waiting: { path: mdiClockOutline.path, color: 'text.disabled', label: 'Waiting' },\n failed: { path: mdiAlertCircle.path, color: 'error.main', label: 'Stopped' },\n skipped: { path: mdiMinusCircleOutline.path, color: 'text.disabled', label: 'Not built' },\n}\n\nfunction RowIcon({ state }: { state: AiSiteBuildRowState }) {\n if (state === 'active') {\n return <CircularProgress size={20} aria-label=\"In progress\" />\n }\n const icon = ROW_ICON[state]\n return (\n <Box component=\"span\" role=\"img\" aria-label={icon.label} sx={{ color: icon.color, display: 'inline-flex', fontSize: (theme) => theme.spacing(2.5) }}>\n <MdiIcon path={icon.path} aria-hidden />\n </Box>\n )\n}\n\n/** The page's frame: the site's name over the heading and its sentence. */\n/** \"0:42\", \"3:05\": how long the active row has been running, from when it started or was first seen. */\nfunction useElapsed(key: string | null, startedAt: string | null | undefined): string | null {\n const [now, setNow] = useState(() => Date.now())\n const seen = useRef<{ key: string | null; at: number }>({ key: null, at: Date.now() })\n if (seen.current.key !== key) seen.current = { key, at: Date.now() }\n useEffect(() => {\n if (!key) return\n const timer = setInterval(() => setNow(Date.now()), 1000)\n return () => clearInterval(timer)\n }, [key])\n if (!key) return null\n const started = startedAt ? Date.parse(startedAt) : NaN\n const from = Number.isFinite(started) ? Math.min(started, seen.current.at) : seen.current.at\n const seconds = Math.max(0, Math.floor((now - from) / 1000))\n return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`\n}\n\nfunction Frame({\n siteName,\n heading,\n lede,\n children,\n}: {\n siteName?: string\n heading: string\n lede?: string\n children?: ReactNode\n}) {\n return (\n <Container maxWidth=\"sm\" sx={{ py: { xs: 3, sm: 5 }, px: { xs: 2, sm: 3 } }}>\n <Stack spacing={4}>\n <Stack spacing={1}>\n {siteName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {siteName}\n </Typography>\n ) : null}\n <Typography variant=\"h4\" component=\"h1\">\n {heading}\n </Typography>\n {lede ? (\n <Typography variant=\"body1\" color=\"text.secondary\">\n {lede}\n </Typography>\n ) : null}\n </Stack>\n {children}\n </Stack>\n </Container>\n )\n}\n\nexport function AiSiteBuildPage({ hostId, segments, basePath }: ConsolePluginPageProps) {\n const { data: user } = useUser()\n const jobId = segments?.[0] ? decodeURIComponent(String(segments[0])) : null\n const orgSlug = (basePath ?? '').split('/')[1] ?? ''\n // `/{orgSlug}/hosts/{subdomain}/ai-jobs`: the site's subdomain, which a console URL names it by.\n const hostSubdomain = (basePath ?? '').split('/')[3] || null\n const site = useAiJobSite(hostId)\n const orgId = site.status === 'ready' ? site.orgId : null\n const siteName = site.status === 'ready' ? site.name : undefined\n\n const [job, setJob, retry] = useAiJobById(user, orgId, jobId)\n const [busy, setBusy] = useState(false)\n const [notice, setNotice] = useState<string | null>(null)\n // A failed guided start's Try again reopens its questions, filled in (AGL-3596);\n // `?retry=1` — what the AI jobs drawer links — opens them on arrival.\n const [retrying, setRetrying] = useState(\n () => typeof window !== 'undefined' && new URLSearchParams(window.location.search).get('retry') === '1',\n )\n const tryAgain = useCallback(async () => {\n if (!orgId || !job || typeof job !== 'object') return\n setBusy(true)\n setNotice(null)\n // A finished build tries again only what failed (AGL-3616).\n const decision = await resumeAiJobRequest(\n user,\n orgId,\n job,\n aiBuildCanRetry(job) ? { retry: 'failed-items' } : {},\n )\n if (decision.job) setJob(decision.job)\n if (decision.error) setNotice(decision.error)\n setBusy(false)\n }, [orgId, job, user, setJob])\n const confirmPlan = useCallback(\n async (target: AiJobSummary, options: { publish?: boolean } = {}) => {\n if (!orgId) return\n setBusy(true)\n setNotice(null)\n const decision = await resumeAiJobRequest(user, orgId, target, options)\n if (decision.job) setJob(decision.job)\n if (decision.error) setNotice(decision.error)\n setBusy(false)\n },\n [orgId, user, setJob],\n )\n\n const ready = job && typeof job === 'object' ? job : null\n const copy = ready ? aiJobPageCopy(ready, PLATFORM_BRAND_NAME) : null\n // The active row's running time, read before any early return (a hook).\n const liveRow =\n ready && aiSiteBuildPhase(ready) === 'working'\n ? (aiSiteBuildRows(ready).find((row) => row.state === 'active') ?? null)\n : null\n const elapsed = useElapsed(liveRow ? `${ready?.id}:${liveRow.id}` : null, liveRow?.startedAt)\n // The shell's header names the job's page as the page does, and its trail\n // walks back to the site's AI jobs.\n const record = <PageHeaderRecord title={copy?.heading} />\n\n if (site.status === 'error') {\n return (\n <Frame heading=\"This site could not be read\">\n <Alert severity=\"warning\">\n {'The site this job belongs to could not be loaded. Check your connection and reload the page.'}\n </Alert>\n </Frame>\n )\n }\n if (job === 'missing') {\n return (\n <Frame siteName={siteName} heading=\"This job could not be found\">\n <Alert severity=\"info\">{'It may belong to another workspace, or it may have expired.'}</Alert>\n {basePath ? (\n <Box>\n <Button variant=\"outlined\" component={AppLink} href={basePath}>\n {'See this site’s AI jobs'}\n </Button>\n </Box>\n ) : null}\n </Frame>\n )\n }\n if (job === 'error') {\n return (\n <Frame siteName={siteName} heading=\"This job could not be loaded\">\n <Alert\n severity=\"warning\"\n action={\n <Button color=\"inherit\" size=\"small\" onClick={retry}>\n {'Try again'}\n </Button>\n }\n >\n {'Something went wrong reading it. It may still be running: try again in a moment.'}\n </Alert>\n </Frame>\n )\n }\n if (!ready || !copy) {\n return (\n <Frame siteName={siteName} heading=\"Building your site\">\n <Stack sx={{ alignItems: 'center', py: 4 }}>\n <CircularProgress aria-label=\"Loading the job\" />\n </Stack>\n </Frame>\n )\n }\n\n const phase = aiSiteBuildPhase(ready)\n const rows = aiSiteBuildRows(ready)\n const fraction = aiSiteBuildFraction(rows)\n const activeRow = phase === 'working' ? (rows.find((row) => row.state === 'active') ?? null) : null\n const credits = aiSiteBuildCreditsLine(ready)\n const links = phase === 'done' ? aiSiteBuildDoneLinks(ready, orgSlug) : { view: null, pages: null }\n const sitePublish = ready.kind === 'site' && phase === 'done' ? (ready.sitePublish ?? null) : null\n const liveUrl = sitePublish && sitePublish.published.length > 0 ? sitePublish.liveUrl : null\n const retryRefusal = ready.review?.retryRefusal\n const buildRetry = aiBuildCanRetry(ready)\n const canRetry = (phase === 'stopped' && ready.review?.reason === 'doctrine') || buildRetry\n const buildPlanWaiting = ready.kind === 'build' && phase === 'stopped' && ready.review?.reason === 'plan'\n // A guided start that ended without building its site starts over from its\n // own answers, as a fresh job: the questions reopen filled in.\n const restartAnswers =\n ready.kind === 'site' && (phase === 'failed' || phase === 'canceled')\n ? aiSiteStartAnswersFromInputs(ready.siteInputs)\n : null\n const refund = phase === 'failed' || phase === 'stopped' || phase === 'canceled' ? aiJobRefundCopy(ready) : null\n\n return (\n <Frame siteName={siteName} heading={copy.heading} lede={copy.lede}>\n {record}\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n {phase === 'working' &&\n (fraction !== null ? (\n <LinearProgress\n variant=\"determinate\"\n value={Math.round(fraction * 100)}\n aria-label={`Building: ${rows.filter((row) => row.state === 'done').length} of ${rows.length} steps done`}\n />\n ) : (\n <LinearProgress aria-label=\"Building\" />\n ))}\n <Box component=\"ol\" aria-label=\"Progress\" sx={{ listStyle: 'none', m: 0, p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n {rows.map((row) => (\n <Stack component=\"li\" key={row.id} direction=\"row\" spacing={2} sx={{ alignItems: 'flex-start' }}>\n <Box sx={{ width: (theme) => theme.spacing(3), display: 'flex', justifyContent: 'center' }}>\n <RowIcon state={row.state} />\n </Box>\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline', justifyContent: 'space-between' }}>\n <Typography\n variant=\"body1\"\n color={row.state === 'waiting' || row.state === 'skipped' ? 'text.secondary' : 'text.primary'}\n >\n {row.label}\n </Typography>\n {row.id === activeRow?.id && elapsed ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ fontVariantNumeric: 'tabular-nums' }}>\n {elapsed}\n </Typography>\n ) : typeof row.credits === 'number' && row.credits > 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ whiteSpace: 'nowrap' }}>\n {`${row.credits} ${row.credits === 1 ? 'credit' : 'credits'}`}\n </Typography>\n ) : null}\n </Stack>\n {row.id === activeRow?.id && row.hint ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.hint}\n </Typography>\n ) : null}\n {row.sections?.length && (row.state === 'active' || row.state === 'done') ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${row.state === 'active' ? 'Writing' : 'Wrote'}: ${row.sections.join(', ')}`}\n </Typography>\n ) : null}\n {/* A build item's failure, note or refund (AGL-3616). */}\n {row.detail ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.detail}\n </Typography>\n ) : null}\n </Box>\n </Stack>\n ))}\n </Stack>\n </Box>\n </Card>\n {refund && (ready.refundedCredits ?? 0) > 0 ? (\n <Alert severity=\"info\">{refund}</Alert>\n ) : credits ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {credits}\n </Typography>\n ) : null}\n {retrying && restartAnswers && hostId ? (\n <AiSiteStartCard\n hostId={hostId}\n orgId={orgId ?? undefined}\n orgSlug={orgSlug}\n host={hostSubdomain}\n initialAnswers={restartAnswers}\n startBlank={() => setRetrying(false)}\n leave={() => setRetrying(false)}\n />\n ) : null}\n {buildPlanWaiting ? (\n // A build's plan, confirmed here as in the chat (AGL-3616).\n <AiJobPlan job={ready} busy={busy} onResume={(target, options) => void confirmPlan(target, options)} />\n ) : null}\n {sitePublish && sitePublish.drafts.length > 0 && (\n // The pages the publish left as drafts, each with its plain reason;\n // Edit your pages is where they are fixed and published.\n <Alert severity=\"warning\">\n <Typography variant=\"body2\" sx={{ mb: 1 }}>\n {sitePublish.drafts.length === 1 ? 'This page stayed a draft:' : 'These pages stayed drafts:'}\n </Typography>\n <Box component=\"ul\" sx={{ m: 0, pl: 2.5 }}>\n {sitePublish.drafts.map((draft) => (\n <li key={draft.id}>\n <Typography variant=\"body2\">{`${draft.label}: ${draft.reason}`}</Typography>\n </li>\n ))}\n </Box>\n <Typography variant=\"body2\" sx={{ mt: 1 }}>\n {'Open Edit your pages to fix and publish them.'}\n </Typography>\n </Alert>\n )}\n {phase === 'done' && buildRetry && (\n <Box>\n <Button variant=\"outlined\" disabled={busy} onClick={() => void tryAgain()}>\n {'Try again what failed'}\n </Button>\n </Box>\n )}\n {phase === 'done' && (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n {liveUrl ? (\n // The live site, in a tab of its own: the console stays where it is.\n <Button\n variant=\"contained\"\n size=\"large\"\n component=\"a\"\n href={liveUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {'View your site'}\n </Button>\n ) : links.view ? (\n <Button variant=\"contained\" size=\"large\" component={AppLink} href={links.view}>\n {'View your site'}\n </Button>\n ) : null}\n {links.pages && (\n <Button variant=\"outlined\" size=\"large\" component={AppLink} href={links.pages}>\n {'Edit your pages'}\n </Button>\n )}\n </Stack>\n )}\n {(phase === 'stopped' || phase === 'failed' || phase === 'canceled') && (\n <Stack spacing={1}>\n {retryRefusal && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {retryRefusal}\n </Typography>\n )}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'center' } }}>\n {restartAnswers && hostId && (\n <Button variant=\"contained\" onClick={() => setRetrying(true)}>\n {'Try again'}\n </Button>\n )}\n {canRetry && (\n <Button\n variant=\"contained\"\n disabled={busy || Boolean(retryRefusal)}\n onClick={() => void tryAgain()}\n >\n {'Try again'}\n </Button>\n )}\n {aiSiteStarterFallbackOffered(ready) && user ? <AiSiteStarterFallback job={ready} user={user} /> : null}\n </Stack>\n </Stack>\n )}\n {ready.plan && ready.plan.screens.length > 0 && (\n <Accordion\n // Open while the site is built, so the plan is in view as each part of it is written.\n defaultExpanded={phase === 'working'}\n variant=\"outlined\"\n disableGutters\n sx={{ borderRadius: 2, '&::before': { display: 'none' } }}\n >\n <AccordionSummary expandIcon={<MdiIcon path={mdiChevronDown.path} />}>\n <Typography variant=\"subtitle1\">{'What we’re building'}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Stack component=\"ul\" spacing={1.5} sx={{ m: 0, pl: 2.5 }}>\n {ready.plan.screens.map((screen, index) => (\n <Box component=\"li\" key={`${screen.slug}-${index}`}>\n <Typography variant=\"body1\">{`${screen.title} — ${screen.slug}`}</Typography>\n {screen.sections.length > 0 && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {screen.sections.map((section) => section.name).join(', ')}\n </Typography>\n )}\n </Box>\n ))}\n </Stack>\n </AccordionDetails>\n </Accordion>\n )}\n </Frame>\n )\n}\n\nexport default AiSiteBuildPage\n"],"names":["PLATFORM_BRAND_NAME","PageHeaderRecord","mdiAlertCircle","mdiCheckCircle","mdiChevronDown","mdiClockOutline","mdiMinusCircleOutline","AppLink","MdiIcon","useUser","Accordion","AccordionDetails","AccordionSummary","Alert","Box","Button","Card","CircularProgress","Container","LinearProgress","Stack","Typography","useCallback","useEffect","useRef","useState","aiJobPageCopy","aiSiteBuildCreditsLine","aiSiteBuildFraction","aiSiteBuildPhase","aiSiteBuildRows","aiJobRefundCopy","aiSiteStarterFallbackOffered","aiSiteStartAnswersFromInputs","AiSiteStartCard","AI_JOB_TERMINAL_STATUSES","followAiJobEvents","aiSiteBuildDoneLinks","AiJobPlan","aiBuildCanRetry","resumeAiJobRequest","useAiJobSite","AiSiteStarterFallback","AI_JOB_FIRST_STATE_TIMEOUT_MS","useAiJobById","user","orgId","jobId","userRef","current","job","setJob","attempt","setAttempt","status","moving","includes","undefined","controller","AbortController","heard","timer","setTimeout","signal","next","then","end","aborted","unheard","clearTimeout","abort","retry","count","ROW_ICON","done","path","color","label","waiting","failed","skipped","RowIcon","state","size","aria-label","icon","component","role","sx","display","fontSize","theme","spacing","aria-hidden","useElapsed","key","startedAt","now","setNow","Date","seen","at","setInterval","clearInterval","started","parse","NaN","from","Number","isFinite","Math","min","seconds","max","floor","String","padStart","Frame","siteName","heading","lede","children","maxWidth","py","xs","sm","px","variant","AiSiteBuildPage","hostId","segments","basePath","rows","ready","data","decodeURIComponent","orgSlug","split","hostSubdomain","site","name","busy","setBusy","notice","setNotice","retrying","setRetrying","window","URLSearchParams","location","search","get","tryAgain","decision","error","confirmPlan","target","options","copy","liveRow","find","row","elapsed","id","record","title","severity","href","action","onClick","alignItems","phase","fraction","activeRow","credits","links","view","pages","sitePublish","kind","liveUrl","published","length","retryRefusal","review","buildRetry","canRetry","reason","buildPlanWaiting","restartAnswers","siteInputs","refund","borderRadius","value","round","filter","listStyle","m","p","map","direction","width","justifyContent","flex","minWidth","fontVariantNumeric","whiteSpace","hint","sections","join","detail","refundedCredits","host","initialAnswers","startBlank","leave","onResume","drafts","mb","pl","draft","li","mt","disabled","rel","Boolean","plan","screens","defaultExpanded","disableGutters","expandIcon","screen","index","slug","section"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,SAASA,mBAAmB,QAAQ,eAAc;AAClD,SAASC,gBAAgB,QAAQ,oDAAmD;AAEpF,SACEC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,eAAe,EACfC,qBAAqB,QAChB,yBAAwB;AAC/B,SAASC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AAEvD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,SAAS,EACTC,cAAc,EACdC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAAyBC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChF,SACEC,aAAa,EACbC,sBAAsB,EACtB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B,MAAM,GAAG,mBACxB,KAACjK;4CAAW0G,SAAQ;4CAAQnD,OAAM;sDAC/B2J,OAAOvB,QAAQ,CAACT,GAAG,CAAC,CAACmC,UAAYA,QAAQ9F,IAAI,EAAEqE,IAAI,CAAC;;;mCAJlC,GAAGsB,OAAOE,IAAI,CAAC,CAAC,EAAED,OAAO;;;;;;;AAelE;AAEA,eAAexG,gBAAe"}
@@ -0,0 +1,53 @@
1
+ import type { ConsoleWidgetUpgrade } from '@aglyn/aglyn/plugin-manager/feature-plugins';
2
+ import { type ReactNode } from 'react';
3
+ import type { AiBriefKind } from './ai-brief-dialog.component';
4
+ /**
5
+ * "Create with AI" on a plan that could buy the AI add-on and has not
6
+ * (AGL-3601). The shell mounts the entry with `entitled={false}` only where
7
+ * the add-on is sold to this workspace, and the jobs route has said the plan
8
+ * is the one thing missing; the entry then keeps its place on the page and
9
+ * opens this instead of the brief, so the reader sees where the add-on is used.
10
+ */
11
+ /**
12
+ * What a "Create with AI" or "Ask AI" entry makes: the brief kinds, an
13
+ * automation, products, a function or variable, an overlay, and an answer
14
+ * about the figures on a page.
15
+ */
16
+ export type AiUpsellKind = AiBriefKind | 'workflow' | 'product' | 'logic' | 'overlay' | 'funnel' | 'insight';
17
+ /** What one entry's dialog says. */
18
+ export interface AiUpsellCopy {
19
+ title: string;
20
+ does: string;
21
+ /** The entry's own label, which the button reads and the offer names; "Create with AI" when absent. */
22
+ label?: string;
23
+ }
24
+ /** The label every "Create with AI" entry reads. */
25
+ export declare const AI_UPSELL_CREATE_LABEL = "Create with AI";
26
+ /** What the dialog says one entry would do here. */
27
+ export declare const AI_UPSELL_COPY: Readonly<Record<AiUpsellKind, AiUpsellCopy>>;
28
+ /** The label an entry's button reads. */
29
+ export declare function aiUpsellLabel(kind: AiUpsellKind): string;
30
+ /**
31
+ * The sentence that says where the feature comes from, and who can add it.
32
+ * `feature` is what the entry is called: "Create with AI" unless it is an ask.
33
+ */
34
+ export declare function aiUpsellOffer(canManageBilling: boolean, feature?: string): string;
35
+ export interface AiUpsellDialogProps {
36
+ kind: AiUpsellKind;
37
+ open: boolean;
38
+ onClose: () => void;
39
+ upgrade: ConsoleWidgetUpgrade;
40
+ }
41
+ export declare function AiUpsellDialog({ kind, open, onClose, upgrade }: AiUpsellDialogProps): import("react").JSX.Element;
42
+ /**
43
+ * The entry itself on a plan without the add-on: the same button, label and
44
+ * icon as the entitled entry, opening {@link AiUpsellDialog}. Every entry that
45
+ * draws it renders from the shell's client-side gates alone and asks the
46
+ * server nothing until it is used (AGL-3601).
47
+ */
48
+ export declare function AiUpsellButton({ kind, upgrade, label, }: {
49
+ kind: AiUpsellKind;
50
+ upgrade: ConsoleWidgetUpgrade;
51
+ /** The entitled entry's own label, when it is not the kind's. */
52
+ label?: string;
53
+ }): ReactNode;
@@ -0,0 +1,177 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Aglyn LLC
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */ import { aiAddonName } from "@aglyn/aglyn";
19
+ import { trackEvent } from "@aglyn/aglyn/app-utils/analytics-events";
20
+ import { mdiCreation } from "@aglyn/shared-data-mdi";
21
+ import { MdiIcon } from "@aglyn/shared-ui-jsx";
22
+ import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography } from "@mui/material";
23
+ import { useEffect, useState } from "react";
24
+ /** The label every "Create with AI" entry reads. */ export const AI_UPSELL_CREATE_LABEL = 'Create with AI';
25
+ /** What the dialog says one entry would do here. */ export const AI_UPSELL_COPY = {
26
+ page: {
27
+ title: 'Create a page with AI',
28
+ does: 'Describe the page you need and AI plans it from your brief, using your theme and ' + 'what the site already has. You confirm the plan, and the page is built as an ' + 'unpublished draft.'
29
+ },
30
+ template: {
31
+ title: 'Create a page template with AI',
32
+ does: 'Describe what each page should show and AI plans the template, filling what ' + 'changes from page to page from each record. You confirm the plan, and the template ' + 'is built as a draft in your library.'
33
+ },
34
+ layout: {
35
+ title: 'Create a layout with AI',
36
+ does: 'Describe what the layout should hold and AI plans it, linking your pages and placing ' + 'your navigation or menu component when the site has one. You confirm the plan, and ' + 'the layout is built as a draft no page uses until you assign it.'
37
+ },
38
+ form: {
39
+ title: 'Create a form with AI',
40
+ does: 'Describe what the form is for and AI plans its fields, its marketing consent and ' + 'where each submission goes. You confirm the plan, and the form is built as a draft.'
41
+ },
42
+ component: {
43
+ title: 'Create a reusable component with AI',
44
+ does: 'Describe what the component should show and AI plans it, making what each page can ' + 'change into its properties. You confirm the plan, and the component is built as a ' + 'draft.'
45
+ },
46
+ workflow: {
47
+ title: 'Create an automation with AI',
48
+ does: 'Describe what should happen, and when, and AI drafts the automation from the ' + 'triggers and steps your plan includes. It is saved switched off for you to review.'
49
+ },
50
+ email: {
51
+ title: 'Create an email with AI',
52
+ does: 'Describe the email you need and AI plans a design from the email blocks, with three ' + 'subject lines and three preheaders to choose between. You confirm the plan, and the ' + 'design is built as a draft that is sent to nobody.'
53
+ },
54
+ campaign: {
55
+ title: 'Create a campaign with AI',
56
+ does: 'Describe what the campaign is for and AI writes its email design and a draft campaign ' + 'that would send it. Nothing is sent or scheduled, and the campaign is aimed at nobody ' + 'until you pick its lists.'
57
+ },
58
+ product: {
59
+ title: 'Create products with AI',
60
+ does: 'Describe what the store sells and AI proposes up to twelve products. You review them ' + 'before any is created, and each is created as a draft that is not on your storefront ' + 'until you price it and activate it.'
61
+ },
62
+ logic: {
63
+ title: 'Create a function or variable with AI',
64
+ does: 'Describe what it should work out or hold and AI drafts the function or variable. It ' + 'opens unsaved in the editor for you to check and save.'
65
+ },
66
+ overlay: {
67
+ title: 'Create an overlay with AI',
68
+ does: 'Describe the announcement bar or popup you want and AI writes its copy within the ' + 'overlay’s limits. It is saved switched off, for you to check and turn on.'
69
+ },
70
+ funnel: {
71
+ title: 'Create a funnel with AI',
72
+ does: 'Describe the journey you want to measure and AI proposes its steps from the site’s ' + 'real pages, forms and products. It opens in the funnel editor for you to check and save.'
73
+ },
74
+ insight: {
75
+ title: 'Ask AI about these numbers',
76
+ label: 'Ask a question',
77
+ does: 'Ask a question about the figures on this page and AI answers from them, every answer ' + 'traced to the figures it is built from. It reads; it changes nothing.'
78
+ }
79
+ };
80
+ /** The label an entry's button reads. */ export function aiUpsellLabel(kind) {
81
+ var _AI_UPSELL_COPY_kind_label;
82
+ return (_AI_UPSELL_COPY_kind_label = AI_UPSELL_COPY[kind].label) != null ? _AI_UPSELL_COPY_kind_label : AI_UPSELL_CREATE_LABEL;
83
+ }
84
+ /**
85
+ * The sentence that says where the feature comes from, and who can add it.
86
+ * `feature` is what the entry is called: "Create with AI" unless it is an ask.
87
+ */ export function aiUpsellOffer(canManageBilling, feature = AI_UPSELL_CREATE_LABEL) {
88
+ const addon = aiAddonName();
89
+ return canManageBilling ? `${feature} comes with the ${addon} add-on, which you can add to this ` + 'workspace from Billing.' : `${feature} comes with the ${addon} add-on. Ask a workspace owner or admin ` + 'to add it from Billing.';
90
+ }
91
+ export function AiUpsellDialog({ kind, open, onClose, upgrade }) {
92
+ const copy = AI_UPSELL_COPY[kind];
93
+ const { canManageBilling, billingHref } = upgrade;
94
+ // Counted once per opening: the denominator the click is a rate against.
95
+ useEffect(()=>{
96
+ if (open) trackEvent('ai_upsell_shown', {
97
+ kind,
98
+ can_manage: canManageBilling
99
+ });
100
+ }, [
101
+ open,
102
+ kind,
103
+ canManageBilling
104
+ ]);
105
+ return /*#__PURE__*/ _jsxs(Dialog, {
106
+ open: open,
107
+ onClose: onClose,
108
+ fullWidth: true,
109
+ maxWidth: "xs",
110
+ children: [
111
+ /*#__PURE__*/ _jsx(DialogTitle, {
112
+ children: copy.title
113
+ }),
114
+ /*#__PURE__*/ _jsx(DialogContent, {
115
+ children: /*#__PURE__*/ _jsxs(Stack, {
116
+ spacing: 2,
117
+ children: [
118
+ /*#__PURE__*/ _jsx(Typography, {
119
+ variant: "body2",
120
+ children: copy.does
121
+ }),
122
+ /*#__PURE__*/ _jsx(Typography, {
123
+ variant: "body2",
124
+ color: "text.secondary",
125
+ children: aiUpsellOffer(canManageBilling, kind === 'insight' ? copy.title : AI_UPSELL_CREATE_LABEL)
126
+ })
127
+ ]
128
+ })
129
+ }),
130
+ /*#__PURE__*/ _jsxs(DialogActions, {
131
+ children: [
132
+ /*#__PURE__*/ _jsx(Button, {
133
+ onClick: onClose,
134
+ children: canManageBilling ? 'Not now' : 'Close'
135
+ }),
136
+ canManageBilling ? /*#__PURE__*/ _jsx(Button, {
137
+ variant: "contained",
138
+ href: billingHref,
139
+ onClick: ()=>trackEvent('ai_upsell_clicked', {
140
+ kind
141
+ }),
142
+ children: `Add ${aiAddonName()}`
143
+ }) : null
144
+ ]
145
+ })
146
+ ]
147
+ });
148
+ }
149
+ /**
150
+ * The entry itself on a plan without the add-on: the same button, label and
151
+ * icon as the entitled entry, opening {@link AiUpsellDialog}. Every entry that
152
+ * draws it renders from the shell's client-side gates alone and asks the
153
+ * server nothing until it is used (AGL-3601).
154
+ */ export function AiUpsellButton({ kind, upgrade, label }) {
155
+ const [open, setOpen] = useState(false);
156
+ return /*#__PURE__*/ _jsxs(_Fragment, {
157
+ children: [
158
+ /*#__PURE__*/ _jsx(Button, {
159
+ size: "small",
160
+ variant: "outlined",
161
+ startIcon: /*#__PURE__*/ _jsx(MdiIcon, {
162
+ path: mdiCreation.path
163
+ }),
164
+ onClick: ()=>setOpen(true),
165
+ children: label != null ? label : aiUpsellLabel(kind)
166
+ }),
167
+ /*#__PURE__*/ _jsx(AiUpsellDialog, {
168
+ kind: kind,
169
+ open: open,
170
+ onClose: ()=>setOpen(false),
171
+ upgrade: upgrade
172
+ })
173
+ ]
174
+ });
175
+ }
176
+
177
+ //# sourceMappingURL=ai-upsell-dialog.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-upsell-dialog.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { aiAddonName } from '@aglyn/aglyn'\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport type { ConsoleWidgetUpgrade } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState, type ReactNode } from 'react'\nimport type { AiBriefKind } from './ai-brief-dialog.component'\n\n/**\n * \"Create with AI\" on a plan that could buy the AI add-on and has not\n * (AGL-3601). The shell mounts the entry with `entitled={false}` only where\n * the add-on is sold to this workspace, and the jobs route has said the plan\n * is the one thing missing; the entry then keeps its place on the page and\n * opens this instead of the brief, so the reader sees where the add-on is used.\n */\n\n/**\n * What a \"Create with AI\" or \"Ask AI\" entry makes: the brief kinds, an\n * automation, products, a function or variable, an overlay, and an answer\n * about the figures on a page.\n */\nexport type AiUpsellKind =\n | AiBriefKind\n | 'workflow'\n | 'product'\n | 'logic'\n | 'overlay'\n | 'funnel'\n | 'insight'\n\n/** What one entry's dialog says. */\nexport interface AiUpsellCopy {\n title: string\n does: string\n /** The entry's own label, which the button reads and the offer names; \"Create with AI\" when absent. */\n label?: string\n}\n\n/** The label every \"Create with AI\" entry reads. */\nexport const AI_UPSELL_CREATE_LABEL = 'Create with AI'\n\n/** What the dialog says one entry would do here. */\nexport const AI_UPSELL_COPY: Readonly<Record<AiUpsellKind, AiUpsellCopy>> = {\n page: {\n title: 'Create a page with AI',\n does:\n 'Describe the page you need and AI plans it from your brief, using your theme and ' +\n 'what the site already has. You confirm the plan, and the page is built as an ' +\n 'unpublished draft.',\n },\n template: {\n title: 'Create a page template with AI',\n does:\n 'Describe what each page should show and AI plans the template, filling what ' +\n 'changes from page to page from each record. You confirm the plan, and the template ' +\n 'is built as a draft in your library.',\n },\n layout: {\n title: 'Create a layout with AI',\n does:\n 'Describe what the layout should hold and AI plans it, linking your pages and placing ' +\n 'your navigation or menu component when the site has one. You confirm the plan, and ' +\n 'the layout is built as a draft no page uses until you assign it.',\n },\n form: {\n title: 'Create a form with AI',\n does:\n 'Describe what the form is for and AI plans its fields, its marketing consent and ' +\n 'where each submission goes. You confirm the plan, and the form is built as a draft.',\n },\n component: {\n title: 'Create a reusable component with AI',\n does:\n 'Describe what the component should show and AI plans it, making what each page can ' +\n 'change into its properties. You confirm the plan, and the component is built as a ' +\n 'draft.',\n },\n workflow: {\n title: 'Create an automation with AI',\n does:\n 'Describe what should happen, and when, and AI drafts the automation from the ' +\n 'triggers and steps your plan includes. It is saved switched off for you to review.',\n },\n email: {\n title: 'Create an email with AI',\n does:\n 'Describe the email you need and AI plans a design from the email blocks, with three ' +\n 'subject lines and three preheaders to choose between. You confirm the plan, and the ' +\n 'design is built as a draft that is sent to nobody.',\n },\n campaign: {\n title: 'Create a campaign with AI',\n does:\n 'Describe what the campaign is for and AI writes its email design and a draft campaign ' +\n 'that would send it. Nothing is sent or scheduled, and the campaign is aimed at nobody ' +\n 'until you pick its lists.',\n },\n product: {\n title: 'Create products with AI',\n does:\n 'Describe what the store sells and AI proposes up to twelve products. You review them ' +\n 'before any is created, and each is created as a draft that is not on your storefront ' +\n 'until you price it and activate it.',\n },\n logic: {\n title: 'Create a function or variable with AI',\n does:\n 'Describe what it should work out or hold and AI drafts the function or variable. It ' +\n 'opens unsaved in the editor for you to check and save.',\n },\n overlay: {\n title: 'Create an overlay with AI',\n does:\n 'Describe the announcement bar or popup you want and AI writes its copy within the ' +\n 'overlay’s limits. It is saved switched off, for you to check and turn on.',\n },\n funnel: {\n title: 'Create a funnel with AI',\n does:\n 'Describe the journey you want to measure and AI proposes its steps from the site’s ' +\n 'real pages, forms and products. It opens in the funnel editor for you to check and save.',\n },\n insight: {\n title: 'Ask AI about these numbers',\n label: 'Ask a question',\n does:\n 'Ask a question about the figures on this page and AI answers from them, every answer ' +\n 'traced to the figures it is built from. It reads; it changes nothing.',\n },\n}\n\n/** The label an entry's button reads. */\nexport function aiUpsellLabel(kind: AiUpsellKind): string {\n return AI_UPSELL_COPY[kind].label ?? AI_UPSELL_CREATE_LABEL\n}\n\n/**\n * The sentence that says where the feature comes from, and who can add it.\n * `feature` is what the entry is called: \"Create with AI\" unless it is an ask.\n */\nexport function aiUpsellOffer(canManageBilling: boolean, feature = AI_UPSELL_CREATE_LABEL): string {\n const addon = aiAddonName()\n return canManageBilling\n ? `${feature} comes with the ${addon} add-on, which you can add to this ` +\n 'workspace from Billing.'\n : `${feature} comes with the ${addon} add-on. Ask a workspace owner or admin ` +\n 'to add it from Billing.'\n}\n\nexport interface AiUpsellDialogProps {\n kind: AiUpsellKind\n open: boolean\n onClose: () => void\n upgrade: ConsoleWidgetUpgrade\n}\n\nexport function AiUpsellDialog({ kind, open, onClose, upgrade }: AiUpsellDialogProps) {\n const copy = AI_UPSELL_COPY[kind]\n const { canManageBilling, billingHref } = upgrade\n\n // Counted once per opening: the denominator the click is a rate against.\n useEffect(() => {\n if (open) trackEvent('ai_upsell_shown', { kind, can_manage: canManageBilling })\n }, [open, kind, canManageBilling])\n\n return (\n <Dialog open={open} onClose={onClose} fullWidth maxWidth=\"xs\">\n <DialogTitle>{copy.title}</DialogTitle>\n <DialogContent>\n <Stack spacing={2}>\n <Typography variant=\"body2\">{copy.does}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {aiUpsellOffer(canManageBilling, kind === 'insight' ? copy.title : AI_UPSELL_CREATE_LABEL)}\n </Typography>\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose}>{canManageBilling ? 'Not now' : 'Close'}</Button>\n {canManageBilling ? (\n <Button\n variant=\"contained\"\n href={billingHref}\n onClick={() => trackEvent('ai_upsell_clicked', { kind })}\n >\n {`Add ${aiAddonName()}`}\n </Button>\n ) : null}\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * The entry itself on a plan without the add-on: the same button, label and\n * icon as the entitled entry, opening {@link AiUpsellDialog}. Every entry that\n * draws it renders from the shell's client-side gates alone and asks the\n * server nothing until it is used (AGL-3601).\n */\nexport function AiUpsellButton({\n kind,\n upgrade,\n label,\n}: {\n kind: AiUpsellKind\n upgrade: ConsoleWidgetUpgrade\n /** The entitled entry's own label, when it is not the kind's. */\n label?: string\n}): ReactNode {\n const [open, setOpen] = useState(false)\n return (\n <>\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiCreation.path} />}\n onClick={() => setOpen(true)}\n >\n {label ?? aiUpsellLabel(kind)}\n </Button>\n <AiUpsellDialog kind={kind} open={open} onClose={() => setOpen(false)} upgrade={upgrade} />\n </>\n )\n}\n"],"names":["aiAddonName","trackEvent","mdiCreation","MdiIcon","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","Typography","useEffect","useState","AI_UPSELL_CREATE_LABEL","AI_UPSELL_COPY","page","title","does","template","layout","form","component","workflow","email","campaign","product","logic","overlay","funnel","insight","label","aiUpsellLabel","kind","aiUpsellOffer","canManageBilling","feature","addon","AiUpsellDialog","open","onClose","upgrade","copy","billingHref","can_manage","fullWidth","maxWidth","spacing","variant","color","onClick","href","AiUpsellButton","setOpen","size","startIcon","path"],"mappings":"AAAA;;AAEA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAAQ,eAAc;AAC1C,SAASC,UAAU,QAAQ,0CAAyC;AAEpE,SAASC,WAAW,QAAQ,yBAAwB;AACpD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,SAAS,EAAEC,QAAQ,QAAwB,QAAO;AAiC3D,kDAAkD,GAClD,OAAO,MAAMC,yBAAyB,iBAAgB;AAEtD,kDAAkD,GAClD,OAAO,MAAMC,iBAA+D;IAC1EC,MAAM;QACJC,OAAO;QACPC,MACE,sFACA,kFACA;IACJ;IACAC,UAAU;QACRF,OAAO;QACPC,MACE,iFACA,wFACA;IACJ;IACAE,QAAQ;QACNH,OAAO;QACPC,MACE,0FACA,wFACA;IACJ;IACAG,MAAM;QACJJ,OAAO;QACPC,MACE,sFACA;IACJ;IACAI,WAAW;QACTL,OAAO;QACPC,MACE,wFACA,uFACA;IACJ;IACAK,UAAU;QACRN,OAAO;QACPC,MACE,kFACA;IACJ;IACAM,OAAO;QACLP,OAAO;QACPC,MACE,yFACA,yFACA;IACJ;IACAO,UAAU;QACRR,OAAO;QACPC,MACE,2FACA,2FACA;IACJ;IACAQ,SAAS;QACPT,OAAO;QACPC,MACE,0FACA,0FACA;IACJ;IACAS,OAAO;QACLV,OAAO;QACPC,MACE,yFACA;IACJ;IACAU,SAAS;QACPX,OAAO;QACPC,MACE,uFACA;IACJ;IACAW,QAAQ;QACNZ,OAAO;QACPC,MACE,wFACA;IACJ;IACAY,SAAS;QACPb,OAAO;QACPc,OAAO;QACPb,MACE,0FACA;IACJ;AACF,EAAC;AAED,uCAAuC,GACvC,OAAO,SAASc,cAAcC,IAAkB;QACvClB;IAAP,QAAOA,6B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JQ,OAAO,EACPV,KAAK,EAMN;IACC,MAAM,CAACQ,MAAMc,QAAQ,GAAGxC,SAAS;IACjC,qBACE;;0BACE,KAACR;gBACCiD,MAAK;gBACLN,SAAQ;gBACRO,yBAAW,KAACnD;oBAAQoD,MAAMrD,YAAYqD,IAAI;;gBAC1CN,SAAS,IAAMG,QAAQ;0BAEtBtB,gBAAAA,QAASC,cAAcC;;0BAE1B,KAACK;gBAAeL,MAAMA;gBAAMM,MAAMA;gBAAMC,SAAS,IAAMa,QAAQ;gBAAQZ,SAASA;;;;AAGtF"}
@@ -0,0 +1,42 @@
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 { MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token';
18
+ import { type AiJobSummary } from '../model/ai-jobs.types';
19
+ import type { AssistBuildProposal } from '../model/assist-build';
20
+ /**
21
+ * The one card a build proposed in the chat becomes (AGL-3616): while its
22
+ * job plans, a line saying so; then the job's own plan card, with its one
23
+ * price and Confirm — the same `AiJobPlan` the AI jobs drawer shows, so
24
+ * confirming here and there is one door; then where the build stands, item
25
+ * by item, with AI jobs a click away. The job itself is started by the
26
+ * panel, once, when the turn that proposed it ends; this card only follows
27
+ * it, so re-rendering a stored thread never starts a second build.
28
+ */
29
+ export interface AssistBuildCardProps {
30
+ proposal: AssistBuildProposal;
31
+ /** The job the proposal started, as last seen; `null` while it is being created. */
32
+ job: AiJobSummary | null;
33
+ /** Why the job could not be created or confirmed, when it could not. */
34
+ notice: string | null;
35
+ orgId: string;
36
+ user: MaybeTokenSource;
37
+ staff?: boolean;
38
+ /** The job as it moved, for the thread to keep. */
39
+ onJob: (job: AiJobSummary) => void;
40
+ onNotice: (notice: string | null) => void;
41
+ }
42
+ export declare function AssistBuildCard({ proposal, job, notice, orgId, user, staff, onJob, onNotice, }: AssistBuildCardProps): JSX.Element;