@aglyn/plugins-ai 1.0.0-beta.246 → 1.0.0-beta.249

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 (130) hide show
  1. package/package.json +17 -17
  2. package/src/lib/activity/ai-activity-actions.js +5 -1
  3. package/src/lib/activity/ai-activity-actions.js.map +1 -1
  4. package/src/lib/components/ai-job-links.js +14 -0
  5. package/src/lib/components/ai-job-links.js.map +1 -1
  6. package/src/lib/components/ai-site-start-card.component.d.ts +1 -1
  7. package/src/lib/components/ai-site-start-card.component.js +92 -19
  8. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  9. package/src/lib/declarations.server.js +12 -0
  10. package/src/lib/declarations.server.js.map +1 -1
  11. package/src/lib/jobs/ai-build-capabilities.js +56 -2
  12. package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
  13. package/src/lib/jobs/ai-job-build-step.d.ts +3 -8
  14. package/src/lib/jobs/ai-job-build-step.js +49 -12
  15. package/src/lib/jobs/ai-job-build-step.js.map +1 -1
  16. package/src/lib/jobs/ai-job-form-dataset.d.ts +8 -5
  17. package/src/lib/jobs/ai-job-form-dataset.js +28 -10
  18. package/src/lib/jobs/ai-job-form-dataset.js.map +1 -1
  19. package/src/lib/jobs/ai-job-form-step.d.ts +20 -4
  20. package/src/lib/jobs/ai-job-form-step.js +98 -28
  21. package/src/lib/jobs/ai-job-form-step.js.map +1 -1
  22. package/src/lib/jobs/ai-job-layout-language.d.ts +6 -2
  23. package/src/lib/jobs/ai-job-layout-language.js +16 -5
  24. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  25. package/src/lib/jobs/ai-job-layout-step.js +4 -1
  26. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  27. package/src/lib/jobs/ai-job-media-step.d.ts +239 -0
  28. package/src/lib/jobs/ai-job-media-step.js +610 -0
  29. package/src/lib/jobs/ai-job-media-step.js.map +1 -0
  30. package/src/lib/jobs/ai-job-page-language.d.ts +2 -0
  31. package/src/lib/jobs/ai-job-page-language.js +9 -0
  32. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  33. package/src/lib/jobs/ai-job-page-sections.js +4 -3
  34. package/src/lib/jobs/ai-job-page-sections.js.map +1 -1
  35. package/src/lib/jobs/ai-job-page-step.js +3 -2
  36. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  37. package/src/lib/jobs/ai-job-plan-step.d.ts +10 -1
  38. package/src/lib/jobs/ai-job-plan-step.js +73 -15
  39. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  40. package/src/lib/jobs/ai-job-settings-step.d.ts +0 -4
  41. package/src/lib/jobs/ai-job-settings-step.js +2 -7
  42. package/src/lib/jobs/ai-job-settings-step.js.map +1 -1
  43. package/src/lib/jobs/ai-job-site-content.d.ts +2 -2
  44. package/src/lib/jobs/ai-job-site-content.js +5 -3
  45. package/src/lib/jobs/ai-job-site-content.js.map +1 -1
  46. package/src/lib/jobs/ai-job-site-datasets.d.ts +1 -1
  47. package/src/lib/jobs/ai-job-site-datasets.js +3 -2
  48. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  49. package/src/lib/jobs/ai-job-site-events.d.ts +148 -0
  50. package/src/lib/jobs/ai-job-site-events.js +313 -0
  51. package/src/lib/jobs/ai-job-site-events.js.map +1 -0
  52. package/src/lib/jobs/ai-job-site-step.d.ts +9 -3
  53. package/src/lib/jobs/ai-job-site-step.js +63 -17
  54. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  55. package/src/lib/jobs/ai-job-tracking-step.d.ts +184 -0
  56. package/src/lib/jobs/ai-job-tracking-step.js +501 -0
  57. package/src/lib/jobs/ai-job-tracking-step.js.map +1 -0
  58. package/src/lib/jobs/ai-layout-stock-photos.d.ts +41 -0
  59. package/src/lib/jobs/ai-layout-stock-photos.js +71 -3
  60. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  61. package/src/lib/jobs/ai-site-publish.js +2 -3
  62. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  63. package/src/lib/jobs/ai-stock-photo-picker.d.ts +24 -0
  64. package/src/lib/jobs/ai-stock-photo-picker.js +108 -0
  65. package/src/lib/jobs/ai-stock-photo-picker.js.map +1 -0
  66. package/src/lib/jobs/fixtures/ai-jazz-events-build-plan-recording.d.ts +37 -0
  67. package/src/lib/jobs/fixtures/ai-jazz-events-build-plan-recording.js +47 -0
  68. package/src/lib/jobs/fixtures/ai-jazz-events-build-plan-recording.js.map +1 -0
  69. package/src/lib/jobs/fixtures/ai-stock-photo-agl3760-recordings.d.ts +21 -0
  70. package/src/lib/jobs/fixtures/ai-stock-photo-agl3760-recordings.js +128 -0
  71. package/src/lib/jobs/fixtures/ai-stock-photo-agl3760-recordings.js.map +1 -0
  72. package/src/lib/jobs/fixtures/ai-stock-photo-agl3769-recordings.d.ts +21 -0
  73. package/src/lib/jobs/fixtures/ai-stock-photo-agl3769-recordings.js +126 -0
  74. package/src/lib/jobs/fixtures/ai-stock-photo-agl3769-recordings.js.map +1 -0
  75. package/src/lib/layout-language/ai-layout-compiler.d.ts +10 -4
  76. package/src/lib/layout-language/ai-layout-compiler.js +38 -19
  77. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  78. package/src/lib/layout-language/ai-layout-frame.d.ts +7 -5
  79. package/src/lib/layout-language/ai-layout-frame.js +12 -9
  80. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  81. package/src/lib/layout-language/ai-layout-gaps.js +3 -1
  82. package/src/lib/layout-language/ai-layout-gaps.js.map +1 -1
  83. package/src/lib/layout-language/ai-layout-labels.d.ts +70 -0
  84. package/src/lib/layout-language/ai-layout-labels.js +162 -0
  85. package/src/lib/layout-language/ai-layout-labels.js.map +1 -0
  86. package/src/lib/layout-language/ai-layout-links.js +5 -2
  87. package/src/lib/layout-language/ai-layout-links.js.map +1 -1
  88. package/src/lib/layout-language/ai-layout-listings.d.ts +14 -1
  89. package/src/lib/layout-language/ai-layout-listings.js +32 -5
  90. package/src/lib/layout-language/ai-layout-listings.js.map +1 -1
  91. package/src/lib/model/ai-build-event-page.d.ts +70 -0
  92. package/src/lib/model/ai-build-event-page.js +145 -0
  93. package/src/lib/model/ai-build-event-page.js.map +1 -0
  94. package/src/lib/model/ai-build-job.d.ts +21 -0
  95. package/src/lib/model/ai-build-job.js +39 -0
  96. package/src/lib/model/ai-build-job.js.map +1 -1
  97. package/src/lib/model/ai-build-plan.d.ts +25 -14
  98. package/src/lib/model/ai-build-plan.js +33 -23
  99. package/src/lib/model/ai-build-plan.js.map +1 -1
  100. package/src/lib/model/ai-job-activity.js +3 -1
  101. package/src/lib/model/ai-job-activity.js.map +1 -1
  102. package/src/lib/model/ai-jobs.types.d.ts +10 -2
  103. package/src/lib/model/ai-jobs.types.js +3 -1
  104. package/src/lib/model/ai-jobs.types.js.map +1 -1
  105. package/src/lib/model/ai-plan-capabilities.d.ts +8 -0
  106. package/src/lib/model/ai-plan-capabilities.js.map +1 -1
  107. package/src/lib/model/ai-site-inventory.d.ts +2 -0
  108. package/src/lib/model/ai-site-inventory.js +5 -0
  109. package/src/lib/model/ai-site-inventory.js.map +1 -1
  110. package/src/lib/model/ai-site-job.d.ts +2 -2
  111. package/src/lib/model/ai-site-job.js +3 -3
  112. package/src/lib/model/ai-site-job.js.map +1 -1
  113. package/src/lib/runtime/ai-doctrine-validators.d.ts +25 -3
  114. package/src/lib/runtime/ai-doctrine-validators.js +53 -6
  115. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  116. package/src/lib/runtime/ai-doctrine.d.ts +6 -1
  117. package/src/lib/runtime/ai-doctrine.js +13 -9
  118. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  119. package/src/lib/runtime/ai-eval-live.d.ts +1 -1
  120. package/src/lib/runtime/ai-eval-live.js +1 -1
  121. package/src/lib/runtime/ai-eval-live.js.map +1 -1
  122. package/src/lib/runtime/ai-palette.d.ts +3 -1
  123. package/src/lib/runtime/ai-palette.generated.js +498 -10
  124. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  125. package/src/lib/runtime/ai-palette.js +5 -3
  126. package/src/lib/runtime/ai-palette.js.map +1 -1
  127. package/src/lib/runtime/ai-template-examples.js +8 -2
  128. package/src/lib/runtime/ai-template-examples.js.map +1 -1
  129. package/src/lib/server.js +8 -0
  130. package/src/lib/server.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-ai",
3
- "version": "1.0.0-beta.246",
3
+ "version": "1.0.0-beta.249",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,22 +25,22 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.246",
29
- "@aglyn/shared-data-enums": "1.0.0-beta.246",
30
- "@aglyn/shared-data-mdi": "1.0.0-beta.246",
31
- "@aglyn/shared-data-types": "1.0.0-beta.246",
32
- "@aglyn/shared-ui-email-campaigns": "1.0.0-beta.246",
33
- "@aglyn/shared-ui-jsx": "1.0.0-beta.246",
34
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.246",
35
- "@aglyn/shared-ui-theme": "1.0.0-beta.246",
36
- "@aglyn/shared-util-email": "1.0.0-beta.246",
37
- "@aglyn/shared-util-errors": "1.0.0-beta.246",
38
- "@aglyn/shared-util-http": "1.0.0-beta.246",
39
- "@aglyn/shared-util-timestamp": "1.0.0-beta.246",
40
- "@aglyn/shared-util-tools": "1.0.0-beta.246",
41
- "@aglyn/tenant-data-admin": "1.0.0-beta.246",
42
- "@aglyn/tenant-feature-instance": "1.0.0-beta.246",
43
- "@aglyn/tenant-runtime": "1.0.0-beta.246",
28
+ "@aglyn/aglyn": "1.0.0-beta.249",
29
+ "@aglyn/shared-data-enums": "1.0.0-beta.249",
30
+ "@aglyn/shared-data-mdi": "1.0.0-beta.249",
31
+ "@aglyn/shared-data-types": "1.0.0-beta.249",
32
+ "@aglyn/shared-ui-email-campaigns": "1.0.0-beta.249",
33
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.249",
34
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.249",
35
+ "@aglyn/shared-ui-theme": "1.0.0-beta.249",
36
+ "@aglyn/shared-util-email": "1.0.0-beta.249",
37
+ "@aglyn/shared-util-errors": "1.0.0-beta.249",
38
+ "@aglyn/shared-util-http": "1.0.0-beta.249",
39
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.249",
40
+ "@aglyn/shared-util-tools": "1.0.0-beta.249",
41
+ "@aglyn/tenant-data-admin": "1.0.0-beta.249",
42
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.249",
43
+ "@aglyn/tenant-runtime": "1.0.0-beta.249",
44
44
  "@swc/helpers": "0.5.23"
45
45
  },
