@aglyn/plugins-ai 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/package.json +17 -17
  2. package/src/lib/activity/ai-activity.js +4 -2
  3. package/src/lib/activity/ai-activity.js.map +1 -1
  4. package/src/lib/components/ai-credits-card.component.d.ts +4 -3
  5. package/src/lib/components/ai-credits-card.component.js +13 -12
  6. package/src/lib/components/ai-credits-card.component.js.map +1 -1
  7. package/src/lib/components/ai-site-import-job.component.js +14 -5
  8. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  9. package/src/lib/components/ai-upsell-dialog.component.d.ts +2 -2
  10. package/src/lib/components/ai-upsell-dialog.component.js +3 -3
  11. package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
  12. package/src/lib/components/staff-org-ai-card.component.js +2 -2
  13. package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
  14. package/src/lib/declarations.d.ts +2 -2
  15. package/src/lib/declarations.js +10 -9
  16. package/src/lib/declarations.js.map +1 -1
  17. package/src/lib/jobs/ai-job-import-step.d.ts +28 -2
  18. package/src/lib/jobs/ai-job-import-step.js +170 -14
  19. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  20. package/src/lib/jobs/ai-job-layout-language.js +2 -0
  21. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  22. package/src/lib/jobs/ai-job-page-language.js +6 -2
  23. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  24. package/src/lib/jobs/ai-site-import-compile.d.ts +13 -3
  25. package/src/lib/jobs/ai-site-import-compile.js +339 -27
  26. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  27. package/src/lib/jobs/ai-site-import-document.d.ts +3 -1
  28. package/src/lib/jobs/ai-site-import-document.js +42 -1
  29. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  30. package/src/lib/jobs/ai-site-import-look.d.ts +9 -0
  31. package/src/lib/jobs/ai-site-import-look.js +89 -6
  32. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  33. package/src/lib/layout-language/ai-layout-compiler.d.ts +16 -0
  34. package/src/lib/layout-language/ai-layout-compiler.js +378 -56
  35. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  36. package/src/lib/layout-language/ai-layout-frame-source.d.ts +88 -2
  37. package/src/lib/layout-language/ai-layout-frame-source.js +591 -30
  38. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
  39. package/src/lib/layout-language/ai-layout-frame.js +30 -18
  40. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  41. package/src/lib/layout-language/ai-layout-language.d.ts +74 -3
  42. package/src/lib/layout-language/ai-layout-language.js +5 -3
  43. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  44. package/src/lib/layout-language/ai-layout-store.d.ts +8 -0
  45. package/src/lib/layout-language/ai-layout-store.js +32 -6
  46. package/src/lib/layout-language/ai-layout-store.js.map +1 -1
  47. package/src/lib/model/ai-site-import-fidelity.d.ts +31 -1
  48. package/src/lib/model/ai-site-import-fidelity.js +347 -25
  49. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  50. package/src/lib/model/ai-site-import-view.js +4 -3
  51. package/src/lib/model/ai-site-import-view.js.map +1 -1
  52. package/src/lib/model/ai-site-import.d.ts +205 -6
  53. package/src/lib/model/ai-site-import.js +161 -5
  54. package/src/lib/model/ai-site-import.js.map +1 -1
  55. package/src/lib/model/ai-site-look.d.ts +8 -1
  56. package/src/lib/model/ai-site-look.js +8 -5
  57. package/src/lib/model/ai-site-look.js.map +1 -1
  58. package/src/lib/model/ai-upsell-copy.js +4 -3
  59. package/src/lib/model/ai-upsell-copy.js.map +1 -1
  60. package/src/lib/plan-entitlements.d.ts +3 -3
  61. package/src/lib/plan-entitlements.js +1 -1
  62. package/src/lib/plan-entitlements.js.map +1 -1
  63. package/src/lib/providers/model-choice.d.ts +6 -3
  64. package/src/lib/providers/model-choice.js +8 -4
  65. package/src/lib/providers/model-choice.js.map +1 -1
  66. package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -1
  67. package/src/lib/runtime/ai-doctrine-validators.js +25 -2
  68. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  69. package/src/lib/runtime/ai-node-tree.js +19 -2
  70. package/src/lib/runtime/ai-node-tree.js.map +1 -1
  71. package/src/lib/runtime/ai-page-links.d.ts +15 -0
  72. package/src/lib/runtime/ai-page-links.js +48 -0
  73. package/src/lib/runtime/ai-page-links.js.map +1 -1
  74. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +1 -1
  75. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +35 -6
  76. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  77. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +9 -0
  78. package/src/lib/site-import/fixtures/site-layout-recordings.js +24 -5
  79. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  80. package/src/lib/site-import/site-import-crawl.d.ts +3 -1
  81. package/src/lib/site-import/site-import-crawl.js +8 -3
  82. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  83. package/src/lib/site-import/site-import-css.d.ts +20 -0
  84. package/src/lib/site-import/site-import-css.js +106 -0
  85. package/src/lib/site-import/site-import-css.js.map +1 -1
  86. package/src/lib/site-import/site-import-html.d.ts +39 -0
  87. package/src/lib/site-import/site-import-html.js +515 -5
  88. package/src/lib/site-import/site-import-html.js.map +1 -1
  89. package/src/lib/site-import/site-import-layout.d.ts +16 -6
  90. package/src/lib/site-import/site-import-layout.js +528 -52
  91. package/src/lib/site-import/site-import-layout.js.map +1 -1
  92. package/src/lib/site-import/site-import-nav.js +286 -24
  93. package/src/lib/site-import/site-import-nav.js.map +1 -1
  94. package/src/lib/site-import/site-import-page.js +3 -0
  95. package/src/lib/site-import/site-import-page.js.map +1 -1
  96. package/src/lib/usage/assist-credits.d.ts +5 -4
  97. package/src/lib/usage/assist-credits.js +5 -4
  98. package/src/lib/usage/assist-credits.js.map +1 -1
  99. package/src/lib/usage/staff-org-ai-view.js +6 -6
  100. package/src/lib/usage/staff-org-ai-view.js.map +1 -1
  101. package/src/lib/usage/staff-org-ai.d.ts +4 -4
  102. package/src/lib/usage/staff-org-ai.js +8 -7
  103. package/src/lib/usage/staff-org-ai.js.map +1 -1
  104. package/src/lib/usage/staff-org-usage-ai.js +2 -2
  105. package/src/lib/usage/staff-org-usage-ai.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-ai",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
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.7.0",
29
- "@aglyn/shared-data-enums": "1.7.0",
30
- "@aglyn/shared-data-mdi": "1.7.0",
31
- "@aglyn/shared-data-types": "1.7.0",
32
- "@aglyn/shared-ui-email-campaigns": "1.7.0",
33
- "@aglyn/shared-ui-jsx": "1.7.0",
34
- "@aglyn/shared-ui-snackstack": "1.7.0",
35
- "@aglyn/shared-ui-theme": "1.7.0",
36
- "@aglyn/shared-util-email": "1.7.0",
37
- "@aglyn/shared-util-errors": "1.7.0",
38
- "@aglyn/shared-util-http": "1.7.0",
39
- "@aglyn/shared-util-timestamp": "1.7.0",
40
- "@aglyn/shared-util-tools": "1.7.0",
41
- "@aglyn/tenant-data-admin": "1.7.0",
42
- "@aglyn/tenant-feature-instance": "1.7.0",
43
- "@aglyn/tenant-runtime": "1.7.0",
28
+ "@aglyn/aglyn": "1.9.0",
29
+ "@aglyn/shared-data-enums": "1.9.0",
30
+ "@aglyn/shared-data-mdi": "1.9.0",
31
+ "@aglyn/shared-data-types": "1.9.0",
32
+ "@aglyn/shared-ui-email-campaigns": "1.9.0",
33
+ "@aglyn/shared-ui-jsx": "1.9.0",
34
+ "@aglyn/shared-ui-snackstack": "1.9.0",
35
+ "@aglyn/shared-ui-theme": "1.9.0",
36
+ "@aglyn/shared-util-email": "1.9.0",
37
+ "@aglyn/shared-util-errors": "1.9.0",
38
+ "@aglyn/shared-util-http": "1.9.0",
39
+ "@aglyn/shared-util-timestamp": "1.9.0",
40
+ "@aglyn/shared-util-tools": "1.9.0",
41
+ "@aglyn/tenant-data-admin": "1.9.0",
42
+ "@aglyn/tenant-feature-instance": "1.9.0",
43
+ "@aglyn/tenant-runtime": "1.9.0",
44
44
  "@swc/helpers": "0.5.23"
45
45
  },