46
46
  "peerDependencies": {
@@ -177,7 +177,11 @@ export const AI_JOB_NEEDS_INPUT_REASON_LABELS = {
177
177
  // A blog post a guided start wrote (AGL-3676) is the site's content.
178
178
  entry: 'content',
179
179
  // A site's settings a build saved (AGL-3748) describe the site, filed with its content.
180
- settings: 'content'
180
+ settings: 'content',
181
+ // Files a build organized in the site's media library (AGL-3752), filed with its content.
182
+ media: 'content',
183
+ // A site's tracking tags a build saved (AGL-3751), filed with its settings.
184
+ tracking: 'content'
181
185
  };
182
186
  export function aiOutputTargetType(resource) {
183
187
  return AI_OUTPUT_TARGET_TYPES[resource];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/activity/ai-activity-actions.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 * The AI actions an activity log can carry (AGL-2929).\n *\n * Every other action in `orgs/{orgId}/activity` and `hosts/{hostId}/activity`\n * is a prose sentence written at the call site — \"Saved the screen\". The AI\n * rows are CODES instead, because they are read by more than a person: the\n * org feed's \"AI\" chip, the staff audit facet and the actor table all need\n * to recognize an AI row without parsing a sentence, and a sentence that\n * three writers phrase three ways is three rows that look unrelated.\n *\n * One list, so the writers in `ai-activity.ts`, the feed presenter and the\n * staff facet cannot disagree about what counts as AI. A code missing from\n * `AI_ACTIVITY_ACTION_LABELS` fails the type, not the reader.\n */\n\nimport type { AiJobOutputResource } from '../model/ai-jobs.types'\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn/app-utils/platform-brand'\nimport {\n pluginStaffAuditActionGroup,\n pluginStaffAuditActionGroupLabel,\n registerPluginActivityActions,\n type PluginActivityScope,\n} from '@aglyn/aglyn/plugin-manager/plugin-activity-actions'\n\n/** The action code each AI writer stores. */\nexport const AI_ACTIVITY_ACTIONS = {\n jobCreated: 'ai.job.created',\n jobOutput: 'ai.job.output',\n jobCanceled: 'ai.job.canceled',\n jobNeedsInput: 'ai.job.needs_input',\n editApplied: 'ai.edit.applied',\n seoApplied: 'ai.seo.applied',\n assistSection: 'ai.assist.section',\n overageHardCap: 'ai.overage.hardCap',\n overageCap: 'ai.overage.cap',\n allotmentChanged: 'ai.allotment.changed',\n permissionChanged: 'ai.permission.changed',\n addonPurchased: 'ai.addon.purchased',\n addonRemoved: 'ai.addon.removed',\n} as const\n\nexport type AiActivityAction =\n (typeof AI_ACTIVITY_ACTIONS)[keyof typeof AI_ACTIVITY_ACTIONS]\n\n/** What a person reads for each code, in the feed and the actor table. */\nexport const AI_ACTIVITY_ACTION_LABELS: Record<AiActivityAction, string> = {\n 'ai.job.created': 'Started an AI generation',\n 'ai.job.output': 'AI generated',\n 'ai.job.canceled': 'Canceled an AI generation',\n 'ai.job.needs_input': 'AI generation paused for input',\n 'ai.edit.applied': 'Applied AI edits',\n 'ai.seo.applied': 'Applied AI SEO fixes as drafts',\n 'ai.assist.section': 'AI generated a section',\n 'ai.overage.hardCap': 'AI stop-at-band switch',\n 'ai.overage.cap': 'AI overage ceiling',\n 'ai.allotment.changed': 'AI allotment changed',\n 'ai.permission.changed': 'AI permission changed',\n 'ai.addon.purchased': 'Added the AI add-on',\n 'ai.addon.removed': 'Removed the AI add-on',\n}\n\n/**\n * The codes whose row reads as a sentence about its target (AGL-3660):\n * `{target}` is the target's noun and name, so an output row reads\n * `Created page Home with Aglyn AI` rather than `AI generated` beside a\n * Target cell that had to finish the thought.\n */\nexport const AI_ACTIVITY_ACTION_SENTENCES: Partial<Record<AiActivityAction, string>> = {\n 'ai.job.output': `Created {target} with ${PLATFORM_BRAND_NAME} AI`,\n 'ai.edit.applied': `Applied ${PLATFORM_BRAND_NAME} AI edits to {target}`,\n 'ai.seo.applied': `Applied ${PLATFORM_BRAND_NAME} AI search fixes to {target}`,\n 'ai.assist.section': `Added a section to {target} with ${PLATFORM_BRAND_NAME} AI`,\n}\n\n/**\n * What the staff audit trail reads for each code the AI doors write to\n * `adminAudit` (AGL-3660). `ai.job.output` is spelled out per row by the\n * shared describer, which names the thing made.\n */\nexport const AI_STAFF_AUDIT_LABELS: Readonly<Record<string, string>> = {\n 'ai.job.output': `Created a draft with ${PLATFORM_BRAND_NAME} AI`,\n 'ai.job.cancel': `Canceled an ${PLATFORM_BRAND_NAME} AI job`,\n 'ai.job.resume': `Confirmed an ${PLATFORM_BRAND_NAME} AI plan`,\n 'ai.job.apply': `Applied an ${PLATFORM_BRAND_NAME} AI result`,\n 'ai.generate': `Generated with ${PLATFORM_BRAND_NAME} AI`,\n 'ai.allotments.set': 'Set AI allotments',\n 'ai.credits.giveBack': 'Gave AI credits back',\n 'ai.credits.reset': 'Reset AI credits',\n 'ai.overage.clearCeiling': 'Cleared the AI overage ceiling',\n 'ai.overage.liftPause': 'Lifted the AI pause',\n 'ai.overage.resetStep': 'Reset the AI overage step',\n 'ai.overage.setCeiling': 'Set the AI overage ceiling',\n 'platform.aiFreeSpend.paused': 'Paused free AI for the day',\n 'org.ai-viewed': 'Viewed the organization’s AI usage',\n 'user.ai-usage-viewed': 'Viewed the account’s AI usage',\n 'org.ai-conversations-viewed': `Viewed the organization’s ${PLATFORM_BRAND_NAME} AI requests`,\n 'user.ai-requests-viewed': `Viewed the account’s ${PLATFORM_BRAND_NAME} AI requests`,\n ...Object.fromEntries(\n Object.entries(AI_ACTIVITY_ACTION_LABELS).filter(([key]) => key !== 'ai.job.output'),\n ),\n}\n\n/** A job output's `resource`, as the noun the audit sentence uses. */\nconst AI_OUTPUT_NOUNS: Readonly<Record<string, string>> = {\n screen: 'page',\n reusableComponent: 'component',\n emailScreen: 'email',\n orgAutomation: 'automation',\n workflow: 'automation',\n entry: 'post',\n text: 'copy',\n seo: 'search fixes',\n crm: 'CRM answer',\n insight: 'insight',\n}\n\n/**\n * An `ai.job.output` audit row in words (AGL-3660), from the `after` the\n * job writer stores — `{ resource, label }`: `Created page Home with Aglyn\n * AI`, and its outcome, a draft.\n */\nexport function aiStaffAuditDescribe(entry: {\n action: string\n after: Readonly<Record<string, unknown>>\n}): { action?: string; result?: string } | undefined {\n if (entry.action !== AI_ACTIVITY_ACTIONS.jobOutput) return undefined\n const resource = typeof entry.after['resource'] === 'string' ? entry.after['resource'] : ''\n const label = typeof entry.after['label'] === 'string' ? entry.after['label'].trim() : ''\n const noun =\n AI_OUTPUT_NOUNS[resource] ??\n (resource ? resource.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase() : 'draft')\n return {\n action: `Created ${noun}${label ? ` ${label}` : ''} with ${PLATFORM_BRAND_NAME} AI`,\n result: 'Draft created',\n }\n}\n\n/** Every code, in catalog order — what a filter sends as `isAnyOf`. */\nexport const AI_ACTIVITY_ACTION_LIST: readonly AiActivityAction[] =\n Object.values(AI_ACTIVITY_ACTIONS)\n\n/** The feed's filter chip and the staff facet's group, by one name. */\nexport const AI_ACTIVITY_FILTER_LABEL = 'AI'\n\n/**\n * Why a generation stopped and asked for a person (AGL-2904): the plan's\n * band ran out, the org's own ceiling refused, the monthly message cap or\n * the job's own token budget did — or, on the Free taste (AGL-2925), one of\n * its own precautions: the account's credits, its daily request cap, a\n * pause after declined briefs, or the platform's day of free spend. Those\n * are the meter's `AssistRefusedBy` less its `null`, so a ceiling the meter\n * can name is one the feed can label. The last three are the job's own: its\n * plan is ready for review, or an answer broke a building rule on its re-ask\n * (AGL-2935), or the site is at an allowance its plan sets for what the job\n * writes (AGL-2909).\n */\nexport type AiJobNeedsInputReason =\n | 'band'\n | 'cap'\n | 'messages'\n | 'budget'\n | 'allotment'\n | 'account'\n | 'requests'\n | 'refusals'\n | 'platform'\n | 'plan'\n | 'doctrine'\n | 'limit'\n\nexport const AI_JOB_NEEDS_INPUT_REASON_LABELS: Record<\n AiJobNeedsInputReason,\n string\n> = {\n plan: 'its plan is ready for review',\n doctrine: 'its answer broke a building rule twice',\n limit: 'the site reached an allowance of its plan',\n band: 'the included AI band is used up',\n cap: 'the overage ceiling was reached',\n messages: 'the monthly message cap was reached',\n budget: 'the job budget was reached',\n allotment: 'the creator’s or the site’s AI allotment is used up',\n account: 'the account’s free AI credits are used up',\n requests: 'the daily free request cap was reached',\n refusals: 'free generation is paused for the day after declined briefs',\n platform: 'free AI generation is paused for the day',\n}\n\n/**\n * The feed target types a generation job's output can be filed under: the\n * kinds both activity logs know, so the org row and its host copy share a\n * shape.\n */\nexport type AiOutputTargetType =\n | 'screen'\n | 'layout'\n | 'component'\n | 'template'\n | 'workflow'\n | 'content'\n | 'theme'\n\n/**\n * Where the feed files each resource kind a job can write (AGL-2904).\n *\n * A job names its output by the resource it wrote, and the activity logs\n * know a narrower set of targets. The map is total, so a resource kind\n * added to the job document must say where the feed shows it before the\n * machine can log it. `reusableComponent` is the feed's `component`; a\n * `text` output is copy, which the feed files as `content`; a `theme`\n * proposal is filed under the site's theme, which the host feed links to the\n * Theme section (AGL-2938); the kinds whose runners have not shipped are\n * content of the site too, and are filed there until a target of their own\n * exists.\n */\nconst AI_OUTPUT_TARGET_TYPES: Record<AiJobOutputResource, AiOutputTargetType> = {\n screen: 'screen',\n reusableComponent: 'component',\n layout: 'layout',\n template: 'template',\n form: 'content',\n emailScreen: 'content',\n campaign: 'content',\n product: 'content',\n experiment: 'content',\n workflow: 'workflow',\n // An SEO proposal (AGL-2910) is about the site's content, and is filed there.\n seo: 'content',\n text: 'content',\n theme: 'theme',\n // An insight answer (AGL-2915) is about the site's figures; the feed row\n // names it and never what it says.\n insight: 'content',\n // A CRM proposal (AGL-2917) writes nothing; the feed files it with content.\n crm: 'content',\n // Another plugin's draft a build asked its writer for (AGL-3616).\n draft: 'content',\n // A logic proposal (AGL-3603) writes nothing either.\n logic: 'content',\n // So does an org automation's (AGL-3603): the editor's Save is the write.\n orgAutomation: 'content',\n // A blog post a guided start wrote (AGL-3676) is the site's content.\n entry: 'content',\n // A site's settings a build saved (AGL-3748) describe the site, filed with its content.\n settings: 'content',\n}\n\nexport function aiOutputTargetType(resource: AiJobOutputResource): AiOutputTargetType {\n return AI_OUTPUT_TARGET_TYPES[resource]\n}\n\n/** Whether a stored action is one of the AI codes above. */\nexport function isAiActivityAction(action: unknown): action is AiActivityAction {\n return (\n typeof action === 'string' &&\n (AI_ACTIVITY_ACTION_LIST as readonly string[]).includes(action)\n )\n}\n\n/** The readable label for an AI code; `undefined` for any other action. */\nexport function aiActivityActionLabel(action: unknown): string | undefined {\n return isAiActivityAction(action)\n ? AI_ACTIVITY_ACTION_LABELS[action]\n : undefined\n}\n\n/**\n * Staff audit rows that are ABOUT AI without carrying an `ai.` code: the\n * customer's overage controls already write `billing.assistOverage.*`, and\n * the platform's free-spend auto-pause writes `platform.aiFreeSpend.*`\n * (AGL-2925). The audit page's facet folds them under the same group as the\n * codes, because \"what did we do about AI this week\" is one question.\n */\nexport const AI_STAFF_AUDIT_ACTION_PREFIXES: readonly string[] = [\n 'ai.',\n 'billing.assistOverage.',\n 'platform.aiFreeSpend.',\n]\n\n/** The facet group an `adminAudit` action belongs to. */\nexport const STAFF_AUDIT_AI_GROUP = 'ai'\n\n/**\n * Which log each code is written to. The job and edit codes land in both\n * the org feed and the host's copy; the billing and permission codes are\n * org-level facts and land in the org feed alone.\n */\nconst AI_ACTIVITY_ACTION_SCOPES: Record<\n AiActivityAction,\n PluginActivityScope | readonly PluginActivityScope[]\n> = {\n 'ai.job.created': ['org', 'host'],\n 'ai.job.output': ['org', 'host'],\n 'ai.job.canceled': ['org', 'host'],\n 'ai.job.needs_input': ['org', 'host'],\n 'ai.edit.applied': ['org', 'host'],\n 'ai.seo.applied': ['org', 'host'],\n 'ai.assist.section': ['org', 'host'],\n 'ai.overage.hardCap': 'org',\n 'ai.overage.cap': 'org',\n 'ai.allotment.changed': 'org',\n 'ai.permission.changed': 'org',\n 'ai.addon.purchased': 'org',\n 'ai.addon.removed': 'org',\n}\n\n/**\n * The catalog, declared through the generic activity-action seam\n * (AGL-2940) so the feed's chip, the actor table's filter and the staff\n * facet read it from the registry beside every other plugin's codes.\n * `registerAiDeclarations` calls it, in both apps and in the browser.\n */\nexport function registerAiActivityActions(): void {\n registerPluginActivityActions({\n pluginId: 'ai',\n group: {\n id: STAFF_AUDIT_AI_GROUP,\n label: AI_ACTIVITY_FILTER_LABEL,\n staffAuditPrefixes: AI_STAFF_AUDIT_ACTION_PREFIXES.filter(\n (prefix) => prefix !== 'ai.',\n ),\n // The staff cards opening on an org (AGL-2930) and on one account\n // (AGL-2928), which no longer write these, so the rows already in the\n // log still classify as reads; and a staff member reading what an org\n // asked Aglyn AI (AGL-3675), which writes one per page.\n // An account's AI requests on the staff user page (AGL-3660) likewise.\n staffAuditAccessActions: [\n 'org.ai-viewed',\n 'user.ai-usage-viewed',\n 'org.ai-conversations-viewed',\n 'user.ai-requests-viewed',\n ],\n staffAuditLabels: AI_STAFF_AUDIT_LABELS,\n // The audit trail's words for a job's output, its job collection and\n // the feed's job rows, read by core's shared describer (AGL-3660).\n staffAuditDescribe: aiStaffAuditDescribe,\n staffAuditCollections: { aiJobs: { noun: `${PLATFORM_BRAND_NAME} AI job`, job: true } },\n jobTargetTypes: ['aiJob'],\n },\n actions: AI_ACTIVITY_ACTION_LIST.map((key) => ({\n key,\n label: AI_ACTIVITY_ACTION_LABELS[key],\n ...(AI_ACTIVITY_ACTION_SENTENCES[key] ? { sentence: AI_ACTIVITY_ACTION_SENTENCES[key] } : {}),\n scope: AI_ACTIVITY_ACTION_SCOPES[key],\n })),\n // A generation job (AGL-2904): the org feed names the job, and each of\n // its outputs names the resource it produced. Filed as `aiJob` since\n // before plugin target types were namespaced, so the noun is declared\n // here rather than read off the type (AGL-3080).\n targetTypes: { aiJob: 'AI generation' },\n })\n}\n\n/**\n * The group the staff audit facet files an action under: `ai` for every\n * AI row, otherwise the action's leading namespace (`billing`, `org`,\n * `plugins`). Roughly seventy distinct actions write to `adminAudit`, so\n * the facet offers namespaces rather than a seventy-entry menu. Answered\n * by the registry, so every plugin's group is filed the same way.\n */\nexport function staffAuditActionGroup(action: unknown): string {\n return pluginStaffAuditActionGroup(action)\n}\n\n/** How a facet group reads in the menu: `ai` → `AI`, `billing` → `billing`. */\nexport function staffAuditActionGroupLabel(group: string): string {\n return pluginStaffAuditActionGroupLabel(group)\n}\n"],"names":["PLATFORM_BRAND_NAME","pluginStaffAuditActionGroup","pluginStaffAuditActionGroupLabel","registerPluginActivityActions","AI_ACTIVITY_ACTIONS","jobCreated","jobOutput","jobCanceled","jobNeedsInput","editApplied","seoApplied","assistSection","overageHardCap","overageCap","allotmentChanged","permissionChanged","addonPurchased","addonRemoved","AI_ACTIVITY_ACTION_LABELS","AI_ACTIVITY_ACTION_SENTENCES","AI_STAFF_AUDIT_LABELS","Object","fromEntries","entries","filter","key","AI_OUTPUT_NOUNS","screen","reusableComponent","emailScreen","orgAutomation","workflow","entry","text","seo","crm","insight","aiStaffAuditDescribe","action","undefined","resource","after","label","trim","noun","replace","toLowerCase","result","AI_ACTIVITY_ACTION_LIST","values","AI_ACTIVITY_FILTER_LABEL","AI_JOB_NEEDS_INPUT_REASON_LABELS","plan","doctrine","limit","band","cap","messages","budget","allotment","account","requests","refusals","platform","AI_OUTPUT_TARGET_TYPES","layout","template","form","campaign","product","experiment","theme","draft","logic","settings","aiOutputTargetType","isAiActivityAction","includes","aiActivityActionLabel","AI_STAFF_AUDIT_ACTION_PREFIXES","STAFF_AUDIT_AI_GROUP","AI_ACTIVITY_ACTION_SCOPES","registerAiActivityActions","pluginId","group","id","staffAuditPrefixes","prefix","staffAuditAccessActions","staffAuditLabels","staffAuditDescribe","staffAuditCollections","aiJobs","job","jobTargetTypes","actions","map","sentence","scope","targetTypes","aiJob","staffAuditActionGroup","staffAuditActionGroupLabel"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;CAaC;AAGD,SAASA,mBAAmB,QAAQ,wCAAuC;AAC3E,SACEC,2BAA2B,EAC3BC,gCAAgC,EAChCC,6BAA6B,QAExB,sDAAqD;AAE5D,2CAA2C,GAC3C,OAAO,MAAMC,sBAAsB;IACjCC,YAAY;IACZC,WAAW;IACXC,aAAa;IACbC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,eAAe;IACfC,gBAAgB;IAChBC,YAAY;IACZC,kBAAkB;IAClBC,mBAAmB;IACnBC,gBAAgB;IAChBC,cAAc;AAChB,EAAU;AAKV,wEAAwE,GACxE,OAAO,MAAMC,4BAA8D;IACzE,kBAAkB;IAClB,iBAAiB;IACjB,mBAAmB;IACnB,sBAAsB;IACtB,mBAAmB;IACnB,kBAAkB;IAClB,qBAAqB;IACrB,sBAAsB;IACtB,kBAAkB;IAClB,wBAAwB;IACxB,yBAAyB;IACzB,sBAAsB;IACtB,oBAAoB;AACtB,EAAC;AAED;;;;;CAKC,GACD,OAAO,MAAMC,+BAA0E;IACrF,iBAAiB,CAAC,sBAAsB,EAAEnB,oBAAoB,GAAG,CAAC;IAClE,mBAAmB,CAAC,QAAQ,E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C,CAACvE,MAAS;gBAC7CA;gBACAiB,OAAOxB,yBAAyB,CAACO,IAAI;eACjCN,4BAA4B,CAACM,IAAI,GAAG;gBAAEwE,UAAU9E,4BAA4B,CAACM,IAAI;YAAC,IAAI,CAAC;gBAC3FyE,OAAOjB,yBAAyB,CAACxD,IAAI;;QAEvC,uEAAuE;QACvE,qEAAqE;QACrE,sEAAsE;QACtE,iDAAiD;QACjD0E,aAAa;YAAEC,OAAO;QAAgB;IACxC;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,sBAAsB/D,MAAe;IACnD,OAAOrC,4BAA4BqC;AACrC;AAEA,6EAA6E,GAC7E,OAAO,SAASgE,2BAA2BlB,KAAa;IACtD,OAAOlF,iCAAiCkF;AAC1C"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/activity/ai-activity-actions.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 * The AI actions an activity log can carry (AGL-2929).\n *\n * Every other action in `orgs/{orgId}/activity` and `hosts/{hostId}/activity`\n * is a prose sentence written at the call site — \"Saved the screen\". The AI\n * rows are CODES instead, because they are read by more than a person: the\n * org feed's \"AI\" chip, the staff audit facet and the actor table all need\n * to recognize an AI row without parsing a sentence, and a sentence that\n * three writers phrase three ways is three rows that look unrelated.\n *\n * One list, so the writers in `ai-activity.ts`, the feed presenter and the\n * staff facet cannot disagree about what counts as AI. A code missing from\n * `AI_ACTIVITY_ACTION_LABELS` fails the type, not the reader.\n */\n\nimport type { AiJobOutputResource } from '../model/ai-jobs.types'\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn/app-utils/platform-brand'\nimport {\n pluginStaffAuditActionGroup,\n pluginStaffAuditActionGroupLabel,\n registerPluginActivityActions,\n type PluginActivityScope,\n} from '@aglyn/aglyn/plugin-manager/plugin-activity-actions'\n\n/** The action code each AI writer stores. */\nexport const AI_ACTIVITY_ACTIONS = {\n jobCreated: 'ai.job.created',\n jobOutput: 'ai.job.output',\n jobCanceled: 'ai.job.canceled',\n jobNeedsInput: 'ai.job.needs_input',\n editApplied: 'ai.edit.applied',\n seoApplied: 'ai.seo.applied',\n assistSection: 'ai.assist.section',\n overageHardCap: 'ai.overage.hardCap',\n overageCap: 'ai.overage.cap',\n allotmentChanged: 'ai.allotment.changed',\n permissionChanged: 'ai.permission.changed',\n addonPurchased: 'ai.addon.purchased',\n addonRemoved: 'ai.addon.removed',\n} as const\n\nexport type AiActivityAction =\n (typeof AI_ACTIVITY_ACTIONS)[keyof typeof AI_ACTIVITY_ACTIONS]\n\n/** What a person reads for each code, in the feed and the actor table. */\nexport const AI_ACTIVITY_ACTION_LABELS: Record<AiActivityAction, string> = {\n 'ai.job.created': 'Started an AI generation',\n 'ai.job.output': 'AI generated',\n 'ai.job.canceled': 'Canceled an AI generation',\n 'ai.job.needs_input': 'AI generation paused for input',\n 'ai.edit.applied': 'Applied AI edits',\n 'ai.seo.applied': 'Applied AI SEO fixes as drafts',\n 'ai.assist.section': 'AI generated a section',\n 'ai.overage.hardCap': 'AI stop-at-band switch',\n 'ai.overage.cap': 'AI overage ceiling',\n 'ai.allotment.changed': 'AI allotment changed',\n 'ai.permission.changed': 'AI permission changed',\n 'ai.addon.purchased': 'Added the AI add-on',\n 'ai.addon.removed': 'Removed the AI add-on',\n}\n\n/**\n * The codes whose row reads as a sentence about its target (AGL-3660):\n * `{target}` is the target's noun and name, so an output row reads\n * `Created page Home with Aglyn AI` rather than `AI generated` beside a\n * Target cell that had to finish the thought.\n */\nexport const AI_ACTIVITY_ACTION_SENTENCES: Partial<Record<AiActivityAction, string>> = {\n 'ai.job.output': `Created {target} with ${PLATFORM_BRAND_NAME} AI`,\n 'ai.edit.applied': `Applied ${PLATFORM_BRAND_NAME} AI edits to {target}`,\n 'ai.seo.applied': `Applied ${PLATFORM_BRAND_NAME} AI search fixes to {target}`,\n 'ai.assist.section': `Added a section to {target} with ${PLATFORM_BRAND_NAME} AI`,\n}\n\n/**\n * What the staff audit trail reads for each code the AI doors write to\n * `adminAudit` (AGL-3660). `ai.job.output` is spelled out per row by the\n * shared describer, which names the thing made.\n */\nexport const AI_STAFF_AUDIT_LABELS: Readonly<Record<string, string>> = {\n 'ai.job.output': `Created a draft with ${PLATFORM_BRAND_NAME} AI`,\n 'ai.job.cancel': `Canceled an ${PLATFORM_BRAND_NAME} AI job`,\n 'ai.job.resume': `Confirmed an ${PLATFORM_BRAND_NAME} AI plan`,\n 'ai.job.apply': `Applied an ${PLATFORM_BRAND_NAME} AI result`,\n 'ai.generate': `Generated with ${PLATFORM_BRAND_NAME} AI`,\n 'ai.allotments.set': 'Set AI allotments',\n 'ai.credits.giveBack': 'Gave AI credits back',\n 'ai.credits.reset': 'Reset AI credits',\n 'ai.overage.clearCeiling': 'Cleared the AI overage ceiling',\n 'ai.overage.liftPause': 'Lifted the AI pause',\n 'ai.overage.resetStep': 'Reset the AI overage step',\n 'ai.overage.setCeiling': 'Set the AI overage ceiling',\n 'platform.aiFreeSpend.paused': 'Paused free AI for the day',\n 'org.ai-viewed': 'Viewed the organization’s AI usage',\n 'user.ai-usage-viewed': 'Viewed the account’s AI usage',\n 'org.ai-conversations-viewed': `Viewed the organization’s ${PLATFORM_BRAND_NAME} AI requests`,\n 'user.ai-requests-viewed': `Viewed the account’s ${PLATFORM_BRAND_NAME} AI requests`,\n ...Object.fromEntries(\n Object.entries(AI_ACTIVITY_ACTION_LABELS).filter(([key]) => key !== 'ai.job.output'),\n ),\n}\n\n/** A job output's `resource`, as the noun the audit sentence uses. */\nconst AI_OUTPUT_NOUNS: Readonly<Record<string, string>> = {\n screen: 'page',\n reusableComponent: 'component',\n emailScreen: 'email',\n orgAutomation: 'automation',\n workflow: 'automation',\n entry: 'post',\n text: 'copy',\n seo: 'search fixes',\n crm: 'CRM answer',\n insight: 'insight',\n}\n\n/**\n * An `ai.job.output` audit row in words (AGL-3660), from the `after` the\n * job writer stores — `{ resource, label }`: `Created page Home with Aglyn\n * AI`, and its outcome, a draft.\n */\nexport function aiStaffAuditDescribe(entry: {\n action: string\n after: Readonly<Record<string, unknown>>\n}): { action?: string; result?: string } | undefined {\n if (entry.action !== AI_ACTIVITY_ACTIONS.jobOutput) return undefined\n const resource = typeof entry.after['resource'] === 'string' ? entry.after['resource'] : ''\n const label = typeof entry.after['label'] === 'string' ? entry.after['label'].trim() : ''\n const noun =\n AI_OUTPUT_NOUNS[resource] ??\n (resource ? resource.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase() : 'draft')\n return {\n action: `Created ${noun}${label ? ` ${label}` : ''} with ${PLATFORM_BRAND_NAME} AI`,\n result: 'Draft created',\n }\n}\n\n/** Every code, in catalog order — what a filter sends as `isAnyOf`. */\nexport const AI_ACTIVITY_ACTION_LIST: readonly AiActivityAction[] =\n Object.values(AI_ACTIVITY_ACTIONS)\n\n/** The feed's filter chip and the staff facet's group, by one name. */\nexport const AI_ACTIVITY_FILTER_LABEL = 'AI'\n\n/**\n * Why a generation stopped and asked for a person (AGL-2904): the plan's\n * band ran out, the org's own ceiling refused, the monthly message cap or\n * the job's own token budget did — or, on the Free taste (AGL-2925), one of\n * its own precautions: the account's credits, its daily request cap, a\n * pause after declined briefs, or the platform's day of free spend. Those\n * are the meter's `AssistRefusedBy` less its `null`, so a ceiling the meter\n * can name is one the feed can label. The last three are the job's own: its\n * plan is ready for review, or an answer broke a building rule on its re-ask\n * (AGL-2935), or the site is at an allowance its plan sets for what the job\n * writes (AGL-2909).\n */\nexport type AiJobNeedsInputReason =\n | 'band'\n | 'cap'\n | 'messages'\n | 'budget'\n | 'allotment'\n | 'account'\n | 'requests'\n | 'refusals'\n | 'platform'\n | 'plan'\n | 'doctrine'\n | 'limit'\n\nexport const AI_JOB_NEEDS_INPUT_REASON_LABELS: Record<\n AiJobNeedsInputReason,\n string\n> = {\n plan: 'its plan is ready for review',\n doctrine: 'its answer broke a building rule twice',\n limit: 'the site reached an allowance of its plan',\n band: 'the included AI band is used up',\n cap: 'the overage ceiling was reached',\n messages: 'the monthly message cap was reached',\n budget: 'the job budget was reached',\n allotment: 'the creator’s or the site’s AI allotment is used up',\n account: 'the account’s free AI credits are used up',\n requests: 'the daily free request cap was reached',\n refusals: 'free generation is paused for the day after declined briefs',\n platform: 'free AI generation is paused for the day',\n}\n\n/**\n * The feed target types a generation job's output can be filed under: the\n * kinds both activity logs know, so the org row and its host copy share a\n * shape.\n */\nexport type AiOutputTargetType =\n | 'screen'\n | 'layout'\n | 'component'\n | 'template'\n | 'workflow'\n | 'content'\n | 'theme'\n\n/**\n * Where the feed files each resource kind a job can write (AGL-2904).\n *\n * A job names its output by the resource it wrote, and the activity logs\n * know a narrower set of targets. The map is total, so a resource kind\n * added to the job document must say where the feed shows it before the\n * machine can log it. `reusableComponent` is the feed's `component`; a\n * `text` output is copy, which the feed files as `content`; a `theme`\n * proposal is filed under the site's theme, which the host feed links to the\n * Theme section (AGL-2938); the kinds whose runners have not shipped are\n * content of the site too, and are filed there until a target of their own\n * exists.\n */\nconst AI_OUTPUT_TARGET_TYPES: Record<AiJobOutputResource, AiOutputTargetType> = {\n screen: 'screen',\n reusableComponent: 'component',\n layout: 'layout',\n template: 'template',\n form: 'content',\n emailScreen: 'content',\n campaign: 'content',\n product: 'content',\n experiment: 'content',\n workflow: 'workflow',\n // An SEO proposal (AGL-2910) is about the site's content, and is filed there.\n seo: 'content',\n text: 'content',\n theme: 'theme',\n // An insight answer (AGL-2915) is about the site's figures; the feed row\n // names it and never what it says.\n insight: 'content',\n // A CRM proposal (AGL-2917) writes nothing; the feed files it with content.\n crm: 'content',\n // Another plugin's draft a build asked its writer for (AGL-3616).\n draft: 'content',\n // A logic proposal (AGL-3603) writes nothing either.\n logic: 'content',\n // So does an org automation's (AGL-3603): the editor's Save is the write.\n orgAutomation: 'content',\n // A blog post a guided start wrote (AGL-3676) is the site's content.\n entry: 'content',\n // A site's settings a build saved (AGL-3748) describe the site, filed with its content.\n settings: 'content',\n // Files a build organized in the site's media library (AGL-3752), filed with its content.\n media: 'content',\n // A site's tracking tags a build saved (AGL-3751), filed with its settings.\n tracking: 'content',\n}\n\nexport function aiOutputTargetType(resource: AiJobOutputResource): AiOutputTargetType {\n return AI_OUTPUT_TARGET_TYPES[resource]\n}\n\n/** Whether a stored action is one of the AI codes above. */\nexport function isAiActivityAction(action: unknown): action is AiActivityAction {\n return (\n typeof action === 'string' &&\n (AI_ACTIVITY_ACTION_LIST as readonly string[]).includes(action)\n )\n}\n\n/** The readable label for an AI code; `undefined` for any other action. */\nexport function aiActivityActionLabel(action: unknown): string | undefined {\n return isAiActivityAction(action)\n ? AI_ACTIVITY_ACTION_LABELS[action]\n : undefined\n}\n\n/**\n * Staff audit rows that are ABOUT AI without carrying an `ai.` code: the\n * customer's overage controls already write `billing.assistOverage.*`, and\n * the platform's free-spend auto-pause writes `platform.aiFreeSpend.*`\n * (AGL-2925). The audit page's facet folds them under the same group as the\n * codes, because \"what did we do about AI this week\" is one question.\n */\nexport const AI_STAFF_AUDIT_ACTION_PREFIXES: readonly string[] = [\n 'ai.',\n 'billing.assistOverage.',\n 'platform.aiFreeSpend.',\n]\n\n/** The facet group an `adminAudit` action belongs to. */\nexport const STAFF_AUDIT_AI_GROUP = 'ai'\n\n/**\n * Which log each code is written to. The job and edit codes land in both\n * the org feed and the host's copy; the billing and permission codes are\n * org-level facts and land in the org feed alone.\n */\nconst AI_ACTIVITY_ACTION_SCOPES: Record<\n AiActivityAction,\n PluginActivityScope | readonly PluginActivityScope[]\n> = {\n 'ai.job.created': ['org', 'host'],\n 'ai.job.output': ['org', 'host'],\n 'ai.job.canceled': ['org', 'host'],\n 'ai.job.needs_input': ['org', 'host'],\n 'ai.edit.applied': ['org', 'host'],\n 'ai.seo.applied': ['org', 'host'],\n 'ai.assist.section': ['org', 'host'],\n 'ai.overage.hardCap': 'org',\n 'ai.overage.cap': 'org',\n 'ai.allotment.changed': 'org',\n 'ai.permission.changed': 'org',\n 'ai.addon.purchased': 'org',\n 'ai.addon.removed': 'org',\n}\n\n/**\n * The catalog, declared through the generic activity-action seam\n * (AGL-2940) so the feed's chip, the actor table's filter and the staff\n * facet read it from the registry beside every other plugin's codes.\n * `registerAiDeclarations` calls it, in both apps and in the browser.\n */\nexport function registerAiActivityActions(): void {\n registerPluginActivityActions({\n pluginId: 'ai',\n group: {\n id: STAFF_AUDIT_AI_GROUP,\n label: AI_ACTIVITY_FILTER_LABEL,\n staffAuditPrefixes: AI_STAFF_AUDIT_ACTION_PREFIXES.filter(\n (prefix) => prefix !== 'ai.',\n ),\n // The staff cards opening on an org (AGL-2930) and on one account\n // (AGL-2928), which no longer write these, so the rows already in the\n // log still classify as reads; and a staff member reading what an org\n // asked Aglyn AI (AGL-3675), which writes one per page.\n // An account's AI requests on the staff user page (AGL-3660) likewise.\n staffAuditAccessActions: [\n 'org.ai-viewed',\n 'user.ai-usage-viewed',\n 'org.ai-conversations-viewed',\n 'user.ai-requests-viewed',\n ],\n staffAuditLabels: AI_STAFF_AUDIT_LABELS,\n // The audit trail's words for a job's output, its job collection and\n // the feed's job rows, read by core's shared describer (AGL-3660).\n staffAuditDescribe: aiStaffAuditDescribe,\n staffAuditCollections: { aiJobs: { noun: `${PLATFORM_BRAND_NAME} AI job`, job: true } },\n jobTargetTypes: ['aiJob'],\n },\n actions: AI_ACTIVITY_ACTION_LIST.map((key) => ({\n key,\n label: AI_ACTIVITY_ACTION_LABELS[key],\n ...(AI_ACTIVITY_ACTION_SENTENCES[key] ? { sentence: AI_ACTIVITY_ACTION_SENTENCES[key] } : {}),\n scope: AI_ACTIVITY_ACTION_SCOPES[key],\n })),\n // A generation job (AGL-2904): the org feed names the job, and each of\n // its outputs names the resource it produced. Filed as `aiJob` since\n // before plugin target types were namespaced, so the noun is declared\n // here rather than read off the type (AGL-3080).\n targetTypes: { aiJob: 'AI generation' },\n })\n}\n\n/**\n * The group the staff audit facet files an action under: `ai` for every\n * AI row, otherwise the action's leading namespace (`billing`, `org`,\n * `plugins`). Roughly seventy distinct actions write to `adminAudit`, so\n * the facet offers namespaces rather than a seventy-entry menu. Answered\n * by the registry, so every plugin's group is filed the same way.\n */\nexport function staffAuditActionGroup(action: unknown): string {\n return pluginStaffAuditActionGroup(action)\n}\n\n/** How a facet group reads in the menu: `ai` → `AI`, `billing` → `billing`. */\nexport function staffAuditActionGroupLabel(group: string): string {\n return pluginStaffAuditActionGroupLabel(group)\n}\n"],"names":["PLATFORM_BRAND_NAME","pluginStaffAuditActionGroup","pluginStaffAuditActionGroupLabel","registerPluginActivityActions","AI_ACTIVITY_ACTIONS","jobCreated","jobOutput","jobCanceled","jobNeedsInput","editApplied","seoApplied","assistSection","overageHardCap","overageCap","allotmentChanged","permissionChanged","addonPurchased","addonRemoved","AI_ACTIVITY_ACTION_LABELS","AI_ACTIVITY_ACTION_SENTENCES","AI_STAFF_AUDIT_LABELS","Object","fromEntries","entries","filter","key","AI_OUTPUT_NOUNS","screen","reusableComponent","emailScreen","orgAutomation","workflow","entry","text","seo","crm","insight","aiStaffAuditDescribe","action","undefined","resource","after","label","trim","noun","replace","toLowerCase","result","AI_ACTIVITY_ACTION_LIST","values","AI_ACTIVITY_FILTER_LABEL","AI_JOB_NEEDS_INPUT_REASON_LABELS","plan","doctrine","limit","band","cap","messages","budget","allotment","account","requests","refusals","platform","AI_OUTPUT_TARGET_TYPES","layout","template","form","campaign","product","experiment","theme","draft","logic","settings","media","tracking","aiOutputTargetType","isAiActivityAction","includes","aiActivityActionLabel","AI_STAFF_AUDIT_ACTION_PREFIXES","STAFF_AUDIT_AI_GROUP","AI_ACTIVITY_ACTION_SCOPES","registerAiActivityActions","pluginId","group","id","staffAuditPrefixes","prefix","staffAuditAccessActions","staffAuditLabels","staffAuditDescribe","staffAuditCollections","aiJobs","job","jobTargetTypes","actions","map","sentence","scope","targetTypes","aiJob","staffAuditActionGroup","staffAuditActionGroupLabel"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;CAaC;AAGD,SAASA,mBAAmB,QAAQ,wCAAuC;AAC3E,SACEC,2BAA2B,EAC3BC,gCAAgC,EAChCC,6BAA6B,QAExB,sDAAqD;AAE5D,2CAA2C,GAC3C,OAAO,MAAMC,sBAAsB;IACjCC,YAAY;IACZC,WAAW;IACXC,aAAa;IACbC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,eAAe;IACfC,gBAAgB;IAChBC,YAAY;IACZC,kBAAkB;IAClBC,mBAAmB;IACnBC,gBAAgB;IAChBC,cAAc;AAChB,EAAU;AAKV,wEAAwE,GACxE,OAAO,MAAMC,4BAA8D;IACzE,kBAAkB;IAClB,iBAAiB;IACjB,mBAAmB;IACnB,sBAAsB;IACtB,mBAAmB;IACnB,kBAAkB;IAClB,qBAAqB;IACrB,sBAAsB;IACtB,kBAAkB;IAClB,wBAAwB;IACxB,yBAAyB;IACzB,sBAAsB;IACtB,oBAAoB;AACtB,EAAC;AAED;;;;;CAKC,GACD,OAAO,MAAMC,+BAA0E;IACrF,iBAAiB,CAAC,sBAAsB,EAAEnB,oBAAoB,GAAG,CAAC;IAClE,mBAAmB,CAAC,QAAQ,EAAEA,oBAAoB,qBAAqB,CAAC;IACxE,kBAAkB,CAAC,QAAQ,EAAEA,oBAAoB,4BAA4B,CAAC;IAC9E,qBAAqB,CAAC,iCAAiC,EAAEA,oBAAoB,GAAG,CAAC;AACnF,EAAC;AAED;;;;CAIC,GACD,OAAO,MAAMoB,wBAA0D;IACrE,iBAAiB,CAAC,qBAAqB,EAAEpB,oBAAoB,GAAG,CAAC;IACjE,iBAAiB,CAAC,YAAY,EAAEA,oBAAoB,OAAO,CAAC;IAC5D,iB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a;YAAEC,OAAO;QAAgB;IACxC;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,sBAAsBjE,MAAe;IACnD,OAAOrC,4BAA4BqC;AACrC;AAEA,6EAA6E,GAC7E,OAAO,SAASkE,2BAA2BlB,KAAa;IACtD,OAAOpF,iCAAiCoF;AAC1C"}
@@ -75,6 +75,13 @@ import { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } fr
75
75
  host
76
76
  });