46
46
  "peerDependencies": {
@@ -241,9 +241,11 @@ const usd = (value)=>`$${value.toLocaleString('en-US')}`;
241
241
  const before = aiAddonUnits(change.before);
242
242
  const after = aiAddonUnits(change.after);
243
243
  if (before === after) return false;
244
- await logOrgActivity(orgId, actor, after === 1 ? AI_ACTIVITY_ACTIONS.addonPurchased : AI_ACTIVITY_ACTIONS.addonRemoved, {
244
+ // Credit blocks are a quantity (AGL-4144): more blocks is a purchase, fewer
245
+ // a removal, and the row names the count it moved between.
246
+ await logOrgActivity(orgId, actor, after > before ? AI_ACTIVITY_ACTIONS.addonPurchased : AI_ACTIVITY_ACTIONS.addonRemoved, {
245
247
  type: 'subscription',
246
- name: aiAddonName()
248
+ name: `${aiAddonName()} credits (${before} → ${after} blocks)`
247
249
  });
248
250
  return true;
249
251
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/activity/ai-activity.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 writers over the two customer-visible activity logs (AGL-2929).\n *\n * Every generation, applied edit and control change lands in\n * `orgs/{orgId}/activity` (and, for a host-scoped output, in\n * `hosts/{hostId}/activity`) through {@link logOrgActivity} and\n * {@link logHostActivity} — never a collection of its own, so the retention\n * `docs/DATA_RETENTION.md` already promises for the activity logs covers\n * these rows without a new entry, and the one permission-gated route that\n * serves the org feed serves them.\n *\n * Each helper owns ONE action code from `AI_ACTIVITY_ACTIONS` and the shape\n * of its target, so a caller cannot store a code the viewers do not know or\n * a target the presenter cannot label. What varies per row is folded into\n * `target.name`, which is the only free text the row carries: the feed reads\n * `<label> — <name>`, and a name like `screen · 240-character brief · Acme`\n * is what makes two jobs distinguishable in a list of them.\n *\n * Attribution follows `logOrgActivity`'s rule: `uid` is nullable because\n * some of these acts HAVE no actor — a job paused by the band with nobody\n * present, an add-on Stripe removed at the period end — and naming the last\n * person who touched the thing would file an act under someone who did not\n * perform it. A caller passes what it verified and nothing more.\n *\n * The control-change writers answer whether a row was written: a control set\n * to the value it already had is not a change, and a feed that said \"AI\n * overage ceiling — $25\" twice for one decision would read as two decisions.\n */\n\nimport type { HostActivityActor } from '@aglyn/aglyn/app-utils/activity-presenter'\nimport {\n AI_ACTIVITY_ACTIONS,\n AI_JOB_NEEDS_INPUT_REASON_LABELS,\n type AiJobNeedsInputReason,\n} from './ai-activity-actions'\nimport {\n aiAddonName,\n aiAddonUnits,\n} from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport type { OrgSeatAddons } from '@aglyn/aglyn/server'\nimport {\n logHostActivity,\n logOrgActivity,\n type HostActivityTarget,\n type OrgActivityTarget,\n} from '@aglyn/tenant-data-admin/server/organizations'\n\n/** Who performed the act — `uid: null` when nobody was present. */\nexport interface AiActivityActor {\n uid: string | null\n email?: string | null\n}\n\n/** The resource kinds a generation job can produce. */\nexport type AiOutputResourceType = Extract<\n OrgActivityTarget['type'],\n HostActivityTarget['type']\n>\n\n/** The pieces a target name is built from, blanks dropped. */\nconst named = (...parts: Array<string | number | null | undefined>): string =>\n parts\n .map((part) => (part === null || part === undefined ? '' : String(part).trim()))\n .filter(Boolean)\n .join(' · ')\n\n/** A verified uid, or nothing: the host log has no anonymous actor. */\nconst hostActor = (actor: AiActivityActor): HostActivityActor | null =>\n actor.uid ? { uid: actor.uid, email: actor.email ?? null } : null\n\n/**\n * `ai.job.created` — a generation job was briefed (AGL-2904).\n *\n * Names the job's kind, how long the brief was and the site it targets, so\n * the row says what was asked for without storing the brief itself.\n */\nexport async function logAiJobCreated(\n orgId: string,\n actor: AiActivityActor,\n job: {\n jobId: string\n /** What the job builds — a screen, a site, a section. */\n kind: string\n briefLength: number\n hostId?: string | null\n hostName?: string | null\n },\n): Promise<void> {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.jobCreated, {\n type: 'aiJob',\n id: job.jobId,\n name: named(\n job.kind,\n `${Math.max(0, Math.floor(job.briefLength))}-character brief`,\n job.hostName ?? job.hostId,\n ),\n })\n}\n\n/**\n * `ai.job.output` — one resource a job produced, one row per output.\n *\n * The org row names the resource, and a host-scoped output is copied into\n * the site's own feed so a site's activity shows what was generated on it.\n * The copy needs a uid: the host log's contract has no anonymous actor, so a\n * job that finished with nobody present still lands in the org feed and\n * only there.\n */\nexport async function logAiJobOutput(\n orgId: string,\n actor: AiActivityActor,\n output: {\n jobId: string\n hostId?: string | null\n resource: {\n type: AiOutputResourceType\n id: string\n name?: string | null\n versionId?: string | null\n }\n },\n): Promise<void> {\n const target = {\n type: output.resource.type,\n id: output.resource.id,\n ...(output.resource.name ? { name: output.resource.name } : {}),\n ...(output.resource.versionId ? { versionId: output.resource.versionId } : {}),\n }\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.jobOutput, target)\n const onHost = hostActor(actor)\n if (output.hostId && onHost) {\n await logHostActivity(output.hostId, onHost, AI_ACTIVITY_ACTIONS.jobOutput, target)\n }\n}\n\n/** `ai.job.canceled` — a job was stopped before it finished. */\nexport async function logAiJobCanceled(\n orgId: string,\n actor: AiActivityActor,\n job: { jobId: string; kind?: string | null; name?: string | null },\n): Promise<void> {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.jobCanceled, {\n type: 'aiJob',\n id: job.jobId,\n ...(named(job.kind, job.name) ? { name: named(job.kind, job.name) } : {}),\n })\n}\n\n/**\n * `ai.job.needs_input` — a job stopped and asked for a person, and why.\n * Usually actorless: the band, the ceiling or the budget stopped it, not a\n * member.\n */\nexport async function logAiJobNeedsInput(\n orgId: string,\n actor: AiActivityActor,\n job: { jobId: string; kind?: string | null; reason: AiJobNeedsInputReason },\n): Promise<void> {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.jobNeedsInput, {\n type: 'aiJob',\n id: job.jobId,\n name: named(job.kind, AI_JOB_NEEDS_INPUT_REASON_LABELS[job.reason]),\n })\n}\n\n/**\n * `ai.edit.applied` — a proposal's edits landed on a besigner document\n * (AGL-2906).\n *\n * The edits are applied in the author's own editor, as unsaved changes, so\n * no server sees them land. The row is written by the door the editor\n * reports the apply to, and only once that door has found the proposal on an\n * exchange the same member had about the same document — so it stands on a\n * proposal the server issued rather than on the client's word alone. Op\n * counts are folded into the name (`Home · 3 set, 1 insert`); the edits\n * themselves are the site's content and are not logged.\n */\nexport async function logAiEditApplied(\n hostId: string,\n actor: HostActivityActor,\n edit: {\n /** The kind of document the edits landed on. */\n type: 'screen' | 'component' | 'layout'\n id: string\n name?: string | null\n versionId: string\n /** Edits applied, by operation — `{ set: 3, insert: 1 }`. */\n opCounts: Record<string, number>\n },\n): Promise<void> {\n const counts = Object.entries(edit.opCounts)\n .filter(([, count]) => Number.isFinite(count) && count > 0)\n .map(([op, count]) => `${Math.floor(count)} ${op}`)\n .join(', ')\n await logHostActivity(hostId, actor, AI_ACTIVITY_ACTIONS.editApplied, {\n type: edit.type,\n id: edit.id,\n name: named(edit.name, counts),\n versionId: edit.versionId,\n })\n}\n\n/**\n * `ai.seo.applied` — a site audit's fixes were applied as drafts (AGL-2910).\n *\n * Written by the door that applied them. The name carries the counts — new\n * unpublished versions, listings staged for a person to save — and never\n * the text proposed, which is the site's content. Org feed, and the site's\n * own feed when a person is named.\n */\nexport async function logAiSeoApplied(\n orgId: string,\n actor: AiActivityActor,\n apply: {\n jobId: string\n hostId: string\n hostName?: string | null\n versions: number\n staged: number\n },\n): Promise<void> {\n const versions = Math.max(0, Math.floor(apply.versions))\n const staged = Math.max(0, Math.floor(apply.staged))\n const target = {\n type: 'aiJob' as const,\n id: apply.jobId,\n name: named(\n apply.hostName ?? apply.hostId,\n `${versions} draft ${versions === 1 ? 'version' : 'versions'}`,\n `${staged} ${staged === 1 ? 'listing' : 'listings'} to review`,\n ),\n }\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.seoApplied, target)\n const onHost = hostActor(actor)\n if (onHost) {\n await logHostActivity(apply.hostId, onHost, AI_ACTIVITY_ACTIONS.seoApplied, {\n type: 'host',\n id: apply.hostId,\n name: target.name,\n })\n }\n}\n\n/**\n * `ai.assist.section` — the assist door returned a section subtree.\n *\n * Into the site's feed when the request named a site, else the org's, so\n * the act is never unlogged for want of a host. Element rewrites are not\n * logged here at all — too chatty — and the per-user rollup carries their\n * count. The instruction is the customer's own copy and is not stored.\n */\nexport async function logAiAssistSection(\n actor: AiActivityActor,\n section: {\n orgId: string\n hostId?: string | null\n hostName?: string | null\n nodeCount: number\n },\n): Promise<void> {\n const nodes = Math.max(0, Math.floor(section.nodeCount))\n const size = `${nodes} ${nodes === 1 ? 'element' : 'elements'}`\n const onHost = hostActor(actor)\n if (section.hostId && onHost) {\n await logHostActivity(section.hostId, onHost, AI_ACTIVITY_ACTIONS.assistSection, {\n type: 'host',\n id: section.hostId,\n name: named(section.hostName, size),\n })\n return\n }\n await logOrgActivity(section.orgId, actor, AI_ACTIVITY_ACTIONS.assistSection, {\n type: 'org',\n name: named(section.hostName ?? section.hostId, size),\n })\n}\n\n/** The two overage controls a customer holds (AGL-2653, AGL-2898). */\nexport type AiOverageControlChange =\n | { control: 'hardCap'; before: boolean; after: boolean }\n | { control: 'cap'; before: number | null; after: number | null }\n\nconst usd = (value: number): string => `$${value.toLocaleString('en-US')}`\n\n/**\n * `ai.overage.hardCap` / `ai.overage.cap` — a control moved.\n *\n * The routes already write `adminAudit`; this is the org-feed row that\n * lets the customer see who set the control. Answers `false`, and writes\n * nothing, when the value did not move.\n */\nexport async function logAiOverageControl(\n orgId: string,\n actor: AiActivityActor,\n change: AiOverageControlChange,\n): Promise<boolean> {\n if (change.before === change.after) return false\n if (change.control === 'hardCap') {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.overageHardCap, {\n type: 'org',\n name: change.after ? 'On' : 'Off',\n })\n return true\n }\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.overageCap, {\n type: 'org',\n name: change.after === null ? 'Cleared' : usd(change.after),\n })\n return true\n}\n\n/**\n * `ai.allotment.changed` — a manager set, changed or removed an AI allotment\n * (AGL-2942): a member's, a collaborator's on one site, a site's, or the\n * org-wide model restriction. The subject is the row's target; what it was\n * set to is the name, in credits, never dollars.\n */\nexport async function logAiAllotmentChanged(\n orgId: string,\n actor: AiActivityActor,\n change: {\n subject: {\n type: 'org' | 'member' | 'host'\n id?: string | null\n name?: string | null\n }\n /** `null` when the allotment was removed. */\n after: {\n credits: number | null\n mode: 'hard' | 'soft'\n models: readonly string[] | null\n } | null\n },\n): Promise<void> {\n const after = change.after\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.allotmentChanged, {\n type: change.subject.type,\n ...(change.subject.id ? { id: change.subject.id } : {}),\n name: named(\n change.subject.name,\n after === null\n ? 'removed'\n : after.credits === null\n ? null\n : `${after.credits.toLocaleString('en-US')} credits a month (${after.mode})`,\n after?.models?.length ? `${after.models.length} models allowed` : null,\n ),\n })\n}\n\n/**\n * `ai.permission.changed` — an AI permission moved on a role, a member's\n * override, a collaborator's site toggle or the org's default. The subject\n * is the row's target; the permission and its direction are the name.\n */\nexport async function logAiPermissionChanged(\n orgId: string,\n actor: AiActivityActor,\n change: {\n subject: {\n type: 'org' | 'role' | 'member' | 'host'\n id?: string | null\n name?: string | null\n }\n /** The permission key that moved — `ai.assist`, `ai.generate`. */\n permission: string\n granted: boolean\n },\n): Promise<void> {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.permissionChanged, {\n type: change.subject.type,\n ...(change.subject.id ? { id: change.subject.id } : {}),\n name: named(\n change.subject.name,\n `${change.permission} ${change.granted ? 'granted' : 'revoked'}`,\n ),\n })\n}\n\n/**\n * `ai.addon.purchased` / `ai.addon.removed` — the AI add-on came or went.\n *\n * Decided off the mirrored `seatAddons` maps rather than told, because the\n * add-ons route mirrors the purchase at once and the webhook re-derives the\n * same map on every subscription event: comparing before and after is what\n * keeps a redelivery, or the webhook confirming a purchase the route already\n * logged, from writing the row twice. Answers `false` when nothing moved.\n */\nexport async function logAiAddonChanged(\n orgId: string,\n actor: AiActivityActor,\n change: {\n before: OrgSeatAddons | null | undefined\n after: OrgSeatAddons | null | undefined\n },\n): Promise<boolean> {\n const before = aiAddonUnits(change.before)\n const after = aiAddonUnits(change.after)\n if (before === after) return false\n await logOrgActivity(\n orgId,\n actor,\n after === 1 ? AI_ACTIVITY_ACTIONS.addonPurchased : AI_ACTIVITY_ACTIONS.addonRemoved,\n { type: 'subscription', name: aiAddonName() },\n )\n return true\n}\n"],"names":["AI_ACTIVITY_ACTIONS","AI_JOB_NEEDS_INPUT_REASON_LABELS","aiAddonName","aiAddonUnits","logHostActivity","logOrgActivity","named","parts","map","part","undefined","String","trim","filter","Boolean","join","hostActor","actor","uid","email","logAiJobCreated","orgId","job","jobCreated","type","id","jobId","name","kind","Math","max","floor","briefLength","hostName","hostId","logAiJobOutput","output","target","resource","versionId","jobOutput","onHost","logAiJobCanceled","jobCanceled","logAiJobNeedsInput","jobNeedsInput","reason","logAiEditApplied","edit","counts","Object","entries","opCounts","count","Number","isFinite","op","editApplied","logAiSeoApplied","apply","versions","staged","seoApplied","logAiAssistSection","section","nodes","nodeCount","size","assistSection","usd","value","toLocaleString","logAiOverageControl","change","before","after","control","overageHardCap","overageCap","logAiAllotmentChanged","allotmentChanged","subject","credits","mode","models","length","logAiPermissionChanged","permissionChanged","permission","granted","logAiAddonChanged","addonPurchased","addonRemoved"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC;AAGD,SACEA,mBAAmB,EACnBC,gCAAgC,QAE3B,2BAAuB;AAC9B,SACEC,WAAW,EACXC,YAAY,QACP,2CAA0C;AAEjD,SACEC,eAAe,EACfC,cAAc,QAGT,gDAA+C;AActD,4DAA4D,GAC5D,MAAMC,QAAQ,CAAC,GAAGC,QAChBA,MACGC,GAAG,CAAC,CAACC,OAAUA,SAAS,QAAQA,SAASC,YAAY,KAAKC,OAAOF,MAAMG,IAAI,IAC3EC,MAAM,CAACC,SACPC,IAAI,CAAC;AAEV,qEAAqE,GACrE,MAAMC,YAAY,CAACC;QACoBA;WAArCA,MAAMC,GAAG,GAAG;QAAEA,KAAKD,MAAMC,GAAG;QAAEC,KAAK,GAAEF,eAAAA,MAAME,KAAK,YAAXF,eAAe;IAAK,IAAI;;AAE/D;;;;;CAKC,GACD,OAAO,eAAeG,gBACpBC,KAAa,EACbJ,KAAsB,EACtBK,GAOC;QAQGA;IANJ,MAAMjB,eAAegB,OAAOJ,OAAOjB,oBAAoBuB,UAAU,EAAE;QACjEC,MAAM;QACNC,IAAIH,IAAII,KAAK;QACbC,MAAMrB,MACJgB,IAAIM,IAAI,EACR,GAAGC,KAAKC,GAAG,CAAC,GAAGD,KAAKE,KAAK,CAACT,IAAIU,WAAW,GAAG,gBAAgB,CAAC,GAC7DV,gBAAAA,IAAIW,QAAQ,YAAZX,gBAAgBA,IAAIY,MAAM;IAE9B;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeC,eACpBd,KAAa,EACbJ,KAAsB,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E,aAAasE,OAAOC,MAAM;IACzC,MAAMC,QAAQxE,aAAasE,OAAOE,KAAK;IACvC,IAAID,WAAWC,OAAO,OAAO;IAC7B,MAAMtE,eACJgB,OACAJ,OACA0D,UAAU,IAAI3E,oBAAoB2F,cAAc,GAAG3F,oBAAoB4F,YAAY,EACnF;QAAEpE,MAAM;QAAgBG,MAAMzB;IAAc;IAE9C,OAAO;AACT"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/activity/ai-activity.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 writers over the two customer-visible activity logs (AGL-2929).\n *\n * Every generation, applied edit and control change lands in\n * `orgs/{orgId}/activity` (and, for a host-scoped output, in\n * `hosts/{hostId}/activity`) through {@link logOrgActivity} and\n * {@link logHostActivity} — never a collection of its own, so the retention\n * `docs/DATA_RETENTION.md` already promises for the activity logs covers\n * these rows without a new entry, and the one permission-gated route that\n * serves the org feed serves them.\n *\n * Each helper owns ONE action code from `AI_ACTIVITY_ACTIONS` and the shape\n * of its target, so a caller cannot store a code the viewers do not know or\n * a target the presenter cannot label. What varies per row is folded into\n * `target.name`, which is the only free text the row carries: the feed reads\n * `<label> — <name>`, and a name like `screen · 240-character brief · Acme`\n * is what makes two jobs distinguishable in a list of them.\n *\n * Attribution follows `logOrgActivity`'s rule: `uid` is nullable because\n * some of these acts HAVE no actor — a job paused by the band with nobody\n * present, an add-on Stripe removed at the period end — and naming the last\n * person who touched the thing would file an act under someone who did not\n * perform it. A caller passes what it verified and nothing more.\n *\n * The control-change writers answer whether a row was written: a control set\n * to the value it already had is not a change, and a feed that said \"AI\n * overage ceiling — $25\" twice for one decision would read as two decisions.\n */\n\nimport type { HostActivityActor } from '@aglyn/aglyn/app-utils/activity-presenter'\nimport {\n AI_ACTIVITY_ACTIONS,\n AI_JOB_NEEDS_INPUT_REASON_LABELS,\n type AiJobNeedsInputReason,\n} from './ai-activity-actions'\nimport {\n aiAddonName,\n aiAddonUnits,\n} from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport type { OrgSeatAddons } from '@aglyn/aglyn/server'\nimport {\n logHostActivity,\n logOrgActivity,\n type HostActivityTarget,\n type OrgActivityTarget,\n} from '@aglyn/tenant-data-admin/server/organizations'\n\n/** Who performed the act — `uid: null` when nobody was present. */\nexport interface AiActivityActor {\n uid: string | null\n email?: string | null\n}\n\n/** The resource kinds a generation job can produce. */\nexport type AiOutputResourceType = Extract<\n OrgActivityTarget['type'],\n HostActivityTarget['type']\n>\n\n/** The pieces a target name is built from, blanks dropped. */\nconst named = (...parts: Array<string | number | null | undefined>): string =>\n parts\n .map((part) => (part === null || part === undefined ? '' : String(part).trim()))\n .filter(Boolean)\n .join(' · ')\n\n/** A verified uid, or nothing: the host log has no anonymous actor. */\nconst hostActor = (actor: AiActivityActor): HostActivityActor | null =>\n actor.uid ? { uid: actor.uid, email: actor.email ?? null } : null\n\n/**\n * `ai.job.created` — a generation job was briefed (AGL-2904).\n *\n * Names the job's kind, how long the brief was and the site it targets, so\n * the row says what was asked for without storing the brief itself.\n */\nexport async function logAiJobCreated(\n orgId: string,\n actor: AiActivityActor,\n job: {\n jobId: string\n /** What the job builds — a screen, a site, a section. */\n kind: string\n briefLength: number\n hostId?: string | null\n hostName?: string | null\n },\n): Promise<void> {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.jobCreated, {\n type: 'aiJob',\n id: job.jobId,\n name: named(\n job.kind,\n `${Math.max(0, Math.floor(job.briefLength))}-character brief`,\n job.hostName ?? job.hostId,\n ),\n })\n}\n\n/**\n * `ai.job.output` — one resource a job produced, one row per output.\n *\n * The org row names the resource, and a host-scoped output is copied into\n * the site's own feed so a site's activity shows what was generated on it.\n * The copy needs a uid: the host log's contract has no anonymous actor, so a\n * job that finished with nobody present still lands in the org feed and\n * only there.\n */\nexport async function logAiJobOutput(\n orgId: string,\n actor: AiActivityActor,\n output: {\n jobId: string\n hostId?: string | null\n resource: {\n type: AiOutputResourceType\n id: string\n name?: string | null\n versionId?: string | null\n }\n },\n): Promise<void> {\n const target = {\n type: output.resource.type,\n id: output.resource.id,\n ...(output.resource.name ? { name: output.resource.name } : {}),\n ...(output.resource.versionId ? { versionId: output.resource.versionId } : {}),\n }\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.jobOutput, target)\n const onHost = hostActor(actor)\n if (output.hostId && onHost) {\n await logHostActivity(output.hostId, onHost, AI_ACTIVITY_ACTIONS.jobOutput, target)\n }\n}\n\n/** `ai.job.canceled` — a job was stopped before it finished. */\nexport async function logAiJobCanceled(\n orgId: string,\n actor: AiActivityActor,\n job: { jobId: string; kind?: string | null; name?: string | null },\n): Promise<void> {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.jobCanceled, {\n type: 'aiJob',\n id: job.jobId,\n ...(named(job.kind, job.name) ? { name: named(job.kind, job.name) } : {}),\n })\n}\n\n/**\n * `ai.job.needs_input` — a job stopped and asked for a person, and why.\n * Usually actorless: the band, the ceiling or the budget stopped it, not a\n * member.\n */\nexport async function logAiJobNeedsInput(\n orgId: string,\n actor: AiActivityActor,\n job: { jobId: string; kind?: string | null; reason: AiJobNeedsInputReason },\n): Promise<void> {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.jobNeedsInput, {\n type: 'aiJob',\n id: job.jobId,\n name: named(job.kind, AI_JOB_NEEDS_INPUT_REASON_LABELS[job.reason]),\n })\n}\n\n/**\n * `ai.edit.applied` — a proposal's edits landed on a besigner document\n * (AGL-2906).\n *\n * The edits are applied in the author's own editor, as unsaved changes, so\n * no server sees them land. The row is written by the door the editor\n * reports the apply to, and only once that door has found the proposal on an\n * exchange the same member had about the same document — so it stands on a\n * proposal the server issued rather than on the client's word alone. Op\n * counts are folded into the name (`Home · 3 set, 1 insert`); the edits\n * themselves are the site's content and are not logged.\n */\nexport async function logAiEditApplied(\n hostId: string,\n actor: HostActivityActor,\n edit: {\n /** The kind of document the edits landed on. */\n type: 'screen' | 'component' | 'layout'\n id: string\n name?: string | null\n versionId: string\n /** Edits applied, by operation — `{ set: 3, insert: 1 }`. */\n opCounts: Record<string, number>\n },\n): Promise<void> {\n const counts = Object.entries(edit.opCounts)\n .filter(([, count]) => Number.isFinite(count) && count > 0)\n .map(([op, count]) => `${Math.floor(count)} ${op}`)\n .join(', ')\n await logHostActivity(hostId, actor, AI_ACTIVITY_ACTIONS.editApplied, {\n type: edit.type,\n id: edit.id,\n name: named(edit.name, counts),\n versionId: edit.versionId,\n })\n}\n\n/**\n * `ai.seo.applied` — a site audit's fixes were applied as drafts (AGL-2910).\n *\n * Written by the door that applied them. The name carries the counts — new\n * unpublished versions, listings staged for a person to save — and never\n * the text proposed, which is the site's content. Org feed, and the site's\n * own feed when a person is named.\n */\nexport async function logAiSeoApplied(\n orgId: string,\n actor: AiActivityActor,\n apply: {\n jobId: string\n hostId: string\n hostName?: string | null\n versions: number\n staged: number\n },\n): Promise<void> {\n const versions = Math.max(0, Math.floor(apply.versions))\n const staged = Math.max(0, Math.floor(apply.staged))\n const target = {\n type: 'aiJob' as const,\n id: apply.jobId,\n name: named(\n apply.hostName ?? apply.hostId,\n `${versions} draft ${versions === 1 ? 'version' : 'versions'}`,\n `${staged} ${staged === 1 ? 'listing' : 'listings'} to review`,\n ),\n }\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.seoApplied, target)\n const onHost = hostActor(actor)\n if (onHost) {\n await logHostActivity(apply.hostId, onHost, AI_ACTIVITY_ACTIONS.seoApplied, {\n type: 'host',\n id: apply.hostId,\n name: target.name,\n })\n }\n}\n\n/**\n * `ai.assist.section` — the assist door returned a section subtree.\n *\n * Into the site's feed when the request named a site, else the org's, so\n * the act is never unlogged for want of a host. Element rewrites are not\n * logged here at all — too chatty — and the per-user rollup carries their\n * count. The instruction is the customer's own copy and is not stored.\n */\nexport async function logAiAssistSection(\n actor: AiActivityActor,\n section: {\n orgId: string\n hostId?: string | null\n hostName?: string | null\n nodeCount: number\n },\n): Promise<void> {\n const nodes = Math.max(0, Math.floor(section.nodeCount))\n const size = `${nodes} ${nodes === 1 ? 'element' : 'elements'}`\n const onHost = hostActor(actor)\n if (section.hostId && onHost) {\n await logHostActivity(section.hostId, onHost, AI_ACTIVITY_ACTIONS.assistSection, {\n type: 'host',\n id: section.hostId,\n name: named(section.hostName, size),\n })\n return\n }\n await logOrgActivity(section.orgId, actor, AI_ACTIVITY_ACTIONS.assistSection, {\n type: 'org',\n name: named(section.hostName ?? section.hostId, size),\n })\n}\n\n/** The two overage controls a customer holds (AGL-2653, AGL-2898). */\nexport type AiOverageControlChange =\n | { control: 'hardCap'; before: boolean; after: boolean }\n | { control: 'cap'; before: number | null; after: number | null }\n\nconst usd = (value: number): string => `$${value.toLocaleString('en-US')}`\n\n/**\n * `ai.overage.hardCap` / `ai.overage.cap` — a control moved.\n *\n * The routes already write `adminAudit`; this is the org-feed row that\n * lets the customer see who set the control. Answers `false`, and writes\n * nothing, when the value did not move.\n */\nexport async function logAiOverageControl(\n orgId: string,\n actor: AiActivityActor,\n change: AiOverageControlChange,\n): Promise<boolean> {\n if (change.before === change.after) return false\n if (change.control === 'hardCap') {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.overageHardCap, {\n type: 'org',\n name: change.after ? 'On' : 'Off',\n })\n return true\n }\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.overageCap, {\n type: 'org',\n name: change.after === null ? 'Cleared' : usd(change.after),\n })\n return true\n}\n\n/**\n * `ai.allotment.changed` — a manager set, changed or removed an AI allotment\n * (AGL-2942): a member's, a collaborator's on one site, a site's, or the\n * org-wide model restriction. The subject is the row's target; what it was\n * set to is the name, in credits, never dollars.\n */\nexport async function logAiAllotmentChanged(\n orgId: string,\n actor: AiActivityActor,\n change: {\n subject: {\n type: 'org' | 'member' | 'host'\n id?: string | null\n name?: string | null\n }\n /** `null` when the allotment was removed. */\n after: {\n credits: number | null\n mode: 'hard' | 'soft'\n models: readonly string[] | null\n } | null\n },\n): Promise<void> {\n const after = change.after\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.allotmentChanged, {\n type: change.subject.type,\n ...(change.subject.id ? { id: change.subject.id } : {}),\n name: named(\n change.subject.name,\n after === null\n ? 'removed'\n : after.credits === null\n ? null\n : `${after.credits.toLocaleString('en-US')} credits a month (${after.mode})`,\n after?.models?.length ? `${after.models.length} models allowed` : null,\n ),\n })\n}\n\n/**\n * `ai.permission.changed` — an AI permission moved on a role, a member's\n * override, a collaborator's site toggle or the org's default. The subject\n * is the row's target; the permission and its direction are the name.\n */\nexport async function logAiPermissionChanged(\n orgId: string,\n actor: AiActivityActor,\n change: {\n subject: {\n type: 'org' | 'role' | 'member' | 'host'\n id?: string | null\n name?: string | null\n }\n /** The permission key that moved — `ai.assist`, `ai.generate`. */\n permission: string\n granted: boolean\n },\n): Promise<void> {\n await logOrgActivity(orgId, actor, AI_ACTIVITY_ACTIONS.permissionChanged, {\n type: change.subject.type,\n ...(change.subject.id ? { id: change.subject.id } : {}),\n name: named(\n change.subject.name,\n `${change.permission} ${change.granted ? 'granted' : 'revoked'}`,\n ),\n })\n}\n\n/**\n * `ai.addon.purchased` / `ai.addon.removed` — the AI add-on came or went.\n *\n * Decided off the mirrored `seatAddons` maps rather than told, because the\n * add-ons route mirrors the purchase at once and the webhook re-derives the\n * same map on every subscription event: comparing before and after is what\n * keeps a redelivery, or the webhook confirming a purchase the route already\n * logged, from writing the row twice. Answers `false` when nothing moved.\n */\nexport async function logAiAddonChanged(\n orgId: string,\n actor: AiActivityActor,\n change: {\n before: OrgSeatAddons | null | undefined\n after: OrgSeatAddons | null | undefined\n },\n): Promise<boolean> {\n const before = aiAddonUnits(change.before)\n const after = aiAddonUnits(change.after)\n if (before === after) return false\n // Credit blocks are a quantity (AGL-4144): more blocks is a purchase, fewer\n // a removal, and the row names the count it moved between.\n await logOrgActivity(\n orgId,\n actor,\n after > before ? AI_ACTIVITY_ACTIONS.addonPurchased : AI_ACTIVITY_ACTIONS.addonRemoved,\n { type: 'subscription', name: `${aiAddonName()} credits (${before} → ${after} blocks)` },\n )\n return true\n}\n"],"names":["AI_ACTIVITY_ACTIONS","AI_JOB_NEEDS_INPUT_REASON_LABELS","aiAddonName","aiAddonUnits","logHostActivity","logOrgActivity","named","parts","map","part","undefined","String","trim","filter","Boolean","join","hostActor","actor","uid","email","logAiJobCreated","orgId","job","jobCreated","type","id","jobId","name","kind","Math","max","floor","briefLength","hostName","hostId","logAiJobOutput","output","target","resource","versionId","jobOutput","onHost","logAiJobCanceled","jobCanceled","logAiJobNeedsInput","jobNeedsInput","reason","logAiEditApplied","edit","counts","Object","entries","opCounts","count","Number","isFinite","op","editApplied","logAiSeoApplied","apply","versions","staged","seoApplied","logAiAssistSection","section","nodes","nodeCount","size","assistSection","usd","value","toLocaleString","logAiOverageControl","change","before","after","control","overageHardCap","overageCap","logAiAllotmentChanged","allotmentChanged","subject","credits","mode","models","length","logAiPermissionChanged","permissionChanged","permission","granted","logAiAddonChanged","addonPurchased","addonRemoved"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC;AAGD,SACEA,mBAAmB,EACnBC,gCAAgC,QAE3B,2BAAuB;AAC9B,SACEC,WAAW,EACXC,YAAY,QACP,2CAA0C;AAEjD,SACEC,eAAe,EACfC,cAAc,QAGT,gDAA+C;AActD,4DAA4D,GAC5D,MAAMC,QAAQ,CAAC,GAAGC,QAChBA,MACGC,GAAG,CAAC,CAACC,OAAUA,SAAS,QAAQA,SAASC,YAAY,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AI,CAAC,CAAC,CAAC,EAChFR,CAAAA,0BAAAA,gBAAAA,MAAOS,MAAM,qBAAbT,cAAeU,MAAM,IAAG,GAAGV,MAAMS,MAAM,CAACC,MAAM,CAAC,eAAe,CAAC,GAAG;;AAGxE;AAEA;;;;CAIC,GACD,OAAO,eAAeC,uBACpBjE,KAAa,EACbJ,KAAsB,EACtBwD,MASC;IAED,MAAMpE,eAAegB,OAAOJ,OAAOjB,oBAAoBuF,iBAAiB,EAAE;QACxE/D,MAAMiD,OAAOQ,OAAO,CAACzD,IAAI;OACrBiD,OAAOQ,OAAO,CAACxD,EAAE,GAAG;QAAEA,IAAIgD,OAAOQ,OAAO,CAACxD,EAAE;IAAC,IAAI,CAAC;QACrDE,MAAMrB,MACJmE,OAAOQ,OAAO,CAACtD,IAAI,EACnB,GAAG8C,OAAOe,UAAU,CAAC,CAAC,EAAEf,OAAOgB,OAAO,GAAG,YAAY,WAAW;;AAGtE;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeC,kBACpBrE,KAAa,EACbJ,KAAsB,EACtBwD,MAGC;IAED,MAAMC,SAASvE,aAAasE,OAAOC,MAAM;IACzC,MAAMC,QAAQxE,aAAasE,OAAOE,KAAK;IACvC,IAAID,WAAWC,OAAO,OAAO;IAC7B,4EAA4E;IAC5E,2DAA2D;IAC3D,MAAMtE,eACJgB,OACAJ,OACA0D,QAAQD,SAAS1E,oBAAoB2F,cAAc,GAAG3F,oBAAoB4F,YAAY,EACtF;QAAEpE,MAAM;QAAgBG,MAAM,GAAGzB,cAAc,UAAU,EAAEwE,OAAO,GAAG,EAAEC,MAAM,QAAQ,CAAC;IAAC;IAEzF,OAAO;AACT"}
@@ -24,9 +24,10 @@ export interface AiCreditsCardProps {
24
24
  * but says the plan has no credits and links to Billing (AGL-3982), since a
25
25
  * missing card reads as AI not existing here. ONE meter for one pool: the
26
26
  * plan's included credits pay for every AI action, generation included
27
- * (AGL-3965), and an Aglyn AI tier widens `assistCreditsPerMonth` rather than
28
- * opening a second band, so the limit here is already plan plus tier and the
29
- * caption under it says how much of that the tier is.
27
+ * (AGL-3965), and Aglyn AI credit blocks (AGL-4144) widen
28
+ * `assistCreditsPerMonth` rather than opening a second band, so the limit here
29
+ * is already plan plus blocks and the caption under it says how much of that
30
+ * the blocks are.
30
31
  *
31
32
  * From the server, not from Firestore like the platform's meters:
32
33
  * `orgs/{orgId}/assistUsage` is default-deny for every client, so a browser
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */ 'use client';
17
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
- import { AI_TIERS, aiAddonName, aiTierName, isUnlimitedQuota, orgCanBuyAiTier, resolveAiTier, resolveOrgEntitlements } from "@aglyn/aglyn";
18
+ import { AI_CREDIT_BLOCK_MONTHLY_USD, AI_CREDITS_PER_BLOCK, aiAddonName, aiCreditBlocksCredits, aiCreditBlocksLabel, isUnlimitedQuota, orgCanBuyAiCredits, resolveAiCreditBlocks, resolveOrgEntitlements } from "@aglyn/aglyn";
19
19
  import { pluginDocsHelp } from "@aglyn/aglyn/app-utils/docs-help";
20
20
  import { CardDisplay } from "@aglyn/shared-ui-jsx";
21
21
  import { PrerequisiteNotice } from "@aglyn/shared-ui-jsx/components/prerequisite-notice.component";
@@ -42,9 +42,10 @@ import { useUser } from "@aglyn/tenant-feature-instance";
42
42
  * but says the plan has no credits and links to Billing (AGL-3982), since a
43
43
  * missing card reads as AI not existing here. ONE meter for one pool: the
44
44
  * plan's included credits pay for every AI action, generation included
45
- * (AGL-3965), and an Aglyn AI tier widens `assistCreditsPerMonth` rather than
46
- * opening a second band, so the limit here is already plan plus tier and the
47
- * caption under it says how much of that the tier is.
45
+ * (AGL-3965), and Aglyn AI credit blocks (AGL-4144) widen
46
+ * `assistCreditsPerMonth` rather than opening a second band, so the limit here
47
+ * is already plan plus blocks and the caption under it says how much of that
48
+ * the blocks are.
48
49
  *
49
50
  * From the server, not from Firestore like the platform's meters:
50
51
  * `orgs/{orgId}/assistUsage` is default-deny for every client, so a browser
@@ -78,7 +79,7 @@ import { useUser } from "@aglyn/tenant-feature-instance";
78
79
  const entitlements = resolveOrgEntitlements(org);
79
80
  const help = pluginDocsHelp('aiCredits', {
80
81
  anchor: '#see-your-credits',
81
- excerpt: 'AI credits drawn this month against one pool: your plan’s included ' + 'credits plus your AI tier’s, if you have one. Every AI action draws on ' + 'it. The pool resets on the first of the month.'
82
+ excerpt: 'AI credits drawn this month against one pool: your plan’s included ' + 'credits plus any AI credit blocks you bought. Every AI action draws on ' + 'it. The pool resets on the first of the month.'
82
83
  });
83
84
  // A band of zero (AGL-3982): said, with the way to a plan that has one,
84
85
  // rather than a missing card that reads as AI not existing here.
@@ -95,10 +96,10 @@ import { useUser } from "@aglyn/tenant-feature-instance";
95
96
  })