77
77
  }
78
+ if (output.resource === 'media') {
79
+ // Files a build organized (AGL-3752) open in the site's media library.
80
+ return buildRoute(Route.HOST_MEDIA, {
81
+ orgSlug,
82
+ host
83
+ });
84
+ }
78
85
  if (output.resource === 'settings') {
79
86
  // Settings a build saved (AGL-3748) open where most of them are edited.
80
87
  return buildRoute(Route.HOST_SETUP_SEO, {
@@ -82,6 +89,13 @@ import { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } fr
82
89
  host
83
90
  });
84
91
  }
92
+ if (output.resource === 'tracking') {
93
+ // Tags a build saved (AGL-3751) open on the card that edits them.
94
+ return buildRoute(Route.HOST_SETUP_TRACKING, {
95
+ orgSlug,
96
+ host
97
+ });
98
+ }
85
99
  if (output.resource === 'draft' && output.draftResource) {
86
100
  // A draft another plugin wrote — a dataset a site start or a build made
87
101
  // (AGL-3616) — opens where its owner lists it, or nowhere it is not loaded.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-job-links.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 */\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport {\n pluginRecordHref,\n pluginRecordListHref,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { AI_JOB_BESIGNER_SEGMENT as BESIGNER_SEGMENT, AI_SITE_BUILD_HREF } from '../model/ai-job-notice'\nimport type { AiJobOutput, AiJobSummary } from '../model/ai-jobs.types'\nimport { AI_STORE_FINISH_STEPS, type AiStoreFinishStep } from '../model/ai-site-store-pages'\nimport { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } from '../model/ai-build-store-pages'\n\n// Where a job's work opens in the console (AGL-2904), shared by the AI jobs\n// drawer and every dialog that follows the job it started (AGL-3593).\n\n/**\n * Where \"open draft\" goes, or `null` when the output has no page of its\n * own — a `text` output carries its copy on the job and is shown inline.\n * A versioned resource opens in the besigner on the version the job wrote;\n * one the console lists without a detail page opens its list; a `theme`\n * proposal opens the site's Theme section, where it is put in the editor.\n *\n * A console URL names a site by its SUBDOMAIN: the `[host]` segment resolves\n * through the member's host projection by subdomain, never by document id.\n * So an output that carries no `hostSubdomain` gets no link rather than one\n * that opens no site.\n */\nexport function aiJobOutputHref(output: AiJobOutput, orgSlug: string): string | null {\n const host = output.hostSubdomain\n if (!orgSlug || !host) return null\n const segment = BESIGNER_SEGMENT[output.resource]\n if (segment) {\n const base = `/${orgSlug}/hosts/${host}/${segment}/${output.id}`\n return output.versionId ? `${base}/versions/${output.versionId}/besigner` : base\n }\n if (output.resource === 'product') {\n // The catalog a drafted product lands in: the commerce plugin's address\n // for it (AGL-3080), or no link where commerce is not loaded.\n return pluginRecordListHref('product', { orgSlug, host })\n }\n if (output.resource === 'workflow') {\n // A drafted automation is an action (AGL-2919), listed switched off on\n // the workflows plugin's list of actions, or no link where it is not loaded.\n return pluginRecordListHref('action', { orgSlug, host })\n }\n if (output.resource === 'entry') {\n // A post a guided start wrote (AGL-3676) opens in its blog's list in Content.\n const collectionSlug = output.proposal?.['collectionSlug']\n return typeof collectionSlug === 'string' && collectionSlug\n ? buildRoute(Route.HOST_CONTENT_COLLECTION, { orgSlug, host, collectionSlug })\n : buildRoute(Route.HOST_CONTENT, { orgSlug, host })\n }\n if (output.resource === 'theme') {\n return buildRoute(Route.HOST_SETUP_THEME, { orgSlug, host })\n }\n if (output.resource === 'settings') {\n // Settings a build saved (AGL-3748) open where most of them are edited.\n return buildRoute(Route.HOST_SETUP_SEO, { orgSlug, host })\n }\n if (output.resource === 'draft' && output.draftResource) {\n // A draft another plugin wrote — a dataset a site start or a build made\n // (AGL-3616) — opens where its owner lists it, or nowhere it is not loaded.\n return pluginRecordListHref(output.draftResource, { orgSlug, host })\n }\n if (output.resource === 'form') {\n // A new form has no version for the besigner to open: its own page — the\n // forms plugin's address for it — mints the first one, and holds the\n // routing and consent it declares.\n return pluginRecordHref('form', { orgSlug, host }, output.id)\n }\n if (output.resource === 'campaign') {\n // A campaign's page is the marketing plugin's, under the site: its\n // address for the campaign (AGL-3080), or no link where it is not loaded.\n return pluginRecordHref('campaign', { orgSlug, host }, output.id)\n }\n return null\n}\n\n/**\n * The ONE action a finished job's row, its notification and the dialog that\n * started it lead with (AGL-3593): what the job built. Several pages from one\n * job — a site's — open the site's Pages list, where they wait as drafts; one\n * output with a page of its own opens that page; anything else has no single\n * place to go, and the row's own links stand. `null` until the job is done.\n */\nexport function aiJobPrimaryLink(\n job: Pick<AiJobSummary, 'status' | 'outputs'>,\n orgSlug: string,\n): { href: string; label: string } | null {\n if (job.status !== 'done' || !orgSlug) return null\n const screens = job.outputs.filter(\n (output) => output.resource === 'screen' && output.hostSubdomain,\n )\n if (screens.length > 1) {\n return {\n href: buildRoute(Route.HOST_SCREENS, { orgSlug, host: String(screens[0].hostSubdomain) }),\n label: 'Open your draft pages',\n }\n }\n for (const output of job.outputs) {\n const href = aiJobOutputHref(output, orgSlug)\n if (href) {\n return {\n href,\n label: output.resource === 'screen' ? 'Open the draft page' : `Open ${output.label}`,\n }\n }\n }\n return null\n}\n\nexport { AI_SITE_BUILD_HREF }\n\n/**\n * The \"Building your site\" page for one site job (AGL-3594): linkable, so the\n * guided start lands on it, a reload keeps it and a notification opens it.\n * `null` without the org slug or the site's subdomain a console URL needs.\n */\nexport function aiSiteBuildHref(\n orgSlug: string | null | undefined,\n hostSubdomain: string | null | undefined,\n jobId: string,\n): string | null {\n if (!orgSlug || !hostSubdomain || !jobId) return null\n return `/${orgSlug}/hosts/${hostSubdomain}${AI_SITE_BUILD_HREF}/${encodeURIComponent(jobId)}`\n}\n\n/**\n * A finished site's two ways in (AGL-3594): its first page's draft, opened in\n * the console's preview of that version, and the Pages list every draft waits\n * in. Either is `null` where the job reported nothing to open.\n */\nexport function aiSiteBuildDoneLinks(\n job: Pick<AiJobSummary, 'outputs'>,\n orgSlug: string,\n): { view: string | null; pages: string | null } {\n const screens = job.outputs.filter((output) => output.resource === 'screen' && output.hostSubdomain)\n const first = screens[0]\n if (!first || !orgSlug) return { view: null, pages: null }\n const host = String(first.hostSubdomain)\n return {\n view: first.versionId\n ? `/${orgSlug}/hosts/${host}/screens/${first.id}/versions/${first.versionId}/view`\n : null,\n pages: buildRoute(Route.HOST_SCREENS, { orgSlug, host }),\n }\n}\n\n/**\n * Where a person gets more AI credits (AGL-3660): the workspace's Billing\n * page at its plans, where an upgrade and the AI add-on are both sold — the\n * door the AI credits meter's own upgrade link opens.\n */\nexport function aiCreditsBillingHref(orgSlug: string): string {\n return `${buildRoute(Route.MANAGE_BILLING, { orgSlug })}#plans`\n}\n\n/** One thing left to finish an AI-built store, with where it is done. */\nexport interface AiStoreFinishLink extends AiStoreFinishStep {\n /** The console page it is done on; `null` where the owner of that page is not loaded. */\n href: string | null\n}\n\n/**\n * What is left to finish a store a site start built (AGL-3676), or `null`\n * where the start built no store's own pages: its account, cart and policy\n * pages are written, so payments, products, shipping and tax, and the\n * policies' brackets are all that remain. Each links the exact console page:\n * the store's settings and its catalog, as the commerce plugin publishes\n * them, and the site's Pages.\n */\nexport function aiStoreFinishLinks(\n job: Pick<AiJobSummary, 'kind' | 'status' | 'items' | 'outputs'> & Partial<Pick<AiJobSummary, 'sitePublish'>>,\n orgSlug: string,\n): AiStoreFinishLink[] | null {\n // A site start's store, or an Assist build that made the site a store (AGL-3676).\n if ((job.kind !== 'site' && job.kind !== 'build') || job.status !== 'done' || !orgSlug) return null\n const row = (job.items ?? []).find((one) => one.slot === 'store')\n if (!row || (row.status !== 'succeeded' && row.status !== 'degraded')) return null\n const host = job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostSubdomain\n if (!host) return null\n const context = { orgSlug, host: String(host) }\n // A build's products are drafts with no price unless asked, and it may\n // have written none of the policies (the site had them): its list says so.\n const build = job.kind === 'build'\n const mine = job.outputs.filter((output) => row.outputs.includes(output.id))\n const written = new Set(mine.map((output) => output.proposal?.['storePage']))\n const policies = !build || ['shipping', 'privacy', 'terms'].some((key) => written.has(key))\n const steps: AiStoreFinishLink[] = AI_STORE_FINISH_STEPS.filter((step) => step.id !== 'policies' || policies).map((step) => ({\n ...step,\n ...(build && step.id === 'products' ? { text: AI_BUILD_STORE_PRODUCTS_TEXT } : {}),\n href:\n step.opens === 'pages'\n ? buildRoute(Route.HOST_SCREENS, context)\n : step.opens === 'layouts' || step.opens === 'layout'\n ? buildRoute(Route.HOST_LAYOUTS, context)\n : pluginRecordListHref(step.opens, context),\n }))\n if (!build) return steps\n // The site's own header and footer (AGL-3676): links it had no list for are\n // the owner's to add; links drafted into it wait for its publish.\n if (mine.some((output) => output.proposal?.['storeLinks'] === 'missing')) {\n steps.push({ ...AI_BUILD_STORE_LINKS_MISSING_STEP, href: buildRoute(Route.HOST_LAYOUTS, context) })\n }\n const draft = mine.find((output) => output.resource === 'layout' && output.proposal?.['storeLinks'] === 'draft')\n const live = draft && job.sitePublish?.published.length\n if (draft && !live) steps.push({ ...AI_BUILD_STORE_LINKS_DRAFT_STEP, href: aiJobOutputHref(draft, orgSlug) })\n return steps\n}\n\n/** What a build's \"Review your products\" step says: its products are drafts, priced only where the request said. */\nexport const AI_BUILD_STORE_PRODUCTS_TEXT =\n 'Your new products are drafts. Set their prices, photos and stock, then make them active so they show in your store.'\n"],"names":["buildRoute","Route","pluginRecordHref","pluginRecordListHref","AI_JOB_BESIGNER_SEGMENT","BESIGNER_SEGMENT","AI_SITE_BUILD_HREF","AI_STORE_FINISH_STEPS","AI_BUILD_STORE_LINKS_DRAFT_STEP","AI_BUILD_STORE_LINKS_MISSING_STEP","aiJobOutputHref","output","orgSlug","host","hostSubdomain","segment","resource","base","id","versionId","collectionSlug","proposal","HOST_CONTENT_COLLECTION","HOST_CONTENT","HOST_SETUP_THEME","HOST_SETUP_SEO","draftResource","aiJobPrimaryLink","job","status","screens","outputs","filter","length","href","HOST_SCREENS","String","label","aiSiteBuildHref","jobId","encodeURIComponent","aiSiteBuildDoneLinks","first","view","pages","aiCreditsBillingHref","MANAGE_BILLING","aiStoreFinishLinks","kind","row","items","find","one","slot","context","build","mine","includes","written","Set","map","policies","some","key","has","steps","step","text","AI_BUILD_STORE_PRODUCTS_TEXT","opens","HOST_LAYOUTS","push","draft","live","sitePublish","published"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,mDAAkD;AACzD,SAASC,2BAA2BC,gBAAgB,EAAEC,kBAAkB,QAAQ,4BAAwB;AAExG,SAASC,qBAAqB,QAAgC,kCAA8B;AAC5F,SAASC,+BAA+B,EAAEC,iCAAiC,QAAQ,mCAA+B;AAElH,4EAA4E;AAC5E,sEAAsE;AAEtE;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,OAAe;IAClE,MAAMC,OAAOF,OAAOG,aAAa;IACjC,IAAI,CAACF,WAAW,CAACC,MAAM,OAAO;IAC9B,MAAME,UAAUV,gBA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AAK9D;YAAmCyB,MAAMlC,WAAWC,MAAMqE,YAAY,EAAEhB;;IAC1F;IACA,MAAMkB,QAAQhB,KAAKL,IAAI,CAAC,CAACxC;YAA2CA;eAAhCA,OAAOK,QAAQ,KAAK,YAAYL,EAAAA,mBAAAA,OAAOU,QAAQ,qBAAfV,gBAAiB,CAAC,aAAa,MAAK;;IACxG,MAAM8D,OAAOD,WAAS5C,mBAAAA,IAAI8C,WAAW,qBAAf9C,iBAAiB+C,SAAS,CAAC1C,MAAM;IACvD,IAAIuC,SAAS,CAACC,MAAMR,MAAMM,IAAI,CAAC,aAAK/D;QAAiC0B,MAAMxB,gBAAgB8D,OAAO5D;;IAClG,OAAOqD;AACT;AAEA,kHAAkH,GAClH,OAAO,MAAMG,+BACX,sHAAqH"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-job-links.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 */\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport {\n pluginRecordHref,\n pluginRecordListHref,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { AI_JOB_BESIGNER_SEGMENT as BESIGNER_SEGMENT, AI_SITE_BUILD_HREF } from '../model/ai-job-notice'\nimport type { AiJobOutput, AiJobSummary } from '../model/ai-jobs.types'\nimport { AI_STORE_FINISH_STEPS, type AiStoreFinishStep } from '../model/ai-site-store-pages'\nimport { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } from '../model/ai-build-store-pages'\n\n// Where a job's work opens in the console (AGL-2904), shared by the AI jobs\n// drawer and every dialog that follows the job it started (AGL-3593).\n\n/**\n * Where \"open draft\" goes, or `null` when the output has no page of its\n * own — a `text` output carries its copy on the job and is shown inline.\n * A versioned resource opens in the besigner on the version the job wrote;\n * one the console lists without a detail page opens its list; a `theme`\n * proposal opens the site's Theme section, where it is put in the editor.\n *\n * A console URL names a site by its SUBDOMAIN: the `[host]` segment resolves\n * through the member's host projection by subdomain, never by document id.\n * So an output that carries no `hostSubdomain` gets no link rather than one\n * that opens no site.\n */\nexport function aiJobOutputHref(output: AiJobOutput, orgSlug: string): string | null {\n const host = output.hostSubdomain\n if (!orgSlug || !host) return null\n const segment = BESIGNER_SEGMENT[output.resource]\n if (segment) {\n const base = `/${orgSlug}/hosts/${host}/${segment}/${output.id}`\n return output.versionId ? `${base}/versions/${output.versionId}/besigner` : base\n }\n if (output.resource === 'product') {\n // The catalog a drafted product lands in: the commerce plugin's address\n // for it (AGL-3080), or no link where commerce is not loaded.\n return pluginRecordListHref('product', { orgSlug, host })\n }\n if (output.resource === 'workflow') {\n // A drafted automation is an action (AGL-2919), listed switched off on\n // the workflows plugin's list of actions, or no link where it is not loaded.\n return pluginRecordListHref('action', { orgSlug, host })\n }\n if (output.resource === 'entry') {\n // A post a guided start wrote (AGL-3676) opens in its blog's list in Content.\n const collectionSlug = output.proposal?.['collectionSlug']\n return typeof collectionSlug === 'string' && collectionSlug\n ? buildRoute(Route.HOST_CONTENT_COLLECTION, { orgSlug, host, collectionSlug })\n : buildRoute(Route.HOST_CONTENT, { orgSlug, host })\n }\n if (output.resource === 'theme') {\n return buildRoute(Route.HOST_SETUP_THEME, { orgSlug, host })\n }\n if (output.resource === 'media') {\n // Files a build organized (AGL-3752) open in the site's media library.\n return buildRoute(Route.HOST_MEDIA, { orgSlug, host })\n }\n if (output.resource === 'settings') {\n // Settings a build saved (AGL-3748) open where most of them are edited.\n return buildRoute(Route.HOST_SETUP_SEO, { orgSlug, host })\n }\n if (output.resource === 'tracking') {\n // Tags a build saved (AGL-3751) open on the card that edits them.\n return buildRoute(Route.HOST_SETUP_TRACKING, { orgSlug, host })\n }\n if (output.resource === 'draft' && output.draftResource) {\n // A draft another plugin wrote — a dataset a site start or a build made\n // (AGL-3616) — opens where its owner lists it, or nowhere it is not loaded.\n return pluginRecordListHref(output.draftResource, { orgSlug, host })\n }\n if (output.resource === 'form') {\n // A new form has no version for the besigner to open: its own page — the\n // forms plugin's address for it — mints the first one, and holds the\n // routing and consent it declares.\n return pluginRecordHref('form', { orgSlug, host }, output.id)\n }\n if (output.resource === 'campaign') {\n // A campaign's page is the marketing plugin's, under the site: its\n // address for the campaign (AGL-3080), or no link where it is not loaded.\n return pluginRecordHref('campaign', { orgSlug, host }, output.id)\n }\n return null\n}\n\n/**\n * The ONE action a finished job's row, its notification and the dialog that\n * started it lead with (AGL-3593): what the job built. Several pages from one\n * job — a site's — open the site's Pages list, where they wait as drafts; one\n * output with a page of its own opens that page; anything else has no single\n * place to go, and the row's own links stand. `null` until the job is done.\n */\nexport function aiJobPrimaryLink(\n job: Pick<AiJobSummary, 'status' | 'outputs'>,\n orgSlug: string,\n): { href: string; label: string } | null {\n if (job.status !== 'done' || !orgSlug) return null\n const screens = job.outputs.filter(\n (output) => output.resource === 'screen' && output.hostSubdomain,\n )\n if (screens.length > 1) {\n return {\n href: buildRoute(Route.HOST_SCREENS, { orgSlug, host: String(screens[0].hostSubdomain) }),\n label: 'Open your draft pages',\n }\n }\n for (const output of job.outputs) {\n const href = aiJobOutputHref(output, orgSlug)\n if (href) {\n return {\n href,\n label: output.resource === 'screen' ? 'Open the draft page' : `Open ${output.label}`,\n }\n }\n }\n return null\n}\n\nexport { AI_SITE_BUILD_HREF }\n\n/**\n * The \"Building your site\" page for one site job (AGL-3594): linkable, so the\n * guided start lands on it, a reload keeps it and a notification opens it.\n * `null` without the org slug or the site's subdomain a console URL needs.\n */\nexport function aiSiteBuildHref(\n orgSlug: string | null | undefined,\n hostSubdomain: string | null | undefined,\n jobId: string,\n): string | null {\n if (!orgSlug || !hostSubdomain || !jobId) return null\n return `/${orgSlug}/hosts/${hostSubdomain}${AI_SITE_BUILD_HREF}/${encodeURIComponent(jobId)}`\n}\n\n/**\n * A finished site's two ways in (AGL-3594): its first page's draft, opened in\n * the console's preview of that version, and the Pages list every draft waits\n * in. Either is `null` where the job reported nothing to open.\n */\nexport function aiSiteBuildDoneLinks(\n job: Pick<AiJobSummary, 'outputs'>,\n orgSlug: string,\n): { view: string | null; pages: string | null } {\n const screens = job.outputs.filter((output) => output.resource === 'screen' && output.hostSubdomain)\n const first = screens[0]\n if (!first || !orgSlug) return { view: null, pages: null }\n const host = String(first.hostSubdomain)\n return {\n view: first.versionId\n ? `/${orgSlug}/hosts/${host}/screens/${first.id}/versions/${first.versionId}/view`\n : null,\n pages: buildRoute(Route.HOST_SCREENS, { orgSlug, host }),\n }\n}\n\n/**\n * Where a person gets more AI credits (AGL-3660): the workspace's Billing\n * page at its plans, where an upgrade and the AI add-on are both sold — the\n * door the AI credits meter's own upgrade link opens.\n */\nexport function aiCreditsBillingHref(orgSlug: string): string {\n return `${buildRoute(Route.MANAGE_BILLING, { orgSlug })}#plans`\n}\n\n/** One thing left to finish an AI-built store, with where it is done. */\nexport interface AiStoreFinishLink extends AiStoreFinishStep {\n /** The console page it is done on; `null` where the owner of that page is not loaded. */\n href: string | null\n}\n\n/**\n * What is left to finish a store a site start built (AGL-3676), or `null`\n * where the start built no store's own pages: its account, cart and policy\n * pages are written, so payments, products, shipping and tax, and the\n * policies' brackets are all that remain. Each links the exact console page:\n * the store's settings and its catalog, as the commerce plugin publishes\n * them, and the site's Pages.\n */\nexport function aiStoreFinishLinks(\n job: Pick<AiJobSummary, 'kind' | 'status' | 'items' | 'outputs'> & Partial<Pick<AiJobSummary, 'sitePublish'>>,\n orgSlug: string,\n): AiStoreFinishLink[] | null {\n // A site start's store, or an Assist build that made the site a store (AGL-3676).\n if ((job.kind !== 'site' && job.kind !== 'build') || job.status !== 'done' || !orgSlug) return null\n const row = (job.items ?? []).find((one) => one.slot === 'store')\n if (!row || (row.status !== 'succeeded' && row.status !== 'degraded')) return null\n const host = job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostSubdomain\n if (!host) return null\n const context = { orgSlug, host: String(host) }\n // A build's products are drafts with no price unless asked, and it may\n // have written none of the policies (the site had them): its list says so.\n const build = job.kind === 'build'\n const mine = job.outputs.filter((output) => row.outputs.includes(output.id))\n const written = new Set(mine.map((output) => output.proposal?.['storePage']))\n const policies = !build || ['shipping', 'privacy', 'terms'].some((key) => written.has(key))\n const steps: AiStoreFinishLink[] = AI_STORE_FINISH_STEPS.filter((step) => step.id !== 'policies' || policies).map((step) => ({\n ...step,\n ...(build && step.id === 'products' ? { text: AI_BUILD_STORE_PRODUCTS_TEXT } : {}),\n href:\n step.opens === 'pages'\n ? buildRoute(Route.HOST_SCREENS, context)\n : step.opens === 'layouts' || step.opens === 'layout'\n ? buildRoute(Route.HOST_LAYOUTS, context)\n : pluginRecordListHref(step.opens, context),\n }))\n if (!build) return steps\n // The site's own header and footer (AGL-3676): links it had no list for are\n // the owner's to add; links drafted into it wait for its publish.\n if (mine.some((output) => output.proposal?.['storeLinks'] === 'missing')) {\n steps.push({ ...AI_BUILD_STORE_LINKS_MISSING_STEP, href: buildRoute(Route.HOST_LAYOUTS, context) })\n }\n const draft = mine.find((output) => output.resource === 'layout' && output.proposal?.['storeLinks'] === 'draft')\n const live = draft && job.sitePublish?.published.length\n if (draft && !live) steps.push({ ...AI_BUILD_STORE_LINKS_DRAFT_STEP, href: aiJobOutputHref(draft, orgSlug) })\n return steps\n}\n\n/** What a build's \"Review your products\" step says: its products are drafts, priced only where the request said. */\nexport const AI_BUILD_STORE_PRODUCTS_TEXT =\n 'Your new products are drafts. Set their prices, photos and stock, then make them active so they show in your store.'\n"],"names":["buildRoute","Route","pluginRecordHref","pluginRecordListHref","AI_JOB_BESIGNER_SEGMENT","BESIGNER_SEGMENT","AI_SITE_BUILD_HREF","AI_STORE_FINISH_STEPS","AI_BUILD_STORE_LINKS_DRAFT_STEP","AI_BUILD_STORE_LINKS_MISSING_STEP","aiJobOutputHref","output","orgSlug","host","hostSubdomain","segment","resource","base","id","versionId","collectionSlug","proposal","HOST_CONTENT_COLLECTION","HOST_CONTENT","HOST_SETUP_THEME","HOST_MEDIA","HOST_SETUP_SEO","HOST_SETUP_TRACKING","draftResource","aiJobPrimaryLink","job","status","screens","outputs","filter","length","href","HOST_SCREENS","String","label","aiSiteBuildHref","jobId","encodeURIComponent","aiSiteBuildDoneLinks","first","view","pages","aiCreditsBillingHref","MANAGE_BILLING","aiStoreFinishLinks","kind","row","items","find","one","slot","context","build","mine","includes","written","Set","map","policies","some","key","has","steps","step","text","AI_BUILD_STORE_PRODUCTS_TEXT","opens","HOST_LAYOUTS","push","draft","live","sitePublish","published"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,mDAAkD;AACzD,SAASC,2BAA2BC,gBAAgB,EAAEC,kBAAkB,QAAQ,4BAAwB;AAExG,SAASC,qBAAqB,QAAgC,kCAA8B;AAC5F,SAASC,+BAA+B,EAAEC,iCAAiC,QAAQ,mCAA+B;AAElH,4EAA4E;AAC5E,sEAAsE;AAEtE;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,OAAe;IAClE,MAAMC,OAAOF,OAAOG,aAAa;IACjC,IAAI,CAACF,WAAW,CAACC,MAAM,OAAO;IAC9B,MAAME,UAAUV,gBAAgB,CAACM,OAAOK,QAAQ,CAAC;IACjD,IAAID,SAAS;QACX,MAAME,OAAO,CAAC,CAAC,EAAEL,QAAQ,OAAO,EAAEC,KAAK,CAAC,EAAEE,QAAQ,CAAC,EAAEJ,OAAOO,EAAE,EAAE;QAChE,OAAOP,OAAOQ,SAAS,GAAG,GAA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AAC,aAAa,MAAK;QAAY;QACxEwD,MAAMM,IAAI,CAAC,aAAKhE;YAAmC2B,MAAMpC,WAAWC,MAAMuE,YAAY,EAAEhB;;IAC1F;IACA,MAAMkB,QAAQhB,KAAKL,IAAI,CAAC,CAAC1C;YAA2CA;eAAhCA,OAAOK,QAAQ,KAAK,YAAYL,EAAAA,mBAAAA,OAAOU,QAAQ,qBAAfV,gBAAiB,CAAC,aAAa,MAAK;;IACxG,MAAMgE,OAAOD,WAAS5C,mBAAAA,IAAI8C,WAAW,qBAAf9C,iBAAiB+C,SAAS,CAAC1C,MAAM;IACvD,IAAIuC,SAAS,CAACC,MAAMR,MAAMM,IAAI,CAAC,aAAKjE;QAAiC4B,MAAM1B,gBAAgBgE,OAAO9D;;IAClG,OAAOuD;AACT;AAEA,kHAAkH,GAClH,OAAO,MAAMG,+BACX,sHAAqH"}
@@ -32,5 +32,5 @@ export declare const AI_SITE_START_SURFACE_SX: {
32
32
  export type AiSiteStartCardProps = ConsoleHostFirstRunZoneProps & {
33
33
  initialAnswers?: AiSiteStartAnswers | null;
34
34
  };
35
- export declare function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leave, initialAnswers, }: AiSiteStartCardProps): import("react").JSX.Element;
35
+ export declare function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leave, pendingSite, initialAnswers, }: AiSiteStartCardProps): import("react").JSX.Element;
36
36
  export default AiSiteStartCard;
@@ -217,7 +217,7 @@ function SectionLabel({ children, help }) {
217
217
  ]
218
218
  });
219
219
  }
220
- export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leave, initialAnswers = null }) {
220
+ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leave, pendingSite, initialAnswers = null }) {
221
221
  var _ref, _aiFreeSitePrompt, _ref1;
222
222
  var _modelChoice_options_options_find, _modelChoice_options, _aiSiteKindOfInputs;
223
223
  const { data: user } = useUser();
@@ -247,6 +247,13 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
247
247
  const [confirmingLeave, setConfirmingLeave] = useState(false);
248
248
  // The dialog's own root, to tell its Escape from a nested popup's.
249
249
  const dialogRef = useRef(null);
250
+ // Drawn by "Create site" before the site exists (AGL-3761): the shell's
251
+ // name and address are asked on step 1, and the site is created only by
252
+ // the starter, Skip, or Plan my site. Read through a ref by the verdict
253
+ // below, which must not re-run when the shell re-renders it.
254
+ const pendingRef = useRef(pendingSite);
255
+ pendingRef.current = pendingSite;
256
+ const creating = Boolean(pendingSite) && !(pendingSite == null ? void 0 : pendingSite.created);
250
257
  useEffect(()=>{
251
258
  if (!orgId || !uid) return;
252
259
  let active = true;
@@ -255,6 +262,8 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
255
262
  const response = await authorizedFetch(userRef.current, `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&limit=1`);
256
263
  const payload = response.ok ? await response.json().catch(()=>null) : null;
257
264
  if (active) {
265
+ var // "Create site" shows its own dialog when this one will not draw.
266
+ _pendingRef_current;
258
267
  if ((payload == null ? void 0 : payload.freeTaste) === true) {
259
268
  setFreeTaste(true);
260
269
  const credits = payload == null ? void 0 : payload.freeCredits;
@@ -265,10 +274,16 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
265
274
  welcomeEmail: false
266
275
  }));
267
276
  }
268
- setVerdict(response.status === 404 || response.status === 403 ? 'hidden' : 'ready');
277
+ const shown = response.status !== 404 && response.status !== 403;
278
+ setVerdict(shown ? 'ready' : 'hidden');
279
+ (_pendingRef_current = pendingRef.current) == null ? void 0 : _pendingRef_current.ready(shown);
269
280
  }