96
97
  });
97
98
  }
98
- const aiTier = resolveAiTier(org);
99
+ const aiBlocks = resolveAiCreditBlocks(org);
99
100
  // Sold to THIS workspace, not merely on its plan: a staff comp has no
100
101
  // subscription to add the item to, so it sells none (AGL-3034).
101
- const tiersSold = orgCanBuyAiTier(org);
102
+ const blocksSold = orgCanBuyAiCredits(org);
102
103
  return /*#__PURE__*/ _jsxs(CardDisplay, {
103
104
  header: 'AI credits',
104
105
  help: help,
@@ -112,7 +113,7 @@ import { useUser } from "@aglyn/tenant-feature-instance";
112
113
  unlimited: isUnlimitedQuota(entitlements.assistCreditsPerMonth),
113
114
  upgradeHref: billingHref ? `${billingHref}#plans` : '#plans'
114
115
  }),
115
- aiTier ? /*#__PURE__*/ _jsx(Typography, {
116
+ aiBlocks > 0 ? /*#__PURE__*/ _jsx(Typography, {
116
117
  variant: "caption",
117
118
  color: "text.secondary",
118
119
  sx: {
@@ -120,9 +121,9 @@ import { useUser } from "@aglyn/tenant-feature-instance";
120
121
  mt: -1.5,
121
122
  mb: 2
122
123
  },
123
- children: `Includes ${AI_TIERS[aiTier].credits.toLocaleString()} credits a month ` + `from ${aiTierName(aiTier)}, on top of your plan's.`
124
+ children: `Includes ${aiCreditBlocksCredits(aiBlocks).toLocaleString()} credits a month ` + `from ${aiCreditBlocksLabel(aiBlocks)} of ${aiAddonName()} credits, on top of your plan's.`
124
125
  }) : null,
125
- !aiTier && tiersSold ? /*#__PURE__*/ _jsxs(Typography, {
126
+ aiBlocks === 0 && blocksSold ? /*#__PURE__*/ _jsxs(Typography, {
126
127
  variant: "caption",
127
128
  color: "text.secondary",
128
129
  sx: {
@@ -131,12 +132,12 @@ import { useUser } from "@aglyn/tenant-feature-instance";
131
132
  mb: 2
132
133
  },
133
134
  children: [
134
- `Need more? An ${aiAddonName()} tier adds ` + `${AI_TIERS.spark.credits.toLocaleString()} to ` + `${AI_TIERS.studio.credits.toLocaleString()} credits a month to this pool: `,
135
+ `Need more? Each block of ${aiAddonName()} credits adds ` + `${AI_CREDITS_PER_BLOCK.toLocaleString()} credits a month to this pool for ` + `$${AI_CREDIT_BLOCK_MONTHLY_USD}: `,
135
136
  /*#__PURE__*/ _jsx(Link, {
136
137
  href: `${billingHref != null ? billingHref : ''}#addons`,
137
138
  color: "primary",
138
139
  underline: "hover",
139
- children: 'Choose a tier'
140
+ children: 'Add credits'
140
141
  }),
141
142
  ' in Billing → Plan.'
142
143
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-credits-card.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'use client'\n\nimport {\n AI_TIERS,\n aiAddonName,\n aiTierName,\n isUnlimitedQuota,\n orgCanBuyAiTier,\n resolveAiTier,\n resolveOrgEntitlements,\n type AglynOrgBilling,\n} from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { UsageMeter } from '@aglyn/shared-ui-jsx/components/usage-meter.component'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { Link, Typography } from '@mui/material'\nimport { useEffect, useState } from 'react'\nimport { useUser } from '@aglyn/tenant-feature-instance'\n\nexport interface AiCreditsCardProps {\n orgId?: string | null\n /** The billing-merged org doc the Usage page resolved. */\n org?: Partial<AglynOrgBilling> | null\n /** The Billing overview's path, for the one caption that points at the add-ons card. */\n billingHref?: string\n}\n\n/**\n * The AI credits meter (AGL-2899), on the Billing → Usage page's plugin\n * band below the platform's own meters (AGL-2939).\n *\n * Credits, because AI actions differ in cost by up to two orders of\n * magnitude — a question against generating a screen — and a message count\n * would price them the same. The band is refused at the cap, so this\n * readout is the only thing standing between a customer and learning their\n * limit by being turned down mid-build.\n *\n * Rendered only where a band is sold, which since AGL-3203 is every plan\n * row: Free carries the taste and Starter 750, so both render a meter even\n * though neither carries `aiAssist` — the band is credits, not the guided\n * rung. A band of ZERO, which now reaches this component only as a per-org\n * override, draws no meter — a \"0 of 0\" meter is not a readout of anything —\n * but says the plan has no credits and links to Billing (AGL-3982), since a\n * missing card reads as AI not existing here. ONE meter for one pool: the\n * plan's included credits pay for every AI action, generation included\n * (AGL-3965), and an Aglyn AI tier widens `assistCreditsPerMonth` rather than\n * opening a second band, so the limit here is already plan plus tier and the\n * caption under it says how much of that the tier is.\n *\n * From the server, not from Firestore like the platform's meters:\n * `orgs/{orgId}/assistUsage` is default-deny for every client, so a browser\n * read would fail silently and leave this reading \"not yet metered\" forever.\n * Credits, never dollars: the route is where the one conversion happens.\n */\nexport default function AiCreditsCard(props: AiCreditsCardProps) {\n const { orgId, org, billingHref } = props\n const { data: user } = useUser()\n const [credits, setCredits] = useState<{ used: number; limit: number | null } | null>(null)\n useEffect(() => {\n if (!orgId || !user) return undefined\n let active = true\n void (async () => {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/billing/credits?orgId=${encodeURIComponent(orgId)}`,\n )\n if (!response.ok) return\n const result = await response.json()\n if (active && result?.credits) setCredits(result.credits)\n } catch {\n // The meter keeps its \"not yet metered\" state on failure —\n // deliberately not 0, which reads as \"you have used none\".\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, user])\n\n const entitlements = resolveOrgEntitlements(org)\n const help = pluginDocsHelp('aiCredits', {\n anchor: '#see-your-credits',\n excerpt:\n 'AI credits drawn this month against one pool: your plan’s included ' +\n 'credits plus your AI tier’s, if you have one. Every AI action draws on ' +\n 'it. The pool resets on the first of the month.',\n })\n // A band of zero (AGL-3982): said, with the way to a plan that has one,\n // rather than a missing card that reads as AI not existing here.\n if (entitlements.assistCreditsPerMonth <= 0) {\n return (\n <CardDisplay header={'AI credits'} help={help} contentGutterX contentGutterY>\n <PrerequisiteNotice href={billingHref ? `${billingHref}#plans` : '#plans'} actionLabel=\"See plans\">\n {'Your plan includes no AI credits. Choose a plan with AI credits in Billing to use the AI features.'}\n </PrerequisiteNotice>\n </CardDisplay>\n )\n }\n const aiTier = resolveAiTier(org)\n // Sold to THIS workspace, not merely on its plan: a staff comp has no\n // subscription to add the item to, so it sells none (AGL-3034).\n const tiersSold = orgCanBuyAiTier(org)\n return (\n <CardDisplay\n header={'AI credits'}\n help={help}\n contentGutterX\n contentGutterY\n >\n {/* An uncapped staff comp (AGL-3049) resolves this band `UNLIMITED`:\n the meter reads \"Unlimited\" and draws no bar, never \"/ Infinity\". */}\n <UsageMeter\n label=\"AI credits (this month)\"\n used={credits ? credits.used : null}\n limit={entitlements.assistCreditsPerMonth}\n unlimited={isUnlimitedQuota(entitlements.assistCreditsPerMonth)}\n upgradeHref={billingHref ? `${billingHref}#plans` : '#plans'}\n />\n {aiTier ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mt: -1.5, mb: 2 }}\n >\n {`Includes ${AI_TIERS[aiTier].credits.toLocaleString()} credits a month ` +\n `from ${aiTierName(aiTier)}, on top of your plan's.`}\n </Typography>\n ) : null}\n {/* A plan that sells tiers and holds none: the one line on the meters\n that points at more capacity rather than at an upgrade. */}\n {!aiTier && tiersSold ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mt: -1.5, mb: 2 }}\n >\n {`Need more? An ${aiAddonName()} tier adds ` +\n `${AI_TIERS.spark.credits.toLocaleString()} to ` +\n `${AI_TIERS.studio.credits.toLocaleString()} credits a month to this pool: `}\n <Link href={`${billingHref ?? ''}#addons`} color=\"primary\" underline=\"hover\">\n {'Choose a tier'}\n </Link>\n {' in Billing → Plan.'}\n </Typography>\n ) : null}\n </CardDisplay>\n )\n}\n"],"names":["AI_TIERS","aiAddonName","aiTierName","isUnlimitedQuota","orgCanBuyAiTier","resolveAiTier","resolveOrgEntitlements","pluginDocsHelp","CardDisplay","PrerequisiteNotice","UsageMeter","authorizedFetch","Link","Typography","useEffect","useState","useUser","AiCreditsCard","props","orgId","org","billingHref","data","user","credits","setCredits","undefined","active","response","encodeURIComponent","ok","result","json","entitlements","help","anchor","excerpt","assistCreditsPerMonth","header","contentGutterX","contentGutterY","href","actionLabel","aiTier","tiersSold","label","used","limit","unlimited","upgradeHref","variant","color","sx","display","mt","mb","toLocaleString","spark","studio","underline"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,QAAQ,EACRC,WAAW,EACXC,UAAU,EACVC,gBAAgB,EAChBC,eAAe,EACfC,aAAa,EACbC,sBAAsB,QAEjB,eAAc;AACrB,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,UAAU,QAAQ,wDAAuD;AAClF,SAASC,e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,cAAce;IAC7B,sEAAsE;IACtE,gEAAgE;IAChE,MAAMwB,YAAYxC,gBAAgBgB;IAClC,qBACE,MAACZ;QACC8B,QAAQ;QACRJ,MAAMA;QACNK,cAAc;QACdC,cAAc;;0BAId,KAAC9B;gBACCmC,OAAM;gBACNC,MAAMtB,UAAUA,QAAQsB,IAAI,GAAG;gBAC/BC,OAAOd,aAAaI,qBAAqB;gBACzCW,WAAW7C,iBAAiB8B,aAAaI,qBAAqB;gBAC9DY,aAAa5B,cAAc,GAAGA,YAAY,MAAM,CAAC,GAAG;;YAErDsB,uBACC,KAAC9B;gBACCqC,SAAQ;gBACRC,OAAM;gBACNC,IAAI;oBAAEC,SAAS;oBAASC,IAAI,CAAC;oBAAKC,IAAI;gBAAE;0BAEvC,CAAC,SAAS,EAAEvD,QAAQ,CAAC2C,OAAO,CAACnB,OAAO,CAACgC,cAAc,GAAG,iBAAiB,CAAC,GACvE,CAAC,KAAK,EAAEtD,WAAWyC,QAAQ,wBAAwB,CAAC;iBAEtD;YAGH,CAACA,UAAUC,0BACV,MAAC/B;gBACCqC,SAAQ;gBACRC,OAAM;gBACNC,IAAI;oBAAEC,SAAS;oBAASC,IAAI,CAAC;oBAAKC,IAAI;gBAAE;;oBAEvC,CAAC,cAAc,EAAEtD,cAAc,WAAW,CAAC,GAC1C,GAAGD,SAASyD,KAAK,CAACjC,OAAO,CAACgC,cAAc,GAAG,IAAI,CAAC,GAChD,GAAGxD,SAAS0D,MAAM,CAAClC,OAAO,CAACgC,cAAc,GAAG,+BAA+B,CAAC;kCAC9E,KAAC5C;wBAAK6B,MAAM,GAAGpB,sBAAAA,cAAe,GAAG,OAAO,CAAC;wBAAE8B,OAAM;wBAAUQ,WAAU;kCAClE;;oBAEF;;iBAED;;;AAGV"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-credits-card.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'use client'\n\nimport {\n AI_CREDIT_BLOCK_MONTHLY_USD,\n AI_CREDITS_PER_BLOCK,\n aiAddonName,\n aiCreditBlocksCredits,\n aiCreditBlocksLabel,\n isUnlimitedQuota,\n orgCanBuyAiCredits,\n resolveAiCreditBlocks,\n resolveOrgEntitlements,\n type AglynOrgBilling,\n} from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { UsageMeter } from '@aglyn/shared-ui-jsx/components/usage-meter.component'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { Link, Typography } from '@mui/material'\nimport { useEffect, useState } from 'react'\nimport { useUser } from '@aglyn/tenant-feature-instance'\n\nexport interface AiCreditsCardProps {\n orgId?: string | null\n /** The billing-merged org doc the Usage page resolved. */\n org?: Partial<AglynOrgBilling> | null\n /** The Billing overview's path, for the one caption that points at the add-ons card. */\n billingHref?: string\n}\n\n/**\n * The AI credits meter (AGL-2899), on the Billing → Usage page's plugin\n * band below the platform's own meters (AGL-2939).\n *\n * Credits, because AI actions differ in cost by up to two orders of\n * magnitude — a question against generating a screen — and a message count\n * would price them the same. The band is refused at the cap, so this\n * readout is the only thing standing between a customer and learning their\n * limit by being turned down mid-build.\n *\n * Rendered only where a band is sold, which since AGL-3203 is every plan\n * row: Free carries the taste and Starter 750, so both render a meter even\n * though neither carries `aiAssist` — the band is credits, not the guided\n * rung. A band of ZERO, which now reaches this component only as a per-org\n * override, draws no meter — a \"0 of 0\" meter is not a readout of anything —\n * but says the plan has no credits and links to Billing (AGL-3982), since a\n * missing card reads as AI not existing here. ONE meter for one pool: the\n * plan's included credits pay for every AI action, generation included\n * (AGL-3965), and Aglyn AI credit blocks (AGL-4144) widen\n * `assistCreditsPerMonth` rather than opening a second band, so the limit here\n * is already plan plus blocks and the caption under it says how much of that\n * the blocks are.\n *\n * From the server, not from Firestore like the platform's meters:\n * `orgs/{orgId}/assistUsage` is default-deny for every client, so a browser\n * read would fail silently and leave this reading \"not yet metered\" forever.\n * Credits, never dollars: the route is where the one conversion happens.\n */\nexport default function AiCreditsCard(props: AiCreditsCardProps) {\n const { orgId, org, billingHref } = props\n const { data: user } = useUser()\n const [credits, setCredits] = useState<{ used: number; limit: number | null } | null>(null)\n useEffect(() => {\n if (!orgId || !user) return undefined\n let active = true\n void (async () => {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/billing/credits?orgId=${encodeURIComponent(orgId)}`,\n )\n if (!response.ok) return\n const result = await response.json()\n if (active && result?.credits) setCredits(result.credits)\n } catch {\n // The meter keeps its \"not yet metered\" state on failure —\n // deliberately not 0, which reads as \"you have used none\".\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, user])\n\n const entitlements = resolveOrgEntitlements(org)\n const help = pluginDocsHelp('aiCredits', {\n anchor: '#see-your-credits',\n excerpt:\n 'AI credits drawn this month against one pool: your plan’s included ' +\n 'credits plus any AI credit blocks you bought. Every AI action draws on ' +\n 'it. The pool resets on the first of the month.',\n })\n // A band of zero (AGL-3982): said, with the way to a plan that has one,\n // rather than a missing card that reads as AI not existing here.\n if (entitlements.assistCreditsPerMonth <= 0) {\n return (\n <CardDisplay header={'AI credits'} help={help} contentGutterX contentGutterY>\n <PrerequisiteNotice href={billingHref ? `${billingHref}#plans` : '#plans'} actionLabel=\"See plans\">\n {'Your plan includes no AI credits. Choose a plan with AI credits in Billing to use the AI features.'}\n </PrerequisiteNotice>\n </CardDisplay>\n )\n }\n const aiBlocks = resolveAiCreditBlocks(org)\n // Sold to THIS workspace, not merely on its plan: a staff comp has no\n // subscription to add the item to, so it sells none (AGL-3034).\n const blocksSold = orgCanBuyAiCredits(org)\n return (\n <CardDisplay\n header={'AI credits'}\n help={help}\n contentGutterX\n contentGutterY\n >\n {/* An uncapped staff comp (AGL-3049) resolves this band `UNLIMITED`:\n the meter reads \"Unlimited\" and draws no bar, never \"/ Infinity\". */}\n <UsageMeter\n label=\"AI credits (this month)\"\n used={credits ? credits.used : null}\n limit={entitlements.assistCreditsPerMonth}\n unlimited={isUnlimitedQuota(entitlements.assistCreditsPerMonth)}\n upgradeHref={billingHref ? `${billingHref}#plans` : '#plans'}\n />\n {aiBlocks > 0 ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mt: -1.5, mb: 2 }}\n >\n {`Includes ${aiCreditBlocksCredits(aiBlocks).toLocaleString()} credits a month ` +\n `from ${aiCreditBlocksLabel(aiBlocks)} of ${aiAddonName()} credits, on top of your plan's.`}\n </Typography>\n ) : null}\n {/* A plan that sells blocks and holds none: the one line on the meters\n that points at more capacity rather than at an upgrade. */}\n {aiBlocks === 0 && blocksSold ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mt: -1.5, mb: 2 }}\n >\n {`Need more? Each block of ${aiAddonName()} credits adds ` +\n `${AI_CREDITS_PER_BLOCK.toLocaleString()} credits a month to this pool for ` +\n `$${AI_CREDIT_BLOCK_MONTHLY_USD}: `}\n <Link href={`${billingHref ?? ''}#addons`} color=\"primary\" underline=\"hover\">\n {'Add credits'}\n </Link>\n {' in Billing → Plan.'}\n </Typography>\n ) : null}\n </CardDisplay>\n )\n}\n"],"names":["AI_CREDIT_BLOCK_MONTHLY_USD","AI_CREDITS_PER_BLOCK","aiAddonName","aiCreditBlocksCredits","aiCreditBlocksLabel","isUnlimitedQuota","orgCanBuyAiCredits","resolveAiCreditBlocks","resolveOrgEntitlements","pluginDocsHelp","CardDisplay","PrerequisiteNotice","UsageMeter","authorizedFetch","Link","Typography","useEffect","useState","useUser","AiCreditsCard","props","orgId","org","billingHref","data","user","credits","setCredits","undefined","active","response","encodeURIComponent","ok","result","json","entitlements","help","anchor","excerpt","assistCreditsPerMonth","header","contentGutterX","contentGutterY","href","actionLabel","aiBlocks","blocksSold","label","used","limit","unlimited","upgradeHref","variant","color","sx","display","mt","mb","toLocaleString","underline"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,2BAA2B,EAC3BC,oBAAoB,EACpBC,WAAW,EACXC,qBAAqB,EACrBC,mBAAmB,EACnBC,gBAAgB,EAChBC,kBAAkB,EAClBC,qBAAqB,EACrBC,sBAAsB,QAEjB,eAAc;AACrB,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,UAAU,QAAQ,wDAAuD;AAClF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,IAAI,EAAEC,UAAU,QAAQ,gBAAe;AAChD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC3C,SAASC,OAAO,QAAQ,iCAAgC;AAUxD;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,eAAe,SAASC,cAAcC,KAAyB;IAC7D,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,EAAE,GAAGH;IACpC,MAAM,EAAEI,MAAMC,IAAI,EAAE,GAAGP;IACvB,MAAM,CAACQ,SAASC,WAAW,GAAGV,SAAwD;IACtFD,UAAU;QACR,IAAI,CAACK,SAAS,CAACI,MAAM,OAAOG;QAC5B,IAAIC,SAAS;QACb,KAAK,AAAC,CAAA;YACJ,IAAI;gBACF,MAAMC,WAAW,MAAMjB,gBACrBY,MACA,CAAC,8BAA8B,EAAEM,mBAAmBV,QAAQ;gBAE9D,IAAI,CAACS,SAASE,EAAE,EAAE;gBAClB,MAAMC,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CAAC;iBAE7F;YAGH2C,aAAa,KAAKC,2BACjB,MAAC/B;gBACCqC,SAAQ;gBACRC,OAAM;gBACNC,IAAI;oBAAEC,SAAS;oBAASC,IAAI,CAAC;oBAAKC,IAAI;gBAAE;;oBAEvC,CAAC,yBAAyB,EAAEvD,cAAc,cAAc,CAAC,GACxD,GAAGD,qBAAqByD,cAAc,GAAG,kCAAkC,CAAC,GAC5E,CAAC,CAAC,EAAE1D,4BAA4B,EAAE,CAAC;kCACrC,KAACc;wBAAK6B,MAAM,GAAGpB,sBAAAA,cAAe,GAAG,OAAO,CAAC;wBAAE8B,OAAM;wBAAUM,WAAU;kCAClE;;oBAEF;;iBAED;;;AAGV"}
@@ -567,12 +567,21 @@ function Frame({ siteName, heading, lede, children }) {
567
567
  });
568
568
  }
569
569
  if (phase === 'review' && state) {
570
+ var _ref2;
571
+ var _job_sitePublish;
570
572
  const wave = aiSiteImportReviewWave(state);
571
573
  const spent = aiSiteImportWaveSpent(job, wave);
574
+ // A site in preview has the wave's pages live for its team (AGL-4084); any other has them as drafts.
575
+ const live = new Set(((_ref2 = (_job_sitePublish = job.sitePublish) == null ? void 0 : _job_sitePublish.published) != null ? _ref2 : []).map((page)=>page.id));
576
+ const inPreview = wave.slots.some((slot)=>{
577
+ var _ref;
578
+ var _state_pages_find;
579
+ return live.has((_ref = (_state_pages_find = state.pages.find((page)=>page.slot === slot)) == null ? void 0 : _state_pages_find.draftId) != null ? _ref : '');
580
+ });
572
581
  return /*#__PURE__*/ _jsxs(Frame, {
573
582
  siteName: siteName,
574
- heading: `${wave.label} is in`,
575
- lede: "Open each page to review it. They are drafts: nothing is published until you publish it.",
583
+ heading: inPreview ? `${wave.label} is in your site’s preview` : `${wave.label} is in`,
584
+ lede: inPreview ? 'Its pages are on your site, where only you and your team can see them. Open each page to review it.' : 'Open each page to review it. They are drafts: nothing is published until you publish it.',
576
585
  children: [
577
586
  notice && /*#__PURE__*/ _jsx(Alert, {
578
587
  severity: "warning",
@@ -599,7 +608,7 @@ function Frame({ siteName, heading, lede, children }) {
599
608
  variant: "outlined",
600
609
  component: AppLink,
601
610
  href: pagesHref,
602
- children: 'Open your draft pages'
611
+ children: inPreview ? 'Open your pages' : 'Open your draft pages'
603
612
  })
604
613
  }) : null,
605
614
  start ? /*#__PURE__*/ _jsxs(Card, {
@@ -675,7 +684,7 @@ function Frame({ siteName, heading, lede, children }) {
675
684
  });
676
685
  }
677
686
  if (phase === 'held' || phase === 'paused') {
678
- var _ref2, _ref3;
687
+ var _ref3, _ref4;
679
688
  var _job_review1, _job_review2;
680
689
  const ownership = ((_job_review1 = job.review) == null ? void 0 : _job_review1.reason) === 'ownership';
681
690
  return /*#__PURE__*/ _jsxs(Frame, {
@@ -688,7 +697,7 @@ function Frame({ siteName, heading, lede, children }) {
688
697
  }),
689
698
  /*#__PURE__*/ _jsx(Alert, {
690
699
  severity: "info",
691
- children: (_ref2 = (_ref3 = (_job_review2 = job.review) == null ? void 0 : _job_review2.message) != null ? _ref3 : job.error) != null ? _ref2 : 'It stopped for your decision.'
700
+ children: (_ref3 = (_ref4 = (_job_review2 = job.review) == null ? void 0 : _job_review2.message) != null ? _ref4 : job.error) != null ? _ref3 : 'It stopped for your decision.'
692
701
  }),
693
702
  ownership && orgId ? claim ? /*#__PURE__*/ _jsx(AiSiteOwnershipProof, {
694
703
  orgId: orgId,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-import-job.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 { PageHeaderRecord } from '@aglyn/aglyn/app-utils/page-header-record-context'\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport {\n mdiAlertCircle,\n mdiCheckCircle,\n mdiChevronDown,\n mdiClockOutline,\n mdiMinusCircleOutline,\n mdiOpenInNew,\n} from '@aglyn/shared-data-mdi'\nimport { AppLink, HelpTip, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport type { MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\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 { useCallback, useState, type ReactNode } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport { aiSiteImportReviewWave, aiSiteImportRunningWave, type AiSiteImportWave } from '../model/ai-site-import'\nimport {\n aiSiteImportFoundText,\n aiSiteImportHeldCopy,\n aiSiteImportLeftOutLines,\n aiSiteImportPhaseOf,\n aiSiteImportPlanText,\n aiSiteImportStartAction,\n aiSiteImportStartAllAction,\n aiSiteImportStoppedCopy,\n aiSiteImportVerdictNote,\n aiSiteImportWaveRows,\n aiSiteImportWaveSpent,\n type AiSiteImportClaim,\n type AiSiteImportRowState,\n} from '../model/ai-site-import-view'\nimport { AiJobCancelButton } from './ai-job-cancel.component'\nimport { aiCreditsBillingHref, aiJobOutputHref } from './ai-job-links'\nimport { AI_SITE_IMPORT_HELP } from './ai-site-import-start.component'\nimport { AiSiteOwnershipProof, postAiSiteOwnership } from './ai-site-ownership-proof.component'\n\nconst ROW_ICON: Readonly<Record<Exclude<AiSiteImportRowState, 'active'>, { path: string; color: string; label: string }>> = {\n done: { path: mdiCheckCircle.path, color: 'success.main', label: 'In' },\n waiting: { path: mdiClockOutline.path, color: 'text.disabled', label: 'Waiting' },\n failed: { path: mdiAlertCircle.path, color: 'error.main', label: 'Could not be brought in' },\n skipped: { path: mdiMinusCircleOutline.path, color: 'text.disabled', label: 'Left out' },\n}\n\nfunction RowIcon({ state }: { state: AiSiteImportRowState }) {\n if (state === 'active') return <CircularProgress size={20} aria-label=\"In progress\" />\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/** One wave's pages: where each was, where it is now, how it went, and its draft to open. */\nfunction WaveRows({ job, wave, orgSlug }: { job: AiJobSummary; wave: AiSiteImportWave; orgSlug: string }) {\n const rows = aiSiteImportWaveRows(job, wave)\n return (\n <Box component=\"ol\" aria-label={wave.label} sx={{ listStyle: 'none', m: 0, p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n {rows.map((row) => {\n const output = row.outputId ? job.outputs.find((entry) => entry.id === row.outputId) : undefined\n const href = output ? aiJobOutputHref(output, orgSlug) : null\n return (\n <Stack component=\"li\" key={row.slot} 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 variant=\"body1\" color={row.state === 'waiting' || row.state === 'skipped' ? 'text.secondary' : 'text.primary'}>\n {row.title}\n </Typography>\n {href && row.state === 'done' ? (\n <Button size=\"small\" component={AppLink} href={href}>\n {'Open draft'}\n </Button>\n ) : null}\n </Stack>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline', flexWrap: 'wrap' }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ overflowWrap: 'anywhere' }}>\n {`${row.from} → ${row.to}`}\n </Typography>\n <Button\n size=\"small\"\n component=\"a\"\n href={row.oldPage}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n endIcon={<MdiIcon path={mdiOpenInNew.path} aria-hidden />}\n aria-label={`Old page: ${row.from}, opens in a new tab`}\n sx={{ minWidth: 0, py: 0 }}\n >\n {'Old page'}\n </Button>\n </Stack>\n {row.build || row.words ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {[row.build, row.words].filter(Boolean).join(' · ')}\n </Typography>\n ) : null}\n {row.photos ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.photos}\n </Typography>\n ) : null}\n {row.note && row.state !== 'done' ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.note}\n </Typography>\n ) : null}\n </Box>\n </Stack>\n )\n })}\n </Stack>\n </Box>\n )\n}\n\nfunction Frame({ siteName, heading, lede, children }: { siteName?: string; heading: string; lede?: string; children?: ReactNode }) {\n return (\n <Container maxWidth=\"sm\" sx={{ py: { xs: 3, sm: 5 }, px: { xs: 2, sm: 3 } }}>\n <PageHeaderRecord title={heading} />\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 interface AiSiteImportJobProps {\n job: AiJobSummary\n orgId: string | null\n orgSlug: string\n /** The site's subdomain, which its Pages list is addressed by. */\n host: string | null\n siteName?: string\n user: MaybeTokenSource\n busy: boolean\n notice: string | null\n /** Starts the next wave, or reads the site again: the resume door. */\n onResume: () => void\n /**\n * Starts every remaining wave with no review between them (AGL-4083). The\n * button is drawn only where the page can start them this way.\n */\n onStartAll?: () => void\n onJob: (job: AiJobSummary) => void\n}\n\n/**\n * \"Bring my site\" (AGL-3976), on the import job's own page: the site read\n * and its waves planned with each one's quote, a wave running page by page,\n * a wave in for its review with its drafts to open, and the next wave's\n * button — the only way the next one starts. A wave held for a new proof, the\n * day's limit or a site that could not be read says so and offers the way on.\n */\nexport function AiSiteImportJob({ job, orgId, orgSlug, host, siteName, user, busy, notice, onResume, onStartAll, onJob }: AiSiteImportJobProps) {\n const phase = aiSiteImportPhaseOf(job)\n const state = job.siteImport ?? null\n const start = aiSiteImportStartAction(job)\n const startAll = onStartAll ? aiSiteImportStartAllAction(job) : null\n const held = aiSiteImportHeldCopy(job)\n const pagesHref = host && orgSlug ? buildRoute(Route.HOST_SCREENS, { orgSlug, host }) : null\n const [claim, setClaim] = useState<AiSiteImportClaim | null>(null)\n const [claimNotice, setClaimNotice] = useState<string | null>(null)\n const verifyAgain = useCallback(async () => {\n if (!orgId || !state) return\n setClaimNotice(null)\n const answer = await postAiSiteOwnership(user, { orgId, action: 'claim', domain: state.domain })\n if (answer.claim) setClaim(answer.claim)\n else setClaimNotice(answer.message)\n }, [orgId, state, user])\n\n const cancel = (\n <Box>\n <AiJobCancelButton job={job} user={user} orgId={orgId} onJob={onJob} variant=\"text\" size=\"small\" />\n </Box>\n )\n const startButton = start ? (\n <Stack spacing={1}>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.5} sx={{ alignItems: { sm: 'center' } }}>\n <Box>\n <Button variant=\"contained\" size=\"large\" disabled={busy} onClick={onResume}>\n {busy ? 'Starting…' : start.label}\n </Button>\n </Box>\n {startAll && onStartAll ? (\n <Box>\n <Button variant=\"outlined\" size=\"large\" disabled={busy} onClick={onStartAll}>\n {startAll.label}\n </Button>\n </Box>\n ) : null}\n </Stack>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${start.quote}, from your AI credits. Its pages land in your site’s preview, or as drafts where the site is not in preview.`}\n </Typography>\n <HelpTip {...AI_SITE_IMPORT_HELP.waves} ariaLabel=\"How waves work\" />\n </Stack>\n {startAll && onStartAll ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${startAll.quote} for every remaining wave (${startAll.waves}), one after another with no review between them. You review the last one.`}\n </Typography>\n ) : null}\n </Stack>\n ) : null\n const waves = state ? (\n <Accordion variant=\"outlined\" disableGutters sx={{ borderRadius: 2, '&::before': { display: 'none' } }}>\n <AccordionSummary expandIcon={<MdiIcon path={mdiChevronDown.path} />}>\n <Typography variant=\"subtitle1\">{`Every wave (${state.waves.length})`}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Stack component=\"ol\" spacing={1} sx={{ m: 0, pl: 2.5 }}>\n {state.waves.map((wave) => (\n <Typography component=\"li\" variant=\"body2\" key={wave.index}>\n {`${wave.label}: ${wave.slots.length} ${wave.slots.length === 1 ? 'page' : 'pages'}${wave.frame ? ', with your header and footer' : ''}${\n wave.status === 'done' || wave.status === 'review'\n ? ' (in)'\n : wave.status === 'running'\n ? ' (running)'\n : wave.status === 'stopped'\n ? wave.startedAt\n ? ' (stopped)'\n : ' (not started)'\n : ''\n }`}\n </Typography>\n ))}\n </Stack>\n </AccordionDetails>\n </Accordion>\n ) : null\n const leftOut = state ? aiSiteImportLeftOutLines(state) : []\n const leftOutCard = leftOut.length ? (\n <Accordion variant=\"outlined\" disableGutters sx={{ borderRadius: 2, '&::before': { display: 'none' } }}>\n <AccordionSummary expandIcon={<MdiIcon path={mdiChevronDown.path} />}>\n <Typography variant=\"subtitle1\">{`Not brought in (${leftOut.reduce((total, line) => total + line.count, 0)})`}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Stack spacing={1.5}>\n {leftOut.map((line) => (\n <Box key={line.reason}>\n <Typography variant=\"body2\">{`${line.count} · ${line.text}`}</Typography>\n {line.paths.length ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ overflowWrap: 'anywhere' }}>\n {line.paths.slice(0, 8).join(', ')}\n {line.paths.length > 8 || line.count > line.paths.length ? ', …' : ''}\n </Typography>\n ) : null}\n {line.reason === 'plan-limit' && orgSlug ? (\n <Button size=\"small\" component={AppLink} href={aiCreditsBillingHref(orgSlug)} sx={{ mt: 0.5 }}>\n {'See plans'}\n </Button>\n ) : null}\n </Box>\n ))}\n </Stack>\n </AccordionDetails>\n </Accordion>\n ) : null\n\n if (phase === 'reading') {\n return (\n <Frame siteName={siteName} heading=\"Reading your site\" lede=\"AglynBot reads robots.txt first, then your sitemap and your pages. Nothing is built yet, and reading uses no AI credits.\">\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <LinearProgress aria-label=\"Reading your site\" />\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ p: { xs: 2, sm: 3 } }}>\n {'This takes a minute or two. You can leave this page; we tell you when your site is read.'}\n </Typography>\n </Card>\n {cancel}\n </Frame>\n )\n }\n\n if (phase === 'ready' && state) {\n return (\n <Frame siteName={siteName} heading={aiSiteImportStoppedCopy(job) ? 'Your import is waiting for you' : 'Your site is read'} lede={job.review?.message ?? undefined}>\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n {aiSiteImportVerdictNote(state) ? <Alert severity=\"warning\">{aiSiteImportVerdictNote(state)}</Alert> : null}\n <Stack spacing={1}>\n <Typography variant=\"body1\">{aiSiteImportFoundText(state)}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {aiSiteImportPlanText(state)}\n </Typography>\n </Stack>\n {start ? (\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <Typography variant=\"subtitle1\" sx={{ px: { xs: 2, sm: 3 }, pt: { xs: 2, sm: 3 } }}>\n {`First: ${start.wave.label}`}\n </Typography>\n <WaveRows job={job} wave={start.wave} orgSlug={orgSlug} />\n </Card>\n ) : null}\n {startButton}\n {waves}\n {leftOutCard}\n {cancel}\n </Frame>\n )\n }\n\n if ((phase === 'running' || phase === 'starting') && state) {\n const wave = aiSiteImportRunningWave(state) ?? start?.wave ?? null\n const rows = wave ? aiSiteImportWaveRows(job, wave) : []\n const done = rows.filter((row) => row.state !== 'waiting' && row.state !== 'active').length\n return (\n <Frame\n siteName={siteName}\n heading={wave ? `Bringing in ${wave.label}` : 'Bringing in your site'}\n lede=\"Each page is rewritten into your new site’s design with its own words, facts and photos. You review the wave when it is in.\"\n >\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n {rows.length ? (\n <LinearProgress variant=\"determinate\" value={Math.round((done / rows.length) * 100)} aria-label={`${done} of ${rows.length} in`} />\n ) : (\n <LinearProgress aria-label=\"Starting the wave\" />\n )}\n {wave ? <WaveRows job={job} wave={wave} orgSlug={orgSlug} /> : null}\n </Card>\n {waves}\n {cancel}\n </Frame>\n )\n }\n\n if (phase === 'review' && state) {\n const wave = aiSiteImportReviewWave(state) as AiSiteImportWave\n const spent = aiSiteImportWaveSpent(job, wave)\n return (\n <Frame siteName={siteName} heading={`${wave.label} is in`} lede=\"Open each page to review it. They are drafts: nothing is published until you publish it.\">\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <WaveRows job={job} wave={wave} orgSlug={orgSlug} />\n </Card>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`This wave used ${spent.toLocaleString('en-US')} AI ${spent === 1 ? 'credit' : 'credits'}.`}\n </Typography>\n {pagesHref ? (\n <Box>\n <Button variant=\"outlined\" component={AppLink} href={pagesHref}>\n {'Open your draft pages'}\n </Button>\n </Box>\n ) : null}\n {start ? (\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <Typography variant=\"subtitle1\" sx={{ px: { xs: 2, sm: 3 }, pt: { xs: 2, sm: 3 } }}>\n {`Next: ${start.wave.label}`}\n </Typography>\n <WaveRows job={job} wave={start.wave} orgSlug={orgSlug} />\n </Card>\n ) : null}\n {startButton}\n {waves}\n {leftOutCard}\n {cancel}\n </Frame>\n )\n }\n\n // The home page was turned away or could not be read (AGL-4083): nothing was\n // planned or spent, and Check again reads the site again, for free.\n if (phase === 'held' && held) {\n return (\n <Frame siteName={siteName} heading={held.heading}>\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Alert severity=\"warning\">{held.message}</Alert>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Button variant=\"contained\" disabled={busy} onClick={onResume}>\n {busy ? 'Checking…' : held.action}\n </Button>\n <HelpTip {...AI_SITE_IMPORT_HELP.turnedAway} ariaLabel=\"How to let AglynBot in\" />\n </Stack>\n {leftOutCard}\n {cancel}\n </Frame>\n )\n }\n\n if (phase === 'held' || phase === 'paused') {\n const ownership = job.review?.reason === 'ownership'\n return (\n <Frame siteName={siteName} heading={ownership ? 'Verify your site again' : phase === 'paused' ? 'Your site import is paused' : 'Your site import is waiting'}>\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Alert severity=\"info\">{job.review?.message ?? job.error ?? 'It stopped for your decision.'}</Alert>\n {ownership && orgId ? (\n claim ? (\n <AiSiteOwnershipProof orgId={orgId} user={user} claim={claim} onClaim={setClaim} />\n ) : (\n <Box>\n <Button variant=\"outlined\" onClick={() => void verifyAgain()}>\n {'Verify again'}\n </Button>\n {claimNotice ? <Alert severity=\"warning\" sx={{ mt: 1 }}>{claimNotice}</Alert> : null}\n </Box>\n )\n ) : null}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'center' } }}>\n <Button variant=\"contained\" disabled={busy || (ownership && !claim?.current)} onClick={onResume}>\n {busy ? 'Starting…' : phase === 'paused' ? 'Resume' : start ? `${start.label} again` : 'Read the site again'}\n </Button>\n {phase === 'paused' && orgSlug ? (\n <Button variant=\"outlined\" component={AppLink} href={aiCreditsBillingHref(orgSlug)}>\n {'Get more AI credits'}\n </Button>\n ) : null}\n </Stack>\n {waves}\n {cancel}\n </Frame>\n )\n }\n\n if (phase === 'done' && state) {\n const brought = (job.items ?? []).filter((row) => row.op === 'page' && (row.status === 'succeeded' || row.status === 'degraded')).length\n return (\n <Frame\n siteName={siteName}\n heading=\"Your site is in\"\n lede={`${brought} ${brought === 1 ? 'page was' : 'pages were'} brought in from ${state.domain}. They are drafts: review them, then publish them when you are ready.`}\n >\n {pagesHref ? (\n <Box>\n <Button variant=\"contained\" size=\"large\" component={AppLink} href={pagesHref}>\n {'Open your draft pages'}\n </Button>\n </Box>\n ) : null}\n {state.waves.map((wave) => (\n <Card key={wave.index} variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <Typography variant=\"subtitle1\" sx={{ px: { xs: 2, sm: 3 }, pt: { xs: 2, sm: 3 } }}>\n {wave.label}\n </Typography>\n <WaveRows job={job} wave={wave} orgSlug={orgSlug} />\n </Card>\n ))}\n {leftOutCard}\n </Frame>\n )\n }\n\n return (\n <Frame siteName={siteName} heading={job.status === 'canceled' ? 'Your site import was stopped' : 'Your site import stopped'}>\n <Alert severity=\"info\">\n {job.error ??\n (job.status === 'canceled'\n ? 'Nothing more is brought in. The pages already in stay where they are: in your site’s preview, or as drafts.'\n : 'It could not go on. The pages already in stay where they are: in your site’s preview, or as drafts.')}\n </Alert>\n {pagesHref ? (\n <Box>\n <Button variant=\"outlined\" component={AppLink} href={pagesHref}>\n {'Open your draft pages'}\n </Button>\n </Box>\n ) : null}\n {/* Which waves came in and which stopped (AGL-4107). */}\n {waves}\n </Frame>\n )\n}\n\nexport default AiSiteImportJob\n"],"names":["PageHeaderRecord","buildRoute","Route","mdiAlertCircle","mdiCheckCircle","mdiChevronDown","mdiClockOutline","mdiMinusCircleOutline","mdiOpenInNew","AppLink","HelpTip","MdiIcon","Accordion","AccordionDetails","AccordionSummary","Alert","Box","Button","Card","CircularProgress","Container","LinearProgress","Stack","Typography","useCallback","useState","aiSiteImportReviewWave","aiSiteImportRunningWave","aiSiteImportFoundText","aiSiteImportHeldCopy","aiSiteImportLeftOutLines","aiSiteImportPhaseOf","aiSiteImportPlanText","aiSiteImportStartAction","aiSiteImportStartAllAction","aiSiteImportStoppedCopy","aiSiteImportVerdictNote","aiSiteImportWaveRows","aiSiteImportWaveSpent","AiJobCancelButton","aiCreditsBillingHref","aiJobOutputHref","AI_SITE_IMPORT_HELP","AiSiteOwnershipProof","postAiSiteOwnership","ROW_ICON","done","path","color","label","waiting","failed","skipped","RowIcon","state","size","aria-label","icon","component","role","sx","display","fontSize","theme","spacing","aria-hidden","WaveRows","job","wave","orgSlug","rows","listStyle","m","p","xs","sm","map","row","output","outputId","outputs","find","entry","id","undefined","href","direction","alignItems","width","justifyContent","flex","minWidth","variant","title","flexWrap","overflowWrap","from","to","oldPage","target","rel","endIcon","py","build","words","filter","Boolean","join","photos","note","slot","Frame","siteName","heading","lede","children","maxWidth","px","AiSiteImportJob","orgId","host","user","busy","notice","onResume","onStartAll","onJob","phase","siteImport","start","startAll","held","pagesHref","HOST_SCREENS","claim","setClaim","claimNotice","setClaimNotice","verifyAgain","answer","action","domain","message","cancel","startButton","disabled","onClick","quote","waves","ariaLabel","disableGutters","borderRadius","expandIcon","length","pl","slots","frame","status","startedAt","index","leftOut","leftOutCard","reduce","total","line","count","text","paths","slice","reason","mt","review","severity","pt","value","Math","round","spent","toLocaleString","turnedAway","ownership","error","onClaim","current","brought","items","op"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,gBAAgB,QAAQ,oDAAmD;AACpF,SAASC,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SACEC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,eAAe,EACfC,qBAAqB,EACrBC,YAAY,QACP,yBAAwB;AAC/B,SAASC,OAAO,EAAEC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AAEhE,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,SAASC,WAAW,EAAEC,QAAQ,QAAwB,QAAO;AAE7D,SAASC,sBAAsB,EAAEC,uBAAuB,QAA+B,6BAAyB;AAChH,SACEC,qBAAqB,EACrBC,oBAAoB,EACpBC,wBAAwB,EACxBC,mBAAmB,EAC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AAClD;wBAAsB0E,SAAQ;wBAAWhC,IAAI;4BAAE2F,cAAc;wBAAE;;0CAC9D,KAAChI;gCAAWqE,SAAQ;gCAAYhC,IAAI;oCAAEyD,IAAI;wCAAE3C,IAAI;wCAAGC,IAAI;oCAAE;oCAAGkG,IAAI;wCAAEnG,IAAI;wCAAGC,IAAI;oCAAE;gCAAE;0CAC9EP,KAAKnB,KAAK;;0CAEb,KAACiB;gCAASC,KAAKA;gCAAKC,MAAMA;gCAAMC,SAASA;;;uBAJhCD,KAAK2F,KAAK;gBAOtBE;;;IAGP;IAEA,qBACE,MAAClD;QAAMC,UAAUA;QAAUC,SAAS9C,IAAI0F,MAAM,KAAK,aAAa,iCAAiC;;0BAC/F,KAAC9I;gBAAM6J,UAAS;2BACbzG,aAAAA,IAAIkH,KAAK,YAATlH,aACEA,IAAI0F,MAAM,KAAK,aACZ,gHACA;;YAEPzB,0BACC,KAACpH;0BACC,cAAA,KAACC;oBAAO2E,SAAQ;oBAAWlC,WAAWjD;oBAAS4E,MAAM+C;8BAClD;;iBAGH;YAEHgB;;;AAGP;AAEA,eAAe9B,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-import-job.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 { PageHeaderRecord } from '@aglyn/aglyn/app-utils/page-header-record-context'\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport {\n mdiAlertCircle,\n mdiCheckCircle,\n mdiChevronDown,\n mdiClockOutline,\n mdiMinusCircleOutline,\n mdiOpenInNew,\n} from '@aglyn/shared-data-mdi'\nimport { AppLink, HelpTip, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport type { MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\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 { useCallback, useState, type ReactNode } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport { aiSiteImportReviewWave, aiSiteImportRunningWave, type AiSiteImportWave } from '../model/ai-site-import'\nimport {\n aiSiteImportFoundText,\n aiSiteImportHeldCopy,\n aiSiteImportLeftOutLines,\n aiSiteImportPhaseOf,\n aiSiteImportPlanText,\n aiSiteImportStartAction,\n aiSiteImportStartAllAction,\n aiSiteImportStoppedCopy,\n aiSiteImportVerdictNote,\n aiSiteImportWaveRows,\n aiSiteImportWaveSpent,\n type AiSiteImportClaim,\n type AiSiteImportRowState,\n} from '../model/ai-site-import-view'\nimport { AiJobCancelButton } from './ai-job-cancel.component'\nimport { aiCreditsBillingHref, aiJobOutputHref } from './ai-job-links'\nimport { AI_SITE_IMPORT_HELP } from './ai-site-import-start.component'\nimport { AiSiteOwnershipProof, postAiSiteOwnership } from './ai-site-ownership-proof.component'\n\nconst ROW_ICON: Readonly<Record<Exclude<AiSiteImportRowState, 'active'>, { path: string; color: string; label: string }>> = {\n done: { path: mdiCheckCircle.path, color: 'success.main', label: 'In' },\n waiting: { path: mdiClockOutline.path, color: 'text.disabled', label: 'Waiting' },\n failed: { path: mdiAlertCircle.path, color: 'error.main', label: 'Could not be brought in' },\n skipped: { path: mdiMinusCircleOutline.path, color: 'text.disabled', label: 'Left out' },\n}\n\nfunction RowIcon({ state }: { state: AiSiteImportRowState }) {\n if (state === 'active') return <CircularProgress size={20} aria-label=\"In progress\" />\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/** One wave's pages: where each was, where it is now, how it went, and its draft to open. */\nfunction WaveRows({ job, wave, orgSlug }: { job: AiJobSummary; wave: AiSiteImportWave; orgSlug: string }) {\n const rows = aiSiteImportWaveRows(job, wave)\n return (\n <Box component=\"ol\" aria-label={wave.label} sx={{ listStyle: 'none', m: 0, p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n {rows.map((row) => {\n const output = row.outputId ? job.outputs.find((entry) => entry.id === row.outputId) : undefined\n const href = output ? aiJobOutputHref(output, orgSlug) : null\n return (\n <Stack component=\"li\" key={row.slot} 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 variant=\"body1\" color={row.state === 'waiting' || row.state === 'skipped' ? 'text.secondary' : 'text.primary'}>\n {row.title}\n </Typography>\n {href && row.state === 'done' ? (\n <Button size=\"small\" component={AppLink} href={href}>\n {'Open draft'}\n </Button>\n ) : null}\n </Stack>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline', flexWrap: 'wrap' }}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ overflowWrap: 'anywhere' }}>\n {`${row.from} → ${row.to}`}\n </Typography>\n <Button\n size=\"small\"\n component=\"a\"\n href={row.oldPage}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n endIcon={<MdiIcon path={mdiOpenInNew.path} aria-hidden />}\n aria-label={`Old page: ${row.from}, opens in a new tab`}\n sx={{ minWidth: 0, py: 0 }}\n >\n {'Old page'}\n </Button>\n </Stack>\n {row.build || row.words ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {[row.build, row.words].filter(Boolean).join(' · ')}\n </Typography>\n ) : null}\n {row.photos ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.photos}\n </Typography>\n ) : null}\n {row.note && row.state !== 'done' ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.note}\n </Typography>\n ) : null}\n </Box>\n </Stack>\n )\n })}\n </Stack>\n </Box>\n )\n}\n\nfunction Frame({ siteName, heading, lede, children }: { siteName?: string; heading: string; lede?: string; children?: ReactNode }) {\n return (\n <Container maxWidth=\"sm\" sx={{ py: { xs: 3, sm: 5 }, px: { xs: 2, sm: 3 } }}>\n <PageHeaderRecord title={heading} />\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 interface AiSiteImportJobProps {\n job: AiJobSummary\n orgId: string | null\n orgSlug: string\n /** The site's subdomain, which its Pages list is addressed by. */\n host: string | null\n siteName?: string\n user: MaybeTokenSource\n busy: boolean\n notice: string | null\n /** Starts the next wave, or reads the site again: the resume door. */\n onResume: () => void\n /**\n * Starts every remaining wave with no review between them (AGL-4083). The\n * button is drawn only where the page can start them this way.\n */\n onStartAll?: () => void\n onJob: (job: AiJobSummary) => void\n}\n\n/**\n * \"Bring my site\" (AGL-3976), on the import job's own page: the site read\n * and its waves planned with each one's quote, a wave running page by page,\n * a wave in for its review with its drafts to open, and the next wave's\n * button — the only way the next one starts. A wave held for a new proof, the\n * day's limit or a site that could not be read says so and offers the way on.\n */\nexport function AiSiteImportJob({ job, orgId, orgSlug, host, siteName, user, busy, notice, onResume, onStartAll, onJob }: AiSiteImportJobProps) {\n const phase = aiSiteImportPhaseOf(job)\n const state = job.siteImport ?? null\n const start = aiSiteImportStartAction(job)\n const startAll = onStartAll ? aiSiteImportStartAllAction(job) : null\n const held = aiSiteImportHeldCopy(job)\n const pagesHref = host && orgSlug ? buildRoute(Route.HOST_SCREENS, { orgSlug, host }) : null\n const [claim, setClaim] = useState<AiSiteImportClaim | null>(null)\n const [claimNotice, setClaimNotice] = useState<string | null>(null)\n const verifyAgain = useCallback(async () => {\n if (!orgId || !state) return\n setClaimNotice(null)\n const answer = await postAiSiteOwnership(user, { orgId, action: 'claim', domain: state.domain })\n if (answer.claim) setClaim(answer.claim)\n else setClaimNotice(answer.message)\n }, [orgId, state, user])\n\n const cancel = (\n <Box>\n <AiJobCancelButton job={job} user={user} orgId={orgId} onJob={onJob} variant=\"text\" size=\"small\" />\n </Box>\n )\n const startButton = start ? (\n <Stack spacing={1}>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.5} sx={{ alignItems: { sm: 'center' } }}>\n <Box>\n <Button variant=\"contained\" size=\"large\" disabled={busy} onClick={onResume}>\n {busy ? 'Starting…' : start.label}\n </Button>\n </Box>\n {startAll && onStartAll ? (\n <Box>\n <Button variant=\"outlined\" size=\"large\" disabled={busy} onClick={onStartAll}>\n {startAll.label}\n </Button>\n </Box>\n ) : null}\n </Stack>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${start.quote}, from your AI credits. Its pages land in your site’s preview, or as drafts where the site is not in preview.`}\n </Typography>\n <HelpTip {...AI_SITE_IMPORT_HELP.waves} ariaLabel=\"How waves work\" />\n </Stack>\n {startAll && onStartAll ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${startAll.quote} for every remaining wave (${startAll.waves}), one after another with no review between them. You review the last one.`}\n </Typography>\n ) : null}\n </Stack>\n ) : null\n const waves = state ? (\n <Accordion variant=\"outlined\" disableGutters sx={{ borderRadius: 2, '&::before': { display: 'none' } }}>\n <AccordionSummary expandIcon={<MdiIcon path={mdiChevronDown.path} />}>\n <Typography variant=\"subtitle1\">{`Every wave (${state.waves.length})`}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Stack component=\"ol\" spacing={1} sx={{ m: 0, pl: 2.5 }}>\n {state.waves.map((wave) => (\n <Typography component=\"li\" variant=\"body2\" key={wave.index}>\n {`${wave.label}: ${wave.slots.length} ${wave.slots.length === 1 ? 'page' : 'pages'}${wave.frame ? ', with your header and footer' : ''}${\n wave.status === 'done' || wave.status === 'review'\n ? ' (in)'\n : wave.status === 'running'\n ? ' (running)'\n : wave.status === 'stopped'\n ? wave.startedAt\n ? ' (stopped)'\n : ' (not started)'\n : ''\n }`}\n </Typography>\n ))}\n </Stack>\n </AccordionDetails>\n </Accordion>\n ) : null\n const leftOut = state ? aiSiteImportLeftOutLines(state) : []\n const leftOutCard = leftOut.length ? (\n <Accordion variant=\"outlined\" disableGutters sx={{ borderRadius: 2, '&::before': { display: 'none' } }}>\n <AccordionSummary expandIcon={<MdiIcon path={mdiChevronDown.path} />}>\n <Typography variant=\"subtitle1\">{`Not brought in (${leftOut.reduce((total, line) => total + line.count, 0)})`}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Stack spacing={1.5}>\n {leftOut.map((line) => (\n <Box key={line.reason}>\n <Typography variant=\"body2\">{`${line.count} · ${line.text}`}</Typography>\n {line.paths.length ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ overflowWrap: 'anywhere' }}>\n {line.paths.slice(0, 8).join(', ')}\n {line.paths.length > 8 || line.count > line.paths.length ? ', …' : ''}\n </Typography>\n ) : null}\n {line.reason === 'plan-limit' && orgSlug ? (\n <Button size=\"small\" component={AppLink} href={aiCreditsBillingHref(orgSlug)} sx={{ mt: 0.5 }}>\n {'See plans'}\n </Button>\n ) : null}\n </Box>\n ))}\n </Stack>\n </AccordionDetails>\n </Accordion>\n ) : null\n\n if (phase === 'reading') {\n return (\n <Frame siteName={siteName} heading=\"Reading your site\" lede=\"AglynBot reads robots.txt first, then your sitemap and your pages. Nothing is built yet, and reading uses no AI credits.\">\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <LinearProgress aria-label=\"Reading your site\" />\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ p: { xs: 2, sm: 3 } }}>\n {'This takes a minute or two. You can leave this page; we tell you when your site is read.'}\n </Typography>\n </Card>\n {cancel}\n </Frame>\n )\n }\n\n if (phase === 'ready' && state) {\n return (\n <Frame siteName={siteName} heading={aiSiteImportStoppedCopy(job) ? 'Your import is waiting for you' : 'Your site is read'} lede={job.review?.message ?? undefined}>\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n {aiSiteImportVerdictNote(state) ? <Alert severity=\"warning\">{aiSiteImportVerdictNote(state)}</Alert> : null}\n <Stack spacing={1}>\n <Typography variant=\"body1\">{aiSiteImportFoundText(state)}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {aiSiteImportPlanText(state)}\n </Typography>\n </Stack>\n {start ? (\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <Typography variant=\"subtitle1\" sx={{ px: { xs: 2, sm: 3 }, pt: { xs: 2, sm: 3 } }}>\n {`First: ${start.wave.label}`}\n </Typography>\n <WaveRows job={job} wave={start.wave} orgSlug={orgSlug} />\n </Card>\n ) : null}\n {startButton}\n {waves}\n {leftOutCard}\n {cancel}\n </Frame>\n )\n }\n\n if ((phase === 'running' || phase === 'starting') && state) {\n const wave = aiSiteImportRunningWave(state) ?? start?.wave ?? null\n const rows = wave ? aiSiteImportWaveRows(job, wave) : []\n const done = rows.filter((row) => row.state !== 'waiting' && row.state !== 'active').length\n return (\n <Frame\n siteName={siteName}\n heading={wave ? `Bringing in ${wave.label}` : 'Bringing in your site'}\n lede=\"Each page is rewritten into your new site’s design with its own words, facts and photos. You review the wave when it is in.\"\n >\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n {rows.length ? (\n <LinearProgress variant=\"determinate\" value={Math.round((done / rows.length) * 100)} aria-label={`${done} of ${rows.length} in`} />\n ) : (\n <LinearProgress aria-label=\"Starting the wave\" />\n )}\n {wave ? <WaveRows job={job} wave={wave} orgSlug={orgSlug} /> : null}\n </Card>\n {waves}\n {cancel}\n </Frame>\n )\n }\n\n if (phase === 'review' && state) {\n const wave = aiSiteImportReviewWave(state) as AiSiteImportWave\n const spent = aiSiteImportWaveSpent(job, wave)\n // A site in preview has the wave's pages live for its team (AGL-4084); any other has them as drafts.\n const live = new Set((job.sitePublish?.published ?? []).map((page) => page.id))\n const inPreview = wave.slots.some((slot) => live.has(state.pages.find((page) => page.slot === slot)?.draftId ?? ''))\n return (\n <Frame\n siteName={siteName}\n heading={inPreview ? `${wave.label} is in your site’s preview` : `${wave.label} is in`}\n lede={\n inPreview\n ? 'Its pages are on your site, where only you and your team can see them. Open each page to review it.'\n : 'Open each page to review it. They are drafts: nothing is published until you publish it.'\n }\n >\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <WaveRows job={job} wave={wave} orgSlug={orgSlug} />\n </Card>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`This wave used ${spent.toLocaleString('en-US')} AI ${spent === 1 ? 'credit' : 'credits'}.`}\n </Typography>\n {pagesHref ? (\n <Box>\n <Button variant=\"outlined\" component={AppLink} href={pagesHref}>\n {inPreview ? 'Open your pages' : 'Open your draft pages'}\n </Button>\n </Box>\n ) : null}\n {start ? (\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <Typography variant=\"subtitle1\" sx={{ px: { xs: 2, sm: 3 }, pt: { xs: 2, sm: 3 } }}>\n {`Next: ${start.wave.label}`}\n </Typography>\n <WaveRows job={job} wave={start.wave} orgSlug={orgSlug} />\n </Card>\n ) : null}\n {startButton}\n {waves}\n {leftOutCard}\n {cancel}\n </Frame>\n )\n }\n\n // The home page was turned away or could not be read (AGL-4083): nothing was\n // planned or spent, and Check again reads the site again, for free.\n if (phase === 'held' && held) {\n return (\n <Frame siteName={siteName} heading={held.heading}>\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Alert severity=\"warning\">{held.message}</Alert>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Button variant=\"contained\" disabled={busy} onClick={onResume}>\n {busy ? 'Checking…' : held.action}\n </Button>\n <HelpTip {...AI_SITE_IMPORT_HELP.turnedAway} ariaLabel=\"How to let AglynBot in\" />\n </Stack>\n {leftOutCard}\n {cancel}\n </Frame>\n )\n }\n\n if (phase === 'held' || phase === 'paused') {\n const ownership = job.review?.reason === 'ownership'\n return (\n <Frame siteName={siteName} heading={ownership ? 'Verify your site again' : phase === 'paused' ? 'Your site import is paused' : 'Your site import is waiting'}>\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Alert severity=\"info\">{job.review?.message ?? job.error ?? 'It stopped for your decision.'}</Alert>\n {ownership && orgId ? (\n claim ? (\n <AiSiteOwnershipProof orgId={orgId} user={user} claim={claim} onClaim={setClaim} />\n ) : (\n <Box>\n <Button variant=\"outlined\" onClick={() => void verifyAgain()}>\n {'Verify again'}\n </Button>\n {claimNotice ? <Alert severity=\"warning\" sx={{ mt: 1 }}>{claimNotice}</Alert> : null}\n </Box>\n )\n ) : null}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'center' } }}>\n <Button variant=\"contained\" disabled={busy || (ownership && !claim?.current)} onClick={onResume}>\n {busy ? 'Starting…' : phase === 'paused' ? 'Resume' : start ? `${start.label} again` : 'Read the site again'}\n </Button>\n {phase === 'paused' && orgSlug ? (\n <Button variant=\"outlined\" component={AppLink} href={aiCreditsBillingHref(orgSlug)}>\n {'Get more AI credits'}\n </Button>\n ) : null}\n </Stack>\n {waves}\n {cancel}\n </Frame>\n )\n }\n\n if (phase === 'done' && state) {\n const brought = (job.items ?? []).filter((row) => row.op === 'page' && (row.status === 'succeeded' || row.status === 'degraded')).length\n return (\n <Frame\n siteName={siteName}\n heading=\"Your site is in\"\n lede={`${brought} ${brought === 1 ? 'page was' : 'pages were'} brought in from ${state.domain}. They are drafts: review them, then publish them when you are ready.`}\n >\n {pagesHref ? (\n <Box>\n <Button variant=\"contained\" size=\"large\" component={AppLink} href={pagesHref}>\n {'Open your draft pages'}\n </Button>\n </Box>\n ) : null}\n {state.waves.map((wave) => (\n <Card key={wave.index} variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <Typography variant=\"subtitle1\" sx={{ px: { xs: 2, sm: 3 }, pt: { xs: 2, sm: 3 } }}>\n {wave.label}\n </Typography>\n <WaveRows job={job} wave={wave} orgSlug={orgSlug} />\n </Card>\n ))}\n {leftOutCard}\n </Frame>\n )\n }\n\n return (\n <Frame siteName={siteName} heading={job.status === 'canceled' ? 'Your site import was stopped' : 'Your site import stopped'}>\n <Alert severity=\"info\">\n {job.error ??\n (job.status === 'canceled'\n ? 'Nothing more is brought in. The pages already in stay where they are: in your site’s preview, or as drafts.'\n : 'It could not go on. The pages already in stay where they are: in your site’s preview, or as drafts.')}\n </Alert>\n {pagesHref ? (\n <Box>\n <Button variant=\"outlined\" component={AppLink} href={pagesHref}>\n {'Open your draft pages'}\n </Button>\n </Box>\n ) : null}\n {/* Which waves came in and which stopped (AGL-4107). */}\n {waves}\n </Frame>\n )\n}\n\nexport default AiSiteImportJob\n"],"names":["PageHeaderRecord","buildRoute","Route","mdiAlertCircle","mdiCheckCircle","mdiChevronDown","mdiClockOutline","mdiMinusCircleOutline","mdiOpenInNew","AppLink","HelpTip","MdiIcon","Accordion","AccordionDetails","AccordionSummary","Alert","Box","Button","Card","CircularProgress","Container","LinearProgress","Stack","Typography","useCallback","useState","aiSiteImportReviewWave","aiSiteImportRunningWave","aiSiteImportFoundText","aiSiteImportHeldCopy","aiSiteImportLeftOutLines","aiSiteImportPhaseOf","aiSiteImportPlanText","aiSiteImportStartAction","aiSiteImportStartAllAction","aiSiteImportStoppedCopy","aiSiteImportVerdictNote","aiSiteImportWaveRows","aiSiteImportWaveSpent","AiJobCancelButton","aiCreditsBillingHref","aiJobOutputHref","AI_SITE_IMPORT_HELP","AiSiteOwnershipProof","postAiSiteOwnership","ROW_ICON","done","path","color","label","waiting","failed","skipped","RowIcon","state","size","aria-label","icon","component","role","sx","display","fontSize","theme","spacing","aria-hidden","WaveRows","job","wave","orgSlug","rows","listStyle","m","p","xs","sm","map","row","output","outputId","outputs","find","entry","id","undefined","href","direction","alignItems","width","justifyContent","flex","minWidth","variant","title","flexWrap","overflowWrap","from","to","oldPage","target","rel","endIcon","py","build","words","filter","Boolean","join","photos","note","slot","Frame","siteName","heading","lede","children","maxWidth","px","AiSiteImportJob","orgId","host","user","busy","notice","onResume","onStartAll","onJob","phase","siteImport","start","startAll","held","pagesHref","HOST_SCREENS","claim","setClaim","claimNotice","setClaimNotice","verifyAgain","answer","action","domain","message","cancel","startButton","disabled","onClick","quote","waves","ariaLabel","disableGutters","borderRadius","expandIcon","length","pl","slots","frame","status","startedAt","index","leftOut","leftOutCard","reduce","total","line","count","text","paths","slice","reason","mt","review","severity","pt","value","Math","round","spent","live","Set","sitePublish","published","page","inPreview","some","has","pages","draftId","toLocaleString","turnedAway","ownership","error","onClaim","current","brought","items","op"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,gBAAgB,QAAQ,oDAAmD;AACpF,SAASC,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SACEC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,eAAe,EACfC,qBAAqB,EACrBC,YAAY,QACP,yBAAwB;AAC/B,SAASC,OAAO,EAAEC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AAEhE,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,SAASC,WAAW,EAAEC,Q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;oBAAWlC,WAAWjD;oBAAS4E,MAAM+C;8BAClD;;iBAGH;YAEHgB;;;AAGP;AAEA,eAAe9B,gBAAe"}
@@ -3,10 +3,10 @@ import { type ReactNode } from 'react';
3
3
  import { AI_UPSELL_COPY, AI_UPSELL_CREATE_LABEL, aiUpsellLabel, aiUpsellOffer, type AiUpsellKind } from '../model/ai-upsell-copy';
4
4
  /**
5
5
  * "Create with AI" where generation is switched off for a workspace that
6
- * could buy an Aglyn AI tier (AGL-3601, AGL-3965). Since AGL-3965 every paid
6
+ * could buy Aglyn AI credits (AGL-3601, AGL-4144). Since AGL-3965 every paid
7
7
  * plan's own credits pay for generation, so this is reached only where a
8
8
  * per-org setting closed it. The shell mounts the entry with
9
- * `entitled={false}` only where a tier is sold to this workspace, and the
9
+ * `entitled={false}` only where credit blocks are sold to this workspace, and the
10
10
  * jobs route has said that is the one thing missing; the entry then keeps its
11
11
  * place on the page and opens this instead of the brief.
12
12
  */