270
281
  } catch (unused) {
271
- if (active) setVerdict('hidden');
282
+ if (active) {
283
+ var _pendingRef_current1;
284
+ setVerdict('hidden');
285
+ (_pendingRef_current1 = pendingRef.current) == null ? void 0 : _pendingRef_current1.ready(false);
286
+ }
272
287
  }
273
288
  })();
274
289
  return ()=>{
@@ -334,6 +349,28 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
334
349
  setServerPrompt(null);
335
350
  try {
336
351
  var _ref;
352
+ // The site, created now when it does not exist yet (AGL-3761): this is
353
+ // the moment the person asked for it. A refusal is said here, and one
354
+ // about the name or address goes back to step 1, where they are typed.
355
+ let site = {
356
+ hostId,
357
+ host,
358
+ orgSlug
359
+ };
360
+ if (!hostId && pendingSite) {
361
+ const made = await pendingSite.create();
362
+ if ('error' in made) {
363
+ setNotice(made.error);
364
+ if (made.address) setStep('choose');
365
+ return;
366
+ }
367
+ site = {
368
+ hostId: made.hostId,
369
+ host: made.host,
370
+ orgSlug: made.orgSlug || orgSlug
371
+ };
372
+ }
373
+ if (!site.hostId) return;
337
374
  const response = await authorizedFetch(userRef.current, '/api/ai/jobs', {
338
375
  method: 'POST',
339
376
  headers: {
@@ -341,7 +378,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
341
378
  },
342
379
  body: JSON.stringify(_extends({
343
380
  orgId,
344
- hostId,
381
+ hostId: site.hostId,
345
382
  kind: 'site',
346
383
  brief: aiSiteStartBrief(asked),
347
384
  // The guided start confirms its own plan (AGL-3594): the build
@@ -376,7 +413,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
376
413
  // Where the next step is (AGL-3594): the site's "Building your site"
377
414
  // page for this job. The zone closes without the starter first, so the
378
415
  // setup page does not ask again behind it.
379
- const href = aiSiteBuildHref(orgSlug, host, created.id);
416
+ const href = aiSiteBuildHref(site.orgSlug, site.host, created.id);
380
417
  if (href) {
381
418
  ;
382
419
  (leave != null ? leave : ()=>undefined)();
@@ -401,30 +438,55 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
401
438
  host,
402
439
  leave,
403
440
  router,
404
- pickedModel
441
+ pickedModel,
442
+ pendingSite
443
+ ]);
444
+ // The zone's `startBlank`. Before the site exists it creates it with the
445
+ // starter, and answers `false` when it could not — most often a name or
446
+ // address to fix, which step 1 shows.
447
+ const runStartBlank = useCallback(()=>{
448
+ const result = startBlank();
449
+ if (result && typeof result.then === 'function') {
450
+ void result.then((done)=>{
451
+ if (done) return;
452
+ setStartingStarter(false);
453
+ setStep('choose');
454
+ });
455
+ }
456
+ }, [
457
+ startBlank
405
458
  ]);
406
459
  const chooseStarter = useCallback(()=>{
460
+ if (pendingSite && !pendingSite.created && !pendingSite.check()) return;
407
461
  setStartingStarter(true);
408
462
  trackEvent('site_start_choice', {
409
463
  choice: 'starter'
410
464
  });
411
- startBlank();
465
+ runStartBlank();
412
466
  }, [
413
- startBlank
467
+ pendingSite,
468
+ runStartBlank
414
469
  ]);
415
470
  const chooseAi = useCallback(()=>{
471
+ if (pendingSite && !pendingSite.created && !pendingSite.check()) return;
416
472
  trackEvent('site_start_choice', {
417
473
  choice: 'ai'
418
474
  });
419
475
  setStep('describe');
420
- }, []);
476
+ }, [
477
+ pendingSite
478
+ ]);
421
479
  if (verdict !== 'ready') return null;
422
- // Before a job is started every way out is the blank site, which writes the
423
- // starter (AGL-3594); after, it only closes — the job builds the site.
424
- const exit = started ? leave != null ? leave : startBlank : startBlank;
480
+ // Before a job is started Skip is the blank site, which writes the starter
481
+ // (AGL-3594); after, it only closes — the job builds the site.
482
+ const exit = started ? leave != null ? leave : runStartBlank : runStartBlank;
483
+ // Escape and the close control. Before "Create site" has made the site
484
+ // (AGL-3761) there is nothing to give a starter to, so they only close,
485
+ // and nothing is created; otherwise they are the same way out as Skip.
486
+ const dismissTo = creating && !started ? leave != null ? leave : runStartBlank : exit;
425
487
  // Anything the person typed or picked, which a dismissal must not discard
426
488
  // silently (AGL-3660). After a job starts there is nothing left to lose.
427
- const drafted = !started && Boolean(answers.siteType.trim() || answers.audience.trim() || answers.kind !== null);
489
+ const drafted = !started && Boolean(answers.siteType.trim() || answers.audience.trim() || answers.kind !== null || creating && (pendingSite == null ? void 0 : pendingSite.dirty));
428
490
  // Escape and the close control: a dismissal, never a choice. Escape that
429
491
  // bubbled here through React from a portal outside this dialog's own DOM is
430
492
  // a nested menu's, already handled there, and is not this dialog's to act on.
@@ -435,16 +497,16 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
435
497
  if (root && target instanceof Node && !root.contains(target)) return;
436
498
  }
437
499
  if (drafted) setConfirmingLeave(true);
438
- else exit();
500
+ else dismissTo();
439
501
  };
440
502
  const leaveDraft = ()=>{
441
503
  setConfirmingLeave(false);
442
- exit();
504
+ dismissTo();
443
505
  };
444
506
  // The chosen model's cost against Auto's, as the model list states it.
445
507
  const modelMultiplier = pickedModel && ((_modelChoice_options = modelChoice.options) == null ? void 0 : (_modelChoice_options_options_find = _modelChoice_options.options.find((option)=>option.id === pickedModel)) == null ? void 0 : _modelChoice_options_options_find.multiplier) || 1;
446
508
  // What the start is likely to cost and at most (AGL-3722): "About 137
447
- // credits (up to 282)", the measured figures scaled by the chosen model.
509
+ // credits (up to 283)", the measured figures scaled by the chosen model.
448
510
  const scaled = (range)=>({
449
511
  likely: Math.round(range.likely * modelMultiplier),
450
512
  p90: Math.round(range.p90 * modelMultiplier),
@@ -574,7 +636,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
574
636
  float: 'right'
575
637
  }
576
638
  }, START_HELP.choose)) : null,
577
- choosing ? 'You can change everything later.' : `A few answers and ${PLATFORM_BRAND_NAME} AI plans and writes your pages, then publishes your site.`
639
+ choosing ? creating ? 'Name your site, then choose how it starts. You can change everything later.' : 'You can change everything later.' : `A few answers and ${PLATFORM_BRAND_NAME} AI plans and writes your pages, then publishes your site.`
578
640
  ]
579
641
  })
580
642
  ]
@@ -606,6 +668,17 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
606
668
  pages: 1
607
669
  })
608
670
  }),
671
+ choosing && creating && pendingSite ? /*#__PURE__*/ _jsxs(Stack, {
672
+ spacing: 2,
673
+ component: "section",
674
+ "aria-label": "Your site",
675
+ children: [
676
+ /*#__PURE__*/ _jsx(SectionLabel, {
677
+ children: 'Your site'
678
+ }),
679
+ pendingSite.fields
680
+ ]
681
+ }) : null,
609
682
  choosing ? /*#__PURE__*/ _jsxs(Box, {
610
683
  sx: {
611
684
  display: 'grid',
@@ -891,7 +964,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
891
964
  /*#__PURE__*/ _jsx(DialogContent, {
892
965
  children: /*#__PURE__*/ _jsx(DialogContentText, {
893
966
  id: `${TITLE_ID}-leave-text`,
894
- children: 'What you typed is not saved. Leaving starts your site from the starter site instead.'
967
+ children: creating ? 'What you typed is not saved, and no site is created.' : 'What you typed is not saved. Leaving starts your site from the starter site instead.'
895
968
  })
896
969
  }),
897
970
  /*#__PURE__*/ _jsxs(DialogActions, {
@@ -899,7 +972,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
899
972
  /*#__PURE__*/ _jsx(Button, {
900
973
  color: "inherit",
901
974
  onClick: leaveDraft,
902
- children: 'Leave and start blank'
975
+ children: creating ? 'Leave' : 'Leave and start blank'
903
976
  }),
904
977
  /*#__PURE__*/ _jsx(Button, {
905
978
  variant: "contained",